Blame SOURCES/kyotocabinet-1.2.76-8-byte-atomics.patch

b0c39e
Patch by Shawn Landden <shawnlandden@gmail.com> for kyotocabinet >= 1.2.76, which fixes
b0c39e
the configure test to handle lack of 8 byte atomics correctly as is the case with ARM 32
b0c39e
bit on all Fedora releases, Intel 32 bit on RHEL 5 and PowerPC 32 bit on RHEL 5 and all
b0c39e
Fedora releases.
b0c39e
b0c39e
--- kyotocabinet-1.2.76/configure.in			2012-05-24 13:31:42.000000000 +0200
b0c39e
+++ kyotocabinet-1.2.76/configure.in.8-byte-atomics	2013-03-01 00:21:21.000000000 +0100
b0c39e
@@ -238,9 +238,22 @@
b0c39e
 # Atomic operations
b0c39e
 if test "$enable_atomic" != "no"
b0c39e
 then
b0c39e
-  printf 'checking for atomic operations... '
b0c39e
-  AC_TRY_COMPILE([], [__sync_fetch_and_add], [MYGCCATOMIC=yes], [MYGCCATOMIC=no])
b0c39e
-  if test "$MYGCCATOMIC" = "yes"
b0c39e
+  printf 'checking for 8 byte atomic operations... '
b0c39e
+  if printf '
b0c39e
+/* Some targets support 4 byte atomics, but not 8 byte atomics,
b0c39e
+ * and will fail at link time if they are used.
b0c39e
+ *
b0c39e
+ * http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Atomic-Builtins.html
b0c39e
+ * http://gcc.gnu.org/wiki/Atomic
b0c39e
+ */
b0c39e
+#include <stdint.h>
b0c39e
+int
b0c39e
+main ()
b0c39e
+{
b0c39e
+uint64_t n = 0xdeadbeaf;
b0c39e
+__sync_bool_compare_and_swap(&n, 0xdeadbeaf, 0);
b0c39e
+return n;
b0c39e
+}' | $CC -xc -o config.tmp - >/dev/null 2>&1
b0c39e
   then
b0c39e
     MYCPPFLAGS="$MYCPPFLAGS -D_MYGCCATOMIC"
b0c39e
     printf 'yes\n'
b0c39e
--- kyotocabinet-1.2.76/configure			2012-05-24 13:31:45.000000000 +0200
b0c39e
+++ kyotocabinet-1.2.76/configure.8-byte-atomics	2013-03-01 00:22:37.000000000 +0100
b0c39e
@@ -4012,25 +4012,22 @@
b0c39e
 # Atomic operations
b0c39e
 if test "$enable_atomic" != "no"
b0c39e
 then
b0c39e
-  printf 'checking for atomic operations... '
b0c39e
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
b0c39e
-/* end confdefs.h.  */
b0c39e
-
b0c39e
+  printf 'checking for 8 byte atomic operations... '
b0c39e
+  if printf '
b0c39e
+/* Some targets support 4 byte atomics, but not 8 byte atomics,
b0c39e
+ * and will fail at link time if they are used.
b0c39e
+ *
b0c39e
+ * http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Atomic-Builtins.html
b0c39e
+ * http://gcc.gnu.org/wiki/Atomic
b0c39e
+ */
b0c39e
+#include <stdint.h>
b0c39e
 int
b0c39e
 main ()
b0c39e
 {
b0c39e
-__sync_fetch_and_add
b0c39e
-  ;
b0c39e
-  return 0;
b0c39e
-}
b0c39e
-_ACEOF
b0c39e
-if ac_fn_cxx_try_compile "$LINENO"; then :
b0c39e
-  MYGCCATOMIC=yes
b0c39e
-else
b0c39e
-  MYGCCATOMIC=no
b0c39e
-fi
b0c39e
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
b0c39e
-  if test "$MYGCCATOMIC" = "yes"
b0c39e
+uint64_t n = 0xdeadbeaf;
b0c39e
+__sync_bool_compare_and_swap(&n, 0xdeadbeaf, 0);
b0c39e
+return n;
b0c39e
+}' | $CC -xc -o config.tmp - >/dev/null 2>&1
b0c39e
   then
b0c39e
     MYCPPFLAGS="$MYCPPFLAGS -D_MYGCCATOMIC"
b0c39e
     printf 'yes\n'