mirror of
https://github.com/mcneel/opennurbs.git
synced 2026-03-20 09:29:26 +08:00
temp fix for rhino3dm linux build. Next 8.x merge should make this unnecessary
This commit is contained in:
246
opennurbs_lock.h
246
opennurbs_lock.h
@@ -1,123 +1,123 @@
|
||||
//
|
||||
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
|
||||
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
|
||||
// McNeel & Associates.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
|
||||
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
|
||||
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
|
||||
//
|
||||
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(OPENNURBS_LOCK_INC_)
|
||||
#define OPENNURBS_LOCK_INC_
|
||||
|
||||
/*
|
||||
Description:
|
||||
ON_Lock is a thread safe lock semephore. It is implemented using
|
||||
platform specfic compare and set functions.
|
||||
*/
|
||||
class ON_CLASS ON_Lock
|
||||
{
|
||||
public:
|
||||
#if defined(ON_COMPILER_CLANG)
|
||||
ON_Lock() ON_NOEXCEPT;
|
||||
#else
|
||||
ON_Lock() = default;
|
||||
#endif
|
||||
~ON_Lock() = default;
|
||||
|
||||
// Copy constructor and operator= are implicitly deleted because
|
||||
// __atomic_base<int, false> has a deleted copy constructor
|
||||
// ON_Lock(const ON_Lock&) = default;
|
||||
// ON_Lock& operator=(const ON_Lock&) = default;
|
||||
|
||||
// ON_Lock::InvalidLockValue (= -1) may never be used as a lock value.
|
||||
enum : int
|
||||
{
|
||||
UnlockedValue = 0,
|
||||
DefaultLockedValue = 1,
|
||||
InvalidLockValue = -1
|
||||
};
|
||||
|
||||
/*
|
||||
Returns:
|
||||
Current lock value
|
||||
ON_Lock::UnlockedValue indicates the the resource protected by the lock is available.
|
||||
*/
|
||||
int IsLocked();
|
||||
|
||||
/*
|
||||
Description:
|
||||
Calls GetLock(ON_Lock::DefaultLockedValue);
|
||||
Returns:
|
||||
True if the lock state was unlocked
|
||||
and the current lock value was changed from ON_Lock::UnlockedValue to ON_Lock::DefaultLockedValue.
|
||||
False otherwise.
|
||||
*/
|
||||
bool GetDefaultLock();
|
||||
|
||||
/*
|
||||
Description:
|
||||
Calls ReturnLock(ON_Lock::DefaultLockedValue);
|
||||
Returns:
|
||||
True if the lock state was locked with a locak value = ON_Lock::DefaultLockedValue
|
||||
and the current lock value was changed from ON_Lock::DefaultLockedValue to ON_Lock::UnlockedValue.
|
||||
False otherwise.
|
||||
*/
|
||||
bool ReturnDefaultLock();
|
||||
|
||||
/*
|
||||
Parameters:
|
||||
lock_value - [in]
|
||||
any value except ON_Lock::UnlockedValue or ON_Lock::InvalidLockValue.
|
||||
Typically ON_Lock::DefaultLockedValue is used.
|
||||
Returns:
|
||||
True if the lock_value parameter was valid and the current
|
||||
lock value was changed from ON_Lock::UnlockedValue to lock_value.
|
||||
False otherwise.
|
||||
*/
|
||||
bool GetLock(int lock_value);
|
||||
|
||||
/*
|
||||
Parameters:
|
||||
lock_value - [in]
|
||||
any value except ON_Lock::UnlockedValue or ON_Lock::InvalidLockValue.
|
||||
Typically this is the value that was passed to GetLock().
|
||||
Returns:
|
||||
True if the lock_value parameter was valid and the current
|
||||
lock value was changed from that value to zero.
|
||||
False otherwise.
|
||||
*/
|
||||
bool ReturnLock(int lock_value);
|
||||
|
||||
/*
|
||||
Description:
|
||||
Unconditionally sets the lock value to ON_Lock::UnlockedValue.
|
||||
Returns:
|
||||
previous value of the lock.
|
||||
ON_Lock::UnlockedValue indicates the lock was available
|
||||
otherwise the lock passed to GetLock() is returned
|
||||
*/
|
||||
int BreakLock();
|
||||
|
||||
private:
|
||||
// It is important that sizeof(ON_Lock) = sizeof(int)
|
||||
// and that m_lock_value be an int.
|
||||
#pragma ON_PRAGMA_WARNING_PUSH
|
||||
#pragma ON_PRAGMA_WARNING_DISABLE_MSC( 4251 )
|
||||
// C4251: 'ON_Lock::m_lock_value': struct 'std::atomic<int>'
|
||||
// needs to have dll-interface to be used by clients of class 'ON_Lock'
|
||||
// m_lock_value is private and all code that manages m_lock_value is explicitly implemented in the DLL.
|
||||
private:
|
||||
#if defined(ON_COMPILER_CLANG)
|
||||
std::atomic<int> m_lock_value;
|
||||
#else
|
||||
std::atomic<int> m_lock_value = ON_Lock::UnlockedValue;
|
||||
#endif
|
||||
#pragma ON_PRAGMA_WARNING_POP
|
||||
};
|
||||
|
||||
#endif
|
||||
//
|
||||
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
|
||||
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
|
||||
// McNeel & Associates.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
|
||||
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
|
||||
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
|
||||
//
|
||||
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(OPENNURBS_LOCK_INC_)
|
||||
#define OPENNURBS_LOCK_INC_
|
||||
|
||||
/*
|
||||
Description:
|
||||
ON_Lock is a thread safe lock semephore. It is implemented using
|
||||
platform specfic compare and set functions.
|
||||
*/
|
||||
class ON_CLASS ON_Lock
|
||||
{
|
||||
public:
|
||||
#if defined(ON_COMPILER_CLANG)
|
||||
ON_Lock() ON_NOEXCEPT;
|
||||
#else
|
||||
ON_Lock() = default;
|
||||
#endif
|
||||
~ON_Lock() = default;
|
||||
|
||||
// Copy constructor and operator= are implicitly deleted because
|
||||
// __atomic_base<int, false> has a deleted copy constructor
|
||||
// ON_Lock(const ON_Lock&) = default;
|
||||
// ON_Lock& operator=(const ON_Lock&) = default;
|
||||
|
||||
// ON_Lock::InvalidLockValue (= -1) may never be used as a lock value.
|
||||
enum : int
|
||||
{
|
||||
UnlockedValue = 0,
|
||||
DefaultLockedValue = 1,
|
||||
InvalidLockValue = -1
|
||||
};
|
||||
|
||||
/*
|
||||
Returns:
|
||||
Current lock value
|
||||
ON_Lock::UnlockedValue indicates the the resource protected by the lock is available.
|
||||
*/
|
||||
int IsLocked();
|
||||
|
||||
/*
|
||||
Description:
|
||||
Calls GetLock(ON_Lock::DefaultLockedValue);
|
||||
Returns:
|
||||
True if the lock state was unlocked
|
||||
and the current lock value was changed from ON_Lock::UnlockedValue to ON_Lock::DefaultLockedValue.
|
||||
False otherwise.
|
||||
*/
|
||||
bool GetDefaultLock();
|
||||
|
||||
/*
|
||||
Description:
|
||||
Calls ReturnLock(ON_Lock::DefaultLockedValue);
|
||||
Returns:
|
||||
True if the lock state was locked with a locak value = ON_Lock::DefaultLockedValue
|
||||
and the current lock value was changed from ON_Lock::DefaultLockedValue to ON_Lock::UnlockedValue.
|
||||
False otherwise.
|
||||
*/
|
||||
bool ReturnDefaultLock();
|
||||
|
||||
/*
|
||||
Parameters:
|
||||
lock_value - [in]
|
||||
any value except ON_Lock::UnlockedValue or ON_Lock::InvalidLockValue.
|
||||
Typically ON_Lock::DefaultLockedValue is used.
|
||||
Returns:
|
||||
True if the lock_value parameter was valid and the current
|
||||
lock value was changed from ON_Lock::UnlockedValue to lock_value.
|
||||
False otherwise.
|
||||
*/
|
||||
bool GetLock(int lock_value);
|
||||
|
||||
/*
|
||||
Parameters:
|
||||
lock_value - [in]
|
||||
any value except ON_Lock::UnlockedValue or ON_Lock::InvalidLockValue.
|
||||
Typically this is the value that was passed to GetLock().
|
||||
Returns:
|
||||
True if the lock_value parameter was valid and the current
|
||||
lock value was changed from that value to zero.
|
||||
False otherwise.
|
||||
*/
|
||||
bool ReturnLock(int lock_value);
|
||||
|
||||
/*
|
||||
Description:
|
||||
Unconditionally sets the lock value to ON_Lock::UnlockedValue.
|
||||
Returns:
|
||||
previous value of the lock.
|
||||
ON_Lock::UnlockedValue indicates the lock was available
|
||||
otherwise the lock passed to GetLock() is returned
|
||||
*/
|
||||
int BreakLock();
|
||||
|
||||
private:
|
||||
// It is important that sizeof(ON_Lock) = sizeof(int)
|
||||
// and that m_lock_value be an int.
|
||||
#pragma ON_PRAGMA_WARNING_PUSH
|
||||
#pragma ON_PRAGMA_WARNING_DISABLE_MSC( 4251 )
|
||||
// C4251: 'ON_Lock::m_lock_value': struct 'std::atomic<int>'
|
||||
// needs to have dll-interface to be used by clients of class 'ON_Lock'
|
||||
// m_lock_value is private and all code that manages m_lock_value is explicitly implemented in the DLL.
|
||||
private:
|
||||
#if defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX)
|
||||
std::atomic<int> m_lock_value;
|
||||
#else
|
||||
std::atomic<int> m_lock_value = ON_Lock::UnlockedValue;
|
||||
#endif
|
||||
#pragma ON_PRAGMA_WARNING_POP
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,207 +1,208 @@
|
||||
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
|
||||
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
|
||||
// McNeel & Associates.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
|
||||
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
|
||||
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
|
||||
//
|
||||
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(OPENNURBS_SYSTEM_RUNTIME_INC_)
|
||||
#define OPENNURBS_SYSTEM_RUNTIME_INC_
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Determines the runtime environment where the code is executed.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BEGIN - ON_RUNTIME_APPLE / ON_RUNTIME_WIN / ON_RUNTIME_ANDROID defines
|
||||
//
|
||||
// ON_RUNTIME_* specifies the runtime C/C++ SDK being used
|
||||
// At most one the ON_RUNTIME_* should be defined
|
||||
//
|
||||
// ON_RUNTIME_APPLE / ON_RUNTIME_WIN / ON_RUNTIME_ANDROID
|
||||
//
|
||||
*/
|
||||
#if (defined(__APPLE__) || defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) || defined(__IOS__))
|
||||
|
||||
#if !defined(ON_RUNTIME_APPLE)
|
||||
#define ON_RUNTIME_APPLE
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || defined(WINDOWS) || defined(_WINDOWS_) || defined(__WINDOWS__)
|
||||
|
||||
#if !defined(ON_RUNTIME_WIN)
|
||||
#define ON_RUNTIME_WIN
|
||||
#endif
|
||||
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
// __EMSCRIPTEN__ is for a web assembly compile which currently compiles with the
|
||||
// same settings as an android build. We will need to add an ON_RUNTIME_WASM once
|
||||
// the __EMSCRIPTEN__ compile stabilizes
|
||||
#if !defined(ON_RUNTIME_ANDROID)
|
||||
#define ON_RUNTIME_ANDROID
|
||||
#endif
|
||||
|
||||
#elif defined(__linux__)
|
||||
#if !defined(ON_RUNTIME_LINUX)
|
||||
#define ON_RUNTIME_LINUX
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
//
|
||||
// END - ON_RUNTIME_APPLE / ON_RUNTIME_WIN / ON_RUNTIME_ANDROID defines
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BEGIN - Additional platform defines
|
||||
//
|
||||
// ON_64BIT_RUNTIME / ON_32BIT_RUNTIME
|
||||
// ON_LITTLE_ENDIAN / ON_BIG_ENDIAN
|
||||
// ON_SIZEOF_WCHAR_T
|
||||
// ON_RUNTIME_<PLATFORM>_<SUBPLATFORM>
|
||||
//
|
||||
*/
|
||||
#if defined(ON_RUNTIME_APPLE)
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#if (TARGET_OS_IPHONE == 1)
|
||||
#define ON_RUNTIME_APPLE_IOS
|
||||
#endif
|
||||
|
||||
#if (TARGET_OS_SIMULATOR == 1)
|
||||
#define ON_RUNTIME_APPLE_IOS
|
||||
#define ON_RUNTIME_APPLE_IOS_SIMULATOR
|
||||
#endif
|
||||
|
||||
#if !defined(ON_RUNTIME_APPLE_IOS)
|
||||
#define ON_RUNTIME_APPLE_MACOS
|
||||
|
||||
#if !defined(RHINO_CORE_COMPONENT)
|
||||
// Apple:
|
||||
// Defines RHINO_CORE_COMPONENT here.
|
||||
// If we publish an Apple C++ pubic SDK, this will need to be adjusted.
|
||||
// Windows:
|
||||
// uses the property sheet RhinoProjectPropertySheets/Rhino.Cpp.common.props
|
||||
// Some build products in Windows are not "core components"
|
||||
#define RHINO_CORE_COMPONENT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(__LP64__) || defined(__ppc64__))
|
||||
#define ON_64BIT_RUNTIME
|
||||
#elif defined(__LP32__)
|
||||
#define ON_32BIT_RUNTIME
|
||||
#else
|
||||
#error Add code to detect sizeof pointer on this Apple platform
|
||||
#endif
|
||||
|
||||
#define ON_SIZEOF_WCHAR_T 4
|
||||
|
||||
#if (defined(__ppc__) || defined(__ppc64__))
|
||||
#define ON_BIG_ENDIAN
|
||||
#else
|
||||
#define ON_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#elif defined(ON_RUNTIME_WIN)
|
||||
|
||||
#define ON_SIZEOF_WCHAR_T 2
|
||||
|
||||
#if defined(WINDOWS_PHONE)
|
||||
#define ON_RUNTIME_WIN_MOBILE
|
||||
#else
|
||||
#define ON_RUNTIME_WIN_WINOS
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64) || defined(_WIN64)
|
||||
#define ON_64BIT_RUNTIME
|
||||
#elif defined(_M_X86) || defined(_WIN32)
|
||||
#define ON_32BIT_RUNTIME
|
||||
#else
|
||||
#error Add code to detect sizeof pointer on this Windows platform
|
||||
#endif
|
||||
|
||||
#if !defined(ON_LITTLE_ENDIAN)
|
||||
#if (defined(_M_X64) || defined(_M_IX86) || defined (__i386__) || defined( __x86_64__ ))
|
||||
#define ON_LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(ON_RUNTIME_ANDROID)
|
||||
|
||||
#if !defined(ON_SIZEOF_WCHAR_T)
|
||||
#define ON_SIZEOF_WCHAR_T 4
|
||||
#endif
|
||||
|
||||
#elif defined(ON_RUNTIME_LINUX)
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#define ON_64BIT_RUNTIME
|
||||
#else
|
||||
#define ON_32BIT_RUNTIME
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(ON_SIZEOF_WCHAR_T)
|
||||
#define ON_SIZEOF_WCHAR_T 4
|
||||
#endif
|
||||
|
||||
#if !defined(ON_LITTLE_ENDIAN)
|
||||
#if defined( __x86_64__ )
|
||||
#define ON_LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(ON_64BIT_RUNTIME) && !defined(ON_32BIT_RUNTIME)
|
||||
/* Attempt to determing runtime pointer size */
|
||||
#if (defined(_M_X64) || defined(__LP64__) || defined(__ppc64__))
|
||||
#define ON_64BIT_RUNTIME
|
||||
#elif (defined(_M_X86) || defined(__LP32__))
|
||||
#define ON_32BIT_RUNTIME
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ON_64BIT_RUNTIME) && defined(ON_32BIT_RUNTIME)
|
||||
#error Exactly one of ON_64BIT_RUNTIME or ON_32BIT_RUNTIME must be defined.
|
||||
#endif
|
||||
|
||||
#if !defined(ON_64BIT_RUNTIME) && !defined(ON_32BIT_RUNTIME)
|
||||
#error Exactly one of ON_64BIT_RUNTIME or ON_32BIT_RUNTIME must be defined.
|
||||
#endif
|
||||
|
||||
#if defined(ON_BIG_ENDIAN) && defined(ON_LITTLE_ENDIAN)
|
||||
#error Exactly one of ON_LITTLE_ENDIAN or ON_BIG_ENDIAN should be defined.
|
||||
#endif
|
||||
|
||||
#if !defined(ON_BIG_ENDIAN) && !defined(ON_LITTLE_ENDIAN)
|
||||
#error Exactly one of ON_LITTLE_ENDIAN or ON_BIG_ENDIAN should be defined.
|
||||
#endif
|
||||
|
||||
#if (!defined(ON_ARM_64) && defined(__aarch64__))
|
||||
#define ON_ARM_64
|
||||
#endif
|
||||
|
||||
/*
|
||||
//
|
||||
// END - Additional platform defines
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
#endif
|
||||
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
|
||||
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
|
||||
// McNeel & Associates.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
|
||||
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
|
||||
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
|
||||
//
|
||||
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(OPENNURBS_SYSTEM_RUNTIME_INC_)
|
||||
#define OPENNURBS_SYSTEM_RUNTIME_INC_
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Determines the runtime environment where the code is executed.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BEGIN - ON_RUNTIME_APPLE / ON_RUNTIME_WIN / ON_RUNTIME_ANDROID defines
|
||||
//
|
||||
// ON_RUNTIME_* specifies the runtime C/C++ SDK being used
|
||||
// At most one the ON_RUNTIME_* should be defined
|
||||
//
|
||||
// ON_RUNTIME_APPLE / ON_RUNTIME_WIN / ON_RUNTIME_ANDROID
|
||||
//
|
||||
*/
|
||||
#if (defined(__APPLE__) || defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) || defined(__IOS__))
|
||||
|
||||
#if !defined(ON_RUNTIME_APPLE)
|
||||
#define ON_RUNTIME_APPLE
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || defined(WINDOWS) || defined(_WINDOWS_) || defined(__WINDOWS__)
|
||||
|
||||
#if !defined(ON_RUNTIME_WIN)
|
||||
#define ON_RUNTIME_WIN
|
||||
#endif
|
||||
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
// __EMSCRIPTEN__ is for a web assembly compile which currently compiles with the
|
||||
// same settings as an android build. We will need to add an ON_RUNTIME_WASM once
|
||||
// the __EMSCRIPTEN__ compile stabilizes
|
||||
#if !defined(ON_RUNTIME_ANDROID)
|
||||
#define ON_RUNTIME_ANDROID
|
||||
#endif
|
||||
|
||||
#elif defined(__linux__)
|
||||
#if !defined(ON_RUNTIME_LINUX)
|
||||
#define ON_RUNTIME_LINUX
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
//
|
||||
// END - ON_RUNTIME_APPLE / ON_RUNTIME_WIN / ON_RUNTIME_ANDROID defines
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BEGIN - Additional platform defines
|
||||
//
|
||||
// ON_64BIT_RUNTIME / ON_32BIT_RUNTIME
|
||||
// ON_LITTLE_ENDIAN / ON_BIG_ENDIAN
|
||||
// ON_SIZEOF_WCHAR_T
|
||||
// ON_RUNTIME_<PLATFORM>_<SUBPLATFORM>
|
||||
//
|
||||
*/
|
||||
#if defined(ON_RUNTIME_APPLE)
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#if (TARGET_OS_IPHONE == 1)
|
||||
#define ON_RUNTIME_APPLE_IOS
|
||||
#endif
|
||||
|
||||
#if (TARGET_OS_SIMULATOR == 1)
|
||||
#define ON_RUNTIME_APPLE_IOS
|
||||
#define ON_RUNTIME_APPLE_IOS_SIMULATOR
|
||||
#endif
|
||||
|
||||
#if !defined(ON_RUNTIME_APPLE_IOS)
|
||||
#define ON_RUNTIME_APPLE_MACOS
|
||||
|
||||
#if !defined(RHINO_CORE_COMPONENT)
|
||||
// Apple:
|
||||
// Defines RHINO_CORE_COMPONENT here.
|
||||
// If we publish an Apple C++ pubic SDK, this will need to be adjusted.
|
||||
// Windows:
|
||||
// uses the property sheet RhinoProjectPropertySheets/Rhino.Cpp.common.props
|
||||
// Some build products in Windows are not "core components"
|
||||
#define RHINO_CORE_COMPONENT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined(__LP64__) || defined(__ppc64__))
|
||||
#define ON_64BIT_RUNTIME
|
||||
#elif defined(__LP32__)
|
||||
#define ON_32BIT_RUNTIME
|
||||
#else
|
||||
#error Add code to detect sizeof pointer on this Apple platform
|
||||
#endif
|
||||
|
||||
#define ON_SIZEOF_WCHAR_T 4
|
||||
|
||||
#if (defined(__ppc__) || defined(__ppc64__))
|
||||
#define ON_BIG_ENDIAN
|
||||
#else
|
||||
#define ON_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#elif defined(ON_RUNTIME_WIN)
|
||||
|
||||
#define ON_SIZEOF_WCHAR_T 2
|
||||
|
||||
#if defined(WINDOWS_PHONE)
|
||||
#define ON_RUNTIME_WIN_MOBILE
|
||||
#else
|
||||
#define ON_RUNTIME_WIN_WINOS
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64) || defined(_WIN64)
|
||||
#define ON_64BIT_RUNTIME
|
||||
#elif defined(_M_X86) || defined(_WIN32)
|
||||
#define ON_32BIT_RUNTIME
|
||||
#else
|
||||
#error Add code to detect sizeof pointer on this Windows platform
|
||||
#endif
|
||||
|
||||
#if !defined(ON_LITTLE_ENDIAN)
|
||||
#if (defined(_M_X64) || defined(_M_IX86) || defined (__i386__) || defined( __x86_64__ ))
|
||||
#define ON_LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(ON_RUNTIME_ANDROID)
|
||||
|
||||
#if !defined(ON_SIZEOF_WCHAR_T)
|
||||
#define ON_SIZEOF_WCHAR_T 4
|
||||
#endif
|
||||
|
||||
#elif defined(ON_RUNTIME_LINUX)
|
||||
|
||||
#if !defined(ON_SIZEOF_WCHAR_T)
|
||||
#define ON_SIZEOF_WCHAR_T 4
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#if INTPTR_MAX == INT64_MAX
|
||||
#define ON_64BIT_RUNTIME
|
||||
#elif INTPTR_MAX == INT32_MAX
|
||||
#define ON_32BIT_RUNTIME
|
||||
#endif
|
||||
|
||||
#include <endian.h>
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define ON_LITTLE_ENDIAN
|
||||
#else
|
||||
#define ON_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(ON_64BIT_RUNTIME) && !defined(ON_32BIT_RUNTIME)
|
||||
/* Attempt to determing runtime pointer size */
|
||||
#if (defined(_M_X64) || defined(__LP64__) || defined(__ppc64__))
|
||||
#define ON_64BIT_RUNTIME
|
||||
#elif (defined(_M_X86) || defined(__LP32__))
|
||||
#define ON_32BIT_RUNTIME
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ON_64BIT_RUNTIME) && defined(ON_32BIT_RUNTIME)
|
||||
#error Exactly one of ON_64BIT_RUNTIME or ON_32BIT_RUNTIME must be defined.
|
||||
#endif
|
||||
|
||||
#if !defined(ON_64BIT_RUNTIME) && !defined(ON_32BIT_RUNTIME)
|
||||
#error Exactly one of ON_64BIT_RUNTIME or ON_32BIT_RUNTIME must be defined.
|
||||
#endif
|
||||
|
||||
#if defined(ON_BIG_ENDIAN) && defined(ON_LITTLE_ENDIAN)
|
||||
#error Exactly one of ON_LITTLE_ENDIAN or ON_BIG_ENDIAN should be defined.
|
||||
#endif
|
||||
|
||||
#if !defined(ON_BIG_ENDIAN) && !defined(ON_LITTLE_ENDIAN)
|
||||
#error Exactly one of ON_LITTLE_ENDIAN or ON_BIG_ENDIAN should be defined.
|
||||
#endif
|
||||
|
||||
#if (!defined(ON_ARM_64) && defined(__aarch64__))
|
||||
#define ON_ARM_64
|
||||
#endif
|
||||
|
||||
/*
|
||||
//
|
||||
// END - Additional platform defines
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user