about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-28 10:10:29 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-28 10:10:29 +0000
commitfc690079c889ed5a97359515d75fe9260dd9ea91 (patch)
tree19ebe83667d6e0365371a039ea38bd1b7893cabc
parentfdda1473240485b7e996e425ed1a46ce0e50174e (diff)
downloadraindrops-fc690079c889ed5a97359515d75fe9260dd9ea91.tar.gz
__sync_lock_test_and_set might not be the correct check after all,
but __sync_val_compare_and_swap probably is.  At least this is
what Ruby 2.0.0 uses to check and attempt -march=i486 on.
-rw-r--r--ext/raindrops/extconf.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index 447a90a..f012808 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -20,6 +20,7 @@ int main(int argc, char * const argv[]) {
         unsigned long i = 0;
         __sync_lock_test_and_set(&i, 0);
         __sync_lock_test_and_set(&i, 1);
+        __sync_bool_compare_and_swap(&i, 0, 1);
         __sync_add_and_fetch(&i, argc);
         __sync_sub_and_fetch(&i, argc);
         return 0;
@@ -30,7 +31,17 @@ SRC
     $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
     true
   else
-    false
+    # some compilers still target 386 by default, but we need at least 486
+    # to run atomic builtins.
+    prev_cflags = $CFLAGS
+    $CFLAGS += " -march=i486 "
+    if try_link(src)
+      $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
+      true
+    else
+      prev_cflags = $CFLAGS
+      false
+    end
   end
 end or have_header('atomic_ops.h') or abort <<-SRC