json 2.13.2 → 2.19.5

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,116 @@
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
+ #ifdef RUBY_TYPED_EMBEDDABLE
58
+ # define HAVE_RUBY_TYPED_EMBEDDABLE 1
59
+ #else
60
+ # ifdef HAVE_CONST_RUBY_TYPED_EMBEDDABLE
61
+ # define RUBY_TYPED_EMBEDDABLE RUBY_TYPED_EMBEDDABLE
62
+ # define HAVE_RUBY_TYPED_EMBEDDABLE 1
63
+ # else
64
+ # define RUBY_TYPED_EMBEDDABLE 0
65
+ # endif
66
+ #endif
67
+
68
+ #ifndef NORETURN
69
+ #if defined(__has_attribute) && __has_attribute(noreturn)
70
+ #define NORETURN(x) __attribute__((noreturn)) x
71
+ #else
72
+ #define NORETURN(x) x
73
+ #endif
74
+ #endif
75
+
76
+ #ifndef NOINLINE
77
+ #if defined(__has_attribute) && __has_attribute(noinline)
78
+ #define NOINLINE(x) __attribute__((noinline)) x
79
+ #else
80
+ #define NOINLINE(x) x
81
+ #endif
82
+ #endif
83
+
84
+ #ifndef ALWAYS_INLINE
85
+ #if defined(__has_attribute) && __has_attribute(always_inline)
86
+ #define ALWAYS_INLINE(x) inline __attribute__((always_inline)) x
87
+ #else
88
+ #define ALWAYS_INLINE(x) inline x
89
+ #endif
90
+ #endif
91
+
92
+ #ifndef RB_UNLIKELY
93
+ #define RB_UNLIKELY(expr) expr
94
+ #endif
95
+
96
+ #ifndef RB_LIKELY
97
+ #define RB_LIKELY(expr) expr
98
+ #endif
99
+
100
+ #ifndef MAYBE_UNUSED
101
+ # define MAYBE_UNUSED(x) x
102
+ #endif
103
+
104
+ #ifdef RUBY_DEBUG
105
+ #ifndef JSON_DEBUG
106
+ #define JSON_DEBUG RUBY_DEBUG
107
+ #endif
108
+ #endif
109
+
110
+ #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && INTPTR_MAX == INT64_MAX
111
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 1
112
+ #else
113
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 0
114
+ #endif
115
+
116
+ #endif // _JSON_H_
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
  require 'mkmf'
3
3
 
4
+ $defs << "-DJSON_DEBUG" if ENV.fetch("JSON_DEBUG", "0") != "0"
4
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
9
+
10
+ if RUBY_ENGINE == "ruby"
11
+ have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
12
+ end
8
13
 
9
14
  append_cflags("-std=c99")
10
15