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