STEPConstruct_AP203Context = pw_gecos member of passwd struct disabled in android case.
Standard_Atomic - correct usage of __atomic_inc()/__atomic_dec().
Standard_CLocaleSentry - Android doesn't support locales in the C library.
Standard_MMgrOpt - use "/dev/zero" and "/dev/null" for allocation of memory blocks on Android.
OSD_Chronometer - fix compilation on Android.
OSD_Disk, OSD_signal - fix headers inclusion on Android.
//=======================================================================
void OSD_Chronometer::GetProcessCPU (Standard_Real& UserSeconds, Standard_Real& SystemSeconds)
{
-#if defined(LIN) || defined(linux) || defined(__FreeBSD__)
+#if defined(LIN) || defined(linux) || defined(__FreeBSD__) || defined(__ANDROID__)
static const long aCLK_TCK = sysconf(_SC_CLK_TCK);
#else
static const long aCLK_TCK = CLK_TCK;
theUserSeconds = Standard_Real(aTaskInfo.user_time.seconds) + 0.000001 * aTaskInfo.user_time.microseconds;
theSystemSeconds = Standard_Real(aTaskInfo.system_time.seconds) + 0.000001 * aTaskInfo.system_time.microseconds;
}
-#elif defined(_POSIX_TIMERS) && defined(_POSIX_THREAD_CPUTIME)
+#elif (defined(_POSIX_TIMERS) && defined(_POSIX_THREAD_CPUTIME)) || defined(__ANDROID__)
// on Linux, only user times are available for threads via clock_gettime()
struct timespec t;
if (!clock_gettime (CLOCK_THREAD_CPUTIME_ID, &t))
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#ifndef WNT
+#ifndef _WIN32
#include <OSD_Disk.ixx>
#include <OSD_WhoAmI.hxx>
extern "C" {
#endif
-#include <sys/statvfs.h>
+#if defined(__ANDROID__)
+ #include <sys/vfs.h>
+ #define statvfs statfs
+ #define fstatvfs fstatfs
+#else
+ #include <sys/statvfs.h>
+ int statvfs(const char *, struct statvfs *);
+#endif
#ifdef __cplusplus
}
-#endif
+#endif
#include <errno.h>
-extern "C" {int statvfs(const char *, struct statvfs *); }
-
OSD_Disk::OSD_Disk() : myQuotaSize(0) {}
#include <OSD.ixx>
-#ifndef WNT
+#ifndef _WIN32
//---------- All Systems except Windows NT : ----------------------------------
typedef void (* SIG_PFV) (int);
#include <signal.h>
-#include <sys/signal.h>
-#if defined(HAVE_PTHREAD_H) && defined(NO_CXX_EXCEPTION)
+#if !defined(__ANDROID__)
+ #include <sys/signal.h>
+#endif
+
+#if defined(HAVE_PTHREAD_H) && defined(NO_CXX_EXCEPTION)
//============================================================================
//==== GetOldSigAction
//==== get previous
// construct person`s name
OSD_Process sys;
Standard_CString usr = sys.UserName().ToCString();
-#ifndef WNT
+#if !defined(_WIN32) && !defined(__ANDROID__)
if ( usr ) {
struct passwd *pwd = getpwnam ( usr );
if ( pwd ) usr = pwd->pw_gecos;
#ifndef _Standard_Atomic_HeaderFile
#define _Standard_Atomic_HeaderFile
-#if defined(__ANDROID__)
- #include <sys/atomics.h>
-#endif
-
//! Increments atomically integer variable pointed by theValue
//! and returns resulting incremented value.
inline int Standard_Atomic_Increment (volatile int* theValue);
return __sync_sub_and_fetch (theValue, 1);
}
-#elif defined(_WIN32) || defined(__WIN32__)
+#elif defined(_WIN32)
extern "C" {
long _InterlockedIncrement (volatile long* lpAddend);
long _InterlockedDecrement (volatile long* lpAddend);
}
#elif defined(__ANDROID__)
+
// Atomic operations that were exported by the C library didn't
// provide any memory barriers, which created potential issues on
// multi-core devices. Starting from ndk version r7b they are defined as
// inlined calls to GCC sync builtins, which always provide a full barrier.
// It is strongly recommended to use newer versions of ndk.
+#include <sys/atomics.h>
int Standard_Atomic_Increment (volatile int* theValue)
{
- return __atomic_inc (theValue);
+ return __atomic_inc (theValue) + 1; // analog of __sync_fetch_and_add
}
int Standard_Atomic_Decrement (volatile int* theValue)
{
- return __atomic_dec (theValue);
+ return __atomic_dec (theValue) - 1; // analog of __sync_fetch_and_sub
}
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64))
#include <cstring>
+#if !defined(__ANDROID__)
+
namespace
{
#endif
#endif
{
-#ifndef HAVE_XLOCALE_H
+#if !defined(HAVE_XLOCALE_H)
const char* aPrevLocale = (const char* )myPrevLocale;
- if (aPrevLocale[0] == 'C' && aPrevLocale[1] == '\0')
+ if (myPrevLocale == NULL
+ || (aPrevLocale[0] == 'C' && aPrevLocale[1] == '\0'))
{
myPrevLocale = NULL; // already C locale
return;
// =======================================================================
Standard_CLocaleSentry::~Standard_CLocaleSentry()
{
-#ifdef HAVE_XLOCALE_H
+#if defined(HAVE_XLOCALE_H)
uselocale ((locale_t )myPrevLocale);
#else
if (myPrevLocale != NULL)
#endif
#endif
}
+
+#endif // __ANDROID__
#include <xlocale.h>
#endif
+#if !defined(__ANDROID__)
+
//! This class intended to temporary switch C locale and logically equivalent to setlocale(LC_ALL, "C").
//! It is intended to format text regardless of user locale settings (for import/export functionality).
//! Thus following calls to sprintf, atoi and other functions will use "C" locale.
Standard_EXPORT Standard_CLocaleSentry();
//! Restore previous locale.
- Standard_EXPORT virtual ~Standard_CLocaleSentry();
+ Standard_EXPORT ~Standard_CLocaleSentry();
public:
};
+#else
+
+//! C/C++ runtime on Android currently supports only C-locale, no need to call anything.
+class Standard_CLocaleSentry
+{
+public:
+ Standard_CLocaleSentry() {}
+ typedef void* clocale_t;
+ static clocale_t GetCLocale() { return 0; }
+};
+
+#endif // __ANDROID__
+
#endif // _Standard_CLocaleSentry_H__
perror("ERR_MEMRY_FAIL");
#endif
-#if defined(IRIX) || defined(__sgi) || defined(SOLARIS) || defined(__sun) || defined(LIN) || defined(linux) || defined(__FreeBSD__)
+#if defined(IRIX) || defined(__sgi) || defined(SOLARIS) || defined(__sun) || defined(LIN) || defined(linux) || defined(__FreeBSD__) || defined(__ANDROID__)
if ((myMMap = open ("/dev/zero", O_RDWR)) < 0) {
if ((myMMap = open ("/dev/null", O_RDWR)) < 0){
myMMap = 0;