diff -urN a/configure.ac b/configure.ac --- a/configure.ac 2014-10-11 14:21:18.680234100 +0100 +++ b/configure.ac 2014-10-11 14:21:21.473393900 +0100 @@ -1708,7 +1708,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 \ @@ -2418,9 +2418,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 @@ -4672,6 +4674,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 -urN a/Python/condvar.h b/Python/condvar.h --- a/Python/condvar.h 2014-10-11 14:21:18.718236300 +0100 +++ b/Python/condvar.h 2014-10-11 14:21:21.475394000 +0100 @@ -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 -urN a/Python/thread.c b/Python/thread.c --- a/Python/thread.c 2014-10-11 14:21:18.719236400 +0100 +++ b/Python/thread.c 2014-10-11 14:21:21.476394100 +0100 @@ -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