https://github.com/python/cpython/commit/4618c0e5e60067025fd4e3ffeec494af68534862 commit: 4618c0e5e60067025fd4e3ffeec494af68534862 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: Yhg1s <[email protected]> date: 2024-09-27T19:58:36Z summary:
[3.13] gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (GH-124663) (#124698) gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (GH-124663) (cherry picked from commit 0881e2d3b1212d988733f1d3acca4011ce5e6280) Co-authored-by: Tony Roberts <[email protected]> files: A Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst M Include/Python.h M Include/object.h M Misc/ACKS diff --git a/Include/Python.h b/Include/Python.h index 882b96b73a7684..fb2d32d7110447 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -55,6 +55,10 @@ # 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" diff --git a/Include/object.h b/Include/object.h index b4db7fb204fd7d..78aa7ad0f459ff 100644 --- a/Include/object.h +++ b/Include/object.h @@ -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__) diff --git a/Misc/ACKS b/Misc/ACKS index dff73bba013698..a4a73709fae4bc 100644 --- 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 index 00000000000000..203868a8fee39c --- /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. Patch by Tony Roberts. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
