debase-ruby_core_source 0.10.15 → 0.10.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/debase-ruby_core_source.gemspec +1 -1
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/addr2line.h +1 -1
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/ccan/list/list.h +773 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/ccan/str/str.h +16 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/constant.h +51 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/debug_counter.h +109 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/dln.h +10 -9
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/encindex.h +69 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/eval_intern.h +334 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/gc.h +27 -10
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/id.h +250 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/id_table.h +31 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/insns.inc +217 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/insns_info.inc +1570 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/internal.h +2036 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/iseq.h +308 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/known_errors.inc +16 -1
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/method.h +218 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/node.h +115 -79
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/node_name.inc +12 -22
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/opt_sc.inc +1601 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/optinsn.inc +103 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/optunifs.inc +28 -83
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/parse.h +74 -60
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/probes_helper.h +43 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/regenc.h +254 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/regint.h +299 -211
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/regparse.h +45 -37
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/revision.h +1 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/ruby_assert.h +54 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/ruby_atomic.h +84 -26
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/siphash.h +1 -1
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/symbol.h +108 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/thread_pthread.h +14 -11
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/thread_win32.h +2 -6
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/timev.h +42 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/transcode_data.h +34 -12
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/version.h +73 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/vm.inc +3667 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/vm_call_iseq_optimized.inc +213 -0
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/vm_core.h +1768 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550/debug.h → ruby-2.5.4-p155/vm_debug.h} +4 -8
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/vm_exec.h +38 -30
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/vm_insnhelper.h +255 -0
- data/lib/debase/ruby_core_source/{ruby-1.9.3-p550 → ruby-2.5.4-p155}/vm_opts.h +14 -9
- data/lib/debase/ruby_core_source/ruby-2.5.4-p155/vmtc.inc +214 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +52 -42
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/constant.h +0 -34
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/encdb.h +0 -167
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/eval_intern.h +0 -234
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/id.h +0 -177
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/insns.inc +0 -179
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/insns_info.inc +0 -695
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/internal.h +0 -242
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/iseq.h +0 -126
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/method.h +0 -105
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/opt_sc.inc +0 -670
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/optinsn.inc +0 -30
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/regenc.h +0 -219
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/revision.h +0 -1
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/timev.h +0 -21
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/transdb.h +0 -189
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/version.h +0 -52
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/vm.inc +0 -3054
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/vm_core.h +0 -763
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/vm_insnhelper.h +0 -220
- data/lib/debase/ruby_core_source/ruby-1.9.3-p550/vmtc.inc +0 -97
@@ -0,0 +1,2036 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
internal.h -
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
created at: Tue May 17 11:42:20 JST 2011
|
7
|
+
|
8
|
+
Copyright (C) 2011 Yukihiro Matsumoto
|
9
|
+
|
10
|
+
**********************************************************************/
|
11
|
+
|
12
|
+
#ifndef RUBY_INTERNAL_H
|
13
|
+
#define RUBY_INTERNAL_H 1
|
14
|
+
|
15
|
+
#include "ruby.h"
|
16
|
+
#include "ruby/encoding.h"
|
17
|
+
#include "ruby/io.h"
|
18
|
+
|
19
|
+
#if defined(__cplusplus)
|
20
|
+
extern "C" {
|
21
|
+
#if 0
|
22
|
+
} /* satisfy cc-mode */
|
23
|
+
#endif
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#ifdef HAVE_STDBOOL_H
|
27
|
+
# include <stdbool.h>
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#ifndef __bool_true_false_are_defined
|
31
|
+
# ifndef __cplusplus
|
32
|
+
# undef bool
|
33
|
+
# undef false
|
34
|
+
# undef true
|
35
|
+
# define bool signed char
|
36
|
+
# define false 0
|
37
|
+
# define true 1
|
38
|
+
# define __bool_true_false_are_defined 1
|
39
|
+
# endif
|
40
|
+
#endif
|
41
|
+
|
42
|
+
/* The most significant bit of the lower part of half-long integer.
|
43
|
+
* If sizeof(long) == 4, this is 0x8000.
|
44
|
+
* If sizeof(long) == 8, this is 0x80000000.
|
45
|
+
*/
|
46
|
+
#define HALF_LONG_MSB ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2))
|
47
|
+
|
48
|
+
#define LIKELY(x) RB_LIKELY(x)
|
49
|
+
#define UNLIKELY(x) RB_UNLIKELY(x)
|
50
|
+
|
51
|
+
#ifndef MAYBE_UNUSED
|
52
|
+
# define MAYBE_UNUSED(x) x
|
53
|
+
#endif
|
54
|
+
|
55
|
+
#ifndef WARN_UNUSED_RESULT
|
56
|
+
# define WARN_UNUSED_RESULT(x) x
|
57
|
+
#endif
|
58
|
+
|
59
|
+
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
60
|
+
# include <valgrind/memcheck.h>
|
61
|
+
# ifndef VALGRIND_MAKE_MEM_DEFINED
|
62
|
+
# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
|
63
|
+
# endif
|
64
|
+
# ifndef VALGRIND_MAKE_MEM_UNDEFINED
|
65
|
+
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
|
66
|
+
# endif
|
67
|
+
#else
|
68
|
+
# define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
|
69
|
+
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
|
70
|
+
#endif
|
71
|
+
|
72
|
+
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
|
73
|
+
|
74
|
+
#ifndef __has_feature
|
75
|
+
# define __has_feature(x) 0
|
76
|
+
#endif
|
77
|
+
|
78
|
+
#ifndef __has_extension
|
79
|
+
# define __has_extension __has_feature
|
80
|
+
#endif
|
81
|
+
|
82
|
+
#if GCC_VERSION_SINCE(4, 6, 0) || __has_extension(c_static_assert)
|
83
|
+
# define STATIC_ASSERT(name, expr) _Static_assert(expr, #name ": " #expr)
|
84
|
+
#else
|
85
|
+
# define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
|
86
|
+
#endif
|
87
|
+
|
88
|
+
#define SIGNED_INTEGER_TYPE_P(int_type) (0 > ((int_type)0)-1)
|
89
|
+
#define SIGNED_INTEGER_MAX(sint_type) \
|
90
|
+
(sint_type) \
|
91
|
+
((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) | \
|
92
|
+
((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) - 1))
|
93
|
+
#define SIGNED_INTEGER_MIN(sint_type) (-SIGNED_INTEGER_MAX(sint_type)-1)
|
94
|
+
#define UNSIGNED_INTEGER_MAX(uint_type) (~(uint_type)0)
|
95
|
+
|
96
|
+
#if SIGNEDNESS_OF_TIME_T < 0 /* signed */
|
97
|
+
# define TIMET_MAX SIGNED_INTEGER_MAX(time_t)
|
98
|
+
# define TIMET_MIN SIGNED_INTEGER_MIN(time_t)
|
99
|
+
#elif SIGNEDNESS_OF_TIME_T > 0 /* unsigned */
|
100
|
+
# define TIMET_MAX UNSIGNED_INTEGER_MAX(time_t)
|
101
|
+
# define TIMET_MIN ((time_t)0)
|
102
|
+
#endif
|
103
|
+
#define TIMET_MAX_PLUS_ONE (2*(double)(TIMET_MAX/2+1))
|
104
|
+
|
105
|
+
#ifdef HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW_P
|
106
|
+
#define MUL_OVERFLOW_P(a, b) \
|
107
|
+
__builtin_mul_overflow_p((a), (b), (__typeof__(a * b))0)
|
108
|
+
#elif defined HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW
|
109
|
+
#define MUL_OVERFLOW_P(a, b) \
|
110
|
+
({__typeof__(a) c; __builtin_mul_overflow((a), (b), &c);})
|
111
|
+
#endif
|
112
|
+
|
113
|
+
#define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
|
114
|
+
(a) == 0 ? 0 : \
|
115
|
+
(a) == -1 ? (b) < -(max) : \
|
116
|
+
(a) > 0 ? \
|
117
|
+
((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
|
118
|
+
((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
|
119
|
+
|
120
|
+
#ifdef HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW_P
|
121
|
+
/* __builtin_mul_overflow_p can take bitfield */
|
122
|
+
/* and GCC permits bitfields for integers other than int */
|
123
|
+
#define MUL_OVERFLOW_FIXNUM_P(a, b) ({ \
|
124
|
+
struct { long fixnum : SIZEOF_LONG * CHAR_BIT - 1; } c; \
|
125
|
+
__builtin_mul_overflow_p((a), (b), c.fixnum); \
|
126
|
+
})
|
127
|
+
#else
|
128
|
+
#define MUL_OVERFLOW_FIXNUM_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
|
129
|
+
#endif
|
130
|
+
|
131
|
+
#ifdef MUL_OVERFLOW_P
|
132
|
+
#define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
133
|
+
#define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
134
|
+
#define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_P(a, b)
|
135
|
+
#else
|
136
|
+
#define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
|
137
|
+
#define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
|
138
|
+
#define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
|
139
|
+
#endif
|
140
|
+
|
141
|
+
#ifndef swap16
|
142
|
+
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP16
|
143
|
+
# define swap16(x) __builtin_bswap16(x)
|
144
|
+
# endif
|
145
|
+
#endif
|
146
|
+
|
147
|
+
#ifndef swap16
|
148
|
+
# define swap16(x) ((uint16_t)((((x)&0xFF)<<8) | (((x)>>8)&0xFF)))
|
149
|
+
#endif
|
150
|
+
|
151
|
+
#ifndef swap32
|
152
|
+
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP32
|
153
|
+
# define swap32(x) __builtin_bswap32(x)
|
154
|
+
# endif
|
155
|
+
#endif
|
156
|
+
|
157
|
+
#ifndef swap32
|
158
|
+
# define swap32(x) ((uint32_t)((((x)&0xFF)<<24) \
|
159
|
+
|(((x)>>24)&0xFF) \
|
160
|
+
|(((x)&0x0000FF00)<<8) \
|
161
|
+
|(((x)&0x00FF0000)>>8) ))
|
162
|
+
#endif
|
163
|
+
|
164
|
+
#ifndef swap64
|
165
|
+
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP64
|
166
|
+
# define swap64(x) __builtin_bswap64(x)
|
167
|
+
# endif
|
168
|
+
#endif
|
169
|
+
|
170
|
+
#ifndef swap64
|
171
|
+
# ifdef HAVE_INT64_T
|
172
|
+
# define byte_in_64bit(n) ((uint64_t)0xff << (n))
|
173
|
+
# define swap64(x) ((uint64_t)((((x)&byte_in_64bit(0))<<56) \
|
174
|
+
|(((x)>>56)&0xFF) \
|
175
|
+
|(((x)&byte_in_64bit(8))<<40) \
|
176
|
+
|(((x)&byte_in_64bit(48))>>40) \
|
177
|
+
|(((x)&byte_in_64bit(16))<<24) \
|
178
|
+
|(((x)&byte_in_64bit(40))>>24) \
|
179
|
+
|(((x)&byte_in_64bit(24))<<8) \
|
180
|
+
|(((x)&byte_in_64bit(32))>>8)))
|
181
|
+
# endif
|
182
|
+
#endif
|
183
|
+
|
184
|
+
static inline unsigned int
|
185
|
+
nlz_int(unsigned int x)
|
186
|
+
{
|
187
|
+
#if defined(HAVE_BUILTIN___BUILTIN_CLZ)
|
188
|
+
if (x == 0) return SIZEOF_INT * CHAR_BIT;
|
189
|
+
return (unsigned int)__builtin_clz(x);
|
190
|
+
#else
|
191
|
+
unsigned int y;
|
192
|
+
# if 64 < SIZEOF_INT * CHAR_BIT
|
193
|
+
unsigned int n = 128;
|
194
|
+
# elif 32 < SIZEOF_INT * CHAR_BIT
|
195
|
+
unsigned int n = 64;
|
196
|
+
# else
|
197
|
+
unsigned int n = 32;
|
198
|
+
# endif
|
199
|
+
# if 64 < SIZEOF_INT * CHAR_BIT
|
200
|
+
y = x >> 64; if (y) {n -= 64; x = y;}
|
201
|
+
# endif
|
202
|
+
# if 32 < SIZEOF_INT * CHAR_BIT
|
203
|
+
y = x >> 32; if (y) {n -= 32; x = y;}
|
204
|
+
# endif
|
205
|
+
y = x >> 16; if (y) {n -= 16; x = y;}
|
206
|
+
y = x >> 8; if (y) {n -= 8; x = y;}
|
207
|
+
y = x >> 4; if (y) {n -= 4; x = y;}
|
208
|
+
y = x >> 2; if (y) {n -= 2; x = y;}
|
209
|
+
y = x >> 1; if (y) {return n - 2;}
|
210
|
+
return (unsigned int)(n - x);
|
211
|
+
#endif
|
212
|
+
}
|
213
|
+
|
214
|
+
static inline unsigned int
|
215
|
+
nlz_long(unsigned long x)
|
216
|
+
{
|
217
|
+
#if defined(HAVE_BUILTIN___BUILTIN_CLZL)
|
218
|
+
if (x == 0) return SIZEOF_LONG * CHAR_BIT;
|
219
|
+
return (unsigned int)__builtin_clzl(x);
|
220
|
+
#else
|
221
|
+
unsigned long y;
|
222
|
+
# if 64 < SIZEOF_LONG * CHAR_BIT
|
223
|
+
unsigned int n = 128;
|
224
|
+
# elif 32 < SIZEOF_LONG * CHAR_BIT
|
225
|
+
unsigned int n = 64;
|
226
|
+
# else
|
227
|
+
unsigned int n = 32;
|
228
|
+
# endif
|
229
|
+
# if 64 < SIZEOF_LONG * CHAR_BIT
|
230
|
+
y = x >> 64; if (y) {n -= 64; x = y;}
|
231
|
+
# endif
|
232
|
+
# if 32 < SIZEOF_LONG * CHAR_BIT
|
233
|
+
y = x >> 32; if (y) {n -= 32; x = y;}
|
234
|
+
# endif
|
235
|
+
y = x >> 16; if (y) {n -= 16; x = y;}
|
236
|
+
y = x >> 8; if (y) {n -= 8; x = y;}
|
237
|
+
y = x >> 4; if (y) {n -= 4; x = y;}
|
238
|
+
y = x >> 2; if (y) {n -= 2; x = y;}
|
239
|
+
y = x >> 1; if (y) {return n - 2;}
|
240
|
+
return (unsigned int)(n - x);
|
241
|
+
#endif
|
242
|
+
}
|
243
|
+
|
244
|
+
#ifdef HAVE_LONG_LONG
|
245
|
+
static inline unsigned int
|
246
|
+
nlz_long_long(unsigned LONG_LONG x)
|
247
|
+
{
|
248
|
+
#if defined(HAVE_BUILTIN___BUILTIN_CLZLL)
|
249
|
+
if (x == 0) return SIZEOF_LONG_LONG * CHAR_BIT;
|
250
|
+
return (unsigned int)__builtin_clzll(x);
|
251
|
+
#else
|
252
|
+
unsigned LONG_LONG y;
|
253
|
+
# if 64 < SIZEOF_LONG_LONG * CHAR_BIT
|
254
|
+
unsigned int n = 128;
|
255
|
+
# elif 32 < SIZEOF_LONG_LONG * CHAR_BIT
|
256
|
+
unsigned int n = 64;
|
257
|
+
# else
|
258
|
+
unsigned int n = 32;
|
259
|
+
# endif
|
260
|
+
# if 64 < SIZEOF_LONG_LONG * CHAR_BIT
|
261
|
+
y = x >> 64; if (y) {n -= 64; x = y;}
|
262
|
+
# endif
|
263
|
+
# if 32 < SIZEOF_LONG_LONG * CHAR_BIT
|
264
|
+
y = x >> 32; if (y) {n -= 32; x = y;}
|
265
|
+
# endif
|
266
|
+
y = x >> 16; if (y) {n -= 16; x = y;}
|
267
|
+
y = x >> 8; if (y) {n -= 8; x = y;}
|
268
|
+
y = x >> 4; if (y) {n -= 4; x = y;}
|
269
|
+
y = x >> 2; if (y) {n -= 2; x = y;}
|
270
|
+
y = x >> 1; if (y) {return n - 2;}
|
271
|
+
return (unsigned int)(n - x);
|
272
|
+
#endif
|
273
|
+
}
|
274
|
+
#endif
|
275
|
+
|
276
|
+
#ifdef HAVE_UINT128_T
|
277
|
+
static inline unsigned int
|
278
|
+
nlz_int128(uint128_t x)
|
279
|
+
{
|
280
|
+
uint128_t y;
|
281
|
+
unsigned int n = 128;
|
282
|
+
y = x >> 64; if (y) {n -= 64; x = y;}
|
283
|
+
y = x >> 32; if (y) {n -= 32; x = y;}
|
284
|
+
y = x >> 16; if (y) {n -= 16; x = y;}
|
285
|
+
y = x >> 8; if (y) {n -= 8; x = y;}
|
286
|
+
y = x >> 4; if (y) {n -= 4; x = y;}
|
287
|
+
y = x >> 2; if (y) {n -= 2; x = y;}
|
288
|
+
y = x >> 1; if (y) {return n - 2;}
|
289
|
+
return (unsigned int)(n - x);
|
290
|
+
}
|
291
|
+
#endif
|
292
|
+
|
293
|
+
static inline unsigned int
|
294
|
+
nlz_intptr(uintptr_t x)
|
295
|
+
{
|
296
|
+
#if SIZEOF_VOIDP == 8
|
297
|
+
return nlz_long_long(x);
|
298
|
+
#elif SIZEOF_VOIDP == 4
|
299
|
+
return nlz_int(x);
|
300
|
+
#endif
|
301
|
+
}
|
302
|
+
|
303
|
+
static inline unsigned int
|
304
|
+
rb_popcount32(uint32_t x)
|
305
|
+
{
|
306
|
+
#ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
|
307
|
+
return (unsigned int)__builtin_popcount(x);
|
308
|
+
#else
|
309
|
+
x = (x & 0x55555555) + (x >> 1 & 0x55555555);
|
310
|
+
x = (x & 0x33333333) + (x >> 2 & 0x33333333);
|
311
|
+
x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
|
312
|
+
x = (x & 0x001f001f) + (x >> 8 & 0x001f001f);
|
313
|
+
return (x & 0x0000003f) + (x >>16 & 0x0000003f);
|
314
|
+
#endif
|
315
|
+
}
|
316
|
+
|
317
|
+
static inline int
|
318
|
+
rb_popcount64(uint64_t x)
|
319
|
+
{
|
320
|
+
#ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
|
321
|
+
return __builtin_popcountll(x);
|
322
|
+
#else
|
323
|
+
x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
|
324
|
+
x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
|
325
|
+
x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
|
326
|
+
x = (x & 0x001f001f001f001f) + (x >> 8 & 0x001f001f001f001f);
|
327
|
+
x = (x & 0x0000003f0000003f) + (x >>16 & 0x0000003f0000003f);
|
328
|
+
return (x & 0x7f) + (x >>32 & 0x7f);
|
329
|
+
#endif
|
330
|
+
}
|
331
|
+
|
332
|
+
static inline int
|
333
|
+
rb_popcount_intptr(uintptr_t x)
|
334
|
+
{
|
335
|
+
#if SIZEOF_VOIDP == 8
|
336
|
+
return rb_popcount64(x);
|
337
|
+
#elif SIZEOF_VOIDP == 4
|
338
|
+
return rb_popcount32(x);
|
339
|
+
#endif
|
340
|
+
}
|
341
|
+
|
342
|
+
static inline int
|
343
|
+
ntz_int32(uint32_t x)
|
344
|
+
{
|
345
|
+
#ifdef HAVE_BUILTIN___BUILTIN_CTZ
|
346
|
+
return __builtin_ctz(x);
|
347
|
+
#else
|
348
|
+
return rb_popcount32((~x) & (x-1));
|
349
|
+
#endif
|
350
|
+
}
|
351
|
+
|
352
|
+
static inline int
|
353
|
+
ntz_int64(uint64_t x)
|
354
|
+
{
|
355
|
+
#ifdef HAVE_BUILTIN___BUILTIN_CTZLL
|
356
|
+
return __builtin_ctzll(x);
|
357
|
+
#else
|
358
|
+
return rb_popcount64((~x) & (x-1));
|
359
|
+
#endif
|
360
|
+
}
|
361
|
+
|
362
|
+
static inline int
|
363
|
+
ntz_intptr(uintptr_t x)
|
364
|
+
{
|
365
|
+
#if SIZEOF_VOIDP == 8
|
366
|
+
return ntz_int64(x);
|
367
|
+
#elif SIZEOF_VOIDP == 4
|
368
|
+
return ntz_int32(x);
|
369
|
+
#endif
|
370
|
+
}
|
371
|
+
|
372
|
+
#if HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
|
373
|
+
# define DLONG LONG_LONG
|
374
|
+
# define DL2NUM(x) LL2NUM(x)
|
375
|
+
#elif defined(HAVE_INT128_T)
|
376
|
+
# define DLONG int128_t
|
377
|
+
# define DL2NUM(x) (RB_FIXABLE(x) ? LONG2FIX(x) : rb_int128t2big(x))
|
378
|
+
VALUE rb_int128t2big(int128_t n);
|
379
|
+
#endif
|
380
|
+
|
381
|
+
static inline long
|
382
|
+
rb_overflowed_fix_to_int(long x)
|
383
|
+
{
|
384
|
+
return (long)((unsigned long)(x >> 1) ^ (1LU << (SIZEOF_LONG * CHAR_BIT - 1)));
|
385
|
+
}
|
386
|
+
|
387
|
+
static inline VALUE
|
388
|
+
rb_fix_plus_fix(VALUE x, VALUE y)
|
389
|
+
{
|
390
|
+
#ifdef HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
|
391
|
+
long lz;
|
392
|
+
/* NOTE
|
393
|
+
* (1) `LONG2FIX(FIX2LONG(x)+FIX2LONG(y))`
|
394
|
+
+ = `((lx*2+1)/2 + (ly*2+1)/2)*2+1`
|
395
|
+
+ = `lx*2 + ly*2 + 1`
|
396
|
+
+ = `(lx*2+1) + (ly*2+1) - 1`
|
397
|
+
+ = `x + y - 1`
|
398
|
+
* (2) Fixnum's LSB is always 1.
|
399
|
+
* It means you can always run `x - 1` without overflow.
|
400
|
+
* (3) Of course `z = x + (y-1)` may overflow.
|
401
|
+
* At that time true value is
|
402
|
+
* * positive: 0b0 1xxx...1, and z = 0b1xxx...1
|
403
|
+
* * nevative: 0b1 0xxx...1, and z = 0b0xxx...1
|
404
|
+
* To convert this true value to long,
|
405
|
+
* (a) Use arithmetic shift
|
406
|
+
* * positive: 0b11xxx...
|
407
|
+
* * negative: 0b00xxx...
|
408
|
+
* (b) invert MSB
|
409
|
+
* * positive: 0b01xxx...
|
410
|
+
* * negative: 0b10xxx...
|
411
|
+
*/
|
412
|
+
if (__builtin_add_overflow((long)x, (long)y-1, &lz)) {
|
413
|
+
return rb_int2big(rb_overflowed_fix_to_int(lz));
|
414
|
+
}
|
415
|
+
else {
|
416
|
+
return (VALUE)lz;
|
417
|
+
}
|
418
|
+
#else
|
419
|
+
long lz = FIX2LONG(x) + FIX2LONG(y);
|
420
|
+
return LONG2NUM(lz);
|
421
|
+
#endif
|
422
|
+
}
|
423
|
+
|
424
|
+
static inline VALUE
|
425
|
+
rb_fix_minus_fix(VALUE x, VALUE y)
|
426
|
+
{
|
427
|
+
#ifdef HAVE_BUILTIN___BUILTIN_SUB_OVERFLOW
|
428
|
+
long lz;
|
429
|
+
if (__builtin_sub_overflow((long)x, (long)y-1, &lz)) {
|
430
|
+
return rb_int2big(rb_overflowed_fix_to_int(lz));
|
431
|
+
}
|
432
|
+
else {
|
433
|
+
return (VALUE)lz;
|
434
|
+
}
|
435
|
+
#else
|
436
|
+
long lz = FIX2LONG(x) - FIX2LONG(y);
|
437
|
+
return LONG2NUM(lz);
|
438
|
+
#endif
|
439
|
+
}
|
440
|
+
|
441
|
+
/* arguments must be Fixnum */
|
442
|
+
static inline VALUE
|
443
|
+
rb_fix_mul_fix(VALUE x, VALUE y)
|
444
|
+
{
|
445
|
+
long lx = FIX2LONG(x);
|
446
|
+
long ly = FIX2LONG(y);
|
447
|
+
#ifdef DLONG
|
448
|
+
return DL2NUM((DLONG)lx * (DLONG)ly);
|
449
|
+
#else
|
450
|
+
if (MUL_OVERFLOW_FIXNUM_P(lx, ly)) {
|
451
|
+
return rb_big_mul(rb_int2big(lx), rb_int2big(ly));
|
452
|
+
}
|
453
|
+
else {
|
454
|
+
return LONG2FIX(lx * ly);
|
455
|
+
}
|
456
|
+
#endif
|
457
|
+
}
|
458
|
+
|
459
|
+
/*
|
460
|
+
* This behaves different from C99 for negative arguments.
|
461
|
+
* Note that div may overflow fixnum.
|
462
|
+
*/
|
463
|
+
static inline void
|
464
|
+
rb_fix_divmod_fix(VALUE a, VALUE b, VALUE *divp, VALUE *modp)
|
465
|
+
{
|
466
|
+
/* assume / and % comply C99.
|
467
|
+
* ldiv(3) won't be inlined by GCC and clang.
|
468
|
+
* I expect / and % are compiled as single idiv.
|
469
|
+
*/
|
470
|
+
long x = FIX2LONG(a);
|
471
|
+
long y = FIX2LONG(b);
|
472
|
+
long div, mod;
|
473
|
+
if (x == FIXNUM_MIN && y == -1) {
|
474
|
+
if (divp) *divp = LONG2NUM(-FIXNUM_MIN);
|
475
|
+
if (modp) *modp = LONG2FIX(0);
|
476
|
+
return;
|
477
|
+
}
|
478
|
+
div = x / y;
|
479
|
+
mod = x % y;
|
480
|
+
if (y > 0 ? mod < 0 : mod > 0) {
|
481
|
+
mod += y;
|
482
|
+
div -= 1;
|
483
|
+
}
|
484
|
+
if (divp) *divp = LONG2FIX(div);
|
485
|
+
if (modp) *modp = LONG2FIX(mod);
|
486
|
+
}
|
487
|
+
|
488
|
+
/* div() for Ruby
|
489
|
+
* This behaves different from C99 for negative arguments.
|
490
|
+
*/
|
491
|
+
static inline VALUE
|
492
|
+
rb_fix_div_fix(VALUE x, VALUE y)
|
493
|
+
{
|
494
|
+
VALUE div;
|
495
|
+
rb_fix_divmod_fix(x, y, &div, NULL);
|
496
|
+
return div;
|
497
|
+
}
|
498
|
+
|
499
|
+
/* mod() for Ruby
|
500
|
+
* This behaves different from C99 for negative arguments.
|
501
|
+
*/
|
502
|
+
static inline VALUE
|
503
|
+
rb_fix_mod_fix(VALUE x, VALUE y)
|
504
|
+
{
|
505
|
+
VALUE mod;
|
506
|
+
rb_fix_divmod_fix(x, y, NULL, &mod);
|
507
|
+
return mod;
|
508
|
+
}
|
509
|
+
|
510
|
+
#if defined(HAVE_UINT128_T)
|
511
|
+
# define bit_length(x) \
|
512
|
+
(unsigned int) \
|
513
|
+
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
514
|
+
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
|
515
|
+
sizeof(x) <= SIZEOF_LONG_LONG ? SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)) : \
|
516
|
+
SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
|
517
|
+
#elif defined(HAVE_LONG_LONG)
|
518
|
+
# define bit_length(x) \
|
519
|
+
(unsigned int) \
|
520
|
+
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
521
|
+
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
|
522
|
+
SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)))
|
523
|
+
#else
|
524
|
+
# define bit_length(x) \
|
525
|
+
(unsigned int) \
|
526
|
+
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
527
|
+
SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)))
|
528
|
+
#endif
|
529
|
+
|
530
|
+
#ifndef BDIGIT
|
531
|
+
# if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
|
532
|
+
# define BDIGIT unsigned int
|
533
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
534
|
+
# define BDIGIT_DBL unsigned LONG_LONG
|
535
|
+
# define BDIGIT_DBL_SIGNED LONG_LONG
|
536
|
+
# define PRI_BDIGIT_PREFIX ""
|
537
|
+
# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
|
538
|
+
# elif SIZEOF_INT*2 <= SIZEOF_LONG
|
539
|
+
# define BDIGIT unsigned int
|
540
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
541
|
+
# define BDIGIT_DBL unsigned long
|
542
|
+
# define BDIGIT_DBL_SIGNED long
|
543
|
+
# define PRI_BDIGIT_PREFIX ""
|
544
|
+
# define PRI_BDIGIT_DBL_PREFIX "l"
|
545
|
+
# elif SIZEOF_SHORT*2 <= SIZEOF_LONG
|
546
|
+
# define BDIGIT unsigned short
|
547
|
+
# define SIZEOF_BDIGIT SIZEOF_SHORT
|
548
|
+
# define BDIGIT_DBL unsigned long
|
549
|
+
# define BDIGIT_DBL_SIGNED long
|
550
|
+
# define PRI_BDIGIT_PREFIX "h"
|
551
|
+
# define PRI_BDIGIT_DBL_PREFIX "l"
|
552
|
+
# else
|
553
|
+
# define BDIGIT unsigned short
|
554
|
+
# define SIZEOF_BDIGIT (SIZEOF_LONG/2)
|
555
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
|
556
|
+
# define BDIGIT_DBL unsigned long
|
557
|
+
# define BDIGIT_DBL_SIGNED long
|
558
|
+
# define PRI_BDIGIT_PREFIX "h"
|
559
|
+
# define PRI_BDIGIT_DBL_PREFIX "l"
|
560
|
+
# endif
|
561
|
+
#endif
|
562
|
+
#ifndef SIZEOF_ACTUAL_BDIGIT
|
563
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
|
564
|
+
#endif
|
565
|
+
|
566
|
+
#ifdef PRI_BDIGIT_PREFIX
|
567
|
+
# define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
|
568
|
+
# define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
|
569
|
+
# define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
|
570
|
+
# define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
|
571
|
+
# define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
|
572
|
+
# define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
|
573
|
+
#endif
|
574
|
+
|
575
|
+
#ifdef PRI_BDIGIT_DBL_PREFIX
|
576
|
+
# define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
|
577
|
+
# define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
|
578
|
+
# define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
|
579
|
+
# define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
|
580
|
+
# define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
|
581
|
+
# define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
|
582
|
+
#endif
|
583
|
+
|
584
|
+
#define BIGNUM_EMBED_LEN_NUMBITS 3
|
585
|
+
#ifndef BIGNUM_EMBED_LEN_MAX
|
586
|
+
# if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
|
587
|
+
# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
|
588
|
+
# else
|
589
|
+
# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
|
590
|
+
# endif
|
591
|
+
#endif
|
592
|
+
|
593
|
+
struct RBignum {
|
594
|
+
struct RBasic basic;
|
595
|
+
union {
|
596
|
+
struct {
|
597
|
+
size_t len;
|
598
|
+
BDIGIT *digits;
|
599
|
+
} heap;
|
600
|
+
BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
|
601
|
+
} as;
|
602
|
+
};
|
603
|
+
#define BIGNUM_SIGN_BIT ((VALUE)FL_USER1)
|
604
|
+
/* sign: positive:1, negative:0 */
|
605
|
+
#define BIGNUM_SIGN(b) ((RBASIC(b)->flags & BIGNUM_SIGN_BIT) != 0)
|
606
|
+
#define BIGNUM_SET_SIGN(b,sign) \
|
607
|
+
((sign) ? (RBASIC(b)->flags |= BIGNUM_SIGN_BIT) \
|
608
|
+
: (RBASIC(b)->flags &= ~BIGNUM_SIGN_BIT))
|
609
|
+
#define BIGNUM_POSITIVE_P(b) BIGNUM_SIGN(b)
|
610
|
+
#define BIGNUM_NEGATIVE_P(b) (!BIGNUM_SIGN(b))
|
611
|
+
#define BIGNUM_NEGATE(b) (RBASIC(b)->flags ^= BIGNUM_SIGN_BIT)
|
612
|
+
|
613
|
+
#define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
|
614
|
+
#define BIGNUM_EMBED_LEN_MASK ((VALUE)(FL_USER5|FL_USER4|FL_USER3))
|
615
|
+
#define BIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+BIGNUM_EMBED_LEN_NUMBITS)
|
616
|
+
#define BIGNUM_LEN(b) \
|
617
|
+
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
618
|
+
(size_t)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \
|
619
|
+
(BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT)) : \
|
620
|
+
RBIGNUM(b)->as.heap.len)
|
621
|
+
/* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
|
622
|
+
#define BIGNUM_DIGITS(b) \
|
623
|
+
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
624
|
+
RBIGNUM(b)->as.ary : \
|
625
|
+
RBIGNUM(b)->as.heap.digits)
|
626
|
+
#define BIGNUM_LENINT(b) rb_long2int(BIGNUM_LEN(b))
|
627
|
+
|
628
|
+
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
|
629
|
+
|
630
|
+
struct RRational {
|
631
|
+
struct RBasic basic;
|
632
|
+
const VALUE num;
|
633
|
+
const VALUE den;
|
634
|
+
};
|
635
|
+
|
636
|
+
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
|
637
|
+
#define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
|
638
|
+
#define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
|
639
|
+
|
640
|
+
struct RFloat {
|
641
|
+
struct RBasic basic;
|
642
|
+
double float_value;
|
643
|
+
};
|
644
|
+
|
645
|
+
#define RFLOAT(obj) (R_CAST(RFloat)(obj))
|
646
|
+
|
647
|
+
struct RComplex {
|
648
|
+
struct RBasic basic;
|
649
|
+
const VALUE real;
|
650
|
+
const VALUE imag;
|
651
|
+
};
|
652
|
+
|
653
|
+
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
|
654
|
+
|
655
|
+
#ifdef RCOMPLEX_SET_REAL /* shortcut macro for internal only */
|
656
|
+
#undef RCOMPLEX_SET_REAL
|
657
|
+
#undef RCOMPLEX_SET_IMAG
|
658
|
+
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
|
659
|
+
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
|
660
|
+
#endif
|
661
|
+
|
662
|
+
struct RHash {
|
663
|
+
struct RBasic basic;
|
664
|
+
struct st_table *ntbl; /* possibly 0 */
|
665
|
+
int iter_lev;
|
666
|
+
const VALUE ifnone;
|
667
|
+
};
|
668
|
+
|
669
|
+
#define RHASH(obj) (R_CAST(RHash)(obj))
|
670
|
+
|
671
|
+
#ifdef RHASH_ITER_LEV
|
672
|
+
#undef RHASH_ITER_LEV
|
673
|
+
#undef RHASH_IFNONE
|
674
|
+
#undef RHASH_SIZE
|
675
|
+
#define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
|
676
|
+
#define RHASH_IFNONE(h) (RHASH(h)->ifnone)
|
677
|
+
#define RHASH_SIZE(h) (RHASH(h)->ntbl ? RHASH(h)->ntbl->num_entries : (st_index_t)0)
|
678
|
+
#endif
|
679
|
+
|
680
|
+
/* missing/setproctitle.c */
|
681
|
+
#ifndef HAVE_SETPROCTITLE
|
682
|
+
extern void ruby_init_setproctitle(int argc, char *argv[]);
|
683
|
+
#endif
|
684
|
+
|
685
|
+
#define RSTRUCT_EMBED_LEN_MAX RSTRUCT_EMBED_LEN_MAX
|
686
|
+
#define RSTRUCT_EMBED_LEN_MASK RSTRUCT_EMBED_LEN_MASK
|
687
|
+
#define RSTRUCT_EMBED_LEN_SHIFT RSTRUCT_EMBED_LEN_SHIFT
|
688
|
+
enum {
|
689
|
+
RSTRUCT_EMBED_LEN_MAX = 3,
|
690
|
+
RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
|
691
|
+
RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
|
692
|
+
|
693
|
+
RSTRUCT_ENUM_END
|
694
|
+
};
|
695
|
+
|
696
|
+
struct RStruct {
|
697
|
+
struct RBasic basic;
|
698
|
+
union {
|
699
|
+
struct {
|
700
|
+
long len;
|
701
|
+
const VALUE *ptr;
|
702
|
+
} heap;
|
703
|
+
const VALUE ary[RSTRUCT_EMBED_LEN_MAX];
|
704
|
+
} as;
|
705
|
+
};
|
706
|
+
|
707
|
+
#undef RSTRUCT_LEN
|
708
|
+
#undef RSTRUCT_PTR
|
709
|
+
#undef RSTRUCT_SET
|
710
|
+
#undef RSTRUCT_GET
|
711
|
+
#define RSTRUCT_EMBED_LEN(st) \
|
712
|
+
(long)((RBASIC(st)->flags >> RSTRUCT_EMBED_LEN_SHIFT) & \
|
713
|
+
(RSTRUCT_EMBED_LEN_MASK >> RSTRUCT_EMBED_LEN_SHIFT))
|
714
|
+
#define RSTRUCT_LEN(st) rb_struct_len(st)
|
715
|
+
#define RSTRUCT_LENINT(st) rb_long2int(RSTRUCT_LEN(st))
|
716
|
+
#define RSTRUCT_CONST_PTR(st) rb_struct_const_ptr(st)
|
717
|
+
#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(STRUCT, st)))
|
718
|
+
#define RSTRUCT_SET(st, idx, v) RB_OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v))
|
719
|
+
#define RSTRUCT_GET(st, idx) (RSTRUCT_CONST_PTR(st)[idx])
|
720
|
+
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
|
721
|
+
|
722
|
+
static inline long
|
723
|
+
rb_struct_len(VALUE st)
|
724
|
+
{
|
725
|
+
return (RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
|
726
|
+
RSTRUCT_EMBED_LEN(st) : RSTRUCT(st)->as.heap.len;
|
727
|
+
}
|
728
|
+
|
729
|
+
static inline const VALUE *
|
730
|
+
rb_struct_const_ptr(VALUE st)
|
731
|
+
{
|
732
|
+
return FIX_CONST_VALUE_PTR((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
|
733
|
+
RSTRUCT(st)->as.ary : RSTRUCT(st)->as.heap.ptr);
|
734
|
+
}
|
735
|
+
|
736
|
+
/* class.c */
|
737
|
+
|
738
|
+
struct rb_deprecated_classext_struct {
|
739
|
+
char conflict[sizeof(VALUE) * 3];
|
740
|
+
};
|
741
|
+
|
742
|
+
struct rb_subclass_entry;
|
743
|
+
typedef struct rb_subclass_entry rb_subclass_entry_t;
|
744
|
+
|
745
|
+
struct rb_subclass_entry {
|
746
|
+
VALUE klass;
|
747
|
+
rb_subclass_entry_t *next;
|
748
|
+
};
|
749
|
+
|
750
|
+
#if defined(HAVE_LONG_LONG)
|
751
|
+
typedef unsigned LONG_LONG rb_serial_t;
|
752
|
+
#define SERIALT2NUM ULL2NUM
|
753
|
+
#elif defined(HAVE_UINT64_T)
|
754
|
+
typedef uint64_t rb_serial_t;
|
755
|
+
#define SERIALT2NUM SIZET2NUM
|
756
|
+
#else
|
757
|
+
typedef unsigned long rb_serial_t;
|
758
|
+
#define SERIALT2NUM ULONG2NUM
|
759
|
+
#endif
|
760
|
+
|
761
|
+
struct rb_classext_struct {
|
762
|
+
struct st_table *iv_index_tbl;
|
763
|
+
struct st_table *iv_tbl;
|
764
|
+
struct rb_id_table *const_tbl;
|
765
|
+
struct rb_id_table *callable_m_tbl;
|
766
|
+
rb_subclass_entry_t *subclasses;
|
767
|
+
rb_subclass_entry_t **parent_subclasses;
|
768
|
+
/**
|
769
|
+
* In the case that this is an `ICLASS`, `module_subclasses` points to the link
|
770
|
+
* in the module's `subclasses` list that indicates that the klass has been
|
771
|
+
* included. Hopefully that makes sense.
|
772
|
+
*/
|
773
|
+
rb_subclass_entry_t **module_subclasses;
|
774
|
+
rb_serial_t class_serial;
|
775
|
+
const VALUE origin_;
|
776
|
+
VALUE refined_class;
|
777
|
+
rb_alloc_func_t allocator;
|
778
|
+
};
|
779
|
+
|
780
|
+
typedef struct rb_classext_struct rb_classext_t;
|
781
|
+
|
782
|
+
#undef RClass
|
783
|
+
struct RClass {
|
784
|
+
struct RBasic basic;
|
785
|
+
VALUE super;
|
786
|
+
rb_classext_t *ptr;
|
787
|
+
struct rb_id_table *m_tbl;
|
788
|
+
};
|
789
|
+
|
790
|
+
void rb_class_subclass_add(VALUE super, VALUE klass);
|
791
|
+
void rb_class_remove_from_super_subclasses(VALUE);
|
792
|
+
int rb_singleton_class_internal_p(VALUE sklass);
|
793
|
+
|
794
|
+
#define RCLASS_EXT(c) (RCLASS(c)->ptr)
|
795
|
+
#define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
|
796
|
+
#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
|
797
|
+
#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
|
798
|
+
#define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
|
799
|
+
#define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
|
800
|
+
#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
|
801
|
+
#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
|
802
|
+
#define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
|
803
|
+
|
804
|
+
#define RICLASS_IS_ORIGIN FL_USER5
|
805
|
+
|
806
|
+
static inline void
|
807
|
+
RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
|
808
|
+
{
|
809
|
+
RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
|
810
|
+
if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
|
811
|
+
}
|
812
|
+
|
813
|
+
#undef RCLASS_SUPER
|
814
|
+
static inline VALUE
|
815
|
+
RCLASS_SUPER(VALUE klass)
|
816
|
+
{
|
817
|
+
return RCLASS(klass)->super;
|
818
|
+
}
|
819
|
+
|
820
|
+
static inline VALUE
|
821
|
+
RCLASS_SET_SUPER(VALUE klass, VALUE super)
|
822
|
+
{
|
823
|
+
if (super) {
|
824
|
+
rb_class_remove_from_super_subclasses(klass);
|
825
|
+
rb_class_subclass_add(super, klass);
|
826
|
+
}
|
827
|
+
RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
|
828
|
+
return super;
|
829
|
+
}
|
830
|
+
/* IMEMO: Internal memo object */
|
831
|
+
|
832
|
+
#ifndef IMEMO_DEBUG
|
833
|
+
#define IMEMO_DEBUG 0
|
834
|
+
#endif
|
835
|
+
|
836
|
+
struct RIMemo {
|
837
|
+
VALUE flags;
|
838
|
+
VALUE v0;
|
839
|
+
VALUE v1;
|
840
|
+
VALUE v2;
|
841
|
+
VALUE v3;
|
842
|
+
};
|
843
|
+
|
844
|
+
enum imemo_type {
|
845
|
+
imemo_env = 0,
|
846
|
+
imemo_cref = 1, /*!< class reference */
|
847
|
+
imemo_svar = 2, /*!< special variable */
|
848
|
+
imemo_throw_data = 3,
|
849
|
+
imemo_ifunc = 4, /*!< iterator function */
|
850
|
+
imemo_memo = 5,
|
851
|
+
imemo_ment = 6,
|
852
|
+
imemo_iseq = 7,
|
853
|
+
imemo_alloc = 8,
|
854
|
+
imemo_ast = 9,
|
855
|
+
imemo_parser_strterm = 10
|
856
|
+
};
|
857
|
+
#define IMEMO_MASK 0x0f
|
858
|
+
|
859
|
+
static inline enum imemo_type
|
860
|
+
imemo_type(VALUE imemo)
|
861
|
+
{
|
862
|
+
return (RBASIC(imemo)->flags >> FL_USHIFT) & IMEMO_MASK;
|
863
|
+
}
|
864
|
+
|
865
|
+
static inline int
|
866
|
+
imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
|
867
|
+
{
|
868
|
+
if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
|
869
|
+
/* fixed at compile time if imemo_type is given. */
|
870
|
+
const VALUE mask = (IMEMO_MASK << FL_USHIFT) | RUBY_T_MASK;
|
871
|
+
const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
|
872
|
+
/* fixed at runtime. */
|
873
|
+
return expected_type == (RBASIC(imemo)->flags & mask);
|
874
|
+
}
|
875
|
+
else {
|
876
|
+
return 0;
|
877
|
+
}
|
878
|
+
}
|
879
|
+
|
880
|
+
/* FL_USER0 to FL_USER3 is for type */
|
881
|
+
#define IMEMO_FL_USHIFT (FL_USHIFT + 4)
|
882
|
+
#define IMEMO_FL_USER0 FL_USER4
|
883
|
+
#define IMEMO_FL_USER1 FL_USER5
|
884
|
+
#define IMEMO_FL_USER2 FL_USER6
|
885
|
+
#define IMEMO_FL_USER3 FL_USER7
|
886
|
+
#define IMEMO_FL_USER4 FL_USER8
|
887
|
+
|
888
|
+
/* CREF (Class REFerence) is defined in method.h */
|
889
|
+
|
890
|
+
/*! SVAR (Special VARiable) */
|
891
|
+
struct vm_svar {
|
892
|
+
VALUE flags;
|
893
|
+
const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
|
894
|
+
const VALUE lastline;
|
895
|
+
const VALUE backref;
|
896
|
+
const VALUE others;
|
897
|
+
};
|
898
|
+
|
899
|
+
|
900
|
+
#define THROW_DATA_CONSUMED IMEMO_FL_USER0
|
901
|
+
|
902
|
+
/*! THROW_DATA */
|
903
|
+
struct vm_throw_data {
|
904
|
+
VALUE flags;
|
905
|
+
VALUE reserved;
|
906
|
+
const VALUE throw_obj;
|
907
|
+
const struct rb_control_frame_struct *catch_frame;
|
908
|
+
VALUE throw_state;
|
909
|
+
};
|
910
|
+
|
911
|
+
#define THROW_DATA_P(err) RB_TYPE_P((VALUE)(err), T_IMEMO)
|
912
|
+
|
913
|
+
/* IFUNC (Internal FUNCtion) */
|
914
|
+
|
915
|
+
struct vm_ifunc_argc {
|
916
|
+
#if SIZEOF_INT * 2 > SIZEOF_VALUE
|
917
|
+
signed int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
|
918
|
+
signed int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
|
919
|
+
#else
|
920
|
+
int min, max;
|
921
|
+
#endif
|
922
|
+
};
|
923
|
+
|
924
|
+
/*! IFUNC (Internal FUNCtion) */
|
925
|
+
struct vm_ifunc {
|
926
|
+
VALUE flags;
|
927
|
+
VALUE reserved;
|
928
|
+
VALUE (*func)(ANYARGS);
|
929
|
+
const void *data;
|
930
|
+
struct vm_ifunc_argc argc;
|
931
|
+
};
|
932
|
+
|
933
|
+
#define IFUNC_NEW(a, b, c) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
|
934
|
+
struct vm_ifunc *rb_vm_ifunc_new(VALUE (*func)(ANYARGS), const void *data, int min_argc, int max_argc);
|
935
|
+
static inline struct vm_ifunc *
|
936
|
+
rb_vm_ifunc_proc_new(VALUE (*func)(ANYARGS), const void *data)
|
937
|
+
{
|
938
|
+
return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
|
939
|
+
}
|
940
|
+
|
941
|
+
typedef struct rb_imemo_alloc_struct {
|
942
|
+
VALUE flags;
|
943
|
+
VALUE reserved;
|
944
|
+
VALUE *ptr; /* malloc'ed buffer */
|
945
|
+
struct rb_imemo_alloc_struct *next; /* next imemo */
|
946
|
+
size_t cnt; /* buffer size in VALUE */
|
947
|
+
} rb_imemo_alloc_t;
|
948
|
+
|
949
|
+
rb_imemo_alloc_t *rb_imemo_alloc_new(VALUE, VALUE, VALUE, VALUE);
|
950
|
+
|
951
|
+
void rb_strterm_mark(VALUE obj);
|
952
|
+
|
953
|
+
/*! MEMO
|
954
|
+
*
|
955
|
+
* @see imemo_type
|
956
|
+
* */
|
957
|
+
struct MEMO {
|
958
|
+
VALUE flags;
|
959
|
+
VALUE reserved;
|
960
|
+
const VALUE v1;
|
961
|
+
const VALUE v2;
|
962
|
+
union {
|
963
|
+
long cnt;
|
964
|
+
long state;
|
965
|
+
const VALUE value;
|
966
|
+
VALUE (*func)(ANYARGS);
|
967
|
+
} u3;
|
968
|
+
};
|
969
|
+
|
970
|
+
#define MEMO_V1_SET(m, v) RB_OBJ_WRITE((m), &(m)->v1, (v))
|
971
|
+
#define MEMO_V2_SET(m, v) RB_OBJ_WRITE((m), &(m)->v2, (v))
|
972
|
+
|
973
|
+
#define MEMO_CAST(m) ((struct MEMO *)m)
|
974
|
+
|
975
|
+
#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
|
976
|
+
|
977
|
+
#define roomof(x, y) (((x) + (y) - 1) / (y))
|
978
|
+
#define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
|
979
|
+
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
|
980
|
+
#define NEW_MEMO_FOR(type, value) \
|
981
|
+
((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
|
982
|
+
#define NEW_PARTIAL_MEMO_FOR(type, value, member) \
|
983
|
+
((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), \
|
984
|
+
rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
|
985
|
+
MEMO_FOR(type, value))
|
986
|
+
|
987
|
+
#define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
|
988
|
+
|
989
|
+
#ifdef RUBY_INTEGER_UNIFICATION
|
990
|
+
# define rb_cFixnum rb_cInteger
|
991
|
+
# define rb_cBignum rb_cInteger
|
992
|
+
#endif
|
993
|
+
|
994
|
+
enum {
|
995
|
+
cmp_opt_Fixnum,
|
996
|
+
cmp_opt_String,
|
997
|
+
cmp_opt_Float,
|
998
|
+
cmp_optimizable_count
|
999
|
+
};
|
1000
|
+
|
1001
|
+
struct cmp_opt_data {
|
1002
|
+
unsigned int opt_methods;
|
1003
|
+
unsigned int opt_inited;
|
1004
|
+
};
|
1005
|
+
|
1006
|
+
#define NEW_CMP_OPT_MEMO(type, value) \
|
1007
|
+
NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
|
1008
|
+
#define CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
|
1009
|
+
#define CMP_OPTIMIZABLE(data, type) \
|
1010
|
+
(((data).opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
|
1011
|
+
((data).opt_methods & CMP_OPTIMIZABLE_BIT(type)) : \
|
1012
|
+
(((data).opt_inited |= CMP_OPTIMIZABLE_BIT(type)), \
|
1013
|
+
rb_method_basic_definition_p(TOKEN_PASTE(rb_c,type), id_cmp) && \
|
1014
|
+
((data).opt_methods |= CMP_OPTIMIZABLE_BIT(type))))
|
1015
|
+
|
1016
|
+
#define OPTIMIZED_CMP(a, b, data) \
|
1017
|
+
((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Fixnum)) ? \
|
1018
|
+
(((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
|
1019
|
+
(STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) ? \
|
1020
|
+
rb_str_cmp(a, b) : \
|
1021
|
+
(RB_FLOAT_TYPE_P(a) && RB_FLOAT_TYPE_P(b) && CMP_OPTIMIZABLE(data, Float)) ? \
|
1022
|
+
rb_float_cmp(a, b) : \
|
1023
|
+
rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
|
1024
|
+
|
1025
|
+
/* ment is in method.h */
|
1026
|
+
|
1027
|
+
/* global variable */
|
1028
|
+
|
1029
|
+
struct rb_global_entry {
|
1030
|
+
struct rb_global_variable *var;
|
1031
|
+
ID id;
|
1032
|
+
};
|
1033
|
+
|
1034
|
+
struct rb_global_entry *rb_global_entry(ID);
|
1035
|
+
VALUE rb_gvar_get(struct rb_global_entry *);
|
1036
|
+
VALUE rb_gvar_set(struct rb_global_entry *, VALUE);
|
1037
|
+
VALUE rb_gvar_defined(struct rb_global_entry *);
|
1038
|
+
|
1039
|
+
struct vtm; /* defined by timev.h */
|
1040
|
+
|
1041
|
+
/* array.c */
|
1042
|
+
VALUE rb_ary_last(int, const VALUE *, VALUE);
|
1043
|
+
void rb_ary_set_len(VALUE, long);
|
1044
|
+
void rb_ary_delete_same(VALUE, VALUE);
|
1045
|
+
VALUE rb_ary_tmp_new_fill(long capa);
|
1046
|
+
VALUE rb_ary_at(VALUE, VALUE);
|
1047
|
+
VALUE rb_ary_aref1(VALUE ary, VALUE i);
|
1048
|
+
VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
|
1049
|
+
size_t rb_ary_memsize(VALUE);
|
1050
|
+
VALUE rb_to_array_type(VALUE obj);
|
1051
|
+
#ifdef __GNUC__
|
1052
|
+
#define rb_ary_new_from_args(n, ...) \
|
1053
|
+
__extension__ ({ \
|
1054
|
+
const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
|
1055
|
+
if (__builtin_constant_p(n)) { \
|
1056
|
+
STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
|
1057
|
+
} \
|
1058
|
+
rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
|
1059
|
+
})
|
1060
|
+
#endif
|
1061
|
+
|
1062
|
+
/* bignum.c */
|
1063
|
+
extern const char ruby_digitmap[];
|
1064
|
+
double rb_big_fdiv_double(VALUE x, VALUE y);
|
1065
|
+
VALUE rb_big_uminus(VALUE x);
|
1066
|
+
VALUE rb_big_hash(VALUE);
|
1067
|
+
VALUE rb_big_odd_p(VALUE);
|
1068
|
+
VALUE rb_big_even_p(VALUE);
|
1069
|
+
size_t rb_big_size(VALUE);
|
1070
|
+
VALUE rb_integer_float_cmp(VALUE x, VALUE y);
|
1071
|
+
VALUE rb_integer_float_eq(VALUE x, VALUE y);
|
1072
|
+
VALUE rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base);
|
1073
|
+
VALUE rb_big_comp(VALUE x);
|
1074
|
+
VALUE rb_big_aref(VALUE x, VALUE y);
|
1075
|
+
VALUE rb_big_abs(VALUE x);
|
1076
|
+
VALUE rb_big_size_m(VALUE big);
|
1077
|
+
VALUE rb_big_bit_length(VALUE big);
|
1078
|
+
VALUE rb_big_remainder(VALUE x, VALUE y);
|
1079
|
+
VALUE rb_big_gt(VALUE x, VALUE y);
|
1080
|
+
VALUE rb_big_ge(VALUE x, VALUE y);
|
1081
|
+
VALUE rb_big_lt(VALUE x, VALUE y);
|
1082
|
+
VALUE rb_big_le(VALUE x, VALUE y);
|
1083
|
+
VALUE rb_int_powm(int const argc, VALUE * const argv, VALUE const num);
|
1084
|
+
|
1085
|
+
/* class.c */
|
1086
|
+
VALUE rb_class_boot(VALUE);
|
1087
|
+
VALUE rb_class_inherited(VALUE, VALUE);
|
1088
|
+
VALUE rb_make_metaclass(VALUE, VALUE);
|
1089
|
+
VALUE rb_include_class_new(VALUE, VALUE);
|
1090
|
+
void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
|
1091
|
+
void rb_class_detach_subclasses(VALUE);
|
1092
|
+
void rb_class_detach_module_subclasses(VALUE);
|
1093
|
+
void rb_class_remove_from_module_subclasses(VALUE);
|
1094
|
+
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
|
1095
|
+
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
|
1096
|
+
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
|
1097
|
+
VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
|
1098
|
+
VALUE rb_special_singleton_class(VALUE);
|
1099
|
+
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
1100
|
+
VALUE rb_singleton_class_get(VALUE obj);
|
1101
|
+
void Init_class_hierarchy(void);
|
1102
|
+
|
1103
|
+
int rb_class_has_methods(VALUE c);
|
1104
|
+
void rb_undef_methods_from(VALUE klass, VALUE super);
|
1105
|
+
|
1106
|
+
/* compar.c */
|
1107
|
+
VALUE rb_invcmp(VALUE, VALUE);
|
1108
|
+
|
1109
|
+
/* compile.c */
|
1110
|
+
struct rb_block;
|
1111
|
+
int rb_dvar_defined(ID, const struct rb_block *);
|
1112
|
+
int rb_local_defined(ID, const struct rb_block *);
|
1113
|
+
const char * rb_insns_name(int i);
|
1114
|
+
VALUE rb_insns_name_array(void);
|
1115
|
+
|
1116
|
+
/* complex.c */
|
1117
|
+
VALUE rb_complex_plus(VALUE, VALUE);
|
1118
|
+
VALUE rb_complex_mul(VALUE, VALUE);
|
1119
|
+
VALUE rb_complex_abs(VALUE x);
|
1120
|
+
VALUE rb_complex_sqrt(VALUE x);
|
1121
|
+
|
1122
|
+
/* cont.c */
|
1123
|
+
VALUE rb_obj_is_fiber(VALUE);
|
1124
|
+
void rb_fiber_reset_root_local_storage(VALUE);
|
1125
|
+
void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*rollback_func)(ANYARGS));
|
1126
|
+
|
1127
|
+
/* debug.c */
|
1128
|
+
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
1129
|
+
|
1130
|
+
/* dir.c */
|
1131
|
+
VALUE rb_dir_getwd_ospath(void);
|
1132
|
+
|
1133
|
+
/* dmyext.c */
|
1134
|
+
void Init_enc(void);
|
1135
|
+
void Init_ext(void);
|
1136
|
+
|
1137
|
+
/* encoding.c */
|
1138
|
+
ID rb_id_encoding(void);
|
1139
|
+
void rb_gc_mark_encodings(void);
|
1140
|
+
rb_encoding *rb_enc_get_from_index(int index);
|
1141
|
+
rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
|
1142
|
+
int rb_encdb_replicate(const char *alias, const char *orig);
|
1143
|
+
int rb_encdb_alias(const char *alias, const char *orig);
|
1144
|
+
int rb_encdb_dummy(const char *name);
|
1145
|
+
void rb_encdb_declare(const char *name);
|
1146
|
+
void rb_enc_set_base(const char *name, const char *orig);
|
1147
|
+
int rb_enc_set_dummy(int index);
|
1148
|
+
void rb_encdb_set_unicode(int index);
|
1149
|
+
PUREFUNC(int rb_data_is_encoding(VALUE obj));
|
1150
|
+
|
1151
|
+
/* enum.c */
|
1152
|
+
VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
|
1153
|
+
VALUE rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary);
|
1154
|
+
|
1155
|
+
/* error.c */
|
1156
|
+
extern VALUE rb_eEAGAIN;
|
1157
|
+
extern VALUE rb_eEWOULDBLOCK;
|
1158
|
+
extern VALUE rb_eEINPROGRESS;
|
1159
|
+
void rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args);
|
1160
|
+
VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
|
1161
|
+
VALUE rb_check_backtrace(VALUE);
|
1162
|
+
NORETURN(void rb_async_bug_errno(const char *,int));
|
1163
|
+
const char *rb_builtin_type_name(int t);
|
1164
|
+
const char *rb_builtin_class_name(VALUE x);
|
1165
|
+
PRINTF_ARGS(void rb_sys_warn(const char *fmt, ...), 1, 2);
|
1166
|
+
PRINTF_ARGS(void rb_syserr_warn(int err, const char *fmt, ...), 2, 3);
|
1167
|
+
PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
1168
|
+
PRINTF_ARGS(void rb_sys_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
1169
|
+
PRINTF_ARGS(void rb_syserr_enc_warn(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
|
1170
|
+
PRINTF_ARGS(void rb_sys_warning(const char *fmt, ...), 1, 2);
|
1171
|
+
PRINTF_ARGS(void rb_syserr_warning(int err, const char *fmt, ...), 2, 3);
|
1172
|
+
PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
1173
|
+
PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
1174
|
+
PRINTF_ARGS(void rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
|
1175
|
+
|
1176
|
+
#define rb_raise_cstr(etype, mesg) \
|
1177
|
+
rb_exc_raise(rb_exc_new_str(etype, rb_str_new_cstr(mesg)))
|
1178
|
+
#define rb_raise_static(etype, mesg) \
|
1179
|
+
rb_exc_raise(rb_exc_new_str(etype, rb_str_new_static(mesg, rb_strlen_lit(mesg))))
|
1180
|
+
|
1181
|
+
VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method);
|
1182
|
+
#define rb_name_err_raise_str(mesg, recv, name) \
|
1183
|
+
rb_exc_raise(rb_name_err_new(mesg, recv, name))
|
1184
|
+
#define rb_name_err_raise(mesg, recv, name) \
|
1185
|
+
rb_name_err_raise_str(rb_fstring_cstr(mesg), (recv), (name))
|
1186
|
+
VALUE rb_key_err_new(VALUE mesg, VALUE recv, VALUE name);
|
1187
|
+
#define rb_key_err_raise(mesg, recv, name) \
|
1188
|
+
rb_exc_raise(rb_key_err_new(mesg, recv, name))
|
1189
|
+
NORETURN(void ruby_deprecated_internal_feature(const char *));
|
1190
|
+
#define DEPRECATED_INTERNAL_FEATURE(func) \
|
1191
|
+
(ruby_deprecated_internal_feature(func), UNREACHABLE)
|
1192
|
+
VALUE rb_warning_warn(VALUE mod, VALUE str);
|
1193
|
+
VALUE rb_warning_string(const char *fmt, ...);
|
1194
|
+
|
1195
|
+
/* eval.c */
|
1196
|
+
VALUE rb_refinement_module_get_refined_class(VALUE module);
|
1197
|
+
|
1198
|
+
/* eval_error.c */
|
1199
|
+
VALUE rb_get_backtrace(VALUE info);
|
1200
|
+
|
1201
|
+
/* eval_jump.c */
|
1202
|
+
void rb_call_end_proc(VALUE data);
|
1203
|
+
void rb_mark_end_proc(void);
|
1204
|
+
|
1205
|
+
/* file.c */
|
1206
|
+
VALUE rb_home_dir_of(VALUE user, VALUE result);
|
1207
|
+
VALUE rb_default_home_dir(VALUE result);
|
1208
|
+
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
|
1209
|
+
VALUE rb_check_realpath(VALUE basedir, VALUE path);
|
1210
|
+
void rb_file_const(const char*, VALUE);
|
1211
|
+
int rb_file_load_ok(const char *);
|
1212
|
+
VALUE rb_file_expand_path_fast(VALUE, VALUE);
|
1213
|
+
VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
|
1214
|
+
VALUE rb_get_path_check_to_string(VALUE, int);
|
1215
|
+
VALUE rb_get_path_check_convert(VALUE, VALUE, int);
|
1216
|
+
VALUE rb_get_path_check(VALUE, int);
|
1217
|
+
void Init_File(void);
|
1218
|
+
int ruby_is_fd_loadable(int fd);
|
1219
|
+
|
1220
|
+
#ifdef RUBY_FUNCTION_NAME_STRING
|
1221
|
+
# if defined __GNUC__ && __GNUC__ >= 4
|
1222
|
+
# pragma GCC visibility push(default)
|
1223
|
+
# endif
|
1224
|
+
NORETURN(void rb_sys_fail_path_in(const char *func_name, VALUE path));
|
1225
|
+
NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path));
|
1226
|
+
# if defined __GNUC__ && __GNUC__ >= 4
|
1227
|
+
# pragma GCC visibility pop
|
1228
|
+
# endif
|
1229
|
+
# define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
|
1230
|
+
# define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
|
1231
|
+
#else
|
1232
|
+
# define rb_sys_fail_path(path) rb_sys_fail_str(path)
|
1233
|
+
# define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
|
1234
|
+
#endif
|
1235
|
+
|
1236
|
+
/* gc.c */
|
1237
|
+
extern VALUE *ruby_initial_gc_stress_ptr;
|
1238
|
+
extern int ruby_disable_gc;
|
1239
|
+
void Init_heap(void);
|
1240
|
+
void *ruby_mimmalloc(size_t size);
|
1241
|
+
void ruby_mimfree(void *ptr);
|
1242
|
+
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
1243
|
+
#if USE_RGENGC
|
1244
|
+
void rb_gc_writebarrier_remember(VALUE obj);
|
1245
|
+
#else
|
1246
|
+
#define rb_gc_writebarrier_remember(obj) 0
|
1247
|
+
#endif
|
1248
|
+
void ruby_gc_set_params(int safe_level);
|
1249
|
+
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
|
1250
|
+
|
1251
|
+
#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
|
1252
|
+
#define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
|
1253
|
+
#define ruby_sized_xrealloc2(ptr, new_count, element_size, old_count) ruby_xrealloc(ptr, new_count, element_size)
|
1254
|
+
#define ruby_sized_xfree(ptr, size) ruby_xfree(ptr)
|
1255
|
+
#define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)
|
1256
|
+
#else
|
1257
|
+
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));
|
1258
|
+
void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_ALLOC_SIZE((2, 3));
|
1259
|
+
void ruby_sized_xfree(void *x, size_t size);
|
1260
|
+
#define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
|
1261
|
+
#endif
|
1262
|
+
|
1263
|
+
/* optimized version of NEWOBJ() */
|
1264
|
+
#undef NEWOBJF_OF
|
1265
|
+
#undef RB_NEWOBJ_OF
|
1266
|
+
#define RB_NEWOBJ_OF(obj,type,klass,flags) \
|
1267
|
+
type *(obj) = (type*)(((flags) & FL_WB_PROTECTED) ? \
|
1268
|
+
rb_wb_protected_newobj_of(klass, (flags) & ~FL_WB_PROTECTED) : \
|
1269
|
+
rb_wb_unprotected_newobj_of(klass, flags))
|
1270
|
+
#define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags)
|
1271
|
+
|
1272
|
+
/* hash.c */
|
1273
|
+
struct st_table *rb_hash_tbl_raw(VALUE hash);
|
1274
|
+
VALUE rb_hash_new_with_size(st_index_t size);
|
1275
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
1276
|
+
VALUE rb_hash_new_compare_by_id(void);
|
1277
|
+
RUBY_SYMBOL_EXPORT_END
|
1278
|
+
VALUE rb_hash_has_key(VALUE hash, VALUE key);
|
1279
|
+
VALUE rb_hash_default_value(VALUE hash, VALUE key);
|
1280
|
+
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
|
1281
|
+
long rb_objid_hash(st_index_t index);
|
1282
|
+
long rb_dbl_long_hash(double d);
|
1283
|
+
st_table *rb_init_identtable(void);
|
1284
|
+
st_table *rb_init_identtable_with_size(st_index_t size);
|
1285
|
+
VALUE rb_hash_compare_by_id_p(VALUE hash);
|
1286
|
+
VALUE rb_to_hash_type(VALUE obj);
|
1287
|
+
|
1288
|
+
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
|
1289
|
+
VALUE rb_hash_keys(VALUE hash);
|
1290
|
+
VALUE rb_hash_values(VALUE hash);
|
1291
|
+
VALUE rb_hash_rehash(VALUE hash);
|
1292
|
+
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
|
1293
|
+
#define HASH_PROC_DEFAULT FL_USER2
|
1294
|
+
|
1295
|
+
/* inits.c */
|
1296
|
+
void rb_call_inits(void);
|
1297
|
+
|
1298
|
+
/* io.c */
|
1299
|
+
const char *ruby_get_inplace_mode(void);
|
1300
|
+
void ruby_set_inplace_mode(const char *);
|
1301
|
+
ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
|
1302
|
+
void rb_stdio_set_default_encoding(void);
|
1303
|
+
VALUE rb_io_flush_raw(VALUE, int);
|
1304
|
+
size_t rb_io_memsize(const rb_io_t *);
|
1305
|
+
int rb_stderr_tty_p(void);
|
1306
|
+
|
1307
|
+
/* load.c */
|
1308
|
+
VALUE rb_get_load_path(void);
|
1309
|
+
VALUE rb_get_expanded_load_path(void);
|
1310
|
+
int rb_require_internal(VALUE fname, int safe);
|
1311
|
+
NORETURN(void rb_load_fail(VALUE, const char*));
|
1312
|
+
|
1313
|
+
/* loadpath.c */
|
1314
|
+
extern const char ruby_exec_prefix[];
|
1315
|
+
extern const char ruby_initial_load_paths[];
|
1316
|
+
|
1317
|
+
/* localeinit.c */
|
1318
|
+
int Init_enc_set_filesystem_encoding(void);
|
1319
|
+
|
1320
|
+
/* math.c */
|
1321
|
+
VALUE rb_math_atan2(VALUE, VALUE);
|
1322
|
+
VALUE rb_math_cos(VALUE);
|
1323
|
+
VALUE rb_math_cosh(VALUE);
|
1324
|
+
VALUE rb_math_exp(VALUE);
|
1325
|
+
VALUE rb_math_hypot(VALUE, VALUE);
|
1326
|
+
VALUE rb_math_log(int argc, const VALUE *argv);
|
1327
|
+
VALUE rb_math_sin(VALUE);
|
1328
|
+
VALUE rb_math_sinh(VALUE);
|
1329
|
+
VALUE rb_math_sqrt(VALUE);
|
1330
|
+
|
1331
|
+
/* newline.c */
|
1332
|
+
void Init_newline(void);
|
1333
|
+
|
1334
|
+
/* numeric.c */
|
1335
|
+
|
1336
|
+
#define FIXNUM_POSITIVE_P(num) ((SIGNED_VALUE)(num) > (SIGNED_VALUE)INT2FIX(0))
|
1337
|
+
#define FIXNUM_NEGATIVE_P(num) ((SIGNED_VALUE)(num) < 0)
|
1338
|
+
#define FIXNUM_ZERO_P(num) ((num) == INT2FIX(0))
|
1339
|
+
|
1340
|
+
#define INT_NEGATIVE_P(x) (FIXNUM_P(x) ? FIXNUM_NEGATIVE_P(x) : BIGNUM_NEGATIVE_P(x))
|
1341
|
+
|
1342
|
+
#ifndef ROUND_DEFAULT
|
1343
|
+
# define ROUND_DEFAULT RUBY_NUM_ROUND_HALF_UP
|
1344
|
+
#endif
|
1345
|
+
enum ruby_num_rounding_mode {
|
1346
|
+
RUBY_NUM_ROUND_HALF_UP,
|
1347
|
+
RUBY_NUM_ROUND_HALF_EVEN,
|
1348
|
+
RUBY_NUM_ROUND_HALF_DOWN,
|
1349
|
+
RUBY_NUM_ROUND_DEFAULT = ROUND_DEFAULT
|
1350
|
+
};
|
1351
|
+
#define ROUND_TO(mode, even, up, down) \
|
1352
|
+
((mode) == RUBY_NUM_ROUND_HALF_EVEN ? even : \
|
1353
|
+
(mode) == RUBY_NUM_ROUND_HALF_UP ? up : down)
|
1354
|
+
#define ROUND_FUNC(mode, name) \
|
1355
|
+
ROUND_TO(mode, name##_half_even, name##_half_up, name##_half_down)
|
1356
|
+
#define ROUND_CALL(mode, name, args) \
|
1357
|
+
ROUND_TO(mode, name##_half_even args, \
|
1358
|
+
name##_half_up args, name##_half_down args)
|
1359
|
+
|
1360
|
+
int rb_num_to_uint(VALUE val, unsigned int *ret);
|
1361
|
+
VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
|
1362
|
+
int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl);
|
1363
|
+
double ruby_float_mod(double x, double y);
|
1364
|
+
int rb_num_negative_p(VALUE);
|
1365
|
+
VALUE rb_int_succ(VALUE num);
|
1366
|
+
VALUE rb_int_pred(VALUE num);
|
1367
|
+
VALUE rb_int_uminus(VALUE num);
|
1368
|
+
VALUE rb_float_uminus(VALUE num);
|
1369
|
+
VALUE rb_int_plus(VALUE x, VALUE y);
|
1370
|
+
VALUE rb_int_minus(VALUE x, VALUE y);
|
1371
|
+
VALUE rb_int_mul(VALUE x, VALUE y);
|
1372
|
+
VALUE rb_int_idiv(VALUE x, VALUE y);
|
1373
|
+
VALUE rb_int_modulo(VALUE x, VALUE y);
|
1374
|
+
VALUE rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode);
|
1375
|
+
VALUE rb_int2str(VALUE num, int base);
|
1376
|
+
VALUE rb_dbl_hash(double d);
|
1377
|
+
VALUE rb_fix_plus(VALUE x, VALUE y);
|
1378
|
+
VALUE rb_int_gt(VALUE x, VALUE y);
|
1379
|
+
int rb_float_cmp(VALUE x, VALUE y);
|
1380
|
+
VALUE rb_float_gt(VALUE x, VALUE y);
|
1381
|
+
VALUE rb_int_ge(VALUE x, VALUE y);
|
1382
|
+
enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
|
1383
|
+
double rb_int_fdiv_double(VALUE x, VALUE y);
|
1384
|
+
VALUE rb_int_pow(VALUE x, VALUE y);
|
1385
|
+
VALUE rb_float_pow(VALUE x, VALUE y);
|
1386
|
+
VALUE rb_int_cmp(VALUE x, VALUE y);
|
1387
|
+
VALUE rb_int_equal(VALUE x, VALUE y);
|
1388
|
+
VALUE rb_int_divmod(VALUE x, VALUE y);
|
1389
|
+
VALUE rb_int_and(VALUE x, VALUE y);
|
1390
|
+
VALUE rb_int_lshift(VALUE x, VALUE y);
|
1391
|
+
VALUE rb_int_div(VALUE x, VALUE y);
|
1392
|
+
VALUE rb_int_abs(VALUE num);
|
1393
|
+
VALUE rb_int_odd_p(VALUE num);
|
1394
|
+
|
1395
|
+
static inline VALUE
|
1396
|
+
rb_num_compare_with_zero(VALUE num, ID mid)
|
1397
|
+
{
|
1398
|
+
VALUE zero = INT2FIX(0);
|
1399
|
+
VALUE r = rb_check_funcall(num, mid, 1, &zero);
|
1400
|
+
if (r == Qundef) {
|
1401
|
+
rb_cmperr(num, zero);
|
1402
|
+
}
|
1403
|
+
return r;
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
static inline int
|
1407
|
+
rb_num_positive_int_p(VALUE num)
|
1408
|
+
{
|
1409
|
+
const ID mid = '>';
|
1410
|
+
|
1411
|
+
if (FIXNUM_P(num)) {
|
1412
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
1413
|
+
return FIXNUM_POSITIVE_P(num);
|
1414
|
+
}
|
1415
|
+
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
1416
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
1417
|
+
return BIGNUM_POSITIVE_P(num);
|
1418
|
+
}
|
1419
|
+
return RTEST(rb_num_compare_with_zero(num, mid));
|
1420
|
+
}
|
1421
|
+
|
1422
|
+
|
1423
|
+
static inline int
|
1424
|
+
rb_num_negative_int_p(VALUE num)
|
1425
|
+
{
|
1426
|
+
const ID mid = '<';
|
1427
|
+
|
1428
|
+
if (FIXNUM_P(num)) {
|
1429
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
1430
|
+
return FIXNUM_NEGATIVE_P(num);
|
1431
|
+
}
|
1432
|
+
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
1433
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
1434
|
+
return BIGNUM_NEGATIVE_P(num);
|
1435
|
+
}
|
1436
|
+
return RTEST(rb_num_compare_with_zero(num, mid));
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
|
1440
|
+
VALUE rb_float_abs(VALUE flt);
|
1441
|
+
VALUE rb_float_equal(VALUE x, VALUE y);
|
1442
|
+
VALUE rb_float_eql(VALUE x, VALUE y);
|
1443
|
+
|
1444
|
+
#if USE_FLONUM
|
1445
|
+
#define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
|
1446
|
+
#define RUBY_BIT_ROTR(v, n) (((v) >> (n)) | ((v) << ((sizeof(v) * 8) - n)))
|
1447
|
+
#endif
|
1448
|
+
|
1449
|
+
static inline double
|
1450
|
+
rb_float_flonum_value(VALUE v)
|
1451
|
+
{
|
1452
|
+
#if USE_FLONUM
|
1453
|
+
if (v != (VALUE)0x8000000000000002) { /* LIKELY */
|
1454
|
+
union {
|
1455
|
+
double d;
|
1456
|
+
VALUE v;
|
1457
|
+
} t;
|
1458
|
+
|
1459
|
+
VALUE b63 = (v >> 63);
|
1460
|
+
/* e: xx1... -> 011... */
|
1461
|
+
/* xx0... -> 100... */
|
1462
|
+
/* ^b63 */
|
1463
|
+
t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~(VALUE)0x03), 3);
|
1464
|
+
return t.d;
|
1465
|
+
}
|
1466
|
+
#endif
|
1467
|
+
return 0.0;
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
static inline double
|
1471
|
+
rb_float_noflonum_value(VALUE v)
|
1472
|
+
{
|
1473
|
+
return ((struct RFloat *)v)->float_value;
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
static inline double
|
1477
|
+
rb_float_value_inline(VALUE v)
|
1478
|
+
{
|
1479
|
+
if (FLONUM_P(v)) {
|
1480
|
+
return rb_float_flonum_value(v);
|
1481
|
+
}
|
1482
|
+
return rb_float_noflonum_value(v);
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
static inline VALUE
|
1486
|
+
rb_float_new_inline(double d)
|
1487
|
+
{
|
1488
|
+
#if USE_FLONUM
|
1489
|
+
union {
|
1490
|
+
double d;
|
1491
|
+
VALUE v;
|
1492
|
+
} t;
|
1493
|
+
int bits;
|
1494
|
+
|
1495
|
+
t.d = d;
|
1496
|
+
bits = (int)((VALUE)(t.v >> 60) & 0x7);
|
1497
|
+
/* bits contains 3 bits of b62..b60. */
|
1498
|
+
/* bits - 3 = */
|
1499
|
+
/* b011 -> b000 */
|
1500
|
+
/* b100 -> b001 */
|
1501
|
+
|
1502
|
+
if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
|
1503
|
+
!((bits-3) & ~0x01)) {
|
1504
|
+
return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
|
1505
|
+
}
|
1506
|
+
else if (t.v == (VALUE)0) {
|
1507
|
+
/* +0.0 */
|
1508
|
+
return 0x8000000000000002;
|
1509
|
+
}
|
1510
|
+
/* out of range */
|
1511
|
+
#endif
|
1512
|
+
return rb_float_new_in_heap(d);
|
1513
|
+
}
|
1514
|
+
|
1515
|
+
#define rb_float_value(v) rb_float_value_inline(v)
|
1516
|
+
#define rb_float_new(d) rb_float_new_inline(d)
|
1517
|
+
|
1518
|
+
/* object.c */
|
1519
|
+
void rb_obj_copy_ivar(VALUE dest, VALUE obj);
|
1520
|
+
CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
|
1521
|
+
CONSTFUNC(VALUE rb_obj_not(VALUE obj));
|
1522
|
+
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
|
1523
|
+
NORETURN(void rb_undefined_alloc(VALUE klass));
|
1524
|
+
double rb_num_to_dbl(VALUE val);
|
1525
|
+
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
|
1526
|
+
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
|
1527
|
+
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
|
1528
|
+
VALUE rb_convert_type_with_id(VALUE,int,const char*,ID);
|
1529
|
+
VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
|
1530
|
+
|
1531
|
+
struct RBasicRaw {
|
1532
|
+
VALUE flags;
|
1533
|
+
VALUE klass;
|
1534
|
+
};
|
1535
|
+
|
1536
|
+
#define RBASIC_CLEAR_CLASS(obj) memset(&(((struct RBasicRaw *)((VALUE)(obj)))->klass), 0, sizeof(VALUE))
|
1537
|
+
#define RBASIC_SET_CLASS_RAW(obj, cls) memcpy(&((struct RBasicRaw *)((VALUE)(obj)))->klass, &(cls), sizeof(VALUE))
|
1538
|
+
#define RBASIC_SET_CLASS(obj, cls) do { \
|
1539
|
+
VALUE _obj_ = (obj); \
|
1540
|
+
RB_OBJ_WRITE(_obj_, &((struct RBasicRaw *)(_obj_))->klass, cls); \
|
1541
|
+
} while (0)
|
1542
|
+
|
1543
|
+
/* parse.y */
|
1544
|
+
#ifndef USE_SYMBOL_GC
|
1545
|
+
#define USE_SYMBOL_GC 1
|
1546
|
+
#endif
|
1547
|
+
VALUE rb_parser_get_yydebug(VALUE);
|
1548
|
+
VALUE rb_parser_set_yydebug(VALUE, VALUE);
|
1549
|
+
VALUE rb_parser_set_context(VALUE, const struct rb_block *, int);
|
1550
|
+
void *rb_parser_load_file(VALUE parser, VALUE name);
|
1551
|
+
int rb_is_const_name(VALUE name);
|
1552
|
+
int rb_is_class_name(VALUE name);
|
1553
|
+
int rb_is_global_name(VALUE name);
|
1554
|
+
int rb_is_instance_name(VALUE name);
|
1555
|
+
int rb_is_attrset_name(VALUE name);
|
1556
|
+
int rb_is_local_name(VALUE name);
|
1557
|
+
int rb_is_method_name(VALUE name);
|
1558
|
+
int rb_is_junk_name(VALUE name);
|
1559
|
+
PUREFUNC(int rb_is_const_sym(VALUE sym));
|
1560
|
+
PUREFUNC(int rb_is_class_sym(VALUE sym));
|
1561
|
+
PUREFUNC(int rb_is_global_sym(VALUE sym));
|
1562
|
+
PUREFUNC(int rb_is_instance_sym(VALUE sym));
|
1563
|
+
PUREFUNC(int rb_is_attrset_sym(VALUE sym));
|
1564
|
+
PUREFUNC(int rb_is_local_sym(VALUE sym));
|
1565
|
+
PUREFUNC(int rb_is_method_sym(VALUE sym));
|
1566
|
+
PUREFUNC(int rb_is_junk_sym(VALUE sym));
|
1567
|
+
ID rb_make_internal_id(void);
|
1568
|
+
void rb_gc_free_dsymbol(VALUE);
|
1569
|
+
ID rb_id_attrget(ID id);
|
1570
|
+
|
1571
|
+
/* proc.c */
|
1572
|
+
VALUE rb_proc_location(VALUE self);
|
1573
|
+
st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
|
1574
|
+
int rb_block_arity(void);
|
1575
|
+
int rb_block_min_max_arity(int *max);
|
1576
|
+
VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
|
1577
|
+
VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
|
1578
|
+
VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_info);
|
1579
|
+
|
1580
|
+
/* process.c */
|
1581
|
+
#define RB_MAX_GROUPS (65536)
|
1582
|
+
|
1583
|
+
struct rb_execarg {
|
1584
|
+
union {
|
1585
|
+
struct {
|
1586
|
+
VALUE shell_script;
|
1587
|
+
} sh;
|
1588
|
+
struct {
|
1589
|
+
VALUE command_name;
|
1590
|
+
VALUE command_abspath; /* full path string or nil */
|
1591
|
+
VALUE argv_str;
|
1592
|
+
VALUE argv_buf;
|
1593
|
+
} cmd;
|
1594
|
+
} invoke;
|
1595
|
+
VALUE redirect_fds;
|
1596
|
+
VALUE envp_str;
|
1597
|
+
VALUE envp_buf;
|
1598
|
+
VALUE dup2_tmpbuf;
|
1599
|
+
unsigned use_shell : 1;
|
1600
|
+
unsigned pgroup_given : 1;
|
1601
|
+
unsigned umask_given : 1;
|
1602
|
+
unsigned unsetenv_others_given : 1;
|
1603
|
+
unsigned unsetenv_others_do : 1;
|
1604
|
+
unsigned close_others_given : 1;
|
1605
|
+
unsigned close_others_do : 1;
|
1606
|
+
unsigned chdir_given : 1;
|
1607
|
+
unsigned new_pgroup_given : 1;
|
1608
|
+
unsigned new_pgroup_flag : 1;
|
1609
|
+
unsigned uid_given : 1;
|
1610
|
+
unsigned gid_given : 1;
|
1611
|
+
rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
|
1612
|
+
VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
|
1613
|
+
mode_t umask_mask;
|
1614
|
+
rb_uid_t uid;
|
1615
|
+
rb_gid_t gid;
|
1616
|
+
int close_others_maxhint;
|
1617
|
+
VALUE fd_dup2;
|
1618
|
+
VALUE fd_close;
|
1619
|
+
VALUE fd_open;
|
1620
|
+
VALUE fd_dup2_child;
|
1621
|
+
VALUE env_modification; /* Qfalse or [[k1,v1], ...] */
|
1622
|
+
VALUE path_env;
|
1623
|
+
VALUE chdir_dir;
|
1624
|
+
};
|
1625
|
+
|
1626
|
+
/* argv_str contains extra two elements.
|
1627
|
+
* The beginning one is for /bin/sh used by exec_with_sh.
|
1628
|
+
* The last one for terminating NULL used by execve.
|
1629
|
+
* See rb_exec_fillarg() in process.c. */
|
1630
|
+
#define ARGVSTR2ARGC(argv_str) (RSTRING_LEN(argv_str) / sizeof(char *) - 2)
|
1631
|
+
#define ARGVSTR2ARGV(argv_str) ((char **)RSTRING_PTR(argv_str) + 1)
|
1632
|
+
|
1633
|
+
rb_pid_t rb_fork_ruby(int *status);
|
1634
|
+
void rb_last_status_clear(void);
|
1635
|
+
|
1636
|
+
/* rational.c */
|
1637
|
+
VALUE rb_rational_uminus(VALUE self);
|
1638
|
+
VALUE rb_rational_plus(VALUE self, VALUE other);
|
1639
|
+
VALUE rb_lcm(VALUE x, VALUE y);
|
1640
|
+
VALUE rb_rational_reciprocal(VALUE x);
|
1641
|
+
VALUE rb_cstr_to_rat(const char *, int);
|
1642
|
+
VALUE rb_rational_abs(VALUE self);
|
1643
|
+
VALUE rb_rational_cmp(VALUE self, VALUE other);
|
1644
|
+
VALUE rb_numeric_quo(VALUE x, VALUE y);
|
1645
|
+
|
1646
|
+
/* re.c */
|
1647
|
+
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
|
1648
|
+
VALUE rb_reg_check_preprocess(VALUE);
|
1649
|
+
long rb_reg_search0(VALUE, VALUE, long, int, int);
|
1650
|
+
VALUE rb_reg_match_p(VALUE re, VALUE str, long pos);
|
1651
|
+
bool rb_reg_start_with_p(VALUE re, VALUE str);
|
1652
|
+
void rb_backref_set_string(VALUE string, long pos, long len);
|
1653
|
+
int rb_match_count(VALUE match);
|
1654
|
+
int rb_match_nth_defined(int nth, VALUE match);
|
1655
|
+
|
1656
|
+
/* signal.c */
|
1657
|
+
extern int ruby_enable_coredump;
|
1658
|
+
int rb_get_next_signal(void);
|
1659
|
+
int rb_sigaltstack_size(void);
|
1660
|
+
|
1661
|
+
/* st.c */
|
1662
|
+
extern void rb_hash_bulk_insert(long, const VALUE *, VALUE);
|
1663
|
+
|
1664
|
+
/* strftime.c */
|
1665
|
+
#ifdef RUBY_ENCODING_H
|
1666
|
+
VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc,
|
1667
|
+
const struct vtm *vtm, struct timespec *ts, int gmt);
|
1668
|
+
VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc,
|
1669
|
+
const struct vtm *vtm, VALUE timev, int gmt);
|
1670
|
+
#endif
|
1671
|
+
|
1672
|
+
/* string.c */
|
1673
|
+
VALUE rb_fstring(VALUE);
|
1674
|
+
VALUE rb_fstring_new(const char *ptr, long len);
|
1675
|
+
#define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
|
1676
|
+
#define rb_fstring_literal(str) rb_fstring_lit(str)
|
1677
|
+
VALUE rb_fstring_cstr(const char *str);
|
1678
|
+
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
|
1679
|
+
# define rb_fstring_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
|
1680
|
+
(__builtin_constant_p(str)) ? \
|
1681
|
+
rb_fstring_new((str), (long)strlen(str)) : \
|
1682
|
+
rb_fstring_cstr(str) \
|
1683
|
+
)
|
1684
|
+
#endif
|
1685
|
+
#ifdef RUBY_ENCODING_H
|
1686
|
+
VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
|
1687
|
+
#define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
|
1688
|
+
#define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
|
1689
|
+
VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
|
1690
|
+
# ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
|
1691
|
+
# define rb_fstring_enc_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
|
1692
|
+
(__builtin_constant_p(str)) ? \
|
1693
|
+
rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
|
1694
|
+
rb_fstring_enc_cstr(str, enc) \
|
1695
|
+
)
|
1696
|
+
# endif
|
1697
|
+
#endif
|
1698
|
+
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
|
1699
|
+
int rb_str_symname_p(VALUE);
|
1700
|
+
VALUE rb_str_quote_unprintable(VALUE);
|
1701
|
+
VALUE rb_id_quote_unprintable(ID);
|
1702
|
+
#define QUOTE(str) rb_str_quote_unprintable(str)
|
1703
|
+
#define QUOTE_ID(id) rb_id_quote_unprintable(id)
|
1704
|
+
char *rb_str_fill_terminator(VALUE str, const int termlen);
|
1705
|
+
void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
|
1706
|
+
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
|
1707
|
+
VALUE rb_str_tmp_frozen_acquire(VALUE str);
|
1708
|
+
void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
|
1709
|
+
VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
|
1710
|
+
#ifdef RUBY_ENCODING_H
|
1711
|
+
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
|
1712
|
+
VALUE rb_str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
|
1713
|
+
rb_encoding *from, int ecflags, VALUE ecopts);
|
1714
|
+
VALUE rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl);
|
1715
|
+
VALUE rb_str_initialize(VALUE str, const char *ptr, long len, rb_encoding *enc);
|
1716
|
+
#endif
|
1717
|
+
#define STR_NOEMBED FL_USER1
|
1718
|
+
#define STR_SHARED FL_USER2 /* = ELTS_SHARED */
|
1719
|
+
#define STR_EMBED_P(str) (!FL_TEST_RAW((str), STR_NOEMBED))
|
1720
|
+
#define STR_SHARED_P(s) FL_ALL_RAW((s), STR_NOEMBED|ELTS_SHARED)
|
1721
|
+
#define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
|
1722
|
+
#define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
|
1723
|
+
size_t rb_str_memsize(VALUE);
|
1724
|
+
VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, VALUE passed_proc);
|
1725
|
+
VALUE rb_sym_to_proc(VALUE sym);
|
1726
|
+
char *rb_str_to_cstr(VALUE str);
|
1727
|
+
VALUE rb_str_eql(VALUE str1, VALUE str2);
|
1728
|
+
|
1729
|
+
/* symbol.c */
|
1730
|
+
#ifdef RUBY_ENCODING_H
|
1731
|
+
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
|
1732
|
+
VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc);
|
1733
|
+
#ifdef __GNUC__
|
1734
|
+
#define rb_sym_intern_cstr(ptr, enc) __extension__ ( \
|
1735
|
+
{ \
|
1736
|
+
(__builtin_constant_p(ptr)) ? \
|
1737
|
+
rb_sym_intern((ptr), (long)strlen(ptr), (enc)) : \
|
1738
|
+
rb_sym_intern_cstr((ptr), (enc)); \
|
1739
|
+
})
|
1740
|
+
#endif
|
1741
|
+
#endif
|
1742
|
+
VALUE rb_sym_intern_ascii(const char *ptr, long len);
|
1743
|
+
VALUE rb_sym_intern_ascii_cstr(const char *ptr);
|
1744
|
+
#ifdef __GNUC__
|
1745
|
+
#define rb_sym_intern_ascii_cstr(ptr) __extension__ ( \
|
1746
|
+
{ \
|
1747
|
+
(__builtin_constant_p(ptr)) ? \
|
1748
|
+
rb_sym_intern_ascii((ptr), (long)strlen(ptr)) : \
|
1749
|
+
rb_sym_intern_ascii_cstr(ptr); \
|
1750
|
+
})
|
1751
|
+
#endif
|
1752
|
+
VALUE rb_to_symbol_type(VALUE obj);
|
1753
|
+
|
1754
|
+
/* struct.c */
|
1755
|
+
VALUE rb_struct_init_copy(VALUE copy, VALUE s);
|
1756
|
+
VALUE rb_struct_lookup(VALUE s, VALUE idx);
|
1757
|
+
VALUE rb_struct_s_keyword_init(VALUE klass);
|
1758
|
+
|
1759
|
+
/* time.c */
|
1760
|
+
struct timeval rb_time_timeval(VALUE);
|
1761
|
+
|
1762
|
+
/* thread.c */
|
1763
|
+
#define COVERAGE_INDEX_LINES 0
|
1764
|
+
#define COVERAGE_INDEX_BRANCHES 1
|
1765
|
+
#define COVERAGE_TARGET_LINES 1
|
1766
|
+
#define COVERAGE_TARGET_BRANCHES 2
|
1767
|
+
#define COVERAGE_TARGET_METHODS 4
|
1768
|
+
|
1769
|
+
VALUE rb_obj_is_mutex(VALUE obj);
|
1770
|
+
VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
|
1771
|
+
void rb_thread_execute_interrupts(VALUE th);
|
1772
|
+
void rb_clear_trace_func(void);
|
1773
|
+
VALUE rb_get_coverages(void);
|
1774
|
+
VALUE rb_default_coverage(int);
|
1775
|
+
VALUE rb_thread_shield_new(void);
|
1776
|
+
VALUE rb_thread_shield_wait(VALUE self);
|
1777
|
+
VALUE rb_thread_shield_release(VALUE self);
|
1778
|
+
VALUE rb_thread_shield_destroy(VALUE self);
|
1779
|
+
int rb_thread_to_be_killed(VALUE thread);
|
1780
|
+
void rb_mutex_allow_trap(VALUE self, int val);
|
1781
|
+
VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
|
1782
|
+
VALUE rb_mutex_owned_p(VALUE self);
|
1783
|
+
|
1784
|
+
/* thread_pthread.c, thread_win32.c */
|
1785
|
+
int rb_divert_reserved_fd(int fd);
|
1786
|
+
|
1787
|
+
/* transcode.c */
|
1788
|
+
extern VALUE rb_cEncodingConverter;
|
1789
|
+
size_t rb_econv_memsize(rb_econv_t *);
|
1790
|
+
|
1791
|
+
/* us_ascii.c */
|
1792
|
+
extern rb_encoding OnigEncodingUS_ASCII;
|
1793
|
+
|
1794
|
+
/* util.c */
|
1795
|
+
char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
|
1796
|
+
char *ruby_hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve);
|
1797
|
+
|
1798
|
+
/* utf_8.c */
|
1799
|
+
extern rb_encoding OnigEncodingUTF_8;
|
1800
|
+
|
1801
|
+
/* variable.c */
|
1802
|
+
void rb_gc_mark_global_tbl(void);
|
1803
|
+
size_t rb_generic_ivar_memsize(VALUE);
|
1804
|
+
VALUE rb_search_class_path(VALUE);
|
1805
|
+
VALUE rb_attr_delete(VALUE, ID);
|
1806
|
+
VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
|
1807
|
+
void rb_autoload_str(VALUE mod, ID id, VALUE file);
|
1808
|
+
void rb_deprecate_constant(VALUE mod, const char *name);
|
1809
|
+
|
1810
|
+
/* version.c */
|
1811
|
+
extern const char ruby_engine[];
|
1812
|
+
|
1813
|
+
/* vm_insnhelper.h */
|
1814
|
+
rb_serial_t rb_next_class_serial(void);
|
1815
|
+
|
1816
|
+
/* vm.c */
|
1817
|
+
VALUE rb_obj_is_thread(VALUE obj);
|
1818
|
+
void rb_vm_mark(void *ptr);
|
1819
|
+
void Init_BareVM(void);
|
1820
|
+
void Init_vm_objects(void);
|
1821
|
+
PUREFUNC(VALUE rb_vm_top_self(void));
|
1822
|
+
void rb_thread_recycle_stack_release(VALUE *);
|
1823
|
+
void rb_vm_change_state(void);
|
1824
|
+
void rb_vm_inc_const_missing_count(void);
|
1825
|
+
const void **rb_vm_get_insns_address_table(void);
|
1826
|
+
VALUE rb_source_location(int *pline);
|
1827
|
+
const char *rb_source_location_cstr(int *pline);
|
1828
|
+
void rb_vm_pop_cfunc_frame(void);
|
1829
|
+
int rb_vm_add_root_module(ID id, VALUE module);
|
1830
|
+
void rb_vm_check_redefinition_by_prepend(VALUE klass);
|
1831
|
+
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
|
1832
|
+
VALUE ruby_vm_special_exception_copy(VALUE);
|
1833
|
+
PUREFUNC(st_table *rb_vm_fstring_table(void));
|
1834
|
+
|
1835
|
+
|
1836
|
+
/* vm_dump.c */
|
1837
|
+
void rb_print_backtrace(void);
|
1838
|
+
|
1839
|
+
/* vm_eval.c */
|
1840
|
+
void Init_vm_eval(void);
|
1841
|
+
VALUE rb_current_realfilepath(void);
|
1842
|
+
VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
|
1843
|
+
typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
|
1844
|
+
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
|
1845
|
+
rb_check_funcall_hook *hook, VALUE arg);
|
1846
|
+
const char *rb_type_str(enum ruby_value_type type);
|
1847
|
+
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
|
1848
|
+
VALUE rb_yield_1(VALUE val);
|
1849
|
+
VALUE rb_yield_force_blockarg(VALUE values);
|
1850
|
+
VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
|
1851
|
+
rb_block_call_func_t bl_proc, int min_argc, int max_argc,
|
1852
|
+
VALUE data2);
|
1853
|
+
|
1854
|
+
/* vm_insnhelper.c */
|
1855
|
+
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
|
1856
|
+
VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
|
1857
|
+
|
1858
|
+
/* vm_method.c */
|
1859
|
+
void Init_eval_method(void);
|
1860
|
+
int rb_method_defined_by(VALUE obj, ID mid, VALUE (*cfunc)(ANYARGS));
|
1861
|
+
|
1862
|
+
/* miniprelude.c, prelude.c */
|
1863
|
+
void Init_prelude(void);
|
1864
|
+
|
1865
|
+
/* vm_backtrace.c */
|
1866
|
+
void Init_vm_backtrace(void);
|
1867
|
+
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
|
1868
|
+
VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval);
|
1869
|
+
|
1870
|
+
VALUE rb_make_backtrace(void);
|
1871
|
+
void rb_backtrace_print_as_bugreport(void);
|
1872
|
+
int rb_backtrace_p(VALUE obj);
|
1873
|
+
VALUE rb_backtrace_to_str_ary(VALUE obj);
|
1874
|
+
VALUE rb_backtrace_to_location_ary(VALUE obj);
|
1875
|
+
void rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output);
|
1876
|
+
|
1877
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
1878
|
+
const char *rb_objspace_data_type_name(VALUE obj);
|
1879
|
+
|
1880
|
+
/* Temporary. This API will be removed (renamed). */
|
1881
|
+
VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
|
1882
|
+
|
1883
|
+
/* bignum.c (export) */
|
1884
|
+
VALUE rb_big_mul_normal(VALUE x, VALUE y);
|
1885
|
+
VALUE rb_big_mul_balance(VALUE x, VALUE y);
|
1886
|
+
VALUE rb_big_mul_karatsuba(VALUE x, VALUE y);
|
1887
|
+
VALUE rb_big_mul_toom3(VALUE x, VALUE y);
|
1888
|
+
VALUE rb_big_sq_fast(VALUE x);
|
1889
|
+
VALUE rb_big_divrem_normal(VALUE x, VALUE y);
|
1890
|
+
VALUE rb_big2str_poweroftwo(VALUE x, int base);
|
1891
|
+
VALUE rb_big2str_generic(VALUE x, int base);
|
1892
|
+
VALUE rb_str2big_poweroftwo(VALUE arg, int base, int badcheck);
|
1893
|
+
VALUE rb_str2big_normal(VALUE arg, int base, int badcheck);
|
1894
|
+
VALUE rb_str2big_karatsuba(VALUE arg, int base, int badcheck);
|
1895
|
+
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
|
1896
|
+
VALUE rb_big_mul_gmp(VALUE x, VALUE y);
|
1897
|
+
VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
|
1898
|
+
VALUE rb_big2str_gmp(VALUE x, int base);
|
1899
|
+
VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
|
1900
|
+
#endif
|
1901
|
+
enum rb_int_parse_flags {
|
1902
|
+
RB_INT_PARSE_SIGN = 0x01,
|
1903
|
+
RB_INT_PARSE_UNDERSCORE = 0x02,
|
1904
|
+
RB_INT_PARSE_PREFIX = 0x04,
|
1905
|
+
RB_INT_PARSE_ALL = 0x07,
|
1906
|
+
RB_INT_PARSE_DEFAULT = 0x07
|
1907
|
+
};
|
1908
|
+
VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
|
1909
|
+
|
1910
|
+
/* error.c (export) */
|
1911
|
+
int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
|
1912
|
+
NORETURN(void rb_unexpected_type(VALUE,int));
|
1913
|
+
#undef Check_Type
|
1914
|
+
#define Check_Type(v, t) \
|
1915
|
+
(!RB_TYPE_P((VALUE)(v), (t)) || \
|
1916
|
+
((t) == RUBY_T_DATA && RTYPEDDATA_P(v)) ? \
|
1917
|
+
rb_unexpected_type((VALUE)(v), (t)) : (void)0)
|
1918
|
+
|
1919
|
+
/* file.c (export) */
|
1920
|
+
#ifdef HAVE_READLINK
|
1921
|
+
VALUE rb_readlink(VALUE path, rb_encoding *enc);
|
1922
|
+
#endif
|
1923
|
+
#ifdef __APPLE__
|
1924
|
+
VALUE rb_str_normalize_ospath(const char *ptr, long len);
|
1925
|
+
#endif
|
1926
|
+
|
1927
|
+
/* hash.c (export) */
|
1928
|
+
VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
|
1929
|
+
VALUE rb_ident_hash_new(void);
|
1930
|
+
|
1931
|
+
/* io.c (export) */
|
1932
|
+
void rb_maygvl_fd_fix_cloexec(int fd);
|
1933
|
+
int rb_gc_for_fd(int err);
|
1934
|
+
void rb_write_error_str(VALUE mesg);
|
1935
|
+
|
1936
|
+
/* numeric.c (export) */
|
1937
|
+
VALUE rb_int_positive_pow(long x, unsigned long y);
|
1938
|
+
|
1939
|
+
/* process.c (export) */
|
1940
|
+
int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
|
1941
|
+
rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
|
1942
|
+
VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell);
|
1943
|
+
struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
|
1944
|
+
VALUE rb_execarg_init(int argc, const VALUE *argv, int accept_shell, VALUE execarg_obj);
|
1945
|
+
int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
|
1946
|
+
void rb_execarg_parent_start(VALUE execarg_obj);
|
1947
|
+
void rb_execarg_parent_end(VALUE execarg_obj);
|
1948
|
+
int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
|
1949
|
+
VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
|
1950
|
+
void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
|
1951
|
+
|
1952
|
+
/* rational.c (export) */
|
1953
|
+
VALUE rb_gcd(VALUE x, VALUE y);
|
1954
|
+
VALUE rb_gcd_normal(VALUE self, VALUE other);
|
1955
|
+
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
|
1956
|
+
VALUE rb_gcd_gmp(VALUE x, VALUE y);
|
1957
|
+
#endif
|
1958
|
+
|
1959
|
+
/* string.c (export) */
|
1960
|
+
#ifdef RUBY_ENCODING_H
|
1961
|
+
/* internal use */
|
1962
|
+
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
|
1963
|
+
#endif
|
1964
|
+
|
1965
|
+
/* thread.c (export) */
|
1966
|
+
int ruby_thread_has_gvl_p(void); /* for ext/fiddle/closure.c */
|
1967
|
+
|
1968
|
+
/* util.c (export) */
|
1969
|
+
extern const signed char ruby_digit36_to_number_table[];
|
1970
|
+
extern const char ruby_hexdigits[];
|
1971
|
+
extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
|
1972
|
+
|
1973
|
+
/* variable.c (export) */
|
1974
|
+
void rb_mark_generic_ivar(VALUE);
|
1975
|
+
VALUE rb_const_missing(VALUE klass, VALUE name);
|
1976
|
+
int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
|
1977
|
+
st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
|
1978
|
+
|
1979
|
+
/* gc.c (export) */
|
1980
|
+
VALUE rb_wb_protected_newobj_of(VALUE, VALUE);
|
1981
|
+
VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE);
|
1982
|
+
|
1983
|
+
size_t rb_obj_memsize_of(VALUE);
|
1984
|
+
void rb_gc_verify_internal_consistency(void);
|
1985
|
+
|
1986
|
+
#define RB_OBJ_GC_FLAGS_MAX 5
|
1987
|
+
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
1988
|
+
void rb_gc_mark_values(long n, const VALUE *values);
|
1989
|
+
|
1990
|
+
#if IMEMO_DEBUG
|
1991
|
+
VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
|
1992
|
+
#define rb_imemo_new(type, v1, v2, v3, v0) rb_imemo_new_debug(type, v1, v2, v3, v0, __FILE__, __LINE__)
|
1993
|
+
#else
|
1994
|
+
VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
|
1995
|
+
#endif
|
1996
|
+
|
1997
|
+
RUBY_SYMBOL_EXPORT_END
|
1998
|
+
|
1999
|
+
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
|
2000
|
+
RUBY_DTRACE_HOOK(name##_CREATE, arg)
|
2001
|
+
#define RUBY_DTRACE_HOOK(name, arg) \
|
2002
|
+
do { \
|
2003
|
+
if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
|
2004
|
+
int dtrace_line; \
|
2005
|
+
const char *dtrace_file = rb_source_location_cstr(&dtrace_line); \
|
2006
|
+
if (!dtrace_file) dtrace_file = ""; \
|
2007
|
+
RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
|
2008
|
+
} \
|
2009
|
+
} while (0)
|
2010
|
+
|
2011
|
+
#define RB_OBJ_BUILTIN_TYPE(obj) rb_obj_builtin_type(obj)
|
2012
|
+
#define OBJ_BUILTIN_TYPE(obj) RB_OBJ_BUILTIN_TYPE(obj)
|
2013
|
+
#ifdef __GNUC__
|
2014
|
+
#define rb_obj_builtin_type(obj) \
|
2015
|
+
__extension__({ \
|
2016
|
+
VALUE arg_obj = (obj); \
|
2017
|
+
RB_SPECIAL_CONST_P(arg_obj) ? -1 : \
|
2018
|
+
RB_BUILTIN_TYPE(arg_obj); \
|
2019
|
+
})
|
2020
|
+
#else
|
2021
|
+
static inline int
|
2022
|
+
rb_obj_builtin_type(VALUE obj)
|
2023
|
+
{
|
2024
|
+
return RB_SPECIAL_CONST_P(obj) ? -1 :
|
2025
|
+
RB_BUILTIN_TYPE(obj);
|
2026
|
+
}
|
2027
|
+
#endif
|
2028
|
+
|
2029
|
+
#if defined(__cplusplus)
|
2030
|
+
#if 0
|
2031
|
+
{ /* satisfy cc-mode */
|
2032
|
+
#endif
|
2033
|
+
} /* extern "C" { */
|
2034
|
+
#endif
|
2035
|
+
|
2036
|
+
#endif /* RUBY_INTERNAL_H */
|