879 lines · c
1//===-- Definition of macros from stdint.h --------------------------------===//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 LLVM_LIBC_MACROS_STDINT_MACROS_H10#define LLVM_LIBC_MACROS_STDINT_MACROS_H11 12// These definitions are copied directly from the clang implementation located13// at 'clang/lib/Headers/stdint.h'. We provide it here again for compatibility.14 15/* C99 7.18.1.1 Exact-width integer types.16 * C99 7.18.1.2 Minimum-width integer types.17 * C99 7.18.1.3 Fastest minimum-width integer types.18 *19 * The standard requires that exact-width type be defined for 8-, 16-, 32-, and20 * 64-bit types if they are implemented. Other exact width types are optional.21 * This implementation defines an exact-width types for every integer width22 * that is represented in the standard integer types.23 *24 * The standard also requires minimum-width types be defined for 8-, 16-, 32-,25 * and 64-bit widths regardless of whether there are corresponding exact-width26 * types.27 *28 * To accommodate targets that are missing types that are exactly 8, 16, 32, or29 * 64 bits wide, this implementation takes an approach of cascading30 * redefinitions, redefining __int_leastN_t to successively smaller exact-width31 * types. It is therefore important that the types are defined in order of32 * descending widths.33 *34 * We currently assume that the minimum-width types and the fastest35 * minimum-width types are the same. This is allowed by the standard, but is36 * suboptimal.37 *38 * In violation of the standard, some targets do not implement a type that is39 * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit).40 * To accommodate these targets, a required minimum-width type is only41 * defined if there exists an exact-width type of equal or greater width.42 */43 44#ifdef __INT64_TYPE__45#ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/46typedef __INT64_TYPE__ int64_t;47#endif /* __int8_t_defined */48typedef __UINT64_TYPE__ uint64_t;49#undef __int_least64_t50#define __int_least64_t int64_t51#undef __uint_least64_t52#define __uint_least64_t uint64_t53#undef __int_least32_t54#define __int_least32_t int64_t55#undef __uint_least32_t56#define __uint_least32_t uint64_t57#undef __int_least16_t58#define __int_least16_t int64_t59#undef __uint_least16_t60#define __uint_least16_t uint64_t61#undef __int_least8_t62#define __int_least8_t int64_t63#undef __uint_least8_t64#define __uint_least8_t uint64_t65#endif /* __INT64_TYPE__ */66 67#ifdef __int_least64_t68typedef __int_least64_t int_least64_t;69typedef __uint_least64_t uint_least64_t;70typedef __int_least64_t int_fast64_t;71typedef __uint_least64_t uint_fast64_t;72#endif /* __int_least64_t */73 74#ifdef __INT56_TYPE__75typedef __INT56_TYPE__ int56_t;76typedef __UINT56_TYPE__ uint56_t;77typedef int56_t int_least56_t;78typedef uint56_t uint_least56_t;79typedef int56_t int_fast56_t;80typedef uint56_t uint_fast56_t;81#undef __int_least32_t82#define __int_least32_t int56_t83#undef __uint_least32_t84#define __uint_least32_t uint56_t85#undef __int_least16_t86#define __int_least16_t int56_t87#undef __uint_least16_t88#define __uint_least16_t uint56_t89#undef __int_least8_t90#define __int_least8_t int56_t91#undef __uint_least8_t92#define __uint_least8_t uint56_t93#endif /* __INT56_TYPE__ */94 95#ifdef __INT48_TYPE__96typedef __INT48_TYPE__ int48_t;97typedef __UINT48_TYPE__ uint48_t;98typedef int48_t int_least48_t;99typedef uint48_t uint_least48_t;100typedef int48_t int_fast48_t;101typedef uint48_t uint_fast48_t;102#undef __int_least32_t103#define __int_least32_t int48_t104#undef __uint_least32_t105#define __uint_least32_t uint48_t106#undef __int_least16_t107#define __int_least16_t int48_t108#undef __uint_least16_t109#define __uint_least16_t uint48_t110#undef __int_least8_t111#define __int_least8_t int48_t112#undef __uint_least8_t113#define __uint_least8_t uint48_t114#endif /* __INT48_TYPE__ */115 116#ifdef __INT40_TYPE__117typedef __INT40_TYPE__ int40_t;118typedef __UINT40_TYPE__ uint40_t;119typedef int40_t int_least40_t;120typedef uint40_t uint_least40_t;121typedef int40_t int_fast40_t;122typedef uint40_t uint_fast40_t;123#undef __int_least32_t124#define __int_least32_t int40_t125#undef __uint_least32_t126#define __uint_least32_t uint40_t127#undef __int_least16_t128#define __int_least16_t int40_t129#undef __uint_least16_t130#define __uint_least16_t uint40_t131#undef __int_least8_t132#define __int_least8_t int40_t133#undef __uint_least8_t134#define __uint_least8_t uint40_t135#endif /* __INT40_TYPE__ */136 137#ifdef __INT32_TYPE__138 139#ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/140typedef __INT32_TYPE__ int32_t;141#endif /* __int8_t_defined */142 143#ifndef __uint32_t_defined /* more glibc compatibility */144#define __uint32_t_defined145typedef __UINT32_TYPE__ uint32_t;146#endif /* __uint32_t_defined */147 148#undef __int_least32_t149#define __int_least32_t int32_t150#undef __uint_least32_t151#define __uint_least32_t uint32_t152#undef __int_least16_t153#define __int_least16_t int32_t154#undef __uint_least16_t155#define __uint_least16_t uint32_t156#undef __int_least8_t157#define __int_least8_t int32_t158#undef __uint_least8_t159#define __uint_least8_t uint32_t160#endif /* __INT32_TYPE__ */161 162#ifdef __int_least32_t163typedef __int_least32_t int_least32_t;164typedef __uint_least32_t uint_least32_t;165typedef __int_least32_t int_fast32_t;166typedef __uint_least32_t uint_fast32_t;167#endif /* __int_least32_t */168 169#ifdef __INT24_TYPE__170typedef __INT24_TYPE__ int24_t;171typedef __UINT24_TYPE__ uint24_t;172typedef int24_t int_least24_t;173typedef uint24_t uint_least24_t;174typedef int24_t int_fast24_t;175typedef uint24_t uint_fast24_t;176#undef __int_least16_t177#define __int_least16_t int24_t178#undef __uint_least16_t179#define __uint_least16_t uint24_t180#undef __int_least8_t181#define __int_least8_t int24_t182#undef __uint_least8_t183#define __uint_least8_t uint24_t184#endif /* __INT24_TYPE__ */185 186#ifdef __INT16_TYPE__187#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/188typedef __INT16_TYPE__ int16_t;189#endif /* __int8_t_defined */190typedef __UINT16_TYPE__ uint16_t;191#undef __int_least16_t192#define __int_least16_t int16_t193#undef __uint_least16_t194#define __uint_least16_t uint16_t195#undef __int_least8_t196#define __int_least8_t int16_t197#undef __uint_least8_t198#define __uint_least8_t uint16_t199#endif /* __INT16_TYPE__ */200 201#ifdef __int_least16_t202typedef __int_least16_t int_least16_t;203typedef __uint_least16_t uint_least16_t;204typedef __int_least16_t int_fast16_t;205typedef __uint_least16_t uint_fast16_t;206#endif /* __int_least16_t */207 208#ifdef __INT8_TYPE__209#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/210typedef __INT8_TYPE__ int8_t;211#endif /* __int8_t_defined */212typedef __UINT8_TYPE__ uint8_t;213#undef __int_least8_t214#define __int_least8_t int8_t215#undef __uint_least8_t216#define __uint_least8_t uint8_t217#endif /* __INT8_TYPE__ */218 219#ifdef __int_least8_t220typedef __int_least8_t int_least8_t;221typedef __uint_least8_t uint_least8_t;222typedef __int_least8_t int_fast8_t;223typedef __uint_least8_t uint_fast8_t;224#endif /* __int_least8_t */225 226/* prevent glibc sys/types.h from defining conflicting types */227#ifndef __int8_t_defined228#define __int8_t_defined229#endif /* __int8_t_defined */230 231/* C99 7.18.1.4 Integer types capable of holding object pointers.232 */233#define __stdint_join3(a, b, c) a##b##c234 235#ifndef _INTPTR_T236#ifndef __intptr_t_defined237typedef __INTPTR_TYPE__ intptr_t;238#define __intptr_t_defined239#define _INTPTR_T240#endif241#endif242 243#ifndef _UINTPTR_T244typedef __UINTPTR_TYPE__ uintptr_t;245#define _UINTPTR_T246#endif247 248/* C99 7.18.1.5 Greatest-width integer types.249 */250typedef __INTMAX_TYPE__ intmax_t;251typedef __UINTMAX_TYPE__ uintmax_t;252 253/* C99 7.18.4 Macros for minimum-width integer constants.254 *255 * The standard requires that integer constant macros be defined for all the256 * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width257 * types are required, the corresponding integer constant macros are defined258 * here. This implementation also defines minimum-width types for every other259 * integer width that the target implements, so corresponding macros are260 * defined below, too.261 *262 * These macros are defined using the same successive-shrinking approach as263 * the type definitions above. It is likewise important that macros are defined264 * in order of decending width.265 *266 * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the267 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).268 */269 270#define __int_c_join(a, b) a##b271#define __int_c(v, suffix) __int_c_join(v, suffix)272#define __uint_c(v, suffix) __int_c_join(v##U, suffix)273 274#ifdef __INT64_TYPE__275#undef __int64_c_suffix276#undef __int32_c_suffix277#undef __int16_c_suffix278#undef __int8_c_suffix279#ifdef __INT64_C_SUFFIX__280#define __int64_c_suffix __INT64_C_SUFFIX__281#define __int32_c_suffix __INT64_C_SUFFIX__282#define __int16_c_suffix __INT64_C_SUFFIX__283#define __int8_c_suffix __INT64_C_SUFFIX__284#endif /* __INT64_C_SUFFIX__ */285#endif /* __INT64_TYPE__ */286 287#ifdef __int_least64_t288#ifdef __int64_c_suffix289#define INT64_C(v) __int_c(v, __int64_c_suffix)290#define UINT64_C(v) __uint_c(v, __int64_c_suffix)291#else292#define INT64_C(v) v293#define UINT64_C(v) v##U294#endif /* __int64_c_suffix */295#endif /* __int_least64_t */296 297#ifdef __INT56_TYPE__298#undef __int32_c_suffix299#undef __int16_c_suffix300#undef __int8_c_suffix301#ifdef __INT56_C_SUFFIX__302#define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__)303#define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__)304#define __int32_c_suffix __INT56_C_SUFFIX__305#define __int16_c_suffix __INT56_C_SUFFIX__306#define __int8_c_suffix __INT56_C_SUFFIX__307#else308#define INT56_C(v) v309#define UINT56_C(v) v##U310#endif /* __INT56_C_SUFFIX__ */311#endif /* __INT56_TYPE__ */312 313#ifdef __INT48_TYPE__314#undef __int32_c_suffix315#undef __int16_c_suffix316#undef __int8_c_suffix317#ifdef __INT48_C_SUFFIX__318#define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__)319#define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__)320#define __int32_c_suffix __INT48_C_SUFFIX__321#define __int16_c_suffix __INT48_C_SUFFIX__322#define __int8_c_suffix __INT48_C_SUFFIX__323#else324#define INT48_C(v) v325#define UINT48_C(v) v##U326#endif /* __INT48_C_SUFFIX__ */327#endif /* __INT48_TYPE__ */328 329#ifdef __INT40_TYPE__330#undef __int32_c_suffix331#undef __int16_c_suffix332#undef __int8_c_suffix333#ifdef __INT40_C_SUFFIX__334#define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__)335#define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__)336#define __int32_c_suffix __INT40_C_SUFFIX__337#define __int16_c_suffix __INT40_C_SUFFIX__338#define __int8_c_suffix __INT40_C_SUFFIX__339#else340#define INT40_C(v) v341#define UINT40_C(v) v##U342#endif /* __INT40_C_SUFFIX__ */343#endif /* __INT40_TYPE__ */344 345#ifdef __INT32_TYPE__346#undef __int32_c_suffix347#undef __int16_c_suffix348#undef __int8_c_suffix349#ifdef __INT32_C_SUFFIX__350#define __int32_c_suffix __INT32_C_SUFFIX__351#define __int16_c_suffix __INT32_C_SUFFIX__352#define __int8_c_suffix __INT32_C_SUFFIX__353#endif /* __INT32_C_SUFFIX__ */354#endif /* __INT32_TYPE__ */355 356#ifdef __int_least32_t357#ifdef __int32_c_suffix358#define INT32_C(v) __int_c(v, __int32_c_suffix)359#define UINT32_C(v) __uint_c(v, __int32_c_suffix)360#else361#define INT32_C(v) v362#define UINT32_C(v) v##U363#endif /* __int32_c_suffix */364#endif /* __int_least32_t */365 366#ifdef __INT24_TYPE__367#undef __int16_c_suffix368#undef __int8_c_suffix369#ifdef __INT24_C_SUFFIX__370#define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__)371#define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__)372#define __int16_c_suffix __INT24_C_SUFFIX__373#define __int8_c_suffix __INT24_C_SUFFIX__374#else375#define INT24_C(v) v376#define UINT24_C(v) v##U377#endif /* __INT24_C_SUFFIX__ */378#endif /* __INT24_TYPE__ */379 380#ifdef __INT16_TYPE__381#undef __int16_c_suffix382#undef __int8_c_suffix383#ifdef __INT16_C_SUFFIX__384#define __int16_c_suffix __INT16_C_SUFFIX__385#define __int8_c_suffix __INT16_C_SUFFIX__386#endif /* __INT16_C_SUFFIX__ */387#endif /* __INT16_TYPE__ */388 389#ifdef __int_least16_t390#ifdef __int16_c_suffix391#define INT16_C(v) __int_c(v, __int16_c_suffix)392#define UINT16_C(v) __uint_c(v, __int16_c_suffix)393#else394#define INT16_C(v) v395#define UINT16_C(v) v##U396#endif /* __int16_c_suffix */397#endif /* __int_least16_t */398 399#ifdef __INT8_TYPE__400#undef __int8_c_suffix401#ifdef __INT8_C_SUFFIX__402#define __int8_c_suffix __INT8_C_SUFFIX__403#endif /* __INT8_C_SUFFIX__ */404#endif /* __INT8_TYPE__ */405 406#ifdef __int_least8_t407#ifdef __int8_c_suffix408#define INT8_C(v) __int_c(v, __int8_c_suffix)409#define UINT8_C(v) __uint_c(v, __int8_c_suffix)410#else411#define INT8_C(v) v412#define UINT8_C(v) v##U413#endif /* __int8_c_suffix */414#endif /* __int_least8_t */415 416/* C99 7.18.2.1 Limits of exact-width integer types.417 * C99 7.18.2.2 Limits of minimum-width integer types.418 * C99 7.18.2.3 Limits of fastest minimum-width integer types.419 *420 * The presence of limit macros are completely optional in C99. This421 * implementation defines limits for all of the types (exact- and422 * minimum-width) that it defines above, using the limits of the minimum-width423 * type for any types that do not have exact-width representations.424 *425 * As in the type definitions, this section takes an approach of426 * successive-shrinking to determine which limits to use for the standard (8,427 * 16, 32, 64) bit widths when they don't have exact representations. It is428 * therefore important that the definitions be kept in order of decending429 * widths.430 *431 * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the432 * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).433 */434 435#ifdef __INT64_TYPE__436#define INT64_MAX INT64_C(9223372036854775807)437#define INT64_MIN (-INT64_C(9223372036854775807) - 1)438#define UINT64_MAX UINT64_C(18446744073709551615)439 440#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L441#define UINT64_WIDTH 64442#define INT64_WIDTH UINT64_WIDTH443 444#define __UINT_LEAST64_WIDTH UINT64_WIDTH445#undef __UINT_LEAST32_WIDTH446#define __UINT_LEAST32_WIDTH UINT64_WIDTH447#undef __UINT_LEAST16_WIDTH448#define __UINT_LEAST16_WIDTH UINT64_WIDTH449#undef __UINT_LEAST8_MAX450#define __UINT_LEAST8_MAX UINT64_MAX451#endif /* __STDC_VERSION__ */452 453#define __INT_LEAST64_MIN INT64_MIN454#define __INT_LEAST64_MAX INT64_MAX455#define __UINT_LEAST64_MAX UINT64_MAX456#undef __INT_LEAST32_MIN457#define __INT_LEAST32_MIN INT64_MIN458#undef __INT_LEAST32_MAX459#define __INT_LEAST32_MAX INT64_MAX460#undef __UINT_LEAST32_MAX461#define __UINT_LEAST32_MAX UINT64_MAX462#undef __INT_LEAST16_MIN463#define __INT_LEAST16_MIN INT64_MIN464#undef __INT_LEAST16_MAX465#define __INT_LEAST16_MAX INT64_MAX466#undef __UINT_LEAST16_MAX467#define __UINT_LEAST16_MAX UINT64_MAX468#undef __INT_LEAST8_MIN469#define __INT_LEAST8_MIN INT64_MIN470#undef __INT_LEAST8_MAX471#define __INT_LEAST8_MAX INT64_MAX472#undef __UINT_LEAST8_MAX473#define __UINT_LEAST8_MAX UINT64_MAX474#endif /* __INT64_TYPE__ */475 476#ifdef __INT_LEAST64_MIN477#define INT_LEAST64_MIN __INT_LEAST64_MIN478#define INT_LEAST64_MAX __INT_LEAST64_MAX479#define UINT_LEAST64_MAX __UINT_LEAST64_MAX480#define INT_FAST64_MIN __INT_LEAST64_MIN481#define INT_FAST64_MAX __INT_LEAST64_MAX482#define UINT_FAST64_MAX __UINT_LEAST64_MAX483 484#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L485#define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH486#define INT_LEAST64_WIDTH UINT_LEAST64_WIDTH487#define UINT_FAST64_WIDTH __UINT_LEAST64_WIDTH488#define INT_FAST64_WIDTH UINT_FAST64_WIDTH489#endif /* __STDC_VERSION__ */490#endif /* __INT_LEAST64_MIN */491 492#ifdef __INT56_TYPE__493#define INT56_MAX INT56_C(36028797018963967)494#define INT56_MIN (-INT56_C(36028797018963967) - 1)495#define UINT56_MAX UINT56_C(72057594037927935)496#define INT_LEAST56_MIN INT56_MIN497#define INT_LEAST56_MAX INT56_MAX498#define UINT_LEAST56_MAX UINT56_MAX499#define INT_FAST56_MIN INT56_MIN500#define INT_FAST56_MAX INT56_MAX501#define UINT_FAST56_MAX UINT56_MAX502 503#undef __INT_LEAST32_MIN504#define __INT_LEAST32_MIN INT56_MIN505#undef __INT_LEAST32_MAX506#define __INT_LEAST32_MAX INT56_MAX507#undef __UINT_LEAST32_MAX508#define __UINT_LEAST32_MAX UINT56_MAX509#undef __INT_LEAST16_MIN510#define __INT_LEAST16_MIN INT56_MIN511#undef __INT_LEAST16_MAX512#define __INT_LEAST16_MAX INT56_MAX513#undef __UINT_LEAST16_MAX514#define __UINT_LEAST16_MAX UINT56_MAX515#undef __INT_LEAST8_MIN516#define __INT_LEAST8_MIN INT56_MIN517#undef __INT_LEAST8_MAX518#define __INT_LEAST8_MAX INT56_MAX519#undef __UINT_LEAST8_MAX520#define __UINT_LEAST8_MAX UINT56_MAX521 522#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L523#define UINT56_WIDTH 56524#define INT56_WIDTH UINT56_WIDTH525#define UINT_LEAST56_WIDTH UINT56_WIDTH526#define INT_LEAST56_WIDTH UINT_LEAST56_WIDTH527#define UINT_FAST56_WIDTH UINT56_WIDTH528#define INT_FAST56_WIDTH UINT_FAST56_WIDTH529#undef __UINT_LEAST32_WIDTH530#define __UINT_LEAST32_WIDTH UINT56_WIDTH531#undef __UINT_LEAST16_WIDTH532#define __UINT_LEAST16_WIDTH UINT56_WIDTH533#undef __UINT_LEAST8_WIDTH534#define __UINT_LEAST8_WIDTH UINT56_WIDTH535#endif /* __STDC_VERSION__ */536#endif /* __INT56_TYPE__ */537 538#ifdef __INT48_TYPE__539#define INT48_MAX INT48_C(140737488355327)540#define INT48_MIN (-INT48_C(140737488355327) - 1)541#define UINT48_MAX UINT48_C(281474976710655)542#define INT_LEAST48_MIN INT48_MIN543#define INT_LEAST48_MAX INT48_MAX544#define UINT_LEAST48_MAX UINT48_MAX545#define INT_FAST48_MIN INT48_MIN546#define INT_FAST48_MAX INT48_MAX547#define UINT_FAST48_MAX UINT48_MAX548 549#undef __INT_LEAST32_MIN550#define __INT_LEAST32_MIN INT48_MIN551#undef __INT_LEAST32_MAX552#define __INT_LEAST32_MAX INT48_MAX553#undef __UINT_LEAST32_MAX554#define __UINT_LEAST32_MAX UINT48_MAX555#undef __INT_LEAST16_MIN556#define __INT_LEAST16_MIN INT48_MIN557#undef __INT_LEAST16_MAX558#define __INT_LEAST16_MAX INT48_MAX559#undef __UINT_LEAST16_MAX560#define __UINT_LEAST16_MAX UINT48_MAX561#undef __INT_LEAST8_MIN562#define __INT_LEAST8_MIN INT48_MIN563#undef __INT_LEAST8_MAX564#define __INT_LEAST8_MAX INT48_MAX565#undef __UINT_LEAST8_MAX566#define __UINT_LEAST8_MAX UINT48_MAX567 568#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L569#define UINT48_WIDTH 48570#define INT48_WIDTH UINT48_WIDTH571#define UINT_LEAST48_WIDTH UINT48_WIDTH572#define INT_LEAST48_WIDTH UINT_LEAST48_WIDTH573#define UINT_FAST48_WIDTH UINT48_WIDTH574#define INT_FAST48_WIDTH UINT_FAST48_WIDTH575#undef __UINT_LEAST32_WIDTH576#define __UINT_LEAST32_WIDTH UINT48_WIDTH577#undef __UINT_LEAST16_WIDTH578#define __UINT_LEAST16_WIDTH UINT48_WIDTH579#undef __UINT_LEAST8_WIDTH580#define __UINT_LEAST8_WIDTH UINT48_WIDTH581#endif /* __STDC_VERSION__ */582#endif /* __INT48_TYPE__ */583 584#ifdef __INT40_TYPE__585#define INT40_MAX INT40_C(549755813887)586#define INT40_MIN (-INT40_C(549755813887) - 1)587#define UINT40_MAX UINT40_C(1099511627775)588#define INT_LEAST40_MIN INT40_MIN589#define INT_LEAST40_MAX INT40_MAX590#define UINT_LEAST40_MAX UINT40_MAX591#define INT_FAST40_MIN INT40_MIN592#define INT_FAST40_MAX INT40_MAX593#define UINT_FAST40_MAX UINT40_MAX594 595#undef __INT_LEAST32_MIN596#define __INT_LEAST32_MIN INT40_MIN597#undef __INT_LEAST32_MAX598#define __INT_LEAST32_MAX INT40_MAX599#undef __UINT_LEAST32_MAX600#define __UINT_LEAST32_MAX UINT40_MAX601#undef __INT_LEAST16_MIN602#define __INT_LEAST16_MIN INT40_MIN603#undef __INT_LEAST16_MAX604#define __INT_LEAST16_MAX INT40_MAX605#undef __UINT_LEAST16_MAX606#define __UINT_LEAST16_MAX UINT40_MAX607#undef __INT_LEAST8_MIN608#define __INT_LEAST8_MIN INT40_MIN609#undef __INT_LEAST8_MAX610#define __INT_LEAST8_MAX INT40_MAX611#undef __UINT_LEAST8_MAX612#define __UINT_LEAST8_MAX UINT40_MAX613 614#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L615#define UINT40_WIDTH 40616#define INT40_WIDTH UINT40_WIDTH617#define UINT_LEAST40_WIDTH UINT40_WIDTH618#define INT_LEAST40_WIDTH UINT_LEAST40_WIDTH619#define UINT_FAST40_WIDTH UINT40_WIDTH620#define INT_FAST40_WIDTH UINT_FAST40_WIDTH621#undef __UINT_LEAST32_WIDTH622#define __UINT_LEAST32_WIDTH UINT40_WIDTH623#undef __UINT_LEAST16_WIDTH624#define __UINT_LEAST16_WIDTH UINT40_WIDTH625#undef __UINT_LEAST8_WIDTH626#define __UINT_LEAST8_WIDTH UINT40_WIDTH627#endif /* __STDC_VERSION__ */628#endif /* __INT40_TYPE__ */629 630#ifdef __INT32_TYPE__631#define INT32_MAX INT32_C(2147483647)632#define INT32_MIN (-INT32_C(2147483647) - 1)633#define UINT32_MAX UINT32_C(4294967295)634 635#undef __INT_LEAST32_MIN636#define __INT_LEAST32_MIN INT32_MIN637#undef __INT_LEAST32_MAX638#define __INT_LEAST32_MAX INT32_MAX639#undef __UINT_LEAST32_MAX640#define __UINT_LEAST32_MAX UINT32_MAX641#undef __INT_LEAST16_MIN642#define __INT_LEAST16_MIN INT32_MIN643#undef __INT_LEAST16_MAX644#define __INT_LEAST16_MAX INT32_MAX645#undef __UINT_LEAST16_MAX646#define __UINT_LEAST16_MAX UINT32_MAX647#undef __INT_LEAST8_MIN648#define __INT_LEAST8_MIN INT32_MIN649#undef __INT_LEAST8_MAX650#define __INT_LEAST8_MAX INT32_MAX651#undef __UINT_LEAST8_MAX652#define __UINT_LEAST8_MAX UINT32_MAX653 654#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L655#define UINT32_WIDTH 32656#define INT32_WIDTH UINT32_WIDTH657#undef __UINT_LEAST32_WIDTH658#define __UINT_LEAST32_WIDTH UINT32_WIDTH659#undef __UINT_LEAST16_WIDTH660#define __UINT_LEAST16_WIDTH UINT32_WIDTH661#undef __UINT_LEAST8_WIDTH662#define __UINT_LEAST8_WIDTH UINT32_WIDTH663#endif /* __STDC_VERSION__ */664#endif /* __INT32_TYPE__ */665 666#ifdef __INT_LEAST32_MIN667#define INT_LEAST32_MIN __INT_LEAST32_MIN668#define INT_LEAST32_MAX __INT_LEAST32_MAX669#define UINT_LEAST32_MAX __UINT_LEAST32_MAX670#define INT_FAST32_MIN __INT_LEAST32_MIN671#define INT_FAST32_MAX __INT_LEAST32_MAX672#define UINT_FAST32_MAX __UINT_LEAST32_MAX673 674#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L675#define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH676#define INT_LEAST32_WIDTH UINT_LEAST32_WIDTH677#define UINT_FAST32_WIDTH __UINT_LEAST32_WIDTH678#define INT_FAST32_WIDTH UINT_FAST32_WIDTH679#endif /* __STDC_VERSION__ */680#endif /* __INT_LEAST32_MIN */681 682#ifdef __INT24_TYPE__683#define INT24_MAX INT24_C(8388607)684#define INT24_MIN (-INT24_C(8388607) - 1)685#define UINT24_MAX UINT24_C(16777215)686#define INT_LEAST24_MIN INT24_MIN687#define INT_LEAST24_MAX INT24_MAX688#define UINT_LEAST24_MAX UINT24_MAX689#define INT_FAST24_MIN INT24_MIN690#define INT_FAST24_MAX INT24_MAX691#define UINT_FAST24_MAX UINT24_MAX692 693#undef __INT_LEAST16_MIN694#define __INT_LEAST16_MIN INT24_MIN695#undef __INT_LEAST16_MAX696#define __INT_LEAST16_MAX INT24_MAX697#undef __UINT_LEAST16_MAX698#define __UINT_LEAST16_MAX UINT24_MAX699#undef __INT_LEAST8_MIN700#define __INT_LEAST8_MIN INT24_MIN701#undef __INT_LEAST8_MAX702#define __INT_LEAST8_MAX INT24_MAX703#undef __UINT_LEAST8_MAX704#define __UINT_LEAST8_MAX UINT24_MAX705 706#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L707#define UINT24_WIDTH 24708#define INT24_WIDTH UINT24_WIDTH709#define UINT_LEAST24_WIDTH UINT24_WIDTH710#define INT_LEAST24_WIDTH UINT_LEAST24_WIDTH711#define UINT_FAST24_WIDTH UINT24_WIDTH712#define INT_FAST24_WIDTH UINT_FAST24_WIDTH713#undef __UINT_LEAST16_WIDTH714#define __UINT_LEAST16_WIDTH UINT24_WIDTH715#undef __UINT_LEAST8_WIDTH716#define __UINT_LEAST8_WIDTH UINT24_WIDTH717#endif /* __STDC_VERSION__ */718#endif /* __INT24_TYPE__ */719 720#ifdef __INT16_TYPE__721#define INT16_MAX INT16_C(32767)722#define INT16_MIN (-INT16_C(32767) - 1)723#define UINT16_MAX UINT16_C(65535)724 725#undef __INT_LEAST16_MIN726#define __INT_LEAST16_MIN INT16_MIN727#undef __INT_LEAST16_MAX728#define __INT_LEAST16_MAX INT16_MAX729#undef __UINT_LEAST16_MAX730#define __UINT_LEAST16_MAX UINT16_MAX731#undef __INT_LEAST8_MIN732#define __INT_LEAST8_MIN INT16_MIN733#undef __INT_LEAST8_MAX734#define __INT_LEAST8_MAX INT16_MAX735#undef __UINT_LEAST8_MAX736#define __UINT_LEAST8_MAX UINT16_MAX737 738#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L739#define UINT16_WIDTH 16740#define INT16_WIDTH UINT16_WIDTH741#undef __UINT_LEAST16_WIDTH742#define __UINT_LEAST16_WIDTH UINT16_WIDTH743#undef __UINT_LEAST8_WIDTH744#define __UINT_LEAST8_WIDTH UINT16_WIDTH745#endif /* __STDC_VERSION__ */746#endif /* __INT16_TYPE__ */747 748#ifdef __INT_LEAST16_MIN749#define INT_LEAST16_MIN __INT_LEAST16_MIN750#define INT_LEAST16_MAX __INT_LEAST16_MAX751#define UINT_LEAST16_MAX __UINT_LEAST16_MAX752#define INT_FAST16_MIN __INT_LEAST16_MIN753#define INT_FAST16_MAX __INT_LEAST16_MAX754#define UINT_FAST16_MAX __UINT_LEAST16_MAX755 756#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L757#define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH758#define INT_LEAST16_WIDTH UINT_LEAST16_WIDTH759#define UINT_FAST16_WIDTH __UINT_LEAST16_WIDTH760#define INT_FAST16_WIDTH UINT_FAST16_WIDTH761#endif /* __STDC_VERSION__ */762#endif /* __INT_LEAST16_MIN */763 764#ifdef __INT8_TYPE__765#define INT8_MAX INT8_C(127)766#define INT8_MIN (-INT8_C(127) - 1)767#define UINT8_MAX UINT8_C(255)768 769#undef __INT_LEAST8_MIN770#define __INT_LEAST8_MIN INT8_MIN771#undef __INT_LEAST8_MAX772#define __INT_LEAST8_MAX INT8_MAX773#undef __UINT_LEAST8_MAX774#define __UINT_LEAST8_MAX UINT8_MAX775 776#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L777#define UINT8_WIDTH 8778#define INT8_WIDTH UINT8_WIDTH779#undef __UINT_LEAST8_WIDTH780#define __UINT_LEAST8_WIDTH UINT8_WIDTH781#endif /* __STDC_VERSION__ */782#endif /* __INT8_TYPE__ */783 784#ifdef __INT_LEAST8_MIN785#define INT_LEAST8_MIN __INT_LEAST8_MIN786#define INT_LEAST8_MAX __INT_LEAST8_MAX787#define UINT_LEAST8_MAX __UINT_LEAST8_MAX788#define INT_FAST8_MIN __INT_LEAST8_MIN789#define INT_FAST8_MAX __INT_LEAST8_MAX790#define UINT_FAST8_MAX __UINT_LEAST8_MAX791 792#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L793#define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH794#define INT_LEAST8_WIDTH UINT_LEAST8_WIDTH795#define UINT_FAST8_WIDTH __UINT_LEAST8_WIDTH796#define INT_FAST8_WIDTH UINT_FAST8_WIDTH797#endif /* __STDC_VERSION__ */798#endif /* __INT_LEAST8_MIN */799 800/* Some utility macros */801#define __INTN_MIN(n) __stdint_join3(INT, n, _MIN)802#define __INTN_MAX(n) __stdint_join3(INT, n, _MAX)803#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX)804#define __INTN_C(n, v) __stdint_join3(INT, n, _C(v))805#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))806 807/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */808/* C99 7.18.3 Limits of other integer types. */809 810#define INTPTR_MIN (-__INTPTR_MAX__ - 1)811#define INTPTR_MAX __INTPTR_MAX__812#define UINTPTR_MAX __UINTPTR_MAX__813#define PTRDIFF_MIN (-__PTRDIFF_MAX__ - 1)814#define PTRDIFF_MAX __PTRDIFF_MAX__815#define SIZE_MAX __SIZE_MAX__816 817/* C23 7.22.2.4 Width of integer types capable of holding object pointers. */818#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L819/* NB: The C standard requires that these be the same value, but the compiler820 exposes separate internal width macros. */821#define INTPTR_WIDTH __INTPTR_WIDTH__822#define UINTPTR_WIDTH __UINTPTR_WIDTH__823#endif824 825/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__826 * is enabled. */827#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1828#define RSIZE_MAX (SIZE_MAX >> 1)829#endif830 831/* C99 7.18.2.5 Limits of greatest-width integer types. */832#define INTMAX_MIN (-__INTMAX_MAX__ - 1)833#define INTMAX_MAX __INTMAX_MAX__834#define UINTMAX_MAX __UINTMAX_MAX__835 836/* C23 7.22.2.5 Width of greatest-width integer types. */837#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L838/* NB: The C standard requires that these be the same value, but the compiler839 exposes separate internal width macros. */840#define INTMAX_WIDTH __INTMAX_WIDTH__841#define UINTMAX_WIDTH __UINTMAX_WIDTH__842#endif843 844/* C99 7.18.3 Limits of other integer types. */845#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)846#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)847#ifdef __WINT_UNSIGNED__848#define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0)849#define WINT_MAX __UINTN_MAX(__WINT_WIDTH__)850#else851#define WINT_MIN __INTN_MIN(__WINT_WIDTH__)852#define WINT_MAX __INTN_MAX(__WINT_WIDTH__)853#endif854 855#ifndef WCHAR_MAX856#define WCHAR_MAX __WCHAR_MAX__857#endif858#ifndef WCHAR_MIN859#if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)860#define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)861#else862#define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)863#endif864#endif865 866/* 7.18.4.2 Macros for greatest-width integer constants. */867#define INTMAX_C(v) __int_c(v, __INTMAX_C_SUFFIX__)868#define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__)869 870/* C23 7.22.3.x Width of other integer types. */871#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L872#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__873#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__874#define SIZE_WIDTH __SIZE_WIDTH__875#define WCHAR_WIDTH __WCHAR_WIDTH__876#define WINT_WIDTH __WINT_WIDTH__877#endif878#endif // LLVM_LIBC_MACROS_STDINT_MACROS_H879