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