summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-16 09:53:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-16 09:53:45 +0000
commitecabbf1bf606305bb553100700e1edb487604ecc (patch)
treeb9173748f7e09561c37c02efe9107d518b933266 /ext
parentfc3fbc143cc5ee95758b561a59d6b856c492bbb4 (diff)
* internal.h (INTEGER_PACK_2COMP): Defined.
(rb_integer_pack_2comp): Removed. * bignum.c (bary_pack): Support INTEGER_PACK_2COMP. (rb_integer_pack): Invoke bary_pack directly. (rb_integer_pack_2comp): Removed. (rb_integer_pack_internal): Ditto. (absint_numwords_generic): Follow the above change. * pack.c (pack_pack): Ditto. * sprintf.c (rb_str_format): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/bignum/pack.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/ext/-test-/bignum/pack.c b/ext/-test-/bignum/pack.c
index fc2dac1..f95c932 100644
--- a/ext/-test-/bignum/pack.c
+++ b/ext/-test-/bignum/pack.c
@@ -36,24 +36,6 @@ rb_integer_pack_m(VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails
}
static VALUE
-rb_integer_pack_2comp_m(VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
-{
- int sign;
- size_t numwords = NUM2SIZET(numwords_arg);
- size_t wordsize = NUM2SIZET(wordsize_arg);
- VALUE buf;
-
- if (numwords != 0 && wordsize != 0 && LONG_MAX / wordsize < numwords)
- rb_raise(rb_eArgError, "too big numwords * wordsize");
- buf = rb_str_new(NULL, numwords * wordsize);
- sign = rb_integer_pack_2comp(val,
- RSTRING_PTR(buf), numwords,
- wordsize, NUM2SIZET(nails), NUM2INT(flags));
-
- return rb_assoc_new(INT2NUM(sign), buf);
-}
-
-static VALUE
rb_integer_unpack_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags)
{
StringValue(buf);
@@ -78,7 +60,6 @@ Init_pack(VALUE klass)
{
rb_define_method(rb_cInteger, "test_pack_raw", rb_integer_pack_raw_m, 5);
rb_define_method(rb_cInteger, "test_pack", rb_integer_pack_m, 4);
- rb_define_method(rb_cInteger, "test_pack_2comp", rb_integer_pack_2comp_m, 4);
rb_define_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_m, 5);
rb_define_singleton_method(rb_cInteger, "test_unpack_2comp", rb_integer_unpack_2comp_m, 5);
rb_define_const(rb_cInteger, "INTEGER_PACK_MSWORD_FIRST", INT2NUM(INTEGER_PACK_MSWORD_FIRST));
@@ -86,6 +67,7 @@ Init_pack(VALUE klass)
rb_define_const(rb_cInteger, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));
rb_define_const(rb_cInteger, "INTEGER_PACK_LSBYTE_FIRST", INT2NUM(INTEGER_PACK_LSBYTE_FIRST));
rb_define_const(rb_cInteger, "INTEGER_PACK_NATIVE_BYTE_ORDER", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_2COMP", INT2NUM(INTEGER_PACK_2COMP));
rb_define_const(rb_cInteger, "INTEGER_PACK_LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN));
rb_define_const(rb_cInteger, "INTEGER_PACK_BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN));
rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_BIGNUM", INT2NUM(INTEGER_PACK_FORCE_BIGNUM));