194 #if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED) 
  196 #define _PSTDINT_H_INCLUDED 
  197 # ifndef PRINTF_INT64_MODIFIER 
  198 #  define PRINTF_INT64_MODIFIER "ll" 
  200 # ifndef PRINTF_INT32_MODIFIER 
  201 #  define PRINTF_INT32_MODIFIER "l" 
  203 # ifndef PRINTF_INT16_MODIFIER 
  204 #  define PRINTF_INT16_MODIFIER "h" 
  206 # ifndef PRINTF_INTMAX_MODIFIER 
  207 #  define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER 
  209 # ifndef PRINTF_INT64_HEX_WIDTH 
  210 #  define PRINTF_INT64_HEX_WIDTH "16" 
  212 # ifndef PRINTF_INT32_HEX_WIDTH 
  213 #  define PRINTF_INT32_HEX_WIDTH "8" 
  215 # ifndef PRINTF_INT16_HEX_WIDTH 
  216 #  define PRINTF_INT16_HEX_WIDTH "4" 
  218 # ifndef PRINTF_INT8_HEX_WIDTH 
  219 #  define PRINTF_INT8_HEX_WIDTH "2" 
  221 # ifndef PRINTF_INT64_DEC_WIDTH 
  222 #  define PRINTF_INT64_DEC_WIDTH "20" 
  224 # ifndef PRINTF_INT32_DEC_WIDTH 
  225 #  define PRINTF_INT32_DEC_WIDTH "10" 
  227 # ifndef PRINTF_INT16_DEC_WIDTH 
  228 #  define PRINTF_INT16_DEC_WIDTH "5" 
  230 # ifndef PRINTF_INT8_DEC_WIDTH 
  231 #  define PRINTF_INT8_DEC_WIDTH "3" 
  233 # ifndef PRINTF_INTMAX_HEX_WIDTH 
  234 #  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH 
  236 # ifndef PRINTF_INTMAX_DEC_WIDTH 
  237 #  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH 
  245 # if defined (__WATCOMC__) && __WATCOMC__ >= 1250 
  246 #  if !defined (INT64_C) 
  247 #   define INT64_C(x)   (x + (INT64_MAX - INT64_MAX)) 
  249 #  if !defined (UINT64_C) 
  250 #   define UINT64_C(x)  (x + (UINT64_MAX - UINT64_MAX)) 
  252 #  if !defined (INT32_C) 
  253 #   define INT32_C(x)   (x + (INT32_MAX - INT32_MAX)) 
  255 #  if !defined (UINT32_C) 
  256 #   define UINT32_C(x)  (x + (UINT32_MAX - UINT32_MAX)) 
  258 #  if !defined (INT16_C) 
  259 #   define INT16_C(x)   (x) 
  261 #  if !defined (UINT16_C) 
  262 #   define UINT16_C(x)  (x) 
  264 #  if !defined (INT8_C) 
  265 #   define INT8_C(x)   (x) 
  267 #  if !defined (UINT8_C) 
  268 #   define UINT8_C(x)  (x) 
  270 #  if !defined (UINT64_MAX) 
  271 #   define UINT64_MAX  18446744073709551615ULL 
  273 #  if !defined (INT64_MAX) 
  274 #   define INT64_MAX  9223372036854775807LL 
  276 #  if !defined (UINT32_MAX) 
  277 #   define UINT32_MAX  4294967295UL 
  279 #  if !defined (INT32_MAX) 
  280 #   define INT32_MAX  2147483647L 
  282 #  if !defined (INTMAX_MAX) 
  283 #   define INTMAX_MAX INT64_MAX 
  285 #  if !defined (INTMAX_MIN) 
  286 #   define INTMAX_MIN INT64_MIN 
  291 #ifndef _PSTDINT_H_INCLUDED 
  292 #define _PSTDINT_H_INCLUDED 
  295 # define SIZE_MAX (~(size_t)0) 
  305 # define UINT8_MAX 0xff 
  308 # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) 
  309     typedef unsigned char uint8_t;
 
  310 #   define UINT8_C(v) ((uint8_t) v) 
  312 #   error "Platform not supported" 
  317 # define INT8_MAX 0x7f 
  320 # define INT8_MIN INT8_C(0x80) 
  323 # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) 
  324     typedef signed char int8_t;
 
  325 #   define INT8_C(v) ((int8_t) v) 
  327 #   error "Platform not supported" 
  332 # define UINT16_MAX 0xffff 
  335 #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) 
  336   typedef unsigned int uint16_t;
 
  337 # ifndef PRINTF_INT16_MODIFIER 
  338 #  define PRINTF_INT16_MODIFIER "" 
  340 # define UINT16_C(v) ((uint16_t) (v)) 
  341 #elif (USHRT_MAX == UINT16_MAX) 
  342   typedef unsigned short uint16_t;
 
  343 # define UINT16_C(v) ((uint16_t) (v)) 
  344 # ifndef PRINTF_INT16_MODIFIER 
  345 #  define PRINTF_INT16_MODIFIER "h" 
  348 #error "Platform not supported" 
  353 # define INT16_MAX 0x7fff 
  356 # define INT16_MIN INT16_C(0x8000) 
  359 #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) 
  360   typedef signed int int16_t;
 
  361 # define INT16_C(v) ((int16_t) (v)) 
  362 # ifndef PRINTF_INT16_MODIFIER 
  363 #  define PRINTF_INT16_MODIFIER "" 
  365 #elif (SHRT_MAX == INT16_MAX) 
  366   typedef signed short int16_t;
 
  367 # define INT16_C(v) ((int16_t) (v)) 
  368 # ifndef PRINTF_INT16_MODIFIER 
  369 #  define PRINTF_INT16_MODIFIER "h" 
  372 #error "Platform not supported" 
  377 # define UINT32_MAX (0xffffffffUL) 
  380 #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) 
  381   typedef unsigned long uint32_t;
 
  382 # define UINT32_C(v) v ## UL 
  383 # ifndef PRINTF_INT32_MODIFIER 
  384 #  define PRINTF_INT32_MODIFIER "l" 
  386 #elif (UINT_MAX == UINT32_MAX) 
  387   typedef unsigned int uint32_t;
 
  388 # ifndef PRINTF_INT32_MODIFIER 
  389 #  define PRINTF_INT32_MODIFIER "" 
  391 # define UINT32_C(v) v ## U 
  392 #elif (USHRT_MAX == UINT32_MAX) 
  393   typedef unsigned short uint32_t;
 
  394 # define UINT32_C(v) ((unsigned short) (v)) 
  395 # ifndef PRINTF_INT32_MODIFIER 
  396 #  define PRINTF_INT32_MODIFIER "" 
  399 #error "Platform not supported" 
  404 # define INT32_MAX (0x7fffffffL) 
  407 # define INT32_MIN INT32_C(0x80000000) 
  410 #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) 
  411   typedef signed long int32_t;
 
  412 # define INT32_C(v) v ## L 
  413 # ifndef PRINTF_INT32_MODIFIER 
  414 #  define PRINTF_INT32_MODIFIER "l" 
  416 #elif (INT_MAX == INT32_MAX) 
  417   typedef signed int int32_t;
 
  418 # define INT32_C(v) v 
  419 # ifndef PRINTF_INT32_MODIFIER 
  420 #  define PRINTF_INT32_MODIFIER "" 
  422 #elif (SHRT_MAX == INT32_MAX) 
  423   typedef signed short int32_t;
 
  424 # define INT32_C(v) ((short) (v)) 
  425 # ifndef PRINTF_INT32_MODIFIER 
  426 #  define PRINTF_INT32_MODIFIER "" 
  429 #error "Platform not supported" 
  440 #undef stdint_int64_defined 
  441 #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) 
  442 # if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S) 
  443 #  define stdint_int64_defined 
  444    typedef long long int64_t;
 
  445    typedef unsigned long long uint64_t;
 
  446 #  define UINT64_C(v) v ## ULL 
  447 #  define  INT64_C(v) v ## LL 
  448 #  ifndef PRINTF_INT64_MODIFIER 
  449 #   define PRINTF_INT64_MODIFIER "ll" 
  454 #if !defined (stdint_int64_defined) 
  455 # if defined(__GNUC__) 
  456 #  define stdint_int64_defined 
  457    __extension__ 
