diff options
author | Tony Roberts <tony@pyxll.com> | 2024-09-27 18:52:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-27 18:52:23 (GMT) |
commit | 0881e2d3b1212d988733f1d3acca4011ce5e6280 (patch) | |
tree | 7afc9664bcb62f1ab54a43f59d7789bb4ef64dc1 | |
parent | 2e155536caf8a090c06d62dd92647abc62362463 (diff) | |
download | cpython-0881e2d3b1212d988733f1d3acca4011ce5e6280.zip cpython-0881e2d3b1212d988733f1d3acca4011ce5e6280.tar.gz cpython-0881e2d3b1212d988733f1d3acca4011ce5e6280.tar.bz2 |
gh-124609: Fix _Py_ThreadId for Windows builds using MinGW (#124663)
-rw-r--r-- | Include/Python.h | 4 | ||||
-rw-r--r-- | Include/object.h | 6 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Windows/2024-09-27-13-40-25.gh-issue-124609.WaKk8G.rst | 1 |
4 files changed, 12 insertions, 0 deletions
diff --git a/Include/Python.h b/Include/Python.h index 8fffa22..e1abdd1 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 7124f58..418f219 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__) @@ -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 index 0000000..203868a --- /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. |