about summary refs log tree commit homepage
path: root/ext/raindrops/extconf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/raindrops/extconf.rb')
-rw-r--r--ext/raindrops/extconf.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index d637287..09d6e36 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -7,5 +7,31 @@ have_func('munmap', 'sys/mman.h') or abort 'munmap() not found'
 have_func("rb_struct_alloc_noinit")
 have_func('rb_thread_blocking_region')
 
+checking_for "GCC 4+ atomic builtins" do
+  src = <<SRC
+int main(int argc, char * const argv[]) {
+        volatile unsigned long i = 0;
+        __sync_add_and_fetch(&i, argc);
+        __sync_sub_and_fetch(&i, argc);
+        return 0;
+}
+SRC
+
+  if try_run(src)
+    $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
+    true
+  else
+    false
+  end
+end or have_header('atomic_ops.h') or abort <<-SRC
+
+libatomic_ops is required if GCC 4+ is not used.
+See http://www.hpl.hp.com/research/linux/atomic_ops/
+
+Users of Debian-based distros may run:
+
+  apt-get install libatomic-ops-dev
+SRC
+
 dir_config('raindrops')
 create_makefile('raindrops_ext')