typedef long long int64_t;
 
  458    __extension__ 
typedef unsigned long long uint64_t;
 
  459 #  define UINT64_C(v) v ## ULL 
  460 #  define  INT64_C(v) v ## LL 
  461 #  ifndef PRINTF_INT64_MODIFIER 
  462 #   define PRINTF_INT64_MODIFIER "ll" 
  464 # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) 
  465 #  define stdint_int64_defined 
  466    typedef long long int64_t;
 
  467    typedef unsigned long long uint64_t;
 
  468 #  define UINT64_C(v) v ## ULL 
  469 #  define  INT64_C(v) v ## LL 
  470 #  ifndef PRINTF_INT64_MODIFIER 
  471 #   define PRINTF_INT64_MODIFIER "ll" 
  473 # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) 
  474 #  define stdint_int64_defined 
  475    typedef __int64 int64_t;
 
  476    typedef unsigned __int64 uint64_t;
 
  477 #  define UINT64_C(v) v ## UI64 
  478 #  define  INT64_C(v) v ## I64 
  479 #  ifndef PRINTF_INT64_MODIFIER 
  480 #   define PRINTF_INT64_MODIFIER "I64" 
  485 #if !defined (LONG_LONG_MAX) && defined (INT64_C) 
  486 # define LONG_LONG_MAX INT64_C (9223372036854775807) 
  488 #ifndef ULONG_LONG_MAX 
  489 # define ULONG_LONG_MAX UINT64_C (18446744073709551615) 
  492 #if !defined (INT64_MAX) && defined (INT64_C) 
  493 # define INT64_MAX INT64_C (9223372036854775807) 
  495 #if !defined (INT64_MIN) && defined (INT64_C) 
  496 # define INT64_MIN INT64_C (-9223372036854775808) 
  498 #if !defined (UINT64_MAX) && defined (INT64_C) 
  499 # define UINT64_MAX UINT64_C (18446744073709551615) 
  506 #ifndef PRINTF_INT64_HEX_WIDTH 
  507 # define PRINTF_INT64_HEX_WIDTH "16" 
  509 #ifndef PRINTF_INT32_HEX_WIDTH 
  510 # define PRINTF_INT32_HEX_WIDTH "8" 
  512 #ifndef PRINTF_INT16_HEX_WIDTH 
  513 # define PRINTF_INT16_HEX_WIDTH "4" 
  515 #ifndef PRINTF_INT8_HEX_WIDTH 
  516 # define PRINTF_INT8_HEX_WIDTH "2" 
  519 #ifndef PRINTF_INT64_DEC_WIDTH 
  520 # define PRINTF_INT64_DEC_WIDTH "20" 
  522 #ifndef PRINTF_INT32_DEC_WIDTH 
  523 # define PRINTF_INT32_DEC_WIDTH "10" 
  525 #ifndef PRINTF_INT16_DEC_WIDTH 
  526 # define PRINTF_INT16_DEC_WIDTH "5" 
  528 #ifndef PRINTF_INT8_DEC_WIDTH 
  529 # define PRINTF_INT8_DEC_WIDTH "3" 
  538 #ifdef stdint_int64_defined 
  539   typedef int64_t intmax_t;
 
  540   typedef uint64_t uintmax_t;
 
  541 # define  INTMAX_MAX   INT64_MAX 
  542 # define  INTMAX_MIN   INT64_MIN 
  543 # define UINTMAX_MAX  UINT64_MAX 
  544 # define UINTMAX_C(v) UINT64_C(v) 
  545 # define  INTMAX_C(v)  INT64_C(v) 
  546 # ifndef PRINTF_INTMAX_MODIFIER 
  547 #   define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER 
  549 # ifndef PRINTF_INTMAX_HEX_WIDTH 
  550 #  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH 
  552 # ifndef PRINTF_INTMAX_DEC_WIDTH 
  553 #  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH 
  556   typedef int32_t intmax_t;
 
  557   typedef uint32_t uintmax_t;
 
  558 # define  INTMAX_MAX   INT32_MAX 
  559 # define UINTMAX_MAX  UINT32_MAX 
  560 # define UINTMAX_C(v) UINT32_C(v) 
  561 # define  INTMAX_C(v)  INT32_C(v) 
  562 # ifndef PRINTF_INTMAX_MODIFIER 
  563 #   define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER 
  565 # ifndef PRINTF_INTMAX_HEX_WIDTH 
  566 #  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH 
  568 # ifndef PRINTF_INTMAX_DEC_WIDTH 
  569 #  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH 
  580 #ifndef stdint_least_defined 
  581   typedef   int8_t   int_least8_t;
 
  582   typedef  uint8_t  uint_least8_t;
 
  583   typedef  int16_t  int_least16_t;
 
  584   typedef uint16_t uint_least16_t;
 
  585   typedef  int32_t  int_least32_t;
 
  586   typedef uint32_t uint_least32_t;
 
  587 # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER 
  588 # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER 
  589 # define  UINT_LEAST8_MAX  UINT8_MAX 
  590 # define   INT_LEAST8_MAX   INT8_MAX 
  591 # define UINT_LEAST16_MAX UINT16_MAX 
  592 # define  INT_LEAST16_MAX  INT16_MAX 
  593 # define UINT_LEAST32_MAX UINT32_MAX 
  594 # define  INT_LEAST32_MAX  INT32_MAX 
  595 # define   INT_LEAST8_MIN   INT8_MIN 
  596 # define  INT_LEAST16_MIN  INT16_MIN 
  597 # define  INT_LEAST32_MIN  INT32_MIN 
  598 # ifdef stdint_int64_defined 
  599     typedef  int64_t  int_least64_t;
 
  600     typedef uint64_t uint_least64_t;
 
  601 #   define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER 
  602 #   define UINT_LEAST64_MAX UINT64_MAX 
  603 #   define  INT_LEAST64_MAX  INT64_MAX 
  604 #   define  INT_LEAST64_MIN  INT64_MIN 
  607 #undef stdint_least_defined 
  620 typedef   int_least8_t   int_fast8_t;
 
  621 typedef  uint_least8_t  uint_fast8_t;
 
  622 typedef  int_least16_t  int_fast16_t;
 
  623 typedef uint_least16_t uint_fast16_t;
 
  624 typedef  int_least32_t  int_fast32_t;
 
  625 typedef uint_least32_t uint_fast32_t;
 
  626 #define  UINT_FAST8_MAX  UINT_LEAST8_MAX 
  627 #define   INT_FAST8_MAX   INT_LEAST8_MAX 
  628 #define UINT_FAST16_MAX UINT_LEAST16_MAX 
  629 #define  INT_FAST16_MAX  INT_LEAST16_MAX 
  630 #define UINT_FAST32_MAX UINT_LEAST32_MAX 
  631 #define  INT_FAST32_MAX  INT_LEAST32_MAX 
  632 #define   INT_FAST8_MIN   INT_LEAST8_MIN 
  633 #define  INT_FAST16_MIN  INT_LEAST16_MIN 
  634 #define  INT_FAST32_MIN  INT_LEAST32_MIN 
  635 #ifdef stdint_int64_defined 
  636   typedef  int_least64_t  int_fast64_t;
 
  637   typedef uint_least64_t uint_fast64_t;
 
  638 # define UINT_FAST64_MAX UINT_LEAST64_MAX 
  639 # define  INT_FAST64_MAX  INT_LEAST64_MAX 
  640 # define  INT_FAST64_MIN  INT_LEAST64_MIN 
  643 #undef stdint_int64_defined 
  650 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) 
  656 #  define WCHAR_MAX ((wchar_t)-1) 
  665 #if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED) 
  666 # define STDINT_H_UINTPTR_T_DEFINED 
  669 #ifndef STDINT_H_UINTPTR_T_DEFINED 
  670 # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) 
  671 #  define stdint_intptr_bits 64 
  672 # elif defined (__WATCOMC__) || defined (__TURBOC__) 
  673 #  if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) 
  674 #    define stdint_intptr_bits 16 
  676 #    define stdint_intptr_bits 32 
  678 # elif defined (__i386__) || defined (_WIN32) || defined (WIN32) 
  679 #  define stdint_intptr_bits 32 
  680 # elif defined (__INTEL_COMPILER) 
  684 # ifdef stdint_intptr_bits 
  685 #  define stdint_intptr_glue3_i(a,b,c)  a##b##c 
  686 #  define stdint_intptr_glue3(a,b,c)    stdint_intptr_glue3_i(a,b,c) 
  687 #  ifndef PRINTF_INTPTR_MODIFIER 
  688 #    define PRINTF_INTPTR_MODIFIER      stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) 
  691 #    define PTRDIFF_MAX                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) 
  694 #    define PTRDIFF_MIN                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) 
  697 #    define UINTPTR_MAX                 stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) 
  700 #    define INTPTR_MAX                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) 
  703 #    define INTPTR_MIN                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) 
  706 #    define INTPTR_C(x)                 stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) 
  709 #    define UINTPTR_C(x)                stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) 
  711   typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
 
  712   typedef stdint_intptr_glue3( 
int,stdint_intptr_bits,_t)  intptr_t;
 
  716   typedef ptrdiff_t intptr_t;
 
  718 # define STDINT_H_UINTPTR_T_DEFINED 
  725 #ifndef SIG_ATOMIC_MAX 
  726 # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) 
  731 #if defined (__TEST_PSTDINT_FOR_CORRECTNESS) 
  742 #define glue3_aux(x,y,z) x ## y ## z 
  743 #define glue3(x,y,z) glue3_aux(x,y,z) 
  745 #define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0); 
  746 #define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0); 
  748 #define DECL(us,bits) glue3(DECL,us,) (bits) 
  750 #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) 
  763     intmax_t imax = INTMAX_C(0);
 
  764     uintmax_t umax = UINTMAX_C(0);
 
  765     char str0[256], str1[256];
 
  767     sprintf (str0, 
"%d %x\n", 0, ~0);
 
  769     sprintf (str1, 
"%d %x\n",  i8, ~0);
 
  770     if (0 != strcmp (str0, str1)) printf (
"Something wrong with i8 : %s\n", str1);
 
  771     sprintf (str1, 
"%u %x\n",  u8, ~0);
 
  772     if (0 != strcmp (str0, str1)) printf (
"Something wrong with u8 : %s\n", str1);
 
  773     sprintf (str1, 
"%d %x\n",  i16, ~0);
 
  774     if (0 != strcmp (str0, str1)) printf (
"Something wrong with i16 : %s\n", str1);
 
  775     sprintf (str1, 
"%u %x\n",  u16, ~0);
 
  776     if (0 != strcmp (str0, str1)) printf (
"Something wrong with u16 : %s\n", str1); 
 
  777     sprintf (str1, 
"%" PRINTF_INT32_MODIFIER 
"d %x\n",  i32, ~0);
 
  778     if (0 != strcmp (str0, str1)) printf (
"Something wrong with i32 : %s\n", str1);
 
  779     sprintf (str1, 
"%" PRINTF_INT32_MODIFIER 
"u %x\n",  u32, ~0);
 
  780     if (0 != strcmp (str0, str1)) printf (
"Something wrong with u32 : %s\n", str1);
 
  782     sprintf (str1, 
"%" PRINTF_INT64_MODIFIER 
"d %x\n",  i64, ~0);
 
  783     if (0 != strcmp (str0, str1)) printf (
"Something wrong with i64 : %s\n", str1);
 
  785     sprintf (str1, 
"%" PRINTF_INTMAX_MODIFIER 
"d %x\n",  imax, ~0);
 
  786     if (0 != strcmp (str0, str1)) printf (
"Something wrong with imax : %s\n", str1);
 
  787     sprintf (str1, 
"%" PRINTF_INTMAX_MODIFIER 
"u %x\n",  umax, ~0);
 
  788     if (0 != strcmp (str0, str1)) printf (
"Something wrong with umax : %s\n", str1);    
 
int main(int argc, char **argv)
This is the entry point for the unit test executable.