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