diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c index 94816204f1..458132b784 100644 --- a/ext/dl/cfunc.c +++ b/ext/dl/cfunc.c @@ -222,20 +222,9 @@ rb_dlcfunc_inspect(VALUE self) return val; } -#if defined(__GNUC__) -# define DECL_FUNC_CDECL(f,ret,args) FUNC_CDECL(ret (*f)(args)) -# define DECL_FUNC_STDCALL(f,ret,args) FUNC_STDCALL(ret (*f)(args)) -/* # define DECL_FUNC(f,ret,args,calltype) ret (*f)(args) */ -#elif defined(_MSC_VER) || defined(__BORLANDC__) -# define DECL_FUNC_CDECL(f,ret,args) ret (__cdecl *f)(args) -# define DECL_FUNC_STDCALL(f,ret,args) ret (__stdcall *f)(args) -#elif defined(__SUNPRO_C) -# define DECL_FUNC(f,ret,args,calltype) ret (*f)(args) -# define DECL_FUNC_CDECL(f,ret,args) ret (*f)(args) -# define DECL_FUNC_STDCALL(f,ret,args) ret (*f)(args) -#else -# error "unsupported compiler." -#endif + +# define DECL_FUNC_CDECL(f,ret,args) ret (FUNC_CDECL(*f))(args) +# define DECL_FUNC_STDCALL(f,ret,args) ret (FUNC_STDCALL(*f))(args) #define CALL_CASE switch( RARRAY(ary)->len ){ \ CASE(0); break; \ diff --git a/ext/dl/dl.c b/ext/dl/dl.c index fcfcbd1bcc..015e76f09e 100644 --- a/ext/dl/dl.c +++ b/ext/dl/dl.c @@ -56,31 +56,6 @@ rb_dl_value2ptr(VALUE self, VALUE val) return PTR2NUM((void*)val); } -#if defined(__GNUC__) -# define PRE_DECL_CDECL __attribute__((cdecl)) -# define PRE_DECL_STDCALL __attribute__((stdcall)) -# define MIDST_DECL_CDECL -# define MIDST_DECL_STDCALL -# define POST_DECL_CDECL -# define POST_DECL_STDCALL -#elif defined(_MSC_VER) || defined(__BORLANDC__) -# define PRE_DECL_CDECL -# define PRE_DECL_STDCALL -# define MIDST_DECL_CDECL __cdecl -# define MIDST_DECL_STDCALL __stdcall -# define POST_DECL_CDECL -# define POST_DECL_STDCALL -#elif (__SUNPRO_C) -# define PRE_DECL_CDECL -# define PRE_DECL_STDCALL -# define MIDST_DECL_CDECL -# define MIDST_DECL_STDCALL -# define POST_DECL_CDECL -# define POST_DECL_STDCALL -#else -# error "unsupported compiler" -#endif - #include "callback.h" void diff --git a/ext/dl/mkcallback.rb b/ext/dl/mkcallback.rb index 493f55b188..8526353bf3 100644 --- a/ext/dl/mkcallback.rb +++ b/ext/dl/mkcallback.rb @@ -111,8 +111,8 @@ for calltype in CALLTYPES for n in 0..(MAX_CALLBACK-1) $out << (<<-EOS) -FUNC_#{calltype.upcase}(static #{DLTYPE[ty][:type]} -#{func_name(ty,argc,n,calltype)}(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")})) +static #{DLTYPE[ty][:type]} +FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")}) { VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""}; #{ diff --git a/ext/dl/test/test_dl2.rb b/ext/dl/test/test_dl2.rb index e59956cf7b..8c1f3e71b4 100644 --- a/ext/dl/test/test_dl2.rb +++ b/ext/dl/test/test_dl2.rb @@ -94,14 +94,14 @@ class TestDL < TestBase assert_equal(str[0,2], ptr[0,2]) assert_equal(str[1,2], ptr[1,2]) assert_equal(str[1,0], ptr[1,0]) - assert_equal(str[0], ptr[0]) - assert_equal(str[1], ptr[1]) + assert_equal(str[0].ord, ptr[0]) + assert_equal(str[1].ord, ptr[1]) } str = 'abc' ptr = CPtr[str] check.call(str, ptr) - str[0] = ?c - ptr[0] = ?c + str[0] = "c" + ptr[0] = "c".ord check.call(str, ptr) str[0,2] = "aa" ptr[0,2] = "aa"