debase-ruby_core_source 0.10.16 → 0.10.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/addr2line.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/builtin.h +121 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/list/list.h +789 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/constant.h +55 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/darray.h +179 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/debug_counter.h +469 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/dln.h +31 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/eval_intern.h +339 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/gc.h +143 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/hrtime.h +226 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/id.h +295 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/id_table.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/insns.inc +249 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/insns_info.inc +9061 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/array.h +162 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/bignum.h +246 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/bits.h +565 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/class.h +212 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/cmdlineopt.h +58 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/compar.h +49 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/compile.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/compilers.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/cont.h +26 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/encoding.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/error.h +191 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/eval.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/file.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/fixnum.h +184 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/gc.h +188 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/hash.h +243 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/imemo.h +242 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/inits.h +50 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/io.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/load.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/missing.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/numeric.h +271 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/object.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/parse.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/proc.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/process.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/ractor.h +6 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/random.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/range.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/rational.h +72 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/re.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/sanitizers.h +190 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/signal.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/string.h +146 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/struct.h +153 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/symbol.h +42 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/thread.h +54 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/transcode.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/variable.h +83 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/vm.h +134 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal.h +113 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/iseq.h +328 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/known_errors.inc +791 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/method.h +253 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit.h +136 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit_compile_attr.inc +430 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit_compiler.h +58 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit_unit.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/node.h +510 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/node_name.inc +208 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/opt_sc.inc +109 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/parse.h +214 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/probes_helper.h +44 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ractor_core.h +341 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/regenc.h +255 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/regint.h +957 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/regparse.h +370 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/revision.h +2 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ruby_atomic.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/symbol.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/thread_none.h +20 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/thread_pthread.h +132 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/thread_win32.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/timev.h +57 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/transient_heap.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/variable.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/version.h +68 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm.inc +5476 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_callinfo.h +522 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_core.h +2130 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_debug.h +122 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_exec.h +197 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_insnhelper.h +269 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_opts.h +73 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_sync.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vmtc.inc +243 -0
- data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/yjit.h +72 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +116 -2
@@ -0,0 +1,271 @@
|
|
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
|
+
#if SIZEOF_DOUBLE <= SIZEOF_VALUE
|
39
|
+
typedef double rb_float_value_type;
|
40
|
+
#else
|
41
|
+
typedef struct {
|
42
|
+
VALUE values[(SIZEOF_DOUBLE + SIZEOF_VALUE - 1) / SIZEOF_VALUE];
|
43
|
+
/* roomof() needs internal.h, and the order of some macros may matter */
|
44
|
+
} rb_float_value_type;
|
45
|
+
#endif
|
46
|
+
|
47
|
+
struct RFloat {
|
48
|
+
struct RBasic basic;
|
49
|
+
rb_float_value_type float_value;
|
50
|
+
};
|
51
|
+
|
52
|
+
#define RFLOAT(obj) ((struct RFloat *)(obj))
|
53
|
+
|
54
|
+
/* numeric.c */
|
55
|
+
int rb_num_to_uint(VALUE val, unsigned int *ret);
|
56
|
+
VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
|
57
|
+
double ruby_float_step_size(double beg, double end, double unit, int excl);
|
58
|
+
int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless);
|
59
|
+
int rb_num_negative_p(VALUE);
|
60
|
+
VALUE rb_int_succ(VALUE num);
|
61
|
+
VALUE rb_float_uminus(VALUE num);
|
62
|
+
VALUE rb_int_plus(VALUE x, VALUE y);
|
63
|
+
VALUE rb_float_plus(VALUE x, VALUE y);
|
64
|
+
VALUE rb_int_minus(VALUE x, VALUE y);
|
65
|
+
VALUE rb_float_minus(VALUE x, VALUE y);
|
66
|
+
VALUE rb_int_mul(VALUE x, VALUE y);
|
67
|
+
VALUE rb_float_mul(VALUE x, VALUE y);
|
68
|
+
VALUE rb_float_div(VALUE x, VALUE y);
|
69
|
+
VALUE rb_int_idiv(VALUE x, VALUE y);
|
70
|
+
VALUE rb_int_modulo(VALUE x, VALUE y);
|
71
|
+
VALUE rb_int2str(VALUE num, int base);
|
72
|
+
VALUE rb_fix_plus(VALUE x, VALUE y);
|
73
|
+
VALUE rb_int_gt(VALUE x, VALUE y);
|
74
|
+
VALUE rb_float_gt(VALUE x, VALUE y);
|
75
|
+
VALUE rb_int_ge(VALUE x, VALUE y);
|
76
|
+
enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
|
77
|
+
double rb_int_fdiv_double(VALUE x, VALUE y);
|
78
|
+
VALUE rb_int_pow(VALUE x, VALUE y);
|
79
|
+
VALUE rb_float_pow(VALUE x, VALUE y);
|
80
|
+
VALUE rb_int_cmp(VALUE x, VALUE y);
|
81
|
+
VALUE rb_int_equal(VALUE x, VALUE y);
|
82
|
+
VALUE rb_int_divmod(VALUE x, VALUE y);
|
83
|
+
VALUE rb_int_and(VALUE x, VALUE y);
|
84
|
+
VALUE rb_int_lshift(VALUE x, VALUE y);
|
85
|
+
VALUE rb_int_div(VALUE x, VALUE y);
|
86
|
+
int rb_int_positive_p(VALUE num);
|
87
|
+
int rb_int_negative_p(VALUE num);
|
88
|
+
VALUE rb_check_integer_type(VALUE);
|
89
|
+
VALUE rb_num_pow(VALUE x, VALUE y);
|
90
|
+
VALUE rb_float_ceil(VALUE num, int ndigits);
|
91
|
+
VALUE rb_float_floor(VALUE x, int ndigits);
|
92
|
+
VALUE rb_float_abs(VALUE flt);
|
93
|
+
static inline VALUE rb_num_compare_with_zero(VALUE num, ID mid);
|
94
|
+
static inline int rb_num_positive_int_p(VALUE num);
|
95
|
+
static inline int rb_num_negative_int_p(VALUE num);
|
96
|
+
static inline double rb_float_flonum_value(VALUE v);
|
97
|
+
static inline double rb_float_noflonum_value(VALUE v);
|
98
|
+
static inline double rb_float_value_inline(VALUE v);
|
99
|
+
static inline VALUE rb_float_new_inline(double d);
|
100
|
+
static inline bool INT_POSITIVE_P(VALUE num);
|
101
|
+
static inline bool INT_NEGATIVE_P(VALUE num);
|
102
|
+
static inline bool FLOAT_ZERO_P(VALUE num);
|
103
|
+
#define rb_float_value rb_float_value_inline
|
104
|
+
#define rb_float_new rb_float_new_inline
|
105
|
+
|
106
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
107
|
+
/* numeric.c (export) */
|
108
|
+
RUBY_SYMBOL_EXPORT_END
|
109
|
+
|
110
|
+
MJIT_SYMBOL_EXPORT_BEGIN
|
111
|
+
VALUE rb_flo_div_flo(VALUE x, VALUE y);
|
112
|
+
double ruby_float_mod(double x, double y);
|
113
|
+
VALUE rb_float_equal(VALUE x, VALUE y);
|
114
|
+
int rb_float_cmp(VALUE x, VALUE y);
|
115
|
+
VALUE rb_float_eql(VALUE x, VALUE y);
|
116
|
+
VALUE rb_fix_aref(VALUE fix, VALUE idx);
|
117
|
+
VALUE rb_int_zero_p(VALUE num);
|
118
|
+
VALUE rb_int_even_p(VALUE num);
|
119
|
+
VALUE rb_int_odd_p(VALUE num);
|
120
|
+
VALUE rb_int_abs(VALUE num);
|
121
|
+
VALUE rb_int_bit_length(VALUE num);
|
122
|
+
VALUE rb_int_uminus(VALUE num);
|
123
|
+
VALUE rb_int_comp(VALUE num);
|
124
|
+
MJIT_SYMBOL_EXPORT_END
|
125
|
+
|
126
|
+
static inline bool
|
127
|
+
INT_POSITIVE_P(VALUE num)
|
128
|
+
{
|
129
|
+
if (FIXNUM_P(num)) {
|
130
|
+
return FIXNUM_POSITIVE_P(num);
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
return BIGNUM_POSITIVE_P(num);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
static inline bool
|
138
|
+
INT_NEGATIVE_P(VALUE num)
|
139
|
+
{
|
140
|
+
if (FIXNUM_P(num)) {
|
141
|
+
return FIXNUM_NEGATIVE_P(num);
|
142
|
+
}
|
143
|
+
else {
|
144
|
+
return BIGNUM_NEGATIVE_P(num);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
static inline bool
|
149
|
+
FLOAT_ZERO_P(VALUE num)
|
150
|
+
{
|
151
|
+
return RFLOAT_VALUE(num) == 0.0;
|
152
|
+
}
|
153
|
+
|
154
|
+
static inline VALUE
|
155
|
+
rb_num_compare_with_zero(VALUE num, ID mid)
|
156
|
+
{
|
157
|
+
VALUE zero = INT2FIX(0);
|
158
|
+
VALUE r = rb_check_funcall(num, mid, 1, &zero);
|
159
|
+
if (r == Qundef) {
|
160
|
+
rb_cmperr(num, zero);
|
161
|
+
}
|
162
|
+
return r;
|
163
|
+
}
|
164
|
+
|
165
|
+
static inline int
|
166
|
+
rb_num_positive_int_p(VALUE num)
|
167
|
+
{
|
168
|
+
const ID mid = '>';
|
169
|
+
|
170
|
+
if (FIXNUM_P(num)) {
|
171
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
172
|
+
return FIXNUM_POSITIVE_P(num);
|
173
|
+
}
|
174
|
+
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
175
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
176
|
+
return BIGNUM_POSITIVE_P(num);
|
177
|
+
}
|
178
|
+
return RTEST(rb_num_compare_with_zero(num, mid));
|
179
|
+
}
|
180
|
+
|
181
|
+
static inline int
|
182
|
+
rb_num_negative_int_p(VALUE num)
|
183
|
+
{
|
184
|
+
const ID mid = '<';
|
185
|
+
|
186
|
+
if (FIXNUM_P(num)) {
|
187
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
188
|
+
return FIXNUM_NEGATIVE_P(num);
|
189
|
+
}
|
190
|
+
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
191
|
+
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
192
|
+
return BIGNUM_NEGATIVE_P(num);
|
193
|
+
}
|
194
|
+
return RTEST(rb_num_compare_with_zero(num, mid));
|
195
|
+
}
|
196
|
+
|
197
|
+
static inline double
|
198
|
+
rb_float_flonum_value(VALUE v)
|
199
|
+
{
|
200
|
+
#if USE_FLONUM
|
201
|
+
if (v != (VALUE)0x8000000000000002) { /* LIKELY */
|
202
|
+
union {
|
203
|
+
double d;
|
204
|
+
VALUE v;
|
205
|
+
} t;
|
206
|
+
|
207
|
+
VALUE b63 = (v >> 63);
|
208
|
+
/* e: xx1... -> 011... */
|
209
|
+
/* xx0... -> 100... */
|
210
|
+
/* ^b63 */
|
211
|
+
t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~(VALUE)0x03), 3);
|
212
|
+
return t.d;
|
213
|
+
}
|
214
|
+
#endif
|
215
|
+
return 0.0;
|
216
|
+
}
|
217
|
+
|
218
|
+
static inline double
|
219
|
+
rb_float_noflonum_value(VALUE v)
|
220
|
+
{
|
221
|
+
#if SIZEOF_DOUBLE <= SIZEOF_VALUE
|
222
|
+
return RFLOAT(v)->float_value;
|
223
|
+
#else
|
224
|
+
union {
|
225
|
+
rb_float_value_type v;
|
226
|
+
double d;
|
227
|
+
} u = {RFLOAT(v)->float_value};
|
228
|
+
return u.d;
|
229
|
+
#endif
|
230
|
+
}
|
231
|
+
|
232
|
+
static inline double
|
233
|
+
rb_float_value_inline(VALUE v)
|
234
|
+
{
|
235
|
+
if (FLONUM_P(v)) {
|
236
|
+
return rb_float_flonum_value(v);
|
237
|
+
}
|
238
|
+
return rb_float_noflonum_value(v);
|
239
|
+
}
|
240
|
+
|
241
|
+
static inline VALUE
|
242
|
+
rb_float_new_inline(double d)
|
243
|
+
{
|
244
|
+
#if USE_FLONUM
|
245
|
+
union {
|
246
|
+
double d;
|
247
|
+
VALUE v;
|
248
|
+
} t;
|
249
|
+
int bits;
|
250
|
+
|
251
|
+
t.d = d;
|
252
|
+
bits = (int)((VALUE)(t.v >> 60) & 0x7);
|
253
|
+
/* bits contains 3 bits of b62..b60. */
|
254
|
+
/* bits - 3 = */
|
255
|
+
/* b011 -> b000 */
|
256
|
+
/* b100 -> b001 */
|
257
|
+
|
258
|
+
if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
|
259
|
+
!((bits-3) & ~0x01)) {
|
260
|
+
return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
|
261
|
+
}
|
262
|
+
else if (t.v == (VALUE)0) {
|
263
|
+
/* +0.0 */
|
264
|
+
return 0x8000000000000002;
|
265
|
+
}
|
266
|
+
/* out of range */
|
267
|
+
#endif
|
268
|
+
return rb_float_new_in_heap(d);
|
269
|
+
}
|
270
|
+
|
271
|
+
#endif /* INTERNAL_NUMERIC_H */
|
@@ -0,0 +1,83 @@
|
|
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
|
+
#include "internal/class.h" /* for RCLASS_IV_INDEX_TBL */
|
13
|
+
|
14
|
+
#ifdef ROBJECT_IV_INDEX_TBL
|
15
|
+
# undef ROBJECT_IV_INDEX_TBL
|
16
|
+
#endif
|
17
|
+
|
18
|
+
/* object.c */
|
19
|
+
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
|
20
|
+
NORETURN(void rb_undefined_alloc(VALUE klass));
|
21
|
+
double rb_num_to_dbl(VALUE val);
|
22
|
+
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
|
23
|
+
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
|
24
|
+
VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
|
25
|
+
int rb_bool_expected(VALUE, const char *, int raise);
|
26
|
+
static inline void RBASIC_CLEAR_CLASS(VALUE obj);
|
27
|
+
static inline void RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass);
|
28
|
+
static inline void RBASIC_SET_CLASS(VALUE obj, VALUE klass);
|
29
|
+
static inline struct st_table *ROBJECT_IV_INDEX_TBL_inline(VALUE obj);
|
30
|
+
|
31
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
32
|
+
/* object.c (export) */
|
33
|
+
int rb_opts_exception_p(VALUE opts, int default_value);
|
34
|
+
RUBY_SYMBOL_EXPORT_END
|
35
|
+
|
36
|
+
MJIT_SYMBOL_EXPORT_BEGIN
|
37
|
+
CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
|
38
|
+
CONSTFUNC(VALUE rb_obj_not(VALUE obj));
|
39
|
+
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
|
40
|
+
void rb_obj_copy_ivar(VALUE dest, VALUE obj);
|
41
|
+
VALUE rb_false(VALUE obj);
|
42
|
+
VALUE rb_convert_type_with_id(VALUE v, int t, const char* nam, ID mid);
|
43
|
+
VALUE rb_obj_size(VALUE self, VALUE args, VALUE obj);
|
44
|
+
VALUE rb_get_freeze_opt(int argc, VALUE *argv);
|
45
|
+
MJIT_SYMBOL_EXPORT_END
|
46
|
+
|
47
|
+
static inline void
|
48
|
+
RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass)
|
49
|
+
{
|
50
|
+
const VALUE *ptr = &RBASIC(obj)->klass;
|
51
|
+
*(VALUE *)ptr = klass;
|
52
|
+
}
|
53
|
+
|
54
|
+
static inline void
|
55
|
+
RBASIC_CLEAR_CLASS(VALUE obj)
|
56
|
+
{
|
57
|
+
RBASIC_SET_CLASS_RAW(obj, 0);
|
58
|
+
}
|
59
|
+
|
60
|
+
static inline void
|
61
|
+
RBASIC_SET_CLASS(VALUE obj, VALUE klass)
|
62
|
+
{
|
63
|
+
VALUE oldv = RBASIC_CLASS(obj);
|
64
|
+
RBASIC_SET_CLASS_RAW(obj, klass);
|
65
|
+
RB_OBJ_WRITTEN(obj, oldv, klass);
|
66
|
+
}
|
67
|
+
|
68
|
+
RBIMPL_ATTR_PURE()
|
69
|
+
static inline struct st_table *
|
70
|
+
ROBJECT_IV_INDEX_TBL_inline(VALUE obj)
|
71
|
+
{
|
72
|
+
if (RB_FL_ANY_RAW(obj, ROBJECT_EMBED)) {
|
73
|
+
VALUE klass = rb_obj_class(obj);
|
74
|
+
return RCLASS_IV_INDEX_TBL(klass);
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
const struct RObject *const ptr = ROBJECT(obj);
|
78
|
+
return ptr->as.heap.iv_index_tbl;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
#define ROBJECT_IV_INDEX_TBL ROBJECT_IV_INDEX_TBL_inline
|
82
|
+
|
83
|
+
#endif /* INTERNAL_OBJECT_H */
|
@@ -0,0 +1,23 @@
|
|
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
|
+
|
19
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
20
|
+
VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
|
21
|
+
RUBY_SYMBOL_EXPORT_END
|
22
|
+
|
23
|
+
#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,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 */
|