Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:55

0001 #ifndef Py_PYTHREAD_H
0002 #define Py_PYTHREAD_H
0003 
0004 typedef void *PyThread_type_lock;
0005 
0006 #ifdef __cplusplus
0007 extern "C" {
0008 #endif
0009 
0010 /* Return status codes for Python lock acquisition.  Chosen for maximum
0011  * backwards compatibility, ie failure -> 0, success -> 1.  */
0012 typedef enum PyLockStatus {
0013     PY_LOCK_FAILURE = 0,
0014     PY_LOCK_ACQUIRED = 1,
0015     PY_LOCK_INTR
0016 } PyLockStatus;
0017 
0018 PyAPI_FUNC(void) PyThread_init_thread(void);
0019 PyAPI_FUNC(unsigned long) PyThread_start_new_thread(void (*)(void *), void *);
0020 PyAPI_FUNC(void) _Py_NO_RETURN PyThread_exit_thread(void);
0021 PyAPI_FUNC(unsigned long) PyThread_get_thread_ident(void);
0022 
0023 #if (defined(__APPLE__) || defined(__linux__) || defined(_WIN32) \
0024      || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
0025      || defined(__OpenBSD__) || defined(__NetBSD__) \
0026      || defined(__DragonFly__) || defined(_AIX))
0027 #define PY_HAVE_THREAD_NATIVE_ID
0028 PyAPI_FUNC(unsigned long) PyThread_get_thread_native_id(void);
0029 #endif
0030 
0031 PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
0032 PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock);
0033 PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
0034 #define WAIT_LOCK       1
0035 #define NOWAIT_LOCK     0
0036 
0037 // PY_TIMEOUT_T is the integral type used to specify timeouts when waiting
0038 // on a lock (see PyThread_acquire_lock_timed() below).
0039 #define PY_TIMEOUT_T long long
0040 
0041 
0042 /* If microseconds == 0, the call is non-blocking: it returns immediately
0043    even when the lock can't be acquired.
0044    If microseconds > 0, the call waits up to the specified duration.
0045    If microseconds < 0, the call waits until success (or abnormal failure)
0046 
0047    If *microseconds* is greater than PY_TIMEOUT_MAX, clamp the timeout to
0048    PY_TIMEOUT_MAX microseconds.
0049 
0050    If intr_flag is true and the acquire is interrupted by a signal, then the
0051    call will return PY_LOCK_INTR.  The caller may reattempt to acquire the
0052    lock.
0053 */
0054 PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock,
0055                                                      PY_TIMEOUT_T microseconds,
0056                                                      int intr_flag);
0057 
0058 PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
0059 
0060 PyAPI_FUNC(size_t) PyThread_get_stacksize(void);
0061 PyAPI_FUNC(int) PyThread_set_stacksize(size_t);
0062 
0063 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
0064 PyAPI_FUNC(PyObject*) PyThread_GetInfo(void);
0065 #endif
0066 
0067 
0068 /* Thread Local Storage (TLS) API
0069    TLS API is DEPRECATED.  Use Thread Specific Storage (TSS) API.
0070 
0071    The existing TLS API has used int to represent TLS keys across all
0072    platforms, but it is not POSIX-compliant.  Therefore, the new TSS API uses
0073    opaque data type to represent TSS keys to be compatible (see PEP 539).
0074 */
0075 Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_create_key(void);
0076 Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key(int key);
0077 Py_DEPRECATED(3.7) PyAPI_FUNC(int) PyThread_set_key_value(int key,
0078                                                           void *value);
0079 Py_DEPRECATED(3.7) PyAPI_FUNC(void *) PyThread_get_key_value(int key);
0080 Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_delete_key_value(int key);
0081 
0082 /* Cleanup after a fork */
0083 Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyThread_ReInitTLS(void);
0084 
0085 
0086 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
0087 /* New in 3.7 */
0088 /* Thread Specific Storage (TSS) API */
0089 
0090 typedef struct _Py_tss_t Py_tss_t;  /* opaque */
0091 
0092 PyAPI_FUNC(Py_tss_t *) PyThread_tss_alloc(void);
0093 PyAPI_FUNC(void) PyThread_tss_free(Py_tss_t *key);
0094 
0095 /* The parameter key must not be NULL. */
0096 PyAPI_FUNC(int) PyThread_tss_is_created(Py_tss_t *key);
0097 PyAPI_FUNC(int) PyThread_tss_create(Py_tss_t *key);
0098 PyAPI_FUNC(void) PyThread_tss_delete(Py_tss_t *key);
0099 PyAPI_FUNC(int) PyThread_tss_set(Py_tss_t *key, void *value);
0100 PyAPI_FUNC(void *) PyThread_tss_get(Py_tss_t *key);
0101 #endif  /* New in 3.7 */
0102 
0103 #ifndef Py_LIMITED_API
0104 #  define Py_CPYTHON_PYTHREAD_H
0105 #  include "cpython/pythread.h"
0106 #  undef Py_CPYTHON_PYTHREAD_H
0107 #endif
0108 
0109 #ifdef __cplusplus
0110 }
0111 #endif
0112 #endif /* !Py_PYTHREAD_H */