22 #ifndef __ND_TYPES_H__
23 #define __ND_TYPES_H__
27 #define HAVE_STRUCT_TIMESPEC
31 #define ND_NEWTON_VERSION 402
33 #if (defined (WIN32) || defined(_WIN32) || defined (_M_ARM) || defined (_M_ARM64))
62 #include <condition_variable>
67 #if defined(__STRICT_ANSI__) && (defined (__MINGW32__) || defined (__MINGW64__))
68 #pragma push_macro("__STRICT_ANSI__")
69 #undef __STRICT_ANSI__
73 #if (defined (__MINGW32__) || defined (__MINGW64__))
74 #pragma pop_macro("__STRICT_ANSI__")
77 #if (defined (__MINGW32__) || defined (__MINGW64__))
85 #if (defined (__linux__ ) || defined (__MINGW32__) || defined (__MINGW64__))
96 #if (!defined(__arm__) && !defined(__aarch64__))
100 #include <immintrin.h>
101 #include <pmmintrin.h>
102 #include <emmintrin.h>
103 #include <mmintrin.h>
108 #if defined (__x86_64) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
109 #include <immintrin.h>
112 #if defined(__arm__) && defined(__aarch64__)
113 #include <arm_neon.h>
116 #if defined (__APPLE__)
118 #include <sys/sysctl.h>
120 #if (defined __i386__ || defined __x86_64__)
121 #include <immintrin.h>
122 #include <pmmintrin.h>
123 #include <emmintrin.h>
124 #include <mmintrin.h>
132 #ifdef D_FORCE_PROFILE_PHYSICS
154 #ifdef D_USE_FORCE_THREAD_EMULATION
155 #ifndef D_USE_THREAD_EMULATION
156 #define D_USE_THREAD_EMULATION
161 #ifdef D_DISABLE_ASSERT
164 #if (defined (WIN32) || defined(_WIN32) || defined (_M_ARM) || defined (_M_ARM64))
165 #define ndAssert(x) _ASSERTE(x)
168 #define ndAssert(x) assert(x)
179 #if defined(_MSC_VER)
180 #define D_GCC_NEWTON_ALIGN_16
181 #define D_MSV_NEWTON_ALIGN_16 __declspec(align(16))
183 #define D_GCC_NEWTON_ALIGN_32
184 #define D_MSV_NEWTON_ALIGN_32 __declspec(align(32))
186 #define D_GCC_NEWTON_ALIGN_16 __attribute__((aligned (16)))
187 #define D_MSV_NEWTON_ALIGN_16
189 #define D_GCC_NEWTON_ALIGN_32 __attribute__((aligned (32)))
190 #define D_MSV_NEWTON_ALIGN_32
193 #if defined(_MSC_VER)
194 #define D_LIBRARY_EXPORT __declspec(dllexport)
195 #define D_LIBRARY_IMPORT __declspec(dllimport)
197 #define D_LIBRARY_EXPORT __attribute__((visibility("default")))
198 #define D_LIBRARY_IMPORT __attribute__((visibility("default")))
202 #ifdef _D_CORE_EXPORT_DLL
203 #define D_CORE_API D_LIBRARY_EXPORT
205 #define D_CORE_API D_LIBRARY_IMPORT
211 typedef float ndReal;
212 typedef int8_t ndInt8;
213 typedef uint8_t ndUnsigned8;
214 typedef int16_t ndInt16;
215 typedef uint16_t ndUnsigned16;
216 typedef int32_t ndInt32;
217 typedef uint32_t ndUnsigned32;
218 typedef int64_t ndInt64;
219 typedef uint64_t ndUnsigned64;
221 typedef double ndFloat64;
222 #ifdef D_NEWTON_USE_DOUBLE
223 typedef double ndFloat32;
225 typedef float ndFloat32;
228 #define ndPi ndFloat32 (3.141592f)
229 #define ndEXP ndFloat32 (2.71828f)
230 #define ndEpsilon ndFloat32 (1.0e-5f)
231 #define ndDegreeToRad ndFloat32 (ndPi / 180.0f)
232 #define ndRadToDegree ndFloat32 (180.0f / ndPi)
234 #define ndSqrt(x) ndFloat32 (sqrt(x))
235 #define ndSin(x) ndFloat32 (sin(x))
236 #define ndCos(x) ndFloat32 (cos(x))
237 #define ndAsin(x) ndFloat32 (asin(x))
238 #define ndAcos(x) ndFloat32 (acos(x))
239 #define ndLog(x) ndFloat32 (log(x))
240 #define ndCeil(x) ndFloat32 (ceil(x))
241 #define ndFloor(x) ndFloat32 (floor(x))
242 #define ndPow(x,y) ndFloat32 (pow(x,y))
243 #define ndFmod(x,y) ndFloat32 (fmod(x,y))
244 #define ndTan(x) ndFloat32 (tan(x))
245 #define ndAtan(x) ndFloat32 (atan(x))
246 #define ndAtan2(x,y) ndFloat32 (atan2(x,y))
247 #define ndRsqrt(x) (ndFloat32 (1.0f) / ndSqrt(x))
249 #if (defined (WIN32) || defined(_WIN32) || defined (_M_ARM) || defined (_M_ARM64))
251 #define ndCheckFloat(x) (1)
254 #define ndCheckFloat(x) (1)
257 #ifdef D_NEWTON_USE_DOUBLE
291 #define D_OPERATOR_NEW_AND_DELETE \
292 inline void *operator new (size_t size) \
294 return ndMemory::Malloc(size); \
297 inline void *operator new[](size_t size) \
299 return ndMemory::Malloc(size); \
302 inline void operator delete (void* ptr) \
304 ndMemory::Free(ptr); \
307 inline void operator delete[](void* ptr) \
309 ndMemory::Free(ptr); \
313 #ifdef D_USE_THREAD_EMULATION
364 bool compare_exchange_weak(T oldValue, T newValue)
366 if (m_val == oldValue)
384 : std::atomic<T>(T(0))
389 : std::atomic<T>(val)
394 : std::atomic<T>(copy.load())
400 return std::atomic<T>::operator=(value);