diff options
Diffstat (limited to 'gl/m4/stdint.m4')
| -rw-r--r-- | gl/m4/stdint.m4 | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4 index 1a4b4a6a..bb6c34fe 100644 --- a/gl/m4/stdint.m4 +++ b/gl/m4/stdint.m4 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # stdint.m4 serial 22 | 1 | # stdint.m4 serial 29 |
| 2 | dnl Copyright (C) 2001-2002, 2004-2007 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| @@ -45,32 +45,32 @@ AC_DEFUN([gl_STDINT_H], | |||
| 45 | fi | 45 | fi |
| 46 | AC_SUBST([HAVE_SYS_TYPES_H]) | 46 | AC_SUBST([HAVE_SYS_TYPES_H]) |
| 47 | 47 | ||
| 48 | dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_stdint_h. | 48 | gl_CHECK_NEXT_HEADERS([stdint.h]) |
| 49 | if test $ac_cv_header_stdint_h = yes; then | 49 | if test $ac_cv_header_stdint_h = yes; then |
| 50 | gl_ABSOLUTE_HEADER([stdint.h]) | ||
| 51 | ABSOLUTE_STDINT_H=\"$gl_cv_absolute_stdint_h\" | ||
| 52 | HAVE_STDINT_H=1 | 50 | HAVE_STDINT_H=1 |
| 53 | else | 51 | else |
| 54 | ABSOLUTE_STDINT_H=\"no/such/file/stdint.h\" | ||
| 55 | HAVE_STDINT_H=0 | 52 | HAVE_STDINT_H=0 |
| 56 | fi | 53 | fi |
| 57 | AC_SUBST([ABSOLUTE_STDINT_H]) | ||
| 58 | AC_SUBST([HAVE_STDINT_H]) | 54 | AC_SUBST([HAVE_STDINT_H]) |
| 59 | 55 | ||
| 60 | dnl Now see whether we need a substitute <stdint.h>. Use | 56 | dnl Now see whether we need a substitute <stdint.h>. |
| 61 | dnl ABSOLUTE_STDINT_H, not <stdint.h>, so that it also works during | ||
| 62 | dnl a "config.status --recheck" if a stdint.h has been | ||
| 63 | dnl created in the build directory. | ||
| 64 | if test $ac_cv_header_stdint_h = yes; then | 57 | if test $ac_cv_header_stdint_h = yes; then |
| 65 | AC_CACHE_CHECK([whether stdint.h conforms to C99], | 58 | AC_CACHE_CHECK([whether stdint.h conforms to C99], |
| 66 | [gl_cv_header_working_stdint_h], | 59 | [gl_cv_header_working_stdint_h], |
| 67 | [gl_cv_header_working_stdint_h=no | 60 | [gl_cv_header_working_stdint_h=no |
| 68 | AC_COMPILE_IFELSE([ | 61 | AC_COMPILE_IFELSE([ |
| 69 | AC_LANG_PROGRAM([[ | 62 | AC_LANG_PROGRAM([[ |
| 70 | #include <stddef.h> | ||
| 71 | #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ | 63 | #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ |
| 72 | #define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */ | 64 | #define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */ |
| 73 | #include ABSOLUTE_STDINT_H | 65 | #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ |
| 66 | #include <stdint.h> | ||
| 67 | /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */ | ||
| 68 | #if !(defined WCHAR_MIN && defined WCHAR_MAX) | ||
| 69 | #error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>" | ||
| 70 | #endif | ||
| 71 | ] | ||
| 72 | gl_STDINT_INCLUDES | ||
| 73 | [ | ||
| 74 | #ifdef INT8_MAX | 74 | #ifdef INT8_MAX |
| 75 | int8_t a1 = INT8_MAX; | 75 | int8_t a1 = INT8_MAX; |
| 76 | int8_t a1min = INT8_MIN; | 76 | int8_t a1min = INT8_MIN; |
| @@ -142,12 +142,32 @@ uintptr_t h = UINTPTR_MAX; | |||
| 142 | #endif | 142 | #endif |
| 143 | intmax_t i = INTMAX_MAX; | 143 | intmax_t i = INTMAX_MAX; |
| 144 | uintmax_t j = UINTMAX_MAX; | 144 | uintmax_t j = UINTMAX_MAX; |
| 145 | |||
| 146 | #include <limits.h> /* for CHAR_BIT */ | ||
| 147 | #define TYPE_MINIMUM(t) \ | ||
| 148 | ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) | ||
| 149 | #define TYPE_MAXIMUM(t) \ | ||
| 150 | ((t) ((t) 0 < (t) -1 ? (t) -1 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) | ||
| 145 | struct s { | 151 | struct s { |
| 146 | int check_PTRDIFF: PTRDIFF_MIN < 0 && 0 < PTRDIFF_MAX ? 1 : -1; | 152 | int check_PTRDIFF: |
| 147 | int check_SIG_ATOMIC: SIG_ATOMIC_MIN <= 0 && 0 < SIG_ATOMIC_MAX ? 1 : -1; | 153 | PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) |
| 148 | int check_SIZE: 0 < SIZE_MAX ? 1 : -1; | 154 | && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) |
| 149 | int check_WCHAR: WCHAR_MIN <= 0 && 0 < WCHAR_MAX ? 1 : -1; | 155 | ? 1 : -1; |
| 150 | int check_WINT: WINT_MIN <= 0 && 0 < WINT_MAX ? 1 : -1; | 156 | /* Detect bug in FreeBSD 6.0 / ia64. */ |
| 157 | int check_SIG_ATOMIC: | ||
| 158 | SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) | ||
| 159 | && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) | ||
| 160 | ? 1 : -1; | ||
| 161 | int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1; | ||
| 162 | int check_WCHAR: | ||
| 163 | WCHAR_MIN == TYPE_MINIMUM (wchar_t) | ||
| 164 | && WCHAR_MAX == TYPE_MAXIMUM (wchar_t) | ||
| 165 | ? 1 : -1; | ||
| 166 | /* Detect bug in mingw. */ | ||
| 167 | int check_WINT: | ||
| 168 | WINT_MIN == TYPE_MINIMUM (wint_t) | ||
| 169 | && WINT_MAX == TYPE_MAXIMUM (wint_t) | ||
| 170 | ? 1 : -1; | ||
| 151 | 171 | ||
| 152 | /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ | 172 | /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ |
| 153 | int check_UINT8_C: | 173 | int check_UINT8_C: |
| @@ -202,6 +222,10 @@ struct s { | |||
| 202 | fi | 222 | fi |
| 203 | AC_SUBST([HAVE_SYS_BITYPES_H]) | 223 | AC_SUBST([HAVE_SYS_BITYPES_H]) |
| 204 | 224 | ||
| 225 | dnl Check for <wchar.h> (missing in Linux uClibc when built without wide | ||
| 226 | dnl character support). | ||
| 227 | AC_CHECK_HEADERS_ONCE([wchar.h]) | ||
| 228 | |||
| 205 | gl_STDINT_TYPE_PROPERTIES | 229 | gl_STDINT_TYPE_PROPERTIES |
| 206 | STDINT_H=stdint.h | 230 | STDINT_H=stdint.h |
| 207 | fi | 231 | fi |
| @@ -337,14 +361,16 @@ AC_DEFUN([gl_STDINT_INCLUDES], | |||
| 337 | included before <wchar.h>. */ | 361 | included before <wchar.h>. */ |
| 338 | #include <stddef.h> | 362 | #include <stddef.h> |
| 339 | #include <signal.h> | 363 | #include <signal.h> |
| 340 | #include <stdio.h> | 364 | #if HAVE_WCHAR_H |
| 341 | #include <time.h> | 365 | # include <stdio.h> |
| 342 | #include <wchar.h> | 366 | # include <time.h> |
| 367 | # include <wchar.h> | ||
| 368 | #endif | ||
| 343 | ]]) | 369 | ]]) |
| 344 | 370 | ||
| 345 | dnl gl_STDINT_TYPE_PROPERTIES | 371 | dnl gl_STDINT_TYPE_PROPERTIES |
| 346 | dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t | 372 | dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t |
| 347 | dnl of interest to stdint_.h. | 373 | dnl of interest to stdint.in.h. |
| 348 | AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], | 374 | AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], |
| 349 | [ | 375 | [ |
| 350 | gl_STDINT_BITSIZEOF([ptrdiff_t sig_atomic_t size_t wchar_t wint_t], | 376 | gl_STDINT_BITSIZEOF([ptrdiff_t sig_atomic_t size_t wchar_t wint_t], |
