Revert all changes to dln.c, dmydln.c, dln.h for the shared GC
This commit is contained in:
parent
64988e66d7
commit
52a0dfd4bf
50
dln.c
50
dln.c
@ -76,12 +76,6 @@ void *xrealloc();
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool
|
|
||||||
dln_supported_p(void)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef dln_loaderror
|
#ifndef dln_loaderror
|
||||||
static void
|
static void
|
||||||
dln_loaderror(const char *format, ...)
|
dln_loaderror(const char *format, ...)
|
||||||
@ -200,6 +194,7 @@ dln_strerror(char *message, size_t size)
|
|||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
#define dln_strerror() dln_strerror(message, sizeof message)
|
||||||
#elif defined USE_DLN_DLOPEN
|
#elif defined USE_DLN_DLOPEN
|
||||||
static const char *
|
static const char *
|
||||||
dln_strerror(void)
|
dln_strerror(void)
|
||||||
@ -344,13 +339,16 @@ dln_disable_dlclose(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
|
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
|
||||||
void *
|
static void *
|
||||||
dln_open(const char *file, char *error, size_t size)
|
dln_open(const char *file)
|
||||||
{
|
{
|
||||||
static const char incompatible[] = "incompatible library version";
|
static const char incompatible[] = "incompatible library version";
|
||||||
|
const char *error = NULL;
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
char message[1024];
|
||||||
|
|
||||||
/* Convert the file path to wide char */
|
/* Convert the file path to wide char */
|
||||||
WCHAR *winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);
|
WCHAR *winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);
|
||||||
if (!winfile) {
|
if (!winfile) {
|
||||||
@ -362,15 +360,15 @@ dln_open(const char *file, char *error, size_t size)
|
|||||||
free(winfile);
|
free(winfile);
|
||||||
|
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
strlcpy(error, dln_strerror(error, size), size);
|
error = dln_strerror();
|
||||||
return NULL;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(RUBY_EXPORT)
|
# if defined(RUBY_EXPORT)
|
||||||
if (!rb_w32_check_imported(handle, rb_libruby_handle())) {
|
if (!rb_w32_check_imported(handle, rb_libruby_handle())) {
|
||||||
FreeLibrary(handle);
|
FreeLibrary(handle);
|
||||||
strlcpy(error, incompatible, size);
|
error = incompatible;
|
||||||
return NULL;
|
goto failed;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -389,8 +387,8 @@ dln_open(const char *file, char *error, size_t size)
|
|||||||
/* Load file */
|
/* Load file */
|
||||||
handle = dlopen(file, RTLD_LAZY|RTLD_GLOBAL);
|
handle = dlopen(file, RTLD_LAZY|RTLD_GLOBAL);
|
||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
strlcpy(error, dln_strerror(), size);
|
error = dln_strerror();
|
||||||
return NULL;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(RUBY_EXPORT)
|
# if defined(RUBY_EXPORT)
|
||||||
@ -412,15 +410,11 @@ dln_open(const char *file, char *error, size_t size)
|
|||||||
libruby_name = tmp;
|
libruby_name = tmp;
|
||||||
}
|
}
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
|
|
||||||
if (libruby_name) {
|
if (libruby_name) {
|
||||||
snprintf(error, size, "linked to incompatible %s - %s", libruby_name, file);
|
dln_loaderror("linked to incompatible %s - %s", libruby_name, file);
|
||||||
}
|
}
|
||||||
else {
|
error = incompatible;
|
||||||
strlcpy(error, incompatible, size);
|
goto failed;
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -428,9 +422,12 @@ dln_open(const char *file, char *error, size_t size)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
|
|
||||||
|
failed:
|
||||||
|
dln_loaderror("%s - %s", error, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
static void *
|
||||||
dln_sym(void *handle, const char *symbol)
|
dln_sym(void *handle, const char *symbol)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -449,7 +446,7 @@ dln_sym_func(void *handle, const char *symbol)
|
|||||||
const char *error;
|
const char *error;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
char message[1024];
|
char message[1024];
|
||||||
error = dln_strerror(message, sizeof(message));
|
error = dln_strerror();
|
||||||
#elif defined(USE_DLN_DLOPEN)
|
#elif defined(USE_DLN_DLOPEN)
|
||||||
const size_t errlen = strlen(error = dln_strerror()) + 1;
|
const size_t errlen = strlen(error = dln_strerror()) + 1;
|
||||||
error = memcpy(ALLOCA_N(char, errlen), error, errlen);
|
error = memcpy(ALLOCA_N(char, errlen), error, errlen);
|
||||||
@ -504,12 +501,7 @@ void *
|
|||||||
dln_load(const char *file)
|
dln_load(const char *file)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
|
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
|
||||||
char error[1024];
|
void *handle = dln_open(file);
|
||||||
void *handle = dln_open(file, error, sizeof(error));
|
|
||||||
|
|
||||||
if (handle == NULL) {
|
|
||||||
dln_loaderror("%s - %s", error, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef RUBY_DLN_CHECK_ABI
|
#ifdef RUBY_DLN_CHECK_ABI
|
||||||
typedef unsigned long long abi_version_number;
|
typedef unsigned long long abi_version_number;
|
||||||
|
2
dln.h
2
dln.h
@ -22,11 +22,9 @@ RUBY_SYMBOL_EXPORT_BEGIN
|
|||||||
#define DLN_FIND_EXTRA_ARG_DECL
|
#define DLN_FIND_EXTRA_ARG_DECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool dln_supported_p(void);
|
|
||||||
char *dln_find_exe_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
|
char *dln_find_exe_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
|
||||||
char *dln_find_file_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
|
char *dln_find_file_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
|
||||||
void *dln_load(const char*);
|
void *dln_load(const char*);
|
||||||
void *dln_open(const char *file, char *error, size_t size);
|
|
||||||
void *dln_symbol(void*,const char*);
|
void *dln_symbol(void*,const char*);
|
||||||
|
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
15
dmydln.c
15
dmydln.c
@ -3,12 +3,6 @@
|
|||||||
|
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
|
|
||||||
bool
|
|
||||||
dln_supported_p(void)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NORETURN(void *dln_load(const char *));
|
NORETURN(void *dln_load(const char *));
|
||||||
void*
|
void*
|
||||||
dln_load(const char *file)
|
dln_load(const char *file)
|
||||||
@ -26,12 +20,3 @@ dln_symbol(void *handle, const char *symbol)
|
|||||||
|
|
||||||
UNREACHABLE_RETURN(NULL);
|
UNREACHABLE_RETURN(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
|
||||||
dln_open(const char *library, char *error, size_t size)
|
|
||||||
{
|
|
||||||
static const char *error_str = "this executable file can't load extension libraries";
|
|
||||||
strlcpy(error, error_str, size);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user