From 57c57df7b4579b60a84062df2e64f84dd84558b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tapani=20P=C3=A4lli?= Date: Thu, 16 Aug 2012 13:59:12 +0300 Subject: [PATCH] mesa/dlopen: use HAVE_DLOPEN instead of _GNU_SOURCE MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patches changes mesa to use 'HAVE_DLOPEN' defined by configure and Android.mk instead of _GNU_SOURCE for detecting dlopen capability. This makes dlopen to work also on Android where _GNU_SOURCE is not defined. [mattst88] v2: HAVE_DLOPEN is sufficient for including dlfcn.h, remove mingw/blrts checks around dlfcn.h inclusion. Reviewed-by: Brian Paul Reviewed-by: Matt Turner Signed-off-by: Tapani Pälli --- Android.common.mk | 4 +++- configure.ac | 5 +++-- src/mesa/main/dlopen.c | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Android.common.mk b/Android.common.mk index e8b900697f3..1e9f040ac07 100644 --- a/Android.common.mk +++ b/Android.common.mk @@ -47,7 +47,9 @@ LOCAL_CFLAGS += \ ifeq ($(strip $(MESA_ENABLE_ASM)),true) ifeq ($(TARGET_ARCH),x86) LOCAL_CFLAGS += \ - -DUSE_X86_ASM + -DUSE_X86_ASM \ + -DHAVE_DLOPEN \ + endif endif diff --git a/configure.ac b/configure.ac index ad20c87c505..9bf4e1e1f63 100644 --- a/configure.ac +++ b/configure.ac @@ -499,8 +499,9 @@ MESA_PIC_FLAGS dnl Check to see if dlopen is in default libraries (like Solaris, which dnl has it in libc), or if libdl is needed to get it. -AC_CHECK_FUNC([dlopen], [], - [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])]) +AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"], + [AC_CHECK_LIB([dl], [dlopen], + [DEFINES="$DEFINES -DHAVE_DLOPEN"; DLOPEN_LIBS="-ldl"])]) AC_SUBST([DLOPEN_LIBS]) dnl See if posix_memalign is available diff --git a/src/mesa/main/dlopen.c b/src/mesa/main/dlopen.c index 57a33292ed1..aaee9636936 100644 --- a/src/mesa/main/dlopen.c +++ b/src/mesa/main/dlopen.c @@ -31,7 +31,7 @@ #include "compiler.h" #include "dlopen.h" -#if defined(_GNU_SOURCE) && !defined(__MINGW32__) && !defined(__blrts) +#if defined(HAVE_DLOPEN) #include #endif #if defined(_WIN32) @@ -48,7 +48,7 @@ _mesa_dlopen(const char *libname, int flags) { #if defined(__blrts) return NULL; -#elif defined(_GNU_SOURCE) +#elif defined(HAVE_DLOPEN) flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */ return dlopen(libname, flags); #elif defined(__MINGW32__) @@ -80,7 +80,7 @@ _mesa_dlsym(void *handle, const char *fname) strncpy(fname2 + 1, fname, 998); fname2[999] = 0; u.v = dlsym(handle, fname2); -#elif defined(_GNU_SOURCE) +#elif defined(HAVE_DLOPEN) u.v = dlsym(handle, fname); #elif defined(__MINGW32__) u.v = (void *) GetProcAddress(handle, fname); @@ -99,7 +99,7 @@ _mesa_dlclose(void *handle) { #if defined(__blrts) (void) handle; -#elif defined(_GNU_SOURCE) +#elif defined(HAVE_DLOPEN) dlclose(handle); #elif defined(__MINGW32__) FreeLibrary(handle); -- 2.30.2