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