ext/kcar/extconf.rb in kcar-0.6.0 vs ext/kcar/extconf.rb in kcar-0.7.0
- old
+ new
@@ -3,12 +3,37 @@
dir_config("kcar")
have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h")
have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h")
-have_func("rb_str_set_len", "ruby.h")
-have_func("rb_str_modify", "ruby.h")
-# -fPIC is needed for Rubinius, MRI already uses it regardless
-with_cflags($CFLAGS + " -fPIC ") do
- create_makefile("kcar_ext")
+message('checking if String#-@ (str_uminus) dedupes... ')
+begin
+ a = -(%w(t e s t).join)
+ b = -(%w(t e s t).join)
+ if a.equal?(b)
+ $CPPFLAGS += " -DSTR_UMINUS_DEDUPE=1 "
+ message("yes\n")
+ else
+ $CPPFLAGS += " -DSTR_UMINUS_DEDUPE=0 "
+ message("no, needs Ruby 2.5+\n")
+ end
+rescue NoMethodError
+ $CPPFLAGS += " -DSTR_UMINUS_DEDUPE=0 "
+ message("no, String#-@ not available\n")
end
+
+message('checking if Hash#[]= (rb_hash_aset) dedupes... ')
+h = {}
+x = {}
+r = rand.to_s
+h[%W(#{r}).join('')] = :foo
+x[%W(#{r}).join('')] = :foo
+if x.keys[0].equal?(h.keys[0])
+ $CPPFLAGS += ' -DHASH_ASET_DEDUPE=1 '
+ message("yes\n")
+else
+ $CPPFLAGS += ' -DHASH_ASET_DEDUPE=0 '
+ message("no, needs Ruby 2.6+\n")
+end
+
+create_makefile("kcar_ext")