-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsignal.nelua
252 lines (252 loc) · 9.13 KB
/
signal.nelua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
## cinclude '<signal.h>'
global __sigset_t: type <cimport,nodecl> = @record{
__val: [16]culong
}
global sigset_t: type = @__sigset_t
global timespec: type <cimport,nodecl,ctypedef> = @record{
tv_sec: ctime_t,
tv_nsec: clong
}
global sigval: type <cimport,nodecl,ctypedef> = @union{
sival_int: cint,
sival_ptr: pointer
}
global __sigval_t: type = @sigval
global siginfo_t: type <cimport,nodecl> = @record{
si_signo: cint,
si_errno: cint,
si_code: cint,
__pad0: cint,
_sifields: union{
_pad: [28]cint,
_kill: record{
si_pid: cint,
si_uid: cuint
},
_timer: record{
si_tid: cint,
si_overrun: cint,
si_sigval: __sigval_t
},
_rt: record{
si_pid: cint,
si_uid: cuint,
si_sigval: __sigval_t
},
_sigchld: record{
si_pid: cint,
si_uid: cuint,
si_status: cint,
si_utime: cclock_t,
si_stime: cclock_t
},
_sigfault: record{
si_addr: pointer,
si_addr_lsb: cshort,
_bounds: union{
_addr_bnd: record{
_lower: pointer,
_upper: pointer
},
_pkey: uint32
}
},
_sigpoll: record{
si_band: clong,
si_fd: cint
},
_sigsys: record{
_call_addr: pointer,
_syscall: cint,
_arch: cuint
}
}
}
global SI_ASYNCNL: cint <comptime> = -60
global SI_DETHREAD: cint <comptime> = -7
global SI_TKILL: cint <comptime> = -6
global SI_SIGIO: cint <comptime> = -5
global SI_ASYNCIO: cint <comptime> = -4
global SI_MESGQ: cint <comptime> = -3
global SI_TIMER: cint <comptime> = -2
global SI_QUEUE: cint <comptime> = -1
global SI_USER: cint <comptime> = 0
global SI_KERNEL: cint <comptime> = 128
global ILL_ILLOPC: cint <comptime> = 1
global ILL_ILLOPN: cint <comptime> = 2
global ILL_ILLADR: cint <comptime> = 3
global ILL_ILLTRP: cint <comptime> = 4
global ILL_PRVOPC: cint <comptime> = 5
global ILL_PRVREG: cint <comptime> = 6
global ILL_COPROC: cint <comptime> = 7
global ILL_BADSTK: cint <comptime> = 8
global ILL_BADIADDR: cint <comptime> = 9
global FPE_INTDIV: cint <comptime> = 1
global FPE_INTOVF: cint <comptime> = 2
global FPE_FLTDIV: cint <comptime> = 3
global FPE_FLTOVF: cint <comptime> = 4
global FPE_FLTUND: cint <comptime> = 5
global FPE_FLTRES: cint <comptime> = 6
global FPE_FLTINV: cint <comptime> = 7
global FPE_FLTSUB: cint <comptime> = 8
global FPE_FLTUNK: cint <comptime> = 14
global FPE_CONDTRAP: cint <comptime> = 15
global SEGV_MAPERR: cint <comptime> = 1
global SEGV_ACCERR: cint <comptime> = 2
global SEGV_BNDERR: cint <comptime> = 3
global SEGV_PKUERR: cint <comptime> = 4
global SEGV_ACCADI: cint <comptime> = 5
global SEGV_ADIDERR: cint <comptime> = 6
global SEGV_ADIPERR: cint <comptime> = 7
global SEGV_MTEAERR: cint <comptime> = 8
global SEGV_MTESERR: cint <comptime> = 9
global BUS_ADRALN: cint <comptime> = 1
global BUS_ADRERR: cint <comptime> = 2
global BUS_OBJERR: cint <comptime> = 3
global BUS_MCEERR_AR: cint <comptime> = 4
global BUS_MCEERR_AO: cint <comptime> = 5
global TRAP_BRKPT: cint <comptime> = 1
global TRAP_TRACE: cint <comptime> = 2
global TRAP_BRANCH: cint <comptime> = 3
global TRAP_HWBKPT: cint <comptime> = 4
global TRAP_UNK: cint <comptime> = 5
global CLD_EXITED: cint <comptime> = 1
global CLD_KILLED: cint <comptime> = 2
global CLD_DUMPED: cint <comptime> = 3
global CLD_TRAPPED: cint <comptime> = 4
global CLD_STOPPED: cint <comptime> = 5
global CLD_CONTINUED: cint <comptime> = 6
global POLL_IN: cint <comptime> = 1
global POLL_OUT: cint <comptime> = 2
global POLL_MSG: cint <comptime> = 3
global POLL_ERR: cint <comptime> = 4
global POLL_PRI: cint <comptime> = 5
global POLL_HUP: cint <comptime> = 6
global pthread_attr_t: type <cimport,nodecl,forwarddecl> = @union{}
global sigevent: type <cimport,nodecl,ctypedef> = @record{
sigev_value: __sigval_t,
sigev_signo: cint,
sigev_notify: cint,
_sigev_un: union{
_pad: [12]cint,
_tid: cint,
_sigev_thread: record{
_function: function(__sigval_t): void,
_attribute: *pthread_attr_t
}
}
}
global sigevent_t: type = @sigevent
global SIGEV_SIGNAL: cint <comptime> = 0
global SIGEV_NONE: cint <comptime> = 1
global SIGEV_THREAD: cint <comptime> = 2
global SIGEV_THREAD_ID: cint <comptime> = 4
global __sighandler_t: type <cimport,nodecl> = @function(cint): void
global function signal(sig: cint, handler: __sighandler_t): __sighandler_t <cimport,nodecl> end
global function kill(pid: cint, sig: cint): cint <cimport,nodecl> end
global function killpg(pgrp: cint, sig: cint): cint <cimport,nodecl> end
global function raise(sig: cint): cint <cimport,nodecl> end
global function psignal(sig: cint, s: cstring): void <cimport,nodecl> end
global function psiginfo(pinfo: *siginfo_t, s: cstring): void <cimport,nodecl> end
global function sigpause(sig: cint): cint <cimport,nodecl> end
global function sigemptyset(set: *sigset_t): cint <cimport,nodecl> end
global function sigfillset(set: *sigset_t): cint <cimport,nodecl> end
global function sigaddset(set: *sigset_t, signo: cint): cint <cimport,nodecl> end
global function sigdelset(set: *sigset_t, signo: cint): cint <cimport,nodecl> end
global function sigismember(set: *sigset_t, signo: cint): cint <cimport,nodecl> end
global function sigprocmask(how: cint, set: *sigset_t, oset: *sigset_t): cint <cimport,nodecl> end
global function sigsuspend(set: *sigset_t): cint <cimport,nodecl> end
global function sigpending(set: *sigset_t): cint <cimport,nodecl> end
global function sigwait(set: *sigset_t, sig: *cint): cint <cimport,nodecl> end
global function sigwaitinfo(set: *sigset_t, info: *siginfo_t): cint <cimport,nodecl> end
global function sigtimedwait(set: *sigset_t, info: *siginfo_t, timeout: *timespec): cint <cimport,nodecl> end
global function sigqueue(pid: cint, sig: cint, val: sigval): cint <cimport,nodecl> end
global stack_t: type <cimport,nodecl> = @record{
ss_sp: pointer,
ss_flags: cint,
ss_size: csize
}
global mcontext_t: type <cimport,nodecl,cincomplete> = @record{}
global ucontext_t: type <cimport,nodecl,forwarddecl,cincomplete> = @record{}
ucontext_t = @record{
__uc_flags: culong,
uc_link: *ucontext_t,
uc_stack: stack_t,
uc_mcontext: mcontext_t,
uc_sigmask: sigset_t,
__ssp: [4]culonglong
}
global function siginterrupt(sig: cint, interrupt: cint): cint <cimport,nodecl> end
global SS_ONSTACK: cint <comptime> = 1
global SS_DISABLE: cint <comptime> = 2
global function sigaltstack(ss: *stack_t, oss: *stack_t): cint <cimport,nodecl> end
global function sighold(sig: cint): cint <cimport,nodecl> end
global function sigrelse(sig: cint): cint <cimport,nodecl> end
global function sigignore(sig: cint): cint <cimport,nodecl> end
global function sigset(sig: cint, disp: __sighandler_t): __sighandler_t <cimport,nodecl> end
pthread_attr_t = @union{
__size: [56]cchar,
__align: clong
}
global SIGINT: cint <comptime> = 2
global SIGILL: cint <comptime> = 4
global SIGABRT: cint <comptime> = 6
global SIGFPE: cint <comptime> = 8
global SIGSEGV: cint <comptime> = 11
global SIGTERM: cint <comptime> = 15
global SIGHUP: cint <comptime> = 1
global SIGQUIT: cint <comptime> = 3
global SIGTRAP: cint <comptime> = 5
global SIGKILL: cint <comptime> = 9
global SIGPIPE: cint <comptime> = 13
global SIGALRM: cint <comptime> = 14
global SIGIO: cint <cimport,nodecl,const>
global SIGIOT: cint <comptime> = SIGABRT
global SIGCLD: cint <cimport,nodecl,const>
global SIGSTKFLT: cint <comptime> = 16
global SIGPWR: cint <comptime> = 30
global SIGBUS: cint <comptime> = 7
global SIGSYS: cint <comptime> = 31
global SIGURG: cint <comptime> = 23
global SIGSTOP: cint <comptime> = 19
global SIGTSTP: cint <comptime> = 20
global SIGCONT: cint <comptime> = 18
global SIGCHLD: cint <comptime> = 17
global SIGTTIN: cint <comptime> = 21
global SIGTTOU: cint <comptime> = 22
global SIGPOLL: cint <comptime> = 29
global SIGXFSZ: cint <comptime> = 25
global SIGXCPU: cint <comptime> = 24
global SIGVTALRM: cint <comptime> = 26
global SIGPROF: cint <comptime> = 27
global SIGUSR1: cint <comptime> = 10
global SIGUSR2: cint <comptime> = 12
global SIGWINCH: cint <comptime> = 28
global SIGIO: cint <comptime> = SIGPOLL
global SIGIOT: cint <comptime> = SIGABRT
global SIGCLD: cint <comptime> = SIGCHLD
global SA_NOCLDSTOP: cuint <comptime> = 1
global SA_NOCLDWAIT: cuint <comptime> = 2
global SA_SIGINFO: cuint <comptime> = 4
global SA_ONSTACK: cuint <comptime> = 0x08000000
global SA_RESTART: cuint <comptime> = 0x10000000
global SA_NODEFER: cuint <comptime> = 0x40000000
global SA_RESETHAND: cuint <comptime> = 0x80000000
global SA_INTERRUPT: cuint <comptime> = 0x20000000
global SA_NOMASK: cuint <comptime> = SA_NODEFER
global SA_ONESHOT: cuint <comptime> = SA_RESETHAND
global SA_STACK: cuint <comptime> = SA_ONSTACK
global SIGSTKSZ: cint <comptime> = 8192
global SIGRTMIN: cint <cimport,nodecl,const>
global SIGRTMAX: cint <cimport,nodecl,const>
global sigaction_t: type <nodecl, cimport, ctypedef 'sigaction', cincomplete> = @record{
sa_handler: function(cint),
sa_sigaction: function(cint, *siginfo_t, pointer),
sa_mask: sigset_t,
sa_flags: cint,
sa_restorer: function()
}
global function sigaction(sig: cint, act: *sigaction_t, oact: *sigaction_t): cint <cimport, nodecl> end
global SIG_ERR: function(cint) <cimport, nodecl>
global SIG_DFL: function(cint) <cimport, nodecl>
global SIG_IGN: function(cint) <cimport, nodecl>