File tree Expand file tree Collapse file tree 4 files changed +29
-52
lines changed
Expand file tree Collapse file tree 4 files changed +29
-52
lines changed Original file line number Diff line number Diff line change 1+ if RbConfig ::CONFIG [ 'host_cpu' ] =~ /^(arm.*|aarch64.*)/
2+ # Try to compile a small program using NEON instructions
3+ if have_header ( 'arm_neon.h' )
4+ have_type ( 'uint8x16_t' , headers = [ 'arm_neon.h' ] ) && try_compile ( <<~'SRC' )
5+ #include <arm_neon.h>
6+ int main() {
7+ uint8x16_t test = vdupq_n_u8(32);
8+ return 0;
9+ }
10+ SRC
11+ $defs. push ( "-DJSON_ENABLE_SIMD" )
12+ end
13+ end
14+
15+ if have_header ( 'x86intrin.h' ) && have_type ( '__m128i' , headers = [ 'x86intrin.h' ] ) && try_compile ( <<~'SRC' )
16+ #include <x86intrin.h>
17+ int main() {
18+ __m128i test = _mm_set1_epi8(32);
19+ return 0;
20+ }
21+ SRC
22+ $defs. push ( "-DJSON_ENABLE_SIMD" )
23+ end
24+
25+ have_header ( 'cpuid.h' )
Original file line number Diff line number Diff line change 99 $defs << "-DJSON_DEBUG" if ENV [ "JSON_DEBUG" ]
1010
1111 if enable_config ( 'generator-use-simd' , default = !ENV [ "JSON_DISABLE_SIMD" ] )
12- if RbConfig ::CONFIG [ 'host_cpu' ] =~ /^(arm.*|aarch64.*)/
13- # Try to compile a small program using NEON instructions
14- if have_header ( 'arm_neon.h' )
15- have_type ( 'uint8x16_t' , headers = [ 'arm_neon.h' ] ) && try_compile ( <<~'SRC' )
16- #include <arm_neon.h>
17- int main() {
18- uint8x16_t test = vdupq_n_u8(32);
19- return 0;
20- }
21- SRC
22- $defs. push ( "-DJSON_ENABLE_SIMD" )
23- end
24- end
25-
26- if have_header ( 'x86intrin.h' ) && have_type ( '__m128i' , headers = [ 'x86intrin.h' ] ) && try_compile ( <<~'SRC' )
27- #include <x86intrin.h>
28- int main() {
29- __m128i test = _mm_set1_epi8(32);
30- return 0;
31- }
32- SRC
33- $defs. push ( "-DJSON_ENABLE_SIMD" )
34- end
35-
36- have_header ( 'cpuid.h' )
12+ require_relative "../simd/conf.rb"
3713 end
3814
3915 create_makefile 'json/ext/generator'
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ spec = Gem::Specification.new do |s|
5252 s . files += Dir [ "lib/json/ext/**/*.jar" ]
5353 else
5454 s . extensions = Dir [ "ext/json/**/extconf.rb" ]
55- s . files += Dir [ "ext/json/**/*.{c,h}" ]
55+ s . files += Dir [ "ext/json/**/*.{c,h,rb }" ]
5656 end
5757end
5858
Original file line number Diff line number Diff line change 99append_cflags ( "-std=c99" )
1010
1111if enable_config ( 'parser-use-simd' , default = !ENV [ "JSON_DISABLE_SIMD" ] )
12- if RbConfig ::CONFIG [ 'host_cpu' ] =~ /^(arm.*|aarch64.*)/
13- # Try to compile a small program using NEON instructions
14- if have_header ( 'arm_neon.h' )
15- have_type ( 'uint8x16_t' , headers = [ 'arm_neon.h' ] ) && try_compile ( <<~'SRC' )
16- #include <arm_neon.h>
17- int main() {
18- uint8x16_t test = vdupq_n_u8(32);
19- return 0;
20- }
21- SRC
22- $defs. push ( "-DJSON_ENABLE_SIMD" )
23- end
24- end
25-
26- if have_header ( 'x86intrin.h' ) && have_type ( '__m128i' , headers = [ 'x86intrin.h' ] ) && try_compile ( <<~'SRC' )
27- #include <x86intrin.h>
28- int main() {
29- __m128i test = _mm_set1_epi8(32);
30- return 0;
31- }
32- SRC
33- $defs. push ( "-DJSON_ENABLE_SIMD" )
34- end
35-
36- have_header ( 'cpuid.h' )
37- end
12+ require_relative "../simd/conf.rb"
13+ end
3814
3915create_makefile 'json/ext/parser'
You can’t perform that action at this time.
0 commit comments