]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (GH-124663) (#124698)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 27 Sep 2024 19:58:36 +0000 (21:58 +0200)
committerGitHub <noreply@github.com>
Fri, 27 Sep 2024 19:58:36 +0000 (19:58 +0000)
gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (GH-124663)
(cherry picked from commit 0881e2d3b1212d988733f1d3acca4011ce5e6280)

Co-authored-by: Tony Roberts <tony@pyxll.com>
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 882b96b73a7684f1e48ad52618e216a9ea882572..fb2d32d71104475d1505e5ab7afca980ef192ce1 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 b4db7fb204fd7d49a27c9a8ff94897e165b647dd..78aa7ad0f459fff9576898079fcb7b6e681de515 100644 (file)
@@ -247,6 +247,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 dff73bba0136987487d781ac2baec8528c73fc06..a4a73709fae4bc1ee0dc19e7263d4675198491ba 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1550,6 +1550,7 @@ Lisa Roach
 Carl Robben
 Ben Roberts
 Mark Roberts
+Tony Roberts
 Andy Robinson
 Jim Robinson
 Yolanda Robla
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.