From 83fe35b78b7a5e0b780ed05aef9b8fb7cd62c610 Mon Sep 17 00:00:00 2001 From: Tony Roberts Date: Fri, 27 Sep 2024 12:20:17 +0100 Subject: [PATCH 1/4] Fix _Py_ThreadId for Windows builds using MinGW Fixes #124609 --- Include/Python.h | 4 ++++ Include/object.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/Include/Python.h b/Include/Python.h index 8fffa22df9da48..e1abdd16f031fb 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -55,6 +55,10 @@ # include // __readgsqword() #endif +#if defined(Py_GIL_DISABLED) && defined(__MINGW32__) +# include // __readgsqword() +#endif + // Include Python header files #include "pyport.h" #include "pymacro.h" diff --git a/Include/object.h b/Include/object.h index 7124f58f6bdb37..418f2196062df7 100644 --- a/Include/object.h +++ b/Include/object.h @@ -180,6 +180,12 @@ _Py_ThreadId(void) tid = __readfsdword(24); #elif defined(_MSC_VER) && defined(_M_ARM64) tid = __getReg(18); +#elif defined(__MINGW32__) && defined(_M_X64) + tid = __readgsqword(48); +#elif defined(__MINGW32__) && defined(_M_IX86) + tid = __readfsdword(24); +#elif defined(__MINGW32__) && defined(_M_ARM64) + tid = __getReg(18); #elif defined(__i386__) __asm__("movl %%gs:0, %0" : "=r" (tid)); // 32-bit always uses GS #elif defined(__MACH__) && defined(__x86_64__) From 8232f7d0b4b308bc78b8b8f1a8aa94f605eedc02 Mon Sep 17 00:00:00 2001 From: Tony Roberts Date: Fri, 27 Sep 2024 12:26:19 +0100 Subject: [PATCH 2/4] Add self to acknowledgements --- Misc/ACKS | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/ACKS b/Misc/ACKS index b2529601a2f71a..d94cbacf888468 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1552,6 +1552,7 @@ Lisa Roach Carl Robben Ben Roberts Mark Roberts +Tony Roberts Andy Robinson Izan "TizzySaurus" Robinson Jim Robinson From 2ba7f6a94b3c6e4eba7ab77cd1bc5fdd7d269a24 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:40:26 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst diff --git a/Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst b/Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst new file mode 100644 index 00000000000000..f07fbb3b750ed5 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst @@ -0,0 +1 @@ +Fix _Py_ThreadId for Windows builds using MinGW. From 8ef34e4e55b94faa2a0a47132249c4f459af6549 Mon Sep 17 00:00:00 2001 From: Tony Roberts Date: Fri, 27 Sep 2024 17:20:55 +0100 Subject: [PATCH 4/4] Update Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- .../next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst b/Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst index f07fbb3b750ed5..203868a8fee39c 100644 --- a/Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst +++ b/Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst @@ -1 +1 @@ -Fix _Py_ThreadId for Windows builds using MinGW. +Fix ``_Py_ThreadId`` for Windows builds using MinGW. Patch by Tony Roberts.