zscan 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/ext/extconf.rb +9 -1
  3. data/ext/pack/builtin-27.h +79 -0
  4. data/ext/pack/builtin.h +79 -0
  5. data/ext/pack/internal-27.h +96 -0
  6. data/ext/pack/internal-27/array.h +103 -0
  7. data/ext/pack/internal-27/bignum.h +246 -0
  8. data/ext/pack/internal-27/bits.h +566 -0
  9. data/ext/pack/internal-27/class.h +162 -0
  10. data/ext/pack/internal-27/compar.h +50 -0
  11. data/ext/pack/internal-27/compile.h +32 -0
  12. data/ext/pack/internal-27/compilers.h +108 -0
  13. data/ext/pack/internal-27/complex.h +29 -0
  14. data/ext/pack/internal-27/cont.h +23 -0
  15. data/ext/pack/internal-27/dir.h +17 -0
  16. data/ext/pack/internal-27/enc.h +20 -0
  17. data/ext/pack/internal-27/encoding.h +28 -0
  18. data/ext/pack/internal-27/enum.h +19 -0
  19. data/ext/pack/internal-27/enumerator.h +22 -0
  20. data/ext/pack/internal-27/error.h +129 -0
  21. data/ext/pack/internal-27/eval.h +33 -0
  22. data/ext/pack/internal-27/file.h +39 -0
  23. data/ext/pack/internal-27/fixnum.h +185 -0
  24. data/ext/pack/internal-27/gc.h +153 -0
  25. data/ext/pack/internal-27/hash.h +234 -0
  26. data/ext/pack/internal-27/imemo.h +242 -0
  27. data/ext/pack/internal-27/inits.h +51 -0
  28. data/ext/pack/internal-27/io.h +35 -0
  29. data/ext/pack/internal-27/load.h +19 -0
  30. data/ext/pack/internal-27/loadpath.h +17 -0
  31. data/ext/pack/internal-27/math.h +24 -0
  32. data/ext/pack/internal-27/missing.h +19 -0
  33. data/ext/pack/internal-27/mjit.h +29 -0
  34. data/ext/pack/internal-27/numeric.h +249 -0
  35. data/ext/pack/internal-27/object.h +60 -0
  36. data/ext/pack/internal-27/parse.h +23 -0
  37. data/ext/pack/internal-27/proc.h +32 -0
  38. data/ext/pack/internal-27/process.h +130 -0
  39. data/ext/pack/internal-27/random.h +17 -0
  40. data/ext/pack/internal-27/range.h +37 -0
  41. data/ext/pack/internal-27/rational.h +68 -0
  42. data/ext/pack/internal-27/re.h +29 -0
  43. data/ext/pack/internal-27/sanitizers.h +191 -0
  44. data/ext/pack/internal-27/serial.h +24 -0
  45. data/ext/pack/internal-27/signal.h +22 -0
  46. data/ext/pack/internal-27/static_assert.h +17 -0
  47. data/ext/pack/internal-27/string.h +135 -0
  48. data/ext/pack/internal-27/struct.h +154 -0
  49. data/ext/pack/internal-27/symbol.h +41 -0
  50. data/ext/pack/internal-27/thread.h +52 -0
  51. data/ext/pack/internal-27/time.h +35 -0
  52. data/ext/pack/internal-27/transcode.h +21 -0
  53. data/ext/pack/internal-27/util.h +31 -0
  54. data/ext/pack/internal-27/variable.h +92 -0
  55. data/ext/pack/internal-27/vm.h +127 -0
  56. data/ext/pack/internal-27/warnings.h +17 -0
  57. data/ext/pack/internal.h +57 -2102
  58. data/ext/pack/internal/array.h +103 -0
  59. data/ext/pack/internal/bignum.h +246 -0
  60. data/ext/pack/internal/bits.h +566 -0
  61. data/ext/pack/internal/class.h +162 -0
  62. data/ext/pack/internal/compar.h +50 -0
  63. data/ext/pack/internal/compile.h +32 -0
  64. data/ext/pack/internal/compilers.h +108 -0
  65. data/ext/pack/internal/complex.h +29 -0
  66. data/ext/pack/internal/cont.h +23 -0
  67. data/ext/pack/internal/dir.h +17 -0
  68. data/ext/pack/internal/enc.h +20 -0
  69. data/ext/pack/internal/encoding.h +28 -0
  70. data/ext/pack/internal/enum.h +19 -0
  71. data/ext/pack/internal/enumerator.h +22 -0
  72. data/ext/pack/internal/error.h +129 -0
  73. data/ext/pack/internal/eval.h +33 -0
  74. data/ext/pack/internal/file.h +39 -0
  75. data/ext/pack/internal/fixnum.h +185 -0
  76. data/ext/pack/internal/gc.h +153 -0
  77. data/ext/pack/internal/hash.h +234 -0
  78. data/ext/pack/internal/imemo.h +242 -0
  79. data/ext/pack/internal/inits.h +51 -0
  80. data/ext/pack/internal/io.h +35 -0
  81. data/ext/pack/internal/load.h +19 -0
  82. data/ext/pack/internal/loadpath.h +17 -0
  83. data/ext/pack/internal/math.h +24 -0
  84. data/ext/pack/internal/missing.h +19 -0
  85. data/ext/pack/internal/mjit.h +29 -0
  86. data/ext/pack/internal/numeric.h +249 -0
  87. data/ext/pack/internal/object.h +60 -0
  88. data/ext/pack/internal/parse.h +23 -0
  89. data/ext/pack/internal/proc.h +32 -0
  90. data/ext/pack/internal/process.h +130 -0
  91. data/ext/pack/internal/random.h +17 -0
  92. data/ext/pack/internal/range.h +37 -0
  93. data/ext/pack/internal/rational.h +68 -0
  94. data/ext/pack/internal/re.h +29 -0
  95. data/ext/pack/internal/sanitizers.h +191 -0
  96. data/ext/pack/internal/serial.h +24 -0
  97. data/ext/pack/internal/signal.h +22 -0
  98. data/ext/pack/internal/static_assert.h +17 -0
  99. data/ext/pack/internal/string.h +135 -0
  100. data/ext/pack/internal/struct.h +154 -0
  101. data/ext/pack/internal/symbol.h +41 -0
  102. data/ext/pack/internal/thread.h +52 -0
  103. data/ext/pack/internal/time.h +35 -0
  104. data/ext/pack/internal/transcode.h +21 -0
  105. data/ext/pack/internal/util.h +31 -0
  106. data/ext/pack/internal/variable.h +92 -0
  107. data/ext/pack/internal/vm.h +127 -0
  108. data/ext/pack/internal/warnings.h +17 -0
  109. data/ext/pack/pack-26.c +2 -109
  110. data/ext/pack/pack-27.c +1022 -0
  111. data/ext/pack/pack.c +57 -1047
  112. data/lib/zscan.rb +1 -1
  113. data/zscan.gemspec +1 -1
  114. metadata +109 -3
