diff -r 3248782c3176 Python/thread_pthread.h --- a/Python/thread_pthread.h Sat Nov 19 16:20:31 2016 +0100 +++ b/Python/thread_pthread.h Sun Nov 20 03:39:07 2016 +0900 @@ -601,6 +601,12 @@ #define THREAD_SET_STACKSIZE(x) _pythread_pthread_set_stacksize(x) + +/* Issue #25658: POSIX doesn't require that pthread_key_t is integer. + If key type isn't integer, TLS functions are implemented by CPython self. +*/ +#ifdef PTHREAD_KEY_T_IS_INTEGER + #define Py_HAVE_NATIVE_TLS int @@ -648,3 +654,5 @@ void PyThread_ReInitTLS(void) {} + +#endif /* PTHREAD_KEY_T_IS_INTEGER */ diff -r 3248782c3176 configure --- a/configure Sat Nov 19 16:20:31 2016 +0100 +++ b/configure Sun Nov 20 03:39:07 2016 +0900 @@ -8990,6 +8990,35 @@ fi + +# Issue #25658: POSIX doesn't require that pthread_key_t is integer. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_key_t is integer" >&5 +$as_echo_n "checking whether pthread_key_t is integer... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +pthread_key_t k; k * 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_pthread_key_t_is_integer=yes +else + ac_pthread_key_t_is_integer=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pthread_key_t_is_integer" >&5 +$as_echo "$ac_pthread_key_t_is_integer" >&6; } +if test "$ac_pthread_key_t_is_integer" = yes ; then + +$as_echo "#define PTHREAD_KEY_T_IS_INTEGER 1" >>confdefs.h + +fi CC="$ac_save_cc" diff -r 3248782c3176 configure.ac --- a/configure.ac Sat Nov 19 16:20:31 2016 +0100 +++ b/configure.ac Sun Nov 20 03:39:07 2016 +0900 @@ -2268,6 +2268,19 @@ #endif ]) fi + +# Issue #25658: POSIX doesn't require that pthread_key_t is integer. +AC_MSG_CHECKING(whether pthread_key_t is integer) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include ]], [[pthread_key_t k; k * 1;]])], + [ac_pthread_key_t_is_integer=yes], + [ac_pthread_key_t_is_integer=no] +) +AC_MSG_RESULT($ac_pthread_key_t_is_integer) +if test "$ac_pthread_key_t_is_integer" = yes ; then + AC_DEFINE(PTHREAD_KEY_T_IS_INTEGER, 1, + [Define if pthread_key_t is integer.]) +fi CC="$ac_save_cc" AC_SUBST(OTHER_LIBTOOL_OPT) diff -r 3248782c3176 pyconfig.h.in --- a/pyconfig.h.in Sat Nov 19 16:20:31 2016 +0100 +++ b/pyconfig.h.in Sun Nov 20 03:39:07 2016 +0900 @@ -1238,6 +1238,9 @@ /* Define if POSIX semaphores aren't enabled on your system */ #undef POSIX_SEMAPHORES_NOT_ENABLED +/* Define if pthread_key_t is integer. */ +#undef PTHREAD_KEY_T_IS_INTEGER + /* Defined if PTHREAD_SCOPE_SYSTEM supported. */ #undef PTHREAD_SYSTEM_SCHED_SUPPORTED