Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Always assume the HAVE_THREAD_LOCAL macro is defined.
  • Loading branch information
ZeroIntensity committed Oct 27, 2025
commit 977e50a8e4307a5e63b1f03847378f667fb376cc
7 changes: 2 additions & 5 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,7 @@ extern "C" {

#ifdef WITH_THREAD
# ifdef Py_BUILD_CORE
Comment thread
ZeroIntensity marked this conversation as resolved.
Outdated
# ifdef HAVE_THREAD_LOCAL
# error "HAVE_THREAD_LOCAL is already defined"
# endif
// HAVE_THREAD_LOCAL is just defined here for compatibility's sake
# define HAVE_THREAD_LOCAL 1
# ifdef thread_local
# define _Py_thread_local thread_local
Expand All @@ -523,8 +521,7 @@ extern "C" {
# elif defined(__GNUC__) /* includes clang */
# define _Py_thread_local __thread
# else
// fall back to the PyThread_tss_*() API, or ignore.
# undef HAVE_THREAD_LOCAL
# error "no supported thread-local variable storage classifier"
# endif
# endif
#endif
Expand Down
14 changes: 0 additions & 14 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,42 +782,28 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
substitute this (if the name actually matches).
*/

#ifdef HAVE_THREAD_LOCAL
_Py_thread_local const char *pkgcontext = NULL;
# undef PKGCONTEXT
# define PKGCONTEXT pkgcontext
#endif

const char *
_PyImport_ResolveNameWithPackageContext(const char *name)
{
#ifndef HAVE_THREAD_LOCAL
PyMutex_Lock(&EXTENSIONS.mutex);
#endif
if (PKGCONTEXT != NULL) {
const char *p = strrchr(PKGCONTEXT, '.');
if (p != NULL && strcmp(name, p+1) == 0) {
name = PKGCONTEXT;
PKGCONTEXT = NULL;
}
}
#ifndef HAVE_THREAD_LOCAL
PyMutex_Unlock(&EXTENSIONS.mutex);
#endif
return name;
}

const char *
_PyImport_SwapPackageContext(const char *newcontext)
{
#ifndef HAVE_THREAD_LOCAL
PyMutex_Lock(&EXTENSIONS.mutex);
#endif
const char *oldcontext = PKGCONTEXT;
PKGCONTEXT = newcontext;
#ifndef HAVE_THREAD_LOCAL
PyMutex_Unlock(&EXTENSIONS.mutex);
#endif
return oldcontext;
}

Expand Down
3 changes: 0 additions & 3 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ to avoid the expense of doing their own locking).
For each of these functions, the GIL must be held by the current thread.
*/

#ifndef HAVE_THREAD_LOCAL
# error "no supported thread-local variable storage classifier"
#endif

/* The attached thread state for the current thread. */
_Py_thread_local PyThreadState *_Py_tss_tstate = NULL;
Expand Down
Loading