libc/unix/linux_like/linux/gnu/b64/x86_64/
mod.rs

1//! x86_64-specific definitions for 64-bit linux-like values
2
3use crate::prelude::*;
4use crate::{off64_t, off_t};
5
6pub type c_char = i8;
7pub type wchar_t = i32;
8pub type nlink_t = u64;
9pub type blksize_t = i64;
10pub type greg_t = i64;
11pub type suseconds_t = i64;
12pub type __u64 = c_ulonglong;
13pub type __s64 = c_longlong;
14
15s! {
16    pub struct sigaction {
17        pub sa_sigaction: crate::sighandler_t,
18        pub sa_mask: crate::sigset_t,
19        #[cfg(target_arch = "sparc64")]
20        __reserved0: c_int,
21        pub sa_flags: c_int,
22        pub sa_restorer: Option<extern "C" fn()>,
23    }
24
25    pub struct statfs {
26        pub f_type: crate::__fsword_t,
27        pub f_bsize: crate::__fsword_t,
28        pub f_blocks: crate::fsblkcnt_t,
29        pub f_bfree: crate::fsblkcnt_t,
30        pub f_bavail: crate::fsblkcnt_t,
31
32        pub f_files: crate::fsfilcnt_t,
33        pub f_ffree: crate::fsfilcnt_t,
34        pub f_fsid: crate::fsid_t,
35
36        pub f_namelen: crate::__fsword_t,
37        pub f_frsize: crate::__fsword_t,
38        f_spare: [crate::__fsword_t; 5],
39    }
40
41    pub struct flock {
42        pub l_type: c_short,
43        pub l_whence: c_short,
44        pub l_start: off_t,
45        pub l_len: off_t,
46        pub l_pid: crate::pid_t,
47    }
48
49    pub struct flock64 {
50        pub l_type: c_short,
51        pub l_whence: c_short,
52        pub l_start: off64_t,
53        pub l_len: off64_t,
54        pub l_pid: crate::pid_t,
55    }
56
57    pub struct siginfo_t {
58        pub si_signo: c_int,
59        pub si_errno: c_int,
60        pub si_code: c_int,
61        #[doc(hidden)]
62        #[deprecated(
63            since = "0.2.54",
64            note = "Please leave a comment on \
65                  https://github.com/rust-lang/libc/pull/1316 if you're using \
66                  this field"
67        )]
68        pub _pad: [c_int; 29],
69        _align: [u64; 0],
70    }
71
72    pub struct stack_t {
73        pub ss_sp: *mut c_void,
74        pub ss_flags: c_int,
75        pub ss_size: size_t,
76    }
77
78    pub struct stat {
79        pub st_dev: crate::dev_t,
80        pub st_ino: crate::ino_t,
81        pub st_nlink: crate::nlink_t,
82        pub st_mode: crate::mode_t,
83        pub st_uid: crate::uid_t,
84        pub st_gid: crate::gid_t,
85        __pad0: c_int,
86        pub st_rdev: crate::dev_t,
87        pub st_size: off_t,
88        pub st_blksize: crate::blksize_t,
89        pub st_blocks: crate::blkcnt_t,
90        pub st_atime: crate::time_t,
91        pub st_atime_nsec: i64,
92        pub st_mtime: crate::time_t,
93        pub st_mtime_nsec: i64,
94        pub st_ctime: crate::time_t,
95        pub st_ctime_nsec: i64,
96        __unused: [i64; 3],
97    }
98
99    pub struct stat64 {
100        pub st_dev: crate::dev_t,
101        pub st_ino: crate::ino64_t,
102        pub st_nlink: crate::nlink_t,
103        pub st_mode: crate::mode_t,
104        pub st_uid: crate::uid_t,
105        pub st_gid: crate::gid_t,
106        __pad0: c_int,
107        pub st_rdev: crate::dev_t,
108        pub st_size: off_t,
109        pub st_blksize: crate::blksize_t,
110        pub st_blocks: crate::blkcnt64_t,
111        pub st_atime: crate::time_t,
112        pub st_atime_nsec: i64,
113        pub st_mtime: crate::time_t,
114        pub st_mtime_nsec: i64,
115        pub st_ctime: crate::time_t,
116        pub st_ctime_nsec: i64,
117        __reserved: [i64; 3],
118    }
119
120    pub struct statfs64 {
121        pub f_type: crate::__fsword_t,
122        pub f_bsize: crate::__fsword_t,
123        pub f_blocks: u64,
124        pub f_bfree: u64,
125        pub f_bavail: u64,
126        pub f_files: u64,
127        pub f_ffree: u64,
128        pub f_fsid: crate::fsid_t,
129        pub f_namelen: crate::__fsword_t,
130        pub f_frsize: crate::__fsword_t,
131        pub f_flags: crate::__fsword_t,
132        pub f_spare: [crate::__fsword_t; 4],
133    }
134
135    pub struct statvfs64 {
136        pub f_bsize: c_ulong,
137        pub f_frsize: c_ulong,
138        pub f_blocks: u64,
139        pub f_bfree: u64,
140        pub f_bavail: u64,
141        pub f_files: u64,
142        pub f_ffree: u64,
143        pub f_favail: u64,
144        pub f_fsid: c_ulong,
145        pub f_flag: c_ulong,
146        pub f_namemax: c_ulong,
147        __f_spare: [c_int; 6],
148    }
149
150    pub struct pthread_attr_t {
151        #[cfg(target_pointer_width = "32")]
152        __size: [u32; 8],
153        #[cfg(target_pointer_width = "64")]
154        __size: [u64; 7],
155    }
156
157    pub struct _libc_fpxreg {
158        pub significand: [u16; 4],
159        pub exponent: u16,
160        __private: [u16; 3],
161    }
162
163    pub struct _libc_xmmreg {
164        pub element: [u32; 4],
165    }
166
167    pub struct _libc_fpstate {
168        pub cwd: u16,
169        pub swd: u16,
170        pub ftw: u16,
171        pub fop: u16,
172        pub rip: u64,
173        pub rdp: u64,
174        pub mxcsr: u32,
175        pub mxcr_mask: u32,
176        pub _st: [_libc_fpxreg; 8],
177        pub _xmm: [_libc_xmmreg; 16],
178        __private: [u64; 12],
179    }
180
181    pub struct user_regs_struct {
182        pub r15: c_ulonglong,
183        pub r14: c_ulonglong,
184        pub r13: c_ulonglong,
185        pub r12: c_ulonglong,
186        pub rbp: c_ulonglong,
187        pub rbx: c_ulonglong,
188        pub r11: c_ulonglong,
189        pub r10: c_ulonglong,
190        pub r9: c_ulonglong,
191        pub r8: c_ulonglong,
192        pub rax: c_ulonglong,
193        pub rcx: c_ulonglong,
194        pub rdx: c_ulonglong,
195        pub rsi: c_ulonglong,
196        pub rdi: c_ulonglong,
197        pub orig_rax: c_ulonglong,
198        pub rip: c_ulonglong,
199        pub cs: c_ulonglong,
200        pub eflags: c_ulonglong,
201        pub rsp: c_ulonglong,
202        pub ss: c_ulonglong,
203        pub fs_base: c_ulonglong,
204        pub gs_base: c_ulonglong,
205        pub ds: c_ulonglong,
206        pub es: c_ulonglong,
207        pub fs: c_ulonglong,
208        pub gs: c_ulonglong,
209    }
210
211    pub struct user {
212        pub regs: user_regs_struct,
213        pub u_fpvalid: c_int,
214        pub i387: user_fpregs_struct,
215        pub u_tsize: c_ulonglong,
216        pub u_dsize: c_ulonglong,
217        pub u_ssize: c_ulonglong,
218        pub start_code: c_ulonglong,
219        pub start_stack: c_ulonglong,
220        pub signal: c_longlong,
221        __reserved: c_int,
222        #[cfg(target_pointer_width = "32")]
223        __pad1: u32,
224        pub u_ar0: *mut user_regs_struct,
225        #[cfg(target_pointer_width = "32")]
226        __pad2: u32,
227        pub u_fpstate: *mut user_fpregs_struct,
228        pub magic: c_ulonglong,
229        pub u_comm: [c_char; 32],
230        pub u_debugreg: [c_ulonglong; 8],
231    }
232
233    pub struct mcontext_t {
234        pub gregs: [greg_t; 23],
235        pub fpregs: *mut _libc_fpstate,
236        __private: [u64; 8],
237    }
238
239    pub struct ipc_perm {
240        pub __key: crate::key_t,
241        pub uid: crate::uid_t,
242        pub gid: crate::gid_t,
243        pub cuid: crate::uid_t,
244        pub cgid: crate::gid_t,
245        pub mode: c_ushort,
246        __pad1: c_ushort,
247        pub __seq: c_ushort,
248        __pad2: c_ushort,
249        __unused1: u64,
250        __unused2: u64,
251    }
252
253    pub struct shmid_ds {
254        pub shm_perm: crate::ipc_perm,
255        pub shm_segsz: size_t,
256        pub shm_atime: crate::time_t,
257        pub shm_dtime: crate::time_t,
258        pub shm_ctime: crate::time_t,
259        pub shm_cpid: crate::pid_t,
260        pub shm_lpid: crate::pid_t,
261        pub shm_nattch: crate::shmatt_t,
262        __unused4: u64,
263        __unused5: u64,
264    }
265
266    pub struct ptrace_rseq_configuration {
267        pub rseq_abi_pointer: crate::__u64,
268        pub rseq_abi_size: crate::__u32,
269        pub signature: crate::__u32,
270        pub flags: crate::__u32,
271        pub pad: crate::__u32,
272    }
273
274    #[repr(align(8))]
275    pub struct clone_args {
276        pub flags: c_ulonglong,
277        pub pidfd: c_ulonglong,
278        pub child_tid: c_ulonglong,
279        pub parent_tid: c_ulonglong,
280        pub exit_signal: c_ulonglong,
281        pub stack: c_ulonglong,
282        pub stack_size: c_ulonglong,
283        pub tls: c_ulonglong,
284        pub set_tid: c_ulonglong,
285        pub set_tid_size: c_ulonglong,
286        pub cgroup: c_ulonglong,
287    }
288}
289
290s_no_extra_traits! {
291    pub struct user_fpregs_struct {
292        pub cwd: c_ushort,
293        pub swd: c_ushort,
294        pub ftw: c_ushort,
295        pub fop: c_ushort,
296        pub rip: c_ulonglong,
297        pub rdp: c_ulonglong,
298        pub mxcsr: c_uint,
299        pub mxcr_mask: c_uint,
300        pub st_space: [c_uint; 32],
301        pub xmm_space: [c_uint; 64],
302        padding: [c_uint; 24],
303    }
304
305    pub struct ucontext_t {
306        pub uc_flags: c_ulong,
307        pub uc_link: *mut ucontext_t,
308        pub uc_stack: crate::stack_t,
309        pub uc_mcontext: mcontext_t,
310        pub uc_sigmask: crate::sigset_t,
311        __private: [u8; 512],
312        // FIXME: the shadow stack field requires glibc >= 2.28.
313        // Re-add once we drop compatibility with glibc versions older than
314        // 2.28.
315        //
316        // __ssp: [c_ulonglong; 4],
317    }
318
319    #[allow(missing_debug_implementations)]
320    #[repr(align(16))]
321    pub struct max_align_t {
322        priv_: [f64; 4],
323    }
324}
325
326cfg_if! {
327    if #[cfg(feature = "extra_traits")] {
328        impl PartialEq for user_fpregs_struct {
329            fn eq(&self, other: &user_fpregs_struct) -> bool {
330                self.cwd == other.cwd
331                    && self.swd == other.swd
332                    && self.ftw == other.ftw
333                    && self.fop == other.fop
334                    && self.rip == other.rip
335                    && self.rdp == other.rdp
336                    && self.mxcsr == other.mxcsr
337                    && self.mxcr_mask == other.mxcr_mask
338                    && self.st_space == other.st_space
339                    && self
340                        .xmm_space
341                        .iter()
342                        .zip(other.xmm_space.iter())
343                        .all(|(a, b)| a == b)
344                // Ignore padding field
345            }
346        }
347
348        impl Eq for user_fpregs_struct {}
349
350        impl fmt::Debug for user_fpregs_struct {
351            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
352                f.debug_struct("user_fpregs_struct")
353                    .field("cwd", &self.cwd)
354                    .field("ftw", &self.ftw)
355                    .field("fop", &self.fop)
356                    .field("rip", &self.rip)
357                    .field("rdp", &self.rdp)
358                    .field("mxcsr", &self.mxcsr)
359                    .field("mxcr_mask", &self.mxcr_mask)
360                    .field("st_space", &self.st_space)
361                    // FIXME: .field("xmm_space", &self.xmm_space)
362                    // Ignore padding field
363                    .finish()
364            }
365        }
366
367        impl hash::Hash for user_fpregs_struct {
368            fn hash<H: hash::Hasher>(&self, state: &mut H) {
369                self.cwd.hash(state);
370                self.ftw.hash(state);
371                self.fop.hash(state);
372                self.rip.hash(state);
373                self.rdp.hash(state);
374                self.mxcsr.hash(state);
375                self.mxcr_mask.hash(state);
376                self.st_space.hash(state);
377                self.xmm_space.hash(state);
378                // Ignore padding field
379            }
380        }
381
382        impl PartialEq for ucontext_t {
383            fn eq(&self, other: &ucontext_t) -> bool {
384                self.uc_flags == other.uc_flags
385                    && self.uc_link == other.uc_link
386                    && self.uc_stack == other.uc_stack
387                    && self.uc_mcontext == other.uc_mcontext
388                    && self.uc_sigmask == other.uc_sigmask
389                // Ignore __private field
390            }
391        }
392
393        impl Eq for ucontext_t {}
394
395        impl fmt::Debug for ucontext_t {
396            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
397                f.debug_struct("ucontext_t")
398                    .field("uc_flags", &self.uc_flags)
399                    .field("uc_link", &self.uc_link)
400                    .field("uc_stack", &self.uc_stack)
401                    .field("uc_mcontext", &self.uc_mcontext)
402                    .field("uc_sigmask", &self.uc_sigmask)
403                    // Ignore __private field
404                    .finish()
405            }
406        }
407
408        impl hash::Hash for ucontext_t {
409            fn hash<H: hash::Hasher>(&self, state: &mut H) {
410                self.uc_flags.hash(state);
411                self.uc_link.hash(state);
412                self.uc_stack.hash(state);
413                self.uc_mcontext.hash(state);
414                self.uc_sigmask.hash(state);
415                // Ignore __private field
416            }
417        }
418    }
419}
420
421pub const POSIX_FADV_DONTNEED: c_int = 4;
422pub const POSIX_FADV_NOREUSE: c_int = 5;
423
424pub const VEOF: usize = 4;
425pub const RTLD_DEEPBIND: c_int = 0x8;
426pub const RTLD_GLOBAL: c_int = 0x100;
427pub const RTLD_NOLOAD: c_int = 0x4;
428
429pub const O_APPEND: c_int = 1024;
430pub const O_CREAT: c_int = 64;
431pub const O_EXCL: c_int = 128;
432pub const O_NOCTTY: c_int = 256;
433pub const O_NONBLOCK: c_int = 2048;
434pub const O_SYNC: c_int = 1052672;
435pub const O_RSYNC: c_int = 1052672;
436pub const O_DSYNC: c_int = 4096;
437pub const O_FSYNC: c_int = 0x101000;
438pub const O_NOATIME: c_int = 0o1000000;
439pub const O_PATH: c_int = 0o10000000;
440pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY;
441
442pub const MADV_SOFT_OFFLINE: c_int = 101;
443pub const MAP_GROWSDOWN: c_int = 0x0100;
444
445pub const EDEADLK: c_int = 35;
446pub const ENAMETOOLONG: c_int = 36;
447pub const ENOLCK: c_int = 37;
448pub const ENOSYS: c_int = 38;
449pub const ENOTEMPTY: c_int = 39;
450pub const ELOOP: c_int = 40;
451pub const ENOMSG: c_int = 42;
452pub const EIDRM: c_int = 43;
453pub const ECHRNG: c_int = 44;
454pub const EL2NSYNC: c_int = 45;
455pub const EL3HLT: c_int = 46;
456pub const EL3RST: c_int = 47;
457pub const ELNRNG: c_int = 48;
458pub const EUNATCH: c_int = 49;
459pub const ENOCSI: c_int = 50;
460pub const EL2HLT: c_int = 51;
461pub const EBADE: c_int = 52;
462pub const EBADR: c_int = 53;
463pub const EXFULL: c_int = 54;
464pub const ENOANO: c_int = 55;
465pub const EBADRQC: c_int = 56;
466pub const EBADSLT: c_int = 57;
467pub const EMULTIHOP: c_int = 72;
468pub const EOVERFLOW: c_int = 75;
469pub const ENOTUNIQ: c_int = 76;
470pub const EBADFD: c_int = 77;
471pub const EBADMSG: c_int = 74;
472pub const EREMCHG: c_int = 78;
473pub const ELIBACC: c_int = 79;
474pub const ELIBBAD: c_int = 80;
475pub const ELIBSCN: c_int = 81;
476pub const ELIBMAX: c_int = 82;
477pub const ELIBEXEC: c_int = 83;
478pub const EILSEQ: c_int = 84;
479pub const ERESTART: c_int = 85;
480pub const ESTRPIPE: c_int = 86;
481pub const EUSERS: c_int = 87;
482pub const ENOTSOCK: c_int = 88;
483pub const EDESTADDRREQ: c_int = 89;
484pub const EMSGSIZE: c_int = 90;
485pub const EPROTOTYPE: c_int = 91;
486pub const ENOPROTOOPT: c_int = 92;
487pub const EPROTONOSUPPORT: c_int = 93;
488pub const ESOCKTNOSUPPORT: c_int = 94;
489pub const EOPNOTSUPP: c_int = 95;
490pub const EPFNOSUPPORT: c_int = 96;
491pub const EAFNOSUPPORT: c_int = 97;
492pub const EADDRINUSE: c_int = 98;
493pub const EADDRNOTAVAIL: c_int = 99;
494pub const ENETDOWN: c_int = 100;
495pub const ENETUNREACH: c_int = 101;
496pub const ENETRESET: c_int = 102;
497pub const ECONNABORTED: c_int = 103;
498pub const ECONNRESET: c_int = 104;
499pub const ENOBUFS: c_int = 105;
500pub const EISCONN: c_int = 106;
501pub const ENOTCONN: c_int = 107;
502pub const ESHUTDOWN: c_int = 108;
503pub const ETOOMANYREFS: c_int = 109;
504pub const ETIMEDOUT: c_int = 110;
505pub const ECONNREFUSED: c_int = 111;
506pub const EHOSTDOWN: c_int = 112;
507pub const EHOSTUNREACH: c_int = 113;
508pub const EALREADY: c_int = 114;
509pub const EINPROGRESS: c_int = 115;
510pub const ESTALE: c_int = 116;
511pub const EDQUOT: c_int = 122;
512pub const ENOMEDIUM: c_int = 123;
513pub const EMEDIUMTYPE: c_int = 124;
514pub const ECANCELED: c_int = 125;
515pub const ENOKEY: c_int = 126;
516pub const EKEYEXPIRED: c_int = 127;
517pub const EKEYREVOKED: c_int = 128;
518pub const EKEYREJECTED: c_int = 129;
519pub const EOWNERDEAD: c_int = 130;
520pub const ENOTRECOVERABLE: c_int = 131;
521pub const EHWPOISON: c_int = 133;
522pub const ERFKILL: c_int = 132;
523
524pub const SOCK_STREAM: c_int = 1;
525pub const SOCK_DGRAM: c_int = 2;
526
527pub const SA_ONSTACK: c_int = 0x08000000;
528pub const SA_SIGINFO: c_int = 0x00000004;
529pub const SA_NOCLDWAIT: c_int = 0x00000002;
530
531pub const SIGTTIN: c_int = 21;
532pub const SIGTTOU: c_int = 22;
533pub const SIGXCPU: c_int = 24;
534pub const SIGXFSZ: c_int = 25;
535pub const SIGVTALRM: c_int = 26;
536pub const SIGPROF: c_int = 27;
537pub const SIGWINCH: c_int = 28;
538pub const SIGCHLD: c_int = 17;
539pub const SIGBUS: c_int = 7;
540pub const SIGUSR1: c_int = 10;
541pub const SIGUSR2: c_int = 12;
542pub const SIGCONT: c_int = 18;
543pub const SIGSTOP: c_int = 19;
544pub const SIGTSTP: c_int = 20;
545pub const SIGURG: c_int = 23;
546pub const SIGIO: c_int = 29;
547pub const SIGSYS: c_int = 31;
548pub const SIGSTKFLT: c_int = 16;
549#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")]
550pub const SIGUNUSED: c_int = 31;
551pub const SIGPOLL: c_int = 29;
552pub const SIGPWR: c_int = 30;
553pub const SIG_SETMASK: c_int = 2;
554pub const SIG_BLOCK: c_int = 0x000000;
555pub const SIG_UNBLOCK: c_int = 0x01;
556
557pub const POLLWRNORM: c_short = 0x100;
558pub const POLLWRBAND: c_short = 0x200;
559
560pub const O_ASYNC: c_int = 0x2000;
561pub const O_NDELAY: c_int = 0x800;
562
563pub const PTRACE_DETACH: c_uint = 17;
564pub const PTRACE_GET_RSEQ_CONFIGURATION: c_uint = 0x420f;
565
566pub const EFD_NONBLOCK: c_int = 0x800;
567
568pub const F_GETLK: c_int = 5;
569pub const F_GETOWN: c_int = 9;
570pub const F_SETOWN: c_int = 8;
571pub const F_SETLK: c_int = 6;
572pub const F_SETLKW: c_int = 7;
573pub const F_OFD_GETLK: c_int = 36;
574pub const F_OFD_SETLK: c_int = 37;
575pub const F_OFD_SETLKW: c_int = 38;
576
577pub const F_RDLCK: c_int = 0;
578pub const F_WRLCK: c_int = 1;
579pub const F_UNLCK: c_int = 2;
580
581pub const SFD_NONBLOCK: c_int = 0x0800;
582
583pub const TCSANOW: c_int = 0;
584pub const TCSADRAIN: c_int = 1;
585pub const TCSAFLUSH: c_int = 2;
586
587pub const SFD_CLOEXEC: c_int = 0x080000;
588
589pub const NCCS: usize = 32;
590
591pub const O_TRUNC: c_int = 512;
592
593pub const O_CLOEXEC: c_int = 0x80000;
594
595pub const EBFONT: c_int = 59;
596pub const ENOSTR: c_int = 60;
597pub const ENODATA: c_int = 61;
598pub const ETIME: c_int = 62;
599pub const ENOSR: c_int = 63;
600pub const ENONET: c_int = 64;
601pub const ENOPKG: c_int = 65;
602pub const EREMOTE: c_int = 66;
603pub const ENOLINK: c_int = 67;
604pub const EADV: c_int = 68;
605pub const ESRMNT: c_int = 69;
606pub const ECOMM: c_int = 70;
607pub const EPROTO: c_int = 71;
608pub const EDOTDOT: c_int = 73;
609
610pub const SA_NODEFER: c_int = 0x40000000;
611pub const SA_RESETHAND: c_int = 0x80000000;
612pub const SA_RESTART: c_int = 0x10000000;
613pub const SA_NOCLDSTOP: c_int = 0x00000001;
614
615pub const EPOLL_CLOEXEC: c_int = 0x80000;
616
617pub const EFD_CLOEXEC: c_int = 0x80000;
618
619pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
620pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
621pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
622
623pub const O_DIRECT: c_int = 0x4000;
624pub const O_DIRECTORY: c_int = 0x10000;
625pub const O_NOFOLLOW: c_int = 0x20000;
626
627pub const MAP_HUGETLB: c_int = 0x040000;
628pub const MAP_LOCKED: c_int = 0x02000;
629pub const MAP_NORESERVE: c_int = 0x04000;
630pub const MAP_32BIT: c_int = 0x0040;
631pub const MAP_ANON: c_int = 0x0020;
632pub const MAP_ANONYMOUS: c_int = 0x0020;
633pub const MAP_DENYWRITE: c_int = 0x0800;
634pub const MAP_EXECUTABLE: c_int = 0x01000;
635pub const MAP_POPULATE: c_int = 0x08000;
636pub const MAP_NONBLOCK: c_int = 0x010000;
637pub const MAP_STACK: c_int = 0x020000;
638pub const MAP_SYNC: c_int = 0x080000;
639
640pub const EDEADLOCK: c_int = 35;
641pub const EUCLEAN: c_int = 117;
642pub const ENOTNAM: c_int = 118;
643pub const ENAVAIL: c_int = 119;
644pub const EISNAM: c_int = 120;
645pub const EREMOTEIO: c_int = 121;
646
647pub const PTRACE_GETFPREGS: c_uint = 14;
648pub const PTRACE_SETFPREGS: c_uint = 15;
649pub const PTRACE_GETFPXREGS: c_uint = 18;
650pub const PTRACE_SETFPXREGS: c_uint = 19;
651pub const PTRACE_GETREGS: c_uint = 12;
652pub const PTRACE_SETREGS: c_uint = 13;
653pub const PTRACE_PEEKSIGINFO_SHARED: c_uint = 1;
654pub const PTRACE_SYSEMU: c_uint = 31;
655pub const PTRACE_SYSEMU_SINGLESTEP: c_uint = 32;
656
657pub const PR_GET_SPECULATION_CTRL: c_int = 52;
658pub const PR_SET_SPECULATION_CTRL: c_int = 53;
659pub const PR_SPEC_NOT_AFFECTED: c_uint = 0;
660pub const PR_SPEC_PRCTL: c_uint = 1 << 0;
661pub const PR_SPEC_ENABLE: c_uint = 1 << 1;
662pub const PR_SPEC_DISABLE: c_uint = 1 << 2;
663pub const PR_SPEC_FORCE_DISABLE: c_uint = 1 << 3;
664pub const PR_SPEC_DISABLE_NOEXEC: c_uint = 1 << 4;
665pub const PR_SPEC_STORE_BYPASS: c_int = 0;
666pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1;
667// FIXME: perharps for later
668//pub const PR_SPEC_L1D_FLUSH: c_int = 2;
669
670pub const MCL_CURRENT: c_int = 0x0001;
671pub const MCL_FUTURE: c_int = 0x0002;
672pub const MCL_ONFAULT: c_int = 0x0004;
673
674pub const SIGSTKSZ: size_t = 8192;
675pub const MINSIGSTKSZ: size_t = 2048;
676pub const CBAUD: crate::tcflag_t = 0o0010017;
677pub const TAB1: crate::tcflag_t = 0x00000800;
678pub const TAB2: crate::tcflag_t = 0x00001000;
679pub const TAB3: crate::tcflag_t = 0x00001800;
680pub const CR1: crate::tcflag_t = 0x00000200;
681pub const CR2: crate::tcflag_t = 0x00000400;
682pub const CR3: crate::tcflag_t = 0x00000600;
683pub const FF1: crate::tcflag_t = 0x00008000;
684pub const BS1: crate::tcflag_t = 0x00002000;
685pub const VT1: crate::tcflag_t = 0x00004000;
686pub const VWERASE: usize = 14;
687pub const VREPRINT: usize = 12;
688pub const VSUSP: usize = 10;
689pub const VSTART: usize = 8;
690pub const VSTOP: usize = 9;
691pub const VDISCARD: usize = 13;
692pub const VTIME: usize = 5;
693pub const IXON: crate::tcflag_t = 0x00000400;
694pub const IXOFF: crate::tcflag_t = 0x00001000;
695pub const ONLCR: crate::tcflag_t = 0x4;
696pub const CSIZE: crate::tcflag_t = 0x00000030;
697pub const CS6: crate::tcflag_t = 0x00000010;
698pub const CS7: crate::tcflag_t = 0x00000020;
699pub const CS8: crate::tcflag_t = 0x00000030;
700pub const CSTOPB: crate::tcflag_t = 0x00000040;
701pub const CREAD: crate::tcflag_t = 0x00000080;
702pub const PARENB: crate::tcflag_t = 0x00000100;
703pub const PARODD: crate::tcflag_t = 0x00000200;
704pub const HUPCL: crate::tcflag_t = 0x00000400;
705pub const CLOCAL: crate::tcflag_t = 0x00000800;
706pub const ECHOKE: crate::tcflag_t = 0x00000800;
707pub const ECHOE: crate::tcflag_t = 0x00000010;
708pub const ECHOK: crate::tcflag_t = 0x00000020;
709pub const ECHONL: crate::tcflag_t = 0x00000040;
710pub const ECHOPRT: crate::tcflag_t = 0x00000400;
711pub const ECHOCTL: crate::tcflag_t = 0x00000200;
712pub const ISIG: crate::tcflag_t = 0x00000001;
713pub const ICANON: crate::tcflag_t = 0x00000002;
714pub const PENDIN: crate::tcflag_t = 0x00004000;
715pub const NOFLSH: crate::tcflag_t = 0x00000080;
716pub const CIBAUD: crate::tcflag_t = 0o02003600000;
717pub const CBAUDEX: crate::tcflag_t = 0o010000;
718pub const VSWTC: usize = 7;
719pub const OLCUC: crate::tcflag_t = 0o000002;
720pub const NLDLY: crate::tcflag_t = 0o000400;
721pub const CRDLY: crate::tcflag_t = 0o003000;
722pub const TABDLY: crate::tcflag_t = 0o014000;
723pub const BSDLY: crate::tcflag_t = 0o020000;
724pub const FFDLY: crate::tcflag_t = 0o100000;
725pub const VTDLY: crate::tcflag_t = 0o040000;
726pub const XTABS: crate::tcflag_t = 0o014000;
727
728pub const B0: crate::speed_t = 0o000000;
729pub const B50: crate::speed_t = 0o000001;
730pub const B75: crate::speed_t = 0o000002;
731pub const B110: crate::speed_t = 0o000003;
732pub const B134: crate::speed_t = 0o000004;
733pub const B150: crate::speed_t = 0o000005;
734pub const B200: crate::speed_t = 0o000006;
735pub const B300: crate::speed_t = 0o000007;
736pub const B600: crate::speed_t = 0o000010;
737pub const B1200: crate::speed_t = 0o000011;
738pub const B1800: crate::speed_t = 0o000012;
739pub const B2400: crate::speed_t = 0o000013;
740pub const B4800: crate::speed_t = 0o000014;
741pub const B9600: crate::speed_t = 0o000015;
742pub const B19200: crate::speed_t = 0o000016;
743pub const B38400: crate::speed_t = 0o000017;
744pub const EXTA: crate::speed_t = B19200;
745pub const EXTB: crate::speed_t = B38400;
746pub const B57600: crate::speed_t = 0o010001;
747pub const B115200: crate::speed_t = 0o010002;
748pub const B230400: crate::speed_t = 0o010003;
749pub const B460800: crate::speed_t = 0o010004;
750pub const B500000: crate::speed_t = 0o010005;
751pub const B576000: crate::speed_t = 0o010006;
752pub const B921600: crate::speed_t = 0o010007;
753pub const B1000000: crate::speed_t = 0o010010;
754pub const B1152000: crate::speed_t = 0o010011;
755pub const B1500000: crate::speed_t = 0o010012;
756pub const B2000000: crate::speed_t = 0o010013;
757pub const B2500000: crate::speed_t = 0o010014;
758pub const B3000000: crate::speed_t = 0o010015;
759pub const B3500000: crate::speed_t = 0o010016;
760pub const B4000000: crate::speed_t = 0o010017;
761
762pub const VEOL: usize = 11;
763pub const VEOL2: usize = 16;
764pub const VMIN: usize = 6;
765pub const IEXTEN: crate::tcflag_t = 0x00008000;
766pub const TOSTOP: crate::tcflag_t = 0x00000100;
767pub const FLUSHO: crate::tcflag_t = 0x00001000;
768pub const EXTPROC: crate::tcflag_t = 0x00010000;
769
770// offsets in user_regs_structs, from sys/reg.h
771pub const R15: c_int = 0;
772pub const R14: c_int = 1;
773pub const R13: c_int = 2;
774pub const R12: c_int = 3;
775pub const RBP: c_int = 4;
776pub const RBX: c_int = 5;
777pub const R11: c_int = 6;
778pub const R10: c_int = 7;
779pub const R9: c_int = 8;
780pub const R8: c_int = 9;
781pub const RAX: c_int = 10;
782pub const RCX: c_int = 11;
783pub const RDX: c_int = 12;
784pub const RSI: c_int = 13;
785pub const RDI: c_int = 14;
786pub const ORIG_RAX: c_int = 15;
787pub const RIP: c_int = 16;
788pub const CS: c_int = 17;
789pub const EFLAGS: c_int = 18;
790pub const RSP: c_int = 19;
791pub const SS: c_int = 20;
792pub const FS_BASE: c_int = 21;
793pub const GS_BASE: c_int = 22;
794pub const DS: c_int = 23;
795pub const ES: c_int = 24;
796pub const FS: c_int = 25;
797pub const GS: c_int = 26;
798
799// offsets in mcontext_t.gregs from sys/ucontext.h
800pub const REG_R8: c_int = 0;
801pub const REG_R9: c_int = 1;
802pub const REG_R10: c_int = 2;
803pub const REG_R11: c_int = 3;
804pub const REG_R12: c_int = 4;
805pub const REG_R13: c_int = 5;
806pub const REG_R14: c_int = 6;
807pub const REG_R15: c_int = 7;
808pub const REG_RDI: c_int = 8;
809pub const REG_RSI: c_int = 9;
810pub const REG_RBP: c_int = 10;
811pub const REG_RBX: c_int = 11;
812pub const REG_RDX: c_int = 12;
813pub const REG_RAX: c_int = 13;
814pub const REG_RCX: c_int = 14;
815pub const REG_RSP: c_int = 15;
816pub const REG_RIP: c_int = 16;
817pub const REG_EFL: c_int = 17;
818pub const REG_CSGSFS: c_int = 18;
819pub const REG_ERR: c_int = 19;
820pub const REG_TRAPNO: c_int = 20;
821pub const REG_OLDMASK: c_int = 21;
822pub const REG_CR2: c_int = 22;
823
824extern "C" {
825    pub fn getcontext(ucp: *mut ucontext_t) -> c_int;
826    pub fn setcontext(ucp: *const ucontext_t) -> c_int;
827    pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...);
828    pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int;
829}
830
831cfg_if! {
832    if #[cfg(target_pointer_width = "32")] {
833        mod x32;
834        pub use self::x32::*;
835    } else {
836        mod not_x32;
837        pub use self::not_x32::*;
838    }
839}