Debian Codegraph @

Include/cpython/pythread.h

raw
1 #ifndef Py_CPYTHON_PYTHREAD_H
2 # error "this header file must not be included directly"
3 #endif
4
5 // PY_TIMEOUT_MAX is the highest usable value (in microseconds) of PY_TIMEOUT_T
6 // type, and depends on the system threading API.
7 //
8 // NOTE: this isn't the same value as `_thread.TIMEOUT_MAX`. The _thread module
9 // exposes a higher-level API, with timeouts expressed in seconds and
10 // floating-point numbers allowed.
11 PyAPI_DATA(const long long) PY_TIMEOUT_MAX;
12
13 #define PYTHREAD_INVALID_THREAD_ID ((unsigned long)-1)
14
15 #ifdef HAVE_PTHREAD_H
16 /* Darwin needs pthread.h to know type name the pthread_key_t. */
17 # include <pthread.h>
18 # define NATIVE_TSS_KEY_T pthread_key_t
19 #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 long
24 #elif defined(HAVE_PTHREAD_STUBS)
25 # include "pthread_stubs.h"
26 # define NATIVE_TSS_KEY_T pthread_key_t
27 #else
28 # error "Require native threads. See https://bugs.python.org/issue31370"
29 #endif
30
31 /* When Py_LIMITED_API is not defined, the type layout of Py_tss_t is
32 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 */
35 struct _Py_tss_t {
36 int _is_initialized;
37 NATIVE_TSS_KEY_T _key;
38 };
39
40 #undef NATIVE_TSS_KEY_T
41
42 /* When static allocation, you must initialize with Py_tss_NEEDS_INIT. */
43 #define Py_tss_NEEDS_INIT {0}