Ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
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)
18extern "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
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 */
89void *alloca();
90# endif
91# endif /* AIX */
92# endif /* HAVE_ALLOCA_H */
93#endif /* __GNUC__ */
94
95#if defined HAVE_UINTPTR_T && 0
96typedef uintptr_t VALUE;
97typedef 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
102typedef unsigned long VALUE;
103typedef 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
108typedef unsigned LONG_LONG VALUE;
109typedef 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
118typedef char ruby_check_sizeof_int[SIZEOF_INT == sizeof(int) ? 1 : -1];
119typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1];
120#ifdef HAVE_LONG_LONG
121typedef char ruby_check_sizeof_long_long[SIZEOF_LONG_LONG == sizeof(LONG_LONG) ? 1 : -1];
122#endif
123typedef 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)
268
269#define rb_int_new(v) rb_int2inum(v)
271
272#define rb_uint_new(v) rb_uint2inum(v)
273
274#ifdef HAVE_LONG_LONG
276#define LL2NUM(v) rb_ll2inum(v)
277VALUE 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
335NORETURN(void rb_out_of_int(SIGNED_VALUE num));
336#endif
337
338#if SIZEOF_INT < SIZEOF_LONG
339static inline int
340rb_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))
379static inline long
380rb_fix2long(VALUE x)
381{
382 return RB_FIX2LONG(x);
383}
384#define RB_FIX2ULONG(x) ((unsigned long)RB_FIX2LONG(x))
385static inline unsigned long
386rb_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
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 */
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
444 RUBY_FIXNUM_FLAG = 0x01, /* ...xxxx xxx1 */
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
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
488
504
511
517
518 RUBY_T_MASK = 0x1f
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
553static 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)
579static 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
583volatile 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
594void rb_check_type(VALUE,int);
595#define Check_Type(v,t) rb_check_type((VALUE)(v),(t))
596
598VALUE rb_string_value(volatile VALUE*);
599char *rb_string_value_ptr(volatile VALUE*);
600char *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
607#define SafeStringValue(v) StringValue(v)
608#if GCC_VERSION_SINCE(4,4,0)
609void 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
617#define ExportStringValue(v) do {\
618 StringValue(v);\
619 (v) = rb_str_export(v);\
620} while (0)
622
624#define FilePathValue(v) (RB_GC_GUARD(v) = rb_get_path(v))
625
627#define FilePathStringValue(v) ((v) = rb_get_path(v))
628
629/* Remove in 3.0 */
630#define RUBY_SAFE_LEVEL_MAX 1
631void rb_secure(int);
632int rb_safe_level(void);
633void rb_set_safe_level(int);
634#if GCC_VERSION_SINCE(4,4,0)
635int ruby_safe_level_2_error(void) __attribute__((error("$SAFE=2 to 4 are obsolete")));
636int 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
664
665VALUE rb_errinfo(void);
667
668long rb_num2long(VALUE);
669unsigned long rb_num2ulong(VALUE);
670static inline long
671rb_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)
680static inline unsigned long
681rb_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
691long rb_num2int(VALUE);
692long rb_fix2int(VALUE);
693#define RB_FIX2INT(x) ((int)rb_fix2int((VALUE)(x)))
694
695static inline int
696rb_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
705unsigned long rb_num2uint(VALUE);
706#define RB_NUM2UINT(x) ((unsigned int)rb_num2uint(x))
707unsigned 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
720short rb_num2short(VALUE);
721unsigned short rb_num2ushort(VALUE);
722short rb_fix2short(VALUE);
723unsigned short rb_fix2ushort(VALUE);
724#define RB_FIX2SHORT(x) (rb_fix2short((VALUE)(x)))
725#define FIX2SHORT(x) RB_FIX2SHORT(x)
726static inline short
727rb_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
741LONG_LONG rb_num2ll(VALUE);
742unsigned LONG_LONG rb_num2ull(VALUE);
743static inline LONG_LONG
744rb_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
773double rb_num2dbl(VALUE);
774#define NUM2DBL(x) rb_num2dbl((VALUE)(x))
775
778
779VALUE rb_newobj(void);
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
850 RUBY_FL_EXIVAR = (1<<10),
851 RUBY_FL_FREEZE = (1<<11),
852
854
855#define RUBY_FL_USER_N(n) RUBY_FL_USER##n = (1<<(RUBY_FL_USHIFT+n))
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,
883 RUBY_FL_SINGLETON = RUBY_FL_USER0
885
886struct RUBY_ALIGNAS(SIZEOF_VALUE) RBasic {
887 VALUE flags;
888 const VALUE klass;
889};
890
892VALUE 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
911};
912
913#define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
914#define ROBJECT_EMBED ROBJECT_EMBED
917 ROBJECT_EMBED = RUBY_FL_USER1,
918
921
922struct RObject {
923 struct RBasic basic;
924 union {
925 struct {
928 void *iv_index_tbl; /* shortcut for RCLASS_IV_INDEX_TBL(rb_obj_class(obj)) */
929 } heap;
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
955 RMODULE_IS_OVERLAID = RUBY_FL_USER2,
956 RMODULE_IS_REFINEMENT = RUBY_FL_USER3,
958
961
963VALUE rb_float_new(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
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),
983 RSTRING_FSTR = RUBY_FL_USER17,
984
987
988struct RString {
989 struct RBasic basic;
990 union {
991 struct {
992 long len;
993 char *ptr;
994 union {
995 long capa;
997 } aux;
998 } heap;
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
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),
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
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
1048struct 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
1061 } aux;
1062 const VALUE *ptr;
1063 } heap;
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
1112struct RRegexp {
1113 struct RBasic basic;
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 */
1125size_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
1134struct RFile {
1135 struct RBasic basic;
1136 struct rb_io_t *fptr;
1137};
1138
1139struct RData {
1140 struct RBasic basic;
1141 void (*dmark)(void*);
1142 void (*dfree)(void*);
1143 void *data;
1144};
1145
1147
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;
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
1169 struct RBasic basic;
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*/
1184typedef 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
1197int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent);
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) ({\
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) ({\
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
1260int 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
1382
1383static inline void
1384rb_obj_freeze_inline(VALUE x)
1385{
1386 if (RB_FL_ABLE(x)) {
1388 if (RBASIC_CLASS(x) && !(RBASIC(x)->flags & RUBY_FL_SINGLETON)) {
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)
1403#endif
1404RUBY_UNTYPED_DATA_FUNC(static inline void *rb_data_object_get_warning(VALUE));
1405
1406static inline VALUE
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
1422static inline void *
1424{
1426 return ((struct RData *)obj)->data;
1427}
1428
1429#if defined(__GNUC__) && !defined(__NO_INLINE__)
1430static inline void *
1431rb_data_object_get_warning(VALUE obj)
1432{
1433 return rb_data_object_get(obj);
1434}
1435#endif
1436
1437static inline VALUE
1438rb_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
1444static inline VALUE
1445rb_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
1453static inline VALUE
1455{
1456 return rb_data_object_wrap(klass, data, dmark, dfree);
1457}
1458#endif
1459
1460#ifndef rb_data_typed_object_alloc
1462static inline VALUE
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
1486void rb_gc_writebarrier(VALUE a, VALUE b);
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
1516void rb_gc_unprotect_logging(void *objptr, const char *filename, int line);
1517#define RGENGC_LOGGING_WB_UNPROTECT rb_gc_unprotect_logging
1518#endif
1519
1520static inline VALUE
1521rb_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
1528#endif
1529 return x;
1530}
1531
1532static inline VALUE
1533rb_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
1548static inline VALUE
1549rb_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
1576static inline int
1577rb_integer_type_p(VALUE obj)
1578{
1579 return (RB_FIXNUM_P(obj) ||
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
1589static inline VALUE
1590rb_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
1599static inline VALUE
1600rb_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
1612static inline VALUE
1613rb_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
1622static inline VALUE
1623rb_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
1632static inline char
1633rb_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
1687void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2));
1688void *rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len,size_t count) RUBY_ATTR_ALLOC_SIZE((2,3));
1689void rb_free_tmp_buffer(volatile VALUE *store);
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
1696static inline int
1697rb_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}
1712static inline void *
1713rb_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))) {
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))) {
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__
1757static inline void *
1758ruby_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
1766void rb_obj_infect(VALUE victim, VALUE carrier);
1767
1768typedef int ruby_glob_func(const char*,VALUE, void*);
1769void rb_glob(const char*,void(*)(const char*,VALUE,void*),VALUE);
1770int ruby_glob(const char*,int,ruby_glob_func*,VALUE);
1771int ruby_brace_glob(const char*,int,ruby_glob_func*,VALUE);
1772
1773VALUE rb_define_class(const char*,VALUE);
1774VALUE rb_define_module(const char*);
1775VALUE rb_define_class_under(VALUE, const char*, VALUE);
1776VALUE rb_define_module_under(VALUE, const char*);
1777
1781
1782typedef VALUE rb_gvar_getter_t(ID id, VALUE *data);
1783typedef void rb_gvar_setter_t(VALUE val, ID id, VALUE *data);
1784typedef void rb_gvar_marker_t(VALUE *var);
1785
1789
1793
1797
1799
1800void rb_define_variable(const char*,VALUE*);
1803void rb_define_readonly_variable(const char*,const VALUE*);
1804void rb_define_const(VALUE,const char*,VALUE);
1805void rb_define_global_const(const char*,VALUE);
1806
1807void rb_define_method(VALUE,const char*,VALUE(*)(ANYARGS),int);
1808void rb_define_module_function(VALUE,const char*,VALUE(*)(ANYARGS),int);
1809void rb_define_global_function(const char*,VALUE(*)(ANYARGS),int);
1810
1811void rb_undef_method(VALUE,const char*);
1812void rb_define_alias(VALUE,const char*,const char*);
1813void rb_define_attr(VALUE,const char*,int,int);
1814
1819
1820ID rb_intern(const char*);
1821ID rb_intern2(const char*, long);
1823const char *rb_id2name(ID);
1824ID rb_check_id(volatile VALUE *);
1829VALUE rb_check_symbol(volatile VALUE *namep);
1830
1831#define RUBY_CONST_ID_CACHE_NB(result, str) \
1832 static ID rb_intern_id_cache; \
1833 if (!rb_intern_id_cache) \
1834 rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
1835 result rb_intern_id_cache;
1836#define RUBY_CONST_ID_CACHE(result, str) \
1837 { \
1838 RUBY_CONST_ID_CACHE_NB(result, str) \
1839 }
1840#define RUBY_CONST_ID(var, str) \
1841 do RUBY_CONST_ID_CACHE((var) =, (str)) while (0)
1842#define CONST_ID_CACHE(result, str) RUBY_CONST_ID_CACHE(result, str)
1843#define CONST_ID(var, str) RUBY_CONST_ID(var, str)
1844#if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR)
1845/* __builtin_constant_p and statement expression is available
1846 * since gcc-2.7.2.3 at least. */
1847#define rb_intern(str) \
1848 (__builtin_constant_p(str) ? \
1849 __extension__ ({RUBY_CONST_ID_CACHE_NB((ID), (str))}) : \
1850 rb_intern(str))
1851#define rb_intern_const(str) \
1852 (__builtin_constant_p(str) ? \
1853 __extension__ (rb_intern2((str), (long)strlen(str))) : \
1854 (rb_intern)(str))
1855
1856# define rb_varargs_argc_check_runtime(argc, vargc) \
1857 (((argc) <= (vargc)) ? (argc) : \
1858 (rb_fatal("argc(%d) exceeds actual arguments(%d)", \
1859 argc, vargc), 0))
1860# define rb_varargs_argc_valid_p(argc, vargc) \
1861 ((argc) == 0 ? (vargc) <= 1 : /* [ruby-core:85266] [Bug #14425] */ \
1862 (argc) == (vargc))
1863# if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P)
1864# if HAVE_ATTRIBUTE_ERRORFUNC
1865ERRORFUNC((" argument length doesn't match"), int rb_varargs_bad_length(int,int));
1866# else
1867# define rb_varargs_bad_length(argc, vargc) \
1868 ((argc)/rb_varargs_argc_valid_p(argc, vargc))
1869# endif
1870# define rb_varargs_argc_check(argc, vargc) \
1871 __builtin_choose_expr(__builtin_constant_p(argc), \
1872 (rb_varargs_argc_valid_p(argc, vargc) ? (argc) : \
1873 rb_varargs_bad_length(argc, vargc)), \
1874 rb_varargs_argc_check_runtime(argc, vargc))
1875# else
1876# define rb_varargs_argc_check(argc, vargc) \
1877 rb_varargs_argc_check_runtime(argc, vargc)
1878# endif
1879
1880#else
1881#define rb_intern_const(str) rb_intern2((str), (long)strlen(str))
1882#endif
1883
1884const char *rb_class2name(VALUE);
1885const char *rb_obj_classname(VALUE);
1886
1887void rb_p(VALUE);
1888
1889VALUE rb_eval_string(const char*);
1890VALUE rb_eval_string_protect(const char*, int*);
1891VALUE rb_eval_string_wrap(const char*, int*);
1892VALUE rb_funcall(VALUE, ID, int, ...);
1893VALUE rb_funcallv(VALUE, ID, int, const VALUE*);
1894VALUE rb_funcallv_kw(VALUE, ID, int, const VALUE*, int);
1895VALUE rb_funcallv_public(VALUE, ID, int, const VALUE*);
1896VALUE rb_funcallv_public_kw(VALUE, ID, int, const VALUE*, int);
1897#define rb_funcall2 rb_funcallv
1898#define rb_funcall3 rb_funcallv_public
1900VALUE rb_funcall_passing_block_kw(VALUE, ID, int, const VALUE*, int);
1902VALUE rb_funcall_with_block_kw(VALUE, ID, int, const VALUE*, VALUE, int);
1903int rb_scan_args(int, const VALUE*, const char*, ...);
1904#define RB_SCAN_ARGS_PASS_CALLED_KEYWORDS 0
1905#define RB_SCAN_ARGS_KEYWORDS 1
1906#define RB_SCAN_ARGS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */
1907#define RB_SCAN_ARGS_LAST_HASH_KEYWORDS 3
1908int rb_scan_args_kw(int, int, const VALUE*, const char*, ...);
1909VALUE rb_call_super(int, const VALUE*);
1910VALUE rb_call_super_kw(int, const VALUE*, int);
1912int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *);
1914
1915/* rb_scan_args() format allows ':' for optional hash */
1916#define HAVE_RB_SCAN_ARGS_OPTIONAL_HASH 1
1917
1918VALUE rb_gv_set(const char*, VALUE);
1919VALUE rb_gv_get(const char*);
1920VALUE rb_iv_get(VALUE, const char*);
1921VALUE rb_iv_set(VALUE, const char*, VALUE);
1922
1924
1927#define ruby_verbose (*rb_ruby_verbose_ptr())
1928#define ruby_debug (*rb_ruby_debug_ptr())
1929
1930/* for rb_readwrite_sys_fail first argument */
1932#define RB_IO_WAIT_READABLE RB_IO_WAIT_READABLE
1933#define RB_IO_WAIT_WRITABLE RB_IO_WAIT_WRITABLE
1934
1935PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char*, ...)), 2, 3);
1936PRINTF_ARGS(NORETURN(void rb_fatal(const char*, ...)), 1, 2);
1937COLDFUNC PRINTF_ARGS(NORETURN(void rb_bug(const char*, ...)), 1, 2);
1938NORETURN(void rb_bug_errno(const char*, int));
1939NORETURN(void rb_sys_fail(const char*));
1941NORETURN(void rb_mod_sys_fail(VALUE, const char*));
1944NORETURN(void rb_iter_break(void));
1947NORETURN(void rb_notimplement(void));
1948VALUE rb_syserr_new(int, const char *);
1950NORETURN(void rb_syserr_fail(int, const char*));
1952NORETURN(void rb_mod_syserr_fail(VALUE, int, const char*));
1955
1956/* reports if `-W' specified */
1957PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2);
1958PRINTF_ARGS(void rb_compile_warning(const char *, int, const char*, ...), 3, 4);
1959PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
1960/* reports always */
1961COLDFUNC PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
1962PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
1963
1964#define RB_BLOCK_CALL_FUNC_STRICT 1
1965#define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1
1966#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) \
1967 VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg
1968typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
1970
1973VALUE rb_yield_values(int n, ...);
1974VALUE rb_yield_values2(int n, const VALUE *argv);
1975VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat);
1978VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)); /* rb_block_call_func */
1979#define RB_NO_KEYWORDS 0
1980#define RB_PASS_KEYWORDS 1
1981#define RB_PASS_EMPTY_KEYWORDS 2 /* Will be removed in 3.0 */
1982#define RB_PASS_CALLED_KEYWORDS 3
1983int rb_keyword_given_p(void);
1984int rb_block_given_p(void);
1985void rb_need_block(void);
1995NORETURN(void rb_throw(const char*,VALUE));
1997
1998VALUE rb_require(const char*);
1999
2010
2014#ifndef RUBY_INTEGER_UNIFICATION
2016#endif
2026#ifndef RUBY_INTEGER_UNIFICATION
2028#endif
2053
2084
2089
2091
2093
2094static inline VALUE
2095rb_class_of(VALUE obj)
2096{
2097 if (RB_IMMEDIATE_P(obj)) {
2098 if (RB_FIXNUM_P(obj)) return rb_cInteger;
2099 if (RB_FLONUM_P(obj)) return rb_cFloat;
2100 if (obj == RUBY_Qtrue) return rb_cTrueClass;
2101 if (RB_STATIC_SYM_P(obj)) return rb_cSymbol;
2102 }
2103 else if (!RB_TEST(obj)) {
2104 if (obj == RUBY_Qnil) return rb_cNilClass;
2105 if (obj == RUBY_Qfalse) return rb_cFalseClass;
2106 }
2107 return RBASIC(obj)->klass;
2108}
2109
2110static inline int
2111rb_type(VALUE obj)
2112{
2113 if (RB_IMMEDIATE_P(obj)) {
2114 if (RB_FIXNUM_P(obj)) return RUBY_T_FIXNUM;
2115 if (RB_FLONUM_P(obj)) return RUBY_T_FLOAT;
2116 if (obj == RUBY_Qtrue) return RUBY_T_TRUE;
2117 if (RB_STATIC_SYM_P(obj)) return RUBY_T_SYMBOL;
2118 if (obj == RUBY_Qundef) return RUBY_T_UNDEF;
2119 }
2120 else if (!RB_TEST(obj)) {
2121 if (obj == RUBY_Qnil) return RUBY_T_NIL;
2122 if (obj == RUBY_Qfalse) return RUBY_T_FALSE;
2123 }
2124 return RB_BUILTIN_TYPE(obj);
2125}
2126
2127#ifdef __GNUC__
2128#define rb_type_p(obj, type) \
2129 __extension__ (__builtin_constant_p(type) ? RB_TYPE_P((obj), (type)) : \
2130 rb_type(obj) == (type))
2131#else
2132#define rb_type_p(obj, type) (rb_type(obj) == (type))
2133#endif
2134
2135#ifdef __GNUC__
2136#define rb_special_const_p(obj) \
2137 __extension__ ({ \
2138 VALUE special_const_obj = (obj); \
2139 (int)(RB_SPECIAL_CONST_P(special_const_obj) ? RUBY_Qtrue : RUBY_Qfalse); \
2140 })
2141#else
2142static inline int
2144{
2145 if (RB_SPECIAL_CONST_P(obj)) return (int)RUBY_Qtrue;
2146 return (int)RUBY_Qfalse;
2147}
2148#endif
2149
2150#include "ruby/intern.h"
2151
2152static inline void
2153rb_clone_setup(VALUE clone, VALUE obj)
2154{
2159}
2160
2161static inline void
2162rb_dup_setup(VALUE dup, VALUE obj)
2163{
2166}
2167
2168static inline long
2169rb_array_len(VALUE a)
2170{
2171 return (RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
2172 RARRAY_EMBED_LEN(a) : RARRAY(a)->as.heap.len;
2173}
2174
2175#if defined(__fcc__) || defined(__fcc_version) || \
2176 defined(__FCC__) || defined(__FCC_VERSION)
2177/* workaround for old version of Fujitsu C Compiler (fcc) */
2178# define FIX_CONST_VALUE_PTR(x) ((const VALUE *)(x))
2179#else
2180# define FIX_CONST_VALUE_PTR(x) (x)
2181#endif
2182
2183/* internal function. do not use this function */
2184static inline const VALUE *
2185rb_array_const_ptr_transient(VALUE a)
2186{
2187 return FIX_CONST_VALUE_PTR((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
2188 RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
2189}
2190
2191/* internal function. do not use this function */
2192static inline const VALUE *
2193rb_array_const_ptr(VALUE a)
2194{
2195#if USE_TRANSIENT_HEAP
2196 void rb_ary_detransient(VALUE a);
2197
2198 if (RARRAY_TRANSIENT_P(a)) {
2200 }
2201#endif
2202 return rb_array_const_ptr_transient(a);
2203}
2204
2205/* internal function. do not use this function */
2206static inline VALUE *
2207rb_array_ptr_use_start(VALUE a, int allow_transient)
2208{
2210
2211#if USE_TRANSIENT_HEAP
2212 if (!allow_transient) {
2213 if (RARRAY_TRANSIENT_P(a)) {
2214 void rb_ary_detransient(VALUE a);
2216 }
2217 }
2218#endif
2219 (void)allow_transient;
2220
2221 return rb_ary_ptr_use_start(a);
2222}
2223
2224/* internal function. do not use this function */
2225static inline void
2226rb_array_ptr_use_end(VALUE a, int allow_transient)
2227{
2228 void rb_ary_ptr_use_end(VALUE a);
2230 (void)allow_transient;
2231}
2232
2233#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
2234/* hook for external modules */
2235static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
2236#endif
2237
2238#define RUBY_VM 1 /* YARV */
2239#define HAVE_NATIVETHREAD
2240int ruby_native_thread_p(void);
2241
2242/* traditional set_trace_func events */
2243#define RUBY_EVENT_NONE 0x0000
2244#define RUBY_EVENT_LINE 0x0001
2245#define RUBY_EVENT_CLASS 0x0002
2246#define RUBY_EVENT_END 0x0004
2247#define RUBY_EVENT_CALL 0x0008
2248#define RUBY_EVENT_RETURN 0x0010
2249#define RUBY_EVENT_C_CALL 0x0020
2250#define RUBY_EVENT_C_RETURN 0x0040
2251#define RUBY_EVENT_RAISE 0x0080
2252#define RUBY_EVENT_ALL 0x00ff
2253
2254/* for TracePoint extended events */
2255#define RUBY_EVENT_B_CALL 0x0100
2256#define RUBY_EVENT_B_RETURN 0x0200
2257#define RUBY_EVENT_THREAD_BEGIN 0x0400
2258#define RUBY_EVENT_THREAD_END 0x0800
2259#define RUBY_EVENT_FIBER_SWITCH 0x1000
2260#define RUBY_EVENT_SCRIPT_COMPILED 0x2000
2261#define RUBY_EVENT_TRACEPOINT_ALL 0xffff
2262
2263/* special events */
2264#define RUBY_EVENT_RESERVED_FOR_INTERNAL_USE 0x030000
2265
2266/* internal events */
2267#define RUBY_INTERNAL_EVENT_SWITCH 0x040000
2268#define RUBY_EVENT_SWITCH 0x040000 /* obsolete name. this macro is for compatibility */
2269 /* 0x080000 */
2270#define RUBY_INTERNAL_EVENT_NEWOBJ 0x100000
2271#define RUBY_INTERNAL_EVENT_FREEOBJ 0x200000
2272#define RUBY_INTERNAL_EVENT_GC_START 0x400000
2273#define RUBY_INTERNAL_EVENT_GC_END_MARK 0x800000
2274#define RUBY_INTERNAL_EVENT_GC_END_SWEEP 0x1000000
2275#define RUBY_INTERNAL_EVENT_GC_ENTER 0x2000000
2276#define RUBY_INTERNAL_EVENT_GC_EXIT 0x4000000
2277#define RUBY_INTERNAL_EVENT_OBJSPACE_MASK 0x7f00000
2278#define RUBY_INTERNAL_EVENT_MASK 0xffff0000
2279
2281typedef void (*rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass);
2282
2283#define RB_EVENT_HOOKS_HAVE_CALLBACK_DATA 1
2286
2287/* locale insensitive functions */
2288
2289static inline int rb_isascii(int c){ return '\0' <= c && c <= '\x7f'; }
2290static inline int rb_isupper(int c){ return 'A' <= c && c <= 'Z'; }
2291static inline int rb_islower(int c){ return 'a' <= c && c <= 'z'; }
2292static inline int rb_isalpha(int c){ return rb_isupper(c) || rb_islower(c); }
2293static inline int rb_isdigit(int c){ return '0' <= c && c <= '9'; }
2294static inline int rb_isalnum(int c){ return rb_isalpha(c) || rb_isdigit(c); }
2295static inline int rb_isxdigit(int c){ return rb_isdigit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f'); }
2296static inline int rb_isblank(int c){ return c == ' ' || c == '\t'; }
2297static inline int rb_isspace(int c){ return c == ' ' || ('\t' <= c && c <= '\r'); }
2298static inline int rb_iscntrl(int c){ return ('\0' <= c && c < ' ') || c == '\x7f'; }
2299static inline int rb_isprint(int c){ return ' ' <= c && c <= '\x7e'; }
2300static inline int rb_ispunct(int c){ return !rb_isalnum(c); }
2301static inline int rb_isgraph(int c){ return '!' <= c && c <= '\x7e'; }
2302static inline int rb_tolower(int c) { return rb_isupper(c) ? (c|0x20) : c; }
2303static inline int rb_toupper(int c) { return rb_islower(c) ? (c&0x5f) : c; }
2304
2305#ifndef ISPRINT
2306#define ISASCII(c) rb_isascii(c)
2307#define ISPRINT(c) rb_isprint(c)
2308#define ISGRAPH(c) rb_isgraph(c)
2309#define ISSPACE(c) rb_isspace(c)
2310#define ISUPPER(c) rb_isupper(c)
2311#define ISLOWER(c) rb_islower(c)
2312#define ISALNUM(c) rb_isalnum(c)
2313#define ISALPHA(c) rb_isalpha(c)
2314#define ISDIGIT(c) rb_isdigit(c)
2315#define ISXDIGIT(c) rb_isxdigit(c)
2316#define ISBLANK(c) rb_isblank(c)
2317#define ISCNTRL(c) rb_iscntrl(c)
2318#define ISPUNCT(c) rb_ispunct(c)
2319#endif
2320#define TOUPPER(c) rb_toupper(c)
2321#define TOLOWER(c) rb_tolower(c)
2322
2323int st_locale_insensitive_strcasecmp(const char *s1, const char *s2);
2324int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n);
2325#define STRCASECMP(s1, s2) (st_locale_insensitive_strcasecmp((s1), (s2)))
2326#define STRNCASECMP(s1, s2, n) (st_locale_insensitive_strncasecmp((s1), (s2), (n)))
2327
2328unsigned long ruby_strtoul(const char *str, char **endptr, int base);
2329#define STRTOUL(str, endptr, base) (ruby_strtoul((str), (endptr), (base)))
2330
2331#define InitVM(ext) {void InitVM_##ext(void);InitVM_##ext();}
2332
2333PRINTF_ARGS(int ruby_snprintf(char *str, size_t n, char const *fmt, ...), 3, 4);
2334int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
2335
2336/* -- Remove In 3.0, Only public for rb_scan_args optimized version -- */
2337int rb_empty_keyword_given_p(void);
2338
2339#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
2340# define rb_scan_args(argc,argvp,fmt,...) \
2341 __builtin_choose_expr(__builtin_constant_p(fmt), \
2342 rb_scan_args0(argc,argvp,fmt,\
2343 (sizeof((VALUE*[]){__VA_ARGS__})/sizeof(VALUE*)), \
2344 ((VALUE*[]){__VA_ARGS__})), \
2345 rb_scan_args(argc,argvp,fmt,##__VA_ARGS__))
2346# if HAVE_ATTRIBUTE_ERRORFUNC
2347ERRORFUNC(("bad scan arg format"), void rb_scan_args_bad_format(const char*));
2348ERRORFUNC(("variable argument length doesn't match"), void rb_scan_args_length_mismatch(const char*,int));
2349# else
2350# define rb_scan_args_bad_format(fmt) ((void)0)
2351# define rb_scan_args_length_mismatch(fmt, varc) ((void)0)
2352# endif
2353
2354# define rb_scan_args_isdigit(c) ((unsigned char)((c)-'0')<10)
2355
2356# define rb_scan_args_count_end(fmt, ofs, vari) \
2357 (fmt[ofs] ? -1 : (vari))
2358
2359# define rb_scan_args_count_block(fmt, ofs, vari) \
2360 (fmt[ofs]!='&' ? \
2361 rb_scan_args_count_end(fmt, ofs, vari) : \
2362 rb_scan_args_count_end(fmt, ofs+1, vari+1))
2363
2364# define rb_scan_args_count_hash(fmt, ofs, vari) \
2365 (fmt[ofs]!=':' ? \
2366 rb_scan_args_count_block(fmt, ofs, vari) : \
2367 rb_scan_args_count_block(fmt, ofs+1, vari+1))
2368
2369# define rb_scan_args_count_trail(fmt, ofs, vari) \
2370 (!rb_scan_args_isdigit(fmt[ofs]) ? \
2371 rb_scan_args_count_hash(fmt, ofs, vari) : \
2372 rb_scan_args_count_hash(fmt, ofs+1, vari+(fmt[ofs]-'0')))
2373
2374# define rb_scan_args_count_var(fmt, ofs, vari) \
2375 (fmt[ofs]!='*' ? \
2376 rb_scan_args_count_trail(fmt, ofs, vari) : \
2377 rb_scan_args_count_trail(fmt, ofs+1, vari+1))
2378
2379# define rb_scan_args_count_opt(fmt, ofs, vari) \
2380 (!rb_scan_args_isdigit(fmt[ofs]) ? \
2381 rb_scan_args_count_var(fmt, ofs, vari) : \
2382 rb_scan_args_count_var(fmt, ofs+1, vari+fmt[ofs]-'0'))
2383
2384# define rb_scan_args_count_lead(fmt, ofs, vari) \
2385 (!rb_scan_args_isdigit(fmt[ofs]) ? \
2386 rb_scan_args_count_var(fmt, ofs, vari) : \
2387 rb_scan_args_count_opt(fmt, ofs+1, vari+fmt[ofs]-'0'))
2388
2389# define rb_scan_args_count(fmt) rb_scan_args_count_lead(fmt, 0, 0)
2390
2391# if defined(__has_attribute) && __has_attribute(diagnose_if)
2392# define rb_scan_args_verify(fmt, varc) (void)0
2393# else
2394# define rb_scan_args_verify(fmt, varc) \
2395 (sizeof(char[1-2*(rb_scan_args_count(fmt)<0)])!=1 ? \
2396 rb_scan_args_bad_format(fmt) : \
2397 sizeof(char[1-2*(rb_scan_args_count(fmt)!=(varc))])!=1 ? \
2398 rb_scan_args_length_mismatch(fmt, varc) : \
2399 (void)0)
2400# endif
2401
2402ALWAYS_INLINE(static int rb_scan_args_lead_p(const char *fmt));
2403static inline int
2404rb_scan_args_lead_p(const char *fmt)
2405{
2406 return rb_scan_args_isdigit(fmt[0]);
2407}
2408
2409ALWAYS_INLINE(static int rb_scan_args_n_lead(const char *fmt));
2410static inline int
2411rb_scan_args_n_lead(const char *fmt)
2412{
2413 return (rb_scan_args_lead_p(fmt) ? fmt[0]-'0' : 0);
2414}
2415
2416ALWAYS_INLINE(static int rb_scan_args_opt_p(const char *fmt));
2417static inline int
2418rb_scan_args_opt_p(const char *fmt)
2419{
2420 return (rb_scan_args_lead_p(fmt) && rb_scan_args_isdigit(fmt[1]));
2421}
2422
2423ALWAYS_INLINE(static int rb_scan_args_n_opt(const char *fmt));
2424static inline int
2425rb_scan_args_n_opt(const char *fmt)
2426{
2427 return (rb_scan_args_opt_p(fmt) ? fmt[1]-'0' : 0);
2428}
2429
2430ALWAYS_INLINE(static int rb_scan_args_var_idx(const char *fmt));
2431static inline int
2432rb_scan_args_var_idx(const char *fmt)
2433{
2434 return (!rb_scan_args_lead_p(fmt) ? 0 : !rb_scan_args_isdigit(fmt[1]) ? 1 : 2);
2435}
2436
2437ALWAYS_INLINE(static int rb_scan_args_f_var(const char *fmt));
2438static inline int
2439rb_scan_args_f_var(const char *fmt)
2440{
2441 return (fmt[rb_scan_args_var_idx(fmt)]=='*');
2442}
2443
2444ALWAYS_INLINE(static int rb_scan_args_trail_idx(const char *fmt));
2445static inline int
2446rb_scan_args_trail_idx(const char *fmt)
2447{
2448 const int idx = rb_scan_args_var_idx(fmt);
2449 return idx+(fmt[idx]=='*');
2450}
2451
2452ALWAYS_INLINE(static int rb_scan_args_n_trail(const char *fmt));
2453static inline int
2454rb_scan_args_n_trail(const char *fmt)
2455{
2456 const int idx = rb_scan_args_trail_idx(fmt);
2457 return (rb_scan_args_isdigit(fmt[idx]) ? fmt[idx]-'0' : 0);
2458}
2459
2460ALWAYS_INLINE(static int rb_scan_args_hash_idx(const char *fmt));
2461static inline int
2462rb_scan_args_hash_idx(const char *fmt)
2463{
2464 const int idx = rb_scan_args_trail_idx(fmt);
2465 return idx+rb_scan_args_isdigit(fmt[idx]);
2466}
2467
2468ALWAYS_INLINE(static int rb_scan_args_f_hash(const char *fmt));
2469static inline int
2470rb_scan_args_f_hash(const char *fmt)
2471{
2472 return (fmt[rb_scan_args_hash_idx(fmt)]==':');
2473}
2474
2475ALWAYS_INLINE(static int rb_scan_args_block_idx(const char *fmt));
2476static inline int
2477rb_scan_args_block_idx(const char *fmt)
2478{
2479 const int idx = rb_scan_args_hash_idx(fmt);
2480 return idx+(fmt[idx]==':');
2481}
2482
2483ALWAYS_INLINE(static int rb_scan_args_f_block(const char *fmt));
2484static inline int
2485rb_scan_args_f_block(const char *fmt)
2486{
2487 return (fmt[rb_scan_args_block_idx(fmt)]=='&');
2488}
2489
2490# if 0
2491ALWAYS_INLINE(static int rb_scan_args_end_idx(const char *fmt));
2492static inline int
2493rb_scan_args_end_idx(const char *fmt)
2494{
2495 const int idx = rb_scan_args_block_idx(fmt);
2496 return idx+(fmt[idx]=='&');
2497}
2498# endif
2499
2500/* NOTE: Use `char *fmt` instead of `const char *fmt` because of clang's bug*/
2501/* https://bugs.llvm.org/show_bug.cgi?id=38095 */
2502# define rb_scan_args0(argc, argv, fmt, varc, vars) \
2503 rb_scan_args_set(argc, argv, \
2504 rb_scan_args_n_lead(fmt), \
2505 rb_scan_args_n_opt(fmt), \
2506 rb_scan_args_n_trail(fmt), \
2507 rb_scan_args_f_var(fmt), \
2508 rb_scan_args_f_hash(fmt), \
2509 rb_scan_args_f_block(fmt), \
2510 (rb_scan_args_verify(fmt, varc), vars), (char *)fmt, varc)
2511ALWAYS_INLINE(static int
2512rb_scan_args_set(int argc, const VALUE *argv,
2513 int n_lead, int n_opt, int n_trail,
2514 int f_var, int f_hash, int f_block,
2515 VALUE *vars[], char *fmt, int varc));
2516
2517inline int
2518rb_scan_args_set(int argc, const VALUE *argv,
2519 int n_lead, int n_opt, int n_trail,
2520 int f_var, int f_hash, int f_block,
2521 VALUE *vars[], RB_UNUSED_VAR(char *fmt), RB_UNUSED_VAR(int varc))
2522# if defined(__has_attribute) && __has_attribute(diagnose_if)
2523 __attribute__((diagnose_if(rb_scan_args_count(fmt)<0,"bad scan arg format","error")))
2524 __attribute__((diagnose_if(rb_scan_args_count(fmt)!=varc,"variable argument length doesn't match","error")))
2525# endif
2526{
2527 int i, argi = 0, vari = 0, last_idx = -1;
2528 VALUE *var, hash = Qnil, last_hash = 0;
2529 const int n_mand = n_lead + n_trail;
2530 int keyword_given = rb_keyword_given_p();
2531 int empty_keyword_given = 0;
2532 VALUE tmp_buffer = 0;
2533
2534 if (!keyword_given) {
2535 empty_keyword_given = rb_empty_keyword_given_p();
2536 }
2537
2538 /* capture an option hash - phase 1: pop */
2539 /* Ignore final positional hash if empty keywords given */
2540 if (argc > 0 && !(f_hash && empty_keyword_given)) {
2541 VALUE last = argv[argc - 1];
2542
2543 if (f_hash && n_mand < argc) {
2544 if (keyword_given) {
2545 if (!RB_TYPE_P(last, T_HASH)) {
2546 rb_warn("Keyword flag set when calling rb_scan_args, but last entry is not a hash");
2547 }
2548 else {
2549 hash = last;
2550 }
2551 }
2552 else if (NIL_P(last)) {
2553 /* For backwards compatibility, nil is taken as an empty
2554 option hash only if it is not ambiguous; i.e. '*' is
2555 not specified and arguments are given more than sufficient.
2556 This will be removed in Ruby 3. */
2557 if (!f_var && n_mand + n_opt < argc) {
2558 rb_warn("The last argument is nil, treating as empty keywords");
2559 argc--;
2560 }
2561 }
2562 else {
2563 hash = rb_check_hash_type(last);
2564 }
2565
2566 /* Ruby 3: Remove if branch, as it will not attempt to split hashes */
2567 if (!NIL_P(hash)) {
2568 VALUE opts = rb_extract_keywords(&hash);
2569
2570 if (!(last_hash = hash)) {
2571 if (!keyword_given) {
2572 /* Warn if treating positional as keyword, as in Ruby 3,
2573 this will be an error */
2574 rb_warn("Using the last argument as keyword parameters is deprecated");
2575 }
2576 argc--;
2577 }
2578 else {
2579 /* Warn if splitting either positional hash to keywords or keywords
2580 to positional hash, as in Ruby 3, no splitting will be done */
2581 rb_warn("The last argument is split into positional and keyword parameters");
2582 last_idx = argc - 1;
2583 }
2584 hash = opts ? opts : Qnil;
2585 }
2586 }
2587 else if (f_hash && keyword_given && n_mand == argc) {
2588 /* Warn if treating keywords as positional, as in Ruby 3, this will be an error */
2589 rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
2590 }
2591 }
2592 if (f_hash && n_mand > 0 && n_mand == argc+1 && empty_keyword_given) {
2593 VALUE *ptr = (VALUE *)rb_alloc_tmp_buffer2(&tmp_buffer, argc+1, sizeof(VALUE));
2594 memcpy(ptr, argv, sizeof(VALUE)*argc);
2595 ptr[argc] = rb_hash_new();
2596 argc++;
2597 *(&argv) = ptr;
2598 rb_warn("Passing the keyword argument as the last hash parameter is deprecated");
2599 }
2600
2601
2602 if (argc < n_mand) {
2603 goto argc_error;
2604 }
2605
2606 /* capture leading mandatory arguments */
2607 for (i = n_lead; i-- > 0; ) {
2608 var = vars[vari++];
2609 if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
2610 argi++;
2611 }
2612 /* capture optional arguments */
2613 for (i = n_opt; i-- > 0; ) {
2614 var = vars[vari++];
2615 if (argi < argc - n_trail) {
2616 if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
2617 argi++;
2618 }
2619 else {
2620 if (var) *var = Qnil;
2621 }
2622 }
2623 /* capture variable length arguments */
2624 if (f_var) {
2625 int n_var = argc - argi - n_trail;
2626
2627 var = vars[vari++];
2628 if (0 < n_var) {
2629 if (var) {
2630 int f_last = (last_idx + 1 == argc - n_trail);
2631 *var = rb_ary_new4(n_var-f_last, &argv[argi]);
2632 if (f_last) rb_ary_push(*var, last_hash);
2633 }
2634 argi += n_var;
2635 }
2636 else {
2637 if (var) *var = rb_ary_new();
2638 }
2639 }
2640 /* capture trailing mandatory arguments */
2641 for (i = n_trail; i-- > 0; ) {
2642 var = vars[vari++];
2643 if (var) *var = (argi == last_idx) ? last_hash : argv[argi];
2644 argi++;
2645 }
2646 /* capture an option hash - phase 2: assignment */
2647 if (f_hash) {
2648 var = vars[vari++];
2649 if (var) *var = hash;
2650 }
2651 /* capture iterator block */
2652 if (f_block) {
2653 var = vars[vari++];
2654 if (rb_block_given_p()) {
2655 *var = rb_block_proc();
2656 }
2657 else {
2658 *var = Qnil;
2659 }
2660 }
2661
2662 if (argi < argc) {
2663 argc_error:
2664 if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer);
2665 rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
2666 }
2667
2668 if (tmp_buffer) rb_free_tmp_buffer(&tmp_buffer);
2669 return argc;
2670}
2671#endif
2672
2673#if defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO) && defined(__OPTIMIZE__)
2674# define rb_yield_values(argc, ...) \
2675__extension__({ \
2676 const int rb_yield_values_argc = (argc); \
2677 const VALUE rb_yield_values_args[] = {__VA_ARGS__}; \
2678 const int rb_yield_values_nargs = \
2679 (int)(sizeof(rb_yield_values_args) / sizeof(VALUE)); \
2680 rb_yield_values2( \
2681 rb_varargs_argc_check(rb_yield_values_argc, rb_yield_values_nargs), \
2682 rb_yield_values_nargs ? rb_yield_values_args : NULL); \
2683 })
2684
2685# define rb_funcall(recv, mid, argc, ...) \
2686__extension__({ \
2687 const int rb_funcall_argc = (argc); \
2688 const VALUE rb_funcall_args[] = {__VA_ARGS__}; \
2689 const int rb_funcall_nargs = \
2690 (int)(sizeof(rb_funcall_args) / sizeof(VALUE)); \
2691 rb_funcallv(recv, mid, \
2692 rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
2693 rb_funcall_nargs ? rb_funcall_args : NULL); \
2694 })
2695#endif
2696
2697#ifndef RUBY_DONT_SUBST
2698#include "ruby/subst.h"
2699#endif
2700
2717void ruby_sysinit(int *argc, char ***argv);
2718void ruby_init(void);
2719void* ruby_options(int argc, char** argv);
2720int ruby_executable_node(void *n, int *status);
2721int ruby_run_node(void *n);
2722
2723/* version.c */
2724void ruby_show_version(void);
2725void ruby_show_copyright(void);
2726
2727
2730#define RUBY_INIT_STACK \
2731 VALUE variable_in_this_stack_frame; \
2732 ruby_init_stack(&variable_in_this_stack_frame);
2735void ruby_init_stack(volatile VALUE*);
2736
2737int ruby_setup(void);
2738int ruby_cleanup(volatile int);
2739
2740void ruby_finalize(void);
2741NORETURN(void ruby_stop(int));
2742
2744int ruby_stack_check(void);
2745size_t ruby_stack_length(VALUE**);
2746
2747int ruby_exec_node(void *n);
2748
2749void ruby_script(const char* name);
2751
2752void ruby_prog_init(void);
2753void ruby_set_argv(int, char**);
2754void *ruby_process_options(int, char**);
2755void ruby_init_loadpath(void);
2756void ruby_incpush(const char*);
2757void ruby_sig_finalize(void);
2758
2761#if !defined RUBY_EXPORT && !defined RUBY_NO_OLD_COMPATIBILITY
2762# include "ruby/backward.h"
2763#endif
2764
2766
2767#if defined(__cplusplus)
2768#if 0
2769{ /* satisfy cc-mode */
2770#endif
2771} /* extern "C" { */
2772extern "C++" {
2773#endif
2774
2775#ifdef RB_METHOD_DEFINITION_DECL
2776
2777RB_METHOD_DEFINITION_DECL(rb_define_method, (2,3), (VALUE klass, const char *name), (klass, name))
2778#ifdef __cplusplus
2779#define rb_define_method(m, n, f, a) rb_define_method_tmpl<a>::define(m, n, f)
2780#else
2781#define rb_define_method_if_constexpr(x, t, f) __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(x),(x),0),(t),(f))
2782#define rb_define_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_method15,rb_define_methodm3)
2783#define rb_define_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_method14,rb_define_method_choose_prototype15(n))
2784#define rb_define_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_method13,rb_define_method_choose_prototype14(n))
2785#define rb_define_method_choose_prototype12(n) rb_define_method_if_constexpr((n)==12,rb_define_method12,rb_define_method_choose_prototype13(n))
2786#define rb_define_method_choose_prototype11(n) rb_define_method_if_constexpr((n)==11,rb_define_method11,rb_define_method_choose_prototype12(n))
2787#define rb_define_method_choose_prototype10(n) rb_define_method_if_constexpr((n)==10,rb_define_method10,rb_define_method_choose_prototype11(n))
2788#define rb_define_method_choose_prototype9(n) rb_define_method_if_constexpr((n)== 9,rb_define_method9, rb_define_method_choose_prototype10(n))
2789#define rb_define_method_choose_prototype8(n) rb_define_method_if_constexpr((n)== 8,rb_define_method8, rb_define_method_choose_prototype9(n))
2790#define rb_define_method_choose_prototype7(n) rb_define_method_if_constexpr((n)== 7,rb_define_method7, rb_define_method_choose_prototype8(n))
2791#define rb_define_method_choose_prototype6(n) rb_define_method_if_constexpr((n)== 6,rb_define_method6, rb_define_method_choose_prototype7(n))
2792#define rb_define_method_choose_prototype5(n) rb_define_method_if_constexpr((n)== 5,rb_define_method5, rb_define_method_choose_prototype6(n))
2793#define rb_define_method_choose_prototype4(n) rb_define_method_if_constexpr((n)== 4,rb_define_method4, rb_define_method_choose_prototype5(n))
2794#define rb_define_method_choose_prototype3(n) rb_define_method_if_constexpr((n)== 3,rb_define_method3, rb_define_method_choose_prototype4(n))
2795#define rb_define_method_choose_prototype2(n) rb_define_method_if_constexpr((n)== 2,rb_define_method2, rb_define_method_choose_prototype3(n))
2796#define rb_define_method_choose_prototype1(n) rb_define_method_if_constexpr((n)== 1,rb_define_method1, rb_define_method_choose_prototype2(n))
2797#define rb_define_method_choose_prototype0(n) rb_define_method_if_constexpr((n)== 0,rb_define_method0, rb_define_method_choose_prototype1(n))
2798#define rb_define_method_choose_prototypem1(n) rb_define_method_if_constexpr((n)==-1,rb_define_methodm1,rb_define_method_choose_prototype0(n))
2799#define rb_define_method_choose_prototypem2(n) rb_define_method_if_constexpr((n)==-2,rb_define_methodm2,rb_define_method_choose_prototypem1(n))
2800#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))
2801#define rb_define_method(klass, mid, func, arity) rb_define_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
2802#endif
2803
2804RB_METHOD_DEFINITION_DECL(rb_define_module_function, (2,3), (VALUE klass, const char *name), (klass, name))
2805#ifdef __cplusplus
2806#define rb_define_module_function(m, n, f, a) rb_define_module_function_tmpl<a>::define(m, n, f)
2807#else
2808#define rb_define_module_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_module_function15,rb_define_module_functionm3)
2809#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))
2810#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))
2811#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))
2812#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))
2813#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))
2814#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))
2815#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))
2816#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))
2817#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))
2818#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))
2819#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))
2820#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))
2821#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))
2822#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))
2823#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))
2824#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))
2825#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))
2826#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))
2827#define rb_define_module_function(klass, mid, func, arity) rb_define_module_function_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity));
2828#endif
2829
2830RB_METHOD_DEFINITION_DECL(rb_define_global_function, (1,2), (const char *name), (name))
2831#ifdef __cplusplus
2832#define rb_define_global_function(n, f, a) rb_define_global_function_tmpl<a>::define(n, f)
2833#else
2834#define rb_define_global_function_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_global_function15,rb_define_global_functionm3)
2835#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))
2836#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))
2837#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))
2838#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))
2839#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))
2840#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))
2841#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))
2842#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))
2843#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))
2844#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))
2845#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))
2846#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))
2847#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))
2848#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))
2849#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))
2850#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))
2851#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))
2852#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))
2853#define rb_define_global_function(mid, func, arity) rb_define_global_function_choose_prototypem3((arity),(func))((mid),(func),(arity));
2854#endif
2855
2856#endif
2857
2858#if defined(RUBY_DEVEL) && RUBY_DEVEL && (!defined(__cplusplus) || defined(RB_METHOD_DEFINITION_DECL))
2859# define RUBY_METHOD_FUNC(func) (func)
2860#else
2861# define RUBY_METHOD_FUNC(func) ((VALUE (*)(ANYARGS))(func))
2862#endif
2863
2864#ifdef __cplusplus
2865#include "backward/cxxanyargs.hpp"
2866
2867#if 0
2868{ /* satisfy cc-mode */
2869#endif
2870} /* extern "C++" { */
2871#endif
2872
2873#endif /* RUBY_RUBY_H */
Provides old prototypes for C++ programs.
struct RIMemo * ptr
Definition: debug.c:65
#define free(x)
Definition: dln.c:52
int count
Definition: encoding.c:57
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
void ruby_stop(int ex)
Calls ruby_cleanup() and exits the process.
Definition: eval.c:288
#define rb_data_object_alloc
Definition: gc.c:14
void ruby_malloc_size_overflow(size_t count, size_t elsize)
Definition: gc.c:10107
void rb_gc_unprotect_logging(void *objptr, const char *filename, int line)
Definition: gc.c:6925
#define rb_data_typed_object_alloc
Definition: gc.c:15
VALUE rb_singleton_class_clone(VALUE)
Definition: class.c:373
void rb_singleton_class_attached(VALUE, VALUE)
Attach a object to a singleton class.
Definition: class.c:444
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
Definition: ruby.h:1966
VALUE rb_call_super_kw(int, const VALUE *, int)
Definition: vm_eval.c:298
VALUE rb_eval_string(const char *)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1715
RUBY_EXTERN VALUE rb_cArray
Definition: ruby.h:2013
RUBY_EXTERN VALUE rb_cTrueClass
Definition: ruby.h:2051
int rb_scan_args(int, const VALUE *, const char *,...)
Definition: class.c:2177
RUBY_EXTERN VALUE rb_cThread
Definition: ruby.h:2049
void rb_add_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data)
Definition: vm_trace.c:157
RUBY_EXTERN VALUE rb_cNilClass
Definition: ruby.h:2038
RUBY_EXTERN VALUE rb_cRange
Definition: ruby.h:2042
void rb_define_virtual_variable(const char *, rb_gvar_getter_t *, rb_gvar_setter_t *)
Definition: variable.c:511
void * data
Definition: ruby.h:1172
VALUE rb_funcallv(VALUE, ID, int, const VALUE *)
Calls a method.
Definition: vm_eval.c:956
RUBY_EXTERN VALUE rb_cRational
Definition: ruby.h:2043
rb_gvar_setter_t rb_gvar_var_setter
Definition: ruby.h:1795
RUBY_EXTERN VALUE rb_cEnumerator
Definition: ruby.h:2023
RUBY_EXTERN VALUE rb_stderr
Definition: ruby.h:2092
rb_gvar_marker_t rb_gvar_var_marker
Definition: ruby.h:1796
VALUE rb_rescue2(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE,...)
An equivalent of rescue clause.
Definition: eval.c:962
int rb_empty_keyword_given_p(void)
Definition: eval.c:919
RUBY_EXTERN VALUE rb_cUnboundMethod
Definition: ruby.h:2052
#define RARRAY_TRANSIENT_FLAG
Definition: ruby.h:1036
void rb_define_attr(VALUE, const char *, int, int)
Defines (a) public accessor method(s) for an attribute.
Definition: class.c:1831
int st_locale_insensitive_strcasecmp(const char *s1, const char *s2)
Definition: st.c:2082
RUBY_EXTERN VALUE rb_mKernel
Definition: ruby.h:2000
RUBY_EXTERN VALUE rb_eStopIteration
Definition: ruby.h:2063
VALUE rb_vrescue2(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE, va_list)
An equivalent of rescue clause.
Definition: eval.c:977
@ ROBJECT_ENUM_END
Definition: ruby.h:919
VALUE rb_gv_set(const char *, VALUE)
Definition: variable.c:671
VALUE rb_syserr_new(int, const char *)
Definition: error.c:2769
VALUE * ivptr
Definition: ruby.h:927
RUBY_EXTERN VALUE rb_eStandardError
Definition: ruby.h:2055
void rb_glob(const char *, void(*)(const char *, VALUE, void *), VALUE)
Definition: dir.c:2544
VALUE rb_define_module_under(VALUE, const char *)
Definition: class.c:810
RUBY_EXTERN VALUE rb_cClass
Definition: ruby.h:2018
RUBY_EXTERN VALUE rb_cData
Definition: ruby.h:2020
VALUE rb_extract_keywords(VALUE *orighash)
Definition: class.c:1886
VALUE rb_funcallv_kw(VALUE, ID, int, const VALUE *, int)
Definition: vm_eval.c:962
void rb_gc_register_mark_object(VALUE)
Definition: gc.c:7079
void rb_gc_unregister_address(VALUE *)
Definition: gc.c:7105
const rb_data_type_t * parent
Definition: ruby.h:1158
VALUE rb_id2str(ID)
Definition: symbol.c:795
VALUE rb_syserr_new_str(int n, VALUE arg)
Definition: error.c:2777
void rb_p(VALUE)
Definition: io.c:7802
RUBY_EXTERN VALUE rb_eZeroDivError
Definition: ruby.h:2073
RUBY_EXTERN VALUE rb_eLocalJumpError
Definition: ruby.h:2078
VALUE rb_block_call_kw(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE, int)
Definition: vm_eval.c:1484
RUBY_EXTERN VALUE rb_cFile
Definition: ruby.h:2025
void rb_gvar_marker_t(VALUE *var)
Definition: ruby.h:1784
void rb_need_block(void)
Declares that the current method needs a block.
Definition: eval.c:932
void rb_prepend_module(VALUE, VALUE)
Definition: class.c:1017
RUBY_EXTERN VALUE rb_eInterrupt
Definition: ruby.h:2057
VALUE rb_check_symbol(volatile VALUE *namep)
Definition: symbol.c:952
void rb_define_global_function(const char *, VALUE(*)(ANYARGS), int)
Defines a global function.
Definition: class.c:1805
const char * rb_id2name(ID)
Definition: symbol.c:801
RUBY_EXTERN VALUE rb_eSyntaxError
Definition: ruby.h:2087
void rb_gvar_setter_t(VALUE val, ID id, VALUE *data)
Definition: ruby.h:1783
RUBY_EXTERN VALUE rb_cStruct
Definition: ruby.h:2047
const VALUE shared_root
Definition: ruby.h:1060
RUBY_EXTERN VALUE rb_cBasicObject
Definition: ruby.h:2011
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:2012
int ruby_brace_glob(const char *, int, ruby_glob_func *, VALUE)
Definition: dir.c:2659
void rb_define_variable(const char *, VALUE *)
Definition: variable.c:499
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2903
NORETURN(void rb_insecure_operation(void))
RUBY_EXTERN VALUE rb_eScriptError
Definition: ruby.h:2085
int rb_remove_event_hook(rb_event_hook_func_t func)
Definition: vm_trace.c:262
#define RUBY_FL_USER_N(n)
Definition: ruby.h:855
RUBY_EXTERN VALUE rb_eFrozenError
Definition: ruby.h:2068
RUBY_EXTERN VALUE rb_eEncCompatError
Definition: ruby.h:2082
RUBY_EXTERN VALUE rb_cHash
Definition: ruby.h:2031
VALUE rb_current_receiver(void)
Definition: vm_eval.c:314
@ RUBY_SPECIAL_SHIFT
Definition: ruby.h:460
@ RUBY_FIXNUM_FLAG
Definition: ruby.h:444
@ RUBY_FLONUM_MASK
Definition: ruby.h:445
@ RUBY_FLONUM_FLAG
Definition: ruby.h:446
@ RUBY_SYMBOL_FLAG
Definition: ruby.h:447
@ RUBY_IMMEDIATE_MASK
Definition: ruby.h:443
void rb_freeze_singleton_class(VALUE klass)
Definition: class.c:1692
long capa
Definition: ruby.h:995
VALUE rb_sym2str(VALUE)
Definition: symbol.c:784
RUBY_EXTERN VALUE rb_cInteger
Definition: ruby.h:2033
RUBY_EXTERN VALUE rb_eEOFError
Definition: ruby.h:2061
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *)
Definition: class.c:1904
RUBY_EXTERN VALUE rb_cTime
Definition: ruby.h:2050
rb_gvar_setter_t rb_gvar_val_setter
Definition: ruby.h:1791
void rb_define_method(VALUE, const char *, VALUE(*)(ANYARGS), int)
Definition: class.c:1569
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:922
VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE *, VALUE)
Definition: vm_eval.c:1050
void * data
Definition: ruby.h:1143
struct rb_io_t * fptr
Definition: ruby.h:1136
void rb_obj_infect(VALUE victim, VALUE carrier)
Does nothing.
Definition: object.c:1068
VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE *)
Definition: vm_eval.c:1032
void rb_gc_writebarrier_unprotect(VALUE obj)
Definition: gc.c:6854
RUBY_EXTERN VALUE rb_cNumeric
Definition: ruby.h:2039
VALUE rb_catch(const char *, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:2290
int ruby_glob(const char *, int, ruby_glob_func *, VALUE)
Definition: dir.c:2519
rb_gvar_marker_t rb_gvar_undef_marker
Definition: ruby.h:1788
RUBY_EXTERN VALUE rb_eRegexpError
Definition: ruby.h:2080
RUBY_EXTERN VALUE rb_eIOError
Definition: ruby.h:2066
void rb_undef_method(VALUE, const char *)
Definition: class.c:1593
VALUE rb_iterate(VALUE(*)(VALUE), VALUE, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:1444
const char * rb_obj_classname(VALUE)
Definition: variable.c:289
void rb_global_variable(VALUE *)
Definition: gc.c:7128
VALUE rb_ensure(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE), VALUE)
An equivalent to ensure clause.
Definition: eval.c:1115
RUBY_EXTERN VALUE rb_cString
Definition: ruby.h:2046
void * rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t len, size_t count) RUBY_ATTR_ALLOC_SIZE((2
VALUE typed_flag
Definition: ruby.h:1171
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
Definition: sprintf.c:1004
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:3318
VALUE rb_yield_values(int n,...)
Definition: vm_eval.c:1249
RUBY_EXTERN VALUE rb_cFalseClass
Definition: ruby.h:2024
const VALUE src
Definition: ruby.h:1115
rb_gvar_getter_t rb_gvar_undef_getter
Definition: ruby.h:1786
rb_gvar_marker_t rb_gvar_val_marker
Definition: ruby.h:1792
RUBY_EXTERN VALUE rb_mGC
Definition: ruby.h:2005
RUBY_EXTERN VALUE rb_cNameErrorMesg
Definition: ruby.h:2037
void rb_define_const(VALUE, const char *, VALUE)
Definition: variable.c:2891
long len
Definition: ruby.h:992
void(* rb_event_hook_func_t)(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
Definition: ruby.h:2281
RUBY_EXTERN VALUE rb_cRandom
Definition: ruby.h:2041
@ RARRAY_ENUM_END
Definition: ruby.h:1041
RUBY_EXTERN VALUE rb_eNameError
Definition: ruby.h:2086
RUBY_EXTERN VALUE rb_stdout
Definition: ruby.h:2092
VALUE rb_define_class(const char *, VALUE)
Defines a top-level class.
Definition: class.c:662
RUBY_EXTERN VALUE rb_eException
Definition: ruby.h:2054
RUBY_EXTERN VALUE rb_cRegexp
Definition: ruby.h:2044
RUBY_EXTERN VALUE rb_eIndexError
Definition: ruby.h:2062
long capa
Definition: ruby.h:1054
void * rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2))
Definition: gc.c:10278
DEPRECATED_BY(rb_data_object_wrap, static inline VALUE rb_data_object_alloc(VALUE, void *, RUBY_DATA_FUNC, RUBY_DATA_FUNC))
RUBY_EXTERN VALUE rb_eSystemCallError
Definition: ruby.h:2070
RUBY_EXTERN VALUE rb_eEncodingError
Definition: ruby.h:2081
const rb_data_type_t * type
Definition: ruby.h:1170
void rb_gc_register_address(VALUE *)
Definition: gc.c:7093
VALUE * rb_ruby_verbose_ptr(void)
Definition: vm.c:3377
PRINTF_ARGS(NORETURN(void rb_raise(VALUE, const char *,...)), 2, 3)
ID rb_intern2(const char *, long)
Definition: symbol.c:653
RUBY_EXTERN VALUE rb_cSymbol
Definition: ruby.h:2048
unsigned long ruby_strtoul(const char *str, char **endptr, int base)
Definition: util.c:130
VALUE rb_yield_values2(int n, const VALUE *argv)
Definition: vm_eval.c:1271
RUBY_EXTERN VALUE rb_eFloatDomainError
Definition: ruby.h:2077
void rb_define_readonly_variable(const char *, const VALUE *)
Definition: variable.c:505
VALUE rb_require(const char *)
Definition: load.c:1161
RUBY_EXTERN VALUE rb_eSignal
Definition: ruby.h:2058
const char * wrap_struct_name
Definition: ruby.h:1149
ID rb_intern(const char *)
Definition: symbol.c:660
long len
Definition: ruby.h:1052
RUBY_EXTERN VALUE rb_eThreadError
Definition: ruby.h:2071
VALUE rb_yield_values_kw(int n, const VALUE *argv, int kw_splat)
Definition: vm_eval.c:1277
RUBY_EXTERN VALUE rb_mErrno
Definition: ruby.h:2003
RUBY_EXTERN VALUE rb_eFatal
Definition: ruby.h:2059
void rb_gc_writebarrier(VALUE a, VALUE b)
Definition: gc.c:6833
RUBY_EXTERN VALUE rb_eRuntimeError
Definition: ruby.h:2067
VALUE rb_funcallv_public_kw(VALUE, ID, int, const VALUE *, int)
Definition: vm_eval.c:986
void rb_define_module_function(VALUE, const char *, VALUE(*)(ANYARGS), int)
Defines a module function for module.
Definition: class.c:1789
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
Definition: class.c:711
void void rb_free_tmp_buffer(volatile VALUE *store)
Definition: gc.c:10290
rb_block_call_func * rb_block_call_func_t
Definition: ruby.h:1969
int ruby_glob_func(const char *, VALUE, void *)
Definition: ruby.h:1768
RUBY_EXTERN VALUE rb_eSystemExit
Definition: ruby.h:2056
RUBY_EXTERN VALUE rb_eRangeError
Definition: ruby.h:2065
VALUE rb_funcall_passing_block_kw(VALUE, ID, int, const VALUE *, int)
Definition: vm_eval.c:1039
RUBY_EXTERN VALUE rb_eLoadError
Definition: ruby.h:2088
VALUE shared
Definition: ruby.h:996
RUBY_EXTERN VALUE rb_eNoMemError
Definition: ruby.h:2075
#define FIX_CONST_VALUE_PTR(x)
Definition: ruby.h:2180
int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: st.c:2106
RUBY_EXTERN VALUE rb_mProcess
Definition: ruby.h:2007
char * ptr
Definition: ruby.h:993
VALUE rb_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
RUBY_EXTERN VALUE rb_cProc
Definition: ruby.h:2040
RUBY_EXTERN VALUE rb_cMatch
Definition: ruby.h:2034
RUBY_EXTERN VALUE rb_mWaitWritable
Definition: ruby.h:2009
RUBY_EXTERN VALUE rb_cComplex
Definition: ruby.h:2029
VALUE rb_gv_get(const char *)
Definition: variable.c:680
RUBY_EXTERN VALUE rb_mWaitReadable
Definition: ruby.h:2008
void rb_include_module(VALUE, VALUE)
Definition: class.c:882
ID rb_check_id(volatile VALUE *)
Returns ID for the given name if it is interned already, or 0.
Definition: symbol.c:919
VALUE rb_funcall_with_block_kw(VALUE, ID, int, const VALUE *, VALUE, int)
Definition: vm_eval.c:1060
#define RB_IO_WAIT_WRITABLE
Definition: ruby.h:1933
VALUE rb_to_symbol(VALUE name)
Definition: string.c:11156
RUBY_EXTERN VALUE rb_mEnumerable
Definition: ruby.h:2002
VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
Definition: ruby.h:1968
unsigned long usecnt
Definition: ruby.h:1116
VALUE rb_eval_string_wrap(const char *, int *)
Evaluates the given string under a module binding in an isolated binding.
Definition: vm_eval.c:1769
void rb_define_hooked_variable(const char *, VALUE *, rb_gvar_getter_t *, rb_gvar_setter_t *)
Definition: variable.c:480
VALUE rb_each(VALUE)
Definition: vm_eval.c:1542
RUBY_EXTERN VALUE rb_eSysStackError
Definition: ruby.h:2079
uint32_t rb_event_flag_t
Definition: ruby.h:2280
uint32_t numiv
Definition: ruby.h:926
RUBY_EXTERN VALUE rb_cStat
Definition: ruby.h:2045
VALUE rb_yield_splat(VALUE)
Definition: vm_eval.c:1283
VALUE rb_iv_get(VALUE, const char *)
Definition: variable.c:3305
RUBY_EXTERN VALUE rb_cBinding
Definition: ruby.h:2017
VALUE * rb_ruby_debug_ptr(void)
Definition: vm.c:3383
VALUE rb_yield_splat_kw(VALUE, int)
Definition: vm_eval.c:1296
@ RSTRING_ENUM_END
Definition: ruby.h:985
RUBY_EXTERN VALUE rb_cModule
Definition: ruby.h:2036
void rb_extend_object(VALUE, VALUE)
Extend the object with the module.
Definition: eval.c:1701
void * iv_index_tbl
Definition: ruby.h:928
VALUE rb_gvar_getter_t(ID id, VALUE *data)
Definition: ruby.h:1782
VALUE rb_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:1470
RUBY_EXTERN VALUE rb_mComparable
Definition: ruby.h:2001
VALUE rb_eval_string_protect(const char *, int *)
Evaluates the given string in an isolated binding.
Definition: vm_eval.c:1737
#define RB_IO_WAIT_READABLE
Definition: ruby.h:1932
RUBY_EXTERN VALUE rb_eSecurityError
Definition: ruby.h:2069
RUBY_EXTERN VALUE rb_cFloat
Definition: ruby.h:2030
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:2006
RUBY_EXTERN VALUE rb_eTypeError
Definition: ruby.h:2072
VALUE rb_define_module(const char *)
Definition: class.c:785
VALUE rb_equal(VALUE, VALUE)
Same as Object#===, case equality.
Definition: object.c:124
RUBY_EXTERN VALUE rb_mFileTest
Definition: ruby.h:2004
void rb_define_alias(VALUE, const char *, const char *)
Defines an alias of a method.
Definition: class.c:1818
VALUE rb_rescue(VALUE(*)(VALUE), VALUE, VALUE(*)(VALUE, VALUE), VALUE)
An equivalent of rescue clause.
Definition: eval.c:1047
RUBY_EXTERN VALUE rb_cMethod
Definition: ruby.h:2035
const VALUE * ptr
Definition: ruby.h:1062
VALUE rb_yield(VALUE)
Definition: vm_eval.c:1237
int rb_keyword_given_p(void)
Definition: eval.c:911
RUBY_EXTERN VALUE rb_cEncoding
Definition: ruby.h:2022
RUBY_EXTERN VALUE rb_cCont
Definition: ruby.h:2019
int rb_block_given_p(void)
Determines if the current method is given a block.
Definition: eval.c:898
rb_gvar_setter_t rb_gvar_undef_setter
Definition: ruby.h:1787
rb_gvar_getter_t rb_gvar_val_getter
Definition: ruby.h:1790
ID rb_intern_str(VALUE str)
Definition: symbol.c:666
@ RUBY_FL_PROMOTED1
Definition: ruby.h:844
@ RUBY_FL_SINGLETON
Definition: ruby.h:883
@ RUBY_FL_TAINT
Definition: ruby.h:847
@ RUBY_FL_USHIFT
Definition: ruby.h:853
@ RUBY_FL_WB_PROTECTED
Definition: ruby.h:842
@ RUBY_FL_PROMOTED0
Definition: ruby.h:843
@ RUBY_FL_EXIVAR
Definition: ruby.h:850
@ RUBY_FL_UNTRUSTED
Definition: ruby.h:848
@ RUBY_FL_PROMOTED
Definition: ruby.h:845
@ RUBY_FL_FREEZE
Definition: ruby.h:851
@ RUBY_FL_DUPPED
Definition: ruby.h:882
@ RUBY_FL_SEEN_OBJ_ID
Definition: ruby.h:849
@ RUBY_FL_FINALIZE
Definition: ruby.h:846
@ RUBY_T_SYMBOL
Definition: ruby.h:508
@ RUBY_T_MATCH
Definition: ruby.h:501
@ RUBY_T_MODULE
Definition: ruby.h:491
@ RUBY_T_ICLASS
Definition: ruby.h:514
@ RUBY_T_MOVED
Definition: ruby.h:516
@ RUBY_T_FIXNUM
Definition: ruby.h:509
@ RUBY_T_IMEMO
Definition: ruby.h:512
@ RUBY_T_NODE
Definition: ruby.h:513
@ RUBY_T_OBJECT
Definition: ruby.h:489
@ RUBY_T_DATA
Definition: ruby.h:500
@ RUBY_T_FALSE
Definition: ruby.h:507
@ RUBY_T_UNDEF
Definition: ruby.h:510
@ RUBY_T_COMPLEX
Definition: ruby.h:502
@ RUBY_T_STRING
Definition: ruby.h:493
@ RUBY_T_HASH
Definition: ruby.h:496
@ RUBY_T_NIL
Definition: ruby.h:505
@ RUBY_T_CLASS
Definition: ruby.h:490
@ RUBY_T_ARRAY
Definition: ruby.h:495
@ RUBY_T_MASK
Definition: ruby.h:518
@ RUBY_T_RATIONAL
Definition: ruby.h:503
@ RUBY_T_ZOMBIE
Definition: ruby.h:515
@ RUBY_T_BIGNUM
Definition: ruby.h:498
@ RUBY_T_TRUE
Definition: ruby.h:506
@ RUBY_T_FLOAT
Definition: ruby.h:492
@ RUBY_T_STRUCT
Definition: ruby.h:497
@ RUBY_T_NONE
Definition: ruby.h:487
@ RUBY_T_REGEXP
Definition: ruby.h:494
@ RUBY_T_FILE
Definition: ruby.h:499
RUBY_EXTERN VALUE rb_cIO
Definition: ruby.h:2032
int ruby_native_thread_p(void)
Definition: thread.c:5276
RUBY_EXTERN VALUE rb_eKeyError
Definition: ruby.h:2064
int rb_scan_args_kw(int, int, const VALUE *, const char *,...)
Definition: class.c:2198
RUBY_EXTERN VALUE rb_eNoMatchingPatternError
Definition: ruby.h:2083
#define RUBY_UNTYPED_DATA_FUNC(func)
Definition: ruby.h:1397
RUBY_EXTERN VALUE rb_eNoMethodError
Definition: ruby.h:2076
@ RMODULE_ENUM_END
Definition: ruby.h:959
const char * rb_class2name(VALUE)
Definition: variable.c:280
RUBY_EXTERN VALUE rb_eNotImpError
Definition: ruby.h:2074
VALUE rb_catch_obj(VALUE, rb_block_call_func_t, VALUE)
Definition: vm_eval.c:2332
VALUE rb_funcallv_public(VALUE, ID, int, const VALUE *)
Calls a method.
Definition: vm_eval.c:980
RUBY_EXTERN VALUE rb_eArgError
Definition: ruby.h:2060
VALUE rb_call_super(int, const VALUE *)
Definition: vm_eval.c:306
struct re_pattern_buffer * ptr
Definition: ruby.h:1114
RUBY_EXTERN VALUE rb_stdin
Definition: ruby.h:2092
RUBY_EXTERN VALUE rb_eMathDomainError
Definition: ruby.h:2090
rb_gvar_getter_t rb_gvar_var_getter
Definition: ruby.h:1794
ID rb_to_id(VALUE)
Definition: string.c:11146
RUBY_EXTERN VALUE rb_cDir
Definition: ruby.h:2021
void ruby_set_argv(int, char **)
Definition: ruby.c:2391
int ruby_exec_node(void *n)
Runs the given compiled source.
Definition: eval.c:341
void ruby_incpush(const char *)
Definition: ruby.c:426
int ruby_setup(void)
Initializes the VM and builtin libraries.
Definition: eval.c:56
void ruby_finalize(void)
Runs the VM finalization processes.
Definition: eval.c:163
void ruby_script(const char *name)
Sets the current script name to this value.
Definition: ruby.c:2302
void ruby_set_script_name(VALUE name)
Sets the current script name to this value.
Definition: ruby.c:2315
int ruby_stack_check(void)
Definition: gc.c:4687
void ruby_init_loadpath(void)
Definition: ruby.c:586
void ruby_init_stack(volatile VALUE *)
void * ruby_process_options(int, char **)
Definition: ruby.c:2412
void ruby_prog_init(void)
Defines built-in variables.
Definition: ruby.c:2366
int ruby_cleanup(volatile int)
Destructs the VM.
Definition: eval.c:181
void ruby_sig_finalize(void)
Definition: signal.c:1470
size_t ruby_stack_length(VALUE **)
Definition: gc.c:4647
void ruby_set_stack_size(size_t)
void rb_notimplement(void)
Definition: error.c:2714
void rb_syserr_fail(int e, const char *mesg)
Definition: error.c:2783
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2671
int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent)
Definition: error.c:864
void rb_mod_sys_fail_str(VALUE mod, VALUE mesg)
Definition: error.c:2843
void rb_mod_sys_fail(VALUE mod, const char *mesg)
Definition: error.c:2835
int rb_typeddata_is_kind_of(VALUE, const rb_data_type_t *)
Definition: error.c:874
void rb_bug(const char *fmt,...)
Definition: error.c:636
void rb_set_errinfo(VALUE)
Sets the current exception ($!) to the given value.
Definition: eval.c:1896
void rb_syserr_fail_str(int e, VALUE mesg)
Definition: error.c:2789
void rb_sys_fail_str(VALUE mesg)
Definition: error.c:2801
void rb_fatal(const char *fmt,...)
Definition: error.c:2722
void rb_bug_errno(const char *mesg, int errno_arg)
Definition: error.c:669
void * rb_check_typeddata(VALUE, const rb_data_type_t *)
Definition: error.c:891
void rb_warn(const char *fmt,...)
Definition: error.c:315
void rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
Definition: error.c:2851
VALUE rb_errinfo(void)
The current exception in the current thread.
Definition: eval.c:1882
void rb_sys_fail(const char *mesg)
Definition: error.c:2795
void rb_mod_syserr_fail_str(VALUE mod, int e, VALUE mesg)
Definition: error.c:2859
void rb_check_type(VALUE, int)
Definition: error.c:839
VALUE rb_obj_reveal(VALUE obj, VALUE klass)
Make a hidden object visible again.
Definition: object.c:95
VALUE rb_obj_hide(VALUE obj)
Make the object invisible from Ruby code.
Definition: object.c:78
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
Definition: object.c:217
double rb_num2dbl(VALUE)
Converts a Numeric object to double.
Definition: object.c:3616
VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
Fills common (RBasic) fields in obj.
Definition: object.c:112
int ruby_run_node(void *n)
Runs the given compiled source and exits this process.
Definition: eval.c:327
void ruby_init(void)
Calls ruby_setup() and check error.
Definition: eval.c:94
void * ruby_options(int argc, char **argv)
Processes command line arguments and compiles the Ruby source to execute.
Definition: eval.c:115
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout.
Definition: version.c:138
void ruby_sysinit(int *argc, char ***argv)
Initializes the process for libruby.
Definition: ruby.c:2472
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
Definition: version.c:119
int ruby_executable_node(void *n, int *status)
Checks the return value of ruby_options().
Definition: eval.c:306
void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite writable, int n, const char *mesg)
Definition: io.c:12944
void rb_readwrite_sys_fail(enum rb_io_wait_readwrite writable, const char *mesg)
Definition: io.c:12938
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39
const char * name
Definition: nkf.c:208
unsigned int last
Definition: nkf.c:4324
long rb_num2int(VALUE val)
Definition: numeric.c:3002
double rb_float_value(VALUE v)
Definition: numeric.c:5841
long rb_fix2int(VALUE val)
Definition: numeric.c:3008
void rb_exit(int status)
Definition: process.c:4225
__uint32_t uint32_t
#define rb_data_object_get
#define rb_cBignum
const char *void void rb_compile_warning(const char *, int, const char *,...) __attribute__((format(printf
#define UNLIMITED_ARGUMENTS
#define RUBY_ATTR_ALLOC_SIZE(params)
VALUE rb_ull2inum(unsigned long long)
void rb_copy_generic_ivar(VALUE, VALUE)
Definition: variable.c:1447
#define ALWAYS_INLINE(x)
const VALUE int int int int int int VALUE * vars[]
VALUE rb_ll2inum(long long)
void rb_compile_warn(const char *, int, const char *,...) __attribute__((format(printf
#define SIZEOF_LONG
#define rb_data_object_wrap_warning(klass, ptr, mark, free)
#define COLDFUNC
const VALUE VALUE obj
const rb_iseq_t const char * error
#define SIZEOF_INT
char ruby_check_sizeof_long_long[8==sizeof(long long) ? 1 :-1]
__intptr_t intptr_t
#define rb_special_const_p(obj)
const VALUE int int int int int int VALUE char int varc
const VALUE int int int int int f_hash
const char size_t n
#define RUBY_SYMBOL_EXPORT_BEGIN
int ruby_snprintf(char *str, size_t n, char const *fmt,...) __attribute__((format(printf
const VALUE int int int int f_var
unsigned long VALUE
VALUE rb_ary_push(VALUE, VALUE)
Definition: array.c:1195
void rb_ary_detransient(VALUE a)
Definition: array.c:408
#define rb_ary_new4
__inline__ const void *__restrict__ src
const VALUE int int int n_trail
const VALUE int int int int int int f_block
uint32_t i
__inline__ const void *__restrict__ size_t len
const VALUE int int int int int int VALUE char * fmt
VALUE rb_block_proc(void)
Definition: proc.c:837
VALUE * rb_ary_ptr_use_start(VALUE ary)
Definition: array.c:226
__gnuc_va_list va_list
#define long
void rb_ary_ptr_use_end(VALUE ary)
Definition: array.c:235
#define SIZEOF_VOIDP
#define RB_UNLIKELY(x)
#define RUBY_SYMBOL_EXPORT_END
void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_)
Definition: variable.c:412
const char * s2
int VALUE v
VALUE rb_ary_new(void)
Definition: array.c:723
const VALUE int n_lead
const char *void void void rb_sys_warning(const char *,...) __attribute__((format(printf
unsigned int size
rb_block_call_func * rb_block_call_func_t
long unsigned int size_t
#define rb_scan_args_count(fmt)
const VALUE int int n_opt
int dup(int __fildes)
__uintptr_t uintptr_t
void * memcpy(void *__restrict__, const void *__restrict__, size_t)
VALUE rb_check_hash_type(VALUE)
Definition: hash.c:1852
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)))
const VALUE * argv
#define SIZEOF_LONG_LONG
uint32_t rb_event_flag_t
__inline__ int
#define rb_cFixnum
#define DSIZE_T
#define rb_data_object_make
#define RUBY_EXTERN
unsigned long ID
rb_control_frame_t * __attribute__((__fastcall__)) *rb_insn_func_t)(rb_execution_context_t *
#define rb_scan_args_isdigit(c)
const char *void rb_warning(const char *,...) __attribute__((format(printf
#define ERRORFUNC(mesg, x)
VALUE rb_hash_new(void)
Definition: hash.c:1523
#define ANYARGS
#define LONG_LONG
int ruby_safe_level_2_error(void) __attribute__((error("$SAFE
#define RARRAY_EMBED_FLAG
Definition: ruby.h:1043
VALUE rb_str_to_str(VALUE)
Definition: string.c:1382
volatile VALUE * rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
Definition: gc.c:250
VALUE rb_data_object_zalloc(VALUE, size_t, RUBY_DATA_FUNC, RUBY_DATA_FUNC)
#define RSTRING_LEN(str)
Definition: ruby.h:1005
#define RB_FIX2LONG(x)
Definition: ruby.h:378
#define RB_INT2FIX(i)
Definition: ruby.h:262
VALUE rb_int2inum(intptr_t)
Definition: bignum.c:3208
#define RBASIC(obj)
Definition: ruby.h:1267
VALUE rb_data_object_wrap(VALUE, void *, RUBY_DATA_FUNC, RUBY_DATA_FUNC)
Definition: gc.c:2391
VALUE rb_newobj(void)
Definition: gc.c:2303
#define RUBY_Qfalse
Definition: ruby.h:463
#define RMODULE_INCLUDED_INTO_REFINEMENT
Definition: ruby.h:953
#define RB_UNUSED_VAR(x)
Definition: ruby.h:591
void rb_set_safe_level_force(int)
Definition: safe.c:38
int rb_big_sign(VALUE)
Definition: bignum.c:6772
#define RB_SPECIAL_CONST_P(x)
Definition: ruby.h:1312
#define RMODULE_IS_REFINEMENT
Definition: ruby.h:952
ruby_robject_flags
Definition: ruby.h:915
VALUE rb_uint2inum(uintptr_t)
Definition: bignum.c:3201
#define ROBJECT_EMBED_LEN_MAX
Definition: ruby.h:913
#define RSTRING_NOEMBED
Definition: ruby.h:972
unsigned long VALUE
Definition: ruby.h:102
#define RSTRING_PTR(str)
Definition: ruby.h:1009
void rb_secure_update(VALUE)
Definition: safe.c:116
VALUE rb_str_export_locale(VALUE)
Definition: string.c:1129
#define RB_POSFIXABLE(f)
Definition: ruby.h:391
#define NIL_P(v)
Definition: ruby.h:482
#define RB_LONG2FIX(i)
Definition: ruby.h:264
#define ROBJECT_EMBED
Definition: ruby.h:914
char ruby_check_sizeof_int[SIZEOF_INT==sizeof(int) ? 1 :-1]
Definition: ruby.h:118
VALUE rb_id2sym(ID)
Definition: symbol.c:776
VALUE rb_float_new(double)
Definition: numeric.c:5848
#define LONG_MAX
Definition: ruby.h:220
#define RB_FL_TEST_RAW(x, f)
Definition: ruby.h:1316
char * rb_string_value_ptr(volatile VALUE *)
Definition: string.c:2186
VALUE rb_str_export(VALUE)
Definition: string.c:1123
#define FL_PROMOTED0
Definition: ruby.h:1280
void rb_set_safe_level(int)
Definition: safe.c:45
VALUE rb_int2big(intptr_t)
Definition: bignum.c:3180
#define RB_FIX2ULONG(x)
Definition: ruby.h:384
#define RARRAY(obj)
Definition: ruby.h:1273
#define FL_FINALIZE
Definition: ruby.h:1282
RUBY_SYMBOL_EXPORT_BEGIN void * alloca()
long rb_num2long(VALUE)
Definition: numeric.c:2854
#define RB_FLONUM_P(x)
Definition: ruby.h:426
VALUE rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
VALUE rb_float_new_in_heap(double)
Definition: numeric.c:895
#define TypedData_Make_Struct0(result, klass, type, size, data_type, sval)
Definition: ruby.h:1234
#define T_HASH
Definition: ruby.h:531
#define NUM2INT(x)
Definition: ruby.h:715
ruby_rarray_flags
Definition: ruby.h:1027
#define RSTRING_EMBED_LEN_MAX
Definition: ruby.h:975
#define RSTRING_FSTR
Definition: ruby.h:976
void rb_secure(int)
Definition: safe.c:99
PUREFUNC(double rb_float_value(VALUE))
#define RB_FL_TEST(x, f)
Definition: ruby.h:1317
#define RSTRING_EMBED_LEN_SHIFT
Definition: ruby.h:974
VALUE rb_string_value(volatile VALUE *)
Definition: string.c:2175
unsigned short rb_fix2ushort(VALUE)
Definition: numeric.c:3074
#define RB_IMMEDIATE_P(x)
Definition: ruby.h:401
#define RARRAY_EMBED_LEN_SHIFT
Definition: ruby.h:1046
unsigned long rb_num2ulong(VALUE)
Definition: numeric.c:2923
#define RUBY_Qundef
Definition: ruby.h:466
ruby_rvalue_flags
Definition: ruby.h:909
#define RB_FIXABLE(f)
Definition: ruby.h:393
int rb_safe_level(void)
Definition: safe.c:31
char ruby_check_sizeof_voidp[SIZEOF_VOIDP==sizeof(void *) ? 1 :-1]
Definition: ruby.h:123
#define RB_FIXNUM_P(f)
Definition: ruby.h:390
#define RARRAY_EMBED_LEN_MAX
Definition: ruby.h:1045
VALUE rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *)
Definition: gc.c:2412
#define Qnil
Definition: ruby.h:469
short rb_fix2short(VALUE)
Definition: numeric.c:3055
#define SIGNED_VALUE
Definition: ruby.h:104
#define RARRAY_TRANSIENT_P(ary)
Definition: ruby.h:1076
ID rb_sym2id(VALUE)
Definition: symbol.c:748
#define RB_TYPE_P(obj, type)
Definition: ruby.h:560
#define RMODULE_IS_OVERLAID
Definition: ruby.h:951
#define RUBY_ELTS_SHARED
Definition: ruby.h:969
#define RARRAY_EMBED_LEN(a)
Definition: ruby.h:1067
#define RB_OBJ_FREEZE_RAW(x)
Definition: ruby.h:1343
#define Data_Make_Struct0(result, klass, type, size, mark, free, sval)
Definition: ruby.h:1214
#define RB_TEST(v)
Definition: ruby.h:479
VALUE rb_get_path(VALUE)
Definition: file.c:230
#define RUBY_Qtrue
Definition: ruby.h:464
char * rb_string_value_cstr(volatile VALUE *)
Definition: string.c:2291
void(* RUBY_DATA_FUNC)(void *)
Definition: ruby.h:1184
ruby_rstring_flags
Definition: ruby.h:977
#define Check_Type(v, t)
Definition: ruby.h:595
#define RARRAY_EMBED_LEN_MASK
Definition: ruby.h:1044
void rb_check_safe_obj(VALUE)
Definition: safe.c:136
short rb_num2short(VALUE)
Definition: numeric.c:3046
#define FL_PROMOTED1
Definition: ruby.h:1281
#define RUBY_Qnil
Definition: ruby.h:465
#define RB_BUILTIN_TYPE(x)
Definition: ruby.h:550
#define RVALUE_EMBED_LEN_MAX
Definition: ruby.h:908
#define RBASIC_CLASS(obj)
Definition: ruby.h:906
size_t rb_hash_size_num(VALUE hash)
Definition: hash.c:2945
VALUE rb_get_path_no_checksafe(VALUE)
Definition: file.c:224
#define RB_STATIC_SYM_P(x)
Definition: ruby.h:406
ruby_fl_type
Definition: ruby.h:841
VALUE rb_uint2big(uintptr_t)
Definition: bignum.c:3158
ruby_rmodule_flags
Definition: ruby.h:954
unsigned short rb_num2ushort(VALUE)
Definition: numeric.c:3064
VALUE rb_newobj_of(VALUE, VALUE)
Definition: gc.c:2309
unsigned long ID
Definition: ruby.h:103
#define RSTRING_EMBED_LEN_MASK
Definition: ruby.h:973
#define rb_check_safe_str(x)
Definition: ruby.h:612
#define RB_FL_ABLE(x)
Definition: ruby.h:1315
char ruby_check_sizeof_long[SIZEOF_LONG==sizeof(long) ? 1 :-1]
Definition: ruby.h:119
int ruby_safe_level_2_warning(void)
Definition: safe.c:24
void rb_insecure_operation(void)
Definition: safe.c:122
rb_atomic_t cnt[RUBY_NSIG]
Definition: signal.c:503
Definition: ruby.h:1048
Definition: ruby.h:1139
Definition: ruby.h:1134
Definition: ruby.h:922
Definition: ruby.h:1112
Definition: ruby.h:988
Definition: gc.c:90
Definition: io.h:66
void rb_iter_break(void)
Definition: vm.c:1546
void rb_iter_break_value(VALUE val)
Definition: vm.c:1552
void rb_throw(const char *tag, VALUE val)
Definition: vm_eval.c:2220
void rb_throw_obj(VALUE tag, VALUE value)
Definition: vm_eval.c:2195
MJIT_STATIC void rb_error_arity(int argc, int min, int max)