Debian Codegraph @

third_party/rust/libc/src/unix/solarish/illumos.rs

raw
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 fmt::Debug for utmpx {
93 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
94 f.debug_struct("utmpx")
95 .field("ut_user", &self.ut_user)
96 .field("ut_id", &self.ut_id)
97 .field("ut_line", &self.ut_line)
98 .field("ut_pid", &self.ut_pid)
99 .field("ut_type", &self.ut_type)
100 .field("ut_exit", &self.ut_exit)
101 .field("ut_tv", &self.ut_tv)
102 .field("ut_session", &self.ut_session)
103 .field("ut_pad", &self.ut_pad)
104 .field("ut_syslen", &self.ut_syslen)
105 .field("ut_host", &&self.ut_host[..])
106 .finish()
107 }
108 }
109
110 impl hash::Hash for utmpx {
111 fn hash<H: hash::Hasher>(&self, state: &mut H) {
112 self.ut_user.hash(state);
113 self.ut_type.hash(state);
114 self.ut_pid.hash(state);
115 self.ut_line.hash(state);
116 self.ut_id.hash(state);
117 self.ut_host.hash(state);
118 self.ut_exit.hash(state);
119 self.ut_session.hash(state);
120 self.ut_tv.hash(state);
121 self.ut_syslen.hash(state);
122 self.ut_pad.hash(state);
123 }
124 }
125
126 impl PartialEq for epoll_event {
127 fn eq(&self, other: &epoll_event) -> bool {
128 self.events == other.events && self.u64 == other.u64
129 }
130 }
131 impl Eq for epoll_event {}
132 impl fmt::Debug for epoll_event {
133 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
134 let events = self.events;
135 let u64 = self.u64;
136 f.debug_struct("epoll_event")
137 .field("events", &events)
138 .field("u64", &u64)
139 .finish()
140 }
141 }
142 impl hash::Hash for epoll_event {
143 fn hash<H: hash::Hasher>(&self, state: &mut H) {
144 let events = self.events;
145 let u64 = self.u64;
146 events.hash(state);
147 u64.hash(state);
148 }
149 }
150 }
151 }
152
153 pub const _UTX_USERSIZE: usize = 32;
154 pub const _UTX_LINESIZE: usize = 32;
155 pub const _UTX_PADSIZE: usize = 5;
156 pub const _UTX_IDSIZE: usize = 4;
157 pub const _UTX_HOSTSIZE: usize = 257;
158
159 pub const AF_LOCAL: c_int = 1; // AF_UNIX
160 pub const AF_FILE: c_int = 1; // AF_UNIX
161
162 pub const EFD_SEMAPHORE: c_int = 0x1;
163 pub const EFD_NONBLOCK: c_int = 0x800;
164 pub const EFD_CLOEXEC: c_int = 0x80000;
165
166 pub const POLLRDHUP: c_short = 0x4000;
167
168 pub const TCP_KEEPIDLE: c_int = 34;
169 pub const TCP_KEEPCNT: c_int = 35;
170 pub const TCP_KEEPINTVL: c_int = 36;
171 pub const TCP_CONGESTION: c_int = 37;
172
173 // These constants are correct for 64-bit programs or 32-bit programs that are
174 // not using large-file mode. If Rust ever supports anything other than 64-bit
175 // compilation on illumos, this may require adjustment:
176 pub const F_OFD_GETLK: c_int = 47;
177 pub const F_OFD_SETLK: c_int = 48;
178 pub const F_OFD_SETLKW: c_int = 49;
179 pub const F_FLOCK: c_int = 53;
180 pub const F_FLOCKW: c_int = 54;
181
182 pub const F_DUPFD_CLOEXEC: c_int = 37;
183 pub const F_DUPFD_CLOFORK: c_int = 58;
184 pub const F_DUP2FD_CLOEXEC: c_int = 36;
185 pub const F_DUP2FD_CLOFORK: c_int = 57;
186 pub const F_DUP3FD: c_int = 59;
187
188 pub const FD_CLOFORK: c_int = 2;
189
190 pub const FIL_ATTACH: c_int = 0x1;
191 pub const FIL_DETACH: c_int = 0x2;
192 pub const FIL_LIST: c_int = 0x3;
193 pub const FILNAME_MAX: c_int = 32;
194 pub const FILF_PROG: c_int = 0x1;
195 pub const FILF_AUTO: c_int = 0x2;
196 pub const FILF_BYPASS: c_int = 0x4;
197 pub const SOL_FILTER: c_int = 0xfffc;
198
199 pub const MADV_PURGE: c_int = 9;
200
201 pub const POSIX_FADV_NORMAL: c_int = 0;
202 pub const POSIX_FADV_RANDOM: c_int = 1;
203 pub const POSIX_FADV_SEQUENTIAL: c_int = 2;
204 pub const POSIX_FADV_WILLNEED: c_int = 3;
205 pub const POSIX_FADV_DONTNEED: c_int = 4;
206 pub const POSIX_FADV_NOREUSE: c_int = 5;
207
208 pub const POSIX_SPAWN_SETSID: c_short = 0x40;
209
210 pub const SIGINFO: c_int = 41;
211
212 pub const O_DIRECT: c_int = 0x2000000;
213 pub const O_CLOFORK: c_int = 0x4000000;
214
215 pub const MSG_CMSG_CLOEXEC: c_int = 0x1000;
216 pub const MSG_CMSG_CLOFORK: c_int = 0x2000;
217
218 pub const PBIND_HARD: crate::processorid_t = -3;
219 pub const PBIND_SOFT: crate::processorid_t = -4;
220
221 pub const PS_SYSTEM: c_int = 1;
222
223 pub const MAP_FILE: c_int = 0;
224
225 pub const MAP_32BIT: c_int = 0x80;
226
227 pub const AF_NCA: c_int = 28;
228
229 pub const PF_NCA: c_int = AF_NCA;
230
231 pub const LOCK_SH: c_int = 1;
232 pub const LOCK_EX: c_int = 2;
233 pub const LOCK_NB: c_int = 4;
234 pub const LOCK_UN: c_int = 8;
235
236 pub const _PC_LAST: c_int = 101;
237
238 pub const VSTATUS: usize = 16;
239 pub const VERASE2: usize = 17;
240
241 pub const EPOLLIN: c_int = 0x1;
242 pub const EPOLLPRI: c_int = 0x2;
243 pub const EPOLLOUT: c_int = 0x4;
244 pub const EPOLLRDNORM: c_int = 0x40;
245 pub const EPOLLRDBAND: c_int = 0x80;
246 pub const EPOLLWRNORM: c_int = 0x100;
247 pub const EPOLLWRBAND: c_int = 0x200;
248 pub const EPOLLMSG: c_int = 0x400;
249 pub const EPOLLERR: c_int = 0x8;
250 pub const EPOLLHUP: c_int = 0x10;
251 pub const EPOLLET: c_int = 0x80000000;
252 pub const EPOLLRDHUP: c_int = 0x2000;
253 pub const EPOLLONESHOT: c_int = 0x40000000;
254 pub const EPOLLWAKEUP: c_int = 0x20000000;
255 pub const EPOLLEXCLUSIVE: c_int = 0x10000000;
256 pub const EPOLL_CLOEXEC: c_int = 0x80000;
257 pub const EPOLL_CTL_ADD: c_int = 1;
258 pub const EPOLL_CTL_MOD: c_int = 3;
259 pub const EPOLL_CTL_DEL: c_int = 2;
260
261 pub const PRIV_USER: c_uint = PRIV_DEBUG
262 | NET_MAC_AWARE
263 | NET_MAC_AWARE_INHERIT
264 | PRIV_XPOLICY
265 | PRIV_AWARE_RESET
266 | PRIV_PFEXEC;
267
268 pub const LGRP_RSRC_COUNT: crate::lgrp_rsrc_t = 2;
269 pub const LGRP_RSRC_CPU: crate::lgrp_rsrc_t = 0;
270 pub const LGRP_RSRC_MEM: crate::lgrp_rsrc_t = 1;
271
272 pub const P_DISABLED: c_int = 0x008;
273
274 pub const AT_SUN_HWCAP2: c_uint = 2023;
275 pub const AT_SUN_FPTYPE: c_uint = 2027;
276
277 pub const B1000000: crate::speed_t = 24;
278 pub const B1152000: crate::speed_t = 25;
279 pub const B1500000: crate::speed_t = 26;
280 pub const B2000000: crate::speed_t = 27;
281 pub const B2500000: crate::speed_t = 28;
282 pub const B3000000: crate::speed_t = 29;
283 pub const B3500000: crate::speed_t = 30;
284 pub const B4000000: crate::speed_t = 31;
285
286 // sys/systeminfo.h
287 pub const SI_ADDRESS_WIDTH: c_int = 520;
288
289 extern "C" {
290 pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
291
292 pub fn epoll_pwait(
293 epfd: c_int,
294 events: *mut crate::epoll_event,
295 maxevents: c_int,
296 timeout: c_int,
297 sigmask: *const crate::sigset_t,
298 ) -> c_int;
299 pub fn epoll_create(size: c_int) -> c_int;
300 pub fn epoll_create1(flags: c_int) -> c_int;
301 pub fn epoll_wait(
302 epfd: c_int,
303 events: *mut crate::epoll_event,
304 maxevents: c_int,
305 timeout: c_int,
306 ) -> c_int;
307 pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int;
308
309 pub fn mincore(addr: crate::caddr_t, len: size_t, vec: *mut c_char) -> c_int;
310
311 pub fn pset_bind_lwp(
312 pset: crate::psetid_t,
313 id: crate::id_t,
314 pid: crate::pid_t,
315 opset: *mut crate::psetid_t,
316 ) -> c_int;
317 pub fn pset_getloadavg(pset: crate::psetid_t, load: *mut c_double, num: c_int) -> c_int;
318
319 pub fn pthread_attr_get_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t)
320 -> c_int;
321 pub fn pthread_attr_getstackaddr(
322 attr: *const crate::pthread_attr_t,
323 stackaddr: *mut *mut c_void,
324 ) -> c_int;
325 pub fn pthread_attr_setstack(
326 attr: *mut crate::pthread_attr_t,
327 stackaddr: *mut c_void,
328 stacksize: size_t,
329 ) -> c_int;
330 pub fn pthread_attr_setstackaddr(
331 attr: *mut crate::pthread_attr_t,
332 stackaddr: *mut c_void,
333 ) -> c_int;
334
335 pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int;
336 pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
337 pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
338 pub fn getpagesizes2(pagesize: *mut size_t, nelem: c_int) -> c_int;
339
340 pub fn posix_spawn_file_actions_addfchdir_np(
341 file_actions: *mut crate::posix_spawn_file_actions_t,
342 fd: c_int,
343 ) -> c_int;
344
345 pub fn ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int;
346
347 pub fn syncfs(fd: c_int) -> c_int;
348
349 pub fn strcasecmp_l(s1: *const c_char, s2: *const c_char, loc: crate::locale_t) -> c_int;
350 pub fn strncasecmp_l(
351 s1: *const c_char,
352 s2: *const c_char,
353 n: size_t,
354 loc: crate::locale_t,
355 ) -> c_int;
356 }