bug-gnulib
[Top][All Lists]
Advanced

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

Re: gnulib stdint.h substitution of int64_t results in a linking error i


From: Paul Eggert
Subject: Re: gnulib stdint.h substitution of int64_t results in a linking error in GCC 4.(3|2|0) on OSX
Date: Wed, 24 Nov 2010 12:07:52 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10

I pushed the following patch; could you please give it a try?
I don't have an OSX host to test it on.  Thanks.

>From 531b8a416b6ae40f89808e1db8976eb25972e661 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Wed, 24 Nov 2010 12:05:43 -0800
Subject: [PATCH] stdint: port to GCC 4.3 + OSX + Octave

On this platform, stdint.h is buggy and defines int64_t to long
long int.  The replacement defined it to long int, causing
problems with C++ style name mangling.  Instead, trust the system
definition if INT64_MAX is defined, and likewise for the unsigned
variant.   Problem reported by Jarno Rajahalme in
<http://lists.gnu.org/archive/html/bug-gnulib/2010-04/msg00143.html>.
* lib/stdint.in.h (GL_INT64_T): Define if INT64_MAX is defined,
and don't mess with int64_t and INT64_MAX in this case.
(GL_UINT64_T): Likewise for UINT64_MAX and uint64_t.
---
 ChangeLog       |   13 ++++++++++
 lib/stdint.in.h |   68 +++++++++++++++++++++++++++++++-----------------------
 2 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 86d939a..8dd51e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-11-24  Paul Eggert  <address@hidden>
+
+       stdint: port to GCC 4.3 + OSX + Octave
+       On this platform, stdint.h is buggy and defines int64_t to long
+       long int.  The replacement defined it to long int, causing
+       problems with C++ style name mangling.  Instead, trust the system
+       definition if INT64_MAX is defined, and likewise for the unsigned
+       variant.   Problem reported by Jarno Rajahalme in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2010-04/msg00143.html>.
+       * lib/stdint.in.h (GL_INT64_T): Define if INT64_MAX is defined,
+       and don't mess with int64_t and INT64_MAX in this case.
+       (GL_UINT64_T): Likewise for UINT64_MAX and uint64_t.
+
 2010-11-24  Bruno Haible  <address@hidden>
 
        doc: Corrections regarding MacOS X 10.4 and 10.5.
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index e660cfb..70822b8 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -134,40 +134,53 @@ typedef unsigned int gl_uint32_t;
 #define int32_t gl_int32_t
 #define uint32_t gl_uint32_t
 
+/* If the system defines INT64_MAX, assume int64_t works.  That way,
+   if the underlying platform defines int64_t to be a 64-bit long long
+   int, the code below won't mistakenly define it to be a 64-bit long
+   int, which would mess up C++ name mangling.  */
+
+#if INT64_MAX
+# define GL_INT64_T
+#else
 /* Do not undefine int64_t if gnulib is not being used with 64-bit
    types, since otherwise it breaks platforms like Tandem/NSK.  */
-#if LONG_MAX >> 31 >> 31 == 1
-# undef int64_t
+# if LONG_MAX >> 31 >> 31 == 1
+#  undef int64_t
 typedef long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-#elif defined _MSC_VER
-# undef int64_t
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# elif defined _MSC_VER
+#  undef int64_t
 typedef __int64 gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
-#elif @HAVE_LONG_LONG_INT@
-# undef int64_t
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# elif @HAVE_LONG_LONG_INT@
+#  undef int64_t
 typedef long long int gl_int64_t;
-# define int64_t gl_int64_t
-# define GL_INT64_T
+#  define int64_t gl_int64_t
+#  define GL_INT64_T
+# endif
 #endif
 
-#if ULONG_MAX >> 31 >> 31 >> 1 == 1
-# undef uint64_t
-typedef unsigned long int gl_uint64_t;
-# define uint64_t gl_uint64_t
+#if UINT64_MAX
 # define GL_UINT64_T
-#elif defined _MSC_VER
-# undef uint64_t
+#else
+# if ULONG_MAX >> 31 >> 31 >> 1 == 1
+#  undef uint64_t
+typedef unsigned long int gl_uint64_t;
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# elif defined _MSC_VER
+#  undef uint64_t
 typedef unsigned __int64 gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
-#elif @HAVE_UNSIGNED_LONG_LONG_INT@
-# undef uint64_t
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# elif @HAVE_UNSIGNED_LONG_LONG_INT@
+#  undef uint64_t
 typedef unsigned long long int gl_uint64_t;
-# define uint64_t gl_uint64_t
-# define GL_UINT64_T
+#  define uint64_t gl_uint64_t
+#  define GL_UINT64_T
+# endif
 #endif
 
 /* Avoid collision with Solaris 2.5.1 <pthread.h> etc.  */
@@ -312,17 +325,14 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == 
sizeof (uintmax_t)
 #define INT32_MAX  2147483647
 #define UINT32_MAX  4294967295U
 
-#undef INT64_MIN
-#undef INT64_MAX
-#ifdef GL_INT64_T
+#if defined GL_INT64_T && ! defined INT64_MAX
 /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
    evaluates the latter incorrectly in preprocessor expressions.  */
 # define INT64_MIN  (- INTMAX_C (1) << 63)
 # define INT64_MAX  INTMAX_C (9223372036854775807)
 #endif
 
-#undef UINT64_MAX
-#ifdef GL_UINT64_T
+#if defined GL_UINT64_T && ! defined UINT64_MAX
 # define UINT64_MAX  UINTMAX_C (18446744073709551615)
 #endif
 
-- 
1.7.2





reply via email to

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