odeconfig.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] Web: www.q12.org *
  5. * *
  6. * This library is free software; you can redistribute it and/or *
  7. * modify it under the terms of EITHER: *
  8. * (1) The GNU Lesser General Public License as published by the Free *
  9. * Software Foundation; either version 2.1 of the License, or (at *
  10. * your option) any later version. The text of the GNU Lesser *
  11. * General Public License is included with this library in the *
  12. * file LICENSE.TXT. *
  13. * (2) The BSD-style license that is included with this library in *
  14. * the file LICENSE-BSD.TXT. *
  15. * *
  16. * This library is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  19. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  20. * *
  21. *************************************************************************/
  22. #ifndef _ODE_ODECONFIG_H_
  23. #define _ODE_ODECONFIG_H_
  24. /* Pull in the standard headers */
  25. #include <stddef.h>
  26. #include <limits.h>
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <stdarg.h>
  30. #include <math.h>
  31. #include <string.h>
  32. #include <float.h>
  33. #include <ode/precision.h>
  34. #if defined(ODE_DLL) || defined(ODE_LIB)
  35. #define __ODE__
  36. #endif
  37. /* Define a DLL export symbol for those platforms that need it */
  38. #if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
  39. #if defined(ODE_DLL)
  40. #define ODE_API __declspec(dllexport)
  41. #else
  42. #define ODE_API
  43. #endif
  44. #endif
  45. #if !defined(ODE_API)
  46. #define ODE_API
  47. #endif
  48. #if defined(_MSC_VER)
  49. # define ODE_API_DEPRECATED __declspec(deprecated)
  50. #elif defined (__GNUC__) && ( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) )
  51. # define ODE_API_DEPRECATED __attribute__((__deprecated__))
  52. #else
  53. # define ODE_API_DEPRECATED
  54. #endif
  55. #define ODE_PURE_INLINE static __inline
  56. #define ODE_INLINE __inline
  57. #if defined(__cplusplus)
  58. #define ODE_EXTERN_C extern "C"
  59. #else
  60. #define ODE_EXTERN_C
  61. #endif
  62. #if defined(__GNUC__)
  63. #define ODE_NORETURN __attribute__((noreturn))
  64. #elif defined(_MSC_VER)
  65. #define ODE_NORETURN __declspec(noreturn)
  66. #else // #if !defined(_MSC_VER)
  67. #define ODE_NORETURN
  68. #endif // #if !defined(__GNUC__)
  69. /* Well-defined common data types...need to be defined for 64 bit systems */
  70. #if defined(__aarch64__) || defined(__alpha__) || defined(__ppc64__) \
  71. || defined(__s390__) || defined(__s390x__) || defined(__zarch__) \
  72. || defined(__mips__) || defined(__powerpc64__) || defined(__riscv) \
  73. || (defined(__sparc__) && defined(__arch64__))
  74. #include <stdint.h>
  75. typedef int64_t dint64;
  76. typedef uint64_t duint64;
  77. typedef int32_t dint32;
  78. typedef uint32_t duint32;
  79. typedef int16_t dint16;
  80. typedef uint16_t duint16;
  81. typedef int8_t dint8;
  82. typedef uint8_t duint8;
  83. typedef intptr_t dintptr;
  84. typedef uintptr_t duintptr;
  85. typedef ptrdiff_t ddiffint;
  86. typedef size_t dsizeint;
  87. #elif (defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)) && !defined(__ILP32__) && !defined(_ILP32)
  88. #define X86_64_SYSTEM 1
  89. #if defined(_MSC_VER)
  90. typedef __int64 dint64;
  91. typedef unsigned __int64 duint64;
  92. #else
  93. #if defined(_LP64) || defined(__LP64__)
  94. typedef long dint64;
  95. typedef unsigned long duint64;
  96. #else
  97. typedef long long dint64;
  98. typedef unsigned long long duint64;
  99. #endif
  100. #endif
  101. typedef int dint32;
  102. typedef unsigned int duint32;
  103. typedef short dint16;
  104. typedef unsigned short duint16;
  105. typedef signed char dint8;
  106. typedef unsigned char duint8;
  107. typedef dint64 dintptr;
  108. typedef duint64 duintptr;
  109. typedef dint64 ddiffint;
  110. typedef duint64 dsizeint;
  111. #else
  112. #if defined(_MSC_VER)
  113. typedef __int64 dint64;
  114. typedef unsigned __int64 duint64;
  115. #else
  116. typedef long long dint64;
  117. typedef unsigned long long duint64;
  118. #endif
  119. typedef int dint32;
  120. typedef unsigned int duint32;
  121. typedef short dint16;
  122. typedef unsigned short duint16;
  123. typedef signed char dint8;
  124. typedef unsigned char duint8;
  125. typedef dint32 dintptr;
  126. typedef duint32 duintptr;
  127. typedef dint32 ddiffint;
  128. typedef duint32 dsizeint;
  129. #endif
  130. /* Define the dInfinity macro */
  131. #ifdef INFINITY
  132. #ifdef dSINGLE
  133. #define dInfinity ((float)INFINITY)
  134. #else
  135. #define dInfinity ((double)INFINITY)
  136. #endif
  137. #elif defined(HUGE_VAL)
  138. #ifdef dSINGLE
  139. #ifdef HUGE_VALF
  140. #define dInfinity HUGE_VALF
  141. #else
  142. #define dInfinity ((float)HUGE_VAL)
  143. #endif
  144. #else
  145. #define dInfinity HUGE_VAL
  146. #endif
  147. #else
  148. #ifdef dSINGLE
  149. #define dInfinity ((float)(1.0/0.0))
  150. #else
  151. #define dInfinity (1.0/0.0)
  152. #endif
  153. #endif
  154. /* Define the dNaN macro */
  155. #if defined(NAN)
  156. #define dNaN NAN
  157. #elif defined(__GNUC__)
  158. #define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; })
  159. #elif defined(__cplusplus)
  160. union _dNaNUnion
  161. {
  162. _dNaNUnion(): m_ui(0x7FC00000) {}
  163. duint32 m_ui;
  164. float m_f;
  165. };
  166. #define dNaN (_dNaNUnion().m_f)
  167. #else
  168. #ifdef dSINGLE
  169. #define dNaN ((float)(dInfinity - dInfinity))
  170. #else
  171. #define dNaN (dInfinity - dInfinity)
  172. #endif
  173. #endif
  174. /* Visual C does not define these functions */
  175. #if defined(_MSC_VER)
  176. #define _ode_copysignf(x, y) ((float)_copysign(x, y))
  177. #define _ode_copysign(x, y) _copysign(x, y)
  178. #define _ode_nextafterf(x, y) _nextafterf(x, y)
  179. #define _ode_nextafter(x, y) _nextafter(x, y)
  180. #if !defined(_WIN64) && defined(dSINGLE)
  181. #define _ODE__NEXTAFTERF_REQUIRED
  182. ODE_EXTERN_C float _nextafterf(float x, float y);
  183. #endif
  184. #else
  185. #define _ode_copysignf(x, y) copysignf(x, y)
  186. #define _ode_copysign(x, y) copysign(x, y)
  187. #define _ode_nextafterf(x, y) nextafterf(x, y)
  188. #define _ode_nextafter(x, y) nextafter(x, y)
  189. #endif
  190. #if defined(_MSC_VER) && _MSC_VER < 1700 // Also mind similar defines in ccd/vec3.h
  191. /* Define fmin, fmax, fminf, fmaxf which are missing from MSVC (up to VS2008 at least) */
  192. static __inline double _ode_fmin(double x, double y) { return __min(x, y); }
  193. static __inline double _ode_fmax(double x, double y) { return __max(x, y); }
  194. static __inline float _ode_fminf(float x, float y) { return __min(x, y); }
  195. static __inline float _ode_fmaxf(float x, float y) { return __max(x, y); }
  196. #else // #if !defined(_MSC_VER) || _MSC_VER >= 1700
  197. #define _ode_fmin(x, y) fmin(x, y)
  198. #define _ode_fmax(x, y) fmax(x, y)
  199. #define _ode_fminf(x, y) fminf(x, y)
  200. #define _ode_fmaxf(x, y) fmaxf(x, y)
  201. #endif // #if !defined(_MSC_VER) || _MSC_VER >= 1700
  202. #endif