mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 12:34:21 +00:00
[ruby/json] Reduce duplication in extconf.rb
https://github.com/ruby/json/commit/3ae3eeb9d3
This commit is contained in:
parent
50b6cd409a
commit
bc334be4db
25
ext/json/ext/simd/conf.rb
Normal file
25
ext/json/ext/simd/conf.rb
Normal file
@ -0,0 +1,25 @@
|
||||
if RbConfig::CONFIG['host_cpu'] =~ /^(arm.*|aarch64.*)/
|
||||
# Try to compile a small program using NEON instructions
|
||||
if have_header('arm_neon.h')
|
||||
have_type('uint8x16_t', headers=['arm_neon.h']) && try_compile(<<~'SRC')
|
||||
#include <arm_neon.h>
|
||||
int main() {
|
||||
uint8x16_t test = vdupq_n_u8(32);
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
end
|
||||
|
||||
if have_header('x86intrin.h') && have_type('__m128i', headers=['x86intrin.h']) && try_compile(<<~'SRC')
|
||||
#include <x86intrin.h>
|
||||
int main() {
|
||||
__m128i test = _mm_set1_epi8(32);
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
|
||||
have_header('cpuid.h')
|
||||
@ -9,31 +9,7 @@ else
|
||||
$defs << "-DJSON_DEBUG" if ENV["JSON_DEBUG"]
|
||||
|
||||
if enable_config('generator-use-simd', default=!ENV["JSON_DISABLE_SIMD"])
|
||||
if RbConfig::CONFIG['host_cpu'] =~ /^(arm.*|aarch64.*)/
|
||||
# Try to compile a small program using NEON instructions
|
||||
if have_header('arm_neon.h')
|
||||
have_type('uint8x16_t', headers=['arm_neon.h']) && try_compile(<<~'SRC')
|
||||
#include <arm_neon.h>
|
||||
int main() {
|
||||
uint8x16_t test = vdupq_n_u8(32);
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
end
|
||||
|
||||
if have_header('x86intrin.h') && have_type('__m128i', headers=['x86intrin.h']) && try_compile(<<~'SRC')
|
||||
#include <x86intrin.h>
|
||||
int main() {
|
||||
__m128i test = _mm_set1_epi8(32);
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
|
||||
have_header('cpuid.h')
|
||||
require_relative "../simd/conf.rb"
|
||||
end
|
||||
|
||||
create_makefile 'json/ext/generator'
|
||||
|
||||
@ -52,7 +52,7 @@ spec = Gem::Specification.new do |s|
|
||||
s.files += Dir["lib/json/ext/**/*.jar"]
|
||||
else
|
||||
s.extensions = Dir["ext/json/**/extconf.rb"]
|
||||
s.files += Dir["ext/json/**/*.{c,h}"]
|
||||
s.files += Dir["ext/json/**/*.{c,h,rb}"]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -9,31 +9,7 @@ have_func("strnlen", "string.h") # Missing on Solaris 10
|
||||
append_cflags("-std=c99")
|
||||
|
||||
if enable_config('parser-use-simd', default=!ENV["JSON_DISABLE_SIMD"])
|
||||
if RbConfig::CONFIG['host_cpu'] =~ /^(arm.*|aarch64.*)/
|
||||
# Try to compile a small program using NEON instructions
|
||||
if have_header('arm_neon.h')
|
||||
have_type('uint8x16_t', headers=['arm_neon.h']) && try_compile(<<~'SRC')
|
||||
#include <arm_neon.h>
|
||||
int main() {
|
||||
uint8x16_t test = vdupq_n_u8(32);
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
end
|
||||
|
||||
if have_header('x86intrin.h') && have_type('__m128i', headers=['x86intrin.h']) && try_compile(<<~'SRC')
|
||||
#include <x86intrin.h>
|
||||
int main() {
|
||||
__m128i test = _mm_set1_epi8(32);
|
||||
return 0;
|
||||
}
|
||||
SRC
|
||||
$defs.push("-DJSON_ENABLE_SIMD")
|
||||
end
|
||||
|
||||
have_header('cpuid.h')
|
||||
end
|
||||
require_relative "../simd/conf.rb"
|
||||
end
|
||||
|
||||
create_makefile 'json/ext/parser'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user