1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0024444: Compilation issues on some not fully POSIX compliant Unix systems

- Standard package.
- OSD package.
- Aspect package.
- Xw package.
This commit is contained in:
apl
2014-08-14 13:42:50 +04:00
committed by abv
parent 72b11796c5
commit 0304f71151
11 changed files with 62 additions and 26 deletions

View File

@@ -28,7 +28,7 @@
#include <locale.h>
#endif
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__ANDROID__)
#include <malloc.h>
#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 1)
#include <mm_malloc.h>
@@ -231,8 +231,10 @@ Standard_Address Standard::AllocateAligned (const Standard_Size theSize,
{
#if defined(_MSC_VER)
return _aligned_malloc (theSize, theAlign);
#elif defined(__ANDROID__)
return memalign (theAlign, theSize);
#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 1)
return _mm_malloc (theSize, theAlign);
return _mm_malloc (theSize, theAlign);
#else
void* aPtr;
if (posix_memalign (&aPtr, theAlign, theSize))
@@ -252,6 +254,8 @@ void Standard::FreeAligned (Standard_Address thePtrAligned)
{
#if defined(_MSC_VER)
_aligned_free (thePtrAligned);
#elif defined(__ANDROID__)
free (thePtrAligned);
#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 1)
_mm_free (thePtrAligned);
#else

View File

@@ -27,6 +27,10 @@
#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);
@@ -95,6 +99,23 @@ int Standard_Atomic_Decrement (volatile int* theValue)
return OSAtomicDecrement32Barrier (theValue);
}
#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.
int Standard_Atomic_Increment (volatile int* theValue)
{
return __atomic_inc (theValue);
}
int Standard_Atomic_Decrement (volatile int* theValue)
{
return __atomic_dec (theValue);
}
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64))
// use x86 / x86_64 inline assembly (compatibility with alien compilers / old GCC)

View File

@@ -20,16 +20,23 @@
#include <locale.h>
//! "xlocale.h" available in Mac OS X and glibc (Linux) for a long time as an extension
//! and become part of POSIX since '2008.
//! Notice that this is impossible to test (_POSIX_C_SOURCE >= 200809L)
//! since POSIX didn't declared such identifier.
//! We check _GNU_SOURCE for glibc extensions here and it is always defined by g++ compiler.
#if defined(__APPLE__) || defined(_GNU_SOURCE) || defined(HAVE_XLOCALE_H)
#include <xlocale.h>
#ifndef HAVE_XLOCALE_H
#ifndef HAVE_XLOCALE_H
//! "xlocale.h" available in Mac OS X and glibc (Linux) for a long time as an extension
//! and become part of POSIX since '2008.
//! Notice that this is impossible to test (_POSIX_C_SOURCE >= 200809L)
//! since POSIX didn't declared such identifier.
#if defined(__APPLE__)
#define HAVE_XLOCALE_H
#endif
//! We check _GNU_SOURCE for glibc extensions here and it is always defined by g++ compiler.
#if defined(_GNU_SOURCE) && !defined(__ANDROID__)
#define HAVE_XLOCALE_H
#endif
#endif // ifndef HAVE_LOCALE_H
#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
#endif
//! This class intended to temporary switch C locale and logically equivalent to setlocale(LC_ALL, "C").

View File

@@ -77,7 +77,12 @@ Standard_Integer HashCodes (const Standard_CString Value,
// So we switch to C locale temporarily
#define SAVE_TL() Standard_CLocaleSentry aLocaleSentry;
#ifndef HAVE_XLOCALE_H
#error System does not support xlocale. Import/export could be broken if C locale did not specified by application.
// glibc version for android platform use locale-independent implementation of
// strtod, strtol, strtoll functions. For other system with locale-depended
// implementations problems may appear if "C" locale is not set explicitly.
#ifndef __ANDROID__
#error System does not support xlocale. Import/export could be broken if C locale did not specified by application.
#endif
#define strtod_l(thePtr, theNextPtr, theLocale) strtod(thePtr, theNextPtr)
#endif
#define vprintf_l(theLocale, theFormat, theArgPtr) vprintf(theFormat, theArgPtr)