codekingpro/portable-devtools
115k
1#ifndef Py_CPYTHON_PYTHREAD_H2# error "this header file must not be included directly"3#endif4 5// PY_TIMEOUT_MAX is the highest usable value (in microseconds) of PY_TIMEOUT_T6// type, and depends on the system threading API.7//8// NOTE: this isn't the same value as `_thread.TIMEOUT_MAX`. The _thread module9// exposes a higher-level API, with timeouts expressed in seconds and10// floating-point numbers allowed.11PyAPI_DATA(const long long) PY_TIMEOUT_MAX;12 13#define PYTHREAD_INVALID_THREAD_ID ((unsigned long)-1)14 15#ifdef HAVE_PTHREAD_H16 /* Darwin needs pthread.h to know type name the pthread_key_t. */17# include <pthread.h>18# define NATIVE_TSS_KEY_T pthread_key_t19#elif defined(NT_THREADS)20 /* In Windows, native TSS key type is DWORD,21 but hardcode the unsigned long to avoid errors for include directive.22 */23# define NATIVE_TSS_KEY_T unsigned long24#elif defined(HAVE_PTHREAD_STUBS)25# include "pthread_stubs.h"26# define NATIVE_TSS_KEY_T pthread_key_t27#else28# error "Require native threads. See https://bugs.python.org/issue31370"29#endif30 31/* When Py_LIMITED_API is not defined, the type layout of Py_tss_t is32 exposed to allow static allocation in the API clients. Even in this case,33 you must handle TSS keys through API functions due to compatibility.34*/35struct _Py_tss_t {36 int _is_initialized;37 NATIVE_TSS_KEY_T _key;38};39 40#undef NATIVE_TSS_KEY_T41 42/* When static allocation, you must initialize with Py_tss_NEEDS_INIT. */43#define Py_tss_NEEDS_INIT {0}44 