datadog-ruby_core_source 3.5.5 → 3.5.6

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
  4. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
  5. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
  6. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
  7. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
  8. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
  9. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
  10. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
  11. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
  12. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
  13. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
  14. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
  15. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
  16. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
  17. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
  18. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
  19. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
  20. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
  21. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
  22. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
  23. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
  24. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
  25. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
  26. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
  27. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
  28. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
  29. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
  30. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
  31. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
  32. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
  33. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
  34. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
  35. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
  36. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
  37. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
  38. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
  39. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
  40. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
  41. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
  42. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
  43. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
  44. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
  45. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
  46. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
  47. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
  48. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
  49. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
  50. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
  51. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
  52. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
  53. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
  54. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
  55. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
  56. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
  57. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
  58. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
  59. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
  60. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
  61. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
  62. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
  63. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
  64. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
  65. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
  66. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
  67. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
  68. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
  69. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
  70. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
  71. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
  72. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
  73. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
  74. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
  75. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
  76. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
  77. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
  78. data/lib/datadog/ruby_core_source/version.rb +1 -1
  79. metadata +77 -2
@@ -0,0 +1,237 @@
1
+ #ifndef RB_HRTIME_H
2
+ #define RB_HRTIME_H
3
+ #include "ruby/ruby.h"
4
+ #include <time.h>
5
+ #if defined(HAVE_SYS_TIME_H)
6
+ # include <sys/time.h>
7
+ #endif
8
+
9
+ #include "internal/compilers.h"
10
+
11
+ /*
12
+ * Hi-res monotonic clock. It is currently nsec resolution, which has over
13
+ * 500 years of range (with an unsigned 64-bit integer). Developers
14
+ * targeting small systems may try 32-bit and low-resolution (milliseconds).
15
+ *
16
+ * TBD: Is nsec even necessary? usec resolution seems enough for userspace
17
+ * and it'll be suitable for use with devices lasting over 500,000 years
18
+ * (maybe some devices designed for long-term space travel)
19
+ *
20
+ * Current API:
21
+ *
22
+ * * rb_hrtime_now - current clock value (monotonic if available)
23
+ * * rb_hrtime_mul - multiply with overflow check
24
+ * * rb_hrtime_add - add with overflow check
25
+ * * rb_timeval2hrtime - convert from timeval
26
+ * * rb_timespec2hrtime - convert from timespec
27
+ * * rb_msec2hrtime - convert from millisecond
28
+ * * rb_sec2hrtime - convert from time_t (seconds)
29
+ * * rb_hrtime2timeval - convert to timeval
30
+ * * rb_hrtime2timespec - convert to timespec
31
+ *
32
+ * Note: no conversion to milliseconds is provided here because different
33
+ * functions have different limits (e.g. epoll_wait vs w32_wait_events).
34
+ * So we provide RB_HRTIME_PER_MSEC and similar macros for implementing
35
+ * this for each use case.
36
+ */
37
+ #define RB_HRTIME_PER_USEC ((rb_hrtime_t)1000)
38
+ #define RB_HRTIME_PER_MSEC (RB_HRTIME_PER_USEC * (rb_hrtime_t)1000)
39
+ #define RB_HRTIME_PER_SEC (RB_HRTIME_PER_MSEC * (rb_hrtime_t)1000)
40
+ #define RB_HRTIME_MAX UINT64_MAX
41
+ #define RB_HRTIME_MIN ((rb_hrtime_t)0)
42
+
43
+ /*
44
+ * Lets try to support time travelers. Lets assume anybody with a time machine
45
+ * also has access to a modern gcc or clang with 128-bit int support
46
+ */
47
+ #ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
48
+ typedef int128_t rb_hrtime_t;
49
+ #else
50
+ typedef uint64_t rb_hrtime_t;
51
+ #endif
52
+
53
+ /* thread.c */
54
+ /* returns the value of the monotonic clock (if available) */
55
+ rb_hrtime_t rb_hrtime_now(void);
56
+
57
+ /*
58
+ * multiply @a and @b with overflow check and return the
59
+ * (clamped to RB_HRTIME_MAX) result.
60
+ */
61
+ static inline rb_hrtime_t
62
+ rb_hrtime_mul(rb_hrtime_t a, rb_hrtime_t b)
63
+ {
64
+ rb_hrtime_t c;
65
+
66
+ #ifdef ckd_mul
67
+ if (ckd_mul(&c, a, b))
68
+ return RB_HRTIME_MAX;
69
+
70
+ #elif __has_builtin(__builtin_mul_overflow)
71
+ if (__builtin_mul_overflow(a, b, &c))
72
+ return RB_HRTIME_MAX;
73
+ #else
74
+ if (b != 0 && a > RB_HRTIME_MAX / b) /* overflow */
75
+ return RB_HRTIME_MAX;
76
+ c = a * b;
77
+ #endif
78
+ return c;
79
+ }
80
+
81
+ /*
82
+ * add @a and @b with overflow check and return the
83
+ * (clamped to RB_HRTIME_MAX) result.
84
+ */
85
+ static inline rb_hrtime_t
86
+ rb_hrtime_add(rb_hrtime_t a, rb_hrtime_t b)
87
+ {
88
+ rb_hrtime_t c;
89
+
90
+ #ifdef ckd_add
91
+ if (ckd_add(&c, a, b))
92
+ return RB_HRTIME_MAX;
93
+
94
+ #elif __has_builtin(__builtin_add_overflow)
95
+ if (__builtin_add_overflow(a, b, &c))
96
+ return RB_HRTIME_MAX;
97
+ #else
98
+ c = a + b;
99
+ if (c < a) /* overflow */
100
+ return RB_HRTIME_MAX;
101
+ #endif
102
+ return c;
103
+ }
104
+
105
+ static inline rb_hrtime_t
106
+ rb_hrtime_sub(rb_hrtime_t a, rb_hrtime_t b)
107
+ {
108
+ if (a < b) {
109
+ return RB_HRTIME_MIN;
110
+ }
111
+ return a - b;
112
+ }
113
+
114
+ /*
115
+ * convert a timeval struct to rb_hrtime_t, clamping at RB_HRTIME_MAX
116
+ */
117
+ static inline rb_hrtime_t
118
+ rb_timeval2hrtime(const struct timeval *tv)
119
+ {
120
+ rb_hrtime_t s = rb_hrtime_mul((rb_hrtime_t)tv->tv_sec, RB_HRTIME_PER_SEC);
121
+ rb_hrtime_t u = rb_hrtime_mul((rb_hrtime_t)tv->tv_usec, RB_HRTIME_PER_USEC);
122
+
123
+ return rb_hrtime_add(s, u);
124
+ }
125
+
126
+ /*
127
+ * convert a timespec struct to rb_hrtime_t, clamping at RB_HRTIME_MAX
128
+ */
129
+ static inline rb_hrtime_t
130
+ rb_timespec2hrtime(const struct timespec *ts)
131
+ {
132
+ rb_hrtime_t s = rb_hrtime_mul((rb_hrtime_t)ts->tv_sec, RB_HRTIME_PER_SEC);
133
+
134
+ return rb_hrtime_add(s, (rb_hrtime_t)ts->tv_nsec);
135
+ }
136
+
137
+ /*
138
+ * convert a millisecond value to rb_hrtime_t, clamping at RB_HRTIME_MAX
139
+ */
140
+ static inline rb_hrtime_t
141
+ rb_msec2hrtime(unsigned long msec)
142
+ {
143
+ return rb_hrtime_mul((rb_hrtime_t)msec, RB_HRTIME_PER_MSEC);
144
+ }
145
+
146
+ /*
147
+ * convert a time_t value to rb_hrtime_t, clamping at RB_HRTIME_MAX
148
+ * Negative values will be clamped at 0.
149
+ */
150
+ static inline rb_hrtime_t
151
+ rb_sec2hrtime(time_t sec)
152
+ {
153
+ if (sec <= 0) return 0;
154
+
155
+ return rb_hrtime_mul((rb_hrtime_t)sec, RB_HRTIME_PER_SEC);
156
+ }
157
+
158
+ /*
159
+ * convert a rb_hrtime_t value to a timespec, suitable for calling
160
+ * functions like ppoll(2) or kevent(2)
161
+ */
162
+ static inline struct timespec *
163
+ rb_hrtime2timespec(struct timespec *ts, const rb_hrtime_t *hrt)
164
+ {
165
+ if (hrt) {
166
+ ts->tv_sec = (time_t)(*hrt / RB_HRTIME_PER_SEC);
167
+ ts->tv_nsec = (int32_t)(*hrt % RB_HRTIME_PER_SEC);
168
+ return ts;
169
+ }
170
+ return 0;
171
+ }
172
+
173
+ /*
174
+ * convert a rb_hrtime_t value to a timeval, suitable for calling
175
+ * functions like select(2)
176
+ */
177
+ static inline struct timeval *
178
+ rb_hrtime2timeval(struct timeval *tv, const rb_hrtime_t *hrt)
179
+ {
180
+ if (hrt) {
181
+ tv->tv_sec = (time_t)(*hrt / RB_HRTIME_PER_SEC);
182
+ tv->tv_usec = (int32_t)((*hrt % RB_HRTIME_PER_SEC)/RB_HRTIME_PER_USEC);
183
+
184
+ return tv;
185
+ }
186
+ return 0;
187
+ }
188
+
189
+ #include "internal/warnings.h"
190
+ #include "internal/time.h"
191
+
192
+ /*
193
+ * Back when we used "struct timeval", not all platforms implemented
194
+ * tv_sec as time_t. Nowadays we use "struct timespec" and tv_sec
195
+ * seems to be implemented more consistently across platforms.
196
+ * At least other parts of our code hasn't had to deal with non-time_t
197
+ * tv_sec in timespec...
198
+ */
199
+ #define TIMESPEC_SEC_MAX TIMET_MAX
200
+ #define TIMESPEC_SEC_MIN TIMET_MIN
201
+
202
+ COMPILER_WARNING_PUSH
203
+ #if __has_warning("-Wimplicit-int-float-conversion")
204
+ COMPILER_WARNING_IGNORED(-Wimplicit-int-float-conversion)
205
+ #elif defined(_MSC_VER)
206
+ /* C4305: 'initializing': truncation from '__int64' to 'const double' */
207
+ COMPILER_WARNING_IGNORED(4305)
208
+ #endif
209
+ static const double TIMESPEC_SEC_MAX_as_double = TIMESPEC_SEC_MAX;
210
+ COMPILER_WARNING_POP
211
+
212
+ static inline rb_hrtime_t *
213
+ double2hrtime(rb_hrtime_t *hrt, double d)
214
+ {
215
+ /* assume timespec.tv_sec has same signedness as time_t */
216
+ const double TIMESPEC_SEC_MAX_PLUS_ONE = 2.0 * (TIMESPEC_SEC_MAX_as_double / 2.0 + 1.0);
217
+
218
+ if (TIMESPEC_SEC_MAX_PLUS_ONE <= d) {
219
+ *hrt = RB_HRTIME_MAX;
220
+ return NULL;
221
+ }
222
+ else if (d <= 0) {
223
+ *hrt = 0;
224
+ }
225
+ else {
226
+ *hrt = (rb_hrtime_t)(d * (double)RB_HRTIME_PER_SEC);
227
+ }
228
+ return hrt;
229
+ }
230
+
231
+ static inline double
232
+ hrtime2double(rb_hrtime_t hrt)
233
+ {
234
+ return (double)hrt / (double)RB_HRTIME_PER_SEC;
235
+ }
236
+
237
+ #endif /* RB_HRTIME_H */
@@ -0,0 +1,365 @@
1
+ /* DO NOT EDIT THIS FILE DIRECTLY: source is at template/id.h.tmpl */
2
+ /**********************************************************************
3
+
4
+ id.h -
5
+
6
+ $Author$
7
+ created at: Sun Oct 19 21:12:51 2008
8
+
9
+ Copyright (C) 2007 Koichi Sasada
10
+
11
+ **********************************************************************/
12
+
13
+ #ifndef RUBY_ID_H
14
+ #define RUBY_ID_H
15
+
16
+ enum ruby_id_types {
17
+ RUBY_ID_LOCAL = 0x00,
18
+ RUBY_ID_STATIC_SYM = 0x01,
19
+ RUBY_ID_INSTANCE = (0x01<<1),
20
+ RUBY_ID_GLOBAL = (0x03<<1),
21
+ RUBY_ID_ATTRSET = (0x04<<1),
22
+ RUBY_ID_CONST = (0x05<<1),
23
+ RUBY_ID_CLASS = (0x06<<1),
24
+ RUBY_ID_INTERNAL = (0x07<<1),
25
+ RUBY_ID_SCOPE_SHIFT = 4,
26
+ RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
27
+ };
28
+
29
+ #define ID_STATIC_SYM RUBY_ID_STATIC_SYM
30
+ #define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
31
+ #define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
32
+ #define ID_LOCAL RUBY_ID_LOCAL
33
+ #define ID_INSTANCE RUBY_ID_INSTANCE
34
+ #define ID_GLOBAL RUBY_ID_GLOBAL
35
+ #define ID_ATTRSET RUBY_ID_ATTRSET
36
+ #define ID_CONST RUBY_ID_CONST
37
+ #define ID_CLASS RUBY_ID_CLASS
38
+ #define ID_INTERNAL RUBY_ID_INTERNAL
39
+
40
+ #define symIFUNC ID2SYM(idIFUNC)
41
+ #define symCFUNC ID2SYM(idCFUNC)
42
+
43
+ #define RUBY_TOKEN_DOT2 128
44
+ #define RUBY_TOKEN_DOT3 129
45
+ #define RUBY_TOKEN_BDOT2 130
46
+ #define RUBY_TOKEN_BDOT3 131
47
+ #define RUBY_TOKEN_UPLUS 132
48
+ #define RUBY_TOKEN_UMINUS 133
49
+ #define RUBY_TOKEN_POW 134
50
+ #define RUBY_TOKEN_CMP 135
51
+ #define RUBY_TOKEN_LSHFT 136
52
+ #define RUBY_TOKEN_RSHFT 137
53
+ #define RUBY_TOKEN_LEQ 138
54
+ #define RUBY_TOKEN_GEQ 139
55
+ #define RUBY_TOKEN_EQ 140
56
+ #define RUBY_TOKEN_EQQ 141
57
+ #define RUBY_TOKEN_NEQ 142
58
+ #define RUBY_TOKEN_MATCH 143
59
+ #define RUBY_TOKEN_NMATCH 144
60
+ #define RUBY_TOKEN_AREF 145
61
+ #define RUBY_TOKEN_ASET 146
62
+ #define RUBY_TOKEN_COLON2 147
63
+ #define RUBY_TOKEN_ANDOP 148
64
+ #define RUBY_TOKEN_OROP 149
65
+ #define RUBY_TOKEN_ANDDOT 150
66
+ #define RUBY_TOKEN(t) RUBY_TOKEN_##t
67
+
68
+ #define RUBY_TOKEN2ID_TYPE(tok, type) ((tok<<RUBY_ID_SCOPE_SHIFT)|type|RUBY_ID_STATIC_SYM)
69
+ #define TOKEN2LOCALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_LOCAL)
70
+ #define TOKEN2INSTANCEID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_INSTANCE)
71
+ #define TOKEN2GLOBALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_GLOBAL)
72
+ #define TOKEN2CONSTID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CONST)
73
+ #define TOKEN2CLASSID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CLASS)
74
+ #define TOKEN2ATTRSETID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_ATTRSET)
75
+
76
+ enum ruby_method_ids {
77
+ idDot2 = RUBY_TOKEN(DOT2),
78
+ idDot3 = RUBY_TOKEN(DOT3),
79
+ idUPlus = RUBY_TOKEN(UPLUS),
80
+ idUMinus = RUBY_TOKEN(UMINUS),
81
+ idPow = RUBY_TOKEN(POW),
82
+ idCmp = RUBY_TOKEN(CMP),
83
+ idPLUS = '+',
84
+ idMINUS = '-',
85
+ idMULT = '*',
86
+ idDIV = '/',
87
+ idMOD = '%',
88
+ idLTLT = RUBY_TOKEN(LSHFT),
89
+ idGTGT = RUBY_TOKEN(RSHFT),
90
+ idLT = '<',
91
+ idLE = RUBY_TOKEN(LEQ),
92
+ idGT = '>',
93
+ idGE = RUBY_TOKEN(GEQ),
94
+ idEq = RUBY_TOKEN(EQ),
95
+ idEqq = RUBY_TOKEN(EQQ),
96
+ idNeq = RUBY_TOKEN(NEQ),
97
+ idNot = '!',
98
+ idAnd = '&',
99
+ idOr = '|',
100
+ idBackquote = '`',
101
+ idEqTilde = RUBY_TOKEN(MATCH),
102
+ idNeqTilde = RUBY_TOKEN(NMATCH),
103
+ idAREF = RUBY_TOKEN(AREF),
104
+ idASET = RUBY_TOKEN(ASET),
105
+ idCOLON2 = RUBY_TOKEN(COLON2),
106
+ idANDOP = RUBY_TOKEN(ANDOP),
107
+ idOROP = RUBY_TOKEN(OROP),
108
+ idANDDOT = RUBY_TOKEN(ANDDOT),
109
+ tPRESERVED_ID_BEGIN = 150,
110
+ idNilP,
111
+ idIncludeP,
112
+ idItImplicit,
113
+ idNULL,
114
+ idEmptyP,
115
+ idEqlP,
116
+ idRespond_to,
117
+ idRespond_to_missing,
118
+ idIFUNC,
119
+ idCFUNC,
120
+ id_core_set_method_alias,
121
+ id_core_set_variable_alias,
122
+ id_core_undef_method,
123
+ id_core_define_method,
124
+ id_core_define_singleton_method,
125
+ id_core_iseq_path,
126
+ id_core_set_postexe,
127
+ id_core_hash_merge_ptr,
128
+ id_core_hash_merge_bang_ptr,
129
+ id_core_hash_merge_kwd,
130
+ id_core_hash_merge_bang_kwd,
131
+ id_core_hash_coerce,
132
+ id_core_raise,
133
+ id_core_sprintf,
134
+ id_debug_created_info,
135
+ tPRESERVED_ID_END,
136
+
137
+ /* LOCAL tokens {{{ */
138
+ tTOKEN_LOCAL_BEGIN = tPRESERVED_ID_END-1,
139
+ tMax,
140
+ tMin,
141
+ tHash,
142
+ tFreeze,
143
+ tInspect,
144
+ tIntern,
145
+ tObject_id,
146
+ t__id__,
147
+ tConst_added,
148
+ tConst_missing,
149
+ tMethodMissing,
150
+ tMethod_added,
151
+ tSingleton_method_added,
152
+ tMethod_removed,
153
+ tSingleton_method_removed,
154
+ tMethod_undefined,
155
+ tSingleton_method_undefined,
156
+ tLength,
157
+ tSize,
158
+ tGets,
159
+ tSucc,
160
+ tEach,
161
+ tProc,
162
+ tLambda,
163
+ tSend,
164
+ t__send__,
165
+ t__recursive_key__,
166
+ tClone,
167
+ tInitialize,
168
+ tInitialize_copy,
169
+ tInitialize_clone,
170
+ tInitialize_dup,
171
+ tTo_int,
172
+ tTo_ary,
173
+ tTo_str,
174
+ tTo_sym,
175
+ tTo_hash,
176
+ tTo_proc,
177
+ tTo_io,
178
+ tTo_a,
179
+ tTo_s,
180
+ tTo_i,
181
+ tTo_f,
182
+ tTo_r,
183
+ tBt,
184
+ tBt_locations,
185
+ tCall,
186
+ tYield,
187
+ tMesg,
188
+ tException,
189
+ tLocals,
190
+ tNOT,
191
+ tAND,
192
+ tOR,
193
+ tDiv,
194
+ tDivmod,
195
+ tFdiv,
196
+ tQuo,
197
+ tName,
198
+ tNil,
199
+ tPath,
200
+ tPack,
201
+ tBuffer,
202
+ tAborted,
203
+ tExited,
204
+ tUScore,
205
+ tNUMPARAM_1,
206
+ tNUMPARAM_2,
207
+ tNUMPARAM_3,
208
+ tNUMPARAM_4,
209
+ tNUMPARAM_5,
210
+ tNUMPARAM_6,
211
+ tNUMPARAM_7,
212
+ tNUMPARAM_8,
213
+ tNUMPARAM_9,
214
+ tIt,
215
+ tDefault,
216
+ tTOKEN_LOCAL_END,
217
+ /* LOCAL tokens }}} */
218
+
219
+ /* INSTANCE tokens {{{ */
220
+ tTOKEN_INSTANCE_BEGIN = tTOKEN_LOCAL_END-1,
221
+ tTOKEN_INSTANCE_END,
222
+ /* INSTANCE tokens }}} */
223
+
224
+ /* GLOBAL tokens {{{ */
225
+ tTOKEN_GLOBAL_BEGIN = tTOKEN_INSTANCE_END-1,
226
+ tLASTLINE,
227
+ tBACKREF,
228
+ tERROR_INFO,
229
+ tTOKEN_GLOBAL_END,
230
+ /* GLOBAL tokens }}} */
231
+
232
+ /* CONST tokens {{{ */
233
+ tTOKEN_CONST_BEGIN = tTOKEN_GLOBAL_END-1,
234
+ tRuby,
235
+ tTOKEN_CONST_END,
236
+ /* CONST tokens }}} */
237
+
238
+ /* CLASS tokens {{{ */
239
+ tTOKEN_CLASS_BEGIN = tTOKEN_CONST_END-1,
240
+ tTOKEN_CLASS_END,
241
+ /* CLASS tokens }}} */
242
+
243
+ /* ATTRSET tokens {{{ */
244
+ tTOKEN_ATTRSET_BEGIN = tTOKEN_CLASS_END-1,
245
+ tTOKEN_ATTRSET_END,
246
+ /* ATTRSET tokens }}} */
247
+
248
+ tNEXT_ID = tTOKEN_ATTRSET_END,
249
+
250
+ /* LOCAL IDs {{{ */
251
+ #define DEFINE_LOCALID_FROM_TOKEN(n) id##n = TOKEN2LOCALID(t##n)
252
+ DEFINE_LOCALID_FROM_TOKEN(Max),
253
+ DEFINE_LOCALID_FROM_TOKEN(Min),
254
+ DEFINE_LOCALID_FROM_TOKEN(Hash),
255
+ DEFINE_LOCALID_FROM_TOKEN(Freeze),
256
+ DEFINE_LOCALID_FROM_TOKEN(Inspect),
257
+ DEFINE_LOCALID_FROM_TOKEN(Intern),
258
+ DEFINE_LOCALID_FROM_TOKEN(Object_id),
259
+ DEFINE_LOCALID_FROM_TOKEN(__id__),
260
+ DEFINE_LOCALID_FROM_TOKEN(Const_added),
261
+ DEFINE_LOCALID_FROM_TOKEN(Const_missing),
262
+ DEFINE_LOCALID_FROM_TOKEN(MethodMissing),
263
+ DEFINE_LOCALID_FROM_TOKEN(Method_added),
264
+ DEFINE_LOCALID_FROM_TOKEN(Singleton_method_added),
265
+ DEFINE_LOCALID_FROM_TOKEN(Method_removed),
266
+ DEFINE_LOCALID_FROM_TOKEN(Singleton_method_removed),
267
+ DEFINE_LOCALID_FROM_TOKEN(Method_undefined),
268
+ DEFINE_LOCALID_FROM_TOKEN(Singleton_method_undefined),
269
+ DEFINE_LOCALID_FROM_TOKEN(Length),
270
+ DEFINE_LOCALID_FROM_TOKEN(Size),
271
+ DEFINE_LOCALID_FROM_TOKEN(Gets),
272
+ DEFINE_LOCALID_FROM_TOKEN(Succ),
273
+ DEFINE_LOCALID_FROM_TOKEN(Each),
274
+ DEFINE_LOCALID_FROM_TOKEN(Proc),
275
+ DEFINE_LOCALID_FROM_TOKEN(Lambda),
276
+ DEFINE_LOCALID_FROM_TOKEN(Send),
277
+ DEFINE_LOCALID_FROM_TOKEN(__send__),
278
+ DEFINE_LOCALID_FROM_TOKEN(__recursive_key__),
279
+ DEFINE_LOCALID_FROM_TOKEN(Clone),
280
+ DEFINE_LOCALID_FROM_TOKEN(Initialize),
281
+ DEFINE_LOCALID_FROM_TOKEN(Initialize_copy),
282
+ DEFINE_LOCALID_FROM_TOKEN(Initialize_clone),
283
+ DEFINE_LOCALID_FROM_TOKEN(Initialize_dup),
284
+ DEFINE_LOCALID_FROM_TOKEN(To_int),
285
+ DEFINE_LOCALID_FROM_TOKEN(To_ary),
286
+ DEFINE_LOCALID_FROM_TOKEN(To_str),
287
+ DEFINE_LOCALID_FROM_TOKEN(To_sym),
288
+ DEFINE_LOCALID_FROM_TOKEN(To_hash),
289
+ DEFINE_LOCALID_FROM_TOKEN(To_proc),
290
+ DEFINE_LOCALID_FROM_TOKEN(To_io),
291
+ DEFINE_LOCALID_FROM_TOKEN(To_a),
292
+ DEFINE_LOCALID_FROM_TOKEN(To_s),
293
+ DEFINE_LOCALID_FROM_TOKEN(To_i),
294
+ DEFINE_LOCALID_FROM_TOKEN(To_f),
295
+ DEFINE_LOCALID_FROM_TOKEN(To_r),
296
+ DEFINE_LOCALID_FROM_TOKEN(Bt),
297
+ DEFINE_LOCALID_FROM_TOKEN(Bt_locations),
298
+ DEFINE_LOCALID_FROM_TOKEN(Call),
299
+ DEFINE_LOCALID_FROM_TOKEN(Yield),
300
+ DEFINE_LOCALID_FROM_TOKEN(Mesg),
301
+ DEFINE_LOCALID_FROM_TOKEN(Exception),
302
+ DEFINE_LOCALID_FROM_TOKEN(Locals),
303
+ DEFINE_LOCALID_FROM_TOKEN(NOT),
304
+ DEFINE_LOCALID_FROM_TOKEN(AND),
305
+ DEFINE_LOCALID_FROM_TOKEN(OR),
306
+ DEFINE_LOCALID_FROM_TOKEN(Div),
307
+ DEFINE_LOCALID_FROM_TOKEN(Divmod),
308
+ DEFINE_LOCALID_FROM_TOKEN(Fdiv),
309
+ DEFINE_LOCALID_FROM_TOKEN(Quo),
310
+ DEFINE_LOCALID_FROM_TOKEN(Name),
311
+ DEFINE_LOCALID_FROM_TOKEN(Nil),
312
+ DEFINE_LOCALID_FROM_TOKEN(Path),
313
+ DEFINE_LOCALID_FROM_TOKEN(Pack),
314
+ DEFINE_LOCALID_FROM_TOKEN(Buffer),
315
+ DEFINE_LOCALID_FROM_TOKEN(Aborted),
316
+ DEFINE_LOCALID_FROM_TOKEN(Exited),
317
+ DEFINE_LOCALID_FROM_TOKEN(UScore),
318
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_1),
319
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_2),
320
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_3),
321
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_4),
322
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_5),
323
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_6),
324
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_7),
325
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_8),
326
+ DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_9),
327
+ DEFINE_LOCALID_FROM_TOKEN(It),
328
+ DEFINE_LOCALID_FROM_TOKEN(Default),
329
+ #undef DEFINE_LOCALID_FROM_TOKEN
330
+ /* LOCAL IDs }}} */
331
+
332
+ /* INSTANCE IDs {{{ */
333
+ #define DEFINE_INSTANCEID_FROM_TOKEN(n) id##n = TOKEN2INSTANCEID(t##n)
334
+ #undef DEFINE_INSTANCEID_FROM_TOKEN
335
+ /* INSTANCE IDs }}} */
336
+
337
+ /* GLOBAL IDs {{{ */
338
+ #define DEFINE_GLOBALID_FROM_TOKEN(n) id##n = TOKEN2GLOBALID(t##n)
339
+ DEFINE_GLOBALID_FROM_TOKEN(LASTLINE),
340
+ DEFINE_GLOBALID_FROM_TOKEN(BACKREF),
341
+ DEFINE_GLOBALID_FROM_TOKEN(ERROR_INFO),
342
+ #undef DEFINE_GLOBALID_FROM_TOKEN
343
+ /* GLOBAL IDs }}} */
344
+
345
+ /* CONST IDs {{{ */
346
+ #define DEFINE_CONSTID_FROM_TOKEN(n) id##n = TOKEN2CONSTID(t##n)
347
+ DEFINE_CONSTID_FROM_TOKEN(Ruby),
348
+ #undef DEFINE_CONSTID_FROM_TOKEN
349
+ /* CONST IDs }}} */
350
+
351
+ /* CLASS IDs {{{ */
352
+ #define DEFINE_CLASSID_FROM_TOKEN(n) id##n = TOKEN2CLASSID(t##n)
353
+ #undef DEFINE_CLASSID_FROM_TOKEN
354
+ /* CLASS IDs }}} */
355
+
356
+ /* ATTRSET IDs {{{ */
357
+ #define DEFINE_ATTRSETID_FROM_TOKEN(n) id##n = TOKEN2ATTRSETID(t##n)
358
+ #undef DEFINE_ATTRSETID_FROM_TOKEN
359
+ /* ATTRSET IDs }}} */
360
+
361
+ tLAST_OP_ID = tPRESERVED_ID_END-1,
362
+ idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
363
+ };
364
+
365
+ #endif /* RUBY_ID_H */
@@ -0,0 +1,74 @@
1
+ #ifndef RUBY_ID_TABLE_H
2
+ #define RUBY_ID_TABLE_H 1
3
+ #include "ruby/internal/config.h"
4
+ #include <stddef.h>
5
+ #include "ruby/ruby.h"
6
+
7
+ struct rb_id_table {
8
+ int capa;
9
+ int num;
10
+ int used;
11
+ /* The table body is a single buffer laid out as:
12
+ *
13
+ * [VALUE values[capa] | id_key_t keys[capa] | collision bitmap]
14
+ *
15
+ * where the collision bitmap uses one mark bit per slot. */
16
+ void *buf;
17
+ };
18
+
19
+ /* compatible with ST_* */
20
+ enum rb_id_table_iterator_result {
21
+ ID_TABLE_CONTINUE = ST_CONTINUE,
22
+ ID_TABLE_STOP = ST_STOP,
23
+ ID_TABLE_DELETE = ST_DELETE,
24
+ ID_TABLE_REPLACE = ST_REPLACE,
25
+ ID_TABLE_ITERATOR_RESULT_END
26
+ };
27
+
28
+ struct rb_id_table *rb_id_table_create(size_t size);
29
+ struct rb_id_table *rb_id_table_init(struct rb_id_table *tbl, size_t capa);
30
+
31
+ void rb_id_table_free(struct rb_id_table *tbl);
32
+ void rb_id_table_free_items(struct rb_id_table *tbl);
33
+ void rb_id_table_clear(struct rb_id_table *tbl);
34
+
35
+ size_t rb_id_table_memsize(const struct rb_id_table *tbl);
36
+
37
+ int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
38
+ int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
39
+ int rb_id_table_delete(struct rb_id_table *tbl, ID id);
40
+
41
+ typedef enum rb_id_table_iterator_result rb_id_table_update_value_callback_func_t(VALUE *val, void *data, int existing);
42
+ typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
43
+ typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
44
+ void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
45
+ void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
46
+ void rb_id_table_foreach_values_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, rb_id_table_update_value_callback_func_t *replace, void *data);
47
+
48
+ VALUE rb_managed_id_table_create(const rb_data_type_t *type, size_t capa);
49
+ VALUE rb_managed_id_table_new(size_t capa);
50
+ VALUE rb_managed_id_table_dup(VALUE table);
51
+ int rb_managed_id_table_insert(VALUE table, ID id, VALUE val);
52
+ int rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp);
53
+ size_t rb_managed_id_table_size(VALUE table);
54
+ void rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data);
55
+ void rb_managed_id_table_foreach_values(VALUE table, rb_id_table_foreach_values_func_t *func, void *data);
56
+ int rb_managed_id_table_delete(VALUE table, ID id);
57
+
58
+ extern const rb_data_type_t rb_managed_id_table_type;
59
+
60
+ VALUE rb_marked_id_table_new(size_t capa);
61
+ int rb_marked_id_table_insert(VALUE table, ID id, VALUE val);
62
+ VALUE rb_marked_id_table_dup(VALUE table);
63
+
64
+ // alisases
65
+ #define rb_marked_id_table_size rb_managed_id_table_size
66
+ #define rb_marked_id_table_lookup rb_managed_id_table_lookup
67
+ #define rb_marked_id_table_foreach rb_managed_id_table_foreach
68
+ #define rb_marked_id_table_foreach_values rb_managed_id_table_foreach_values
69
+
70
+ RUBY_SYMBOL_EXPORT_BEGIN
71
+ size_t rb_id_table_size(const struct rb_id_table *tbl);
72
+ RUBY_SYMBOL_EXPORT_END
73
+
74
+ #endif /* RUBY_ID_TABLE_H */