summaryrefslogtreecommitdiff
path: root/ruby_2_2/ext/-test-
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_2_2/ext/-test-')
-rw-r--r--ruby_2_2/ext/-test-/array/resize/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/array/resize/resize.c14
-rw-r--r--ruby_2_2/ext/-test-/bignum/big2str.c53
-rw-r--r--ruby_2_2/ext/-test-/bignum/bigzero.c26
-rw-r--r--ruby_2_2/ext/-test-/bignum/depend102
-rw-r--r--ruby_2_2/ext/-test-/bignum/div.c35
-rw-r--r--ruby_2_2/ext/-test-/bignum/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/bignum/init.c11
-rw-r--r--ruby_2_2/ext/-test-/bignum/intpack.c87
-rw-r--r--ruby_2_2/ext/-test-/bignum/mul.c65
-rw-r--r--ruby_2_2/ext/-test-/bignum/str2big.c38
-rw-r--r--ruby_2_2/ext/-test-/bug-3571/bug.c23
-rw-r--r--ruby_2_2/ext/-test-/bug-3571/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/bug-3662/bug.c16
-rw-r--r--ruby_2_2/ext/-test-/bug-3662/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/bug-5832/bug.c14
-rw-r--r--ruby_2_2/ext/-test-/bug-5832/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/bug_reporter/bug_reporter.c24
-rw-r--r--ruby_2_2/ext/-test-/bug_reporter/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/class/class2name.c14
-rw-r--r--ruby_2_2/ext/-test-/class/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/class/init.c11
-rw-r--r--ruby_2_2/ext/-test-/debug/depend32
-rw-r--r--ruby_2_2/ext/-test-/debug/extconf.rb6
-rw-r--r--ruby_2_2/ext/-test-/debug/init.c11
-rw-r--r--ruby_2_2/ext/-test-/debug/inspector.c32
-rw-r--r--ruby_2_2/ext/-test-/debug/profile_frames.c43
-rw-r--r--ruby_2_2/ext/-test-/dln/empty/empty.c4
-rw-r--r--ruby_2_2/ext/-test-/dln/empty/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/exception/dataerror.c31
-rw-r--r--ruby_2_2/ext/-test-/exception/depend43
-rw-r--r--ruby_2_2/ext/-test-/exception/enc_raise.c15
-rw-r--r--ruby_2_2/ext/-test-/exception/ensured.c25
-rw-r--r--ruby_2_2/ext/-test-/exception/extconf.rb6
-rw-r--r--ruby_2_2/ext/-test-/exception/init.c11
-rw-r--r--ruby_2_2/ext/-test-/fatal/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/fatal/rb_fatal.c19
-rw-r--r--ruby_2_2/ext/-test-/file/depend36
-rw-r--r--ruby_2_2/ext/-test-/file/extconf.rb22
-rw-r--r--ruby_2_2/ext/-test-/file/fs.c105
-rw-r--r--ruby_2_2/ext/-test-/file/init.c11
-rw-r--r--ruby_2_2/ext/-test-/file/stat.c27
-rw-r--r--ruby_2_2/ext/-test-/float/depend3
-rw-r--r--ruby_2_2/ext/-test-/float/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/float/init.c11
-rw-r--r--ruby_2_2/ext/-test-/float/nextafter.c36
-rw-r--r--ruby_2_2/ext/-test-/funcall/extconf.rb2
-rw-r--r--ruby_2_2/ext/-test-/funcall/passing_block.c30
-rw-r--r--ruby_2_2/ext/-test-/hash/delete.c16
-rw-r--r--ruby_2_2/ext/-test-/hash/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/hash/init.c11
-rw-r--r--ruby_2_2/ext/-test-/iseq_load/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/iseq_load/iseq_load.c21
-rw-r--r--ruby_2_2/ext/-test-/iter/break.c25
-rw-r--r--ruby_2_2/ext/-test-/iter/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/iter/init.c11
-rw-r--r--ruby_2_2/ext/-test-/iter/yield.c16
-rw-r--r--ruby_2_2/ext/-test-/load/dot.dot/dot.dot.c1
-rw-r--r--ruby_2_2/ext/-test-/load/dot.dot/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/marshal/compat/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/marshal/compat/usrcompat.c32
-rw-r--r--ruby_2_2/ext/-test-/marshal/usr/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/marshal/usr/usrmarshal.c50
-rw-r--r--ruby_2_2/ext/-test-/method/arity.c22
-rw-r--r--ruby_2_2/ext/-test-/method/extconf.rb6
-rw-r--r--ruby_2_2/ext/-test-/method/init.c11
-rw-r--r--ruby_2_2/ext/-test-/num2int/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/num2int/num2int.c136
-rw-r--r--ruby_2_2/ext/-test-/path_to_class/extconf.rb6
-rw-r--r--ruby_2_2/ext/-test-/path_to_class/path_to_class.c15
-rw-r--r--ruby_2_2/ext/-test-/postponed_job/depend1
-rw-r--r--ruby_2_2/ext/-test-/postponed_job/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/postponed_job/postponed_job.c53
-rw-r--r--ruby_2_2/ext/-test-/printf/depend3
-rw-r--r--ruby_2_2/ext/-test-/printf/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/printf/printf.c101
-rw-r--r--ruby_2_2/ext/-test-/proc/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/proc/init.c11
-rw-r--r--ruby_2_2/ext/-test-/proc/receiver.c21
-rw-r--r--ruby_2_2/ext/-test-/proc/super.c27
-rw-r--r--ruby_2_2/ext/-test-/rational/depend20
-rw-r--r--ruby_2_2/ext/-test-/rational/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/rational/rat.c37
-rw-r--r--ruby_2_2/ext/-test-/recursion/extconf.rb2
-rw-r--r--ruby_2_2/ext/-test-/recursion/recursion.c28
-rw-r--r--ruby_2_2/ext/-test-/st/foreach/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/st/foreach/foreach.c175
-rw-r--r--ruby_2_2/ext/-test-/st/numhash/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/st/numhash/numhash.c138
-rw-r--r--ruby_2_2/ext/-test-/st/update/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/st/update/update.c34
-rw-r--r--ruby_2_2/ext/-test-/string/coderange.c47
-rw-r--r--ruby_2_2/ext/-test-/string/cstr.c57
-rw-r--r--ruby_2_2/ext/-test-/string/depend115
-rw-r--r--ruby_2_2/ext/-test-/string/ellipsize.c13
-rw-r--r--ruby_2_2/ext/-test-/string/enc_associate.c14
-rw-r--r--ruby_2_2/ext/-test-/string/enc_str_buf_cat.c14
-rw-r--r--ruby_2_2/ext/-test-/string/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/string/init.c11
-rw-r--r--ruby_2_2/ext/-test-/string/modify.c22
-rw-r--r--ruby_2_2/ext/-test-/string/nofree.c13
-rw-r--r--ruby_2_2/ext/-test-/string/normalize.c17
-rw-r--r--ruby_2_2/ext/-test-/string/qsort.c61
-rw-r--r--ruby_2_2/ext/-test-/string/set_len.c14
-rw-r--r--ruby_2_2/ext/-test-/struct/duplicate.c24
-rw-r--r--ruby_2_2/ext/-test-/struct/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/struct/init.c11
-rw-r--r--ruby_2_2/ext/-test-/struct/member.c18
-rw-r--r--ruby_2_2/ext/-test-/symbol/extconf.rb7
-rw-r--r--ruby_2_2/ext/-test-/symbol/init.c25
-rw-r--r--ruby_2_2/ext/-test-/symbol/type.c78
-rw-r--r--ruby_2_2/ext/-test-/tracepoint/depend22
-rw-r--r--ruby_2_2/ext/-test-/tracepoint/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/tracepoint/gc_hook.c80
-rw-r--r--ruby_2_2/ext/-test-/tracepoint/tracepoint.c96
-rw-r--r--ruby_2_2/ext/-test-/typeddata/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/typeddata/typeddata.c20
-rw-r--r--ruby_2_2/ext/-test-/vm/at_exit.c44
-rw-r--r--ruby_2_2/ext/-test-/vm/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/wait_for_single_fd/depend14
-rw-r--r--ruby_2_2/ext/-test-/wait_for_single_fd/extconf.rb1
-rw-r--r--ruby_2_2/ext/-test-/wait_for_single_fd/wait_for_single_fd.c30
-rw-r--r--ruby_2_2/ext/-test-/win32/console/attribute.c56
-rw-r--r--ruby_2_2/ext/-test-/win32/console/depend1
-rw-r--r--ruby_2_2/ext/-test-/win32/console/extconf.rb8
-rw-r--r--ruby_2_2/ext/-test-/win32/console/init.c11
-rw-r--r--ruby_2_2/ext/-test-/win32/dln/dlntest.c17
-rw-r--r--ruby_2_2/ext/-test-/win32/dln/extconf.rb37
-rw-r--r--ruby_2_2/ext/-test-/win32/dln/libdlntest.c4
-rw-r--r--ruby_2_2/ext/-test-/win32/dln/libdlntest.def2
-rw-r--r--ruby_2_2/ext/-test-/win32/fd_setsize/depend1
-rw-r--r--ruby_2_2/ext/-test-/win32/fd_setsize/extconf.rb3
-rw-r--r--ruby_2_2/ext/-test-/win32/fd_setsize/fd_setsize.c55
133 files changed, 3270 insertions, 0 deletions
diff --git a/ruby_2_2/ext/-test-/array/resize/extconf.rb b/ruby_2_2/ext/-test-/array/resize/extconf.rb
new file mode 100644
index 0000000000..6500a878fc
--- /dev/null
+++ b/ruby_2_2/ext/-test-/array/resize/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/array/resize")
diff --git a/ruby_2_2/ext/-test-/array/resize/resize.c b/ruby_2_2/ext/-test-/array/resize/resize.c
new file mode 100644
index 0000000000..08bcee3e7a
--- /dev/null
+++ b/ruby_2_2/ext/-test-/array/resize/resize.c
@@ -0,0 +1,14 @@
+#include "ruby/ruby.h"
+
+static VALUE
+ary_resize(VALUE ary, VALUE len)
+{
+ rb_ary_resize(ary, NUM2LONG(len));
+ return ary;
+}
+
+void
+Init_resize(void)
+{
+ rb_define_method(rb_cArray, "__resize__", ary_resize, 1);
+}
diff --git a/ruby_2_2/ext/-test-/bignum/big2str.c b/ruby_2_2/ext/-test-/bignum/big2str.c
new file mode 100644
index 0000000000..ec4bde2915
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/bigzero.c b/ruby_2_2/ext/-test-/bignum/bigzero.c
new file mode 100644
index 0000000000..35117db7ae
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/depend b/ruby_2_2/ext/-test-/bignum/depend
new file mode 100644
index 0000000000..26cb890dbf
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/div.c b/ruby_2_2/ext/-test-/bignum/div.c
new file mode 100644
index 0000000000..a1db21dc30
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/extconf.rb b/ruby_2_2/ext/-test-/bignum/extconf.rb
new file mode 100644
index 0000000000..e8c1febc82
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/init.c b/ruby_2_2/ext/-test-/bignum/init.c
new file mode 100644
index 0000000000..82a159bf1d
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/intpack.c b/ruby_2_2/ext/-test-/bignum/intpack.c
new file mode 100644
index 0000000000..2d19442cf2
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/mul.c b/ruby_2_2/ext/-test-/bignum/mul.c
new file mode 100644
index 0000000000..d34e98fabb
--- /dev/null
+++ b/ruby_2_2/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/ruby_2_2/ext/-test-/bignum/str2big.c b/ruby_2_2/ext/-test-/bignum/str2big.c
new file mode 100644
index 0000000000..bc79ef0329
--- /dev/null
+++ b/ruby_2_2/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);
+}
diff --git a/ruby_2_2/ext/-test-/bug-3571/bug.c b/ruby_2_2/ext/-test-/bug-3571/bug.c
new file mode 100644
index 0000000000..87a5df0588
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug-3571/bug.c
@@ -0,0 +1,23 @@
+#include <ruby.h>
+
+static VALUE
+bug_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
+{
+ rb_notimplement();
+ return ID2SYM(rb_frame_this_func());
+}
+
+static VALUE
+bug_start(VALUE self, VALUE hash)
+{
+ VALUE ary = rb_ary_new3(1, Qnil);
+ rb_block_call(ary, rb_intern("map"), 0, 0, bug_i, self);
+ return ary;
+}
+
+void
+Init_bug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "start", bug_start, 0);
+}
diff --git a/ruby_2_2/ext/-test-/bug-3571/extconf.rb b/ruby_2_2/ext/-test-/bug-3571/extconf.rb
new file mode 100644
index 0000000000..6390fce219
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug-3571/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug-3571/bug")
diff --git a/ruby_2_2/ext/-test-/bug-3662/bug.c b/ruby_2_2/ext/-test-/bug-3662/bug.c
new file mode 100644
index 0000000000..9375dace10
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug-3662/bug.c
@@ -0,0 +1,16 @@
+#include <ruby.h>
+
+static VALUE
+bug_funcall(int argc, VALUE *argv, VALUE self)
+{
+ if (argc < 1) rb_raise(rb_eArgError, "not enough argument");
+ return rb_funcall2(self, rb_to_id(*argv), argc-1, argv+1);
+}
+
+void
+Init_bug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "funcall", bug_funcall, -1);
+ rb_define_module_function(mBug, "notimplement", rb_f_notimplement, -1);
+}
diff --git a/ruby_2_2/ext/-test-/bug-3662/extconf.rb b/ruby_2_2/ext/-test-/bug-3662/extconf.rb
new file mode 100644
index 0000000000..7a1b73023c
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug-3662/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug-3662/bug")
diff --git a/ruby_2_2/ext/-test-/bug-5832/bug.c b/ruby_2_2/ext/-test-/bug-5832/bug.c
new file mode 100644
index 0000000000..67be5844b6
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug-5832/bug.c
@@ -0,0 +1,14 @@
+#include <ruby.h>
+
+static VALUE
+bug_funcall_callback(VALUE self, VALUE obj)
+{
+ return rb_funcall(obj, rb_intern("callback"), 0);
+}
+
+void
+Init_bug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "funcall_callback", bug_funcall_callback, 1);
+}
diff --git a/ruby_2_2/ext/-test-/bug-5832/extconf.rb b/ruby_2_2/ext/-test-/bug-5832/extconf.rb
new file mode 100644
index 0000000000..55a4b7d93f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug-5832/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug-5832/bug")
diff --git a/ruby_2_2/ext/-test-/bug_reporter/bug_reporter.c b/ruby_2_2/ext/-test-/bug_reporter/bug_reporter.c
new file mode 100644
index 0000000000..e9ea9e3db0
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug_reporter/bug_reporter.c
@@ -0,0 +1,24 @@
+#include <ruby.h>
+#include <stdio.h>
+
+int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
+
+static void
+sample_bug_reporter(FILE *out, void *ptr)
+{
+ int n = (int)(uintptr_t)ptr;
+ fprintf(out, "Sample bug reporter: %d\n", n);
+}
+
+static VALUE
+register_sample_bug_reporter(VALUE self, VALUE obj)
+{
+ rb_bug_reporter_add(sample_bug_reporter, (void *)(uintptr_t)NUM2INT(obj));
+ return Qnil;
+}
+
+void
+Init_bug_reporter(void)
+{
+ rb_define_global_function("register_sample_bug_reporter", register_sample_bug_reporter, 1);
+}
diff --git a/ruby_2_2/ext/-test-/bug_reporter/extconf.rb b/ruby_2_2/ext/-test-/bug_reporter/extconf.rb
new file mode 100644
index 0000000000..0fccd81a41
--- /dev/null
+++ b/ruby_2_2/ext/-test-/bug_reporter/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug_reporter/bug_reporter")
diff --git a/ruby_2_2/ext/-test-/class/class2name.c b/ruby_2_2/ext/-test-/class/class2name.c
new file mode 100644
index 0000000000..c48df6fb2a
--- /dev/null
+++ b/ruby_2_2/ext/-test-/class/class2name.c
@@ -0,0 +1,14 @@
+#include <ruby/ruby.h>
+
+static VALUE
+class2name(VALUE self, VALUE klass)
+{
+ const char *name = rb_class2name(klass);
+ return name ? rb_str_new_cstr(name) : Qnil;
+}
+
+void
+Init_class2name(VALUE klass)
+{
+ rb_define_singleton_method(klass, "class2name", class2name, 1);
+}
diff --git a/ruby_2_2/ext/-test-/class/extconf.rb b/ruby_2_2/ext/-test-/class/extconf.rb
new file mode 100644
index 0000000000..a07d660b87
--- /dev/null
+++ b/ruby_2_2/ext/-test-/class/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-/class")
diff --git a/ruby_2_2/ext/-test-/class/init.c b/ruby_2_2/ext/-test-/class/init.c
new file mode 100644
index 0000000000..ed715c1942
--- /dev/null
+++ b/ruby_2_2/ext/-test-/class/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE mod); Init_##n(mod);}
+
+void
+Init_class(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE mod = rb_define_module_under(mBug, "Class");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/debug/depend b/ruby_2_2/ext/-test-/debug/depend
new file mode 100644
index 0000000000..5178d85673
--- /dev/null
+++ b/ruby_2_2/ext/-test-/debug/depend
@@ -0,0 +1,32 @@
+# AUTOGENERATED DEPENDENCIES START
+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
+inspector.o: $(RUBY_EXTCONF_H)
+inspector.o: $(arch_hdrdir)/ruby/config.h
+inspector.o: $(hdrdir)/ruby/debug.h
+inspector.o: $(hdrdir)/ruby/defines.h
+inspector.o: $(hdrdir)/ruby/intern.h
+inspector.o: $(hdrdir)/ruby/missing.h
+inspector.o: $(hdrdir)/ruby/ruby.h
+inspector.o: $(hdrdir)/ruby/st.h
+inspector.o: $(hdrdir)/ruby/subst.h
+inspector.o: inspector.c
+profile_frames.o: $(RUBY_EXTCONF_H)
+profile_frames.o: $(arch_hdrdir)/ruby/config.h
+profile_frames.o: $(hdrdir)/ruby/debug.h
+profile_frames.o: $(hdrdir)/ruby/defines.h
+profile_frames.o: $(hdrdir)/ruby/intern.h
+profile_frames.o: $(hdrdir)/ruby/missing.h
+profile_frames.o: $(hdrdir)/ruby/ruby.h
+profile_frames.o: $(hdrdir)/ruby/st.h
+profile_frames.o: $(hdrdir)/ruby/subst.h
+profile_frames.o: profile_frames.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ruby_2_2/ext/-test-/debug/extconf.rb b/ruby_2_2/ext/-test-/debug/extconf.rb
new file mode 100644
index 0000000000..8f7922e1a6
--- /dev/null
+++ b/ruby_2_2/ext/-test-/debug/extconf.rb
@@ -0,0 +1,6 @@
+$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-/debug")
diff --git a/ruby_2_2/ext/-test-/debug/init.c b/ruby_2_2/ext/-test-/debug/init.c
new file mode 100644
index 0000000000..fe3979cbc5
--- /dev/null
+++ b/ruby_2_2/ext/-test-/debug/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_debug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Debug");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/debug/inspector.c b/ruby_2_2/ext/-test-/debug/inspector.c
new file mode 100644
index 0000000000..f0c58e59f9
--- /dev/null
+++ b/ruby_2_2/ext/-test-/debug/inspector.c
@@ -0,0 +1,32 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+static VALUE
+callback(const rb_debug_inspector_t *dbg_context, void *data)
+{
+ VALUE locs = rb_debug_inspector_backtrace_locations(dbg_context);
+ long i, len = RARRAY_LEN(locs);
+ VALUE binds = rb_ary_new();
+ for (i = 0; i < len; ++i) {
+ VALUE entry = rb_ary_new();
+ rb_ary_push(binds, entry);
+ rb_ary_push(entry, rb_debug_inspector_frame_self_get(dbg_context, i));
+ rb_ary_push(entry, rb_debug_inspector_frame_binding_get(dbg_context, i));
+ rb_ary_push(entry, rb_debug_inspector_frame_class_get(dbg_context, i));
+ rb_ary_push(entry, rb_debug_inspector_frame_iseq_get(dbg_context, i));
+ rb_ary_push(entry, rb_ary_entry(locs, i));
+ }
+ return binds;
+}
+
+static VALUE
+debug_inspector(VALUE self)
+{
+ return rb_debug_inspector_open(callback, NULL);
+}
+
+void
+Init_inspector(VALUE klass)
+{
+ rb_define_module_function(klass, "inspector", debug_inspector, 0);
+}
diff --git a/ruby_2_2/ext/-test-/debug/profile_frames.c b/ruby_2_2/ext/-test-/debug/profile_frames.c
new file mode 100644
index 0000000000..1656ff7d4b
--- /dev/null
+++ b/ruby_2_2/ext/-test-/debug/profile_frames.c
@@ -0,0 +1,43 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+#define MAX_BUF_SIZE 0x100
+
+static VALUE
+profile_frames(VALUE self, VALUE start_v, VALUE num_v)
+{
+ int i, collected_size;
+ int start = NUM2INT(start_v);
+ int buff_size = NUM2INT(num_v);
+ VALUE buff[MAX_BUF_SIZE];
+ int lines[MAX_BUF_SIZE];
+ VALUE result = rb_ary_new();
+
+ if (buff_size > MAX_BUF_SIZE) rb_raise(rb_eRuntimeError, "too long buff_size");
+
+ collected_size = rb_profile_frames(start, buff_size, buff, lines);
+
+ for (i=0; i<collected_size; i++) {
+ VALUE ary = rb_ary_new();
+ rb_ary_push(ary, rb_profile_frame_path(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_absolute_path(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_label(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_base_label(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_full_label(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_first_lineno(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_classpath(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_singleton_method_p(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_method_name(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_qualified_method_name(buff[i]));
+
+ rb_ary_push(result, ary);
+ }
+
+ return result;
+}
+
+void
+Init_profile_frames(VALUE klass)
+{
+ rb_define_module_function(klass, "profile_frames", profile_frames, 2);
+}
diff --git a/ruby_2_2/ext/-test-/dln/empty/empty.c b/ruby_2_2/ext/-test-/dln/empty/empty.c
new file mode 100644
index 0000000000..c4f94f1644
--- /dev/null
+++ b/ruby_2_2/ext/-test-/dln/empty/empty.c
@@ -0,0 +1,4 @@
+void
+Init_empty(void)
+{
+}
diff --git a/ruby_2_2/ext/-test-/dln/empty/extconf.rb b/ruby_2_2/ext/-test-/dln/empty/extconf.rb
new file mode 100644
index 0000000000..6110887b3d
--- /dev/null
+++ b/ruby_2_2/ext/-test-/dln/empty/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/dln/empty")
diff --git a/ruby_2_2/ext/-test-/exception/dataerror.c b/ruby_2_2/ext/-test-/exception/dataerror.c
new file mode 100644
index 0000000000..d8beba8aa4
--- /dev/null
+++ b/ruby_2_2/ext/-test-/exception/dataerror.c
@@ -0,0 +1,31 @@
+#include <ruby/ruby.h>
+
+static void
+dataerror_mark(void *ptr)
+{
+ rb_gc_mark((VALUE)ptr);
+}
+
+static void
+dataerror_free(void *ptr)
+{
+}
+
+static const rb_data_type_t dataerror_type = {
+ "Bug #9167",
+ {dataerror_mark, dataerror_free},
+};
+
+static VALUE
+dataerror_alloc(VALUE klass)
+{
+ VALUE n = rb_str_new_cstr("[Bug #9167] error");
+ return TypedData_Wrap_Struct(klass, &dataerror_type, (void *)n);
+}
+
+void
+Init_dataerror(VALUE klass)
+{
+ VALUE rb_eDataErr = rb_define_class_under(klass, "DataError", rb_eStandardError);
+ rb_define_alloc_func(rb_eDataErr, dataerror_alloc);
+}
diff --git a/ruby_2_2/ext/-test-/exception/depend b/ruby_2_2/ext/-test-/exception/depend
new file mode 100644
index 0000000000..a89ecf7a4f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/exception/depend
@@ -0,0 +1,43 @@
+# AUTOGENERATED DEPENDENCIES START
+dataerror.o: $(RUBY_EXTCONF_H)
+dataerror.o: $(arch_hdrdir)/ruby/config.h
+dataerror.o: $(hdrdir)/ruby/defines.h
+dataerror.o: $(hdrdir)/ruby/intern.h
+dataerror.o: $(hdrdir)/ruby/missing.h
+dataerror.o: $(hdrdir)/ruby/ruby.h
+dataerror.o: $(hdrdir)/ruby/st.h
+dataerror.o: $(hdrdir)/ruby/subst.h
+dataerror.o: dataerror.c
+enc_raise.o: $(RUBY_EXTCONF_H)
+enc_raise.o: $(arch_hdrdir)/ruby/config.h
+enc_raise.o: $(hdrdir)/ruby/defines.h
+enc_raise.o: $(hdrdir)/ruby/encoding.h
+enc_raise.o: $(hdrdir)/ruby/intern.h
+enc_raise.o: $(hdrdir)/ruby/missing.h
+enc_raise.o: $(hdrdir)/ruby/oniguruma.h
+enc_raise.o: $(hdrdir)/ruby/ruby.h
+enc_raise.o: $(hdrdir)/ruby/st.h
+enc_raise.o: $(hdrdir)/ruby/subst.h
+enc_raise.o: $(top_srcdir)/include/ruby.h
+enc_raise.o: enc_raise.c
+ensured.o: $(RUBY_EXTCONF_H)
+ensured.o: $(arch_hdrdir)/ruby/config.h
+ensured.o: $(hdrdir)/ruby/defines.h
+ensured.o: $(hdrdir)/ruby/intern.h
+ensured.o: $(hdrdir)/ruby/missing.h
+ensured.o: $(hdrdir)/ruby/ruby.h
+ensured.o: $(hdrdir)/ruby/st.h
+ensured.o: $(hdrdir)/ruby/subst.h
+ensured.o: $(top_srcdir)/include/ruby.h
+ensured.o: ensured.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
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ruby_2_2/ext/-test-/exception/enc_raise.c b/ruby_2_2/ext/-test-/exception/enc_raise.c
new file mode 100644
index 0000000000..dc8a42cf3f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/exception/enc_raise.c
@@ -0,0 +1,15 @@
+#include <ruby.h>
+#include <ruby/encoding.h>
+
+static VALUE
+enc_raise(VALUE exc, VALUE encoding, VALUE mesg)
+{
+ rb_enc_raise(rb_to_encoding(encoding), exc, "%s", StringValueCStr(mesg));
+ UNREACHABLE;
+}
+
+void
+Init_enc_raise(VALUE klass)
+{
+ rb_define_module_function(klass, "enc_raise", enc_raise, 2);
+}
diff --git a/ruby_2_2/ext/-test-/exception/ensured.c b/ruby_2_2/ext/-test-/exception/ensured.c
new file mode 100644
index 0000000000..365e1f4f79
--- /dev/null
+++ b/ruby_2_2/ext/-test-/exception/ensured.c
@@ -0,0 +1,25 @@
+#include <ruby.h>
+
+static VALUE
+begin(VALUE object)
+{
+ return rb_funcall(object, rb_intern("try_method"), 0);
+}
+
+static VALUE
+ensure(VALUE object)
+{
+ return rb_funcall(object, rb_intern("ensured_method"), 0);
+}
+
+static VALUE
+ensured(VALUE module, VALUE object)
+{
+ return rb_ensure(begin, object, ensure, object);
+}
+
+void
+Init_ensured(VALUE klass)
+{
+ rb_define_module_function(klass, "ensured", ensured, 1);
+}
diff --git a/ruby_2_2/ext/-test-/exception/extconf.rb b/ruby_2_2/ext/-test-/exception/extconf.rb
new file mode 100644
index 0000000000..0faf6d53ed
--- /dev/null
+++ b/ruby_2_2/ext/-test-/exception/extconf.rb
@@ -0,0 +1,6 @@
+$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-/exception")
diff --git a/ruby_2_2/ext/-test-/exception/init.c b/ruby_2_2/ext/-test-/exception/init.c
new file mode 100644
index 0000000000..853bb68f79
--- /dev/null
+++ b/ruby_2_2/ext/-test-/exception/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_exception(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Exception", rb_eStandardError);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/fatal/extconf.rb b/ruby_2_2/ext/-test-/fatal/extconf.rb
new file mode 100644
index 0000000000..e0cfeb2095
--- /dev/null
+++ b/ruby_2_2/ext/-test-/fatal/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/fatal/rb_fatal")
diff --git a/ruby_2_2/ext/-test-/fatal/rb_fatal.c b/ruby_2_2/ext/-test-/fatal/rb_fatal.c
new file mode 100644
index 0000000000..71aef4658a
--- /dev/null
+++ b/ruby_2_2/ext/-test-/fatal/rb_fatal.c
@@ -0,0 +1,19 @@
+#include <ruby.h>
+
+static VALUE
+ruby_fatal(VALUE obj, VALUE msg)
+{
+ const char *cmsg = NULL;
+
+ (void)obj;
+
+ cmsg = RSTRING_PTR(msg);
+ rb_fatal("%s", cmsg);
+ return 0; /* never reached */
+}
+
+void
+Init_rb_fatal(void)
+{
+ rb_define_method(rb_mKernel, "rb_fatal", ruby_fatal, 1);
+}
diff --git a/ruby_2_2/ext/-test-/file/depend b/ruby_2_2/ext/-test-/file/depend
new file mode 100644
index 0000000000..a43b4275dc
--- /dev/null
+++ b/ruby_2_2/ext/-test-/file/depend
@@ -0,0 +1,36 @@
+# AUTOGENERATED DEPENDENCIES START
+fs.o: $(RUBY_EXTCONF_H)
+fs.o: $(arch_hdrdir)/ruby/config.h
+fs.o: $(hdrdir)/ruby/defines.h
+fs.o: $(hdrdir)/ruby/encoding.h
+fs.o: $(hdrdir)/ruby/intern.h
+fs.o: $(hdrdir)/ruby/io.h
+fs.o: $(hdrdir)/ruby/missing.h
+fs.o: $(hdrdir)/ruby/oniguruma.h
+fs.o: $(hdrdir)/ruby/ruby.h
+fs.o: $(hdrdir)/ruby/st.h
+fs.o: $(hdrdir)/ruby/subst.h
+fs.o: fs.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
+stat.o: $(RUBY_EXTCONF_H)
+stat.o: $(arch_hdrdir)/ruby/config.h
+stat.o: $(hdrdir)/ruby/defines.h
+stat.o: $(hdrdir)/ruby/encoding.h
+stat.o: $(hdrdir)/ruby/intern.h
+stat.o: $(hdrdir)/ruby/io.h
+stat.o: $(hdrdir)/ruby/missing.h
+stat.o: $(hdrdir)/ruby/oniguruma.h
+stat.o: $(hdrdir)/ruby/ruby.h
+stat.o: $(hdrdir)/ruby/st.h
+stat.o: $(hdrdir)/ruby/subst.h
+stat.o: stat.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ruby_2_2/ext/-test-/file/extconf.rb b/ruby_2_2/ext/-test-/file/extconf.rb
new file mode 100644
index 0000000000..44aa828b25
--- /dev/null
+++ b/ruby_2_2/ext/-test-/file/extconf.rb
@@ -0,0 +1,22 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+
+headers = %w[sys/param.h sys/mount.h sys/vfs.h].select {|h| have_header(h)}
+if have_type("struct statfs", headers)
+ have_struct_member("struct statfs", "f_fstypename", headers)
+ have_struct_member("struct statfs", "f_type", headers)
+ have_struct_member("struct statfs", "f_flags", headers)
+end
+
+headers = %w[sys/statvfs.h].select {|h| have_header(h)}
+if have_type("struct statvfs", headers)
+ have_struct_member("struct statvfs", "f_fstypename", headers)
+ have_struct_member("struct statvfs", "f_basetype", headers)
+ have_struct_member("struct statvfs", "f_type", headers)
+end
+
+$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-/file")
diff --git a/ruby_2_2/ext/-test-/file/fs.c b/ruby_2_2/ext/-test-/file/fs.c
new file mode 100644
index 0000000000..657a7d20a5
--- /dev/null
+++ b/ruby_2_2/ext/-test-/file/fs.c
@@ -0,0 +1,105 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+#ifdef HAVE_SYS_MOUNT_H
+#include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_VFS_H
+#include <sys/vfs.h>
+#endif
+#ifdef HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#endif
+
+#if defined HAVE_STRUCT_STATFS_F_FSTYPENAME
+typedef struct statfs statfs_t;
+# define STATFS(f, s) statfs((f), (s))
+# define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
+# if defined HAVE_STRUCT_STATFS_F_TYPE
+# define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
+#elif defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME) /* NetBSD */
+typedef struct statvfs statfs_t;
+# define STATFS(f, s) statvfs((f), (s))
+# define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
+# if defined HAVE_STRUCT_STATVFS_F_TYPE
+# define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
+#elif defined(HAVE_STRUCT_STATVFS_F_BASETYPE) /* AIX, HP-UX, Solaris */
+typedef struct statvfs statfs_t;
+# define STATFS(f, s) statvfs((f), (s))
+# define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
+# define f_fstypename f_basetype
+# if defined HAVE_STRUCT_STATVFS_F_TYPE
+# define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
+#elif defined(HAVE_STRUCT_STATFS_F_TYPE) /* Linux */
+typedef struct statfs statfs_t;
+# define STATFS(f, s) statfs((f), (s))
+# if defined HAVE_STRUCT_STATFS_F_TYPE
+# define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
+#endif
+
+VALUE
+get_fsname(VALUE self, VALUE str)
+{
+#ifdef STATFS
+ statfs_t st;
+# define CSTR(s) rb_str_new_cstr(s)
+
+ FilePathValue(str);
+ str = rb_str_encode_ospath(str);
+ if (STATFS(StringValueCStr(str), &st) == -1) {
+ rb_sys_fail_str(str);
+ }
+# ifdef HAVE_STRUCT_STATFS_T_F_FSTYPENAME
+ if (st.f_fstypename[0])
+ return CSTR(st.f_fstypename);
+# endif
+# ifdef HAVE_STRUCT_STATFS_T_F_TYPE
+ switch (st.f_type) {
+ case 0x9123683E: /* BTRFS_SUPER_MAGIC */
+ return CSTR("btrfs");
+ case 0x7461636f: /* OCFS2_SUPER_MAGIC */
+ return CSTR("ocfs");
+ case 0xEF53: /* EXT2_SUPER_MAGIC EXT3_SUPER_MAGIC EXT4_SUPER_MAGIC */
+ return CSTR("ext4");
+ case 0x58465342: /* XFS_SUPER_MAGIC */
+ return CSTR("xfs");
+ case 0x01021994: /* TMPFS_MAGIC */
+ return CSTR("tmpfs");
+ }
+# endif
+#endif
+ return Qnil;
+}
+
+VALUE
+get_noatime_p(VALUE self, VALUE str)
+{
+#ifdef STATFS
+ statfs_t st;
+ FilePathValue(str);
+ str = rb_str_encode_ospath(str);
+ if (STATFS(StringValueCStr(str), &st) == -1) {
+ rb_sys_fail_str(str);
+ }
+# ifdef HAVE_STRUCT_STATFS_F_FLAGS
+# ifdef MNT_NOATIME
+ return st.f_flags & MNT_NOATIME ? Qtrue : Qfalse;
+# elif defined(ST_NOATIME)
+ return st.f_flags & ST_NOATIME ? Qtrue : Qfalse;
+# endif
+# endif
+#endif
+ return Qnil;
+}
+
+void
+Init_fs(VALUE module)
+{
+ VALUE fs = rb_define_module_under(module, "Fs");
+ rb_define_module_function(fs, "fsname", get_fsname, 1);
+ rb_define_module_function(fs, "noatime?", get_noatime_p, 1);
+}
diff --git a/ruby_2_2/ext/-test-/file/init.c b/ruby_2_2/ext/-test-/file/init.c
new file mode 100644
index 0000000000..1117993d6c
--- /dev/null
+++ b/ruby_2_2/ext/-test-/file/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(module);}
+
+void
+Init_file(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE module = rb_define_module_under(mBug, "File");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/file/stat.c b/ruby_2_2/ext/-test-/file/stat.c
new file mode 100644
index 0000000000..fed5d389eb
--- /dev/null
+++ b/ruby_2_2/ext/-test-/file/stat.c
@@ -0,0 +1,27 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+static VALUE
+stat_for_fd(VALUE self, VALUE fileno)
+{
+ struct stat st;
+ if (fstat(NUM2INT(fileno), &st)) rb_sys_fail(0);
+ return rb_stat_new(&st);
+}
+
+static VALUE
+stat_for_path(VALUE self, VALUE path)
+{
+ struct stat st;
+ FilePathValue(path);
+ if (stat(RSTRING_PTR(path), &st)) rb_sys_fail(0);
+ return rb_stat_new(&st);
+}
+
+void
+Init_stat(VALUE module)
+{
+ VALUE st = rb_define_module_under(module, "Stat");
+ rb_define_module_function(st, "for_fd", stat_for_fd, 1);
+ rb_define_module_function(st, "for_path", stat_for_path, 1);
+}
diff --git a/ruby_2_2/ext/-test-/float/depend b/ruby_2_2/ext/-test-/float/depend
new file mode 100644
index 0000000000..dff14550f7
--- /dev/null
+++ b/ruby_2_2/ext/-test-/float/depend
@@ -0,0 +1,3 @@
+$(OBJS): $(HDRS) $(ruby_headers)
+
+nextafter.o: nextafter.c $(top_srcdir)/missing/nextafter.c
diff --git a/ruby_2_2/ext/-test-/float/extconf.rb b/ruby_2_2/ext/-test-/float/extconf.rb
new file mode 100644
index 0000000000..0a9a299aa5
--- /dev/null
+++ b/ruby_2_2/ext/-test-/float/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-/float")
diff --git a/ruby_2_2/ext/-test-/float/init.c b/ruby_2_2/ext/-test-/float/init.c
new file mode 100644
index 0000000000..d962108e39
--- /dev/null
+++ b/ruby_2_2/ext/-test-/float/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_float(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Float", rb_cObject);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/float/nextafter.c b/ruby_2_2/ext/-test-/float/nextafter.c
new file mode 100644
index 0000000000..30fb71f520
--- /dev/null
+++ b/ruby_2_2/ext/-test-/float/nextafter.c
@@ -0,0 +1,36 @@
+#include "ruby.h"
+
+static VALUE
+system_nextafter_m(VALUE klass, VALUE vx, VALUE vy)
+{
+ double x, y, z;
+
+ x = NUM2DBL(vx);
+ y = NUM2DBL(vy);
+ z = nextafter(x, y);
+
+ return DBL2NUM(z);
+}
+
+#define nextafter missing_nextafter
+#include "../../../missing/nextafter.c"
+#undef nextafter
+
+static VALUE
+missing_nextafter_m(VALUE klass, VALUE vx, VALUE vy)
+{
+ double x, y, z;
+
+ x = NUM2DBL(vx);
+ y = NUM2DBL(vy);
+ z = missing_nextafter(x, y);
+
+ return DBL2NUM(z);
+}
+
+void
+Init_nextafter(VALUE klass)
+{
+ rb_define_singleton_method(klass, "system_nextafter", system_nextafter_m, 2);
+ rb_define_singleton_method(klass, "missing_nextafter", missing_nextafter_m, 2);
+}
diff --git a/ruby_2_2/ext/-test-/funcall/extconf.rb b/ruby_2_2/ext/-test-/funcall/extconf.rb
new file mode 100644
index 0000000000..8a9179ab2f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/funcall/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile("-test-/funcall/funcall")
diff --git a/ruby_2_2/ext/-test-/funcall/passing_block.c b/ruby_2_2/ext/-test-/funcall/passing_block.c
new file mode 100644
index 0000000000..0200f80369
--- /dev/null
+++ b/ruby_2_2/ext/-test-/funcall/passing_block.c
@@ -0,0 +1,30 @@
+#include "ruby.h"
+
+VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
+
+static VALUE
+with_funcall2(int argc, VALUE *argv, VALUE self)
+{
+ return rb_funcall2(self, rb_intern("target"), argc, argv);
+}
+
+static VALUE
+with_funcall_passing_block(int argc, VALUE *argv, VALUE self)
+{
+ return rb_funcall_passing_block(self, rb_intern("target"), argc, argv);
+}
+
+void
+Init_funcall(void)
+{
+ VALUE cRelay = rb_path2class("TestFuncall::Relay");
+
+ rb_define_singleton_method(cRelay,
+ "with_funcall2",
+ with_funcall2,
+ -1);
+ rb_define_singleton_method(cRelay,
+ "with_funcall_passing_block",
+ with_funcall_passing_block,
+ -1);
+}
diff --git a/ruby_2_2/ext/-test-/hash/delete.c b/ruby_2_2/ext/-test-/hash/delete.c
new file mode 100644
index 0000000000..10d4aec6e7
--- /dev/null
+++ b/ruby_2_2/ext/-test-/hash/delete.c
@@ -0,0 +1,16 @@
+#include "ruby.h"
+
+extern VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
+
+static VALUE
+hash_delete(VALUE hash, VALUE key)
+{
+ VALUE ret = rb_hash_delete_entry(hash, key);
+ return ret == Qundef ? Qnil : rb_ary_new_from_values(1, &ret);
+}
+
+void
+Init_delete(VALUE klass)
+{
+ rb_define_method(klass, "delete!", hash_delete, 1);
+}
diff --git a/ruby_2_2/ext/-test-/hash/extconf.rb b/ruby_2_2/ext/-test-/hash/extconf.rb
new file mode 100644
index 0000000000..9d4ef4f935
--- /dev/null
+++ b/ruby_2_2/ext/-test-/hash/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-/hash")
diff --git a/ruby_2_2/ext/-test-/hash/init.c b/ruby_2_2/ext/-test-/hash/init.c
new file mode 100644
index 0000000000..9f6cbde652
--- /dev/null
+++ b/ruby_2_2/ext/-test-/hash/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_hash(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Hash", rb_cHash);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/iseq_load/extconf.rb b/ruby_2_2/ext/-test-/iseq_load/extconf.rb
new file mode 100644
index 0000000000..860f30befd
--- /dev/null
+++ b/ruby_2_2/ext/-test-/iseq_load/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/iseq_load/iseq_load")
diff --git a/ruby_2_2/ext/-test-/iseq_load/iseq_load.c b/ruby_2_2/ext/-test-/iseq_load/iseq_load.c
new file mode 100644
index 0000000000..b4b9a8aa3d
--- /dev/null
+++ b/ruby_2_2/ext/-test-/iseq_load/iseq_load.c
@@ -0,0 +1,21 @@
+#include <ruby.h>
+
+VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
+
+static VALUE
+iseq_load(int argc, VALUE *argv, VALUE self)
+{
+ VALUE data, opt = Qnil;
+
+ rb_scan_args(argc, argv, "11", &data, &opt);
+
+ return rb_iseq_load(data, 0, opt);
+}
+
+void
+Init_iseq_load(void)
+{
+ VALUE rb_cISeq = rb_path2class("RubyVM::InstructionSequence");
+
+ rb_define_singleton_method(rb_cISeq, "iseq_load", iseq_load, -1);
+}
diff --git a/ruby_2_2/ext/-test-/iter/break.c b/ruby_2_2/ext/-test-/iter/break.c
new file mode 100644
index 0000000000..66ed26a9b8
--- /dev/null
+++ b/ruby_2_2/ext/-test-/iter/break.c
@@ -0,0 +1,25 @@
+#include <ruby.h>
+
+static VALUE
+iter_break(VALUE self)
+{
+ rb_iter_break();
+
+ UNREACHABLE;
+}
+
+static VALUE
+iter_break_value(VALUE self, VALUE val)
+{
+ rb_iter_break_value(val);
+
+ UNREACHABLE;
+}
+
+void
+Init_break(VALUE klass)
+{
+ VALUE breakable = rb_define_module_under(klass, "Breakable");
+ rb_define_module_function(breakable, "iter_break", iter_break, 0);
+ rb_define_module_function(breakable, "iter_break_value", iter_break_value, 1);
+}
diff --git a/ruby_2_2/ext/-test-/iter/extconf.rb b/ruby_2_2/ext/-test-/iter/extconf.rb
new file mode 100644
index 0000000000..0ba99691bd
--- /dev/null
+++ b/ruby_2_2/ext/-test-/iter/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-/iter")
diff --git a/ruby_2_2/ext/-test-/iter/init.c b/ruby_2_2/ext/-test-/iter/init.c
new file mode 100644
index 0000000000..a074ec46a9
--- /dev/null
+++ b/ruby_2_2/ext/-test-/iter/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_iter(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Iter");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/iter/yield.c b/ruby_2_2/ext/-test-/iter/yield.c
new file mode 100644
index 0000000000..3cd408a928
--- /dev/null
+++ b/ruby_2_2/ext/-test-/iter/yield.c
@@ -0,0 +1,16 @@
+#include <ruby.h>
+
+static VALUE
+yield_block(int argc, VALUE *argv, VALUE self)
+{
+ rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
+ return rb_block_call(self, rb_to_id(argv[0]), argc-1, argv+1, rb_yield_block, 0);
+}
+
+void
+Init_yield(VALUE klass)
+{
+ VALUE yield = rb_define_module_under(klass, "Yield");
+
+ rb_define_method(yield, "yield_block", yield_block, -1);
+}
diff --git a/ruby_2_2/ext/-test-/load/dot.dot/dot.dot.c b/ruby_2_2/ext/-test-/load/dot.dot/dot.dot.c
new file mode 100644
index 0000000000..936d28931a
--- /dev/null
+++ b/ruby_2_2/ext/-test-/load/dot.dot/dot.dot.c
@@ -0,0 +1 @@
+void Init_dot(void) {}
diff --git a/ruby_2_2/ext/-test-/load/dot.dot/extconf.rb b/ruby_2_2/ext/-test-/load/dot.dot/extconf.rb
new file mode 100644
index 0000000000..6287db6bd8
--- /dev/null
+++ b/ruby_2_2/ext/-test-/load/dot.dot/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/load/dot.dot/dot.dot")
diff --git a/ruby_2_2/ext/-test-/marshal/compat/extconf.rb b/ruby_2_2/ext/-test-/marshal/compat/extconf.rb
new file mode 100644
index 0000000000..bb11ebfb8c
--- /dev/null
+++ b/ruby_2_2/ext/-test-/marshal/compat/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/marshal/compat")
diff --git a/ruby_2_2/ext/-test-/marshal/compat/usrcompat.c b/ruby_2_2/ext/-test-/marshal/compat/usrcompat.c
new file mode 100644
index 0000000000..f812df5631
--- /dev/null
+++ b/ruby_2_2/ext/-test-/marshal/compat/usrcompat.c
@@ -0,0 +1,32 @@
+#include <ruby.h>
+
+static VALUE
+usr_dumper(VALUE self)
+{
+ return self;
+}
+
+static VALUE
+usr_loader(VALUE self, VALUE m)
+{
+ VALUE val = rb_ivar_get(m, rb_intern("@value"));
+ *(int *)DATA_PTR(self) = NUM2INT(val);
+ return self;
+}
+
+static VALUE
+compat_mload(VALUE self, VALUE data)
+{
+ rb_ivar_set(self, rb_intern("@value"), data);
+ return self;
+}
+
+void
+Init_compat(void)
+{
+ VALUE newclass = rb_path2class("Bug::Marshal::UsrMarshal");
+ VALUE oldclass = rb_define_class_under(newclass, "compat", rb_cObject);
+
+ rb_define_method(oldclass, "marshal_load", compat_mload, 1);
+ rb_marshal_define_compat(newclass, oldclass, usr_dumper, usr_loader);
+}
diff --git a/ruby_2_2/ext/-test-/marshal/usr/extconf.rb b/ruby_2_2/ext/-test-/marshal/usr/extconf.rb
new file mode 100644
index 0000000000..c662b23dd5
--- /dev/null
+++ b/ruby_2_2/ext/-test-/marshal/usr/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/marshal/usr")
diff --git a/ruby_2_2/ext/-test-/marshal/usr/usrmarshal.c b/ruby_2_2/ext/-test-/marshal/usr/usrmarshal.c
new file mode 100644
index 0000000000..0c9e079af2
--- /dev/null
+++ b/ruby_2_2/ext/-test-/marshal/usr/usrmarshal.c
@@ -0,0 +1,50 @@
+#include <ruby.h>
+
+static size_t
+usr_size(const void *ptr)
+{
+ return sizeof(int);
+}
+
+static const rb_data_type_t usrmarshal_type = {
+ "UsrMarshal",
+ {0, RUBY_DEFAULT_FREE, usr_size,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
+};
+
+static VALUE
+usr_alloc(VALUE klass)
+{
+ int *p;
+ return TypedData_Make_Struct(klass, int, &usrmarshal_type, p);
+}
+
+static VALUE
+usr_init(VALUE self, VALUE val)
+{
+ int *ptr = Check_TypedStruct(self, &usrmarshal_type);
+ *ptr = NUM2INT(val);
+ return self;
+}
+
+static VALUE
+usr_value(VALUE self)
+{
+ int *ptr = Check_TypedStruct(self, &usrmarshal_type);
+ int val = *ptr;
+ return INT2NUM(val);
+}
+
+void
+Init_usr(void)
+{
+ VALUE mMarshal = rb_define_module_under(rb_define_module("Bug"), "Marshal");
+ VALUE newclass = rb_define_class_under(mMarshal, "UsrMarshal", rb_cObject);
+
+ rb_define_alloc_func(newclass, usr_alloc);
+ rb_define_method(newclass, "initialize", usr_init, 1);
+ rb_define_method(newclass, "value", usr_value, 0);
+ rb_define_method(newclass, "marshal_load", usr_init, 1);
+ rb_define_method(newclass, "marshal_dump", usr_value, 0);
+}
diff --git a/ruby_2_2/ext/-test-/method/arity.c b/ruby_2_2/ext/-test-/method/arity.c
new file mode 100644
index 0000000000..239b9f7f10
--- /dev/null
+++ b/ruby_2_2/ext/-test-/method/arity.c
@@ -0,0 +1,22 @@
+#include "ruby.h"
+
+static VALUE
+obj_method_arity(VALUE self, VALUE obj, VALUE mid)
+{
+ int arity = rb_obj_method_arity(obj, rb_check_id(&mid));
+ return INT2FIX(arity);
+}
+
+static VALUE
+mod_method_arity(VALUE self, VALUE mod, VALUE mid)
+{
+ int arity = rb_mod_method_arity(mod, rb_check_id(&mid));
+ return INT2FIX(arity);
+}
+
+void
+Init_arity(VALUE mod)
+{
+ rb_define_module_function(mod, "obj_method_arity", obj_method_arity, 2);
+ rb_define_module_function(mod, "mod_method_arity", mod_method_arity, 2);
+}
diff --git a/ruby_2_2/ext/-test-/method/extconf.rb b/ruby_2_2/ext/-test-/method/extconf.rb
new file mode 100644
index 0000000000..658b7af1f1
--- /dev/null
+++ b/ruby_2_2/ext/-test-/method/extconf.rb
@@ -0,0 +1,6 @@
+$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-/method")
diff --git a/ruby_2_2/ext/-test-/method/init.c b/ruby_2_2/ext/-test-/method/init.c
new file mode 100644
index 0000000000..cea2346240
--- /dev/null
+++ b/ruby_2_2/ext/-test-/method/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_method(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Method");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/num2int/extconf.rb b/ruby_2_2/ext/-test-/num2int/extconf.rb
new file mode 100644
index 0000000000..2bc820e480
--- /dev/null
+++ b/ruby_2_2/ext/-test-/num2int/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/num2int/num2int")
diff --git a/ruby_2_2/ext/-test-/num2int/num2int.c b/ruby_2_2/ext/-test-/num2int/num2int.c
new file mode 100644
index 0000000000..3aec3ccf3b
--- /dev/null
+++ b/ruby_2_2/ext/-test-/num2int/num2int.c
@@ -0,0 +1,136 @@
+#include <ruby.h>
+
+static VALUE
+test_num2short(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", NUM2SHORT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2ushort(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%u", NUM2USHORT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2int(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", NUM2INT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2uint(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%u", NUM2UINT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2long(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%ld", NUM2LONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2ulong(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%lu", NUM2ULONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+#ifdef HAVE_LONG_LONG
+static VALUE
+test_num2ll(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2ull(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
+ return rb_str_new_cstr(buf);
+}
+#endif
+
+static VALUE
+test_fix2short(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", FIX2SHORT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2int(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", FIX2INT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2uint(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%u", FIX2UINT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2long(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%ld", FIX2LONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2ulong(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%lu", FIX2ULONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+void
+Init_num2int(void)
+{
+ VALUE mNum2int = rb_define_module("Num2int");
+
+ rb_define_module_function(mNum2int, "NUM2SHORT", test_num2short, 1);
+ rb_define_module_function(mNum2int, "NUM2USHORT", test_num2ushort, 1);
+
+ rb_define_module_function(mNum2int, "NUM2INT", test_num2int, 1);
+ rb_define_module_function(mNum2int, "NUM2UINT", test_num2uint, 1);
+
+ rb_define_module_function(mNum2int, "NUM2LONG", test_num2long, 1);
+ rb_define_module_function(mNum2int, "NUM2ULONG", test_num2ulong, 1);
+
+#ifdef HAVE_LONG_LONG
+ rb_define_module_function(mNum2int, "NUM2LL", test_num2ll, 1);
+ rb_define_module_function(mNum2int, "NUM2ULL", test_num2ull, 1);
+#endif
+
+ rb_define_module_function(mNum2int, "FIX2SHORT", test_fix2short, 1);
+
+ rb_define_module_function(mNum2int, "FIX2INT", test_fix2int, 1);
+ rb_define_module_function(mNum2int, "FIX2UINT", test_fix2uint, 1);
+
+ rb_define_module_function(mNum2int, "FIX2LONG", test_fix2long, 1);
+ rb_define_module_function(mNum2int, "FIX2ULONG", test_fix2ulong, 1);
+}
+
diff --git a/ruby_2_2/ext/-test-/path_to_class/extconf.rb b/ruby_2_2/ext/-test-/path_to_class/extconf.rb
new file mode 100644
index 0000000000..e1072b1443
--- /dev/null
+++ b/ruby_2_2/ext/-test-/path_to_class/extconf.rb
@@ -0,0 +1,6 @@
+$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-/path_to_class/path_to_class")
diff --git a/ruby_2_2/ext/-test-/path_to_class/path_to_class.c b/ruby_2_2/ext/-test-/path_to_class/path_to_class.c
new file mode 100644
index 0000000000..c8c2831b09
--- /dev/null
+++ b/ruby_2_2/ext/-test-/path_to_class/path_to_class.c
@@ -0,0 +1,15 @@
+#include "ruby.h"
+
+static VALUE
+path_to_class(VALUE klass, VALUE path)
+{
+ return rb_path_to_class(path);
+}
+
+void
+Init_path_to_class(void)
+{
+ VALUE klass = rb_path2class("Test_PathToClass");
+
+ rb_define_singleton_method(klass, "path_to_class", path_to_class, 1);
+}
diff --git a/ruby_2_2/ext/-test-/postponed_job/depend b/ruby_2_2/ext/-test-/postponed_job/depend
new file mode 100644
index 0000000000..d672e53f00
--- /dev/null
+++ b/ruby_2_2/ext/-test-/postponed_job/depend
@@ -0,0 +1 @@
+postponed_job.o: $(HDRS) $(ruby_headers) $(hdrdir)/ruby/debug.h
diff --git a/ruby_2_2/ext/-test-/postponed_job/extconf.rb b/ruby_2_2/ext/-test-/postponed_job/extconf.rb
new file mode 100644
index 0000000000..aa29b593f4
--- /dev/null
+++ b/ruby_2_2/ext/-test-/postponed_job/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/postponed_job')
diff --git a/ruby_2_2/ext/-test-/postponed_job/postponed_job.c b/ruby_2_2/ext/-test-/postponed_job/postponed_job.c
new file mode 100644
index 0000000000..157230e33b
--- /dev/null
+++ b/ruby_2_2/ext/-test-/postponed_job/postponed_job.c
@@ -0,0 +1,53 @@
+#include "ruby.h"
+#include "ruby/debug.h"
+
+static void
+pjob_callback(void *data)
+{
+ VALUE ary = (VALUE)data;
+ Check_Type(ary, T_ARRAY);
+
+ rb_ary_replace(ary, rb_funcall(Qnil, rb_intern("caller"), 0));
+}
+
+static VALUE
+pjob_register(VALUE self, VALUE obj)
+{
+ rb_postponed_job_register(0, pjob_callback, (void *)obj);
+ return self;
+}
+
+static void
+pjob_one_callback(void *data)
+{
+ VALUE ary = (VALUE)data;
+ Check_Type(ary, T_ARRAY);
+
+ rb_ary_push(ary, INT2FIX(1));
+}
+
+static VALUE
+pjob_register_one(VALUE self, VALUE obj)
+{
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ return self;
+}
+
+static VALUE
+pjob_call_direct(VALUE self, VALUE obj)
+{
+ pjob_callback((void *)obj);
+ return self;
+}
+
+void
+Init_postponed_job(VALUE self)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1);
+ rb_define_module_function(mBug, "postponed_job_register_one", pjob_register_one, 1);
+ rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1);
+}
+
diff --git a/ruby_2_2/ext/-test-/printf/depend b/ruby_2_2/ext/-test-/printf/depend
new file mode 100644
index 0000000000..79b6c53f50
--- /dev/null
+++ b/ruby_2_2/ext/-test-/printf/depend
@@ -0,0 +1,3 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/ruby_2_2/ext/-test-/printf/extconf.rb b/ruby_2_2/ext/-test-/printf/extconf.rb
new file mode 100644
index 0000000000..7b96da0c85
--- /dev/null
+++ b/ruby_2_2/ext/-test-/printf/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/printf")
diff --git a/ruby_2_2/ext/-test-/printf/printf.c b/ruby_2_2/ext/-test-/printf/printf.c
new file mode 100644
index 0000000000..666f5592e5
--- /dev/null
+++ b/ruby_2_2/ext/-test-/printf/printf.c
@@ -0,0 +1,101 @@
+#include <ruby.h>
+#include <ruby/encoding.h>
+
+static VALUE
+printf_test_s(VALUE self, VALUE obj)
+{
+ return rb_enc_sprintf(rb_usascii_encoding(), "<%"PRIsVALUE">", obj);
+}
+
+static VALUE
+printf_test_v(VALUE self, VALUE obj)
+{
+ return rb_enc_sprintf(rb_usascii_encoding(), "{%+"PRIsVALUE"}", obj);
+}
+
+static VALUE
+printf_test_q(VALUE self, VALUE obj)
+{
+ return rb_enc_sprintf(rb_usascii_encoding(), "[% "PRIsVALUE"]", obj);
+}
+
+static char *
+uint_to_str(char *p, char *e, unsigned int x)
+{
+ char *e0 = e;
+ if (e <= p) return p;
+ do {
+ *--e = x % 10 + '0';
+ } while ((x /= 10) != 0 && e > p);
+ memmove(p, e, e0 - e);
+ return p + (e0 - e);
+}
+
+static VALUE
+printf_test_call(int argc, VALUE *argv, VALUE self)
+{
+ VALUE opt, type, num, result;
+ char format[sizeof(int) * 6 + 8], *p = format, cnv;
+ int n = 0;
+ const char *s = 0;
+
+ rb_scan_args(argc, argv, "2:", &type, &num, &opt);
+ Check_Type(type, T_STRING);
+ if (RSTRING_LEN(type) != 1) rb_raise(rb_eArgError, "wrong length(%ld)", RSTRING_LEN(type));
+ switch (cnv = RSTRING_PTR(type)[0]) {
+ case 'd': case 'x': case 'o': case 'X':
+ n = NUM2INT(num);
+ break;
+ case 's':
+ s = StringValueCStr(num);
+ break;
+ default: rb_raise(rb_eArgError, "wrong conversion(%c)", cnv);
+ }
+ *p++ = '%';
+ if (!NIL_P(opt)) {
+ VALUE v;
+ Check_Type(opt, T_HASH);
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("space"))))) {
+ *p++ = ' ';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("hash"))))) {
+ *p++ = '#';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("plus"))))) {
+ *p++ = '+';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("minus"))))) {
+ *p++ = '-';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("zero"))))) {
+ *p++ = '0';
+ }
+ if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("width"))))) {
+ p = uint_to_str(p, format + sizeof(format), NUM2UINT(v));
+ }
+ if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("prec"))))) {
+ *p++ = '.';
+ if (FIXNUM_P(v))
+ p = uint_to_str(p, format + sizeof(format), NUM2UINT(v));
+ }
+ }
+ *p++ = cnv;
+ *p++ = '\0';
+ if (cnv == 's') {
+ result = rb_enc_sprintf(rb_usascii_encoding(), format, s);
+ }
+ else {
+ result = rb_enc_sprintf(rb_usascii_encoding(), format, n);
+ }
+ return rb_assoc_new(result, rb_usascii_str_new_cstr(format));
+}
+
+void
+Init_printf(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Printf");
+ rb_define_singleton_method(m, "s", printf_test_s, 1);
+ rb_define_singleton_method(m, "v", printf_test_v, 1);
+ rb_define_singleton_method(m, "q", printf_test_q, 1);
+ rb_define_singleton_method(m, "call", printf_test_call, -1);
+}
diff --git a/ruby_2_2/ext/-test-/proc/extconf.rb b/ruby_2_2/ext/-test-/proc/extconf.rb
new file mode 100644
index 0000000000..40741d07cc
--- /dev/null
+++ b/ruby_2_2/ext/-test-/proc/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-/proc")
diff --git a/ruby_2_2/ext/-test-/proc/init.c b/ruby_2_2/ext/-test-/proc/init.c
new file mode 100644
index 0000000000..814c55d98b
--- /dev/null
+++ b/ruby_2_2/ext/-test-/proc/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_proc(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Proc");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/proc/receiver.c b/ruby_2_2/ext/-test-/proc/receiver.c
new file mode 100644
index 0000000000..fe44a2246c
--- /dev/null
+++ b/ruby_2_2/ext/-test-/proc/receiver.c
@@ -0,0 +1,21 @@
+#include "ruby.h"
+
+VALUE rb_current_receiver(void);
+
+static VALUE
+bug_proc_call_receiver(RB_BLOCK_CALL_FUNC_ARGLIST(yieldarg, procarg))
+{
+ return rb_current_receiver();
+}
+
+static VALUE
+bug_proc_make_call_receiver(VALUE self, VALUE procarg)
+{
+ return rb_proc_new(bug_proc_call_receiver, procarg);
+}
+
+void
+Init_receiver(VALUE klass)
+{
+ rb_define_singleton_method(klass, "make_call_receiver", bug_proc_make_call_receiver, 1);
+}
diff --git a/ruby_2_2/ext/-test-/proc/super.c b/ruby_2_2/ext/-test-/proc/super.c
new file mode 100644
index 0000000000..dbe8af08f1
--- /dev/null
+++ b/ruby_2_2/ext/-test-/proc/super.c
@@ -0,0 +1,27 @@
+#include "ruby.h"
+
+static VALUE
+bug_proc_call_super(RB_BLOCK_CALL_FUNC_ARGLIST(yieldarg, procarg))
+{
+ VALUE args[2];
+ VALUE ret;
+ args[0] = yieldarg;
+ args[1] = procarg;
+ ret = rb_call_super(2, args);
+ if (!NIL_P(blockarg)) {
+ ret = rb_proc_call(blockarg, ret);
+ }
+ return ret;
+}
+
+static VALUE
+bug_proc_make_call_super(VALUE self, VALUE procarg)
+{
+ return rb_proc_new(bug_proc_call_super, procarg);
+}
+
+void
+Init_super(VALUE klass)
+{
+ rb_define_singleton_method(klass, "make_call_super", bug_proc_make_call_super, 1);
+}
diff --git a/ruby_2_2/ext/-test-/rational/depend b/ruby_2_2/ext/-test-/rational/depend
new file mode 100644
index 0000000000..bff4981ed6
--- /dev/null
+++ b/ruby_2_2/ext/-test-/rational/depend
@@ -0,0 +1,20 @@
+$(OBJS): $(HDRS) $(ruby_headers)
+
+rat.o: rat.c $(top_srcdir)/internal.h
+
+# AUTOGENERATED DEPENDENCIES START
+rat.o: $(RUBY_EXTCONF_H)
+rat.o: $(arch_hdrdir)/ruby/config.h
+rat.o: $(hdrdir)/ruby/defines.h
+rat.o: $(hdrdir)/ruby/encoding.h
+rat.o: $(hdrdir)/ruby/intern.h
+rat.o: $(hdrdir)/ruby/io.h
+rat.o: $(hdrdir)/ruby/missing.h
+rat.o: $(hdrdir)/ruby/oniguruma.h
+rat.o: $(hdrdir)/ruby/ruby.h
+rat.o: $(hdrdir)/ruby/st.h
+rat.o: $(hdrdir)/ruby/subst.h
+rat.o: $(top_srcdir)/include/ruby.h
+rat.o: $(top_srcdir)/internal.h
+rat.o: rat.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ruby_2_2/ext/-test-/rational/extconf.rb b/ruby_2_2/ext/-test-/rational/extconf.rb
new file mode 100644
index 0000000000..bd658def46
--- /dev/null
+++ b/ruby_2_2/ext/-test-/rational/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-/rational")
diff --git a/ruby_2_2/ext/-test-/rational/rat.c b/ruby_2_2/ext/-test-/rational/rat.c
new file mode 100644
index 0000000000..772546fca8
--- /dev/null
+++ b/ruby_2_2/ext/-test-/rational/rat.c
@@ -0,0 +1,37 @@
+#include "internal.h"
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_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));
+}
+#endif
+
+static VALUE
+gcd_normal(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_gcd_normal(rb_to_int(x), rb_to_int(y)));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+gcd_gmp(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_gcd_gmp(big(x), big(y)));
+}
+#else
+#define gcd_gmp rb_f_notimplement
+#endif
+
+void
+Init_rational(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "gcd_normal", gcd_normal, 1);
+ rb_define_method(rb_cInteger, "gcd_gmp", gcd_gmp, 1);
+}
diff --git a/ruby_2_2/ext/-test-/recursion/extconf.rb b/ruby_2_2/ext/-test-/recursion/extconf.rb
new file mode 100644
index 0000000000..92b28657f0
--- /dev/null
+++ b/ruby_2_2/ext/-test-/recursion/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile("-test-/recursion")
diff --git a/ruby_2_2/ext/-test-/recursion/recursion.c b/ruby_2_2/ext/-test-/recursion/recursion.c
new file mode 100644
index 0000000000..13d41f0ba8
--- /dev/null
+++ b/ruby_2_2/ext/-test-/recursion/recursion.c
@@ -0,0 +1,28 @@
+#include <ruby.h>
+
+static VALUE
+recursive_i(VALUE obj, VALUE mid, int recur)
+{
+ if (recur) return Qnil;
+ return rb_funcallv(obj, rb_to_id(mid), 0, 0);
+}
+
+static VALUE
+exec_recursive(VALUE self, VALUE mid)
+{
+ return rb_exec_recursive(recursive_i, self, mid);
+}
+
+static VALUE
+exec_recursive_outer(VALUE self, VALUE mid)
+{
+ return rb_exec_recursive_outer(recursive_i, self, mid);
+}
+
+void
+Init_recursion(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Recursive");
+ rb_define_method(m, "exec_recursive", exec_recursive, 1);
+ rb_define_method(m, "exec_recursive_outer", exec_recursive_outer, 1);
+}
diff --git a/ruby_2_2/ext/-test-/st/foreach/extconf.rb b/ruby_2_2/ext/-test-/st/foreach/extconf.rb
new file mode 100644
index 0000000000..969f386ff9
--- /dev/null
+++ b/ruby_2_2/ext/-test-/st/foreach/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/st/foreach")
diff --git a/ruby_2_2/ext/-test-/st/foreach/foreach.c b/ruby_2_2/ext/-test-/st/foreach/foreach.c
new file mode 100644
index 0000000000..1e0fd515c9
--- /dev/null
+++ b/ruby_2_2/ext/-test-/st/foreach/foreach.c
@@ -0,0 +1,175 @@
+#include <ruby.h>
+#include <ruby/st.h>
+
+static st_data_t expect_size = 32;
+struct checker {
+ st_table *tbl;
+ st_index_t nr;
+ VALUE test;
+};
+
+static void
+force_unpack_check(struct checker *c, st_data_t key, st_data_t val)
+{
+ if (c->nr == 0) {
+ st_data_t i;
+
+ if (!c->tbl->entries_packed) rb_bug("should be packed\n");
+
+ /* force unpacking during iteration: */
+ for (i = 1; i < expect_size; i++)
+ st_add_direct(c->tbl, i, i);
+
+ if (c->tbl->entries_packed) rb_bug("should be unpacked\n");
+ }
+
+ if (key != c->nr) {
+ rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)key, (VALUE)c->nr);
+ }
+ if (val != c->nr) {
+ rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)val, (VALUE)c->nr);
+ }
+
+ c->nr++;
+}
+
+static int
+unp_fec_i(st_data_t key, st_data_t val, st_data_t args, int error)
+{
+ struct checker *c = (struct checker *)args;
+
+ if (error) {
+ if (c->test == ID2SYM(rb_intern("delete2")))
+ return ST_STOP;
+
+ rb_bug("unexpected error");
+ }
+
+ force_unpack_check(c, key, val);
+
+ if (c->test == ID2SYM(rb_intern("check"))) {
+ return ST_CHECK;
+ }
+ if (c->test == ID2SYM(rb_intern("delete1"))) {
+ if (c->nr == 1) return ST_DELETE;
+ return ST_CHECK;
+ }
+ if (c->test == ID2SYM(rb_intern("delete2"))) {
+ if (c->nr == 1) {
+ st_data_t k = 0;
+ st_data_t v;
+
+ if (!st_delete(c->tbl, &k, &v)) {
+ rb_bug("failed to delete\n");
+ }
+ if (v != 0) {
+ rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
+ }
+ }
+ return ST_CHECK;
+ }
+
+ rb_raise(rb_eArgError, "unexpected arg: %+"PRIsVALUE, c->test);
+}
+
+static VALUE
+unp_fec(VALUE self, VALUE test)
+{
+ st_table *tbl = st_init_numtable();
+ struct checker c;
+
+ c.tbl = tbl;
+ c.nr = 0;
+ c.test = test;
+
+ st_add_direct(tbl, 0, 0);
+
+ if (!tbl->entries_packed) rb_bug("should still be packed\n");
+
+ st_foreach_check(tbl, unp_fec_i, (st_data_t)&c, -1);
+
+ if (c.test == ID2SYM(rb_intern("delete2"))) {
+ if (c.nr != 1) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ }
+ }
+ else if (c.nr != expect_size) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")\n",
+ (VALUE)c.nr, (VALUE)expect_size);
+ }
+
+ if (tbl->entries_packed) rb_bug("should be unpacked\n");
+
+ st_free_table(tbl);
+
+ return Qnil;
+}
+
+static int
+unp_fe_i(st_data_t key, st_data_t val, st_data_t args, int error)
+{
+ struct checker *c = (struct checker *)args;
+
+ force_unpack_check(c, key, val);
+ if (c->test == ID2SYM(rb_intern("unpacked"))) {
+ return ST_CONTINUE;
+ }
+ else if (c->test == ID2SYM(rb_intern("unpack_delete"))) {
+ if (c->nr == 1) {
+ st_data_t k = 0;
+ st_data_t v;
+
+ if (!st_delete(c->tbl, &k, &v)) {
+ rb_bug("failed to delete\n");
+ }
+ if (v != 0) {
+ rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
+ }
+ return ST_CONTINUE;
+ }
+ rb_bug("should never get here\n");
+ }
+
+ rb_raise(rb_eArgError, "unexpected arg: %+"PRIsVALUE, c->test);
+}
+
+static VALUE
+unp_fe(VALUE self, VALUE test)
+{
+ st_table *tbl = st_init_numtable();
+ struct checker c;
+
+ c.tbl = tbl;
+ c.nr = 0;
+ c.test = test;
+
+ st_add_direct(tbl, 0, 0);
+
+ if (!tbl->entries_packed) rb_bug("should still be packed\n");
+
+ st_foreach(tbl, unp_fe_i, (st_data_t)&c);
+
+ if (c.test == ID2SYM(rb_intern("unpack_delete"))) {
+ if (c.nr != 1) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ }
+ }
+ else if (c.nr != expect_size) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)\n",
+ (VALUE)c.nr, (VALUE)expect_size);
+ }
+
+ if (tbl->entries_packed) rb_bug("should be unpacked\n");
+
+ st_free_table(tbl);
+
+ return Qnil;
+}
+
+void
+Init_foreach(void)
+{
+ VALUE bug = rb_define_module("Bug");
+ rb_define_singleton_method(bug, "unp_st_foreach_check", unp_fec, 1);
+ rb_define_singleton_method(bug, "unp_st_foreach", unp_fe, 1);
+}
diff --git a/ruby_2_2/ext/-test-/st/numhash/extconf.rb b/ruby_2_2/ext/-test-/st/numhash/extconf.rb
new file mode 100644
index 0000000000..867fd75d2a
--- /dev/null
+++ b/ruby_2_2/ext/-test-/st/numhash/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/st/numhash")
diff --git a/ruby_2_2/ext/-test-/st/numhash/numhash.c b/ruby_2_2/ext/-test-/st/numhash/numhash.c
new file mode 100644
index 0000000000..e033886f9d
--- /dev/null
+++ b/ruby_2_2/ext/-test-/st/numhash/numhash.c
@@ -0,0 +1,138 @@
+#include <ruby.h>
+#include <ruby/st.h>
+
+static void
+numhash_free(void *ptr)
+{
+ if (ptr) st_free_table(ptr);
+}
+
+static size_t
+numhash_memsize(const void *ptr)
+{
+ return ptr ? st_memsize(ptr) : 0;
+}
+
+static const rb_data_type_t numhash_type = {
+ "numhash",
+ {0, numhash_free, numhash_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
+};
+
+static VALUE
+numhash_alloc(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &numhash_type, 0);
+}
+
+static VALUE
+numhash_init(VALUE self)
+{
+ st_table *tbl = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (tbl) st_free_table(tbl);
+ DATA_PTR(self) = st_init_numtable();
+ return self;
+}
+
+static VALUE
+numhash_aref(VALUE self, VALUE key)
+{
+ st_data_t data;
+ st_table *tbl = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (!SPECIAL_CONST_P(key)) rb_raise(rb_eArgError, "not a special const");
+ if (st_lookup(tbl, (st_data_t)key, &data))
+ return (VALUE)data;
+ return Qnil;
+}
+
+static VALUE
+numhash_aset(VALUE self, VALUE key, VALUE data)
+{
+ st_table *tbl = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (!SPECIAL_CONST_P(key)) rb_raise(rb_eArgError, "not a special const");
+ if (!SPECIAL_CONST_P(data)) rb_raise(rb_eArgError, "not a special const");
+ st_insert(tbl, (st_data_t)key, (st_data_t)data);
+ return self;
+}
+
+static int
+numhash_i(st_data_t key, st_data_t value, st_data_t arg)
+{
+ VALUE ret;
+ ret = rb_yield_values(3, (VALUE)key, (VALUE)value, (VALUE)arg);
+ if (ret == Qtrue) return ST_CHECK;
+ return ST_CONTINUE;
+}
+
+static VALUE
+numhash_each(VALUE self)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ st_data_t data = (st_data_t)self;
+ return st_foreach_check(table, numhash_i, data, data) ? Qtrue : Qfalse;
+}
+
+static int
+update_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
+{
+ VALUE ret = rb_yield_values(existing ? 2 : 1, (VALUE)*key, (VALUE)*value);
+ switch (ret) {
+ case Qfalse:
+ return ST_STOP;
+ case Qnil:
+ return ST_DELETE;
+ default:
+ *value = ret;
+ return ST_CONTINUE;
+ }
+}
+
+static VALUE
+numhash_update(VALUE self, VALUE key)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (st_update(table, (st_data_t)key, update_func, 0))
+ return Qtrue;
+ else
+ return Qfalse;
+}
+
+#if SIZEOF_LONG == SIZEOF_VOIDP
+# define ST2NUM(x) ULONG2NUM(x)
+#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
+# define ST2NUM(x) ULL2NUM(x)
+#endif
+
+static VALUE
+numhash_size(VALUE self)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ return ST2NUM(table->num_entries);
+}
+
+static VALUE
+numhash_delete_safe(VALUE self, VALUE key)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ st_data_t val, k = (st_data_t)key;
+ if (st_delete_safe(table, &k, &val, (st_data_t)self)) {
+ return val;
+ }
+ return Qnil;
+}
+
+void
+Init_numhash(void)
+{
+ VALUE st = rb_define_class_under(rb_define_module("Bug"), "StNumHash", rb_cData);
+ rb_define_alloc_func(st, numhash_alloc);
+ rb_define_method(st, "initialize", numhash_init, 0);
+ rb_define_method(st, "[]", numhash_aref, 1);
+ rb_define_method(st, "[]=", numhash_aset, 2);
+ rb_define_method(st, "each", numhash_each, 0);
+ rb_define_method(st, "update", numhash_update, 1);
+ rb_define_method(st, "size", numhash_size, 0);
+ rb_define_method(st, "delete_safe", numhash_delete_safe, 1);
+}
+
diff --git a/ruby_2_2/ext/-test-/st/update/extconf.rb b/ruby_2_2/ext/-test-/st/update/extconf.rb
new file mode 100644
index 0000000000..96dbae43ab
--- /dev/null
+++ b/ruby_2_2/ext/-test-/st/update/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/st/update")
diff --git a/ruby_2_2/ext/-test-/st/update/update.c b/ruby_2_2/ext/-test-/st/update/update.c
new file mode 100644
index 0000000000..979ad3e334
--- /dev/null
+++ b/ruby_2_2/ext/-test-/st/update/update.c
@@ -0,0 +1,34 @@
+#include <ruby.h>
+#include <ruby/st.h>
+
+static int
+update_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
+{
+ VALUE ret = rb_yield_values(existing ? 2 : 1, (VALUE)*key, (VALUE)*value);
+ switch (ret) {
+ case Qfalse:
+ return ST_STOP;
+ case Qnil:
+ return ST_DELETE;
+ default:
+ *value = ret;
+ return ST_CONTINUE;
+ }
+}
+
+static VALUE
+test_st_update(VALUE self, VALUE key)
+{
+ if (st_update(RHASH_TBL(self), (st_data_t)key, update_func, 0))
+ return Qtrue;
+ else
+ return Qfalse;
+}
+
+void
+Init_update(void)
+{
+ VALUE st = rb_define_class_under(rb_define_module("Bug"), "StTable", rb_cHash);
+ rb_define_method(st, "st_update", test_st_update, 1);
+}
+
diff --git a/ruby_2_2/ext/-test-/string/coderange.c b/ruby_2_2/ext/-test-/string/coderange.c
new file mode 100644
index 0000000000..b93172d72d
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/coderange.c
@@ -0,0 +1,47 @@
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE sym_7bit, sym_valid, sym_unknown, sym_broken;
+
+static VALUE
+coderange_int2sym(int coderange)
+{
+ switch (coderange) {
+ case ENC_CODERANGE_7BIT:
+ return sym_7bit;
+ case ENC_CODERANGE_VALID:
+ return sym_valid;
+ case ENC_CODERANGE_UNKNOWN:
+ return sym_unknown;
+ case ENC_CODERANGE_BROKEN:
+ return sym_broken;
+ }
+ rb_bug("wrong condition of coderange");
+ UNREACHABLE;
+}
+
+/* return coderange without scan */
+static VALUE
+str_coderange(VALUE str)
+{
+ return coderange_int2sym(ENC_CODERANGE(str));
+}
+
+/* scan coderange and return the result */
+static VALUE
+str_coderange_scan(VALUE str)
+{
+ ENC_CODERANGE_SET(str, ENC_CODERANGE_UNKNOWN);
+ return coderange_int2sym(rb_enc_str_coderange(str));
+}
+
+void
+Init_coderange(VALUE klass)
+{
+ sym_7bit = ID2SYM(rb_intern("7bit"));
+ sym_valid = ID2SYM(rb_intern("valid"));
+ sym_unknown = ID2SYM(rb_intern("unknown"));
+ sym_broken = ID2SYM(rb_intern("broken"));
+ rb_define_method(klass, "coderange", str_coderange, 0);
+ rb_define_method(klass, "coderange_scan", str_coderange_scan, 0);
+}
diff --git a/ruby_2_2/ext/-test-/string/cstr.c b/ruby_2_2/ext/-test-/string/cstr.c
new file mode 100644
index 0000000000..ba2e46bc55
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/cstr.c
@@ -0,0 +1,57 @@
+#include "ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE
+bug_str_cstr_term(VALUE str)
+{
+ long len;
+ char *s;
+ int c;
+ rb_encoding *enc;
+
+ rb_str_modify(str);
+ len = RSTRING_LEN(str);
+ RSTRING_PTR(str)[len] = 'x';
+ s = StringValueCStr(str);
+ rb_gc();
+ enc = rb_enc_get(str);
+ c = rb_enc_codepoint(&s[len], &s[len+rb_enc_mbminlen(enc)], enc);
+ return INT2NUM(c);
+}
+
+static VALUE
+bug_str_cstr_term_char(VALUE str)
+{
+ long len;
+ char *s;
+ int c;
+ rb_encoding *enc = rb_enc_get(str);
+
+ RSTRING_GETMEM(str, s, len);
+ s += len;
+ len = rb_enc_mbminlen(enc);
+ c = rb_enc_precise_mbclen(s, s + len, enc);
+ if (!MBCLEN_CHARFOUND_P(c)) {
+ c = (unsigned char)*s;
+ }
+ else {
+ c = rb_enc_mbc_to_codepoint(s, s + len, enc);
+ if (!c) return Qnil;
+ }
+ return rb_enc_uint_chr((unsigned int)c, enc);
+}
+
+static VALUE
+bug_str_s_cstr_term_char(VALUE self, VALUE str)
+{
+ Check_Type(str, T_STRING);
+ return bug_str_cstr_term_char(str);
+}
+
+void
+Init_cstr(VALUE klass)
+{
+ rb_define_method(klass, "cstr_term", bug_str_cstr_term, 0);
+ rb_define_method(klass, "cstr_term_char", bug_str_cstr_term_char, 0);
+ rb_define_singleton_method(klass, "cstr_term_char", bug_str_s_cstr_term_char, 1);
+}
diff --git a/ruby_2_2/ext/-test-/string/depend b/ruby_2_2/ext/-test-/string/depend
new file mode 100644
index 0000000000..ef13e44df5
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/depend
@@ -0,0 +1,115 @@
+# AUTOGENERATED DEPENDENCIES START
+coderange.o: $(RUBY_EXTCONF_H)
+coderange.o: $(arch_hdrdir)/ruby/config.h
+coderange.o: $(hdrdir)/ruby/defines.h
+coderange.o: $(hdrdir)/ruby/encoding.h
+coderange.o: $(hdrdir)/ruby/intern.h
+coderange.o: $(hdrdir)/ruby/missing.h
+coderange.o: $(hdrdir)/ruby/oniguruma.h
+coderange.o: $(hdrdir)/ruby/ruby.h
+coderange.o: $(hdrdir)/ruby/st.h
+coderange.o: $(hdrdir)/ruby/subst.h
+coderange.o: coderange.c
+cstr.o: $(RUBY_EXTCONF_H)
+cstr.o: $(arch_hdrdir)/ruby/config.h
+cstr.o: $(hdrdir)/ruby/defines.h
+cstr.o: $(hdrdir)/ruby/encoding.h
+cstr.o: $(hdrdir)/ruby/intern.h
+cstr.o: $(hdrdir)/ruby/missing.h
+cstr.o: $(hdrdir)/ruby/oniguruma.h
+cstr.o: $(hdrdir)/ruby/ruby.h
+cstr.o: $(hdrdir)/ruby/st.h
+cstr.o: $(hdrdir)/ruby/subst.h
+cstr.o: $(top_srcdir)/include/ruby.h
+cstr.o: cstr.c
+ellipsize.o: $(RUBY_EXTCONF_H)
+ellipsize.o: $(arch_hdrdir)/ruby/config.h
+ellipsize.o: $(hdrdir)/ruby/defines.h
+ellipsize.o: $(hdrdir)/ruby/intern.h
+ellipsize.o: $(hdrdir)/ruby/missing.h
+ellipsize.o: $(hdrdir)/ruby/ruby.h
+ellipsize.o: $(hdrdir)/ruby/st.h
+ellipsize.o: $(hdrdir)/ruby/subst.h
+ellipsize.o: $(top_srcdir)/include/ruby.h
+ellipsize.o: ellipsize.c
+enc_associate.o: $(RUBY_EXTCONF_H)
+enc_associate.o: $(arch_hdrdir)/ruby/config.h
+enc_associate.o: $(hdrdir)/ruby/defines.h
+enc_associate.o: $(hdrdir)/ruby/encoding.h
+enc_associate.o: $(hdrdir)/ruby/intern.h
+enc_associate.o: $(hdrdir)/ruby/missing.h
+enc_associate.o: $(hdrdir)/ruby/oniguruma.h
+enc_associate.o: $(hdrdir)/ruby/ruby.h
+enc_associate.o: $(hdrdir)/ruby/st.h
+enc_associate.o: $(hdrdir)/ruby/subst.h
+enc_associate.o: $(top_srcdir)/include/ruby.h
+enc_associate.o: enc_associate.c
+enc_str_buf_cat.o: $(RUBY_EXTCONF_H)
+enc_str_buf_cat.o: $(arch_hdrdir)/ruby/config.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/defines.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/encoding.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/intern.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/missing.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/oniguruma.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/ruby.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/st.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/subst.h
+enc_str_buf_cat.o: enc_str_buf_cat.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
+modify.o: $(RUBY_EXTCONF_H)
+modify.o: $(arch_hdrdir)/ruby/config.h
+modify.o: $(hdrdir)/ruby/defines.h
+modify.o: $(hdrdir)/ruby/intern.h
+modify.o: $(hdrdir)/ruby/missing.h
+modify.o: $(hdrdir)/ruby/ruby.h
+modify.o: $(hdrdir)/ruby/st.h
+modify.o: $(hdrdir)/ruby/subst.h
+modify.o: $(top_srcdir)/include/ruby.h
+modify.o: modify.c
+normalize.o: $(RUBY_EXTCONF_H)
+normalize.o: $(arch_hdrdir)/ruby/config.h
+normalize.o: $(hdrdir)/ruby/defines.h
+normalize.o: $(hdrdir)/ruby/encoding.h
+normalize.o: $(hdrdir)/ruby/intern.h
+normalize.o: $(hdrdir)/ruby/io.h
+normalize.o: $(hdrdir)/ruby/missing.h
+normalize.o: $(hdrdir)/ruby/oniguruma.h
+normalize.o: $(hdrdir)/ruby/ruby.h
+normalize.o: $(hdrdir)/ruby/st.h
+normalize.o: $(hdrdir)/ruby/subst.h
+normalize.o: $(top_srcdir)/include/ruby.h
+normalize.o: $(top_srcdir)/internal.h
+normalize.o: normalize.c
+qsort.o: $(RUBY_EXTCONF_H)
+qsort.o: $(arch_hdrdir)/ruby/config.h
+qsort.o: $(hdrdir)/ruby/defines.h
+qsort.o: $(hdrdir)/ruby/encoding.h
+qsort.o: $(hdrdir)/ruby/intern.h
+qsort.o: $(hdrdir)/ruby/missing.h
+qsort.o: $(hdrdir)/ruby/oniguruma.h
+qsort.o: $(hdrdir)/ruby/ruby.h
+qsort.o: $(hdrdir)/ruby/st.h
+qsort.o: $(hdrdir)/ruby/subst.h
+qsort.o: $(hdrdir)/ruby/util.h
+qsort.o: $(top_srcdir)/include/ruby.h
+qsort.o: qsort.c
+set_len.o: $(RUBY_EXTCONF_H)
+set_len.o: $(arch_hdrdir)/ruby/config.h
+set_len.o: $(hdrdir)/ruby/defines.h
+set_len.o: $(hdrdir)/ruby/intern.h
+set_len.o: $(hdrdir)/ruby/missing.h
+set_len.o: $(hdrdir)/ruby/ruby.h
+set_len.o: $(hdrdir)/ruby/st.h
+set_len.o: $(hdrdir)/ruby/subst.h
+set_len.o: $(top_srcdir)/include/ruby.h
+set_len.o: set_len.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ruby_2_2/ext/-test-/string/ellipsize.c b/ruby_2_2/ext/-test-/string/ellipsize.c
new file mode 100644
index 0000000000..0451519492
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/ellipsize.c
@@ -0,0 +1,13 @@
+#include "ruby.h"
+
+static VALUE
+bug_str_ellipsize(VALUE str, VALUE len)
+{
+ return rb_str_ellipsize(str, NUM2LONG(len));
+}
+
+void
+Init_ellipsize(VALUE klass)
+{
+ rb_define_method(klass, "ellipsize", bug_str_ellipsize, 1);
+}
diff --git a/ruby_2_2/ext/-test-/string/enc_associate.c b/ruby_2_2/ext/-test-/string/enc_associate.c
new file mode 100644
index 0000000000..d6614fb298
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/enc_associate.c
@@ -0,0 +1,14 @@
+#include "ruby.h"
+#include "ruby/encoding.h"
+
+VALUE
+bug_str_enc_associate(VALUE str, VALUE enc)
+{
+ return rb_enc_associate(str, rb_to_encoding(enc));
+}
+
+void
+Init_enc_associate(VALUE klass)
+{
+ rb_define_method(klass, "associate_encoding!", bug_str_enc_associate, 1);
+}
diff --git a/ruby_2_2/ext/-test-/string/enc_str_buf_cat.c b/ruby_2_2/ext/-test-/string/enc_str_buf_cat.c
new file mode 100644
index 0000000000..5d583c65dc
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/enc_str_buf_cat.c
@@ -0,0 +1,14 @@
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE
+enc_str_buf_cat(VALUE str, VALUE str2)
+{
+ return rb_enc_str_buf_cat(str, RSTRING_PTR(str2), RSTRING_LEN(str2), rb_enc_get(str2));
+}
+
+void
+Init_enc_str_buf_cat(VALUE klass)
+{
+ rb_define_method(klass, "enc_str_buf_cat", enc_str_buf_cat, 1);
+}
diff --git a/ruby_2_2/ext/-test-/string/extconf.rb b/ruby_2_2/ext/-test-/string/extconf.rb
new file mode 100644
index 0000000000..10d33cbab9
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/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-/string/string")
diff --git a/ruby_2_2/ext/-test-/string/init.c b/ruby_2_2/ext/-test-/string/init.c
new file mode 100644
index 0000000000..0b3e4a6ff2
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_string(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "String", rb_cString);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/string/modify.c b/ruby_2_2/ext/-test-/string/modify.c
new file mode 100644
index 0000000000..ddd2efd8f0
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/modify.c
@@ -0,0 +1,22 @@
+#include "ruby.h"
+
+VALUE
+bug_str_modify(VALUE str)
+{
+ rb_str_modify(str);
+ return str;
+}
+
+VALUE
+bug_str_modify_expand(VALUE str, VALUE expand)
+{
+ rb_str_modify_expand(str, NUM2LONG(expand));
+ return str;
+}
+
+void
+Init_modify(VALUE klass)
+{
+ rb_define_method(klass, "modify!", bug_str_modify, 0);
+ rb_define_method(klass, "modify_expand!", bug_str_modify_expand, 1);
+}
diff --git a/ruby_2_2/ext/-test-/string/nofree.c b/ruby_2_2/ext/-test-/string/nofree.c
new file mode 100644
index 0000000000..d3d8071ff9
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/nofree.c
@@ -0,0 +1,13 @@
+#include "ruby.h"
+
+VALUE
+bug_str_nofree(VALUE self)
+{
+ return rb_str_new_cstr("abcdef");
+}
+
+void
+Init_nofree(VALUE klass)
+{
+ rb_define_singleton_method(klass, "nofree", bug_str_nofree, 0);
+}
diff --git a/ruby_2_2/ext/-test-/string/normalize.c b/ruby_2_2/ext/-test-/string/normalize.c
new file mode 100644
index 0000000000..2e16a4616f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/normalize.c
@@ -0,0 +1,17 @@
+#include "internal.h"
+
+#ifdef __APPLE__
+static VALUE
+normalize_ospath(VALUE str)
+{
+ return rb_str_normalize_ospath(RSTRING_PTR(str), RSTRING_LEN(str));
+}
+#else
+#define normalize_ospath rb_f_notimplement
+#endif
+
+void
+Init_normalize(VALUE klass)
+{
+ rb_define_method(klass, "normalize_ospath", normalize_ospath, 0);
+}
diff --git a/ruby_2_2/ext/-test-/string/qsort.c b/ruby_2_2/ext/-test-/string/qsort.c
new file mode 100644
index 0000000000..0b34936d38
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/qsort.c
@@ -0,0 +1,61 @@
+#include "ruby.h"
+#include "ruby/util.h"
+#include "ruby/encoding.h"
+
+struct sort_data {
+ rb_encoding *enc;
+ long elsize;
+};
+
+static int
+cmp_1(const void *ap, const void *bp, void *dummy)
+{
+ struct sort_data *d = dummy;
+ VALUE a = rb_enc_str_new(ap, d->elsize, d->enc);
+ VALUE b = rb_enc_str_new(bp, d->elsize, d->enc);
+ VALUE retval = rb_yield_values(2, a, b);
+ return rb_cmpint(retval, a, b);
+}
+
+static int
+cmp_2(const void *ap, const void *bp, void *dummy)
+{
+ int a = *(const unsigned char *)ap;
+ int b = *(const unsigned char *)bp;
+ return a - b;
+}
+
+static VALUE
+bug_str_qsort_bang(int argc, VALUE *argv, VALUE str)
+{
+ VALUE beg, len, size;
+ long l, b = 0, n, s = 1;
+ struct sort_data d;
+
+ rb_scan_args(argc, argv, "03", &beg, &len, &size);
+ l = RSTRING_LEN(str);
+ if (!NIL_P(beg) && (b = NUM2INT(beg)) < 0 && (b += l) < 0) {
+ rb_raise(rb_eArgError, "out of bounds");
+ }
+ if (!NIL_P(size) && (s = NUM2INT(size)) < 0) {
+ rb_raise(rb_eArgError, "negative size");
+ }
+ if (NIL_P(len) ||
+ (((n = NUM2INT(len)) < 0) ?
+ (rb_raise(rb_eArgError, "negative length"), 0) :
+ (b + n * s > l))) {
+ n = (l - b) / s;
+ }
+ rb_str_modify(str);
+ d.enc = rb_enc_get(str);
+ d.elsize = s;
+ ruby_qsort(RSTRING_PTR(str) + b, n, s,
+ rb_block_given_p() ? cmp_1 : cmp_2, &d);
+ return str;
+}
+
+void
+Init_qsort(VALUE klass)
+{
+ rb_define_method(klass, "qsort!", bug_str_qsort_bang, -1);
+}
diff --git a/ruby_2_2/ext/-test-/string/set_len.c b/ruby_2_2/ext/-test-/string/set_len.c
new file mode 100644
index 0000000000..3c7d19d778
--- /dev/null
+++ b/ruby_2_2/ext/-test-/string/set_len.c
@@ -0,0 +1,14 @@
+#include "ruby.h"
+
+static VALUE
+bug_str_set_len(VALUE str, VALUE len)
+{
+ rb_str_set_len(str, NUM2LONG(len));
+ return str;
+}
+
+void
+Init_set_len(VALUE klass)
+{
+ rb_define_method(klass, "set_len", bug_str_set_len, 1);
+}
diff --git a/ruby_2_2/ext/-test-/struct/duplicate.c b/ruby_2_2/ext/-test-/struct/duplicate.c
new file mode 100644
index 0000000000..596d32aad8
--- /dev/null
+++ b/ruby_2_2/ext/-test-/struct/duplicate.c
@@ -0,0 +1,24 @@
+#include "ruby.h"
+
+static VALUE
+bug_struct_new_duplicate(VALUE obj, VALUE name, VALUE mem)
+{
+ const char *n = NIL_P(name) ? 0 : StringValueCStr(name);
+ const char *m = StringValueCStr(mem);
+ return rb_struct_define(n, m, m, NULL);
+}
+
+static VALUE
+bug_struct_new_duplicate_under(VALUE obj, VALUE name, VALUE mem)
+{
+ const char *n = StringValueCStr(name);
+ const char *m = StringValueCStr(mem);
+ return rb_struct_define_under(obj, n, m, m, NULL);
+}
+
+void
+Init_duplicate(VALUE klass)
+{
+ rb_define_singleton_method(klass, "new_duplicate", bug_struct_new_duplicate, 2);
+ rb_define_singleton_method(klass, "new_duplicate_under", bug_struct_new_duplicate_under, 2);
+}
diff --git a/ruby_2_2/ext/-test-/struct/extconf.rb b/ruby_2_2/ext/-test-/struct/extconf.rb
new file mode 100644
index 0000000000..0e4f9551f2
--- /dev/null
+++ b/ruby_2_2/ext/-test-/struct/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-/struct")
diff --git a/ruby_2_2/ext/-test-/struct/init.c b/ruby_2_2/ext/-test-/struct/init.c
new file mode 100644
index 0000000000..459a939e79
--- /dev/null
+++ b/ruby_2_2/ext/-test-/struct/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_struct(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Struct", rb_cStruct);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/struct/member.c b/ruby_2_2/ext/-test-/struct/member.c
new file mode 100644
index 0000000000..1d404039b4
--- /dev/null
+++ b/ruby_2_2/ext/-test-/struct/member.c
@@ -0,0 +1,18 @@
+#include "ruby.h"
+
+static VALUE
+bug_struct_get(VALUE obj, VALUE name)
+{
+ ID id = rb_check_id(&name);
+
+ if (!id) {
+ rb_name_error_str(name, "`%"PRIsVALUE"' is not a struct member", name);
+ }
+ return rb_struct_getmember(obj, id);
+}
+
+void
+Init_member(VALUE klass)
+{
+ rb_define_method(klass, "get", bug_struct_get, 1);
+}
diff --git a/ruby_2_2/ext/-test-/symbol/extconf.rb b/ruby_2_2/ext/-test-/symbol/extconf.rb
new file mode 100644
index 0000000000..fc00ec9abf
--- /dev/null
+++ b/ruby_2_2/ext/-test-/symbol/extconf.rb
@@ -0,0 +1,7 @@
+$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(' ')}\""
+have_func("rb_pin_dynamic_symbol")
+create_makefile("-test-/symbol")
diff --git a/ruby_2_2/ext/-test-/symbol/init.c b/ruby_2_2/ext/-test-/symbol/init.c
new file mode 100644
index 0000000000..9e42e1a38b
--- /dev/null
+++ b/ruby_2_2/ext/-test-/symbol/init.c
@@ -0,0 +1,25 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+static VALUE
+sym_find(VALUE dummy, VALUE sym)
+{
+ return rb_check_symbol(&sym);
+}
+
+static VALUE
+sym_pinneddown_p(VALUE dummy, VALUE sym)
+{
+ return rb_check_id(&sym) ? Qtrue : Qfalse;
+}
+
+void
+Init_symbol(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Symbol", rb_cSymbol);
+ rb_define_singleton_method(klass, "find", sym_find, 1);
+ rb_define_singleton_method(klass, "pinneddown?", sym_pinneddown_p, 1);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/symbol/type.c b/ruby_2_2/ext/-test-/symbol/type.c
new file mode 100644
index 0000000000..e51e09eb26
--- /dev/null
+++ b/ruby_2_2/ext/-test-/symbol/type.c
@@ -0,0 +1,78 @@
+#include "ruby.h"
+
+#ifdef HAVE_RB_IS_CONST_NAME
+# define get_symbol_type(type, t, name) do { \
+ ID id = rb_check_id(&name); \
+ t = (id ? rb_is_##type##_id(id) : rb_is_##type##_name(name)); \
+ } while (0)
+#else
+# define get_symbol_type(type, t, name) do { \
+ t = rb_is_##type##_id(rb_to_id(name)); \
+ } while (0)
+#endif
+
+#define define_symbol_type_p(type) \
+static VALUE \
+bug_sym_##type##_p(VALUE self, VALUE name) \
+{ \
+ int t; \
+ get_symbol_type(type, t, name); \
+ return (t ? Qtrue : Qfalse); \
+}
+
+#define declare_symbol_type_p(type) \
+ rb_define_singleton_method(klass, #type"?", bug_sym_##type##_p, 1);
+
+#define FOREACH_ID_TYPES(x) x(const) x(class) x(global) x(instance) x(attrset) x(local) x(junk)
+
+FOREACH_ID_TYPES(define_symbol_type_p)
+
+static VALUE
+bug_sym_attrset(VALUE self, VALUE name)
+{
+ ID id = rb_to_id(name);
+ id = rb_id_attrset(id);
+ return ID2SYM(id);
+}
+
+static VALUE
+bug_id2str(VALUE self, VALUE sym)
+{
+ return rb_sym2str(sym);
+}
+
+static VALUE
+bug_static_p(VALUE self, VALUE sym)
+{
+ return STATIC_SYM_P(sym) ? Qtrue : Qfalse;
+}
+
+static VALUE
+bug_dynamic_p(VALUE self, VALUE sym)
+{
+ return DYNAMIC_SYM_P(sym) ? Qtrue : Qfalse;
+}
+
+#ifdef HAVE_RB_PIN_DYNAMIC_SYMBOL
+ID rb_pin_dynamic_symbol(VALUE);
+
+static VALUE
+bug_pindown(VALUE self, VALUE sym)
+{
+ rb_pin_dynamic_symbol(sym);
+ return sym;
+}
+#endif
+
+void
+Init_type(VALUE klass)
+{
+ FOREACH_ID_TYPES(declare_symbol_type_p);
+ rb_define_singleton_method(klass, "attrset", bug_sym_attrset, 1);
+ rb_define_singleton_method(klass, "id2str", bug_id2str, 1);
+ rb_define_singleton_method(klass, "static?", bug_static_p, 1);
+ rb_define_singleton_method(klass, "dynamic?", bug_dynamic_p, 1);
+#ifdef HAVE_RB_PIN_DYNAMIC_SYMBOL
+ rb_define_singleton_method(klass, "pindown", bug_pindown, 1);
+#endif
+}
diff --git a/ruby_2_2/ext/-test-/tracepoint/depend b/ruby_2_2/ext/-test-/tracepoint/depend
new file mode 100644
index 0000000000..741bad0386
--- /dev/null
+++ b/ruby_2_2/ext/-test-/tracepoint/depend
@@ -0,0 +1,22 @@
+# AUTOGENERATED DEPENDENCIES START
+gc_hook.o: $(RUBY_EXTCONF_H)
+gc_hook.o: $(arch_hdrdir)/ruby/config.h
+gc_hook.o: $(hdrdir)/ruby/debug.h
+gc_hook.o: $(hdrdir)/ruby/defines.h
+gc_hook.o: $(hdrdir)/ruby/intern.h
+gc_hook.o: $(hdrdir)/ruby/missing.h
+gc_hook.o: $(hdrdir)/ruby/ruby.h
+gc_hook.o: $(hdrdir)/ruby/st.h
+gc_hook.o: $(hdrdir)/ruby/subst.h
+gc_hook.o: gc_hook.c
+tracepoint.o: $(RUBY_EXTCONF_H)
+tracepoint.o: $(arch_hdrdir)/ruby/config.h
+tracepoint.o: $(hdrdir)/ruby/debug.h
+tracepoint.o: $(hdrdir)/ruby/defines.h
+tracepoint.o: $(hdrdir)/ruby/intern.h
+tracepoint.o: $(hdrdir)/ruby/missing.h
+tracepoint.o: $(hdrdir)/ruby/ruby.h
+tracepoint.o: $(hdrdir)/ruby/st.h
+tracepoint.o: $(hdrdir)/ruby/subst.h
+tracepoint.o: tracepoint.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ruby_2_2/ext/-test-/tracepoint/extconf.rb b/ruby_2_2/ext/-test-/tracepoint/extconf.rb
new file mode 100644
index 0000000000..c0c2399eb4
--- /dev/null
+++ b/ruby_2_2/ext/-test-/tracepoint/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/tracepoint")
diff --git a/ruby_2_2/ext/-test-/tracepoint/gc_hook.c b/ruby_2_2/ext/-test-/tracepoint/gc_hook.c
new file mode 100644
index 0000000000..6d8485ecb1
--- /dev/null
+++ b/ruby_2_2/ext/-test-/tracepoint/gc_hook.c
@@ -0,0 +1,80 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+static int invoking; /* TODO: should not be global variable */
+
+static VALUE
+invoke_proc_ensure(void *dmy)
+{
+ invoking = 0;
+ return Qnil;
+}
+
+static VALUE
+invoke_proc_begin(VALUE proc)
+{
+ return rb_proc_call(proc, rb_ary_new());
+}
+
+static void
+invoke_proc(void *data)
+{
+ VALUE proc = (VALUE)data;
+ invoking += 1;
+ rb_ensure(invoke_proc_begin, proc, invoke_proc_ensure, 0);
+}
+
+static void
+gc_start_end_i(VALUE tpval, void *data)
+{
+ if (0) {
+ rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
+ fprintf(stderr, "trace: %s\n", rb_tracearg_event_flag(tparg) == RUBY_INTERNAL_EVENT_GC_START ? "gc_start" : "gc_end");
+ }
+
+ if (invoking == 0) {
+ rb_postponed_job_register(0, invoke_proc, data);
+ }
+}
+
+static VALUE
+set_gc_hook(VALUE module, VALUE proc, rb_event_flag_t event, const char *tp_str, const char *proc_str)
+{
+ VALUE tpval;
+ ID tp_key = rb_intern(tp_str);
+ ID proc_key = rb_intern(proc_str);
+
+ /* disable previous keys */
+ if (rb_ivar_defined(module, tp_key) != 0 &&
+ RTEST(tpval = rb_ivar_get(module, tp_key))) {
+ rb_tracepoint_disable(tpval);
+ rb_ivar_set(module, tp_key, Qnil);
+ rb_ivar_set(module, proc_key, Qnil);
+ }
+
+ if (RTEST(proc)) {
+ if (!rb_obj_is_proc(proc)) {
+ rb_raise(rb_eTypeError, "trace_func needs to be Proc");
+ }
+
+ tpval = rb_tracepoint_new(0, event, gc_start_end_i, (void *)proc);
+ rb_ivar_set(module, tp_key, tpval);
+ rb_ivar_set(module, proc_key, proc); /* GC guard */
+ rb_tracepoint_enable(tpval);
+ }
+
+ return proc;
+}
+
+static VALUE
+set_after_gc_start(VALUE module, VALUE proc)
+{
+ return set_gc_hook(module, proc, RUBY_INTERNAL_EVENT_GC_START,
+ "__set_after_gc_start_tpval__", "__set_after_gc_start_proc__");
+}
+
+void
+Init_gc_hook(VALUE module)
+{
+ rb_define_module_function(module, "after_gc_start_hook=", set_after_gc_start, 1);
+}
diff --git a/ruby_2_2/ext/-test-/tracepoint/tracepoint.c b/ruby_2_2/ext/-test-/tracepoint/tracepoint.c
new file mode 100644
index 0000000000..aa8c212f99
--- /dev/null
+++ b/ruby_2_2/ext/-test-/tracepoint/tracepoint.c
@@ -0,0 +1,96 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+struct tracepoint_track {
+ size_t newobj_count;
+ size_t free_count;
+ size_t gc_start_count;
+ size_t gc_end_mark_count;
+ size_t gc_end_sweep_count;
+ size_t objects_count;
+ VALUE objects[10];
+};
+
+#define objects_max (sizeof(((struct tracepoint_track *)NULL)->objects)/sizeof(VALUE))
+
+static void
+tracepoint_track_objspace_events_i(VALUE tpval, void *data)
+{
+ rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
+ struct tracepoint_track *track = data;
+
+ switch (rb_tracearg_event_flag(tparg)) {
+ case RUBY_INTERNAL_EVENT_NEWOBJ:
+ {
+ VALUE obj = rb_tracearg_object(tparg);
+ if (track->objects_count < objects_max)
+ track->objects[track->objects_count++] = obj;
+ track->newobj_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_FREEOBJ:
+ {
+ track->free_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_GC_START:
+ {
+ track->gc_start_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_GC_END_MARK:
+ {
+ track->gc_end_mark_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_GC_END_SWEEP:
+ {
+ track->gc_end_sweep_count++;
+ break;
+ }
+ default:
+ rb_raise(rb_eRuntimeError, "unknown event");
+ }
+}
+
+static VALUE
+tracepoint_track_objspace_events(VALUE self)
+{
+ struct tracepoint_track track = {0, 0, 0, 0, 0,};
+ VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ |
+ RUBY_INTERNAL_EVENT_GC_START | RUBY_INTERNAL_EVENT_GC_END_MARK |
+ RUBY_INTERNAL_EVENT_GC_END_SWEEP,
+ tracepoint_track_objspace_events_i, &track);
+ VALUE result = rb_ary_new();
+
+ rb_tracepoint_enable(tpval);
+ rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval);
+
+ rb_ary_push(result, SIZET2NUM(track.newobj_count));
+ rb_ary_push(result, SIZET2NUM(track.free_count));
+ rb_ary_push(result, SIZET2NUM(track.gc_start_count));
+ rb_ary_push(result, SIZET2NUM(track.gc_end_mark_count));
+ rb_ary_push(result, SIZET2NUM(track.gc_end_sweep_count));
+ rb_ary_cat(result, track.objects, track.objects_count);
+
+ return result;
+}
+
+static VALUE
+tracepoint_specify_normal_and_internal_events(VALUE self)
+{
+ VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_EVENT_CALL, 0, 0);
+ rb_tracepoint_enable(tpval);
+ return Qnil; /* should not be reached */
+}
+
+void Init_gc_hook(VALUE);
+
+void
+Init_tracepoint(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ Init_gc_hook(mBug);
+ rb_define_module_function(mBug, "tracepoint_track_objspace_events", tracepoint_track_objspace_events, 0);
+ rb_define_module_function(mBug, "tracepoint_specify_normal_and_internal_events", tracepoint_specify_normal_and_internal_events, 0);
+}
diff --git a/ruby_2_2/ext/-test-/typeddata/extconf.rb b/ruby_2_2/ext/-test-/typeddata/extconf.rb
new file mode 100644
index 0000000000..02e3e41c8b
--- /dev/null
+++ b/ruby_2_2/ext/-test-/typeddata/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/typeddata/typeddata")
diff --git a/ruby_2_2/ext/-test-/typeddata/typeddata.c b/ruby_2_2/ext/-test-/typeddata/typeddata.c
new file mode 100644
index 0000000000..1c5d677713
--- /dev/null
+++ b/ruby_2_2/ext/-test-/typeddata/typeddata.c
@@ -0,0 +1,20 @@
+#include <ruby.h>
+
+static const rb_data_type_t test_data = {
+ "typed_data",
+};
+
+static VALUE
+test_check(VALUE self, VALUE obj)
+{
+ rb_check_typeddata(obj, &test_data);
+ return obj;
+}
+
+void
+Init_typeddata(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "TypedData", rb_cData);
+ rb_define_singleton_method(klass, "check", test_check, 1);
+}
diff --git a/ruby_2_2/ext/-test-/vm/at_exit.c b/ruby_2_2/ext/-test-/vm/at_exit.c
new file mode 100644
index 0000000000..6cfbfafa9e
--- /dev/null
+++ b/ruby_2_2/ext/-test-/vm/at_exit.c
@@ -0,0 +1,44 @@
+#include <ruby/ruby.h>
+#include <ruby/vm.h>
+
+static void
+do_nothing(ruby_vm_t *vm)
+{
+}
+
+static void
+print_begin(ruby_vm_t *vm)
+{
+ printf("begin\n");
+}
+
+static void
+print_end(ruby_vm_t *vm)
+{
+ printf("end\n");
+}
+
+static VALUE
+register_at_exit(VALUE self, VALUE t)
+{
+ switch (t) {
+ case Qtrue:
+ ruby_vm_at_exit(print_begin);
+ break;
+ case Qfalse:
+ ruby_vm_at_exit(print_end);
+ break;
+ default:
+ ruby_vm_at_exit(do_nothing);
+ break;
+ }
+ return self;
+}
+
+void
+Init_at_exit(void)
+{
+ VALUE m = rb_define_module("Bug");
+ VALUE c = rb_define_class_under(m, "VM", rb_cObject);
+ rb_define_singleton_method(c, "register_at_exit", register_at_exit, 1);
+}
diff --git a/ruby_2_2/ext/-test-/vm/extconf.rb b/ruby_2_2/ext/-test-/vm/extconf.rb
new file mode 100644
index 0000000000..614ec960d8
--- /dev/null
+++ b/ruby_2_2/ext/-test-/vm/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/vm/at_exit')
diff --git a/ruby_2_2/ext/-test-/wait_for_single_fd/depend b/ruby_2_2/ext/-test-/wait_for_single_fd/depend
new file mode 100644
index 0000000000..fddd41053f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/wait_for_single_fd/depend
@@ -0,0 +1,14 @@
+# AUTOGENERATED DEPENDENCIES START
+wait_for_single_fd.o: $(RUBY_EXTCONF_H)
+wait_for_single_fd.o: $(arch_hdrdir)/ruby/config.h
+wait_for_single_fd.o: $(hdrdir)/ruby/defines.h
+wait_for_single_fd.o: $(hdrdir)/ruby/encoding.h
+wait_for_single_fd.o: $(hdrdir)/ruby/intern.h
+wait_for_single_fd.o: $(hdrdir)/ruby/io.h
+wait_for_single_fd.o: $(hdrdir)/ruby/missing.h
+wait_for_single_fd.o: $(hdrdir)/ruby/oniguruma.h
+wait_for_single_fd.o: $(hdrdir)/ruby/ruby.h
+wait_for_single_fd.o: $(hdrdir)/ruby/st.h
+wait_for_single_fd.o: $(hdrdir)/ruby/subst.h
+wait_for_single_fd.o: wait_for_single_fd.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/ruby_2_2/ext/-test-/wait_for_single_fd/extconf.rb b/ruby_2_2/ext/-test-/wait_for_single_fd/extconf.rb
new file mode 100644
index 0000000000..1a28b23da3
--- /dev/null
+++ b/ruby_2_2/ext/-test-/wait_for_single_fd/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/wait_for_single_fd/wait_for_single_fd")
diff --git a/ruby_2_2/ext/-test-/wait_for_single_fd/wait_for_single_fd.c b/ruby_2_2/ext/-test-/wait_for_single_fd/wait_for_single_fd.c
new file mode 100644
index 0000000000..d406724a3f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/wait_for_single_fd/wait_for_single_fd.c
@@ -0,0 +1,30 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+static VALUE
+wait_for_single_fd(VALUE ign, VALUE fd, VALUE events, VALUE timeout)
+{
+ struct timeval tv;
+ struct timeval *tvp = NULL;
+ int rc;
+
+ if (!NIL_P(timeout)) {
+ tv = rb_time_timeval(timeout);
+ tvp = &tv;
+ }
+
+ rc = rb_wait_for_single_fd(NUM2INT(fd), NUM2INT(events), tvp);
+ if (rc == -1)
+ rb_sys_fail("rb_wait_for_single_fd");
+ return INT2NUM(rc);
+}
+
+void
+Init_wait_for_single_fd(void)
+{
+ rb_define_const(rb_cObject, "RB_WAITFD_IN", INT2NUM(RB_WAITFD_IN));
+ rb_define_const(rb_cObject, "RB_WAITFD_OUT", INT2NUM(RB_WAITFD_OUT));
+ rb_define_const(rb_cObject, "RB_WAITFD_PRI", INT2NUM(RB_WAITFD_PRI));
+ rb_define_singleton_method(rb_cIO, "wait_for_single_fd",
+ wait_for_single_fd, 3);
+}
diff --git a/ruby_2_2/ext/-test-/win32/console/attribute.c b/ruby_2_2/ext/-test-/win32/console/attribute.c
new file mode 100644
index 0000000000..a2c07fc4fe
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/console/attribute.c
@@ -0,0 +1,56 @@
+#include <ruby.h>
+
+static VALUE rb_cConsoleScreenBufferInfo;
+
+static VALUE
+console_info(VALUE io)
+{
+ int fd = NUM2INT(rb_funcallv(io, rb_intern("fileno"), 0, 0));
+ HANDLE h = (HANDLE)rb_w32_get_osfhandle(fd);
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ if (h == (HANDLE)-1) rb_raise(rb_eIOError, "invalid io");
+ if (!GetConsoleScreenBufferInfo(h, &csbi))
+ rb_syserr_fail(rb_w32_map_errno(GetLastError()), "not console");
+ return rb_struct_new(rb_cConsoleScreenBufferInfo,
+ INT2FIX(csbi.dwSize.X), INT2FIX(csbi.dwSize.Y),
+ INT2FIX(csbi.dwCursorPosition.X), INT2FIX(csbi.dwCursorPosition.Y),
+ INT2FIX(csbi.wAttributes));
+}
+
+static VALUE
+console_set_attribute(VALUE io, VALUE attr)
+{
+ int fd = NUM2INT(rb_funcallv(io, rb_intern("fileno"), 0, 0));
+ HANDLE h = (HANDLE)rb_w32_get_osfhandle(fd);
+
+ if (h == (HANDLE)-1) rb_raise(rb_eIOError, "invalid io");
+ SetConsoleTextAttribute(h, (WORD)NUM2INT(attr));
+ return Qnil;
+}
+
+#define FOREGROUND_MASK (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY)
+#define BACKGROUND_MASK (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY)
+
+void
+Init_attribute(VALUE m)
+{
+ rb_cConsoleScreenBufferInfo = rb_struct_define_under(m, "ConsoleScreenBufferInfo",
+ "size_x", "size_y",
+ "cur_x", "cur_y",
+ "attr", NULL);
+ rb_define_method(rb_cIO, "console_info", console_info, 0);
+ rb_define_method(rb_cIO, "console_attribute", console_set_attribute, 1);
+
+ rb_define_const(m, "FOREGROUND_MASK", INT2FIX(FOREGROUND_MASK));
+ rb_define_const(m, "FOREGROUND_BLUE", INT2FIX(FOREGROUND_BLUE));
+ rb_define_const(m, "FOREGROUND_GREEN", INT2FIX(FOREGROUND_GREEN));
+ rb_define_const(m, "FOREGROUND_RED", INT2FIX(FOREGROUND_RED));
+ rb_define_const(m, "FOREGROUND_INTENSITY", INT2FIX(FOREGROUND_INTENSITY));
+
+ rb_define_const(m, "BACKGROUND_MASK", INT2FIX(BACKGROUND_MASK));
+ rb_define_const(m, "BACKGROUND_BLUE", INT2FIX(BACKGROUND_BLUE));
+ rb_define_const(m, "BACKGROUND_GREEN", INT2FIX(BACKGROUND_GREEN));
+ rb_define_const(m, "BACKGROUND_RED", INT2FIX(BACKGROUND_RED));
+ rb_define_const(m, "BACKGROUND_INTENSITY", INT2FIX(BACKGROUND_INTENSITY));
+}
diff --git a/ruby_2_2/ext/-test-/win32/console/depend b/ruby_2_2/ext/-test-/win32/console/depend
new file mode 100644
index 0000000000..f4f65adf9a
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/console/depend
@@ -0,0 +1 @@
+attribute.o: $(ruby_headers) $(hdrdir)/ruby/win32.h
diff --git a/ruby_2_2/ext/-test-/win32/console/extconf.rb b/ruby_2_2/ext/-test-/win32/console/extconf.rb
new file mode 100644
index 0000000000..4de9fa7e4f
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/console/extconf.rb
@@ -0,0 +1,8 @@
+if $mingw or $mswin
+ $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-/win32/console")
+end
diff --git a/ruby_2_2/ext/-test-/win32/console/init.c b/ruby_2_2/ext/-test-/win32/console/init.c
new file mode 100644
index 0000000000..f2e0d1c821
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/console/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE m); Init_##n(m);}
+
+void
+Init_console(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE m = rb_define_module_under(mBug, "Win32");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ruby_2_2/ext/-test-/win32/dln/dlntest.c b/ruby_2_2/ext/-test-/win32/dln/dlntest.c
new file mode 100644
index 0000000000..3e6037ac07
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/dln/dlntest.c
@@ -0,0 +1,17 @@
+#include <ruby.h>
+
+extern __declspec(dllimport) void dlntest_ordinal(void);
+
+static VALUE
+dln_dlntest(VALUE self)
+{
+ dlntest_ordinal();
+ return self;
+}
+
+void
+Init_dln(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Win32");
+ rb_define_module_function(m, "dlntest", dln_dlntest, 0);
+}
diff --git a/ruby_2_2/ext/-test-/win32/dln/extconf.rb b/ruby_2_2/ext/-test-/win32/dln/extconf.rb
new file mode 100644
index 0000000000..57cee23b40
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/dln/extconf.rb
@@ -0,0 +1,37 @@
+if $mingw or $mswin
+ $objs = ["dlntest.o"]
+ testdll = "$(topdir)/dlntest.dll"
+ $cleanfiles << testdll
+ $cleanfiles << "dlntest.#{$LIBEXT}"
+ config_string('cleanobjs') {|t| $cleanfiles.concat(t.gsub(/\$\*/, 'dlntest').split)}
+
+ create_makefile("-test-/win32/dln")
+ m = File.read("Makefile")
+ dlntestlib = "dlntest.#{$LIBEXT}"
+ m.sub!(/^OBJS =.*/) {"#{$&} #{dlntestlib}"}
+ FileUtils.rm_f(RbConfig.expand(testdll.dup))
+ open("Makefile", "wb") do |mf|
+ mf.puts m, "\n"
+ sodir = $extout ? "$(RUBYARCHDIR)/" : ''
+ mf.print "#{sodir}$(DLLIB): #{dlntestlib}"
+ mf.puts
+ mf.puts "#{dlntestlib}: $(topdir)/dlntest.dll"
+ mf.puts
+ if $mingw
+ mf.puts "$(topdir)/dlntest.dll: DEFFILE := $(srcdir)/libdlntest.def"
+ mf.puts "$(topdir)/dlntest.dll: DLDFLAGS += -Wl,--out-implib,#{dlntestlib}"
+ end
+ mf.puts depend_rules("$(topdir)/dlntest.dll: libdlntest.o libdlntest.def")
+ mf.puts "\t$(ECHO) linking shared-object $(@F)\n"
+ mf.print "\t-$(Q)$(RM) $@\n"
+ mf.print "\t-$(Q)$(MAKEDIRS) $(@D)\n" if $extout
+ link_so = LINK_SO.gsub(/^/, "\t$(Q) ")
+ link_so.sub!(/\$\(LOCAL_LIBS\)/, '')
+ link_so.gsub!(/-\$\(arch\)/, '')
+ link_so.gsub!(/:.so=/, ':.dll=')
+ link_so.sub!(/\$\(OBJS\)/, "libdlntest.#{$OBJEXT}")
+ link_so.sub!(/\$\(DEFFILE\)/, "$(srcdir)/libdlntest.def")
+ mf.puts link_so
+ mf.puts
+ end
+end
diff --git a/ruby_2_2/ext/-test-/win32/dln/libdlntest.c b/ruby_2_2/ext/-test-/win32/dln/libdlntest.c
new file mode 100644
index 0000000000..5923b732c8
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/dln/libdlntest.c
@@ -0,0 +1,4 @@
+void
+dlntest_ordinal(void)
+{
+}
diff --git a/ruby_2_2/ext/-test-/win32/dln/libdlntest.def b/ruby_2_2/ext/-test-/win32/dln/libdlntest.def
new file mode 100644
index 0000000000..85bc9c7a55
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/dln/libdlntest.def
@@ -0,0 +1,2 @@
+EXPORTS
+dlntest_ordinal @1 NONAME
diff --git a/ruby_2_2/ext/-test-/win32/fd_setsize/depend b/ruby_2_2/ext/-test-/win32/fd_setsize/depend
new file mode 100644
index 0000000000..7d40e8d572
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/fd_setsize/depend
@@ -0,0 +1 @@
+fd_setsize.o: $(ruby_headers) $(hdrdir)/ruby/win32.h
diff --git a/ruby_2_2/ext/-test-/win32/fd_setsize/extconf.rb b/ruby_2_2/ext/-test-/win32/fd_setsize/extconf.rb
new file mode 100644
index 0000000000..ed40f8b1d7
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/fd_setsize/extconf.rb
@@ -0,0 +1,3 @@
+if $mingw or $mswin
+ create_makefile("-test-/win32/fd_setsize")
+end
diff --git a/ruby_2_2/ext/-test-/win32/fd_setsize/fd_setsize.c b/ruby_2_2/ext/-test-/win32/fd_setsize/fd_setsize.c
new file mode 100644
index 0000000000..8da8b1eaa0
--- /dev/null
+++ b/ruby_2_2/ext/-test-/win32/fd_setsize/fd_setsize.c
@@ -0,0 +1,55 @@
+#undef FD_SETSIZE
+/* redefine smaller size then default 64 */
+#define FD_SETSIZE 32
+#include <ruby.h>
+
+static VALUE
+test_select(VALUE self)
+{
+ int sd = socket(AF_INET, SOCK_DGRAM, 0);
+ struct timeval zero;
+ fd_set read;
+ fd_set write;
+ fd_set error;
+
+ zero.tv_sec = 0;
+ zero.tv_usec = 0;
+
+ FD_ZERO(&read);
+ FD_ZERO(&write);
+ FD_ZERO(&error);
+
+ FD_SET(sd, &read);
+ FD_SET(sd, &write);
+ FD_SET(sd, &error);
+
+ select(sd+1, &read, &write, &error, &zero);
+
+ return Qtrue;
+}
+
+static VALUE
+test_fdset(VALUE self)
+{
+ int i;
+ fd_set set;
+
+ FD_ZERO(&set);
+
+ for (i = 0; i < FD_SETSIZE * 2; i++) {
+ int sd = socket(AF_INET, SOCK_DGRAM, 0);
+ FD_SET(sd, &set);
+ if (set.fd_count > FD_SETSIZE) {
+ return Qfalse;
+ }
+ }
+ return Qtrue;
+}
+
+void
+Init_fd_setsize(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Win32");
+ rb_define_module_function(m, "test_select", test_select, 0);
+ rb_define_module_function(m, "test_fdset", test_fdset, 0);
+}