summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--bignum.c14
-rw-r--r--configure.in2
-rw-r--r--ext/-test-/bignum/export.c4
-rw-r--r--ext/-test-/bignum/import.c4
5 files changed, 19 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 30ca0d6cce..1c7f93143c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/bignum.c b/bignum.c
index 159cded92b..e076acbfb5 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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);
diff --git a/configure.in b/configure.in
index 5b638c79b3..ff796bef5a 100644
--- a/configure.in
+++ b/configure.in
@@ -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
diff --git a/ext/-test-/bignum/export.c b/ext/-test-/bignum/export.c
index 33cc2d0a42..56e4f9f6dc 100644
--- a/ext/-test-/bignum/export.c
+++ b/ext/-test-/bignum/export.c
@@ -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
diff --git a/ext/-test-/bignum/import.c b/ext/-test-/bignum/import.c
index 22cc86dcde..c50d855c44 100644
--- a/ext/-test-/bignum/import.c
+++ b/ext/-test-/bignum/import.c
@@ -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