Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:46

0001 #ifndef Py_INTERNAL_PYTHREAD_H
0002 #define Py_INTERNAL_PYTHREAD_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006 
0007 #ifndef Py_BUILD_CORE
0008 #  error "this header requires Py_BUILD_CORE define"
0009 #endif
0010 
0011 
0012 #ifndef _POSIX_THREADS
0013 /* This means pthreads are not implemented in libc headers, hence the macro
0014    not present in unistd.h. But they still can be implemented as an external
0015    library (e.g. gnu pth in pthread emulation) */
0016 # ifdef HAVE_PTHREAD_H
0017 #  include <pthread.h> /* _POSIX_THREADS */
0018 # endif
0019 # ifndef _POSIX_THREADS
0020 /* Check if we're running on HP-UX and _SC_THREADS is defined. If so, then
0021    enough of the Posix threads package is implemented to support python
0022    threads.
0023 
0024    This is valid for HP-UX 11.23 running on an ia64 system. If needed, add
0025    a check of __ia64 to verify that we're running on an ia64 system instead
0026    of a pa-risc system.
0027 */
0028 #  ifdef __hpux
0029 #   ifdef _SC_THREADS
0030 #    define _POSIX_THREADS
0031 #   endif
0032 #  endif
0033 # endif /* _POSIX_THREADS */
0034 #endif /* _POSIX_THREADS */
0035 
0036 #if defined(_POSIX_THREADS) || defined(HAVE_PTHREAD_STUBS)
0037 # define _USE_PTHREADS
0038 #endif
0039 
0040 #if defined(_USE_PTHREADS) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
0041 // monotonic is supported statically.  It doesn't mean it works on runtime.
0042 # define CONDATTR_MONOTONIC
0043 #endif
0044 
0045 
0046 #if defined(HAVE_PTHREAD_STUBS)
0047 // pthread_key
0048 struct py_stub_tls_entry {
0049     bool in_use;
0050     void *value;
0051 };
0052 #endif
0053 
0054 struct _pythread_runtime_state {
0055     int initialized;
0056 
0057 #ifdef _USE_PTHREADS
0058     // This matches when thread_pthread.h is used.
0059     struct {
0060         /* NULL when pthread_condattr_setclock(CLOCK_MONOTONIC) is not supported. */
0061         pthread_condattr_t *ptr;
0062 # ifdef CONDATTR_MONOTONIC
0063     /* The value to which condattr_monotonic is set. */
0064         pthread_condattr_t val;
0065 # endif
0066     } _condattr_monotonic;
0067 
0068 #endif  // USE_PTHREADS
0069 
0070 #if defined(HAVE_PTHREAD_STUBS)
0071     struct {
0072         struct py_stub_tls_entry tls_entries[PTHREAD_KEYS_MAX];
0073     } stubs;
0074 #endif
0075 };
0076 
0077 
0078 #ifdef __cplusplus
0079 }
0080 #endif
0081 #endif /* !Py_INTERNAL_PYTHREAD_H */