json 2.12.2 → 2.18.1

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,101 @@
1
+ #ifndef _JSON_H_
2
+ #define _JSON_H_
3
+
4
+ #include "ruby.h"
5
+ #include "ruby/encoding.h"
6
+ #include <stdint.h>
7
+
8
+ #ifndef RBIMPL_ASSERT_OR_ASSUME
9
+ # define RBIMPL_ASSERT_OR_ASSUME(x)
10
+ #endif
11
+
12
+ #if defined(RUBY_DEBUG) && RUBY_DEBUG
13
+ # define JSON_ASSERT RUBY_ASSERT
14
+ #else
15
+ # ifdef JSON_DEBUG
16
+ # include <assert.h>
17
+ # define JSON_ASSERT(x) assert(x)
18
+ # else
19
+ # define JSON_ASSERT(x)
20
+ # endif
21
+ #endif
22
+
23
+ /* shims */
24
+
25
+ #if SIZEOF_UINT64_T == SIZEOF_LONG_LONG
26
+ # define INT64T2NUM(x) LL2NUM(x)
27
+ # define UINT64T2NUM(x) ULL2NUM(x)
28
+ #elif SIZEOF_UINT64_T == SIZEOF_LONG
29
+ # define INT64T2NUM(x) LONG2NUM(x)
30
+ # define UINT64T2NUM(x) ULONG2NUM(x)
31
+ #else
32
+ # error No uint64_t conversion
33
+ #endif
34
+
35
+ /* This is the fallback definition from Ruby 3.4 */
36
+ #ifndef RBIMPL_STDBOOL_H
37
+ #if defined(__cplusplus)
38
+ # if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
39
+ # include <cstdbool>
40
+ # endif
41
+ #elif defined(HAVE_STDBOOL_H)
42
+ # include <stdbool.h>
43
+ #elif !defined(HAVE__BOOL)
44
+ typedef unsigned char _Bool;
45
+ # define bool _Bool
46
+ # define true ((_Bool)+1)
47
+ # define false ((_Bool)+0)
48
+ # define __bool_true_false_are_defined
49
+ #endif
50
+ #endif
51
+
52
+ #ifndef HAVE_RB_EXT_RACTOR_SAFE
53
+ # undef RUBY_TYPED_FROZEN_SHAREABLE
54
+ # define RUBY_TYPED_FROZEN_SHAREABLE 0
55
+ #endif
56
+
57
+ #ifndef NORETURN
58
+ #define NORETURN(x) x
59
+ #endif
60
+
61
+ #ifndef NOINLINE
62
+ #if defined(__has_attribute) && __has_attribute(noinline)
63
+ #define NOINLINE(x) __attribute__((noinline)) x
64
+ #else
65
+ #define NOINLINE(x) x
66
+ #endif
67
+ #endif
68
+
69
+ #ifndef ALWAYS_INLINE
70
+ #if defined(__has_attribute) && __has_attribute(always_inline)
71
+ #define ALWAYS_INLINE(x) inline __attribute__((always_inline)) x
72
+ #else
73
+ #define ALWAYS_INLINE(x) inline x
74
+ #endif
75
+ #endif
76
+
77
+ #ifndef RB_UNLIKELY
78
+ #define RB_UNLIKELY(expr) expr
79
+ #endif
80
+
81
+ #ifndef RB_LIKELY
82
+ #define RB_LIKELY(expr) expr
83
+ #endif
84
+
85
+ #ifndef MAYBE_UNUSED
86
+ # define MAYBE_UNUSED(x) x
87
+ #endif
88
+
89
+ #ifdef RUBY_DEBUG
90
+ #ifndef JSON_DEBUG
91
+ #define JSON_DEBUG RUBY_DEBUG
92
+ #endif
93
+ #endif
94
+
95
+ #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && INTPTR_MAX == INT64_MAX
96
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 1
97
+ #else
98
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 0
99
+ #endif
100
+
101
+ #endif // _JSON_H_
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  require 'mkmf'
3
3
 
4
- have_func("rb_enc_interned_str", "ruby.h") # RUBY_VERSION >= 3.0
4
+ $defs << "-DJSON_DEBUG" if ENV.fetch("JSON_DEBUG", "0") != "0"
5
+ have_func("rb_enc_interned_str", "ruby/encoding.h") # RUBY_VERSION >= 3.0
6
+ have_func("rb_str_to_interned_str", "ruby.h") # RUBY_VERSION >= 3.0
5
7
  have_func("rb_hash_new_capa", "ruby.h") # RUBY_VERSION >= 3.2
6
8
  have_func("rb_hash_bulk_insert", "ruby.h") # Missing on TruffleRuby
7
- have_func("strnlen", "string.h") # Missing on Solaris 10
8
9
 
9
10
  append_cflags("-std=c99")
10
11
 
12
+ if enable_config('parser-use-simd', default=!ENV["JSON_DISABLE_SIMD"])
13
+ load __dir__ + "/../simd/conf.rb"
14
+ end
15
+
11
16
  create_makefile 'json/ext/parser'