stdint.m4 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. # stdint.m4 serial 50
  2. dnl Copyright (C) 2001-2017 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl From Paul Eggert and Bruno Haible.
  7. dnl Test whether <stdint.h> is supported or must be substituted.
  8. AC_DEFUN_ONCE([gl_STDINT_H],
  9. [
  10. AC_PREREQ([2.59])dnl
  11. AC_REQUIRE([gl_LIMITS_H])
  12. AC_REQUIRE([gt_TYPE_WINT_T])
  13. dnl Check for long long int and unsigned long long int.
  14. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  15. if test $ac_cv_type_long_long_int = yes; then
  16. HAVE_LONG_LONG_INT=1
  17. else
  18. HAVE_LONG_LONG_INT=0
  19. fi
  20. AC_SUBST([HAVE_LONG_LONG_INT])
  21. AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
  22. if test $ac_cv_type_unsigned_long_long_int = yes; then
  23. HAVE_UNSIGNED_LONG_LONG_INT=1
  24. else
  25. HAVE_UNSIGNED_LONG_LONG_INT=0
  26. fi
  27. AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
  28. dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
  29. AC_CHECK_HEADERS_ONCE([wchar.h])
  30. if test $ac_cv_header_wchar_h = yes; then
  31. HAVE_WCHAR_H=1
  32. else
  33. HAVE_WCHAR_H=0
  34. fi
  35. AC_SUBST([HAVE_WCHAR_H])
  36. dnl Check for <inttypes.h>.
  37. dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
  38. if test $ac_cv_header_inttypes_h = yes; then
  39. HAVE_INTTYPES_H=1
  40. else
  41. HAVE_INTTYPES_H=0
  42. fi
  43. AC_SUBST([HAVE_INTTYPES_H])
  44. dnl Check for <sys/types.h>.
  45. dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h.
  46. if test $ac_cv_header_sys_types_h = yes; then
  47. HAVE_SYS_TYPES_H=1
  48. else
  49. HAVE_SYS_TYPES_H=0
  50. fi
  51. AC_SUBST([HAVE_SYS_TYPES_H])
  52. gl_CHECK_NEXT_HEADERS([stdint.h])
  53. if test $ac_cv_header_stdint_h = yes; then
  54. HAVE_STDINT_H=1
  55. else
  56. HAVE_STDINT_H=0
  57. fi
  58. AC_SUBST([HAVE_STDINT_H])
  59. dnl Now see whether we need a substitute <stdint.h>.
  60. if test $ac_cv_header_stdint_h = yes; then
  61. AC_CACHE_CHECK([whether stdint.h conforms to C99],
  62. [gl_cv_header_working_stdint_h],
  63. [gl_cv_header_working_stdint_h=no
  64. AC_COMPILE_IFELSE([
  65. AC_LANG_PROGRAM([[
  66. #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
  67. #define __STDC_CONSTANT_MACROS 1
  68. #define __STDC_LIMIT_MACROS 1
  69. #include <stdint.h>
  70. /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */
  71. #if !(defined WCHAR_MIN && defined WCHAR_MAX)
  72. #error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
  73. #endif
  74. ]
  75. gl_STDINT_INCLUDES
  76. [
  77. #ifdef INT8_MAX
  78. int8_t a1 = INT8_MAX;
  79. int8_t a1min = INT8_MIN;
  80. #endif
  81. #ifdef INT16_MAX
  82. int16_t a2 = INT16_MAX;
  83. int16_t a2min = INT16_MIN;
  84. #endif
  85. #ifdef INT32_MAX
  86. int32_t a3 = INT32_MAX;
  87. int32_t a3min = INT32_MIN;
  88. #endif
  89. #ifdef INT64_MAX
  90. int64_t a4 = INT64_MAX;
  91. int64_t a4min = INT64_MIN;
  92. #endif
  93. #ifdef UINT8_MAX
  94. uint8_t b1 = UINT8_MAX;
  95. #else
  96. typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
  97. #endif
  98. #ifdef UINT16_MAX
  99. uint16_t b2 = UINT16_MAX;
  100. #endif
  101. #ifdef UINT32_MAX
  102. uint32_t b3 = UINT32_MAX;
  103. #endif
  104. #ifdef UINT64_MAX
  105. uint64_t b4 = UINT64_MAX;
  106. #endif
  107. int_least8_t c1 = INT8_C (0x7f);
  108. int_least8_t c1max = INT_LEAST8_MAX;
  109. int_least8_t c1min = INT_LEAST8_MIN;
  110. int_least16_t c2 = INT16_C (0x7fff);
  111. int_least16_t c2max = INT_LEAST16_MAX;
  112. int_least16_t c2min = INT_LEAST16_MIN;
  113. int_least32_t c3 = INT32_C (0x7fffffff);
  114. int_least32_t c3max = INT_LEAST32_MAX;
  115. int_least32_t c3min = INT_LEAST32_MIN;
  116. int_least64_t c4 = INT64_C (0x7fffffffffffffff);
  117. int_least64_t c4max = INT_LEAST64_MAX;
  118. int_least64_t c4min = INT_LEAST64_MIN;
  119. uint_least8_t d1 = UINT8_C (0xff);
  120. uint_least8_t d1max = UINT_LEAST8_MAX;
  121. uint_least16_t d2 = UINT16_C (0xffff);
  122. uint_least16_t d2max = UINT_LEAST16_MAX;
  123. uint_least32_t d3 = UINT32_C (0xffffffff);
  124. uint_least32_t d3max = UINT_LEAST32_MAX;
  125. uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
  126. uint_least64_t d4max = UINT_LEAST64_MAX;
  127. int_fast8_t e1 = INT_FAST8_MAX;
  128. int_fast8_t e1min = INT_FAST8_MIN;
  129. int_fast16_t e2 = INT_FAST16_MAX;
  130. int_fast16_t e2min = INT_FAST16_MIN;
  131. int_fast32_t e3 = INT_FAST32_MAX;
  132. int_fast32_t e3min = INT_FAST32_MIN;
  133. int_fast64_t e4 = INT_FAST64_MAX;
  134. int_fast64_t e4min = INT_FAST64_MIN;
  135. uint_fast8_t f1 = UINT_FAST8_MAX;
  136. uint_fast16_t f2 = UINT_FAST16_MAX;
  137. uint_fast32_t f3 = UINT_FAST32_MAX;
  138. uint_fast64_t f4 = UINT_FAST64_MAX;
  139. #ifdef INTPTR_MAX
  140. intptr_t g = INTPTR_MAX;
  141. intptr_t gmin = INTPTR_MIN;
  142. #endif
  143. #ifdef UINTPTR_MAX
  144. uintptr_t h = UINTPTR_MAX;
  145. #endif
  146. intmax_t i = INTMAX_MAX;
  147. uintmax_t j = UINTMAX_MAX;
  148. /* Check that SIZE_MAX has the correct type, if possible. */
  149. #if 201112 <= __STDC_VERSION__
  150. int k = _Generic (SIZE_MAX, size_t: 0);
  151. #elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
  152. || (0x5110 <= __SUNPRO_C && !__STDC__))
  153. extern size_t k;
  154. extern __typeof__ (SIZE_MAX) k;
  155. #endif
  156. #include <limits.h> /* for CHAR_BIT */
  157. #define TYPE_MINIMUM(t) \
  158. ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
  159. #define TYPE_MAXIMUM(t) \
  160. ((t) ((t) 0 < (t) -1 \
  161. ? (t) -1 \
  162. : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
  163. struct s {
  164. int check_PTRDIFF:
  165. PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
  166. && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
  167. ? 1 : -1;
  168. /* Detect bug in FreeBSD 6.0 / ia64. */
  169. int check_SIG_ATOMIC:
  170. SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
  171. && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
  172. ? 1 : -1;
  173. int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
  174. int check_WCHAR:
  175. WCHAR_MIN == TYPE_MINIMUM (wchar_t)
  176. && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
  177. ? 1 : -1;
  178. /* Detect bug in mingw. */
  179. int check_WINT:
  180. WINT_MIN == TYPE_MINIMUM (wint_t)
  181. && WINT_MAX == TYPE_MAXIMUM (wint_t)
  182. ? 1 : -1;
  183. /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */
  184. int check_UINT8_C:
  185. (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
  186. int check_UINT16_C:
  187. (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
  188. /* Detect bugs in OpenBSD 3.9 stdint.h. */
  189. #ifdef UINT8_MAX
  190. int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
  191. #endif
  192. #ifdef UINT16_MAX
  193. int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
  194. #endif
  195. #ifdef UINT32_MAX
  196. int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
  197. #endif
  198. #ifdef UINT64_MAX
  199. int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
  200. #endif
  201. int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
  202. int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
  203. int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
  204. int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
  205. int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
  206. int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
  207. int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
  208. int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
  209. int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
  210. int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
  211. int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
  212. };
  213. ]])],
  214. [dnl Determine whether the various *_MIN, *_MAX macros are usable
  215. dnl in preprocessor expression. We could do it by compiling a test
  216. dnl program for each of these macros. It is faster to run a program
  217. dnl that inspects the macro expansion.
  218. dnl This detects a bug on HP-UX 11.23/ia64.
  219. AC_RUN_IFELSE([
  220. AC_LANG_PROGRAM([[
  221. #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
  222. #define __STDC_CONSTANT_MACROS 1
  223. #define __STDC_LIMIT_MACROS 1
  224. #include <stdint.h>
  225. ]
  226. gl_STDINT_INCLUDES
  227. [
  228. #include <stdio.h>
  229. #include <string.h>
  230. #define MVAL(macro) MVAL1(macro)
  231. #define MVAL1(expression) #expression
  232. static const char *macro_values[] =
  233. {
  234. #ifdef INT8_MAX
  235. MVAL (INT8_MAX),
  236. #endif
  237. #ifdef INT16_MAX
  238. MVAL (INT16_MAX),
  239. #endif
  240. #ifdef INT32_MAX
  241. MVAL (INT32_MAX),
  242. #endif
  243. #ifdef INT64_MAX
  244. MVAL (INT64_MAX),
  245. #endif
  246. #ifdef UINT8_MAX
  247. MVAL (UINT8_MAX),
  248. #endif
  249. #ifdef UINT16_MAX
  250. MVAL (UINT16_MAX),
  251. #endif
  252. #ifdef UINT32_MAX
  253. MVAL (UINT32_MAX),
  254. #endif
  255. #ifdef UINT64_MAX
  256. MVAL (UINT64_MAX),
  257. #endif
  258. NULL
  259. };
  260. ]], [[
  261. const char **mv;
  262. for (mv = macro_values; *mv != NULL; mv++)
  263. {
  264. const char *value = *mv;
  265. /* Test whether it looks like a cast expression. */
  266. if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
  267. || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
  268. || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
  269. || strncmp (value, "((int)"/*)*/, 6) == 0
  270. || strncmp (value, "((signed short)"/*)*/, 15) == 0
  271. || strncmp (value, "((signed char)"/*)*/, 14) == 0)
  272. return mv - macro_values + 1;
  273. }
  274. return 0;
  275. ]])],
  276. [gl_cv_header_working_stdint_h=yes],
  277. [],
  278. [dnl When cross-compiling, assume it works.
  279. gl_cv_header_working_stdint_h=yes
  280. ])
  281. ])
  282. ])
  283. fi
  284. HAVE_C99_STDINT_H=0
  285. HAVE_SYS_BITYPES_H=0
  286. HAVE_SYS_INTTYPES_H=0
  287. STDINT_H=stdint.h
  288. if test "$gl_cv_header_working_stdint_h" = yes; then
  289. HAVE_C99_STDINT_H=1
  290. dnl Now see whether the system <stdint.h> works without
  291. dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
  292. AC_CACHE_CHECK([whether stdint.h predates C++11],
  293. [gl_cv_header_stdint_predates_cxx11_h],
  294. [gl_cv_header_stdint_predates_cxx11_h=yes
  295. AC_COMPILE_IFELSE([
  296. AC_LANG_PROGRAM([[
  297. #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
  298. #include <stdint.h>
  299. ]
  300. gl_STDINT_INCLUDES
  301. [
  302. intmax_t im = INTMAX_MAX;
  303. int32_t i32 = INT32_C (0x7fffffff);
  304. ]])],
  305. [gl_cv_header_stdint_predates_cxx11_h=no])])
  306. if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then
  307. AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
  308. [Define to 1 if the system <stdint.h> predates C++11.])
  309. AC_DEFINE([__STDC_LIMIT_MACROS], [1],
  310. [Define to 1 if the system <stdint.h> predates C++11.])
  311. fi
  312. AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
  313. [gl_cv_header_stdint_width],
  314. [gl_cv_header_stdint_width=no
  315. AC_COMPILE_IFELSE(
  316. [AC_LANG_PROGRAM([[
  317. /* Work if build is not clean. */
  318. #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
  319. #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
  320. #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
  321. #endif
  322. #include <stdint.h>
  323. ]gl_STDINT_INCLUDES[
  324. int iw = UINTMAX_WIDTH;
  325. ]])],
  326. [gl_cv_header_stdint_width=yes])])
  327. if test "$gl_cv_header_stdint_width" = yes; then
  328. STDINT_H=
  329. fi
  330. else
  331. dnl Check for <sys/inttypes.h>, and for
  332. dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
  333. AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
  334. if test $ac_cv_header_sys_inttypes_h = yes; then
  335. HAVE_SYS_INTTYPES_H=1
  336. fi
  337. if test $ac_cv_header_sys_bitypes_h = yes; then
  338. HAVE_SYS_BITYPES_H=1
  339. fi
  340. gl_STDINT_TYPE_PROPERTIES
  341. fi
  342. dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
  343. LIMITS_H=limits.h
  344. AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"])
  345. AC_SUBST([HAVE_C99_STDINT_H])
  346. AC_SUBST([HAVE_SYS_BITYPES_H])
  347. AC_SUBST([HAVE_SYS_INTTYPES_H])
  348. AC_SUBST([STDINT_H])
  349. AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"])
  350. ])
  351. dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
  352. dnl Determine the size of each of the given types in bits.
  353. AC_DEFUN([gl_STDINT_BITSIZEOF],
  354. [
  355. dnl Use a shell loop, to avoid bloating configure, and
  356. dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
  357. dnl config.h.in,
  358. dnl - extra AC_SUBST calls, so that the right substitutions are made.
  359. m4_foreach_w([gltype], [$1],
  360. [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
  361. [Define to the number of bits in type ']gltype['.])])
  362. for gltype in $1 ; do
  363. AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
  364. [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT],
  365. [$2
  366. #include <limits.h>], [result=unknown])
  367. eval gl_cv_bitsizeof_${gltype}=\$result
  368. ])
  369. eval result=\$gl_cv_bitsizeof_${gltype}
  370. if test $result = unknown; then
  371. dnl Use a nonempty default, because some compilers, such as IRIX 5 cc,
  372. dnl do a syntax check even on unused #if conditions and give an error
  373. dnl on valid C code like this:
  374. dnl #if 0
  375. dnl # if > 32
  376. dnl # endif
  377. dnl #endif
  378. result=0
  379. fi
  380. GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
  381. AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
  382. eval BITSIZEOF_${GLTYPE}=\$result
  383. done
  384. m4_foreach_w([gltype], [$1],
  385. [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
  386. ])
  387. dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
  388. dnl Determine the signedness of each of the given types.
  389. dnl Define HAVE_SIGNED_TYPE if type is signed.
  390. AC_DEFUN([gl_CHECK_TYPES_SIGNED],
  391. [
  392. dnl Use a shell loop, to avoid bloating configure, and
  393. dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
  394. dnl config.h.in,
  395. dnl - extra AC_SUBST calls, so that the right substitutions are made.
  396. m4_foreach_w([gltype], [$1],
  397. [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
  398. [Define to 1 if ']gltype[' is a signed integer type.])])
  399. for gltype in $1 ; do
  400. AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
  401. [AC_COMPILE_IFELSE(
  402. [AC_LANG_PROGRAM([$2[
  403. int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])],
  404. result=yes, result=no)
  405. eval gl_cv_type_${gltype}_signed=\$result
  406. ])
  407. eval result=\$gl_cv_type_${gltype}_signed
  408. GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
  409. if test "$result" = yes; then
  410. AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
  411. eval HAVE_SIGNED_${GLTYPE}=1
  412. else
  413. eval HAVE_SIGNED_${GLTYPE}=0
  414. fi
  415. done
  416. m4_foreach_w([gltype], [$1],
  417. [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
  418. ])
  419. dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
  420. dnl Determine the suffix to use for integer constants of the given types.
  421. dnl Define t_SUFFIX for each such type.
  422. AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
  423. [
  424. dnl Use a shell loop, to avoid bloating configure, and
  425. dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
  426. dnl config.h.in,
  427. dnl - extra AC_SUBST calls, so that the right substitutions are made.
  428. m4_foreach_w([gltype], [$1],
  429. [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
  430. [Define to l, ll, u, ul, ull, etc., as suitable for
  431. constants of type ']gltype['.])])
  432. for gltype in $1 ; do
  433. AC_CACHE_CHECK([for $gltype integer literal suffix],
  434. [gl_cv_type_${gltype}_suffix],
  435. [eval gl_cv_type_${gltype}_suffix=no
  436. eval result=\$gl_cv_type_${gltype}_signed
  437. if test "$result" = yes; then
  438. glsufu=
  439. else
  440. glsufu=u
  441. fi
  442. for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
  443. case $glsuf in
  444. '') gltype1='int';;
  445. l) gltype1='long int';;
  446. ll) gltype1='long long int';;
  447. i64) gltype1='__int64';;
  448. u) gltype1='unsigned int';;
  449. ul) gltype1='unsigned long int';;
  450. ull) gltype1='unsigned long long int';;
  451. ui64)gltype1='unsigned __int64';;
  452. esac
  453. AC_COMPILE_IFELSE(
  454. [AC_LANG_PROGRAM([$2[
  455. extern $gltype foo;
  456. extern $gltype1 foo;]])],
  457. [eval gl_cv_type_${gltype}_suffix=\$glsuf])
  458. eval result=\$gl_cv_type_${gltype}_suffix
  459. test "$result" != no && break
  460. done])
  461. GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
  462. eval result=\$gl_cv_type_${gltype}_suffix
  463. test "$result" = no && result=
  464. eval ${GLTYPE}_SUFFIX=\$result
  465. AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
  466. done
  467. m4_foreach_w([gltype], [$1],
  468. [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
  469. ])
  470. dnl gl_STDINT_INCLUDES
  471. AC_DEFUN([gl_STDINT_INCLUDES],
  472. [[
  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 <signal.h>
  477. #if HAVE_WCHAR_H
  478. # include <stdio.h>
  479. # include <time.h>
  480. # include <wchar.h>
  481. #endif
  482. ]])
  483. dnl gl_STDINT_TYPE_PROPERTIES
  484. dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
  485. dnl of interest to stdint.in.h.
  486. AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
  487. [
  488. AC_REQUIRE([gl_MULTIARCH])
  489. if test $APPLE_UNIVERSAL_BUILD = 0; then
  490. gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
  491. [gl_STDINT_INCLUDES])
  492. fi
  493. gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
  494. [gl_STDINT_INCLUDES])
  495. gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
  496. [gl_STDINT_INCLUDES])
  497. gl_cv_type_ptrdiff_t_signed=yes
  498. gl_cv_type_size_t_signed=no
  499. if test $APPLE_UNIVERSAL_BUILD = 0; then
  500. gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
  501. [gl_STDINT_INCLUDES])
  502. fi
  503. gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
  504. [gl_STDINT_INCLUDES])
  505. dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99
  506. dnl requirement that wint_t is "unchanged by default argument promotions".
  507. dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
  508. dnl Set the variable BITSIZEOF_WINT_T accordingly.
  509. if test $GNULIB_OVERRIDES_WINT_T = 1; then
  510. BITSIZEOF_WINT_T=32
  511. fi
  512. ])
  513. dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
  514. dnl Remove this when we can assume autoconf >= 2.61.
  515. m4_ifdef([AC_COMPUTE_INT], [], [
  516. AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
  517. ])