stdint.h revision 199482
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 accomodate 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 accomodate 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*/ 67typedef signed __INT64_TYPE__ int64_t; 68# endif /* __int8_t_defined */ 69typedef 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 81typedef __int_least64_t int_least64_t; 82typedef __uint_least64_t uint_least64_t; 83typedef __int_least64_t int_fast64_t; 84typedef __uint_least64_t uint_fast64_t; 85#endif /* __int_least64_t */ 86 87#ifdef __INT56_TYPE__ 88typedef signed __INT56_TYPE__ int56_t; 89typedef unsigned __INT56_TYPE__ uint56_t; 90typedef int56_t int_least56_t; 91typedef uint56_t uint_least56_t; 92typedef int56_t int_fast56_t; 93typedef 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__ 104typedef signed __INT48_TYPE__ int48_t; 105typedef unsigned __INT48_TYPE__ uint48_t; 106typedef int48_t int_least48_t; 107typedef uint48_t uint_least48_t; 108typedef int48_t int_fast48_t; 109typedef 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__ 120typedef signed __INT40_TYPE__ int40_t; 121typedef unsigned __INT40_TYPE__ uint40_t; 122typedef int40_t int_least40_t; 123typedef uint40_t uint_least40_t; 124typedef int40_t int_fast40_t; 125typedef 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*/ 138typedef signed __INT32_TYPE__ int32_t; 139# endif /* __int8_t_defined */ 140 141# ifndef __uint32_t_defined /* more glibc compatibility */ 142# define __uint32_t_defined 143typedef 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 155typedef __int_least32_t int_least32_t; 156typedef __uint_least32_t uint_least32_t; 157typedef __int_least32_t int_fast32_t; 158typedef __uint_least32_t uint_fast32_t; 159#endif /* __int_least32_t */ 160 161#ifdef __INT24_TYPE__ 162typedef signed __INT24_TYPE__ int24_t; 163typedef unsigned __INT24_TYPE__ uint24_t; 164typedef int24_t int_least24_t; 165typedef uint24_t uint_least24_t; 166typedef int24_t int_fast24_t; 167typedef 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*/ 176typedef signed __INT16_TYPE__ int16_t; 177#endif /* __int8_t_defined */ 178typedef 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 186typedef __int_least16_t int_least16_t; 187typedef __uint_least16_t uint_least16_t; 188typedef __int_least16_t int_fast16_t; 189typedef __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*/ 195typedef signed __INT8_TYPE__ int8_t; 196#endif /* __int8_t_defined */ 197typedef 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 203typedef __int_least8_t int_least8_t; 204typedef __uint_least8_t uint_least8_t; 205typedef __int_least8_t int_fast8_t; 206typedef __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#ifndef __intptr_t_defined 217typedef __INTPTR_TYPE__ intptr_t; 218#define __intptr_t_defined 219#endif 220typedef unsigned __INTPTR_TYPE__ uintptr_t; 221 222/* C99 7.18.1.5 Greatest-width integer types. 223 */ 224typedef __INTMAX_TYPE__ intmax_t; 225typedef __UINTMAX_TYPE__ uintmax_t; 226 227/* C99 7.18.4 Macros for minimum-width integer constants. 228 * 229 * The standard requires that integer constant macros be defined for all the 230 * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width 231 * types are required, the corresponding integer constant macros are defined 232 * here. This implementation also defines minimum-width types for every other 233 * integer width that the target implements, so corresponding macros are 234 * defined below, too. 235 * 236 * These macros are defined using the same successive-shrinking approach as 237 * the type definitions above. It is likewise important that macros are defined 238 * in order of decending width. 239 * 240 * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the 241 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). 242 */ 243 244#define __int_c_join(a, b) a ## b 245#define __int_c(v, suffix) __int_c_join(v, suffix) 246#define __uint_c(v, suffix) __int_c_join(v##U, suffix) 247 248 249#ifdef __INT64_TYPE__ 250# ifdef __INT64_C_SUFFIX__ 251# define __int64_c_suffix __INT64_C_SUFFIX__ 252# define __int32_c_suffix __INT64_C_SUFFIX__ 253# define __int16_c_suffix __INT64_C_SUFFIX__ 254# define __int8_c_suffix __INT64_C_SUFFIX__ 255# else 256# undef __int64_c_suffix 257# undef __int32_c_suffix 258# undef __int16_c_suffix 259# undef __int8_c_suffix 260# endif /* __INT64_C_SUFFIX__ */ 261#endif /* __INT64_TYPE__ */ 262 263#ifdef __int_least64_t 264# ifdef __int64_c_suffix 265# define INT64_C(v) __int_c(v, __int64_c_suffix) 266# define UINT64_C(v) __uint_c(v, __int64_c_suffix) 267# else 268# define INT64_C(v) v 269# define UINT64_C(v) v ## U 270# endif /* __int64_c_suffix */ 271#endif /* __int_least64_t */ 272 273 274#ifdef __INT56_TYPE__ 275# ifdef __INT56_C_SUFFIX__ 276# define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__) 277# define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__) 278# define __int32_c_suffix __INT56_C_SUFFIX__ 279# define __int16_c_suffix __INT56_C_SUFFIX__ 280# define __int8_c_suffix __INT56_C_SUFFIX__ 281# else 282# define INT56_C(v) v 283# define UINT56_C(v) v ## U 284# undef __int32_c_suffix 285# undef __int16_c_suffix 286# undef __int8_c_suffix 287# endif /* __INT56_C_SUFFIX__ */ 288#endif /* __INT56_TYPE__ */ 289 290 291#ifdef __INT48_TYPE__ 292# ifdef __INT48_C_SUFFIX__ 293# define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__) 294# define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__) 295# define __int32_c_suffix __INT48_C_SUFFIX__ 296# define __int16_c_suffix __INT48_C_SUFFIX__ 297# define __int8_c_suffix __INT48_C_SUFFIX__ 298# else 299# define INT48_C(v) v 300# define UINT48_C(v) v ## U 301# undef __int32_c_suffix 302# undef __int16_c_suffix 303# undef __int8_c_suffix 304# endif /* __INT48_C_SUFFIX__ */ 305#endif /* __INT48_TYPE__ */ 306 307 308#ifdef __INT40_TYPE__ 309# ifdef __INT40_C_SUFFIX__ 310# define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__) 311# define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__) 312# define __int32_c_suffix __INT40_C_SUFFIX__ 313# define __int16_c_suffix __INT40_C_SUFFIX__ 314# define __int8_c_suffix __INT40_C_SUFFIX__ 315# else 316# define INT40_C(v) v 317# define UINT40_C(v) v ## U 318# undef __int32_c_suffix 319# undef __int16_c_suffix 320# undef __int8_c_suffix 321# endif /* __INT40_C_SUFFIX__ */ 322#endif /* __INT40_TYPE__ */ 323 324 325#ifdef __INT32_TYPE__ 326# ifdef __INT32_C_SUFFIX__ 327# define __int32_c_suffix __INT32_C_SUFFIX__ 328# define __int16_c_suffix __INT32_C_SUFFIX__ 329# define __int8_c_suffix __INT32_C_SUFFIX__ 330#else 331# undef __int32_c_suffix 332# undef __int16_c_suffix 333# undef __int8_c_suffix 334# endif /* __INT32_C_SUFFIX__ */ 335#endif /* __INT32_TYPE__ */ 336 337#ifdef __int_least32_t 338# ifdef __int32_c_suffix 339# define INT32_C(v) __int_c(v, __int32_c_suffix) 340# define UINT32_C(v) __uint_c(v, __int32_c_suffix) 341# else 342# define INT32_C(v) v 343# define UINT32_C(v) v ## U 344# endif /* __int32_c_suffix */ 345#endif /* __int_least32_t */ 346 347 348#ifdef __INT24_TYPE__ 349# ifdef __INT24_C_SUFFIX__ 350# define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__) 351# define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__) 352# define __int16_c_suffix __INT24_C_SUFFIX__ 353# define __int8_c_suffix __INT24_C_SUFFIX__ 354# else 355# define INT24_C(v) v 356# define UINT24_C(v) v ## U 357# undef __int16_c_suffix 358# undef __int8_c_suffix 359# endif /* __INT24_C_SUFFIX__ */ 360#endif /* __INT24_TYPE__ */ 361 362 363#ifdef __INT16_TYPE__ 364# ifdef __INT16_C_SUFFIX__ 365# define __int16_c_suffix __INT16_C_SUFFIX__ 366# define __int8_c_suffix __INT16_C_SUFFIX__ 367#else 368# undef __int16_c_suffix 369# undef __int8_c_suffix 370# endif /* __INT16_C_SUFFIX__ */ 371#endif /* __INT16_TYPE__ */ 372 373#ifdef __int_least16_t 374# ifdef __int16_c_suffix 375# define INT16_C(v) __int_c(v, __int16_c_suffix) 376# define UINT16_C(v) __uint_c(v, __int16_c_suffix) 377# else 378# define INT16_C(v) v 379# define UINT16_C(v) v ## U 380# endif /* __int16_c_suffix */ 381#endif /* __int_least16_t */ 382 383 384#ifdef __INT8_TYPE__ 385# ifdef __INT8_C_SUFFIX__ 386# define __int8_c_suffix __INT8_C_SUFFIX__ 387#else 388# undef __int8_c_suffix 389# endif /* __INT8_C_SUFFIX__ */ 390#endif /* __INT8_TYPE__ */ 391 392#ifdef __int_least8_t 393# ifdef __int8_c_suffix 394# define INT8_C(v) __int_c(v, __int8_c_suffix) 395# define UINT8_C(v) __uint_c(v, __int8_c_suffix) 396# else 397# define INT8_C(v) v 398# define UINT8_C(v) v ## U 399# endif /* __int8_c_suffix */ 400#endif /* __int_least8_t */ 401 402 403/* C99 7.18.2.1 Limits of exact-width integer types. 404 * C99 7.18.2.2 Limits of minimum-width integer types. 405 * C99 7.18.2.3 Limits of fastest minimum-width integer types. 406 * 407 * The presence of limit macros are completely optional in C99. This 408 * implementation defines limits for all of the types (exact- and 409 * minimum-width) that it defines above, using the limits of the minimum-width 410 * type for any types that do not have exact-width representations. 411 * 412 * As in the type definitions, this section takes an approach of 413 * successive-shrinking to determine which limits to use for the standard (8, 414 * 16, 32, 64) bit widths when they don't have exact representations. It is 415 * therefore important that the defintions be kept in order of decending 416 * widths. 417 * 418 * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the 419 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). 420 */ 421 422#ifdef __INT64_TYPE__ 423# define INT64_MAX INT64_C( 9223372036854775807) 424# define INT64_MIN (-INT64_C( 9223372036854775807)-1) 425# define UINT64_MAX UINT64_C(18446744073709551615) 426# define __INT_LEAST64_MIN INT64_MIN 427# define __INT_LEAST64_MAX INT64_MAX 428# define __UINT_LEAST64_MAX UINT64_MAX 429# define __INT_LEAST32_MIN INT64_MIN 430# define __INT_LEAST32_MAX INT64_MAX 431# define __UINT_LEAST32_MAX UINT64_MAX 432# define __INT_LEAST16_MIN INT64_MIN 433# define __INT_LEAST16_MAX INT64_MAX 434# define __UINT_LEAST16_MAX UINT64_MAX 435# define __INT_LEAST8_MIN INT64_MIN 436# define __INT_LEAST8_MAX INT64_MAX 437# define __UINT_LEAST8_MAX UINT64_MAX 438#endif /* __INT64_TYPE__ */ 439 440#ifdef __INT_LEAST64_MIN 441# define INT_LEAST64_MIN __INT_LEAST64_MIN 442# define INT_LEAST64_MAX __INT_LEAST64_MAX 443# define UINT_LEAST64_MAX __UINT_LEAST64_MAX 444# define INT_FAST64_MIN __INT_LEAST64_MIN 445# define INT_FAST64_MAX __INT_LEAST64_MAX 446# define UINT_FAST64_MAX __UINT_LEAST64_MAX 447#endif /* __INT_LEAST64_MIN */ 448 449 450#ifdef __INT56_TYPE__ 451# define INT56_MAX INT56_C(36028797018963967) 452# define INT56_MIN (-INT56_C(36028797018963967)-1) 453# define UINT56_MAX UINT56_C(72057594037927935) 454# define INT_LEAST56_MIN INT56_MIN 455# define INT_LEAST56_MAX INT56_MAX 456# define UINT_LEAST56_MAX UINT56_MAX 457# define INT_FAST56_MIN INT56_MIN 458# define INT_FAST56_MAX INT56_MAX 459# define UINT_FAST56_MAX UINT56_MAX 460# define __INT_LEAST32_MIN INT56_MIN 461# define __INT_LEAST32_MAX INT56_MAX 462# define __UINT_LEAST32_MAX UINT56_MAX 463# define __INT_LEAST16_MIN INT56_MIN 464# define __INT_LEAST16_MAX INT56_MAX 465# define __UINT_LEAST16_MAX UINT56_MAX 466# define __INT_LEAST8_MIN INT56_MIN 467# define __INT_LEAST8_MAX INT56_MAX 468# define __UINT_LEAST8_MAX UINT56_MAX 469#endif /* __INT56_TYPE__ */ 470 471 472#ifdef __INT48_TYPE__ 473# define INT48_MAX INT48_C(140737488355327) 474# define INT48_MIN (-INT48_C(140737488355327)-1) 475# define UINT48_MAX UINT48_C(281474976710655) 476# define INT_LEAST48_MIN INT48_MIN 477# define INT_LEAST48_MAX INT48_MAX 478# define UINT_LEAST48_MAX UINT48_MAX 479# define INT_FAST48_MIN INT48_MIN 480# define INT_FAST48_MAX INT48_MAX 481# define UINT_FAST48_MAX UINT48_MAX 482# define __INT_LEAST32_MIN INT48_MIN 483# define __INT_LEAST32_MAX INT48_MAX 484# define __UINT_LEAST32_MAX UINT48_MAX 485# define __INT_LEAST16_MIN INT48_MIN 486# define __INT_LEAST16_MAX INT48_MAX 487# define __UINT_LEAST16_MAX UINT48_MAX 488# define __INT_LEAST8_MIN INT48_MIN 489# define __INT_LEAST8_MAX INT48_MAX 490# define __UINT_LEAST8_MAX UINT48_MAX 491#endif /* __INT48_TYPE__ */ 492 493 494#ifdef __INT40_TYPE__ 495# define INT40_MAX INT40_C(549755813887) 496# define INT40_MIN (-INT40_C(549755813887)-1) 497# define UINT40_MAX UINT40_C(1099511627775) 498# define INT_LEAST40_MIN INT40_MIN 499# define INT_LEAST40_MAX INT40_MAX 500# define UINT_LEAST40_MAX UINT40_MAX 501# define INT_FAST40_MIN INT40_MIN 502# define INT_FAST40_MAX INT40_MAX 503# define UINT_FAST40_MAX UINT40_MAX 504# define __INT_LEAST32_MIN INT40_MIN 505# define __INT_LEAST32_MAX INT40_MAX 506# define __UINT_LEAST32_MAX UINT40_MAX 507# define __INT_LEAST16_MIN INT40_MIN 508# define __INT_LEAST16_MAX INT40_MAX 509# define __UINT_LEAST16_MAX UINT40_MAX 510# define __INT_LEAST8_MIN INT40_MIN 511# define __INT_LEAST8_MAX INT40_MAX 512# define __UINT_LEAST8_MAX UINT40_MAX 513#endif /* __INT40_TYPE__ */ 514 515 516#ifdef __INT32_TYPE__ 517# define INT32_MAX INT32_C(2147483647) 518# define INT32_MIN (-INT32_C(2147483647)-1) 519# define UINT32_MAX UINT32_C(4294967295) 520# define __INT_LEAST32_MIN INT32_MIN 521# define __INT_LEAST32_MAX INT32_MAX 522# define __UINT_LEAST32_MAX UINT32_MAX 523# define __INT_LEAST16_MIN INT32_MIN 524# define __INT_LEAST16_MAX INT32_MAX 525# define __UINT_LEAST16_MAX UINT32_MAX 526# define __INT_LEAST8_MIN INT32_MIN 527# define __INT_LEAST8_MAX INT32_MAX 528# define __UINT_LEAST8_MAX UINT32_MAX 529#endif /* __INT32_TYPE__ */ 530 531#ifdef __INT_LEAST32_MIN 532# define INT_LEAST32_MIN __INT_LEAST32_MIN 533# define INT_LEAST32_MAX __INT_LEAST32_MAX 534# define UINT_LEAST32_MAX __UINT_LEAST32_MAX 535# define INT_FAST32_MIN __INT_LEAST32_MIN 536# define INT_FAST32_MAX __INT_LEAST32_MAX 537# define UINT_FAST32_MAX __UINT_LEAST32_MAX 538#endif /* __INT_LEAST32_MIN */ 539 540 541#ifdef __INT24_TYPE__ 542# define INT24_MAX INT24_C(8388607) 543# define INT24_MIN (-INT24_C(8388607)-1) 544# define UINT24_MAX UINT24_C(16777215) 545# define INT_LEAST24_MIN INT24_MIN 546# define INT_LEAST24_MAX INT24_MAX 547# define UINT_LEAST24_MAX UINT24_MAX 548# define INT_FAST24_MIN INT24_MIN 549# define INT_FAST24_MAX INT24_MAX 550# define UINT_FAST24_MAX UINT24_MAX 551# define __INT_LEAST16_MIN INT24_MIN 552# define __INT_LEAST16_MAX INT24_MAX 553# define __UINT_LEAST16_MAX UINT24_MAX 554# define __INT_LEAST8_MIN INT24_MIN 555# define __INT_LEAST8_MAX INT24_MAX 556# define __UINT_LEAST8_MAX UINT24_MAX 557#endif /* __INT24_TYPE__ */ 558 559 560#ifdef __INT16_TYPE__ 561#define INT16_MAX INT16_C(32767) 562#define INT16_MIN (-INT16_C(32767)-1) 563#define UINT16_MAX UINT16_C(65535) 564# define __INT_LEAST16_MIN INT16_MIN 565# define __INT_LEAST16_MAX INT16_MAX 566# define __UINT_LEAST16_MAX UINT16_MAX 567# define __INT_LEAST8_MIN INT16_MIN 568# define __INT_LEAST8_MAX INT16_MAX 569# define __UINT_LEAST8_MAX UINT16_MAX 570#endif /* __INT16_TYPE__ */ 571 572#ifdef __INT_LEAST16_MIN 573# define INT_LEAST16_MIN __INT_LEAST16_MIN 574# define INT_LEAST16_MAX __INT_LEAST16_MAX 575# define UINT_LEAST16_MAX __UINT_LEAST16_MAX 576# define INT_FAST16_MIN __INT_LEAST16_MIN 577# define INT_FAST16_MAX __INT_LEAST16_MAX 578# define UINT_FAST16_MAX __UINT_LEAST16_MAX 579#endif /* __INT_LEAST16_MIN */ 580 581 582#ifdef __INT8_TYPE__ 583# define INT8_MAX INT8_C(127) 584# define INT8_MIN (-INT8_C(127)-1) 585# define UINT8_MAX UINT8_C(255) 586# define __INT_LEAST8_MIN INT8_MIN 587# define __INT_LEAST8_MAX INT8_MAX 588# define __UINT_LEAST8_MAX UINT8_MAX 589#endif /* __INT8_TYPE__ */ 590 591#ifdef __INT_LEAST8_MIN 592# define INT_LEAST8_MIN __INT_LEAST8_MIN 593# define INT_LEAST8_MAX __INT_LEAST8_MAX 594# define UINT_LEAST8_MAX __UINT_LEAST8_MAX 595# define INT_FAST8_MIN __INT_LEAST8_MIN 596# define INT_FAST8_MAX __INT_LEAST8_MAX 597# define UINT_FAST8_MAX __UINT_LEAST8_MAX 598#endif /* __INT_LEAST8_MIN */ 599 600/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ 601/* C99 7.18.3 Limits of other integer types. */ 602 603#if __POINTER_WIDTH__ == 64 604 605#define INTPTR_MIN INT64_MIN 606#define INTPTR_MAX INT64_MAX 607#define UINTPTR_MAX UINT64_MAX 608#define PTRDIFF_MIN INT64_MIN 609#define PTRDIFF_MAX INT64_MAX 610#define SIZE_MAX UINT64_MAX 611 612#elif __POINTER_WIDTH__ == 32 613 614#define INTPTR_MIN INT32_MIN 615#define INTPTR_MAX INT32_MAX 616#define UINTPTR_MAX UINT32_MAX 617#define PTRDIFF_MIN INT32_MIN 618#define PTRDIFF_MAX INT32_MAX 619#define SIZE_MAX UINT32_MAX 620 621#elif __POINTER_WIDTH__ == 16 622 623#define INTPTR_MIN INT16_MIN 624#define INTPTR_MAX INT16_MAX 625#define UINTPTR_MAX UINT16_MAX 626#define PTRDIFF_MIN INT16_MIN 627#define PTRDIFF_MAX INT16_MAX 628#define SIZE_MAX UINT16_MAX 629 630#else 631#error "unknown or unset pointer width!" 632#endif 633 634/* C99 7.18.2.5 Limits of greatest-width integer types. */ 635#define INTMAX_MIN (-__INTMAX_MAX__-1) 636#define INTMAX_MAX __INTMAX_MAX__ 637#define UINTMAX_MAX (__INTMAX_MAX__*2ULL+1ULL) 638 639/* C99 7.18.3 Limits of other integer types. */ 640#define SIG_ATOMIC_MIN INT32_MIN 641#define SIG_ATOMIC_MAX INT32_MAX 642#define WINT_MIN INT32_MIN 643#define WINT_MAX INT32_MAX 644 645/* FIXME: if we ever support a target with unsigned wchar_t, this should be 646 * 0 .. Max. 647 */ 648#ifndef WCHAR_MAX 649#define WCHAR_MAX __WCHAR_MAX__ 650#endif 651#ifndef WCHAR_MIN 652#define WCHAR_MIN (-__WCHAR_MAX__-1) 653#endif 654 655/* 7.18.4.2 Macros for greatest-width integer constants. */ 656#define INTMAX_C(v) v##LL 657#define UINTMAX_C(v) v##ULL 658 659#endif /* __STDC_HOSTED__ */ 660#endif /* __CLANG_STDINT_H */ 661