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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
pub type sig_atomic_t = ::int_t;

#[repr(C)]
#[derive(Copy)]
pub struct sigset_t {
    _data: [::ulong_t; 16usize],
}

new!(sigset_t);

#[repr(C)]
#[derive(Copy)]
pub struct sigevent {
    pub sigev_value: sigval,
    pub sigev_signo: ::int_t,
    pub sigev_notify: ::int_t,
    pub sigev_notify_function: ::std::option::Option<extern fn(arg1: sigval)>,
    pub sigev_notify_attribute: *mut ::sys::types::pthread_attr_t,
    _pad: [u64; 4usize],
}

new!(sigevent);

#[repr(C)]
#[derive(Copy)]
pub struct sigval {
    _data: [u64; 1usize],
}

new!(sigval);

impl sigval {
    pub fn sival_int(&self) -> &::int_t {
        unsafe { ::std::mem::transmute(self) }
    }

    pub fn sival_ptr(&self) -> &*mut ::void_t {
        unsafe { ::std::mem::transmute(self) }
    }

    pub fn sival_int_mut(&mut self) -> &mut ::int_t {
        unsafe { ::std::mem::transmute(self) }
    }

    pub fn sival_ptr_mut(&mut self) -> &mut *mut ::void_t {
        unsafe { ::std::mem::transmute(self) }
    }
}

#[repr(C)]
#[derive(Copy)]
pub struct sigaction {
    hlr: [u64; 1usize],
    pub sa_mask: sigset_t,
    pub sa_flags: ::int_t,
    pub sa_restorer: ::std::option::Option<extern fn()>,
}

new!(sigaction);

impl sigaction {
    pub fn sa_handler(&self) -> &::std::option::Option<extern fn(arg1: ::int_t)> {
        unsafe { ::std::mem::transmute(&self.hlr) }
    }

    pub fn sa_sigaction(&self) ->
            &::std::option::Option<extern fn(arg1: ::int_t, arg2: *mut siginfo_t, arg3: *mut ::void_t)> {
        unsafe { ::std::mem::transmute(&self.hlr) }
    }

    pub fn sa_handler_mut(&mut self) ->
            &mut ::std::option::Option<extern fn(arg1: ::int_t)> {
        unsafe { ::std::mem::transmute(&self.hlr) }
    }

    pub fn sa_sigaction_mut(&mut self) ->
            &mut ::std::option::Option<extern fn (arg1: ::int_t, arg2: *mut siginfo_t, arg3: *mut ::void_t)> {
        unsafe { ::std::mem::transmute(&self.hlr) }
    }
}

#[repr(C)]
#[derive(Copy)]
pub struct mcontext_t {
    _data: [u64; 32],
}

new!(mcontext_t);

#[repr(C)]
#[derive(Copy)]
pub struct ucontext {
    pub uc_flags: ::ulong_t,
    pub uc_link: *mut ucontext,
    pub uc_stack: stack_t,
    pub uc_mcontext: mcontext_t,
    pub uc_sigmask: sigset_t,
    _data: [u64; 64],
}

new!(ucontext);

#[repr(C)]
#[derive(Copy)]
pub struct stack_t {
    pub ss_sp: *mut ::void_t,
    pub ss_flags: ::int_t,
    pub ss_size: ::size_t,
}

new!(stack_t);

#[repr(C)]
#[derive(Copy)]
pub struct siginfo_t {
    pub si_signo: ::int_t,
    pub si_errno: ::int_t,
    pub si_code: ::int_t,
    _data: [u64; 14usize],
}

new!(siginfo_t);

impl siginfo_t {
    pub fn si_pid(&self) -> &::sys::types::pid_t {
        let tmp: &_rt = unsafe { ::std::mem::transmute(&self._data) };
        &tmp.si_pid
    }

    pub fn si_pid_mut(&mut self) -> &mut ::sys::types::pid_t {
        let tmp: &mut _rt = unsafe { ::std::mem::transmute(&self._data) };
        &mut tmp.si_pid
    }

