From 056cbcb8becf3b1e22bfb452ad04a5116fa71432 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 23 Jun 2006 14:58:59 +0000 Subject: [PATCH] Take into account ISO C 99 TC1. --- ChangeLog | 5 +++++ lib/ChangeLog | 5 +++++ lib/stdint_.h | 31 ++++++++++++++++++++++++++++--- tests/test-stdint.c | 28 ++++++++++------------------ 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index eca0b9591b..2b06e7d6f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-06-23 Bruno Haible + + * tests/test-stdint.c: Update to match ISO C 99 Technical + Corrigendum 1. + 2006-06-21 Simon Josefsson * tests/test-getaddrinfo.c: New file. diff --git a/lib/ChangeLog b/lib/ChangeLog index 8ea50832eb..2c4cf82492 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2006-06-23 Bruno Haible + + * stdlib_.h (UINT8_C, UINT16_C, UINT32_C): Define according to + ISO C 99 Technical Corrigendum 1. + 2006-06-22 Paul Eggert * glob.c (collated_compare): Remove 'const' uses that weren't needed. diff --git a/lib/stdint_.h b/lib/stdint_.h index d7f7431253..96385e1f40 100644 --- a/lib/stdint_.h +++ b/lib/stdint_.h @@ -924,21 +924,46 @@ typedef uint32_t uintmax_t; #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) /* 7.18.4.1. Macros for minimum-width integer constants */ +/* According to ISO C 99 Technical Corrigendum 1 */ #undef INT8_C #undef UINT8_C #define INT8_C(x) x -#define UINT8_C(x) x##U +#if @HAVE_UINT8_T@ +# if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@ +# define UINT8_C(x) x +# else +# define UINT8_C(x) x##U +# endif +#else +# define UINT8_C(x) x +#endif #undef INT16_C #undef UINT16_C #define INT16_C(x) x -#define UINT16_C(x) x##U +#if @HAVE_UINT16_T@ +# if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@ +# define UINT16_C(x) x +# else +# define UINT16_C(x) x##U +# endif +#else +# define UINT16_C(x) x +#endif #undef INT32_C #undef UINT32_C #define INT32_C(x) x -#define UINT32_C(x) x##U +#if @HAVE_UINT32_T@ +# if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@ +# define UINT32_C(x) x +# else +# define UINT32_C(x) x##U +# endif +#else +# define UINT32_C(x) x +#endif #undef INT64_C #undef UINT64_C diff --git a/tests/test-stdint.c b/tests/test-stdint.c index a2f8f8e0ba..cff7f54a54 100644 --- a/tests/test-stdint.c +++ b/tests/test-stdint.c @@ -322,41 +322,33 @@ err or; /* 7.18.4. Macros for integer constants */ verify (INT8_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (INT8_C (17), (int_least8_t)0); -#endif +verify_same_types (INT8_C (17), (int_least8_t)0 + 0); verify (UINT8_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (UINT8_C (17), (uint_least8_t)0); -#endif +verify_same_types (UINT8_C (17), (uint_least8_t)0 + 0); verify (INT16_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (INT16_C (17), (int_least16_t)0); -#endif +verify_same_types (INT16_C (17), (int_least16_t)0 + 0); verify (UINT16_C (17) == 17); -#if 0 /* The language in ISO C 99 7.18.4 is too strong. */ -verify_same_types (UINT16_C (17), (uint_least16_t)0); -#endif +verify_same_types (UINT16_C (17), (uint_least16_t)0 + 0); verify (INT32_C (17) == 17); -verify_same_types (INT32_C (17), (int_least32_t)0); +verify_same_types (INT32_C (17), (int_least32_t)0 + 0); verify (UINT32_C (17) == 17); -verify_same_types (UINT32_C (17), (uint_least32_t)0); +verify_same_types (UINT32_C (17), (uint_least32_t)0 + 0); #if HAVE_INT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_INT64 verify (INT64_C (17) == 17); -verify_same_types (INT64_C (17), (int_least64_t)0); +verify_same_types (INT64_C (17), (int_least64_t)0 + 0); #endif #if HAVE_UINT_LEAST64_T_IN_STDINT_H || _STDINT_H_HAVE_UINT64 verify (UINT64_C (17) == 17); -verify_same_types (UINT64_C (17), (uint_least64_t)0); +verify_same_types (UINT64_C (17), (uint_least64_t)0 + 0); #endif verify (INTMAX_C (17) == 17); -verify_same_types (INTMAX_C (17), (intmax_t)0); +verify_same_types (INTMAX_C (17), (intmax_t)0 + 0); verify (UINTMAX_C (17) == 17); -verify_same_types (UINTMAX_C (17), (uintmax_t)0); +verify_same_types (UINTMAX_C (17), (uintmax_t)0 + 0); int -- 2.30.2