* bignum.c (bdigit_roomof): Use SIZEOF_BDIGITS.
(bigfixize): Refine an ifdef condition. (rb_absint_size): Use bdigit_roomof. (rb_absint_singlebit_p): Ditto. (rb_integer_pack): Ditto. (integer_pack_fill_dd): Use BITSPERDIG. (integer_unpack_push_bits): Use BITSPERDIG, BIGLO and BIGDN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a30d9f9e1e
commit
a5b0cace63
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Thu Jun 20 01:34:15 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (bdigit_roomof): Use SIZEOF_BDIGITS.
|
||||||
|
(bigfixize): Refine an ifdef condition.
|
||||||
|
(rb_absint_size): Use bdigit_roomof.
|
||||||
|
(rb_absint_singlebit_p): Ditto.
|
||||||
|
(rb_integer_pack): Ditto.
|
||||||
|
(integer_pack_fill_dd): Use BITSPERDIG.
|
||||||
|
(integer_unpack_push_bits): Use BITSPERDIG, BIGLO and BIGDN.
|
||||||
|
|
||||||
Thu Jun 20 01:07:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Jun 20 01:07:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* gc.c (MARKED_IN_BITMAP, FL_TEST2): return boolean value since always
|
* gc.c (MARKED_IN_BITMAP, FL_TEST2): return boolean value since always
|
||||||
|
22
bignum.c
22
bignum.c
@ -54,7 +54,7 @@ static VALUE big_three = Qnil;
|
|||||||
|
|
||||||
#define BIGDIVREM_EXTRA_WORDS 2
|
#define BIGDIVREM_EXTRA_WORDS 2
|
||||||
#define roomof(n, m) ((int)(((n)+(m)-1) / (m)))
|
#define roomof(n, m) ((int)(((n)+(m)-1) / (m)))
|
||||||
#define bdigit_roomof(n) roomof(n, sizeof(BDIGIT))
|
#define bdigit_roomof(n) roomof(n, SIZEOF_BDIGITS)
|
||||||
#define BARY_ARGS(ary) ary, numberof(ary)
|
#define BARY_ARGS(ary) ary, numberof(ary)
|
||||||
|
|
||||||
#define BARY_ADD(z, x, y) bary_add(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
|
#define BARY_ADD(z, x, y) bary_add(BARY_ARGS(z), BARY_ARGS(x), BARY_ARGS(y))
|
||||||
@ -295,7 +295,7 @@ bigfixize(VALUE x)
|
|||||||
if (len == 0) return INT2FIX(0);
|
if (len == 0) return INT2FIX(0);
|
||||||
if (rb_absint_size(x, NULL) <= sizeof(long)) {
|
if (rb_absint_size(x, NULL) <= sizeof(long)) {
|
||||||
long num = 0;
|
long num = 0;
|
||||||
#if 2*SIZEOF_BDIGITS > SIZEOF_LONG
|
#if SIZEOF_BDIGITS >= SIZEOF_LONG
|
||||||
num = (long)ds[0];
|
num = (long)ds[0];
|
||||||
#else
|
#else
|
||||||
while (len--) {
|
while (len--) {
|
||||||
@ -542,7 +542,7 @@ rb_absint_size(VALUE val, int *nlz_bits_ret)
|
|||||||
{
|
{
|
||||||
BDIGIT *dp;
|
BDIGIT *dp;
|
||||||
BDIGIT *de;
|
BDIGIT *de;
|
||||||
BDIGIT fixbuf[(sizeof(long) + SIZEOF_BDIGITS - 1) / SIZEOF_BDIGITS];
|
BDIGIT fixbuf[bdigit_roomof(sizeof(long))];
|
||||||
|
|
||||||
int num_leading_zeros;
|
int num_leading_zeros;
|
||||||
|
|
||||||
@ -707,7 +707,7 @@ rb_absint_singlebit_p(VALUE val)
|
|||||||
{
|
{
|
||||||
BDIGIT *dp;
|
BDIGIT *dp;
|
||||||
BDIGIT *de;
|
BDIGIT *de;
|
||||||
BDIGIT fixbuf[(sizeof(long) + SIZEOF_BDIGITS - 1) / SIZEOF_BDIGITS];
|
BDIGIT fixbuf[bdigit_roomof(sizeof(long))];
|
||||||
BDIGIT d;
|
BDIGIT d;
|
||||||
|
|
||||||
val = rb_to_int(val);
|
val = rb_to_int(val);
|
||||||
@ -857,9 +857,9 @@ integer_pack_loop_setup(
|
|||||||
static inline void
|
static inline void
|
||||||
integer_pack_fill_dd(BDIGIT **dpp, BDIGIT **dep, BDIGIT_DBL *ddp, int *numbits_in_dd_p)
|
integer_pack_fill_dd(BDIGIT **dpp, BDIGIT **dep, BDIGIT_DBL *ddp, int *numbits_in_dd_p)
|
||||||
{
|
{
|
||||||
if (*dpp < *dep && SIZEOF_BDIGITS * CHAR_BIT <= (int)sizeof(*ddp) * CHAR_BIT - *numbits_in_dd_p) {
|
if (*dpp < *dep && BITSPERDIG <= (int)sizeof(*ddp) * CHAR_BIT - *numbits_in_dd_p) {
|
||||||
*ddp |= (BDIGIT_DBL)(*(*dpp)++) << *numbits_in_dd_p;
|
*ddp |= (BDIGIT_DBL)(*(*dpp)++) << *numbits_in_dd_p;
|
||||||
*numbits_in_dd_p += SIZEOF_BDIGITS * CHAR_BIT;
|
*numbits_in_dd_p += BITSPERDIG;
|
||||||
}
|
}
|
||||||
else if (*dpp == *dep) {
|
else if (*dpp == *dep) {
|
||||||
/* higher bits are infinity zeros */
|
/* higher bits are infinity zeros */
|
||||||
@ -1112,7 +1112,7 @@ rb_integer_pack(VALUE val, void *words, size_t numwords, size_t wordsize, size_t
|
|||||||
int sign;
|
int sign;
|
||||||
BDIGIT *ds;
|
BDIGIT *ds;
|
||||||
size_t num_bdigits;
|
size_t num_bdigits;
|
||||||
BDIGIT fixbuf[(sizeof(long) + SIZEOF_BDIGITS - 1) / SIZEOF_BDIGITS];
|
BDIGIT fixbuf[bdigit_roomof(sizeof(long))];
|
||||||
|
|
||||||
RB_GC_GUARD(val) = rb_to_int(val);
|
RB_GC_GUARD(val) = rb_to_int(val);
|
||||||
|
|
||||||
@ -1245,10 +1245,10 @@ integer_unpack_push_bits(int data, int numbits, BDIGIT_DBL *ddp, int *numbits_in
|
|||||||
{
|
{
|
||||||
(*ddp) |= ((BDIGIT_DBL)data) << (*numbits_in_dd_p);
|
(*ddp) |= ((BDIGIT_DBL)data) << (*numbits_in_dd_p);
|
||||||
*numbits_in_dd_p += numbits;
|
*numbits_in_dd_p += numbits;
|
||||||
while (SIZEOF_BDIGITS*CHAR_BIT <= *numbits_in_dd_p) {
|
while (BITSPERDIG <= *numbits_in_dd_p) {
|
||||||
*(*dpp)++ = (BDIGIT)((*ddp) & (((BDIGIT_DBL)1 << (SIZEOF_BDIGITS*CHAR_BIT))-1));
|
*(*dpp)++ = BIGLO(*ddp);
|
||||||
*ddp >>= SIZEOF_BDIGITS*CHAR_BIT;
|
*ddp = BIGDN(*ddp);
|
||||||
*numbits_in_dd_p -= SIZEOF_BDIGITS*CHAR_BIT;
|
*numbits_in_dd_p -= BITSPERDIG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user