aboutsummaryrefslogtreecommitdiffstats
path: root/ext/-test-/bignum
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-12 15:18:00 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-12 15:18:00 +0000
commitaaa1461d7b1508c12e9aaa3f2c2681ddc82fa0f4 (patch)
treeb9c7a602b2756d9a17c55d8701b889b481440a8a /ext/-test-/bignum
parent17f1cdaa00ff51470b934c99f6e54a24bf377b71 (diff)
downloadruby-aaa1461d7b1508c12e9aaa3f2c2681ddc82fa0f4.tar.gz
* bignum.c (rb_integer_unpack_2comp): New function.
(rb_integer_unpack_internal): Extracted from rb_integer_unpack and nlp_bits_ret argument added. (integer_unpack_num_bdigits_small): nlp_bits_ret argument added to return number of leading padding bits. (integer_unpack_num_bdigits_generic): Ditto. * internal.h (rb_integer_unpack_2comp): Declared. * pack.c (pack_unpack): Use rb_integer_unpack_2comp and rb_integer_unpack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/bignum')
-rw-r--r--ext/-test-/bignum/pack.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/-test-/bignum/pack.c b/ext/-test-/bignum/pack.c
index 553c101be6..fc2dac1b25 100644
--- a/ext/-test-/bignum/pack.c
+++ b/ext/-test-/bignum/pack.c
@@ -63,6 +63,16 @@ rb_integer_unpack_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALU
NUM2SIZET(nails), NUM2INT(flags));
}
+static VALUE
+rb_integer_unpack_2comp_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags)
+{
+ StringValue(buf);
+
+ return rb_integer_unpack_2comp(RSTRING_PTR(buf),
+ NUM2SIZET(numwords), NUM2SIZET(wordsize),
+ NUM2SIZET(nails), NUM2INT(flags));
+}
+
void
Init_pack(VALUE klass)
{
@@ -70,6 +80,7 @@ Init_pack(VALUE klass)
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));
rb_define_const(rb_cInteger, "INTEGER_PACK_LSWORD_FIRST", INT2NUM(INTEGER_PACK_LSWORD_FIRST));
rb_define_const(rb_cInteger, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));