changeset 6861:b82bca6af622

Take into account ISO C 99 TC1.
author Bruno Haible <bruno@clisp.org>
date Fri, 23 Jun 2006 14:58:59 +0000
parents 58381f8b1b9b
children ba1b5722df42
files ChangeLog lib/ChangeLog lib/stdint_.h tests/test-stdint.c
diffstat 4 files changed, 48 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-23  Bruno Haible  <bruno@clisp.org>
+
+	* tests/test-stdint.c: Update to match ISO C 99 Technical
+	Corrigendum 1.
+
 2006-06-21  Simon Josefsson  <jas@extundo.com>
 
 	* tests/test-getaddrinfo.c: New file.
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-23  Bruno Haible  <bruno@clisp.org>
+
+	* stdlib_.h (UINT8_C, UINT16_C, UINT32_C): Define according to
+	ISO C 99 Technical Corrigendum 1.
+
 2006-06-22  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* glob.c (collated_compare): Remove 'const' uses that weren't needed.
--- a/lib/stdint_.h
+++ b/lib/stdint_.h
@@ -924,21 +924,46 @@
 #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
--- a/tests/test-stdint.c
+++ b/tests/test-stdint.c
@@ -322,41 +322,33 @@
 /* 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