Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update json gem #13194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 30, 2025
1 change: 1 addition & 0 deletions ext/json/generator/depend
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,5 @@ generator.o: $(srcdir)/../fbuffer/fbuffer.h
generator.o: $(srcdir)/../vendor/fpconv.c
generator.o: $(srcdir)/../vendor/jeaiii-ltoa.h
generator.o: generator.c
generator.o: simd.h
# AUTOGENERATED DEPENDENCIES END
29 changes: 29 additions & 0 deletions ext/json/generator/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,34 @@
else
append_cflags("-std=c99")
$defs << "-DJSON_GENERATOR"

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("-DENABLE_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("-DENABLE_SIMD")
end

have_header('cpuid.h')
end

create_makefile 'json/ext/generator'
end
Loading
Loading