Cosmetic: Commentary spelling corrections by Max Seidenstücker
[ode.git] / include / ode / odeconfig.h
blobecd62cbe31921eb8d55b5bbc8b9faab8ac3dd157
1 /*************************************************************************
2 * *
3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org 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 *************************************************************************/
23 #ifndef _ODE_ODECONFIG_H_
24 #define _ODE_ODECONFIG_H_
26 /* Pull in the standard headers */
27 #include <stddef.h>
28 #include <limits.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <stdarg.h>
32 #include <math.h>
33 #include <string.h>
34 #include <float.h>
37 #include <ode/precision.h>
40 #if defined(ODE_DLL) || defined(ODE_LIB)
41 #define __ODE__
42 #endif
44 /* Define a DLL export symbol for those platforms that need it */
45 #if defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32))
46 #if defined(ODE_DLL)
47 #define ODE_API __declspec(dllexport)
48 #else
49 #define ODE_API
50 #endif
51 #endif
53 #if !defined(ODE_API)
54 #define ODE_API
55 #endif
57 #if defined(_MSC_VER)
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__))
61 #else
62 # define ODE_API_DEPRECATED
63 #endif
65 #define ODE_PURE_INLINE static __inline
66 #define ODE_INLINE __inline
68 #if defined(__cplusplus)
69 #define ODE_EXTERN_C extern "C"
70 #else
71 #define ODE_EXTERN_C
72 #endif
74 #if defined(__GNUC__)
75 #define ODE_NORETURN __attribute__((noreturn))
76 #elif defined(_MSC_VER)
77 #define ODE_NORETURN __declspec(noreturn)
78 #else // #if !defined(_MSC_VER)
79 #define ODE_NORETURN
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__))
89 #include <stdint.h>
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;
96 typedef int8_t dint8;
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;
109 #else
110 #if defined(_LP64) || defined(__LP64__)
111 typedef long dint64;
112 typedef unsigned long duint64;
113 #else
114 typedef long long dint64;
115 typedef unsigned long long duint64;
116 #endif
117 #endif
118 typedef int dint32;
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;
130 #else
131 #if defined(_MSC_VER)
132 typedef __int64 dint64;
133 typedef unsigned __int64 duint64;
134 #else
135 typedef long long dint64;
136 typedef unsigned long long duint64;
137 #endif
138 typedef int dint32;
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;
150 #endif
153 /* Define the dInfinity macro */
154 #ifdef INFINITY
155 #ifdef dSINGLE
156 #define dInfinity ((float)INFINITY)
157 #else
158 #define dInfinity ((double)INFINITY)
159 #endif
160 #elif defined(HUGE_VAL)
161 #ifdef dSINGLE
162 #ifdef HUGE_VALF
163 #define dInfinity HUGE_VALF
164 #else
165 #define dInfinity ((float)HUGE_VAL)
166 #endif
167 #else
168 #define dInfinity HUGE_VAL
169 #endif
170 #else
171 #ifdef dSINGLE
172 #define dInfinity ((float)(1.0/0.0))
173 #else
174 #define dInfinity (1.0/0.0)
175 #endif
176 #endif
179 /* Define the dNaN macro */
180 #if defined(NAN)
181 #define dNaN NAN
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)
185 union _dNaNUnion
187 _dNaNUnion(): m_ui(0x7FC00000) {}
188 duint32 m_ui;
189 float m_f;
191 #define dNaN (_dNaNUnion().m_f)
192 #else
193 #ifdef dSINGLE
194 #define dNaN ((float)(dInfinity - dInfinity))
195 #else
196 #define dNaN (dInfinity - dInfinity)
197 #endif
198 #endif
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);
210 #endif
211 #else
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)
216 #endif
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
233 #endif