json 2.15.2 → 2.17.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,97 @@
1
+ #ifndef _JSON_H_
2
+ #define _JSON_H_
3
+
4
+ #include "ruby.h"
5
+ #include "ruby/encoding.h"
6
+ #include <stdint.h>
7
+
8
+ #if defined(RUBY_DEBUG) && RUBY_DEBUG
9
+ # define JSON_ASSERT RUBY_ASSERT
10
+ #else
11
+ # ifdef JSON_DEBUG
12
+ # include <assert.h>
13
+ # define JSON_ASSERT(x) assert(x)
14
+ # else
15
+ # define JSON_ASSERT(x)
16
+ # endif
17
+ #endif
18
+
19
+ /* shims */
20
+
21
+ #if SIZEOF_UINT64_T == SIZEOF_LONG_LONG
22
+ # define INT64T2NUM(x) LL2NUM(x)
23
+ # define UINT64T2NUM(x) ULL2NUM(x)
24
+ #elif SIZEOF_UINT64_T == SIZEOF_LONG
25
+ # define INT64T2NUM(x) LONG2NUM(x)
26
+ # define UINT64T2NUM(x) ULONG2NUM(x)
27
+ #else
28
+ # error No uint64_t conversion
29
+ #endif
30
+
31
+ /* This is the fallback definition from Ruby 3.4 */
32
+ #ifndef RBIMPL_STDBOOL_H
33
+ #if defined(__cplusplus)
34
+ # if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
35
+ # include <cstdbool>
36
+ # endif
37
+ #elif defined(HAVE_STDBOOL_H)
38
+ # include <stdbool.h>
39
+ #elif !defined(HAVE__BOOL)
40
+ typedef unsigned char _Bool;
41
+ # define bool _Bool
42
+ # define true ((_Bool)+1)
43
+ # define false ((_Bool)+0)
44
+ # define __bool_true_false_are_defined
45
+ #endif
46
+ #endif
47
+
48
+ #ifndef HAVE_RB_EXT_RACTOR_SAFE
49
+ # undef RUBY_TYPED_FROZEN_SHAREABLE
50
+ # define RUBY_TYPED_FROZEN_SHAREABLE 0
51
+ #endif
52
+
53
+ #ifndef NORETURN
54
+ #define NORETURN(x) x
55
+ #endif
56
+
57
+ #ifndef NOINLINE
58
+ #if defined(__has_attribute) && __has_attribute(noinline)
59
+ #define NOINLINE(x) __attribute__((noinline)) x
60
+ #else
61
+ #define NOINLINE(x) x
62
+ #endif
63
+ #endif
64
+
65
+ #ifndef ALWAYS_INLINE
66
+ #if defined(__has_attribute) && __has_attribute(always_inline)
67
+ #define ALWAYS_INLINE(x) inline __attribute__((always_inline)) x
68
+ #else
69
+ #define ALWAYS_INLINE(x) inline x
70
+ #endif
71
+ #endif
72
+
73
+ #ifndef RB_UNLIKELY
74
+ #define RB_UNLIKELY(expr) expr
75
+ #endif
76
+
77
+ #ifndef RB_LIKELY
78
+ #define RB_LIKELY(expr) expr
79
+ #endif
80
+
81
+ #ifndef MAYBE_UNUSED
82
+ # define MAYBE_UNUSED(x) x
83
+ #endif
84
+
85
+ #ifdef RUBY_DEBUG
86
+ #ifndef JSON_DEBUG
87
+ #define JSON_DEBUG RUBY_DEBUG
88
+ #endif
89
+ #endif
90
+
91
+ #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && INTPTR_MAX == INT64_MAX
92
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 1
93
+ #else
94
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 0
95
+ #endif
96
+
97
+ #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