gh-112535: Implement fallback implementation of _Py_ThreadId() (gh-113185)

---------

Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
Donghee Na 2023-12-18 16:54:49 +00:00 committed by GitHub
parent 59f0766ae5
commit d00dbf5415
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -1951,6 +1951,20 @@ _PyThreadState_Bind(PyThreadState *tstate)
}
}
#if defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
uintptr_t
_Py_GetThreadLocal_Addr(void)
{
#ifdef HAVE_THREAD_LOCAL
// gh-112535: Use the address of the thread-local PyThreadState variable as
// a unique identifier for the current thread. Each thread has a unique
// _Py_tss_tstate variable with a unique address.
return (uintptr_t)&_Py_tss_tstate;
#else
# error "no supported thread-local variable storage classifier"
#endif
}
#endif
/***********************************/
/* routines for advanced debuggers */