Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

ruby.h
Go to the documentation of this file.
1 /**********************************************************************
2
3 ruby/ruby.h -
4
5 $Author$
6 created at: Thu Jun 10 14:26:32 JST 1993
7
8 Copyright (C) 1993-2008 Yukihiro Matsumoto
9 Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
10 Copyright (C) 2000 Information-technology Promotion Agency, Japan
11
12 **********************************************************************/
13
14 #ifndef RUBY_RUBY_H
15 #define RUBY_RUBY_H 1
16
17 #if defined(__cplusplus)
18 extern "C" {
19 #if 0
20 } /* satisfy cc-mode */
21 #endif
22 #endif
23
24 #include "ruby/config.h"
25 #ifdef RUBY_EXTCONF_H
26 #include RUBY_EXTCONF_H
27 #endif
28
29 #include "defines.h"
30 #include "ruby/assert.h"
31
32 /* For MinGW, we need __declspec(dllimport) for RUBY_EXTERN on MJIT.
33 mswin's RUBY_EXTERN already has that. See also: win32/Makefile.sub */
34 #if defined(MJIT_HEADER) && defined(_WIN32) && defined(__GNUC__)
35 # undef RUBY_EXTERN
36 # define RUBY_EXTERN extern __declspec(dllimport)
37 #endif
38
39 #if defined(__cplusplus)
40 /* __builtin_choose_expr and __builtin_types_compatible aren't available
41 * on C++. See https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */
42 # undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P
43 # undef HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P
44 #elif GCC_VERSION_BEFORE(4,8,6) /* Bug #14221 */
45 # undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P
46 #endif
47
48 #ifndef ASSUME
49 # ifdef UNREACHABLE
50 # define ASSUME(x) (RB_LIKELY(!!(x)) ? (void)0 : UNREACHABLE)
51 # else
52 # define ASSUME(x) ((void)(x))
53 # endif
54 #endif
55 #ifndef UNREACHABLE_RETURN
56 # ifdef UNREACHABLE
57 # define UNREACHABLE_RETURN(val) UNREACHABLE
58 # else
59 # define UNREACHABLE_RETURN(val) return (val)
60 # endif
61 #endif
62 #ifndef UNREACHABLE
63 # define UNREACHABLE ((void)0) /* unreachable */
64 #endif
65
66 #define RUBY_MACRO_SELECT(base, n) TOKEN_PASTE(base, n)
67
68 #ifdef HAVE_INTRINSICS_H
69 # include <intrinsics.h>
70 #endif
71
72 #include <stdarg.h>
73
74 RUBY_SYMBOL_EXPORT_BEGIN
75
76 /* Make alloca work the best possible way. */
77 #ifdef __GNUC__
78 # ifndef alloca
79 # define alloca __builtin_alloca
80 # endif
81 #else
82 # ifdef HAVE_ALLOCA_H
83 # include <alloca.h>
84 # else
85 # ifdef _AIX
86 #pragma alloca
87 # else
88 # ifndef alloca /* predefined by HP cc +Olibcalls */
89 void *alloca();
90 # endif
91 # endif /* AIX */
92 # endif /* HAVE_ALLOCA_H */
93 #endif /* __GNUC__ */
94
95 #if defined HAVE_UINTPTR_T && 0
96 typedef uintptr_t VALUE;
97 typedef uintptr_t ID;
98 # define SIGNED_VALUE intptr_t
99 # define SIZEOF_VALUE SIZEOF_UINTPTR_T
100 # undef PRI_VALUE_PREFIX
101 #elif SIZEOF_LONG == SIZEOF_VOIDP
102 typedef unsigned long VALUE;
103 typedef unsigned long ID;
104 # define SIGNED_VALUE long
105 # define SIZEOF_VALUE SIZEOF_LONG
106 # define PRI_VALUE_PREFIX "l"
107 #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
108 typedef unsigned LONG_LONG VALUE;
109 typedef unsigned LONG_LONG ID;
110 # define SIGNED_VALUE LONG_LONG
111 # define LONG_LONG_VALUE 1
112 # define SIZEOF_VALUE SIZEOF_LONG_LONG
113 # define PRI_VALUE_PREFIX PRI_LL_PREFIX
114 #else
115 # error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
116 #endif
117
118 typedef char ruby_check_sizeof_int[SIZEOF_INT == sizeof(int) ? 1 : -1];
119 typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1];
120 #ifdef HAVE_LONG_LONG
121 typedef char ruby_check_sizeof_long_long[SIZEOF_LONG_LONG == sizeof(LONG_LONG) ? 1 : -1];
122 #endif
123 typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
124
125 #ifndef PRI_INT_PREFIX
126 #define PRI_INT_PREFIX ""
127 #endif
128 #ifndef PRI_LONG_PREFIX
129 #define PRI_LONG_PREFIX "l"
130 #endif
131 #ifndef PRI_SHORT_PREFIX
132 #define PRI_SHORT_PREFIX "h"
133 #endif
134
135 #ifndef PRI_64_PREFIX
136 #if SIZEOF_LONG == 8
137 #define PRI_64_PREFIX PRI_LONG_PREFIX
138 #elif SIZEOF_LONG_LONG == 8
139 #define PRI_64_PREFIX PRI_LL_PREFIX
140 #endif
141 #endif
142
143 #ifndef PRIdPTR
144 #define PRIdPTR PRI_PTR_PREFIX"d"
145 #define PRIiPTR PRI_PTR_PREFIX"i"
146 #define PRIoPTR PRI_PTR_PREFIX"o"
147 #define PRIuPTR PRI_PTR_PREFIX"u"
148 #define PRIxPTR PRI_PTR_PREFIX"x"
149 #define PRIXPTR PRI_PTR_PREFIX"X"
150 #endif
151
152 #define RUBY_PRI_VALUE_MARK "\v"
153 #if defined PRIdPTR && !defined PRI_VALUE_PREFIX
154 #define PRIdVALUE PRIdPTR
155 #define PRIoVALUE PRIoPTR
156 #define PRIuVALUE PRIuPTR
157 #define PRIxVALUE PRIxPTR
158 #define PRIXVALUE PRIXPTR
159 #define PRIsVALUE PRIiPTR"" RUBY_PRI_VALUE_MARK
160 #else
161 #define PRIdVALUE PRI_VALUE_PREFIX"d"
162 #define PRIoVALUE PRI_VALUE_PREFIX"o"
163 #define PRIuVALUE PRI_VALUE_PREFIX"u"
164 #define PRIxVALUE PRI_VALUE_PREFIX"x"
165 #define PRIXVALUE PRI_VALUE_PREFIX"X"
166 #define PRIsVALUE PRI_VALUE_PREFIX"i" RUBY_PRI_VALUE_MARK
167 #endif
168 #ifndef PRI_VALUE_PREFIX
169 # define PRI_VALUE_PREFIX ""
170 #endif
171
172 #ifndef PRI_TIMET_PREFIX
173 # if SIZEOF_TIME_T == SIZEOF_INT
174 # define PRI_TIMET_PREFIX
175 # elif SIZEOF_TIME_T == SIZEOF_LONG
176 # define PRI_TIMET_PREFIX "l"
177 # elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
178 # define PRI_TIMET_PREFIX PRI_LL_PREFIX
179 # endif
180 #endif
181
182 #if defined PRI_PTRDIFF_PREFIX
183 #elif SIZEOF_PTRDIFF_T == SIZEOF_INT
184 # define PRI_PTRDIFF_PREFIX ""
185 #elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
186 # define PRI_PTRDIFF_PREFIX "l"
187 #elif SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
188 # define PRI_PTRDIFF_PREFIX PRI_LL_PREFIX
189 #endif
190 #define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d"
191 #define PRIiPTRDIFF PRI_PTRDIFF_PREFIX"i"
192 #define PRIoPTRDIFF PRI_PTRDIFF_PREFIX"o"
193 #define PRIuPTRDIFF PRI_PTRDIFF_PREFIX"u"
194 #define PRIxPTRDIFF PRI_PTRDIFF_PREFIX"x"
195 #define PRIXPTRDIFF PRI_PTRDIFF_PREFIX"X"
196
197 #if defined PRI_SIZE_PREFIX
198 #elif SIZEOF_SIZE_T == SIZEOF_INT
199 # define PRI_SIZE_PREFIX ""
200 #elif SIZEOF_SIZE_T == SIZEOF_LONG
201 # define PRI_SIZE_PREFIX "l"
202 #elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
203 # define PRI_SIZE_PREFIX PRI_LL_PREFIX
204 #endif
205 #define PRIdSIZE PRI_SIZE_PREFIX"d"
206 #define PRIiSIZE PRI_SIZE_PREFIX"i"
207 #define PRIoSIZE PRI_SIZE_PREFIX"o"
208 #define PRIuSIZE PRI_SIZE_PREFIX"u"
209 #define PRIxSIZE PRI_SIZE_PREFIX"x"
210 #define PRIXSIZE PRI_SIZE_PREFIX"X"
211
212 #ifdef __STDC__
213 # include <limits.h>
214 #else
215 # ifndef LONG_MAX
216 # ifdef HAVE_LIMITS_H
217 # include <limits.h>
218 # else
219 /* assuming 32bit(2's complement) long */
220 # define LONG_MAX 2147483647
221 # endif
222 # endif
223 # ifndef LONG_MIN
224 # define LONG_MIN (-LONG_MAX-1)
225 # endif
226 # ifndef CHAR_BIT
227 # define CHAR_BIT 8
228 # endif
229 #endif
230
231 #ifdef HAVE_LONG_LONG
232 # ifndef LLONG_MAX
233 # ifdef LONG_LONG_MAX
234 # define LLONG_MAX LONG_LONG_MAX
235 # else
236 # ifdef _I64_MAX
237 # define LLONG_MAX _I64_MAX
238 # else
239 /* assuming 64bit(2's complement) long long */
240 # define LLONG_MAX 9223372036854775807LL
241 # endif
242 # endif
243 # endif
244 # ifndef LLONG_MIN
245 # ifdef LONG_LONG_MIN
246 # define LLONG_MIN LONG_LONG_MIN
247 # else
248 # ifdef _I64_MIN
249 # define LLONG_MIN _I64_MIN
250 # else
251 # define LLONG_MIN (-LLONG_MAX-1)
252 # endif
253 # endif
254 # endif
255 #endif
256
257 #define RUBY_FIXNUM_MAX (LONG_MAX>>1)
258 #define RUBY_FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
259 #define FIXNUM_MAX RUBY_FIXNUM_MAX
260 #define FIXNUM_MIN RUBY_FIXNUM_MIN
261
262 #define RB_INT2FIX(i) (((VALUE)(i))<<1 | RUBY_FIXNUM_FLAG)
263 #define INT2FIX(i) RB_INT2FIX(i)
264 #define RB_LONG2FIX(i) RB_INT2FIX(i)
265 #define LONG2FIX(i) RB_INT2FIX(i)
266 #define rb_fix_new(v) RB_INT2FIX(v)
267 VALUE rb_int2inum(intptr_t);
268
269 #define rb_int_new(v) rb_int2inum(v)
270 VALUE rb_uint2inum(uintptr_t);
271
272 #define rb_uint_new(v) rb_uint2inum(v)
273
274 #ifdef HAVE_LONG_LONG
275 VALUE rb_ll2inum(LONG_LONG);
276 #define LL2NUM(v) rb_ll2inum(v)
277 VALUE rb_ull2inum(unsigned LONG_LONG);
278 #define ULL2NUM(v) rb_ull2inum(v)
279 #endif
280
281 #ifndef OFFT2NUM
282 #if SIZEOF_OFF_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
283 # define OFFT2NUM(v) LL2NUM(v)
284 #elif SIZEOF_OFF_T == SIZEOF_LONG
285 # define OFFT2NUM(v) LONG2NUM(v)
286 #else
287 # define OFFT2NUM(v) INT2NUM(v)
288 #endif
289 #endif
290
291 #if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
292 # define SIZET2NUM(v) ULL2NUM(v)
293 # define SSIZET2NUM(v) LL2NUM(v)
294 #elif SIZEOF_SIZE_T == SIZEOF_LONG
295 # define SIZET2NUM(v) ULONG2NUM(v)
296 # define SSIZET2NUM(v) LONG2NUM(v)
297 #else
298 # define SIZET2NUM(v) UINT2NUM(v)
299 # define SSIZET2NUM(v) INT2NUM(v)
300 #endif
301
302 #ifndef SIZE_MAX
303 # if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
304 # define SIZE_MAX ULLONG_MAX
305 # define SIZE_MIN ULLONG_MIN
306 # elif SIZEOF_SIZE_T == SIZEOF_LONG
307 # define SIZE_MAX ULONG_MAX
308 # define SIZE_MIN ULONG_MIN
309 # elif SIZEOF_SIZE_T == SIZEOF_INT
310 # define SIZE_MAX UINT_MAX
311 # define SIZE_MIN UINT_MIN
312 # else
313 # define SIZE_MAX USHRT_MAX
314 # define SIZE_MIN USHRT_MIN
315 # endif
316 #endif
317
318 #ifndef SSIZE_MAX
319 # if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
320 # define SSIZE_MAX LLONG_MAX
321 # define SSIZE_MIN LLONG_MIN
322 # elif SIZEOF_SIZE_T == SIZEOF_LONG
323 # define SSIZE_MAX LONG_MAX
324 # define SSIZE_MIN LONG_MIN
325 # elif SIZEOF_SIZE_T == SIZEOF_INT
326 # define SSIZE_MAX INT_MAX
327 # define SSIZE_MIN INT_MIN
328 # else
329 # define SSIZE_MAX SHRT_MAX
330 # define SSIZE_MIN SHRT_MIN
331 # endif
332 #endif
333
334 #if SIZEOF_INT < SIZEOF_VALUE
335 NORETURN(void rb_out_of_int(SIGNED_VALUE num));
336 #endif
337
338 #if SIZEOF_INT < SIZEOF_LONG
339 static inline int
340 rb_long2int_inline(long n)
341 {
342 int i = (int)n;
343 if ((long)i != n)
344 rb_out_of_int(n);
345
346 return i;
347 }
348 #define rb_long2int(n) rb_long2int_inline(n)
349 #else
350 #define rb_long2int(n) ((int)(n))
351 #endif
352
353 #ifndef PIDT2NUM
354 #define PIDT2NUM(v) LONG2NUM(v)
355 #endif
356 #ifndef NUM2PIDT
357 #define NUM2PIDT(v) NUM2LONG(v)
358 #endif
359 #ifndef UIDT2NUM
360 #define UIDT2NUM(v) LONG2NUM(v)
361 #endif
362 #ifndef NUM2UIDT
363 #define NUM2UIDT(v) NUM2LONG(v)
364 #endif
365 #ifndef GIDT2NUM
366 #define GIDT2NUM(v) LONG2NUM(v)
367 #endif
368 #ifndef NUM2GIDT
369 #define NUM2GIDT(v) NUM2LONG(v)
370 #endif
371 #ifndef NUM2MODET
372 #define NUM2MODET(v) NUM2INT(v)
373 #endif
374 #ifndef MODET2NUM
375 #define MODET2NUM(v) INT2NUM(v)
376 #endif
377
378 #define RB_FIX2LONG(x) ((long)RSHIFT((SIGNED_VALUE)(x),1))
379 static inline long
380 rb_fix2long(VALUE x)
381 {
382 return RB_FIX2LONG(x);
383 }
384 #define RB_FIX2ULONG(x) ((unsigned long)RB_FIX2LONG(x))
385 static inline unsigned long
386 rb_fix2ulong(VALUE x)
387 {
388 return RB_FIX2ULONG(x);
389 }
390 #define RB_FIXNUM_P(f) (((int)(SIGNED_VALUE)(f))&RUBY_FIXNUM_FLAG)
391 #define RB_POSFIXABLE(f) ((f) < RUBY_FIXNUM_MAX+1)
392 #define RB_NEGFIXABLE(f) ((f) >= RUBY_FIXNUM_MIN)
393 #define RB_FIXABLE(f) (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f))
394 #define FIX2LONG(x) RB_FIX2LONG(x)
395 #define FIX2ULONG(x) RB_FIX2ULONG(x)
396 #define FIXNUM_P(f) RB_FIXNUM_P(f)
397 #define POSFIXABLE(f) RB_POSFIXABLE(f)
398 #define NEGFIXABLE(f) RB_NEGFIXABLE(f)
399 #define FIXABLE(f) RB_FIXABLE(f)
400
401 #define RB_IMMEDIATE_P(x) ((VALUE)(x) & RUBY_IMMEDIATE_MASK)
402 #define IMMEDIATE_P(x) RB_IMMEDIATE_P(x)
403
404 ID rb_sym2id(VALUE);
405 VALUE rb_id2sym(ID);
406 #define RB_STATIC_SYM_P(x) (((VALUE)(x)&~((~(VALUE)0)<<RUBY_SPECIAL_SHIFT)) == RUBY_SYMBOL_FLAG)
407 #define RB_DYNAMIC_SYM_P(x) (!RB_SPECIAL_CONST_P(x) && RB_BUILTIN_TYPE(x) == (RUBY_T_SYMBOL))
408 #define RB_SYMBOL_P(x) (RB_STATIC_SYM_P(x)||RB_DYNAMIC_SYM_P(x))
409 #define RB_ID2SYM(x) (rb_id2sym(x))
410 #define RB_SYM2ID(x) (rb_sym2id(x))
411 #define STATIC_SYM_P(x) RB_STATIC_SYM_P(x)
412 #define DYNAMIC_SYM_P(x) RB_DYNAMIC_SYM_P(x)
413 #define SYMBOL_P(x) RB_SYMBOL_P(x)
414 #define ID2SYM(x) RB_ID2SYM(x)
415 #define SYM2ID(x) RB_SYM2ID(x)
416
417 #ifndef USE_FLONUM
418 #if SIZEOF_VALUE >= SIZEOF_DOUBLE
419 #define USE_FLONUM 1
420 #else
421 #define USE_FLONUM 0
422 #endif
423 #endif
424
425 #if USE_FLONUM
426 #define RB_FLONUM_P(x) ((((int)(SIGNED_VALUE)(x))&RUBY_FLONUM_MASK) == RUBY_FLONUM_FLAG)
427 #else
428 #define RB_FLONUM_P(x) 0
429 #endif
430 #define FLONUM_P(x) RB_FLONUM_P(x)
431
432 /* Module#methods, #singleton_methods and so on return Symbols */
433 #define USE_SYMBOL_AS_METHOD_NAME 1
434
435 /* special constants - i.e. non-zero and non-fixnum constants */
436 enum ruby_special_consts {
437 #if USE_FLONUM
438 RUBY_Qfalse = 0x00, /* ...0000 0000 */
439 RUBY_Qtrue = 0x14, /* ...0001 0100 */
440 RUBY_Qnil = 0x08, /* ...0000 1000 */
441 RUBY_Qundef = 0x34, /* ...0011 0100 */
442
443 RUBY_IMMEDIATE_MASK = 0x07,
444 RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
445 RUBY_FLONUM_MASK = 0x03,
446 RUBY_FLONUM_FLAG = 0x02, /* ...xxxx xx10 */
447 RUBY_SYMBOL_FLAG = 0x0c, /* ...0000 1100 */
448 #else
449 RUBY_Qfalse = 0, /* ...0000 0000 */
450 RUBY_Qtrue = 2, /* ...0000 0010 */
451 RUBY_Qnil = 4, /* ...0000 0100 */
452 RUBY_Qundef = 6, /* ...0000 0110 */
453
454 RUBY_IMMEDIATE_MASK = 0x03,
455 RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
456 RUBY_FLONUM_MASK = 0x00, /* any values ANDed with FLONUM_MASK cannot be FLONUM_FLAG */
457 RUBY_FLONUM_FLAG = 0x02,
458 RUBY_SYMBOL_FLAG = 0x0e, /* ...0000 1110 */
459 #endif
460 RUBY_SPECIAL_SHIFT = 8
461 };
462
463 #define RUBY_Qfalse ((VALUE)RUBY_Qfalse)
464 #define RUBY_Qtrue ((VALUE)RUBY_Qtrue)
465 #define RUBY_Qnil ((VALUE)RUBY_Qnil)
466 #define RUBY_Qundef ((VALUE)RUBY_Qundef) /* undefined value for placeholder */
467 #define Qfalse RUBY_Qfalse
468 #define Qtrue RUBY_Qtrue
469 #define Qnil RUBY_Qnil
470 #define Qundef RUBY_Qundef
471 #define IMMEDIATE_MASK RUBY_IMMEDIATE_MASK
472 #define FIXNUM_FLAG RUBY_FIXNUM_FLAG
473 #if USE_FLONUM
474 #define FLONUM_MASK RUBY_FLONUM_MASK
475 #define FLONUM_FLAG RUBY_FLONUM_FLAG
476 #endif
477 #define SYMBOL_FLAG RUBY_SYMBOL_FLAG
478
479 #define RB_TEST(v) !(((VALUE)(v) & (VALUE)~RUBY_Qnil) == 0)
480 #define RB_NIL_P(v) !((VALUE)(v) != RUBY_Qnil)
481 #define RTEST(v) RB_TEST(v)
482 #define NIL_P(v) RB_NIL_P(v)
483
484 #define CLASS_OF(v) rb_class_of((VALUE)(v))
485
486 enum ruby_value_type {
487 RUBY_T_NONE = 0x00,
488
489 RUBY_T_OBJECT = 0x01,
490 RUBY_T_CLASS = 0x02,
491 RUBY_T_MODULE = 0x03,
492 RUBY_T_FLOAT = 0x04,
493 RUBY_T_STRING = 0x05,
494 RUBY_T_REGEXP = 0x06,
495 RUBY_T_ARRAY = 0x07,
496 RUBY_T_HASH = 0x08,
497 RUBY_T_STRUCT = 0x09,
498 RUBY_T_BIGNUM = 0x0a,
499 RUBY_T_FILE = 0x0b,
500 RUBY_T_DATA = 0x0c,
501 RUBY_T_MATCH = 0x0d,
502 RUBY_T_COMPLEX = 0x0e,
503 RUBY_T_RATIONAL = 0x0f,
504
505 RUBY_T_NIL = 0x11,
506 RUBY_T_TRUE = 0x12,
507 RUBY_T_FALSE = 0x13,
508 RUBY_T_SYMBOL = 0x14,
509 RUBY_T_FIXNUM = 0x15,
510 RUBY_T_UNDEF = 0x16,
511
512 RUBY_T_IMEMO = 0x1a,
513 RUBY_T_NODE = 0x1b,
514 RUBY_T_ICLASS = 0x1c,
515 RUBY_T_ZOMBIE = 0x1d,
516 RUBY_T_MOVED = 0x1e,
517
518 RUBY_T_MASK = 0x1f
519 };
520
521 #define T_NONE RUBY_T_NONE
522 #define T_NIL RUBY_T_NIL
523 #define T_OBJECT RUBY_T_OBJECT
524 #define T_CLASS RUBY_T_CLASS
525 #define T_ICLASS RUBY_T_ICLASS
526 #define T_MODULE RUBY_T_MODULE
527 #define T_FLOAT RUBY_T_FLOAT
528 #define T_STRING RUBY_T_STRING
529 #define T_REGEXP RUBY_T_REGEXP
530 #define T_ARRAY RUBY_T_ARRAY
531 #define T_HASH RUBY_T_HASH
532 #define T_STRUCT RUBY_T_STRUCT
533 #define T_BIGNUM RUBY_T_BIGNUM
534 #define T_FILE RUBY_T_FILE
535 #define T_FIXNUM RUBY_T_FIXNUM
536 #define T_TRUE RUBY_T_TRUE
537 #define T_FALSE RUBY_T_FALSE
538 #define T_DATA RUBY_T_DATA
539 #define T_MATCH RUBY_T_MATCH
540 #define T_SYMBOL RUBY_T_SYMBOL
541 #define T_RATIONAL RUBY_T_RATIONAL
542 #define T_COMPLEX RUBY_T_COMPLEX
543 #define T_IMEMO RUBY_T_IMEMO
544 #define T_UNDEF RUBY_T_UNDEF
545 #define T_NODE RUBY_T_NODE
546 #define T_ZOMBIE RUBY_T_ZOMBIE
547 #define T_MOVED RUBY_T_MOVED
548 #define T_MASK RUBY_T_MASK
549
550 #define RB_BUILTIN_TYPE(x) (int)(((struct RBasic*)(x))->flags & RUBY_T_MASK)
551 #define BUILTIN_TYPE(x) RB_BUILTIN_TYPE(x)
552
553 static inline int rb_type(VALUE obj);
554 #define TYPE(x) rb_type((VALUE)(x))
555
556 #define RB_FLOAT_TYPE_P(obj) (\
557 RB_FLONUM_P(obj) || \
558 (!RB_SPECIAL_CONST_P(obj) && RB_BUILTIN_TYPE(obj) == RUBY_T_FLOAT))
559
560 #define RB_TYPE_P(obj, type) ( \
561 ((type) == RUBY_T_FIXNUM) ? RB_FIXNUM_P(obj) : \
562 ((type) == RUBY_T_TRUE) ? ((obj) == RUBY_Qtrue) : \
563 ((type) == RUBY_T_FALSE) ? ((obj) == RUBY_Qfalse) : \
564 ((type) == RUBY_T_NIL) ? ((obj) == RUBY_Qnil) : \
565 ((type) == RUBY_T_UNDEF) ? ((obj) == RUBY_Qundef) : \
566 ((type) == RUBY_T_SYMBOL) ? RB_SYMBOL_P(obj) : \
567 ((type) == RUBY_T_FLOAT) ? RB_FLOAT_TYPE_P(obj) : \
568 (!RB_SPECIAL_CONST_P(obj) && RB_BUILTIN_TYPE(obj) == (type)))
569
570 #ifdef __GNUC__
571 #define RB_GC_GUARD(v) \
572 (*__extension__ ({ \
573 volatile VALUE *rb_gc_guarded_ptr = &(v); \
574 __asm__("" : : "m"(rb_gc_guarded_ptr)); \
575 rb_gc_guarded_ptr; \
576 }))
577 #elif defined _MSC_VER
578 #pragma optimize("", off)
579 static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;}
580 #pragma optimize("", on)
581 #define RB_GC_GUARD(v) (*rb_gc_guarded_ptr(&(v)))
582 #else
583 volatile VALUE *rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val);
584 #define HAVE_RB_GC_GUARDED_PTR_VAL 1
585 #define RB_GC_GUARD(v) (*rb_gc_guarded_ptr_val(&(v),(v)))
586 #endif
587
588 #ifdef __GNUC__
589 #define RB_UNUSED_VAR(x) x __attribute__ ((unused))
590 #else
591 #define RB_UNUSED_VAR(x) x
592 #endif
593
594 void rb_check_type(VALUE,int);
595 #define Check_Type(v,t) rb_check_type((VALUE)(v),(t))
596
597 VALUE rb_str_to_str(VALUE);
598 VALUE rb_string_value(volatile VALUE*);
599 char *rb_string_value_ptr(volatile VALUE*);
600 char *rb_string_value_cstr(volatile VALUE*);
601
602 #define StringValue(v) rb_string_value(&(v))
603 #define StringValuePtr(v) rb_string_value_ptr(&(v))
604 #define StringValueCStr(v) rb_string_value_cstr(&(v))
605
606 void rb_check_safe_obj(VALUE);
607 #define SafeStringValue(v) StringValue(v)
608 #if GCC_VERSION_SINCE(4,4,0)
609 void rb_check_safe_str(VALUE) __attribute__((error("rb_check_safe_str() and Check_SafeStr() are obsolete; use StringValue() instead")));
610 # define Check_SafeStr(v) rb_check_safe_str((VALUE)(v))
611 #else
612 # define rb_check_safe_str(x) [<"rb_check_safe_str() is obsolete; use StringValue() instead">]
613 # define Check_SafeStr(v) [<"Check_SafeStr() is obsolete; use StringValue() instead">]
614 #endif
615
616 VALUE rb_str_export(VALUE);
617 #define ExportStringValue(v) do {\
618 StringValue(v);\
619 (v) = rb_str_export(v);\
620 } while (0)
621 VALUE rb_str_export_locale(VALUE);
622
623 VALUE rb_get_path(VALUE);
624 #define FilePathValue(v) (RB_GC_GUARD(v) = rb_get_path(v))
625
626 VALUE rb_get_path_no_checksafe(VALUE);
627 #define FilePathStringValue(v) ((v) = rb_get_path(v))
628
629 /* Remove in 3.0 */
630 #define RUBY_SAFE_LEVEL_MAX 1
631 void rb_secure(int);
632 int rb_safe_level(void);
633 void rb_set_safe_level(int);
634 #if GCC_VERSION_SINCE(4,4,0)
635 int ruby_safe_level_2_error(void) __attribute__((error("$SAFE=2 to 4 are obsolete")));
636 int ruby_safe_level_2_warning(void) __attribute__((const,warning("$SAFE=2 to 4 are obsolete")));
637 # ifdef RUBY_EXPORT
638 # define ruby_safe_level_2_warning() ruby_safe_level_2_error()
639 # endif
640 # if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
641 # define RUBY_SAFE_LEVEL_INVALID_P(level) \
642 __extension__(\
643 __builtin_choose_expr(\
644 __builtin_constant_p(level), \
645 ((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level)), 0))
646 # define RUBY_SAFE_LEVEL_CHECK(level, type) \
647 __extension__(__builtin_choose_expr(RUBY_SAFE_LEVEL_INVALID_P(level), ruby_safe_level_2_##type(), (level)))
648 # else
649 /* in gcc 4.8 or earlier, __builtin_choose_expr() does not consider
650 * __builtin_constant_p(variable) a constant expression.
651 */
652 # define RUBY_SAFE_LEVEL_INVALID_P(level) \
653 __extension__(__builtin_constant_p(level) && \
654 ((level) < 0 || RUBY_SAFE_LEVEL_MAX < (level)))
655 # define RUBY_SAFE_LEVEL_CHECK(level, type) \
656 (RUBY_SAFE_LEVEL_INVALID_P(level) ? ruby_safe_level_2_##type() : (level))
657 # endif
658 # define rb_secure(level) rb_secure(RUBY_SAFE_LEVEL_CHECK(level, warning))
659 # define rb_set_safe_level(level) rb_set_safe_level(RUBY_SAFE_LEVEL_CHECK(level, error))
660 #endif
661 void rb_set_safe_level_force(int);
662 void rb_secure_update(VALUE);
663 NORETURN(void rb_insecure_operation(void));
664
665 VALUE rb_errinfo(void);
666 void rb_set_errinfo(VALUE);
667
668 long rb_num2long(VALUE);
669 unsigned long rb_num2ulong(VALUE);
670 static inline long
671 rb_num2long_inline(VALUE x)
672 {
673 if (RB_FIXNUM_P(x))
674 return RB_FIX2LONG(x);
675 else
676 return rb_num2long(x);
677 }
678 #define RB_NUM2LONG(x) rb_num2long_inline(x)
679 #define NUM2LONG(x) RB_NUM2LONG(x)
680 static inline unsigned long
681 rb_num2ulong_inline(VALUE x)
682 {
683 if (RB_FIXNUM_P(x))
684 return RB_FIX2ULONG(x);
685 else
686 return rb_num2ulong(x);
687 }
688 #define RB_NUM2ULONG(x) rb_num2ulong_inline(x)
689 #define NUM2ULONG(x) RB_NUM2ULONG(x)
690 #if SIZEOF_INT < SIZEOF_LONG
691 long rb_num2int(VALUE);
692 long rb_fix2int(VALUE);
693 #define RB_FIX2INT(x) ((int)rb_fix2int((VALUE)(x)))
694
695 static inline int
696 rb_num2int_inline(VALUE x)
697 {
698 if (RB_FIXNUM_P(x))
699 return (int)rb_fix2int(x);
700 else
701 return (int)rb_num2int(x);
702 }
703 #define RB_NUM2INT(x) rb_num2int_inline(x)
704
705 unsigned long rb_num2uint(VALUE);
706 #define RB_NUM2UINT(x) ((unsigned int)rb_num2uint(x))
707 unsigned long rb_fix2uint(VALUE);
708 #define RB_FIX2UINT(x) ((unsigned int)rb_fix2uint(x))
709 #else /* SIZEOF_INT < SIZEOF_LONG */
710 #define RB_NUM2INT(x) ((int)RB_NUM2LONG(x))
711 #define RB_NUM2UINT(x) ((unsigned int)RB_NUM2ULONG(x))
712 #define RB_FIX2INT(x) ((int)RB_FIX2LONG(x))
713 #define RB_FIX2UINT(x) ((unsigned int)RB_FIX2ULONG(x))
714 #endif /* SIZEOF_INT < SIZEOF_LONG */
715 #define NUM2INT(x) RB_NUM2INT(x)
716 #define NUM2UINT(x) RB_NUM2UINT(x)
717 #define FIX2INT(x) RB_FIX2INT(x)
718 #define FIX2UINT(x) RB_FIX2UINT(x)
719
720 short rb_num2short(VALUE);
721 unsigned short rb_num2ushort(VALUE);
722 short rb_fix2short(VALUE);
723 unsigned short rb_fix2ushort(VALUE);
724 #define RB_FIX2SHORT(x) (rb_fix2short((VALUE)(x)))
725 #define FIX2SHORT(x) RB_FIX2SHORT(x)
726 static inline short
727 rb_num2short_inline(VALUE x)
728 {
729 if (RB_FIXNUM_P(x))
730 return rb_fix2short(x);
731 else
732 return rb_num2short(x);
733 }
734
735 #define RB_NUM2SHORT(x) rb_num2short_inline(x)
736 #define RB_NUM2USHORT(x) rb_num2ushort(x)
737 #define NUM2SHORT(x) RB_NUM2SHORT(x)
738 #define NUM2USHORT(x) RB_NUM2USHORT(x)
739
740 #ifdef HAVE_LONG_LONG
741 LONG_LONG rb_num2ll(VALUE);
742 unsigned LONG_LONG rb_num2ull(VALUE);
743 static inline LONG_LONG
744 rb_num2ll_inline(VALUE x)
745 {
746 if (RB_FIXNUM_P(x))
747 return RB_FIX2LONG(x);
748 else
749 return rb_num2ll(x);
750 }
751 # define RB_NUM2LL(x) rb_num2ll_inline(x)
752 # define RB_NUM2ULL(x) rb_num2ull(x)
753 # define NUM2LL(x) RB_NUM2LL(x)
754 # define NUM2ULL(x) RB_NUM2ULL(x)
755 #endif
756
757 #if !defined(NUM2OFFT)
758 # if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T > SIZEOF_LONG
759 # define NUM2OFFT(x) ((off_t)NUM2LL(x))
760 # else
761 # define NUM2OFFT(x) NUM2LONG(x)
762 # endif
763 #endif
764
765 #if defined(HAVE_LONG_LONG) && SIZEOF_SIZE_T > SIZEOF_LONG
766 # define NUM2SIZET(x) ((size_t)NUM2ULL(x))
767 # define NUM2SSIZET(x) ((ssize_t)NUM2LL(x))
768 #else
769 # define NUM2SIZET(x) NUM2ULONG(x)
770 # define NUM2SSIZET(x) NUM2LONG(x)
771 #endif
772
773 double rb_num2dbl(VALUE);
774 #define NUM2DBL(x) rb_num2dbl((VALUE)(x))
775
776 VALUE rb_uint2big(uintptr_t);
777 VALUE rb_int2big(intptr_t);
778
779 VALUE rb_newobj(void);
780 VALUE rb_newobj_of(VALUE, VALUE);
781 VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type);
782 #define RB_NEWOBJ(obj,type) type *(obj) = (type*)rb_newobj()
783 #define RB_NEWOBJ_OF(obj,type,klass,flags) type *(obj) = (type*)rb_newobj_of(klass, flags)
784 #define NEWOBJ(obj,type) RB_NEWOBJ(obj,type)
785 #define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags) /* core has special NEWOBJ_OF() in internal.h */
786 #define OBJSETUP(obj,c,t) rb_obj_setup(obj, c, t) /* use NEWOBJ_OF instead of NEWOBJ()+OBJSETUP() */
787 #define CLONESETUP(clone,obj) rb_clone_setup(clone,obj)
788 #define DUPSETUP(dup,obj) rb_dup_setup(dup,obj)
789
790 #ifndef USE_RGENGC
791 #define USE_RGENGC 1
792 #ifndef USE_RINCGC
793 #define USE_RINCGC 1
794 #endif
795 #endif
796
797 #if USE_RGENGC == 0
798 #define USE_RINCGC 0
799 #endif
800
801 #ifndef RGENGC_WB_PROTECTED_ARRAY
802 #define RGENGC_WB_PROTECTED_ARRAY 1
803 #endif
804 #ifndef RGENGC_WB_PROTECTED_HASH
805 #define RGENGC_WB_PROTECTED_HASH 1
806 #endif
807 #ifndef RGENGC_WB_PROTECTED_STRUCT
808 #define RGENGC_WB_PROTECTED_STRUCT 1
809 #endif
810 #ifndef RGENGC_WB_PROTECTED_STRING
811 #define RGENGC_WB_PROTECTED_STRING 1
812 #endif
813 #ifndef RGENGC_WB_PROTECTED_OBJECT
814 #define RGENGC_WB_PROTECTED_OBJECT 1
815 #endif
816 #ifndef RGENGC_WB_PROTECTED_REGEXP
817 #define RGENGC_WB_PROTECTED_REGEXP 1
818 #endif
819 #ifndef RGENGC_WB_PROTECTED_CLASS
820 #define RGENGC_WB_PROTECTED_CLASS 1
821 #endif
822 #ifndef RGENGC_WB_PROTECTED_FLOAT
823 #define RGENGC_WB_PROTECTED_FLOAT 1
824 #endif
825 #ifndef RGENGC_WB_PROTECTED_COMPLEX
826 #define RGENGC_WB_PROTECTED_COMPLEX 1
827 #endif
828 #ifndef RGENGC_WB_PROTECTED_RATIONAL
829 #define RGENGC_WB_PROTECTED_RATIONAL 1
830 #endif
831 #ifndef RGENGC_WB_PROTECTED_BIGNUM
832 #define RGENGC_WB_PROTECTED_BIGNUM 1
833 #endif
834 #ifndef RGENGC_WB_PROTECTED_NODE_CREF
835 #define RGENGC_WB_PROTECTED_NODE_CREF 1
836 #endif
837
838 #ifdef __GNUC__
839 __extension__
840 #endif
841 enum ruby_fl_type {
842 RUBY_FL_WB_PROTECTED = (1<<5),
843 RUBY_FL_PROMOTED0 = (1<<5),
844 RUBY_FL_PROMOTED1 = (1<<6),
845 RUBY_FL_PROMOTED = RUBY_FL_PROMOTED0|RUBY_FL_PROMOTED1,
846 RUBY_FL_FINALIZE = (1<<7),
847 RUBY_FL_TAINT = (1<<8),
848 RUBY_FL_UNTRUSTED = RUBY_FL_TAINT,
849 RUBY_FL_SEEN_OBJ_ID = (1<<9),
850 RUBY_FL_EXIVAR = (1<<10),
851 RUBY_FL_FREEZE = (1<<11),
852
853 RUBY_FL_USHIFT = 12,
854
855 #define RUBY_FL_USER_N(n) RUBY_FL_USER##n = (1<<(RUBY_FL_USHIFT+n))
856 RUBY_FL_USER_N(0),
857 RUBY_FL_USER_N(1),
858 RUBY_FL_USER_N(2),
859 RUBY_FL_USER_N(3),
860 RUBY_FL_USER_N(4),
861 RUBY_FL_USER_N(5),
862 RUBY_FL_USER_N(6),
863 RUBY_FL_USER_N(7),
864 RUBY_FL_USER_N(8),
865 RUBY_FL_USER_N(9),
866 RUBY_FL_USER_N(10),
867 RUBY_FL_USER_N(11),
868 RUBY_FL_USER_N(12),
869 RUBY_FL_USER_N(13),
870 RUBY_FL_USER_N(14),
871 RUBY_FL_USER_N(15),
872 RUBY_FL_USER_N(16),
873 RUBY_FL_USER_N(17),
874 RUBY_FL_USER_N(18),
875 #if defined ENUM_OVER_INT || SIZEOF_INT*CHAR_BIT>12+19+1
876 RUBY_FL_USER_N(19),
877 #else
878 #define RUBY_FL_USER19 (((VALUE)1)<<(RUBY_FL_USHIFT+19))
879 #endif
880
881 RUBY_ELTS_SHARED = RUBY_FL_USER2,
882 RUBY_FL_DUPPED = (RUBY_T_MASK|RUBY_FL_EXIVAR|RUBY_FL_TAINT),
883 RUBY_FL_SINGLETON = RUBY_FL_USER0
884 };
885
886 struct RUBY_ALIGNAS(SIZEOF_VALUE) RBasic {
887 VALUE flags;
888 const VALUE klass;
889 };
890
891 VALUE rb_obj_hide(VALUE obj);
892 VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change klass information */
893
894 #if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
895 # define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
896 __extension__( \
897 __builtin_choose_expr( \
898 RGENGC_WB_PROTECTED_##type, \
899 OBJ_WB_UNPROTECT((VALUE)(obj)), ((VALUE)(obj))))
900 #else
901 # define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
902 (RGENGC_WB_PROTECTED_##type ? \
903 OBJ_WB_UNPROTECT((VALUE)(obj)) : ((VALUE)(obj)))
904 #endif
905
906 #define RBASIC_CLASS(obj) (RBASIC(obj)->klass)
907
908 #define RVALUE_EMBED_LEN_MAX RVALUE_EMBED_LEN_MAX
909 enum ruby_rvalue_flags {
910 RVALUE_EMBED_LEN_MAX = 3,
911 };
912
913 #define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
914 #define ROBJECT_EMBED ROBJECT_EMBED
915 enum ruby_robject_flags {
916 ROBJECT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
917 ROBJECT_EMBED = RUBY_FL_USER1,
918
919 ROBJECT_ENUM_END
920 };
921
922 struct RObject {
923 struct RBasic basic;
924 union {
925 struct {
926 uint32_t numiv;
927 VALUE *ivptr;
928 void *iv_index_tbl; /* shortcut for RCLASS_IV_INDEX_TBL(rb_obj_class(obj)) */
929 } heap;
930 VALUE ary[ROBJECT_EMBED_LEN_MAX];
931 } as;
932 };
933 #define ROBJECT_NUMIV(o) \
934 ((RBASIC(o)->flags & ROBJECT_EMBED) ? \
935 ROBJECT_EMBED_LEN_MAX : \
936 ROBJECT(o)->as.heap.numiv)
937 #define ROBJECT_IVPTR(o) \
938 ((RBASIC(o)->flags & ROBJECT_EMBED) ? \
939 ROBJECT(o)->as.ary : \
940 ROBJECT(o)->as.heap.ivptr)
941 #define ROBJECT_IV_INDEX_TBL(o) \
942 ((RBASIC(o)->flags & ROBJECT_EMBED) ? \
943 RCLASS_IV_INDEX_TBL(rb_obj_class(o)) : \
944 ROBJECT(o)->as.heap.iv_index_tbl)
945
946 #define RCLASS_SUPER(c) rb_class_get_superclass(c)
947 #define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m)
948 #define RMODULE_CONST_TBL(m) RCLASS_CONST_TBL(m)
949 #define RMODULE_M_TBL(m) RCLASS_M_TBL(m)
950 #define RMODULE_SUPER(m) RCLASS_SUPER(m)
951 #define RMODULE_IS_OVERLAID RMODULE_IS_OVERLAID
952 #define RMODULE_IS_REFINEMENT RMODULE_IS_REFINEMENT
953 #define RMODULE_INCLUDED_INTO_REFINEMENT RMODULE_INCLUDED_INTO_REFINEMENT
954 enum ruby_rmodule_flags {
955 RMODULE_IS_OVERLAID = RUBY_FL_USER2,
956 RMODULE_IS_REFINEMENT = RUBY_FL_USER3,
957 RMODULE_INCLUDED_INTO_REFINEMENT = RUBY_FL_USER4,
958
959 RMODULE_ENUM_END
960 };
961
962 PUREFUNC(double rb_float_value(VALUE));
963 VALUE rb_float_new(double);
964 VALUE rb_float_new_in_heap(double);
965
966 #define RFLOAT_VALUE(v) rb_float_value(v)
967 #define DBL2NUM(dbl) rb_float_new(dbl)
968
969 #define RUBY_ELTS_SHARED RUBY_ELTS_SHARED
970 #define ELTS_SHARED RUBY_ELTS_SHARED
971
972 #define RSTRING_NOEMBED RSTRING_NOEMBED
973 #define RSTRING_EMBED_LEN_MASK RSTRING_EMBED_LEN_MASK
974 #define RSTRING_EMBED_LEN_SHIFT RSTRING_EMBED_LEN_SHIFT
975 #define RSTRING_EMBED_LEN_MAX RSTRING_EMBED_LEN_MAX
976 #define RSTRING_FSTR RSTRING_FSTR
977 enum ruby_rstring_flags {
978 RSTRING_NOEMBED = RUBY_FL_USER1,
979 RSTRING_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|
980 RUBY_FL_USER5|RUBY_FL_USER6),
981 RSTRING_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+2),
982 RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*RVALUE_EMBED_LEN_MAX)/sizeof(char)-1),
983 RSTRING_FSTR = RUBY_FL_USER17,
984
985 RSTRING_ENUM_END
986 };
987
988 struct RString {
989 struct RBasic basic;
990 union {
991 struct {
992 long len;
993 char *ptr;
994 union {
995 long capa;
996 VALUE shared;
997 } aux;
998 } heap;
999 char ary[RSTRING_EMBED_LEN_MAX + 1];
1000 } as;
1001 };
1002 #define RSTRING_EMBED_LEN(str) \
1003 (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \
1004 (RSTRING_EMBED_LEN_MASK >> RSTRING_EMBED_LEN_SHIFT))
1005 #define RSTRING_LEN(str) \
1006 (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
1007 RSTRING_EMBED_LEN(str) : \
1008 RSTRING(str)->as.heap.len)
1009 #define RSTRING_PTR(str) \
1010 (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
1011 RSTRING(str)->as.ary : \
1012 RSTRING(str)->as.heap.ptr)
1013 #define RSTRING_END(str) \
1014 (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
1015 (RSTRING(str)->as.ary + RSTRING_EMBED_LEN(str)) : \
1016 (RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len))
1017 #define RSTRING_LENINT(str) rb_long2int(RSTRING_LEN(str))
1018 #define RSTRING_GETMEM(str, ptrvar, lenvar) \
1019 (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
1020 ((ptrvar) = RSTRING(str)->as.ary, (lenvar) = RSTRING_EMBED_LEN(str)) : \
1021 ((ptrvar) = RSTRING(str)->as.heap.ptr, (lenvar) = RSTRING(str)->as.heap.len))
1022
1023 #ifndef USE_TRANSIENT_HEAP
1024 #define USE_TRANSIENT_HEAP 1
1025 #endif
1026
1027 enum ruby_rarray_flags {
1028 RARRAY_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
1029 RARRAY_EMBED_FLAG = RUBY_FL_USER1,
1030 /* RUBY_FL_USER2 is for ELTS_SHARED */
1031 RARRAY_EMBED_LEN_MASK = (RUBY_FL_USER4|RUBY_FL_USER3),
1032 RARRAY_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+3),
1033
1034 #if USE_TRANSIENT_HEAP
1035 RARRAY_TRANSIENT_FLAG = RUBY_FL_USER13,
1036 #define RARRAY_TRANSIENT_FLAG RARRAY_TRANSIENT_FLAG
1037 #else
1038 #define RARRAY_TRANSIENT_FLAG 0
1039 #endif
1040
1041 RARRAY_ENUM_END
1042 };
1043 #define RARRAY_EMBED_FLAG (VALUE)RARRAY_EMBED_FLAG
1044 #define RARRAY_EMBED_LEN_MASK (VALUE)RARRAY_EMBED_LEN_MASK
1045 #define RARRAY_EMBED_LEN_MAX RARRAY_EMBED_LEN_MAX
1046 #define RARRAY_EMBED_LEN_SHIFT RARRAY_EMBED_LEN_SHIFT
1047
1048 struct RArray {
1049 struct RBasic basic;
1050 union {
1051 struct {
1052 long len;
1053 union {
1054 long capa;
1055 #if defined(__clang__) /* <- clang++ is sane */ || \
1056 !defined(__cplusplus) /* <- C99 is sane */ || \
1057 (__cplusplus > 199711L) /* <- C++11 is sane */
1058 const
1059 #endif
1060 VALUE shared_root;
1061 } aux;
1062 const VALUE *ptr;
1063 } heap;
1064 const VALUE ary[RARRAY_EMBED_LEN_MAX];
1065 } as;
1066 };
1067 #define RARRAY_EMBED_LEN(a) \
1068 (long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
1069 (RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT))
1070 #define RARRAY_LEN(a) rb_array_len(a)
1071 #define RARRAY_LENINT(ary) rb_long2int(RARRAY_LEN(ary))
1072 #define RARRAY_CONST_PTR(a) rb_array_const_ptr(a)
1073 #define RARRAY_CONST_PTR_TRANSIENT(a) rb_array_const_ptr_transient(a)
1074
1075 #if USE_TRANSIENT_HEAP
1076 #define RARRAY_TRANSIENT_P(ary) FL_TEST_RAW((ary), RARRAY_TRANSIENT_FLAG)
1077 #else
1078 #define RARRAY_TRANSIENT_P(ary) 0
1079 #endif
1080
1081 #define RARRAY_PTR_USE_START_TRANSIENT(a) rb_array_ptr_use_start(a, 1)
1082 #define RARRAY_PTR_USE_END_TRANSIENT(a) rb_array_ptr_use_end(a, 1)
1083
1084 #define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr) do { \
1085 const VALUE _ary = (ary); \
1086 VALUE *ptr_name = (VALUE *)RARRAY_PTR_USE_START_TRANSIENT(_ary); \
1087 expr; \
1088 RARRAY_PTR_USE_END_TRANSIENT(_ary); \
1089 } while (0)
1090
1091 #define RARRAY_PTR_USE_START(a) rb_array_ptr_use_start(a, 0)
1092 #define RARRAY_PTR_USE_END(a) rb_array_ptr_use_end(a, 0)
1093
1094 #define RARRAY_PTR_USE(ary, ptr_name, expr) do { \
1095 const VALUE _ary = (ary); \
1096 VALUE *ptr_name = (VALUE *)RARRAY_PTR_USE_START(_ary); \
1097 expr; \
1098 RARRAY_PTR_USE_END(_ary); \
1099 } while (0)
1100
1101 #define RARRAY_AREF(a, i) (RARRAY_CONST_PTR_TRANSIENT(a)[i])
1102 #define RARRAY_ASET(a, i, v) do { \
1103 const VALUE _ary = (a); \
1104 const VALUE _v = (v); \
1105 VALUE *ptr = (VALUE *)RARRAY_PTR_USE_START_TRANSIENT(_ary); \
1106 RB_OBJ_WRITE(_ary, &ptr[i], _v); \
1107 RARRAY_PTR_USE_END_TRANSIENT(_ary); \
1108 } while (0)
1109
1110 #define RARRAY_PTR(a) ((VALUE *)RARRAY_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(ARRAY, a)))
1111
1112 struct RRegexp {
1113 struct RBasic basic;
1114 struct re_pattern_buffer *ptr;
1115 const VALUE src;
1116 unsigned long usecnt;
1117 };
1118 #define RREGEXP_PTR(r) (RREGEXP(r)->ptr)
1119 #define RREGEXP_SRC(r) (RREGEXP(r)->src)
1120 #define RREGEXP_SRC_PTR(r) RSTRING_PTR(RREGEXP(r)->src)
1121 #define RREGEXP_SRC_LEN(r) RSTRING_LEN(RREGEXP(r)->src)
1122 #define RREGEXP_SRC_END(r) RSTRING_END(RREGEXP(r)->src)
1123
1124 /* RHash is defined at internal.h */
1125 size_t rb_hash_size_num(VALUE hash);
1126
1127 #define RHASH_TBL(h) rb_hash_tbl(h, __FILE__, __LINE__)
1128 #define RHASH_ITER_LEV(h) rb_hash_iter_lev(h)
1129 #define RHASH_IFNONE(h) rb_hash_ifnone(h)
1130 #define RHASH_SIZE(h) rb_hash_size_num(h)
1131 #define RHASH_EMPTY_P(h) (RHASH_SIZE(h) == 0)
1132 #define RHASH_SET_IFNONE(h, ifnone) rb_hash_set_ifnone((VALUE)h, ifnone)
1133
1134 struct RFile {
1135 struct RBasic basic;
1136 struct rb_io_t *fptr;
1137 };
1138
1139 struct RData {
1140 struct RBasic basic;
1141 void (*dmark)(void*);
1142 void (*dfree)(void*);
1143 void *data;
1144 };
1145
1146 typedef struct rb_data_type_struct rb_data_type_t;
1147
1148 struct rb_data_type_struct {
1149 const char *wrap_struct_name;
1150 struct {
1151 void (*dmark)(void*);
1152 void (*dfree)(void*);
1153 size_t (*dsize)(const void *);
1154 void (*dcompact)(void*);
1155 void *reserved[1]; /* For future extension.
1156 This array *must* be filled with ZERO. */
1157 } function;
1158 const rb_data_type_t *parent;
1159 void *data; /* This area can be used for any purpose
1160 by a programmer who define the type. */
1161 VALUE flags; /* RUBY_FL_WB_PROTECTED */
1162 };
1163
1164 #define HAVE_TYPE_RB_DATA_TYPE_T 1
1165 #define HAVE_RB_DATA_TYPE_T_FUNCTION 1
1166 #define HAVE_RB_DATA_TYPE_T_PARENT 1
1167
1168 struct RTypedData {
1169 struct RBasic basic;
1170 const rb_data_type_t *type;
1171 VALUE typed_flag; /* 1 or not */
1172 void *data;
1173 };
1174
1175 #define DATA_PTR(dta) (RDATA(dta)->data)
1176
1177 #define RTYPEDDATA_P(v) (RTYPEDDATA(v)->typed_flag == 1)
1178 #define RTYPEDDATA_TYPE(v) (RTYPEDDATA(v)->type)
1179 #define RTYPEDDATA_DATA(v) (RTYPEDDATA(v)->data)
1180
1181 /*
1182 #define RUBY_DATA_FUNC(func) ((void (*)(void*))(func))
1183 */
1184 typedef void (*RUBY_DATA_FUNC)(void*);
1185
1186 #ifndef RUBY_UNTYPED_DATA_WARNING
1187 # if defined RUBY_EXPORT
1188 # define RUBY_UNTYPED_DATA_WARNING 1
1189 # else
1190 # define RUBY_UNTYPED_DATA_WARNING 0
1191 # endif
1192 #endif
1193 VALUE rb_data_object_wrap(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
1194 VALUE rb_data_object_zalloc(VALUE,size_t,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
1195 VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *);
1196 VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type);
1197 int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent);
1198 int rb_typeddata_is_kind_of(VALUE, const rb_data_type_t *);
1199 void *rb_check_typeddata(VALUE, const rb_data_type_t *);
1200 #define Check_TypedStruct(v,t) rb_check_typeddata((VALUE)(v),(t))
1201 #define RUBY_DEFAULT_FREE ((RUBY_DATA_FUNC)-1)
1202 #define RUBY_NEVER_FREE ((RUBY_DATA_FUNC)0)
1203 #define RUBY_TYPED_DEFAULT_FREE RUBY_DEFAULT_FREE
1204 #define RUBY_TYPED_NEVER_FREE RUBY_NEVER_FREE
1205
1206 /* bits for rb_data_type_struct::flags */
1207 #define RUBY_TYPED_FREE_IMMEDIATELY 1 /* TYPE field */
1208 #define RUBY_TYPED_WB_PROTECTED RUBY_FL_WB_PROTECTED /* THIS FLAG DEPENDS ON Ruby version */
1209 #define RUBY_TYPED_PROMOTED1 RUBY_FL_PROMOTED1 /* THIS FLAG DEPENDS ON Ruby version */
1210
1211 #define Data_Wrap_Struct(klass,mark,free,sval)\
1212 rb_data_object_wrap((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
1213
1214 #define Data_Make_Struct0(result, klass, type, size, mark, free, sval) \
1215 VALUE result = rb_data_object_zalloc((klass), (size), \
1216 (RUBY_DATA_FUNC)(mark), \
1217 (RUBY_DATA_FUNC)(free)); \
1218 (void)((sval) = (type *)DATA_PTR(result));
1219
1220 #ifdef __GNUC__
1221 #define Data_Make_Struct(klass,type,mark,free,sval) RB_GNUC_EXTENSION_BLOCK(\
1222 Data_Make_Struct0(data_struct_obj, klass, type, sizeof(type), mark, free, sval); \
1223 data_struct_obj \
1224 )
1225 #else
1226 #define Data_Make_Struct(klass,type,mark,free,sval) (\
1227 rb_data_object_make((klass),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free),(void **)&(sval),sizeof(type)) \
1228 )
1229 #endif
1230
1231 #define TypedData_Wrap_Struct(klass,data_type,sval)\
1232 rb_data_typed_object_wrap((klass),(sval),(data_type))
1233
1234 #define TypedData_Make_Struct0(result, klass, type, size, data_type, sval) \
1235 VALUE result = rb_data_typed_object_zalloc(klass, size, data_type); \
1236 (void)((sval) = (type *)DATA_PTR(result));
1237
1238 #ifdef __GNUC__
1239 #define TypedData_Make_Struct(klass, type, data_type, sval) RB_GNUC_EXTENSION_BLOCK(\
1240 TypedData_Make_Struct0(data_struct_obj, klass, type, sizeof(type), data_type, sval); \
1241 data_struct_obj \
1242 )
1243 #else
1244 #define TypedData_Make_Struct(klass, type, data_type, sval) (\
1245 rb_data_typed_object_make((klass),(data_type),(void **)&(sval),sizeof(type)) \
1246 )
1247 #endif
1248
1249 #define Data_Get_Struct(obj,type,sval) \
1250 ((sval) = (type*)rb_data_object_get(obj))
1251
1252 #define TypedData_Get_Struct(obj,type,data_type,sval) \
1253 ((sval) = (type*)rb_check_typeddata((obj), (data_type)))
1254
1255 #define RSTRUCT_LEN(st) NUM2LONG(rb_struct_size(st))
1256 #define RSTRUCT_PTR(st) rb_struct_ptr(st)
1257 #define RSTRUCT_SET(st, idx, v) rb_struct_aset(st, INT2NUM(idx), (v))
1258 #define RSTRUCT_GET(st, idx) rb_struct_aref(st, INT2NUM(idx))
1259
1260 int rb_big_sign(VALUE);
1261 #define RBIGNUM_SIGN(b) (rb_big_sign(b))
1262 #define RBIGNUM_POSITIVE_P(b) (RBIGNUM_SIGN(b)!=0)
1263 #define RBIGNUM_NEGATIVE_P(b) (RBIGNUM_SIGN(b)==0)
1264
1265 #define R_CAST(st) (struct st*)
1266 #define RMOVED(obj) (R_CAST(RMoved)(obj))
1267 #define RBASIC(obj) (R_CAST(RBasic)(obj))
1268 #define ROBJECT(obj) (R_CAST(RObject)(obj))
1269 #define RCLASS(obj) (R_CAST(RClass)(obj))
1270 #define RMODULE(obj) RCLASS(obj)
1271 #define RSTRING(obj) (R_CAST(RString)(obj))
1272 #define RREGEXP(obj) (R_CAST(RRegexp)(obj))
1273 #define RARRAY(obj) (R_CAST(RArray)(obj))
1274 #define RDATA(obj) (R_CAST(RData)(obj))
1275 #define RTYPEDDATA(obj) (R_CAST(RTypedData)(obj))
1276 #define RFILE(obj) (R_CAST(RFile)(obj))
1277
1278 #define FL_SINGLETON ((VALUE)RUBY_FL_SINGLETON)
1279 #define FL_WB_PROTECTED ((VALUE)RUBY_FL_WB_PROTECTED)
1280 #define FL_PROMOTED0 ((VALUE)RUBY_FL_PROMOTED0)
1281 #define FL_PROMOTED1 ((VALUE)RUBY_FL_PROMOTED1)
1282 #define FL_FINALIZE ((VALUE)RUBY_FL_FINALIZE)
1283 #define FL_TAINT ((VALUE)RUBY_FL_TAINT)
1284 #define FL_UNTRUSTED ((VALUE)RUBY_FL_UNTRUSTED)
1285 #define FL_SEEN_OBJ_ID ((VALUE)RUBY_FL_SEEN_OBJ_ID)
1286 #define FL_EXIVAR ((VALUE)RUBY_FL_EXIVAR)
1287 #define FL_FREEZE ((VALUE)RUBY_FL_FREEZE)
1288
1289 #define FL_USHIFT ((VALUE)RUBY_FL_USHIFT)
1290
1291 #define FL_USER0 ((VALUE)RUBY_FL_USER0)
1292 #define FL_USER1 ((VALUE)RUBY_FL_USER1)
1293 #define FL_USER2 ((VALUE)RUBY_FL_USER2)
1294 #define FL_USER3 ((VALUE)RUBY_FL_USER3)
1295 #define FL_USER4 ((VALUE)RUBY_FL_USER4)
1296 #define FL_USER5 ((VALUE)RUBY_FL_USER5)
1297 #define FL_USER6 ((VALUE)RUBY_FL_USER6)
1298 #define FL_USER7 ((VALUE)RUBY_FL_USER7)
1299 #define FL_USER8 ((VALUE)RUBY_FL_USER8)
1300 #define FL_USER9 ((VALUE)RUBY_FL_USER9)
1301 #define FL_USER10 ((VALUE)RUBY_FL_USER10)
1302 #define FL_USER11 ((VALUE)RUBY_FL_USER11)
1303 #define FL_USER12 ((VALUE)RUBY_FL_USER12)
1304 #define FL_USER13 ((VALUE)RUBY_FL_USER13)
1305 #define FL_USER14 ((VALUE)RUBY_FL_USER14)
1306 #define FL_USER15 ((VALUE)RUBY_FL_USER15)
1307 #define FL_USER16 ((VALUE)RUBY_FL_USER16)
1308 #define FL_USER17 ((VALUE)RUBY_FL_USER17)
1309 #define FL_USER18 ((VALUE)RUBY_FL_USER18)
1310 #define FL_USER19 ((VALUE)(unsigned int)RUBY_FL_USER19)
1311
1312 #define RB_SPECIAL_CONST_P(x) (RB_IMMEDIATE_P(x) || !RB_TEST(x))
1313 #define SPECIAL_CONST_P(x) RB_SPECIAL_CONST_P(x)
1314
1315 #define RB_FL_ABLE(x) (!RB_SPECIAL_CONST_P(x) && RB_BUILTIN_TYPE(x) != RUBY_T_NODE)
1316 #define RB_FL_TEST_RAW(x,f) (RBASIC(x)->flags&(f))
1317 #define RB_FL_TEST(x,f) (RB_FL_ABLE(x)?RB_FL_TEST_RAW((x),(f)):0)
1318 #define RB_FL_ANY_RAW(x,f) RB_FL_TEST_RAW((x),(f))
1319 #define RB_FL_ANY(x,f) RB_FL_TEST((x),(f))
1320 #define RB_FL_ALL_RAW(x,f) (RB_FL_TEST_RAW((x),(f)) == (f))
1321 #define RB_FL_ALL(x,f) (RB_FL_TEST((x),(f)) == (f))
1322 #define RB_FL_SET_RAW(x,f) (void)(RBASIC(x)->flags |= (f))
1323 #define RB_FL_SET(x,f) (RB_FL_ABLE(x) ? RB_FL_SET_RAW(x, f) : (void)0)
1324 #define RB_FL_UNSET_RAW(x,f) (void)(RBASIC(x)->flags &= ~(VALUE)(f))
1325 #define RB_FL_UNSET(x,f) (RB_FL_ABLE(x) ? RB_FL_UNSET_RAW(x, f) : (void)0)
1326 #define RB_FL_REVERSE_RAW(x,f) (void)(RBASIC(x)->flags ^= (f))
1327 #define RB_FL_REVERSE(x,f) (RB_FL_ABLE(x) ? RB_FL_REVERSE_RAW(x, f) : (void)0)
1328
1329 #define RB_OBJ_TAINTABLE(x) (RB_FL_ABLE(x) && RB_BUILTIN_TYPE(x) != RUBY_T_BIGNUM && RB_BUILTIN_TYPE(x) != RUBY_T_FLOAT)
1330 #define RB_OBJ_TAINTED_RAW(x) RB_FL_TEST_RAW(x, RUBY_FL_TAINT)
1331 #define RB_OBJ_TAINTED(x) (!!RB_FL_TEST((x), RUBY_FL_TAINT))
1332 #define RB_OBJ_TAINT_RAW(x) RB_FL_SET_RAW(x, RUBY_FL_TAINT)
1333 #define RB_OBJ_TAINT(x) (RB_OBJ_TAINTABLE(x) ? RB_OBJ_TAINT_RAW(x) : (void)0)
1334 #define RB_OBJ_UNTRUSTED(x) RB_OBJ_TAINTED(x)
1335 #define RB_OBJ_UNTRUST(x) RB_OBJ_TAINT(x)
1336 #define RB_OBJ_INFECT_RAW(x,s) RB_FL_SET_RAW(x, RB_OBJ_TAINTED_RAW(s))
1337 #define RB_OBJ_INFECT(x,s) ( \
1338 (RB_OBJ_TAINTABLE(x) && RB_FL_ABLE(s)) ? \
1339 RB_OBJ_INFECT_RAW(x, s) : (void)0)
1340
1341 #define RB_OBJ_FROZEN_RAW(x) (RBASIC(x)->flags&RUBY_FL_FREEZE)
1342 #define RB_OBJ_FROZEN(x) (!RB_FL_ABLE(x) || RB_OBJ_FROZEN_RAW(x))
1343 #define RB_OBJ_FREEZE_RAW(x) (void)(RBASIC(x)->flags |= RUBY_FL_FREEZE)
1344 #define RB_OBJ_FREEZE(x) rb_obj_freeze_inline((VALUE)x)
1345
1351 #define FL_ABLE(x) RB_FL_ABLE(x)
1352 #define FL_TEST_RAW(x,f) RB_FL_TEST_RAW(x,f)
1353 #define FL_TEST(x,f) RB_FL_TEST(x,f)
1354 #define FL_ANY_RAW(x,f) RB_FL_ANY_RAW(x,f)
1355 #define FL_ANY(x,f) RB_FL_ANY(x,f)
1356 #define FL_ALL_RAW(x,f) RB_FL_ALL_RAW(x,f)
1357 #define FL_ALL(x,f) RB_FL_ALL(x,f)
1358 #define FL_SET_RAW(x,f) RB_FL_SET_RAW(x,f)
1359 #define FL_SET(x,f) RB_FL_SET(x,f)
1360 #define FL_UNSET_RAW(x,f) RB_FL_UNSET_RAW(x,f)
1361 #define FL_UNSET(x,f) RB_FL_UNSET(x,f)
1362 #define FL_REVERSE_RAW(x,f) RB_FL_REVERSE_RAW(x,f)
1363 #define FL_REVERSE(x,f) RB_FL_REVERSE(x,f)
1364
1365 #define OBJ_TAINTABLE(x) RB_OBJ_TAINTABLE(x)
1366 #define OBJ_TAINTED_RAW(x) RB_OBJ_TAINTED_RAW(x)
1367 #define OBJ_TAINTED(x) RB_OBJ_TAINTED(x)
1368 #define OBJ_TAINT_RAW(x) RB_OBJ_TAINT_RAW(x)
1369 #define OBJ_TAINT(x) RB_OBJ_TAINT(x)
1370 #define OBJ_UNTRUSTED(x) RB_OBJ_UNTRUSTED(x)
1371 #define OBJ_UNTRUST(x) RB_OBJ_UNTRUST(x)
1372 #define OBJ_INFECT_RAW(x,s) RB_OBJ_INFECT_RAW(x,s)
1373 #define OBJ_INFECT(x,s) RB_OBJ_INFECT(x,s)
1374 #define OBJ_FROZEN_RAW(x) RB_OBJ_FROZEN_RAW(x)
1375 #define OBJ_FROZEN(x) RB_OBJ_FROZEN(x)
1376 #define OBJ_FREEZE_RAW(x) RB_OBJ_FREEZE_RAW(x)
1377 #define OBJ_FREEZE(x) RB_OBJ_FREEZE(x)
1378
1379 /* \} */
1380
1381 void rb_freeze_singleton_class(VALUE klass);
1382
1383 static inline void
1384 rb_obj_freeze_inline(VALUE x)
1385 {
1386 if (RB_FL_ABLE(x)) {
1387 RB_OBJ_FREEZE_RAW(x);
1388 if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & RUBY_FL_SINGLETON)) {
1389 rb_freeze_singleton_class(x);
1390 }
1391 }
1392 }
1393
1394 #if GCC_VERSION_SINCE(4,4,0)
1395 # define RUBY_UNTYPED_DATA_FUNC(func) func __attribute__((warning("untyped Data is unsafe; use TypedData instead")))
1396 #else
1397 # define RUBY_UNTYPED_DATA_FUNC(func) DEPRECATED(func)
1398 #endif
1399
1400 #if defined(__GNUC__) && !defined(__NO_INLINE__)
1401 #if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
1402 RUBY_UNTYPED_DATA_FUNC(static inline VALUE rb_data_object_wrap_warning(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
1403 #endif
1404 RUBY_UNTYPED_DATA_FUNC(static inline void *rb_data_object_get_warning(VALUE));
1405
1406 static inline VALUE
1407 rb_data_object_wrap_warning(VALUE klass, void *ptr, RUBY_DATA_FUNC mark, RUBY_DATA_FUNC free)
1408 {
1409 return rb_data_object_wrap(klass, ptr, mark, free);
1410 }
1411
1412 #if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
1413 #define rb_data_object_wrap_warning(klass, ptr, mark, free) \
1414 __extension__( \
1415 __builtin_choose_expr( \
1416 __builtin_constant_p(klass) && !(klass), \
1417 rb_data_object_wrap(klass, ptr, mark, free), \
1418 rb_data_object_wrap_warning(klass, ptr, mark, free)))
1419 #endif
1420 #endif
1421
1422 static inline void *
1423 rb_data_object_get(VALUE obj)
1424 {
1425 Check_Type(obj, RUBY_T_DATA);
1426 return ((struct RData *)obj)->data;
1427 }
1428
1429 #if defined(__GNUC__) && !defined(__NO_INLINE__)
1430 static inline void *
1431 rb_data_object_get_warning(VALUE obj)
1432 {
1433 return rb_data_object_get(obj);
1434 }
1435 #endif
1436
1437 static inline VALUE
1438 rb_data_object_make(VALUE klass, RUBY_DATA_FUNC mark_func, RUBY_DATA_FUNC free_func, void **datap, size_t size)
1439 {
1440 Data_Make_Struct0(result, klass, void, size, mark_func, free_func, *datap);
1441 return result;
1442 }
1443
1444 static inline VALUE
1445 rb_data_typed_object_make(VALUE klass, const rb_data_type_t *type, void **datap, size_t size)
1446 {
1447 TypedData_Make_Struct0(result, klass, void, size, type, *datap);
1448 return result;
1449 }
1450
1451 #ifndef rb_data_object_alloc
1452 DEPRECATED_BY(rb_data_object_wrap, static inline VALUE rb_data_object_alloc(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC));
1453 static inline VALUE
1454 rb_data_object_alloc(VALUE klass, void *data, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
1455 {
1456 return rb_data_object_wrap(klass, data, dmark, dfree);
1457 }
1458 #endif
1459
1460 #ifndef rb_data_typed_object_alloc
1461 DEPRECATED_BY(rb_data_typed_object_wrap, static inline VALUE rb_data_typed_object_alloc(VALUE,void*,const rb_data_type_t*));
1462 static inline VALUE
1463 rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *type)
1464 {
1465 return rb_data_typed_object_wrap(klass, datap, type);
1466 }
1467 #endif
1468
1469 #if defined(__GNUC__) && !defined(__NO_INLINE__)
1470 #define rb_data_object_wrap_0 rb_data_object_wrap
1471 #define rb_data_object_wrap_1 rb_data_object_wrap_warning
1472 #define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)
1473 #define rb_data_object_get_0 rb_data_object_get
1474 #define rb_data_object_get_1 rb_data_object_get_warning
1475 #define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_, RUBY_UNTYPED_DATA_WARNING)
1476 #define rb_data_object_make_0 rb_data_object_make
1477 #define rb_data_object_make_1 rb_data_object_make_warning
1478 #define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING)
1479 #endif
1480
1481 #if USE_RGENGC
1482 #define RB_OBJ_PROMOTED_RAW(x) RB_FL_ALL_RAW(x, RUBY_FL_PROMOTED)
1483 #define RB_OBJ_PROMOTED(x) (RB_SPECIAL_CONST_P(x) ? 0 : RB_OBJ_PROMOTED_RAW(x))
1484 #define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
1485
1486 void rb_gc_writebarrier(VALUE a, VALUE b);
1487 void rb_gc_writebarrier_unprotect(VALUE obj);
1488
1489 #else /* USE_RGENGC */
1490 #define RB_OBJ_PROMOTED(x) 0
1491 #define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
1492 #endif
1493 #define OBJ_PROMOTED_RAW(x) RB_OBJ_PROMOTED_RAW(x)
1494 #define OBJ_PROMOTED(x) RB_OBJ_PROMOTED(x)
1495 #define OBJ_WB_UNPROTECT(x) RB_OBJ_WB_UNPROTECT(x)
1496
1497 /* Write barrier (WB) interfaces:
1498 * - RB_OBJ_WRITE(a, slot, b): WB for new reference from `a' to `b'.
1499 * Write `b' into `*slot'. `slot' is a pointer in `a'.
1500 * - RB_OBJ_WRITTEN(a, oldv, b): WB for new reference from `a' to `b'.
1501 * This doesn't write any values, but only a WB declaration.
1502 * `oldv' is replaced value with `b' (not used in current Ruby).
1503 *
1504 * NOTE: The following core interfaces can be changed in the future.
1505 * Please catch up if you want to insert WB into C-extensions
1506 * correctly.
1507 */
1508 #define RB_OBJ_WRITE(a, slot, b) rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__)
1509 #define RB_OBJ_WRITTEN(a, oldv, b) rb_obj_written((VALUE)(a), (VALUE)(oldv), (VALUE)(b), __FILE__, __LINE__)
1510
1511 #ifndef USE_RGENGC_LOGGING_WB_UNPROTECT
1512 #define USE_RGENGC_LOGGING_WB_UNPROTECT 0
1513 #endif
1514
1515 #if USE_RGENGC_LOGGING_WB_UNPROTECT
1516 void rb_gc_unprotect_logging(void *objptr, const char *filename, int line);
1517 #define RGENGC_LOGGING_WB_UNPROTECT rb_gc_unprotect_logging
1518 #endif
1519
1520 static inline VALUE
1521 rb_obj_wb_unprotect(VALUE x, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
1522 {
1523 #ifdef RGENGC_LOGGING_WB_UNPROTECT
1524 RGENGC_LOGGING_WB_UNPROTECT((void *)x, filename, line);
1525 #endif
1526 #if USE_RGENGC
1527 rb_gc_writebarrier_unprotect(x);
1528 #endif
1529 return x;
1530 }
1531
1532 static inline VALUE
1533 rb_obj_written(VALUE a, RB_UNUSED_VAR(VALUE oldv), VALUE b, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
1534 {
1535 #ifdef RGENGC_LOGGING_OBJ_WRITTEN
1536 RGENGC_LOGGING_OBJ_WRITTEN(a, oldv, b, filename, line);
1537 #endif
1538
1539 #if USE_RGENGC
1540 if (!RB_SPECIAL_CONST_P(b)) {
1541 rb_gc_writebarrier(a, b);
1542 }
1543 #endif
1544
1545 return a;
1546 }
1547
1548 static inline VALUE
1549 rb_obj_write(VALUE a, VALUE *slot, VALUE b, RB_UNUSED_VAR(const char *filename), RB_UNUSED_VAR(int line))
1550 {
1551 #ifdef RGENGC_LOGGING_WRITE
1552 RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
1553 #endif
1554
1555 *slot = b;
1556
1557 #if USE_RGENGC
1558 rb_obj_written(a, RUBY_Qundef /* ignore `oldv' now */, b, filename, line);
1559 #endif
1560 return a;
1561 }
1562
1563 #define RUBY_INTEGER_UNIFICATION 1
1564 #define RB_INTEGER_TYPE_P(obj) rb_integer_type_p(obj)
1565 #if defined __GNUC__ && !GCC_VERSION_SINCE(4, 3, 0)
1566 /* clang 3.x (4.2 compatible) can't eliminate CSE of RB_BUILTIN_TYPE
1567 * in inline function and caller function */
1568 #define rb_integer_type_p(obj) \
1569 __extension__ ({ \
1570 const VALUE integer_type_obj = (obj); \
1571 (RB_FIXNUM_P(integer_type_obj) || \
1572 (!RB_SPECIAL_CONST_P(integer_type_obj) && \
1573 RB_BUILTIN_TYPE(integer_type_obj) == RUBY_T_BIGNUM)); \
1574 })
1575 #else
1576 static inline int
1577 rb_integer_type_p(VALUE obj)
1578 {
1579 return (RB_FIXNUM_P(obj) ||
1580 (!RB_SPECIAL_CONST_P(obj) &&
1581 RB_BUILTIN_TYPE(obj) == RUBY_T_BIGNUM));
1582 }
1583 #endif
1584
1585 #if SIZEOF_INT < SIZEOF_LONG
1586 # define RB_INT2NUM(v) RB_INT2FIX((int)(v))
1587 # define RB_UINT2NUM(v) RB_LONG2FIX((unsigned int)(v))
1588 #else
1589 static inline VALUE
1590 rb_int2num_inline(int v)
1591 {
1592 if (RB_FIXABLE(v))
1593 return RB_INT2FIX(v);
1594 else
1595 return rb_int2big(v);
1596 }
1597 #define RB_INT2NUM(x) rb_int2num_inline(x)
1598
1599 static inline VALUE
1600 rb_uint2num_inline(unsigned int v)
1601 {
1602 if (RB_POSFIXABLE(v))
1603 return RB_LONG2FIX(v);
1604 else
1605 return rb_uint2big(v);
1606 }
1607 #define RB_UINT2NUM(x) rb_uint2num_inline(x)
1608 #endif
1609 #define INT2NUM(x) RB_INT2NUM(x)
1610 #define UINT2NUM(x) RB_UINT2NUM(x)
1611
1612 static inline VALUE
1613 rb_long2num_inline(long v)
1614 {
1615 if (RB_FIXABLE(v))
1616 return RB_LONG2FIX(v);
1617 else
1618 return rb_int2big(v);
1619 }
1620 #define RB_LONG2NUM(x) rb_long2num_inline(x)
1621
1622 static inline VALUE
1623 rb_ulong2num_inline(unsigned long v)
1624 {
1625 if (RB_POSFIXABLE(v))
1626 return RB_LONG2FIX(v);
1627 else
1628 return rb_uint2big(v);
1629 }
1630 #define RB_ULONG2NUM(x) rb_ulong2num_inline(x)
1631
1632 static inline char
1633 rb_num2char_inline(VALUE x)
1634 {
1635 if (RB_TYPE_P(x, RUBY_T_STRING) && (RSTRING_LEN(x)>=1))
1636 return RSTRING_PTR(x)[0];
1637 else
1638 return (char)(NUM2INT(x) & 0xff);
1639 }
1640 #define RB_NUM2CHR(x) rb_num2char_inline(x)
1641
1642 #define RB_CHR2FIX(x) RB_INT2FIX((long)((x)&0xff))
1643
1644 #define LONG2NUM(x) RB_LONG2NUM(x)
1645 #define ULONG2NUM(x) RB_ULONG2NUM(x)
1646 #define USHORT2NUM(x) RB_INT2FIX(x)
1647 #define NUM2CHR(x) RB_NUM2CHR(x)
1648 #define CHR2FIX(x) RB_CHR2FIX(x)
1649
1650 #if SIZEOF_LONG < SIZEOF_VALUE
1651 #define RB_ST2FIX(h) RB_LONG2FIX((long)((h) > 0 ? (h) & (unsigned long)-1 >> 2 : (h) | ~((unsigned long)-1 >> 2)))
1652 #else
1653 #define RB_ST2FIX(h) RB_LONG2FIX((long)(h))
1654 #endif
1655 #define ST2FIX(h) RB_ST2FIX(h)
1656
1657 #define RB_ALLOC_N(type,n) ((type*)ruby_xmalloc2((size_t)(n),sizeof(type)))
1658 #define RB_ALLOC(type) ((type*)ruby_xmalloc(sizeof(type)))
1659 #define RB_ZALLOC_N(type,n) ((type*)ruby_xcalloc((size_t)(n),sizeof(type)))
1660 #define RB_ZALLOC(type) (RB_ZALLOC_N(type,1))
1661 #define RB_REALLOC_N(var,type,n) ((var)=(type*)ruby_xrealloc2((char*)(var),(size_t)(n),sizeof(type)))
1662
1663 #define ALLOC_N(type,n) RB_ALLOC_N(type,n)
1664 #define ALLOC(type) RB_ALLOC(type)
1665 #define ZALLOC_N(type,n) RB_ZALLOC_N(type,n)
1666 #define ZALLOC(type) RB_ZALLOC(type)
1667 #define REALLOC_N(var,type,n) RB_REALLOC_N(var,type,n)
1668
1669 #if GCC_VERSION_BEFORE(4,9,5)
1670 /* GCC 4.9.2 reportedly has this feature and is broken.
1671 * The function is not officially documented below.
1672 * Seems we should not use it.
1673 * https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Other-Builtins.html#Other-Builtins */
1674 # undef HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN
1675 #endif
1676
1677 #if defined(HAVE_BUILTIN___BUILTIN_ALLOCA_WITH_ALIGN) && defined(RUBY_ALIGNOF)
1678 /* I don't know why but __builtin_alloca_with_align's second argument
1679 takes bits rather than bytes. */
1680 #define ALLOCA_N(type, n) \
1681 (type*)__builtin_alloca_with_align((sizeof(type)*(n)), \
1682 RUBY_ALIGNOF(type) * CHAR_BIT)
1683 #else
1684 #define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
1685 #endif
1686
1687 void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2));
1688 void *rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len,size_t count) RUBY_ATTR_ALLOC_SIZE((2,3));
1689 void rb_free_tmp_buffer(volatile VALUE *store);
1690 NORETURN(void ruby_malloc_size_overflow(size_t, size_t));
1691 #if HAVE_LONG_LONG && SIZEOF_SIZE_T * 2 <= SIZEOF_LONG_LONG
1692 # define DSIZE_T unsigned LONG_LONG
1693 #elif defined(HAVE_INT128_T)
1694 # define DSIZE_T uint128_t
1695 #endif
1696 static inline int
1697 rb_mul_size_overflow(size_t a, size_t b, size_t max, size_t *c)
1698 {
1699 #ifdef DSIZE_T
1700 # ifdef __GNUC__
1701 __extension__
1702 # endif
1703 DSIZE_T c2 = (DSIZE_T)a * (DSIZE_T)b;
1704 if (c2 > max) return 1;
1705 *c = (size_t)c2;
1706 #else
1707 if (b != 0 && a > max / b) return 1;
1708 *c = a * b;
1709 #endif
1710 return 0;
1711 }
1712 static inline void *
1713 rb_alloc_tmp_buffer2(volatile VALUE *store, long count, size_t elsize)
1714 {
1715 size_t cnt = (size_t)count;
1716 if (elsize == sizeof(VALUE)) {
1717 if (RB_UNLIKELY(cnt > LONG_MAX / sizeof(VALUE))) {
1718 ruby_malloc_size_overflow(cnt, elsize);
1719 }
1720 }
1721 else {
1722 size_t size, max = LONG_MAX - sizeof(VALUE) + 1;
1723 if (RB_UNLIKELY(rb_mul_size_overflow(cnt, elsize, max, &size))) {
1724 ruby_malloc_size_overflow(cnt, elsize);
1725 }
1726 cnt = (size + sizeof(VALUE) - 1) / sizeof(VALUE);
1727 }
1728 return rb_alloc_tmp_buffer_with_count(store, cnt * sizeof(VALUE), cnt);
1729 }
1730 /* allocates _n_ bytes temporary buffer and stores VALUE including it
1731 * in _v_. _n_ may be evaluated twice. */
1732 #ifdef C_ALLOCA
1733 # define RB_ALLOCV(v, n) rb_alloc_tmp_buffer(&(v), (n))
1734 # define RB_ALLOCV_N(type, v, n) \
1735 rb_alloc_tmp_buffer2(&(v), (n), sizeof(type))
1736 #else
1737 # define RUBY_ALLOCV_LIMIT 1024
1738 # define RB_ALLOCV(v, n) ((n) < RUBY_ALLOCV_LIMIT ? \
1739 ((v) = 0, alloca(n)) : \
1740 rb_alloc_tmp_buffer(&(v), (n)))
1741 # define RB_ALLOCV_N(type, v, n) \
1742 ((type*)(((size_t)(n) < RUBY_ALLOCV_LIMIT / sizeof(type)) ? \
1743 ((v) = 0, alloca((size_t)(n) * sizeof(type))) : \
1744 rb_alloc_tmp_buffer2(&(v), (long)(n), sizeof(type))))
1745 #endif
1746 #define RB_ALLOCV_END(v) rb_free_tmp_buffer(&(v))
1747
1748 #define ALLOCV(v, n) RB_ALLOCV(v, n)
1749 #define ALLOCV_N(type, v, n) RB_ALLOCV_N(type, v, n)
1750 #define ALLOCV_END(v) RB_ALLOCV_END(v)
1751
1752 #define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(size_t)(n))
1753 #define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(size_t)(n))
1754 #define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(size_t)(n))
1755 #define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(size_t)(n))
1756 #ifdef __GLIBC__
1757 static inline void *
1758 ruby_nonempty_memcpy(void *dest, const void *src, size_t n)
1759 {
1760 /* if nothing to be copied, src may be NULL */
1761 return (n ? memcpy(dest, src, n) : dest);
1762 }
1763 #define memcpy(p1,p2,n) ruby_nonempty_memcpy(p1, p2, n)
1764 #endif
1765
1766 void rb_obj_infect(VALUE victim, VALUE carrier);
1767
1768 typedef int ruby_glob_func(const char*,VALUE, void*);
1769 void rb_glob(const char*,void(*)(const char*,VALUE,void*),VALUE);
1770 int ruby_glob(const char*,int,ruby_glob_func*,VALUE);
1771 int ruby_brace_glob(const char*,int,ruby_glob_func*,VALUE);
1772
1773 VALUE rb_define_class(const char*,VALUE);
1774 VALUE rb_define_module(const char*);
1775 VALUE rb_define_class_under(VALUE, const char*, VALUE);
1776 VALUE rb_define_module_under(VALUE, const char*);
1777
1778 void rb_include_module(VALUE,VALUE);
1779 void rb_extend_object(VALUE,VALUE);
1780 void rb_prepend_module(VALUE,VALUE);
1781
1782 typedef VALUE rb_gvar_getter_t(ID id, VALUE *data);
1783 typedef void rb_gvar_setter_t(VALUE val, ID id, VALUE *data);
1784 typedef void rb_gvar_marker_t(VALUE *var);
1785
1786 rb_gvar_getter_t rb_gvar_undef_getter;
1787 rb_gvar_setter_t rb_gvar_undef_setter;
1788 rb_gvar_marker_t rb_gvar_undef_marker;
1789
1790 rb_gvar_getter_t rb_gvar_val_getter;
1791 rb_gvar_setter_t rb_gvar_val_setter;
1792 rb_gvar_marker_t rb_gvar_val_marker;
1793
1794 rb_gvar_getter_t rb_gvar_var_getter;
1795 rb_gvar_setter_t rb_gvar_var_setter;
1796 rb_gvar_marker_t rb_gvar_var_marker;
1797
1798 NORETURN(rb_gvar_setter_t rb_gvar_readonly_setter);
1799
1800 void rb_define_variable(const char*,VALUE*);
1801 void rb_define_virtual_variable(const char*,rb_gvar_getter_t*,rb_gvar_setter_t*);
1802 void rb_define_hooked_variable(const char*,VALUE*,rb_gvar_getter_t*,rb_gvar_setter_t*);
1803 void rb_define_readonly_variable(const char*,const VALUE*);
1804 void rb_define_const(VALUE,const char*,VALUE);
1805 void rb_define_global_const(const char*,VALUE);
1806
1807 void rb_define_method(VALUE,const char*,VALUE(*)(ANYARGS),int);
1808 void rb_define_module_function(VALUE,const char*,VALUE(*)(ANYARGS),int);
1809 void rb_define_global_function(const char*,VALUE(*)(ANYARGS),int);
1810
1811 void rb_undef_method(VALUE,const char*);
1812 void rb_define_alias(VALUE,const char*,const char*);
1813 void rb_define_attr(VALUE,const char*,int,int);
1814
1815 void rb_global_variable(VALUE*);
1816 void rb_gc_register_mark_object(VALUE);
1817 void rb_gc_register_address(VALUE*);
1818 void rb_gc_unregister_address(VALUE*);
1819
1820 ID rb_intern(const char*);
1821 ID rb_intern2(const char*, long);
1822 ID rb_intern_str(VALUE str);
1823 const char *rb_id2name(ID);
1824 ID rb_check_id(volatile VALUE *);
1825 ID rb_to_id(VALUE);
1826 VALUE rb_id2str(ID);
1827 VALUE rb_sym2str(VALUE);
1828 VALUE rb_to_symbol(VALUE name);
1829 VALUE rb_check_symbol(volatile VALUE *namep);
1830
1831 #define RUBY_CONST_ID_CACHE(result, str) \
1832 { \
1833 static ID rb_intern_id_cache; \
1834 if (!rb_intern_id_cache) \
1835 rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
1836 result rb_intern_id_cache; \
1837 }
1838 #define RUBY_CONST_ID(var, str) \
1839 do RUBY_CONST_ID_CACHE((var) =, (str)) while (0)
1840 #define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
1841 #define CONST_ID(var, str) RUBY_CONST_ID(var, str)
1842 #if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR)
1843 /* __builtin_constant_p and statement expression is available
1844 * since gcc-2.7.2.3 at least. */
1845 #define rb_intern(str) \
1846 (__builtin_constant_p(str) ? \
1847 __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
1848 rb_intern(str))
1849 #define rb_intern_const(str) \
1850 (__builtin_constant_p(str) ? \
1851 __extension__ (rb_intern2((str), (long)strlen(str))) : \
1852 (rb_intern)(str))
1853
1854 # define rb_varargs_argc_check_runtime(argc, vargc) \
1855 (((argc) <= (vargc)) ? (argc) : \
1856 (rb_fatal("argc(%d) exceeds actual arguments(%d)", \
1857 argc, vargc), 0))
1858 # define rb_varargs_argc_valid_p(argc, vargc) \
1859 ((argc) == 0 ? (vargc) <= 1 : /* [ruby-core:85266] [Bug #14425] */ \
1860 (argc) == (vargc))
1861 # if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
1862 # if HAVE_ATTRIBUTE_ERRORFUNC
1863 ERRORFUNC((" argument length doesn't match"), int rb_varargs_bad_length(int,int));
1864 # else
1865 # define rb_varargs_bad_length(argc, vargc) \
1866 ((argc)/rb_varargs_argc_valid_p(argc, vargc))
1867 # endif
1868 # define rb_varargs_argc_check(argc, vargc) \
1869 __builtin_choose_expr(__builtin_constant_p(argc), \
1870 (rb_varargs_argc_valid_p(argc, vargc) ? (argc) : \
1871 rb_varargs_bad_length(argc, vargc)), \
1872 rb_varargs_argc_check_runtime(argc, vargc))
1873 # else
1874 # define rb_varargs_argc_check(argc, vargc) \
1875 rb_varargs_argc_check_runtime(argc, vargc)
1876 # endif
1877
1878 #else
1879 #define rb_intern_const(str) rb_intern2((str), (long)strlen(str))
1880 #endif
1881
1882 const char *rb_class2name(VALUE);
1883 const char *rb_obj_classname(VALUE);
1884
1885 void rb_p(VALUE);
1886
1887 VALUE rb_eval_string(const char*);
1888 VALUE rb_eval_string_protect(const char*, int*);
1889 VALUE rb_eval_string_wrap(const char*, int*);
1890 VALUE rb_funcall(VALUE, ID, int, ...);
1891 VALUE rb_funcallv(VALUE, ID, int, const VALUE*);
1892 VALUE rb_funcallv_kw(VALUE, ID, int, const VALUE*, int);
1893 VALUE rb_funcallv_public(VALUE, ID, int, const VALUE*);
1894 VALUE rb_funcallv_public_kw(VALUE, ID, int, const VALUE*, int);
1895 #define rb_funcall2 rb_funcallv
1896 #define rb_funcall3 rb_funcallv_public
1897 VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
1898 VALUE rb_funcall_passing_block_kw(VALUE, ID, int, const VALUE*, int);
1899 VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE*, VALUE);
1900 VALUE rb_funcall_with_block_kw(VALUE, ID, int, const VALUE*, VALUE, int);
1901 int rb_scan_args(int, const VALUE*, const char*, ...);
1902 #define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS 0
1903 #define RB_SCAN_ARGS_KEYWORDS 1
1904 #define RB_SCAN_ARGS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */
1905 #define RB_SCAN_ARGS_LAST_HASH_KEYWORDS 3
1906 int rb_scan_args_kw(int, int, const VALUE*, const char*, ...);
1907 VALUE rb_call_super(int, const VALUE*);
1908 VALUE rb_call_super_kw(int, const VALUE*, int);
1909 VALUE rb_current_receiver(void);
1910 int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *);
1911 VALUE rb_extract_keywords(VALUE *orighash);
1912
1913 /* rb_scan_args() format allows ':' for optional hash */
1914 #define HAVE_RB_SCAN_ARGS_OPTIONAL_HASH 1
1915
1916 VALUE rb_gv_set(const char*, VALUE);
1917 VALUE rb_gv_get(const char*);
1918 VALUE rb_iv_get(VALUE, const char*);
1919 VALUE rb_iv_set(VALUE, const char*, VALUE);
1920
1921 VALUE rb_equal(VALUE,VALUE);
1922
1923 VALUE *rb_ruby_verbose_ptr(void);
1924 VALUE *rb_ruby_debug_ptr(void);
1925 #define ruby_verbose (*rb_ruby_verbose_ptr())
1926 #define ruby_debug (*rb_ruby_debug_ptr())
1927
1928 /* for rb_readwrite_sys_fail first argument */
1929 enum rb_io_wait_readwrite {RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE};
1930 #define RB_IO_WAIT_READABLE RB_IO_WAIT_READABLE
1931 #define RB_IO_WAIT_WRITABLE RB_IO_WAIT_WRITABLE
1932
1933 PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3);
1934 PRINTF_ARGS(NORETURN(void rb_fatal(const char*, ...)), 1, 2);
1935 COLDFUNC PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
1936 NORETURN(void rb_bug_errno(const char*, int));
1937 NORETURN(void rb_sys_fail(const char*));
1938 NORETURN(void rb_sys_fail_str(VALUE));
1939 NORETURN(void rb_mod_sys_fail(VALUE, const char*));
1940 NORETURN(void rb_mod_sys_fail_str(VALUE, VALUE));
1941 NORETURN(void rb_readwrite_sys_fail(enum rb_io_wait_readwrite, const char*));
1942 NORETURN(void rb_iter_break(void));
1943 NORETURN(void rb_iter_break_value(VALUE));
1944 NORETURN(void rb_exit(int));
1945 NORETURN(void rb_notimplement(void));
1946 VALUE rb_syserr_new(int, const char *);
1947 VALUE rb_syserr_new_str(int n, VALUE arg);
1948 NORETURN(void rb_syserr_fail(int, const char*));
1949 NORETURN(void rb_syserr_fail_str(int, VALUE));
1950 NORETURN(void rb_mod_syserr_fail(VALUE, int, const char*));
1951 NORETURN(void rb_mod_syserr_fail_str(VALUE, int, VALUE));
1952 NORETURN(void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite, int, const char*));
1953
1954 /* reports if `-W' specified */
1955 PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2);
1956 PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4);
1957 PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
1958 /* reports always */
1959 COLDFUNC PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
1960 PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
1961
1962 #define RB_BLOCK_CALL_FUNC_STRICT 1
1963 #define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1
1964 #define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) \
1965 VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg
1966 typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
1967 typedef rb_block_call_func *rb_block_call_func_t;
1968
1969 VALUE rb_each(VALUE);
1970 VALUE rb_yield(VALUE);
1971 VALUE rb_yield_values(int n, ...);
1972 VALUE rb_yield_values2(int n, const VALUE *argv);
1973 VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat);
1974 VALUE rb_yield_splat(VALUE);
1975 VALUE rb_yield_splat_kw(VALUE, int);
1976 VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)); /* rb_block_call_func */
1977 #define RB_NO_KEYWORDS 0
1978 #define RB_PASS_KEYWORDS 1
1979 #define RB_PASS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */
1980 #define RB_PASS_CALLED_KEYWORDS 3
1981 int rb_keyword_given_p(void);
1982 int rb_block_given_p(void);
1983 void rb_need_block(void);
1984 VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
1985 VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE);
1986 VALUE rb_block_call_kw(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE,int);
1987 VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
1988 VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
1989 VALUE rb_vrescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,va_list);
1990 VALUE rb_ensure(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE),VALUE);
1991 VALUE rb_catch(const char*,rb_block_call_func_t,VALUE);
1992 VALUE rb_catch_obj(VALUE,rb_block_call_func_t,VALUE);
1993 NORETURN(void rb_throw(const char*,VALUE));
1994 NORETURN(void rb_throw_obj(VALUE,VALUE));
1995
1996 VALUE rb_require(const char*);
1997
1998 RUBY_EXTERN VALUE rb_mKernel;
1999 RUBY_EXTERN VALUE rb_mComparable;
2000 RUBY_EXTERN VALUE rb_mEnumerable;
2001 RUBY_EXTERN VALUE rb_mErrno;
2002 RUBY_EXTERN VALUE rb_mFileTest;
2003 RUBY_EXTERN VALUE rb_mGC;
2004 RUBY_EXTERN VALUE rb_mMath;
2005 RUBY_EXTERN VALUE rb_mProcess;
2006 RUBY_EXTERN VALUE rb_mWaitReadable;
2007 RUBY_EXTERN VALUE rb_mWaitWritable;
2008
2009 RUBY_EXTERN VALUE rb_cBasicObject;
2010 RUBY_EXTERN VALUE rb_cObject;
2011 RUBY_EXTERN VALUE rb_cArray;
2012 #ifndef RUBY_INTEGER_UNIFICATION
2013 RUBY_EXTERN VALUE rb_cBignum;
2014 #endif
2015 RUBY_EXTERN VALUE rb_cBinding;
2016 RUBY_EXTERN VALUE rb_cClass;
2017 RUBY_EXTERN VALUE rb_cCont;
2018 RUBY_EXTERN VALUE rb_cData;
2019 RUBY_EXTERN VALUE rb_cDir;
2020 RUBY_EXTERN VALUE rb_cEncoding;
2021 RUBY_EXTERN VALUE rb_cEnumerator;
2022 RUBY_EXTERN VALUE rb_cFalseClass;
2023 RUBY_EXTERN VALUE rb_cFile;
2024 #ifndef RUBY_INTEGER_UNIFICATION
2025 RUBY_EXTERN VALUE rb_cFixnum;
2026 #endif
2027 RUBY_EXTERN VALUE rb_cComplex;
2028 RUBY_EXTERN VALUE rb_cFloat;
2029 RUBY_EXTERN VALUE rb_cHash;
2030 RUBY_EXTERN VALUE rb_cIO;
2031 RUBY_EXTERN VALUE rb_cInteger;
2032 RUBY_EXTERN VALUE rb_cMatch;
2033 RUBY_EXTERN VALUE rb_cMethod;
2034 RUBY_EXTERN VALUE rb_cModule;
2035 RUBY_EXTERN VALUE rb_cNameErrorMesg;
2036 RUBY_EXTERN VALUE rb_cNilClass;
2037 RUBY_EXTERN VALUE rb_cNumeric;
2038 RUBY_EXTERN VALUE rb_cProc;
2039 RUBY_EXTERN VALUE rb_cRandom;
2040 RUBY_EXTERN VALUE rb_cRange;
2041 RUBY_EXTERN VALUE rb_cRational;
2042 RUBY_EXTERN VALUE rb_cRegexp;
2043 RUBY_EXTERN VALUE rb_cStat;
2044 RUBY_EXTERN VALUE rb_cString;
2045 RUBY_EXTERN VALUE rb_cStruct;
2046 RUBY_EXTERN VALUE rb_cSymbol;
2047 RUBY_EXTERN VALUE rb_cThread;
2048 RUBY_EXTERN VALUE rb_cTime;
2049 RUBY_EXTERN VALUE rb_cTrueClass;
2050 RUBY_EXTERN VALUE rb_cUnboundMethod;
2051
2052 RUBY_EXTERN VALUE rb_eException;
2053 RUBY_EXTERN VALUE rb_eStandardError;
2054 RUBY_EXTERN VALUE rb_eSystemExit;
2055 RUBY_EXTERN VALUE rb_eInterrupt;
2056 RUBY_EXTERN VALUE rb_eSignal;
2057 RUBY_EXTERN VALUE rb_eFatal;
2058 RUBY_EXTERN VALUE rb_eArgError;
2059 RUBY_EXTERN VALUE rb_eEOFError;
2060 RUBY_EXTERN VALUE rb_eIndexError;
2061 RUBY_EXTERN VALUE rb_eStopIteration;
2062 RUBY_EXTERN VALUE rb_eKeyError;
2063 RUBY_EXTERN VALUE rb_eRangeError;
2064 RUBY_EXTERN VALUE rb_eIOError;
2065 RUBY_EXTERN VALUE rb_eRuntimeError;
2066 RUBY_EXTERN VALUE rb_eFrozenError;
2067 RUBY_EXTERN VALUE rb_eSecurityError;
2068 RUBY_EXTERN VALUE rb_eSystemCallError;
2069 RUBY_EXTERN VALUE rb_eThreadError;
2070 RUBY_EXTERN VALUE rb_eTypeError;
2071 RUBY_EXTERN VALUE rb_eZeroDivError;
2072 RUBY_EXTERN VALUE rb_eNotImpError;
2073 RUBY_EXTERN VALUE rb_eNoMemError;
2074 RUBY_EXTERN VALUE rb_eNoMethodError;
2075 RUBY_EXTERN VALUE rb_eFloatDomainError;
2076 RUBY_EXTERN VALUE rb_eLocalJumpError;
2077 RUBY_EXTERN VALUE rb_eSysStackError;
2078 RUBY_EXTERN VALUE rb_eRegexpError;
2079 RUBY_EXTERN VALUE rb_eEncodingError;
2080 RUBY_EXTERN VALUE rb_eEncCompatError;
2081 RUBY_EXTERN VALUE rb_eNoMatchingPatternError;
2082
2083 RUBY_EXTERN VALUE rb_eScriptError;
2084 RUBY_EXTERN VALUE rb_eNameError;
2085 RUBY_EXTERN VALUE rb_eSyntaxError;
2086 RUBY_EXTERN VALUE rb_eLoadError;
2087
2088 RUBY_EXTERN VALUE rb_eMathDomainError;
2089
2090 RUBY_EXTERN VALUE rb_stdin, rb_stdout, rb_stderr;
2091
2092 static inline VALUE
2093 rb_class_of(VALUE obj)
2094 {
2095 if (RB_IMMEDIATE_P(obj)) {
2096 if (RB_FIXNUM_P(obj)) return rb_cInteger;
2097 if (RB_FLONUM_P(obj)) return rb_cFloat;
2098 if (obj == RUBY_Qtrue) return rb_cTrueClass;
2099 if (RB_STATIC_SYM_P(obj)) return rb_cSymbol;
2100 }
2101 else if (!RB_TEST(obj)) {
2102 if (obj == RUBY_Qnil) return rb_cNilClass;
2103 if (obj == RUBY_Qfalse) return rb_cFalseClass;
2104 }
2105 return RBASIC(obj)->klass;
2106 }
2107
2108 static inline int
2109 rb_type(VALUE obj)
2110 {
2111 if (RB_IMMEDIATE_P(obj)) {
2112 if (RB_FIXNUM_P(obj)) return RUBY_T_FIXNUM;
2113 if (RB_FLONUM_P(obj)) return RUBY_T_FLOAT;
2114 if (obj == RUBY_Qtrue) return RUBY_T_TRUE;
2115 if (RB_STATIC_SYM_P(obj)) return RUBY_T_SYMBOL;
2116 if (obj == RUBY_Qundef) return RUBY_T_UNDEF;
2117 }
2118 else if (!RB_TEST(obj)) {
2119 if (obj == RUBY_Qnil) return RUBY_T_NIL;
2120 if (obj == RUBY_Qfalse) return RUBY_T_FALSE;
2121 }
2122 return RB_BUILTIN_TYPE(obj);
2123 }
2124
2125 #ifdef __GNUC__
2126 #define rb_type_p(obj, type) \
2127 __extension__ (__builtin_constant_p(type) ? RB_TYPE_P((obj), (type)) : \
2128 rb_type(obj) == (type))
2129 #else
2130 #define rb_type_p(obj, type) (rb_type(obj) == (type))
2131 #endif
2132
2133 #ifdef __GNUC__
2134 #define rb_special_const_p(obj) \
2135 __extension__ ({ \
2136 VALUE special_const_obj = (obj); \
2137 (int)(RB_SPECIAL_CONST_P(special_const_obj) ? RUBY_Qtrue : RUBY_Qfalse); \
2138 })
2139 #else
2140 static inline int
2141 rb_special_const_p(VALUE obj)
2142 {
2143 if (RB_SPECIAL_CONST_P(obj)) return (int)RUBY_Qtrue;
2144 return (int)RUBY_Qfalse;
2145 }
2146 #endif
2147
2148 #include "ruby/intern.h"
2149
2150 static inline void
2151 rb_clone_setup(VALUE clone, VALUE obj)
2152 {
2153 rb_obj_setup(clone, rb_singleton_class_clone(obj),
2154 RBASIC(obj)->flags & ~(FL_PROMOTED0|FL_PROMOTED1|FL_FINALIZE));
2155 rb_singleton_class_attached(RBASIC_CLASS(clone), clone);
2156 if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(clone, obj);
2157 }
2158
2159 static inline void
2160 rb_dup_setup(VALUE dup, VALUE obj)
2161 {
2162 rb_obj_setup(dup, rb_obj_class(obj), RB_FL_TEST_RAW(obj, RUBY_FL_DUPPED));
2163 if (RB_FL_TEST(obj, RUBY_FL_EXIVAR)) rb_copy_generic_ivar(dup, obj);
2164 }
2165
2166 static inline long
2167 rb_array_len(VALUE a)
2168 {
2169 return (RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
2170 RARRAY_EMBED_LEN(a) : RARRAY(a)->as.heap.len;
2171 }
2172
2173 #if defined(__fcc__) || defined(__fcc_version) || \
2174 defined(__FCC__) || defined(__FCC_VERSION)
2175 /* workaround for old version of Fujitsu C Compiler (fcc) */
2176 # define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x))
2177 #else
2178 # define FIX_CONST_VALUE_PTR(x) (x)
2179 #endif
2180
2181 /* internal function. do not use this function */
2182 static inline const VALUE *
2183 rb_array_const_ptr_transient(VALUE a)
2184 {
2185 return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
2186 RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
2187 }
2188
2189 /* internal function. do not use this function */
2190 static inline const VALUE *
2191 rb_array_const_ptr(VALUE a)
2192 {
2193 #if USE_TRANSIENT_HEAP
2194 void rb_ary_detransient(VALUE a);
2195
2196 if (RARRAY_TRANSIENT_P(a)) {
2197 rb_ary_detransient(a);
2198 }
2199 #endif
2200 return rb_array_const_ptr_transient(a);
2201 }
2202
2203 /* internal function. do not use this function */
2204 static inline VALUE *
2205 rb_array_ptr_use_start(VALUE a, int allow_transient)
2206 {
2207 VALUE *rb_ary_ptr_use_start(VALUE ary);
2208
2209 #if USE_TRANSIENT_HEAP
2210 if (!allow_transient) {
2211 if (RARRAY_TRANSIENT_P(a)) {
2212 void rb_ary_detransient(VALUE a);
2213 rb_ary_detransient(a);
2214 }
2215 }
2216 #endif
2217 (void)allow_transient;
2218
2219 return rb_ary_ptr_use_start(a);
2220 }
2221
2222 /* internal function. do not use this function */
2223 static inline void
2224 rb_array_ptr_use_end(VALUE a, int allow_transient)
2225 {
2226 void rb_ary_ptr_use_end(VALUE a);
2227 rb_ary_ptr_use_end(a);
2228 (void)allow_transient;
2229 }
2230
2231 #if defined(EXTLIB) && defined(USE_DLN_A_OUT)
2232 /* hook for external modules */
2233 static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
2234 #endif
2235
2236 #define RUBY_VM 1 /* YARV */
2237 #define HAVE_NATIVETHREAD
2238 int ruby_native_thread_p(void);
2239
2240 /* traditional set_trace_func events */
2241 #define RUBY_EVENT_NONE 0x0000
2242 #define RUBY_EVENT_LINE 0x0001
2243 #define RUBY_EVENT_CLASS 0x0002
2244 #define RUBY_EVENT_END 0x0004
2245 #define RUBY_EVENT_CALL 0x0008
2246 #define RUBY_EVENT_RETURN 0x0010
2247 #define RUBY_EVENT_C_CALL 0x0020
2248 #define RUBY_EVENT_C_RETURN 0x0040
2249 #define RUBY_EVENT_RAISE 0x0080
2250 #define RUBY_EVENT_ALL 0x00ff
2251
2252 /* for TracePoint extended events */
2253 #define RUBY_EVENT_B_CALL 0x0100
2254 #define RUBY_EVENT_B_RETURN 0x0200
2255 #define RUBY_EVENT_THREAD_BEGIN 0x0400
2256 #define RUBY_EVENT_THREAD_END 0x0800
2257 #define RUBY_EVENT_FIBER_SWITCH 0x1000
2258 #define RUBY_EVENT_SCRIPT_COMPILED 0x2000
2259 #define RUBY_EVENT_TRACEPOINT_ALL 0xffff
2260
2261 /* special events */
2262 #define RUBY_EVENT_RESERVED_FOR_INTERNAL_USE 0x030000
2263
2264 /* internal events */
2265 #define RUBY_INTERNAL_EVENT_SWITCH 0x040000
2266 #define RUBY_EVENT_SWITCH 0x040000 /* obsolete name. this macro is for compatibility */
2267 /* 0x080000 */
2268 #define RUBY_INTERNAL_EVENT_NEWOBJ 0x100000
2269 #define RUBY_INTERNAL_EVENT_FREEOBJ 0x200000
2270 #define RUBY_INTERNAL_EVENT_GC_START 0x400000
2271 #define RUBY_INTERNAL_EVENT_GC_END_MARK 0x800000
2272 #define RUBY_INTERNAL_EVENT_GC_END_SWEEP 0x1000000
2273 #define RUBY_INTERNAL_EVENT_GC_ENTER 0x2000000
2274 #define RUBY_INTERNAL_EVENT_GC_EXIT 0x4000000
2275 #define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0x7f00000
2276 #define RUBY_INTERNAL_EVENT_MASK 0xffff0000
2277
2278 typedef uint32_t rb_event_flag_t;
2279 typedef void (*rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass);
2280
2281 #define RB_EVENT_HOOKS_HAVE_CALLBACK_DATA 1
2282 void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data);
2283 int rb_remove_event_hook(rb_event_hook_func_t func);
2284
2285 /* locale insensitive functions */
2286
2287 static inline int rb_isascii(int c){ return '\0' <= c && c <= '\x7f'; }
2288 static inline int rb_isupper(int c){ return 'A' <= c && c <= 'Z'; }
2289 static inline int rb_islower(int c){ return 'a' <= c && c <= 'z'; }
2290 static inline int rb_isalpha(int c){ return rb_isupper(c) || rb_islower(c); }
2291 static inline int rb_isdigit(int c){ return '0' <= c && c <= '9'; }
2292 static inline int rb_isalnum(int c){ return rb_isalpha(c) || rb_isdigit(c); }
2293 static inline int rb_isxdigit(int c){ return rb_isdigit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f'); }
2294 static inline int rb_isblank(int c){ return c == ' ' || c == '\t'; }
2295 static inline int rb_isspace(int c){ return c == ' ' || ('\t' <= c && c <= '\r'); }
2296 static inline int rb_iscntrl(int c){ return ('\0' <= c && c < ' ') || c == '\x7f'; }
2297 static inline int rb_isprint(int c){ return ' ' <= c && c <= '\x7e'; }
2298 static inline int rb_ispunct(int c){ return !rb_isalnum(c); }
2299 static inline int rb_isgraph(int c){ return '!' <= c && c <= '\x7e'; }
2300 static inline int rb_tolower(int c) { return rb_isupper(c) ? (c|0x20) : c; }
2301 static inline int rb_toupper(int c) { return rb_islower(c) ? (c&0x5f) : c; }
2302
2303 #ifndef ISPRINT
2304 #define ISASCII(c) rb_isascii(c)
2305 #define ISPRINT(c) rb_isprint(c)
2306 #define ISGRAPH(c) rb_isgraph(c)
2307 #define ISSPACE(c) rb_isspace(c)
2308 #define ISUPPER(c) rb_isupper(c)
2309 #define ISLOWER(c) rb_islower(c)
2310 #define ISALNUM(c) rb_isalnum(c)
2311 #define ISALPHA(c) rb_isalpha(c)
2312 #define ISDIGIT(c) rb_isdigit(c)
2313 #define ISXDIGIT(c) rb_isxdigit(c)
2314 #define ISBLANK(c) rb_isblank(c)
2315 #define ISCNTRL(c) rb_iscntrl(c)
2316 #define ISPUNCT(c) rb_ispunct(c)
2317 #endif
2318 #define TOUPPER(c) rb_toupper(c)
2319 #define TOLOWER(c) rb_tolower(c)
2320
2321 int st_locale_insensitive_strcasecmp(const char *s1, const char *s2);
2322 int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n);
2323 #define STRCASECMP(s1, s2) (st_locale_insensitive_strcasecmp((s1), (s2)))
2324 #define STRNCASECMP(s1, s2, n) (st_locale_insensitive_strncasecmp((s1), (s2), (n)))
2325
2326 unsigned long ruby_strtoul(const char *str, char **endptr, int base);
2327 #define STRTOUL(str, endptr, base) (ruby_strtoul((str), (endptr), (base)))
2328
2329 #define InitVM(ext) {void InitVM_##ext(void);InitVM_##ext();}
2330
2331 PRINTF_ARGS(int ruby_snprintf(char *str, size_t n, char const *fmt, ...), 3, 4);
2332 int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
2333
2334 /* -- Remove In 3.0, Only public for rb_scan_args optimized version -- */
2335 int rb_empty_keyword_given_p(void);
2336
2337 #if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
2338 # define rb_scan_args(argc,argvp,fmt,...) \
2339 __builtin_choose_expr(__builtin_constant_p(fmt), \
2340 rb_scan_args0(argc,argvp,fmt,\
2341 (sizeof((VALUE*[]){__VA_ARGS__})/sizeof(VALUE*)), \
2342 ((VALUE*[]){__VA_ARGS__})), \
2343 rb_scan_args(argc,argvp,fmt,##__VA_ARGS__))
2344 # if HAVE_ATTRIBUTE_ERRORFUNC
2345 ERRORFUNC(("bad scan arg format"), void rb_scan_args_bad_format(const char*));
2346 ERRORFUNC(("variable argument length doesn't match"), void rb_scan_args_length_mismatch(const char*,int));
2347 # else
2348 # define rb_scan_args_bad_format(fmt) ((void)0)
2349 # define rb_scan_args_length_mismatch(fmt, varc) ((void)0)
2350 # endif
2351
2352 # define rb_scan_args_isdigit(c) ((unsigned char)((c)-'0')<10)
2353
2354 # define rb_scan_args_count_end(fmt, ofs, vari) \
2355 (fmt[ofs] ? -1 : (vari))
2356
2357 # define rb_scan_args_count_block(fmt, ofs, vari) \
2358 (fmt[ofs]!='&' ? \
2359 rb_scan_args_count_end(fmt, ofs, vari) : \
2360 rb_scan_args_count_end(fmt, ofs+1, vari+1))
2361
2362 # define rb_scan_args_count_hash(fmt, ofs, vari) \
2363 (fmt[ofs]!=':' ? \
2364 rb_scan_args_count_block(fmt, ofs, vari) : \
2365 rb_scan_args_count_block(fmt, ofs+1, vari+1))
2366
2367 # define rb_scan_args_count_trail(fmt, ofs, vari) \
2368 (!rb_scan_args_isdigit(fmt[ofs]) ? \
2369 rb_scan_args_count_hash(fmt, ofs, vari) : \
2370 rb_scan_args_count_hash(fmt, ofs+1, vari+(fmt[ofs]-'0')))
2371
2372 # define rb_scan_args_count_var(fmt, ofs, vari) \
2373 (fmt[ofs]!='*' ? \
2374 rb_scan_args_count_trail(fmt, ofs, vari) : \
2375 rb_scan_args_count_trail(fmt, ofs+1, vari+1))
2376
2377 # define rb_scan_args_count_opt(fmt, ofs, vari) \
2378 (!rb_scan_args_isdigit(fmt[ofs]) ? \
2379 rb_scan_args_count_var(fmt, ofs, vari) : \
2380 rb_scan_args_count_var(fmt, ofs+1, vari+fmt[ofs]-'0'))
2381
2382 # define rb_scan_args_count_lead(fmt, ofs, vari) \
2383 (!rb_scan_args_isdigit(fmt[ofs]) ? \
2384 rb_scan_args_count_var(fmt, ofs, vari) : \
2385 rb_scan_args_count_opt(fmt, ofs+1, vari+fmt[ofs]-'0'))
2386
2387 # define rb_scan_args_count(fmt) rb_scan_args_count_lead(fmt, 0, 0)
2388
2389 # if defined(__has_attribute) && __has_attribute(diagnose_if)
2390 # define rb_scan_args_verify(fmt, varc) (void)0
2391 # else
2392 # define rb_scan_args_verify(fmt, varc) \
2393 (sizeof(char[1-2*(rb_scan_args_count(fmt)<0)])!=1 ? \
2394 rb_scan_args_bad_format(fmt) : \
2395 sizeof(char[1-2*(rb_scan_args_count(fmt)!=(varc))])!=1 ? \
2396 rb_scan_args_length_mismatch(fmt, varc) : \
2397 (void)0)
2398 # endif
2399
2400 ALWAYS_INLINE(static int rb_scan_args_lead_p(const char *fmt));
2401 static inline int
2402 rb_scan_args_lead_p(const char *fmt)
2403 {
2404 return rb_scan_args_isdigit(fmt[0]);
2405 }
2406
2407 ALWAYS_INLINE(static int rb_scan_args_n_lead(const char *fmt));
2408 static inline int
2409 rb_scan_args_n_lead(const char *fmt)
2410 {
2411 return (rb_scan_args_lead_p(fmt) ? fmt[0]-'0' : 0);
2412 }
2413
2414 ALWAYS_INLINE(static int rb_scan_args_opt_p(const char *fmt));
2415 static inline int
2416 rb_scan_args_opt_p(const char *fmt)
2417 {
2418 return (rb_scan_args_lead_p(fmt) && rb_scan_args_isdigit(fmt[1]));
2419 }
2420
2421 ALWAYS_INLINE(static int rb_scan_args_n_opt(const char *fmt));
2422 static inline int
2423 rb_scan_args_n_opt(const char *fmt)
2424 {
2425 return (rb_scan_args_opt_p(fmt) ? fmt[1]-'0' : 0);
2426 }
2427
2428 ALWAYS_INLINE(static int rb_scan_args_var_idx(const char *fmt));
2429 static inline int
2430 rb_scan_args_var_idx(const char *fmt)
2431 {
2432 return (!rb_scan_args_lead_p(fmt) ? 0 : !rb_scan_args_isdigit(fmt[1]) ? 1 : 2);
2433 }
2434
2435 ALWAYS_INLINE(static int rb_scan_args_f_var(const char *fmt));
2436 static inline int
2437 rb_scan_args_f_var(const char *fmt)
2438 {
2439 return (fmt[rb_scan_args_var_idx(fmt)]=='*');
2440 }
2441
2442 ALWAYS_INLINE(static int rb_scan_args_trail_idx(const char *fmt));
2443 static inline int
2444 rb_scan_args_trail_idx(const char *fmt)
2445 {
2446 const int idx = rb_scan_args_var_idx(fmt);
2447 return idx+(fmt[idx]=='*');
2448 }
2449
2450 ALWAYS_INLINE(static int rb_scan_args_n_trail(const char *fmt));
2451 static inline int
2452 rb_scan_args_n_trail(const char *fmt)
2453 {
2454 const int idx = rb_scan_args_trail_idx(fmt);
2455 return (rb_scan_args_isdigit(fmt[idx]) ? fmt[idx]-'0' : 0);
2456 }
2457
2458 ALWAYS_INLINE(static int rb_scan_args_hash_idx(const char *fmt));
2459 static inline int
2460 rb_scan_args_hash_idx(const char *fmt)
2461 {
2462 const int idx = rb_scan_args_trail_idx(fmt);
2463 return idx+rb_scan_args_isdigit(fmt[idx]);
2464 }
2465
2466 ALWAYS_INLINE(static int rb_scan_args_f_hash(const char *fmt));
2467 static inline int
2468 rb_scan_args_f_hash(const char *fmt)
2469 {
2470 return (fmt[rb_scan_args_hash_idx(fmt)]==':');
2471 }
2472
2473 ALWAYS_INLINE(static int rb_scan_args_block_idx(const char *fmt));
2474 static inline int
2475 rb_scan_args_block_idx(const char *fmt)
2476 {
2477 const int idx = rb_scan_args_hash_idx(fmt);
2478 return idx+(fmt[idx]==':');
2479 }
2480
2481 ALWAYS_INLINE(static int rb_scan_args_f_block(const char *fmt));
2482 static inline int
2483 rb_scan_args_f_block(const char *fmt)
2484 {
2485 return (fmt[rb_scan_args_block_idx(fmt)]=='&');
2486 }
2487
2488 # if 0
2489 ALWAYS_INLINE(static int rb_scan_args_end_idx(const char *fmt));
2490 static inline int
2491 rb_scan_args_end_idx(const char *fmt)
2492 {
2493 const int idx = rb_scan_args_block_idx(fmt);
2494 return idx+(fmt[idx]=='&');
2495 }
2496 # endif
2497
2498 /* NOTE: Use `char *fmt` instead of `const char *fmt` because of clang's bug*/
2499 /* https://bugs.llvm.org/show_bug.cgi?id=38095 */
2500 # define rb_scan_args0(argc, argv, fmt, varc, vars) \
2501 rb_scan_args_set(argc, argv, \
2502 rb_scan_args_n_lead(fmt), \
2503 rb_scan_args_n_opt(fmt), \
2504 rb_scan_args_n_trail(fmt), \
2505 rb_scan_args_f_var(fmt), \
2506 rb_scan_args_f_hash(fmt), \
2507 rb_scan_args_f_block(fmt), \
2508 (rb_scan_args_verify(fmt, varc), vars), (char *)fmt, varc)
2509 ALWAYS_INLINE(static int
2510 rb_scan_args_set(int argc, const VALUE *argv,
2511 int n_lead, int n_opt, int n_trail,
2512 int f_var, int f_hash, int f_block,
2513 VALUE *vars[], char *fmt, int varc));
2514
2515 inline int
2516 rb_scan_args_set(int argc, const VALUE *argv,
2517 int n_lead, int n_opt, int n_trail,
2518 int f_var, int f_hash, int f_block,
2519 VALUE *vars[], RB_UNUSED_VAR(char *fmt), RB_UNUSED_VAR(int varc))
2520 # if defined(__has_attribute) && __has_attribute(diagnose_if)
2521 __attribute__((diagnose_if(rb_scan_args_count(fmt)<0,"bad scan arg format","error")))
2522 __attribute__((diagnose_if(rb_scan_args_count(fmt)!=varc,"variable argument length doesn't match","error")))
2523 # endif
2524 {
2525 int i, argi = 0, vari = 0, last_idx = -1;
2526 VALUE *var, hash = Qnil, last_hash = 0;
2527 const int n_mand = n_lead + n_trail;
2528 int keyword_given = rb_keyword_given_p();
2529 int empty_keyword_given = 0;
2530 VALUE tmp_buffer = 0;
2531
2532 if (!keyword_given) {
2533 empty_keyword_given = rb_empty_keyword_given_p();
2534 }
2535
2536 /* capture an option hash - phase 1: pop */
2537 /* Ignore final positional hash if empty keywords given */
2538 if (argc > 0 && !(f_hash && empty_keyword_given)) {
2539 VALUE last = argv[argc - 1];
2540
2541 if (f_hash && n_mand < argc) {
2542 if (keyword_given) {
2543 if (!RB_TYPE_P(last, T_HASH)) {
2544 rb_warn("Keyword flag set when calling rb_scan_args, but last entry is not a hash");
2545 }
2546 else {
2547 hash = last;
2548 }
2549 }
2550 else if (NIL_P(last)) {
2551 /* For backwards compatibility, nil is taken as an empty
2552 option hash only if it is not ambiguous; i.e. '*' is
2553 not specified and arguments are given more than sufficient.
2554 This will be removed in Ruby 3. */
2555 if (!f_var && n_mand + n_opt < argc) {
2556 rb_warn("The last argument is nil, treating as empty keywords");
2557 argc--;
2558 }
2559 }
2560 else {
2561 hash = rb_check_hash_type(last);
2562 }
2563
2564 /* Ruby 3: Remove if branch, as it will not attempt to split hashes */
2565 if (!NIL_P(hash)) {
2566 VALUE opts = rb_extract_keywords(&hash);
2567
2568 if (!(last_hash = hash)) {
2569 if (!keyword_given) {
2570 /* Warn if treating positional as keyword, as in Ruby 3,
2571 this will be an error */
2572 rb_warn("Using the last argument as keyword parameters is deprecated");
2573 }
2574 argc--;
2575 }
2576 else {
2577 /* Warn if splitting either positional hash to keywords or keywords
2578 to positional hash, as in Ruby 3, no splitting will be done */
2579 rb_warn("The last argument is split into positional and keyword parameters");
2580 last_idx = argc - 1;
2581 }
2582 hash = opts ? opts : Qnil;
2583 }
2584 }
2585 else if (f_hash && keyword_given && n_mand == argc) {
2586 /* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
2587 rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
2588 }
2589 }
2590 if (f_hash && n_mand > 0 && n_mand == argc+1 && empty_keyword_given) {
2591 VALUE *ptr = (VALUE *)rb_alloc_tmp_buffer2(&tmp_buffer, argc+1, sizeof(VALUE));
2592 memcpy(ptr, argv, sizeof(VALUE)*argc);
2593 ptr[argc] = rb_hash_new();
2594 argc++;
2595 *(&argv) = ptr;
2596 rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
2597 }
2598
2599
2600 if (argc < n_mand) {
2601 goto argc_error;
2602 }
2603
2604 /* capture leading mandatory arguments */
2605 for (i = n_lead; i-- > 0; ) {
2606 var = vars[vari++];
2607 if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
2608 argi++;
2609 }
2610 /* capture optional arguments */
2611 for (i = n_opt; i-- > 0; ) {
2612 var = vars[vari++];
2613 if (argi < argc - n_trail) {
2614 if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
2615 argi++;
2616 }
2617 else {
2618 if (var) *var = Qnil;
2619 }
2620 }
2621 /* capture variable length arguments */
2622 if (f_var) {
2623 int n_var = argc - argi - n_trail;
2624
2625 var = vars[vari++];
2626 if (0 < n_var) {
2627 if (var) {
2628 int f_last = (last_idx + 1 == argc - n_trail);
2629 *var = rb_ary_new4(n_var-f_last, &argv[argi]);
2630 if (f_last) rb_ary_push(*var, last_hash);
2631 }
2632 argi += n_var;
2633 }
2634 else {
2635 if (var) *var = rb_ary_new();
2636 }
2637 }
2638 /* capture trailing mandatory arguments */
2639 for (i = n_trail; i-- > 0; ) {
2640 var = vars[vari++];
2641 if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
2642 argi++;
2643 }
2644 /* capture an option hash - phase 2: assignment */
2645 if (f_hash) {
2646 var = vars[vari++];
2647 if (var) *var = hash;
2648 }
2649 /* capture iterator block */
2650 if (f_block) {
2651 var = vars[vari++];
2652 if (rb_block_given_p()) {
2653 *var = rb_block_proc();
2654 }
2655 else {
2656 *var = Qnil;
2657 }
2658 }
2659
2660 if (argi < argc) {
2661 argc_error:
2662 if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer);
2663 rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
2664 }
2665
2666 if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer);
2667 return argc;
2668 }
2669 #endif
2670
2671 #if defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
2672 # define rb_yield_values(argc, ...) \
2673 __extension__({ \
2674 const int rb_yield_values_argc = (argc); \
2675 const VALUE rb_yield_values_args[] = {__VA_ARGS__}; \
2676 const int rb_yield_values_nargs = \
2677 (int)(sizeof(rb_yield_values_args) / sizeof(VALUE)); \
2678 rb_yield_values2( \
2679 rb_varargs_argc_check(rb_yield_values_argc, rb_yield_values_nargs), \
2680 rb_yield_values_nargs ? rb_yield_values_args : NULL); \
2681 })
2682
2683 # define rb_funcall(recv, mid, argc, ...) \
2684 __extension__({ \
2685 const int rb_funcall_argc = (argc); \
2686 const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
2687 const int rb_funcall_nargs = \
2688 (int)(sizeof(rb_funcall_args) / sizeof(VALUE)); \
2689 rb_funcallv(recv, mid, \
2690 rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
2691 rb_funcall_nargs ? rb_funcall_args : NULL); \
2692 })
2693 #endif
2694
2695 #ifndef RUBY_DONT_SUBST
2696 #include "ruby/subst.h"
2697 #endif
2698
2715 void ruby_sysinit(int *argc, char ***argv);
2716 void ruby_init(void);
2717 void* ruby_options(int argc, char** argv);
2718 int ruby_executable_node(void *n, int *status);
2719 int ruby_run_node(void *n);
2720
2721 /* version.c */
2722 void ruby_show_version(void);
2723 void ruby_show_copyright(void);
2724
2725
2728 #define RUBY_INIT_STACK \
2729 VALUE variable_in_this_stack_frame; \
2730 ruby_init_stack(&variable_in_this_stack_frame);
2731
2733 void ruby_init_stack(volatile VALUE*);
2734
2735 int ruby_setup(void);
2736 int ruby_cleanup(volatile int);
2737
2738 void ruby_finalize(void);
2739 NORETURN(void ruby_stop(int));
2740
2741 void ruby_set_stack_size(size_t);
2742 int ruby_stack_check(void);
2743 size_t ruby_stack_length(VALUE**);
2744
2745 int ruby_exec_node(void *n);
2746
2747 void ruby_script(const char* name);
2748 void ruby_set_script_name(VALUE name);
2749
2750 void ruby_prog_init(void);
2751 void ruby_set_argv(int, char**);
2752 void *ruby_process_options(int, char**);
2753 void ruby_init_loadpath(void);
2754 void ruby_incpush(const char*);
2755 void ruby_sig_finalize(void);
2756
2759 #if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
2760 # include "ruby/backward.h"
2761 #endif
2762
2763 RUBY_SYMBOL_EXPORT_END
2764
2765 #if defined(__cplusplus)
2766 #if 0
2767 { /* satisfy cc-mode */
2768 #endif
2769 } /* extern "C" { */
2770 extern "C++" {
2771 #endif
2772
2773 #ifdef RB_METHOD_DEFINITION_DECL
2774
2775 RB_METHOD_DEFINITION_DECL(rb_define_method, (2,3), (VALUE klass, const char *name), (klass, name))
2776 #ifdef __cplusplus
2777 #define rb_define_method(m, n, f, a) rb_define_method_tmpl<a>::define(m, n, f)
2778 #else
2779 #define rb_define_method_if_constexpr(x, t, f) __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(x),(x),0),(t),(f))
2780 #define rb_define_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_method15,rb_define_methodm3)
2781 #define rb_define_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_method14,rb_define_method_choose_prototype15(n))
2782 #define rb_define_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_method13,rb_define_method_choose_prototype14(n))
2783 #define rb_define_method_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_method12,rb_define_method_choose_prototype13(n))
2784 #define rb_define_method_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_method11,rb_define_method_choose_prototype12(n))
2785 #define rb_define_method_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_method10,rb_define_method_choose_prototype11(n))
2786 #define rb_define_method_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_method9, rb_define_method_choose_prototype10(n))
2787 #define rb_define_method_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_method8, rb_define_method_choose_prototype9(n))
2788 #define rb_define_method_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_method7, rb_define_method_choose_prototype8(n))
2789 #define rb_define_method_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_method6, rb_define_method_choose_prototype7(n))
2790 #define rb_define_method_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_method5, rb_define_method_choose_prototype6(n))
2791 #define rb_define_method_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_method4, rb_define_method_choose_prototype5(n))
2792 #define rb_define_method_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_method3, rb_define_method_choose_prototype4(n))
2793 #define rb_define_method_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_method2, rb_define_method_choose_prototype3(n))
2794 #define rb_define_method_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_method1, rb_define_method_choose_prototype2(n))
2795 #define rb_define_method_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_method0, rb_define_method_choose_prototype1(n))
2796 #define rb_define_method_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_methodm1,rb_define_method_choose_prototype0(n))
2797 #define rb_define_method_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_methodm2,rb_define_method_choose_prototypem1(n))
2798 #define rb_define_method_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_methodm3,rb_define_method_choose_prototypem2(n))
2799 #define rb_define_method(klass, mid, func, arity) rb_define_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
2800 #endif
2801
2802 RB_METHOD_DEFINITION_DECL(rb_define_module_function, (2,3), (VALUE klass, const char *name), (klass, name))
2803 #ifdef __cplusplus
2804 #define rb_define_module_function(m, n, f, a) rb_define_module_function_tmpl<a>::define(m, n, f)
2805 #else
2806 #define rb_define_module_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_module_function15,rb_define_module_functionm3)
2807 #define rb_define_module_function_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_module_function14,rb_define_module_function_choose_prototype15(n))
2808 #define rb_define_module_function_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_module_function13,rb_define_module_function_choose_prototype14(n))
2809 #define rb_define_module_function_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_module_function12,rb_define_module_function_choose_prototype13(n))
2810 #define rb_define_module_function_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_module_function11,rb_define_module_function_choose_prototype12(n))
2811 #define rb_define_module_function_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_module_function10,rb_define_module_function_choose_prototype11(n))
2812 #define rb_define_module_function_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_module_function9, rb_define_module_function_choose_prototype10(n))
2813 #define rb_define_module_function_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_module_function8, rb_define_module_function_choose_prototype9(n))
2814 #define rb_define_module_function_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_module_function7, rb_define_module_function_choose_prototype8(n))
2815 #define rb_define_module_function_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_module_function6, rb_define_module_function_choose_prototype7(n))
2816 #define rb_define_module_function_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_module_function5, rb_define_module_function_choose_prototype6(n))
2817 #define rb_define_module_function_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_module_function4, rb_define_module_function_choose_prototype5(n))
2818 #define rb_define_module_function_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_module_function3, rb_define_module_function_choose_prototype4(n))
2819 #define rb_define_module_function_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_module_function2, rb_define_module_function_choose_prototype3(n))
2820 #define rb_define_module_function_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_module_function1, rb_define_module_function_choose_prototype2(n))
2821 #define rb_define_module_function_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_module_function0, rb_define_module_function_choose_prototype1(n))
2822 #define rb_define_module_function_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_module_functionm1,rb_define_module_function_choose_prototype0(n))
2823 #define rb_define_module_function_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_module_functionm2,rb_define_module_function_choose_prototypem1(n))
2824 #define rb_define_module_function_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_module_functionm3,rb_define_module_function_choose_prototypem2(n))
2825 #define rb_define_module_function(klass, mid, func, arity) rb_define_module_function_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
2826 #endif
2827
2828 RB_METHOD_DEFINITION_DECL(rb_define_global_function, (1,2), (const char *name), (name))
2829 #ifdef __cplusplus
2830 #define rb_define_global_function(n, f, a) rb_define_global_function_tmpl<a>::define(n, f)
2831 #else
2832 #define rb_define_global_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_global_function15,rb_define_global_functionm3)
2833 #define rb_define_global_function_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_global_function14,rb_define_global_function_choose_prototype15(n))
2834 #define rb_define_global_function_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_global_function13,rb_define_global_function_choose_prototype14(n))
2835 #define rb_define_global_function_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_global_function12,rb_define_global_function_choose_prototype13(n))
2836 #define rb_define_global_function_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_global_function11,rb_define_global_function_choose_prototype12(n))
2837 #define rb_define_global_function_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_global_function10,rb_define_global_function_choose_prototype11(n))
2838 #define rb_define_global_function_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_global_function9, rb_define_global_function_choose_prototype10(n))
2839 #define rb_define_global_function_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_global_function8, rb_define_global_function_choose_prototype9(n))
2840 #define rb_define_global_function_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_global_function7, rb_define_global_function_choose_prototype8(n))
2841 #define rb_define_global_function_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_global_function6, rb_define_global_function_choose_prototype7(n))
2842 #define rb_define_global_function_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_global_function5, rb_define_global_function_choose_prototype6(n))
2843 #define rb_define_global_function_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_global_function4, rb_define_global_function_choose_prototype5(n))
2844 #define rb_define_global_function_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_global_function3, rb_define_global_function_choose_prototype4(n))
2845 #define rb_define_global_function_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_global_function2, rb_define_global_function_choose_prototype3(n))
2846 #define rb_define_global_function_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_global_function1, rb_define_global_function_choose_prototype2(n))
2847 #define rb_define_global_function_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_global_function0, rb_define_global_function_choose_prototype1(n))
2848 #define rb_define_global_function_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_global_functionm1,rb_define_global_function_choose_prototype0(n))
2849 #define rb_define_global_function_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_global_functionm2,rb_define_global_function_choose_prototypem1(n))
2850 #define rb_define_global_function_choose_prototypem3(n, f) rb_define_method_if_constexpr(rb_f_notimplement_p(f),rb_define_global_functionm3,rb_define_global_function_choose_prototypem2(n))
2851 #define rb_define_global_function(mid, func, arity) rb_define_global_function_choose_prototypem3((arity),(func))((mid),(func),(arity));
2852 #endif
2853
2854 #endif
2855
2856 #if defined(RUBY_DEVEL) && RUBY_DEVEL && (!defined(__cplusplus) || defined(RB_METHOD_DEFINITION_DECL))
2857 # define RUBY_METHOD_FUNC(func) (func)
2858 #else
2859 # define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))(func))
2860 #endif
2861
2862 #ifdef __cplusplus
2863 #include "backward/cxxanyargs.hpp"
2864
2865 #if 0
2866 { /* satisfy cc-mode */
2867 #endif
2868 } /* extern "C++" { */
2869 #endif
2870
2871 #endif /* RUBY_RUBY_H */
f_hash
const VALUE int int int int int f_hash
Definition: rb_mjit_min_header-2.7.0.h:6462
rb_obj_infect
void rb_obj_infect(VALUE victim, VALUE carrier)
Does nothing.
Definition: object.c:1068
ruby_brace_glob
int ruby_brace_glob(const char *, int, ruby_glob_func *, VALUE)
Definition: dir.c:2659
RB_LONG2FIX
#define RB_LONG2FIX(i)
Definition: ruby.h:264
rb_gv_set
VALUE rb_gv_set(const char *, VALUE)
Definition: variable.c:671
rb_check_symbol
VALUE rb_check_symbol(volatile VALUE *namep)
Definition: symbol.c:952
rb_str_export_locale
VALUE rb_str_export_locale(VALUE)
Definition: string.c:1129
RUBY_T_STRING
@ RUBY_T_STRING
Definition: ruby.h:493
__attribute__
unsigned int UINT8 __attribute__((__mode__(__QI__)))
Definition: ffi_common.h:110
ruby_stop
void ruby_stop(int ex)
Calls ruby_cleanup() and exits the process.
Definition: eval.c:287
RARRAY_TRANSIENT_P
#define RARRAY_TRANSIENT_P(ary)
Definition: ruby.h:1076
ruby_check_sizeof_long_long
char ruby_check_sizeof_long_long[8==sizeof(long long) ? 1 :-1]
Definition: rb_mjit_min_header-2.7.0.h:3997
FL_FINALIZE
#define FL_FINALIZE
Definition: ruby.h:1282
rb_eSystemCallError
RUBY_EXTERN VALUE rb_eSystemCallError
Definition: ruby.h:2068
ID
unsigned long ID
Definition: ruby.h:103
RUBY_T_ARRAY
@ RUBY_T_ARRAY
Definition: ruby.h:495
RUBY_SYMBOL_EXPORT_END
#define RUBY_SYMBOL_EXPORT_END
Definition: missing.h:49
rb_num2short
short rb_num2short(VALUE)
Definition: numeric.c:3041
f_var
const VALUE int int int int f_var
Definition: rb_mjit_min_header-2.7.0.h:6462
RUBY_FLONUM_FLAG
@ RUBY_FLONUM_FLAG
Definition: ruby.h:446
ruby_stack_length
size_t ruby_stack_length(VALUE **)
Definition: gc.c:4631
rb_id2name
const char * rb_id2name(ID)
Definition: symbol.c:801
void
void
Definition: rb_mjit_min_header-2.7.0.h:13273
rb_cDir
RUBY_EXTERN VALUE rb_cDir
Definition: ruby.h:2019
rb_safe_level
int rb_safe_level(void)
Definition: safe.c:31
RB_UNLIKELY
#define RB_UNLIKELY(x)
Definition: defines.h:92
rb_big_sign
int rb_big_sign(VALUE)
Definition: bignum.c:6772
Check_Type
#define Check_Type(v, t)
Definition: ruby.h:595
ruby_set_stack_size
void ruby_set_stack_size(size_t)
RUBY_T_STRUCT
@ RUBY_T_STRUCT
Definition: ruby.h:497
rb_newobj
VALUE rb_newobj(void)
Definition: gc.c:2288
rb_check_id
ID rb_check_id(volatile VALUE *)
Returns ID for the given name if it is interned already, or 0.
Definition: symbol.c:919
ruby_safe_level_2_warning
int ruby_safe_level_2_warning(void)
Definition: safe.c:24
rb_cHash
RUBY_EXTERN VALUE rb_cHash
Definition: ruby.h:2029
ruby_rmodule_flags
ruby_rmodule_flags
Definition: ruby.h:954
FIX_CONST_VALUE_PTR
#define FIX_CONST_VALUE_PTR(x)
Definition: ruby.h:2178
RUBY_Qfalse
#define RUBY_Qfalse
Definition: ruby.h:463
ruby_snprintf
int ruby_snprintf(char *str, size_t n, char const *fmt,...)
Definition: sprintf.c:1031
vars
const VALUE int int int int int int VALUE * vars[]
Definition: rb_mjit_min_header-2.7.0.h:6462
RTypedData::type
const rb_data_type_t * type
Definition: ruby.h:1170
rb_obj_hide
VALUE rb_obj_hide(VALUE obj)
Make the object invisible from Ruby code.
Definition: object.c:78
rb_rescue2
VALUE rb_rescue2(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE,...)
An equivalent of rescue clause.
Definition: eval.c:961
rb_mEnumerable
RUBY_EXTERN VALUE rb_mEnumerable
Definition: ruby.h:2000
ruby_options
void * ruby_options(int argc, char **argv)
Processes command line arguments and compiles the Ruby source to execute.
Definition: eval.c:114
RUBY_FL_WB_PROTECTED
@ RUBY_FL_WB_PROTECTED
Definition: ruby.h:842
rb_cData
RUBY_EXTERN VALUE rb_cData
Definition: ruby.h:2018
rb_check_type
void rb_check_type(VALUE, int)
Definition: error.c:837
LONG_MAX
#define LONG_MAX
Definition: ruby.h:220
rb_block_call
VALUE rb_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:1470
RUBY_Qundef
#define RUBY_Qundef
Definition: ruby.h:466
ruby_value_type
ruby_value_type
Definition: ruby.h:486
rb_cUnboundMethod
RUBY_EXTERN VALUE rb_cUnboundMethod
Definition: ruby.h:2050
rb_eTypeError
RUBY_EXTERN VALUE rb_eTypeError
Definition: ruby.h:2070
rb_hash_new
VALUE rb_hash_new(void)
Definition: hash.c:1501
rb_gc_register_mark_object
void rb_gc_register_mark_object(VALUE)
Definition: gc.c:7063
ruby_malloc_size_overflow
void ruby_malloc_size_overflow(size_t count, size_t elsize)
Definition: gc.c:10074
rb_iterate
VALUE rb_iterate(VALUE(*)(VALUE), VALUE, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:1444
ruby_show_version
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
Definition: version.c:119
rb_cBignum
#define rb_cBignum
Definition: internal.h:1312
rb_warn
void rb_warn(const char *fmt,...)
Definition: error.c:313
rb_yield_block
VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
rb_intern
ID rb_intern(const char *)
Definition: symbol.c:660
rb_check_safe_obj
void rb_check_safe_obj(VALUE)
Definition: safe.c:136
ruby_exec_node
int ruby_exec_node(void *n)
Runs the given compiled source.
Definition: eval.c:340
rb_stderr
RUBY_EXTERN VALUE rb_stderr
Definition: ruby.h:2090
RUBY_FL_FREEZE
@ RUBY_FL_FREEZE
Definition: ruby.h:851
RUBY_FL_USHIFT
@ RUBY_FL_USHIFT
Definition: ruby.h:853
rb_current_receiver
VALUE rb_current_receiver(void)
Definition: vm_eval.c:314
rb_warning
void rb_warning(const char *fmt,...)
Definition: error.c:334
size_t
long unsigned int size_t
Definition: rb_mjit_min_header-2.7.0.h:666
RMODULE_IS_REFINEMENT
#define RMODULE_IS_REFINEMENT
Definition: ruby.h:952
RB_BUILTIN_TYPE
#define RB_BUILTIN_TYPE(x)
Definition: ruby.h:550
rb_eFatal
RUBY_EXTERN VALUE rb_eFatal
Definition: ruby.h:2057
rb_mGC
RUBY_EXTERN VALUE rb_mGC
Definition: ruby.h:2003
COLDFUNC
#define COLDFUNC
Definition: defines.h:102
RARRAY_EMBED_FLAG
#define RARRAY_EMBED_FLAG
Definition: ruby.h:1043
rb_cNumeric
RUBY_EXTERN VALUE rb_cNumeric
Definition: ruby.h:2037
ruby_rvalue_flags
ruby_rvalue_flags
Definition: ruby.h:909
rb_funcallv_kw
VALUE rb_funcallv_kw(VALUE, ID, int, const VALUE *, int)
Definition: vm_eval.c:962
rb_yield_values_kw
VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:1277
rb_fix2short
short rb_fix2short(VALUE)
Definition: numeric.c:3050
rb_eNameError
RUBY_EXTERN VALUE rb_eNameError
Definition: ruby.h:2084
rb_eStopIteration
RUBY_EXTERN VALUE rb_eStopIteration
Definition: ruby.h:2061
RB_IO_WAIT_WRITABLE
#define RB_IO_WAIT_WRITABLE
Definition: ruby.h:1931
RUBY_FL_UNTRUSTED
@ RUBY_FL_UNTRUSTED
Definition: ruby.h:848
ruby_rstring_flags
ruby_rstring_flags
Definition: ruby.h:977
rb_mComparable
RUBY_EXTERN VALUE rb_mComparable
Definition: ruby.h:1999
rb_to_symbol
VALUE rb_to_symbol(VALUE name)
Definition: string.c:11156
RUBY_IMMEDIATE_MASK
@ RUBY_IMMEDIATE_MASK
Definition: ruby.h:443
RObject
Definition: ruby.h:922
rb_funcallv
VALUE rb_funcallv(VALUE, ID, int, const VALUE *)
Calls a method.
Definition: vm_eval.c:956
RUBY_ELTS_SHARED
#define RUBY_ELTS_SHARED
Definition: ruby.h:969
RUBY_ATTR_ALLOC_SIZE
#define RUBY_ATTR_ALLOC_SIZE(params)
Definition: defines.h:226
RSTRING_PTR
#define RSTRING_PTR(str)
Definition: ruby.h:1009
rb_empty_keyword_given_p
int rb_empty_keyword_given_p(void)
Definition: eval.c:918
rb_cComplex
RUBY_EXTERN VALUE rb_cComplex
Definition: ruby.h:2027
rb_bug_errno
void rb_bug_errno(const char *mesg, int errno_arg)
Definition: error.c:667
LONG_LONG
#define LONG_LONG
Definition: rb_mjit_min_header-2.7.0.h:3939
rb_uint2inum
VALUE rb_uint2inum(uintptr_t)
Definition: bignum.c:3201
rb_gvar_var_setter
rb_gvar_setter_t rb_gvar_var_setter
Definition: ruby.h:1795
rb_data_type_struct::parent
const rb_data_type_t * parent
Definition: ruby.h:1158
rb_throw_obj
void rb_throw_obj(VALUE tag, VALUE value)
Definition: vm_eval.c:2193
rb_eLoadError
RUBY_EXTERN VALUE rb_eLoadError
Definition: ruby.h:2086
rb_equal
VALUE rb_equal(VALUE, VALUE)
Same as Object#===, case equality.
Definition: object.c:124
rb_eInterrupt
RUBY_EXTERN VALUE rb_eInterrupt
Definition: ruby.h:2055
rb_singleton_class_clone
VALUE rb_singleton_class_clone(VALUE obj)
Definition: class.c:370
rb_float_new
VALUE rb_float_new(double)
Definition: numeric.c:5841
RUBY_SPECIAL_SHIFT
@ RUBY_SPECIAL_SHIFT
Definition: ruby.h:460
rb_gvar_readonly_setter
void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_)
Definition: variable.c:412
rb_data_type_struct::flags
VALUE flags
Definition: ruby.h:1161
VALUE
unsigned long VALUE
Definition: ruby.h:102
rb_funcallv_public
VALUE rb_funcallv_public(VALUE, ID, int, const VALUE *)
Calls a method.
Definition: vm_eval.c:980
RUBY_T_FLOAT
@ RUBY_T_FLOAT
Definition: ruby.h:492
rb_cMethod
RUBY_EXTERN VALUE rb_cMethod
Definition: ruby.h:2033
RUBY_T_NIL
@ RUBY_T_NIL
Definition: ruby.h:505
RUBY_FL_PROMOTED
@ RUBY_FL_PROMOTED
Definition: ruby.h:845
RUBY_DATA_FUNC
void(* RUBY_DATA_FUNC)(void *)
Definition: ruby.h:1184
RB_TYPE_P
#define RB_TYPE_P(obj, type)
Definition: ruby.h:560
rb_eSystemExit
RUBY_EXTERN VALUE rb_eSystemExit
Definition: ruby.h:2054
ruby_run_node
int ruby_run_node(void *n)
Runs the given compiled source and exits this process.
Definition: eval.c:326
rb_cModule
RUBY_EXTERN VALUE rb_cModule
Definition: ruby.h:2034
rb_cTime
RUBY_EXTERN VALUE rb_cTime
Definition: ruby.h:2048
rb_cProc
RUBY_EXTERN VALUE rb_cProc
Definition: ruby.h:2038
SIZEOF_INT
#define SIZEOF_INT
Definition: rb_mjit_min_header-2.7.0.h:83
rb_float_value
double rb_float_value(VALUE v)
Definition: numeric.c:5834
rb_define_module_under
VALUE rb_define_module_under(VALUE, const char *)
Definition: class.c:797
rb_data_object_wrap_warning
#define rb_data_object_wrap_warning(klass, ptr, mark, free)
Definition: rb_mjit_min_header-2.7.0.h:4905
rb_ary_ptr_use_start
VALUE * rb_ary_ptr_use_start(VALUE ary)
Definition: array.c:226
int
__inline__ int
Definition: rb_mjit_min_header-2.7.0.h:2839
RUBY_T_NODE
@ RUBY_T_NODE
Definition: ruby.h:513
subst.h
rb_eRuntimeError
RUBY_EXTERN VALUE rb_eRuntimeError
Definition: ruby.h:2065
rb_cFloat
RUBY_EXTERN VALUE rb_cFloat
Definition: ruby.h:2028
RUBY_T_NONE
@ RUBY_T_NONE
Definition: ruby.h:487
SIGNED_VALUE
#define SIGNED_VALUE
Definition: ruby.h:104
rb_call_super
VALUE rb_call_super(int, const VALUE *)
Definition: vm_eval.c:306
rb_funcall_passing_block_kw
VALUE rb_funcall_passing_block_kw(VALUE, ID, int, const VALUE *, int)
Definition: vm_eval.c:1039
PRINTF_ARGS
PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char *,...)), 2, 3)
assert.h
RMODULE_ENUM_END
@ RMODULE_ENUM_END
Definition: ruby.h:959
ruby_stack_check
int ruby_stack_check(void)
Definition: gc.c:4671
rb_stdin
RUBY_EXTERN VALUE rb_stdin
Definition: ruby.h:2090
RRegexp::ptr
struct re_pattern_buffer * ptr
Definition: ruby.h:1114
rb_define_readonly_variable
void rb_define_readonly_variable(const char *, const VALUE *)
Definition: variable.c:505
rb_mWaitReadable
RUBY_EXTERN VALUE rb_mWaitReadable
Definition: ruby.h:2006
rb_gvar_getter_t
VALUE rb_gvar_getter_t(ID id, VALUE *data)
Definition: ruby.h:1782
rb_mod_syserr_fail
void rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
Definition: error.c:2849
rb_catch_obj
VALUE rb_catch_obj(VALUE, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:2330
rb_ruby_debug_ptr
VALUE * rb_ruby_debug_ptr(void)
Definition: vm.c:3379
RArray::@97::@98::ptr
const VALUE * ptr
Definition: ruby.h:1062
RUBY_T_UNDEF
@ RUBY_T_UNDEF
Definition: ruby.h:510
rb_eIOError
RUBY_EXTERN VALUE rb_eIOError
Definition: ruby.h:2064
RData::data
void * data
Definition: ruby.h:1143
rb_prepend_module
void rb_prepend_module(VALUE, VALUE)
Definition: class.c:999
RUBY_T_RATIONAL
@ RUBY_T_RATIONAL
Definition: ruby.h:503
ptr
struct RIMemo * ptr
Definition: debug.c:74
RB_FIX2ULONG
#define RB_FIX2ULONG(x)
Definition: ruby.h:384
SIZEOF_LONG_LONG
#define SIZEOF_LONG_LONG
Definition: rb_mjit_min_header-2.7.0.h:86
RUBY_T_FILE
@ RUBY_T_FILE
Definition: ruby.h:499
RUBY_T_TRUE
@ RUBY_T_TRUE
Definition: ruby.h:506
RSTRING_EMBED_LEN_MAX
#define RSTRING_EMBED_LEN_MAX
Definition: ruby.h:975
rb_define_attr
void rb_define_attr(VALUE, const char *, int, int)
Defines (a) public accessor method(s) for an attribute.
Definition: class.c:1813
rb_num2long
long rb_num2long(VALUE)
Definition: numeric.c:2849
uintptr_t
unsigned int uintptr_t
Definition: win32.h:106
RTypedData::data
void * data
Definition: ruby.h:1172
rb_stdout
RUBY_EXTERN VALUE rb_stdout
Definition: ruby.h:2090
rb_cClass
RUBY_EXTERN VALUE rb_cClass
Definition: ruby.h:2016
rb_gvar_setter_t
void rb_gvar_setter_t(VALUE val, ID id, VALUE *data)
Definition: ruby.h:1783
rb_cRational
RUBY_EXTERN VALUE rb_cRational
Definition: ruby.h:2041
DSIZE_T
#define DSIZE_T
Definition: rb_mjit_min_header-2.7.0.h:5045
rb_cInteger
RUBY_EXTERN VALUE rb_cInteger
Definition: ruby.h:2031
rb_gvar_undef_setter
rb_gvar_setter_t rb_gvar_undef_setter
Definition: ruby.h:1787
ruby_finalize
void ruby_finalize(void)
Runs the VM finalization processes.
Definition: eval.c:162
ruby_setup
int ruby_setup(void)
Initializes the VM and builtin libraries.
Definition: eval.c:55
rb_fix2ushort
unsigned short rb_fix2ushort(VALUE)
Definition: numeric.c:3069
uint32_t
unsigned int uint32_t
Definition: sha2.h:101
rb_eval_string_wrap
VALUE rb_eval_string_wrap(const char *, int *)
Evaluates the given string under a module binding in an isolated binding.
Definition: vm_eval.c:1767
rb_float_new_in_heap
VALUE rb_float_new_in_heap(double)
Definition: numeric.c:895
rb_typeddata_inherited_p
int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent)
Definition: error.c:862
RB_OBJ_FREEZE_RAW
#define RB_OBJ_FREEZE_RAW(x)
Definition: ruby.h:1343
ERRORFUNC
#define ERRORFUNC(mesg, x)
Definition: defines.h:52
RUBY_UNTYPED_DATA_FUNC
#define RUBY_UNTYPED_DATA_FUNC(func)
Definition: ruby.h:1397
rb_funcallv_public_kw
VALUE rb_funcallv_public_kw(VALUE, ID, int, const VALUE *, int)
Definition: vm_eval.c:986
rb_uint2big
VALUE rb_uint2big(uintptr_t)
Definition: bignum.c:3158
rb_eEncCompatError
RUBY_EXTERN VALUE rb_eEncCompatError
Definition: ruby.h:2080
rb_readwrite_syserr_fail
void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite writable, int n, const char *mesg)
Definition: io.c:12929
RUBY_T_MASK
@ RUBY_T_MASK
Definition: ruby.h:518
RSTRING_ENUM_END
@ RSTRING_ENUM_END
Definition: ruby.h:985
last
unsigned int last
Definition: nkf.c:4324
rb_fatal
void rb_fatal(const char *fmt,...)
Definition: error.c:2720
rb_gvar_marker_t
void rb_gvar_marker_t(VALUE *var)
Definition: ruby.h:1784
RB_FL_TEST_RAW
#define RB_FL_TEST_RAW(x, f)
Definition: ruby.h:1316
rb_define_hooked_variable
void rb_define_hooked_variable(const char *, VALUE *, rb_gvar_getter_t *, rb_gvar_setter_t *)
Define a function-backended global variable.
Definition: cxxanyargs.hpp:106
error
const rb_iseq_t const char * error
Definition: rb_mjit_min_header-2.7.0.h:13506
rb_gc_guarded_ptr_val
volatile VALUE * rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
Definition: gc.c:250
rb_funcall_with_block_kw
VALUE rb_funcall_with_block_kw(VALUE, ID, int, const VALUE *, VALUE, int)
Definition: vm_eval.c:1060
rb_free_tmp_buffer
void void rb_free_tmp_buffer(volatile VALUE *store)
Definition: gc.c:10257
rb_syserr_new
VALUE rb_syserr_new(int, const char *)
Definition: error.c:2767
rb_alloc_tmp_buffer
void * rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2))
Definition: gc.c:10245
RB_UNUSED_VAR
#define RB_UNUSED_VAR(x)
Definition: ruby.h:591
RUBY_Qtrue
#define RUBY_Qtrue
Definition: ruby.h:464
rb_eException
RUBY_EXTERN VALUE rb_eException
Definition: ruby.h:2052
ruby_safe_level_2_error
int ruby_safe_level_2_error(void) __attribute__((error("$SAFE
RB_FIX2LONG
#define RB_FIX2LONG(x)
Definition: ruby.h:378
ruby_check_sizeof_voidp
char ruby_check_sizeof_voidp[SIZEOF_VOIDP==sizeof(void *) ? 1 :-1]
Definition: ruby.h:123
RB_BLOCK_CALL_FUNC_ARGLIST
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Definition: ruby.h:1964
rb_data_type_struct::wrap_struct_name
const char * wrap_struct_name
Definition: ruby.h:1149
ruby_cleanup
int ruby_cleanup(volatile int)
Destructs the VM.
Definition: eval.c:180
RTypedData
Definition: ruby.h:1168
v
int VALUE v
Definition: rb_mjit_min_header-2.7.0.h:12332
rb_cRange
RUBY_EXTERN VALUE rb_cRange
Definition: ruby.h:2040
rb_extract_keywords
VALUE rb_extract_keywords(VALUE *orighash)
Definition: class.c:1868
rb_funcall_passing_block
VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE *)
Definition: vm_eval.c:1032
rb_gc_writebarrier
void rb_gc_writebarrier(VALUE a, VALUE b)
Definition: gc.c:6817
rb_data_typed_object_wrap
VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *)
Definition: gc.c:2397
rb_exit
void rb_exit(int status)
Definition: process.c:4190
UNLIMITED_ARGUMENTS
#define UNLIMITED_ARGUMENTS
Definition: intern.h:57
ruby_init
void ruby_init(void)
Calls ruby_setup() and check error.
Definition: eval.c:93
rb_raise
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2669
rb_eNoMatchingPatternError
RUBY_EXTERN VALUE rb_eNoMatchingPatternError
Definition: ruby.h:2081
RARRAY_EMBED_LEN_SHIFT
#define RARRAY_EMBED_LEN_SHIFT
Definition: ruby.h:1046
rb_notimplement
void rb_notimplement(void)
Definition: error.c:2712
defines.h
rb_each
VALUE rb_each(VALUE)
Definition: vm_eval.c:1542
FL_PROMOTED0
#define FL_PROMOTED0
Definition: ruby.h:1280
n_trail
const VALUE int int int n_trail
Definition: rb_mjit_min_header-2.7.0.h:6462
RUBY_FL_PROMOTED0
@ RUBY_FL_PROMOTED0
Definition: ruby.h:843
rb_set_safe_level_force
void rb_set_safe_level_force(int)
Definition: safe.c:38
rb_ull2inum
VALUE rb_ull2inum(unsigned long long)
rb_cMatch
RUBY_EXTERN VALUE rb_cMatch
Definition: ruby.h:2032
obj
const VALUE VALUE obj
Definition: rb_mjit_min_header-2.7.0.h:5742
SIZEOF_LONG
#define SIZEOF_LONG
Definition: rb_mjit_min_header-2.7.0.h:85
rb_obj_class
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
Definition: object.c:217
NORETURN
NORETURN(void rb_insecure_operation(void))
rb_eKeyError
RUBY_EXTERN VALUE rb_eKeyError
Definition: ruby.h:2062
RObject::@92::@93::ivptr
VALUE * ivptr
Definition: ruby.h:927
rb_data_typed_object_zalloc
VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
rb_eSysStackError
RUBY_EXTERN VALUE rb_eSysStackError
Definition: ruby.h:2077
ruby_prog_init
void ruby_prog_init(void)
Defines built-in variables.
Definition: ruby.c:2341
memcpy
void * memcpy(void *__restrict, const void *__restrict, size_t)
ruby_incpush
void ruby_incpush(const char *)
Definition: ruby.c:426
RString::@94::@95::@96::capa
long capa
Definition: ruby.h:995
rb_cNilClass
RUBY_EXTERN VALUE rb_cNilClass
Definition: ruby.h:2036
rb_syserr_fail
void rb_syserr_fail(int e, const char *mesg)
Definition: error.c:2781
RUBY_T_DATA
@ RUBY_T_DATA
Definition: ruby.h:500
rb_define_class
VALUE rb_define_class(const char *, VALUE)
Defines a top-level class.
Definition: class.c:649
ROBJECT_EMBED
#define ROBJECT_EMBED
Definition: ruby.h:914
rb_hash_size_num
size_t rb_hash_size_num(VALUE hash)
Definition: hash.c:2872
RUBY_FL_EXIVAR
@ RUBY_FL_EXIVAR
Definition: ruby.h:850
rb_gvar_undef_marker
rb_gvar_marker_t rb_gvar_undef_marker
Definition: ruby.h:1788
RFile::fptr
struct rb_io_t * fptr
Definition: ruby.h:1136
RARRAY_ENUM_END
@ RARRAY_ENUM_END
Definition: ruby.h:1041
rb_gc_unregister_address
void rb_gc_unregister_address(VALUE *)
Definition: gc.c:7089
RUBY_SYMBOL_FLAG
@ RUBY_SYMBOL_FLAG
Definition: ruby.h:447
intern.h
ruby_process_options
void * ruby_process_options(int, char **)
Definition: ruby.c:2387
ruby_check_sizeof_long
char ruby_check_sizeof_long[SIZEOF_LONG==sizeof(long) ? 1 :-1]
Definition: ruby.h:119
rb_cBasicObject
RUBY_EXTERN VALUE rb_cBasicObject
Definition: ruby.h:2009
TypedData_Make_Struct0
#define TypedData_Make_Struct0(result, klass, type, size, data_type, sval)
Definition: ruby.h:1234
rb_block_given_p
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition: eval.c:897
RUBY_T_FIXNUM
@ RUBY_T_FIXNUM
Definition: ruby.h:509
ruby_init_stack
void ruby_init_stack(volatile VALUE *)
RB_TEST
#define RB_TEST(v)
Definition: ruby.h:479
rb_iv_get
VALUE rb_iv_get(VALUE, const char *)
Definition: variable.c:3294
RSTRING_EMBED_LEN_SHIFT
#define RSTRING_EMBED_LEN_SHIFT
Definition: ruby.h:974
rb_scan_args_kw
int rb_scan_args_kw(int, int, const VALUE *, const char *,...)
Definition: class.c:2180
RRegexp
Definition: ruby.h:1112
rb_get_kwargs
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *)
Definition: class.c:1886
rb_insecure_operation
void rb_insecure_operation(void)
Definition: safe.c:122
i
uint32_t i
Definition: rb_mjit_min_header-2.7.0.h:5464
rb_singleton_class_attached
void rb_singleton_class_attached(VALUE klass, VALUE obj)
Attach a object to a singleton class.
Definition: class.c:426
rb_eRegexpError
RUBY_EXTERN VALUE rb_eRegexpError
Definition: ruby.h:2078
rb_cSymbol
RUBY_EXTERN VALUE rb_cSymbol
Definition: ruby.h:2046
rb_extend_object
void rb_extend_object(VALUE, VALUE)
Extend the object with the module.
Definition: eval.c:1700
RFile
Definition: ruby.h:1134
rb_id2sym
VALUE rb_id2sym(ID)
Definition: symbol.c:776
rb_eFloatDomainError
RUBY_EXTERN VALUE rb_eFloatDomainError
Definition: ruby.h:2075
rb_eEOFError
RUBY_EXTERN VALUE rb_eEOFError
Definition: ruby.h:2059
rb_alloc_tmp_buffer_with_count
void * rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len, size_t count) RUBY_ATTR_ALLOC_SIZE((2
rb_yield_splat
VALUE rb_yield_splat(VALUE)
Definition: vm_eval.c:1283
rb_compile_warning
void rb_compile_warning(const char *file, int line, const char *fmt,...)
Definition: error.c:285
rb_to_id
ID rb_to_id(VALUE)
Definition: string.c:11146
rb_int2big
VALUE rb_int2big(intptr_t)
Definition: bignum.c:3180
ruby_robject_flags
ruby_robject_flags
Definition: ruby.h:915
ruby_strtoul
unsigned long ruby_strtoul(const char *str, char **endptr, int base)
Definition: util.c:130
RObject::@92::@93::iv_index_tbl
void * iv_index_tbl
Definition: ruby.h:928
long
#define long
Definition: rb_mjit_min_header-2.7.0.h:2880
rb_fix2int
long rb_fix2int(VALUE val)
Definition: numeric.c:3003
rb_gc_writebarrier_unprotect
void rb_gc_writebarrier_unprotect(VALUE obj)
Definition: gc.c:6838
rb_p
void rb_p(VALUE)
Definition: io.c:7798
rb_data_object_get
#define rb_data_object_get
Definition: rb_mjit_min_header-2.7.0.h:4946
rb_eSecurityError
RUBY_EXTERN VALUE rb_eSecurityError
Definition: ruby.h:2067
rb_eArgError
RUBY_EXTERN VALUE rb_eArgError
Definition: ruby.h:2058
rb_errinfo
VALUE rb_errinfo(void)
The current exception in the current thread.
Definition: eval.c:1881
rb_ary_push
VALUE rb_ary_push(VALUE ary, VALUE item)
Definition: array.c:1195
rb_num2ushort
unsigned short rb_num2ushort(VALUE)
Definition: numeric.c:3059
st_locale_insensitive_strncasecmp
int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: st.c:2107
rb_newobj_of
VALUE rb_newobj_of(VALUE, VALUE)
Definition: gc.c:2294
rb_gvar_undef_getter
rb_gvar_getter_t rb_gvar_undef_getter
Definition: ruby.h:1786
RUBY_FL_USER_N
#define RUBY_FL_USER_N(n)
Definition: ruby.h:855
rb_num2ulong
unsigned long rb_num2ulong(VALUE)
Definition: numeric.c:2918
rb_eZeroDivError
RUBY_EXTERN VALUE rb_eZeroDivError
Definition: ruby.h:2071
cnt
rb_atomic_t cnt[RUBY_NSIG]
Definition: signal.c:503
rb_vrescue2
VALUE rb_vrescue2(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE, va_list)
An equivalent of rescue clause.
Definition: eval.c:976
rb_block_call_func
VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
Definition: ruby.h:1966
rb_mod_sys_fail
void rb_mod_sys_fail(VALUE mod, const char *mesg)
Definition: error.c:2833
ruby_show_copyright
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout.
Definition: version.c:138
ruby_script
void ruby_script(const char *name)
Sets the current script name to this value.
Definition: ruby.c:2277
ruby_rarray_flags
ruby_rarray_flags
Definition: ruby.h:1027
RB_FLONUM_P
#define RB_FLONUM_P(x)
Definition: ruby.h:426
rb_sys_fail
void rb_sys_fail(const char *mesg)
Definition: error.c:2793
rb_gvar_val_getter
rb_gvar_getter_t rb_gvar_val_getter
Definition: ruby.h:1790
rb_require
VALUE rb_require(const char *)
Definition: load.c:1118
ROBJECT_ENUM_END
@ ROBJECT_ENUM_END
Definition: ruby.h:919
RUBY_T_BIGNUM
@ RUBY_T_BIGNUM
Definition: ruby.h:498
RBASIC_CLASS
#define RBASIC_CLASS(obj)
Definition: ruby.h:906
ROBJECT_EMBED_LEN_MAX
#define ROBJECT_EMBED_LEN_MAX
Definition: ruby.h:913
rb_copy_generic_ivar
void rb_copy_generic_ivar(VALUE, VALUE)
Definition: variable.c:1447
rb_cFalseClass
RUBY_EXTERN VALUE rb_cFalseClass
Definition: ruby.h:2022
RUBY_Qnil
#define RUBY_Qnil
Definition: ruby.h:465
RUBY_FLONUM_MASK
@ RUBY_FLONUM_MASK
Definition: ruby.h:445
RUBY_T_CLASS
@ RUBY_T_CLASS
Definition: ruby.h:490
rb_scan_args_isdigit
#define rb_scan_args_isdigit(c)
Definition: rb_mjit_min_header-2.7.0.h:6375
rb_gvar_var_getter
rb_gvar_getter_t rb_gvar_var_getter
Definition: ruby.h:1794
rb_eNotImpError
RUBY_EXTERN VALUE rb_eNotImpError
Definition: ruby.h:2072
rb_check_safe_str
#define rb_check_safe_str(x)
Definition: ruby.h:612
rb_gvar_val_marker
rb_gvar_marker_t rb_gvar_val_marker
Definition: ruby.h:1792
rb_yield_splat_kw
VALUE rb_yield_splat_kw(VALUE, int)
Definition: vm_eval.c:1296
rb_num2int
long rb_num2int(VALUE val)
Definition: numeric.c:2997
size
int size
Definition: encoding.c:58
RString::@94::@95::len
long len
Definition: ruby.h:992
ruby_set_argv
void ruby_set_argv(int, char **)
Definition: ruby.c:2366
n_opt
const VALUE int int n_opt
Definition: rb_mjit_min_header-2.7.0.h:6462
RString
Definition: ruby.h:988
RVALUE_EMBED_LEN_MAX
#define RVALUE_EMBED_LEN_MAX
Definition: ruby.h:908
rb_string_value
VALUE rb_string_value(volatile VALUE *)
Definition: string.c:2175
rb_class2name
const char * rb_class2name(VALUE)
Definition: variable.c:280
rb_iter_break
void rb_iter_break(void)
Definition: vm.c:1546
rb_gc_register_address
void rb_gc_register_address(VALUE *)
Definition: gc.c:7077
rb_error_arity
MJIT_STATIC void rb_error_arity(int argc, int min, int max)
Definition: vm_insnhelper.c:387
rb_define_variable
void rb_define_variable(const char *, VALUE *)
Definition: variable.c:499
ruby_init_loadpath
void ruby_init_loadpath(void)
Definition: ruby.c:582
rb_event_hook_func_t
void(* rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
Definition: ruby.h:2279
rb_cEncoding
RUBY_EXTERN VALUE rb_cEncoding
Definition: ruby.h:2020
RArray
Definition: ruby.h:1048
rb_cCont
RUBY_EXTERN VALUE rb_cCont
Definition: ruby.h:2017
rb_data_object_zalloc
VALUE rb_data_object_zalloc(VALUE, size_t, RUBY_DATA_FUNC, RUBY_DATA_FUNC)
rb_eMathDomainError
RUBY_EXTERN VALUE rb_eMathDomainError
Definition: ruby.h:2088
rb_sys_warning
void rb_sys_warning(const char *fmt,...)
Definition: error.c:2919
ruby_set_script_name
void ruby_set_script_name(VALUE name)
Sets the current script name to this value.
Definition: ruby.c:2290
RUBY_T_REGEXP
@ RUBY_T_REGEXP
Definition: ruby.h:494
T_HASH
#define T_HASH
Definition: ruby.h:531
rb_freeze_singleton_class
void rb_freeze_singleton_class(VALUE klass)
Definition: class.c:1674
rb_yield_values2
VALUE rb_yield_values2(int n, const VALUE *argv)
Definition: vm_eval.c:1271
rb_remove_event_hook
int rb_remove_event_hook(rb_event_hook_func_t func)
Definition: vm_trace.c:262
rb_cThread
RUBY_EXTERN VALUE rb_cThread
Definition: ruby.h:2047
rb_glob
void rb_glob(const char *, void(*)(const char *, VALUE, void *), VALUE)
Definition: dir.c:2544
RUBY_T_IMEMO
@ RUBY_T_IMEMO
Definition: ruby.h:512
rb_global_variable
void rb_global_variable(VALUE *)
Definition: gc.c:7112
rb_typeddata_is_kind_of
int rb_typeddata_is_kind_of(VALUE, const rb_data_type_t *)
Definition: error.c:872
rb_mod_syserr_fail_str
void rb_mod_syserr_fail_str(VALUE mod, int e, VALUE mesg)
Definition: error.c:2857
RUBY_FL_FINALIZE
@ RUBY_FL_FINALIZE
Definition: ruby.h:846
rb_mFileTest
RUBY_EXTERN VALUE rb_mFileTest
Definition: ruby.h:2002
RSTRING_NOEMBED
#define RSTRING_NOEMBED
Definition: ruby.h:972
RObject::@92::@93::numiv
uint32_t numiv
Definition: ruby.h:926
DEPRECATED_BY
DEPRECATED_BY(rb_data_object_wrap, static inline VALUE rb_data_object_alloc(VALUE, void *, RUBY_DATA_FUNC, RUBY_DATA_FUNC))
Data_Make_Struct0
#define Data_Make_Struct0(result, klass, type, size, mark, free, sval)
Definition: ruby.h:1214
RMODULE_INCLUDED_INTO_REFINEMENT
#define RMODULE_INCLUDED_INTO_REFINEMENT
Definition: ruby.h:953
src
__inline__ const void *__restrict src
Definition: rb_mjit_min_header-2.7.0.h:2836
rb_str_to_str
VALUE rb_str_to_str(VALUE)
Definition: string.c:1382
fmt
const VALUE int int int int int int VALUE char * fmt
Definition: rb_mjit_min_header-2.7.0.h:6462
rb_ary_ptr_use_end
void rb_ary_ptr_use_end(VALUE ary)
Definition: array.c:235
f_block
const VALUE int int int int int int f_block
Definition: rb_mjit_min_header-2.7.0.h:6462
rb_str_export
VALUE rb_str_export(VALUE)
Definition: string.c:1123
RARRAY_EMBED_LEN
#define RARRAY_EMBED_LEN(a)
Definition: ruby.h:1067
rb_io_wait_readwrite
rb_io_wait_readwrite
Definition: ruby.h:1929
RArray::@97::@98::len
long len
Definition: ruby.h:1052
rb_ary_new4
#define rb_ary_new4
Definition: intern.h:105
RArray::@97::@98::@99::shared_root
const VALUE shared_root
Definition: ruby.h:1060
rb_check_hash_type
VALUE rb_check_hash_type(VALUE hash)
Definition: hash.c:1825
rb_eval_string
VALUE rb_eval_string(const char *)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1713
rb_throw
void rb_throw(const char *tag, VALUE val)
Definition: vm_eval.c:2218
RUBY_FL_SINGLETON
@ RUBY_FL_SINGLETON
Definition: ruby.h:883
rb_cObject
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:2010
rb_event_flag_t
uint32_t rb_event_flag_t
Definition: ruby.h:2278
rb_eStandardError
RUBY_EXTERN VALUE rb_eStandardError
Definition: ruby.h:2053
n
const char size_t n
Definition: rb_mjit_min_header-2.7.0.h:5456
RUBY_FL_PROMOTED1
@ RUBY_FL_PROMOTED1
Definition: ruby.h:844
rb_mProcess
RUBY_EXTERN VALUE rb_mProcess
Definition: ruby.h:2005
re_pattern_buffer
Definition: onigmo.h:755
rb_intern2
ID rb_intern2(const char *, long)
Definition: symbol.c:653
rb_bug
void rb_bug(const char *fmt,...)
Definition: error.c:634
RB_FL_ABLE
#define RB_FL_ABLE(x)
Definition: ruby.h:1315
rb_data_object_wrap
VALUE rb_data_object_wrap(VALUE, void *, RUBY_DATA_FUNC, RUBY_DATA_FUNC)
Definition: gc.c:2376
rb_block_call_func_t
rb_block_call_func * rb_block_call_func_t
Definition: ruby.h:1967
arg
VALUE arg
Definition: rb_mjit_min_header-2.7.0.h:5601
rb_mKernel
RUBY_EXTERN VALUE rb_mKernel
Definition: ruby.h:1998
rb_define_alias
void rb_define_alias(VALUE, const char *, const char *)
Defines an alias of a method.
Definition: class.c:1800
argv
char ** argv
Definition: ruby.c:223
ruby_sig_finalize
void ruby_sig_finalize(void)
Definition: signal.c:1470
rb_set_errinfo
void rb_set_errinfo(VALUE)
Sets the current exception ($!) to the given value.
Definition: eval.c:1895
rb_funcall
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:922
rb_int2inum
VALUE rb_int2inum(intptr_t)
Definition: bignum.c:3208
RB_INT2FIX
#define RB_INT2FIX(i)
Definition: ruby.h:262
rb_define_global_const
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2892
RB_STATIC_SYM_P
#define RB_STATIC_SYM_P(x)
Definition: ruby.h:406
rb_data_typed_object_alloc
#define rb_data_typed_object_alloc
Definition: gc.c:15
RUBY_SYMBOL_EXPORT_BEGIN
#define RUBY_SYMBOL_EXPORT_BEGIN
Definition: missing.h:48
RUBY_T_MATCH
@ RUBY_T_MATCH
Definition: ruby.h:501
ANYARGS
#define ANYARGS
Definition: defines.h:201
klass
VALUE klass
Definition: rb_mjit_min_header-2.7.0.h:13254
RARRAY
#define RARRAY(obj)
Definition: ruby.h:1273
RRegexp::usecnt
unsigned long usecnt
Definition: ruby.h:1116
ruby_check_sizeof_int
char ruby_check_sizeof_int[SIZEOF_INT==sizeof(int) ? 1 :-1]
Definition: ruby.h:118
rb_cFixnum
#define rb_cFixnum
Definition: internal.h:1311
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
rb_ary_detransient
void rb_ary_detransient(VALUE ary)
Definition: array.c:408
rb_id2str
VALUE rb_id2str(ID)
Definition: symbol.c:795
RString::@94::@95::@96::shared
VALUE shared
Definition: ruby.h:996
rb_data_object_make
#define rb_data_object_make
Definition: rb_mjit_min_header-2.7.0.h:4949
ruby_glob
int ruby_glob(const char *, int, ruby_glob_func *, VALUE)
Definition: dir.c:2519
rb_readwrite_sys_fail
void rb_readwrite_sys_fail(enum rb_io_wait_readwrite writable, const char *mesg)
Definition: io.c:12923
rb_define_global_function
void rb_define_global_function(const char *, VALUE(*)(ANYARGS), int)
Defines a global function.
Definition: class.c:1787
rb_eSignal
RUBY_EXTERN VALUE rb_eSignal
Definition: ruby.h:2056
ruby_native_thread_p
int ruby_native_thread_p(void)
Definition: thread.c:5277
rb_define_module_function
void rb_define_module_function(VALUE, const char *, VALUE(*)(ANYARGS), int)
Defines a module function for module.
Definition: class.c:1771
rb_define_class_under
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
Definition: class.c:698
RARRAY_EMBED_LEN_MAX
#define RARRAY_EMBED_LEN_MAX
Definition: ruby.h:1045
rb_mMath
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:2004
rb_secure_update
void rb_secure_update(VALUE)
Definition: safe.c:116
rb_eLocalJumpError
RUBY_EXTERN VALUE rb_eLocalJumpError
Definition: ruby.h:2076
RTypedData::typed_flag
VALUE typed_flag
Definition: ruby.h:1171
SIZEOF_VOIDP
#define SIZEOF_VOIDP
Definition: rb_mjit_min_header-2.7.0.h:90
ruby_executable_node
int ruby_executable_node(void *n, int *status)
Checks the return value of ruby_options().
Definition: eval.c:305
rb_cString
RUBY_EXTERN VALUE rb_cString
Definition: ruby.h:2044
rb_eval_string_protect
VALUE rb_eval_string_protect(const char *, int *)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1735
RRegexp::src
const VALUE src
Definition: ruby.h:1115
NIL_P
#define NIL_P(v)
Definition: ruby.h:482
RMODULE_IS_OVERLAID
#define RMODULE_IS_OVERLAID
Definition: ruby.h:951
RSTRING_FSTR
#define RSTRING_FSTR
Definition: ruby.h:976
rb_scan_args_count
#define rb_scan_args_count(fmt)
Definition: rb_mjit_min_header-2.7.0.h:6383
argc
int argc
Definition: ruby.c:222
rb_num2dbl
double rb_num2dbl(VALUE)
Converts a Numeric object to double.
Definition: object.c:3616
st_locale_insensitive_strcasecmp
int st_locale_insensitive_strcasecmp(const char *s1, const char *s2)
Definition: st.c:2083
rb_cStat
RUBY_EXTERN VALUE rb_cStat
Definition: ruby.h:2043
rb_obj_classname
const char * rb_obj_classname(VALUE)
Definition: variable.c:289
rb_sys_fail_str
void rb_sys_fail_str(VALUE mesg)
Definition: error.c:2799
rb_scan_args
int rb_scan_args(int, const VALUE *, const char *,...)
Definition: class.c:2159
RUBY_T_OBJECT
@ RUBY_T_OBJECT
Definition: ruby.h:489
rb_define_const
void rb_define_const(VALUE, const char *, VALUE)
Definition: variable.c:2880
rb_eScriptError
RUBY_EXTERN VALUE rb_eScriptError
Definition: ruby.h:2083
free
#define free(x)
Definition: dln.c:52
rb_catch
VALUE rb_catch(const char *, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:2288
RUBY_EXTERN
#define RUBY_EXTERN
Definition: missing.h:77
rb_mWaitWritable
RUBY_EXTERN VALUE rb_mWaitWritable
Definition: ruby.h:2007
rb_cTrueClass
RUBY_EXTERN VALUE rb_cTrueClass
Definition: ruby.h:2049
RUBY_T_MODULE
@ RUBY_T_MODULE
Definition: ruby.h:491
RB_FL_TEST
#define RB_FL_TEST(x, f)
Definition: ruby.h:1317
rb_data_type_struct
Definition: ruby.h:1148
RString::@94::@95::ptr
char * ptr
Definition: ruby.h:993
RUBY_T_FALSE
@ RUBY_T_FALSE
Definition: ruby.h:507
rb_string_value_cstr
char * rb_string_value_cstr(volatile VALUE *)
Definition: string.c:2291
ALWAYS_INLINE
#define ALWAYS_INLINE(x)
Definition: defines.h:48
s2
const char * s2
Definition: rb_mjit_min_header-2.7.0.h:5454
ruby_glob_func
int ruby_glob_func(const char *, VALUE, void *)
Definition: ruby.h:1768
rb_eNoMemError
RUBY_EXTERN VALUE rb_eNoMemError
Definition: ruby.h:2073
RBASIC
#define RBASIC(obj)
Definition: ruby.h:1267
RB_POSFIXABLE
#define RB_POSFIXABLE(f)
Definition: ruby.h:391
RArray::@97::@98::@99::capa
long capa
Definition: ruby.h:1054
RUBY_T_SYMBOL
@ RUBY_T_SYMBOL
Definition: ruby.h:508
rb_sym2id
ID rb_sym2id(VALUE)
Definition: symbol.c:748
rb_cNameErrorMesg
RUBY_EXTERN VALUE rb_cNameErrorMesg
Definition: ruby.h:2035
rb_eEncodingError
RUBY_EXTERN VALUE rb_eEncodingError
Definition: ruby.h:2079
rb_ensure
VALUE rb_ensure(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE), VALUE)
An equivalent to ensure clause.
Definition: eval.c:1114
ruby_sysinit
void ruby_sysinit(int *argc, char ***argv)
Initializes the process for libruby.
Definition: ruby.c:2447
rb_check_typeddata
void * rb_check_typeddata(VALUE, const rb_data_type_t *)
Definition: error.c:889
rb_iter_break_value
void rb_iter_break_value(VALUE val)
Definition: vm.c:1552
count
int count
Definition: encoding.c:57
rb_define_module
VALUE rb_define_module(const char *)
Definition: class.c:772
rb_compile_warn
void rb_compile_warn(const char *file, int line, const char *fmt,...)
Definition: error.c:270
rb_rescue
VALUE rb_rescue(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE)
An equivalent of rescue clause.
Definition: eval.c:1046
FL_PROMOTED1
#define FL_PROMOTED1
Definition: ruby.h:1281
len
uint8_t len
Definition: escape.c:17
rb_data_type_struct::data
void * data
Definition: ruby.h:1159
RB_IO_WAIT_READABLE
#define RB_IO_WAIT_READABLE
Definition: ruby.h:1930
rb_call_super_kw
VALUE rb_call_super_kw(int, const VALUE *, int)
Definition: vm_eval.c:298
RB_IMMEDIATE_P
#define RB_IMMEDIATE_P(x)
Definition: ruby.h:401
intptr_t
int intptr_t
Definition: win32.h:90
rb_keyword_given_p
int rb_keyword_given_p(void)
Definition: eval.c:910
rb_funcall_with_block
VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE *, VALUE)
Definition: vm_eval.c:1050
rb_cBinding
RUBY_EXTERN VALUE rb_cBinding
Definition: ruby.h:2015
rb_yield_values
VALUE rb_yield_values(int n,...)
Definition: vm_eval.c:1249
RARRAY_EMBED_LEN_MASK
#define RARRAY_EMBED_LEN_MASK
Definition: ruby.h:1044
rb_gc_unprotect_logging
void rb_gc_unprotect_logging(void *objptr, const char *filename, int line)
Definition: gc.c:6909
rb_undef_method
void rb_undef_method(VALUE, const char *)
Definition: class.c:1575
RB_FIXNUM_P
#define RB_FIXNUM_P(f)
Definition: ruby.h:390
backward.h
RUBY_FIXNUM_FLAG
@ RUBY_FIXNUM_FLAG
Definition: ruby.h:444
ruby_vsnprintf
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
Definition: sprintf.c:1004
RUBY_FL_DUPPED
@ RUBY_FL_DUPPED
Definition: ruby.h:882
rb_string_value_ptr
char * rb_string_value_ptr(volatile VALUE *)
Definition: string.c:2186
rb_sym2str
VALUE rb_sym2str(VALUE)
Definition: symbol.c:784
va_list
__gnuc_va_list va_list
Definition: rb_mjit_min_header-2.7.0.h:836
rb_eSyntaxError
RUBY_EXTERN VALUE rb_eSyntaxError
Definition: ruby.h:2085
rb_ll2inum
VALUE rb_ll2inum(long long)
rb_cStruct
RUBY_EXTERN VALUE rb_cStruct
Definition: ruby.h:2045
rb_eRangeError
RUBY_EXTERN VALUE rb_eRangeError
Definition: ruby.h:2063
rb_gv_get
VALUE rb_gv_get(const char *)
Definition: variable.c:680
rb_yield
VALUE rb_yield(VALUE)
Definition: vm_eval.c:1237
rb_block_call_kw
VALUE rb_block_call_kw(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE, int)
Definition: vm_eval.c:1484
RB_FIXABLE
#define RB_FIXABLE(f)
Definition: ruby.h:393
RARRAY_TRANSIENT_FLAG
#define RARRAY_TRANSIENT_FLAG
Definition: ruby.h:1036
rb_gvar_var_marker
rb_gvar_marker_t rb_gvar_var_marker
Definition: ruby.h:1796
rb_obj_setup
VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
Fills common (RBasic) fields in obj.
Definition: object.c:112
RUBY_T_HASH
@ RUBY_T_HASH
Definition: ruby.h:496
rb_set_safe_level
void rb_set_safe_level(int)
Definition: safe.c:45
rb_syserr_new_str
VALUE rb_syserr_new_str(int n, VALUE arg)
Definition: error.c:2775
varc
const VALUE int int int int int int VALUE char int varc
Definition: rb_mjit_min_header-2.7.0.h:6462
rb_ary_new
VALUE rb_ary_new(void)
Definition: array.c:723
rb_gvar_val_setter
rb_gvar_setter_t rb_gvar_val_setter
Definition: ruby.h:1791
rb_eIndexError
RUBY_EXTERN VALUE rb_eIndexError
Definition: ruby.h:2060
rb_define_virtual_variable
void rb_define_virtual_variable(const char *, rb_gvar_getter_t *, rb_gvar_setter_t *)
Define a function-backended global variable.
Definition: cxxanyargs.hpp:59
NUM2INT
#define NUM2INT(x)
Definition: ruby.h:715
Qnil
#define Qnil
Definition: ruby.h:469
rb_define_method
void rb_define_method(VALUE, const char *, VALUE(*)(ANYARGS), int)
Definition: class.c:1551
rb_ruby_verbose_ptr
VALUE * rb_ruby_verbose_ptr(void)
Definition: vm.c:3373
rb_eFrozenError
RUBY_EXTERN VALUE rb_eFrozenError
Definition: ruby.h:2066
PUREFUNC
PUREFUNC(double rb_float_value(VALUE))
RUBY_T_ZOMBIE
@ RUBY_T_ZOMBIE
Definition: ruby.h:515
rb_cEnumerator
RUBY_EXTERN VALUE rb_cEnumerator
Definition: ruby.h:2021
rb_io_t
Definition: io.h:66
rb_cRegexp
RUBY_EXTERN VALUE rb_cRegexp
Definition: ruby.h:2042
RSTRING_EMBED_LEN_MASK
#define RSTRING_EMBED_LEN_MASK
Definition: ruby.h:973
RUBY_T_MOVED
@ RUBY_T_MOVED
Definition: ruby.h:516
rb_intern_str
ID rb_intern_str(VALUE str)
Definition: symbol.c:666
RSTRING_LEN
#define RSTRING_LEN(str)
Definition: ruby.h:1005
alloca
RUBY_SYMBOL_EXPORT_BEGIN void * alloca()
rb_cArray
RUBY_EXTERN VALUE rb_cArray
Definition: ruby.h:2011
RData
Definition: ruby.h:1139
RUBY_T_ICLASS
@ RUBY_T_ICLASS
Definition: ruby.h:514
rb_eNoMethodError
RUBY_EXTERN VALUE rb_eNoMethodError
Definition: ruby.h:2074
rb_cFile
RUBY_EXTERN VALUE rb_cFile
Definition: ruby.h:2023
rb_need_block
void rb_need_block(void)
Declares that the current method needs a block.
Definition: eval.c:931
rb_eThreadError
RUBY_EXTERN VALUE rb_eThreadError
Definition: ruby.h:2069
rb_obj_reveal
VALUE rb_obj_reveal(VALUE obj, VALUE klass)
Make a hidden object visible again.
Definition: object.c:95
rb_mErrno
RUBY_EXTERN VALUE rb_mErrno
Definition: ruby.h:2001
ruby_special_consts
ruby_special_consts
Definition: ruby.h:436
rb_data_object_alloc
#define rb_data_object_alloc
Definition: gc.c:14
rb_secure
void rb_secure(int)
Definition: safe.c:99
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39
RB_SPECIAL_CONST_P
#define RB_SPECIAL_CONST_P(x)
Definition: ruby.h:1312
rb_iv_set
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:3307
rb_cIO
RUBY_EXTERN VALUE rb_cIO
Definition: ruby.h:2030
rb_cRandom
RUBY_EXTERN VALUE rb_cRandom
Definition: ruby.h:2039
rb_special_const_p
#define rb_special_const_p(obj)
Definition: rb_mjit_min_header-2.7.0.h:5357
dup
int dup(int __fildes)
ruby_fl_type
ruby_fl_type
Definition: ruby.h:841
rb_scan_args_set
int rb_scan_args_set(int argc, const VALUE *argv, int n_lead, int n_opt, int n_trail, int f_var, int f_hash, int f_block, VALUE *vars[], char *fmt __attribute__((unused)), int varc __attribute__((unused)))
Definition: rb_mjit_min_header-2.7.0.h:6464
optional
Definition: gc.c:90
rb_include_module
void rb_include_module(VALUE, VALUE)
Definition: class.c:869
rb_mod_sys_fail_str
void rb_mod_sys_fail_str(VALUE mod, VALUE mesg)
Definition: error.c:2841
rb_get_path
VALUE rb_get_path(VALUE)
Definition: file.c:230
RUBY_T_COMPLEX
@ RUBY_T_COMPLEX
Definition: ruby.h:502
RUBY_FL_SEEN_OBJ_ID
@ RUBY_FL_SEEN_OBJ_ID
Definition: ruby.h:849
rb_get_path_no_checksafe
VALUE rb_get_path_no_checksafe(VALUE)
Definition: file.c:224
cxxanyargs.hpp
Provides old prototypes for C++ programs.
rb_syserr_fail_str
void rb_syserr_fail_str(int e, VALUE mesg)
Definition: error.c:2787
rb_add_event_hook
void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
Definition: vm_trace.c:157
RUBY_FL_TAINT
@ RUBY_FL_TAINT
Definition: ruby.h:847
n_lead
const VALUE int n_lead
Definition: rb_mjit_min_header-2.7.0.h:6462
name
const char * name
Definition: nkf.c:208
rb_block_proc
VALUE rb_block_proc(void)
Definition: proc.c:837