odeconfig.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. #elif !defined(ODE_LIB)
  42. #define ODE_DLL_API __declspec(dllimport)
  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 define for 64 bit systems */
  70. #if defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)
  71. #define X86_64_SYSTEM 1
  72. #if defined(_MSC_VER)
  73. typedef __int64 dint64;
  74. typedef unsigned __int64 duint64;
  75. #else
  76. typedef long long dint64;
  77. typedef unsigned long long duint64;
  78. #endif
  79. typedef int dint32;
  80. typedef unsigned int duint32;
  81. typedef short dint16;
  82. typedef unsigned short duint16;
  83. typedef signed char dint8;
  84. typedef unsigned char duint8;
  85. typedef dint64 dintptr;
  86. typedef duint64 duintptr;
  87. typedef dint64 ddiffint;
  88. typedef duint64 dsizeint;
  89. #else
  90. #if defined(_MSC_VER)
  91. typedef __int64 dint64;
  92. typedef unsigned __int64 duint64;
  93. #else
  94. typedef long long dint64;
  95. typedef unsigned long long duint64;
  96. #endif
  97. typedef int dint32;
  98. typedef unsigned int duint32;
  99. typedef short dint16;
  100. typedef unsigned short duint16;
  101. typedef signed char dint8;
  102. typedef unsigned char duint8;
  103. typedef dint32 dintptr;
  104. typedef duint32 duintptr;
  105. typedef dint32 ddiffint;
  106. typedef duint32 dsizeint;
  107. #endif
  108. /* Define the dInfinity macro */
  109. #ifdef INFINITY
  110. #ifdef dSINGLE
  111. #define dInfinity ((float)INFINITY)
  112. #else
  113. #define dInfinity ((double)INFINITY)
  114. #endif
  115. #elif defined(HUGE_VAL)
  116. #ifdef dSINGLE
  117. #ifdef HUGE_VALF
  118. #define dInfinity HUGE_VALF
  119. #else
  120. #define dInfinity ((float)HUGE_VAL)
  121. #endif
  122. #else
  123. #define dInfinity HUGE_VAL
  124. #endif
  125. #else
  126. #ifdef dSINGLE
  127. #define dInfinity ((float)(1.0/0.0))
  128. #else
  129. #define dInfinity (1.0/0.0)
  130. #endif
  131. #endif
  132. /* Define the dNaN macro */
  133. #if defined(NAN)
  134. #define dNaN NAN
  135. #elif defined(__GNUC__)
  136. #define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; })
  137. #elif defined(__cplusplus)
  138. union _dNaNUnion
  139. {
  140. _dNaNUnion(): m_ui(0x7FC00000) {}
  141. duint32 m_ui;
  142. float m_f;
  143. };
  144. #define dNaN (_dNaNUnion().m_f)
  145. #else
  146. #ifdef dSINGLE
  147. #define dNaN ((float)(dInfinity - dInfinity))
  148. #else
  149. #define dNaN (dInfinity - dInfinity)
  150. #endif
  151. #endif
  152. /* Visual C does not define these functions */
  153. #if defined(_MSC_VER)
  154. #define _ode_copysignf(x, y) ((float)_copysign(x, y))
  155. #define _ode_copysign(x, y) _copysign(x, y)
  156. #define _ode_nextafterf(x, y) _nextafterf(x, y)
  157. #define _ode_nextafter(x, y) _nextafter(x, y)
  158. #if !defined(_WIN64) && defined(dSINGLE)
  159. #define _ODE__NEXTAFTERF_REQUIRED
  160. ODE_EXTERN_C float _nextafterf(float x, float y);
  161. #endif
  162. #else
  163. #define _ode_copysignf(x, y) copysignf(x, y)
  164. #define _ode_copysign(x, y) copysign(x, y)
  165. #define _ode_nextafterf(x, y) nextafterf(x, y)
  166. #define _ode_nextafter(x, y) nextafter(x, y)
  167. #endif
  168. #endif