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