From c1f29da23d4f9e31f81a7d37ce9f36394ee903c4 Mon Sep 17 00:00:00 2001 From: ttate Date: Tue, 8 Feb 2005 09:18:16 +0000 Subject: 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 --- ext/dl/cfunc.c | 2 +- ext/dl/dl.c | 2 +- ext/dl/handle.c | 51 +++++++++++++++++---------------------------------- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c index 2e5a35d278..92b2d34cbb 100644 --- a/ext/dl/cfunc.c +++ b/ext/dl/cfunc.c @@ -225,7 +225,7 @@ rb_dlcfunc_inspect(VALUE self) #if defined(__GNUC__) # define DECL_FUNC(f,ret,args,calltype) ret (__attribute__((calltype)) *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) #else # error "unsupported compiler." diff --git a/ext/dl/dl.c b/ext/dl/dl.c index d63777e6c5..53e095ed51 100644 --- a/ext/dl/dl.c +++ b/ext/dl/dl.c @@ -62,7 +62,7 @@ rb_dl_value2ptr(VALUE self, VALUE val) # define MIDST_DECL_STDCALL # define POST_DECL_CDECL # define POST_DECL_STDCALL -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) || defined(__BORLANDC__) # define PRE_DECL_CDECL # define PRE_DECL_STDCALL # define MIDST_DECL_CDECL __cdecl diff --git a/ext/dl/handle.c b/ext/dl/handle.c index 4f9f3efd03..7f7eddfd18 100644 --- a/ext/dl/handle.c +++ b/ext/dl/handle.c @@ -133,6 +133,12 @@ rb_dlhandle_sym(VALUE self, VALUE sym) const char *err; int i; +#if defined(HAVE_DLERROR) +# define CHECK_DLERROR if( err = dlerror() ){ func = 0; } +#else +# define CHECK_DLERROR +#endif + rb_secure(2); if( sym == Qnil ){ @@ -154,12 +160,8 @@ rb_dlhandle_sym(VALUE self, VALUE sym) handle = dlhandle->ptr; func = dlsym(handle, name); -#if defined(HAVE_DLERROR) - if( !func && (err = dlerror()) ) -#else - if( !func ) -#endif - { + CHECK_DLERROR; + if( !func ){ #if defined(__CYGWIN__) || defined(WIN32) || defined(__MINGW32__) { int len = strlen(name); @@ -169,33 +171,22 @@ rb_dlhandle_sym(VALUE self, VALUE sym) name_a[len+1] = '\0'; func = dlsym(handle, name_a); xfree(name_a); -#if defined(HAVE_DLERROR) - if( !func && (err = dlerror()) ) -#else - if( !func ) -#endif - { + CHECK_DLERROR; + if( !func ){ for( i = 0; i < 256; i += 4 ){ int len = strlen(name); char *name_n = (char*)xmalloc(len+5); sprintf(name_n, "%s@%d%c", name, i, 0); func = dlsym(handle, name_n); xfree(name_n); -#if defined(HAVE_DLERROR) - if( func || !(err = dlerror()) ) -#else + CHECK_DLERROR; if( func ) -#endif { break; } } -#if defined(HAVE_DLERROR) - if( !func && (err = dlerror()) ) -#else - if( !func ) -#endif - { + CHECK_DLERROR; + if( !func ){ 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); func = dlsym(handle, name_n); xfree(name_n); -#if defined(HAVE_DLERROR) - if( func || !(err = dlerror()) ) -#else - if( func ) -#endif - { + CHECK_DLERROR; + if( func ){ break; } } -#if defined(HAVE_DLERROR) - if( !func && (err = dlerror()) ) -#else - if( !func ) -#endif - { + CHECK_DLERROR; + if( !func ){ rb_raise(rb_eDLError, "Unknown symbol \"%s\".", name); } #endif -- cgit v1.2.3