Skip to content

Commit d60d4eb

Browse files
committed
[GR-48942] Use the original RB_INT2FIX() and RUBY_FIXNUM_{MIN,MAX}
PullRequest: truffleruby/4019
2 parents eaf1483 + 81d281e commit d60d4eb

File tree

4 files changed

+3
-16
lines changed

4 files changed

+3
-16
lines changed

lib/cext/ABI_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2
1+
3

lib/cext/include/ruby/internal/arithmetic/fixnum.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@
4040
* represent is 4,611,686,018,427,387,904, which is not fixable. The
4141
* seemingly-strange "< FIXNUM_MAX + 1" expression below is due to this.
4242
*/
43-
#ifdef TRUFFLERUBY
44-
#define RB_POSFIXABLE(f) ((f) <= RUBY_FIXNUM_MAX)
45-
#else
4643
#define RB_POSFIXABLE(_) ((_) < RUBY_FIXNUM_MAX + 1)
47-
#endif
4844

4945
/**
5046
* Checks if the passed value is in range of fixnum, assuming it is a negative
@@ -55,15 +51,10 @@
5551
/** Checks if the passed value is in range of fixnum */
5652
#define RB_FIXABLE(_) (RB_POSFIXABLE(_) && RB_NEGFIXABLE(_))
5753

58-
#ifdef TRUFFLERUBY
59-
#define RUBY_FIXNUM_MAX LONG_MAX
60-
#define RUBY_FIXNUM_MIN LONG_MIN
61-
#else
6254
/** Maximum possible value that a fixnum can represent. */
6355
#define RUBY_FIXNUM_MAX (LONG_MAX / 2)
6456

6557
/** Minimum possible value that a fixnum can represent. */
6658
#define RUBY_FIXNUM_MIN (LONG_MIN / 2)
67-
#endif /* TRUFFLERUBY */
6859

6960
#endif /* RBIMPL_ARITHMETIC_FIXNUM_H */

lib/cext/include/ruby/internal/arithmetic/long.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ RBIMPL_ATTR_ARTIFICIAL()
120120
static inline VALUE
121121
RB_INT2FIX(long i)
122122
{
123-
#ifdef TRUFFLERUBY
124-
return rb_tr_longwrap(i);
125-
#else
126123
RBIMPL_ASSERT_OR_ASSUME(RB_FIXABLE(i));
127124

128125
/* :NOTE: VALUE can be wider than long. As j being unsigned, 2j+1 is fully
@@ -135,7 +132,6 @@ RB_INT2FIX(long i)
135132

136133
RBIMPL_ASSERT_OR_ASSUME(RB_FIXNUM_P(n));
137134
return n;
138-
#endif
139135
}
140136

141137
/**

src/main/c/cext/integer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,6 @@ int rb_absint_singlebit_p(VALUE val) {
157157
}
158158

159159
VALUE rb_int2big(intptr_t n) {
160-
// it cannot overflow Fixnum
161-
return LONG2FIX(n);
160+
// intptr_t is the same as long
161+
return rb_tr_longwrap(n);
162162
}

0 commit comments

Comments
 (0)