home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wvis0626.zip / warpvision_20020626.zip / inttypes.h < prev    next >
C/C++ Source or Header  |  2002-06-19  |  19KB  |  509 lines

  1. #ifndef __inttypes_h
  2.    #if __IBMC__ || __IBMCPP__
  3.       #pragma info(none)
  4.       #ifndef __CHKHDR__
  5.          #pragma info(none)
  6.       #endif
  7.       #pragma info(restore)
  8.    #endif
  9.  
  10.    #define __inttypes_h
  11.  
  12.    #ifdef __cplusplus
  13.       extern "C" {
  14.    #endif
  15.  
  16.    #ifndef _LNK_CONV
  17.       #if __IBMC__ || __IBMCPP__ || defined(_OPTLINK_SUPPORTED)
  18.          #define _LNK_CONV _Optlink
  19.       #else
  20.          #define _LNK_CONV
  21.       #endif
  22.    #endif
  23.  
  24.    #ifndef _IMPORT
  25.       #ifdef __IMPORTLIB__
  26.          #define _IMPORT _Import
  27.       #else
  28.          #define _IMPORT
  29.       #endif
  30.    #endif
  31.  
  32.    /********************************************************************/
  33.    /*  <inttypes.h> Header File                                        */
  34.    /*  IBM C and C++ Compilers for OS/2, AIX and for Windows NT,       */
  35.    /*  Version 3.6                                                     */
  36.    /*  Licensed Material - Property of IBM                             */
  37.    /*  (C) Copyright IBM Corp. 1991, 1997. All rights reserved         */
  38.    /*                                                                  */
  39.    /********************************************************************/
  40.  
  41.  
  42.    /*********************** Basic integer types *****************************
  43.    **
  44.    ** The following defines the basic fixed-size integer types.
  45.    **
  46.    ** intmax_t and uintmax_t are the largest signed and unsigned integer
  47.    ** types supported by the implementation.
  48.    **
  49.    ** intptr_t and uintptr_t are signed and unsigned integer types large enough
  50.    ** to hold a pointer; that is, pointers can be assigned into or from
  51.    ** these integer types without losing precision.
  52.    **
  53.    ** intfast_t and uintfast_t are the most efficient signed and unsigned
  54.    ** integer types of the implementation.
  55.    **
  56.    */
  57.  
  58.    typedef signed char int8_t;         /* 8-bit signed integer */
  59.    typedef signed short int16_t;       /* 16-bit signed integer */
  60.    typedef signed int int32_t;         /* 32-bit signed integer */
  61.    typedef unsigned char uint8_t;      /* 8-bit unsigned integer */
  62.    typedef unsigned short uint16_t;    /* 16-bit unsigned integer */
  63.    typedef unsigned int uint32_t;      /* 32-bit unsigned integer */
  64. //   #if _LONG_LONG
  65.    typedef long long int64_t;            /* 64-bit signed integer */
  66.    typedef unsigned long long uint64_t;  /* 64-bit unsigned integer */
  67.    typedef signed long long intmax_t;       /* largest signed integer supported */
  68.    typedef unsigned long long uintmax_t;    /* largest unsigned integer supported */
  69. //   #else
  70. //   typedef signed long intmax_t;       /* largest signed integer supported */
  71. //   typedef unsigned long uintmax_t;    /* largest unsigned integer supported */
  72. //   #endif
  73.    typedef signed int intptr_t;        /* signed integer type capable of holding a void * */
  74.    typedef unsigned int uintptr_t;     /* unsigned integer type capable of holding a void * */
  75.    typedef signed int intfast_t;       /* most efficient signed integer type */
  76.    typedef unsigned int uintfast_t;    /* most efficient unsigned integer type */
  77.  
  78.  
  79.    /*********************** Extended integer types *************************
  80.    **
  81.    ** The following defines smallest integer types that can hold n bits.
  82.    **
  83.    */
  84.  
  85.    typedef signed char int_least8_t;   /* smallest signed integer of at least 8 bits */
  86.    typedef int int_fast8_t;            /* the most efficient integer of at least 8 bits */
  87.    typedef signed short int_least16_t; /* smallest signed integer of at least 16 bits */
  88.    typedef int int_fast16_t;           /* the most efficient integer of at least 16 bits */
  89.    typedef signed int int_least32_t;   /* smallest signed integer of at least 32 bits */
  90.    typedef int int_fast32_t;           /* the most efficient integer of at least 32 bits */
  91.    #ifdef _LONG_LONG
  92.    typedef __int64 int_least64_t;      /* smallest signed integer of at least 64 bits */
  93.    typedef __int64 int_fast64_t;       /* the most efficient integer of at least 64 bits */
  94.    #endif
  95.    typedef unsigned char uint_least8_t;   /* smallest unsigned integer of at least 8 bits */
  96.    typedef unsigned int uint_fast8_t;     /* the most efficient unsigned integer of at least 8 bits */
  97.    typedef unsigned short uint_least16_t; /* smallest unsigned integer of at least 16 bits */
  98.    typedef unsigned int uint_fast16_t;    /* the most efficient unsigned integer of at least 16 bits */
  99.    typedef unsigned int uint_least32_t;   /* smallest unsigned integer of at least 32 bits */
  100.    typedef unsigned int uint_fast32_t;    /* the most efficient unsigned integer of at least 32 bits */
  101.    #ifdef _LONG_LONG
  102.    typedef unsigned __int64 uint_least64_t; /* smallest unsigned integer of at least 64 bits */
  103.    typedef unsigned __int64 uint_fast64_t;  /* the most efficient unsigned integer of at least 64 bits */
  104.    #endif
  105.  
  106.  
  107.    /* ************************** limits ***********************************
  108.    **
  109.    ** The following defines the limits for the above types.
  110.    **
  111.    ** NOTE : A programmer can test to see whether an implementation supports
  112.    ** a particular size of integer by testing if the macro that gives the
  113.    ** maximum for that datatype is defined. For example, if #ifdef UINT64_MAX
  114.    ** tests false, the implementation does not support unsigned 64 bit integers.
  115.    **
  116.    */
  117.  
  118.    #define INT8_MIN                    (-128)
  119.    #define INT16_MIN                   (-32767-1)
  120.    #define INT32_MIN                   (-2147483647-1)
  121.    #if _LONG_LONG
  122.    #define INT64_MIN                   (-9223372036854775807LL-1LL)
  123.    #endif
  124.    #define INT_LEAST8_MIN              (-128)
  125.    #define INT_LEAST16_MIN             (-32767-1)
  126.    #define INT_LEAST32_MIN             (-2147483647-1)
  127.    #if _LONG_LONG
  128.    #define INT_LEAST64_MIN             (-9223372036854775807LL-1LL)
  129.    #endif
  130.    #define INT_FAST8_MIN               (-128)
  131.    #define INT_FAST16_MIN              (-32767-1)
  132.    #define INT_FAST32_MIN              (-2147483647-1)
  133.    #if _LONG_LONG
  134.    #define INT_FAST64_MIN              (-9223372036854775807LL-1LL)
  135.    #endif
  136.    #define INT8_MAX                    (127)
  137.    #define INT16_MAX                   (32767)
  138.    #define INT32_MAX                   (2147483647)
  139.    #if _LONG_LONG
  140.    #define INT64_MAX                   (9223372036854775807LL)
  141.    #endif
  142.    #define UINT8_MAX                   (255U)
  143.    #define UINT16_MAX                  (65535U)
  144.    #define UINT32_MAX                  (4294967295U)
  145.    #if _LONG_LONG
  146.    #define UINT64_MAX                  (18446744073709551615ULL)
  147.    #endif
  148.  
  149.    #if _LONG_LONG
  150.    #define INTMAX_MIN                  (-9223372036854775807LL-1LL)
  151.    #define INTMAX_MAX                  (9223372036854775807LL)
  152.    #define UINTMAX_MAX                 (18446744073709551615ULL)
  153.    #else
  154.    #define INTMAX_MIN                  (-2147483647L-1)
  155.    #define INTMAX_MAX                  (2147483647L)
  156.    #define UINTMAX_MAX                 (4294967295UL)
  157.    #endif
  158.    #define INTFAST_MIN                 (-2147483647L-1)
  159.    #define INTFAST_MAX                 (2147483647L)
  160.    #define UINTFAST_MAX                (4294967295U)
  161.    #define INT_LEAST8_MAX              (127)
  162.    #define INT_LEAST16_MAX             (32767)
  163.    #define INT_LEAST32_MAX             (2147483647)
  164.    #if _LONG_LONG
  165.    #define INT_LEAST64_MAX             (9223372036854775807LL)
  166.    #endif
  167.    #define INT_FAST8_MAX               (2147483647)
  168.    #define INT_FAST16_MAX              (2147483647)
  169.    #define INT_FAST32_MAX              (2147483647)
  170.    #if _LONG_LONG
  171.    #define INT_FAST64_MAX              (9223372036854775807LL)
  172.    #endif
  173.    #define UINT_LEAST8_MAX             (255U)
  174.    #define UINT_LEAST16_MAX            (65535U)
  175.    #define UINT_LEAST32_MAX            (4294967295U)
  176.    #if _LONG_LONG
  177.    #define UINT_LEAST64_MAX            (18446744073709551615ULL)
  178.    #endif
  179.    #define UINT_FAST8_MAX              (4294967295U)
  180.    #define UINT_FAST16_MAX             (4294967295U)
  181.    #define UINT_FAST32_MAX             (4294967295U)
  182.    #if _LONG_LONG
  183.    #define UINT_FAST64_MAX             (18446744073709551615ULL)
  184.    #endif
  185.  
  186.    /* The following 2 macros are provided for testing whether the types
  187.    ** intptr_t and uintptr_t (integers large enough to hold a void *) are
  188.    ** defined in this header. They are needed in case the architecture can't
  189.    ** represent a pointer in any standard integral type.
  190.    */
  191.  
  192.    #define INTPTR_MAX                  (2147483647)
  193.    #define UINTPTR_MAX                 (4294967295U)
  194.  
  195.  
  196.    /* ************************ CONSTANTS ********************************
  197.    **
  198.    ** The following macros create constants of the above types. The intent is
  199.    ** that:
  200.    **   Constants defined using these macros have a specific length and
  201.    **     signedness.
  202.    */
  203.  
  204.    #define __CONCAT__(A,B)             A ## B
  205.    #define INT8_C(c)                   (c)
  206.    #define UINT8_C(c)                  __CONCAT__(c,u)
  207.    #define INT16_C(c)                  (c)
  208.    #define UINT16_C(c)                 __CONCAT__(c,u)
  209.    #define INT32_C(c)                  (c)
  210.    #define UINT32_C(c)                 __CONCAT__(c,u)
  211.    #define INT64_C(c)                  __CONCAT__(c,ll)
  212.    #define UINT64_C(c)                 __CONCAT__(c,ull)
  213.    #define INTMAX_C(c)                 __CONCAT__(c,ll)
  214.    #define UINTMAX_C(c)                __CONCAT__(c,ull)
  215.  
  216.  
  217.    /************************* FORMATTED I/O ********************************
  218.    **
  219.    ** The following macros can be used even when an implementation has not
  220.    ** extended the printf/scanf family of functions.
  221.    **
  222.    ** The form of the names of the macros is either "PRI" for printf specifiers
  223.    ** or "SCN" for scanf specifiers followed by the conversion specifier letter
  224.    ** followed by the datatype size. For example, PRId32 is the macro for
  225.    ** the printf d conversion specifier with the flags for 32 bit datatype.
  226.    **
  227.    ** Separate printf versus scanf macros are given because typically different
  228.    ** size flags must prefix the conversion specifier letter.
  229.    **
  230.    *** An example using one of these macros:
  231.    **
  232.    **    uint64_t u;
  233.    **    printf("u = %016" PRIx64 "\n", u);
  234.    **
  235.    */
  236.  
  237.    /* For signed integers */
  238.    #define PRId8                       "d"
  239.    #define PRId16                      "d"
  240.    #define PRId32                      "d"
  241.    #if _LONG_LONG
  242.    #define PRId64                    "lld"
  243.    #endif
  244.    #define PRIdFAST8                   "d"
  245.    #define PRIdFAST16                  "d"
  246.    #define PRIdFAST32                  "d"
  247.    #if _LONG_LONG
  248.    #define PRIdFAST64                "lld"
  249.    #endif
  250.    #define PRIdLEAST8                  "d"
  251.    #define PRIdLEAST16                 "d"
  252.    #define PRIdLEAST32                 "d"
  253.    #if _LONG_LONG
  254.    #define PRIdLEAST64               "lld"
  255.    #endif
  256.    #define PRIi8                       "i"
  257.    #define PRIi16                      "i"
  258.    #define PRIi32                      "i"
  259.    #if _LONG_LONG
  260.    #define PRIi64                    "lli"
  261.    #endif
  262.    #define PRIiFAST8                   "i"
  263.    #define PRIiFAST16                  "i"
  264.    #define PRIiFAST32                  "i"
  265.    #if _LONG_LONG
  266.    #define PRIiFAST64                "lli"
  267.    #endif
  268.    #define PRIiLEAST8                  "i"
  269.    #define PRIiLEAST16                 "i"
  270.    #define PRIiLEAST32                 "i"
  271.    #if _LONG_LONG
  272.    #define PRIiLEAST64               "lli"
  273.    #endif
  274.    #define PRIo8                       "o"
  275.    #define PRIo16                      "o"
  276.    #define PRIo32                      "o"
  277.    #if _LONG_LONG
  278.    #define PRIo64                    "llo"
  279.    #endif
  280.    #define PRIoFAST8                   "o"
  281.    #define PRIoFAST16                  "o"
  282.    #define PRIoFAST32                  "o"
  283.    #if _LONG_LONG
  284.    #define PRIoFAST64                "llo"
  285.    #endif
  286.    #define PRIoLEAST8                  "o"
  287.    #define PRIoLEAST16                 "o"
  288.    #define PRIoLEAST32                 "o"
  289.    #if _LONG_LONG
  290.    #define PRIoLEAST64               "llo"
  291.    #endif
  292.    #define PRIx8                       "x"
  293.    #define PRIx16                      "x"
  294.    #define PRIx32                      "x"
  295.    #if _LONG_LONG
  296.    #define PRIx64                    "llx"
  297.    #endif
  298.    #define PRIxFAST8                   "x"
  299.    #define PRIxFAST16                  "x"
  300.    #define PRIxFAST32                  "x"
  301.    #if _LONG_LONG
  302.    #define PRIxFAST64                "llx"
  303.    #endif
  304.    #define PRIxLEAST8                  "x"
  305.    #define PRIxLEAST16                 "x"
  306.    #define PRIxLEAST32                 "x"
  307.    #if _LONG_LONG
  308.    #define PRIxLEAST64               "llx"
  309.    #endif
  310.    #define PRIX8                       "X"
  311.    #define PRIX16                      "X"
  312.    #define PRIX32                      "X"
  313.    #if _LONG_LONG
  314.    #define PRIX64                    "llX"
  315.    #endif
  316.    #define PRIXFAST8                   "X"
  317.    #define PRIXFAST16                  "X"
  318.    #define PRIXFAST32                  "X"
  319.    #if _LONG_LONG
  320.    #define PRIXFAST64                "llX"
  321.    #endif
  322.    #define PRIXLEAST8                  "X"
  323.    #define PRIXLEAST16                 "X"
  324.    #define PRIXLEAST32                 "X"
  325.    #if _LONG_LONG
  326.    #define PRIXLEAST64               "llX"
  327.    #endif
  328.  
  329.    /* For unsigned integers */
  330.    #define PRIu8                       "u"
  331.    #define PRIu16                      "u"
  332.    #define PRIu32                      "u"
  333.    #if _LONG_LONG
  334.    #define PRIu64                    "llu"
  335.    #endif
  336.    #define PRIuFAST8                   "u"
  337.    #define PRIuFAST16                  "u"
  338.    #define PRIuFAST32                  "u"
  339.    #if _LONG_LONG
  340.    #define PRIuFAST64                "llu"
  341.    #endif
  342.    #define PRIuLEAST8                  "u"
  343.    #define PRIuLEAST16                 "u"
  344.    #define PRIuLEAST32                 "u"
  345.    #if _LONG_LONG
  346.    #define PRIuLEAST64               "llu"
  347.    #endif
  348.  
  349.    /* scanf macros */
  350.    #define SCNd16                     "hd"
  351.    #define SCNd32                      "d"
  352.    #if _LONG_LONG
  353.    #define SCNd64                    "lld"
  354.    #endif
  355.    #define SCNi16                     "hi"
  356.    #define SCNi32                      "i"
  357.    #if _LONG_LONG
  358.    #define SCNi64                    "lli"
  359.    #endif
  360.    #define SCNo16                     "ho"
  361.    #define SCNo32                      "o"
  362.    #if _LONG_LONG
  363.    #define SCNo64                    "llo"
  364.    #endif
  365.    #define SCNu16                     "hu"
  366.    #define SCNu32                      "u"
  367.    #if _LONG_LONG
  368.    #define SCNu64                    "llu"
  369.    #endif
  370.    #define SCNx16                     "hx"
  371.    #define SCNx32                      "x"
  372.    #if _LONG_LONG
  373.    #define SCNx64                    "llx"
  374.    #endif
  375.    #define SCNdFAST16                  "d"
  376.    #define SCNdFAST32                  "d"
  377.    #if _LONG_LONG
  378.    #define SCNdFAST64                "lld"
  379.    #endif
  380.    #define SCNdLEAST16                 "d"
  381.    #define SCNdLEAST32                 "d"
  382.    #if _LONG_LONG
  383.    #define SCNdLEAST64               "lld"
  384.    #endif
  385.    #define SCNiFAST16                  "i"
  386.    #define SCNiFAST32                  "i"
  387.    #if _LONG_LONG
  388.    #define SCNiFAST64                "lli"
  389.    #endif
  390.    #define SCNiLEAST16                 "i"
  391.    #define SCNiLEAST32                 "i"
  392.    #if _LONG_LONG
  393.    #define SCNiLEAST64               "lli"
  394.    #endif
  395.    #define SCNoFAST16                  "o"
  396.    #define SCNoFAST32                  "o"
  397.    #if _LONG_LONG
  398.    #define SCNoFAST64                "llo"
  399.    #endif
  400.    #define SCNoLEAST16                 "o"
  401.    #define SCNoLEAST32                 "o"
  402.    #if _LONG_LONG
  403.    #define SCNoLEAST64               "llo"
  404.    #endif
  405.    #define SCNuFAST16                  "u"
  406.    #define SCNuFAST32                  "u"
  407.    #if _LONG_LONG
  408.    #define SCNuFAST64                "llu"
  409.    #endif
  410.    #define SCNuLEAST16                 "u"
  411.    #define SCNuLEAST32                 "u"
  412.    #if _LONG_LONG
  413.    #define SCNuLEAST64               "llu"
  414.    #endif
  415.    #define SCNxFAST16                  "x"
  416.    #define SCNxFAST32                  "x"
  417.    #if _LONG_LONG
  418.    #define SCNxFAST64                "llx"
  419.    #endif
  420.    #define SCNxLEAST16                 "x"
  421.    #define SCNxLEAST32                 "x"
  422.    #if _LONG_LONG
  423.    #define SCNxLEAST64               "llx"
  424.    #endif
  425.    #define SCNXFAST16                  "X"
  426.    #define SCNXFAST32                  "X"
  427.    #if _LONG_LONG
  428.    #define SCNXFAST64                "llX"
  429.    #endif
  430.    #define SCNXLEAST16                 "X"
  431.    #define SCNXLEAST32                 "X"
  432.    #if _LONG_LONG
  433.    #define SCNXLEAST64               "llX"
  434.    #endif
  435.  
  436.  
  437.    /* The following macros define I/O formats for intmax_t and uintmax_t.
  438.    */
  439.  
  440.    #define PRIdMAX                   "lld"
  441.    #define PRIiMAX                   "lli"
  442.    #define PRIoMAX                   "llo"
  443.    #define PRIxMAX                   "llx"
  444.    #define PRIXMAX                   "llX"
  445.    #define PRIuMAX                   "llu"
  446.    #define SCNiMAX                   "lli"
  447.    #define SCNdMAX                   "lld"
  448.    #define SCNoMAX                   "llo"
  449.    #define SCNxMAX                   "llx"
  450.    #define SCNuMAX                   "llu"
  451.  
  452.    /* The following macros define I/O formats for intfast_t and uintfast_t.
  453.    */
  454.  
  455.    #define PRIdFAST                    "d"
  456.    #define PRIiFAST                    "i"
  457.    #define PRIoFAST                    "o"
  458.    #define PRIxFAST                    "x"
  459.    #define PRIXFAST                    "X"
  460.    #define PRIuFAST                    "u"
  461.    #define SCNiFAST                    "i"
  462.    #define SCNdFAST                    "d"
  463.    #define SCNoFAST                    "o"
  464.    #define SCNxFAST                    "x"
  465.    #define SCNuFAST                    "u"
  466.  
  467.  
  468.    /*************** conversion functions ********************************
  469.    **
  470.    ** The following routines are proposed to do conversions from strings to the
  471.    ** largest supported integer types. They parallel the ISO C strto* functions.
  472.    */
  473.  
  474.    extern intmax_t _LNK_CONV _IMPORT strtoimax(const char*, char**, int);
  475.    extern uintmax_t _LNK_CONV _IMPORT strtoumax(const char*, char**, int);
  476.  
  477.    #ifdef _LONG_LONG
  478.       #if __WINDOWS__ && __THW_INTEL__
  479.          #pragma map(strtoimax, "?strtoll")
  480.          #pragma map(strtoumax, "?strtoull")
  481.       #else
  482.          #pragma map(strtoimax, "strtoll")
  483.          #pragma map(strtoumax, "strtoull")
  484.       #endif
  485.    #else
  486.       #if __WINDOWS__ && __THW_INTEL__
  487.          #pragma map(strtoimax, "?strtol")
  488.          #pragma map(strtoumax, "?strtoul")
  489.       #else
  490.          #pragma map(strtoimax, "strtol")
  491.          #pragma map(strtoumax, "strtoul")
  492.       #endif
  493.    #endif
  494.  
  495.    #ifdef __cplusplus
  496.       }
  497.    #endif
  498.  
  499.    #if __IBMC__ || __IBMCPP__
  500.       #pragma info(none)
  501.       #ifndef __CHKHDR__
  502.          #pragma info(restore)
  503.       #endif
  504.       #pragma info(restore)
  505.    #endif
  506.  
  507. #endif
  508.  
  509.