[BACK]Return to inttypes.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/inttypes.h, Revision 1.7

1.7     ! millert     1: /*     $OpenBSD: inttypes.h,v 1.6 2006/01/06 18:54:25 millert Exp $    */
1.1       millert     2:
                      3: /*
1.6       millert     4:  * Copyright (c) 1997, 2005 Todd C. Miller <Todd.Miller@courtesan.com>
1.1       millert     5:  *
1.4       millert     6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
1.1       millert     9:  *
1.5       millert    10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1       millert    17:  */
                     18:
1.6       millert    19: #ifndef        _INTTYPES_H_
                     20: #define        _INTTYPES_H_
1.1       millert    21:
1.6       millert    22: #include <sys/stdint.h>
1.1       millert    23:
1.6       millert    24: #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
                     25: /*
                     26:  * 7.8.1 Macros for format specifiers
                     27:  *
                     28:  * Each of the following object-like macros expands to a string
                     29:  * literal containing a conversion specifier, possibly modified by
                     30:  * a prefix such as hh, h, l, or ll, suitable for use within the
                     31:  * format argument of a formatted input/output function when
                     32:  * converting the corresponding integer type.  These macro names
                     33:  * have the general form of PRI (character string literals for the
                     34:  * fprintf family) or SCN (character string literals for the fscanf
                     35:  * family), followed by the conversion specifier, followed by a
                     36:  * name corresponding to a similar typedef name.  For example,
                     37:  * PRIdFAST32 can be used in a format string to print the value of
                     38:  * an integer of type int_fast32_t.
                     39:  */
                     40:
                     41: /* fprintf macros for signed integers */
                     42: #define        PRId8                   "d"
                     43: #define        PRId16                  "d"
                     44: #define        PRId32                  "d"
                     45: #define        PRId64                  "lld"
                     46:
                     47: #define        PRIdLEAST8              "d"
                     48: #define        PRIdLEAST16             "d"
                     49: #define        PRIdLEAST32             "d"
                     50: #define        PRIdLEAST64             "lld"
                     51:
                     52: #define        PRIdFAST8               "d"
                     53: #define        PRIdFAST16              "d"
                     54: #define        PRIdFAST32              "d"
                     55: #define        PRIdFAST64              "lld"
                     56:
                     57: #define        PRIdMAX                 "jd"
                     58: #ifdef __LP64__
                     59: #define        PRIdPTR                 "ld"
                     60: #else
                     61: #define        PRIdPTR                 "d"
                     62: #endif
                     63:
                     64: #define        PRIi8                   "i"
                     65: #define        PRIi16                  "i"
                     66: #define        PRIi32                  "i"
                     67: #define        PRIi64                  "lli"
                     68:
                     69: #define        PRIiLEAST8              "i"
                     70: #define        PRIiLEAST16             "i"
                     71: #define        PRIiLEAST32             "i"
                     72: #define        PRIiLEAST64             "lli"
                     73:
                     74: #define        PRIiFAST8               "i"
                     75: #define        PRIiFAST16              "i"
                     76: #define        PRIiFAST32              "i"
                     77: #define        PRIiFAST64              "lli"
                     78:
                     79: #define        PRIiMAX                 "ji"
                     80: #ifdef __LP64__
                     81: #define        PRIiPTR                 "li"
                     82: #else
                     83: #define        PRIiPTR                 "i"
                     84: #endif
                     85:
                     86: /* fprintf macros for unsigned integers */
                     87: #define        PRIo8                   "o"
                     88: #define        PRIo16                  "o"
                     89: #define        PRIo32                  "o"
                     90: #define        PRIo64                  "llo"
                     91:
                     92: #define        PRIoLEAST8              "o"
                     93: #define        PRIoLEAST16             "o"
                     94: #define        PRIoLEAST32             "o"
                     95: #define        PRIoLEAST64             "llo"
                     96:
                     97: #define        PRIoFAST8               "o"
                     98: #define        PRIoFAST16              "o"
                     99: #define        PRIoFAST32              "o"
                    100: #define        PRIoFAST64              "llo"
                    101:
                    102: #define        PRIoMAX                 "jo"
                    103: #ifdef __LP64__
                    104: #define        PRIoPTR                 "lo"
                    105: #else
                    106: #define        PRIoPTR                 "o"
                    107: #endif
                    108:
                    109: #define        PRIu8                   "u"
                    110: #define        PRIu16                  "u"
                    111: #define        PRIu32                  "u"
                    112: #define        PRIu64                  "llu"
                    113:
                    114: #define        PRIuLEAST8              "u"
                    115: #define        PRIuLEAST16             "u"
                    116: #define        PRIuLEAST32             "u"
                    117: #define        PRIuLEAST64             "llu"
                    118:
                    119: #define        PRIuFAST8               "u"
                    120: #define        PRIuFAST16              "u"
                    121: #define        PRIuFAST32              "u"
                    122: #define        PRIuFAST64              "llu"
                    123:
                    124: #define        PRIuMAX                 "ju"
                    125: #ifdef __LP64__
                    126: #define        PRIuPTR                 "lu"
                    127: #else
                    128: #define        PRIuPTR                 "u"
                    129: #endif
                    130:
                    131: #define        PRIx8                   "x"
                    132: #define        PRIx16                  "x"
                    133: #define        PRIx32                  "x"
                    134: #define        PRIx64                  "llx"
                    135:
                    136: #define        PRIxLEAST8              "x"
                    137: #define        PRIxLEAST16             "x"
                    138: #define        PRIxLEAST32             "x"
                    139: #define        PRIxLEAST64             "llx"
                    140:
                    141: #define        PRIxFAST8               "x"
                    142: #define        PRIxFAST16              "x"
                    143: #define        PRIxFAST32              "x"
                    144: #define        PRIxFAST64              "llx"
                    145:
                    146: #define        PRIxMAX                 "jx"
                    147: #ifdef __LP64__
                    148: #define        PRIxPTR                 "lx"
                    149: #else
                    150: #define        PRIxPTR                 "x"
                    151: #endif
                    152:
                    153: #define        PRIX8                   "X"
                    154: #define        PRIX16                  "X"
                    155: #define        PRIX32                  "X"
                    156: #define        PRIX64                  "llX"
                    157:
                    158: #define        PRIXLEAST8              "X"
                    159: #define        PRIXLEAST16             "X"
                    160: #define        PRIXLEAST32             "X"
                    161: #define        PRIXLEAST64             "llX"
                    162:
                    163: #define        PRIXFAST8               "X"
                    164: #define        PRIXFAST16              "X"
                    165: #define        PRIXFAST32              "X"
                    166: #define        PRIXFAST64              "llX"
                    167:
                    168: #define        PRIXMAX                 "jX"
                    169: #ifdef __LP64__
                    170: #define        PRIXPTR                 "lX"
                    171: #else
                    172: #define        PRIXPTR                 "X"
                    173: #endif
                    174:
                    175: /* fscanf macros for signed integers */
                    176: #define        SCNd8                   "hhd"
                    177: #define        SCNd16                  "hd"
                    178: #define        SCNd32                  "d"
                    179: #define        SCNd64                  "lld"
                    180:
                    181: #define        SCNdLEAST8              "hhd"
                    182: #define        SCNdLEAST16             "hd"
                    183: #define        SCNdLEAST32             "d"
                    184: #define        SCNdLEAST64             "lld"
                    185:
                    186: #define        SCNdFAST8               "hhd"
                    187: #define        SCNdFAST16              "hd"
                    188: #define        SCNdFAST32              "d"
                    189: #define        SCNdFAST64              "lld"
                    190:
                    191: #define        SCNdMAX                 "jd"
                    192: #ifdef __LP64__
                    193: #define        SCNdPTR                 "ld"
                    194: #else
                    195: #define        SCNdPTR                 "d"
                    196: #endif
                    197:
                    198: #define        SCNi8                   "hhi"
                    199: #define        SCNi16                  "hi"
                    200: #define        SCNi32                  "i"
                    201: #define        SCNi64                  "lli"
                    202:
                    203: #define        SCNiLEAST8              "hhi"
                    204: #define        SCNiLEAST16             "hi"
                    205: #define        SCNiLEAST32             "i"
                    206: #define        SCNiLEAST64             "lli"
                    207:
                    208: #define        SCNiFAST8               "hhi"
                    209: #define        SCNiFAST16              "hi"
                    210: #define        SCNiFAST32              "i"
                    211: #define        SCNiFAST64              "lli"
                    212:
                    213: #define        SCNiMAX                 "ji"
                    214: #ifdef __LP64__
                    215: #define        SCNiPTR                 "li"
                    216: #else
                    217: #define        SCNiPTR                 "i"
                    218: #endif
                    219:
                    220: /* fscanf macros for unsigned integers */
                    221: #define        SCNo8                   "hho"
                    222: #define        SCNo16                  "ho"
                    223: #define        SCNo32                  "o"
                    224: #define        SCNo64                  "llo"
                    225:
                    226: #define        SCNoLEAST8              "hho"
                    227: #define        SCNoLEAST16             "ho"
                    228: #define        SCNoLEAST32             "o"
                    229: #define        SCNoLEAST64             "llo"
                    230:
                    231: #define        SCNoFAST8               "hho"
                    232: #define        SCNoFAST16              "ho"
                    233: #define        SCNoFAST32              "o"
                    234: #define        SCNoFAST64              "llo"
                    235:
                    236: #define        SCNoMAX                 "jo"
                    237: #ifdef __LP64__
                    238: #define        SCNoPTR                 "lo"
                    239: #else
                    240: #define        SCNoPTR                 "o"
                    241: #endif
                    242:
                    243: #define        SCNu8                   "hhu"
                    244: #define        SCNu16                  "hu"
                    245: #define        SCNu32                  "u"
                    246: #define        SCNu64                  "llu"
                    247:
                    248: #define        SCNuLEAST8              "hhu"
                    249: #define        SCNuLEAST16             "hu"
                    250: #define        SCNuLEAST32             "u"
                    251: #define        SCNuLEAST64             "llu"
                    252:
                    253: #define        SCNuFAST8               "hhu"
                    254: #define        SCNuFAST16              "hu"
                    255: #define        SCNuFAST32              "u"
                    256: #define        SCNuFAST64              "llu"
                    257:
                    258: #define        SCNuMAX                 "ju"
                    259: #ifdef __LP64__
                    260: #define        SCNuPTR                 "lu"
                    261: #else
                    262: #define        SCNuPTR                 "u"
                    263: #endif
                    264:
                    265: #define        SCNx8                   "hhx"
                    266: #define        SCNx16                  "hx"
                    267: #define        SCNx32                  "x"
                    268: #define        SCNx64                  "llx"
                    269:
                    270: #define        SCNxLEAST8              "hhx"
                    271: #define        SCNxLEAST16             "hx"
                    272: #define        SCNxLEAST32             "x"
                    273: #define        SCNxLEAST64             "llx"
                    274:
                    275: #define        SCNxFAST8               "hhx"
                    276: #define        SCNxFAST16              "hx"
                    277: #define        SCNxFAST32              "x"
                    278: #define        SCNxFAST64              "llx"
                    279:
                    280: #define        SCNxMAX                 "jx"
                    281: #ifdef __LP64__
                    282: #define        SCNxPTR                 "lx"
                    283: #else
                    284: #define        SCNxPTR                 "x"
                    285: #endif
                    286:
                    287: #endif /* __cplusplus || __STDC_FORMAT_MACROS */
                    288:
1.7     ! millert   289: typedef struct {
        !           290:        intmax_t quot;          /* quotient */
        !           291:        intmax_t rem;           /* remainder */
        !           292: } imaxdiv_t;
        !           293:
        !           294: __BEGIN_DECLS
        !           295: intmax_t       imaxabs(intmax_t);
        !           296: imaxdiv_t      imaxdiv(intmax_t, intmax_t);
        !           297: intmax_t       strtoimax(const char *, char **, int);
        !           298: uintmax_t      strtoumax(const char *, char **, int);
        !           299: __END_DECLS
1.1       millert   300:
                    301: #endif /* _INTTYPES_H_ */