stdint.h 23 KB

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