changeset 254:9d70178c1ded

- better cpp checking whether dlinfo() is available, to also cover GLIBC based systems that don't identify as Linux (e.g. debian/k*BSD)
author Tassilo Philipp
date Mon, 15 May 2017 13:06:04 +0200
parents 5cfe4322c500
children 704c28fd9428
files autovar/autovar_OS.h dyncall/dyncall_macros.h dynload/dynload_unix.c test/dynload_plain/dynload_plain.c
diffstat 4 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/autovar/autovar_OS.h	Mon May 15 02:50:03 2017 +0200
+++ b/autovar/autovar_OS.h	Mon May 15 13:06:04 2017 +0200
@@ -39,7 +39,7 @@
 #  endif
 #elif defined(__linux__) || defined(__linux) || defined(__gnu_linux__)
 #  define OS_Linux
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* latter is (also) used by systems using FreeBSD kernel, e.g. Debian/kFreeBSD, which could be detected specifically by also checking for __GLIBC__ */
 #  define OS_FreeBSD
 #elif defined(__OpenBSD__)
 #  define OS_OpenBSD
--- a/dyncall/dyncall_macros.h	Mon May 15 02:50:03 2017 +0200
+++ b/dyncall/dyncall_macros.h	Mon May 15 13:06:04 2017 +0200
@@ -72,7 +72,7 @@
 #define DC__OS_Linux
 
 /* The most powerful open source Unix-like OS - FreeBSD. */
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* latter is (also) used by systems using FreeBSD kernel, e.g. Debian/kFreeBSD, which could be detected specifically by also checking for __GLIBC__ */
 #define DC__OS_FreeBSD
 
 /* The most secure open source Unix-like OS - OpenBSD. */
--- a/dynload/dynload_unix.c	Mon May 15 02:50:03 2017 +0200
+++ b/dynload/dynload_unix.c	Mon May 15 13:06:04 2017 +0200
@@ -79,10 +79,10 @@
 
 
 /* code for dlGetLibraryPath is platform specific - if dlinfo() exists use */
-/* that (checked through existance of RTLD_DI_LINKMAP, usually a #define   */
-/* for dlinfo(), or by OS (always on Solaris where it's from, usually on   */
-/* Linux, where the flag might be an enum instead, ...) */
-#if defined(RTLD_DI_LINKMAP) || defined(OS_SunOS) || (defined(OS_Linux) && !defined(DL_DLADDR_TO_LIBPATH))
+/* that: check for RTLD_DI_LINKMAP (#define for dlinfo()), or if GNU C Lib */
+/* is used (where RTLD_DI_LINKMAP is an enum), or by OS (dlinfo comes from */
+/* Solaris), etc. */
+#if defined(RTLD_DI_LINKMAP) || defined(OS_SunOS) || defined(__GLIBC__) /* @@@ dlinfo() was introduced in glibc 2.3.3 (in 2003), somehow check for that, also */
 
 #include <link.h>
 
--- a/test/dynload_plain/dynload_plain.c	Mon May 15 02:50:03 2017 +0200
+++ b/test/dynload_plain/dynload_plain.c	Mon May 15 13:06:04 2017 +0200
@@ -45,6 +45,7 @@
   const char* path = NULL;
   const char* clibs[] = { /* hacky/lazy list of some clib paths per platform */
     "/lib/libc.so",
+    "/lib/libc.so.0.1",
     "/lib/libc.so.6",
     "/lib/libc.so.7",
     "/lib64/libc.so",