Fix detection of i486 atomic ops.
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 11 Oct 2007 08:57:48 +0000 (09:57 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 11 Oct 2007 08:57:48 +0000 (09:57 +0100)
Previously, the attempts to determine support at compile-time on Darwin were
causing the i486 atomic ops to be used on *all* i386 or x86-64 GCC builds
(AH_VERBATIM can't be conditionalized like we were trying to).

ChangeLog
configure.in
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps.h

index e76969f..4056ac1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-10-11  Simon McVittie  <simon.mcvittie@collabora.co.uk>
+
+       * configure.in, dbus/dbus-sysdeps.h, dbus/dbus-sysdeps-unix.c: Fix
+       detection of i486 atomic ops. Previously, the attempts to determine
+       support at compile-time on Darwin were causing the i486 atomic ops to
+       be used on *all* i386 or x86-64 GCC builds (AH_VERBATIM can't be
+       conditionalized like we were trying to).
+
 2007-10-10  Simon McVittie  <simon.mcvittie@collabora.co.uk>
 
        * dbus/dbus-errors.c, dbus/dbus-protocol.h: Add new error
index 4ed2e1c..c933115 100644 (file)
@@ -536,7 +536,7 @@ fi
 
 #### Atomic integers (checks by Sebastian Wilhelmi for GLib)
 AC_MSG_CHECKING([whether to use inline assembler routines for atomic integers])
-have_atomic_inc=no
+have_atomic_inc_cond=0
 if test x"$GCC" = xyes; then
   if test "x$enable_ansi" = "xyes"; then
     AC_MSG_RESULT([no])
@@ -551,18 +551,13 @@ if test x"$GCC" = xyes; then
             AC_MSG_RESULT([darwin])
             # check at compile-time, so that it is possible to build universal
             # (with multiple architectures at once on the compile line)
-            AH_VERBATIM([DBUS_USE_ATOMIC_INT_486_DARWIN], [
-              #if (defined(__i386__) || defined(__x86_64__))
-              # define DBUS_USE_ATOMIC_INT_486 1
-              #endif
-            ])
+            have_atomic_inc_cond="(defined(__i386__) || defined(__x86_64__))"
             ;;
           *)
             AC_MSG_RESULT([i486])
-            AC_DEFINE_UNQUOTED(DBUS_USE_ATOMIC_INT_486, 1, [Use atomic integer implementation for 486])
+            have_atomic_inc_cond=1
             ;;
         esac
-        have_atomic_inc=yes
         ;;
       *)
         AC_MSG_RESULT([no])
@@ -570,20 +565,10 @@ if test x"$GCC" = xyes; then
     esac
   fi
 fi
-if test x$have_atomic_inc = xyes ; then
-  case $host_os in
-    darwin*)
-      AH_VERBATIM([DBUS_HAVE_ATOMIC_INT_DARWIN], [
-        #if (defined(__i386__) || defined(__x86_64__))
-        # define DBUS_HAVE_ATOMIC_INT 1
-        #endif
-      ])
-      ;;
-    *)
-      AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT, 1, [Some atomic integer implementation present])
-      ;;
-  esac
-fi
+AC_DEFINE_UNQUOTED([DBUS_USE_ATOMIC_INT_486_COND], ["$have_atomic_inc_cond"],
+                   [Always defined; expands to 1 if we should use atomic integer implementation for 486, else 0])
+AC_DEFINE_UNQUOTED(DBUS_HAVE_ATOMIC_INT_COND, ["$have_atomic_inc_cond"],
+                   [Always defined; expands to 1 if we have an atomic integer implementation, else 0])
 
 #### Various functions
 AC_CHECK_LIB(socket,socket)
index 0ab5e73..2ce7427 100644 (file)
@@ -1741,7 +1741,7 @@ _dbus_parse_uid (const DBusString      *uid_str,
 
 _DBUS_DEFINE_GLOBAL_LOCK (atomic);
 
-#ifdef DBUS_USE_ATOMIC_INT_486
+#if DBUS_USE_ATOMIC_INT_486_COND
 /* Taken from CVS version 1.7 of glibc's sysdeps/i386/i486/atomicity.h */
 /* Since the asm stuff here is gcc-specific we go ahead and use "inline" also */
 static inline dbus_int32_t
@@ -1768,7 +1768,7 @@ atomic_exchange_and_add (DBusAtomic            *atomic,
 dbus_int32_t
 _dbus_atomic_inc (DBusAtomic *atomic)
 {
-#ifdef DBUS_USE_ATOMIC_INT_486
+#if DBUS_USE_ATOMIC_INT_486_COND
   return atomic_exchange_and_add (atomic, 1);
 #else
   dbus_int32_t res;
@@ -1791,7 +1791,7 @@ _dbus_atomic_inc (DBusAtomic *atomic)
 dbus_int32_t
 _dbus_atomic_dec (DBusAtomic *atomic)
 {
-#ifdef DBUS_USE_ATOMIC_INT_486
+#if DBUS_USE_ATOMIC_INT_486_COND
   return atomic_exchange_and_add (atomic, -1);
 #else
   dbus_int32_t res;
index eadfb43..1a52e7f 100644 (file)
@@ -199,6 +199,16 @@ struct DBusAtomic
 #endif
 };
 
+/* The value we get from autofoo is in the form of a cpp expression;
+ * convert that to a conventional defined/undef switch. (We can't get
+ * the conventional defined/undef because of multiarch builds only running
+ * ./configure once, on Darwin.) */
+#if DBUS_HAVE_ATOMIC_INT_COND
+#   define DBUS_HAVE_ATOMIC_INT 1
+#else
+#   undef DBUS_HAVE_ATOMIC_INT
+#endif
+
 dbus_int32_t _dbus_atomic_inc (DBusAtomic *atomic);
 dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic);