Home | History | Annotate | Download | only in clang-include
      1 /*===---- stdint.h - Standard header for sized integer types --------------===*\
      2  *
      3  * Copyright (c) 2009 Chris Lattner
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a copy
      6  * of this software and associated documentation files (the "Software"), to deal
      7  * in the Software without restriction, including without limitation the rights
      8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9  * copies of the Software, and to permit persons to whom the Software is
     10  * furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be included in
     13  * all copies or substantial portions of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     21  * THE SOFTWARE.
     22  *
     23 \*===----------------------------------------------------------------------===*/
     24 
     25 #ifndef __CLANG_STDINT_H
     26 #define __CLANG_STDINT_H
     27 
     28 /* If we're hosted, fall back to the system's stdint.h, which might have
     29  * additional definitions.
     30  */
     31 #if __STDC_HOSTED__ && \
     32     defined(__has_include_next) && __has_include_next(<stdint.h>)
     33 # include_next <stdint.h>
     34 #else
     35 
     36 /* C99 7.18.1.1 Exact-width integer types.
     37  * C99 7.18.1.2 Minimum-width integer types.
     38  * C99 7.18.1.3 Fastest minimum-width integer types.
     39  *
     40  * The standard requires that exact-width type be defined for 8-, 16-, 32-, and
     41  * 64-bit types if they are implemented. Other exact width types are optional.
     42  * This implementation defines an exact-width types for every integer width
     43  * that is represented in the standard integer types.
     44  *
     45  * The standard also requires minimum-width types be defined for 8-, 16-, 32-,
     46  * and 64-bit widths regardless of whether there are corresponding exact-width
     47  * types.
     48  *
     49  * To accommodate targets that are missing types that are exactly 8, 16, 32, or
     50  * 64 bits wide, this implementation takes an approach of cascading
     51  * redefintions, redefining __int_leastN_t to successively smaller exact-width
     52  * types. It is therefore important that the types are defined in order of
     53  * descending widths.
     54  *
     55  * We currently assume that the minimum-width types and the fastest
     56  * minimum-width types are the same. This is allowed by the standard, but is
     57  * suboptimal.
     58  *
     59  * In violation of the standard, some targets do not implement a type that is
     60  * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit).
     61  * To accommodate these targets, a required minimum-width type is only
     62  * defined if there exists an exact-width type of equal or greater width.
     63  */
     64 
     65 #ifdef __INT64_TYPE__
     66 # ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/
     67 typedef signed __INT64_TYPE__ int64_t;
     68 # endif /* __int8_t_defined */
     69 typedef unsigned __INT64_TYPE__ uint64_t;
     70 # define __int_least64_t int64_t
     71 # define __uint_least64_t uint64_t
     72 # define __int_least32_t int64_t
     73 # define __uint_least32_t uint64_t
     74 # define __int_least16_t int64_t
     75 # define __uint_least16_t uint64_t
     76 # define __int_least8_t int64_t
     77 # define __uint_least8_t uint64_t
     78 #endif /* __INT64_TYPE__ */
     79 
     80 #ifdef __int_least64_t
     81 typedef __int_least64_t int_least64_t;
     82 typedef __uint_least64_t uint_least64_t;
     83 typedef __int_least64_t int_fast64_t;
     84 typedef __uint_least64_t uint_fast64_t;
     85 #endif /* __int_least64_t */
     86 
     87 #ifdef __INT56_TYPE__
     88 typedef signed __INT56_TYPE__ int56_t;
     89 typedef unsigned __INT56_TYPE__ uint56_t;
     90 typedef int56_t int_least56_t;
     91 typedef uint56_t uint_least56_t;
     92 typedef int56_t int_fast56_t;
     93 typedef uint56_t uint_fast56_t;
     94 # define __int_least32_t int56_t
     95 # define __uint_least32_t uint56_t
     96 # define __int_least16_t int56_t
     97 # define __uint_least16_t uint56_t
     98 # define __int_least8_t int56_t
     99 # define __uint_least8_t uint56_t
    100 #endif /* __INT56_TYPE__ */
    101 
    102 
    103 #ifdef __INT48_TYPE__
    104 typedef signed __INT48_TYPE__ int48_t;
    105 typedef unsigned __INT48_TYPE__ uint48_t;
    106 typedef int48_t int_least48_t;
    107 typedef uint48_t uint_least48_t;
    108 typedef int48_t int_fast48_t;
    109 typedef uint48_t uint_fast48_t;
    110 # define __int_least32_t int48_t
    111 # define __uint_least32_t uint48_t
    112 # define __int_least16_t int48_t
    113 # define __uint_least16_t uint48_t
    114 # define __int_least8_t int48_t
    115 # define __uint_least8_t uint48_t
    116 #endif /* __INT48_TYPE__ */
    117 
    118 
    119 #ifdef __INT40_TYPE__
    120 typedef signed __INT40_TYPE__ int40_t;
    121 typedef unsigned __INT40_TYPE__ uint40_t;
    122 typedef int40_t int_least40_t;
    123 typedef uint40_t uint_least40_t;
    124 typedef int40_t int_fast40_t;
    125 typedef uint40_t uint_fast40_t;
    126 # define __int_least32_t int40_t
    127 # define __uint_least32_t uint40_t
    128 # define __int_least16_t int40_t
    129 # define __uint_least16_t uint40_t
    130 # define __int_least8_t int40_t
    131 # define __uint_least8_t uint40_t
    132 #endif /* __INT40_TYPE__ */
    133 
    134 
    135 #ifdef __INT32_TYPE__
    136 
    137 # ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/
    138 typedef signed __INT32_TYPE__ int32_t;
    139 # endif /* __int8_t_defined */
    140 
    141 # ifndef __uint32_t_defined  /* more glibc compatibility */
    142 # define __uint32_t_defined
    143 typedef unsigned __INT32_TYPE__ uint32_t;
    144 # endif /* __uint32_t_defined */
    145 
    146 # define __int_least32_t int32_t
    147 # define __uint_least32_t uint32_t
    148 # define __int_least16_t int32_t
    149 # define __uint_least16_t uint32_t
    150 # define __int_least8_t int32_t
    151 # define __uint_least8_t uint32_t
    152 #endif /* __INT32_TYPE__ */
    153 
    154 #ifdef __int_least32_t
    155 typedef __int_least32_t int_least32_t;
    156 typedef __uint_least32_t uint_least32_t;
    157 typedef __int_least32_t int_fast32_t;
    158 typedef __uint_least32_t uint_fast32_t;
    159 #endif /* __int_least32_t */
    160 
    161 #ifdef __INT24_TYPE__
    162 typedef signed __INT24_TYPE__ int24_t;
    163 typedef unsigned __INT24_TYPE__ uint24_t;
    164 typedef int24_t int_least24_t;
    165 typedef uint24_t uint_least24_t;
    166 typedef int24_t int_fast24_t;
    167 typedef uint24_t uint_fast24_t;
    168 # define __int_least16_t int24_t
    169 # define __uint_least16_t uint24_t
    170 # define __int_least8_t int24_t
    171 # define __uint_least8_t uint24_t
    172 #endif /* __INT24_TYPE__ */
    173 
    174 #ifdef __INT16_TYPE__
    175 #ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/
    176 typedef signed __INT16_TYPE__ int16_t;
    177 #endif /* __int8_t_defined */
    178 typedef unsigned __INT16_TYPE__ uint16_t;
    179 # define __int_least16_t int16_t
    180 # define __uint_least16_t uint16_t
    181 # define __int_least8_t int16_t
    182 # define __uint_least8_t uint16_t
    183 #endif /* __INT16_TYPE__ */
    184 
    185 #ifdef __int_least16_t
    186 typedef __int_least16_t int_least16_t;
    187 typedef __uint_least16_t uint_least16_t;
    188 typedef __int_least16_t int_fast16_t;
    189 typedef __uint_least16_t uint_fast16_t;
    190 #endif /* __int_least16_t */
    191 
    192 
    193 #ifdef __INT8_TYPE__
    194 #ifndef __int8_t_defined  /* glibc sys/types.h also defines int8_t*/
    195 typedef signed __INT8_TYPE__ int8_t;
    196 #endif /* __int8_t_defined */
    197 typedef unsigned __INT8_TYPE__ uint8_t;
    198 # define __int_least8_t int8_t
    199 # define __uint_least8_t uint8_t
    200 #endif /* __INT8_TYPE__ */
    201 
    202 #ifdef __int_least8_t
    203 typedef __int_least8_t int_least8_t;
    204 typedef __uint_least8_t uint_least8_t;
    205 typedef __int_least8_t int_fast8_t;
    206 typedef __uint_least8_t uint_fast8_t;
    207 #endif /* __int_least8_t */
    208 
    209 /* prevent glibc sys/types.h from defining conflicting types */
    210 #ifndef __int8_t_defined
    211 # define __int8_t_defined
    212 #endif /* __int8_t_defined */
    213 
    214 /* C99 7.18.1.4 Integer types capable of holding object pointers.
    215  */
    216 #define __stdint_join3(a,b,c) a ## b ## c
    217 
    218 #define  __intn_t(n) __stdint_join3( int, n, _t)
    219 #define __uintn_t(n) __stdint_join3(uint, n, _t)
    220 
    221 #ifndef _INTPTR_T
    222 #ifndef __intptr_t_defined
    223 typedef  __intn_t(__INTPTR_WIDTH__)  intptr_t;
    224 #define __intptr_t_defined
    225 #define _INTPTR_T
    226 #endif
    227 #endif
    228 
    229 #ifndef _UINTPTR_T
    230 typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t;
    231 #define _UINTPTR_T
    232 #endif
    233 
    234 /* C99 7.18.1.5 Greatest-width integer types.
    235  */
    236 typedef __INTMAX_TYPE__  intmax_t;
    237 typedef __UINTMAX_TYPE__ uintmax_t;
    238 
    239 /* C99 7.18.4 Macros for minimum-width integer constants.
    240  *
    241  * The standard requires that integer constant macros be defined for all the
    242  * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width
    243  * types are required, the corresponding integer constant macros are defined
    244  * here. This implementation also defines minimum-width types for every other
    245  * integer width that the target implements, so corresponding macros are
    246  * defined below, too.
    247  *
    248  * These macros are defined using the same successive-shrinking approach as
    249  * the type definitions above. It is likewise important that macros are defined
    250  * in order of decending width.
    251  *
    252  * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the
    253  * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
    254  */
    255 
    256 #define __int_c_join(a, b) a ## b
    257 #define __int_c(v, suffix) __int_c_join(v, suffix)
    258 #define __uint_c(v, suffix) __int_c_join(v##U, suffix)
    259 
    260 
    261 #ifdef __INT64_TYPE__
    262 # ifdef __INT64_C_SUFFIX__
    263 #  define __int64_c_suffix __INT64_C_SUFFIX__
    264 #  define __int32_c_suffix __INT64_C_SUFFIX__
    265 #  define __int16_c_suffix __INT64_C_SUFFIX__
    266 #  define  __int8_c_suffix __INT64_C_SUFFIX__
    267 # else
    268 #  undef __int64_c_suffix
    269 #  undef __int32_c_suffix
    270 #  undef __int16_c_suffix
    271 #  undef  __int8_c_suffix
    272 # endif /* __INT64_C_SUFFIX__ */
    273 #endif /* __INT64_TYPE__ */
    274 
    275 #ifdef __int_least64_t
    276 # ifdef __int64_c_suffix
    277 #  define INT64_C(v) __int_c(v, __int64_c_suffix)
    278 #  define UINT64_C(v) __uint_c(v, __int64_c_suffix)
    279 # else
    280 #  define INT64_C(v) v
    281 #  define UINT64_C(v) v ## U
    282 # endif /* __int64_c_suffix */
    283 #endif /* __int_least64_t */
    284 
    285 
    286 #ifdef __INT56_TYPE__
    287 # ifdef __INT56_C_SUFFIX__
    288 #  define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__)
    289 #  define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__)
    290 #  define __int32_c_suffix __INT56_C_SUFFIX__
    291 #  define __int16_c_suffix __INT56_C_SUFFIX__
    292 #  define __int8_c_suffix  __INT56_C_SUFFIX__
    293 # else
    294 #  define INT56_C(v) v
    295 #  define UINT56_C(v) v ## U
    296 #  undef __int32_c_suffix
    297 #  undef __int16_c_suffix
    298 #  undef  __int8_c_suffix
    299 # endif /* __INT56_C_SUFFIX__ */
    300 #endif /* __INT56_TYPE__ */
    301 
    302 
    303 #ifdef __INT48_TYPE__
    304 # ifdef __INT48_C_SUFFIX__
    305 #  define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__)
    306 #  define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__)
    307 #  define __int32_c_suffix __INT48_C_SUFFIX__
    308 #  define __int16_c_suffix __INT48_C_SUFFIX__
    309 #  define __int8_c_suffix  __INT48_C_SUFFIX__
    310 # else
    311 #  define INT48_C(v) v
    312 #  define UINT48_C(v) v ## U
    313 #  undef __int32_c_suffix
    314 #  undef __int16_c_suffix
    315 #  undef  __int8_c_suffix
    316 # endif /* __INT48_C_SUFFIX__ */
    317 #endif /* __INT48_TYPE__ */
    318 
    319 
    320 #ifdef __INT40_TYPE__
    321 # ifdef __INT40_C_SUFFIX__
    322 #  define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__)
    323 #  define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__)
    324 #  define __int32_c_suffix __INT40_C_SUFFIX__
    325 #  define __int16_c_suffix __INT40_C_SUFFIX__
    326 #  define __int8_c_suffix  __INT40_C_SUFFIX__
    327 # else
    328 #  define INT40_C(v) v
    329 #  define UINT40_C(v) v ## U
    330 #  undef __int32_c_suffix
    331 #  undef __int16_c_suffix
    332 #  undef  __int8_c_suffix
    333 # endif /* __INT40_C_SUFFIX__ */
    334 #endif /* __INT40_TYPE__ */
    335 
    336 
    337 #ifdef __INT32_TYPE__
    338 # ifdef __INT32_C_SUFFIX__
    339 #  define __int32_c_suffix __INT32_C_SUFFIX__
    340 #  define __int16_c_suffix __INT32_C_SUFFIX__
    341 #  define __int8_c_suffix  __INT32_C_SUFFIX__
    342 #else
    343 #  undef __int32_c_suffix
    344 #  undef __int16_c_suffix
    345 #  undef  __int8_c_suffix
    346 # endif /* __INT32_C_SUFFIX__ */
    347 #endif /* __INT32_TYPE__ */
    348 
    349 #ifdef __int_least32_t
    350 # ifdef __int32_c_suffix
    351 #  define INT32_C(v) __int_c(v, __int32_c_suffix)
    352 #  define UINT32_C(v) __uint_c(v, __int32_c_suffix)
    353 # else
    354 #  define INT32_C(v) v
    355 #  define UINT32_C(v) v ## U
    356 # endif /* __int32_c_suffix */
    357 #endif /* __int_least32_t */
    358 
    359 
    360 #ifdef __INT24_TYPE__
    361 # ifdef __INT24_C_SUFFIX__
    362 #  define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__)
    363 #  define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__)
    364 #  define __int16_c_suffix __INT24_C_SUFFIX__
    365 #  define __int8_c_suffix  __INT24_C_SUFFIX__
    366 # else
    367 #  define INT24_C(v) v
    368 #  define UINT24_C(v) v ## U
    369 #  undef __int16_c_suffix
    370 #  undef  __int8_c_suffix
    371 # endif /* __INT24_C_SUFFIX__ */
    372 #endif /* __INT24_TYPE__ */
    373 
    374 
    375 #ifdef __INT16_TYPE__
    376 # ifdef __INT16_C_SUFFIX__
    377 #  define __int16_c_suffix __INT16_C_SUFFIX__
    378 #  define __int8_c_suffix  __INT16_C_SUFFIX__
    379 #else
    380 #  undef __int16_c_suffix
    381 #  undef  __int8_c_suffix
    382 # endif /* __INT16_C_SUFFIX__ */
    383 #endif /* __INT16_TYPE__ */
    384 
    385 #ifdef __int_least16_t
    386 # ifdef __int16_c_suffix
    387 #  define INT16_C(v) __int_c(v, __int16_c_suffix)
    388 #  define UINT16_C(v) __uint_c(v, __int16_c_suffix)
    389 # else
    390 #  define INT16_C(v) v
    391 #  define UINT16_C(v) v ## U
    392 # endif /* __int16_c_suffix */
    393 #endif /* __int_least16_t */
    394 
    395 
    396 #ifdef __INT8_TYPE__
    397 # ifdef __INT8_C_SUFFIX__
    398 #  define __int8_c_suffix __INT8_C_SUFFIX__
    399 #else
    400 #  undef  __int8_c_suffix
    401 # endif /* __INT8_C_SUFFIX__ */
    402 #endif /* __INT8_TYPE__ */
    403 
    404 #ifdef __int_least8_t
    405 # ifdef __int8_c_suffix
    406 #  define INT8_C(v) __int_c(v, __int8_c_suffix)
    407 #  define UINT8_C(v) __uint_c(v, __int8_c_suffix)
    408 # else
    409 #  define INT8_C(v) v
    410 #  define UINT8_C(v) v ## U
    411 # endif /* __int8_c_suffix */
    412 #endif /* __int_least8_t */
    413 
    414 
    415 /* C99 7.18.2.1 Limits of exact-width integer types.
    416  * C99 7.18.2.2 Limits of minimum-width integer types.
    417  * C99 7.18.2.3 Limits of fastest minimum-width integer types.
    418  *
    419  * The presence of limit macros are completely optional in C99.  This
    420  * implementation defines limits for all of the types (exact- and
    421  * minimum-width) that it defines above, using the limits of the minimum-width
    422  * type for any types that do not have exact-width representations.
    423  *
    424  * As in the type definitions, this section takes an approach of
    425  * successive-shrinking to determine which limits to use for the standard (8,
    426  * 16, 32, 64) bit widths when they don't have exact representations. It is
    427  * therefore important that the defintions be kept in order of decending
    428  * widths.
    429  *
    430  * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the
    431  * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).
    432  */
    433 
    434 #ifdef __INT64_TYPE__
    435 # define INT64_MAX           INT64_C( 9223372036854775807)
    436 # define INT64_MIN         (-INT64_C( 9223372036854775807)-1)
    437 # define UINT64_MAX         UINT64_C(18446744073709551615)
    438 # define __INT_LEAST64_MIN   INT64_MIN
    439 # define __INT_LEAST64_MAX   INT64_MAX
    440 # define __UINT_LEAST64_MAX UINT64_MAX
    441 # define __INT_LEAST32_MIN   INT64_MIN
    442 # define __INT_LEAST32_MAX   INT64_MAX
    443 # define __UINT_LEAST32_MAX UINT64_MAX
    444 # define __INT_LEAST16_MIN   INT64_MIN
    445 # define __INT_LEAST16_MAX   INT64_MAX
    446 # define __UINT_LEAST16_MAX UINT64_MAX
    447 # define __INT_LEAST8_MIN    INT64_MIN
    448 # define __INT_LEAST8_MAX    INT64_MAX
    449 # define __UINT_LEAST8_MAX  UINT64_MAX
    450 #endif /* __INT64_TYPE__ */
    451 
    452 #ifdef __INT_LEAST64_MIN
    453 # define INT_LEAST64_MIN   __INT_LEAST64_MIN
    454 # define INT_LEAST64_MAX   __INT_LEAST64_MAX
    455 # define UINT_LEAST64_MAX __UINT_LEAST64_MAX
    456 # define INT_FAST64_MIN    __INT_LEAST64_MIN
    457 # define INT_FAST64_MAX    __INT_LEAST64_MAX
    458 # define UINT_FAST64_MAX  __UINT_LEAST64_MAX
    459 #endif /* __INT_LEAST64_MIN */
    460 
    461 
    462 #ifdef __INT56_TYPE__
    463 # define INT56_MAX           INT56_C(36028797018963967)
    464 # define INT56_MIN         (-INT56_C(36028797018963967)-1)
    465 # define UINT56_MAX         UINT56_C(72057594037927935)
    466 # define INT_LEAST56_MIN     INT56_MIN
    467 # define INT_LEAST56_MAX     INT56_MAX
    468 # define UINT_LEAST56_MAX   UINT56_MAX
    469 # define INT_FAST56_MIN      INT56_MIN
    470 # define INT_FAST56_MAX      INT56_MAX
    471 # define UINT_FAST56_MAX    UINT56_MAX
    472 # define __INT_LEAST32_MIN   INT56_MIN
    473 # define __INT_LEAST32_MAX   INT56_MAX
    474 # define __UINT_LEAST32_MAX UINT56_MAX
    475 # define __INT_LEAST16_MIN   INT56_MIN
    476 # define __INT_LEAST16_MAX   INT56_MAX
    477 # define __UINT_LEAST16_MAX UINT56_MAX
    478 # define __INT_LEAST8_MIN    INT56_MIN
    479 # define __INT_LEAST8_MAX    INT56_MAX
    480 # define __UINT_LEAST8_MAX  UINT56_MAX
    481 #endif /* __INT56_TYPE__ */
    482 
    483 
    484 #ifdef __INT48_TYPE__
    485 # define INT48_MAX           INT48_C(140737488355327)
    486 # define INT48_MIN         (-INT48_C(140737488355327)-1)
    487 # define UINT48_MAX         UINT48_C(281474976710655)
    488 # define INT_LEAST48_MIN     INT48_MIN
    489 # define INT_LEAST48_MAX     INT48_MAX
    490 # define UINT_LEAST48_MAX   UINT48_MAX
    491 # define INT_FAST48_MIN      INT48_MIN
    492 # define INT_FAST48_MAX      INT48_MAX
    493 # define UINT_FAST48_MAX    UINT48_MAX
    494 # define __INT_LEAST32_MIN   INT48_MIN
    495 # define __INT_LEAST32_MAX   INT48_MAX
    496 # define __UINT_LEAST32_MAX UINT48_MAX
    497 # define __INT_LEAST16_MIN   INT48_MIN
    498 # define __INT_LEAST16_MAX   INT48_MAX
    499 # define __UINT_LEAST16_MAX UINT48_MAX
    500 # define __INT_LEAST8_MIN    INT48_MIN
    501 # define __INT_LEAST8_MAX    INT48_MAX
    502 # define __UINT_LEAST8_MAX  UINT48_MAX
    503 #endif /* __INT48_TYPE__ */
    504 
    505 
    506 #ifdef __INT40_TYPE__
    507 # define INT40_MAX           INT40_C(549755813887)
    508 # define INT40_MIN         (-INT40_C(549755813887)-1)
    509 # define UINT40_MAX         UINT40_C(1099511627775)
    510 # define INT_LEAST40_MIN     INT40_MIN
    511 # define INT_LEAST40_MAX     INT40_MAX
    512 # define UINT_LEAST40_MAX   UINT40_MAX
    513 # define INT_FAST40_MIN      INT40_MIN
    514 # define INT_FAST40_MAX      INT40_MAX
    515 # define UINT_FAST40_MAX    UINT40_MAX
    516 # define __INT_LEAST32_MIN   INT40_MIN
    517 # define __INT_LEAST32_MAX   INT40_MAX
    518 # define __UINT_LEAST32_MAX UINT40_MAX
    519 # define __INT_LEAST16_MIN   INT40_MIN
    520 # define __INT_LEAST16_MAX   INT40_MAX
    521 # define __UINT_LEAST16_MAX UINT40_MAX
    522 # define __INT_LEAST8_MIN    INT40_MIN
    523 # define __INT_LEAST8_MAX    INT40_MAX
    524 # define __UINT_LEAST8_MAX  UINT40_MAX
    525 #endif /* __INT40_TYPE__ */
    526 
    527 
    528 #ifdef __INT32_TYPE__
    529 # define INT32_MAX           INT32_C(2147483647)
    530 # define INT32_MIN         (-INT32_C(2147483647)-1)
    531 # define UINT32_MAX         UINT32_C(4294967295)
    532 # define __INT_LEAST32_MIN   INT32_MIN
    533 # define __INT_LEAST32_MAX   INT32_MAX
    534 # define __UINT_LEAST32_MAX UINT32_MAX
    535 # define __INT_LEAST16_MIN   INT32_MIN
    536 # define __INT_LEAST16_MAX   INT32_MAX
    537 # define __UINT_LEAST16_MAX UINT32_MAX
    538 # define __INT_LEAST8_MIN    INT32_MIN
    539 # define __INT_LEAST8_MAX    INT32_MAX
    540 # define __UINT_LEAST8_MAX  UINT32_MAX
    541 #endif /* __INT32_TYPE__ */
    542 
    543 #ifdef __INT_LEAST32_MIN
    544 # define INT_LEAST32_MIN   __INT_LEAST32_MIN
    545 # define INT_LEAST32_MAX   __INT_LEAST32_MAX
    546 # define UINT_LEAST32_MAX __UINT_LEAST32_MAX
    547 # define INT_FAST32_MIN    __INT_LEAST32_MIN
    548 # define INT_FAST32_MAX    __INT_LEAST32_MAX
    549 # define UINT_FAST32_MAX  __UINT_LEAST32_MAX
    550 #endif /* __INT_LEAST32_MIN */
    551 
    552 
    553 #ifdef __INT24_TYPE__
    554 # define INT24_MAX           INT24_C(8388607)
    555 # define INT24_MIN         (-INT24_C(8388607)-1)
    556 # define UINT24_MAX         UINT24_C(16777215)
    557 # define INT_LEAST24_MIN     INT24_MIN
    558 # define INT_LEAST24_MAX     INT24_MAX
    559 # define UINT_LEAST24_MAX   UINT24_MAX
    560 # define INT_FAST24_MIN      INT24_MIN
    561 # define INT_FAST24_MAX      INT24_MAX
    562 # define UINT_FAST24_MAX    UINT24_MAX
    563 # define __INT_LEAST16_MIN   INT24_MIN
    564 # define __INT_LEAST16_MAX   INT24_MAX
    565 # define __UINT_LEAST16_MAX UINT24_MAX
    566 # define __INT_LEAST8_MIN    INT24_MIN
    567 # define __INT_LEAST8_MAX    INT24_MAX
    568 # define __UINT_LEAST8_MAX  UINT24_MAX
    569 #endif /* __INT24_TYPE__ */
    570 
    571 
    572 #ifdef __INT16_TYPE__
    573 #define INT16_MAX            INT16_C(32767)
    574 #define INT16_MIN          (-INT16_C(32767)-1)
    575 #define UINT16_MAX          UINT16_C(65535)
    576 # define __INT_LEAST16_MIN   INT16_MIN
    577 # define __INT_LEAST16_MAX   INT16_MAX
    578 # define __UINT_LEAST16_MAX UINT16_MAX
    579 # define __INT_LEAST8_MIN    INT16_MIN
    580 # define __INT_LEAST8_MAX    INT16_MAX
    581 # define __UINT_LEAST8_MAX  UINT16_MAX
    582 #endif /* __INT16_TYPE__ */
    583 
    584 #ifdef __INT_LEAST16_MIN
    585 # define INT_LEAST16_MIN   __INT_LEAST16_MIN
    586 # define INT_LEAST16_MAX   __INT_LEAST16_MAX
    587 # define UINT_LEAST16_MAX __UINT_LEAST16_MAX
    588 # define INT_FAST16_MIN    __INT_LEAST16_MIN
    589 # define INT_FAST16_MAX    __INT_LEAST16_MAX
    590 # define UINT_FAST16_MAX  __UINT_LEAST16_MAX
    591 #endif /* __INT_LEAST16_MIN */
    592 
    593 
    594 #ifdef __INT8_TYPE__
    595 # define INT8_MAX            INT8_C(127)
    596 # define INT8_MIN          (-INT8_C(127)-1)
    597 # define UINT8_MAX          UINT8_C(255)
    598 # define __INT_LEAST8_MIN    INT8_MIN
    599 # define __INT_LEAST8_MAX    INT8_MAX
    600 # define __UINT_LEAST8_MAX  UINT8_MAX
    601 #endif /* __INT8_TYPE__ */
    602 
    603 #ifdef __INT_LEAST8_MIN
    604 # define INT_LEAST8_MIN   __INT_LEAST8_MIN
    605 # define INT_LEAST8_MAX   __INT_LEAST8_MAX
    606 # define UINT_LEAST8_MAX __UINT_LEAST8_MAX
    607 # define INT_FAST8_MIN    __INT_LEAST8_MIN
    608 # define INT_FAST8_MAX    __INT_LEAST8_MAX
    609 # define UINT_FAST8_MAX  __UINT_LEAST8_MAX
    610 #endif /* __INT_LEAST8_MIN */
    611 
    612 /* Some utility macros */
    613 #define  __INTN_MIN(n)  __stdint_join3( INT, n, _MIN)
    614 #define  __INTN_MAX(n)  __stdint_join3( INT, n, _MAX)
    615 #define __UINTN_MAX(n)  __stdint_join3(UINT, n, _MAX)
    616 #define  __INTN_C(n, v) __stdint_join3( INT, n, _C(v))
    617 #define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))
    618 
    619 /* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */
    620 /* C99 7.18.3 Limits of other integer types. */
    621 
    622 #define  INTPTR_MIN  __INTN_MIN(__INTPTR_WIDTH__)
    623 #define  INTPTR_MAX  __INTN_MAX(__INTPTR_WIDTH__)
    624 #define UINTPTR_MAX __UINTN_MAX(__INTPTR_WIDTH__)
    625 #define PTRDIFF_MIN  __INTN_MIN(__PTRDIFF_WIDTH__)
    626 #define PTRDIFF_MAX  __INTN_MAX(__PTRDIFF_WIDTH__)
    627 #define    SIZE_MAX __UINTN_MAX(__SIZE_WIDTH__)
    628 
    629 /* C99 7.18.2.5 Limits of greatest-width integer types. */
    630 #define INTMAX_MIN   __INTN_MIN(__INTMAX_WIDTH__)
    631 #define INTMAX_MAX   __INTN_MAX(__INTMAX_WIDTH__)
    632 #define UINTMAX_MAX __UINTN_MAX(__INTMAX_WIDTH__)
    633 
    634 /* C99 7.18.3 Limits of other integer types. */
    635 #define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
    636 #define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
    637 #ifdef __WINT_UNSIGNED__
    638 # define WINT_MIN       __UINTN_C(__WINT_WIDTH__, 0)
    639 # define WINT_MAX       __UINTN_MAX(__WINT_WIDTH__)
    640 #else
    641 # define WINT_MIN       __INTN_MIN(__WINT_WIDTH__)
    642 # define WINT_MAX       __INTN_MAX(__WINT_WIDTH__)
    643 #endif
    644 
    645 #ifndef WCHAR_MAX
    646 # define WCHAR_MAX __WCHAR_MAX__
    647 #endif
    648 #ifndef WCHAR_MIN
    649 # if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)
    650 #  define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)
    651 # else
    652 #  define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)
    653 # endif
    654 #endif
    655 
    656 /* 7.18.4.2 Macros for greatest-width integer constants. */
    657 #define INTMAX_C(v)   __INTN_C(__INTMAX_WIDTH__, v)
    658 #define UINTMAX_C(v) __UINTN_C(__INTMAX_WIDTH__, v)
    659 
    660 #endif /* __STDC_HOSTED__ */
    661 #endif /* __CLANG_STDINT_H */
    662