Skip to content

[3.13] gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (GH-124663) #124698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,7 @@ Lisa Roach
Carl Robben
Ben Roberts
Mark Roberts
Tony Roberts
Andy Robinson
Jim Robinson
Yolanda Robla
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``_Py_ThreadId`` for Windows builds using MinGW. Patch by Tony Roberts.
Loading