File indexing completed on 2025-01-18 10:06:47
0001
0002
0003 #ifndef Py_INTERNAL_SIGNAL_H
0004 #define Py_INTERNAL_SIGNAL_H
0005 #ifdef __cplusplus
0006 extern "C" {
0007 #endif
0008
0009 #ifndef Py_BUILD_CORE
0010 # error "this header requires Py_BUILD_CORE define"
0011 #endif
0012
0013 #include "pycore_atomic.h" // _Py_atomic_address
0014
0015 #include <signal.h> // NSIG
0016
0017
0018 #ifdef _SIG_MAXSIG
0019
0020
0021
0022 # define Py_NSIG _SIG_MAXSIG
0023 #elif defined(NSIG)
0024 # define Py_NSIG NSIG
0025 #elif defined(_NSIG)
0026 # define Py_NSIG _NSIG
0027 #elif defined(_SIGMAX)
0028 # define Py_NSIG (_SIGMAX + 1)
0029 #elif defined(SIGMAX)
0030 # define Py_NSIG (SIGMAX + 1)
0031 #else
0032 # define Py_NSIG 64
0033 #endif
0034
0035 #define INVALID_FD (-1)
0036
0037 struct _signals_runtime_state {
0038 volatile struct {
0039 _Py_atomic_int tripped;
0040
0041
0042
0043 _Py_atomic_address func;
0044 } handlers[Py_NSIG];
0045
0046 volatile struct {
0047 #ifdef MS_WINDOWS
0048
0049
0050 volatile int fd;
0051 #elif defined(__VXWORKS__)
0052 int fd;
0053 #else
0054 sig_atomic_t fd;
0055 #endif
0056
0057 int warn_on_full_buffer;
0058 #ifdef MS_WINDOWS
0059 int use_send;
0060 #endif
0061 } wakeup;
0062
0063
0064 _Py_atomic_int is_tripped;
0065
0066
0067 PyObject *default_handler;
0068 PyObject *ignore_handler;
0069
0070 #ifdef MS_WINDOWS
0071
0072
0073 void *sigint_event;
0074 #endif
0075
0076
0077
0078 int unhandled_keyboard_interrupt;
0079 };
0080
0081 #ifdef MS_WINDOWS
0082 # define _signals_WAKEUP_INIT \
0083 {.fd = INVALID_FD, .warn_on_full_buffer = 1, .use_send = 0}
0084 #else
0085 # define _signals_WAKEUP_INIT \
0086 {.fd = INVALID_FD, .warn_on_full_buffer = 1}
0087 #endif
0088
0089 #define _signals_RUNTIME_INIT \
0090 { \
0091 .wakeup = _signals_WAKEUP_INIT, \
0092 }
0093
0094
0095 #ifdef __cplusplus
0096 }
0097 #endif
0098 #endif