summaryrefslogtreecommitdiff
path: root/ext/-test-/bignum
diff options
context:
space:
mode:
Diffstat (limited to 'ext/-test-/bignum')
-rw-r--r--ext/-test-/bignum/export.c29
-rw-r--r--ext/-test-/bignum/extconf.rb1
2 files changed, 30 insertions, 0 deletions
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);
+}
diff --git a/ext/-test-/bignum/extconf.rb b/ext/-test-/bignum/extconf.rb
index 4ced662180..e8c1febc82 100644
--- a/ext/-test-/bignum/extconf.rb
+++ b/ext/-test-/bignum/extconf.rb
@@ -1,3 +1,4 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
inits = $srcs.map {|s| File.basename(s, ".*")}
inits.delete("init")