| 1 |
#ifndef Py_PYTHREAD_H |
| 2 |
#define Py_PYTHREAD_H |
| 3 |
|
| 4 |
#define WITH_THREAD |
| 5 |
|
| 6 |
typedef void *PyThread_type_lock; |
| 7 |
|
| 8 |
#ifdef __cplusplus |
| 9 |
extern "C" { |
| 10 |
#endif |
| 11 |
|
| 12 |
typedef enum PyLockStatus { |
| 13 |
PY_LOCK_FAILURE = 0, |
| 14 |
PY_LOCK_ACQUIRED = 1, |
| 15 |
PY_LOCK_INTR |
| 16 |
} PyLockStatus; |
| 17 |
|
| 18 |
PyAPI_FUNC(long) PyThread_get_thread_ident(void); |
| 19 |
|
| 20 |
PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); |
| 21 |
PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); |
| 22 |
PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); |
| 23 |
#define WAIT_LOCK 1 |
| 24 |
#define NOWAIT_LOCK 0 |
| 25 |
|
| 26 |
|
| 27 |
#define PY_TIMEOUT_T long long |
| 28 |
PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock lock, |
| 29 |
PY_TIMEOUT_T microseconds, |
| 30 |
int intr_flag); |
| 31 |
PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); |
| 32 |
|
| 33 |
PyAPI_FUNC(void) PyThread_init_thread(void); |
| 34 |
PyAPI_FUNC(long) PyThread_start_new_thread(void (*func)(void *), void *arg); |
| 35 |
|
| 36 |
|
| 37 |
PyAPI_FUNC(int) PyThread_create_key(void); |
| 38 |
PyAPI_FUNC(void) PyThread_delete_key(int); |
| 39 |
PyAPI_FUNC(int) PyThread_set_key_value(int, void *); |
| 40 |
PyAPI_FUNC(void *) PyThread_get_key_value(int); |
| 41 |
PyAPI_FUNC(void) PyThread_delete_key_value(int key); |
| 42 |
|
| 43 |
|
| 44 |
PyAPI_FUNC(void) PyThread_ReInitTLS(void); |
| 45 |
|
| 46 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
typedef struct _Py_tss_t Py_tss_t; |
| 51 |
|
| 52 |
#ifndef Py_LIMITED_API |
| 53 |
#if defined(_POSIX_THREADS) |
| 54 |
|
| 55 |
# include <pthread.h> |
| 56 |
# define NATIVE_TSS_KEY_T pthread_key_t |
| 57 |
#elif defined(_WIN32) |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
# define NATIVE_TSS_KEY_T unsigned long |
| 62 |
#else |
| 63 |
# error "Require native threads. See https://bugs.python.org/issue31370" |
| 64 |
#endif |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
struct _Py_tss_t { |
| 71 |
int _is_initialized; |
| 72 |
NATIVE_TSS_KEY_T _key; |
| 73 |
}; |
| 74 |
|
| 75 |
#undef NATIVE_TSS_KEY_T |
| 76 |
|
| 77 |
|
| 78 |
#define Py_tss_NEEDS_INIT {0} |
| 79 |
#endif |
| 80 |
|
| 81 |
PyAPI_FUNC(Py_tss_t *) PyThread_tss_alloc(void); |
| 82 |
PyAPI_FUNC(void) PyThread_tss_free(Py_tss_t *key); |
| 83 |
|
| 84 |
|
| 85 |
PyAPI_FUNC(int) PyThread_tss_is_created(Py_tss_t *key); |
| 86 |
PyAPI_FUNC(int) PyThread_tss_create(Py_tss_t *key); |
| 87 |
PyAPI_FUNC(void) PyThread_tss_delete(Py_tss_t *key); |
| 88 |
PyAPI_FUNC(int) PyThread_tss_set(Py_tss_t *key, void *value); |
| 89 |
PyAPI_FUNC(void *) PyThread_tss_get(Py_tss_t *key); |
| 90 |
#endif |
| 91 |
|
| 92 |
#ifdef __cplusplus |
| 93 |
} |
| 94 |
#endif |
| 95 |
|
| 96 |
#endif |