port test/unit/test_ccc.rb to Perl 5
[unicorn.git] / ext / unicorn_http / extconf.rb
blobde896fe9911b38c56f156d5bffbb1effca6e1ca3
1 # -*- encoding: binary -*-
2 # frozen_string_literal: false
3 require 'mkmf'
5 have_func("rb_hash_clear", "ruby.h") or abort 'Ruby 2.0+ required'
7 message('checking if String#-@ (str_uminus) dedupes... ')
8 begin
9   a = -(%w(t e s t).join)
10   b = -(%w(t e s t).join)
11   if a.equal?(b)
12     $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=1 '
13     message("yes\n")
14   else
15     $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 '
16     message("no, needs Ruby 2.5+\n")
17   end
18 rescue NoMethodError
19   $CPPFLAGS += ' -DSTR_UMINUS_DEDUPE=0 '
20   message("no, String#-@ not available\n")
21 end
23 message('checking if Hash#[]= (rb_hash_aset) dedupes... ')
24 h = {}
25 x = {}
26 r = rand.to_s
27 h[%W(#{r}).join('')] = :foo
28 x[%W(#{r}).join('')] = :foo
29 if x.keys[0].equal?(h.keys[0])
30   $CPPFLAGS += ' -DHASH_ASET_DEDUPE=1 '
31   message("yes\n")
32 else
33   $CPPFLAGS += ' -DHASH_ASET_DEDUPE=0 '
34   message("no, needs Ruby 2.6+\n")
35 end
37 if have_func('epoll_create1', %w(sys/epoll.h))
38   have_func('rb_io_descriptor') # Ruby 3.1+
39 end
40 create_makefile("unicorn_http")