Simplification rewrite for stdint module.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 2 Jul 2006 06:49:07 +0000 (06:49 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 2 Jul 2006 06:49:07 +0000 (06:49 +0000)
commit3965bf4053324a67ed53e3d261471a567cff2502
treee7c2f4bba4e0b22b1418cad6cf2a38468636be49
parentd72b97c1e1fc085cc5f375b36e2dcf436b85cbd6
Simplification rewrite for stdint module.

* modules/inttypes (Depends-on): No longer depends on stdint.
* modules/stdint (Description): Say more about assumptions.
Say that the fast types might differ.  Say macros are used.
(Files): Remove m4/size_max.m4, m4/wchar_t.m4.  Add m4/longlong.m4.
(Makefile.am): Revise list of substituted symbols to match
new stdint.m4.
* modules/stdint-tests (Files): Add m4/wchar_t.m4, m4/wint_t.m4.
(configure.ac): Add gt_TYPE_WCHAR_T, gt_TYPE_WINT_T.
* tests/test-stdint.c (verify_same_types)
[! (__GNUC__ >= 2 && DO_PEDANTIC)]: Put in a decl, so that
the code conforms to C99/C89.
Test for WCHAR_MIN and WCHAR_MAX only if HAVE_WCHAR_T.
Test for WINT_MIN and WINT_MAX only if HAVE_WINT_T.

* lib/stdint_.h (_GL_STDINT_H): Renamed from _STDINT_H, to avoid
possible collision with system files.
(<stdio.h>, <time.h>, <wchar.h>) [defined __cplusplus && ! defined
__STDC_CONSTANT_MACROS)]: Do not include, since we don't need
WCHAR_MIN and WCHAR_MAX in this case.
(<stddef.h>): Do not include; no longer needed.
(<sys/types.h>): Include if @HAVE_SYS_TYPES_H@, not if
(defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi)).
(<sys/inttypes.h>): Include if @HAVE_SYS_INTTYPES_H@ &&
!@HAVE_INTTYPES_H@, not if (defined(__FreeBSD__)
&& (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4)).
(__STDINT_H__) [@HAVE_STDINT_H@ && defined __sgi && ! defined
__c99]: Define, to work around IRIX <stdint.h> incompatibility.
(@FULL_PATH_STDINT_H@) [!(defined(__sgi) && @HAVE_INTTYPES_H@ &&
!defined(__c99))]: Include in this case too, since it's harmless
now.
(<inttypes.h>) [@HAVE_INTTYPES_H@]: Include, since it's no longer
dangerous to do so.
(@FULL_PATH_INTTYPES_H@) [(defined(__hpux) || defined(_AIX)) &&
@HAVE_INTTYPES_H@]: Do not include, since we now include <inttypes.h>.
(_STDINT_MIN, _STDINT_MAX): New macros.
(int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t):
(uint64_t, int_least8_t, uint_least8_t, int_least16_t):
(uint_least16_t, int_least32_t, uint_least32_t, int_least64_t):
(uint_least64_t, int_fast8_t, uint_fast8_t, int_fast16_t):
(uint_fast16_t, int_fast32_t, uint_fast32_t, int_fast64_t):
(uint_fast64_t, intptr_t, uintptr_t, intmax_t, uintmax_t): Now
macros, not typedefs; this simplifies things quite a bit.
Use long int for all types narrower than int64_t.
(intmax_t, uintmax_t, INTMAX_C, UINTMAX_C):
Define in terms of long long int or int64_t or long int,
not int64_t or int32_t.  This saves some compile-time testing.
(INT8_MIN, INT8_MAX, UINT8_MAX, INT16_MIN, INT16_MAX, UINT16_MAX):
(INT32_MIN, INT32_MAX, UINT32_MAX, INT64_MIN, INT64_MAX):
(UINT64_MAX, INT_LEAST8_MIN, INT_LEAST8_MAX, UINT_LEAST8_MAX):
(INT_LEAST16_MIN, INT_LEAST16_MAX, UINT_LEAST16_MAX):
(INT_LEAST32_MIN, INT_LEAST32_MAX, UINT_LEAST32_MAX):
(INT_LEAST64_MIN, INT_LEAST64_MAX, UINT_LEAST64_MAX, INT_FAST8_MIN):
(INT_FAST8_MAX, UINT_FAST8_MAX, INT_FAST16_MIN, INT_FAST16_MAX):
(UINT_FAST16_MAX, INT_FAST32_MIN, INT_FAST32_MAX, UINT_FAST32_MAX):
(INT_FAST64_MIN, INT_FAST64_MAX, UINT_FAST64_MAX, INTPTR_MIN):
(INTPTR_MAX, UINTPTR_MAX, INTMAX_MIN, INTMAX_MAX, UINTMAX_MAX):
(PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX):
(SIZE_MAX, WCHAR_MIN, WCHAR_MAX, WINT_MIN, WINT_MAX):
undef any previous version and define our own version, for
simplicity and consistency with the new macros for types.
(PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX):
(SIZE_MAX, WCHAR_MIN, WCHAR_MAX, WINT_MIN, WINT_MAX):
Simplify definitions by using _STDINT_MIN and _STDINT_MAX
where appropriate.  Rely on new symbols @PTRDIFF_T_SUFFIX@,
@SIG_ATOMIC_T_SUFFIX@, @SIZE_T_SUFFIX@, @WCHAR_T_SUFFIX@,
@WINT_T_SUFFIX@ to keep things simple here.
(UINT8_C, UINT16_C, UINT32_C, INT64_C, UINT64_C):
Simplify by assuming typical 8/16/32/64 host, since we're
already doing that elsewhere anyway.
Use (LONG_MAX >> 31 >> 31 == 1) rather than @HAVE_LONG_64BIT@,
and assume long long int is 64 bits if available.  This
speeds up 'configure'.

