Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
It should be possible to build a C extension module using GCC on Windows, but when defining Py_GIL_DISABLED any call to _Py_ThreadId fails.
The if/defs in _Py_ThreadId look for _MSC_VER to be defined to determine whether it's a Windows build or not, but that specifies the VS version and not whether the build is for Windows or not.
Instead it would be better to use _WIN32 (seehttps://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170)
Something along these lines...
#if defined(_WIN32)#include <intrin.h>#endifstatic inline uintptr_t_Py_ThreadId(void){ uintptr_t tid;#if defined(_WIN32) && defined(_M_X64) tid = __readgsqword(48);#elif defined(_WIN32) && defined(_M_IX86) tid = __readfsdword(24);#elif defined(_WIN32) && defined(_M_ARM64) tid = __getReg(18);...CPython versions tested on:
3.13
Operating systems tested on:
Windows