json 2.13.2 → 2.16.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,92 @@
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 NORETURN
49
+ #define NORETURN(x) x
50
+ #endif
51
+
52
+ #ifndef NOINLINE
53
+ #if defined(__has_attribute) && __has_attribute(noinline)
54
+ #define NOINLINE(x) __attribute__((noinline)) x
55
+ #else
56
+ #define NOINLINE(x) x
57
+ #endif
58
+ #endif
59
+
60
+ #ifndef ALWAYS_INLINE
61
+ #if defined(__has_attribute) && __has_attribute(always_inline)
62
+ #define ALWAYS_INLINE(x) inline __attribute__((always_inline)) x
63
+ #else
64
+ #define ALWAYS_INLINE(x) inline x
65
+ #endif
66
+ #endif
67
+
68
+ #ifndef RB_UNLIKELY
69
+ #define RB_UNLIKELY(expr) expr
70
+ #endif
71
+
72
+ #ifndef RB_LIKELY
73
+ #define RB_LIKELY(expr) expr
74
+ #endif
75
+
76
+ #ifndef MAYBE_UNUSED
77
+ # define MAYBE_UNUSED(x) x
78
+ #endif
79
+
80
+ #ifdef RUBY_DEBUG
81
+ #ifndef JSON_DEBUG
82
+ #define JSON_DEBUG RUBY_DEBUG
83
+ #endif
84
+ #endif
85
+
86
+ #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && INTPTR_MAX == INT64_MAX
87
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 1
88
+ #else
89
+ #define JSON_CPU_LITTLE_ENDIAN_64BITS 0
90
+ #endif
91
+
92
+ #endif // _JSON_H_
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  require 'mkmf'
3
3
 
4
+ $defs << "-DJSON_DEBUG" if ENV["JSON_DEBUG"]
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
9
  have_func("strnlen", "string.h") # Missing on Solaris 10