summaryrefslogtreecommitdiff
path: root/ext/json/parser/extconf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json/parser/extconf.rb')
-rw-r--r--ext/json/parser/extconf.rb36
1 files changed, 12 insertions, 24 deletions
diff --git a/ext/json/parser/extconf.rb b/ext/json/parser/extconf.rb
index feb586e1b4..f12fc2dddc 100644
--- a/ext/json/parser/extconf.rb
+++ b/ext/json/parser/extconf.rb
@@ -1,32 +1,20 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'mkmf'
-have_func("rb_enc_raise", "ruby.h")
-have_func("rb_enc_interned_str", "ruby.h")
+$defs << "-DJSON_DEBUG" if ENV.fetch("JSON_DEBUG", "0") != "0"
+have_func("rb_enc_interned_str", "ruby/encoding.h") # RUBY_VERSION >= 3.0
+have_func("rb_str_to_interned_str", "ruby.h") # RUBY_VERSION >= 3.0
+have_func("rb_hash_new_capa", "ruby.h") # RUBY_VERSION >= 3.2
+have_func("rb_hash_bulk_insert", "ruby.h") # Missing on TruffleRuby
-# 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)
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=1 '
- else
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
- end
-rescue NoMethodError
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
+if RUBY_ENGINE == "ruby"
+ have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
end
-# checking if String#-@ (str_uminus) directly interns frozen strings... '
-begin
- s = rand.to_s.freeze
- if (-s).equal?(s) && (-s.dup).equal?(s)
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
- else
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
- end
-rescue NoMethodError
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
+append_cflags("-std=c99")
+
+if enable_config('parser-use-simd', default=!ENV["JSON_DISABLE_SIMD"])
+ load __dir__ + "/../simd/conf.rb"
end
create_makefile 'json/ext/parser'