From 9fea8758e98eed379bf406f2fea6c8403efe2590 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 6 Jun 2013 11:57:35 +0000 Subject: * configure.in: Invoke RUBY_REPLACE_TYPE for size_t. Don't invoke RUBY_CHECK_PRINTF_PREFIX for size_t to avoid conflict with RUBY_REPLACE_TYPE. * internal.h (rb_absint_size): Declared. (rb_absint_size_in_word): Ditto. (rb_int_export): Ditto. * bignum.c (rb_absint_size): New function. (rb_absint_size_in_word): Ditto. (int_export_fill_dd): Ditto. (int_export_take_lowbits): Ditto. (rb_int_export): Ditto. * pack.c (pack_pack): Use rb_int_export for BER compressed integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/-test-/bignum/export.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ext/-test-/bignum/export.c (limited to 'ext/-test-/bignum/export.c') diff --git a/ext/-test-/bignum/export.c b/ext/-test-/bignum/export.c new file mode 100644 index 0000000000..4483452777 --- /dev/null +++ b/ext/-test-/bignum/export.c @@ -0,0 +1,29 @@ +#include "ruby.h" +#include "internal.h" + +static VALUE +rb_int_export_m(VALUE val, VALUE buf, VALUE wordorder, VALUE wordsize_arg, VALUE endian, VALUE nails) +{ + int sign; + size_t count; + void *ret; + size_t wordsize = NUM2SIZE(wordsize_arg); + + if (!NIL_P(buf)) { + StringValue(buf); + rb_str_modify(buf); + count = RSTRING_LEN(buf) / wordsize; + } + + ret = rb_int_export(val, + &sign, 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)); +} + +void +Init_export(VALUE klass) +{ + rb_define_method(rb_cInteger, "test_export", rb_int_export_m, 5); +} -- cgit v1.2.3