mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH 3/4] use exact types for the [U]INTXX_C macros
@ 2014-11-25 14:50 Jens Gustedt
  2014-12-02 18:03 ` Rich Felker
  0 siblings, 1 reply; 11+ messages in thread
From: Jens Gustedt @ 2014-11-25 14:50 UTC (permalink / raw)
  To: musl

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



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-12-03 14:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25 14:50 [PATCH 3/4] use exact types for the [U]INTXX_C macros Jens Gustedt
2014-12-02 18:03 ` Rich Felker
2014-12-02 19:20   ` Jens Gustedt
2014-12-02 19:44     ` Rich Felker
2014-12-02 21:37       ` Jens Gustedt
2014-12-03  0:01         ` Rich Felker
2014-12-03 10:20           ` Jens Gustedt
2014-12-03 13:21             ` Szabolcs Nagy
2014-12-03 14:17               ` Jens Gustedt
2014-12-03 14:50                 ` Rich Felker
2014-12-03 14:47             ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).