bit-twiddle 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/README.md +3 -4
- data/ext/bit_twiddle/Makefile +266 -0
- data/ext/bit_twiddle/bit_twiddle.c +1879 -0
- data/ext/bit_twiddle/bit_twiddle.o +0 -0
- data/ext/bit_twiddle/bit_twiddle.so +0 -0
- data/ext/bit_twiddle/extconf.rb +26 -6
- data/ext/bit_twiddle/mkmf.log +270 -0
- data/ext/bit_twiddle/ruby22/bt_bignum.h +61 -0
- data/ext/bit_twiddle/ruby23/bt_bignum.h +52 -0
- data/ext/bit_twiddle/ruby30/bt_bignum.h +83 -0
- data/lib/bit-twiddle/core_ext.rb +2 -0
- data/lib/bit_twiddle.so +0 -0
- metadata +24 -17
Binary file
|
Binary file
|
data/ext/bit_twiddle/extconf.rb
CHANGED
@@ -2,13 +2,28 @@ require 'mkmf'
|
|
2
2
|
|
3
3
|
dir = File.dirname(__FILE__)
|
4
4
|
|
5
|
-
|
5
|
+
# allow 'CC' env variable to override the compiler used
|
6
|
+
if ENV['CC']
|
7
|
+
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC']
|
8
|
+
end
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
$CFLAGS << ' -Wall ' # turn on all warnings for more thorough code checking
|
11
|
+
# for clang; generated Makefile contains GCC-specific -W options which clang doesn't understand
|
12
|
+
$CFLAGS << ' -Wno-unknown-warning-option '
|
13
|
+
# for clang; ruby.h contains __error__ and __deprecated__, which clang chokes on
|
14
|
+
$CFLAGS << ' -Wno-unknown-attributes -Wno-ignored-attributes '
|
15
|
+
$CFLAGS << ' -Werror ' # convert all warnings to errors so we can't ignore them
|
16
|
+
$CFLAGS << ' -O3 -march=native -mtune=native ' # full optimization
|
17
|
+
$CFLAGS << ' -std=c99 ' # use a modern version of the C standard
|
18
|
+
|
19
|
+
if RUBY_ENGINE == 'rbx'
|
20
|
+
raise "bit-twiddle does not support Rubinius. Sorry!"
|
21
|
+
elsif RUBY_VERSION < '2.3.0'
|
11
22
|
$CFLAGS << " -I#{File.join(dir, 'ruby22')} "
|
23
|
+
elsif RUBY_VERSION < '3.0.0'
|
24
|
+
$CFLAGS << " -I#{File.join(dir, 'ruby23')} "
|
25
|
+
else
|
26
|
+
$CFLAGS << " -I#{File.join(dir, 'ruby30')} "
|
12
27
|
end
|
13
28
|
|
14
29
|
check_sizeof 'short'
|
@@ -16,6 +31,11 @@ check_sizeof 'int'
|
|
16
31
|
check_sizeof 'long'
|
17
32
|
check_sizeof 'long long'
|
18
33
|
|
34
|
+
# if we already have ulong, HAVE_TYPE_ULONG will be defined as a macro
|
35
|
+
have_type 'ulong'
|
36
|
+
# likewise for uchar
|
37
|
+
have_type 'uchar'
|
38
|
+
|
19
39
|
checking_for("whether >> on a signed long is arithmetic shift or logical shift", "%s") do
|
20
40
|
is_arith = try_static_assert("(-1L >> (sizeof(long)/8)) == -1L")
|
21
41
|
$defs.push("-DRSHIFT_IS_ARITH=#{is_arith ? '1' : '0'}")
|
@@ -28,4 +48,4 @@ checking_for("presence of __builtin_bswap16", "%s") do
|
|
28
48
|
have_bswap16 ? "oh yeah" : "nope...but we can sure fix that"
|
29
49
|
end
|
30
50
|
|
31
|
-
create_makefile 'bit_twiddle'
|
51
|
+
create_makefile 'bit_twiddle'
|
@@ -0,0 +1,270 @@
|
|
1
|
+
check_sizeof: checking size of short... -------------------- 2
|
2
|
+
|
3
|
+
"gcc -o conftest -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 conftest.c -L. -L/home/alex/.rbenv/versions/2.7.2/lib -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L. -L/home/alex/.rbenv/versions/2.7.2/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L/home/alex/.rbenv/versions/2.7.2/lib -lruby -lm -lc"
|
4
|
+
checked program was:
|
5
|
+
/* begin */
|
6
|
+
1: #include "ruby.h"
|
7
|
+
2:
|
8
|
+
3: int main(int argc, char **argv)
|
9
|
+
4: {
|
10
|
+
5: return !!argv[argc];
|
11
|
+
6: }
|
12
|
+
/* end */
|
13
|
+
|
14
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
15
|
+
conftest.c:7:5: error: size of array ‘conftest_const’ is negative
|
16
|
+
7 | int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
17
|
+
| ^~~~~~~~~~~~~~
|
18
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-attributes’ [-Werror]
|
19
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
|
20
|
+
cc1: error: unrecognized command line option ‘-Wno-self-assign’ [-Werror]
|
21
|
+
cc1: error: unrecognized command line option ‘-Wno-parentheses-equality’ [-Werror]
|
22
|
+
cc1: error: unrecognized command line option ‘-Wno-constant-logical-operand’ [-Werror]
|
23
|
+
cc1: all warnings being treated as errors
|
24
|
+
checked program was:
|
25
|
+
/* begin */
|
26
|
+
1: #include "ruby.h"
|
27
|
+
2:
|
28
|
+
3: typedef short rbcv_typedef_;
|
29
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
30
|
+
5:
|
31
|
+
6: /*top*/
|
32
|
+
7: int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
33
|
+
/* end */
|
34
|
+
|
35
|
+
"gcc -o conftest -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 conftest.c -L. -L/home/alex/.rbenv/versions/2.7.2/lib -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L. -L/home/alex/.rbenv/versions/2.7.2/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L/home/alex/.rbenv/versions/2.7.2/lib -lruby -lm -lc"
|
36
|
+
checked program was:
|
37
|
+
/* begin */
|
38
|
+
1: #include "ruby.h"
|
39
|
+
2:
|
40
|
+
3: typedef short rbcv_typedef_;
|
41
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
42
|
+
5:
|
43
|
+
6: #include <stdio.h>
|
44
|
+
7: /*top*/
|
45
|
+
8: typedef unsigned
|
46
|
+
9: #ifdef PRI_LL_PREFIX
|
47
|
+
10: #define PRI_CONFTEST_PREFIX PRI_LL_PREFIX
|
48
|
+
11: LONG_LONG
|
49
|
+
12: #else
|
50
|
+
13: #define PRI_CONFTEST_PREFIX "l"
|
51
|
+
14: long
|
52
|
+
15: #endif
|
53
|
+
16: conftest_type;
|
54
|
+
17: conftest_type conftest_const = (conftest_type)(sizeof((*rbcv_ptr_)));
|
55
|
+
18: int main() {printf("%"PRI_CONFTEST_PREFIX"u\n", conftest_const); return 0;}
|
56
|
+
/* end */
|
57
|
+
|
58
|
+
./conftest |
|
59
|
+
--------------------
|
60
|
+
|
61
|
+
check_sizeof: checking size of int... -------------------- 4
|
62
|
+
|
63
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
64
|
+
conftest.c:7:5: error: size of array ‘conftest_const’ is negative
|
65
|
+
7 | int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
66
|
+
| ^~~~~~~~~~~~~~
|
67
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-attributes’ [-Werror]
|
68
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
|
69
|
+
cc1: error: unrecognized command line option ‘-Wno-self-assign’ [-Werror]
|
70
|
+
cc1: error: unrecognized command line option ‘-Wno-parentheses-equality’ [-Werror]
|
71
|
+
cc1: error: unrecognized command line option ‘-Wno-constant-logical-operand’ [-Werror]
|
72
|
+
cc1: all warnings being treated as errors
|
73
|
+
checked program was:
|
74
|
+
/* begin */
|
75
|
+
1: #include "ruby.h"
|
76
|
+
2:
|
77
|
+
3: typedef int rbcv_typedef_;
|
78
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
79
|
+
5:
|
80
|
+
6: /*top*/
|
81
|
+
7: int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
82
|
+
/* end */
|
83
|
+
|
84
|
+
"gcc -o conftest -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 conftest.c -L. -L/home/alex/.rbenv/versions/2.7.2/lib -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L. -L/home/alex/.rbenv/versions/2.7.2/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L/home/alex/.rbenv/versions/2.7.2/lib -lruby -lm -lc"
|
85
|
+
checked program was:
|
86
|
+
/* begin */
|
87
|
+
1: #include "ruby.h"
|
88
|
+
2:
|
89
|
+
3: typedef int rbcv_typedef_;
|
90
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
91
|
+
5:
|
92
|
+
6: #include <stdio.h>
|
93
|
+
7: /*top*/
|
94
|
+
8: typedef unsigned
|
95
|
+
9: #ifdef PRI_LL_PREFIX
|
96
|
+
10: #define PRI_CONFTEST_PREFIX PRI_LL_PREFIX
|
97
|
+
11: LONG_LONG
|
98
|
+
12: #else
|
99
|
+
13: #define PRI_CONFTEST_PREFIX "l"
|
100
|
+
14: long
|
101
|
+
15: #endif
|
102
|
+
16: conftest_type;
|
103
|
+
17: conftest_type conftest_const = (conftest_type)(sizeof((*rbcv_ptr_)));
|
104
|
+
18: int main() {printf("%"PRI_CONFTEST_PREFIX"u\n", conftest_const); return 0;}
|
105
|
+
/* end */
|
106
|
+
|
107
|
+
./conftest |
|
108
|
+
--------------------
|
109
|
+
|
110
|
+
check_sizeof: checking size of long... -------------------- 8
|
111
|
+
|
112
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
113
|
+
conftest.c:7:5: error: size of array ‘conftest_const’ is negative
|
114
|
+
7 | int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
115
|
+
| ^~~~~~~~~~~~~~
|
116
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-attributes’ [-Werror]
|
117
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
|
118
|
+
cc1: error: unrecognized command line option ‘-Wno-self-assign’ [-Werror]
|
119
|
+
cc1: error: unrecognized command line option ‘-Wno-parentheses-equality’ [-Werror]
|
120
|
+
cc1: error: unrecognized command line option ‘-Wno-constant-logical-operand’ [-Werror]
|
121
|
+
cc1: all warnings being treated as errors
|
122
|
+
checked program was:
|
123
|
+
/* begin */
|
124
|
+
1: #include "ruby.h"
|
125
|
+
2:
|
126
|
+
3: typedef long rbcv_typedef_;
|
127
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
128
|
+
5:
|
129
|
+
6: /*top*/
|
130
|
+
7: int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
131
|
+
/* end */
|
132
|
+
|
133
|
+
"gcc -o conftest -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 conftest.c -L. -L/home/alex/.rbenv/versions/2.7.2/lib -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L. -L/home/alex/.rbenv/versions/2.7.2/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L/home/alex/.rbenv/versions/2.7.2/lib -lruby -lm -lc"
|
134
|
+
checked program was:
|
135
|
+
/* begin */
|
136
|
+
1: #include "ruby.h"
|
137
|
+
2:
|
138
|
+
3: typedef long rbcv_typedef_;
|
139
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
140
|
+
5:
|
141
|
+
6: #include <stdio.h>
|
142
|
+
7: /*top*/
|
143
|
+
8: typedef unsigned
|
144
|
+
9: #ifdef PRI_LL_PREFIX
|
145
|
+
10: #define PRI_CONFTEST_PREFIX PRI_LL_PREFIX
|
146
|
+
11: LONG_LONG
|
147
|
+
12: #else
|
148
|
+
13: #define PRI_CONFTEST_PREFIX "l"
|
149
|
+
14: long
|
150
|
+
15: #endif
|
151
|
+
16: conftest_type;
|
152
|
+
17: conftest_type conftest_const = (conftest_type)(sizeof((*rbcv_ptr_)));
|
153
|
+
18: int main() {printf("%"PRI_CONFTEST_PREFIX"u\n", conftest_const); return 0;}
|
154
|
+
/* end */
|
155
|
+
|
156
|
+
./conftest |
|
157
|
+
--------------------
|
158
|
+
|
159
|
+
check_sizeof: checking size of long long... -------------------- 8
|
160
|
+
|
161
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
162
|
+
conftest.c:7:5: error: size of array ‘conftest_const’ is negative
|
163
|
+
7 | int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
164
|
+
| ^~~~~~~~~~~~~~
|
165
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-attributes’ [-Werror]
|
166
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
|
167
|
+
cc1: error: unrecognized command line option ‘-Wno-self-assign’ [-Werror]
|
168
|
+
cc1: error: unrecognized command line option ‘-Wno-parentheses-equality’ [-Werror]
|
169
|
+
cc1: error: unrecognized command line option ‘-Wno-constant-logical-operand’ [-Werror]
|
170
|
+
cc1: all warnings being treated as errors
|
171
|
+
checked program was:
|
172
|
+
/* begin */
|
173
|
+
1: #include "ruby.h"
|
174
|
+
2:
|
175
|
+
3: typedef long long rbcv_typedef_;
|
176
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
177
|
+
5:
|
178
|
+
6: /*top*/
|
179
|
+
7: int conftest_const[(sizeof((*rbcv_ptr_)) < 0) ? 1 : -1];
|
180
|
+
/* end */
|
181
|
+
|
182
|
+
"gcc -o conftest -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 conftest.c -L. -L/home/alex/.rbenv/versions/2.7.2/lib -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L. -L/home/alex/.rbenv/versions/2.7.2/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/alex/.rbenv/versions/2.7.2/lib -L/home/alex/.rbenv/versions/2.7.2/lib -lruby -lm -lc"
|
183
|
+
checked program was:
|
184
|
+
/* begin */
|
185
|
+
1: #include "ruby.h"
|
186
|
+
2:
|
187
|
+
3: typedef long long rbcv_typedef_;
|
188
|
+
4: rbcv_typedef_ *rbcv_ptr_;
|
189
|
+
5:
|
190
|
+
6: #include <stdio.h>
|
191
|
+
7: /*top*/
|
192
|
+
8: typedef unsigned
|
193
|
+
9: #ifdef PRI_LL_PREFIX
|
194
|
+
10: #define PRI_CONFTEST_PREFIX PRI_LL_PREFIX
|
195
|
+
11: LONG_LONG
|
196
|
+
12: #else
|
197
|
+
13: #define PRI_CONFTEST_PREFIX "l"
|
198
|
+
14: long
|
199
|
+
15: #endif
|
200
|
+
16: conftest_type;
|
201
|
+
17: conftest_type conftest_const = (conftest_type)(sizeof((*rbcv_ptr_)));
|
202
|
+
18: int main() {printf("%"PRI_CONFTEST_PREFIX"u\n", conftest_const); return 0;}
|
203
|
+
/* end */
|
204
|
+
|
205
|
+
./conftest |
|
206
|
+
--------------------
|
207
|
+
|
208
|
+
have_type: checking for ulong... -------------------- yes
|
209
|
+
|
210
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
211
|
+
checked program was:
|
212
|
+
/* begin */
|
213
|
+
1: #include "ruby.h"
|
214
|
+
2:
|
215
|
+
3: /*top*/
|
216
|
+
4: typedef ulong conftest_type;
|
217
|
+
5: int conftestval[sizeof(conftest_type)?1:-1];
|
218
|
+
/* end */
|
219
|
+
|
220
|
+
--------------------
|
221
|
+
|
222
|
+
have_type: checking for uchar... -------------------- no
|
223
|
+
|
224
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
225
|
+
conftest.c:4:9: error: unknown type name ‘uchar’
|
226
|
+
4 | typedef uchar conftest_type;
|
227
|
+
| ^~~~~
|
228
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-attributes’ [-Werror]
|
229
|
+
cc1: error: unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror]
|
230
|
+
cc1: error: unrecognized command line option ‘-Wno-self-assign’ [-Werror]
|
231
|
+
cc1: error: unrecognized command line option ‘-Wno-parentheses-equality’ [-Werror]
|
232
|
+
cc1: error: unrecognized command line option ‘-Wno-constant-logical-operand’ [-Werror]
|
233
|
+
cc1: all warnings being treated as errors
|
234
|
+
checked program was:
|
235
|
+
/* begin */
|
236
|
+
1: #include "ruby.h"
|
237
|
+
2:
|
238
|
+
3: /*top*/
|
239
|
+
4: typedef uchar conftest_type;
|
240
|
+
5: int conftestval[sizeof(conftest_type)?1:-1];
|
241
|
+
/* end */
|
242
|
+
|
243
|
+
--------------------
|
244
|
+
|
245
|
+
checking for whether >> on a signed long is arithmetic shift or logical shift... -------------------- arithmetic
|
246
|
+
|
247
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
248
|
+
checked program was:
|
249
|
+
/* begin */
|
250
|
+
1: #include "ruby.h"
|
251
|
+
2:
|
252
|
+
3: /*top*/
|
253
|
+
4: int conftest_const[((-1L >> (sizeof(long)/8)) == -1L) ? 1 : -1];
|
254
|
+
/* end */
|
255
|
+
|
256
|
+
--------------------
|
257
|
+
|
258
|
+
checking for presence of __builtin_bswap16... -------------------- oh yeah
|
259
|
+
|
260
|
+
"gcc -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/x86_64-linux -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0/ruby/backward -I/home/alex/.rbenv/versions/2.7.2/include/ruby-2.7.0 -I. -I/home/alex/.rbenv/versions/2.7.2/include -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Wall -Wno-unknown-warning-option -Wno-unknown-attributes -Wno-ignored-attributes -Werror -O3 -march=native -mtune=native -std=c99 -I./ruby23 -c conftest.c"
|
261
|
+
checked program was:
|
262
|
+
/* begin */
|
263
|
+
1: #include "ruby.h"
|
264
|
+
2:
|
265
|
+
3: /*top*/
|
266
|
+
4: int conftest_const[(__builtin_bswap16(0xAABB) == 0xBBAA) ? 1 : -1];
|
267
|
+
/* end */
|
268
|
+
|
269
|
+
--------------------
|
270
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
|
3
|
+
# define BDIGIT unsigned int
|
4
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
5
|
+
#elif SIZEOF_INT*2 <= SIZEOF_LONG
|
6
|
+
# define BDIGIT unsigned int
|
7
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
8
|
+
#elif SIZEOF_SHORT*2 <= SIZEOF_LONG
|
9
|
+
# define BDIGIT unsigned short
|
10
|
+
# define SIZEOF_BDIGIT SIZEOF_SHORT
|
11
|
+
#else
|
12
|
+
# define BDIGIT unsigned short
|
13
|
+
# define SIZEOF_BDIGIT (SIZEOF_LONG/2)
|
14
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
|
15
|
+
#endif
|
16
|
+
#ifndef SIZEOF_ACTUAL_BDIGIT
|
17
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
|
18
|
+
#endif
|
19
|
+
|
20
|
+
#define FL_USHIFT 12
|
21
|
+
|
22
|
+
#define FL_USER0 (((VALUE)1)<<(FL_USHIFT+0))
|
23
|
+
#define FL_USER1 (((VALUE)1)<<(FL_USHIFT+1))
|
24
|
+
#define FL_USER2 (((VALUE)1)<<(FL_USHIFT+2))
|
25
|
+
#define FL_USER3 (((VALUE)1)<<(FL_USHIFT+3))
|
26
|
+
#define FL_USER4 (((VALUE)1)<<(FL_USHIFT+4))
|
27
|
+
#define FL_USER5 (((VALUE)1)<<(FL_USHIFT+5))
|
28
|
+
|
29
|
+
#define BIGNUM_EMBED_LEN_NUMBITS 3
|
30
|
+
#if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
|
31
|
+
# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
|
32
|
+
#else
|
33
|
+
# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
|
34
|
+
#endif
|
35
|
+
|
36
|
+
struct RBignum {
|
37
|
+
struct RBasic basic;
|
38
|
+
union {
|
39
|
+
struct {
|
40
|
+
size_t len;
|
41
|
+
BDIGIT *digits;
|
42
|
+
} heap;
|
43
|
+
BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
|
44
|
+
} as;
|
45
|
+
};
|
46
|
+
|
47
|
+
#define BIGNUM_EMBED_FLAG FL_USER2
|
48
|
+
#define BIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3)
|
49
|
+
#define BIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+BIGNUM_EMBED_LEN_NUMBITS)
|
50
|
+
#define RBIGNUM_LEN(b) \
|
51
|
+
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
52
|
+
(long)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \
|
53
|
+
(BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT)) : \
|
54
|
+
RBIGNUM(b)->as.heap.len)
|
55
|
+
/* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
|
56
|
+
#define RBIGNUM_DIGITS(b) \
|
57
|
+
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
58
|
+
RBIGNUM(b)->as.ary : \
|
59
|
+
RBIGNUM(b)->as.heap.digits)
|
60
|
+
|
61
|
+
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
|
3
|
+
# define BDIGIT unsigned int
|
4
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
5
|
+
#elif SIZEOF_INT*2 <= SIZEOF_LONG
|
6
|
+
# define BDIGIT unsigned int
|
7
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
8
|
+
#elif SIZEOF_SHORT*2 <= SIZEOF_LONG
|
9
|
+
# define BDIGIT unsigned short
|
10
|
+
# define SIZEOF_BDIGIT SIZEOF_SHORT
|
11
|
+
#else
|
12
|
+
# define BDIGIT unsigned short
|
13
|
+
# define SIZEOF_BDIGIT (SIZEOF_LONG/2)
|
14
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
|
15
|
+
#endif
|
16
|
+
#ifndef SIZEOF_ACTUAL_BDIGIT
|
17
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
|
18
|
+
#endif
|
19
|
+
|
20
|
+
#define BIGNUM_EMBED_LEN_NUMBITS 3
|
21
|
+
#if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
|
22
|
+
# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
|
23
|
+
#else
|
24
|
+
# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
|
25
|
+
#endif
|
26
|
+
|
27
|
+
struct RBignum {
|
28
|
+
struct RBasic basic;
|
29
|
+
union {
|
30
|
+
struct {
|
31
|
+
size_t len;
|
32
|
+
BDIGIT *digits;
|
33
|
+
} heap;
|
34
|
+
BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
|
35
|
+
} as;
|
36
|
+
};
|
37
|
+
|
38
|
+
#define BIGNUM_EMBED_FLAG FL_USER2
|
39
|
+
#define BIGNUM_EMBED_LEN_MASK (FL_USER5|FL_USER4|FL_USER3)
|
40
|
+
#define BIGNUM_EMBED_LEN_SHIFT (FL_USHIFT+BIGNUM_EMBED_LEN_NUMBITS)
|
41
|
+
#define RBIGNUM_LEN(b) \
|
42
|
+
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
43
|
+
(long)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \
|
44
|
+
(BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT)) : \
|
45
|
+
RBIGNUM(b)->as.heap.len)
|
46
|
+
/* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
|
47
|
+
#define RBIGNUM_DIGITS(b) \
|
48
|
+
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
49
|
+
RBIGNUM(b)->as.ary : \
|
50
|
+
RBIGNUM(b)->as.heap.digits)
|
51
|
+
|
52
|
+
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
|
2
|
+
# define BDIGIT unsigned int
|
3
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
4
|
+
#elif SIZEOF_INT*2 <= SIZEOF_LONG
|
5
|
+
# define BDIGIT unsigned int
|
6
|
+
# define SIZEOF_BDIGIT SIZEOF_INT
|
7
|
+
#elif SIZEOF_SHORT*2 <= SIZEOF_LONG
|
8
|
+
# define BDIGIT unsigned short
|
9
|
+
# define SIZEOF_BDIGIT SIZEOF_SHORT
|
10
|
+
#else
|
11
|
+
# define BDIGIT unsigned short
|
12
|
+
# define SIZEOF_BDIGIT (SIZEOF_LONG/2)
|
13
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
|
14
|
+
#endif
|
15
|
+
#ifndef SIZEOF_ACTUAL_BDIGIT
|
16
|
+
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#define RBIGNUM(obj) ((struct RBignum *)(obj))
|
20
|
+
#define BIGNUM_SIGN_BIT FL_USER1
|
21
|
+
#define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
|
22
|
+
#define BIGNUM_EMBED_LEN_NUMBITS 3
|
23
|
+
#define BIGNUM_EMBED_LEN_MASK \
|
24
|
+
(~(~(VALUE)0U << BIGNUM_EMBED_LEN_NUMBITS) << BIGNUM_EMBED_LEN_SHIFT)
|
25
|
+
#define BIGNUM_EMBED_LEN_SHIFT \
|
26
|
+
(FL_USHIFT+3) /* bit offset of BIGNUM_EMBED_LEN_MASK */
|
27
|
+
#ifndef BIGNUM_EMBED_LEN_MAX
|
28
|
+
# if (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
|
29
|
+
# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT)
|
30
|
+
# else
|
31
|
+
# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
|
32
|
+
# endif
|
33
|
+
#endif
|
34
|
+
|
35
|
+
struct RBignum {
|
36
|
+
struct RBasic basic;
|
37
|
+
union {
|
38
|
+
struct {
|
39
|
+
size_t len;
|
40
|
+
BDIGIT *digits;
|
41
|
+
} heap;
|
42
|
+
BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
|
43
|
+
} as;
|
44
|
+
};
|
45
|
+
|
46
|
+
static inline size_t BIGNUM_LEN(VALUE b);
|
47
|
+
static inline BDIGIT *BIGNUM_DIGITS(VALUE b);
|
48
|
+
static inline bool BIGNUM_EMBED_P(VALUE b);
|
49
|
+
|
50
|
+
static inline size_t
|
51
|
+
BIGNUM_LEN(VALUE b)
|
52
|
+
{
|
53
|
+
if (! BIGNUM_EMBED_P(b)) {
|
54
|
+
return RBIGNUM(b)->as.heap.len;
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
size_t ret = RBASIC(b)->flags;
|
58
|
+
ret &= BIGNUM_EMBED_LEN_MASK;
|
59
|
+
ret >>= BIGNUM_EMBED_LEN_SHIFT;
|
60
|
+
return ret;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
/* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
|
65
|
+
static inline BDIGIT *
|
66
|
+
BIGNUM_DIGITS(VALUE b)
|
67
|
+
{
|
68
|
+
if (BIGNUM_EMBED_P(b)) {
|
69
|
+
return RBIGNUM(b)->as.ary;
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
return RBIGNUM(b)->as.heap.digits;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
static inline bool
|
77
|
+
BIGNUM_EMBED_P(VALUE b)
|
78
|
+
{
|
79
|
+
return FL_TEST_RAW(b, BIGNUM_EMBED_FLAG);
|
80
|
+
}
|
81
|
+
|
82
|
+
#define RBIGNUM_DIGITS BIGNUM_DIGITS
|
83
|
+
#define RBIGNUM_LEN BIGNUM_LEN
|