diff -Naur Python-3.5.0-orig/configure.ac Python-3.5.0/configure.ac --- Python-3.5.0-orig/configure.ac 2015-09-21 13:41:56.872256800 +0300 +++ Python-3.5.0/configure.ac 2015-09-21 13:41:56.988523200 +0300 @@ -1896,7 +1896,7 @@ AC_HEADER_STDC AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \ +ieeefp.h io.h langinfo.h libintl.h process.h \ sched.h shadow.h signal.h stdint.h stropts.h termios.h \ unistd.h utime.h \ poll.h sys/devpoll.h sys/epoll.h sys/poll.h \ @@ -2609,9 +2609,11 @@ : else if test "$with_threads" = "yes" -o -z "$with_threads"; then - AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris - # posix4 on Solaris 2.6 - # pthread (first!) on Linux + if test "$ac_cv_ntthread" = "no" -o -z "$ac_cv_ntthread"; then + AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris + # posix4 on Solaris 2.6 + # pthread (first!) on Linux + fi fi fi @@ -4902,6 +4904,14 @@ AC_CHECK_HEADERS(curses.h ncurses.h) +# If using nt threads, don't look for pthread.h or thread.h +if test "x$ac_cv_ntthread" = xno ; then +AC_HEADER_STDC +AC_CHECK_HEADERS(pthread.h thread.h) +AC_HEADER_DIRENT +AC_HEADER_MAJOR +fi + # On Solaris, term.h requires curses.h AC_CHECK_HEADERS(term.h,,,[ #ifdef HAVE_CURSES_H diff -Naur Python-3.5.0-orig/Python/condvar.h Python-3.5.0/Python/condvar.h --- Python-3.5.0-orig/Python/condvar.h 2015-09-13 14:41:26.000000000 +0300 +++ Python-3.5.0/Python/condvar.h 2015-09-21 13:41:56.995296000 +0300 @@ -42,6 +42,12 @@ #include "Python.h" +#ifdef __MINGW32__ +# if !defined(HAVE_PTHREAD_H) || defined(NT_THREADS) +# undef _POSIX_THREADS +# endif +#endif + #ifndef _POSIX_THREADS /* This means pthreads are not implemented in libc headers, hence the macro not present in unistd.h. But they still can be implemented as an external diff -Naur Python-3.5.0-orig/Python/thread.c Python-3.5.0/Python/thread.c --- Python-3.5.0-orig/Python/thread.c 2015-09-13 14:41:26.000000000 +0300 +++ Python-3.5.0/Python/thread.c 2015-09-21 13:41:57.011099200 +0300 @@ -7,6 +7,12 @@ #include "Python.h" +#ifdef __MINGW32__ +# if !defined(HAVE_PTHREAD_H) || defined(NT_THREADS) +# undef _POSIX_THREADS +# endif +#endif + #ifndef _POSIX_THREADS /* This means pthreads are not implemented in libc headers, hence the macro not present in unistd.h. But they still can be implemented as an external