summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/dl/cfunc.c2
-rw-r--r--ext/dl/dl.c2
-rw-r--r--ext/dl/handle.c51
3 files changed, 19 insertions, 36 deletions
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c
index 2e5a35d2780..92b2d34cbbe 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 d63777e6c5d..53e095ed511 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 4f9f3efd033..7f7eddfd18b 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