json 2.15.1 → 2.19.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,105 @@
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
+ #if defined(__has_attribute) && __has_attribute(noreturn)
59
+ #define NORETURN(x) __attribute__((noreturn)) x
60
+ #else
61
+ #define NORETURN(x) x
62
+ #endif
63
+ #endif
64
+
65
+ #ifndef NOINLINE
66
+ #if defined(__has_attribute) && __has_attribute(noinline)
67
+ #define NOINLINE(x) __attribute__((noinline)) x
68
+ #else
69
+ #define NOINLINE(x) x
70
+ #endif
71
+ #endif
72
+
73
+ #ifndef ALWAYS_INLINE
74
+ #if defined(__has_attribute) && __has_attribute(always_inline)
75
+ #define ALWAYS_INLINE(x) inline __attribute__((always_inline)) x
76
+ #else
77
+ #define ALWAYS_INLINE(x) inline x
78
+ #endif
79
+ #endif
80
+
81
+ #ifndef RB_UNLIKELY
82
+ #define RB_UNLIKELY(expr) expr
83
+ #endif
84
+
85
+ #ifndef RB_LIKELY
86
+ #define RB_LIKELY(expr) expr
87
+ #endif
88
+
89
+ #ifndef MAYBE_UNUSED
90
+ # define MAYBE_UNUSED(x) x
91
+ #endif
92
+
93
+ #ifdef RUBY_DEBUG
94
+ #ifndef JSON_DEBUG
95
+ #define JSON_DEBUG RUBY_DEBUG
96
+ #endif
97
+ #endif
98
+
99
+ #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && INTPTR_MAX == INT64_MAX
100
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 1
101
+ #else
102
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 0
103
+ #endif
104
+
105
+ #endif // _JSON_H_
@@ -1,10 +1,11 @@
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
8
9
 
9
10
  append_cflags("-std=c99")
10
11