tz64code2006b.tar.gz
Paul Eggert
eggert at CS.UCLA.EDU
Thu Feb 23 21:21:37 UTC 2006
Ken Pizzini <tz. at explicate.org> writes:
> On one of my ia386 systems which uses
> $ gcc -v 2>&1 | grep version
> gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)
> there is no LLONG_MAX defined in stdint.h, but INT64_MAX is defined.
Well, LLONG_MAX would be in limits.h, not stdint.h.
But I checked a x86 GNU/Linux host and I see now that in this
environment, LLONG_MAX is not defined, because GCC's <limits.h> has
something like this:
#if __STDC_VERSION__ >= 199901L
# define LLONG_MAX __LONG_LONG_MAX__
#endif
and GCC by default doesn't set __STDC_VERSION__ to 199901L, even
though it has 'long long' (because it doesn't fully support all of
C99).
Also, I noticed that this environment has had stdint.h for quite some
time, but our current method of guessing HAVE_STDINT_H misses this.
GNU/Linux is a pretty common case these days. Here's a patch to
private.h that should fix both glitches, so that the tz code works
even with pre-C99 GCC and glibc implementations (the usual case
today). This patch assumes my earlier patches to private.h.
--- private.h 2006/02/23 06:18:32 2006.2.0.5
+++ private.h 2006/02/23 21:16:15 2006.2.0.7
@@ -48,10 +48,6 @@ static char privatehid[] = "@(#)private.
#define HAVE_SETTIMEOFDAY 3
#endif /* !defined HAVE_SETTIMEOFDAY */
-#ifndef HAVE_STDINT_H
-#define HAVE_STDINT_H (199901 <= __STDC_VERSION__)
-#endif /* !defined HAVE_STDINT_H */
-
#ifndef HAVE_STRERROR
#define HAVE_STRERROR 1
#endif /* !defined HAVE_STRERROR */
@@ -128,20 +124,30 @@ static char privatehid[] = "@(#)private.
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
+/* Define HAVE_STDINT_H's default value here, rather than at the
+ start, since __GLIBC__'s value depends on previously-included
+ files. (glibc 2.1 and later have stdint.h, even with pre-C99
+ compilers.) */
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H \
+ (199901 <= __STDC_VERSION__ || 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
+#endif /* !defined HAVE_STDINT_H */
+
#if HAVE_STDINT_H
#include <stdint.h>
#endif /* !HAVE_STDINT_H */
#ifndef INT_FAST64_MAX
-#ifdef LLONG_MAX
+/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
+#if defined LLONG_MAX || defined __LONG_LONG_MAX__
typedef long long int_fast64_t;
-#else /* !defined LLONG_MAX */
+#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
#if (LONG_MAX >> 31) < 0xffffffff
Please use a compiler that supports a 64-bit integer type (or wider);
you may need to compile with "-DHAVE_STDINT_H".
#endif /* (LONG_MAX >> 31) < 0xffffffff */
typedef long int_fast64_t;
-#endif /* !defined LLONG_MAX */
+#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
#endif /* !defined INT_FAST64_MAX */
#ifndef INT32_MAX
More information about the tz
mailing list