1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

use NUM2SIZET and SIZET2NUM

* configure.in: revert r41106.  size_t may not be unsigned

* bignum.c (rb_absint_size_in_word, rb_int_export, rb_int_import): use
  NUM2SIZET() and SIZET2NUM() already defined in ruby/ruby.h.

* ext/-test-/bignum/export.c (rb_int_export_m): ditto.

* ext/-test-/bignum/import.c (rb_int_import_m): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-06-07 02:41:45 +00:00
parent 432321d780
commit 147775ac2b
5 changed files with 19 additions and 12 deletions

View file

@ -1,3 +1,10 @@
Fri Jun 7 11:41:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in: revert r41106. size_t may not be unsigned
* bignum.c (rb_absint_size_in_word, rb_int_export, rb_int_import): use
NUM2SIZET() and SIZET2NUM() already defined in ruby/ruby.h.
Fri Jun 7 11:28:37 2013 Masaya Tarui <tarui@ruby-lang.org>
* gc.c: use oldgen bitmap as initial mark bitmap when mijor gc.

View file

@ -522,14 +522,14 @@ rb_absint_size_in_word(VALUE val, size_t word_numbits_arg, size_t *number_of_lea
div = RARRAY_AREF(div_mod, 0);
mod = RARRAY_AREF(div_mod, 1);
if (mod == LONG2FIX(0)) {
numwords = NUM2SIZE(div);
numwords = NUM2SIZET(div);
if (number_of_leading_zero_bits)
*number_of_leading_zero_bits = 0;
}
else {
numwords = NUM2SIZE(rb_funcall(div, '+', 1, LONG2FIX(1)));
numwords = NUM2SIZET(rb_funcall(div, '+', 1, LONG2FIX(1)));
if (number_of_leading_zero_bits)
*number_of_leading_zero_bits = word_numbits_arg - NUM2SIZE(mod);
*number_of_leading_zero_bits = word_numbits_arg - NUM2SIZET(mod);
}
return numwords;
}
@ -663,7 +663,7 @@ rb_int_export(VALUE val, int *signp, size_t *wordcount_allocated, void *words, s
wordcountv = rb_funcall(val_numbits, '+', 1, word_numbits);
wordcountv = rb_funcall(wordcountv, '-', 1, LONG2FIX(1));
wordcountv = rb_funcall(wordcountv, rb_intern("div"), 1, word_numbits);
wordcount = NUM2SIZE(wordcountv);
wordcount = NUM2SIZET(wordcountv);
buf = xmalloc(wordcount * wordsize);
bufend = buf + wordcount * wordsize;
}
@ -844,10 +844,10 @@ rb_int_import(int sign, const void *words, size_t wordcount, int wordorder, size
* num_bits = (wordsize * CHAR_BIT - nails) * count
* num_bdigits = (num_bits + SIZEOF_BDIGITS*CHAR_BIT - 1) / (SIZEOF_BDIGITS*CHAR_BIT)
*/
num_bits = SIZE2NUM(wordsize);
num_bits = SIZET2NUM(wordsize);
num_bits = rb_funcall(num_bits, '*', 1, LONG2FIX(CHAR_BIT));
num_bits = rb_funcall(num_bits, '-', 1, SIZE2NUM(nails));
num_bits = rb_funcall(num_bits, '*', 1, SIZE2NUM(wordcount));
num_bits = rb_funcall(num_bits, '-', 1, SIZET2NUM(nails));
num_bits = rb_funcall(num_bits, '*', 1, SIZET2NUM(wordcount));
if (num_bits == LONG2FIX(0))
return LONG2FIX(0);

View file

@ -1234,7 +1234,6 @@ RUBY_REPLACE_TYPE(gid_t, int, GIDT)
RUBY_REPLACE_TYPE(time_t, [], TIMET, [@%:@include <time.h>])
RUBY_REPLACE_TYPE(dev_t, [int long "long long"], DEVT)
RUBY_REPLACE_TYPE(mode_t, ["unsigned int" long], MODET, [@%:@include <sys/stat.h>])
RUBY_REPLACE_TYPE(size_t, ["unsigned int" "unsigned long" "unsigned long long"], SIZE)
RUBY_REPLACE_TYPE(rlim_t, [int long "long long"], RLIM, [
@%:@ifdef HAVE_SYS_TYPES_H
@%:@include <sys/types.h>
@ -1483,6 +1482,7 @@ fi
AC_TYPE_SIZE_T
RUBY_CHECK_SIZEOF(size_t, [int long void*], [], [@%:@include <sys/types.h>])
RUBY_CHECK_SIZEOF(ptrdiff_t, size_t, [], [@%:@include <stddef.h>])
RUBY_CHECK_PRINTF_PREFIX(size_t, z)
RUBY_CHECK_PRINTF_PREFIX(ptrdiff_t, t)
AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS

View file

@ -7,7 +7,7 @@ rb_int_export_m(VALUE val, VALUE buf, VALUE wordorder, VALUE wordsize_arg, VALUE
int sign;
size_t count = 0;
void *ret;
size_t wordsize = NUM2SIZE(wordsize_arg);
size_t wordsize = NUM2SIZET(wordsize_arg);
if (!NIL_P(buf)) {
StringValue(buf);
@ -19,7 +19,7 @@ rb_int_export_m(VALUE val, VALUE buf, VALUE wordorder, VALUE wordsize_arg, VALUE
&sign, &count, NIL_P(buf) ? NULL : RSTRING_PTR(buf), count,
NUM2INT(wordorder), wordsize, NUM2INT(endian), NUM2INT(nails));
return rb_ary_new_from_args(3, INT2NUM(sign), ret ? rb_str_new(ret, wordsize * count) : Qnil, SIZE2NUM(count));
return rb_ary_new_from_args(3, INT2NUM(sign), ret ? rb_str_new(ret, wordsize * count) : Qnil, SIZET2NUM(count));
}
void

View file

@ -7,8 +7,8 @@ rb_int_import_m(VALUE klass, VALUE sign, VALUE buf, VALUE wordcount, VALUE wordo
StringValue(buf);
return rb_int_import(NUM2INT(sign), RSTRING_PTR(buf),
NUM2SIZE(wordcount), NUM2INT(wordorder), NUM2SIZE(wordsize),
NUM2INT(endian), NUM2SIZE(nails));
NUM2SIZET(wordcount), NUM2INT(wordorder), NUM2SIZET(wordsize),
NUM2INT(endian), NUM2SIZET(nails));
}
void