json 2.7.3 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,5 +6,34 @@ if RUBY_ENGINE == 'truffleruby'
6
6
  else
7
7
  append_cflags("-std=c99")
8
8
  $defs << "-DJSON_GENERATOR"
9
+
10
+ if enable_config('generator-use-simd', default=!ENV["JSON_DISABLE_SIMD"])
11
+ if RbConfig::CONFIG['host_cpu'] =~ /^(arm.*|aarch64.*)/
12
+ # Try to compile a small program using NEON instructions
13
+ if have_header('arm_neon.h')
14
+ have_type('uint8x16_t', headers=['arm_neon.h']) && try_compile(<<~'SRC')
15
+ #include <arm_neon.h>
16
+ int main() {
17
+ uint8x16_t test = vdupq_n_u8(32);
18
+ return 0;
19
+ }
20
+ SRC
21
+ $defs.push("-DJSON_ENABLE_SIMD")
22
+ end
23
+ end
24
+
25
+ if have_header('x86intrin.h') && have_type('__m128i', headers=['x86intrin.h']) && try_compile(<<~'SRC')
26
+ #include <x86intrin.h>
27
+ int main() {
28
+ __m128i test = _mm_set1_epi8(32);
29
+ return 0;
30
+ }
31
+ SRC
32
+ $defs.push("-DJSON_ENABLE_SIMD")
33
+ end
34
+
35
+ have_header('cpuid.h')
36
+ end
37
+
9
38
  create_makefile 'json/ext/generator'
10
39
  end