debase-ruby_core_source 0.10.17 → 0.10.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/addr2line.h +20 -0
  4. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/builtin.h +121 -0
  5. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/list/list.h +789 -0
  9. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ccan/str/str.h +17 -0
  10. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/constant.h +55 -0
  11. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/darray.h +179 -0
  12. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/debug_counter.h +468 -0
  13. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/dln.h +31 -0
  14. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/encindex.h +70 -0
  15. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/eval_intern.h +339 -0
  16. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/gc.h +147 -0
  17. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/hrtime.h +227 -0
  18. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/id.h +295 -0
  19. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/id_table.h +36 -0
  20. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/insns.inc +249 -0
  21. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/insns_info.inc +9061 -0
  22. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/array.h +163 -0
  23. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/bignum.h +246 -0
  24. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/bits.h +565 -0
  25. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/class.h +181 -0
  26. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/cmdlineopt.h +61 -0
  27. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compar.h +49 -0
  28. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compile.h +35 -0
  29. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/compilers.h +107 -0
  30. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/complex.h +29 -0
  31. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/cont.h +29 -0
  32. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/dir.h +16 -0
  33. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enc.h +19 -0
  34. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/encoding.h +29 -0
  35. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enum.h +18 -0
  36. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/enumerator.h +21 -0
  37. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/error.h +191 -0
  38. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/eval.h +32 -0
  39. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/file.h +38 -0
  40. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/fixnum.h +184 -0
  41. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/gc.h +191 -0
  42. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/hash.h +243 -0
  43. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/imemo.h +242 -0
  44. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/inits.h +50 -0
  45. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/io.h +38 -0
  46. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/load.h +18 -0
  47. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/loadpath.h +16 -0
  48. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/math.h +23 -0
  49. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/missing.h +18 -0
  50. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/numeric.h +275 -0
  51. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/object.h +61 -0
  52. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/parse.h +24 -0
  53. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/proc.h +32 -0
  54. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/process.h +137 -0
  55. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/ractor.h +6 -0
  56. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/random.h +16 -0
  57. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/range.h +40 -0
  58. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/rational.h +72 -0
  59. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/re.h +30 -0
  60. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/sanitizers.h +190 -0
  61. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/serial.h +23 -0
  62. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/signal.h +21 -0
  63. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/static_assert.h +16 -0
  64. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/string.h +147 -0
  65. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/struct.h +153 -0
  66. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/symbol.h +42 -0
  67. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/thread.h +55 -0
  68. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/time.h +34 -0
  69. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/transcode.h +20 -0
  70. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/util.h +27 -0
  71. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/variable.h +88 -0
  72. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/vm.h +134 -0
  73. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal/warnings.h +16 -0
  74. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/internal.h +113 -0
  75. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/iseq.h +329 -0
  76. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/known_errors.inc +791 -0
  77. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/method.h +254 -0
  78. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit.h +132 -0
  79. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_compile_attr.inc +430 -0
  80. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_compiler.h +58 -0
  81. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/mjit_unit.h +29 -0
  82. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/node.h +511 -0
  83. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/node_name.inc +210 -0
  84. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/opt_sc.inc +109 -0
  85. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/optinsn.inc +128 -0
  86. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/optunifs.inc +43 -0
  87. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/parse.h +215 -0
  88. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/probes_helper.h +44 -0
  89. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ractor_core.h +343 -0
  90. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regenc.h +254 -0
  91. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regint.h +984 -0
  92. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/regparse.h +370 -0
  93. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/revision.h +5 -0
  94. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ruby_assert.h +14 -0
  95. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/ruby_atomic.h +23 -0
  96. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/shape.h +194 -0
  97. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/siphash.h +48 -0
  98. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/symbol.h +119 -0
  99. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_none.h +20 -0
  100. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_pthread.h +132 -0
  101. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/thread_win32.h +63 -0
  102. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/timev.h +57 -0
  103. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/transcode_data.h +138 -0
  104. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/transient_heap.h +65 -0
  105. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/variable.h +29 -0
  106. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/version.h +65 -0
  107. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm.inc +5476 -0
  108. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_call_iseq_optimized.inc +244 -0
  109. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_callinfo.h +550 -0
  110. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_core.h +2137 -0
  111. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_debug.h +122 -0
  112. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_exec.h +197 -0
  113. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_insnhelper.h +266 -0
  114. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_opts.h +73 -0
  115. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vm_sync.h +137 -0
  116. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/vmtc.inc +243 -0
  117. data/lib/debase/ruby_core_source/ruby-3.2.0-preview3/yjit.h +72 -0
  118. data/lib/debase/ruby_core_source/version.rb +1 -1
  119. metadata +118 -3
