845 lines · c
1/*===---- stdint.h - Standard header for sized integer types --------------===*\2 *3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4 * See https://llvm.org/LICENSE.txt for license information.5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6 *7\*===----------------------------------------------------------------------===*/8 9#ifndef __CLANG_STDINT_H10// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T11// is defined until an inclusion of it without _STD_TYPES_T occurs, in which12// case the header guard macro is defined.13#if !defined(_AIX) || !defined(_STD_TYPES_T) || !defined(__STDC_HOSTED__)14#define __CLANG_STDINT_H15#endif16 17#if defined(__MVS__) && __has_include_next(<stdint.h>)18#include_next <stdint.h>19#else20 21/* If we're hosted, fall back to the system's stdint.h, which might have22 * additional definitions.23 */24#if __STDC_HOSTED__ && __has_include_next(<stdint.h>)25 26// C99 7.18.3 Limits of other integer types27//28// Footnote 219, 220: C++ implementations should define these macros only when29// __STDC_LIMIT_MACROS is defined before <stdint.h> is included.30//31// Footnote 222: C++ implementations should define these macros only when32// __STDC_CONSTANT_MACROS is defined before <stdint.h> is included.33//34// C++11 [cstdint.syn]p2:35//36// The macros defined by <cstdint> are provided unconditionally. In particular,37// the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in38// footnotes 219, 220, and 222 in the C standard) play no role in C++.39//40// C11 removed the problematic footnotes.41//42// Work around this inconsistency by always defining those macros in C++ mode,43// so that a C library implementation which follows the C99 standard can be44// used in C++.45# ifdef __cplusplus46# if !defined(__STDC_LIMIT_MACROS)47# define __STDC_LIMIT_MACROS48# define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG49# endif50# if !defined(__STDC_CONSTANT_MACROS)51# define __STDC_CONSTANT_MACROS52# define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG53# endif54# endif55 56# include_next <stdint.h>57 58# ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG59# undef __STDC_LIMIT_MACROS60# undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG61# endif62# ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG63# undef __STDC_CONSTANT_MACROS64# undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG65# endif66 67#else68 69/* C99 7.18.1.1 Exact-width integer types.70 * C99 7.18.1.2 Minimum-width integer types.71 * C99 7.18.1.3 Fastest minimum-width integer types.72 *73 * The standard requires that exact-width type be defined for 8-, 16-, 32-, and74 * 64-bit types if they are implemented. Other exact width types are optional.75 * This implementation defines an exact-width types for every integer width76 * that is represented in the standard integer types.77 *78 * The standard also requires minimum-width types be defined for 8-, 16-, 32-,79 * and 64-bit widths regardless of whether there are corresponding exact-width80 * types.81 *82 * To accommodate targets that are missing types that are exactly 8, 16, 32, or83 * 64 bits wide, this implementation takes an approach of cascading84 * redefinitions, redefining __int_leastN_t to successively smaller exact-width85 * types. It is therefore important that the types are defined in order of86 * descending widths.87 *88 * We currently assume that the minimum-width types and the fastest89 * minimum-width types are the same. This is allowed by the standard, but is90 * suboptimal.91 *92 * In violation of the standard, some targets do not implement a type that is93 * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit).94 * To accommodate these targets, a required minimum-width type is only95 * defined if there exists an exact-width type of equal or greater width.96 */97 98#ifdef __INT64_TYPE__99# ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/100typedef __INT64_TYPE__ int64_t;101# endif /* __int8_t_defined */102typedef __UINT64_TYPE__ uint64_t;103# undef __int_least64_t104# define __int_least64_t int64_t105# undef __uint_least64_t106# define __uint_least64_t uint64_t107# undef __int_least32_t108# define __int_least32_t int64_t109# undef __uint_least32_t110# define __uint_least32_t uint64_t111# undef __int_least16_t112# define __int_least16_t int64_t113# undef __uint_least16_t114# define __uint_least16_t uint64_t115# undef __int_least8_t116# define __int_least8_t int64_t117# undef __uint_least8_t118# define __uint_least8_t uint64_t119#endif /* __INT64_TYPE__ */120 121#ifdef __int_least64_t122typedef __int_least64_t int_least64_t;123typedef __uint_least64_t uint_least64_t;124typedef __int_least64_t int_fast64_t;125typedef __uint_least64_t uint_fast64_t;126#endif /* __int_least64_t */127 128#ifdef __INT56_TYPE__129typedef __INT56_TYPE__ int56_t;130typedef __UINT56_TYPE__ uint56_t;131typedef int56_t int_least56_t;132typedef uint56_t uint_least56_t;133typedef int56_t int_fast56_t;134typedef uint56_t uint_fast56_t;135# undef __int_least32_t136# define __int_least32_t int56_t137# undef __uint_least32_t138# define __uint_least32_t uint56_t139# undef __int_least16_t140# define __int_least16_t int56_t141# undef __uint_least16_t142# define __uint_least16_t uint56_t143# undef __int_least8_t144# define __int_least8_t int56_t145# undef __uint_least8_t146# define __uint_least8_t uint56_t147#endif /* __INT56_TYPE__ */148 149 150#ifdef __INT48_TYPE__151typedef __INT48_TYPE__ int48_t;152typedef __UINT48_TYPE__ uint48_t;153typedef int48_t int_least48_t;154typedef uint48_t uint_least48_t;155typedef int48_t int_fast48_t;156typedef uint48_t uint_fast48_t;157# undef __int_least32_t158# define __int_least32_t int48_t159# undef __uint_least32_t160# define __uint_least32_t uint48_t161# undef __int_least16_t162# define __int_least16_t int48_t163# undef __uint_least16_t164# define __uint_least16_t uint48_t165# undef __int_least8_t166# define __int_least8_t int48_t167# undef __uint_least8_t168# define __uint_least8_t uint48_t169#endif /* __INT48_TYPE__ */170 171 172#ifdef __INT40_TYPE__173typedef __INT40_TYPE__ int40_t;174typedef __UINT40_TYPE__ uint40_t;175typedef int40_t int_least40_t;176typedef uint40_t uint_least40_t;177typedef int40_t int_fast40_t;178typedef uint40_t uint_fast40_t;179# undef __int_least32_t180# define __int_least32_t int40_t181# undef __uint_least32_t182# define __uint_least32_t uint40_t183# undef __int_least16_t184# define __int_least16_t int40_t185# undef __uint_least16_t186# define __uint_least16_t uint40_t187# undef __int_least8_t188# define __int_least8_t int40_t189# undef __uint_least8_t190# define __uint_least8_t uint40_t191#endif /* __INT40_TYPE__ */192 193 194#ifdef __INT32_TYPE__195 196# ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/197typedef __INT32_TYPE__ int32_t;198# endif /* __int8_t_defined */199 200# ifndef __uint32_t_defined /* more glibc compatibility */201# define __uint32_t_defined202typedef __UINT32_TYPE__ uint32_t;203# endif /* __uint32_t_defined */204 205# undef __int_least32_t206# define __int_least32_t int32_t207# undef __uint_least32_t208# define __uint_least32_t uint32_t209# undef __int_least16_t210# define __int_least16_t int32_t211# undef __uint_least16_t212# define __uint_least16_t uint32_t213# undef __int_least8_t214# define __int_least8_t int32_t215# undef __uint_least8_t216# define __uint_least8_t uint32_t217#endif /* __INT32_TYPE__ */218 219#ifdef __int_least32_t220typedef __int_least32_t int_least32_t;221typedef __uint_least32_t uint_least32_t;222typedef __int_least32_t int_fast32_t;223typedef __uint_least32_t uint_fast32_t;224#endif /* __int_least32_t */225 226#ifdef __INT24_TYPE__227typedef __INT24_TYPE__ int24_t;228typedef __UINT24_TYPE__ uint24_t;229typedef int24_t int_least24_t;230typedef uint24_t uint_least24_t;231typedef int24_t int_fast24_t;232typedef uint24_t uint_fast24_t;233# undef __int_least16_t234# define __int_least16_t int24_t235# undef __uint_least16_t236# define __uint_least16_t uint24_t237# undef __int_least8_t238# define __int_least8_t int24_t239# undef __uint_least8_t240# define __uint_least8_t uint24_t241#endif /* __INT24_TYPE__ */242 243#ifdef __INT16_TYPE__244#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/245typedef __INT16_TYPE__ int16_t;246#endif /* __int8_t_defined */247typedef __UINT16_TYPE__ uint16_t;248# undef __int_least16_t249# define __int_least16_t int16_t250# undef __uint_least16_t251# define __uint_least16_t uint16_t252# undef __int_least8_t253# define __int_least8_t int16_t254# undef __uint_least8_t255# define __uint_least8_t uint16_t256#endif /* __INT16_TYPE__ */257 258#ifdef __int_least16_t259typedef __int_least16_t int_least16_t;260typedef __uint_least16_t uint_least16_t;261typedef __int_least16_t int_fast16_t;262typedef __uint_least16_t uint_fast16_t;263#endif /* __int_least16_t */264 265 266#ifdef __INT8_TYPE__267#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/268typedef __INT8_TYPE__ int8_t;269#endif /* __int8_t_defined */270typedef __UINT8_TYPE__ uint8_t;271# undef __int_least8_t272# define __int_least8_t int8_t273# undef __uint_least8_t274# define __uint_least8_t uint8_t275#endif /* __INT8_TYPE__ */276 277#ifdef __int_least8_t278typedef __int_least8_t int_least8_t;279typedef __uint_least8_t uint_least8_t;280typedef __int_least8_t int_fast8_t;281typedef __uint_least8_t uint_fast8_t;282#endif /* __int_least8_t */283 284/* prevent glibc sys/types.h from defining conflicting types */285#ifndef __int8_t_defined286# define __int8_t_defined287#endif /* __int8_t_defined */288 289/* C99 7.18.1.4 Integer types capable of holding object pointers.290 */291#define __stdint_join3(a,b,c) a ## b ## c292 293#ifndef _INTPTR_T294#ifndef __intptr_t_defined295typedef __INTPTR_TYPE__ intptr_t;296#define __intptr_t_defined297#define _INTPTR_T298#endif299#endif300 301#ifndef _UINTPTR_T302typedef __UINTPTR_TYPE__ uintptr_t;303#define _UINTPTR_T304#endif305 306/* C99 7.18.1.5 Greatest-width integer types.307 */308typedef __INTMAX_TYPE__ intmax_t;309typedef __UINTMAX_TYPE__ uintmax_t;310 311/* C99 7.18.4 Macros for minimum-width integer constants.312 *313 * The standard requires that integer constant macros be defined for all the314 * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width315 * types are required, the corresponding integer constant macros are defined316 * here. This implementation also defines minimum-width types for every other317 * integer width that the target implements, so corresponding macros are318 * defined below, too.319 *320 * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the321 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).322 */323 324#ifdef __int_least64_t325#define INT64_C(v) __INT64_C(v)326#define UINT64_C(v) __UINT64_C(v)327#endif /* __int_least64_t */328 329 330#ifdef __INT56_TYPE__331#define INT56_C(v) __INT56_C(v)332#define UINT56_C(v) __UINT56_C(v)333#endif /* __INT56_TYPE__ */334 335 336#ifdef __INT48_TYPE__337#define INT48_C(v) __INT48_C(v)338#define UINT48_C(v) __UINT48_C(v)339#endif /* __INT48_TYPE__ */340 341 342#ifdef __INT40_TYPE__343#define INT40_C(v) __INT40_C(v)344#define UINT40_C(v) __UINT40_C(v)345#endif /* __INT40_TYPE__ */346 347 348#ifdef __int_least32_t349#define INT32_C(v) __INT32_C(v)350#define UINT32_C(v) __UINT32_C(v)351#endif /* __int_least32_t */352 353 354#ifdef __INT24_TYPE__355#define INT24_C(v) __INT24_C(v)356#define UINT24_C(v) __UINT24_C(v)357#endif /* __INT24_TYPE__ */358 359 360#ifdef __int_least16_t361#define INT16_C(v) __INT16_C(v)362#define UINT16_C(v) __UINT16_C(v)363#endif /* __int_least16_t */364 365 366#ifdef __int_least8_t367#define INT8_C(v) __INT8_C(v)368#define UINT8_C(v) __UINT8_C(v)369#endif /* __int_least8_t */370 371 372/* C99 7.18.2.1 Limits of exact-width integer types.373 * C99 7.18.2.2 Limits of minimum-width integer types.374 * C99 7.18.2.3 Limits of fastest minimum-width integer types.375 *376 * The presence of limit macros are completely optional in C99. This377 * implementation defines limits for all of the types (exact- and378 * minimum-width) that it defines above, using the limits of the minimum-width379 * type for any types that do not have exact-width representations.380 *381 * As in the type definitions, this section takes an approach of382 * successive-shrinking to determine which limits to use for the standard (8,383 * 16, 32, 64) bit widths when they don't have exact representations. It is384 * therefore important that the definitions be kept in order of decending385 * widths.386 *387 * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the388 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).389 */390 391#ifdef __INT64_TYPE__392# define INT64_MAX INT64_C( 9223372036854775807)393# define INT64_MIN (-INT64_C( 9223372036854775807)-1)394# define UINT64_MAX UINT64_C(18446744073709551615)395 396#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L397# define UINT64_WIDTH 64398# define INT64_WIDTH UINT64_WIDTH399 400# define __UINT_LEAST64_WIDTH UINT64_WIDTH401# undef __UINT_LEAST32_WIDTH402# define __UINT_LEAST32_WIDTH UINT64_WIDTH403# undef __UINT_LEAST16_WIDTH404# define __UINT_LEAST16_WIDTH UINT64_WIDTH405# undef __UINT_LEAST8_MAX406# define __UINT_LEAST8_MAX UINT64_MAX407#endif /* __STDC_VERSION__ */408 409# define __INT_LEAST64_MIN INT64_MIN410# define __INT_LEAST64_MAX INT64_MAX411# define __UINT_LEAST64_MAX UINT64_MAX412# undef __INT_LEAST32_MIN413# define __INT_LEAST32_MIN INT64_MIN414# undef __INT_LEAST32_MAX415# define __INT_LEAST32_MAX INT64_MAX416# undef __UINT_LEAST32_MAX417# define __UINT_LEAST32_MAX UINT64_MAX418# undef __INT_LEAST16_MIN419# define __INT_LEAST16_MIN INT64_MIN420# undef __INT_LEAST16_MAX421# define __INT_LEAST16_MAX INT64_MAX422# undef __UINT_LEAST16_MAX423# define __UINT_LEAST16_MAX UINT64_MAX424# undef __INT_LEAST8_MIN425# define __INT_LEAST8_MIN INT64_MIN426# undef __INT_LEAST8_MAX427# define __INT_LEAST8_MAX INT64_MAX428# undef __UINT_LEAST8_MAX429# define __UINT_LEAST8_MAX UINT64_MAX430#endif /* __INT64_TYPE__ */431 432#ifdef __INT_LEAST64_MIN433# define INT_LEAST64_MIN __INT_LEAST64_MIN434# define INT_LEAST64_MAX __INT_LEAST64_MAX435# define UINT_LEAST64_MAX __UINT_LEAST64_MAX436# define INT_FAST64_MIN __INT_LEAST64_MIN437# define INT_FAST64_MAX __INT_LEAST64_MAX438# define UINT_FAST64_MAX __UINT_LEAST64_MAX439 440#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L441# define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH442# define INT_LEAST64_WIDTH UINT_LEAST64_WIDTH443# define UINT_FAST64_WIDTH __UINT_LEAST64_WIDTH444# define INT_FAST64_WIDTH UINT_FAST64_WIDTH445#endif /* __STDC_VERSION__ */446#endif /* __INT_LEAST64_MIN */447 448 449#ifdef __INT56_TYPE__450# define INT56_MAX INT56_C(36028797018963967)451# define INT56_MIN (-INT56_C(36028797018963967)-1)452# define UINT56_MAX UINT56_C(72057594037927935)453# define INT_LEAST56_MIN INT56_MIN454# define INT_LEAST56_MAX INT56_MAX455# define UINT_LEAST56_MAX UINT56_MAX456# define INT_FAST56_MIN INT56_MIN457# define INT_FAST56_MAX INT56_MAX458# define UINT_FAST56_MAX UINT56_MAX459 460# undef __INT_LEAST32_MIN461# define __INT_LEAST32_MIN INT56_MIN462# undef __INT_LEAST32_MAX463# define __INT_LEAST32_MAX INT56_MAX464# undef __UINT_LEAST32_MAX465# define __UINT_LEAST32_MAX UINT56_MAX466# undef __INT_LEAST16_MIN467# define __INT_LEAST16_MIN INT56_MIN468# undef __INT_LEAST16_MAX469# define __INT_LEAST16_MAX INT56_MAX470# undef __UINT_LEAST16_MAX471# define __UINT_LEAST16_MAX UINT56_MAX472# undef __INT_LEAST8_MIN473# define __INT_LEAST8_MIN INT56_MIN474# undef __INT_LEAST8_MAX475# define __INT_LEAST8_MAX INT56_MAX476# undef __UINT_LEAST8_MAX477# define __UINT_LEAST8_MAX UINT56_MAX478 479#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L480# define UINT56_WIDTH 56481# define INT56_WIDTH UINT56_WIDTH482# define UINT_LEAST56_WIDTH UINT56_WIDTH483# define INT_LEAST56_WIDTH UINT_LEAST56_WIDTH484# define UINT_FAST56_WIDTH UINT56_WIDTH485# define INT_FAST56_WIDTH UINT_FAST56_WIDTH486# undef __UINT_LEAST32_WIDTH487# define __UINT_LEAST32_WIDTH UINT56_WIDTH488# undef __UINT_LEAST16_WIDTH489# define __UINT_LEAST16_WIDTH UINT56_WIDTH490# undef __UINT_LEAST8_WIDTH491# define __UINT_LEAST8_WIDTH UINT56_WIDTH492#endif /* __STDC_VERSION__ */493#endif /* __INT56_TYPE__ */494 495 496#ifdef __INT48_TYPE__497# define INT48_MAX INT48_C(140737488355327)498# define INT48_MIN (-INT48_C(140737488355327)-1)499# define UINT48_MAX UINT48_C(281474976710655)500# define INT_LEAST48_MIN INT48_MIN501# define INT_LEAST48_MAX INT48_MAX502# define UINT_LEAST48_MAX UINT48_MAX503# define INT_FAST48_MIN INT48_MIN504# define INT_FAST48_MAX INT48_MAX505# define UINT_FAST48_MAX UINT48_MAX506 507# undef __INT_LEAST32_MIN508# define __INT_LEAST32_MIN INT48_MIN509# undef __INT_LEAST32_MAX510# define __INT_LEAST32_MAX INT48_MAX511# undef __UINT_LEAST32_MAX512# define __UINT_LEAST32_MAX UINT48_MAX513# undef __INT_LEAST16_MIN514# define __INT_LEAST16_MIN INT48_MIN515# undef __INT_LEAST16_MAX516# define __INT_LEAST16_MAX INT48_MAX517# undef __UINT_LEAST16_MAX518# define __UINT_LEAST16_MAX UINT48_MAX519# undef __INT_LEAST8_MIN520# define __INT_LEAST8_MIN INT48_MIN521# undef __INT_LEAST8_MAX522# define __INT_LEAST8_MAX INT48_MAX523# undef __UINT_LEAST8_MAX524# define __UINT_LEAST8_MAX UINT48_MAX525 526#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L527#define UINT48_WIDTH 48528#define INT48_WIDTH UINT48_WIDTH529#define UINT_LEAST48_WIDTH UINT48_WIDTH530#define INT_LEAST48_WIDTH UINT_LEAST48_WIDTH531#define UINT_FAST48_WIDTH UINT48_WIDTH532#define INT_FAST48_WIDTH UINT_FAST48_WIDTH533#undef __UINT_LEAST32_WIDTH534#define __UINT_LEAST32_WIDTH UINT48_WIDTH535# undef __UINT_LEAST16_WIDTH536#define __UINT_LEAST16_WIDTH UINT48_WIDTH537# undef __UINT_LEAST8_WIDTH538#define __UINT_LEAST8_WIDTH UINT48_WIDTH539#endif /* __STDC_VERSION__ */540#endif /* __INT48_TYPE__ */541 542 543#ifdef __INT40_TYPE__544# define INT40_MAX INT40_C(549755813887)545# define INT40_MIN (-INT40_C(549755813887)-1)546# define UINT40_MAX UINT40_C(1099511627775)547# define INT_LEAST40_MIN INT40_MIN548# define INT_LEAST40_MAX INT40_MAX549# define UINT_LEAST40_MAX UINT40_MAX550# define INT_FAST40_MIN INT40_MIN551# define INT_FAST40_MAX INT40_MAX552# define UINT_FAST40_MAX UINT40_MAX553 554# undef __INT_LEAST32_MIN555# define __INT_LEAST32_MIN INT40_MIN556# undef __INT_LEAST32_MAX557# define __INT_LEAST32_MAX INT40_MAX558# undef __UINT_LEAST32_MAX559# define __UINT_LEAST32_MAX UINT40_MAX560# undef __INT_LEAST16_MIN561# define __INT_LEAST16_MIN INT40_MIN562# undef __INT_LEAST16_MAX563# define __INT_LEAST16_MAX INT40_MAX564# undef __UINT_LEAST16_MAX565# define __UINT_LEAST16_MAX UINT40_MAX566# undef __INT_LEAST8_MIN567# define __INT_LEAST8_MIN INT40_MIN568# undef __INT_LEAST8_MAX569# define __INT_LEAST8_MAX INT40_MAX570# undef __UINT_LEAST8_MAX571# define __UINT_LEAST8_MAX UINT40_MAX572 573#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L574# define UINT40_WIDTH 40575# define INT40_WIDTH UINT40_WIDTH576# define UINT_LEAST40_WIDTH UINT40_WIDTH577# define INT_LEAST40_WIDTH UINT_LEAST40_WIDTH578# define UINT_FAST40_WIDTH UINT40_WIDTH579# define INT_FAST40_WIDTH UINT_FAST40_WIDTH580# undef __UINT_LEAST32_WIDTH581# define __UINT_LEAST32_WIDTH UINT40_WIDTH582# undef __UINT_LEAST16_WIDTH583# define __UINT_LEAST16_WIDTH UINT40_WIDTH584# undef __UINT_LEAST8_WIDTH585# define __UINT_LEAST8_WIDTH UINT40_WIDTH586#endif /* __STDC_VERSION__ */587#endif /* __INT40_TYPE__ */588 589 590#ifdef __INT32_TYPE__591# define INT32_MAX INT32_C(2147483647)592# define INT32_MIN (-INT32_C(2147483647)-1)593# define UINT32_MAX UINT32_C(4294967295)594 595# undef __INT_LEAST32_MIN596# define __INT_LEAST32_MIN INT32_MIN597# undef __INT_LEAST32_MAX598# define __INT_LEAST32_MAX INT32_MAX599# undef __UINT_LEAST32_MAX600# define __UINT_LEAST32_MAX UINT32_MAX601# undef __INT_LEAST16_MIN602# define __INT_LEAST16_MIN INT32_MIN603# undef __INT_LEAST16_MAX604# define __INT_LEAST16_MAX INT32_MAX605# undef __UINT_LEAST16_MAX606# define __UINT_LEAST16_MAX UINT32_MAX607# undef __INT_LEAST8_MIN608# define __INT_LEAST8_MIN INT32_MIN609# undef __INT_LEAST8_MAX610# define __INT_LEAST8_MAX INT32_MAX611# undef __UINT_LEAST8_MAX612# define __UINT_LEAST8_MAX UINT32_MAX613 614#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L615# define UINT32_WIDTH 32616# define INT32_WIDTH UINT32_WIDTH617# undef __UINT_LEAST32_WIDTH618# define __UINT_LEAST32_WIDTH UINT32_WIDTH619# undef __UINT_LEAST16_WIDTH620# define __UINT_LEAST16_WIDTH UINT32_WIDTH621# undef __UINT_LEAST8_WIDTH622# define __UINT_LEAST8_WIDTH UINT32_WIDTH623#endif /* __STDC_VERSION__ */624#endif /* __INT32_TYPE__ */625 626#ifdef __INT_LEAST32_MIN627# define INT_LEAST32_MIN __INT_LEAST32_MIN628# define INT_LEAST32_MAX __INT_LEAST32_MAX629# define UINT_LEAST32_MAX __UINT_LEAST32_MAX630# define INT_FAST32_MIN __INT_LEAST32_MIN631# define INT_FAST32_MAX __INT_LEAST32_MAX632# define UINT_FAST32_MAX __UINT_LEAST32_MAX633 634#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L635# define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH636# define INT_LEAST32_WIDTH UINT_LEAST32_WIDTH637# define UINT_FAST32_WIDTH __UINT_LEAST32_WIDTH638# define INT_FAST32_WIDTH UINT_FAST32_WIDTH639#endif /* __STDC_VERSION__ */640#endif /* __INT_LEAST32_MIN */641 642 643#ifdef __INT24_TYPE__644# define INT24_MAX INT24_C(8388607)645# define INT24_MIN (-INT24_C(8388607)-1)646# define UINT24_MAX UINT24_C(16777215)647# define INT_LEAST24_MIN INT24_MIN648# define INT_LEAST24_MAX INT24_MAX649# define UINT_LEAST24_MAX UINT24_MAX650# define INT_FAST24_MIN INT24_MIN651# define INT_FAST24_MAX INT24_MAX652# define UINT_FAST24_MAX UINT24_MAX653 654# undef __INT_LEAST16_MIN655# define __INT_LEAST16_MIN INT24_MIN656# undef __INT_LEAST16_MAX657# define __INT_LEAST16_MAX INT24_MAX658# undef __UINT_LEAST16_MAX659# define __UINT_LEAST16_MAX UINT24_MAX660# undef __INT_LEAST8_MIN661# define __INT_LEAST8_MIN INT24_MIN662# undef __INT_LEAST8_MAX663# define __INT_LEAST8_MAX INT24_MAX664# undef __UINT_LEAST8_MAX665# define __UINT_LEAST8_MAX UINT24_MAX666 667#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L668# define UINT24_WIDTH 24669# define INT24_WIDTH UINT24_WIDTH670# define UINT_LEAST24_WIDTH UINT24_WIDTH671# define INT_LEAST24_WIDTH UINT_LEAST24_WIDTH672# define UINT_FAST24_WIDTH UINT24_WIDTH673# define INT_FAST24_WIDTH UINT_FAST24_WIDTH674# undef __UINT_LEAST16_WIDTH675# define __UINT_LEAST16_WIDTH UINT24_WIDTH676# undef __UINT_LEAST8_WIDTH677# define __UINT_LEAST8_WIDTH UINT24_WIDTH678#endif /* __STDC_VERSION__ */679#endif /* __INT24_TYPE__ */680 681 682#ifdef __INT16_TYPE__683#define INT16_MAX INT16_C(32767)684#define INT16_MIN (-INT16_C(32767)-1)685#define UINT16_MAX UINT16_C(65535)686 687# undef __INT_LEAST16_MIN688# define __INT_LEAST16_MIN INT16_MIN689# undef __INT_LEAST16_MAX690# define __INT_LEAST16_MAX INT16_MAX691# undef __UINT_LEAST16_MAX692# define __UINT_LEAST16_MAX UINT16_MAX693# undef __INT_LEAST8_MIN694# define __INT_LEAST8_MIN INT16_MIN695# undef __INT_LEAST8_MAX696# define __INT_LEAST8_MAX INT16_MAX697# undef __UINT_LEAST8_MAX698# define __UINT_LEAST8_MAX UINT16_MAX699 700#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L701# define UINT16_WIDTH 16702# define INT16_WIDTH UINT16_WIDTH703# undef __UINT_LEAST16_WIDTH704# define __UINT_LEAST16_WIDTH UINT16_WIDTH705# undef __UINT_LEAST8_WIDTH706# define __UINT_LEAST8_WIDTH UINT16_WIDTH707#endif /* __STDC_VERSION__ */708#endif /* __INT16_TYPE__ */709 710#ifdef __INT_LEAST16_MIN711# define INT_LEAST16_MIN __INT_LEAST16_MIN712# define INT_LEAST16_MAX __INT_LEAST16_MAX713# define UINT_LEAST16_MAX __UINT_LEAST16_MAX714# define INT_FAST16_MIN __INT_LEAST16_MIN715# define INT_FAST16_MAX __INT_LEAST16_MAX716# define UINT_FAST16_MAX __UINT_LEAST16_MAX717 718#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L719# define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH720# define INT_LEAST16_WIDTH UINT_LEAST16_WIDTH721# define UINT_FAST16_WIDTH __UINT_LEAST16_WIDTH722# define INT_FAST16_WIDTH UINT_FAST16_WIDTH723#endif /* __STDC_VERSION__ */724#endif /* __INT_LEAST16_MIN */725 726 727#ifdef __INT8_TYPE__728# define INT8_MAX INT8_C(127)729# define INT8_MIN (-INT8_C(127)-1)730# define UINT8_MAX UINT8_C(255)731 732# undef __INT_LEAST8_MIN733# define __INT_LEAST8_MIN INT8_MIN734# undef __INT_LEAST8_MAX735# define __INT_LEAST8_MAX INT8_MAX736# undef __UINT_LEAST8_MAX737# define __UINT_LEAST8_MAX UINT8_MAX738 739#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L740# define UINT8_WIDTH 8741# define INT8_WIDTH UINT8_WIDTH742# undef __UINT_LEAST8_WIDTH743# define __UINT_LEAST8_WIDTH UINT8_WIDTH744#endif /* __STDC_VERSION__ */745#endif /* __INT8_TYPE__ */746 747#ifdef __INT_LEAST8_MIN748# define INT_LEAST8_MIN __INT_LEAST8_MIN749# define INT_LEAST8_MAX __INT_LEAST8_MAX750# define UINT_LEAST8_MAX __UINT_LEAST8_MAX751# define INT_FAST8_MIN __INT_LEAST8_MIN752# define INT_FAST8_MAX __INT_LEAST8_MAX753# define UINT_FAST8_MAX __UINT_LEAST8_MAX754 755#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L756# define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH757# define INT_LEAST8_WIDTH UINT_LEAST8_WIDTH758# define UINT_FAST8_WIDTH __UINT_LEAST8_WIDTH759# define INT_FAST8_WIDTH UINT_FAST8_WIDTH760#endif /* __STDC_VERSION__ */761#endif /* __INT_LEAST8_MIN */762 763/* Some utility macros */764#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN)765#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX)766#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX)767#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v))768#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))769 770/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */771/* C99 7.18.3 Limits of other integer types. */772 773#define INTPTR_MIN (-__INTPTR_MAX__-1)774#define INTPTR_MAX __INTPTR_MAX__775#define UINTPTR_MAX __UINTPTR_MAX__776#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1)777#define PTRDIFF_MAX __PTRDIFF_MAX__778#define SIZE_MAX __SIZE_MAX__779 780/* C23 7.22.2.4 Width of integer types capable of holding object pointers. */781#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L782/* NB: The C standard requires that these be the same value, but the compiler783 exposes separate internal width macros. */784#define INTPTR_WIDTH __INTPTR_WIDTH__785#define UINTPTR_WIDTH __UINTPTR_WIDTH__786#endif787 788/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__789 * is enabled. */790#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1791#define RSIZE_MAX (SIZE_MAX >> 1)792#endif793 794/* C99 7.18.2.5 Limits of greatest-width integer types. */795#define INTMAX_MIN (-__INTMAX_MAX__-1)796#define INTMAX_MAX __INTMAX_MAX__797#define UINTMAX_MAX __UINTMAX_MAX__798 799/* C23 7.22.2.5 Width of greatest-width integer types. */800#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L801/* NB: The C standard requires that these be the same value, but the compiler802 exposes separate internal width macros. */803#define INTMAX_WIDTH __INTMAX_WIDTH__804#define UINTMAX_WIDTH __UINTMAX_WIDTH__805#endif806 807/* C99 7.18.3 Limits of other integer types. */808#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)809#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)810#ifdef __WINT_UNSIGNED__811# define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0)812# define WINT_MAX __UINTN_MAX(__WINT_WIDTH__)813#else814# define WINT_MIN __INTN_MIN(__WINT_WIDTH__)815# define WINT_MAX __INTN_MAX(__WINT_WIDTH__)816#endif817 818#ifndef WCHAR_MAX819# define WCHAR_MAX __WCHAR_MAX__820#endif821#ifndef WCHAR_MIN822# if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)823# define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)824# else825# define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)826# endif827#endif828 829/* 7.18.4.2 Macros for greatest-width integer constants. */830#define INTMAX_C(v) __INTMAX_C(v)831#define UINTMAX_C(v) __UINTMAX_C(v)832 833/* C23 7.22.3.x Width of other integer types. */834#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L835#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__836#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__837#define SIZE_WIDTH __SIZE_WIDTH__838#define WCHAR_WIDTH __WCHAR_WIDTH__839#define WINT_WIDTH __WINT_WIDTH__840#endif841 842#endif /* __STDC_HOSTED__ */843#endif /* __MVS__ */844#endif /* __CLANG_STDINT_H */845