tcp_info: mark this as Linux-only
[raindrops.git] / ext / raindrops / extconf.rb
blob825625df8ec6b9529cfedf25bddd3973e7324d3b
1 require 'mkmf'
3 dir_config('atomic_ops')
4 have_func('mmap', 'sys/mman.h') or abort 'mmap() not found'
5 have_func('munmap', 'sys/mman.h') or abort 'munmap() not found'
7 $CPPFLAGS += " -D_GNU_SOURCE "
8 have_func('mremap', 'sys/mman.h')
10 $CPPFLAGS += " -D_BSD_SOURCE -D_XOPEN_SOURCE=600 "
11 have_func("getpagesize", "unistd.h")
12 have_func('rb_thread_blocking_region')
13 have_func('rb_thread_io_blocking_region')
15 checking_for "GCC 4+ atomic builtins" do
16   src = <<SRC
17 int main(int argc, char * const argv[]) {
18         volatile unsigned long i = 0;
19         __sync_add_and_fetch(&i, argc);
20         __sync_sub_and_fetch(&i, argc);
21         return 0;
23 SRC
25   if try_run(src)
26     # some systems target GCC for i386 and don't get the atomic builtins
27     # when building shared objects
28     arch = `#{CONFIG['CC']} -dumpmachine`.split(/-/)[0]
29     if arch == "i386" && $CFLAGS !~ /\b-march=/
30       $CFLAGS += " -march=i486 "
31     end
33     $defs.push(format("-DHAVE_GCC_ATOMIC_BUILTINS"))
34     true
35   else
36     false
37   end
38 end or have_header('atomic_ops.h') or abort <<-SRC
40 libatomic_ops is required if GCC 4+ is not used.
41 See http://www.hpl.hp.com/research/linux/atomic_ops/
43 Users of Debian-based distros may run:
45   apt-get install libatomic-ops-dev
46 SRC
47 create_makefile('raindrops_ext')