1 use crate::prelude::*; 2 use crate::{ 3 exit_status, off_t, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, 4 PRIV_PFEXEC, PRIV_XPOLICY, 5 }; 6 7 pub type lgrp_rsrc_t = c_int; 8 pub type lgrp_affinity_t = c_int; 9 10 s! { 11 pub struct aiocb { 12 pub aio_fildes: c_int, 13 pub aio_buf: *mut c_void, 14 pub aio_nbytes: size_t, 15 pub aio_offset: off_t, 16 pub aio_reqprio: c_int, 17 pub aio_sigevent: crate::sigevent, 18 pub aio_lio_opcode: c_int, 19 pub aio_resultp: crate::aio_result_t, 20 pub aio_state: c_int, 21 pub aio__pad: [c_int; 1], 22 } 23 24 pub struct shmid_ds { 25 pub shm_perm: crate::ipc_perm, 26 pub shm_segsz: size_t, 27 pub shm_amp: *mut c_void, 28 pub shm_lkcnt: c_ushort, 29 pub shm_lpid: crate::pid_t, 30 pub shm_cpid: crate::pid_t, 31 pub shm_nattch: crate::shmatt_t, 32 pub shm_cnattch: c_ulong, 33 pub shm_atime: crate::time_t, 34 pub shm_dtime: crate::time_t, 35 pub shm_ctime: crate::time_t, 36 pub shm_pad4: [i64; 4], 37 } 38 39 pub struct fil_info { 40 pub fi_flags: c_int, 41 pub fi_pos: c_int, 42 pub fi_name: [c_char; crate::FILNAME_MAX as usize], 43 } 44 } 45 46 s_no_extra_traits! { 47 #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] 48 pub struct epoll_event { 49 pub events: u32, 50 pub u64: u64, 51 } 52 53 pub struct utmpx { 54 pub ut_user: [c_char; _UTX_USERSIZE], 55 pub ut_id: [c_char; _UTX_IDSIZE], 56 pub ut_line: [c_char; _UTX_LINESIZE], 57 pub ut_pid: crate::pid_t, 58 pub ut_type: c_short, 59 pub ut_exit: exit_status, 60 pub ut_tv: crate::timeval, 61 pub ut_session: c_int, 62 pub ut_pad: [c_int; _UTX_PADSIZE], 63 pub ut_syslen: c_short, 64 pub ut_host: [c_char; _UTX_HOSTSIZE], 65 } 66 } 67 68 cfg_if! { 69 if #[cfg(feature = "extra_traits")] { 70 impl PartialEq for utmpx { 71 fn eq(&self, other: &utmpx) -> bool { 72 self.ut_type == other.ut_type 73 && self.ut_pid == other.ut_pid 74 && self.ut_user == other.ut_user 75 && self.ut_line == other.ut_line 76 && self.ut_id == other.ut_id 77 && self.ut_exit == other.ut_exit 78 && self.ut_session == other.ut_session 79 && self.ut_tv == other.ut_tv 80 && self.ut_syslen == other.ut_syslen 81 && self.ut_pad == other.ut_pad 82 && self 83 .ut_host 84 .iter() 85 .zip(other.ut_host.iter()) 86 .all(|(a, b)| a == b) 87 } 88 } 89 90 impl Eq for utmpx {} 91 92 impl hash::Hash for utmpx { 93 fn hash<H: hash::Hasher>(&self, state: &mut H) { 94 self.ut_user.hash(state); 95 self.ut_type.hash(state); 96 self.ut_pid.hash(state); 97 self.ut_line.hash(state); 98 self.ut_id.hash(state); 99 self.ut_host.hash(state); 100 self.ut_exit.hash(state); 101 self.ut_session.hash(state); 102 self.ut_tv.hash(state); 103 self.ut_syslen.hash(state); 104 self.ut_pad.hash(state); 105 } 106 } 107 108 impl PartialEq for epoll_event { 109 fn eq(&self, other: &epoll_event) -> bool { 110 self.events == other.events && self.u64 == other.u64 111 } 112 } 113 impl Eq for epoll_event {} 114 impl hash::Hash for epoll_event { 115 fn hash<H: hash::Hasher>(&self, state: &mut H) { 116 let events = self.events; 117 let u64 = self.u64; 118 events.hash(state); 119 u64.hash(state); 120 } 121 } 122 } 123 } 124 125 pub const _UTX_USERSIZE: usize = 32; 126 pub const _UTX_LINESIZE: usize = 32; 127 pub const _UTX_PADSIZE: usize = 5; 128 pub const _UTX_IDSIZE: usize = 4; 129 pub const _UTX_HOSTSIZE: usize = 257; 130 131 pub const AF_LOCAL: c_int = 1; // AF_UNIX 132 pub const AF_FILE: c_int = 1; // AF_UNIX 133 134 pub const EFD_SEMAPHORE: c_int = 0x1; 135 pub const EFD_NONBLOCK: c_int = 0x800; 136 pub const EFD_CLOEXEC: c_int = 0x80000; 137 138 pub const POLLRDHUP: c_short = 0x4000; 139 140 pub const TCP_KEEPIDLE: c_int = 34; 141 pub const TCP_KEEPCNT: c_int = 35; 142 pub const TCP_KEEPINTVL: c_int = 36; 143 pub const TCP_CONGESTION: c_int = 37; 144 145 // These constants are correct for 64-bit programs or 32-bit programs that are 146 // not using large-file mode. If Rust ever supports anything other than 64-bit 147 // compilation on illumos, this may require adjustment: 148 pub const F_OFD_GETLK: c_int = 47; 149 pub const F_OFD_SETLK: c_int = 48; 150 pub const F_OFD_SETLKW: c_int = 49; 151 pub const F_FLOCK: c_int = 53; 152 pub const F_FLOCKW: c_int = 54; 153 154 pub const F_DUPFD_CLOEXEC: c_int = 37; 155 pub const F_DUPFD_CLOFORK: c_int = 58; 156 pub const F_DUP2FD_CLOEXEC: c_int = 36; 157 pub const F_DUP2FD_CLOFORK: c_int = 57; 158 pub const F_DUP3FD: c_int = 59; 159 160 pub const FD_CLOFORK: c_int = 2; 161 162 pub const FIL_ATTACH: c_int = 0x1; 163 pub const FIL_DETACH: c_int = 0x2; 164 pub const FIL_LIST: c_int = 0x3; 165 pub const FILNAME_MAX: c_int = 32; 166 pub const FILF_PROG: c_int = 0x1; 167 pub const FILF_AUTO: c_int = 0x2; 168 pub const FILF_BYPASS: c_int = 0x4; 169 pub const SOL_FILTER: c_int = 0xfffc; 170 171 pub const MADV_PURGE: c_int = 9; 172 173 pub const POSIX_FADV_NORMAL: c_int = 0; 174 pub const POSIX_FADV_RANDOM: c_int = 1; 175 pub const POSIX_FADV_SEQUENTIAL: c_int = 2; 176 pub const POSIX_FADV_WILLNEED: c_int = 3; 177 pub const POSIX_FADV_DONTNEED: c_int = 4; 178 pub const POSIX_FADV_NOREUSE: c_int = 5; 179 180 pub const POSIX_SPAWN_SETSID: c_short = 0x40; 181 182 pub const SIGINFO: c_int = 41; 183 184 pub const O_DIRECT: c_int = 0x2000000; 185 pub const O_CLOFORK: c_int = 0x4000000; 186 187 pub const MSG_CMSG_CLOEXEC: c_int = 0x1000; 188 pub const MSG_CMSG_CLOFORK: c_int = 0x2000; 189 190 pub const PBIND_HARD: crate::processorid_t = -3; 191 pub const PBIND_SOFT: crate::processorid_t = -4; 192 193 pub const PS_SYSTEM: c_int = 1; 194 195 pub const MAP_FILE: c_int = 0; 196 197 pub const MAP_32BIT: c_int = 0x80; 198 199 pub const AF_NCA: c_int = 28; 200 201 pub const PF_NCA: c_int = AF_NCA; 202 203 pub const LOCK_SH: c_int = 1; 204 pub const LOCK_EX: c_int = 2; 205 pub const LOCK_NB: c_int = 4; 206 pub const LOCK_UN: c_int = 8; 207 208 pub const _PC_LAST: c_int = 101; 209 210 pub const VSTATUS: usize = 16; 211 pub const VERASE2: usize = 17; 212 213 pub const EPOLLIN: c_int = 0x1; 214 pub const EPOLLPRI: c_int = 0x2; 215 pub const EPOLLOUT: c_int = 0x4; 216 pub const EPOLLRDNORM: c_int = 0x40; 217 pub const EPOLLRDBAND: c_int = 0x80; 218 pub const EPOLLWRNORM: c_int = 0x100; 219 pub const EPOLLWRBAND: c_int = 0x200; 220 pub const EPOLLMSG: c_int = 0x400; 221 pub const EPOLLERR: c_int = 0x8; 222 pub const EPOLLHUP: c_int = 0x10; 223 pub const EPOLLET: c_int = 0x80000000; 224 pub const EPOLLRDHUP: c_int = 0x2000; 225 pub const EPOLLONESHOT: c_int = 0x40000000; 226 pub const EPOLLWAKEUP: c_int = 0x20000000; 227 pub const EPOLLEXCLUSIVE: c_int = 0x10000000; 228 pub const EPOLL_CLOEXEC: c_int = 0x80000; 229 pub const EPOLL_CTL_ADD: c_int = 1; 230 pub const EPOLL_CTL_MOD: c_int = 3; 231 pub const EPOLL_CTL_DEL: c_int = 2; 232 233 pub const PRIV_USER: c_uint = PRIV_DEBUG 234 | NET_MAC_AWARE 235 | NET_MAC_AWARE_INHERIT 236 | PRIV_XPOLICY 237 | PRIV_AWARE_RESET 238 | PRIV_PFEXEC; 239 240 pub const LGRP_RSRC_COUNT: crate::lgrp_rsrc_t = 2; 241 pub const LGRP_RSRC_CPU: crate::lgrp_rsrc_t = 0; 242 pub const LGRP_RSRC_MEM: crate::lgrp_rsrc_t = 1; 243 244 pub const P_DISABLED: c_int = 0x008; 245 246 pub const AT_SUN_HWCAP2: c_uint = 2023; 247 pub const AT_SUN_FPTYPE: c_uint = 2027; 248 249 pub const B1000000: crate::speed_t = 24; 250 pub const B1152000: crate::speed_t = 25; 251 pub const B1500000: crate::speed_t = 26; 252 pub const B2000000: crate::speed_t = 27; 253 pub const B2500000: crate::speed_t = 28; 254 pub const B3000000: crate::speed_t = 29; 255 pub const B3500000: crate::speed_t = 30; 256 pub const B4000000: crate::speed_t = 31; 257 258 // sys/systeminfo.h 259 pub const SI_ADDRESS_WIDTH: c_int = 520; 260 261 // sys/timerfd.h 262 pub const TFD_CLOEXEC: i32 = 0o2000000; 263 pub const TFD_NONBLOCK: i32 = 0o4000; 264 pub const TFD_TIMER_ABSTIME: i32 = 1 << 0; 265 pub const TFD_TIMER_CANCEL_ON_SET: i32 = 1 << 1; 266 267 extern "C" { eventfd(init: c_uint, flags: c_int) -> c_int268 pub fn eventfd(init: c_uint, flags: c_int) -> c_int; 269 epoll_pwait( epfd: c_int, events: *mut crate::epoll_event, maxevents: c_int, timeout: c_int, sigmask: *const crate::sigset_t, ) -> c_int270 pub fn epoll_pwait( 271 epfd: c_int, 272 events: *mut crate::epoll_event, 273 maxevents: c_int, 274 timeout: c_int, 275 sigmask: *const crate::sigset_t, 276 ) -> c_int; epoll_create(size: c_int) -> c_int277 pub fn epoll_create(size: c_int) -> c_int; epoll_create1(flags: c_int) -> c_int278 pub fn epoll_create1(flags: c_int) -> c_int; epoll_wait( epfd: c_int, events: *mut crate::epoll_event, maxevents: c_int, timeout: c_int, ) -> c_int279 pub fn epoll_wait( 280 epfd: c_int, 281 events: *mut crate::epoll_event, 282 maxevents: c_int, 283 timeout: c_int, 284 ) -> c_int; epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int285 pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; 286 mincore(addr: crate::caddr_t, len: size_t, vec: *mut c_char) -> c_int287 pub fn mincore(addr: crate::caddr_t, len: size_t, vec: *mut c_char) -> c_int; 288 pset_bind_lwp( pset: crate::psetid_t, id: crate::id_t, pid: crate::pid_t, opset: *mut crate::psetid_t, ) -> c_int289 pub fn pset_bind_lwp( 290 pset: crate::psetid_t, 291 id: crate::id_t, 292 pid: crate::pid_t, 293 opset: *mut crate::psetid_t, 294 ) -> c_int; pset_getloadavg(pset: crate::psetid_t, load: *mut c_double, num: c_int) -> c_int295 pub fn pset_getloadavg(pset: crate::psetid_t, load: *mut c_double, num: c_int) -> c_int; 296 pthread_attr_get_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int297 pub fn pthread_attr_get_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) 298 -> c_int; pthread_attr_getstackaddr( attr: *const crate::pthread_attr_t, stackaddr: *mut *mut c_void, ) -> c_int299 pub fn pthread_attr_getstackaddr( 300 attr: *const crate::pthread_attr_t, 301 stackaddr: *mut *mut c_void, 302 ) -> c_int; pthread_attr_setstack( attr: *mut crate::pthread_attr_t, stackaddr: *mut c_void, stacksize: size_t, ) -> c_int303 pub fn pthread_attr_setstack( 304 attr: *mut crate::pthread_attr_t, 305 stackaddr: *mut c_void, 306 stacksize: size_t, 307 ) -> c_int; pthread_attr_setstackaddr( attr: *mut crate::pthread_attr_t, stackaddr: *mut c_void, ) -> c_int308 pub fn pthread_attr_setstackaddr( 309 attr: *mut crate::pthread_attr_t, 310 stackaddr: *mut c_void, 311 ) -> c_int; 312 posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int313 pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int; preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t314 pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t315 pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; getpagesizes2(pagesize: *mut size_t, nelem: c_int) -> c_int316 pub fn getpagesizes2(pagesize: *mut size_t, nelem: c_int) -> c_int; 317 posix_spawn_file_actions_addfchdir_np( file_actions: *mut crate::posix_spawn_file_actions_t, fd: c_int, ) -> c_int318 pub fn posix_spawn_file_actions_addfchdir_np( 319 file_actions: *mut crate::posix_spawn_file_actions_t, 320 fd: c_int, 321 ) -> c_int; 322 ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int323 pub fn ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int; 324 syncfs(fd: c_int) -> c_int325 pub fn syncfs(fd: c_int) -> c_int; 326 strcasecmp_l(s1: *const c_char, s2: *const c_char, loc: crate::locale_t) -> c_int327 pub fn strcasecmp_l(s1: *const c_char, s2: *const c_char, loc: crate::locale_t) -> c_int; strncasecmp_l( s1: *const c_char, s2: *const c_char, n: size_t, loc: crate::locale_t, ) -> c_int328 pub fn strncasecmp_l( 329 s1: *const c_char, 330 s2: *const c_char, 331 n: size_t, 332 loc: crate::locale_t, 333 ) -> c_int; 334 timerfd_create(clockid: c_int, flags: c_int) -> c_int335 pub fn timerfd_create(clockid: c_int, flags: c_int) -> c_int; timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int336 pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; timerfd_settime( fd: c_int, flags: c_int, new_value: *const crate::itimerspec, old_value: *mut crate::itimerspec, ) -> c_int337 pub fn timerfd_settime( 338 fd: c_int, 339 flags: c_int, 340 new_value: *const crate::itimerspec, 341 old_value: *mut crate::itimerspec, 342 ) -> c_int; 343 } 344