From d0fc6cbef513341ff6b3d12c9b9a1e4093c0a112 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 14 Jan 2018 21:33:52 -0600 Subject: dlfcn: Combine functions for the same header into one file Changes to existing code: * Make explicit comparison against NULL. * Adjust debug message for readability. Signed-off-by: Samuel Holland --- Makefile | 3 +-- libgcompat/dlfcn.c | 25 +++++++++++++++++++++++++ libgcompat/dlmopen.c | 14 -------------- libgcompat/dlvsym.c | 13 ------------- 4 files changed, 26 insertions(+), 29 deletions(-) create mode 100644 libgcompat/dlfcn.c delete mode 100644 libgcompat/dlmopen.c delete mode 100644 libgcompat/dlvsym.c diff --git a/Makefile b/Makefile index b6ea4f7..4873403 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,7 @@ LIBGCOMPAT_INCLUDE = \ libgcompat/alias.h LIBGCOMPAT_SRC = \ - libgcompat/dlmopen.c \ - libgcompat/dlvsym.c \ + libgcompat/dlfcn.c \ libgcompat/execinfo.c \ libgcompat/gnulib.c \ libgcompat/malloc.c \ diff --git a/libgcompat/dlfcn.c b/libgcompat/dlfcn.c new file mode 100644 index 0000000..f2eaa45 --- /dev/null +++ b/libgcompat/dlfcn.c @@ -0,0 +1,25 @@ +#include /* dlopen, dlsym */ +#include /* NULL */ +#include /* fprintf */ +#include /* getenv */ + +void *dlmopen(long lmid, const char *pathname, int mode) +{ + if (getenv("GLIBC_FAKE_DEBUG") != NULL) { + fprintf(stderr, + "loading library %s was requested in namespace %ld", + pathname, lmid); + } + + return dlopen(pathname, mode); +} + +void *dlvsym(void *handle, char *symbol, char *version) +{ + if (getenv("GLIBC_FAKE_DEBUG") != NULL) { + fprintf(stderr, "symbol %s with version %s is being redirected", + symbol, version); + } + + return dlsym(handle, symbol); +} diff --git a/libgcompat/dlmopen.c b/libgcompat/dlmopen.c deleted file mode 100644 index 4584680..0000000 --- a/libgcompat/dlmopen.c +++ /dev/null @@ -1,14 +0,0 @@ -#include /* dlopen */ -#include /* fprintf */ -#include /* getenv */ - -void *dlmopen(long lmid, const char *pathname, int mode) -{ - if (getenv("GLIBC_FAKE_DEBUG")) { - fprintf(stderr, - "library %s was requested to load in %ld namespace", - pathname, lmid); - } - - return dlopen(pathname, mode); -} diff --git a/libgcompat/dlvsym.c b/libgcompat/dlvsym.c deleted file mode 100644 index 0aba245..0000000 --- a/libgcompat/dlvsym.c +++ /dev/null @@ -1,13 +0,0 @@ -#include /* dlsym */ -#include /* fprintf */ -#include /* getenv */ - -void *dlvsym(void *handle, char *symbol, char *version) -{ - if (getenv("GLIBC_FAKE_DEBUG")) { - fprintf(stderr, "symbol %s with version %s is being redirected", - symbol, version); - } - - return dlsym(handle, symbol); -} -- cgit v1.2.3-60-g2f50