interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / solarish / illumos.rs

305 lines · 9194 bytes Raw Blame History
1use crate::prelude::*;
2use 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
13pub type lgrp_rsrc_t = c_int;
14pub type lgrp_affinity_t = c_int;
15
16s! {
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
72pub const _UTX_USERSIZE: usize = 32;
73pub const _UTX_LINESIZE: usize = 32;
74pub const _UTX_PADSIZE: usize = 5;
75pub const _UTX_IDSIZE: usize = 4;
76pub const _UTX_HOSTSIZE: usize = 257;
77
78pub const AF_LOCAL: c_int = 1; // AF_UNIX
79pub const AF_FILE: c_int = 1; // AF_UNIX
80
81pub const EFD_SEMAPHORE: c_int = 0x1;
82pub const EFD_NONBLOCK: c_int = 0x800;
83pub const EFD_CLOEXEC: c_int = 0x80000;
84
85pub const POLLRDHUP: c_short = 0x4000;
86
87pub const TCP_KEEPIDLE: c_int = 34;
88pub const TCP_KEEPCNT: c_int = 35;
89pub const TCP_KEEPINTVL: c_int = 36;
90pub 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:
95pub const F_OFD_GETLK: c_int = 47;
96pub const F_OFD_SETLK: c_int = 48;
97pub const F_OFD_SETLKW: c_int = 49;
98pub const F_FLOCK: c_int = 53;
99pub const F_FLOCKW: c_int = 54;
100
101pub const F_DUPFD_CLOEXEC: c_int = 37;
102pub const F_DUPFD_CLOFORK: c_int = 58;
103pub const F_DUP2FD_CLOEXEC: c_int = 36;
104pub const F_DUP2FD_CLOFORK: c_int = 57;
105pub const F_DUP3FD: c_int = 59;
106
107pub const FD_CLOFORK: c_int = 2;
108
109pub const FIL_ATTACH: c_int = 0x1;
110pub const FIL_DETACH: c_int = 0x2;
111pub const FIL_LIST: c_int = 0x3;
112
113/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
114/// for details.
115pub const FILNAME_MAX: c_int = 32;
116
117pub const FILF_PROG: c_int = 0x1;
118pub const FILF_AUTO: c_int = 0x2;
119pub const FILF_BYPASS: c_int = 0x4;
120pub const SOL_FILTER: c_int = 0xfffc;
121
122pub const MADV_PURGE: c_int = 9;
123
124pub const POSIX_FADV_NORMAL: c_int = 0;
125pub const POSIX_FADV_RANDOM: c_int = 1;
126pub const POSIX_FADV_SEQUENTIAL: c_int = 2;
127pub const POSIX_FADV_WILLNEED: c_int = 3;
128pub const POSIX_FADV_DONTNEED: c_int = 4;
129pub const POSIX_FADV_NOREUSE: c_int = 5;
130
131pub const POSIX_SPAWN_SETSID: c_short = 0x40;
132
133pub const SIGINFO: c_int = 41;
134
135pub const O_DIRECT: c_int = 0x2000000;
136pub const O_CLOFORK: c_int = 0x4000000;
137
138pub const MSG_CMSG_CLOEXEC: c_int = 0x1000;
139pub const MSG_CMSG_CLOFORK: c_int = 0x2000;
140
141pub const PBIND_HARD: crate::processorid_t = -3;
142pub const PBIND_SOFT: crate::processorid_t = -4;
143
144pub const PS_SYSTEM: c_int = 1;
145
146pub const MAP_FILE: c_int = 0;
147
148pub const MAP_32BIT: c_int = 0x80;
149
150pub const AF_NCA: c_int = 28;
151
152pub const PF_NCA: c_int = AF_NCA;
153
154pub const LOCK_SH: c_int = 1;
155pub const LOCK_EX: c_int = 2;
156pub const LOCK_NB: c_int = 4;
157pub const LOCK_UN: c_int = 8;
158
159/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
160/// for details.
161pub const _PC_LAST: c_int = 101;
162
163pub const _CS_PATH: c_int = 65;
164
165pub const VSTATUS: usize = 16;
166pub const VERASE2: usize = 17;
167
168pub const EPOLLIN: c_int = 0x1;
169pub const EPOLLPRI: c_int = 0x2;
170pub const EPOLLOUT: c_int = 0x4;
171pub const EPOLLRDNORM: c_int = 0x40;
172pub const EPOLLRDBAND: c_int = 0x80;
173pub const EPOLLWRNORM: c_int = 0x100;
174pub const EPOLLWRBAND: c_int = 0x200;
175pub const EPOLLMSG: c_int = 0x400;
176pub const EPOLLERR: c_int = 0x8;
177pub const EPOLLHUP: c_int = 0x10;
178pub const EPOLLET: c_int = u32_cast_int(0x80000000);
179pub const EPOLLRDHUP: c_int = 0x2000;
180pub const EPOLLONESHOT: c_int = 0x40000000;
181pub const EPOLLWAKEUP: c_int = 0x20000000;
182pub const EPOLLEXCLUSIVE: c_int = 0x10000000;
183pub const EPOLL_CLOEXEC: c_int = 0x80000;
184pub const EPOLL_CTL_ADD: c_int = 1;
185pub const EPOLL_CTL_MOD: c_int = 3;
186pub const EPOLL_CTL_DEL: c_int = 2;
187
188pub 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.
197pub const LGRP_RSRC_COUNT: crate::lgrp_rsrc_t = 2;
198
199pub const LGRP_RSRC_CPU: crate::lgrp_rsrc_t = 0;
200pub const LGRP_RSRC_MEM: crate::lgrp_rsrc_t = 1;
201
202pub const P_DISABLED: c_int = 0x008;
203
204pub const AT_SUN_HWCAP2: c_uint = 2023;
205pub const AT_SUN_FPTYPE: c_uint = 2027;
206
207pub const B1000000: crate::speed_t = 24;
208pub const B1152000: crate::speed_t = 25;
209pub const B1500000: crate::speed_t = 26;
210pub const B2000000: crate::speed_t = 27;
211pub const B2500000: crate::speed_t = 28;
212pub const B3000000: crate::speed_t = 29;
213pub const B3500000: crate::speed_t = 30;
214pub const B4000000: crate::speed_t = 31;
215
216// sys/systeminfo.h
217pub const SI_ADDRESS_WIDTH: c_int = 520;
218
219// netinet/in.h
220pub const IP_MINTTL: c_int = 0x1c;
221pub const IPV6_MINHOPCOUNT: c_int = 0x2f;
222
223// sys/timerfd.h
224pub const TFD_CLOEXEC: i32 = 0o2000000;
225pub const TFD_NONBLOCK: i32 = 0o4000;
226pub const TFD_TIMER_ABSTIME: i32 = 1 << 0;
227pub const TFD_TIMER_CANCEL_ON_SET: i32 = 1 << 1;
228
229extern "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}