|
| 1 | +// TODO |
| 2 | +// Avoid restating local alias names |
| 3 | +cfg_if::cfg_if! { |
| 4 | + if #[cfg(target_env = "musl")] { |
| 5 | + // https://git.musl-libc.org/cgit/musl/tree/include/utmpx.h?id=1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 |
| 6 | + pub const EMPTY: libc::c_short = 0_i16; |
| 7 | + pub const RUN_LVL: libc::c_short = 1_i16; |
| 8 | + pub const BOOT_TIME: libc::c_short = 2_i16; |
| 9 | + pub const NEW_TIME: libc::c_short = 3_i16; |
| 10 | + pub const OLD_TIME: libc::c_short = 4_i16; |
| 11 | + pub const INIT_PROCESS: libc::c_short = 5_i16; |
| 12 | + pub const LOGIN_PROCESS: libc::c_short = 6_i16; |
| 13 | + pub const USER_PROCESS: libc::c_short = 7_i16; |
| 14 | + pub const DEAD_PROCESS: libc::c_short = 8_i16; |
| 15 | + |
| 16 | + // Remove when https://github.com/rust-lang/libc/issues/3190 is resolved |
| 17 | + // https://github.com/rust-lang/libc/commit/e3caaf6b0ea08ae294e25a861022c256a7535ec4#diff-5822a2981791fb0bb7689a921abdc2133cc73116ee125eabefad3a9374056b7a |
| 18 | + extern "C" { |
| 19 | + pub fn getutxent() -> *mut libc::utmpx; |
| 20 | + pub fn getutxid(ut: *const libc::utmpx) -> *mut libc::utmpx; |
| 21 | + pub fn getutxline(ut: *const libc::utmpx) -> *mut libc::utmpx; |
| 22 | + pub fn pututxline(ut: *const libc::utmpx) -> *mut libc::utmpx; |
| 23 | + pub fn setutxent(); |
| 24 | + pub fn endutxent(); |
| 25 | + } |
| 26 | + |
| 27 | + type LocalPIoctlOp = libc::c_int; |
| 28 | + type LocalPPriorityWhichT = libc::c_int; |
| 29 | + } else { |
| 30 | + pub use libc::{ |
| 31 | + endutxent, |
| 32 | + getutxent, |
| 33 | + setutxent, |
| 34 | + BOOT_TIME, |
| 35 | + DEAD_PROCESS, |
| 36 | + EMPTY, |
| 37 | + INIT_PROCESS, |
| 38 | + LOGIN_PROCESS, |
| 39 | + NEW_TIME, |
| 40 | + OLD_TIME, |
| 41 | + RUN_LVL, |
| 42 | + USER_PROCESS, |
| 43 | + }; |
| 44 | + |
| 45 | + cfg_if::cfg_if! { |
| 46 | + if #[cfg(target_os = "macos")] { |
| 47 | + type LocalPPriorityWhichT = libc::c_int; |
| 48 | + } else { |
| 49 | + type LocalPPriorityWhichT = libc::__priority_which_t; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + type LocalPIoctlOp = libc::c_ulong; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +// Constants taken from: |
| 58 | +// https://docs.rs/term_size/0.3.2/src/term_size/platform/unix.rs.html#5-19 |
| 59 | +pub(crate) const P_WINSIZE_REQUEST_CODE: LocalPIoctlOp = ({ |
| 60 | + #[cfg(any(target_os = "linux", target_os = "android"))] |
| 61 | + { |
| 62 | + 0x5413 |
| 63 | + } |
| 64 | + |
| 65 | + #[cfg(any( |
| 66 | + target_os = "macos", |
| 67 | + target_os = "ios", |
| 68 | + target_os = "dragonfly", |
| 69 | + target_os = "freebsd", |
| 70 | + target_os = "netbsd", |
| 71 | + target_os = "openbsd" |
| 72 | + ))] |
| 73 | + { |
| 74 | + 0x40087468 |
| 75 | + } |
| 76 | + |
| 77 | + #[cfg(target_os = "solaris")] |
| 78 | + { |
| 79 | + 0x5468 |
| 80 | + } |
| 81 | +}) as LocalPIoctlOp; |
| 82 | + |
| 83 | +pub(crate) type PPriorityWhichT = LocalPPriorityWhichT; |
0 commit comments