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