From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6623 Path: news.gmane.org!not-for-mail From: Jens Gustedt Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 3/4] use exact types for the [U]INTXX_C macros Date: Tue, 25 Nov 2014 15:50:06 +0100 Message-ID: <1416926886.16006.925.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1416927028 1617 80.91.229.3 (25 Nov 2014 14:50:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2014 14:50:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6636-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 25 15:50:20 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XtHRc-0005UZ-Ay for gllmg-musl@m.gmane.org; Tue, 25 Nov 2014 15:50:20 +0100 Original-Received: (qmail 3462 invoked by uid 550); 25 Nov 2014 14:50:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 3451 invoked from network); 25 Nov 2014 14:50:18 -0000 X-IronPort-AV: E=Sophos;i="5.07,455,1413237600"; d="scan'208";a="109493411" Resent-From: Jens Gustedt Resent-To: musl@lists.openwall.com X-Mailer: Evolution 3.4.4-3 Xref: news.gmane.org gmane.linux.lib.musl.general:6623 Archived-At: 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 +/* The limits here must use the promoted types. */ /* Most limits are system-specific */ #include 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 -#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