]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (#124663)
authorTony Roberts <tony@pyxll.com>
Fri, 27 Sep 2024 18:52:23 +0000 (19:52 +0100)
committerGitHub <noreply@github.com>
Fri, 27 Sep 2024 18:52:23 +0000 (18:52 +0000)
Include/Python.h
Include/object.h
Misc/ACKS
Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst [new file with mode: 0644]

index 8fffa22df9da48db37426732b50960c49e4f0324..e1abdd16f031fbd93f6553c8ac1f6b7c784ce4f3 100644 (file)
 #  include <intrin.h>             // __readgsqword()
 #endif
 
+#if defined(Py_GIL_DISABLED) && defined(__MINGW32__)
+#  include <intrin.h>             // __readgsqword()
+#endif
+
 // Include Python header files
 #include "pyport.h"
 #include "pymacro.h"
index 7124f58f6bdb375b8300e366be46eca634eef2ad..418f2196062df7cb071a919ae773acdd4c02a08d 100644 (file)
@@ -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__)
index b2529601a2f71abcefebab94b8ced1db15e97bc5..d94cbacf88846807c621fb57879d24e4a474d743 100644 (file)
--- 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
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 (file)
index 0000000..203868a
--- /dev/null
@@ -0,0 +1 @@
+Fix ``_Py_ThreadId`` for Windows builds using MinGW. Patch by Tony Roberts.