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.
@@ -0,0 +1,112 @@
1
+ typedef enum {
2
+ SIMD_NONE,
3
+ SIMD_NEON,
4
+ SIMD_SSE2
5
+ } SIMD_Implementation;
6
+
7
+ #ifdef JSON_ENABLE_SIMD
8
+
9
+ #ifdef __clang__
10
+ #if __has_builtin(__builtin_ctzll)
11
+ #define HAVE_BUILTIN_CTZLL 1
12
+ #else
13
+ #define HAVE_BUILTIN_CTZLL 0
14
+ #endif
15
+ #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
16
+ #define HAVE_BUILTIN_CTZLL 1
17
+ #else
18
+ #define HAVE_BUILTIN_CTZLL 0
19
+ #endif
20
+
21
+ static inline uint32_t trailing_zeros64(uint64_t input) {
22
+ #if HAVE_BUILTIN_CTZLL
23
+ return __builtin_ctzll(input);
24
+ #else
25
+ uint32_t trailing_zeros = 0;
26
+ uint64_t temp = input;
27
+ while ((temp & 1) == 0 && temp > 0) {
28
+ trailing_zeros++;
29
+ temp >>= 1;
30
+ }
31
+ return trailing_zeros;
32
+ #endif
33
+ }
34
+
35
+ static inline int trailing_zeros(int input) {
36
+ #if HAVE_BUILTIN_CTZLL
37
+ return __builtin_ctz(input);
38
+ #else
39
+ int trailing_zeros = 0;
40
+ int temp = input;
41
+ while ((temp & 1) == 0 && temp > 0) {
42
+ trailing_zeros++;
43
+ temp >>= 1;
44
+ }
45
+ return trailing_zeros;
46
+ #endif
47
+ }
48
+
49
+ #define SIMD_MINIMUM_THRESHOLD 6
50
+
51
+ #if defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(__aarch64__) || defined(_M_ARM64)
52
+ #include <arm_neon.h>
53
+
54
+ #define FIND_SIMD_IMPLEMENTATION_DEFINED 1
55
+ static SIMD_Implementation find_simd_implementation(void) {
56
+ return SIMD_NEON;
57
+ }
58
+
59
+ #define HAVE_SIMD 1
60
+ #define HAVE_SIMD_NEON 1
61
+
62
+ uint8x16x4_t load_uint8x16_4(const unsigned char *table) {
63
+ uint8x16x4_t tab;
64
+ tab.val[0] = vld1q_u8(table);
65
+ tab.val[1] = vld1q_u8(table+16);
66
+ tab.val[2] = vld1q_u8(table+32);
67
+ tab.val[3] = vld1q_u8(table+48);
68
+ return tab;
69
+ }
70
+
71
+ #endif /* ARM Neon Support.*/
72
+
73
+ #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
74
+
75
+ #ifdef HAVE_X86INTRIN_H
76
+ #include <x86intrin.h>
77
+
78
+ #define HAVE_SIMD 1
79
+ #define HAVE_SIMD_SSE2 1
80
+
81
+ #ifdef HAVE_CPUID_H
82
+ #define FIND_SIMD_IMPLEMENTATION_DEFINED 1
83
+
84
+ #include <cpuid.h>
85
+ #endif /* HAVE_CPUID_H */
86
+
87
+ static SIMD_Implementation find_simd_implementation(void) {
88
+
89
+ #if defined(__GNUC__ ) || defined(__clang__)
90
+ #ifdef __GNUC__
91
+ __builtin_cpu_init();
92
+ #endif /* __GNUC__ */
93
+
94
+ // TODO Revisit. I think the SSE version now only uses SSE2 instructions.
95
+ if (__builtin_cpu_supports("sse2")) {
96
+ return SIMD_SSE2;
97
+ }
98
+ #endif /* __GNUC__ || __clang__*/
99
+
100
+ return SIMD_NONE;
101
+ }
102
+
103
+ #endif /* HAVE_X86INTRIN_H */
104
+ #endif /* X86_64 Support */
105
+
106
+ #endif /* JSON_ENABLE_SIMD */
107
+
108
+ #ifndef FIND_SIMD_IMPLEMENTATION_DEFINED
109
+ static SIMD_Implementation find_simd_implementation(void) {
110
+ return SIMD_NONE;
111
+ }
112
+ #endif
@@ -1,33 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
  require 'mkmf'
3
3
 
4
- have_func("rb_enc_raise", "ruby.h")
5
- have_func("rb_enc_interned_str", "ruby.h")
6
-
7
- # checking if String#-@ (str_uminus) dedupes... '
8
- begin
9
- a = -(%w(t e s t).join)
10
- b = -(%w(t e s t).join)
11
- if a.equal?(b)
12
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=1 '
13
- else
14
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
15
- end
16
- rescue NoMethodError
17
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
18
- end
19
-
20
- # checking if String#-@ (str_uminus) directly interns frozen strings... '
21
- begin
22
- s = rand.to_s.freeze
23
- if (-s).equal?(s) && (-s.dup).equal?(s)
24
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
25
- else
26
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
27
- end
28
- rescue NoMethodError
29
- $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
30
- end
4
+ have_func("rb_enc_interned_str", "ruby.h") # RUBY_VERSION >= 3.0
5
+ have_func("rb_hash_new_capa", "ruby.h") # RUBY_VERSION >= 3.2
6
+ have_func("rb_hash_bulk_insert", "ruby.h") # Missing on TruffleRuby
7
+ have_func("strnlen", "string.h") # Missing on Solaris 10
31
8
 
32
9
  append_cflags("-std=c99")
33
10