Skip to content

Commit 977e50a

Browse files
committed
Always assume the HAVE_THREAD_LOCAL macro is defined.
1 parent f5394c2 commit 977e50a

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

Include/pyport.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,7 @@ extern "C" {
510510

511511
#ifdef WITH_THREAD
512512
# ifdef Py_BUILD_CORE
513-
# ifdef HAVE_THREAD_LOCAL
514-
# error "HAVE_THREAD_LOCAL is already defined"
515-
# endif
513+
// HAVE_THREAD_LOCAL is just defined here for compatibility's sake
516514
# define HAVE_THREAD_LOCAL 1
517515
# ifdef thread_local
518516
# define _Py_thread_local thread_local
@@ -523,8 +521,7 @@ extern "C" {
523521
# elif defined(__GNUC__) /* includes clang */
524522
# define _Py_thread_local __thread
525523
# else
526-
// fall back to the PyThread_tss_*() API, or ignore.
527-
# undef HAVE_THREAD_LOCAL
524+
# error "no supported thread-local variable storage classifier"
528525
# endif
529526
# endif
530527
#endif

Python/import.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -782,42 +782,28 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
782782
substitute this (if the name actually matches).
783783
*/
784784

785-
#ifdef HAVE_THREAD_LOCAL
786785
_Py_thread_local const char *pkgcontext = NULL;
787786
# undef PKGCONTEXT
788787
# define PKGCONTEXT pkgcontext
789-
#endif
790788

791789
const char *
792790
_PyImport_ResolveNameWithPackageContext(const char *name)
793791
{
794-
#ifndef HAVE_THREAD_LOCAL
795-
PyMutex_Lock(&EXTENSIONS.mutex);
796-
#endif
797792
if (PKGCONTEXT != NULL) {
798793
const char *p = strrchr(PKGCONTEXT, '.');
799794
if (p != NULL && strcmp(name, p+1) == 0) {
800795
name = PKGCONTEXT;
801796
PKGCONTEXT = NULL;
802797
}
803798
}
804-
#ifndef HAVE_THREAD_LOCAL
805-
PyMutex_Unlock(&EXTENSIONS.mutex);
806-
#endif
807799
return name;
808800
}
809801

810802
const char *
811803
_PyImport_SwapPackageContext(const char *newcontext)
812804
{
813-
#ifndef HAVE_THREAD_LOCAL
814-
PyMutex_Lock(&EXTENSIONS.mutex);
815-
#endif
816805
const char *oldcontext = PKGCONTEXT;
817806
PKGCONTEXT = newcontext;
818-
#ifndef HAVE_THREAD_LOCAL
819-
PyMutex_Unlock(&EXTENSIONS.mutex);
820-
#endif
821807
return oldcontext;
822808
}
823809

Python/pystate.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ to avoid the expense of doing their own locking).
6767
For each of these functions, the GIL must be held by the current thread.
6868
*/
6969

70-
#ifndef HAVE_THREAD_LOCAL
71-
# error "no supported thread-local variable storage classifier"
72-
#endif
7370

7471
/* The attached thread state for the current thread. */
7572
_Py_thread_local PyThreadState *_Py_tss_tstate = NULL;

0 commit comments

Comments
 (0)