summaryrefslogtreecommitdiff
path: root/ext/dl/handle.c
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-08 09:18:16 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-08 09:18:16 +0000
commitc1f29da23d4f9e31f81a7d37ce9f36394ee903c4 (patch)
tree4b903a0335665a0f7a41129f94894bfe6dbc3711 /ext/dl/handle.c
parent84075c004b53559e7f096f1053e70fe232ce6128 (diff)
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
Diffstat (limited to 'ext/dl/handle.c')
-rw-r--r--ext/dl/handle.c51
1 files changed, 17 insertions, 34 deletions
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