From: Paul Eggert Date: Mon, 7 May 2012 23:15:14 +0000 (-0700) Subject: stdint: be more consistent with glibc, SunOS libc X-Git-Tag: v0.1~692 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=7d3ed9f612cfad25a8eb39cde81c8cf6bc422f64;p=gnulib.git stdint: be more consistent with glibc, SunOS libc * lib/stdint.in.h (gl_int_fast8_t, gl_uint_fast8_t) (gl_int_fast16_t, gl_uint_fast16_t) (gl_int_fast32_t, gl_uint_fast32_t) (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): Be consistent with glibc by default, and with SunOS 5.10 and later if __sun is defined. This lessens the likelihood of clashes if code compiled for older hosts is combined with code compiled for newer ones. Problem reported by Niels Möller in . --- diff --git a/ChangeLog b/ChangeLog index 2f06ff07c..db6b62086 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2012-05-07 Paul Eggert + + stdint: be more consistent with glibc, SunOS libc + * lib/stdint.in.h (gl_int_fast8_t, gl_uint_fast8_t) + (gl_int_fast16_t, gl_uint_fast16_t) + (gl_int_fast32_t, gl_uint_fast32_t) + (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): + Be consistent with glibc by default, and with SunOS 5.10 and later + if __sun is defined. This lessens the likelihood of clashes if + code compiled for older hosts is combined with code compiled for + newer ones. Problem reported by Niels Möller in + . + 2012-05-07 Eric Blake isatty: relax license to LGPLv2+ diff --git a/lib/stdint.in.h b/lib/stdint.in.h index 54ec7e0cf..9a82ae744 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -90,7 +90,8 @@ # include #endif -/* Get LONG_MIN, LONG_MAX, ULONG_MAX. */ +/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX, + LONG_MIN, LONG_MAX, ULONG_MAX. */ #include #if @HAVE_INTTYPES_H@ @@ -246,8 +247,9 @@ typedef unsigned long long int gl_uint64_t; /* Here we assume a standard architecture where the hardware integer types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types - are taken from the same list of types. Assume that 'long int' - is fast enough for all narrower integers. */ + are taken from the same list of types. The following code normally + uses types consistent with glibc, as that lessens the chance of + incompatibility with older GNU hosts. */ #undef int_fast8_t #undef uint_fast8_t @@ -257,12 +259,21 @@ typedef unsigned long long int gl_uint64_t; #undef uint_fast32_t #undef int_fast64_t #undef uint_fast64_t -typedef long int gl_int_fast8_t; -typedef unsigned long int gl_uint_fast8_t; -typedef long int gl_int_fast16_t; -typedef unsigned long int gl_uint_fast16_t; +typedef signed char gl_int_fast8_t; +typedef unsigned char gl_uint_fast8_t; + +#ifdef __sun +/* Define types compatible with SunOS 5.10, so that code compiled under + earlier SunOS versions works with code compiled under SunOS 5.10. */ +typedef int gl_int_fast32_t; +typedef unsigned int gl_uint_fast32_t; +#else typedef long int gl_int_fast32_t; typedef unsigned long int gl_uint_fast32_t; +#endif +typedef gl_int_fast32_t gl_int_fast16_t; +typedef gl_uint_fast32_t gl_uint_fast16_t; + #define int_fast8_t gl_int_fast8_t #define uint_fast8_t gl_uint_fast8_t #define int_fast16_t gl_int_fast16_t @@ -418,23 +429,29 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) #undef INT_FAST8_MIN #undef INT_FAST8_MAX #undef UINT_FAST8_MAX -#define INT_FAST8_MIN LONG_MIN -#define INT_FAST8_MAX LONG_MAX -#define UINT_FAST8_MAX ULONG_MAX +#define INT_FAST8_MIN SCHAR_MIN +#define INT_FAST8_MAX SCHAR_MAX +#define UINT_FAST8_MAX UCHAR_MAX #undef INT_FAST16_MIN #undef INT_FAST16_MAX #undef UINT_FAST16_MAX -#define INT_FAST16_MIN LONG_MIN -#define INT_FAST16_MAX LONG_MAX -#define UINT_FAST16_MAX ULONG_MAX +#define INT_FAST16_MIN INT_FAST32_MIN +#define INT_FAST16_MAX INT_FAST32_MAX +#define UINT_FAST16_MAX UINT_FAST32_MAX #undef INT_FAST32_MIN #undef INT_FAST32_MAX #undef UINT_FAST32_MAX -#define INT_FAST32_MIN LONG_MIN -#define INT_FAST32_MAX LONG_MAX -#define UINT_FAST32_MAX ULONG_MAX +#ifdef __sun +# define INT_FAST32_MIN INT_MIN +# define INT_FAST32_MAX INT_MAX +# define UINT_FAST32_MAX UINT_MAX +#else +# define INT_FAST32_MIN LONG_MIN +# define INT_FAST32_MAX LONG_MAX +# define UINT_FAST32_MAX ULONG_MAX +#endif #undef INT_FAST64_MIN #undef INT_FAST64_MAX