Skip to content
Merged
Prev Previous commit
Next Next commit
Only define _Py_thread_local for the core runtime.
  • Loading branch information
ericsnowcurrently committed Apr 7, 2023
commit 4af0ce7e8d06831a72d39566ca8b02093fe6ec05
32 changes: 17 additions & 15 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,21 +664,23 @@ extern char * _getpty(int *, int, mode_t, int);
#endif

#ifdef WITH_THREAD
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is useless. This macro is now always defined. It's only kept for backward compatibility.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it affect WASM builds?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the code 3 lines above:

#ifndef WITH_THREAD
#  define WITH_THREAD
#endif

# ifdef HAVE_THREAD_LOCAL
# error "unexpectedly, HAVE_THREAD_LOCAL is already defined"
# endif
# define HAVE_THREAD_LOCAL 1
# ifdef thread_local
# define _Py_thread_local thread_local
# elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
# define _Py_thread_local _Thread_local
# elif defined(_MSC_VER) /* AKA NT_THREADS */
# define _Py_thread_local __declspec(thread)
# elif defined(__GNUC__) /* includes clang */
# define _Py_thread_local __thread
# else
// fall back to the PyThread_tss_*() API, or ignore.
# undef HAVE_THREAD_LOCAL
# ifdef Py_BUILD_CORE
# ifdef HAVE_THREAD_LOCAL
# error "unexpectedly, HAVE_THREAD_LOCAL is already defined"
# endif
# define HAVE_THREAD_LOCAL 1
# ifdef thread_local
# define _Py_thread_local thread_local
# elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
# define _Py_thread_local _Thread_local
# elif defined(_MSC_VER) /* AKA NT_THREADS */
# define _Py_thread_local __declspec(thread)
# elif defined(__GNUC__) /* includes clang */
# define _Py_thread_local __thread
# else
// fall back to the PyThread_tss_*() API, or ignore.
# undef HAVE_THREAD_LOCAL
# endif
# endif
#endif

Expand Down