stdint.in.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. /* Copyright (C) 2001-2002, 2004-2021 Free Software Foundation, Inc.
  2. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
  3. This file is part of gnulib.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, see <https://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C 99 <stdint.h> for platforms that lack it.
  16. * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html>
  17. */
  18. #ifndef _@GUARD_PREFIX@_STDINT_H
  19. #if __GNUC__ >= 3
  20. @PRAGMA_SYSTEM_HEADER@
  21. #endif
  22. @PRAGMA_COLUMNS@
  23. /* When including a system file that in turn includes <inttypes.h>,
  24. use the system <inttypes.h>, not our substitute. This avoids
  25. problems with (for example) VMS, whose <sys/bitypes.h> includes
  26. <inttypes.h>. */
  27. #define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
  28. /* On Android (Bionic libc), <sys/types.h> includes this file before
  29. having defined 'time_t'. Therefore in this case avoid including
  30. other system header files; just include the system's <stdint.h>.
  31. Ideally we should test __BIONIC__ here, but it is only defined after
  32. <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
  33. #if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H
  34. # @INCLUDE_NEXT@ @NEXT_STDINT_H@
  35. #else
  36. /* Get those types that are already defined in other system include
  37. files, so that we can "#define int8_t signed char" below without
  38. worrying about a later system include file containing a "typedef
  39. signed char int8_t;" that will get messed up by our macro. Our
  40. macros should all be consistent with the system versions, except
  41. for the "fast" types and macros, which we recommend against using
  42. in public interfaces due to compiler differences. */
  43. #if @HAVE_STDINT_H@
  44. # if defined __sgi && ! defined __c99
  45. /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
  46. with "This header file is to be used only for c99 mode compilations"
  47. diagnostics. */
  48. # define __STDINT_H__
  49. # endif
  50. /* Some pre-C++11 <stdint.h> implementations need this. */
  51. # ifdef __cplusplus
  52. # ifndef __STDC_CONSTANT_MACROS
  53. # define __STDC_CONSTANT_MACROS 1
  54. # endif
  55. # ifndef __STDC_LIMIT_MACROS
  56. # define __STDC_LIMIT_MACROS 1
  57. # endif
  58. # endif
  59. /* Other systems may have an incomplete or buggy <stdint.h>.
  60. Include it before <inttypes.h>, since any "#include <stdint.h>"
  61. in <inttypes.h> would reinclude us, skipping our contents because
  62. _@GUARD_PREFIX@_STDINT_H is defined.
  63. The include_next requires a split double-inclusion guard. */
  64. # @INCLUDE_NEXT@ @NEXT_STDINT_H@
  65. #endif
  66. #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
  67. #define _@GUARD_PREFIX@_STDINT_H
  68. /* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
  69. LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
  70. #include <limits.h>
  71. /* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
  72. wint_t. */
  73. #if @GNULIB_OVERRIDES_WINT_T@
  74. # undef WINT_MIN
  75. # undef WINT_MAX
  76. # define WINT_MIN 0x0U
  77. # define WINT_MAX 0xffffffffU
  78. #endif
  79. #if ! @HAVE_C99_STDINT_H@
  80. /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
  81. IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
  82. AIX 5.2 <sys/types.h> isn't needed and causes troubles.
  83. Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
  84. relies on the system <stdint.h> definitions, so include
  85. <sys/types.h> after @NEXT_STDINT_H@. */
  86. # if @HAVE_SYS_TYPES_H@ && ! defined _AIX
  87. # include <sys/types.h>
  88. # endif
  89. # if @HAVE_INTTYPES_H@
  90. /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
  91. int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
  92. <inttypes.h> also defines intptr_t and uintptr_t. */
  93. # include <inttypes.h>
  94. # elif @HAVE_SYS_INTTYPES_H@
  95. /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
  96. the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
  97. # include <sys/inttypes.h>
  98. # endif
  99. # if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
  100. /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
  101. int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
  102. included by <sys/types.h>. */
  103. # include <sys/bitypes.h>
  104. # endif
  105. # undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
  106. /* Minimum and maximum values for an integer type under the usual assumption.
  107. Return an unspecified value if BITS == 0, adding a check to pacify
  108. picky compilers. */
  109. /* These are separate macros, because if you try to merge these macros into
  110. a single one, HP-UX cc rejects the resulting expression in constant
  111. expressions. */
  112. # define _STDINT_UNSIGNED_MIN(bits, zero) \
  113. (zero)
  114. # define _STDINT_SIGNED_MIN(bits, zero) \
  115. (~ _STDINT_MAX (1, bits, zero))
  116. # define _STDINT_MAX(signed, bits, zero) \
  117. (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
  118. #if !GNULIB_defined_stdint_types
  119. /* 7.18.1.1. Exact-width integer types */
  120. /* Here we assume a standard architecture where the hardware integer
  121. types have 8, 16, 32, optionally 64 bits. */
  122. # undef int8_t
  123. # undef uint8_t
  124. typedef signed char gl_int8_t;
  125. typedef unsigned char gl_uint8_t;
  126. # define int8_t gl_int8_t
  127. # define uint8_t gl_uint8_t
  128. # undef int16_t
  129. # undef uint16_t
  130. typedef short int gl_int16_t;
  131. typedef unsigned short int gl_uint16_t;
  132. # define int16_t gl_int16_t
  133. # define uint16_t gl_uint16_t
  134. # undef int32_t
  135. # undef uint32_t
  136. typedef int gl_int32_t;
  137. typedef unsigned int gl_uint32_t;
  138. # define int32_t gl_int32_t
  139. # define uint32_t gl_uint32_t
  140. /* If the system defines INT64_MAX, assume int64_t works. That way,
  141. if the underlying platform defines int64_t to be a 64-bit long long
  142. int, the code below won't mistakenly define it to be a 64-bit long
  143. int, which would mess up C++ name mangling. We must use #ifdef
  144. rather than #if, to avoid an error with HP-UX 10.20 cc. */
  145. # ifdef INT64_MAX
  146. # define GL_INT64_T
  147. # else
  148. /* Do not undefine int64_t if gnulib is not being used with 64-bit
  149. types, since otherwise it breaks platforms like Tandem/NSK. */
  150. # if LONG_MAX >> 31 >> 31 == 1
  151. # undef int64_t
  152. typedef long int gl_int64_t;
  153. # define int64_t gl_int64_t
  154. # define GL_INT64_T
  155. # elif defined _MSC_VER
  156. # undef int64_t
  157. typedef __int64 gl_int64_t;
  158. # define int64_t gl_int64_t
  159. # define GL_INT64_T
  160. # else
  161. # undef int64_t
  162. typedef long long int gl_int64_t;
  163. # define int64_t gl_int64_t
  164. # define GL_INT64_T
  165. # endif
  166. # endif
  167. # ifdef UINT64_MAX
  168. # define GL_UINT64_T
  169. # else
  170. # if ULONG_MAX >> 31 >> 31 >> 1 == 1
  171. # undef uint64_t
  172. typedef unsigned long int gl_uint64_t;
  173. # define uint64_t gl_uint64_t
  174. # define GL_UINT64_T
  175. # elif defined _MSC_VER
  176. # undef uint64_t
  177. typedef unsigned __int64 gl_uint64_t;
  178. # define uint64_t gl_uint64_t
  179. # define GL_UINT64_T
  180. # else
  181. # undef uint64_t
  182. typedef unsigned long long int gl_uint64_t;
  183. # define uint64_t gl_uint64_t
  184. # define GL_UINT64_T
  185. # endif
  186. # endif
  187. /* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
  188. # define _UINT8_T
  189. # define _UINT32_T
  190. # define _UINT64_T
  191. /* 7.18.1.2. Minimum-width integer types */
  192. /* Here we assume a standard architecture where the hardware integer
  193. types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
  194. are the same as the corresponding N_t types. */
  195. # undef int_least8_t
  196. # undef uint_least8_t
  197. # undef int_least16_t
  198. # undef uint_least16_t
  199. # undef int_least32_t
  200. # undef uint_least32_t
  201. # undef int_least64_t
  202. # undef uint_least64_t
  203. # define int_least8_t int8_t
  204. # define uint_least8_t uint8_t
  205. # define int_least16_t int16_t
  206. # define uint_least16_t uint16_t
  207. # define int_least32_t int32_t
  208. # define uint_least32_t uint32_t
  209. # ifdef GL_INT64_T
  210. # define int_least64_t int64_t
  211. # endif
  212. # ifdef GL_UINT64_T
  213. # define uint_least64_t uint64_t
  214. # endif
  215. /* 7.18.1.3. Fastest minimum-width integer types */
  216. /* Note: Other <stdint.h> substitutes may define these types differently.
  217. It is not recommended to use these types in public header files. */
  218. /* Here we assume a standard architecture where the hardware integer
  219. types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
  220. are taken from the same list of types. The following code normally
  221. uses types consistent with glibc, as that lessens the chance of
  222. incompatibility with older GNU hosts. */
  223. # undef int_fast8_t
  224. # undef uint_fast8_t
  225. # undef int_fast16_t
  226. # undef uint_fast16_t
  227. # undef int_fast32_t
  228. # undef uint_fast32_t
  229. # undef int_fast64_t
  230. # undef uint_fast64_t
  231. typedef signed char gl_int_fast8_t;
  232. typedef unsigned char gl_uint_fast8_t;
  233. # ifdef __sun
  234. /* Define types compatible with SunOS 5.10, so that code compiled under
  235. earlier SunOS versions works with code compiled under SunOS 5.10. */
  236. typedef int gl_int_fast32_t;
  237. typedef unsigned int gl_uint_fast32_t;
  238. # else
  239. typedef long int gl_int_fast32_t;
  240. typedef unsigned long int gl_uint_fast32_t;
  241. # endif
  242. typedef gl_int_fast32_t gl_int_fast16_t;
  243. typedef gl_uint_fast32_t gl_uint_fast16_t;
  244. # define int_fast8_t gl_int_fast8_t
  245. # define uint_fast8_t gl_uint_fast8_t
  246. # define int_fast16_t gl_int_fast16_t
  247. # define uint_fast16_t gl_uint_fast16_t
  248. # define int_fast32_t gl_int_fast32_t
  249. # define uint_fast32_t gl_uint_fast32_t
  250. # ifdef GL_INT64_T
  251. # define int_fast64_t int64_t
  252. # endif
  253. # ifdef GL_UINT64_T
  254. # define uint_fast64_t uint64_t
  255. # endif
  256. /* 7.18.1.4. Integer types capable of holding object pointers */
  257. /* kLIBC's <stdint.h> defines _INTPTR_T_DECLARED and needs its own
  258. definitions of intptr_t and uintptr_t (which use int and unsigned)
  259. to avoid clashes with declarations of system functions like sbrk.
  260. Similarly, MinGW WSL-5.4.1 <stdint.h> needs its own intptr_t and
  261. uintptr_t to avoid conflicting declarations of system functions like
  262. _findclose in <io.h>. */
  263. # if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
  264. || defined __MINGW32__)
  265. # undef intptr_t
  266. # undef uintptr_t
  267. # ifdef _WIN64
  268. typedef long long int gl_intptr_t;
  269. typedef unsigned long long int gl_uintptr_t;
  270. # else
  271. typedef long int gl_intptr_t;
  272. typedef unsigned long int gl_uintptr_t;
  273. # endif
  274. # define intptr_t gl_intptr_t
  275. # define uintptr_t gl_uintptr_t
  276. # endif
  277. /* 7.18.1.5. Greatest-width integer types */
  278. /* Note: These types are compiler dependent. It may be unwise to use them in
  279. public header files. */
  280. /* If the system defines INTMAX_MAX, assume that intmax_t works, and
  281. similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
  282. assuming one type where another is used by the system. */
  283. # ifndef INTMAX_MAX
  284. # undef INTMAX_C
  285. # undef intmax_t
  286. # if LONG_MAX >> 30 == 1
  287. typedef long long int gl_intmax_t;
  288. # define intmax_t gl_intmax_t
  289. # elif defined GL_INT64_T
  290. # define intmax_t int64_t
  291. # else
  292. typedef long int gl_intmax_t;
  293. # define intmax_t gl_intmax_t
  294. # endif
  295. # endif
  296. # ifndef UINTMAX_MAX
  297. # undef UINTMAX_C
  298. # undef uintmax_t
  299. # if ULONG_MAX >> 31 == 1
  300. typedef unsigned long long int gl_uintmax_t;
  301. # define uintmax_t gl_uintmax_t
  302. # elif defined GL_UINT64_T
  303. # define uintmax_t uint64_t
  304. # else
  305. typedef unsigned long int gl_uintmax_t;
  306. # define uintmax_t gl_uintmax_t
  307. # endif
  308. # endif
  309. /* Verify that intmax_t and uintmax_t have the same size. Too much code
  310. breaks if this is not the case. If this check fails, the reason is likely
  311. to be found in the autoconf macros. */
  312. typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
  313. ? 1 : -1];
  314. # define GNULIB_defined_stdint_types 1
  315. # endif /* !GNULIB_defined_stdint_types */
  316. /* 7.18.2. Limits of specified-width integer types */
  317. /* 7.18.2.1. Limits of exact-width integer types */
  318. /* Here we assume a standard architecture where the hardware integer
  319. types have 8, 16, 32, optionally 64 bits. */
  320. # undef INT8_MIN
  321. # undef INT8_MAX
  322. # undef UINT8_MAX
  323. # define INT8_MIN (~ INT8_MAX)
  324. # define INT8_MAX 127
  325. # define UINT8_MAX 255
  326. # undef INT16_MIN
  327. # undef INT16_MAX
  328. # undef UINT16_MAX
  329. # define INT16_MIN (~ INT16_MAX)
  330. # define INT16_MAX 32767
  331. # define UINT16_MAX 65535
  332. # undef INT32_MIN
  333. # undef INT32_MAX
  334. # undef UINT32_MAX
  335. # define INT32_MIN (~ INT32_MAX)
  336. # define INT32_MAX 2147483647
  337. # define UINT32_MAX 4294967295U
  338. # if defined GL_INT64_T && ! defined INT64_MAX
  339. /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
  340. evaluates the latter incorrectly in preprocessor expressions. */
  341. # define INT64_MIN (- INTMAX_C (1) << 63)
  342. # define INT64_MAX INTMAX_C (9223372036854775807)
  343. # endif
  344. # if defined GL_UINT64_T && ! defined UINT64_MAX
  345. # define UINT64_MAX UINTMAX_C (18446744073709551615)
  346. # endif
  347. /* 7.18.2.2. Limits of minimum-width integer types */
  348. /* Here we assume a standard architecture where the hardware integer
  349. types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
  350. are the same as the corresponding N_t types. */
  351. # undef INT_LEAST8_MIN
  352. # undef INT_LEAST8_MAX
  353. # undef UINT_LEAST8_MAX
  354. # define INT_LEAST8_MIN INT8_MIN
  355. # define INT_LEAST8_MAX INT8_MAX
  356. # define UINT_LEAST8_MAX UINT8_MAX
  357. # undef INT_LEAST16_MIN
  358. # undef INT_LEAST16_MAX
  359. # undef UINT_LEAST16_MAX
  360. # define INT_LEAST16_MIN INT16_MIN
  361. # define INT_LEAST16_MAX INT16_MAX
  362. # define UINT_LEAST16_MAX UINT16_MAX
  363. # undef INT_LEAST32_MIN
  364. # undef INT_LEAST32_MAX
  365. # undef UINT_LEAST32_MAX
  366. # define INT_LEAST32_MIN INT32_MIN
  367. # define INT_LEAST32_MAX INT32_MAX
  368. # define UINT_LEAST32_MAX UINT32_MAX
  369. # undef INT_LEAST64_MIN
  370. # undef INT_LEAST64_MAX
  371. # ifdef GL_INT64_T
  372. # define INT_LEAST64_MIN INT64_MIN
  373. # define INT_LEAST64_MAX INT64_MAX
  374. # endif
  375. # undef UINT_LEAST64_MAX
  376. # ifdef GL_UINT64_T
  377. # define UINT_LEAST64_MAX UINT64_MAX
  378. # endif
  379. /* 7.18.2.3. Limits of fastest minimum-width integer types */
  380. /* Here we assume a standard architecture where the hardware integer
  381. types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
  382. are taken from the same list of types. */
  383. # undef INT_FAST8_MIN
  384. # undef INT_FAST8_MAX
  385. # undef UINT_FAST8_MAX
  386. # define INT_FAST8_MIN SCHAR_MIN
  387. # define INT_FAST8_MAX SCHAR_MAX
  388. # define UINT_FAST8_MAX UCHAR_MAX
  389. # undef INT_FAST16_MIN
  390. # undef INT_FAST16_MAX
  391. # undef UINT_FAST16_MAX
  392. # define INT_FAST16_MIN INT_FAST32_MIN
  393. # define INT_FAST16_MAX INT_FAST32_MAX
  394. # define UINT_FAST16_MAX UINT_FAST32_MAX
  395. # undef INT_FAST32_MIN
  396. # undef INT_FAST32_MAX
  397. # undef UINT_FAST32_MAX
  398. # ifdef __sun
  399. # define INT_FAST32_MIN INT_MIN
  400. # define INT_FAST32_MAX INT_MAX
  401. # define UINT_FAST32_MAX UINT_MAX
  402. # else
  403. # define INT_FAST32_MIN LONG_MIN
  404. # define INT_FAST32_MAX LONG_MAX
  405. # define UINT_FAST32_MAX ULONG_MAX
  406. # endif
  407. # undef INT_FAST64_MIN
  408. # undef INT_FAST64_MAX
  409. # ifdef GL_INT64_T
  410. # define INT_FAST64_MIN INT64_MIN
  411. # define INT_FAST64_MAX INT64_MAX
  412. # endif
  413. # undef UINT_FAST64_MAX
  414. # ifdef GL_UINT64_T
  415. # define UINT_FAST64_MAX UINT64_MAX
  416. # endif
  417. /* 7.18.2.4. Limits of integer types capable of holding object pointers */
  418. # undef INTPTR_MIN
  419. # undef INTPTR_MAX
  420. # undef UINTPTR_MAX
  421. # ifdef _WIN64
  422. # define INTPTR_MIN LLONG_MIN
  423. # define INTPTR_MAX LLONG_MAX
  424. # define UINTPTR_MAX ULLONG_MAX
  425. # else
  426. # define INTPTR_MIN LONG_MIN
  427. # define INTPTR_MAX LONG_MAX
  428. # define UINTPTR_MAX ULONG_MAX
  429. # endif
  430. /* 7.18.2.5. Limits of greatest-width integer types */
  431. # ifndef INTMAX_MAX
  432. # undef INTMAX_MIN
  433. # ifdef INT64_MAX
  434. # define INTMAX_MIN INT64_MIN
  435. # define INTMAX_MAX INT64_MAX
  436. # else
  437. # define INTMAX_MIN INT32_MIN
  438. # define INTMAX_MAX INT32_MAX
  439. # endif
  440. # endif
  441. # ifndef UINTMAX_MAX
  442. # ifdef UINT64_MAX
  443. # define UINTMAX_MAX UINT64_MAX
  444. # else
  445. # define UINTMAX_MAX UINT32_MAX
  446. # endif
  447. # endif
  448. /* 7.18.3. Limits of other integer types */
  449. /* ptrdiff_t limits */
  450. # undef PTRDIFF_MIN
  451. # undef PTRDIFF_MAX
  452. # if @APPLE_UNIVERSAL_BUILD@
  453. # ifdef _LP64
  454. # define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l)
  455. # define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
  456. # else
  457. # define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0)
  458. # define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
  459. # endif
  460. # else
  461. # define PTRDIFF_MIN \
  462. _STDINT_SIGNED_MIN (@BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
  463. # define PTRDIFF_MAX \
  464. _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
  465. # endif
  466. /* sig_atomic_t limits */
  467. # undef SIG_ATOMIC_MIN
  468. # undef SIG_ATOMIC_MAX
  469. # if @HAVE_SIGNED_SIG_ATOMIC_T@
  470. # define SIG_ATOMIC_MIN \
  471. _STDINT_SIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
  472. # else
  473. # define SIG_ATOMIC_MIN \
  474. _STDINT_UNSIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
  475. # endif
  476. # define SIG_ATOMIC_MAX \
  477. _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
  478. 0@SIG_ATOMIC_T_SUFFIX@)
  479. /* size_t limit */
  480. # undef SIZE_MAX
  481. # if @APPLE_UNIVERSAL_BUILD@
  482. # ifdef _LP64
  483. # define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
  484. # else
  485. # define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
  486. # endif
  487. # else
  488. # define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
  489. # endif
  490. /* wchar_t limits */
  491. /* Get WCHAR_MIN, WCHAR_MAX.
  492. This include is not on the top, above, because on OSF/1 4.0 we have a
  493. sequence of nested includes
  494. <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
  495. <stdint.h> and assumes its types are already defined. */
  496. # if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
  497. # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
  498. # include <wchar.h>
  499. # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
  500. # endif
  501. # undef WCHAR_MIN
  502. # undef WCHAR_MAX
  503. # if @HAVE_SIGNED_WCHAR_T@
  504. # define WCHAR_MIN \
  505. _STDINT_SIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
  506. # else
  507. # define WCHAR_MIN \
  508. _STDINT_UNSIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
  509. # endif
  510. # define WCHAR_MAX \
  511. _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
  512. /* wint_t limits */
  513. /* If gnulib's <wchar.h> or <wctype.h> overrides wint_t, @WINT_T_SUFFIX@ is not
  514. accurate, therefore use the definitions from above. */
  515. # if !@GNULIB_OVERRIDES_WINT_T@
  516. # undef WINT_MIN
  517. # undef WINT_MAX
  518. # if @HAVE_SIGNED_WINT_T@
  519. # define WINT_MIN \
  520. _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
  521. # else
  522. # define WINT_MIN \
  523. _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
  524. # endif
  525. # define WINT_MAX \
  526. _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
  527. # endif
  528. /* 7.18.4. Macros for integer constants */
  529. /* 7.18.4.1. Macros for minimum-width integer constants */
  530. /* According to ISO C 99 Technical Corrigendum 1 */
  531. /* Here we assume a standard architecture where the hardware integer
  532. types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
  533. # undef INT8_C
  534. # undef UINT8_C
  535. # define INT8_C(x) x
  536. # define UINT8_C(x) x
  537. # undef INT16_C
  538. # undef UINT16_C
  539. # define INT16_C(x) x
  540. # define UINT16_C(x) x
  541. # undef INT32_C
  542. # undef UINT32_C
  543. # define INT32_C(x) x
  544. # define UINT32_C(x) x ## U
  545. # undef INT64_C
  546. # undef UINT64_C
  547. # if LONG_MAX >> 31 >> 31 == 1
  548. # define INT64_C(x) x##L
  549. # elif defined _MSC_VER
  550. # define INT64_C(x) x##i64
  551. # else
  552. # define INT64_C(x) x##LL
  553. # endif
  554. # if ULONG_MAX >> 31 >> 31 >> 1 == 1
  555. # define UINT64_C(x) x##UL
  556. # elif defined _MSC_VER
  557. # define UINT64_C(x) x##ui64
  558. # else
  559. # define UINT64_C(x) x##ULL
  560. # endif
  561. /* 7.18.4.2. Macros for greatest-width integer constants */
  562. # ifndef INTMAX_C
  563. # if LONG_MAX >> 30 == 1
  564. # define INTMAX_C(x) x##LL
  565. # elif defined GL_INT64_T
  566. # define INTMAX_C(x) INT64_C(x)
  567. # else
  568. # define INTMAX_C(x) x##L
  569. # endif
  570. # endif
  571. # ifndef UINTMAX_C
  572. # if ULONG_MAX >> 31 == 1
  573. # define UINTMAX_C(x) x##ULL
  574. # elif defined GL_UINT64_T
  575. # define UINTMAX_C(x) UINT64_C(x)
  576. # else
  577. # define UINTMAX_C(x) x##UL
  578. # endif
  579. # endif
  580. #endif /* !@HAVE_C99_STDINT_H@ */
  581. /* Macros specified by ISO/IEC TS 18661-1:2014. */
  582. #if (!defined UINTMAX_WIDTH \
  583. && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
  584. # ifdef INT8_MAX
  585. # define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
  586. # endif
  587. # ifdef UINT8_MAX
  588. # define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
  589. # endif
  590. # ifdef INT16_MAX
  591. # define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
  592. # endif
  593. # ifdef UINT16_MAX
  594. # define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
  595. # endif
  596. # ifdef INT32_MAX
  597. # define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
  598. # endif
  599. # ifdef UINT32_MAX
  600. # define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
  601. # endif
  602. # ifdef INT64_MAX
  603. # define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
  604. # endif
  605. # ifdef UINT64_MAX
  606. # define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
  607. # endif
  608. # define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
  609. # define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
  610. # define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
  611. # define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
  612. # define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
  613. # define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
  614. # define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
  615. # define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
  616. # define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
  617. # define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
  618. # define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
  619. # define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
  620. # define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
  621. # define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
  622. # define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
  623. # define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
  624. # define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
  625. # define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
  626. # define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
  627. # define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
  628. # define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
  629. # define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
  630. # define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
  631. # ifdef WINT_MAX
  632. # define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
  633. # endif
  634. # ifdef SIG_ATOMIC_MAX
  635. # define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
  636. # endif
  637. #endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
  638. #endif /* _@GUARD_PREFIX@_STDINT_H */
  639. #endif /* !(defined __ANDROID__ && ...) */
  640. #endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */