diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-04 09:20:22 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-04 09:20:22 +0000 |
| commit | 9d2e070f0551a873787f62f427fa1062f9414913 (patch) | |
| tree | a2e1889639dd730d0fa6edfabfaa2ddc33b0e63f /ext/dl/cfunc.c | |
| parent | bcc0224e666e5ee6cf3b6fd366194211545dd5b8 (diff) | |
merges r22690 from trunk into ruby_1_9_1.
--
* ext/dl/cfunc.c (rb_dlcfunc_call): fix for stdcall and missing
argument numbers. [ruby-core:22601]
* ext/dl/dl.h (DLSTACK_PROTO0_): added.
* ext/dl/mkcallback.rb (gencallback, gen_callback_file),
(rb_dl_init_callbacks): omit stdcall functions unless supported.
* lib/rubygems/config_file.rb (SHGetFolderPath): stdcall.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@22754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/cfunc.c')
| -rw-r--r-- | ext/dl/cfunc.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c index 724c290f2..0ea60b197 100644 --- a/ext/dl/cfunc.c +++ b/ext/dl/cfunc.c @@ -224,7 +224,9 @@ rb_dlcfunc_inspect(VALUE self) # define DECL_FUNC_CDECL(f,ret,args) ret (FUNC_CDECL(*f))(args) +#ifdef FUNC_STDCALL # define DECL_FUNC_STDCALL(f,ret,args) ret (FUNC_STDCALL(*f))(args) +#endif #define CALL_CASE switch( RARRAY_LEN(ary) ){ \ CASE(0); break; \ @@ -265,7 +267,11 @@ rb_dlcfunc_call(VALUE self, VALUE ary) } /* calltype == CFUNC_CDECL */ - if( cfunc->calltype == CFUNC_CDECL ){ + if( cfunc->calltype == CFUNC_CDECL +#ifndef FUNC_STDCALL + || cfunc->calltype == CFUNC_STDCALL +#endif + ){ switch( cfunc->type ){ case DLTYPE_VOID: #define CASE(n) case n: { \ @@ -329,9 +335,9 @@ rb_dlcfunc_call(VALUE self, VALUE ary) #if HAVE_LONG_LONG /* used in ruby.h */ case DLTYPE_LONG_LONG: #define CASE(n) case n: { \ - DECL_FUNC_CDECL(f,LONG_LONG,DLSTACK_PROTO) = cfunc->ptr; \ + DECL_FUNC_CDECL(f,LONG_LONG,DLSTACK_PROTO##n) = cfunc->ptr; \ LONG_LONG ret; \ - ret = f(DLSTACK_ARGS(stack)); \ + ret = f(DLSTACK_ARGS##n(stack)); \ result = LL2NUM(ret); \ } CALL_CASE; @@ -340,9 +346,9 @@ rb_dlcfunc_call(VALUE self, VALUE ary) #endif case DLTYPE_FLOAT: #define CASE(n) case n: { \ - DECL_FUNC_CDECL(f,float,DLSTACK_PROTO) = cfunc->ptr; \ + DECL_FUNC_CDECL(f,float,DLSTACK_PROTO##n) = cfunc->ptr; \ float ret; \ - ret = f(DLSTACK_ARGS(stack)); \ + ret = f(DLSTACK_ARGS##n(stack)); \ result = rb_float_new(ret); \ } CALL_CASE; @@ -350,9 +356,9 @@ rb_dlcfunc_call(VALUE self, VALUE ary) break; case DLTYPE_DOUBLE: #define CASE(n) case n: { \ - DECL_FUNC_CDECL(f,double,DLSTACK_PROTO) = cfunc->ptr; \ + DECL_FUNC_CDECL(f,double,DLSTACK_PROTO##n) = cfunc->ptr; \ double ret; \ - ret = f(DLSTACK_ARGS(stack)); \ + ret = f(DLSTACK_ARGS##n(stack)); \ result = rb_float_new(ret); \ } CALL_CASE; @@ -362,12 +368,13 @@ rb_dlcfunc_call(VALUE self, VALUE ary) rb_raise(rb_eDLTypeError, "unknown type %d", cfunc->type); } } +#ifdef FUNC_STDCALL else if( cfunc->calltype == CFUNC_STDCALL ){ /* calltype == CFUNC_STDCALL */ switch( cfunc->type ){ case DLTYPE_VOID: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,void,DLSTACK_PROTO##n) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,void,DLSTACK_PROTO##n##_) = cfunc->ptr; \ f(DLSTACK_ARGS##n(stack)); \ result = Qnil; \ } @@ -376,7 +383,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) break; case DLTYPE_VOIDP: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,void*,DLSTACK_PROTO##n) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,void*,DLSTACK_PROTO##n##_) = cfunc->ptr; \ void * ret; \ ret = f(DLSTACK_ARGS##n(stack)); \ result = PTR2NUM(ret); \ @@ -386,7 +393,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) break; case DLTYPE_CHAR: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,char,DLSTACK_PROTO##n) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,char,DLSTACK_PROTO##n##_) = cfunc->ptr; \ char ret; \ ret = f(DLSTACK_ARGS##n(stack)); \ result = CHR2FIX(ret); \ @@ -396,7 +403,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) break; case DLTYPE_SHORT: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,short,DLSTACK_PROTO##n) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,short,DLSTACK_PROTO##n##_) = cfunc->ptr; \ short ret; \ ret = f(DLSTACK_ARGS##n(stack)); \ result = INT2NUM((int)ret); \ @@ -406,7 +413,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) break; case DLTYPE_INT: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,int,DLSTACK_PROTO##n) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,int,DLSTACK_PROTO##n##_) = cfunc->ptr; \ int ret; \ ret = f(DLSTACK_ARGS##n(stack)); \ result = INT2NUM(ret); \ @@ -416,7 +423,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) break; case DLTYPE_LONG: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,long,DLSTACK_PROTO##n) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,long,DLSTACK_PROTO##n##_) = cfunc->ptr; \ long ret; \ ret = f(DLSTACK_ARGS##n(stack)); \ result = LONG2NUM(ret); \ @@ -427,9 +434,9 @@ rb_dlcfunc_call(VALUE self, VALUE ary) #if HAVE_LONG_LONG /* used in ruby.h */ case DLTYPE_LONG_LONG: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,LONG_LONG,DLSTACK_PROTO) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,LONG_LONG,DLSTACK_PROTO##n##_) = cfunc->ptr; \ LONG_LONG ret; \ - ret = f(DLSTACK_ARGS(stack)); \ + ret = f(DLSTACK_ARGS##n(stack)); \ result = LL2NUM(ret); \ } CALL_CASE; @@ -438,9 +445,9 @@ rb_dlcfunc_call(VALUE self, VALUE ary) #endif case DLTYPE_FLOAT: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,float,DLSTACK_PROTO) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,float,DLSTACK_PROTO##n##_) = cfunc->ptr; \ float ret; \ - ret = f(DLSTACK_ARGS(stack)); \ + ret = f(DLSTACK_ARGS##n(stack)); \ result = rb_float_new(ret); \ } CALL_CASE; @@ -448,9 +455,9 @@ rb_dlcfunc_call(VALUE self, VALUE ary) break; case DLTYPE_DOUBLE: #define CASE(n) case n: { \ - DECL_FUNC_STDCALL(f,double,DLSTACK_PROTO) = cfunc->ptr; \ + DECL_FUNC_STDCALL(f,double,DLSTACK_PROTO##n##_) = cfunc->ptr; \ double ret; \ - ret = f(DLSTACK_ARGS(stack)); \ + ret = f(DLSTACK_ARGS##n(stack)); \ result = rb_float_new(ret); \ } CALL_CASE; @@ -460,6 +467,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) rb_raise(rb_eDLTypeError, "unknown type %d", cfunc->type); } } +#endif else{ rb_raise(rb_eDLError, #ifndef LONG_LONG_VALUE |
