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

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