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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20