blob: ec8870b6b8eb74b895ae15ae5934172ff9b7c2e6 [file] [log] [blame]
From cef46d4d01202b0297badf3d715928e3b7406357 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
<alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:51:45 +0530
Subject: [PATCH 036/N] py3k mingw ntthreads vs pthreads
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Алексей <alexey.pawlow@gmail.com>
Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>
---
Include/internal/pycore_condvar.h | 10 ++++++++++
Include/pythread.h | 6 ++++++
2 files changed, 16 insertions(+)
diff --git a/Include/internal/pycore_condvar.h b/Include/internal/pycore_condvar.h
index 8b89d70..dd98245 100644
--- a/Include/internal/pycore_condvar.h
+++ b/Include/internal/pycore_condvar.h
@@ -5,6 +5,12 @@
# error "this header requires Py_BUILD_CORE define"
#endif
+#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
@@ -37,6 +43,10 @@
/* include windows if it hasn't been done before */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+/* winpthreads are involved via windows header, so need undef _POSIX_THREADS after header include */
+#if defined(_POSIX_THREADS)
+#undef _POSIX_THREADS
+#endif
/* options */
/* non-emulated condition variables are provided for those that want
diff --git a/Include/pythread.h b/Include/pythread.h
index bb9d864..f1e52c6 100644
--- a/Include/pythread.h
+++ b/Include/pythread.h
@@ -8,6 +8,12 @@ typedef void *PyThread_type_lock;
extern "C" {
#endif
+#ifdef __MINGW32__
+# if !defined(HAVE_PTHREAD_H) || defined(NT_THREADS)
+# undef _POSIX_THREADS
+# endif
+#endif
+
/* Return status codes for Python lock acquisition. Chosen for maximum
* backwards compatibility, ie failure -> 0, success -> 1. */
typedef enum PyLockStatus {
--
2.32.0