stdint.in.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. /* Copyright (C) 2001-2002, 2004-2017 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 Lesser General Public License as published by
  6. the Free Software Foundation; either version 2, 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 Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, see <http://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C 99 <stdint.h> for platforms that lack it.
  16. * <http://www.opengroup.org/susv3xbd/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. # define _STDINT_MIN(signed, bits, zero) \
  110. ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (zero))
  111. # define _STDINT_MAX(signed, bits, zero) \
  112. (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
  113. #if !GNULIB_defined_stdint_types
  114. /* 7.18.1.1. Exact-width integer types */
  115. /* Here we assume a standard architecture where the hardware integer
  116. types have 8, 16, 32, optionally 64 bits. */
  117. # undef int8_t
  118. # undef uint8_t
  119. typedef signed char gl_int8_t;
  120. typedef unsigned char gl_uint8_t;
  121. # define int8_t gl_int8_t
  122. # define uint8_t gl_uint8_t
  123. # undef int16_t
  124. # undef uint16_t
  125. typedef short int gl_int16_t;
  126. typedef unsigned short int gl_uint16_t;
  127. # define int16_t gl_int16_t
  128. # define uint16_t gl_uint16_t
  129. # undef int32_t
  130. # undef uint32_t
  131. typedef int gl_int32_t;
  132. typedef unsigned int gl_uint32_t;
  133. # define int32_t gl_int32_t
  134. # define uint32_t gl_uint32_t
  135. /* If the system defines INT64_MAX, assume int64_t works. That way,
  136. if the underlying platform defines int64_t to be a 64-bit long long
  137. int, the code below won't mistakenly define it to be a 64-bit long
  138. int, which would mess up C++ name mangling. We must use #ifdef
  139. rather than #if, to avoid an error with HP-UX 10.20 cc. */
  140. # ifdef INT64_MAX
  141. # define GL_INT64_T
  142. # else
  143. /* Do not undefine int64_t if gnulib is not being used with 64-bit
  144. types, since otherwise it breaks platforms like Tandem/NSK. */
  145. # if LONG_MAX >> 31 >> 31 == 1
  146. # undef int64_t
  147. typedef long int gl_int64_t;
  148. # define int64_t gl_int64_t
  149. # define GL_INT64_T
  150. # elif defined _MSC_VER
  151. # undef int64_t
  152. typedef __int64 gl_int64_t;
  153. # define int64_t gl_int64_t
  154. # define GL_INT64_T
  155. # elif @HAVE_LONG_LONG_INT@
  156. # undef int64_t
  157. typedef long long int gl_int64_t;
  158. # define int64_t gl_int64_t
  159. # define GL_INT64_T
  160. # endif
  161. # endif
  162. # ifdef UINT64_MAX
  163. # define GL_UINT64_T
  164. # else
  165. # if ULONG_MAX >> 31 >> 31 >> 1 == 1
  166. # undef uint64_t
  167. typedef unsigned long int gl_uint64_t;
  168. # define uint64_t gl_uint64_t
  169. # define GL_UINT64_T
  170. # elif defined _MSC_VER
  171. # undef uint64_t
  172. typedef unsigned __int64 gl_uint64_t;
  173. # define uint64_t gl_uint64_t
  174. # define GL_UINT64_T
  175. # elif @HAVE_UNSIGNED_LONG_LONG_INT@
  176. # undef uint64_t
  177. typedef unsigned long long int gl_uint64_t;
  178. # define uint64_t gl_uint64_t
  179. # define GL_UINT64_T
  180. # endif
  181. # endif
  182. /* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
  183. # define _UINT8_T
  184. # define _UINT32_T
  185. # define _UINT64_T
  186. /* 7.18.1.2. Minimum-width integer types */
  187. /* Here we assume a standard architecture where the hardware integer
  188. types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
  189. are the same as the corresponding N_t types. */
  190. # undef int_least8_t
  191. # undef uint_least8_t
  192. # undef int_least16_t
  193. # undef uint_least16_t
  194. # undef int_least32_t
  195. # undef uint_least32_t
  196. # undef int_least64_t
  197. # undef uint_least64_t
  198. # define int_least8_t int8_t
  199. # define uint_least8_t uint8_t
  200. # define int_least16_t int16_t
  201. # define uint_least16_t uint16_t
  202. # define int_least32_t int32_t
  203. # define uint_least32_t uint32_t
  204. # ifdef GL_INT64_T
  205. # define int_least64_t int64_t
  206. # endif
  207. # ifdef GL_UINT64_T
  208. # define uint_least64_t uint64_t
  209. # endif
  210. /* 7.18.1.3. Fastest minimum-width integer types */
  211. /* Note: Other <stdint.h> substitutes may define these types differently.
  212. It is not recommended to use these types in public header files. */
  213. /* Here we assume a standard architecture where the hardware integer
  214. types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
  215. are taken from the same list of types. The following code normally
  216. uses types consistent with glibc, as that lessens the chance of
  217. incompatibility with older GNU hosts. */
  218. # undef int_fast8_t
  219. # undef uint_fast8_t
  220. # undef int_fast16_t
  221. # undef uint_fast16_t
  222. # undef int_fast32_t
  223. # undef uint_fast32_t
  224. # undef int_fast64_t
  225. # undef uint_fast64_t
  226. typedef signed char gl_int_fast8_t;
  227. typedef unsigned char gl_uint_fast8_t;
  228. # ifdef __sun
  229. /* Define types compatible with SunOS 5.10, so that code compiled under
  230. earlier SunOS versions works with code compiled under SunOS 5.10. */
  231. typedef int gl_int_fast32_t;
  232. typedef unsigned int gl_uint_fast32_t;
  233. # else
  234. typedef long int gl_int_fast32_t;
  235. typedef unsigned long int gl_uint_fast32_t;
  236. # endif
  237. typedef gl_int_fast32_t gl_int_fast16_t;
  238. typedef gl_uint_fast32_t gl_uint_fast16_t;
  239. # define int_fast8_t gl_int_fast8_t
  240. # define uint_fast8_t gl_uint_fast8_t
  241. # define int_fast16_t gl_int_fast16_t
  242. # define uint_fast16_t gl_uint_fast16_t
  243. # define int_fast32_t gl_int_fast32_t
  244. # define uint_fast32_t gl_uint_fast32_t
  245. # ifdef GL_INT64_T
  246. # define int_fast64_t int64_t
  247. # endif
  248. # ifdef GL_UINT64_T
  249. # define uint_fast64_t uint64_t
  250. # endif
  251. /* 7.18.1.4. Integer types capable of holding object pointers */
  252. /* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
  253. definitions of intptr_t and uintptr_t (which use int and unsigned)
  254. to avoid clashes with declarations of system functions like sbrk. */
  255. # ifndef _INTPTR_T_DECLARED
  256. # undef intptr_t
  257. # undef uintptr_t
  258. typedef long int gl_intptr_t;
  259. typedef unsigned long int gl_uintptr_t;
  260. # define intptr_t gl_intptr_t
  261. # define uintptr_t gl_uintptr_t
  262. # endif
  263. /* 7.18.1.5. Greatest-width integer types */
  264. /* Note: These types are compiler dependent. It may be unwise to use them in
  265. public header files. */
  266. /* If the system defines INTMAX_MAX, assume that intmax_t works, and
  267. similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
  268. assuming one type where another is used by the system. */
  269. # ifndef INTMAX_MAX
  270. # undef INTMAX_C
  271. # undef intmax_t
  272. # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
  273. typedef long long int gl_intmax_t;
  274. # define intmax_t gl_intmax_t
  275. # elif defined GL_INT64_T
  276. # define intmax_t int64_t
  277. # else
  278. typedef long int gl_intmax_t;
  279. # define intmax_t gl_intmax_t
  280. # endif
  281. # endif
  282. # ifndef UINTMAX_MAX
  283. # undef UINTMAX_C
  284. # undef uintmax_t
  285. # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
  286. typedef unsigned long long int gl_uintmax_t;
  287. # define uintmax_t gl_uintmax_t
  288. # elif defined GL_UINT64_T
  289. # define uintmax_t uint64_t
  290. # else
  291. typedef unsigned long int gl_uintmax_t;
  292. # define uintmax_t gl_uintmax_t
  293. # endif
  294. # endif
  295. /* Verify that intmax_t and uintmax_t have the same size. Too much code
  296. breaks if this is not the case. If this check fails, the reason is likely
  297. to be found in the autoconf macros. */
  298. typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
  299. ? 1 : -1];
  300. # define GNULIB_defined_stdint_types 1
  301. # endif /* !GNULIB_defined_stdint_types */
  302. /* 7.18.2. Limits of specified-width integer types */
  303. /* 7.18.2.1. Limits of exact-width integer types */
  304. /* Here we assume a standard architecture where the hardware integer
  305. types have 8, 16, 32, optionally 64 bits. */
  306. # undef INT8_MIN
  307. # undef INT8_MAX
  308. # undef UINT8_MAX
  309. # define INT8_MIN (~ INT8_MAX)
  310. # define INT8_MAX 127
  311. # define UINT8_MAX 255
  312. # undef INT16_MIN
  313. # undef INT16_MAX
  314. # undef UINT16_MAX
  315. # define INT16_MIN (~ INT16_MAX)
  316. # define INT16_MAX 32767
  317. # define UINT16_MAX 65535
  318. # undef INT32_MIN
  319. # undef INT32_MAX
  320. # undef UINT32_MAX
  321. # define INT32_MIN (~ INT32_MAX)
  322. # define INT32_MAX 2147483647
  323. # define UINT32_MAX 4294967295U
  324. # if defined GL_INT64_T && ! defined INT64_MAX
  325. /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
  326. evaluates the latter incorrectly in preprocessor expressions. */
  327. # define INT64_MIN (- INTMAX_C (1) << 63)
  328. # define INT64_MAX INTMAX_C (9223372036854775807)
  329. # endif
  330. # if defined GL_UINT64_T && ! defined UINT64_MAX
  331. # define UINT64_MAX UINTMAX_C (18446744073709551615)
  332. # endif
  333. /* 7.18.2.2. Limits of minimum-width integer types */
  334. /* Here we assume a standard architecture where the hardware integer
  335. types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
  336. are the same as the corresponding N_t types. */
  337. # undef INT_LEAST8_MIN
  338. # undef INT_LEAST8_MAX
  339. # undef UINT_LEAST8_MAX
  340. # define INT_LEAST8_MIN INT8_MIN
  341. # define INT_LEAST8_MAX INT8_MAX
  342. # define UINT_LEAST8_MAX UINT8_MAX
  343. # undef INT_LEAST16_MIN
  344. # undef INT_LEAST16_MAX
  345. # undef UINT_LEAST16_MAX
  346. # define INT_LEAST16_MIN INT16_MIN
  347. # define INT_LEAST16_MAX INT16_MAX
  348. # define UINT_LEAST16_MAX UINT16_MAX
  349. # undef INT_LEAST32_MIN
  350. # undef INT_LEAST32_MAX
  351. # undef UINT_LEAST32_MAX
  352. # define INT_LEAST32_MIN INT32_MIN
  353. # define INT_LEAST32_MAX INT32_MAX
  354. # define UINT_LEAST32_MAX UINT32_MAX
  355. # undef INT_LEAST64_MIN
  356. # undef INT_LEAST64_MAX
  357. # ifdef GL_INT64_T
  358. # define INT_LEAST64_MIN INT64_MIN
  359. # define INT_LEAST64_MAX INT64_MAX
  360. # endif
  361. # undef UINT_LEAST64_MAX
  362. # ifdef GL_UINT64_T
  363. # define UINT_LEAST64_MAX UINT64_MAX
  364. # endif
  365. /* 7.18.2.3. Limits of fastest minimum-width integer types */
  366. /* Here we assume a standard architecture where the hardware integer
  367. types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
  368. are taken from the same list of types. */
  369. # undef INT_FAST8_MIN
  370. # undef INT_FAST8_MAX
  371. # undef UINT_FAST8_MAX
  372. # define INT_FAST8_MIN SCHAR_MIN
  373. # define INT_FAST8_MAX SCHAR_MAX
  374. # define UINT_FAST8_MAX UCHAR_MAX
  375. # undef INT_FAST16_MIN
  376. # undef INT_FAST16_MAX
  377. # undef UINT_FAST16_MAX
  378. # define INT_FAST16_MIN INT_FAST32_MIN
  379. # define INT_FAST16_MAX INT_FAST32_MAX
  380. # define UINT_FAST16_MAX UINT_FAST32_MAX
  381. # undef INT_FAST32_MIN
  382. # undef INT_FAST32_MAX
  383. # undef UINT_FAST32_MAX
  384. # ifdef __sun
  385. # define INT_FAST32_MIN INT_MIN
  386. # define INT_FAST32_MAX INT_MAX
  387. # define UINT_FAST32_MAX UINT_MAX
  388. # else
  389. # define INT_FAST32_MIN LONG_MIN
  390. # define INT_FAST32_MAX LONG_MAX
  391. # define UINT_FAST32_MAX ULONG_MAX
  392. # endif
  393. # undef INT_FAST64_MIN
  394. # undef INT_FAST64_MAX
  395. # ifdef GL_INT64_T
  396. # define INT_FAST64_MIN INT64_MIN
  397. # define INT_FAST64_MAX INT64_MAX
  398. # endif
  399. # undef UINT_FAST64_MAX
  400. # ifdef GL_UINT64_T
  401. # define UINT_FAST64_MAX UINT64_MAX
  402. # endif
  403. /* 7.18.2.4. Limits of integer types capable of holding object pointers */
  404. # undef INTPTR_MIN
  405. # undef INTPTR_MAX
  406. # undef UINTPTR_MAX
  407. # define INTPTR_MIN LONG_MIN
  408. # define INTPTR_MAX LONG_MAX
  409. # define UINTPTR_MAX ULONG_MAX
  410. /* 7.18.2.5. Limits of greatest-width integer types */
  411. # ifndef INTMAX_MAX
  412. # undef INTMAX_MIN
  413. # ifdef INT64_MAX
  414. # define INTMAX_MIN INT64_MIN
  415. # define INTMAX_MAX INT64_MAX
  416. # else
  417. # define INTMAX_MIN INT32_MIN
  418. # define INTMAX_MAX INT32_MAX
  419. # endif
  420. # endif
  421. # ifndef UINTMAX_MAX
  422. # ifdef UINT64_MAX
  423. # define UINTMAX_MAX UINT64_MAX
  424. # else
  425. # define UINTMAX_MAX UINT32_MAX
  426. # endif
  427. # endif
  428. /* 7.18.3. Limits of other integer types */
  429. /* ptrdiff_t limits */
  430. # undef PTRDIFF_MIN
  431. # undef PTRDIFF_MAX
  432. # if @APPLE_UNIVERSAL_BUILD@
  433. # ifdef _LP64
  434. # define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l)
  435. # define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
  436. # else
  437. # define PTRDIFF_MIN _STDINT_MIN (1, 32, 0)
  438. # define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
  439. # endif
  440. # else
  441. # define PTRDIFF_MIN \
  442. _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
  443. # define PTRDIFF_MAX \
  444. _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
  445. # endif
  446. /* sig_atomic_t limits */
  447. # undef SIG_ATOMIC_MIN
  448. # undef SIG_ATOMIC_MAX
  449. # define SIG_ATOMIC_MIN \
  450. _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
  451. 0@SIG_ATOMIC_T_SUFFIX@)
  452. # define SIG_ATOMIC_MAX \
  453. _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
  454. 0@SIG_ATOMIC_T_SUFFIX@)
  455. /* size_t limit */
  456. # undef SIZE_MAX
  457. # if @APPLE_UNIVERSAL_BUILD@
  458. # ifdef _LP64
  459. # define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
  460. # else
  461. # define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
  462. # endif
  463. # else
  464. # define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
  465. # endif
  466. /* wchar_t limits */
  467. /* Get WCHAR_MIN, WCHAR_MAX.
  468. This include is not on the top, above, because on OSF/1 4.0 we have a
  469. sequence of nested includes
  470. <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
  471. <stdint.h> and assumes its types are already defined. */
  472. # if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
  473. /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  474. included before <wchar.h>. */
  475. # include <stddef.h>
  476. # include <stdio.h>
  477. # include <time.h>
  478. # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
  479. # include <wchar.h>
  480. # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
  481. # endif
  482. # undef WCHAR_MIN
  483. # undef WCHAR_MAX
  484. # define WCHAR_MIN \
  485. _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
  486. # define WCHAR_MAX \
  487. _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
  488. /* wint_t limits */
  489. # undef WINT_MIN
  490. # undef WINT_MAX
  491. # define WINT_MIN \
  492. _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
  493. # define WINT_MAX \
  494. _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
  495. /* 7.18.4. Macros for integer constants */
  496. /* 7.18.4.1. Macros for minimum-width integer constants */
  497. /* According to ISO C 99 Technical Corrigendum 1 */
  498. /* Here we assume a standard architecture where the hardware integer
  499. types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
  500. # undef INT8_C
  501. # undef UINT8_C
  502. # define INT8_C(x) x
  503. # define UINT8_C(x) x
  504. # undef INT16_C
  505. # undef UINT16_C
  506. # define INT16_C(x) x
  507. # define UINT16_C(x) x
  508. # undef INT32_C
  509. # undef UINT32_C
  510. # define INT32_C(x) x
  511. # define UINT32_C(x) x ## U
  512. # undef INT64_C
  513. # undef UINT64_C
  514. # if LONG_MAX >> 31 >> 31 == 1
  515. # define INT64_C(x) x##L
  516. # elif defined _MSC_VER
  517. # define INT64_C(x) x##i64
  518. # elif @HAVE_LONG_LONG_INT@
  519. # define INT64_C(x) x##LL
  520. # endif
  521. # if ULONG_MAX >> 31 >> 31 >> 1 == 1
  522. # define UINT64_C(x) x##UL
  523. # elif defined _MSC_VER
  524. # define UINT64_C(x) x##ui64
  525. # elif @HAVE_UNSIGNED_LONG_LONG_INT@
  526. # define UINT64_C(x) x##ULL
  527. # endif
  528. /* 7.18.4.2. Macros for greatest-width integer constants */
  529. # ifndef INTMAX_C
  530. # if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
  531. # define INTMAX_C(x) x##LL
  532. # elif defined GL_INT64_T
  533. # define INTMAX_C(x) INT64_C(x)
  534. # else
  535. # define INTMAX_C(x) x##L
  536. # endif
  537. # endif
  538. # ifndef UINTMAX_C
  539. # if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
  540. # define UINTMAX_C(x) x##ULL
  541. # elif defined GL_UINT64_T
  542. # define UINTMAX_C(x) UINT64_C(x)
  543. # else
  544. # define UINTMAX_C(x) x##UL
  545. # endif
  546. # endif
  547. #endif /* !@HAVE_C99_STDINT_H@ */
  548. /* Macros specified by ISO/IEC TS 18661-1:2014. */
  549. #if (!defined UINTMAX_WIDTH \
  550. && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
  551. # ifdef INT8_MAX
  552. # define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
  553. # endif
  554. # ifdef UINT8_MAX
  555. # define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
  556. # endif
  557. # ifdef INT16_MAX
  558. # define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
  559. # endif
  560. # ifdef UINT16_MAX
  561. # define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
  562. # endif
  563. # ifdef INT32_MAX
  564. # define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
  565. # endif
  566. # ifdef UINT32_MAX
  567. # define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
  568. # endif
  569. # ifdef INT64_MAX
  570. # define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
  571. # endif
  572. # ifdef UINT64_MAX
  573. # define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
  574. # endif
  575. # define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
  576. # define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
  577. # define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
  578. # define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
  579. # define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
  580. # define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
  581. # define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
  582. # define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
  583. # define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
  584. # define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
  585. # define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
  586. # define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
  587. # define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
  588. # define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
  589. # define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
  590. # define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
  591. # define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
  592. # define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
  593. # define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
  594. # define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
  595. # define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
  596. # define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
  597. # define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
  598. # ifdef WINT_MAX
  599. # define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
  600. # endif
  601. # ifdef SIG_ATOMIC_MAX
  602. # define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
  603. # endif
  604. #endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
  605. #endif /* _@GUARD_PREFIX@_STDINT_H */
  606. #endif /* !(defined __ANDROID__ && ...) */
  607. #endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */