Path: blob/main/system/lib/llvm-libc/include/llvm-libc-macros/stdint-macros.h
6172 views
//===-- Definition of macros from stdint.h --------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIBC_MACROS_STDINT_MACROS_H9#define LLVM_LIBC_MACROS_STDINT_MACROS_H1011// These definitions are copied directly from the clang implementation located12// at 'clang/lib/Headers/stdint.h'. We provide it here again for compatibility.1314/* C99 7.18.1.1 Exact-width integer types.15* C99 7.18.1.2 Minimum-width integer types.16* C99 7.18.1.3 Fastest minimum-width integer types.17*18* The standard requires that exact-width type be defined for 8-, 16-, 32-, and19* 64-bit types if they are implemented. Other exact width types are optional.20* This implementation defines an exact-width types for every integer width21* that is represented in the standard integer types.22*23* The standard also requires minimum-width types be defined for 8-, 16-, 32-,24* and 64-bit widths regardless of whether there are corresponding exact-width25* types.26*27* To accommodate targets that are missing types that are exactly 8, 16, 32, or28* 64 bits wide, this implementation takes an approach of cascading29* redefinitions, redefining __int_leastN_t to successively smaller exact-width30* types. It is therefore important that the types are defined in order of31* descending widths.32*33* We currently assume that the minimum-width types and the fastest34* minimum-width types are the same. This is allowed by the standard, but is35* suboptimal.36*37* In violation of the standard, some targets do not implement a type that is38* wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit).39* To accommodate these targets, a required minimum-width type is only40* defined if there exists an exact-width type of equal or greater width.41*/4243#ifdef __INT64_TYPE__44#ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/45typedef __INT64_TYPE__ int64_t;46#endif /* __int8_t_defined */47typedef __UINT64_TYPE__ uint64_t;48#undef __int_least64_t49#define __int_least64_t int64_t50#undef __uint_least64_t51#define __uint_least64_t uint64_t52#undef __int_least32_t53#define __int_least32_t int64_t54#undef __uint_least32_t55#define __uint_least32_t uint64_t56#undef __int_least16_t57#define __int_least16_t int64_t58#undef __uint_least16_t59#define __uint_least16_t uint64_t60#undef __int_least8_t61#define __int_least8_t int64_t62#undef __uint_least8_t63#define __uint_least8_t uint64_t64#endif /* __INT64_TYPE__ */6566#ifdef __int_least64_t67typedef __int_least64_t int_least64_t;68typedef __uint_least64_t uint_least64_t;69typedef __int_least64_t int_fast64_t;70typedef __uint_least64_t uint_fast64_t;71#endif /* __int_least64_t */7273#ifdef __INT56_TYPE__74typedef __INT56_TYPE__ int56_t;75typedef __UINT56_TYPE__ uint56_t;76typedef int56_t int_least56_t;77typedef uint56_t uint_least56_t;78typedef int56_t int_fast56_t;79typedef uint56_t uint_fast56_t;80#undef __int_least32_t81#define __int_least32_t int56_t82#undef __uint_least32_t83#define __uint_least32_t uint56_t84#undef __int_least16_t85#define __int_least16_t int56_t86#undef __uint_least16_t87#define __uint_least16_t uint56_t88#undef __int_least8_t89#define __int_least8_t int56_t90#undef __uint_least8_t91#define __uint_least8_t uint56_t92#endif /* __INT56_TYPE__ */9394#ifdef __INT48_TYPE__95typedef __INT48_TYPE__ int48_t;96typedef __UINT48_TYPE__ uint48_t;97typedef int48_t int_least48_t;98typedef uint48_t uint_least48_t;99typedef int48_t int_fast48_t;100typedef uint48_t uint_fast48_t;101#undef __int_least32_t102#define __int_least32_t int48_t103#undef __uint_least32_t104#define __uint_least32_t uint48_t105#undef __int_least16_t106#define __int_least16_t int48_t107#undef __uint_least16_t108#define __uint_least16_t uint48_t109#undef __int_least8_t110#define __int_least8_t int48_t111#undef __uint_least8_t112#define __uint_least8_t uint48_t113#endif /* __INT48_TYPE__ */114115#ifdef __INT40_TYPE__116typedef __INT40_TYPE__ int40_t;117typedef __UINT40_TYPE__ uint40_t;118typedef int40_t int_least40_t;119typedef uint40_t uint_least40_t;120typedef int40_t int_fast40_t;121typedef uint40_t uint_fast40_t;122#undef __int_least32_t123#define __int_least32_t int40_t124#undef __uint_least32_t125#define __uint_least32_t uint40_t126#undef __int_least16_t127#define __int_least16_t int40_t128#undef __uint_least16_t129#define __uint_least16_t uint40_t130#undef __int_least8_t131#define __int_least8_t int40_t132#undef __uint_least8_t133#define __uint_least8_t uint40_t134#endif /* __INT40_TYPE__ */135136#ifdef __INT32_TYPE__137138#ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/139typedef __INT32_TYPE__ int32_t;140#endif /* __int8_t_defined */141142#ifndef __uint32_t_defined /* more glibc compatibility */143#define __uint32_t_defined144typedef __UINT32_TYPE__ uint32_t;145#endif /* __uint32_t_defined */146147#undef __int_least32_t148#define __int_least32_t int32_t149#undef __uint_least32_t150#define __uint_least32_t uint32_t151#undef __int_least16_t152#define __int_least16_t int32_t153#undef __uint_least16_t154#define __uint_least16_t uint32_t155#undef __int_least8_t156#define __int_least8_t int32_t157#undef __uint_least8_t158#define __uint_least8_t uint32_t159#endif /* __INT32_TYPE__ */160161#ifdef __int_least32_t162typedef __int_least32_t int_least32_t;163typedef __uint_least32_t uint_least32_t;164typedef __int_least32_t int_fast32_t;165typedef __uint_least32_t uint_fast32_t;166#endif /* __int_least32_t */167168#ifdef __INT24_TYPE__169typedef __INT24_TYPE__ int24_t;170typedef __UINT24_TYPE__ uint24_t;171typedef int24_t int_least24_t;172typedef uint24_t uint_least24_t;173typedef int24_t int_fast24_t;174typedef uint24_t uint_fast24_t;175#undef __int_least16_t176#define __int_least16_t int24_t177#undef __uint_least16_t178#define __uint_least16_t uint24_t179#undef __int_least8_t180#define __int_least8_t int24_t181#undef __uint_least8_t182#define __uint_least8_t uint24_t183#endif /* __INT24_TYPE__ */184185#ifdef __INT16_TYPE__186#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/187typedef __INT16_TYPE__ int16_t;188#endif /* __int8_t_defined */189typedef __UINT16_TYPE__ uint16_t;190#undef __int_least16_t191#define __int_least16_t int16_t192#undef __uint_least16_t193#define __uint_least16_t uint16_t194#undef __int_least8_t195#define __int_least8_t int16_t196#undef __uint_least8_t197#define __uint_least8_t uint16_t198#endif /* __INT16_TYPE__ */199200#ifdef __int_least16_t201typedef __int_least16_t int_least16_t;202typedef __uint_least16_t uint_least16_t;203typedef __int_least16_t int_fast16_t;204typedef __uint_least16_t uint_fast16_t;205#endif /* __int_least16_t */206207#ifdef __INT8_TYPE__208#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/209typedef __INT8_TYPE__ int8_t;210#endif /* __int8_t_defined */211typedef __UINT8_TYPE__ uint8_t;212#undef __int_least8_t213#define __int_least8_t int8_t214#undef __uint_least8_t215#define __uint_least8_t uint8_t216#endif /* __INT8_TYPE__ */217218#ifdef __int_least8_t219typedef __int_least8_t int_least8_t;220typedef __uint_least8_t uint_least8_t;221typedef __int_least8_t int_fast8_t;222typedef __uint_least8_t uint_fast8_t;223#endif /* __int_least8_t */224225/* prevent glibc sys/types.h from defining conflicting types */226#ifndef __int8_t_defined227#define __int8_t_defined228#endif /* __int8_t_defined */229230/* C99 7.18.1.4 Integer types capable of holding object pointers.231*/232#define __stdint_join3(a, b, c) a##b##c233234#ifndef _INTPTR_T235#ifndef __intptr_t_defined236typedef __INTPTR_TYPE__ intptr_t;237#define __intptr_t_defined238#define _INTPTR_T239#endif240#endif241242#ifndef _UINTPTR_T243typedef __UINTPTR_TYPE__ uintptr_t;244#define _UINTPTR_T245#endif246247/* C99 7.18.1.5 Greatest-width integer types.248*/249typedef __INTMAX_TYPE__ intmax_t;250typedef __UINTMAX_TYPE__ uintmax_t;251252/* C99 7.18.4 Macros for minimum-width integer constants.253*254* The standard requires that integer constant macros be defined for all the255* minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width256* types are required, the corresponding integer constant macros are defined257* here. This implementation also defines minimum-width types for every other258* integer width that the target implements, so corresponding macros are259* defined below, too.260*261* These macros are defined using the same successive-shrinking approach as262* the type definitions above. It is likewise important that macros are defined263* in order of decending width.264*265* Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the266* claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).267*/268269#define __int_c_join(a, b) a##b270#define __int_c(v, suffix) __int_c_join(v, suffix)271#define __uint_c(v, suffix) __int_c_join(v##U, suffix)272273#ifdef __INT64_TYPE__274#undef __int64_c_suffix275#undef __int32_c_suffix276#undef __int16_c_suffix277#undef __int8_c_suffix278#ifdef __INT64_C_SUFFIX__279#define __int64_c_suffix __INT64_C_SUFFIX__280#define __int32_c_suffix __INT64_C_SUFFIX__281#define __int16_c_suffix __INT64_C_SUFFIX__282#define __int8_c_suffix __INT64_C_SUFFIX__283#endif /* __INT64_C_SUFFIX__ */284#endif /* __INT64_TYPE__ */285286#ifdef __int_least64_t287#ifdef __int64_c_suffix288#define INT64_C(v) __int_c(v, __int64_c_suffix)289#define UINT64_C(v) __uint_c(v, __int64_c_suffix)290#else291#define INT64_C(v) v292#define UINT64_C(v) v##U293#endif /* __int64_c_suffix */294#endif /* __int_least64_t */295296#ifdef __INT56_TYPE__297#undef __int32_c_suffix298#undef __int16_c_suffix299#undef __int8_c_suffix300#ifdef __INT56_C_SUFFIX__301#define INT56_C(v) __int_c(v, __INT56_C_SUFFIX__)302#define UINT56_C(v) __uint_c(v, __INT56_C_SUFFIX__)303#define __int32_c_suffix __INT56_C_SUFFIX__304#define __int16_c_suffix __INT56_C_SUFFIX__305#define __int8_c_suffix __INT56_C_SUFFIX__306#else307#define INT56_C(v) v308#define UINT56_C(v) v##U309#endif /* __INT56_C_SUFFIX__ */310#endif /* __INT56_TYPE__ */311312#ifdef __INT48_TYPE__313#undef __int32_c_suffix314#undef __int16_c_suffix315#undef __int8_c_suffix316#ifdef __INT48_C_SUFFIX__317#define INT48_C(v) __int_c(v, __INT48_C_SUFFIX__)318#define UINT48_C(v) __uint_c(v, __INT48_C_SUFFIX__)319#define __int32_c_suffix __INT48_C_SUFFIX__320#define __int16_c_suffix __INT48_C_SUFFIX__321#define __int8_c_suffix __INT48_C_SUFFIX__322#else323#define INT48_C(v) v324#define UINT48_C(v) v##U325#endif /* __INT48_C_SUFFIX__ */326#endif /* __INT48_TYPE__ */327328#ifdef __INT40_TYPE__329#undef __int32_c_suffix330#undef __int16_c_suffix331#undef __int8_c_suffix332#ifdef __INT40_C_SUFFIX__333#define INT40_C(v) __int_c(v, __INT40_C_SUFFIX__)334#define UINT40_C(v) __uint_c(v, __INT40_C_SUFFIX__)335#define __int32_c_suffix __INT40_C_SUFFIX__336#define __int16_c_suffix __INT40_C_SUFFIX__337#define __int8_c_suffix __INT40_C_SUFFIX__338#else339#define INT40_C(v) v340#define UINT40_C(v) v##U341#endif /* __INT40_C_SUFFIX__ */342#endif /* __INT40_TYPE__ */343344#ifdef __INT32_TYPE__345#undef __int32_c_suffix346#undef __int16_c_suffix347#undef __int8_c_suffix348#ifdef __INT32_C_SUFFIX__349#define __int32_c_suffix __INT32_C_SUFFIX__350#define __int16_c_suffix __INT32_C_SUFFIX__351#define __int8_c_suffix __INT32_C_SUFFIX__352#endif /* __INT32_C_SUFFIX__ */353#endif /* __INT32_TYPE__ */354355#ifdef __int_least32_t356#ifdef __int32_c_suffix357#define INT32_C(v) __int_c(v, __int32_c_suffix)358#define UINT32_C(v) __uint_c(v, __int32_c_suffix)359#else360#define INT32_C(v) v361#define UINT32_C(v) v##U362#endif /* __int32_c_suffix */363#endif /* __int_least32_t */364365#ifdef __INT24_TYPE__366#undef __int16_c_suffix367#undef __int8_c_suffix368#ifdef __INT24_C_SUFFIX__369#define INT24_C(v) __int_c(v, __INT24_C_SUFFIX__)370#define UINT24_C(v) __uint_c(v, __INT24_C_SUFFIX__)371#define __int16_c_suffix __INT24_C_SUFFIX__372#define __int8_c_suffix __INT24_C_SUFFIX__373#else374#define INT24_C(v) v375#define UINT24_C(v) v##U376#endif /* __INT24_C_SUFFIX__ */377#endif /* __INT24_TYPE__ */378379#ifdef __INT16_TYPE__380#undef __int16_c_suffix381#undef __int8_c_suffix382#ifdef __INT16_C_SUFFIX__383#define __int16_c_suffix __INT16_C_SUFFIX__384#define __int8_c_suffix __INT16_C_SUFFIX__385#endif /* __INT16_C_SUFFIX__ */386#endif /* __INT16_TYPE__ */387388#ifdef __int_least16_t389#ifdef __int16_c_suffix390#define INT16_C(v) __int_c(v, __int16_c_suffix)391#define UINT16_C(v) __uint_c(v, __int16_c_suffix)392#else393#define INT16_C(v) v394#define UINT16_C(v) v##U395#endif /* __int16_c_suffix */396#endif /* __int_least16_t */397398#ifdef __INT8_TYPE__399#undef __int8_c_suffix400#ifdef __INT8_C_SUFFIX__401#define __int8_c_suffix __INT8_C_SUFFIX__402#endif /* __INT8_C_SUFFIX__ */403#endif /* __INT8_TYPE__ */404405#ifdef __int_least8_t406#ifdef __int8_c_suffix407#define INT8_C(v) __int_c(v, __int8_c_suffix)408#define UINT8_C(v) __uint_c(v, __int8_c_suffix)409#else410#define INT8_C(v) v411#define UINT8_C(v) v##U412#endif /* __int8_c_suffix */413#endif /* __int_least8_t */414415/* C99 7.18.2.1 Limits of exact-width integer types.416* C99 7.18.2.2 Limits of minimum-width integer types.417* C99 7.18.2.3 Limits of fastest minimum-width integer types.418*419* The presence of limit macros are completely optional in C99. This420* implementation defines limits for all of the types (exact- and421* minimum-width) that it defines above, using the limits of the minimum-width422* type for any types that do not have exact-width representations.423*424* As in the type definitions, this section takes an approach of425* successive-shrinking to determine which limits to use for the standard (8,426* 16, 32, 64) bit widths when they don't have exact representations. It is427* therefore important that the definitions be kept in order of decending428* widths.429*430* Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the431* claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]).432*/433434#ifdef __INT64_TYPE__435#define INT64_MAX INT64_C(9223372036854775807)436#define INT64_MIN (-INT64_C(9223372036854775807) - 1)437#define UINT64_MAX UINT64_C(18446744073709551615)438439#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L440#define UINT64_WIDTH 64441#define INT64_WIDTH UINT64_WIDTH442443#define __UINT_LEAST64_WIDTH UINT64_WIDTH444#undef __UINT_LEAST32_WIDTH445#define __UINT_LEAST32_WIDTH UINT64_WIDTH446#undef __UINT_LEAST16_WIDTH447#define __UINT_LEAST16_WIDTH UINT64_WIDTH448#undef __UINT_LEAST8_MAX449#define __UINT_LEAST8_MAX UINT64_MAX450#endif /* __STDC_VERSION__ */451452#define __INT_LEAST64_MIN INT64_MIN453#define __INT_LEAST64_MAX INT64_MAX454#define __UINT_LEAST64_MAX UINT64_MAX455#undef __INT_LEAST32_MIN456#define __INT_LEAST32_MIN INT64_MIN457#undef __INT_LEAST32_MAX458#define __INT_LEAST32_MAX INT64_MAX459#undef __UINT_LEAST32_MAX460#define __UINT_LEAST32_MAX UINT64_MAX461#undef __INT_LEAST16_MIN462#define __INT_LEAST16_MIN INT64_MIN463#undef __INT_LEAST16_MAX464#define __INT_LEAST16_MAX INT64_MAX465#undef __UINT_LEAST16_MAX466#define __UINT_LEAST16_MAX UINT64_MAX467#undef __INT_LEAST8_MIN468#define __INT_LEAST8_MIN INT64_MIN469#undef __INT_LEAST8_MAX470#define __INT_LEAST8_MAX INT64_MAX471#undef __UINT_LEAST8_MAX472#define __UINT_LEAST8_MAX UINT64_MAX473#endif /* __INT64_TYPE__ */474475#ifdef __INT_LEAST64_MIN476#define INT_LEAST64_MIN __INT_LEAST64_MIN477#define INT_LEAST64_MAX __INT_LEAST64_MAX478#define UINT_LEAST64_MAX __UINT_LEAST64_MAX479#define INT_FAST64_MIN __INT_LEAST64_MIN480#define INT_FAST64_MAX __INT_LEAST64_MAX481#define UINT_FAST64_MAX __UINT_LEAST64_MAX482483#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L484#define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH485#define INT_LEAST64_WIDTH UINT_LEAST64_WIDTH486#define UINT_FAST64_WIDTH __UINT_LEAST64_WIDTH487#define INT_FAST64_WIDTH UINT_FAST64_WIDTH488#endif /* __STDC_VERSION__ */489#endif /* __INT_LEAST64_MIN */490491#ifdef __INT56_TYPE__492#define INT56_MAX INT56_C(36028797018963967)493#define INT56_MIN (-INT56_C(36028797018963967) - 1)494#define UINT56_MAX UINT56_C(72057594037927935)495#define INT_LEAST56_MIN INT56_MIN496#define INT_LEAST56_MAX INT56_MAX497#define UINT_LEAST56_MAX UINT56_MAX498#define INT_FAST56_MIN INT56_MIN499#define INT_FAST56_MAX INT56_MAX500#define UINT_FAST56_MAX UINT56_MAX501502#undef __INT_LEAST32_MIN503#define __INT_LEAST32_MIN INT56_MIN504#undef __INT_LEAST32_MAX505#define __INT_LEAST32_MAX INT56_MAX506#undef __UINT_LEAST32_MAX507#define __UINT_LEAST32_MAX UINT56_MAX508#undef __INT_LEAST16_MIN509#define __INT_LEAST16_MIN INT56_MIN510#undef __INT_LEAST16_MAX511#define __INT_LEAST16_MAX INT56_MAX512#undef __UINT_LEAST16_MAX513#define __UINT_LEAST16_MAX UINT56_MAX514#undef __INT_LEAST8_MIN515#define __INT_LEAST8_MIN INT56_MIN516#undef __INT_LEAST8_MAX517#define __INT_LEAST8_MAX INT56_MAX518#undef __UINT_LEAST8_MAX519#define __UINT_LEAST8_MAX UINT56_MAX520521#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L522#define UINT56_WIDTH 56523#define INT56_WIDTH UINT56_WIDTH524#define UINT_LEAST56_WIDTH UINT56_WIDTH525#define INT_LEAST56_WIDTH UINT_LEAST56_WIDTH526#define UINT_FAST56_WIDTH UINT56_WIDTH527#define INT_FAST56_WIDTH UINT_FAST56_WIDTH528#undef __UINT_LEAST32_WIDTH529#define __UINT_LEAST32_WIDTH UINT56_WIDTH530#undef __UINT_LEAST16_WIDTH531#define __UINT_LEAST16_WIDTH UINT56_WIDTH532#undef __UINT_LEAST8_WIDTH533#define __UINT_LEAST8_WIDTH UINT56_WIDTH534#endif /* __STDC_VERSION__ */535#endif /* __INT56_TYPE__ */536537#ifdef __INT48_TYPE__538#define INT48_MAX INT48_C(140737488355327)539#define INT48_MIN (-INT48_C(140737488355327) - 1)540#define UINT48_MAX UINT48_C(281474976710655)541#define INT_LEAST48_MIN INT48_MIN542#define INT_LEAST48_MAX INT48_MAX543#define UINT_LEAST48_MAX UINT48_MAX544#define INT_FAST48_MIN INT48_MIN545#define INT_FAST48_MAX INT48_MAX546#define UINT_FAST48_MAX UINT48_MAX547548#undef __INT_LEAST32_MIN549#define __INT_LEAST32_MIN INT48_MIN550#undef __INT_LEAST32_MAX551#define __INT_LEAST32_MAX INT48_MAX552#undef __UINT_LEAST32_MAX553#define __UINT_LEAST32_MAX UINT48_MAX554#undef __INT_LEAST16_MIN555#define __INT_LEAST16_MIN INT48_MIN556#undef __INT_LEAST16_MAX557#define __INT_LEAST16_MAX INT48_MAX558#undef __UINT_LEAST16_MAX559#define __UINT_LEAST16_MAX UINT48_MAX560#undef __INT_LEAST8_MIN561#define __INT_LEAST8_MIN INT48_MIN562#undef __INT_LEAST8_MAX563#define __INT_LEAST8_MAX INT48_MAX564#undef __UINT_LEAST8_MAX565#define __UINT_LEAST8_MAX UINT48_MAX566567#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L568#define UINT48_WIDTH 48569#define INT48_WIDTH UINT48_WIDTH570#define UINT_LEAST48_WIDTH UINT48_WIDTH571#define INT_LEAST48_WIDTH UINT_LEAST48_WIDTH572#define UINT_FAST48_WIDTH UINT48_WIDTH573#define INT_FAST48_WIDTH UINT_FAST48_WIDTH574#undef __UINT_LEAST32_WIDTH575#define __UINT_LEAST32_WIDTH UINT48_WIDTH576#undef __UINT_LEAST16_WIDTH577#define __UINT_LEAST16_WIDTH UINT48_WIDTH578#undef __UINT_LEAST8_WIDTH579#define __UINT_LEAST8_WIDTH UINT48_WIDTH580#endif /* __STDC_VERSION__ */581#endif /* __INT48_TYPE__ */582583#ifdef __INT40_TYPE__584#define INT40_MAX INT40_C(549755813887)585#define INT40_MIN (-INT40_C(549755813887) - 1)586#define UINT40_MAX UINT40_C(1099511627775)587#define INT_LEAST40_MIN INT40_MIN588#define INT_LEAST40_MAX INT40_MAX589#define UINT_LEAST40_MAX UINT40_MAX590#define INT_FAST40_MIN INT40_MIN591#define INT_FAST40_MAX INT40_MAX592#define UINT_FAST40_MAX UINT40_MAX593594#undef __INT_LEAST32_MIN595#define __INT_LEAST32_MIN INT40_MIN596#undef __INT_LEAST32_MAX597#define __INT_LEAST32_MAX INT40_MAX598#undef __UINT_LEAST32_MAX599#define __UINT_LEAST32_MAX UINT40_MAX600#undef __INT_LEAST16_MIN601#define __INT_LEAST16_MIN INT40_MIN602#undef __INT_LEAST16_MAX603#define __INT_LEAST16_MAX INT40_MAX604#undef __UINT_LEAST16_MAX605#define __UINT_LEAST16_MAX UINT40_MAX606#undef __INT_LEAST8_MIN607#define __INT_LEAST8_MIN INT40_MIN608#undef __INT_LEAST8_MAX609#define __INT_LEAST8_MAX INT40_MAX610#undef __UINT_LEAST8_MAX611#define __UINT_LEAST8_MAX UINT40_MAX612613#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L614#define UINT40_WIDTH 40615#define INT40_WIDTH UINT40_WIDTH616#define UINT_LEAST40_WIDTH UINT40_WIDTH617#define INT_LEAST40_WIDTH UINT_LEAST40_WIDTH618#define UINT_FAST40_WIDTH UINT40_WIDTH619#define INT_FAST40_WIDTH UINT_FAST40_WIDTH620#undef __UINT_LEAST32_WIDTH621#define __UINT_LEAST32_WIDTH UINT40_WIDTH622#undef __UINT_LEAST16_WIDTH623#define __UINT_LEAST16_WIDTH UINT40_WIDTH624#undef __UINT_LEAST8_WIDTH625#define __UINT_LEAST8_WIDTH UINT40_WIDTH626#endif /* __STDC_VERSION__ */627#endif /* __INT40_TYPE__ */628629#ifdef __INT32_TYPE__630#define INT32_MAX INT32_C(2147483647)631#define INT32_MIN (-INT32_C(2147483647) - 1)632#define UINT32_MAX UINT32_C(4294967295)633634#undef __INT_LEAST32_MIN635#define __INT_LEAST32_MIN INT32_MIN636#undef __INT_LEAST32_MAX637#define __INT_LEAST32_MAX INT32_MAX638#undef __UINT_LEAST32_MAX639#define __UINT_LEAST32_MAX UINT32_MAX640#undef __INT_LEAST16_MIN641#define __INT_LEAST16_MIN INT32_MIN642#undef __INT_LEAST16_MAX643#define __INT_LEAST16_MAX INT32_MAX644#undef __UINT_LEAST16_MAX645#define __UINT_LEAST16_MAX UINT32_MAX646#undef __INT_LEAST8_MIN647#define __INT_LEAST8_MIN INT32_MIN648#undef __INT_LEAST8_MAX649#define __INT_LEAST8_MAX INT32_MAX650#undef __UINT_LEAST8_MAX651#define __UINT_LEAST8_MAX UINT32_MAX652653#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L654#define UINT32_WIDTH 32655#define INT32_WIDTH UINT32_WIDTH656#undef __UINT_LEAST32_WIDTH657#define __UINT_LEAST32_WIDTH UINT32_WIDTH658#undef __UINT_LEAST16_WIDTH659#define __UINT_LEAST16_WIDTH UINT32_WIDTH660#undef __UINT_LEAST8_WIDTH661#define __UINT_LEAST8_WIDTH UINT32_WIDTH662#endif /* __STDC_VERSION__ */663#endif /* __INT32_TYPE__ */664665#ifdef __INT_LEAST32_MIN666#define INT_LEAST32_MIN __INT_LEAST32_MIN667#define INT_LEAST32_MAX __INT_LEAST32_MAX668#define UINT_LEAST32_MAX __UINT_LEAST32_MAX669#define INT_FAST32_MIN __INT_LEAST32_MIN670#define INT_FAST32_MAX __INT_LEAST32_MAX671#define UINT_FAST32_MAX __UINT_LEAST32_MAX672673#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L674#define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH675#define INT_LEAST32_WIDTH UINT_LEAST32_WIDTH676#define UINT_FAST32_WIDTH __UINT_LEAST32_WIDTH677#define INT_FAST32_WIDTH UINT_FAST32_WIDTH678#endif /* __STDC_VERSION__ */679#endif /* __INT_LEAST32_MIN */680681#ifdef __INT24_TYPE__682#define INT24_MAX INT24_C(8388607)683#define INT24_MIN (-INT24_C(8388607) - 1)684#define UINT24_MAX UINT24_C(16777215)685#define INT_LEAST24_MIN INT24_MIN686#define INT_LEAST24_MAX INT24_MAX687#define UINT_LEAST24_MAX UINT24_MAX688#define INT_FAST24_MIN INT24_MIN689#define INT_FAST24_MAX INT24_MAX690#define UINT_FAST24_MAX UINT24_MAX691692#undef __INT_LEAST16_MIN693#define __INT_LEAST16_MIN INT24_MIN694#undef __INT_LEAST16_MAX695#define __INT_LEAST16_MAX INT24_MAX696#undef __UINT_LEAST16_MAX697#define __UINT_LEAST16_MAX UINT24_MAX698#undef __INT_LEAST8_MIN699#define __INT_LEAST8_MIN INT24_MIN700#undef __INT_LEAST8_MAX701#define __INT_LEAST8_MAX INT24_MAX702#undef __UINT_LEAST8_MAX703#define __UINT_LEAST8_MAX UINT24_MAX704705#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L706#define UINT24_WIDTH 24707#define INT24_WIDTH UINT24_WIDTH708#define UINT_LEAST24_WIDTH UINT24_WIDTH709#define INT_LEAST24_WIDTH UINT_LEAST24_WIDTH710#define UINT_FAST24_WIDTH UINT24_WIDTH711#define INT_FAST24_WIDTH UINT_FAST24_WIDTH712#undef __UINT_LEAST16_WIDTH713#define __UINT_LEAST16_WIDTH UINT24_WIDTH714#undef __UINT_LEAST8_WIDTH715#define __UINT_LEAST8_WIDTH UINT24_WIDTH716#endif /* __STDC_VERSION__ */717#endif /* __INT24_TYPE__ */718719#ifdef __INT16_TYPE__720#define INT16_MAX INT16_C(32767)721#define INT16_MIN (-INT16_C(32767) - 1)722#define UINT16_MAX UINT16_C(65535)723724#undef __INT_LEAST16_MIN725#define __INT_LEAST16_MIN INT16_MIN726#undef __INT_LEAST16_MAX727#define __INT_LEAST16_MAX INT16_MAX728#undef __UINT_LEAST16_MAX729#define __UINT_LEAST16_MAX UINT16_MAX730#undef __INT_LEAST8_MIN731#define __INT_LEAST8_MIN INT16_MIN732#undef __INT_LEAST8_MAX733#define __INT_LEAST8_MAX INT16_MAX734#undef __UINT_LEAST8_MAX735#define __UINT_LEAST8_MAX UINT16_MAX736737#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L738#define UINT16_WIDTH 16739#define INT16_WIDTH UINT16_WIDTH740#undef __UINT_LEAST16_WIDTH741#define __UINT_LEAST16_WIDTH UINT16_WIDTH742#undef __UINT_LEAST8_WIDTH743#define __UINT_LEAST8_WIDTH UINT16_WIDTH744#endif /* __STDC_VERSION__ */745#endif /* __INT16_TYPE__ */746747#ifdef __INT_LEAST16_MIN748#define INT_LEAST16_MIN __INT_LEAST16_MIN749#define INT_LEAST16_MAX __INT_LEAST16_MAX750#define UINT_LEAST16_MAX __UINT_LEAST16_MAX751#define INT_FAST16_MIN __INT_LEAST16_MIN752#define INT_FAST16_MAX __INT_LEAST16_MAX753#define UINT_FAST16_MAX __UINT_LEAST16_MAX754755#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L756#define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH757#define INT_LEAST16_WIDTH UINT_LEAST16_WIDTH758#define UINT_FAST16_WIDTH __UINT_LEAST16_WIDTH759#define INT_FAST16_WIDTH UINT_FAST16_WIDTH760#endif /* __STDC_VERSION__ */761#endif /* __INT_LEAST16_MIN */762763#ifdef __INT8_TYPE__764#define INT8_MAX INT8_C(127)765#define INT8_MIN (-INT8_C(127) - 1)766#define UINT8_MAX UINT8_C(255)767768#undef __INT_LEAST8_MIN769#define __INT_LEAST8_MIN INT8_MIN770#undef __INT_LEAST8_MAX771#define __INT_LEAST8_MAX INT8_MAX772#undef __UINT_LEAST8_MAX773#define __UINT_LEAST8_MAX UINT8_MAX774775#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L776#define UINT8_WIDTH 8777#define INT8_WIDTH UINT8_WIDTH778#undef __UINT_LEAST8_WIDTH779#define __UINT_LEAST8_WIDTH UINT8_WIDTH780#endif /* __STDC_VERSION__ */781#endif /* __INT8_TYPE__ */782783#ifdef __INT_LEAST8_MIN784#define INT_LEAST8_MIN __INT_LEAST8_MIN785#define INT_LEAST8_MAX __INT_LEAST8_MAX786#define UINT_LEAST8_MAX __UINT_LEAST8_MAX787#define INT_FAST8_MIN __INT_LEAST8_MIN788#define INT_FAST8_MAX __INT_LEAST8_MAX789#define UINT_FAST8_MAX __UINT_LEAST8_MAX790791#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L792#define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH793#define INT_LEAST8_WIDTH UINT_LEAST8_WIDTH794#define UINT_FAST8_WIDTH __UINT_LEAST8_WIDTH795#define INT_FAST8_WIDTH UINT_FAST8_WIDTH796#endif /* __STDC_VERSION__ */797#endif /* __INT_LEAST8_MIN */798799/* Some utility macros */800#define __INTN_MIN(n) __stdint_join3(INT, n, _MIN)801#define __INTN_MAX(n) __stdint_join3(INT, n, _MAX)802#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX)803#define __INTN_C(n, v) __stdint_join3(INT, n, _C(v))804#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v))805806/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */807/* C99 7.18.3 Limits of other integer types. */808809#define INTPTR_MIN (-__INTPTR_MAX__ - 1)810#define INTPTR_MAX __INTPTR_MAX__811#define UINTPTR_MAX __UINTPTR_MAX__812#define PTRDIFF_MIN (-__PTRDIFF_MAX__ - 1)813#define PTRDIFF_MAX __PTRDIFF_MAX__814#define SIZE_MAX __SIZE_MAX__815816/* C23 7.22.2.4 Width of integer types capable of holding object pointers. */817#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L818/* NB: The C standard requires that these be the same value, but the compiler819exposes separate internal width macros. */820#define INTPTR_WIDTH __INTPTR_WIDTH__821#define UINTPTR_WIDTH __UINTPTR_WIDTH__822#endif823824/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__825* is enabled. */826#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1827#define RSIZE_MAX (SIZE_MAX >> 1)828#endif829830/* C99 7.18.2.5 Limits of greatest-width integer types. */831#define INTMAX_MIN (-__INTMAX_MAX__ - 1)832#define INTMAX_MAX __INTMAX_MAX__833#define UINTMAX_MAX __UINTMAX_MAX__834835/* C23 7.22.2.5 Width of greatest-width integer types. */836#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L837/* NB: The C standard requires that these be the same value, but the compiler838exposes separate internal width macros. */839#define INTMAX_WIDTH __INTMAX_WIDTH__840#define UINTMAX_WIDTH __UINTMAX_WIDTH__841#endif842843/* C99 7.18.3 Limits of other integer types. */844#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)845#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)846#ifdef __WINT_UNSIGNED__847#define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0)848#define WINT_MAX __UINTN_MAX(__WINT_WIDTH__)849#else850#define WINT_MIN __INTN_MIN(__WINT_WIDTH__)851#define WINT_MAX __INTN_MAX(__WINT_WIDTH__)852#endif853854#ifndef WCHAR_MAX855#define WCHAR_MAX __WCHAR_MAX__856#endif857#ifndef WCHAR_MIN858#if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__)859#define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__)860#else861#define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0)862#endif863#endif864865/* 7.18.4.2 Macros for greatest-width integer constants. */866#define INTMAX_C(v) __int_c(v, __INTMAX_C_SUFFIX__)867#define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__)868869/* C23 7.22.3.x Width of other integer types. */870#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L871#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__872#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__873#define SIZE_WIDTH __SIZE_WIDTH__874#define WCHAR_WIDTH __WCHAR_WIDTH__875#define WINT_WIDTH __WINT_WIDTH__876#endif877#endif // LLVM_LIBC_MACROS_STDINT_MACROS_H878879880