1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

added bcc32 support [ruby-dev:25657] and fixed a minor bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ttate 2005-02-08 09:18:16 +00:00
parent 84075c004b
commit c1f29da23d
3 changed files with 19 additions and 36 deletions

View file

@ -225,7 +225,7 @@ rb_dlcfunc_inspect(VALUE self)
#if defined(__GNUC__) #if defined(__GNUC__)
# define DECL_FUNC(f,ret,args,calltype) ret (__attribute__((calltype)) *f)(args) # define DECL_FUNC(f,ret,args,calltype) ret (__attribute__((calltype)) *f)(args)
/* # define DECL_FUNC(f,ret,args,calltype) ret (*f)(args) */ /* # define DECL_FUNC(f,ret,args,calltype) ret (*f)(args) */
#elif defined(_MSC_VER) #elif defined(_MSC_VER) || defined(__BORLANDC__)
# define DECL_FUNC(f,ret,args,calltype) ret (__##calltype *f)(args) # define DECL_FUNC(f,ret,args,calltype) ret (__##calltype *f)(args)
#else #else
# error "unsupported compiler." # error "unsupported compiler."

View file

@ -62,7 +62,7 @@ rb_dl_value2ptr(VALUE self, VALUE val)
# define MIDST_DECL_STDCALL # define MIDST_DECL_STDCALL
# define POST_DECL_CDECL # define POST_DECL_CDECL
# define POST_DECL_STDCALL # define POST_DECL_STDCALL
#elif defined(_MSC_VER) #elif defined(_MSC_VER) || defined(__BORLANDC__)
# define PRE_DECL_CDECL # define PRE_DECL_CDECL
# define PRE_DECL_STDCALL # define PRE_DECL_STDCALL
# define MIDST_DECL_CDECL __cdecl # define MIDST_DECL_CDECL __cdecl

View file

@ -133,6 +133,12 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
const char *err; const char *err;
int i; int i;
#if defined(HAVE_DLERROR)
# define CHECK_DLERROR if( err = dlerror() ){ func = 0; }
#else
# define CHECK_DLERROR
#endif
rb_secure(2); rb_secure(2);
if( sym == Qnil ){ if( sym == Qnil ){
@ -154,12 +160,8 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
handle = dlhandle->ptr; handle = dlhandle->ptr;
func = dlsym(handle, name); func = dlsym(handle, name);
#if defined(HAVE_DLERROR) CHECK_DLERROR;
if( !func && (err = dlerror()) ) if( !func ){
#else
if( !func )
#endif
{
#if defined(__CYGWIN__) || defined(WIN32) || defined(__MINGW32__) #if defined(__CYGWIN__) || defined(WIN32) || defined(__MINGW32__)
{ {
int len = strlen(name); int len = strlen(name);
@ -169,33 +171,22 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
name_a[len+1] = '\0'; name_a[len+1] = '\0';
func = dlsym(handle, name_a); func = dlsym(handle, name_a);
xfree(name_a); xfree(name_a);
#if defined(HAVE_DLERROR) CHECK_DLERROR;
if( !func && (err = dlerror()) ) if( !func ){
#else
if( !func )
#endif
{
for( i = 0; i < 256; i += 4 ){ for( i = 0; i < 256; i += 4 ){
int len = strlen(name); int len = strlen(name);
char *name_n = (char*)xmalloc(len+5); char *name_n = (char*)xmalloc(len+5);
sprintf(name_n, "%s@%d%c", name, i, 0); sprintf(name_n, "%s@%d%c", name, i, 0);
func = dlsym(handle, name_n); func = dlsym(handle, name_n);
xfree(name_n); xfree(name_n);
#if defined(HAVE_DLERROR) CHECK_DLERROR;
if( func || !(err = dlerror()) )
#else
if( func ) if( func )
#endif
{ {
break; break;
} }
} }
#if defined(HAVE_DLERROR) CHECK_DLERROR;
if( !func && (err = dlerror()) ) if( !func ){
#else
if( !func )
#endif
{
rb_raise(rb_eDLError, "Unknown symbol \"%s\".", name); rb_raise(rb_eDLError, "Unknown symbol \"%s\".", name);
} }
} }
@ -207,21 +198,13 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
sprintf(name_n, "%s@%d", name, i); sprintf(name_n, "%s@%d", name, i);
func = dlsym(handle, name_n); func = dlsym(handle, name_n);
xfree(name_n); xfree(name_n);
#if defined(HAVE_DLERROR) CHECK_DLERROR;
if( func || !(err = dlerror()) ) if( func ){
#else
if( func )
#endif
{
break; break;
} }
} }
#if defined(HAVE_DLERROR) CHECK_DLERROR;
if( !func && (err = dlerror()) ) if( !func ){
#else
if( !func )
#endif
{
rb_raise(rb_eDLError, "Unknown symbol \"%s\".", name); rb_raise(rb_eDLError, "Unknown symbol \"%s\".", name);
} }
#endif #endif