    pub fn si_uid(&self) -> &::sys::types::uid_t {
        let tmp: &_rt = unsafe { ::std::mem::transmute(&self._data) };
        &tmp.si_uid
    }

    pub fn si_uid_mut(&mut self) -> &mut ::sys::types::uid_t {
        let tmp: &mut _rt = unsafe { ::std::mem::transmute(&self._data) };
        &mut tmp.si_uid
    }

    pub fn si_addr(&self) -> &*mut ::void_t {
        let tmp: &_sigfault = unsafe { ::std::mem::transmute(&self._data) };
        &tmp.si_addr
    }

    pub fn si_addr_mut(&mut self) -> &mut *mut ::void_t {
        let tmp: &mut _sigfault = unsafe { ::std::mem::transmute(&self._data) };
        &mut tmp.si_addr
    }

    pub fn si_status(&self) -> &::int_t {
        let tmp: &_sigchld = unsafe { ::std::mem::transmute(&self._data) };
        &tmp.si_status
    }

    pub fn si_status_mut(&mut self) -> &mut ::int_t {
        let tmp: &mut _sigchld = unsafe { ::std::mem::transmute(&self._data) };
        &mut tmp.si_status
    }

    pub fn si_band(&self) -> &::long_t {
        let tmp: &_sigpoll = unsafe { ::std::mem::transmute(&self._data) };
        &tmp.si_band
    }

    pub fn si_band_mut(&mut self) -> &mut ::long_t {
        let tmp: &mut _sigpoll = unsafe { ::std::mem::transmute(&self._data) };
        &mut tmp.si_band
    }

    pub fn si_value(&self) -> &sigval {
        let tmp: &_rt = unsafe { ::std::mem::transmute(&self._data) };
        &tmp.si_sigval
    }

    pub fn si_value_mut(&mut self) -> &mut sigval {
        let tmp: &mut _rt = unsafe { ::std::mem::transmute(&self._data) };
        &mut tmp.si_sigval
    }
}

#[repr(C)]
#[derive(Copy)]
struct _rt {
    si_pid: ::sys::types::pid_t,
    si_uid: ::sys::types::uid_t,
    si_sigval: sigval,
}

#[repr(C)]
#[derive(Copy)]
struct _sigchld {
    si_pid: ::sys::types::pid_t,
    si_uid: ::sys::types::uid_t,
    si_status: ::int_t,
}

#[repr(C)]
#[derive(Copy)]
struct _sigfault {
    si_addr: *mut ::void_t,
    si_addr_lsb: ::short_t,
}

#[repr(C)]
#[derive(Copy)]
struct _sigpoll {
    si_band: ::long_t,
}

pub fn SIG_DFL() -> extern fn(::int_t) {
    unsafe { ::std::mem::transmute::<usize,_>(0) }
}

pub fn SIG_ERR() -> extern fn(::int_t) {
    unsafe { ::std::mem::transmute::<usize,_>(-1) }
}

pub fn SIG_IGN() -> extern fn(::int_t) {
    unsafe { ::std::mem::transmute::<usize,_>(1) }
}

