summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/dln.c b/dln.c
index 563e18f555..4db72cdead 100644
--- a/dln.c
+++ b/dln.c
@@ -10,8 +10,7 @@
**********************************************************************/
-#include "config.h"
-#include "defines.h"
+#include "ruby.h"
#include "dln.h"
#ifdef HAVE_STDLIB_H
@@ -1241,6 +1240,11 @@ void*
dln_load(file)
const char *file;
{
+#if !defined(_AIX) && !defined(NeXT)
+ const char *error = 0;
+#define DLN_ERROR() (error = dln_strerror(), strcpy(ALLOCA_N(char, strlen(error) + 1), error))
+#endif
+
#if defined _WIN32 && !defined __CYGWIN__
HINSTANCE handle;
char winfile[MAXPATHLEN];
@@ -1256,6 +1260,7 @@ dln_load(file)
/* Load file */
if ((handle = LoadLibrary(winfile)) == NULL) {
+ error = dln_strerror();
goto failed;
}
@@ -1270,6 +1275,7 @@ dln_load(file)
#else
#ifdef USE_DLN_A_OUT
if (load(file) == -1) {
+ error = dln_strerror();
goto failed;
}
return 0;
@@ -1294,12 +1300,14 @@ dln_load(file)
/* Load file */
if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
+ error = dln_strerror();
goto failed;
}
init_fct = (void(*)())dlsym(handle, buf);
free(buf);
if (init_fct == NULL) {
+ error = DLN_ERROR();
dlclose(handle);
goto failed;
}
@@ -1538,10 +1546,12 @@ dln_load(file)
*p2 = '\0';
if ((handle = (void*)dlopen(fname, 0)) == NULL) {
+ error = dln_strerror();
goto failed;
}
if ((init_fct = (void (*)())dlsym(handle, buf)) == NULL) {
+ error = DLN_ERROR();
dlclose(handle);
goto failed;
}
@@ -1559,7 +1569,7 @@ dln_load(file)
#endif
#if !defined(_AIX) && !defined(NeXT)
failed:
- rb_loaderror("%s - %s", dln_strerror(), file);
+ rb_loaderror("%s - %s", error, file);
#endif
return 0; /* dummy return */
}