* m4/longlong.m4 (AC_TYPE_LONG_LONG_INT): Backport from Autoconf 2.60,
but fix a bug, by requiring at least 64 bits.
* m4/ulonglong.m4 (AC_TYPE_UNSIGNED_LONG_LONG_INT): Likewise.
* m4/longlong.m4 (gl_AC_TYPE_LONG_LONG): Now just call
AC_TYPE_LONG_LONG_INT.  This macro is obsolete and will go soon.
* m4/ulonglong.m4 (gl_AC_TYPE_UNSIGNED_LONG_LONG) Likewise.

* m4/stdint.m4 (gl_STDINT_H): Rewrite to accommodate stdint_.h
changes.  Make 2.59 a prerequisite.  Check and substitute for
HAVE_LONG_LONG_INT.  Rely on Autoconf to check for stdint.h and
inttypes.h.  Do not use special include files; just use the
defaults.  Check for sys/inttypes.h and sys/bitypes.h in the usual
way now.  Remove no-longer-needed tests for HAVE_LONG_64BIT,
HAVE_LONG_LONG_64BIT, int8_t, int16_t, int32_t, int64_t, uint8_t,
uint16_t, uint32_t uint64_t, int_least8_t, int_least16_t,
int_least32_t, int_least64_t, uint_least8_t, uint_least16_t,
uint_least32_t, uint_least64_t, int_fast8_t, int_fast16_t,
int_fast32_t, int_fast64_t, uint_fast8_t uint_fast16_t,
uint_fast32_t, uint_fast64_t, intptr_t, uintptr_t, intmax_t,
uintmax_t, INT8_MIN, INT8_MAX, UINT8_MAX, INT16_MIN, INT16_MAX,
UINT16_MAX, INT32_MIN, INT32_MAX, UINT32_MAX, INT64_MIN,
INT64_MAX, UINT64_MAX, INT_LEAST8_MIN, INT_LEAST8_MAX,
UINT_LEAST8_MAX, INT_LEAST16_MIN, INT_LEAST16_MAX,
UINT_LEAST16_MAX, INT_LEAST32_MIN, INT_LEAST32_MAX,
UINT_LEAST32_MAX, INT_LEAST64_MIN, INT_LEAST64_MAX,
UINT_LEAST64_MAX, INT_FAST8_MIN, INT_FAST8_MAX, UINT_FAST8_MAX,
INT_FAST16_MIN, INT_FAST16_MAX, UINT_FAST16_MAX, INT_FAST32_MIN,
INT_FAST32_MAX, UINT_FAST32_MAX, INT_FAST64_MIN, INT_FAST64_MAX,
UINT_FAST64_MAX, INTPTR_MIN, INTPTR_MAX, UINTPTR_MAX, INTMAX_MIN,
INTMAX_MAX, UINTMAX_MAX, PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN,
SIG_ATOMIC_MAX, SIZE_MAX, WCHAR_MIN, WCHAR_MAX, WINT_MIN,
WINT_MAX.  Check for C99 conformance more strictly, by detecting
bugs in glibc 2.4, Solaris 10, and OpenBSD 3.9.  On the other hand do
not check for things that C99 does not require, e.g., int8_t.  If
a test isn't needed unless <stdint.h> isn't working, and is
unlikely to be needed for any other reason, then don't do it
unless <stdint.h> isn't working.  Do not check for ptrdiff_t or
size_t, since we assume C89 freestanding at least.  Do not check
for sig_atomic_t, wchar_t, or wint_t, since the code now does
the right thing even if the types are not defined.  Instead use:
(gl_STDINT_TYPE_PROPERTIES): New macro.
(gl_HEADER_STDINT_H, gl_HEADER_INTTYPES_H): Remove.  Don't bother
testing whether <sys/types.h> clashes, as Autoconf does this for
us now.  All uses removed.
(gl_STDINT_CHECK_TYPES, gl_STDINT_MISSING_BOUND):
(gl_STDINT_MISSING_BOUNDS, gl_STDINT_MISSING_BOUNDS2):
(gl_CHECK_TYPE_SAME):
Remove; no longer needed.
(gl_STDINT_BITSIZEOF): Don't bother to check whether the type
exists, since we'll return 0 anyway in that case.
(gl_INTEGER_TYPE_SUFFIX, gl_STDINT_INCLUDES): New macros.
ChangeLog
lib/ChangeLog
lib/stdint_.h
m4/ChangeLog
m4/longlong.m4
m4/stdint.m4
m4/ulonglong.m4
modules/inttypes
modules/stdint
modules/stdint-tests
tests/test-stdint.c