Comment remaining unsolved bug.
[ardour.git] / libs / backends / wavesaudio / wavesapi / WavesPublicAPI / wstdint.h
1 /*
2     Copyright (C) 2014 Waves Audio Ltd.
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __stdint_h__
21 #define __stdint_h__
22
23 /* Copy to include
24 #include "wstdint.h"
25 */
26
27
28 #ifdef __APPLE__
29         #include <stddef.h>
30         #include </usr/include/stdint.h>  // Mac has this file in /usr/includez
31 #endif
32 #ifdef __linux__
33         #if ! defined(__STDC_LIMIT_MACROS)
34                 #define __STDC_LIMIT_MACROS
35         #endif
36
37         #include <stddef.h>
38         #include </usr/include/stdint.h>
39 #endif
40
41 #if (defined (PLATFORM_WINDOWS) || defined(WIN32) || defined(WIN64))
42 #if (_MSC_VER > 1600) || defined(__MINGW64__) || defined(__MINGW32__)
43     // Taken from MSDN official page:
44     // In Visual Studio 2010 _MSC_VER  is defined as 1600, In Visual Studio 2012 _MSC_VER  is defined as 1700.
45     #include <stdint.h>
46 #else
47 #ifndef _STDINT_H
48     #define _STDINT_H // this will prevent Altura's CGBase.h from defining int32_t
49 #endif
50 /*
51  * ISO C 99 <stdint.h> for platforms that lack it.
52  * <http://www.opengroup.org/onlinepubs/007904975/basedefs/stdint.h.html>
53  */
54
55 /* Get wchar_t, WCHAR_MIN, WCHAR_MAX.  */
56 #include <stddef.h>
57 /* Get CHAR_BIT, LONG_MIN, LONG_MAX, ULONG_MAX.  */
58 #include <limits.h>
59
60 /* Get those types that are already defined in other system include files.  */
61 #if defined(__FreeBSD__)
62 # include <sys/inttypes.h>
63 #endif
64
65 #if defined(__sun) && HAVE_SYS_INTTYPES_H
66 # include <sys/inttypes.h>
67   /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
68      the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.
69      But note that <sys/int_types.h> contains only the type definitions!  */
70 # define HAVE_SYSTEM_INTTYPES
71 #endif
72 #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H
73 # include <inttypes.h>
74   /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX,
75      UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX.  */
76   /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX,
77      UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX.  */
78 # define HAVE_SYSTEM_INTTYPES
79 #endif
80 #if !(defined(UNIX_CYGWIN32) && defined(__BIT_TYPES_DEFINED__))
81 # define NEED_SIGNED_INT_TYPES
82 #endif
83
84 #if !defined(HAVE_SYSTEM_INTTYPES)
85
86 /* 7.18.1.1. Exact-width integer types */
87 #if !defined(__FreeBSD__)
88
89 #if defined(_MSC_VER)
90 #ifndef __int8_t_defined
91 #define __int8_t_defined
92 typedef          __int8  int8_t;
93 typedef unsigned __int8  uint8_t;
94 typedef          __int16 int16_t;
95 typedef unsigned __int16 uint16_t;
96 typedef          __int32 int32_t;
97 typedef unsigned __int32 uint32_t;
98 typedef          __int64 int64_t;
99 typedef unsigned __int64 uint64_t;
100 #endif
101
102 #else // _MSC_VER
103
104 #ifdef NEED_SIGNED_INT_TYPES
105 typedef signed char    int8_t;
106 #endif
107 typedef unsigned char  uint8_t;
108
109 #ifdef NEED_SIGNED_INT_TYPES
110 typedef short          int16_t;
111 #endif
112 typedef unsigned short uint16_t;
113
114 #ifdef NEED_SIGNED_INT_TYPES
115 typedef int            int32_t;
116 #endif
117 typedef unsigned int   uint32_t;
118
119 #if 0
120 #ifdef NEED_SIGNED_INT_TYPES
121 typedef long           int64_t;
122 #endif
123 typedef unsigned long  uint64_t;
124 #elif 0
125 #ifdef NEED_SIGNED_INT_TYPES
126 typedef long long          int64_t;
127 #endif
128 typedef unsigned long long uint64_t;
129 #endif
130
131 #endif // _MSC_VER
132
133 #endif /* !FreeBSD */
134
135 /* 7.18.1.2. Minimum-width integer types */
136
137 typedef int8_t   int_least8_t;
138 typedef uint8_t  uint_least8_t;
139 typedef int16_t  int_least16_t;
140 typedef uint16_t uint_least16_t;
141 #if !defined(kAlturaAlreadyDefinesInt32)
142 typedef int32_t  int_least32_t;
143 #endif
144 typedef uint32_t uint_least32_t;
145 typedef int64_t  int_least64_t;
146 typedef uint64_t uint_least64_t;
147
148
149 /* 7.18.1.3. Fastest minimum-width integer types */
150
151 #ifndef _STDINT_H
152 typedef int32_t  int_fast8_t;
153 typedef uint32_t uint_fast8_t;
154 typedef int32_t  int_fast16_t;
155 typedef uint32_t uint_fast16_t;
156 typedef int32_t  int_fast32_t;
157 typedef uint32_t uint_fast32_t;
158 typedef int64_t  int_fast64_t;
159 typedef uint64_t uint_fast64_t;
160 #endif
161
162
163 /* 7.18.1.4. Integer types capable of holding object pointers */
164
165 #if !defined(__FreeBSD__)
166
167 /* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long),
168    but this doesn't matter here.  */
169 #if !defined(_INTPTR_T_DEFINED)
170 typedef long          intptr_t;
171 #define _INTPTR_T_DEFINED
172 #endif
173 #if !defined(_UINTPTR_T_DEFINED)
174 typedef unsigned long uintptr_t;
175 #define _UINTPTR_T_DEFINED
176 #endif
177
178 #endif /* !FreeBSD */
179
180 /* 7.18.1.5. Greatest-width integer types */
181
182
183 typedef int64_t  intmax_t;
184 typedef uint64_t uintmax_t;
185 #if 0 || 0
186 typedef int32_t  intmax_t;
187 typedef uint32_t uintmax_t;
188 #endif
189
190 /* 7.18.2. Limits of specified-width integer types */
191
192 //#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
193
194 /* 7.18.2.1. Limits of exact-width integer types */
195
196 #ifndef _STDINT_H
197
198 #define INT8_MIN  -128
199 #define INT8_MAX   127
200 #define UINT8_MAX  255U
201 #define INT16_MIN  -32768
202 #define INT16_MAX   32767
203 #define UINT16_MAX  65535U
204 #define INT32_MIN   (~INT32_MAX)
205 #define INT32_MAX   2147483647
206 #define UINT32_MAX  4294967295U
207 #if 0
208 #define INT64_MIN   (~INT64_MIN)
209 #define INT64_MAX   9223372036854775807L
210 #define UINT64_MAX 18446744073709551615UL
211 #elif 0
212 #define INT64_MIN   (~INT64_MIN)
213 #define INT64_MAX   9223372036854775807LL
214 #define UINT64_MAX 18446744073709551615ULL
215 #endif
216
217 /* 7.18.2.2. Limits of minimum-width integer types */
218
219 #define INT_LEAST8_MIN INT8_MIN
220 #define INT_LEAST8_MAX INT8_MAX
221 #define UINT_LEAST8_MAX UINT8_MAX
222 #define INT_LEAST16_MIN INT16_MIN
223 #define INT_LEAST16_MAX INT16_MAX
224 #define UINT_LEAST16_MAX UINT16_MAX
225 #define INT_LEAST32_MIN INT32_MIN
226 #define INT_LEAST32_MAX INT32_MAX
227 #define UINT_LEAST32_MAX UINT32_MAX
228 #if 0 || 0
229 #define INT_LEAST64_MIN INT64_MIN
230 #define INT_LEAST64_MAX INT64_MAX
231 #define UINT_LEAST64_MAX UINT64_MAX
232 #endif
233
234 /* 7.18.2.3. Limits of fastest minimum-width integer types */
235
236 #define INT_FAST8_MIN INT32_MIN
237 #define INT_FAST8_MAX INT32_MAX
238 #define UINT_FAST8_MAX UINT32_MAX
239 #define INT_FAST16_MIN INT32_MIN
240 #define INT_FAST16_MAX INT32_MAX
241 #define UINT_FAST16_MAX UINT32_MAX
242 #define INT_FAST32_MIN INT32_MIN
243 #define INT_FAST32_MAX INT32_MAX
244 #define UINT_FAST32_MAX UINT32_MAX
245 #if 0 || 0
246 #define INT_FAST64_MIN INT64_MIN
247 #define INT_FAST64_MAX INT64_MAX
248 #define UINT_FAST64_MAX UINT64_MAX
249 #endif
250
251 /* 7.18.2.4. Limits of integer types capable of holding object pointers */
252
253 #define INTPTR_MIN LONG_MIN
254 #define INTPTR_MAX LONG_MAX
255 #define UINTPTR_MAX ULONG_MAX
256
257 /* 7.18.2.5. Limits of greatest-width integer types */
258
259 #if 0 || 0
260 #define INTMAX_MIN INT64_MIN
261 #define INTMAX_MAX INT64_MAX
262 #define UINTMAX_MAX UINT64_MAX
263 #else
264 #define INTMAX_MIN INT32_MIN
265 #define INTMAX_MAX INT32_MAX
266 #define UINTMAX_MAX UINT32_MAX
267 #endif
268
269 /* 7.18.3. Limits of other integer types */
270
271 #define PTRDIFF_MIN (~(ptrdiff_t)0 << (sizeof(ptrdiff_t)*CHAR_BIT-1))
272 #define PTRDIFF_MAX (~PTRDIFF_MIN)
273
274 /* This may be wrong...  */
275 #define SIG_ATOMIC_MIN 0
276 #define SIG_ATOMIC_MAX 127
277
278 #endif /* _STDINT_H */
279
280 //#define SIZE_MAX (~(size_t)0)
281
282 /* wchar_t limits already defined in <stddef.h>.  */
283 /* wint_t limits already defined in <wchar.h>.  */
284
285 //#endif
286
287 /* 7.18.4. Macros for integer constants */
288
289 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
290
291 /* 7.18.4.1. Macros for minimum-width integer constants */
292
293 #ifdef INT8_C
294 #undef INT8_C
295 #endif
296 #define INT8_C(x) x
297
298 #ifdef UINT8_C
299 #undef UINT8_C
300 #endif
301 #define UINT8_C(x) x##U
302
303 #ifdef INT16_C
304 #undef INT16_C
305 #endif
306 #define INT16_C(x) x
307
308 #ifdef UINT16_C
309 #undef UINT16_C
310 #endif
311 #define UINT16_C(x) x##U
312
313 #ifdef INT32_C
314 #undef INT32_C
315 #endif
316 #define INT32_C(x) x
317
318 #ifdef UINT32_C
319 #undef UINT32_C
320 #endif
321 #define UINT32_C(x) x##U
322
323 // INT64_C and UINT64_C definitions
324 #ifdef INT64_C
325 #undef INT64_C
326 #endif
327 #ifdef UINT64_C
328 #undef UINT64_C
329 #endif
330 #if 0
331 #define INT64_C(x) x##L
332 #define UINT64_C(x) x##UL
333 #elif 0
334 #define INT64_C(x) x##LL
335 #define UINT64_C(x) x##ULL
336 #endif // #if 0
337
338 /* 7.18.4.2. Macros for greatest-width integer constants */
339
340 // INTMAX_C and UINTMAX_C definitions
341 #ifdef INTMAX_C
342 #undef INTMAX_C
343 #endif
344 #ifdef UINTMAX_C
345 #undef UINTMAX_C
346 #endif
347
348 #if 0
349 #define INTMAX_C(x) x##L
350 #define UINTMAX_C(x) x##UL
351 #elif 0
352 #define INTMAX_C(x) x##LL
353 #define UINTMAX_C(x) x##ULL
354 #else
355 #define INTMAX_C(x) x
356 #define UINTMAX_C(x) x##U
357 #endif
358
359 #endif
360
361 #endif  /* !HAVE_SYSTEM_INTTYPES */
362
363 #endif /* (_MSC_VER < 1400) */
364
365 #endif /* #ifdef PLATFORM_WINDOWS */
366
367 #endif /* __stdint_h__ */