Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/pythread.h
1 #ifndef Py_PYTHREAD_H 2 #define Py_PYTHREAD_H 3 4 typedef void *PyThread_type_lock; 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 /* Return status codes for Python lock acquisition. Chosen for maximum 11 * backwards compatibility, ie failure -> 0, success -> 1. */ 12 typedef enum PyLockStatus { 13 PY_LOCK_FAILURE = 0, 14 PY_LOCK_ACQUIRED = 1, 15 PY_LOCK_INTR 16 } PyLockStatus; 17 18 PyAPI_FUNC(void) PyThread_init_thread(void); 19 PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *); 20 /* Terminates the current thread. Considered unsafe. 21 * 22 * WARNING: This function is only safe to call if all functions in the full call 23 * stack are written to safely allow it. Additionally, the behavior is 24 * platform-dependent. This function should be avoided, and is no longer called 25 * by Python itself. It is retained only for compatibility with existing C 26 * extension code. 27 * 28 * With pthreads, calls `pthread_exit` causes some libcs (glibc?) to attempt to 29 * unwind the stack and call C++ destructors; if a `noexcept` function is 30 * reached, they may terminate the process. Others (macOS) do unwinding. 31 * 32 * On Windows, calls `_endthreadex` which kills the thread without calling C++ 33 * destructors. 34 * 35 * In either case there is a risk of invalid references remaining to data on the 36 * thread stack. 37 */ 38 Py_DEPRECATED(3.14) PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void); 39 40 PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void); 41 42 #if (defined(__APPLE__) || defined(__linux__) || defined(_WIN32) \ 43 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ 44 || defined(__OpenBSD__) || defined(__NetBSD__) \ 45 || defined(__DragonFly__) || defined(_AIX)) 46 #define PY_HAVE_THREAD_NATIVE_ID 47 PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void); 48 #endif 49 50 PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); 51 PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); 52 PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); 53 #define WAIT_LOCK 1 54 #define NOWAIT_LOCK 0 55 56 // PY_TIMEOUT_T is the integral type used to specify timeouts when waiting 57 // on a lock (see PyThread_acquire_lock_timed() below). 58 #define PY_TIMEOUT_T long long 59 60 61 /* If microseconds == 0, the call is non-blocking: it returns immediately 62 even when the lock can't be acquired. 63 If microseconds > 0, the call waits up to the specified duration. 64 If microseconds < 0, the call waits until success (or abnormal failure) 65 66 If *microseconds* is greater than PY_TIMEOUT_MAX, clamp the timeout to 67 PY_TIMEOUT_MAX microseconds. 68 69 If intr_flag is true and the acquire is interrupted by a signal, then the 70 call will return PY_LOCK_INTR. The caller may reattempt to acquire the 71 lock. 72 */ 73 PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock, 74 PY_TIMEOUT_T microseconds, 75 int intr_flag); 76 77 PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); 78 79 PyAPI_FUNC(size_t) PyThread_get_stacksize(void); 80 PyAPI_FUNC(int) PyThread_set_stacksize(size_t); 81 82 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 83 PyAPI_FUNC(PyObject*) PyThread_GetInfo(void); 84 #endif 85 86 87 /* Thread Local Storage (TLS) API 88 TLS API is DEPRECATED. Use Thread Specific Storage (TSS) API. 89 90 The existing TLS API has used int to represent TLS keys across all 91 platforms, but it is not POSIX-compliant. Therefore, the new TSS API uses 92 opaque data type to represent TSS keys to be compatible (see PEP 539). 93 */ 94 Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_create_key(void); 95 Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key(int key); 96 Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_set_key_value(int key, 97 void *value); 98 Py_DEPRECATED(3.7) PyAPI_FUNC(void *) PyThread_get_key_value(int key); 99 Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key_value(int key); 100 101 /* Cleanup after a fork */ 102 Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_ReInitTLS(void); 103 104 105 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000 106 /* New in 3.7 */ 107 /* Thread Specific Storage (TSS) API */ 108 109 typedef struct _Py_tss_t Py_tss_t; /* opaque */ 110 111 PyAPI_FUNC(Py_tss_t *) PyThread_tss_alloc(void); 112 PyAPI_FUNC(void) PyThread_tss_free(Py_tss_t *key); 113 114 /* The parameter key must not be NULL. */ 115 PyAPI_FUNC(int) PyThread_tss_is_created(Py_tss_t *key); 116 PyAPI_FUNC(int) PyThread_tss_create(Py_tss_t *key); 117 PyAPI_FUNC(void) PyThread_tss_delete(Py_tss_t *key); 118 PyAPI_FUNC(int) PyThread_tss_set(Py_tss_t *key, void *value); 119 PyAPI_FUNC(void *) PyThread_tss_get(Py_tss_t *key); 120 #endif /* New in 3.7 */ 121 122 #ifndef Py_LIMITED_API 123 # define Py_CPYTHON_PYTHREAD_H 124 # include "cpython/pythread.h" 125 # undef Py_CPYTHON_PYTHREAD_H 126 #endif 127 128 #ifdef __cplusplus 129 } 130 #endif 131 #endif /* !Py_PYTHREAD_H */