summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-05-04 06:44:44 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-05-04 06:44:44 (GMT)
commitc2f7d878972db908f5a1bad7af94c692b6d8c564 (patch)
tree5687eaadba2b722df2bf6c954fc44ebdcf67bcdf
parent0e120525f0a2dfcd417905593cad27169907a4d5 (diff)
downloadcpython-c2f7d878972db908f5a1bad7af94c692b6d8c564.zip
cpython-c2f7d878972db908f5a1bad7af94c692b6d8c564.tar.gz
cpython-c2f7d878972db908f5a1bad7af94c692b6d8c564.tar.bz2
Issue #26932: Fixed support of RTLD_* constants defined as enum values,
not via macros (in particular on Android). Patch by Chi Hsuan Yen.
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_ctypes/_ctypes.c4
-rw-r--r--Modules/_ctypes/callproc.c2
-rw-r--r--Modules/posixmodule.c14
-rw-r--r--Python/pystate.c4
-rwxr-xr-xconfigure79
-rw-r--r--configure.ac2
-rw-r--r--pyconfig.h.in28
8 files changed, 124 insertions, 12 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 46cd9ca..bae8c7b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1045,6 +1045,9 @@ Tests
Build
-----
+- Issue #26932: Fixed support of RTLD_* constants defined as enum values,
+ not via macros (in particular on Android). Patch by Chi Hsuan Yen.
+
- Issue #22359: Disable the rules for running _freeze_importlib and pgen when
cross-compiling. The output of these programs is normally saved with the
source code anyway, and is still regenerated when doing a native build.
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 6b1e744..33a7f90 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -5480,14 +5480,14 @@ PyInit__ctypes(void)
#endif
/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */
-#ifndef RTLD_LOCAL
+#if !HAVE_DECL_RTLD_LOCAL
#define RTLD_LOCAL 0
#endif
/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as
RTLD_LOCAL.
*/
-#ifndef RTLD_GLOBAL
+#if !HAVE_DECL_RTLD_GLOBAL
#define RTLD_GLOBAL RTLD_LOCAL
#endif
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 870a0d4..9ab0723 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1307,7 +1307,7 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
PyObject *name, *name2;
char *name_str;
void * handle;
-#ifdef RTLD_LOCAL
+#if HAVE_DECL_RTLD_LOCAL
int mode = RTLD_NOW | RTLD_LOCAL;
#else
/* cygwin doesn't define RTLD_LOCAL */
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 03ad07d..23b2a3c 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -12895,25 +12895,25 @@ all_ins(PyObject *m)
if (PyModule_AddIntMacro(m, XATTR_SIZE_MAX)) return -1;
#endif
-#ifdef RTLD_LAZY
+#if HAVE_DECL_RTLD_LAZY
if (PyModule_AddIntMacro(m, RTLD_LAZY)) return -1;
#endif
-#ifdef RTLD_NOW
+#if HAVE_DECL_RTLD_NOW
if (PyModule_AddIntMacro(m, RTLD_NOW)) return -1;
#endif
-#ifdef RTLD_GLOBAL
+#if HAVE_DECL_RTLD_GLOBAL
if (PyModule_AddIntMacro(m, RTLD_GLOBAL)) return -1;
#endif
-#ifdef RTLD_LOCAL
+#if HAVE_DECL_RTLD_LOCAL
if (PyModule_AddIntMacro(m, RTLD_LOCAL)) return -1;
#endif
-#ifdef RTLD_NODELETE
+#if HAVE_DECL_RTLD_NODELETE
if (PyModule_AddIntMacro(m, RTLD_NODELETE)) return -1;
#endif
-#ifdef RTLD_NOLOAD
+#if HAVE_DECL_RTLD_NOLOAD
if (PyModule_AddIntMacro(m, RTLD_NOLOAD)) return -1;
#endif
-#ifdef RTLD_DEEPBIND
+#if HAVE_DECL_RTLD_DEEPBIND
if (PyModule_AddIntMacro(m, RTLD_DEEPBIND)) return -1;
#endif
diff --git a/Python/pystate.c b/Python/pystate.c
index 0503f32..ba4dd4c 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -25,7 +25,7 @@ to avoid the expense of doing their own locking).
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
-#ifndef RTLD_LAZY
+#if !HAVE_DECL_RTLD_LAZY
#define RTLD_LAZY 1
#endif
#endif
@@ -91,7 +91,7 @@ PyInterpreterState_New(void)
interp->fscodec_initialized = 0;
interp->importlib = NULL;
#ifdef HAVE_DLOPEN
-#ifdef RTLD_NOW
+#if HAVE_DECL_RTLD_NOW
interp->dlopenflags = RTLD_NOW;
#else
interp->dlopenflags = RTLD_LAZY;
diff --git a/configure b/configure
index a961f39..a009afe 100755
--- a/configure
+++ b/configure
@@ -14255,6 +14255,85 @@ $as_echo "#define HAVE_BROKEN_SEM_GETVALUE 1" >>confdefs.h
fi
+ac_fn_c_check_decl "$LINENO" "RTLD_LAZY" "ac_cv_have_decl_RTLD_LAZY" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_LAZY" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_LAZY $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_NOW" "ac_cv_have_decl_RTLD_NOW" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_NOW" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_NOW $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_GLOBAL" "ac_cv_have_decl_RTLD_GLOBAL" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_GLOBAL" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_GLOBAL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_LOCAL" "ac_cv_have_decl_RTLD_LOCAL" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_LOCAL" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_LOCAL $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_NODELETE" "ac_cv_have_decl_RTLD_NODELETE" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_NODELETE" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_NODELETE $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_NOLOAD" "ac_cv_have_decl_RTLD_NOLOAD" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_NOLOAD" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_NOLOAD $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "RTLD_DEEPBIND" "ac_cv_have_decl_RTLD_DEEPBIND" "#include <dlfcn.h>
+"
+if test "x$ac_cv_have_decl_RTLD_DEEPBIND" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_RTLD_DEEPBIND $ac_have_decl
+_ACEOF
+
+
# determine what size digit to use for Python's longs
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking digit size for Python's longs" >&5
$as_echo_n "checking digit size for Python's longs... " >&6; }
diff --git a/configure.ac b/configure.ac
index bfd2b04..f947af9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4342,6 +4342,8 @@ then
[define to 1 if your sem_getvalue is broken.])
fi
+AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND], [], [], [[#include <dlfcn.h>]])
+
# determine what size digit to use for Python's longs
AC_MSG_CHECKING([digit size for Python's longs])
AC_ARG_ENABLE(big-digits,
diff --git a/pyconfig.h.in b/pyconfig.h.in
index b51bd56..0451855 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -167,6 +167,34 @@
*/
#undef HAVE_DECL_ISNAN
+/* Define to 1 if you have the declaration of `RTLD_DEEPBIND', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_DEEPBIND
+
+/* Define to 1 if you have the declaration of `RTLD_GLOBAL', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_GLOBAL
+
+/* Define to 1 if you have the declaration of `RTLD_LAZY', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_LAZY
+
+/* Define to 1 if you have the declaration of `RTLD_LOCAL', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_LOCAL
+
+/* Define to 1 if you have the declaration of `RTLD_NODELETE', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_NODELETE
+
+/* Define to 1 if you have the declaration of `RTLD_NOLOAD', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_NOLOAD
+
+/* Define to 1 if you have the declaration of `RTLD_NOW', and to 0 if you
+ don't. */
+#undef HAVE_DECL_RTLD_NOW
+
/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
*/
#undef HAVE_DECL_TZNAME