Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue, 25 Nov 2014 15:50:06 +0100
From: Jens Gustedt <Jens.Gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: [PATCH 3/4] use exact types for the [U]INTXX_C macros

The C standard requires the exact types [u]int_leastXX_t for these
macros in 7.20.4.1
---
 arch/x86_64/bits/alltypes.h.in |  3 +++
 include/limits.h               |  1 +
 include/stdint.h               | 31 ++++++++++++-------------------
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/arch/x86_64/bits/alltypes.h.in b/arch/x86_64/bits/alltypes.h.in
index 2ce8e4a..aff4b8d 100644
--- a/arch/x86_64/bits/alltypes.h.in
+++ b/arch/x86_64/bits/alltypes.h.in
@@ -2,6 +2,9 @@
 #define _Int64 long
 #define _Reg long
 
+#define _INTEGER_C(T, X) ((T)+(X))
+#define _UINTEGER_C(T, X) ((T)+((X)+0ULL))
+
 TYPEDEF __builtin_va_list va_list;
 TYPEDEF __builtin_va_list __isoc_va_list;
 
diff --git a/include/limits.h b/include/limits.h
index f9805a1..fcb2071 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -3,6 +3,7 @@
 
 #include <features.h>
 
+/* The limits here must use the promoted types. */
 /* Most limits are system-specific */
 
 #include <bits/limits.h>
diff --git a/include/stdint.h b/include/stdint.h
index ad6aaea..8b91163 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -94,24 +94,17 @@ typedef uint64_t uint_least64_t;
 
 #include <bits/stdint.h>
 
-#define INT8_C(c)  c
-#define INT16_C(c) c
-#define INT32_C(c) c
-
-#define UINT8_C(c)  c
-#define UINT16_C(c) c
-#define UINT32_C(c) c ## U
-
-#if UINTPTR_MAX == UINT64_MAX
-#define INT64_C(c) c ## L
-#define UINT64_C(c) c ## UL
-#define INTMAX_C(c)  c ## L
-#define UINTMAX_C(c) c ## UL
-#else
-#define INT64_C(c) c ## LL
-#define UINT64_C(c) c ## ULL
-#define INTMAX_C(c)  c ## LL
-#define UINTMAX_C(c) c ## ULL
-#endif
+/* Macros defined here must use the exact types, not the promoted
+   ones. */
+
+#define INT8_C(c)  _INTEGER_C(int_least8_t, c)
+#define INT16_C(c) _INTEGER_C(int_least16_t, c)
+#define INT32_C(c) _INTEGER_C(int_least32_t, c)
+#define INT64_C(c) _INTEGER_C(int_least64_t, c)
+
+#define UINT8_C(c)  _UINTEGER_C(uint_least8_t, c)
+#define UINT16_C(c) _UINTEGER_C(uint_least16_t, c)
+#define UINT32_C(c) _UINTEGER_C(uint_least32_t, c)
+#define UINT64_C(c) _UINTEGER_C(uint_least64_t, c)
 
 #endif
-- 
1.9.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.