conformed to the usage of FUNC_CDECL/STDCALL described in [ruby-dev:28970].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
57fe65940c
commit
d01f22ec7c
@ -222,20 +222,9 @@ rb_dlcfunc_inspect(VALUE self)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
# define DECL_FUNC_CDECL(f,ret,args) FUNC_CDECL(ret (*f)(args))
|
# define DECL_FUNC_CDECL(f,ret,args) ret (FUNC_CDECL(*f))(args)
|
||||||
# define DECL_FUNC_STDCALL(f,ret,args) FUNC_STDCALL(ret (*f)(args))
|
# define DECL_FUNC_STDCALL(f,ret,args) ret (FUNC_STDCALL(*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 CALL_CASE switch( RARRAY(ary)->len ){ \
|
#define CALL_CASE switch( RARRAY(ary)->len ){ \
|
||||||
CASE(0); break; \
|
CASE(0); break; \
|
||||||
|
25
ext/dl/dl.c
25
ext/dl/dl.c
@ -56,31 +56,6 @@ rb_dl_value2ptr(VALUE self, VALUE val)
|
|||||||
return PTR2NUM((void*)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"
|
#include "callback.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -111,8 +111,8 @@ for calltype in CALLTYPES
|
|||||||
for n in 0..(MAX_CALLBACK-1)
|
for n in 0..(MAX_CALLBACK-1)
|
||||||
$out << (<<-EOS)
|
$out << (<<-EOS)
|
||||||
|
|
||||||
FUNC_#{calltype.upcase}(static #{DLTYPE[ty][:type]}
|
static #{DLTYPE[ty][:type]}
|
||||||
#{func_name(ty,argc,n,calltype)}(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")}))
|
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}]" : ""};
|
VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""};
|
||||||
#{
|
#{
|
||||||
|
@ -94,14 +94,14 @@ class TestDL < TestBase
|
|||||||
assert_equal(str[0,2], ptr[0,2])
|
assert_equal(str[0,2], ptr[0,2])
|
||||||
assert_equal(str[1,2], ptr[1,2])
|
assert_equal(str[1,2], ptr[1,2])
|
||||||
assert_equal(str[1,0], ptr[1,0])
|
assert_equal(str[1,0], ptr[1,0])
|
||||||
assert_equal(str[0], ptr[0])
|
assert_equal(str[0].ord, ptr[0])
|
||||||
assert_equal(str[1], ptr[1])
|
assert_equal(str[1].ord, ptr[1])
|
||||||
}
|
}
|
||||||
str = 'abc'
|
str = 'abc'
|
||||||
ptr = CPtr[str]
|
ptr = CPtr[str]
|
||||||
check.call(str, ptr)
|
check.call(str, ptr)
|
||||||
str[0] = ?c
|
str[0] = "c"
|
||||||
ptr[0] = ?c
|
ptr[0] = "c".ord
|
||||||
check.call(str, ptr)
|
check.call(str, ptr)
|
||||||
str[0,2] = "aa"
|
str[0,2] = "aa"
|
||||||
ptr[0,2] = "aa"
|
ptr[0,2] = "aa"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user