mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* include/ruby/ruby.h: IL32LLP64 support.
* bignum.c (bigfixize, rb_cstr_to_inum): ditto. * insns.def (opt_plus, opt_minus, opt_mult): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9315740101
commit
c179584ba4
4 changed files with 34 additions and 14 deletions
|
@ -1,3 +1,11 @@
|
|||
Tue Jun 26 15:21:20 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* include/ruby/ruby.h: IL32LLP64 support.
|
||||
|
||||
* bignum.c (bigfixize, rb_cstr_to_inum): ditto.
|
||||
|
||||
* insns.def (opt_plus, opt_minus, opt_mult): ditto.
|
||||
|
||||
Tue Jun 26 15:04:06 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* cont.c (rb_fiber_s_new): revert initializing VM stack.
|
||||
|
|
6
bignum.c
6
bignum.c
|
@ -107,8 +107,8 @@ bigfixize(VALUE x)
|
|||
long len = RBIGNUM(x)->len;
|
||||
BDIGIT *ds = BDIGITS(x);
|
||||
|
||||
if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
|
||||
SIGNED_VALUE num = 0;
|
||||
if (len*SIZEOF_BDIGITS <= sizeof(long)) {
|
||||
long num = 0;
|
||||
while (len--) {
|
||||
num = BIGUP(num) + ds[len];
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
|
|||
}
|
||||
len *= strlen(str)*sizeof(char);
|
||||
|
||||
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
|
||||
if (len <= (sizeof(long)*CHAR_BIT)) {
|
||||
unsigned long val = strtoul(str, &end, base);
|
||||
|
||||
if (str < end && *end == '_') goto bigparse;
|
||||
|
|
|
@ -151,13 +151,8 @@ typedef unsigned LONG_LONG ID;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef LONG_LONG_VALUE
|
||||
# define FIXNUM_MAX (LLONG_MAX>>1)
|
||||
# define FIXNUM_MIN RSHIFT((LONG_LONG)LLONG_MIN,1)
|
||||
#else
|
||||
# define FIXNUM_MAX (LONG_MAX>>1)
|
||||
# define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
|
||||
#endif
|
||||
#define FIXNUM_MAX (LONG_MAX>>1)
|
||||
#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
|
||||
|
||||
#define FIXNUM_FLAG 0x01
|
||||
#define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
|
||||
|
|
25
insns.def
25
insns.def
|
@ -1623,12 +1623,25 @@ opt_plus
|
|||
else if (FIXNUM_2_P(recv, obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_PLUS)) {
|
||||
/* fixnum + fixnum */
|
||||
#ifndef LONG_LONG_VALUE
|
||||
val = (recv + (obj & (~1)));
|
||||
if ((~(recv ^ obj) & (recv ^ val)) &
|
||||
((VALUE)0x01 << ((sizeof(VALUE) * CHAR_BIT) - 1))) {
|
||||
val = rb_big_plus(rb_int2big(FIX2INT(recv)),
|
||||
rb_int2big(FIX2INT(obj)));
|
||||
}
|
||||
#else
|
||||
long a, b, c;
|
||||
a = FIX2LONG(recv);
|
||||
b = FIX2LONG(obj);
|
||||
c = a + b;
|
||||
if (FIXABLE(c)) {
|
||||
val = LONG2FIX(c);
|
||||
}
|
||||
else {
|
||||
val = rb_big_plus(rb_int2big(a), rb_int2big(b));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1686,9 +1699,11 @@ opt_minus
|
|||
a = FIX2LONG(recv);
|
||||
b = FIX2LONG(obj);
|
||||
c = a - b;
|
||||
val = LONG2FIX(c);
|
||||
|
||||
if (FIX2LONG(val) != c) {
|
||||
if (FIXABLE(c)) {
|
||||
val = LONG2FIX(c);
|
||||
}
|
||||
else {
|
||||
val = rb_big_minus(rb_int2big(a), rb_int2big(b));
|
||||
}
|
||||
}
|
||||
|
@ -1722,9 +1737,11 @@ opt_mult
|
|||
else {
|
||||
b = FIX2LONG(obj);
|
||||
c = a * b;
|
||||
val = LONG2FIX(c);
|
||||
|
||||
if (FIX2LONG(val) != c || c / a != b) {
|
||||
if (FIXABLE(c) && c / a == b) {
|
||||
val = LONG2FIX(c);
|
||||
}
|
||||
else {
|
||||
val = rb_big_mul(rb_int2big(a), rb_int2big(b));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue