summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/dl/cfunc.c16
2 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 216c115..e60ea52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun May 2 17:25:05 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/dl/cfunc.c (rb_dlcfunc_call): ignore signedness.
+
Sun May 2 12:04:30 2010 wanabe <s.wanabe@gmail.com>
* iseq.c (iseq_load): allow filepath to be nil.
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c
index e1cf9d1..f2579da 100644
--- a/ext/dl/cfunc.c
+++ b/ext/dl/cfunc.c
@@ -6,6 +6,8 @@
#include <errno.h>
#include "dl.h"
+VALUE rb_big2ulong_pack(VALUE x);
+
VALUE rb_cDLCFunc;
static ID id_last_error;
@@ -348,11 +350,21 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
}
for( i = 0; i < RARRAY_LEN(ary); i++ ){
+ VALUE arg;
if( i >= DLSTACK_SIZE ){
rb_raise(rb_eDLError, "too many arguments (stack overflow)");
}
- rb_check_safe_obj(RARRAY_PTR(ary)[i]);
- stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]);
+ arg = rb_to_int(RARRAY_PTR(ary)[i]);
+ rb_check_safe_obj(arg);
+ if (FIXNUM_P(arg)) {
+ stack[i] = (DLSTACK_TYPE)FIX2LONG(arg);
+ }
+ else if (RB_TYPE_P(arg, T_BIGNUM)) {
+ stack[i] = (DLSTACK_TYPE)rb_big2ulong_pack(arg);
+ }
+ else {
+ Check_Type(arg, T_FIXNUM);
+ }
}
/* calltype == CFUNC_CDECL */