rev |
line source |
nuclear@0
|
1 /* A portable stdint.h
|
nuclear@0
|
2 ****************************************************************************
|
nuclear@0
|
3 * BSD License:
|
nuclear@0
|
4 ****************************************************************************
|
nuclear@0
|
5 *
|
nuclear@0
|
6 * Copyright (c) 2005-2016 Paul Hsieh
|
nuclear@0
|
7 * All rights reserved.
|
nuclear@0
|
8 *
|
nuclear@0
|
9 * Redistribution and use in source and binary forms, with or without
|
nuclear@0
|
10 * modification, are permitted provided that the following conditions
|
nuclear@0
|
11 * are met:
|
nuclear@0
|
12 *
|
nuclear@0
|
13 * 1. Redistributions of source code must retain the above copyright
|
nuclear@0
|
14 * notice, this list of conditions and the following disclaimer.
|
nuclear@0
|
15 * 2. Redistributions in binary form must reproduce the above copyright
|
nuclear@0
|
16 * notice, this list of conditions and the following disclaimer in the
|
nuclear@0
|
17 * documentation and/or other materials provided with the distribution.
|
nuclear@0
|
18 * 3. The name of the author may not be used to endorse or promote products
|
nuclear@0
|
19 * derived from this software without specific prior written permission.
|
nuclear@0
|
20 *
|
nuclear@0
|
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
nuclear@0
|
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
nuclear@0
|
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
nuclear@0
|
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
nuclear@0
|
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
nuclear@0
|
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
nuclear@0
|
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
nuclear@0
|
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
nuclear@0
|
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
nuclear@0
|
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
nuclear@0
|
31 *
|
nuclear@0
|
32 ****************************************************************************
|
nuclear@0
|
33 *
|
nuclear@0
|
34 * Version 0.1.15.4
|
nuclear@0
|
35 *
|
nuclear@0
|
36 * The ANSI C standard committee, for the C99 standard, specified the
|
nuclear@0
|
37 * inclusion of a new standard include file called stdint.h. This is
|
nuclear@0
|
38 * a very useful and long desired include file which contains several
|
nuclear@0
|
39 * very precise definitions for integer scalar types that is
|
nuclear@0
|
40 * critically important for making portable several classes of
|
nuclear@0
|
41 * applications including cryptography, hashing, variable length
|
nuclear@0
|
42 * integer libraries and so on. But for most developers its likely
|
nuclear@0
|
43 * useful just for programming sanity.
|
nuclear@0
|
44 *
|
nuclear@0
|
45 * The problem is that some compiler vendors chose to ignore the C99
|
nuclear@0
|
46 * standard and some older compilers have no opportunity to be updated.
|
nuclear@0
|
47 * Because of this situation, simply including stdint.h in your code
|
nuclear@0
|
48 * makes it unportable.
|
nuclear@0
|
49 *
|
nuclear@0
|
50 * So that's what this file is all about. Its an attempt to build a
|
nuclear@0
|
51 * single universal include file that works on as many platforms as
|
nuclear@0
|
52 * possible to deliver what stdint.h is supposed to. Even compilers
|
nuclear@0
|
53 * that already come with stdint.h can use this file instead without
|
nuclear@0
|
54 * any loss of functionality. A few things that should be noted about
|
nuclear@0
|
55 * this file:
|
nuclear@0
|
56 *
|
nuclear@0
|
57 * 1) It is not guaranteed to be portable and/or present an identical
|
nuclear@0
|
58 * interface on all platforms. The extreme variability of the
|
nuclear@0
|
59 * ANSI C standard makes this an impossibility right from the
|
nuclear@0
|
60 * very get go. Its really only meant to be useful for the vast
|
nuclear@0
|
61 * majority of platforms that possess the capability of
|
nuclear@0
|
62 * implementing usefully and precisely defined, standard sized
|
nuclear@0
|
63 * integer scalars. Systems which are not intrinsically 2s
|
nuclear@0
|
64 * complement may produce invalid constants.
|
nuclear@0
|
65 *
|
nuclear@0
|
66 * 2) There is an unavoidable use of non-reserved symbols.
|
nuclear@0
|
67 *
|
nuclear@0
|
68 * 3) Other standard include files are invoked.
|
nuclear@0
|
69 *
|
nuclear@0
|
70 * 4) This file may come in conflict with future platforms that do
|
nuclear@0
|
71 * include stdint.h. The hope is that one or the other can be
|
nuclear@0
|
72 * used with no real difference.
|
nuclear@0
|
73 *
|
nuclear@0
|
74 * 5) In the current version, if your platform can't represent
|
nuclear@0
|
75 * int32_t, int16_t and int8_t, it just dumps out with a compiler
|
nuclear@0
|
76 * error.
|
nuclear@0
|
77 *
|
nuclear@0
|
78 * 6) 64 bit integers may or may not be defined. Test for their
|
nuclear@0
|
79 * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
|
nuclear@0
|
80 * Note that this is different from the C99 specification which
|
nuclear@0
|
81 * requires the existence of 64 bit support in the compiler. If
|
nuclear@0
|
82 * this is not defined for your platform, yet it is capable of
|
nuclear@0
|
83 * dealing with 64 bits then it is because this file has not yet
|
nuclear@0
|
84 * been extended to cover all of your system's capabilities.
|
nuclear@0
|
85 *
|
nuclear@0
|
86 * 7) (u)intptr_t may or may not be defined. Test for its presence
|
nuclear@0
|
87 * with the test: #ifdef PTRDIFF_MAX. If this is not defined
|
nuclear@0
|
88 * for your platform, then it is because this file has not yet
|
nuclear@0
|
89 * been extended to cover all of your system's capabilities, not
|
nuclear@0
|
90 * because its optional.
|
nuclear@0
|
91 *
|
nuclear@0
|
92 * 8) The following might not been defined even if your platform is
|
nuclear@0
|
93 * capable of defining it:
|
nuclear@0
|
94 *
|
nuclear@0
|
95 * WCHAR_MIN
|
nuclear@0
|
96 * WCHAR_MAX
|
nuclear@0
|
97 * (u)int64_t
|
nuclear@0
|
98 * PTRDIFF_MIN
|
nuclear@0
|
99 * PTRDIFF_MAX
|
nuclear@0
|
100 * (u)intptr_t
|
nuclear@0
|
101 *
|
nuclear@0
|
102 * 9) The following have not been defined:
|
nuclear@0
|
103 *
|
nuclear@0
|
104 * WINT_MIN
|
nuclear@0
|
105 * WINT_MAX
|
nuclear@0
|
106 *
|
nuclear@0
|
107 * 10) The criteria for defining (u)int_least(*)_t isn't clear,
|
nuclear@0
|
108 * except for systems which don't have a type that precisely
|
nuclear@0
|
109 * defined 8, 16, or 32 bit types (which this include file does
|
nuclear@0
|
110 * not support anyways). Default definitions have been given.
|
nuclear@0
|
111 *
|
nuclear@0
|
112 * 11) The criteria for defining (u)int_fast(*)_t isn't something I
|
nuclear@0
|
113 * would trust to any particular compiler vendor or the ANSI C
|
nuclear@0
|
114 * committee. It is well known that "compatible systems" are
|
nuclear@0
|
115 * commonly created that have very different performance
|
nuclear@0
|
116 * characteristics from the systems they are compatible with,
|
nuclear@0
|
117 * especially those whose vendors make both the compiler and the
|
nuclear@0
|
118 * system. Default definitions have been given, but its strongly
|
nuclear@0
|
119 * recommended that users never use these definitions for any
|
nuclear@0
|
120 * reason (they do *NOT* deliver any serious guarantee of
|
nuclear@0
|
121 * improved performance -- not in this file, nor any vendor's
|
nuclear@0
|
122 * stdint.h).
|
nuclear@0
|
123 *
|
nuclear@0
|
124 * 12) The following macros:
|
nuclear@0
|
125 *
|
nuclear@0
|
126 * PRINTF_INTMAX_MODIFIER
|
nuclear@0
|
127 * PRINTF_INT64_MODIFIER
|
nuclear@0
|
128 * PRINTF_INT32_MODIFIER
|
nuclear@0
|
129 * PRINTF_INT16_MODIFIER
|
nuclear@0
|
130 * PRINTF_LEAST64_MODIFIER
|
nuclear@0
|
131 * PRINTF_LEAST32_MODIFIER
|
nuclear@0
|
132 * PRINTF_LEAST16_MODIFIER
|
nuclear@0
|
133 * PRINTF_INTPTR_MODIFIER
|
nuclear@0
|
134 *
|
nuclear@0
|
135 * are strings which have been defined as the modifiers required
|
nuclear@0
|
136 * for the "d", "u" and "x" printf formats to correctly output
|
nuclear@0
|
137 * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
|
nuclear@0
|
138 * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
|
nuclear@0
|
139 * PRINTF_INTPTR_MODIFIER is not defined for some systems which
|
nuclear@0
|
140 * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
|
nuclear@0
|
141 * defined if INT64_MAX is not defined. These are an extension
|
nuclear@0
|
142 * beyond what C99 specifies must be in stdint.h.
|
nuclear@0
|
143 *
|
nuclear@0
|
144 * In addition, the following macros are defined:
|
nuclear@0
|
145 *
|
nuclear@0
|
146 * PRINTF_INTMAX_HEX_WIDTH
|
nuclear@0
|
147 * PRINTF_INT64_HEX_WIDTH
|
nuclear@0
|
148 * PRINTF_INT32_HEX_WIDTH
|
nuclear@0
|
149 * PRINTF_INT16_HEX_WIDTH
|
nuclear@0
|
150 * PRINTF_INT8_HEX_WIDTH
|
nuclear@0
|
151 * PRINTF_INTMAX_DEC_WIDTH
|
nuclear@0
|
152 * PRINTF_INT64_DEC_WIDTH
|
nuclear@0
|
153 * PRINTF_INT32_DEC_WIDTH
|
nuclear@0
|
154 * PRINTF_INT16_DEC_WIDTH
|
nuclear@0
|
155 * PRINTF_UINT8_DEC_WIDTH
|
nuclear@0
|
156 * PRINTF_UINTMAX_DEC_WIDTH
|
nuclear@0
|
157 * PRINTF_UINT64_DEC_WIDTH
|
nuclear@0
|
158 * PRINTF_UINT32_DEC_WIDTH
|
nuclear@0
|
159 * PRINTF_UINT16_DEC_WIDTH
|
nuclear@0
|
160 * PRINTF_UINT8_DEC_WIDTH
|
nuclear@0
|
161 *
|
nuclear@0
|
162 * Which specifies the maximum number of characters required to
|
nuclear@0
|
163 * print the number of that type in either hexadecimal or decimal.
|
nuclear@0
|
164 * These are an extension beyond what C99 specifies must be in
|
nuclear@0
|
165 * stdint.h.
|
nuclear@0
|
166 *
|
nuclear@0
|
167 * Compilers tested (all with 0 warnings at their highest respective
|
nuclear@0
|
168 * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
|
nuclear@0
|
169 * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
|
nuclear@0
|
170 * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
|
nuclear@0
|
171 *
|
nuclear@0
|
172 * This file should be considered a work in progress. Suggestions for
|
nuclear@0
|
173 * improvements, especially those which increase coverage are strongly
|
nuclear@0
|
174 * encouraged.
|
nuclear@0
|
175 *
|
nuclear@0
|
176 * Acknowledgements
|
nuclear@0
|
177 *
|
nuclear@0
|
178 * The following people have made significant contributions to the
|
nuclear@0
|
179 * development and testing of this file:
|
nuclear@0
|
180 *
|
nuclear@0
|
181 * Chris Howie
|
nuclear@0
|
182 * John Steele Scott
|
nuclear@0
|
183 * Dave Thorup
|
nuclear@0
|
184 * John Dill
|
nuclear@0
|
185 * Florian Wobbe
|
nuclear@0
|
186 * Christopher Sean Morrison
|
nuclear@0
|
187 * Mikkel Fahnoe Jorgensen
|
nuclear@0
|
188 *
|
nuclear@0
|
189 */
|
nuclear@0
|
190
|
nuclear@0
|
191 #include <stddef.h>
|
nuclear@0
|
192 #include <limits.h>
|
nuclear@0
|
193 #include <signal.h>
|
nuclear@0
|
194
|
nuclear@0
|
195 /*
|
nuclear@0
|
196 * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
|
nuclear@0
|
197 * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
|
nuclear@0
|
198 */
|
nuclear@0
|
199
|
nuclear@0
|
200 #if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
|
nuclear@0
|
201 #include <stdint.h>
|
nuclear@0
|
202 #define _PSTDINT_H_INCLUDED
|
nuclear@0
|
203 # if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
|
nuclear@0
|
204 # ifndef PRINTF_INT64_MODIFIER
|
nuclear@0
|
205 # define PRINTF_INT64_MODIFIER "l"
|
nuclear@0
|
206 # endif
|
nuclear@0
|
207 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
208 # define PRINTF_INT32_MODIFIER ""
|
nuclear@0
|
209 # endif
|
nuclear@0
|
210 # else
|
nuclear@0
|
211 # ifndef PRINTF_INT64_MODIFIER
|
nuclear@0
|
212 # define PRINTF_INT64_MODIFIER "ll"
|
nuclear@0
|
213 # endif
|
nuclear@0
|
214 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
215 # if (UINT_MAX == UINT32_MAX)
|
nuclear@0
|
216 # define PRINTF_INT32_MODIFIER ""
|
nuclear@0
|
217 # else
|
nuclear@0
|
218 # define PRINTF_INT32_MODIFIER "l"
|
nuclear@0
|
219 # endif
|
nuclear@0
|
220 # endif
|
nuclear@0
|
221 # endif
|
nuclear@0
|
222 # ifndef PRINTF_INT16_MODIFIER
|
nuclear@0
|
223 # define PRINTF_INT16_MODIFIER "h"
|
nuclear@0
|
224 # endif
|
nuclear@0
|
225 # ifndef PRINTF_INTMAX_MODIFIER
|
nuclear@0
|
226 # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
nuclear@0
|
227 # endif
|
nuclear@0
|
228 # ifndef PRINTF_INT64_HEX_WIDTH
|
nuclear@0
|
229 # define PRINTF_INT64_HEX_WIDTH "16"
|
nuclear@0
|
230 # endif
|
nuclear@0
|
231 # ifndef PRINTF_UINT64_HEX_WIDTH
|
nuclear@0
|
232 # define PRINTF_UINT64_HEX_WIDTH "16"
|
nuclear@0
|
233 # endif
|
nuclear@0
|
234 # ifndef PRINTF_INT32_HEX_WIDTH
|
nuclear@0
|
235 # define PRINTF_INT32_HEX_WIDTH "8"
|
nuclear@0
|
236 # endif
|
nuclear@0
|
237 # ifndef PRINTF_UINT32_HEX_WIDTH
|
nuclear@0
|
238 # define PRINTF_UINT32_HEX_WIDTH "8"
|
nuclear@0
|
239 # endif
|
nuclear@0
|
240 # ifndef PRINTF_INT16_HEX_WIDTH
|
nuclear@0
|
241 # define PRINTF_INT16_HEX_WIDTH "4"
|
nuclear@0
|
242 # endif
|
nuclear@0
|
243 # ifndef PRINTF_UINT16_HEX_WIDTH
|
nuclear@0
|
244 # define PRINTF_UINT16_HEX_WIDTH "4"
|
nuclear@0
|
245 # endif
|
nuclear@0
|
246 # ifndef PRINTF_INT8_HEX_WIDTH
|
nuclear@0
|
247 # define PRINTF_INT8_HEX_WIDTH "2"
|
nuclear@0
|
248 # endif
|
nuclear@0
|
249 # ifndef PRINTF_UINT8_HEX_WIDTH
|
nuclear@0
|
250 # define PRINTF_UINT8_HEX_WIDTH "2"
|
nuclear@0
|
251 # endif
|
nuclear@0
|
252 # ifndef PRINTF_INT64_DEC_WIDTH
|
nuclear@0
|
253 # define PRINTF_INT64_DEC_WIDTH "19"
|
nuclear@0
|
254 # endif
|
nuclear@0
|
255 # ifndef PRINTF_UINT64_DEC_WIDTH
|
nuclear@0
|
256 # define PRINTF_UINT64_DEC_WIDTH "20"
|
nuclear@0
|
257 # endif
|
nuclear@0
|
258 # ifndef PRINTF_INT32_DEC_WIDTH
|
nuclear@0
|
259 # define PRINTF_INT32_DEC_WIDTH "10"
|
nuclear@0
|
260 # endif
|
nuclear@0
|
261 # ifndef PRINTF_UINT32_DEC_WIDTH
|
nuclear@0
|
262 # define PRINTF_UINT32_DEC_WIDTH "10"
|
nuclear@0
|
263 # endif
|
nuclear@0
|
264 # ifndef PRINTF_INT16_DEC_WIDTH
|
nuclear@0
|
265 # define PRINTF_INT16_DEC_WIDTH "5"
|
nuclear@0
|
266 # endif
|
nuclear@0
|
267 # ifndef PRINTF_UINT16_DEC_WIDTH
|
nuclear@0
|
268 # define PRINTF_UINT16_DEC_WIDTH "5"
|
nuclear@0
|
269 # endif
|
nuclear@0
|
270 # ifndef PRINTF_INT8_DEC_WIDTH
|
nuclear@0
|
271 # define PRINTF_INT8_DEC_WIDTH "3"
|
nuclear@0
|
272 # endif
|
nuclear@0
|
273 # ifndef PRINTF_UINT8_DEC_WIDTH
|
nuclear@0
|
274 # define PRINTF_UINT8_DEC_WIDTH "3"
|
nuclear@0
|
275 # endif
|
nuclear@0
|
276 # ifndef PRINTF_INTMAX_HEX_WIDTH
|
nuclear@0
|
277 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
|
nuclear@0
|
278 # endif
|
nuclear@0
|
279 # ifndef PRINTF_UINTMAX_HEX_WIDTH
|
nuclear@0
|
280 # define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
|
nuclear@0
|
281 # endif
|
nuclear@0
|
282 # ifndef PRINTF_INTMAX_DEC_WIDTH
|
nuclear@0
|
283 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
|
nuclear@0
|
284 # endif
|
nuclear@0
|
285 # ifndef PRINTF_UINTMAX_DEC_WIDTH
|
nuclear@0
|
286 # define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
|
nuclear@0
|
287 # endif
|
nuclear@0
|
288
|
nuclear@0
|
289 /*
|
nuclear@0
|
290 * Something really weird is going on with Open Watcom. Just pull some of
|
nuclear@0
|
291 * these duplicated definitions from Open Watcom's stdint.h file for now.
|
nuclear@0
|
292 */
|
nuclear@0
|
293
|
nuclear@0
|
294 # if defined (__WATCOMC__) && __WATCOMC__ >= 1250
|
nuclear@0
|
295 # if !defined (INT64_C)
|
nuclear@0
|
296 # define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
|
nuclear@0
|
297 # endif
|
nuclear@0
|
298 # if !defined (UINT64_C)
|
nuclear@0
|
299 # define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
|
nuclear@0
|
300 # endif
|
nuclear@0
|
301 # if !defined (INT32_C)
|
nuclear@0
|
302 # define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
|
nuclear@0
|
303 # endif
|
nuclear@0
|
304 # if !defined (UINT32_C)
|
nuclear@0
|
305 # define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
|
nuclear@0
|
306 # endif
|
nuclear@0
|
307 # if !defined (INT16_C)
|
nuclear@0
|
308 # define INT16_C(x) (x)
|
nuclear@0
|
309 # endif
|
nuclear@0
|
310 # if !defined (UINT16_C)
|
nuclear@0
|
311 # define UINT16_C(x) (x)
|
nuclear@0
|
312 # endif
|
nuclear@0
|
313 # if !defined (INT8_C)
|
nuclear@0
|
314 # define INT8_C(x) (x)
|
nuclear@0
|
315 # endif
|
nuclear@0
|
316 # if !defined (UINT8_C)
|
nuclear@0
|
317 # define UINT8_C(x) (x)
|
nuclear@0
|
318 # endif
|
nuclear@0
|
319 # if !defined (UINT64_MAX)
|
nuclear@0
|
320 # define UINT64_MAX 18446744073709551615ULL
|
nuclear@0
|
321 # endif
|
nuclear@0
|
322 # if !defined (INT64_MAX)
|
nuclear@0
|
323 # define INT64_MAX 9223372036854775807LL
|
nuclear@0
|
324 # endif
|
nuclear@0
|
325 # if !defined (UINT32_MAX)
|
nuclear@0
|
326 # define UINT32_MAX 4294967295UL
|
nuclear@0
|
327 # endif
|
nuclear@0
|
328 # if !defined (INT32_MAX)
|
nuclear@0
|
329 # define INT32_MAX 2147483647L
|
nuclear@0
|
330 # endif
|
nuclear@0
|
331 # if !defined (INTMAX_MAX)
|
nuclear@0
|
332 # define INTMAX_MAX INT64_MAX
|
nuclear@0
|
333 # endif
|
nuclear@0
|
334 # if !defined (INTMAX_MIN)
|
nuclear@0
|
335 # define INTMAX_MIN INT64_MIN
|
nuclear@0
|
336 # endif
|
nuclear@0
|
337 # endif
|
nuclear@0
|
338 #endif
|
nuclear@0
|
339
|
nuclear@0
|
340 /*
|
nuclear@0
|
341 * I have no idea what is the truly correct thing to do on older Solaris.
|
nuclear@0
|
342 * From some online discussions, this seems to be what is being
|
nuclear@0
|
343 * recommended. For people who actually are developing on older Solaris,
|
nuclear@0
|
344 * what I would like to know is, does this define all of the relevant
|
nuclear@0
|
345 * macros of a complete stdint.h? Remember, in pstdint.h 64 bit is
|
nuclear@0
|
346 * considered optional.
|
nuclear@0
|
347 */
|
nuclear@0
|
348
|
nuclear@0
|
349 #if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)
|
nuclear@0
|
350 #include <sys/inttypes.h>
|
nuclear@0
|
351 #define _PSTDINT_H_INCLUDED
|
nuclear@0
|
352 #endif
|
nuclear@0
|
353
|
nuclear@0
|
354 #ifndef _PSTDINT_H_INCLUDED
|
nuclear@0
|
355 #define _PSTDINT_H_INCLUDED
|
nuclear@0
|
356
|
nuclear@0
|
357 #ifndef SIZE_MAX
|
nuclear@0
|
358 # define SIZE_MAX (~(size_t)0)
|
nuclear@0
|
359 #endif
|
nuclear@0
|
360
|
nuclear@0
|
361 /*
|
nuclear@0
|
362 * Deduce the type assignments from limits.h under the assumption that
|
nuclear@0
|
363 * integer sizes in bits are powers of 2, and follow the ANSI
|
nuclear@0
|
364 * definitions.
|
nuclear@0
|
365 */
|
nuclear@0
|
366
|
nuclear@0
|
367 #ifndef UINT8_MAX
|
nuclear@0
|
368 # define UINT8_MAX 0xff
|
nuclear@0
|
369 #endif
|
nuclear@0
|
370 #if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)
|
nuclear@0
|
371 # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
|
nuclear@0
|
372 typedef unsigned char uint8_t;
|
nuclear@0
|
373 # define UINT8_C(v) ((uint8_t) v)
|
nuclear@0
|
374 # else
|
nuclear@0
|
375 # error "Platform not supported"
|
nuclear@0
|
376 # endif
|
nuclear@0
|
377 #endif
|
nuclear@0
|
378
|
nuclear@0
|
379 #ifndef INT8_MAX
|
nuclear@0
|
380 # define INT8_MAX 0x7f
|
nuclear@0
|
381 #endif
|
nuclear@0
|
382 #ifndef INT8_MIN
|
nuclear@0
|
383 # define INT8_MIN INT8_C(0x80)
|
nuclear@0
|
384 #endif
|
nuclear@0
|
385 #if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)
|
nuclear@0
|
386 # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
|
nuclear@0
|
387 typedef signed char int8_t;
|
nuclear@0
|
388 # define INT8_C(v) ((int8_t) v)
|
nuclear@0
|
389 # else
|
nuclear@0
|
390 # error "Platform not supported"
|
nuclear@0
|
391 # endif
|
nuclear@0
|
392 #endif
|
nuclear@0
|
393
|
nuclear@0
|
394 #ifndef UINT16_MAX
|
nuclear@0
|
395 # define UINT16_MAX 0xffff
|
nuclear@0
|
396 #endif
|
nuclear@0
|
397 #if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)
|
nuclear@0
|
398 #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
|
nuclear@0
|
399 typedef unsigned int uint16_t;
|
nuclear@0
|
400 # ifndef PRINTF_INT16_MODIFIER
|
nuclear@0
|
401 # define PRINTF_INT16_MODIFIER ""
|
nuclear@0
|
402 # endif
|
nuclear@0
|
403 # define UINT16_C(v) ((uint16_t) (v))
|
nuclear@0
|
404 #elif (USHRT_MAX == UINT16_MAX)
|
nuclear@0
|
405 typedef unsigned short uint16_t;
|
nuclear@0
|
406 # define UINT16_C(v) ((uint16_t) (v))
|
nuclear@0
|
407 # ifndef PRINTF_INT16_MODIFIER
|
nuclear@0
|
408 # define PRINTF_INT16_MODIFIER "h"
|
nuclear@0
|
409 # endif
|
nuclear@0
|
410 #else
|
nuclear@0
|
411 #error "Platform not supported"
|
nuclear@0
|
412 #endif
|
nuclear@0
|
413 #endif
|
nuclear@0
|
414
|
nuclear@0
|
415 #ifndef INT16_MAX
|
nuclear@0
|
416 # define INT16_MAX 0x7fff
|
nuclear@0
|
417 #endif
|
nuclear@0
|
418 #ifndef INT16_MIN
|
nuclear@0
|
419 # define INT16_MIN INT16_C(0x8000)
|
nuclear@0
|
420 #endif
|
nuclear@0
|
421 #if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)
|
nuclear@0
|
422 #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
|
nuclear@0
|
423 typedef signed int int16_t;
|
nuclear@0
|
424 # define INT16_C(v) ((int16_t) (v))
|
nuclear@0
|
425 # ifndef PRINTF_INT16_MODIFIER
|
nuclear@0
|
426 # define PRINTF_INT16_MODIFIER ""
|
nuclear@0
|
427 # endif
|
nuclear@0
|
428 #elif (SHRT_MAX == INT16_MAX)
|
nuclear@0
|
429 typedef signed short int16_t;
|
nuclear@0
|
430 # define INT16_C(v) ((int16_t) (v))
|
nuclear@0
|
431 # ifndef PRINTF_INT16_MODIFIER
|
nuclear@0
|
432 # define PRINTF_INT16_MODIFIER "h"
|
nuclear@0
|
433 # endif
|
nuclear@0
|
434 #else
|
nuclear@0
|
435 #error "Platform not supported"
|
nuclear@0
|
436 #endif
|
nuclear@0
|
437 #endif
|
nuclear@0
|
438
|
nuclear@0
|
439 #ifndef UINT32_MAX
|
nuclear@0
|
440 # define UINT32_MAX (0xffffffffUL)
|
nuclear@0
|
441 #endif
|
nuclear@0
|
442 #if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)
|
nuclear@0
|
443 #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
|
nuclear@0
|
444 typedef unsigned long uint32_t;
|
nuclear@0
|
445 # define UINT32_C(v) v ## UL
|
nuclear@0
|
446 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
447 # define PRINTF_INT32_MODIFIER "l"
|
nuclear@0
|
448 # endif
|
nuclear@0
|
449 #elif (UINT_MAX == UINT32_MAX)
|
nuclear@0
|
450 typedef unsigned int uint32_t;
|
nuclear@0
|
451 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
452 # define PRINTF_INT32_MODIFIER ""
|
nuclear@0
|
453 # endif
|
nuclear@0
|
454 # define UINT32_C(v) v ## U
|
nuclear@0
|
455 #elif (USHRT_MAX == UINT32_MAX)
|
nuclear@0
|
456 typedef unsigned short uint32_t;
|
nuclear@0
|
457 # define UINT32_C(v) ((unsigned short) (v))
|
nuclear@0
|
458 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
459 # define PRINTF_INT32_MODIFIER ""
|
nuclear@0
|
460 # endif
|
nuclear@0
|
461 #else
|
nuclear@0
|
462 #error "Platform not supported"
|
nuclear@0
|
463 #endif
|
nuclear@0
|
464 #endif
|
nuclear@0
|
465
|
nuclear@0
|
466 #ifndef INT32_MAX
|
nuclear@0
|
467 # define INT32_MAX (0x7fffffffL)
|
nuclear@0
|
468 #endif
|
nuclear@0
|
469 #ifndef INT32_MIN
|
nuclear@0
|
470 # define INT32_MIN INT32_C(0x80000000)
|
nuclear@0
|
471 #endif
|
nuclear@0
|
472 #if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)
|
nuclear@0
|
473 #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
|
nuclear@0
|
474 typedef signed long int32_t;
|
nuclear@0
|
475 # define INT32_C(v) v ## L
|
nuclear@0
|
476 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
477 # define PRINTF_INT32_MODIFIER "l"
|
nuclear@0
|
478 # endif
|
nuclear@0
|
479 #elif (INT_MAX == INT32_MAX)
|
nuclear@0
|
480 typedef signed int int32_t;
|
nuclear@0
|
481 # define INT32_C(v) v
|
nuclear@0
|
482 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
483 # define PRINTF_INT32_MODIFIER ""
|
nuclear@0
|
484 # endif
|
nuclear@0
|
485 #elif (SHRT_MAX == INT32_MAX)
|
nuclear@0
|
486 typedef signed short int32_t;
|
nuclear@0
|
487 # define INT32_C(v) ((short) (v))
|
nuclear@0
|
488 # ifndef PRINTF_INT32_MODIFIER
|
nuclear@0
|
489 # define PRINTF_INT32_MODIFIER ""
|
nuclear@0
|
490 # endif
|
nuclear@0
|
491 #else
|
nuclear@0
|
492 #error "Platform not supported"
|
nuclear@0
|
493 #endif
|
nuclear@0
|
494 #endif
|
nuclear@0
|
495
|
nuclear@0
|
496 /*
|
nuclear@0
|
497 * The macro stdint_int64_defined is temporarily used to record
|
nuclear@0
|
498 * whether or not 64 integer support is available. It must be
|
nuclear@0
|
499 * defined for any 64 integer extensions for new platforms that are
|
nuclear@0
|
500 * added.
|
nuclear@0
|
501 */
|
nuclear@0
|
502
|
nuclear@0
|
503 #undef stdint_int64_defined
|
nuclear@0
|
504 #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
|
nuclear@0
|
505 # if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
|
nuclear@0
|
506 # define stdint_int64_defined
|
nuclear@0
|
507 typedef long long int64_t;
|
nuclear@0
|
508 typedef unsigned long long uint64_t;
|
nuclear@0
|
509 # define UINT64_C(v) v ## ULL
|
nuclear@0
|
510 # define INT64_C(v) v ## LL
|
nuclear@0
|
511 # ifndef PRINTF_INT64_MODIFIER
|
nuclear@0
|
512 # define PRINTF_INT64_MODIFIER "ll"
|
nuclear@0
|
513 # endif
|
nuclear@0
|
514 # endif
|
nuclear@0
|
515 #endif
|
nuclear@0
|
516
|
nuclear@0
|
517 #if !defined (stdint_int64_defined)
|
nuclear@0
|
518 # if defined(__GNUC__) && !defined(vxWorks)
|
nuclear@0
|
519 # define stdint_int64_defined
|
nuclear@0
|
520 __extension__ typedef long long int64_t;
|
nuclear@0
|
521 __extension__ typedef unsigned long long uint64_t;
|
nuclear@0
|
522 # define UINT64_C(v) v ## ULL
|
nuclear@0
|
523 # define INT64_C(v) v ## LL
|
nuclear@0
|
524 # ifndef PRINTF_INT64_MODIFIER
|
nuclear@0
|
525 # define PRINTF_INT64_MODIFIER "ll"
|
nuclear@0
|
526 # endif
|
nuclear@0
|
527 # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
|
nuclear@0
|
528 # define stdint_int64_defined
|
nuclear@0
|
529 typedef long long int64_t;
|
nuclear@0
|
530 typedef unsigned long long uint64_t;
|
nuclear@0
|
531 # define UINT64_C(v) v ## ULL
|
nuclear@0
|
532 # define INT64_C(v) v ## LL
|
nuclear@0
|
533 # ifndef PRINTF_INT64_MODIFIER
|
nuclear@0
|
534 # define PRINTF_INT64_MODIFIER "ll"
|
nuclear@0
|
535 # endif
|
nuclear@0
|
536 # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
|
nuclear@0
|
537 # define stdint_int64_defined
|
nuclear@0
|
538 typedef __int64 int64_t;
|
nuclear@0
|
539 typedef unsigned __int64 uint64_t;
|
nuclear@0
|
540 # define UINT64_C(v) v ## UI64
|
nuclear@0
|
541 # define INT64_C(v) v ## I64
|
nuclear@0
|
542 # ifndef PRINTF_INT64_MODIFIER
|
nuclear@0
|
543 # define PRINTF_INT64_MODIFIER "I64"
|
nuclear@0
|
544 # endif
|
nuclear@0
|
545 # endif
|
nuclear@0
|
546 #endif
|
nuclear@0
|
547
|
nuclear@0
|
548 #if !defined (LONG_LONG_MAX) && defined (INT64_C)
|
nuclear@0
|
549 # define LONG_LONG_MAX INT64_C (9223372036854775807)
|
nuclear@0
|
550 #endif
|
nuclear@0
|
551 #ifndef ULONG_LONG_MAX
|
nuclear@0
|
552 # define ULONG_LONG_MAX UINT64_C (18446744073709551615)
|
nuclear@0
|
553 #endif
|
nuclear@0
|
554
|
nuclear@0
|
555 #if !defined (INT64_MAX) && defined (INT64_C)
|
nuclear@0
|
556 # define INT64_MAX INT64_C (9223372036854775807)
|
nuclear@0
|
557 #endif
|
nuclear@0
|
558 #if !defined (INT64_MIN) && defined (INT64_C)
|
nuclear@0
|
559 # define INT64_MIN INT64_C (-9223372036854775808)
|
nuclear@0
|
560 #endif
|
nuclear@0
|
561 #if !defined (UINT64_MAX) && defined (INT64_C)
|
nuclear@0
|
562 # define UINT64_MAX UINT64_C (18446744073709551615)
|
nuclear@0
|
563 #endif
|
nuclear@0
|
564
|
nuclear@0
|
565 /*
|
nuclear@0
|
566 * Width of hexadecimal for number field.
|
nuclear@0
|
567 */
|
nuclear@0
|
568
|
nuclear@0
|
569 #ifndef PRINTF_INT64_HEX_WIDTH
|
nuclear@0
|
570 # define PRINTF_INT64_HEX_WIDTH "16"
|
nuclear@0
|
571 #endif
|
nuclear@0
|
572 #ifndef PRINTF_INT32_HEX_WIDTH
|
nuclear@0
|
573 # define PRINTF_INT32_HEX_WIDTH "8"
|
nuclear@0
|
574 #endif
|
nuclear@0
|
575 #ifndef PRINTF_INT16_HEX_WIDTH
|
nuclear@0
|
576 # define PRINTF_INT16_HEX_WIDTH "4"
|
nuclear@0
|
577 #endif
|
nuclear@0
|
578 #ifndef PRINTF_INT8_HEX_WIDTH
|
nuclear@0
|
579 # define PRINTF_INT8_HEX_WIDTH "2"
|
nuclear@0
|
580 #endif
|
nuclear@0
|
581 #ifndef PRINTF_INT64_DEC_WIDTH
|
nuclear@0
|
582 # define PRINTF_INT64_DEC_WIDTH "19"
|
nuclear@0
|
583 #endif
|
nuclear@0
|
584 #ifndef PRINTF_INT32_DEC_WIDTH
|
nuclear@0
|
585 # define PRINTF_INT32_DEC_WIDTH "10"
|
nuclear@0
|
586 #endif
|
nuclear@0
|
587 #ifndef PRINTF_INT16_DEC_WIDTH
|
nuclear@0
|
588 # define PRINTF_INT16_DEC_WIDTH "5"
|
nuclear@0
|
589 #endif
|
nuclear@0
|
590 #ifndef PRINTF_INT8_DEC_WIDTH
|
nuclear@0
|
591 # define PRINTF_INT8_DEC_WIDTH "3"
|
nuclear@0
|
592 #endif
|
nuclear@0
|
593 #ifndef PRINTF_UINT64_DEC_WIDTH
|
nuclear@0
|
594 # define PRINTF_UINT64_DEC_WIDTH "20"
|
nuclear@0
|
595 #endif
|
nuclear@0
|
596 #ifndef PRINTF_UINT32_DEC_WIDTH
|
nuclear@0
|
597 # define PRINTF_UINT32_DEC_WIDTH "10"
|
nuclear@0
|
598 #endif
|
nuclear@0
|
599 #ifndef PRINTF_UINT16_DEC_WIDTH
|
nuclear@0
|
600 # define PRINTF_UINT16_DEC_WIDTH "5"
|
nuclear@0
|
601 #endif
|
nuclear@0
|
602 #ifndef PRINTF_UINT8_DEC_WIDTH
|
nuclear@0
|
603 # define PRINTF_UINT8_DEC_WIDTH "3"
|
nuclear@0
|
604 #endif
|
nuclear@0
|
605
|
nuclear@0
|
606 /*
|
nuclear@0
|
607 * Ok, lets not worry about 128 bit integers for now. Moore's law says
|
nuclear@0
|
608 * we don't need to worry about that until about 2040 at which point
|
nuclear@0
|
609 * we'll have bigger things to worry about.
|
nuclear@0
|
610 */
|
nuclear@0
|
611
|
nuclear@0
|
612 #ifdef stdint_int64_defined
|
nuclear@0
|
613 typedef int64_t intmax_t;
|
nuclear@0
|
614 typedef uint64_t uintmax_t;
|
nuclear@0
|
615 # define INTMAX_MAX INT64_MAX
|
nuclear@0
|
616 # define INTMAX_MIN INT64_MIN
|
nuclear@0
|
617 # define UINTMAX_MAX UINT64_MAX
|
nuclear@0
|
618 # define UINTMAX_C(v) UINT64_C(v)
|
nuclear@0
|
619 # define INTMAX_C(v) INT64_C(v)
|
nuclear@0
|
620 # ifndef PRINTF_INTMAX_MODIFIER
|
nuclear@0
|
621 # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
nuclear@0
|
622 # endif
|
nuclear@0
|
623 # ifndef PRINTF_INTMAX_HEX_WIDTH
|
nuclear@0
|
624 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
|
nuclear@0
|
625 # endif
|
nuclear@0
|
626 # ifndef PRINTF_INTMAX_DEC_WIDTH
|
nuclear@0
|
627 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
|
nuclear@0
|
628 # endif
|
nuclear@0
|
629 #else
|
nuclear@0
|
630 typedef int32_t intmax_t;
|
nuclear@0
|
631 typedef uint32_t uintmax_t;
|
nuclear@0
|
632 # define INTMAX_MAX INT32_MAX
|
nuclear@0
|
633 # define UINTMAX_MAX UINT32_MAX
|
nuclear@0
|
634 # define UINTMAX_C(v) UINT32_C(v)
|
nuclear@0
|
635 # define INTMAX_C(v) INT32_C(v)
|
nuclear@0
|
636 # ifndef PRINTF_INTMAX_MODIFIER
|
nuclear@0
|
637 # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
|
nuclear@0
|
638 # endif
|
nuclear@0
|
639 # ifndef PRINTF_INTMAX_HEX_WIDTH
|
nuclear@0
|
640 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
|
nuclear@0
|
641 # endif
|
nuclear@0
|
642 # ifndef PRINTF_INTMAX_DEC_WIDTH
|
nuclear@0
|
643 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
|
nuclear@0
|
644 # endif
|
nuclear@0
|
645 #endif
|
nuclear@0
|
646
|
nuclear@0
|
647 /*
|
nuclear@0
|
648 * Because this file currently only supports platforms which have
|
nuclear@0
|
649 * precise powers of 2 as bit sizes for the default integers, the
|
nuclear@0
|
650 * least definitions are all trivial. Its possible that a future
|
nuclear@0
|
651 * version of this file could have different definitions.
|
nuclear@0
|
652 */
|
nuclear@0
|
653
|
nuclear@0
|
654 #ifndef stdint_least_defined
|
nuclear@0
|
655 typedef int8_t int_least8_t;
|
nuclear@0
|
656 typedef uint8_t uint_least8_t;
|
nuclear@0
|
657 typedef int16_t int_least16_t;
|
nuclear@0
|
658 typedef uint16_t uint_least16_t;
|
nuclear@0
|
659 typedef int32_t int_least32_t;
|
nuclear@0
|
660 typedef uint32_t uint_least32_t;
|
nuclear@0
|
661 # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
|
nuclear@0
|
662 # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
|
nuclear@0
|
663 # define UINT_LEAST8_MAX UINT8_MAX
|
nuclear@0
|
664 # define INT_LEAST8_MAX INT8_MAX
|
nuclear@0
|
665 # define UINT_LEAST16_MAX UINT16_MAX
|
nuclear@0
|
666 # define INT_LEAST16_MAX INT16_MAX
|
nuclear@0
|
667 # define UINT_LEAST32_MAX UINT32_MAX
|
nuclear@0
|
668 # define INT_LEAST32_MAX INT32_MAX
|
nuclear@0
|
669 # define INT_LEAST8_MIN INT8_MIN
|
nuclear@0
|
670 # define INT_LEAST16_MIN INT16_MIN
|
nuclear@0
|
671 # define INT_LEAST32_MIN INT32_MIN
|
nuclear@0
|
672 # ifdef stdint_int64_defined
|
nuclear@0
|
673 typedef int64_t int_least64_t;
|
nuclear@0
|
674 typedef uint64_t uint_least64_t;
|
nuclear@0
|
675 # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
|
nuclear@0
|
676 # define UINT_LEAST64_MAX UINT64_MAX
|
nuclear@0
|
677 # define INT_LEAST64_MAX INT64_MAX
|
nuclear@0
|
678 # define INT_LEAST64_MIN INT64_MIN
|
nuclear@0
|
679 # endif
|
nuclear@0
|
680 #endif
|
nuclear@0
|
681 #undef stdint_least_defined
|
nuclear@0
|
682
|
nuclear@0
|
683 /*
|
nuclear@0
|
684 * The ANSI C committee pretending to know or specify anything about
|
nuclear@0
|
685 * performance is the epitome of misguided arrogance. The mandate of
|
nuclear@0
|
686 * this file is to *ONLY* ever support that absolute minimum
|
nuclear@0
|
687 * definition of the fast integer types, for compatibility purposes.
|
nuclear@0
|
688 * No extensions, and no attempt to suggest what may or may not be a
|
nuclear@0
|
689 * faster integer type will ever be made in this file. Developers are
|
nuclear@0
|
690 * warned to stay away from these types when using this or any other
|
nuclear@0
|
691 * stdint.h.
|
nuclear@0
|
692 */
|
nuclear@0
|
693
|
nuclear@0
|
694 typedef int_least8_t int_fast8_t;
|
nuclear@0
|
695 typedef uint_least8_t uint_fast8_t;
|
nuclear@0
|
696 typedef int_least16_t int_fast16_t;
|
nuclear@0
|
697 typedef uint_least16_t uint_fast16_t;
|
nuclear@0
|
698 typedef int_least32_t int_fast32_t;
|
nuclear@0
|
699 typedef uint_least32_t uint_fast32_t;
|
nuclear@0
|
700 #define UINT_FAST8_MAX UINT_LEAST8_MAX
|
nuclear@0
|
701 #define INT_FAST8_MAX INT_LEAST8_MAX
|
nuclear@0
|
702 #define UINT_FAST16_MAX UINT_LEAST16_MAX
|
nuclear@0
|
703 #define INT_FAST16_MAX INT_LEAST16_MAX
|
nuclear@0
|
704 #define UINT_FAST32_MAX UINT_LEAST32_MAX
|
nuclear@0
|
705 #define INT_FAST32_MAX INT_LEAST32_MAX
|
nuclear@0
|
706 #define INT_FAST8_MIN INT_LEAST8_MIN
|
nuclear@0
|
707 #define INT_FAST16_MIN INT_LEAST16_MIN
|
nuclear@0
|
708 #define INT_FAST32_MIN INT_LEAST32_MIN
|
nuclear@0
|
709 #ifdef stdint_int64_defined
|
nuclear@0
|
710 typedef int_least64_t int_fast64_t;
|
nuclear@0
|
711 typedef uint_least64_t uint_fast64_t;
|
nuclear@0
|
712 # define UINT_FAST64_MAX UINT_LEAST64_MAX
|
nuclear@0
|
713 # define INT_FAST64_MAX INT_LEAST64_MAX
|
nuclear@0
|
714 # define INT_FAST64_MIN INT_LEAST64_MIN
|
nuclear@0
|
715 #endif
|
nuclear@0
|
716
|
nuclear@0
|
717 #undef stdint_int64_defined
|
nuclear@0
|
718
|
nuclear@0
|
719 /*
|
nuclear@0
|
720 * Whatever piecemeal, per compiler thing we can do about the wchar_t
|
nuclear@0
|
721 * type limits.
|
nuclear@0
|
722 */
|
nuclear@0
|
723
|
nuclear@0
|
724 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)
|
nuclear@0
|
725 # include <wchar.h>
|
nuclear@0
|
726 # ifndef WCHAR_MIN
|
nuclear@0
|
727 # define WCHAR_MIN 0
|
nuclear@0
|
728 # endif
|
nuclear@0
|
729 # ifndef WCHAR_MAX
|
nuclear@0
|
730 # define WCHAR_MAX ((wchar_t)-1)
|
nuclear@0
|
731 # endif
|
nuclear@0
|
732 #endif
|
nuclear@0
|
733
|
nuclear@0
|
734 /*
|
nuclear@0
|
735 * Whatever piecemeal, per compiler/platform thing we can do about the
|
nuclear@0
|
736 * (u)intptr_t types and limits.
|
nuclear@0
|
737 */
|
nuclear@0
|
738
|
nuclear@0
|
739 #if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
|
nuclear@0
|
740 # define STDINT_H_UINTPTR_T_DEFINED
|
nuclear@0
|
741 #endif
|
nuclear@0
|
742
|
nuclear@0
|
743 #ifndef STDINT_H_UINTPTR_T_DEFINED
|
nuclear@0
|
744 # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
|
nuclear@0
|
745 # define stdint_intptr_bits 64
|
nuclear@0
|
746 # elif defined (__WATCOMC__) || defined (__TURBOC__)
|
nuclear@0
|
747 # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
|
nuclear@0
|
748 # define stdint_intptr_bits 16
|
nuclear@0
|
749 # else
|
nuclear@0
|
750 # define stdint_intptr_bits 32
|
nuclear@0
|
751 # endif
|
nuclear@0
|
752 # elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
|
nuclear@0
|
753 # define stdint_intptr_bits 32
|
nuclear@0
|
754 # elif defined (__INTEL_COMPILER)
|
nuclear@0
|
755 /* TODO -- what did Intel do about x86-64? */
|
nuclear@0
|
756 # else
|
nuclear@0
|
757 /* #error "This platform might not be supported yet" */
|
nuclear@0
|
758 # endif
|
nuclear@0
|
759
|
nuclear@0
|
760 # ifdef stdint_intptr_bits
|
nuclear@0
|
761 # define stdint_intptr_glue3_i(a,b,c) a##b##c
|
nuclear@0
|
762 # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
|
nuclear@0
|
763 # ifndef PRINTF_INTPTR_MODIFIER
|
nuclear@0
|
764 # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
|
nuclear@0
|
765 # endif
|
nuclear@0
|
766 # ifndef PTRDIFF_MAX
|
nuclear@0
|
767 # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
nuclear@0
|
768 # endif
|
nuclear@0
|
769 # ifndef PTRDIFF_MIN
|
nuclear@0
|
770 # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
nuclear@0
|
771 # endif
|
nuclear@0
|
772 # ifndef UINTPTR_MAX
|
nuclear@0
|
773 # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
|
nuclear@0
|
774 # endif
|
nuclear@0
|
775 # ifndef INTPTR_MAX
|
nuclear@0
|
776 # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
nuclear@0
|
777 # endif
|
nuclear@0
|
778 # ifndef INTPTR_MIN
|
nuclear@0
|
779 # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
nuclear@0
|
780 # endif
|
nuclear@0
|
781 # ifndef INTPTR_C
|
nuclear@0
|
782 # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
|
nuclear@0
|
783 # endif
|
nuclear@0
|
784 # ifndef UINTPTR_C
|
nuclear@0
|
785 # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
|
nuclear@0
|
786 # endif
|
nuclear@0
|
787 typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
|
nuclear@0
|
788 typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
|
nuclear@0
|
789 # else
|
nuclear@0
|
790 /* TODO -- This following is likely wrong for some platforms, and does
|
nuclear@0
|
791 nothing for the definition of uintptr_t. */
|
nuclear@0
|
792 typedef ptrdiff_t intptr_t;
|
nuclear@0
|
793 # endif
|
nuclear@0
|
794 # define STDINT_H_UINTPTR_T_DEFINED
|
nuclear@0
|
795 #endif
|
nuclear@0
|
796
|
nuclear@0
|
797 /*
|
nuclear@0
|
798 * Assumes sig_atomic_t is signed and we have a 2s complement machine.
|
nuclear@0
|
799 */
|
nuclear@0
|
800
|
nuclear@0
|
801 #ifndef SIG_ATOMIC_MAX
|
nuclear@0
|
802 # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
|
nuclear@0
|
803 #endif
|
nuclear@0
|
804
|
nuclear@0
|
805 #endif
|
nuclear@0
|
806
|
nuclear@0
|
807 #if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
|
nuclear@0
|
808
|
nuclear@0
|
809 /*
|
nuclear@0
|
810 * Please compile with the maximum warning settings to make sure macros are
|
nuclear@0
|
811 * not defined more than once.
|
nuclear@0
|
812 */
|
nuclear@0
|
813
|
nuclear@0
|
814 #include <stdlib.h>
|
nuclear@0
|
815 #include <stdio.h>
|
nuclear@0
|
816 #include <string.h>
|
nuclear@0
|
817
|
nuclear@0
|
818 #define glue3_aux(x,y,z) x ## y ## z
|
nuclear@0
|
819 #define glue3(x,y,z) glue3_aux(x,y,z)
|
nuclear@0
|
820
|
nuclear@0
|
821 #define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
|
nuclear@0
|
822 #define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);
|
nuclear@0
|
823
|
nuclear@0
|
824 #define DECL(us,bits) glue3(DECL,us,) (bits)
|
nuclear@0
|
825
|
nuclear@0
|
826 #define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)
|
nuclear@0
|
827
|
nuclear@0
|
828 #define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }
|
nuclear@0
|
829
|
nuclear@0
|
830 int main () {
|
nuclear@0
|
831 int err_n = 0;
|
nuclear@0
|
832 int err_first = 0;
|
nuclear@0
|
833 DECL(I,8)
|
nuclear@0
|
834 DECL(U,8)
|
nuclear@0
|
835 DECL(I,16)
|
nuclear@0
|
836 DECL(U,16)
|
nuclear@0
|
837 DECL(I,32)
|
nuclear@0
|
838 DECL(U,32)
|
nuclear@0
|
839 #ifdef INT64_MAX
|
nuclear@0
|
840 DECL(I,64)
|
nuclear@0
|
841 DECL(U,64)
|
nuclear@0
|
842 #endif
|
nuclear@0
|
843 intmax_t imax = INTMAX_C(0);
|
nuclear@0
|
844 uintmax_t umax = UINTMAX_C(0);
|
nuclear@0
|
845 char str0[256], str1[256];
|
nuclear@0
|
846
|
nuclear@0
|
847 sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
|
nuclear@0
|
848 if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
|
nuclear@0
|
849 if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
|
nuclear@0
|
850 sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
|
nuclear@0
|
851 if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
|
nuclear@0
|
852 if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
|
nuclear@0
|
853 #ifdef INT64_MAX
|
nuclear@0
|
854 sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
|
nuclear@0
|
855 if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
|
nuclear@0
|
856 if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
|
nuclear@0
|
857 sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
|
nuclear@0
|
858 if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
|
nuclear@0
|
859 if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
|
nuclear@0
|
860 #endif
|
nuclear@0
|
861
|
nuclear@0
|
862 sprintf (str0, "%d %x\n", 0, ~0);
|
nuclear@0
|
863
|
nuclear@0
|
864 sprintf (str1, "%d %x\n", i8, ~0);
|
nuclear@0
|
865 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
|
nuclear@0
|
866 sprintf (str1, "%u %x\n", u8, ~0);
|
nuclear@0
|
867 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
|
nuclear@0
|
868 sprintf (str1, "%d %x\n", i16, ~0);
|
nuclear@0
|
869 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
|
nuclear@0
|
870 sprintf (str1, "%u %x\n", u16, ~0);
|
nuclear@0
|
871 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
|
nuclear@0
|
872 sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
|
nuclear@0
|
873 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
|
nuclear@0
|
874 sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
|
nuclear@0
|
875 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
|
nuclear@0
|
876 #ifdef INT64_MAX
|
nuclear@0
|
877 sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
|
nuclear@0
|
878 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
|
nuclear@0
|
879 #endif
|
nuclear@0
|
880 sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
|
nuclear@0
|
881 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
|
nuclear@0
|
882 sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
|
nuclear@0
|
883 if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));
|
nuclear@0
|
884
|
nuclear@0
|
885 TESTUMAX(8);
|
nuclear@0
|
886 TESTUMAX(16);
|
nuclear@0
|
887 TESTUMAX(32);
|
nuclear@0
|
888 #ifdef INT64_MAX
|
nuclear@0
|
889 TESTUMAX(64);
|
nuclear@0
|
890 #endif
|
nuclear@0
|
891
|
nuclear@0
|
892 #define STR(v) #v
|
nuclear@0
|
893 #define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
|
nuclear@0
|
894 if (err_n) {
|
nuclear@0
|
895 printf ("pstdint.h is not correct. Please use sizes below to correct it:\n");
|
nuclear@0
|
896 }
|
nuclear@0
|
897
|
nuclear@0
|
898 Q(int)
|
nuclear@0
|
899 Q(unsigned)
|
nuclear@0
|
900 Q(long int)
|
nuclear@0
|
901 Q(short int)
|
nuclear@0
|
902 Q(int8_t)
|
nuclear@0
|
903 Q(int16_t)
|
nuclear@0
|
904 Q(int32_t)
|
nuclear@0
|
905 #ifdef INT64_MAX
|
nuclear@0
|
906 Q(int64_t)
|
nuclear@0
|
907 #endif
|
nuclear@0
|
908
|
nuclear@0
|
909 return EXIT_SUCCESS;
|
nuclear@0
|
910 }
|
nuclear@0
|
911
|
nuclear@0
|
912 #endif
|