Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion cli/loader_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,27 @@ void jl_loader_print_stderr3(const char * msg1, const char * msg2, const char *

/* Wrapper around dlopen(), with extra relative pathing thrown in*/
static void * load_library(const char * rel_path, const char * src_dir) {
void * handle = NULL;

// See if a handle is already open to the basename
const char *basename = rel_path + strlen(rel_path);
while (basename-- > rel_path)
if (*basename == PATHSEPSTRING[0] || *basename == '/')
break;
basename++;
#if defined(_OS_WINDOWS_)
if ((handle = GetModuleHandleW(basename)))
return handle;
#else
if ((handle = dlopen(basename, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL)))
return handle;
#endif

char path[2*PATH_MAX + 1] = {0};
strncat(path, src_dir, sizeof(path) - 1);
strncat(path, PATHSEPSTRING, sizeof(path) - 1);
strncat(path, rel_path, sizeof(path) - 1);

void * handle = NULL;
#if defined(_OS_WINDOWS_)
wchar_t wpath[2*PATH_MAX + 1] = {0};
if (!utf8_to_wchar(path, wpath, 2*PATH_MAX)) {
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,4 @@
XX(jl_vprintf) \
XX(jl_wakeup_thread) \
XX(jl_yield) \