Skip to content

Commit

Permalink
Rename dlopen function to avoid POSIX name clash
Browse files Browse the repository at this point in the history
No function overloading in C!
  • Loading branch information
ctrueden committed Mar 7, 2024
1 parent 5c423ee commit 0f4307e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/c/jvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int launch_jvm(const size_t argc, const char **argv) {

// Load libjvm.
debug("[JAUNCH-JVM] LOADING LIBJVM");
void *jvm_library = dlopen(libjvm_path);
void *jvm_library = loadlib(libjvm_path);
if (!jvm_library) { error("Error loading libjvm: %s", dlerror()); return ERROR_DLOPEN; }

// Load JNI_CreateJavaVM function.
Expand Down
2 changes: 1 addition & 1 deletion src/c/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define SLASH "/"
#define EXE_SUFFIX ""

void *dlopen(const char *path) { return dlopen(path, RTLD_NOW | RTLD_GLOBAL); /* TODO: or RTLD_LAZY? */ }
void *loadlib(const char *path) { return dlopen(path, RTLD_NOW | RTLD_GLOBAL); /* TODO: or RTLD_LAZY? */ }

int file_exists(const char *path) {
return access(path, F_OK) == 0;
Expand Down
2 changes: 1 addition & 1 deletion src/c/python.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int launch_python(const size_t argc, const char **argv) {

// Load libpython.
debug("[JAUNCH-PYTHON] LOADING LIBPYTHON");
void *python_library = dlopen(libpython_path);
void *python_library = loadlib(libpython_path);
if (!python_library) { error("Error loading libpython: %s", dlerror()); return ERROR_DLOPEN; }

// Load Py_BytesMain function.
Expand Down
2 changes: 1 addition & 1 deletion src/c/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define SLASH "\\"
#define EXE_SUFFIX ".exe"

void *dlopen(const char *path) { return LoadLibrary(path); }
void *loadlib(const char *path) { return LoadLibrary(path); }
void *dlsym(void *library, const char *symbol) { return GetProcAddress(library, symbol); }
void dlclose(void *library) { FreeLibrary(library); }
char *dlerror() {
Expand Down

0 comments on commit 0f4307e

Please sign in to comment.