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,163 @@
1
+ #ifndef INTERNAL_ARRAY_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_ARRAY_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 Array.
10
+ */
11
+ #include "ruby/internal/config.h"
12
+ #include <stddef.h> /* for size_t */
13
+ #include "internal/static_assert.h" /* for STATIC_ASSERT */
14
+ #include "ruby/internal/stdbool.h" /* for bool */
15
+ #include "ruby/ruby.h" /* for RARRAY_LEN */
16
+
17
+ #ifndef ARRAY_DEBUG
18
+ # define ARRAY_DEBUG (0+RUBY_DEBUG)
19
+ #endif
20
+
21
+ #define RARRAY_SHARED_FLAG ELTS_SHARED
22
+ #define RARRAY_SHARED_ROOT_FLAG FL_USER12
23
+ #define RARRAY_PTR_IN_USE_FLAG FL_USER14
24
+
25
+ /* array.c */
26
+ VALUE rb_ary_last(int, const VALUE *, VALUE);
27
+ void rb_ary_set_len(VALUE, long);
28
+ void rb_ary_delete_same(VALUE, VALUE);
29
+ VALUE rb_ary_hidden_new_fill(long capa);
30
+ VALUE rb_ary_at(VALUE, VALUE);
31
+ size_t rb_ary_memsize(VALUE);
32
+ VALUE rb_to_array_type(VALUE obj);
33
+ VALUE rb_to_array(VALUE obj);
34
+ void rb_ary_cancel_sharing(VALUE ary);
35
+ size_t rb_ary_size_as_embedded(VALUE ary);
36
+ void rb_ary_make_embedded(VALUE ary);
37
+ bool rb_ary_embeddable_p(VALUE ary);
38
+ VALUE rb_ary_diff(VALUE ary1, VALUE ary2);
39
+
40
+ static inline VALUE rb_ary_entry_internal(VALUE ary, long offset);
41
+ static inline bool ARY_PTR_USING_P(VALUE ary);
42
+ static inline void RARY_TRANSIENT_SET(VALUE ary);
43
+ static inline void RARY_TRANSIENT_UNSET(VALUE ary);
44
+
45
+ MJIT_SYMBOL_EXPORT_BEGIN
46
+ VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
47
+ VALUE rb_check_to_array(VALUE ary);
48
+ VALUE rb_ary_behead(VALUE, long);
49
+ VALUE rb_ary_aref1(VALUE ary, VALUE i);
50
+
51
+ struct rb_execution_context_struct;
52
+ VALUE rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
53
+ MJIT_SYMBOL_EXPORT_END
54
+
55
+ // YJIT needs this function to never allocate and never raise
56
+ static inline VALUE
57
+ rb_ary_entry_internal(VALUE ary, long offset)
58
+ {
59
+ long len = RARRAY_LEN(ary);
60
+ const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
61
+ if (len == 0) return Qnil;
62
+ if (offset < 0) {
63
+ offset += len;
64
+ if (offset < 0) return Qnil;
65
+ }
66
+ else if (len <= offset) {
67
+ return Qnil;
68
+ }
69
+ return ptr[offset];
70
+ }
71
+
72
+ static inline bool
73
+ ARY_PTR_USING_P(VALUE ary)
74
+ {
75
+ return FL_TEST_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
76
+ }
77
+
78
+ RBIMPL_ATTR_MAYBE_UNUSED()
79
+ static inline int
80
+ ary_should_not_be_shared_and_embedded(VALUE ary)
81
+ {
82
+ return !FL_ALL_RAW(ary, RARRAY_SHARED_FLAG|RARRAY_EMBED_FLAG);
83
+ }
84
+
85
+ static inline bool
86
+ ARY_SHARED_P(VALUE ary)
87
+ {
88
+ assert(RB_TYPE_P(ary, T_ARRAY));
89
+ assert(ary_should_not_be_shared_and_embedded(ary));
90
+ return FL_TEST_RAW(ary, RARRAY_SHARED_FLAG);
91
+ }
92
+
93
+ static inline bool
94
+ ARY_EMBED_P(VALUE ary)
95
+ {
96
+ assert(RB_TYPE_P(ary, T_ARRAY));
97
+ assert(ary_should_not_be_shared_and_embedded(ary));
98
+ return FL_TEST_RAW(ary, RARRAY_EMBED_FLAG);
99
+ }
100
+
101
+ static inline VALUE
102
+ ARY_SHARED_ROOT(VALUE ary)
103
+ {
104
+ assert(ARY_SHARED_P(ary));
105
+ return RARRAY(ary)->as.heap.aux.shared_root;
106
+ }
107
+
108
+ static inline bool
109
+ ARY_SHARED_ROOT_P(VALUE ary)
110
+ {
111
+ assert(RB_TYPE_P(ary, T_ARRAY));
112
+ return FL_TEST_RAW(ary, RARRAY_SHARED_ROOT_FLAG);
113
+ }
114
+
115
+ static inline long
116
+ ARY_SHARED_ROOT_REFCNT(VALUE ary)
117
+ {
118
+ assert(ARY_SHARED_ROOT_P(ary));
119
+ return RARRAY(ary)->as.heap.aux.capa;
120
+ }
121
+
122
+ static inline void
123
+ RARY_TRANSIENT_SET(VALUE ary)
124
+ {
125
+ #if USE_TRANSIENT_HEAP
126
+ FL_SET_RAW(ary, RARRAY_TRANSIENT_FLAG);
127
+ #endif
128
+ }
129
+
130
+ static inline void
131
+ RARY_TRANSIENT_UNSET(VALUE ary)
132
+ {
133
+ #if USE_TRANSIENT_HEAP
134
+ FL_UNSET_RAW(ary, RARRAY_TRANSIENT_FLAG);
135
+ #endif
136
+ }
137
+
138
+ #undef rb_ary_new_from_args
139
+ #if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
140
+ # /* Skip it; clang -pedantic doesn't like the following */
141
+ #elif defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
142
+ #define rb_ary_new_from_args(n, ...) \
143
+ __extension__ ({ \
144
+ const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
145
+ if (__builtin_constant_p(n)) { \
146
+ STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
147
+ } \
148
+ rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
149
+ })
150
+ #endif
151
+
152
+ #undef RARRAY_AREF
153
+ RBIMPL_ATTR_PURE_UNLESS_DEBUG()
154
+ RBIMPL_ATTR_ARTIFICIAL()
155
+ static inline VALUE
156
+ RARRAY_AREF(VALUE ary, long i)
157
+ {
158
+ RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
159
+
160
+ return RARRAY_CONST_PTR_TRANSIENT(ary)[i];
161
+ }
162
+
163
+ #endif /* INTERNAL_ARRAY_H */
@@ -0,0 +1,246 @@
1
+ #ifndef INTERNAL_BIGNUM_H /*-*-C-*-vi:se ft=c:*/
2
+ #define INTERNAL_BIGNUM_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 Bignums.
10
+ */
11
+ #include "ruby/internal/config.h" /* for HAVE_LIBGMP */
12
+ #include <stddef.h> /* for size_t */
13
+
14
+ #ifdef HAVE_SYS_TYPES_H
15
+ # include <sys/types.h> /* for ssize_t (note: on Windows ssize_t is */
16
+ #endif /* `#define`d in ruby/config.h) */
17
+
18
+ #include "ruby/internal/stdbool.h" /* for bool */
19
+ #include "ruby/ruby.h" /* for struct RBasic */
20
+
21
+ #ifndef BDIGIT
22
+ # if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
23
+ # define BDIGIT unsigned int
24
+ # define SIZEOF_BDIGIT SIZEOF_INT
25
+ # define BDIGIT_DBL unsigned LONG_LONG
26
+ # define BDIGIT_DBL_SIGNED LONG_LONG
27
+ # define PRI_BDIGIT_PREFIX ""
28
+ # define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
29
+ # elif SIZEOF_INT*2 <= SIZEOF_LONG
30
+ # define BDIGIT unsigned int
31
+ # define SIZEOF_BDIGIT SIZEOF_INT
32
+ # define BDIGIT_DBL unsigned long
33
+ # define BDIGIT_DBL_SIGNED long
34
+ # define PRI_BDIGIT_PREFIX ""
35
+ # define PRI_BDIGIT_DBL_PREFIX "l"
36
+ # elif SIZEOF_SHORT*2 <= SIZEOF_LONG
37
+ # define BDIGIT unsigned short
38
+ # define SIZEOF_BDIGIT SIZEOF_SHORT
39
+ # define BDIGIT_DBL unsigned long
40
+ # define BDIGIT_DBL_SIGNED long
41
+ # define PRI_BDIGIT_PREFIX "h"
42
+ # define PRI_BDIGIT_DBL_PREFIX "l"
43
+ # else
44
+ # define BDIGIT unsigned short
45
+ # define SIZEOF_BDIGIT (SIZEOF_LONG/2)
46
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
47
+ # define BDIGIT_DBL unsigned long
48
+ # define BDIGIT_DBL_SIGNED long
49
+ # define PRI_BDIGIT_PREFIX "h"
50
+ # define PRI_BDIGIT_DBL_PREFIX "l"
51
+ # endif
52
+ #endif
53
+
54
+ #ifndef SIZEOF_ACTUAL_BDIGIT
55
+ # define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
56
+ #endif
57
+
58
+ #ifdef PRI_BDIGIT_PREFIX
59
+ # define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
60
+ # define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
61
+ # define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
62
+ # define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
63
+ # define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
64
+ # define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
65
+ #endif
66
+
67
+ #ifdef PRI_BDIGIT_DBL_PREFIX
68
+ # define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
69
+ # define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
70
+ # define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
71
+ # define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
72
+ # define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
73
+ # define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
74
+ #endif
75
+
76
+ #define RBIGNUM(obj) ((struct RBignum *)(obj))
77
+ #define BIGNUM_SIGN_BIT FL_USER1
78
+ #define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
79
+ #define BIGNUM_EMBED_LEN_NUMBITS 3
80
+ #define BIGNUM_EMBED_LEN_MASK \
81
+ (~(~(VALUE)0U << BIGNUM_EMBED_LEN_NUMBITS) << BIGNUM_EMBED_LEN_SHIFT)
82
+ #define BIGNUM_EMBED_LEN_SHIFT \
83
+ (FL_USHIFT+3) /* bit offset of BIGNUM_EMBED_LEN_MASK */
84
+ #ifndef BIGNUM_EMBED_LEN_MAX
85
+ # if (SIZEOF_VALUE*RBIMPL_RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
86
+ # define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*RBIMPL_RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT)
87
+ # else
88
+ # define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
89
+ # endif
90
+ #endif
91
+
92
+ enum rb_int_parse_flags {
93
+ RB_INT_PARSE_SIGN = 0x01,
94
+ RB_INT_PARSE_UNDERSCORE = 0x02,
95
+ RB_INT_PARSE_PREFIX = 0x04,
96
+ RB_INT_PARSE_ALL = 0x07,
97
+ RB_INT_PARSE_DEFAULT = 0x07,
98
+ };
99
+
100
+ struct RBignum {
101
+ struct RBasic basic;
102
+ union {
103
+ struct {
104
+ size_t len;
105
+ BDIGIT *digits;
106
+ } heap;
107
+ BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
108
+ } as;
109
+ };
110
+
111
+ /* bignum.c */
112
+ extern const char ruby_digitmap[];
113
+ double rb_big_fdiv_double(VALUE x, VALUE y);
114
+ VALUE rb_big_uminus(VALUE x);
115
+ VALUE rb_big_hash(VALUE);
116
+ VALUE rb_big_odd_p(VALUE);
117
+ VALUE rb_big_even_p(VALUE);
118
+ size_t rb_big_size(VALUE);
119
+ VALUE rb_integer_float_cmp(VALUE x, VALUE y);
120
+ VALUE rb_integer_float_eq(VALUE x, VALUE y);
121
+ VALUE rb_str_convert_to_inum(VALUE str, int base, int badcheck, int raise_exception);
122
+ VALUE rb_big_comp(VALUE x);
123
+ VALUE rb_big_aref(VALUE x, VALUE y);
124
+ VALUE rb_big_abs(VALUE x);
125
+ VALUE rb_big_size_m(VALUE big);
126
+ VALUE rb_big_bit_length(VALUE big);
127
+ VALUE rb_big_remainder(VALUE x, VALUE y);
128
+ VALUE rb_big_gt(VALUE x, VALUE y);
129
+ VALUE rb_big_ge(VALUE x, VALUE y);
130
+ VALUE rb_big_lt(VALUE x, VALUE y);
131
+ VALUE rb_big_le(VALUE x, VALUE y);
132
+ VALUE rb_int_powm(int const argc, VALUE * const argv, VALUE const num);
133
+ VALUE rb_big_isqrt(VALUE n);
134
+ static inline bool BIGNUM_SIGN(VALUE b);
135
+ static inline bool BIGNUM_POSITIVE_P(VALUE b);
136
+ static inline bool BIGNUM_NEGATIVE_P(VALUE b);
137
+ static inline void BIGNUM_SET_SIGN(VALUE b, bool sign);
138
+ static inline void BIGNUM_NEGATE(VALUE b);
139
+ static inline size_t BIGNUM_LEN(VALUE b);
140
+ static inline BDIGIT *BIGNUM_DIGITS(VALUE b);
141
+ static inline int BIGNUM_LENINT(VALUE b);
142
+ static inline bool BIGNUM_EMBED_P(VALUE b);
143
+
144
+ RUBY_SYMBOL_EXPORT_BEGIN
145
+ /* bignum.c (export) */
146
+ VALUE rb_big_mul_normal(VALUE x, VALUE y);
147
+ VALUE rb_big_mul_balance(VALUE x, VALUE y);
148
+ VALUE rb_big_mul_karatsuba(VALUE x, VALUE y);
149
+ VALUE rb_big_mul_toom3(VALUE x, VALUE y);
150
+ VALUE rb_big_sq_fast(VALUE x);
151
+ VALUE rb_big_divrem_normal(VALUE x, VALUE y);
152
+ VALUE rb_big2str_poweroftwo(VALUE x, int base);
153
+ VALUE rb_big2str_generic(VALUE x, int base);
154
+ VALUE rb_str2big_poweroftwo(VALUE arg, int base, int badcheck);
155
+ VALUE rb_str2big_normal(VALUE arg, int base, int badcheck);
156
+ VALUE rb_str2big_karatsuba(VALUE arg, int base, int badcheck);
157
+ #if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
158
+ VALUE rb_big_mul_gmp(VALUE x, VALUE y);
159
+ VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
160
+ VALUE rb_big2str_gmp(VALUE x, int base);
161
+ VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
162
+ #endif
163
+ VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
164
+ RUBY_SYMBOL_EXPORT_END
165
+
166
+ MJIT_SYMBOL_EXPORT_BEGIN
167
+ #if defined(HAVE_INT128_T)
168
+ VALUE rb_int128t2big(int128_t n);
169
+ #endif
170
+ MJIT_SYMBOL_EXPORT_END
171
+
172
+ /* sign: positive:1, negative:0 */
173
+ static inline bool
174
+ BIGNUM_SIGN(VALUE b)
175
+ {
176
+ return FL_TEST_RAW(b, BIGNUM_SIGN_BIT);
177
+ }
178
+
179
+ static inline bool
180
+ BIGNUM_POSITIVE_P(VALUE b)
181
+ {
182
+ return BIGNUM_SIGN(b);
183
+ }
184
+
185
+ static inline bool
186
+ BIGNUM_NEGATIVE_P(VALUE b)
187
+ {
188
+ return ! BIGNUM_POSITIVE_P(b);
189
+ }
190
+
191
+ static inline void
192
+ BIGNUM_SET_SIGN(VALUE b, bool sign)
193
+ {
194
+ if (sign) {
195
+ FL_SET_RAW(b, BIGNUM_SIGN_BIT);
196
+ }
197
+ else {
198
+ FL_UNSET_RAW(b, BIGNUM_SIGN_BIT);
199
+ }
200
+ }
201
+
202
+ static inline void
203
+ BIGNUM_NEGATE(VALUE b)
204
+ {
205
+ FL_REVERSE_RAW(b, BIGNUM_SIGN_BIT);
206
+ }
207
+
208
+ static inline size_t
209
+ BIGNUM_LEN(VALUE b)
210
+ {
211
+ if (! BIGNUM_EMBED_P(b)) {
212
+ return RBIGNUM(b)->as.heap.len;
213
+ }
214
+ else {
215
+ size_t ret = RBASIC(b)->flags;
216
+ ret &= BIGNUM_EMBED_LEN_MASK;
217
+ ret >>= BIGNUM_EMBED_LEN_SHIFT;
218
+ return ret;
219
+ }
220
+ }
221
+
222
+ static inline int
223
+ BIGNUM_LENINT(VALUE b)
224
+ {
225
+ return rb_long2int(BIGNUM_LEN(b));
226
+ }
227
+
228
+ /* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
229
+ static inline BDIGIT *
230
+ BIGNUM_DIGITS(VALUE b)
231
+ {
232
+ if (BIGNUM_EMBED_P(b)) {
233
+ return RBIGNUM(b)->as.ary;
234
+ }
235
+ else {
236
+ return RBIGNUM(b)->as.heap.digits;
237
+ }
238
+ }
239
+
240
+ static inline bool
241
+ BIGNUM_EMBED_P(VALUE b)
242
+ {
243
+ return FL_TEST_RAW(b, BIGNUM_EMBED_FLAG);
244
+ }
245
+
246
+ #endif /* INTERNAL_BIGNUM_H */