@@ -0,0 +1,51 @@
1
+ #ifndef INTERNAL_INITS_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_INITS_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header aggregating init functions.
11
+ */
12
+
13
+ /* class.c */
14
+ void Init_class_hierarchy(void);
15
+
16
+ /* dmyext.c */
17
+ void Init_enc(void);
18
+ void Init_ext(void);
19
+
20
+ /* file.c */
21
+ void Init_File(void);
22
+
23
+ /* gc.c */
24
+ void Init_heap(void);
25
+
26
+ /* localeinit.c */
27
+ int Init_enc_set_filesystem_encoding(void);
28
+
29
+ /* newline.c */
30
+ void Init_newline(void);
31
+
32
+ /* vm.c */
33
+ void Init_BareVM(void);
34
+ void Init_vm_objects(void);
35
+
36
+ /* vm_backtrace.c */
37
+ void Init_vm_backtrace(void);
38
+
39
+ /* vm_eval.c */
40
+ void Init_vm_eval(void);
41
+
42
+ /* vm_insnhelper.c */
43
+ void Init_vm_stack_canary(void);
44
+
45
+ /* vm_method.c */
46
+ void Init_eval_method(void);
47
+
48
+ /* inits.c */
49
+ void rb_call_inits(void);
50
+
51
+ #endif /* INTERNAL_INITS_H */
@@ -0,0 +1,35 @@
1
+ #ifndef INTERNAL_IO_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_IO_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for IO.
11
+ */
12
+ #include "ruby/ruby.h" /* for VALUE */
13
+ #include "ruby/io.h" /* for rb_io_t */
14
+
15
+ /* io.c */
16
+ void ruby_set_inplace_mode(const char *);
17
+ void rb_stdio_set_default_encoding(void);
18
+ VALUE rb_io_flush_raw(VALUE, int);
19
+ size_t rb_io_memsize(const rb_io_t *);
20
+ int rb_stderr_tty_p(void);
21
+ void rb_io_fptr_finalize_internal(void *ptr);
22
+ #ifdef rb_io_fptr_finalize
23
+ # undef rb_io_fptr_finalize
24
+ #endif
25
+ #define rb_io_fptr_finalize rb_io_fptr_finalize_internal
26
+ VALUE rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt);
27
+
28
+ RUBY_SYMBOL_EXPORT_BEGIN
29
+ /* io.c (export) */
30
+ void rb_maygvl_fd_fix_cloexec(int fd);
31
+ int rb_gc_for_fd(int err);
32
+ void rb_write_error_str(VALUE mesg);
33
+ RUBY_SYMBOL_EXPORT_END
34
+
35
+ #endif /* INTERNAL_IO_H */
@@ -0,0 +1,19 @@
1
+ #ifndef INTERNAL_LOAD_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_LOAD_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for require.
11
+ */
12
+ #include "ruby/ruby.h" /* for VALUE */
13
+
14
+ /* load.c */
15
+ VALUE rb_get_expanded_load_path(void);
16
+ int rb_require_internal(VALUE fname);
17
+ NORETURN(void rb_load_fail(VALUE, const char*));
18
+
19
+ #endif /* INTERNAL_LOAD_H */
@@ -0,0 +1,17 @@
1
+ #ifndef INTERNAL_LOADPATH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_LOADPATH_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for $LOAD_PATH.
11
+ */
12
+
13
+ /* loadpath.c */
14
+ extern const char ruby_exec_prefix[];
15
+ extern const char ruby_initial_load_paths[];
16
+
17
+ #endif /* INTERNAL_LOADPATH_H */
@@ -0,0 +1,24 @@
1
+ #ifndef INTERNAL_MATH_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_MATH_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for Math.
11
+ */
12
+ #include "ruby/ruby.h" /* for VALUE */
13
+
14
+ /* math.c */
15
+ VALUE rb_math_atan2(VALUE, VALUE);
16
+ VALUE rb_math_cos(VALUE);
17
+ VALUE rb_math_cosh(VALUE);
18
+ VALUE rb_math_exp(VALUE);
19
+ VALUE rb_math_hypot(VALUE, VALUE);
20
+ VALUE rb_math_log(int argc, const VALUE *argv);
21
+ VALUE rb_math_sin(VALUE);
22
+ VALUE rb_math_sinh(VALUE);
23
+
24
+ #endif /* INTERNAL_MATH_H */
@@ -0,0 +1,19 @@
1
+ #ifndef INTERNAL_MISSING_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_MISSING_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header corresponding missing.
11
+ */
12
+ #include "ruby/internal/config.h" /* for HAVE_SETPROCTITLE */
13
+
14
+ /* missing/setproctitle.c */
15
+ #ifndef HAVE_SETPROCTITLE
16
+ extern void ruby_init_setproctitle(int argc, char *argv[]);
17
+ #endif
18
+
19
+ #endif /* INTERNAL_MISSING_H */
@@ -0,0 +1,29 @@
1
+ #ifndef INTERNAL_MJIT_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_MJIT_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for MJIT.
11
+ */
12
+ #include "ruby/internal/stdbool.h" /* for bool */
13
+ #include "ruby/ruby.h" /* for VALUE */
14
+
15
+ /* mjit.c */
16
+
17
+ #if USE_MJIT
18
+ extern bool mjit_enabled;
19
+ VALUE mjit_pause(bool wait_p);
20
+ VALUE mjit_resume(void);
21
+ void mjit_finish(bool close_handle_p);
22
+ #else
23
+ #define mjit_enabled 0
24
+ static inline VALUE mjit_pause(bool wait_p){ return Qnil; } // unreachable
25
+ static inline VALUE mjit_resume(void){ return Qnil; } // unreachable
26
+ static inline void mjit_finish(bool close_handle_p){}
27
+ #endif
28
+
29
+ #endif /* INTERNAL_MJIT_H */
@@ -0,0 +1,249 @@
1
+ #ifndef INTERNAL_NUMERIC_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_NUMERIC_H
3
+ /**
4
+ * @file
5
+ * @author Ruby developers <ruby-core@ruby-lang.org>
6
+ * @copyright This file is a part of the programming language Ruby.
7
+ * Permission is hereby granted, to either redistribute and/or
8
+ * modify this file, provided that the conditions mentioned in the
9
+ * file COPYING are met. Consult the file for details.
10
+ * @brief Internal header for Numeric.
11
+ */
12
+ #include "internal/bignum.h" /* for BIGNUM_POSITIVE_P */
13
+ #include "internal/bits.h" /* for RUBY_BIT_ROTL */
14
+ #include "internal/fixnum.h" /* for FIXNUM_POSITIVE_P */
15
+ #include "internal/vm.h" /* for rb_method_basic_definition_p */
16
+ #include "ruby/intern.h" /* for rb_cmperr */
17
+ #include "ruby/ruby.h" /* for USE_FLONUM */
18
+
19
+ #define ROUND_TO(mode, even, up, down) \
20
+ ((mode) == RUBY_NUM_ROUND_HALF_EVEN ? even : \
21
+ (mode) == RUBY_NUM_ROUND_HALF_UP ? up : down)
22
+ #define ROUND_FUNC(mode, name) \
23
+ ROUND_TO(mode, name##_half_even, name##_half_up, name##_half_down)
24
+ #define ROUND_CALL(mode, name, args) \
25
+ ROUND_TO(mode, name##_half_even args, \
26
+ name##_half_up args, name##_half_down args)
27
+
28
+ #ifndef ROUND_DEFAULT
29
+ # define ROUND_DEFAULT RUBY_NUM_ROUND_HALF_UP
30
+ #endif
31
+
32
+ enum ruby_num_rounding_mode {
33
+ RUBY_NUM_ROUND_HALF_UP,
34
+ RUBY_NUM_ROUND_HALF_EVEN,
35
+ RUBY_NUM_ROUND_HALF_DOWN,
36
+ RUBY_NUM_ROUND_DEFAULT = ROUND_DEFAULT,
37
+ };
38
+
39
+ struct RFloat {
40
+ struct RBasic basic;
41
+ double float_value;
42
+ };
43
+
44
+ #define RFLOAT(obj) (R_CAST(RFloat)(obj))
45
+
46
+ /* numeric.c */
47
+ int rb_num_to_uint(VALUE val, unsigned int *ret);
48
+ VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
49
+ double ruby_float_step_size(double beg, double end, double unit, int excl);
50
+ int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless);
51
+ int rb_num_negative_p(VALUE);
52
+ VALUE rb_int_succ(VALUE num);
53
+ VALUE rb_int_uminus(VALUE num);
54
+ VALUE rb_float_uminus(VALUE num);
55
+ VALUE rb_int_plus(VALUE x, VALUE y);
56
+ VALUE rb_float_plus(VALUE x, VALUE y);
57
+ VALUE rb_int_minus(VALUE x, VALUE y);
58
+ VALUE rb_int_mul(VALUE x, VALUE y);
59
+ VALUE rb_float_mul(VALUE x, VALUE y);
60
+ VALUE rb_float_div(VALUE x, VALUE y);
61
+ VALUE rb_int_idiv(VALUE x, VALUE y);
62
+ VALUE rb_int_modulo(VALUE x, VALUE y);
63
+ VALUE rb_int2str(VALUE num, int base);
64
+ VALUE rb_fix_plus(VALUE x, VALUE y);
65
+ VALUE rb_int_gt(VALUE x, VALUE y);
66
+ VALUE rb_float_gt(VALUE x, VALUE y);
67
+ VALUE rb_int_ge(VALUE x, VALUE y);
68
+ enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
69
+ double rb_int_fdiv_double(VALUE x, VALUE y);
70
+ VALUE rb_int_pow(VALUE x, VALUE y);
71
+ VALUE rb_float_pow(VALUE x, VALUE y);
72
+ VALUE rb_int_cmp(VALUE x, VALUE y);
73
+ VALUE rb_int_equal(VALUE x, VALUE y);
74
+ VALUE rb_int_divmod(VALUE x, VALUE y);
75
+ VALUE rb_int_and(VALUE x, VALUE y);
76
+ VALUE rb_int_lshift(VALUE x, VALUE y);
77
+ VALUE rb_int_div(VALUE x, VALUE y);
78
+ VALUE rb_int_abs(VALUE num);
79
+ VALUE rb_int_odd_p(VALUE num);
80
+ int rb_int_positive_p(VALUE num);
81
+ int rb_int_negative_p(VALUE num);
82
+ VALUE rb_num_pow(VALUE x, VALUE y);
83
+ VALUE rb_float_ceil(VALUE num, int ndigits);
84
+ VALUE rb_float_abs(VALUE flt);
85
+ static inline VALUE rb_num_compare_with_zero(VALUE num, ID mid);
86
+ static inline int rb_num_positive_int_p(VALUE num);
87
+ static inline int rb_num_negative_int_p(VALUE num);
88
+ static inline double rb_float_flonum_value(VALUE v);
89
+ static inline double rb_float_noflonum_value(VALUE v);
90
+ static inline double rb_float_value_inline(VALUE v);
91
+ static inline VALUE rb_float_new_inline(double d);
92
+ static inline bool INT_POSITIVE_P(VALUE num);
93
+ static inline bool INT_NEGATIVE_P(VALUE num);
94
+ static inline bool FLOAT_ZERO_P(VALUE num);
95
+ #define rb_float_value rb_float_value_inline
96
+ #define rb_float_new rb_float_new_inline
97
+
98
+ RUBY_SYMBOL_EXPORT_BEGIN
99
+ /* numeric.c (export) */
100
+ VALUE rb_int_positive_pow(long x, unsigned long y);
101
+ RUBY_SYMBOL_EXPORT_END
102
+
103
+ MJIT_SYMBOL_EXPORT_BEGIN
104
+ VALUE rb_flo_div_flo(VALUE x, VALUE y);
105
+ double ruby_float_mod(double x, double y);
106
+ VALUE rb_float_equal(VALUE x, VALUE y);
107
+ int rb_float_cmp(VALUE x, VALUE y);
108
+ VALUE rb_float_eql(VALUE x, VALUE y);
109
+ VALUE rb_fix_aref(VALUE fix, VALUE idx);
110
+ MJIT_SYMBOL_EXPORT_END
111
+
112
+ static inline bool
113
+ INT_POSITIVE_P(VALUE num)
114
+ {
115
+ if (FIXNUM_P(num)) {
116
+ return FIXNUM_POSITIVE_P(num);
117
+ }
118
+ else {
119
+ return BIGNUM_POSITIVE_P(num);
120
+ }
121
+ }
122
+
123
+ static inline bool
124
+ INT_NEGATIVE_P(VALUE num)
125
+ {
126
+ if (FIXNUM_P(num)) {
127
+ return FIXNUM_NEGATIVE_P(num);
128
+ }
129
+ else {
130
+ return BIGNUM_NEGATIVE_P(num);
131
+ }
132
+ }
133
+
134
+ static inline bool
135
+ FLOAT_ZERO_P(VALUE num)
136
+ {
137
+ return RFLOAT_VALUE(num) == 0.0;
138
+ }
139
+
140
+ static inline VALUE
141
+ rb_num_compare_with_zero(VALUE num, ID mid)
142
+ {
143
+ VALUE zero = INT2FIX(0);
144
+ VALUE r = rb_check_funcall(num, mid, 1, &zero);
145
+ if (r == Qundef) {
146
+ rb_cmperr(num, zero);
147
+ }
148
+ return r;
149
+ }
150
+
151
+ static inline int
152
+ rb_num_positive_int_p(VALUE num)
153
+ {
154
+ const ID mid = '>';
155
+
156
+ if (FIXNUM_P(num)) {
157
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
158
+ return FIXNUM_POSITIVE_P(num);
159
+ }
160
+ else if (RB_TYPE_P(num, T_BIGNUM)) {
161
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
162
+ return BIGNUM_POSITIVE_P(num);
163
+ }
164
+ return RTEST(rb_num_compare_with_zero(num, mid));
165
+ }
166
+
167
+ static inline int
168
+ rb_num_negative_int_p(VALUE num)
169
+ {
170
+ const ID mid = '<';
171
+
172
+ if (FIXNUM_P(num)) {
173
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
174
+ return FIXNUM_NEGATIVE_P(num);
175
+ }
176
+ else if (RB_TYPE_P(num, T_BIGNUM)) {
177
+ if (rb_method_basic_definition_p(rb_cInteger, mid))
178
+ return BIGNUM_NEGATIVE_P(num);
179
+ }
180
+ return RTEST(rb_num_compare_with_zero(num, mid));
181
+ }
182
+
183
+ static inline double
184
+ rb_float_flonum_value(VALUE v)
185
+ {
186
+ #if USE_FLONUM
187
+ if (v != (VALUE)0x8000000000000002) { /* LIKELY */
188
+ union {
189
+ double d;
190
+ VALUE v;
191
+ } t;
192
+
193
+ VALUE b63 = (v >> 63);
194
+ /* e: xx1... -> 011... */
195
+ /* xx0... -> 100... */
196
+ /* ^b63 */
197
+ t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~(VALUE)0x03), 3);
198
+ return t.d;
199
+ }
200
+ #endif
201
+ return 0.0;
202
+ }
203
+
204
+ static inline double
205
+ rb_float_noflonum_value(VALUE v)
206
+ {
207
+ return RFLOAT(v)->float_value;
208
+ }
209
+
210
+ static inline double
211
+ rb_float_value_inline(VALUE v)
212
+ {
213
+ if (FLONUM_P(v)) {
214
+ return rb_float_flonum_value(v);
215
+ }
216
+ return rb_float_noflonum_value(v);
217
+ }
218
+
219
+ static inline VALUE
220
+ rb_float_new_inline(double d)
221
+ {
222
+ #if USE_FLONUM
223
+ union {
224
+ double d;
225
+ VALUE v;
226
+ } t;
227
+ int bits;
228
+
229
+ t.d = d;
230
+ bits = (int)((VALUE)(t.v >> 60) & 0x7);
231
+ /* bits contains 3 bits of b62..b60. */
232
+ /* bits - 3 = */
233
+ /* b011 -> b000 */
234
+ /* b100 -> b001 */
235
+
236
+ if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
237
+ !((bits-3) & ~0x01)) {
238
+ return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
239
+ }
240
+ else if (t.v == (VALUE)0) {
241
+ /* +0.0 */
242
+ return 0x8000000000000002;
243
+ }
244
+ /* out of range */
245
+ #endif
246
+ return rb_float_new_in_heap(d);
247
+ }
248
+
249
+ #endif /* INTERNAL_NUMERIC_H */