@@ -0,0 +1,275 @@
1
+ #ifndef INTERNAL_NUMERIC_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_NUMERIC_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Numeric.
10
+ */
11
+ #include "internal/bignum.h" /* for BIGNUM_POSITIVE_P */
12
+ #include "internal/bits.h" /* for RUBY_BIT_ROTL */
13
+ #include "internal/fixnum.h" /* for FIXNUM_POSITIVE_P */
14
+ #include "internal/vm.h" /* for rb_method_basic_definition_p */
15
+ #include "ruby/intern.h" /* for rb_cmperr */
16
+ #include "ruby/ruby.h" /* for USE_FLONUM */
17
+
18
+ #define ROUND_TO(mode, even, up, down) \
19
+ ((mode) == RUBY_NUM_ROUND_HALF_EVEN ? even : \
20
+ (mode) == RUBY_NUM_ROUND_HALF_UP ? up : down)
21
+ #define ROUND_FUNC(mode, name) \
22
+ ROUND_TO(mode, name##_half_even, name##_half_up, name##_half_down)
23
+ #define ROUND_CALL(mode, name, args) \
24
+ ROUND_TO(mode, name##_half_even args, \
25
+ name##_half_up args, name##_half_down args)
26
+
27
+ #ifndef ROUND_DEFAULT
28
+ # define ROUND_DEFAULT RUBY_NUM_ROUND_HALF_UP
29
+ #endif
30
+
31
+ enum ruby_num_rounding_mode {
32
+ RUBY_NUM_ROUND_HALF_UP,
33
+ RUBY_NUM_ROUND_HALF_EVEN,
34
+ RUBY_NUM_ROUND_HALF_DOWN,
35
+ RUBY_NUM_ROUND_DEFAULT = ROUND_DEFAULT,
36
+ };
37
+
38
+ /* same as internal.h */
39
+ #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
40
+ #define roomof(x, y) (((x) + (y) - 1) / (y))
41
+ #define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
42
+
43
+ #if SIZEOF_DOUBLE <= SIZEOF_VALUE
44
+ typedef double rb_float_value_type;
45
+ #else
46
+ typedef struct {
47
+ VALUE values[roomof(SIZEOF_DOUBLE, SIZEOF_VALUE)];
48
+ } rb_float_value_type;
49
+ #endif
50
+
51
+ struct RFloat {
52
+ struct RBasic basic;
53
+ rb_float_value_type float_value;
54
+ };
55
+
56
+ #define RFLOAT(obj) ((struct RFloat *)(obj))
57
+
58
+ /* numeric.c */
59
+ int rb_num_to_uint(VALUE val, unsigned int *ret);
60
+ VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
61
+ double ruby_float_step_size(double beg, double end, double unit, int excl);
62
+ int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless);
63
+ int rb_num_negative_p(VALUE);
64
+ VALUE rb_int_succ(VALUE num);
65
+ VALUE rb_float_uminus(VALUE num);
66
+ VALUE rb_int_plus(VALUE x, VALUE y);
67
+ VALUE rb_float_plus(VALUE x, VALUE y);
68
+ VALUE rb_int_minus(VALUE x, VALUE y);
69
+ VALUE rb_float_minus(VALUE x, VALUE y);
70
+ VALUE rb_int_mul(VALUE x, VALUE y);
71
+ VALUE rb_float_mul(VALUE x, VALUE y);
72
+ VALUE rb_float_div(VALUE x, VALUE y);
73
+ VALUE rb_int_idiv(VALUE x, VALUE y);
74
+ VALUE rb_int_modulo(VALUE x, VALUE y);
75
+ VALUE rb_int2str(VALUE num, int base);
76
+ VALUE rb_fix_plus(VALUE x, VALUE y);
77
+ VALUE rb_int_gt(VALUE x, VALUE y);
78
+ VALUE rb_float_gt(VALUE x, VALUE y);
79
+ VALUE rb_int_ge(VALUE x, VALUE y);
80
+ enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
81
+ double rb_int_fdiv_double(VALUE x, VALUE y);
82
+ VALUE rb_int_pow(VALUE x, VALUE y);
83
+ VALUE rb_float_pow(VALUE x, VALUE y);
84
+ VALUE rb_int_cmp(VALUE x, VALUE y);
85
+ VALUE rb_int_equal(VALUE x, VALUE y);
86
+ VALUE rb_int_divmod(VALUE x, VALUE y);
87
+ VALUE rb_int_and(VALUE x, VALUE y);
88
+ VALUE rb_int_lshift(VALUE x, VALUE y);
89
+ VALUE rb_int_div(VALUE x, VALUE y);
90
+ int rb_int_positive_p(VALUE num);
91
+ int rb_int_negative_p(VALUE num);
92
+ VALUE rb_check_integer_type(VALUE);
93
+ VALUE rb_num_pow(VALUE x, VALUE y);
94
+ VALUE rb_float_ceil(VALUE num, int ndigits);
95
+ VALUE rb_float_floor(VALUE x, int ndigits);
96
+ VALUE rb_float_abs(VALUE flt);
97
+ static inline VALUE rb_num_compare_with_zero(VALUE num, ID mid);
98
+ static inline int rb_num_positive_int_p(VALUE num);
99
+ static inline int rb_num_negative_int_p(VALUE num);
100
+ static inline double rb_float_flonum_value(VALUE v);
101
+ static inline double rb_float_noflonum_value(VALUE v);
102
+ static inline double rb_float_value_inline(VALUE v);
103
+ static inline VALUE rb_float_new_inline(double d);
104
+ static inline bool INT_POSITIVE_P(VALUE num);
105
+ static inline bool INT_NEGATIVE_P(VALUE num);
106
+ static inline bool FLOAT_ZERO_P(VALUE num);
107
+ #define rb_float_value rb_float_value_inline
108
+ #define rb_float_new rb_float_new_inline
109
+
110
+ RUBY_SYMBOL_EXPORT_BEGIN
111
+ /* numeric.c (export) */
112
+ RUBY_SYMBOL_EXPORT_END
113
+
114
+ MJIT_SYMBOL_EXPORT_BEGIN
115
+ VALUE rb_flo_div_flo(VALUE x, VALUE y);
116
+ double ruby_float_mod(double x, double y);
117
+ VALUE rb_float_equal(VALUE x, VALUE y);
118
+ int rb_float_cmp(VALUE x, VALUE y);
119
+ VALUE rb_float_eql(VALUE x, VALUE y);
120
+ VALUE rb_fix_aref(VALUE fix, VALUE idx);
121
+ VALUE rb_int_zero_p(VALUE num);
122
+ VALUE rb_int_even_p(VALUE num);
123
+ VALUE rb_int_odd_p(VALUE num);
124
+ VALUE rb_int_abs(VALUE num);
125
+ VALUE rb_int_bit_length(VALUE num);
126
+ VALUE rb_int_uminus(VALUE num);
127
+ VALUE rb_int_comp(VALUE num);
128
+ MJIT_SYMBOL_EXPORT_END
129
+
130
+ static inline bool
131
+ INT_POSITIVE_P(VALUE num)
132
+ {
133
+ if (FIXNUM_P(num)) {
134
+ return FIXNUM_POSITIVE_P(num);
135
+ }
136
+ else {
137
+ return BIGNUM_POSITIVE_P(num);
138
+ }
139
+ }
140
+
141
+ static inline bool
142
+ INT_NEGATIVE_P(VALUE num)
143
+ {
144
+ if (FIXNUM_P(num)) {
145
+ return FIXNUM_NEGATIVE_P(num);
146
+ }
147
+ else {
148
+ return BIGNUM_NEGATIVE_P(num);
149
+ }
150
+ }
151
+
152
+ static inline bool
153
+ FLOAT_ZERO_P(VALUE num)
154
+ {
155
+ return RFLOAT_VALUE(num) == 0.0;
156
+ }
157
+
158
+ static inline VALUE
159
+ rb_num_compare_with_zero(VALUE num, ID mid)
160
+ {
161
+ VALUE zero = INT2FIX(0);
162
+ VALUE r = rb_check_funcall(num, mid, 1, &zero);
163
+ if (r == Qundef) {
164
+ rb_cmperr(num, zero);
165
+ }
166
+ return r;
167
+ }
168
+
169
+ static inline int
170
+ rb_num_positive_int_p(VALUE num)
171
+ {
172
+ const ID mid = '>';
173
+
174
+ if (FIXNUM_P(num)) {
175
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
176
+ return FIXNUM_POSITIVE_P(num);
177
+ }
178
+ else if (RB_TYPE_P(num, T_BIGNUM)) {
179
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
180
+ return BIGNUM_POSITIVE_P(num);
181
+ }
182
+ return RTEST(rb_num_compare_with_zero(num, mid));
183
+ }
184
+
185
+ static inline int
186
+ rb_num_negative_int_p(VALUE num)
187
+ {
188
+ const ID mid = '<';
189
+
190
+ if (FIXNUM_P(num)) {
191
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
192
+ return FIXNUM_NEGATIVE_P(num);
193
+ }
194
+ else if (RB_TYPE_P(num, T_BIGNUM)) {
195
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
196
+ return BIGNUM_NEGATIVE_P(num);
197
+ }
198
+ return RTEST(rb_num_compare_with_zero(num, mid));
199
+ }
200
+
201
+ static inline double
202
+ rb_float_flonum_value(VALUE v)
203
+ {
204
+ #if USE_FLONUM
205
+ if (v != (VALUE)0x8000000000000002) { /* LIKELY */
206
+ union {
207
+ double d;
208
+ VALUE v;
209
+ } t;
210
+
211
+ VALUE b63 = (v >> 63);
212
+ /* e: xx1... -> 011... */
213
+ /* xx0... -> 100... */
214
+ /* ^b63 */
215
+ t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~(VALUE)0x03), 3);
216
+ return t.d;
217
+ }
218
+ #endif
219
+ return 0.0;
220
+ }
221
+
222
+ static inline double
223
+ rb_float_noflonum_value(VALUE v)
224
+ {
225
+ #if SIZEOF_DOUBLE <= SIZEOF_VALUE
226
+ return RFLOAT(v)->float_value;
227
+ #else
228
+ union {
229
+ rb_float_value_type v;
230
+ double d;
231
+ } u = {RFLOAT(v)->float_value};
232
+ return u.d;
233
+ #endif
234
+ }
235
+
236
+ static inline double
237
+ rb_float_value_inline(VALUE v)
238
+ {
239
+ if (FLONUM_P(v)) {
240
+ return rb_float_flonum_value(v);
241
+ }
242
+ return rb_float_noflonum_value(v);
243
+ }
244
+
245
+ static inline VALUE
246
+ rb_float_new_inline(double d)
247
+ {
248
+ #if USE_FLONUM
249
+ union {
250
+ double d;
251
+ VALUE v;
252
+ } t;
253
+ int bits;
254
+
255
+ t.d = d;
256
+ bits = (int)((VALUE)(t.v >> 60) & 0x7);
257
+ /* bits contains 3 bits of b62..b60. */
258
+ /* bits - 3 = */
259
+ /* b011 -> b000 */
260
+ /* b100 -> b001 */
261
+
262
+ if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
263
+ !((bits-3) & ~0x01)) {
264
+ return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
265
+ }
266
+ else if (t.v == (VALUE)0) {
267
+ /* +0.0 */
268
+ return 0x8000000000000002;
269
+ }
270
+ /* out of range */
271
+ #endif
272
+ return rb_float_new_in_heap(d);
273
+ }
274
+
275
+ #endif /* INTERNAL_NUMERIC_H */
@@ -0,0 +1,61 @@
1
+ #ifndef INTERNAL_OBJECT_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_OBJECT_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Object.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+
13
+ /* object.c */
14
+ VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
15
+ NORETURN(void rb_undefined_alloc(VALUE klass));
16
+ double rb_num_to_dbl(VALUE val);
17
+ VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
18
+ VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
19
+ VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
20
+ int rb_bool_expected(VALUE, const char *, int raise);
21
+ static inline void RBASIC_CLEAR_CLASS(VALUE obj);
22
+ static inline void RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass);
23
+ static inline void RBASIC_SET_CLASS(VALUE obj, VALUE klass);
24
+
25
+ RUBY_SYMBOL_EXPORT_BEGIN
26
+ /* object.c (export) */
27
+ int rb_opts_exception_p(VALUE opts, int default_value);
28
+ RUBY_SYMBOL_EXPORT_END
29
+
30
+ MJIT_SYMBOL_EXPORT_BEGIN
31
+ CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
32
+ CONSTFUNC(VALUE rb_obj_not(VALUE obj));
33
+ VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
34
+ void rb_obj_copy_ivar(VALUE dest, VALUE obj);
35
+ VALUE rb_false(VALUE obj);
36
+ VALUE rb_convert_type_with_id(VALUE v, int t, const char* nam, ID mid);
37
+ VALUE rb_obj_size(VALUE self, VALUE args, VALUE obj);
38
+ VALUE rb_get_freeze_opt(int argc, VALUE *argv);
39
+ MJIT_SYMBOL_EXPORT_END
40
+
41
+ static inline void
42
+ RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass)
43
+ {
44
+ const VALUE *ptr = &RBASIC(obj)->klass;
45
+ *(VALUE *)ptr = klass;
46
+ }
47
+
48
+ static inline void
49
+ RBASIC_CLEAR_CLASS(VALUE obj)
50
+ {
51
+ RBASIC_SET_CLASS_RAW(obj, 0);
52
+ }
53
+
54
+ static inline void
55
+ RBASIC_SET_CLASS(VALUE obj, VALUE klass)
56
+ {
57
+ VALUE oldv = RBASIC_CLASS(obj);
58
+ RBASIC_SET_CLASS_RAW(obj, klass);
59
+ RB_OBJ_WRITTEN(obj, oldv, klass);
60
+ }
61
+ #endif /* INTERNAL_OBJECT_H */
@@ -0,0 +1,24 @@
1
+ #ifndef INTERNAL_PARSE_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_PARSE_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for the parser.
10
+ */
11
+ #include "ruby/ruby.h" /* for VALUE */
12
+ struct rb_iseq_struct; /* in vm_core.h */
13
+
14
+ /* parse.y */
15
+ VALUE rb_parser_set_yydebug(VALUE, VALUE);
16
+ void *rb_parser_load_file(VALUE parser, VALUE name);
17
+ void rb_parser_keep_script_lines(VALUE vparser);
18
+ void rb_parser_error_tolerant(VALUE vparser);
19
+
20
+ RUBY_SYMBOL_EXPORT_BEGIN
21
+ VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
22
+ RUBY_SYMBOL_EXPORT_END
23
+
24
+ #endif /* INTERNAL_PARSE_H */
@@ -0,0 +1,32 @@
1
+ #ifndef INTERNAL_PROC_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_PROC_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Proc.
10
+ */
11
+ #include "ruby/ruby.h" /* for rb_block_call_func_t */
12
+ #include "ruby/st.h" /* for st_index_t */
13
+ struct rb_block; /* in vm_core.h */
14
+ struct rb_iseq_struct; /* in vm_core.h */
15
+
16
+ /* proc.c */
17
+ VALUE rb_proc_location(VALUE self);
18
+ st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
19
+ int rb_block_pair_yield_optimizable(void);
20
+ int rb_block_arity(void);
21
+ int rb_block_min_max_arity(int *max);
22
+ VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_info);
23
+ VALUE rb_callable_receiver(VALUE);
24
+
25
+ MJIT_SYMBOL_EXPORT_BEGIN
26
+ VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
27
+ VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
28
+ VALUE rb_iseq_location(const struct rb_iseq_struct *iseq);
29
+ VALUE rb_sym_to_proc(VALUE sym);
30
+ MJIT_SYMBOL_EXPORT_END
31
+
32
+ #endif /* INTERNAL_PROC_H */
@@ -0,0 +1,137 @@
1
+ #ifndef INTERNAL_PROCESS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_PROCESS_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Process.
10
+ */
11
+ #include "ruby/internal/config.h" /* for rb_pid_t */
12
+ #include <stddef.h> /* for size_t */
13
+
14
+ #ifdef HAVE_SYS_TYPES_H
15
+ # include <sys/types.h> /* for mode_t */
16
+ #endif
17
+
18
+ #ifdef _WIN32
19
+ # include "ruby/win32.h" /* for mode_t */
20
+ #endif
21
+
22
+ #include "ruby/ruby.h" /* for VALUE */
23
+ #include "internal/imemo.h" /* for RB_IMEMO_TMPBUF_PTR */
24
+ #include "internal/warnings.h" /* for COMPILER_WARNING_PUSH */
25
+
26
+ #define RB_MAX_GROUPS (65536)
27
+
28
+ struct waitpid_state;
29
+ struct rb_process_status;
30
+ struct rb_execarg {
31
+ union {
32
+ struct {
33
+ VALUE shell_script;
34
+ } sh;
35
+ struct {
36
+ VALUE command_name;
37
+ VALUE command_abspath; /* full path string or nil */
38
+ VALUE argv_str;
39
+ VALUE argv_buf;
40
+ } cmd;
41
+ } invoke;
42
+ VALUE redirect_fds;
43
+ VALUE envp_str;
44
+ VALUE envp_buf;
45
+ VALUE dup2_tmpbuf;
46
+ unsigned use_shell : 1;
47
+ unsigned pgroup_given : 1;
48
+ unsigned umask_given : 1;
49
+ unsigned unsetenv_others_given : 1;
50
+ unsigned unsetenv_others_do : 1;
51
+ unsigned close_others_given : 1;
52
+ unsigned close_others_do : 1;
53
+ unsigned chdir_given : 1;
54
+ unsigned new_pgroup_given : 1;
55
+ unsigned new_pgroup_flag : 1;
56
+ unsigned uid_given : 1;
57
+ unsigned gid_given : 1;
58
+ unsigned exception : 1;
59
+ unsigned exception_given : 1;
60
+ struct rb_process_status *status;
61
+ struct waitpid_state *waitpid_state; /* for async process management */
62
+ rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
63
+ VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
64
+ mode_t umask_mask;
65
+ rb_uid_t uid;
66
+ rb_gid_t gid;
67
+ int close_others_maxhint;
68
+ VALUE fd_dup2;
69
+ VALUE fd_close;
70
+ VALUE fd_open;
71
+ VALUE fd_dup2_child;
72
+ VALUE env_modification; /* Qfalse or [[k1,v1], ...] */
73
+ VALUE path_env;
74
+ VALUE chdir_dir;
75
+ };
76
+
77
+ /* process.c */
78
+ rb_pid_t rb_call_proc__fork(void);
79
+ void rb_last_status_clear(void);
80
+ static inline char **ARGVSTR2ARGV(VALUE argv_str);
81
+ static inline size_t ARGVSTR2ARGC(VALUE argv_str);
82
+
83
+ #ifdef HAVE_PWD_H
84
+ VALUE rb_getlogin(void);
85
+ VALUE rb_getpwdirnam_for_login(VALUE login); /* read as: "get pwd db home dir by username for login" */
86
+ VALUE rb_getpwdiruid(void); /* read as: "get pwd db home dir for getuid()" */
87
+ #endif
88
+
89
+ RUBY_SYMBOL_EXPORT_BEGIN
90
+ /* process.c (export) */
91
+ int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
92
+ 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);
93
+ VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell, int allow_exc_opt);
94
+ struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
95
+ int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
96
+ void rb_execarg_parent_start(VALUE execarg_obj);
97
+ void rb_execarg_parent_end(VALUE execarg_obj);
98
+ int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
99
+ VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
100
+ void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
101
+ RUBY_SYMBOL_EXPORT_END
102
+
103
+ /* argv_str contains extra two elements.
104
+ * The beginning one is for /bin/sh used by exec_with_sh.
105
+ * The last one for terminating NULL used by execve.
106
+ * See rb_exec_fillarg() in process.c. */
107
+ static inline char **
108
+ ARGVSTR2ARGV(VALUE argv_str)
109
+ {
110
+ char **buf = RB_IMEMO_TMPBUF_PTR(argv_str);
111
+ return &buf[1];
112
+ }
113
+
114
+ static inline size_t
115
+ ARGVSTR2ARGC(VALUE argv_str)
116
+ {
117
+ size_t i = 0;
118
+ char *const *p = ARGVSTR2ARGV(argv_str);
119
+ while (p[i++])
120
+ ;
121
+ return i - 1;
122
+ }
123
+
124
+ #ifdef HAVE_WORKING_FORK
125
+ COMPILER_WARNING_PUSH
126
+ #if __has_warning("-Wdeprecated-declarations") || RBIMPL_COMPILER_IS(GCC)
127
+ COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
128
+ #endif
129
+ static inline rb_pid_t
130
+ rb_fork(void)
131
+ {
132
+ return fork();
133
+ }
134
+ COMPILER_WARNING_POP
135
+ #endif
136
+
137
+ #endif /* INTERNAL_PROCESS_H */
@@ -0,0 +1,6 @@
1
+ #ifndef INTERNAL_RACTOR_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RACTOR_H
3
+
4
+ void rb_ractor_ensure_main_ractor(const char *msg);
5
+
6
+ #endif /* INTERNAL_RACTOR_H */
@@ -0,0 +1,16 @@
1
+ #ifndef INTERNAL_RANDOM_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RANDOM_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Random.
10
+ */
11
+ #include <stddef.h> /* for size_t */
12
+
13
+ /* random.c */
14
+ int ruby_fill_random_bytes(void *, size_t, int);
15
+
16
+ #endif /* INTERNAL_RANDOM_H */
@@ -0,0 +1,40 @@
1
+ #ifndef INTERNAL_RANGE_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RANGE_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Range.
10
+ */
11
+ #include "internal/struct.h" /* for RSTRUCT */
12
+
13
+ /* range.c */
14
+ static inline VALUE RANGE_BEG(VALUE r);
15
+ static inline VALUE RANGE_END(VALUE r);
16
+ static inline VALUE RANGE_EXCL(VALUE r);
17
+
18
+ static inline VALUE
19
+ RANGE_BEG(VALUE r)
20
+ {
21
+ return RSTRUCT(r)->as.ary[0];
22
+ }
23
+
24
+ static inline VALUE
25
+ RANGE_END(VALUE r)
26
+ {
27
+ return RSTRUCT(r)->as.ary[1];
28
+ }
29
+
30
+ static inline VALUE
31
+ RANGE_EXCL(VALUE r)
32
+ {
33
+ return RSTRUCT(r)->as.ary[2];
34
+ }
35
+
36
+ VALUE
37
+ rb_range_component_beg_len(VALUE b, VALUE e, int excl,
38
+ long *begp, long *lenp, long len, int err);
39
+
40
+ #endif /* INTERNAL_RANGE_H */
@@ -0,0 +1,72 @@
1
+ #ifndef INTERNAL_RATIONAL_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_RATIONAL_H
3
+ /**
4
+ * @author Ruby developers <ruby-core@ruby-lang.org>
5
+ * @copyright This file is a part of the programming language Ruby.
6
+ * Permission is hereby granted, to either redistribute and/or
7
+ * modify this file, provided that the conditions mentioned in the
8
+ * file COPYING are met. Consult the file for details.
9
+ * @brief Internal header for Rational.
10
+ */
11
+ #include "ruby/internal/config.h" /* for HAVE_LIBGMP */
12
+ #include "ruby/ruby.h" /* for struct RBasic */
13
+ #include "internal/gc.h" /* for RB_OBJ_WRITE */
14
+ #include "internal/numeric.h" /* for INT_POSITIVE_P */
15
+ #include "ruby_assert.h" /* for assert */
16
+
17
+ struct RRational {
18
+ struct RBasic basic;
19
+ VALUE num;
20
+ VALUE den;
21
+ };
22
+
23
+ #define RRATIONAL(obj) ((struct RRational *)(obj))
24
+
25
+ /* rational.c */
26
+ VALUE rb_rational_canonicalize(VALUE x);
27
+ VALUE rb_rational_uminus(VALUE self);
28
+ VALUE rb_rational_plus(VALUE self, VALUE other);
29
+ VALUE rb_rational_minus(VALUE self, VALUE other);
30
+ VALUE rb_rational_mul(VALUE self, VALUE other);
31
+ VALUE rb_rational_div(VALUE self, VALUE other);
32
+ VALUE rb_lcm(VALUE x, VALUE y);
33
+ VALUE rb_rational_reciprocal(VALUE x);
34
+ VALUE rb_cstr_to_rat(const char *, int);
35
+ VALUE rb_rational_hash(VALUE self);
36
+ VALUE rb_rational_abs(VALUE self);
37
+ VALUE rb_rational_cmp(VALUE self, VALUE other);
38
+ VALUE rb_rational_pow(VALUE self, VALUE other);
39
+ VALUE rb_rational_floor(VALUE self, int ndigits);
40
+ VALUE rb_numeric_quo(VALUE x, VALUE y);
41
+ VALUE rb_flo_round_by_rational(int argc, VALUE *argv, VALUE num);
42
+ VALUE rb_float_numerator(VALUE x);
43
+ VALUE rb_float_denominator(VALUE x);
44
+
45
+ static inline void RATIONAL_SET_NUM(VALUE r, VALUE n);
46
+ static inline void RATIONAL_SET_DEN(VALUE r, VALUE d);
47
+
48
+ RUBY_SYMBOL_EXPORT_BEGIN
49
+ /* rational.c (export) */
50
+ VALUE rb_gcd(VALUE x, VALUE y);
51
+ VALUE rb_gcd_normal(VALUE self, VALUE other);
52
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
53
+ VALUE rb_gcd_gmp(VALUE x, VALUE y);
54
+ #endif
55
+ RUBY_SYMBOL_EXPORT_END
56
+
57
+ static inline void
58
+ RATIONAL_SET_NUM(VALUE r, VALUE n)
59
+ {
60
+ assert(RB_INTEGER_TYPE_P(n));
61
+ RB_OBJ_WRITE(r, &RRATIONAL(r)->num, n);
62
+ }
63
+
64
+ static inline void
65
+ RATIONAL_SET_DEN(VALUE r, VALUE d)
66
+ {
67
+ assert(RB_INTEGER_TYPE_P(d));
68
+ assert(INT_POSITIVE_P(d));
69
+ RB_OBJ_WRITE(r, &RRATIONAL(r)->den, d);
70
+ }
71
+
72
+ #endif /* INTERNAL_RATIONAL_H */