mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <Jens.Gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: [PATCH 3/4] use exact types for the [U]INTXX_C macros
Date: Tue, 25 Nov 2014 15:50:06 +0100	[thread overview]
Message-ID: <1416926886.16006.925.camel@eris.loria.fr> (raw)

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



             reply	other threads:[~2014-11-25 14:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25 14:50 Jens Gustedt [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416926886.16006.925.camel@eris.loria.fr \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).