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