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