summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/dln.c b/dln.c
index 5f6b1f0564..d3b03e3e87 100644
--- a/dln.c
+++ b/dln.c
@@ -25,8 +25,8 @@ static void dln_loaderror(const char *format, ...);
#endif
#include "dln.h"
#include "internal.h"
+#include "internal/box.h"
#include "internal/compilers.h"
-#include "internal/namespace.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
@@ -77,6 +77,10 @@ void *xrealloc();
# include <unistd.h>
#endif
+#ifndef UNREACHABLE_RETURN
+# define UNREACHABLE_RETURN(x) return (x)
+#endif
+
#ifndef dln_loaderror
static void
dln_loaderror(const char *format, ...)
@@ -348,6 +352,7 @@ dln_open(const char *file)
void *handle;
#if defined(_WIN32)
+# define DLN_DEFINED
char message[1024];
/* Convert the file path to wide char */
@@ -374,6 +379,7 @@ dln_open(const char *file)
# endif
#elif defined(USE_DLN_DLOPEN)
+# define DLN_DEFINED
# ifndef RTLD_LAZY
# define RTLD_LAZY 1
@@ -389,7 +395,7 @@ dln_open(const char *file)
# endif
/* Load file */
- int mode = rb_namespace_available() ? RTLD_LAZY|RTLD_LOCAL : RTLD_LAZY|RTLD_GLOBAL;
+ int mode = rb_box_available() ? RTLD_LAZY|RTLD_LOCAL : RTLD_LAZY|RTLD_GLOBAL;
handle = dlopen(file, mode);
if (handle == NULL) {
error = dln_strerror();
@@ -505,7 +511,7 @@ abi_check_enabled_p(void)
static void *
dln_load_and_init(const char *file, const char *init_fct_name)
{
-#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
+#if defined(DLN_DEFINED)
void *handle = dln_open(file);
#ifdef RUBY_DLN_CHECK_ABI
@@ -523,6 +529,7 @@ dln_load_and_init(const char *file, const char *init_fct_name)
return handle;
#elif defined(_AIX)
+# define DLN_DEFINED
{
void (*init_fct)(void);
@@ -539,33 +546,25 @@ dln_load_and_init(const char *file, const char *init_fct_name)
}
#else
dln_notimplement();
+ UNREACHABLE_RETURN(0);
#endif
-
- return 0; /* dummy return */
}
void *
dln_load(const char *file)
{
-#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
- char *init_fct_name;
- init_funcname(&init_fct_name, file);
- return dln_load_and_init(file, init_fct_name);
-#else
- dln_notimplement();
- return 0;
-#endif
+ return dln_load_feature(file, file);
}
void *
dln_load_feature(const char *file, const char *fname)
{
-#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
+#if defined(DLN_DEFINED)
char *init_fct_name;
init_funcname(&init_fct_name, fname);
return dln_load_and_init(file, init_fct_name);
#else
dln_notimplement();
- return 0;
+ UNREACHABLE_RETURN(0);
#endif
}