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(__loongarch64) || defined(__e2k__) \
88 || (defined(__sparc__) && defined(__arch64__))
90 typedef int64_t dint64
;
91 typedef uint64_t duint64
;
92 typedef int32_t dint32
;
93 typedef uint32_t duint32
;
94 typedef int16_t dint16
;
95 typedef uint16_t duint16
;
97 typedef uint8_t duint8
;
99 typedef intptr_t dintptr
;
100 typedef uintptr_t duintptr
;
101 typedef ptrdiff_t ddiffint
;
102 typedef size_t dsizeint
;
104 #elif (defined(_M_IA64) || defined(__ia64__) || defined(_M_AMD64) || defined(__x86_64__)) && !defined(__ILP32__) && !defined(_ILP32)
105 #define X86_64_SYSTEM 1
106 #if defined(_MSC_VER)
107 typedef __int64 dint64
;
108 typedef unsigned __int64 duint64
;
110 #if defined(_LP64) || defined(__LP64__)
112 typedef unsigned long duint64
;
114 typedef long long dint64
;
115 typedef unsigned long long duint64
;
119 typedef unsigned int duint32
;
120 typedef short dint16
;
121 typedef unsigned short duint16
;
122 typedef signed char dint8
;
123 typedef unsigned char duint8
;
125 typedef dint64 dintptr
;
126 typedef duint64 duintptr
;
127 typedef dint64 ddiffint
;
128 typedef duint64 dsizeint
;
131 #if defined(_MSC_VER)
132 typedef __int64 dint64
;
133 typedef unsigned __int64 duint64
;
135 typedef long long dint64
;
136 typedef unsigned long long duint64
;
139 typedef unsigned int duint32
;
140 typedef short dint16
;
141 typedef unsigned short duint16
;
142 typedef signed char dint8
;
143 typedef unsigned char duint8
;
145 typedef dint32 dintptr
;
146 typedef duint32 duintptr
;
147 typedef dint32 ddiffint
;
148 typedef duint32 dsizeint
;
153 /* Define the dInfinity macro */
156 #define dInfinity ((float)INFINITY)
158 #define dInfinity ((double)INFINITY)
160 #elif defined(HUGE_VAL)
163 #define dInfinity HUGE_VALF
165 #define dInfinity ((float)HUGE_VAL)
168 #define dInfinity HUGE_VAL
172 #define dInfinity ((float)(1.0/0.0))
174 #define dInfinity (1.0/0.0)
179 /* Define the dNaN macro */
182 #elif defined(__GNUC__)
183 #define dNaN ({ union { duint32 m_ui; float m_f; } un; un.m_ui = 0x7FC00000; un.m_f; })
184 #elif defined(__cplusplus)
187 _dNaNUnion(): m_ui(0x7FC00000) {}
191 #define dNaN (_dNaNUnion().m_f)
194 #define dNaN ((float)(dInfinity - dInfinity))
196 #define dNaN (dInfinity - dInfinity)
201 /* Visual C does not define these functions */
202 #if defined(_MSC_VER)
203 #define _ode_copysignf(x, y) ((float)_copysign(x, y))
204 #define _ode_copysign(x, y) _copysign(x, y)
205 #define _ode_nextafterf(x, y) _nextafterf(x, y)
206 #define _ode_nextafter(x, y) _nextafter(x, y)
207 #if !defined(_WIN64) && defined(dSINGLE)
208 #define _ODE__NEXTAFTERF_REQUIRED
209 ODE_EXTERN_C
float _nextafterf(float x
, float y
);
212 #define _ode_copysignf(x, y) copysignf(x, y)
213 #define _ode_copysign(x, y) copysign(x, y)
214 #define _ode_nextafterf(x, y) nextafterf(x, y)
215 #define _ode_nextafter(x, y) nextafter(x, y)
219 #if defined(_MSC_VER) && _MSC_VER < 1700 // Also mind similar defines in ccd/vec3.h
220 /* Define fmin, fmax, fminf, fmaxf which are missing from MSVC (up to VS2008 at least) */
221 static __inline
double _ode_fmin(double x
, double y
) { return __min(x
, y
); }
222 static __inline
double _ode_fmax(double x
, double y
) { return __max(x
, y
); }
223 static __inline
float _ode_fminf(float x
, float y
) { return __min(x
, y
); }
224 static __inline
float _ode_fmaxf(float x
, float y
) { return __max(x
, y
); }
225 #else // #if !defined(_MSC_VER) || _MSC_VER >= 1700
226 #define _ode_fmin(x, y) fmin(x, y)
227 #define _ode_fmax(x, y) fmax(x, y)
228 #define _ode_fminf(x, y) fminf(x, y)
229 #define _ode_fmaxf(x, y) fmaxf(x, y)
230 #endif // #if !defined(_MSC_VER) || _MSC_VER >= 1700