mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00

No longer export these 43 internal C API functions: * _PyDict_CheckConsistency() * _PyErr_ChainStackItem() * _PyErr_CheckSignals() * _PyErr_CheckSignalsTstate() * _PyErr_Clear() * _PyErr_ExceptionMatches() * _PyErr_Fetch() * _PyErr_Format() * _PyErr_FormatFromCauseTstate() * _PyErr_GetExcInfo() * _PyErr_GetHandledException() * _PyErr_GetTopmostException() * _PyErr_NoMemory() * _PyErr_NormalizeException() * _PyErr_Restore() * _PyErr_SetHandledException() * _PyErr_SetNone() * _PyErr_SetObject() * _PyErr_SetString() * _PyErr_StackItemToExcInfoTuple() * _PyExc_CreateExceptionGroup() * _PyExc_PrepReraiseStar() * _PyException_AddNote() * _PyInterpreterState_Enable() * _PyLong_FormatAdvancedWriter() * _PyLong_FormatBytesWriter() * _PyLong_FormatWriter() * _PyMem_GetAllocatorName() * _PyMem_SetDefaultAllocator() * _PyMem_SetupAllocators() * _PyOS_InterruptOccurred() * _PyRuntimeState_Fini() * _PyRuntimeState_Init() * _PyRuntime_Finalize() * _PyRuntime_Initialize() * _PyThreadState_Bind() * _PyThreadState_DeleteExcept() * _PyThreadState_New() * _PyThreadState_Swap() * _PyType_CheckConsistency() * _PyUnicodeTranslateError_Create() * _Py_DumpExtensionModules() * _Py_FatalErrorFormat()
101 lines
2.7 KiB
C
101 lines
2.7 KiB
C
// Define Py_NSIG constant for signal handling.
|
|
|
|
#ifndef Py_INTERNAL_SIGNAL_H
|
|
#define Py_INTERNAL_SIGNAL_H
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef Py_BUILD_CORE
|
|
# error "this header requires Py_BUILD_CORE define"
|
|
#endif
|
|
|
|
#include "pycore_atomic.h" // _Py_atomic_address
|
|
#include <signal.h> // NSIG
|
|
|
|
|
|
// Restore signals that the interpreter has called SIG_IGN on to SIG_DFL.
|
|
// Export for '_posixsubprocess' shared extension.
|
|
PyAPI_FUNC(void) _Py_RestoreSignals(void);
|
|
|
|
#ifdef _SIG_MAXSIG
|
|
// gh-91145: On FreeBSD, <signal.h> defines NSIG as 32: it doesn't include
|
|
// realtime signals: [SIGRTMIN,SIGRTMAX]. Use _SIG_MAXSIG instead. For
|
|
// example on x86-64 FreeBSD 13, SIGRTMAX is 126 and _SIG_MAXSIG is 128.
|
|
# define Py_NSIG _SIG_MAXSIG
|
|
#elif defined(NSIG)
|
|
# define Py_NSIG NSIG
|
|
#elif defined(_NSIG)
|
|
# define Py_NSIG _NSIG // BSD/SysV
|
|
#elif defined(_SIGMAX)
|
|
# define Py_NSIG (_SIGMAX + 1) // QNX
|
|
#elif defined(SIGMAX)
|
|
# define Py_NSIG (SIGMAX + 1) // djgpp
|
|
#else
|
|
# define Py_NSIG 64 // Use a reasonable default value
|
|
#endif
|
|
|
|
#define INVALID_FD (-1)
|
|
|
|
struct _signals_runtime_state {
|
|
volatile struct {
|
|
_Py_atomic_int tripped;
|
|
/* func is atomic to ensure that PyErr_SetInterrupt is async-signal-safe
|
|
* (even though it would probably be otherwise, anyway).
|
|
*/
|
|
_Py_atomic_address func;
|
|
} handlers[Py_NSIG];
|
|
|
|
volatile struct {
|
|
#ifdef MS_WINDOWS
|
|
/* This would be "SOCKET fd" if <winsock2.h> were always included.
|
|
It isn't so we must cast to SOCKET where appropriate. */
|
|
volatile int fd;
|
|
#elif defined(__VXWORKS__)
|
|
int fd;
|
|
#else
|
|
sig_atomic_t fd;
|
|
#endif
|
|
|
|
int warn_on_full_buffer;
|
|
#ifdef MS_WINDOWS
|
|
int use_send;
|
|
#endif
|
|
} wakeup;
|
|
|
|
/* Speed up sigcheck() when none tripped */
|
|
_Py_atomic_int is_tripped;
|
|
|
|
/* These objects necessarily belong to the main interpreter. */
|
|
PyObject *default_handler;
|
|
PyObject *ignore_handler;
|
|
|
|
#ifdef MS_WINDOWS
|
|
/* This would be "HANDLE sigint_event" if <windows.h> were always included.
|
|
It isn't so we must cast to HANDLE everywhere "sigint_event" is used. */
|
|
void *sigint_event;
|
|
#endif
|
|
|
|
/* True if the main interpreter thread exited due to an unhandled
|
|
* KeyboardInterrupt exception, suggesting the user pressed ^C. */
|
|
int unhandled_keyboard_interrupt;
|
|
};
|
|
|
|
#ifdef MS_WINDOWS
|
|
# define _signals_WAKEUP_INIT \
|
|
{.fd = INVALID_FD, .warn_on_full_buffer = 1, .use_send = 0}
|
|
#else
|
|
# define _signals_WAKEUP_INIT \
|
|
{.fd = INVALID_FD, .warn_on_full_buffer = 1}
|
|
#endif
|
|
|
|
#define _signals_RUNTIME_INIT \
|
|
{ \
|
|
.wakeup = _signals_WAKEUP_INIT, \
|
|
}
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif // !Py_INTERNAL_SIGNAL_H
|