diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/-test-/float/depend | 3 | ||||
-rw-r--r-- | ext/-test-/float/extconf.rb | 7 | ||||
-rw-r--r-- | ext/-test-/float/init.c | 11 | ||||
-rw-r--r-- | ext/-test-/float/nextafter.c | 36 |
4 files changed, 57 insertions, 0 deletions
diff --git a/ext/-test-/float/depend b/ext/-test-/float/depend new file mode 100644 index 0000000000..dff14550f7 --- /dev/null +++ b/ext/-test-/float/depend @@ -0,0 +1,3 @@ +$(OBJS): $(HDRS) $(ruby_headers) + +nextafter.o: nextafter.c $(top_srcdir)/missing/nextafter.c diff --git a/ext/-test-/float/extconf.rb b/ext/-test-/float/extconf.rb new file mode 100644 index 0000000000..0a9a299aa5 --- /dev/null +++ b/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/ext/-test-/float/init.c b/ext/-test-/float/init.c new file mode 100644 index 0000000000..d962108e39 --- /dev/null +++ b/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/ext/-test-/float/nextafter.c b/ext/-test-/float/nextafter.c new file mode 100644 index 0000000000..30fb71f520 --- /dev/null +++ b/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); +} |