diff options
Diffstat (limited to 'ruby_1_9_3/ext/-test-')
32 files changed, 0 insertions, 490 deletions
diff --git a/ruby_1_9_3/ext/-test-/array/resize/extconf.rb b/ruby_1_9_3/ext/-test-/array/resize/extconf.rb deleted file mode 100644 index 6500a878fc..0000000000 --- a/ruby_1_9_3/ext/-test-/array/resize/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/array/resize") diff --git a/ruby_1_9_3/ext/-test-/array/resize/resize.c b/ruby_1_9_3/ext/-test-/array/resize/resize.c deleted file mode 100644 index 08bcee3e7a..0000000000 --- a/ruby_1_9_3/ext/-test-/array/resize/resize.c +++ /dev/null @@ -1,14 +0,0 @@ -#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_1_9_3/ext/-test-/bug-3571/bug.c b/ruby_1_9_3/ext/-test-/bug-3571/bug.c deleted file mode 100644 index 72d6bd1021..0000000000 --- a/ruby_1_9_3/ext/-test-/bug-3571/bug.c +++ /dev/null @@ -1,23 +0,0 @@ -#include <ruby.h> - -static VALUE -bug_i(VALUE i, VALUE 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_1_9_3/ext/-test-/bug-3571/extconf.rb b/ruby_1_9_3/ext/-test-/bug-3571/extconf.rb deleted file mode 100644 index 6390fce219..0000000000 --- a/ruby_1_9_3/ext/-test-/bug-3571/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/bug-3571/bug") diff --git a/ruby_1_9_3/ext/-test-/bug-3662/bug.c b/ruby_1_9_3/ext/-test-/bug-3662/bug.c deleted file mode 100644 index 9375dace10..0000000000 --- a/ruby_1_9_3/ext/-test-/bug-3662/bug.c +++ /dev/null @@ -1,16 +0,0 @@ -#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_1_9_3/ext/-test-/bug-3662/extconf.rb b/ruby_1_9_3/ext/-test-/bug-3662/extconf.rb deleted file mode 100644 index 7a1b73023c..0000000000 --- a/ruby_1_9_3/ext/-test-/bug-3662/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/bug-3662/bug") diff --git a/ruby_1_9_3/ext/-test-/funcall/extconf.rb b/ruby_1_9_3/ext/-test-/funcall/extconf.rb deleted file mode 100644 index 8a9179ab2f..0000000000 --- a/ruby_1_9_3/ext/-test-/funcall/extconf.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'mkmf' -create_makefile("-test-/funcall/funcall") diff --git a/ruby_1_9_3/ext/-test-/funcall/passing_block.c b/ruby_1_9_3/ext/-test-/funcall/passing_block.c deleted file mode 100644 index 0200f80369..0000000000 --- a/ruby_1_9_3/ext/-test-/funcall/passing_block.c +++ /dev/null @@ -1,30 +0,0 @@ -#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_1_9_3/ext/-test-/load/dot.dot/dot.dot.c b/ruby_1_9_3/ext/-test-/load/dot.dot/dot.dot.c deleted file mode 100644 index 936d28931a..0000000000 --- a/ruby_1_9_3/ext/-test-/load/dot.dot/dot.dot.c +++ /dev/null @@ -1 +0,0 @@ -void Init_dot(void) {} diff --git a/ruby_1_9_3/ext/-test-/load/dot.dot/extconf.rb b/ruby_1_9_3/ext/-test-/load/dot.dot/extconf.rb deleted file mode 100644 index 6287db6bd8..0000000000 --- a/ruby_1_9_3/ext/-test-/load/dot.dot/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/load/dot.dot/dot.dot") diff --git a/ruby_1_9_3/ext/-test-/old_thread_select/depend b/ruby_1_9_3/ext/-test-/old_thread_select/depend deleted file mode 100644 index a2bc836e1f..0000000000 --- a/ruby_1_9_3/ext/-test-/old_thread_select/depend +++ /dev/null @@ -1,2 +0,0 @@ -old_thread_select.o: $(top_srcdir)/thread.c \ - $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/io.h diff --git a/ruby_1_9_3/ext/-test-/old_thread_select/extconf.rb b/ruby_1_9_3/ext/-test-/old_thread_select/extconf.rb deleted file mode 100644 index 8b410218fa..0000000000 --- a/ruby_1_9_3/ext/-test-/old_thread_select/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/old_thread_select/old_thread_select") diff --git a/ruby_1_9_3/ext/-test-/old_thread_select/old_thread_select.c b/ruby_1_9_3/ext/-test-/old_thread_select/old_thread_select.c deleted file mode 100644 index e374f02355..0000000000 --- a/ruby_1_9_3/ext/-test-/old_thread_select/old_thread_select.c +++ /dev/null @@ -1,75 +0,0 @@ -/* test case for deprecated C API */ -#include "ruby/ruby.h" -#include "ruby/io.h" - -static fd_set * array2fdset(fd_set *fds, VALUE ary, int *max) -{ - long i; - - if (NIL_P(ary)) - return NULL; - - FD_ZERO(fds); - Check_Type(ary, T_ARRAY); - for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE val = RARRAY_PTR(ary)[i]; - int fd; - - Check_Type(val, T_FIXNUM); - fd = FIX2INT(val); - if (fd >= *max) - *max = fd + 1; - FD_SET(fd, fds); - } - - return fds; -} - -static void fdset2array(VALUE dst, fd_set *fds, int max) -{ - int i; - - rb_ary_clear(dst); - - for (i = 0; i < max; i++) { - if (FD_ISSET(i, fds)) - rb_ary_push(dst, INT2NUM(i)); - } -} - -static VALUE -old_thread_select(VALUE klass, VALUE r, VALUE w, VALUE e, VALUE timeout) -{ - struct timeval tv; - struct timeval *tvp = NULL; - fd_set rfds, wfds, efds; - fd_set *rp, *wp, *ep; - int rc; - int max = 0; - - if (!NIL_P(timeout)) { - tv = rb_time_timeval(timeout); - tvp = &tv; - } - rp = array2fdset(&rfds, r, &max); - wp = array2fdset(&wfds, w, &max); - ep = array2fdset(&efds, e, &max); - rc = rb_thread_select(max, rp, wp, ep, tvp); - if (rc == -1) - rb_sys_fail("rb_wait_for_single_fd"); - - if (rp) - fdset2array(r, &rfds, max); - if (wp) - fdset2array(w, &wfds, max); - if (ep) - fdset2array(e, &efds, max); - return INT2NUM(rc); -} - -void -Init_old_thread_select(void) -{ - rb_define_singleton_method(rb_cIO, "old_thread_select", - old_thread_select, 4); -} diff --git a/ruby_1_9_3/ext/-test-/st/numhash/extconf.rb b/ruby_1_9_3/ext/-test-/st/numhash/extconf.rb deleted file mode 100644 index 867fd75d2a..0000000000 --- a/ruby_1_9_3/ext/-test-/st/numhash/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/st/numhash") diff --git a/ruby_1_9_3/ext/-test-/st/numhash/numhash.c b/ruby_1_9_3/ext/-test-/st/numhash/numhash.c deleted file mode 100644 index e186cd43d9..0000000000 --- a/ruby_1_9_3/ext/-test-/st/numhash/numhash.c +++ /dev/null @@ -1,69 +0,0 @@ -#include <ruby.h> -#include <ruby/st.h> - -static void -numhash_free(void *ptr) -{ - if (ptr) st_free_table(ptr); -} - -static VALUE -numhash_alloc(VALUE klass) -{ - return Data_Wrap_Struct(klass, 0, numhash_free, 0); -} - -static VALUE -numhash_init(VALUE self) -{ - st_table *tbl = (st_table *)DATA_PTR(self); - 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; - if (!SPECIAL_CONST_P(key)) rb_raise(rb_eArgError, "not a special const"); - if (st_lookup((st_table *)DATA_PTR(self), (st_data_t)key, &data)) - return (VALUE)data; - return Qnil; -} - -static VALUE -numhash_aset(VALUE self, VALUE key, VALUE data) -{ - 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((st_table *)DATA_PTR(self), (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, int error) -{ - VALUE ret; - if (key == 0 && value == 0 && error == 1) rb_raise(rb_eRuntimeError, "numhash modified"); - 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) -{ - return st_foreach((st_table *)DATA_PTR(self), numhash_i, self) ? Qtrue : Qfalse; -} - -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); -} diff --git a/ruby_1_9_3/ext/-test-/string/cstr.c b/ruby_1_9_3/ext/-test-/string/cstr.c deleted file mode 100644 index d4ff360575..0000000000 --- a/ruby_1_9_3/ext/-test-/string/cstr.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "ruby.h" - -static VALUE -bug_str_cstr_term(VALUE str) -{ - long len; - char *s; - rb_str_modify(str); - len = RSTRING_LEN(str); - RSTRING_PTR(str)[len] = 'x'; - s = StringValueCStr(str); - rb_gc(); - return INT2NUM(s[len]); -} - -void -Init_cstr(VALUE klass) -{ - rb_define_method(klass, "cstr_term", bug_str_cstr_term, 0); -} diff --git a/ruby_1_9_3/ext/-test-/string/ellipsize.c b/ruby_1_9_3/ext/-test-/string/ellipsize.c deleted file mode 100644 index 0451519492..0000000000 --- a/ruby_1_9_3/ext/-test-/string/ellipsize.c +++ /dev/null @@ -1,13 +0,0 @@ -#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_1_9_3/ext/-test-/string/enc_associate.c b/ruby_1_9_3/ext/-test-/string/enc_associate.c deleted file mode 100644 index d6614fb298..0000000000 --- a/ruby_1_9_3/ext/-test-/string/enc_associate.c +++ /dev/null @@ -1,14 +0,0 @@ -#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_1_9_3/ext/-test-/string/extconf.rb b/ruby_1_9_3/ext/-test-/string/extconf.rb deleted file mode 100644 index 42c10b994b..0000000000 --- a/ruby_1_9_3/ext/-test-/string/extconf.rb +++ /dev/null @@ -1,6 +0,0 @@ -$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_1_9_3/ext/-test-/string/init.c b/ruby_1_9_3/ext/-test-/string/init.c deleted file mode 100644 index 0b3e4a6ff2..0000000000 --- a/ruby_1_9_3/ext/-test-/string/init.c +++ /dev/null @@ -1,11 +0,0 @@ -#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_1_9_3/ext/-test-/string/modify.c b/ruby_1_9_3/ext/-test-/string/modify.c deleted file mode 100644 index ddd2efd8f0..0000000000 --- a/ruby_1_9_3/ext/-test-/string/modify.c +++ /dev/null @@ -1,22 +0,0 @@ -#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_1_9_3/ext/-test-/string/set_len.c b/ruby_1_9_3/ext/-test-/string/set_len.c deleted file mode 100644 index 3c7d19d778..0000000000 --- a/ruby_1_9_3/ext/-test-/string/set_len.c +++ /dev/null @@ -1,14 +0,0 @@ -#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_1_9_3/ext/-test-/wait_for_single_fd/depend b/ruby_1_9_3/ext/-test-/wait_for_single_fd/depend deleted file mode 100644 index d9cd50a542..0000000000 --- a/ruby_1_9_3/ext/-test-/wait_for_single_fd/depend +++ /dev/null @@ -1,2 +0,0 @@ -wait_for_single_fd.o: $(top_srcdir)/thread.c \ - $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/io.h diff --git a/ruby_1_9_3/ext/-test-/wait_for_single_fd/extconf.rb b/ruby_1_9_3/ext/-test-/wait_for_single_fd/extconf.rb deleted file mode 100644 index 1a28b23da3..0000000000 --- a/ruby_1_9_3/ext/-test-/wait_for_single_fd/extconf.rb +++ /dev/null @@ -1 +0,0 @@ -create_makefile("-test-/wait_for_single_fd/wait_for_single_fd") diff --git a/ruby_1_9_3/ext/-test-/wait_for_single_fd/wait_for_single_fd.c b/ruby_1_9_3/ext/-test-/wait_for_single_fd/wait_for_single_fd.c deleted file mode 100644 index d406724a3f..0000000000 --- a/ruby_1_9_3/ext/-test-/wait_for_single_fd/wait_for_single_fd.c +++ /dev/null @@ -1,30 +0,0 @@ -#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_1_9_3/ext/-test-/win32/dln/dlntest.c b/ruby_1_9_3/ext/-test-/win32/dln/dlntest.c deleted file mode 100644 index 3e6037ac07..0000000000 --- a/ruby_1_9_3/ext/-test-/win32/dln/dlntest.c +++ /dev/null @@ -1,17 +0,0 @@ -#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_1_9_3/ext/-test-/win32/dln/extconf.rb b/ruby_1_9_3/ext/-test-/win32/dln/extconf.rb deleted file mode 100644 index 0b5089af14..0000000000 --- a/ruby_1_9_3/ext/-test-/win32/dln/extconf.rb +++ /dev/null @@ -1,36 +0,0 @@ -if $mingw or $mswin - $objs = ["dlntest.o"] - testdll = "$(topdir)/dlntest.dll" - $cleanfiles << testdll - 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_1_9_3/ext/-test-/win32/dln/libdlntest.c b/ruby_1_9_3/ext/-test-/win32/dln/libdlntest.c deleted file mode 100644 index 040ae8125d..0000000000 --- a/ruby_1_9_3/ext/-test-/win32/dln/libdlntest.c +++ /dev/null @@ -1,4 +0,0 @@ -extern __declspec(dllexport) void -dlntest_ordinal(void) -{ -} diff --git a/ruby_1_9_3/ext/-test-/win32/dln/libdlntest.def b/ruby_1_9_3/ext/-test-/win32/dln/libdlntest.def deleted file mode 100644 index 85bc9c7a55..0000000000 --- a/ruby_1_9_3/ext/-test-/win32/dln/libdlntest.def +++ /dev/null @@ -1,2 +0,0 @@ -EXPORTS -dlntest_ordinal @1 NONAME diff --git a/ruby_1_9_3/ext/-test-/win32/fd_setsize/depend b/ruby_1_9_3/ext/-test-/win32/fd_setsize/depend deleted file mode 100644 index 4936d6b28c..0000000000 --- a/ruby_1_9_3/ext/-test-/win32/fd_setsize/depend +++ /dev/null @@ -1,2 +0,0 @@ -fd_setsize.o: $(top_srcdir)/win32/win32.c \ - $(hdrdir)/ruby/ruby.h diff --git a/ruby_1_9_3/ext/-test-/win32/fd_setsize/extconf.rb b/ruby_1_9_3/ext/-test-/win32/fd_setsize/extconf.rb deleted file mode 100644 index ed40f8b1d7..0000000000 --- a/ruby_1_9_3/ext/-test-/win32/fd_setsize/extconf.rb +++ /dev/null @@ -1,3 +0,0 @@ -if $mingw or $mswin - create_makefile("-test-/win32/fd_setsize") -end diff --git a/ruby_1_9_3/ext/-test-/win32/fd_setsize/fd_setsize.c b/ruby_1_9_3/ext/-test-/win32/fd_setsize/fd_setsize.c deleted file mode 100644 index 8da8b1eaa0..0000000000 --- a/ruby_1_9_3/ext/-test-/win32/fd_setsize/fd_setsize.c +++ /dev/null @@ -1,55 +0,0 @@ -#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); -} |