1 /*************************************************************************
3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
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 *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
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. *
21 *************************************************************************/
23 #ifndef _ODE_ODECONFIG_H_
24 #define _ODE_ODECONFIG_H_
26 /* Pull in the standard headers */
37 #include <ode/precision.h>
40 #if defined(ODE_DLL) || defined(ODE_LIB)
44 /* Define a DLL export symbol for those platforms that need it */
45 #if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
47 #define ODE_API __declspec(dllexport)
58 # define ODE_API_DEPRECATED __declspec(deprecated)
59 #elif defined (__GNUC__) && ( (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) )
60 # define ODE_API_DEPRECATED __attribute__((__deprecated__))
62 # define ODE_API_DEPRECATED
65 #define ODE_PURE_INLINE static __inline
66 #define ODE_INLINE __inline
68 #if defined(__cplusplus)
69 #define ODE_EXTERN_C extern "C"
75 #define ODE_NORETURN __attribute__((noreturn))
76 #elif defined(_MSC_VER)
77 #define ODE_NORETURN __declspec(noreturn)
78 #else // #if !defined(_MSC_VER)
80 #endif // #if !defined(__GNUC__)
83 /* Well-defined common data types...need to be defined for 64 bit systems */
84 #if defined(__aarch64__) || defined(__alpha__) || defined(__ppc64__) \
85 || defined(__s390__) || defined(__s390x__) || defined(__zarch__) \
86 || defined(__mips__) || defined(__powerpc64__) || defined(__riscv) \
87 || (defined(__sparc__) && defined(__arch64__))
89 typedef int64_t dint64;
90 typedef uint64_t duint64;
91 typedef int32_t dint32;
92 typedef uint32_t duint32;
93 typedef int16_t dint16;
94 typedef uint16_t duint16;
96 typedef uint8_t duint8;
98 typedef intptr_t dintptr;
99 typedef uintptr_t duintptr;
100 typedef ptrdiff_t ddiffint;
101 typedef size_t dsizeint;
103 #elif (defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)) && !defined(__ILP32__) && !defined(_ILP32)
104 #define X86_64_SYSTEM 1
105 #if defined(_MSC_VER)
106 typedef __int64 dint64;
107 typedef unsigned __int64 duint64;
109 #if defined(_LP64) || defined(__LP64__)
111 typedef unsigned long duint64;
113 typedef long long dint64;
114 typedef unsigned long long duint64;
118 typedef unsigned int duint32;
119 typedef short dint16;
120 typedef unsigned short duint16;
121 typedef signed char dint8;
122 typedef unsigned char duint8;
124 typedef dint64 dintptr;
125 typedef duint64 duintptr;
126 typedef dint64 ddiffint;
127 typedef duint64 dsizeint;
130 #if defined(_MSC_VER)
131 typedef __int64 dint64;
132 typedef unsigned __int64 duint64;
134 typedef long long dint64;
135 typedef unsigned long long duint64;
138 typedef unsigned int duint32;
139 typedef short dint16;
140 typedef unsigned short duint16;
141 typedef signed char dint8;
142 typedef unsigned char duint8;
144 typedef dint32 dintptr;
145 typedef duint32 duintptr;
146 typedef dint32 ddiffint;
147 typedef duint32 dsizeint;
152 /* Define the dInfinity macro */
155 #define dInfinity ((float)INFINITY)
157 #define dInfinity ((double)INFINITY)
159 #elif defined(HUGE_VAL)
162 #define dInfinity HUGE_VALF
164 #define dInfinity ((float)HUGE_VAL)
167 #define dInfinity HUGE_VAL
171 #define dInfinity ((float)(1.0/0.0))
173 #define dInfinity (1.0/0.0)
178 /* Define the dNaN macro */
181 #elif defined(__GNUC__)
182 #define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; })
183 #elif defined(__cplusplus)
186 _dNaNUnion(): m_ui(0x7FC00000) {}
190 #define dNaN (_dNaNUnion().m_f)
193 #define dNaN ((float)(dInfinity - dInfinity))
195 #define dNaN (dInfinity - dInfinity)
200 /* Visual C does not define these functions */
201 #if defined(_MSC_VER)
202 #define _ode_copysignf(x, y) ((float)_copysign(x, y))
203 #define _ode_copysign(x, y) _copysign(x, y)
204 #define _ode_nextafterf(x, y) _nextafterf(x, y)
205 #define _ode_nextafter(x, y) _nextafter(x, y)
206 #if !defined(_WIN64) && defined(dSINGLE)
207 #define _ODE__NEXTAFTERF_REQUIRED
208 ODE_EXTERN_C float _nextafterf(float x, float y);
211 #define _ode_copysignf(x, y) copysignf(x, y)
212 #define _ode_copysign(x, y) copysign(x, y)
213 #define _ode_nextafterf(x, y) nextafterf(x, y)
214 #define _ode_nextafter(x, y) nextafter(x, y)