pub const SIGEV_NONE:    ::int_t = 1;
pub const SIGEV_SIGNAL:  ::int_t = 0;
pub const SIGEV_THREAD:  ::int_t = 2;
pub const SIGABRT:       ::int_t = 6;
pub const SIGALRM:       ::int_t = 14;
pub const SIGBUS:        ::int_t = 7;
pub const SIGCHLD:       ::int_t = 17;
pub const SIGCONT:       ::int_t = 18;
pub const SIGFPE:        ::int_t = 8;
pub const SIGHUP:        ::int_t = 1;
pub const SIGILL:        ::int_t = 4;
pub const SIGINT:        ::int_t = 2;
pub const SIGKILL:       ::int_t = 9;
pub const SIGPIPE:       ::int_t = 13;
pub const SIGQUIT:       ::int_t = 3;
pub const SIGSEGV:       ::int_t = 11;
pub const SIGSTOP:       ::int_t = 19;
pub const SIGTERM:       ::int_t = 15;
pub const SIGTSTP:       ::int_t = 20;
pub const SIGTTIN:       ::int_t = 21;
pub const SIGTTOU:       ::int_t = 22;
pub const SIGUSR1:       ::int_t = 10;
pub const SIGUSR2:       ::int_t = 12;
pub const SIGPOLL:       ::int_t = 29;
pub const SIGPROF:       ::int_t = 27;
pub const SIGSYS:        ::int_t = 31;
pub const SIGTRAP:       ::int_t = 5;
pub const SIGURG:        ::int_t = 23;
pub const SIGVTALRM:     ::int_t = 26;
pub const SIGXCPU:       ::int_t = 24;
pub const SIGXFSZ:       ::int_t = 25;
pub const SIG_BLOCK:     ::int_t = 0;
pub const SIG_UNBLOCK:   ::int_t = 1;
pub const SIG_SETMASK:   ::int_t = 2;
pub const SA_NOCLDSTOP:  ::int_t = 1;
pub const SA_ONSTACK:    ::int_t = 134217728;
pub const SA_RESETHAND:  ::int_t = -2147483648;
pub const SA_RESTART:    ::int_t = 268435456;
pub const SA_SIGINFO:    ::int_t = 4;
pub const SA_NOCLDWAIT:  ::int_t = 2;
pub const SA_NODEFER:    ::int_t = 1073741824;
pub const SS_ONSTACK:    ::int_t = 1;
pub const SS_DISABLE:    ::int_t = 2;
pub const MINSIGSTKSZ:   ::int_t = 2048;
pub const SIGSTKSZ:      ::int_t = 8192;
pub const ILL_ILLOPC:    ::int_t = 1;
pub const ILL_ILLOPN:    ::int_t = 2;
pub const ILL_ILLADR:    ::int_t = 3;
pub const ILL_ILLTRP:    ::int_t = 4;
pub const ILL_PRVOPC:    ::int_t = 5;
pub const ILL_PRVREG:    ::int_t = 6;
pub const ILL_COPROC:    ::int_t = 7;
pub const ILL_BADSTK:    ::int_t = 8;
pub const FPE_INTDIV:    ::int_t = 1;
pub const FPE_INTOVF:    ::int_t = 2;
pub const FPE_FLTDIV:    ::int_t = 3;
pub const FPE_FLTOVF:    ::int_t = 4;
pub const FPE_FLTUND:    ::int_t = 5;
pub const FPE_FLTRES:    ::int_t = 6;
pub const FPE_FLTINV:    ::int_t = 7;
pub const FPE_FLTSUB:    ::int_t = 8;
pub const SEGV_MAPERR:   ::int_t = 1;
pub const SEGV_ACCERR:   ::int_t = 2;
pub const BUS_ADRALN:    ::int_t = 1;
pub const BUS_ADRERR:    ::int_t = 2;
pub const BUS_OBJERR:    ::int_t = 3;
pub const TRAP_BRKPT:    ::int_t = 1;
pub const TRAP_TRACE:    ::int_t = 2;
pub const CLD_EXITED:    ::int_t = 1;
pub const CLD_KILLED:    ::int_t = 2;
pub const CLD_DUMPED:    ::int_t = 3;
pub const CLD_TRAPPED:   ::int_t = 4;
pub const CLD_STOPPED:   ::int_t = 5;
pub const CLD_CONTINUED: ::int_t = 6;
pub const POLL_IN:       ::int_t = 1;
pub const POLL_OUT:      ::int_t = 2;
pub const POLL_MSG:      ::int_t = 3;
pub const POLL_ERR:      ::int_t = 4;
pub const POLL_PRI:      ::int_t = 5;
pub const POLL_HUP:      ::int_t = 6;
pub const SI_USER:       ::int_t = 0;
pub const SI_QUEUE:      ::int_t = -1;
pub const SI_TIMER:      ::int_t = -2;
pub const SI_ASYNCIO:    ::int_t = -4;
pub const SI_MESGQ:      ::int_t = -3;