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