summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/-test-/bignum
diff options
context:
space:
mode:
Diffstat (limited to 'jni/ruby/ext/-test-/bignum')
-rw-r--r--jni/ruby/ext/-test-/bignum/Makefile371
-rw-r--r--jni/ruby/ext/-test-/bignum/big2str.c53
-rw-r--r--jni/ruby/ext/-test-/bignum/bigzero.c26
-rw-r--r--jni/ruby/ext/-test-/bignum/depend102
-rw-r--r--jni/ruby/ext/-test-/bignum/div.c35
-rw-r--r--jni/ruby/ext/-test-/bignum/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/bignum/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/bignum/init.c11
-rw-r--r--jni/ruby/ext/-test-/bignum/intpack.c87
-rw-r--r--jni/ruby/ext/-test-/bignum/mul.c65
-rw-r--r--jni/ruby/ext/-test-/bignum/str2big.c38
11 files changed, 799 insertions, 0 deletions
diff --git a/jni/ruby/ext/-test-/bignum/Makefile b/jni/ruby/ext/-test-/bignum/Makefile
new file mode 100644
index 0000000..ba08424
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/Makefile
@@ -0,0 +1,371 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/bignum
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bigzero.c mul.c init.c str2big.c big2str.c div.c intpack.c
+SRCS = $(ORIG_SRCS)
+OBJS = bigzero.o mul.o init.o str2big.o big2str.o div.o intpack.o
+HDRS = $(srcdir)/extconf.h
+TARGET = bignum
+TARGET_NAME = bignum
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+big2str.o: big2str.c
+div.o: div.c
+intpack.o: intpack.c
+mul.o: mul.c
+str2big.o: str2big.c
+
+# AUTOGENERATED DEPENDENCIES START
+big2str.o: $(RUBY_EXTCONF_H)
+big2str.o: $(arch_hdrdir)/ruby/config.h
+big2str.o: $(hdrdir)/ruby/defines.h
+big2str.o: $(hdrdir)/ruby/encoding.h
+big2str.o: $(hdrdir)/ruby/intern.h
+big2str.o: $(hdrdir)/ruby/io.h
+big2str.o: $(hdrdir)/ruby/missing.h
+big2str.o: $(hdrdir)/ruby/oniguruma.h
+big2str.o: $(hdrdir)/ruby/ruby.h
+big2str.o: $(hdrdir)/ruby/st.h
+big2str.o: $(hdrdir)/ruby/subst.h
+big2str.o: $(top_srcdir)/include/ruby.h
+big2str.o: $(top_srcdir)/internal.h
+big2str.o: big2str.c
+bigzero.o: $(RUBY_EXTCONF_H)
+bigzero.o: $(arch_hdrdir)/ruby/config.h
+bigzero.o: $(hdrdir)/ruby/defines.h
+bigzero.o: $(hdrdir)/ruby/encoding.h
+bigzero.o: $(hdrdir)/ruby/intern.h
+bigzero.o: $(hdrdir)/ruby/io.h
+bigzero.o: $(hdrdir)/ruby/missing.h
+bigzero.o: $(hdrdir)/ruby/oniguruma.h
+bigzero.o: $(hdrdir)/ruby/ruby.h
+bigzero.o: $(hdrdir)/ruby/st.h
+bigzero.o: $(hdrdir)/ruby/subst.h
+bigzero.o: $(top_srcdir)/include/ruby.h
+bigzero.o: $(top_srcdir)/internal.h
+bigzero.o: bigzero.c
+div.o: $(RUBY_EXTCONF_H)
+div.o: $(arch_hdrdir)/ruby/config.h
+div.o: $(hdrdir)/ruby/defines.h
+div.o: $(hdrdir)/ruby/encoding.h
+div.o: $(hdrdir)/ruby/intern.h
+div.o: $(hdrdir)/ruby/io.h
+div.o: $(hdrdir)/ruby/missing.h
+div.o: $(hdrdir)/ruby/oniguruma.h
+div.o: $(hdrdir)/ruby/ruby.h
+div.o: $(hdrdir)/ruby/st.h
+div.o: $(hdrdir)/ruby/subst.h
+div.o: $(top_srcdir)/include/ruby.h
+div.o: $(top_srcdir)/internal.h
+div.o: div.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+intpack.o: $(RUBY_EXTCONF_H)
+intpack.o: $(arch_hdrdir)/ruby/config.h
+intpack.o: $(hdrdir)/ruby/defines.h
+intpack.o: $(hdrdir)/ruby/encoding.h
+intpack.o: $(hdrdir)/ruby/intern.h
+intpack.o: $(hdrdir)/ruby/io.h
+intpack.o: $(hdrdir)/ruby/missing.h
+intpack.o: $(hdrdir)/ruby/oniguruma.h
+intpack.o: $(hdrdir)/ruby/ruby.h
+intpack.o: $(hdrdir)/ruby/st.h
+intpack.o: $(hdrdir)/ruby/subst.h
+intpack.o: $(top_srcdir)/include/ruby.h
+intpack.o: $(top_srcdir)/internal.h
+intpack.o: intpack.c
+mul.o: $(RUBY_EXTCONF_H)
+mul.o: $(arch_hdrdir)/ruby/config.h
+mul.o: $(hdrdir)/ruby/defines.h
+mul.o: $(hdrdir)/ruby/encoding.h
+mul.o: $(hdrdir)/ruby/intern.h
+mul.o: $(hdrdir)/ruby/io.h
+mul.o: $(hdrdir)/ruby/missing.h
+mul.o: $(hdrdir)/ruby/oniguruma.h
+mul.o: $(hdrdir)/ruby/ruby.h
+mul.o: $(hdrdir)/ruby/st.h
+mul.o: $(hdrdir)/ruby/subst.h
+mul.o: $(top_srcdir)/include/ruby.h
+mul.o: $(top_srcdir)/internal.h
+mul.o: mul.c
+str2big.o: $(RUBY_EXTCONF_H)
+str2big.o: $(arch_hdrdir)/ruby/config.h
+str2big.o: $(hdrdir)/ruby/defines.h
+str2big.o: $(hdrdir)/ruby/encoding.h
+str2big.o: $(hdrdir)/ruby/intern.h
+str2big.o: $(hdrdir)/ruby/io.h
+str2big.o: $(hdrdir)/ruby/missing.h
+str2big.o: $(hdrdir)/ruby/oniguruma.h
+str2big.o: $(hdrdir)/ruby/ruby.h
+str2big.o: $(hdrdir)/ruby/st.h
+str2big.o: $(hdrdir)/ruby/subst.h
+str2big.o: $(top_srcdir)/include/ruby.h
+str2big.o: $(top_srcdir)/internal.h
+str2big.o: str2big.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/bignum/big2str.c b/jni/ruby/ext/-test-/bignum/big2str.c
new file mode 100644
index 0000000..ec4bde2
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/big2str.c
@@ -0,0 +1,53 @@
+#include "internal.h"
+
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+
+static VALUE
+big2str_generic(VALUE x, VALUE vbase)
+{
+ int base = NUM2INT(vbase);
+ if (base < 2 || 36 < base)
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ return rb_big2str_generic(big(x), base);
+}
+
+#define POW2_P(x) (((x)&((x)-1))==0)
+
+static VALUE
+big2str_poweroftwo(VALUE x, VALUE vbase)
+{
+ int base = NUM2INT(vbase);
+ if (base < 2 || 36 < base || !POW2_P(base))
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ return rb_big2str_poweroftwo(big(x), base);
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+big2str_gmp(VALUE x, VALUE vbase)
+{
+ int base = NUM2INT(vbase);
+ if (base < 2 || 36 < base)
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ return rb_big2str_gmp(big(x), base);
+}
+#else
+#define big2str_gmp rb_f_notimplement
+#endif
+
+void
+Init_big2str(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "big2str_generic", big2str_generic, 1);
+ rb_define_method(rb_cInteger, "big2str_poweroftwo", big2str_poweroftwo, 1);
+ rb_define_method(rb_cInteger, "big2str_gmp", big2str_gmp, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/bigzero.c b/jni/ruby/ext/-test-/bignum/bigzero.c
new file mode 100644
index 0000000..35117db
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/bigzero.c
@@ -0,0 +1,26 @@
+#include "internal.h"
+
+static VALUE
+bug_big_zero(VALUE self, VALUE length)
+{
+ long len = NUM2ULONG(length);
+ VALUE z = rb_big_new(len, 1);
+ MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len);
+ return z;
+}
+
+static VALUE
+bug_big_negzero(VALUE self, VALUE length)
+{
+ long len = NUM2ULONG(length);
+ VALUE z = rb_big_new(len, 0);
+ MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len);
+ return z;
+}
+
+void
+Init_bigzero(VALUE klass)
+{
+ rb_define_singleton_method(klass, "zero", bug_big_zero, 1);
+ rb_define_singleton_method(klass, "negzero", bug_big_negzero, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/depend b/jni/ruby/ext/-test-/bignum/depend
new file mode 100644
index 0000000..26cb890
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/depend
@@ -0,0 +1,102 @@
+big2str.o: big2str.c
+div.o: div.c
+intpack.o: intpack.c
+mul.o: mul.c
+str2big.o: str2big.c
+
+# AUTOGENERATED DEPENDENCIES START
+big2str.o: $(RUBY_EXTCONF_H)
+big2str.o: $(arch_hdrdir)/ruby/config.h
+big2str.o: $(hdrdir)/ruby/defines.h
+big2str.o: $(hdrdir)/ruby/encoding.h
+big2str.o: $(hdrdir)/ruby/intern.h
+big2str.o: $(hdrdir)/ruby/io.h
+big2str.o: $(hdrdir)/ruby/missing.h
+big2str.o: $(hdrdir)/ruby/oniguruma.h
+big2str.o: $(hdrdir)/ruby/ruby.h
+big2str.o: $(hdrdir)/ruby/st.h
+big2str.o: $(hdrdir)/ruby/subst.h
+big2str.o: $(top_srcdir)/include/ruby.h
+big2str.o: $(top_srcdir)/internal.h
+big2str.o: big2str.c
+bigzero.o: $(RUBY_EXTCONF_H)
+bigzero.o: $(arch_hdrdir)/ruby/config.h
+bigzero.o: $(hdrdir)/ruby/defines.h
+bigzero.o: $(hdrdir)/ruby/encoding.h
+bigzero.o: $(hdrdir)/ruby/intern.h
+bigzero.o: $(hdrdir)/ruby/io.h
+bigzero.o: $(hdrdir)/ruby/missing.h
+bigzero.o: $(hdrdir)/ruby/oniguruma.h
+bigzero.o: $(hdrdir)/ruby/ruby.h
+bigzero.o: $(hdrdir)/ruby/st.h
+bigzero.o: $(hdrdir)/ruby/subst.h
+bigzero.o: $(top_srcdir)/include/ruby.h
+bigzero.o: $(top_srcdir)/internal.h
+bigzero.o: bigzero.c
+div.o: $(RUBY_EXTCONF_H)
+div.o: $(arch_hdrdir)/ruby/config.h
+div.o: $(hdrdir)/ruby/defines.h
+div.o: $(hdrdir)/ruby/encoding.h
+div.o: $(hdrdir)/ruby/intern.h
+div.o: $(hdrdir)/ruby/io.h
+div.o: $(hdrdir)/ruby/missing.h
+div.o: $(hdrdir)/ruby/oniguruma.h
+div.o: $(hdrdir)/ruby/ruby.h
+div.o: $(hdrdir)/ruby/st.h
+div.o: $(hdrdir)/ruby/subst.h
+div.o: $(top_srcdir)/include/ruby.h
+div.o: $(top_srcdir)/internal.h
+div.o: div.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+intpack.o: $(RUBY_EXTCONF_H)
+intpack.o: $(arch_hdrdir)/ruby/config.h
+intpack.o: $(hdrdir)/ruby/defines.h
+intpack.o: $(hdrdir)/ruby/encoding.h
+intpack.o: $(hdrdir)/ruby/intern.h
+intpack.o: $(hdrdir)/ruby/io.h
+intpack.o: $(hdrdir)/ruby/missing.h
+intpack.o: $(hdrdir)/ruby/oniguruma.h
+intpack.o: $(hdrdir)/ruby/ruby.h
+intpack.o: $(hdrdir)/ruby/st.h
+intpack.o: $(hdrdir)/ruby/subst.h
+intpack.o: $(top_srcdir)/include/ruby.h
+intpack.o: $(top_srcdir)/internal.h
+intpack.o: intpack.c
+mul.o: $(RUBY_EXTCONF_H)
+mul.o: $(arch_hdrdir)/ruby/config.h
+mul.o: $(hdrdir)/ruby/defines.h
+mul.o: $(hdrdir)/ruby/encoding.h
+mul.o: $(hdrdir)/ruby/intern.h
+mul.o: $(hdrdir)/ruby/io.h
+mul.o: $(hdrdir)/ruby/missing.h
+mul.o: $(hdrdir)/ruby/oniguruma.h
+mul.o: $(hdrdir)/ruby/ruby.h
+mul.o: $(hdrdir)/ruby/st.h
+mul.o: $(hdrdir)/ruby/subst.h
+mul.o: $(top_srcdir)/include/ruby.h
+mul.o: $(top_srcdir)/internal.h
+mul.o: mul.c
+str2big.o: $(RUBY_EXTCONF_H)
+str2big.o: $(arch_hdrdir)/ruby/config.h
+str2big.o: $(hdrdir)/ruby/defines.h
+str2big.o: $(hdrdir)/ruby/encoding.h
+str2big.o: $(hdrdir)/ruby/intern.h
+str2big.o: $(hdrdir)/ruby/io.h
+str2big.o: $(hdrdir)/ruby/missing.h
+str2big.o: $(hdrdir)/ruby/oniguruma.h
+str2big.o: $(hdrdir)/ruby/ruby.h
+str2big.o: $(hdrdir)/ruby/st.h
+str2big.o: $(hdrdir)/ruby/subst.h
+str2big.o: $(top_srcdir)/include/ruby.h
+str2big.o: $(top_srcdir)/internal.h
+str2big.o: str2big.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/bignum/div.c b/jni/ruby/ext/-test-/bignum/div.c
new file mode 100644
index 0000000..a1db21d
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/div.c
@@ -0,0 +1,35 @@
+#include "internal.h"
+
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+
+static VALUE
+divrem_normal(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_divrem_normal(big(x), big(y)));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+divrem_gmp(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_divrem_gmp(big(x), big(y)));
+}
+#else
+#define divrem_gmp rb_f_notimplement
+#endif
+
+void
+Init_div(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "big_divrem_normal", divrem_normal, 1);
+ rb_define_method(rb_cInteger, "big_divrem_gmp", divrem_gmp, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/extconf.h b/jni/ruby/ext/-test-/bignum/extconf.h
new file mode 100644
index 0000000..ada4a2f
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(bigzero) X(mul) X(str2big) X(big2str) X(div) X(intpack)
+#endif
diff --git a/jni/ruby/ext/-test-/bignum/extconf.rb b/jni/ruby/ext/-test-/bignum/extconf.rb
new file mode 100644
index 0000000..e8c1feb
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/extconf.rb
@@ -0,0 +1,7 @@
+$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")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/bignum")
diff --git a/jni/ruby/ext/-test-/bignum/init.c b/jni/ruby/ext/-test-/bignum/init.c
new file mode 100644
index 0000000..82a159b
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_bignum(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Bignum", rb_cString);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/bignum/intpack.c b/jni/ruby/ext/-test-/bignum/intpack.c
new file mode 100644
index 0000000..2d19442
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/intpack.c
@@ -0,0 +1,87 @@
+#include "internal.h"
+
+static VALUE
+rb_integer_pack_raw_m(VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
+{
+ int sign;
+ size_t numwords = 0;
+ size_t wordsize = NUM2SIZET(wordsize_arg);
+
+ StringValue(buf);
+ rb_str_modify(buf);
+ sign = rb_integer_pack(val,
+ RSTRING_PTR(buf), NUM2SIZET(numwords_arg),
+ NUM2SIZET(wordsize_arg), NUM2SIZET(nails), NUM2INT(flags));
+
+ return rb_ary_new_from_args(2, INT2NUM(sign), rb_str_new(RSTRING_PTR(buf), wordsize * numwords));
+}
+
+static VALUE
+rb_integer_pack_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(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);
+
+ return rb_integer_unpack(RSTRING_PTR(buf),
+ NUM2SIZET(numwords), NUM2SIZET(wordsize),
+ NUM2SIZET(nails), NUM2INT(flags));
+}
+
+static VALUE
+rb_integer_test_numbits_2comp_without_sign(VALUE val)
+{
+ size_t size;
+ int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val);
+ size = rb_absint_numwords(val, 1, NULL) - (neg && rb_absint_singlebit_p(val));
+ return SIZET2NUM(size);
+}
+
+static VALUE
+rb_integer_test_numbytes_2comp_with_sign(VALUE val)
+{
+ int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val);
+ int nlz_bits;
+ size_t size = rb_absint_size(val, &nlz_bits);
+ if (nlz_bits == 0 && !(neg && rb_absint_singlebit_p(val)))
+ size++;
+ return SIZET2NUM(size);
+}
+
+void
+Init_intpack(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_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_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));
+ 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));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION", INT2NUM(INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION));
+
+ rb_define_method(rb_cInteger, "test_numbits_2comp_without_sign", rb_integer_test_numbits_2comp_without_sign, 0);
+ rb_define_method(rb_cInteger, "test_numbytes_2comp_with_sign", rb_integer_test_numbytes_2comp_with_sign, 0);
+}
diff --git a/jni/ruby/ext/-test-/bignum/mul.c b/jni/ruby/ext/-test-/bignum/mul.c
new file mode 100644
index 0000000..d34e98f
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/mul.c
@@ -0,0 +1,65 @@
+#include "internal.h"
+
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+
+static VALUE
+mul_normal(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_normal(big(x), big(y)));
+}
+
+static VALUE
+sq_fast(VALUE x)
+{
+ return rb_big_norm(rb_big_sq_fast(big(x)));
+}
+
+static VALUE
+mul_balance(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_balance(big(x), big(y)));
+}
+
+static VALUE
+mul_karatsuba(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_karatsuba(big(x), big(y)));
+}
+
+static VALUE
+mul_toom3(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_toom3(big(x), big(y)));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+mul_gmp(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_gmp(big(x), big(y)));
+}
+#else
+#define mul_gmp rb_f_notimplement
+#endif
+
+void
+Init_mul(VALUE klass)
+{
+ rb_define_const(rb_cBignum, "SIZEOF_BDIGIT", INT2NUM(SIZEOF_BDIGIT));
+ rb_define_const(rb_cBignum, "BITSPERDIG", INT2NUM(SIZEOF_BDIGIT * CHAR_BIT));
+ rb_define_method(rb_cInteger, "big_mul_normal", mul_normal, 1);
+ rb_define_method(rb_cInteger, "big_sq_fast", sq_fast, 0);
+ rb_define_method(rb_cInteger, "big_mul_balance", mul_balance, 1);
+ rb_define_method(rb_cInteger, "big_mul_karatsuba", mul_karatsuba, 1);
+ rb_define_method(rb_cInteger, "big_mul_toom3", mul_toom3, 1);
+ rb_define_method(rb_cInteger, "big_mul_gmp", mul_gmp, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/str2big.c b/jni/ruby/ext/-test-/bignum/str2big.c
new file mode 100644
index 0000000..bc79ef0
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/str2big.c
@@ -0,0 +1,38 @@
+#include "internal.h"
+
+static VALUE
+str2big_poweroftwo(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_poweroftwo(str, NUM2INT(vbase), RTEST(badcheck));
+}
+
+static VALUE
+str2big_normal(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_normal(str, NUM2INT(vbase), RTEST(badcheck));
+}
+
+static VALUE
+str2big_karatsuba(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_karatsuba(str, NUM2INT(vbase), RTEST(badcheck));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+str2big_gmp(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_gmp(str, NUM2INT(vbase), RTEST(badcheck));
+}
+#else
+#define str2big_gmp rb_f_notimplement
+#endif
+
+void
+Init_str2big(VALUE klass)
+{
+ rb_define_method(rb_cString, "str2big_poweroftwo", str2big_poweroftwo, 2);
+ rb_define_method(rb_cString, "str2big_normal", str2big_normal, 2);
+ rb_define_method(rb_cString, "str2big_karatsuba", str2big_karatsuba, 2);
+ rb_define_method(rb_cString, "str2big_gmp", str2big_gmp, 2);
+}