ruby-changes:29078
From: nobu <ko1@a...>
Date: Fri, 7 Jun 2013 11:41:57 +0900 (JST)
Subject: [ruby-changes:29078] nobu:r41130 (trunk): use NUM2SIZET and SIZET2NUM
nobu 2013-06-07 11:41:45 +0900 (Fri, 07 Jun 2013) New Revision: 41130 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41130 Log: 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. Modified files: trunk/ChangeLog trunk/bignum.c trunk/configure.in trunk/ext/-test-/bignum/export.c trunk/ext/-test-/bignum/import.c Index: configure.in =================================================================== --- configure.in (revision 41129) +++ configure.in (revision 41130) @@ -1234,7 +1234,6 @@ RUBY_REPLACE_TYPE(gid_t, int, GIDT) https://github.com/ruby/ruby/blob/trunk/configure.in#L1234 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 https://github.com/ruby/ruby/blob/trunk/configure.in#L1482 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 Index: ChangeLog =================================================================== --- ChangeLog (revision 41129) +++ ChangeLog (revision 41130) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 7 11:41:42 2013 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * gc.c: use oldgen bitmap as initial mark bitmap when mijor gc. Index: ext/-test-/bignum/export.c =================================================================== --- ext/-test-/bignum/export.c (revision 41129) +++ ext/-test-/bignum/export.c (revision 41130) @@ -7,7 +7,7 @@ rb_int_export_m(VALUE val, VALUE buf, VA https://github.com/ruby/ruby/blob/trunk/ext/-test-/bignum/export.c#L7 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, VA https://github.com/ruby/ruby/blob/trunk/ext/-test-/bignum/export.c#L19 &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 Index: ext/-test-/bignum/import.c =================================================================== --- ext/-test-/bignum/import.c (revision 41129) +++ ext/-test-/bignum/import.c (revision 41130) @@ -7,8 +7,8 @@ rb_int_import_m(VALUE klass, VALUE sign, https://github.com/ruby/ruby/blob/trunk/ext/-test-/bignum/import.c#L7 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 Index: bignum.c =================================================================== --- bignum.c (revision 41129) +++ bignum.c (revision 41130) @@ -522,14 +522,14 @@ rb_absint_size_in_word(VALUE val, size_t https://github.com/ruby/ruby/blob/trunk/bignum.c#L522 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, siz https://github.com/ruby/ruby/blob/trunk/bignum.c#L663 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 *word https://github.com/ruby/ruby/blob/trunk/bignum.c#L844 * 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/