00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef MRPT_PSTDINT_H
00030 #define MRPT_PSTDINT_H
00031
00032 #include <stddef.h>
00033 #include <limits.h>
00034 #include <signal.h>
00035
00036
00037
00038
00039
00040
00041
00042 #if (\
00043 (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L)\
00044 || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250))\
00045 || defined(__GNUC__)\
00046 ) && !defined (_PSTDINT_H_INCLUDED)
00047
00048 #include <stdint.h>
00049 #define _PSTDINT_H_INCLUDED
00050 # ifndef PRINTF_INT64_MODIFIER
00051 # define PRINTF_INT64_MODIFIER "ll"
00052 # endif
00053 # ifndef PRINTF_INT32_MODIFIER
00054 # define PRINTF_INT32_MODIFIER "l"
00055 # endif
00056 # ifndef PRINTF_INT16_MODIFIER
00057 # define PRINTF_INT16_MODIFIER "h"
00058 # endif
00059 # ifndef PRINTF_INTMAX_MODIFIER
00060 # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
00061 # endif
00062 # ifndef PRINTF_INT64_HEX_WIDTH
00063 # define PRINTF_INT64_HEX_WIDTH "16"
00064 # endif
00065 # ifndef PRINTF_INT32_HEX_WIDTH
00066 # define PRINTF_INT32_HEX_WIDTH "8"
00067 # endif
00068 # ifndef PRINTF_INT16_HEX_WIDTH
00069 # define PRINTF_INT16_HEX_WIDTH "4"
00070 # endif
00071 # ifndef PRINTF_INT8_HEX_WIDTH
00072 # define PRINTF_INT8_HEX_WIDTH "2"
00073 # endif
00074 # ifndef PRINTF_INT64_DEC_WIDTH
00075 # define PRINTF_INT64_DEC_WIDTH "20"
00076 # endif
00077 # ifndef PRINTF_INT32_DEC_WIDTH
00078 # define PRINTF_INT32_DEC_WIDTH "10"
00079 # endif
00080 # ifndef PRINTF_INT16_DEC_WIDTH
00081 # define PRINTF_INT16_DEC_WIDTH "5"
00082 # endif
00083 # ifndef PRINTF_INT8_DEC_WIDTH
00084 # define PRINTF_INT8_DEC_WIDTH "3"
00085 # endif
00086 # ifndef PRINTF_INTMAX_HEX_WIDTH
00087 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
00088 # endif
00089 # ifndef PRINTF_INTMAX_DEC_WIDTH
00090 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
00091 # endif
00092
00093
00094
00095
00096
00097
00098 # if defined (__WATCOMC__) && __WATCOMC__ >= 1250
00099 # if !defined (INT64_C)
00100 # define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
00101 # endif
00102 # if !defined (UINT64_C)
00103 # define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
00104 # endif
00105 # if !defined (INT32_C)
00106 # define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
00107 # endif
00108 # if !defined (UINT32_C)
00109 # define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
00110 # endif
00111 # if !defined (INT16_C)
00112 # define INT16_C(x) (x)
00113 # endif
00114 # if !defined (UINT16_C)
00115 # define UINT16_C(x) (x)
00116 # endif
00117 # if !defined (INT8_C)
00118 # define INT8_C(x) (x)
00119 # endif
00120 # if !defined (UINT8_C)
00121 # define UINT8_C(x) (x)
00122 # endif
00123 # if !defined (UINT64_MAX)
00124 # define UINT64_MAX 18446744073709551615ULL
00125 # endif
00126 # if !defined (INT64_MAX)
00127 # define INT64_MAX 9223372036854775807LL
00128 # endif
00129 # if !defined (UINT32_MAX)
00130 # define UINT32_MAX 4294967295UL
00131 # endif
00132 # if !defined (INT32_MAX)
00133 # define INT32_MAX 2147483647L
00134 # endif
00135 # if !defined (INTMAX_MAX)
00136 # define INTMAX_MAX INT64_MAX
00137 # endif
00138 # if !defined (INTMAX_MIN)
00139 # define INTMAX_MIN INT64_MIN
00140 # endif
00141 # endif
00142 #endif
00143
00144 #ifndef _PSTDINT_H_INCLUDED
00145 #define _PSTDINT_H_INCLUDED
00146
00147 #ifndef SIZE_MAX
00148 # define SIZE_MAX (~(size_t)0)
00149 #endif
00150
00151
00152
00153
00154
00155
00156
00157 #ifndef UINT8_MAX
00158 # define UINT8_MAX 0xff
00159 #endif
00160 #ifndef uint8_t
00161 # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
00162 typedef unsigned char uint8_t;
00163 # define UINT8_C(v) ((uint8_t) v)
00164 # else
00165 # error "Platform not supported"
00166 # endif
00167 #endif
00168
00169 #ifndef INT8_MAX
00170 # define INT8_MAX 0x7f
00171 #endif
00172 #ifndef INT8_MIN
00173 # define INT8_MIN INT8_C(0x80)
00174 #endif
00175 #ifndef int8_t
00176 # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
00177 typedef signed char int8_t;
00178 # define INT8_C(v) ((int8_t) v)
00179 # else
00180 # error "Platform not supported"
00181 # endif
00182 #endif
00183
00184 #ifndef UINT16_MAX
00185 # define UINT16_MAX 0xffff
00186 #endif
00187 #ifndef uint16_t
00188 #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
00189 typedef unsigned int uint16_t;
00190 # ifndef PRINTF_INT16_MODIFIER
00191 # define PRINTF_INT16_MODIFIER ""
00192 # endif
00193 # define UINT16_C(v) ((uint16_t) (v))
00194 #elif (USHRT_MAX == UINT16_MAX)
00195 typedef unsigned short uint16_t;
00196 # define UINT16_C(v) ((uint16_t) (v))
00197 # ifndef PRINTF_INT16_MODIFIER
00198 # define PRINTF_INT16_MODIFIER "h"
00199 # endif
00200 #else
00201 #error "Platform not supported"
00202 #endif
00203 #endif
00204
00205 #ifndef INT16_MAX
00206 # define INT16_MAX 0x7fff
00207 #endif
00208 #ifndef INT16_MIN
00209 # define INT16_MIN INT16_C(0x8000)
00210 #endif
00211 #ifndef int16_t
00212 #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
00213 typedef signed int int16_t;
00214 # define INT16_C(v) ((int16_t) (v))
00215 # ifndef PRINTF_INT16_MODIFIER
00216 # define PRINTF_INT16_MODIFIER ""
00217 # endif
00218 #elif (SHRT_MAX == INT16_MAX)
00219 typedef signed short int16_t;
00220 # define INT16_C(v) ((int16_t) (v))
00221 # ifndef PRINTF_INT16_MODIFIER
00222 # define PRINTF_INT16_MODIFIER "h"
00223 # endif
00224 #else
00225 #error "Platform not supported"
00226 #endif
00227 #endif
00228
00229 #ifndef UINT32_MAX
00230 # define UINT32_MAX (0xffffffffUL)
00231 #endif
00232 #ifndef uint32_t
00233 #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
00234 typedef unsigned long uint32_t;
00235 # define UINT32_C(v) v ## UL
00236 # ifndef PRINTF_INT32_MODIFIER
00237 # define PRINTF_INT32_MODIFIER "l"
00238 # endif
00239 #elif (UINT_MAX == UINT32_MAX)
00240 typedef unsigned int uint32_t;
00241 # ifndef PRINTF_INT32_MODIFIER
00242 # define PRINTF_INT32_MODIFIER ""
00243 # endif
00244 # define UINT32_C(v) v ## U
00245 #elif (USHRT_MAX == UINT32_MAX)
00246 typedef unsigned short uint32_t;
00247 # define UINT32_C(v) ((unsigned short) (v))
00248 # ifndef PRINTF_INT32_MODIFIER
00249 # define PRINTF_INT32_MODIFIER ""
00250 # endif
00251 #else
00252 #error "Platform not supported"
00253 #endif
00254 #endif
00255
00256 #ifndef INT32_MAX
00257 # define INT32_MAX (0x7fffffffL)
00258 #endif
00259 #ifndef INT32_MIN
00260 # define INT32_MIN INT32_C(0x80000000)
00261 #endif
00262 #ifndef int32_t
00263 #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
00264 typedef signed long int32_t;
00265 # define INT32_C(v) v ## L
00266 # ifndef PRINTF_INT32_MODIFIER
00267 # define PRINTF_INT32_MODIFIER "l"
00268 # endif
00269 #elif (INT_MAX == INT32_MAX)
00270 typedef signed int int32_t;
00271 # define INT32_C(v) v
00272 # ifndef PRINTF_INT32_MODIFIER
00273 # define PRINTF_INT32_MODIFIER ""
00274 # endif
00275 #elif (SHRT_MAX == INT32_MAX)
00276 typedef signed short int32_t;
00277 # define INT32_C(v) ((short) (v))
00278 # ifndef PRINTF_INT32_MODIFIER
00279 # define PRINTF_INT32_MODIFIER ""
00280 # endif
00281 #else
00282 #error "Platform not supported"
00283 #endif
00284 #endif
00285
00286
00287
00288
00289
00290
00291
00292
00293 #undef stdint_int64_defined
00294 #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
00295 # if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S)
00296 # define stdint_int64_defined
00297 typedef long long int64_t;
00298 typedef unsigned long long uint64_t;
00299 # define UINT64_C(v) v ## ULL
00300 # define INT64_C(v) v ## LL
00301 # ifndef PRINTF_INT64_MODIFIER
00302 # define PRINTF_INT64_MODIFIER "ll"
00303 # endif
00304 # endif
00305 #endif
00306
00307 #if !defined (stdint_int64_defined)
00308 # if defined(__GNUC__)
00309 # define stdint_int64_defined
00310 __extension__ typedef long long int64_t;
00311 __extension__ typedef unsigned long long uint64_t;
00312 # define UINT64_C(v) v ## ULL
00313 # define INT64_C(v) v ## LL
00314 # ifndef PRINTF_INT64_MODIFIER
00315 # define PRINTF_INT64_MODIFIER "ll"
00316 # endif
00317 # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
00318 # define stdint_int64_defined
00319 typedef long long int64_t;
00320 typedef unsigned long long uint64_t;
00321 # define UINT64_C(v) v ## ULL
00322 # define INT64_C(v) v ## LL
00323 # ifndef PRINTF_INT64_MODIFIER
00324 # define PRINTF_INT64_MODIFIER "ll"
00325 # endif
00326 # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
00327 # define stdint_int64_defined
00328 typedef __int64 int64_t;
00329 typedef unsigned __int64 uint64_t;
00330 # define UINT64_C(v) v ## UI64
00331 # define INT64_C(v) v ## I64
00332 # ifndef PRINTF_INT64_MODIFIER
00333 # define PRINTF_INT64_MODIFIER "I64"
00334 # endif
00335 # endif
00336 #endif
00337
00338 #if !defined (LONG_LONG_MAX) && defined (INT64_C)
00339 # define LONG_LONG_MAX INT64_C (9223372036854775807)
00340 #endif
00341 #ifndef ULONG_LONG_MAX
00342 # define ULONG_LONG_MAX UINT64_C (18446744073709551615)
00343 #endif
00344
00345 #if !defined (INT64_MAX) && defined (INT64_C)
00346 # define INT64_MAX INT64_C (9223372036854775807)
00347 #endif
00348 #if !defined (INT64_MIN) && defined (INT64_C)
00349 # define INT64_MIN INT64_C (-9223372036854775808)
00350 #endif
00351 #if !defined (UINT64_MAX) && defined (INT64_C)
00352 # define UINT64_MAX UINT64_C (18446744073709551615)
00353 #endif
00354
00355
00356
00357
00358
00359 #ifndef PRINTF_INT64_HEX_WIDTH
00360 # define PRINTF_INT64_HEX_WIDTH "16"
00361 #endif
00362 #ifndef PRINTF_INT32_HEX_WIDTH
00363 # define PRINTF_INT32_HEX_WIDTH "8"
00364 #endif
00365 #ifndef PRINTF_INT16_HEX_WIDTH
00366 # define PRINTF_INT16_HEX_WIDTH "4"
00367 #endif
00368 #ifndef PRINTF_INT8_HEX_WIDTH
00369 # define PRINTF_INT8_HEX_WIDTH "2"
00370 #endif
00371
00372 #ifndef PRINTF_INT64_DEC_WIDTH
00373 # define PRINTF_INT64_DEC_WIDTH "20"
00374 #endif
00375 #ifndef PRINTF_INT32_DEC_WIDTH
00376 # define PRINTF_INT32_DEC_WIDTH "10"
00377 #endif
00378 #ifndef PRINTF_INT16_DEC_WIDTH
00379 # define PRINTF_INT16_DEC_WIDTH "5"
00380 #endif
00381 #ifndef PRINTF_INT8_DEC_WIDTH
00382 # define PRINTF_INT8_DEC_WIDTH "3"
00383 #endif
00384
00385
00386
00387
00388
00389
00390
00391 #ifdef stdint_int64_defined
00392 typedef int64_t intmax_t;
00393 typedef uint64_t uintmax_t;
00394 # define INTMAX_MAX INT64_MAX
00395 # define INTMAX_MIN INT64_MIN
00396 # define UINTMAX_MAX UINT64_MAX
00397 # define UINTMAX_C(v) UINT64_C(v)
00398 # define INTMAX_C(v) INT64_C(v)
00399 # ifndef PRINTF_INTMAX_MODIFIER
00400 # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
00401 # endif
00402 # ifndef PRINTF_INTMAX_HEX_WIDTH
00403 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
00404 # endif
00405 # ifndef PRINTF_INTMAX_DEC_WIDTH
00406 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
00407 # endif
00408 #else
00409 typedef int32_t intmax_t;
00410 typedef uint32_t uintmax_t;
00411 # define INTMAX_MAX INT32_MAX
00412 # define UINTMAX_MAX UINT32_MAX
00413 # define UINTMAX_C(v) UINT32_C(v)
00414 # define INTMAX_C(v) INT32_C(v)
00415 # ifndef PRINTF_INTMAX_MODIFIER
00416 # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
00417 # endif
00418 # ifndef PRINTF_INTMAX_HEX_WIDTH
00419 # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
00420 # endif
00421 # ifndef PRINTF_INTMAX_DEC_WIDTH
00422 # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
00423 # endif
00424 #endif
00425
00426
00427
00428
00429
00430
00431
00432
00433 #ifndef stdint_least_defined
00434 typedef int8_t int_least8_t;
00435 typedef uint8_t uint_least8_t;
00436 typedef int16_t int_least16_t;
00437 typedef uint16_t uint_least16_t;
00438 typedef int32_t int_least32_t;
00439 typedef uint32_t uint_least32_t;
00440 # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
00441 # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
00442 # define UINT_LEAST8_MAX UINT8_MAX
00443 # define INT_LEAST8_MAX INT8_MAX
00444 # define UINT_LEAST16_MAX UINT16_MAX
00445 # define INT_LEAST16_MAX INT16_MAX
00446 # define UINT_LEAST32_MAX UINT32_MAX
00447 # define INT_LEAST32_MAX INT32_MAX
00448 # define INT_LEAST8_MIN INT8_MIN
00449 # define INT_LEAST16_MIN INT16_MIN
00450 # define INT_LEAST32_MIN INT32_MIN
00451 # ifdef stdint_int64_defined
00452 typedef int64_t int_least64_t;
00453 typedef uint64_t uint_least64_t;
00454 # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
00455 # define UINT_LEAST64_MAX UINT64_MAX
00456 # define INT_LEAST64_MAX INT64_MAX
00457 # define INT_LEAST64_MIN INT64_MIN
00458 # endif
00459 #endif
00460 #undef stdint_least_defined
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 typedef int_least8_t int_fast8_t;
00474 typedef uint_least8_t uint_fast8_t;
00475 typedef int_least16_t int_fast16_t;
00476 typedef uint_least16_t uint_fast16_t;
00477 typedef int_least32_t int_fast32_t;
00478 typedef uint_least32_t uint_fast32_t;
00479 #define UINT_FAST8_MAX UINT_LEAST8_MAX
00480 #define INT_FAST8_MAX INT_LEAST8_MAX
00481 #define UINT_FAST16_MAX UINT_LEAST16_MAX
00482 #define INT_FAST16_MAX INT_LEAST16_MAX
00483 #define UINT_FAST32_MAX UINT_LEAST32_MAX
00484 #define INT_FAST32_MAX INT_LEAST32_MAX
00485 #define INT_FAST8_MIN INT_LEAST8_MIN
00486 #define INT_FAST16_MIN INT_LEAST16_MIN
00487 #define INT_FAST32_MIN INT_LEAST32_MIN
00488 #ifdef stdint_int64_defined
00489 typedef int_least64_t int_fast64_t;
00490 typedef uint_least64_t uint_fast64_t;
00491 # define UINT_FAST64_MAX UINT_LEAST64_MAX
00492 # define INT_FAST64_MAX INT_LEAST64_MAX
00493 # define INT_FAST64_MIN INT_LEAST64_MIN
00494 #endif
00495
00496 #undef stdint_int64_defined
00497
00498
00499
00500
00501
00502
00503 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
00504 # include <wchar.h>
00505 # ifndef WCHAR_MIN
00506 # define WCHAR_MIN 0
00507 # endif
00508 # ifndef WCHAR_MAX
00509 # define WCHAR_MAX ((wchar_t)-1)
00510 # endif
00511 #endif
00512
00513
00514
00515
00516
00517
00518 #if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
00519 # define STDINT_H_UINTPTR_T_DEFINED
00520 #endif
00521
00522 #ifndef STDINT_H_UINTPTR_T_DEFINED
00523 # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
00524 # define stdint_intptr_bits 64
00525 # elif defined (__WATCOMC__) || defined (__TURBOC__)
00526 # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
00527 # define stdint_intptr_bits 16
00528 # else
00529 # define stdint_intptr_bits 32
00530 # endif
00531 # elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
00532 # define stdint_intptr_bits 32
00533 # elif defined (__INTEL_COMPILER)
00534
00535 # endif
00536
00537 # ifdef stdint_intptr_bits
00538 # define stdint_intptr_glue3_i(a,b,c) a##b##c
00539 # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
00540 # ifndef PRINTF_INTPTR_MODIFIER
00541 # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
00542 # endif
00543 # ifndef PTRDIFF_MAX
00544 # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
00545 # endif
00546 # ifndef PTRDIFF_MIN
00547 # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
00548 # endif
00549 # ifndef UINTPTR_MAX
00550 # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
00551 # endif
00552 # ifndef INTPTR_MAX
00553 # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
00554 # endif
00555 # ifndef INTPTR_MIN
00556 # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
00557 # endif
00558 # ifndef INTPTR_C
00559 # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
00560 # endif
00561 # ifndef UINTPTR_C
00562 # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
00563 # endif
00564 typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t)* uintptr_t;
00565 typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t)* intptr_t;
00566 # else
00567
00568
00569 typedef ptrdiff_t intptr_t;
00570 # endif
00571 # define STDINT_H_UINTPTR_T_DEFINED
00572 #endif
00573
00574
00575
00576
00577
00578 #ifndef SIG_ATOMIC_MAX
00579 # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
00580 #endif
00581
00582 #endif
00583
00584 #endif // guard
00585