Debian Codegraph @

rpython/translator/c/src/signals.h

raw symbols SCIP
1 #ifndef _PYPY_SIGNALS_H
2 #define _PYPY_SIGNALS_H
3
4 #include "src/precommondefs.h"
5
6 #include <limits.h>
7 #ifndef PATH_MAX
8 #define PATH_MAX 4096
9 #endif
10
11 /* utilities to set a signal handler */
12 RPY_EXTERN
13 void pypysig_ignore(int signum); /* signal will be ignored (SIG_IGN) */
14 RPY_EXTERN
15 void pypysig_default(int signum); /* signal will do default action (SIG_DFL) */
16 RPY_EXTERN
17 void pypysig_setflag(int signum); /* signal will set a flag which can be
18 queried with pypysig_poll() */
19 RPY_EXTERN
20 void pypysig_reinstall(int signum);
21 RPY_EXTERN
22 int pypysig_set_wakeup_fd(int fd, int with_nul_byte);
23
24 /* utility to poll for signals that arrived */
25 RPY_EXTERN
26 int pypysig_poll(void); /* => signum or -1 */
27 /* errno from last failed wakeup-fd write (0 if none); clears on read */
28 RPY_EXTERN
29 int pypysig_get_wakeup_fd_write_errno(void);
30 RPY_EXTERN
31 void pypysig_pushback(int signum);
32
33 /* When a signal is received, pypysig_counter is set to -1. */
34 struct pypysig_long_struct_inner {
35 Signed value;
36 };
37
38 struct pypysig_long_struct {
39 struct pypysig_long_struct_inner inner;
40 /* mechanism to start a debugger remotely, via process_vm_writev:
41 * - write a .py path to debugger_script_path
42 * - set debugger_pending_call to 1
43 * - set value to -1
44 * */
45 char cookie[8];
46 Signed debugger_pending_call;
47 char debugger_script_path[PATH_MAX];
48 };
49 RPY_EXPORTED struct pypysig_long_struct pypysig_counter;
50
51 /* some C tricks to get/set the variable as efficiently as possible:
52 use macros when compiling as a stand-alone program, but still
53 export a function with the correct name for testing */
54 RPY_EXTERN
55 void *pypysig_getaddr_occurred(void);
56 #define pypysig_getaddr_occurred() ((void *)(&pypysig_counter))
57
58 /* siginterrupt(2) is deprecated on Linux; use sigaction instead */
59 #ifndef _WIN32
60 RPY_EXTERN
61 int pypysig_siginterrupt(int sig, int flag);
62 #endif
63
64 inline static char pypysig_check_and_reset(void) {
65 /* used by reverse_debugging */
66 char result = --pypysig_counter.inner.value < 0;
67 if (result)
68 pypysig_counter.inner.value = 100;
69 return result;
70 }
71
72 #endif