bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] stdint_.h update


From: Paul Eggert
Subject: Re: [bug-gnulib] stdint_.h update
Date: Sat, 14 May 2005 10:59:28 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> + #elif defined(_MSC_VER)
> + typedef __int64          int64_t;
> + typedef unsigned __int64 uint64_t;
>   #endif

Shouldn't that typedef of int64_t be protected by "#ifdef
NEED_SIGNED_INT_TYPES"?  That is done everywhere else that int64_t is
declared.  (As an aside, NEED_SIGNED_INT_TYPES seems misnamed to me.
It doesn't affect int_fast32_t, for example.  Perhaps we should just
call it CYGWIN32_BOTCH or something like that?)

I like Jim's suggestion for simplification.  I have one more: define
a symbol HAVE_64_BIT_INT and use it instead of the repeated
"@HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER)".
Something like this, perhaps?

2005-05-14  Paul Eggert  <address@hidden>
       and  Jim Meyering  <address@hidden>

        * stdint_.h (HAVE_64_BIT_INT): New macro, replacing all uses of
        @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER).
        (int64_t): Don't declare if NEED_SIGNED_BIT_TYPES is not set.
        (INT64_MIN, INT64_MAX, UINT64_MAX): Define in terms INT64_C
        and UINT64_C, to eliminate repetition.

--- stdint_.h   2005-05-14 10:38:06 -0700
+++ /tmp/stdint_.h      2005-05-14 10:54:32 -0700
@@ -74,17 +74,22 @@ typedef int            int32_t;
 typedef unsigned int   uint32_t;
 
 #if @HAVE_LONG_64BIT@
+#define HAVE_64_BIT_INT 1
 #ifdef NEED_SIGNED_INT_TYPES
 typedef long           int64_t;
 #endif
 typedef unsigned long  uint64_t;
 #elif @HAVE_LONG_LONG_64BIT@
+#define HAVE_64_BIT_INT 1
 #ifdef NEED_SIGNED_INT_TYPES
 typedef long long          int64_t;
 #endif
 typedef unsigned long long uint64_t;
 #elif defined(_MSC_VER)
+#define HAVE_64_BIT_INT 1
+#ifdef NEED_SIGNED_INT_TYPES
 typedef __int64          int64_t;
+#endif
 typedef unsigned __int64 uint64_t;
 #endif
 
@@ -98,7 +103,7 @@ typedef int16_t  int_least16_t;
 typedef uint16_t uint_least16_t;
 typedef int32_t  int_least32_t;
 typedef uint32_t uint_least32_t;
-#if @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER)
+#if HAVE_64_BIT_INT
 typedef int64_t  int_least64_t;
 typedef uint64_t uint_least64_t;
 #endif
@@ -111,7 +116,7 @@ typedef int32_t  int_fast16_t;
 typedef uint32_t uint_fast16_t;
 typedef int32_t  int_fast32_t;
 typedef uint32_t uint_fast32_t;
-#if @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER)
+#if HAVE_64_BIT_INT
 typedef int64_t  int_fast64_t;
 typedef uint64_t uint_fast64_t;
 #endif
@@ -129,7 +134,7 @@ typedef unsigned long uintptr_t;
 
 /* 7.18.1.5. Greatest-width integer types */
 
-#if @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER)
+#if HAVE_64_BIT_INT
 typedef int64_t  intmax_t;
 typedef uint64_t uintmax_t;
 #else
@@ -152,18 +157,10 @@ typedef uint32_t uintmax_t;
 #define INT32_MIN   (~INT32_MAX)
 #define INT32_MAX   2147483647
 #define UINT32_MAX  4294967295U
-#if @HAVE_LONG_64BIT@
-#define INT64_MIN   (~INT64_MIN)
-#define INT64_MAX   9223372036854775807L
-#define UINT64_MAX 18446744073709551615UL
-#elif @HAVE_LONG_LONG_64BIT@
-#define INT64_MIN   (~INT64_MIN)
-#define INT64_MAX   9223372036854775807LL
-#define UINT64_MAX 18446744073709551615ULL
-#elif defined(_MSC_VER)
-#define INT64_MIN   (~INT64_MIN)
-#define INT64_MAX   9223372036854775807i64
-#define UINT64_MAX 18446744073709551615ui64
+#if HAVE_64_BIT_INT
+#define INT64_MIN   (~INT64_MAX)
+#define INT64_MAX   INT64_C(9223372036854775807)
+#define UINT64_MAX  UINT64_C(18446744073709551615)
 #endif
 
 /* 7.18.2.2. Limits of minimum-width integer types */
@@ -177,7 +174,7 @@ typedef uint32_t uintmax_t;
 #define INT_LEAST32_MIN INT32_MIN
 #define INT_LEAST32_MAX INT32_MAX
 #define UINT_LEAST32_MAX UINT32_MAX
-#if @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER)
+#if HAVE_64_BIT_INT
 #define INT_LEAST64_MIN INT64_MIN
 #define INT_LEAST64_MAX INT64_MAX
 #define UINT_LEAST64_MAX UINT64_MAX
@@ -194,7 +191,7 @@ typedef uint32_t uintmax_t;
 #define INT_FAST32_MIN INT32_MIN
 #define INT_FAST32_MAX INT32_MAX
 #define UINT_FAST32_MAX UINT32_MAX
-#if @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER)
+#if HAVE_64_BIT_INT
 #define INT_FAST64_MIN INT64_MIN
 #define INT_FAST64_MAX INT64_MAX
 #define UINT_FAST64_MAX UINT64_MAX
@@ -208,7 +205,7 @@ typedef uint32_t uintmax_t;
 
 /* 7.18.2.5. Limits of greatest-width integer types */
 
-#if @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined(_MSC_VER)
+#if HAVE_64_BIT_INT
 #define INTMAX_MIN INT64_MIN
 #define INTMAX_MAX INT64_MAX
 #define UINTMAX_MAX UINT64_MAX




reply via email to

[Prev in Thread] Current Thread [Next in Thread]