summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/dln.c b/dln.c
index 100fa08a10..4e39bc8afb 100644
--- a/dln.c
+++ b/dln.c
@@ -48,7 +48,7 @@ void *xrealloc();
#endif
#include <stdio.h>
-#ifdef NT
+#if defined(NT) || defined(__VMS)
#include "missing/file.h"
#endif
#include <sys/types.h>
@@ -72,6 +72,11 @@ void *xrealloc();
char *getenv();
#endif
+#if defined(__VMS)
+#pragma builtins
+#include <dlfcn.h>
+#endif
+
#ifdef __MACOS__
# include <TextUtils.h>
# include <CodeFragments.h>
@@ -1517,6 +1522,33 @@ dln_load(file)
}
#endif /* __MACOS__ */
+#if defined(__VMS)
+#define DLN_DEFINED
+ {
+ void *handle, (*init_fct)();
+ char *fname, *p1, *p2;
+
+ fname = (char *)__alloca(strlen(file)+1);
+ strcpy(fname,file);
+ if (p1 = strrchr(fname,'/'))
+ fname = p1 + 1;
+ if (p2 = strrchr(fname,'.'))
+ *p2 = '¥0';
+
+ if ((handle = (void*)dlopen(fname, 0)) == NULL) {
+ goto failed;
+ }
+
+ if ((init_fct = (void (*)())dlsym(handle, buf)) == NULL) {
+ dlclose(handle);
+ goto failed;
+ }
+ /* Call the init code */
+ (*init_fct)();
+ return handle;
+ }
+#endif /* __VMS */
+
#ifndef DLN_DEFINED
rb_notimplement("dynamic link not supported");
#endif