Debian Codegraph @

.cargo/vendor/libc/src/unix/bsd/mod.rs

raw
1 pub type off_t = i64;
2 pub type useconds_t = u32;
3 pub type blkcnt_t = i64;
4 pub type socklen_t = u32;
5 pub type sa_family_t = u8;
6 pub type pthread_t = ::uintptr_t;
7 pub type nfds_t = ::c_uint;
8 pub type regoff_t = off_t;
9
10 s! {
11 pub struct sockaddr {
12 pub sa_len: u8,
13 pub sa_family: sa_family_t,
14 pub sa_data: [::c_char; 14],
15 }
16
17 pub struct sockaddr_in6 {
18 pub sin6_len: u8,
19 pub sin6_family: sa_family_t,
20 pub sin6_port: ::in_port_t,
21 pub sin6_flowinfo: u32,
22 pub sin6_addr: ::in6_addr,
23 pub sin6_scope_id: u32,
24 }
25
26 pub struct passwd {
27 pub pw_name: *mut ::c_char,
28 pub pw_passwd: *mut ::c_char,
29 pub pw_uid: ::uid_t,
30 pub pw_gid: ::gid_t,
31 pub pw_change: ::time_t,
32 pub pw_class: *mut ::c_char,
33 pub pw_gecos: *mut ::c_char,
34 pub pw_dir: *mut ::c_char,
35 pub pw_shell: *mut ::c_char,
36 pub pw_expire: ::time_t,
37
38 #[cfg(not(any(target_os = "macos",
39 target_os = "ios",
40 target_os = "tvos",
41 target_os = "watchos",
42 target_os = "visionos",
43 target_os = "netbsd",
44 target_os = "openbsd")))]
45 pub pw_fields: ::c_int,
46 }
47
48 pub struct ifaddrs {
49 pub ifa_next: *mut ifaddrs,
50 pub ifa_name: *mut ::c_char,
51 pub ifa_flags: ::c_uint,
52 pub ifa_addr: *mut ::sockaddr,
53 pub ifa_netmask: *mut ::sockaddr,
54 pub ifa_dstaddr: *mut ::sockaddr,
55 pub ifa_data: *mut ::c_void,
56 #[cfg(target_os = "netbsd")]
57 pub ifa_addrflags: ::c_uint
58 }
59
60 pub struct fd_set {
61 #[cfg(all(target_pointer_width = "64",
62 any(target_os = "freebsd", target_os = "dragonfly")))]
63 fds_bits: [i64; FD_SETSIZE / 64],
64 #[cfg(not(all(target_pointer_width = "64",
65 any(target_os = "freebsd", target_os = "dragonfly"))))]
66 fds_bits: [i32; FD_SETSIZE / 32],
67 }
68
69 pub struct tm {
70 pub tm_sec: ::c_int,
71 pub tm_min: ::c_int,
72 pub tm_hour: ::c_int,
73 pub tm_mday: ::c_int,
74 pub tm_mon: ::c_int,
75 pub tm_year: ::c_int,
76 pub tm_wday: ::c_int,
77 pub tm_yday: ::c_int,
78 pub tm_isdst: ::c_int,
79 pub tm_gmtoff: ::c_long,
80 pub tm_zone: *mut ::c_char,
81 }
82
83 pub struct msghdr {
84 pub msg_name: *mut ::c_void,
85 pub msg_namelen: ::socklen_t,
86 pub msg_iov: *mut ::iovec,
87 pub msg_iovlen: ::c_int,
88 pub msg_control: *mut ::c_void,
89 pub msg_controllen: ::socklen_t,
90 pub msg_flags: ::c_int,
91 }
92
93 pub struct cmsghdr {
94 pub cmsg_len: ::socklen_t,
95 pub cmsg_level: ::c_int,
96 pub cmsg_type: ::c_int,
97 }
98
99 pub struct fsid_t {
100 __fsid_val: [i32; 2],
101 }
102
103 pub struct if_nameindex {
104 pub if_index: ::c_uint,
105 pub if_name: *mut ::c_char,
106 }
107
108 pub struct regex_t {
109 __re_magic: ::c_int,
110 __re_nsub: ::size_t,
111 __re_endp: *const ::c_char,
112 __re_g: *mut ::c_void,
113 }
114
115 pub struct regmatch_t {
116 pub rm_so: regoff_t,
117 pub rm_eo: regoff_t,
118 }
119
120 pub struct option {
121 pub name: *const ::c_char,
122 pub has_arg: ::c_int,
123 pub flag: *mut ::c_int,
124 pub val: ::c_int,
125 }
126 }
127
128 s_no_extra_traits! {
129 pub struct sockaddr_un {
130 pub sun_len: u8,
131 pub sun_family: sa_family_t,
132 pub sun_path: [c_char; 104]
133 }
134
135 pub struct utsname {
136 #[cfg(not(target_os = "dragonfly"))]
137 pub sysname: [::c_char; 256],
138 #[cfg(target_os = "dragonfly")]
139 pub sysname: [::c_char; 32],
140 #[cfg(not(target_os = "dragonfly"))]
141 pub nodename: [::c_char; 256],
142 #[cfg(target_os = "dragonfly")]
143 pub nodename: [::c_char; 32],
144 #[cfg(not(target_os = "dragonfly"))]
145 pub release: [::c_char; 256],
146 #[cfg(target_os = "dragonfly")]
147 pub release: [::c_char; 32],
148 #[cfg(not(target_os = "dragonfly"))]
149 pub version: [::c_char; 256],
150 #[cfg(target_os = "dragonfly")]
151 pub version: [::c_char; 32],
152 #[cfg(not(target_os = "dragonfly"))]
153 pub machine: [::c_char; 256],
154 #[cfg(target_os = "dragonfly")]
155 pub machine: [::c_char; 32],
156 }
157
158 }
159
160 cfg_if! {
161 if #[cfg(feature = "extra_traits")] {
162 impl PartialEq for sockaddr_un {
163 fn eq(&self, other: &sockaddr_un) -> bool {
164 self.sun_len == other.sun_len
165 && self.sun_family == other.sun_family
166 && self
167 .sun_path
168 .iter()
169 .zip(other.sun_path.iter())
170 .all(|(a,b)| a == b)
171 }
172 }
173
174 impl Eq for sockaddr_un {}
175
176 impl ::fmt::Debug for sockaddr_un {
177 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
178 f.debug_struct("sockaddr_un")
179 .field("sun_len", &self.sun_len)
180 .field("sun_family", &self.sun_family)
181 // FIXME: .field("sun_path", &self.sun_path)
182 .finish()
183 }
184 }
185
186 impl ::hash::Hash for sockaddr_un {
187 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
188 self.sun_len.hash(state);
189 self.sun_family.hash(state);
190 self.sun_path.hash(state);
191 }
192 }
193
194 impl PartialEq for utsname {
195 fn eq(&self, other: &utsname) -> bool {
196 self.sysname
197 .iter()
198 .zip(other.sysname.iter())
199 .all(|(a,b)| a == b)
200 && self
201 .nodename
202 .iter()
203 .zip(other.nodename.iter())
204 .all(|(a,b)| a == b)
205 && self
206 .release
207 .iter()
208 .zip(other.release.iter())
209 .all(|(a,b)| a == b)
210 && self
211 .version
212 .iter()
213 .zip(other.version.iter())
214 .all(|(a,b)| a == b)
215 && self
216 .machine
217 .iter()
218 .zip(other.machine.iter())
219 .all(|(a,b)| a == b)
220 }
221 }
222
223 impl Eq for utsname {}
224
225 impl ::fmt::Debug for utsname {
226 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
227 f.debug_struct("utsname")
228 // FIXME: .field("sysname", &self.sysname)
229 // FIXME: .field("nodename", &self.nodename)
230 // FIXME: .field("release", &self.release)
231 // FIXME: .field("version", &self.version)
232 // FIXME: .field("machine", &self.machine)
233 .finish()
234 }
235 }
236
237 impl ::hash::Hash for utsname {
238 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
239 self.sysname.hash(state);
240 self.nodename.hash(state);
241 self.release.hash(state);
242 self.version.hash(state);
243 self.machine.hash(state);
244 }
245 }
246 }
247 }
248
249 pub const LC_ALL: ::c_int = 0;
250 pub const LC_COLLATE: ::c_int = 1;
251 pub const LC_CTYPE: ::c_int = 2;
252 pub const LC_MONETARY: ::c_int = 3;
253 pub const LC_NUMERIC: ::c_int = 4;
254 pub const LC_TIME: ::c_int = 5;
255 pub const LC_MESSAGES: ::c_int = 6;
256
257 pub const FIOCLEX: ::c_ulong = 0x20006601;
258 pub const FIONCLEX: ::c_ulong = 0x20006602;
259 pub const FIONREAD: ::c_ulong = 0x4004667f;
260 pub const FIONBIO: ::c_ulong = 0x8004667e;
261 pub const FIOASYNC: ::c_ulong = 0x8004667d;
262 pub const FIOSETOWN: ::c_ulong = 0x8004667c;
263 pub const FIOGETOWN: ::c_ulong = 0x4004667b;
264
265 pub const PATH_MAX: ::c_int = 1024;
266 pub const MAXPATHLEN: ::c_int = PATH_MAX;
267
268 pub const IOV_MAX: ::c_int = 1024;
269
270 pub const SA_ONSTACK: ::c_int = 0x0001;
271 pub const SA_SIGINFO: ::c_int = 0x0040;
272 pub const SA_RESTART: ::c_int = 0x0002;
273 pub const SA_RESETHAND: ::c_int = 0x0004;
274 pub const SA_NOCLDSTOP: ::c_int = 0x0008;
275 pub const SA_NODEFER: ::c_int = 0x0010;
276 pub const SA_NOCLDWAIT: ::c_int = 0x0020;
277
278 pub const SS_ONSTACK: ::c_int = 1;
279 pub const SS_DISABLE: ::c_int = 4;
280
281 pub const SIGCHLD: ::c_int = 20;
282 pub const SIGBUS: ::c_int = 10;
283 pub const SIGUSR1: ::c_int = 30;
284 pub const SIGUSR2: ::c_int = 31;
285 pub const SIGCONT: ::c_int = 19;
286 pub const SIGSTOP: ::c_int = 17;
287 pub const SIGTSTP: ::c_int = 18;
288 pub const SIGURG: ::c_int = 16;
289 pub const SIGIO: ::c_int = 23;
290 pub const SIGSYS: ::c_int = 12;
291 pub const SIGTTIN: ::c_int = 21;
292 pub const SIGTTOU: ::c_int = 22;
293 pub const SIGXCPU: ::c_int = 24;
294 pub const SIGXFSZ: ::c_int = 25;
295 pub const SIGVTALRM: ::c_int = 26;
296 pub const SIGPROF: ::c_int = 27;
297 pub const SIGWINCH: ::c_int = 28;
298 pub const SIGINFO: ::c_int = 29;
299
300 pub const SIG_SETMASK: ::c_int = 3;
301 pub const SIG_BLOCK: ::c_int = 0x1;
302 pub const SIG_UNBLOCK: ::c_int = 0x2;
303
304 pub const IP_TOS: ::c_int = 3;
305 pub const IP_MULTICAST_IF: ::c_int = 9;
306 pub const IP_MULTICAST_TTL: ::c_int = 10;
307 pub const IP_MULTICAST_LOOP: ::c_int = 11;
308
309 pub const IPV6_UNICAST_HOPS: ::c_int = 4;
310 pub const IPV6_MULTICAST_IF: ::c_int = 9;
311 pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
312 pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
313 pub const IPV6_V6ONLY: ::c_int = 27;
314
315 pub const IPTOS_ECN_NOTECT: u8 = 0x00;
316 pub const IPTOS_ECN_MASK: u8 = 0x03;
317 pub const IPTOS_ECN_ECT1: u8 = 0x01;
318 pub const IPTOS_ECN_ECT0: u8 = 0x02;
319 pub const IPTOS_ECN_CE: u8 = 0x03;
320
321 pub const ST_RDONLY: ::c_ulong = 1;
322
323 pub const SCM_RIGHTS: ::c_int = 0x01;
324
325 pub const NCCS: usize = 20;
326
327 pub const O_ACCMODE: ::c_int = 0x3;
328 pub const O_RDONLY: ::c_int = 0;
329 pub const O_WRONLY: ::c_int = 1;
330 pub const O_RDWR: ::c_int = 2;
331 pub const O_APPEND: ::c_int = 8;
332 pub const O_CREAT: ::c_int = 512;
333 pub const O_TRUNC: ::c_int = 1024;
334 pub const O_EXCL: ::c_int = 2048;
335 pub const O_ASYNC: ::c_int = 0x40;
336 pub const O_SYNC: ::c_int = 0x80;
337 pub const O_NONBLOCK: ::c_int = 0x4;
338 pub const O_NOFOLLOW: ::c_int = 0x100;
339 pub const O_SHLOCK: ::c_int = 0x10;
340 pub const O_EXLOCK: ::c_int = 0x20;
341 pub const O_FSYNC: ::c_int = O_SYNC;
342 pub const O_NDELAY: ::c_int = O_NONBLOCK;
343
344 pub const F_GETOWN: ::c_int = 5;
345 pub const F_SETOWN: ::c_int = 6;
346
347 pub const F_RDLCK: ::c_short = 1;
348 pub const F_UNLCK: ::c_short = 2;
349 pub const F_WRLCK: ::c_short = 3;
350
351 pub const MNT_RDONLY: ::c_int = 0x00000001;
352 pub const MNT_SYNCHRONOUS: ::c_int = 0x00000002;
353 pub const MNT_NOEXEC: ::c_int = 0x00000004;
354 pub const MNT_NOSUID: ::c_int = 0x00000008;
355 pub const MNT_ASYNC: ::c_int = 0x00000040;
356 pub const MNT_EXPORTED: ::c_int = 0x00000100;
357 pub const MNT_UPDATE: ::c_int = 0x00010000;
358 pub const MNT_RELOAD: ::c_int = 0x00040000;
359 pub const MNT_FORCE: ::c_int = 0x00080000;
360
361 pub const Q_SYNC: ::c_int = 0x600;
362 pub const Q_QUOTAON: ::c_int = 0x100;
363 pub const Q_QUOTAOFF: ::c_int = 0x200;
364
365 pub const TCIOFF: ::c_int = 3;
366 pub const TCION: ::c_int = 4;
367 pub const TCOOFF: ::c_int = 1;
368 pub const TCOON: ::c_int = 2;
369 pub const TCIFLUSH: ::c_int = 1;
370 pub const TCOFLUSH: ::c_int = 2;
371 pub const TCIOFLUSH: ::c_int = 3;
372 pub const TCSANOW: ::c_int = 0;
373 pub const TCSADRAIN: ::c_int = 1;
374 pub const TCSAFLUSH: ::c_int = 2;
375 pub const VEOF: usize = 0;
376 pub const VEOL: usize = 1;
377 pub const VEOL2: usize = 2;
378 pub const VERASE: usize = 3;
379 pub const VWERASE: usize = 4;
380 pub const VKILL: usize = 5;
381 pub const VREPRINT: usize = 6;
382 pub const VINTR: usize = 8;
383 pub const VQUIT: usize = 9;
384 pub const VSUSP: usize = 10;
385 pub const VDSUSP: usize = 11;
386 pub const VSTART: usize = 12;
387 pub const VSTOP: usize = 13;
388 pub const VLNEXT: usize = 14;
389 pub const VDISCARD: usize = 15;
390 pub const VMIN: usize = 16;
391 pub const VTIME: usize = 17;
392 pub const VSTATUS: usize = 18;
393 pub const _POSIX_VDISABLE: ::cc_t = 0xff;
394 pub const IGNBRK: ::tcflag_t = 0x00000001;
395 pub const BRKINT: ::tcflag_t = 0x00000002;
396 pub const IGNPAR: ::tcflag_t = 0x00000004;
397 pub const PARMRK: ::tcflag_t = 0x00000008;
398 pub const INPCK: ::tcflag_t = 0x00000010;
399 pub const ISTRIP: ::tcflag_t = 0x00000020;
400 pub const INLCR: ::tcflag_t = 0x00000040;
401 pub const IGNCR: ::tcflag_t = 0x00000080;
402 pub const ICRNL: ::tcflag_t = 0x00000100;
403 pub const IXON: ::tcflag_t = 0x00000200;
404 pub const IXOFF: ::tcflag_t = 0x00000400;
405 pub const IXANY: ::tcflag_t = 0x00000800;
406 pub const IMAXBEL: ::tcflag_t = 0x00002000;
407 pub const OPOST: ::tcflag_t = 0x1;
408 pub const ONLCR: ::tcflag_t = 0x2;
409 pub const OXTABS: ::tcflag_t = 0x4;
410 pub const ONOEOT: ::tcflag_t = 0x8;
411 pub const CIGNORE: ::tcflag_t = 0x00000001;
412 pub const CSIZE: ::tcflag_t = 0x00000300;
413 pub const CS5: ::tcflag_t = 0x00000000;
414 pub const CS6: ::tcflag_t = 0x00000100;
415 pub const CS7: ::tcflag_t = 0x00000200;
416 pub const CS8: ::tcflag_t = 0x00000300;
417 pub const CSTOPB: ::tcflag_t = 0x00000400;
418 pub const CREAD: ::tcflag_t = 0x00000800;
419 pub const PARENB: ::tcflag_t = 0x00001000;
420 pub const PARODD: ::tcflag_t = 0x00002000;
421 pub const HUPCL: ::tcflag_t = 0x00004000;
422 pub const CLOCAL: ::tcflag_t = 0x00008000;
423 pub const ECHOKE: ::tcflag_t = 0x00000001;
424 pub const ECHOE: ::tcflag_t = 0x00000002;
425 pub const ECHOK: ::tcflag_t = 0x00000004;
426 pub const ECHO: ::tcflag_t = 0x00000008;
427 pub const ECHONL: ::tcflag_t = 0x00000010;
428 pub const ECHOPRT: ::tcflag_t = 0x00000020;
429 pub const ECHOCTL: ::tcflag_t = 0x00000040;
430 pub const ISIG: ::tcflag_t = 0x00000080;
431 pub const ICANON: ::tcflag_t = 0x00000100;
432 pub const ALTWERASE: ::tcflag_t = 0x00000200;
433 pub const IEXTEN: ::tcflag_t = 0x00000400;
434 pub const EXTPROC: ::tcflag_t = 0x00000800;
435 pub const TOSTOP: ::tcflag_t = 0x00400000;
436 pub const FLUSHO: ::tcflag_t = 0x00800000;
437 pub const NOKERNINFO: ::tcflag_t = 0x02000000;
438 pub const PENDIN: ::tcflag_t = 0x20000000;
439 pub const NOFLSH: ::tcflag_t = 0x80000000;
440 pub const MDMBUF: ::tcflag_t = 0x00100000;
441
442 pub const WNOHANG: ::c_int = 0x00000001;
443 pub const WUNTRACED: ::c_int = 0x00000002;
444
445 pub const RTLD_LAZY: ::c_int = 0x1;
446 pub const RTLD_NOW: ::c_int = 0x2;
447 pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void;
448 pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
449 pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void;
450
451 pub const LOG_CRON: ::c_int = 9 << 3;
452 pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
453 pub const LOG_FTP: ::c_int = 11 << 3;
454 pub const LOG_PERROR: ::c_int = 0x20;
455
456 pub const TCP_NODELAY: ::c_int = 1;
457 pub const TCP_MAXSEG: ::c_int = 2;
458
459 pub const PIPE_BUF: usize = 512;
460
461 // si_code values for SIGBUS signal
462 pub const BUS_ADRALN: ::c_int = 1;
463 pub const BUS_ADRERR: ::c_int = 2;
464 pub const BUS_OBJERR: ::c_int = 3;
465
466 // si_code values for SIGCHLD signal
467 pub const CLD_EXITED: ::c_int = 1;
468 pub const CLD_KILLED: ::c_int = 2;
469 pub const CLD_DUMPED: ::c_int = 3;
470 pub const CLD_TRAPPED: ::c_int = 4;
471 pub const CLD_STOPPED: ::c_int = 5;
472 pub const CLD_CONTINUED: ::c_int = 6;
473
474 pub const POLLIN: ::c_short = 0x1;
475 pub const POLLPRI: ::c_short = 0x2;
476 pub const POLLOUT: ::c_short = 0x4;
477 pub const POLLERR: ::c_short = 0x8;
478 pub const POLLHUP: ::c_short = 0x10;
479 pub const POLLNVAL: ::c_short = 0x20;
480 pub const POLLRDNORM: ::c_short = 0x040;
481 pub const POLLWRNORM: ::c_short = 0x004;
482 pub const POLLRDBAND: ::c_short = 0x080;
483 pub const POLLWRBAND: ::c_short = 0x100;
484
485 pub const BIOCGBLEN: ::c_ulong = 0x40044266;
486 pub const BIOCSBLEN: ::c_ulong = 0xc0044266;
487 pub const BIOCFLUSH: ::c_uint = 0x20004268;
488 pub const BIOCPROMISC: ::c_uint = 0x20004269;
489 pub const BIOCGDLT: ::c_ulong = 0x4004426a;
490 pub const BIOCGETIF: ::c_ulong = 0x4020426b;
491 pub const BIOCSETIF: ::c_ulong = 0x8020426c;
492 pub const BIOCGSTATS: ::c_ulong = 0x4008426f;
493 pub const BIOCIMMEDIATE: ::c_ulong = 0x80044270;
494 pub const BIOCVERSION: ::c_ulong = 0x40044271;
495 pub const BIOCGHDRCMPLT: ::c_ulong = 0x40044274;
496 pub const BIOCSHDRCMPLT: ::c_ulong = 0x80044275;
497 pub const SIOCGIFADDR: ::c_ulong = 0xc0206921;
498
499 pub const REG_BASIC: ::c_int = 0o0000;
500 pub const REG_EXTENDED: ::c_int = 0o0001;
501 pub const REG_ICASE: ::c_int = 0o0002;
502 pub const REG_NOSUB: ::c_int = 0o0004;
503 pub const REG_NEWLINE: ::c_int = 0o0010;
504 pub const REG_NOSPEC: ::c_int = 0o0020;
505 pub const REG_PEND: ::c_int = 0o0040;
506 pub const REG_DUMP: ::c_int = 0o0200;
507
508 pub const REG_NOMATCH: ::c_int = 1;
509 pub const REG_BADPAT: ::c_int = 2;
510 pub const REG_ECOLLATE: ::c_int = 3;
511 pub const REG_ECTYPE: ::c_int = 4;
512 pub const REG_EESCAPE: ::c_int = 5;
513 pub const REG_ESUBREG: ::c_int = 6;
514 pub const REG_EBRACK: ::c_int = 7;
515 pub const REG_EPAREN: ::c_int = 8;
516 pub const REG_EBRACE: ::c_int = 9;
517 pub const REG_BADBR: ::c_int = 10;
518 pub const REG_ERANGE: ::c_int = 11;
519 pub const REG_ESPACE: ::c_int = 12;
520 pub const REG_BADRPT: ::c_int = 13;
521 pub const REG_EMPTY: ::c_int = 14;
522 pub const REG_ASSERT: ::c_int = 15;
523 pub const REG_INVARG: ::c_int = 16;
524 pub const REG_ATOI: ::c_int = 255;
525 pub const REG_ITOA: ::c_int = 0o0400;
526
527 pub const REG_NOTBOL: ::c_int = 0o00001;
528 pub const REG_NOTEOL: ::c_int = 0o00002;
529 pub const REG_STARTEND: ::c_int = 0o00004;
530 pub const REG_TRACE: ::c_int = 0o00400;
531 pub const REG_LARGE: ::c_int = 0o01000;
532 pub const REG_BACKR: ::c_int = 0o02000;
533
534 pub const TIOCCBRK: ::c_uint = 0x2000747a;
535 pub const TIOCSBRK: ::c_uint = 0x2000747b;
536
537 pub const PRIO_PROCESS: ::c_int = 0;
538 pub const PRIO_PGRP: ::c_int = 1;
539 pub const PRIO_USER: ::c_int = 2;
540
541 pub const ITIMER_REAL: ::c_int = 0;
542 pub const ITIMER_VIRTUAL: ::c_int = 1;
543 pub const ITIMER_PROF: ::c_int = 2;
544
545 f! {
546 pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr {
547 if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() {
548 (*mhdr).msg_control as *mut ::cmsghdr
549 } else {
550 0 as *mut ::cmsghdr
551 }
552 }
553
554 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
555 let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
556 let fd = fd as usize;
557 (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
558 return
559 }
560
561 pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
562 let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
563 let fd = fd as usize;
564 return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
565 }
566
567 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
568 let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
569 let fd = fd as usize;
570 (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
571 return
572 }
573
574 pub fn FD_ZERO(set: *mut fd_set) -> () {
575 for slot in (*set).fds_bits.iter_mut() {
576 *slot = 0;
577 }
578 }
579 }
580
581 safe_f! {
582 pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int {
583 status & 0o177
584 }
585
586 pub {const} fn WIFEXITED(status: ::c_int) -> bool {
587 (status & 0o177) == 0
588 }
589
590 pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int {
591 status >> 8
592 }
593
594 pub {const} fn WCOREDUMP(status: ::c_int) -> bool {
595 (status & 0o200) != 0
596 }
597
598 pub {const} fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
599 (cmd << 8) | (type_ & 0x00ff)
600 }
601 }
602
603 extern "C" {
604 #[cfg_attr(
605 all(target_os = "macos", target_arch = "x86"),
606 link_name = "getrlimit$UNIX2003"
607 )]
608 pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
609 #[cfg_attr(
610 all(target_os = "macos", target_arch = "x86"),
611 link_name = "setrlimit$UNIX2003"
612 )]
613 pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
614
615 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
616 pub fn abs(i: ::c_int) -> ::c_int;
617 pub fn labs(i: ::c_long) -> ::c_long;
618 #[cfg_attr(
619 all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
620 link_name = "rand@FBSD_1.0"
621 )]
622 pub fn rand() -> ::c_int;
623 #[cfg_attr(
624 all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
625 link_name = "srand@FBSD_1.0"
626 )]
627 pub fn srand(seed: ::c_uint);
628
629 pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
630 pub fn freeifaddrs(ifa: *mut ::ifaddrs);
631 pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int;
632 pub fn setlogin(name: *const ::c_char) -> ::c_int;
633 pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
634 pub fn kqueue() -> ::c_int;
635 pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
636 pub fn syscall(num: ::c_int, ...) -> ::c_int;
637 #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
638 pub fn getpwent() -> *mut passwd;
639 pub fn setpwent();
640 pub fn endpwent();
641 pub fn endgrent();
642 pub fn getgrent() -> *mut ::group;
643
644 pub fn getprogname() -> *const ::c_char;
645 pub fn setprogname(name: *const ::c_char);
646 pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
647 pub fn if_nameindex() -> *mut if_nameindex;
648 pub fn if_freenameindex(ptr: *mut if_nameindex);
649
650 pub fn getpeereid(socket: ::c_int, euid: *mut ::uid_t, egid: *mut ::gid_t) -> ::c_int;
651
652 #[cfg_attr(
653 all(target_os = "macos", not(target_arch = "aarch64")),
654 link_name = "glob$INODE64"
655 )]
656 #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
657 #[cfg_attr(
658 all(target_os = "freebsd", any(freebsd11, freebsd10)),
659 link_name = "glob@FBSD_1.0"
660 )]
661 pub fn glob(
662 pattern: *const ::c_char,
663 flags: ::c_int,
664 errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
665 pglob: *mut ::glob_t,
666 ) -> ::c_int;
667 #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
668 #[cfg_attr(
669 all(target_os = "freebsd", any(freebsd11, freebsd10)),
670 link_name = "globfree@FBSD_1.0"
671 )]
672 pub fn globfree(pglob: *mut ::glob_t);
673
674 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
675
676 pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
677
678 #[cfg_attr(
679 all(target_os = "macos", target_arch = "x86_64"),
680 link_name = "seekdir$INODE64"
681 )]
682 #[cfg_attr(
683 all(target_os = "macos", target_arch = "x86"),
684 link_name = "seekdir$INODE64$UNIX2003"
685 )]
686 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
687
688 #[cfg_attr(
689 all(target_os = "macos", target_arch = "x86_64"),
690 link_name = "telldir$INODE64"
691 )]
692 #[cfg_attr(
693 all(target_os = "macos", target_arch = "x86"),
694 link_name = "telldir$INODE64$UNIX2003"
695 )]
696 pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
697 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
698
699 #[cfg_attr(
700 all(target_os = "macos", target_arch = "x86"),
701 link_name = "msync$UNIX2003"
702 )]
703 #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
704 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
705
706 #[cfg_attr(
707 all(target_os = "macos", target_arch = "x86"),
708 link_name = "recvfrom$UNIX2003"
709 )]
710 pub fn recvfrom(
711 socket: ::c_int,
712 buf: *mut ::c_void,
713 len: ::size_t,
714 flags: ::c_int,
715 addr: *mut ::sockaddr,
716 addrlen: *mut ::socklen_t,
717 ) -> ::ssize_t;
718 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
719 #[cfg_attr(target_os = "netbsd", link_name = "__futimes50")]
720 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
721 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
722
723 #[cfg_attr(
724 all(target_os = "macos", target_arch = "x86"),
725 link_name = "bind$UNIX2003"
726 )]
727 pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int;
728
729 #[cfg_attr(
730 all(target_os = "macos", target_arch = "x86"),
731 link_name = "writev$UNIX2003"
732 )]
733 pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
734 #[cfg_attr(
735 all(target_os = "macos", target_arch = "x86"),
736 link_name = "readv$UNIX2003"
737 )]
738 pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
739
740 #[cfg_attr(
741 all(target_os = "macos", target_arch = "x86"),
742 link_name = "sendmsg$UNIX2003"
743 )]
744 pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
745 #[cfg_attr(
746 all(target_os = "macos", target_arch = "x86"),
747 link_name = "recvmsg$UNIX2003"
748 )]
749 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
750
751 pub fn sync();
752 pub fn getgrgid_r(
753 gid: ::gid_t,
754 grp: *mut ::group,
755 buf: *mut ::c_char,
756 buflen: ::size_t,
757 result: *mut *mut ::group,
758 ) -> ::c_int;
759 #[cfg_attr(
760 all(target_os = "macos", target_arch = "x86"),
761 link_name = "sigaltstack$UNIX2003"
762 )]
763 #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
764 pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int;
765 pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
766 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
767 pub fn getdtablesize() -> ::c_int;
768 pub fn getgrnam_r(
769 name: *const ::c_char,
770 grp: *mut ::group,
771 buf: *mut ::c_char,
772 buflen: ::size_t,
773 result: *mut *mut ::group,
774 ) -> ::c_int;
775 #[cfg_attr(
776 all(target_os = "macos", target_arch = "x86"),
777 link_name = "pthread_sigmask$UNIX2003"
778 )]
779 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int;
780 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
781 pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
782 #[cfg_attr(
783 all(target_os = "macos", target_arch = "x86"),
784 link_name = "pthread_cancel$UNIX2003"
785 )]
786 pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
787 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
788 pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
789 pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
790 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
791 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
792 pub fn getpwnam_r(
793 name: *const ::c_char,
794 pwd: *mut passwd,
795 buf: *mut ::c_char,
796 buflen: ::size_t,
797 result: *mut *mut passwd,
798 ) -> ::c_int;
799 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
800 pub fn getpwuid_r(
801 uid: ::uid_t,
802 pwd: *mut passwd,
803 buf: *mut ::c_char,
804 buflen: ::size_t,
805 result: *mut *mut passwd,
806 ) -> ::c_int;
807 #[cfg_attr(
808 all(target_os = "macos", target_arch = "x86"),
809 link_name = "sigwait$UNIX2003"
810 )]
811 pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int;
812 pub fn pthread_atfork(
813 prepare: ::Option<unsafe extern "C" fn()>,
814 parent: ::Option<unsafe extern "C" fn()>,
815 child: ::Option<unsafe extern "C" fn()>,
816 ) -> ::c_int;
817 pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
818 #[cfg_attr(
819 all(target_os = "macos", target_arch = "x86"),
820 link_name = "popen$UNIX2003"
821 )]
822 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
823 pub fn faccessat(
824 dirfd: ::c_int,
825 pathname: *const ::c_char,
826 mode: ::c_int,
827 flags: ::c_int,
828 ) -> ::c_int;
829 pub fn pthread_create(
830 native: *mut ::pthread_t,
831 attr: *const ::pthread_attr_t,
832 f: extern "C" fn(*mut ::c_void) -> *mut ::c_void,
833 value: *mut ::c_void,
834 ) -> ::c_int;
835 pub fn acct(filename: *const ::c_char) -> ::c_int;
836 #[cfg_attr(
837 all(target_os = "macos", target_arch = "x86"),
838 link_name = "wait4$UNIX2003"
839 )]
840 #[cfg_attr(
841 all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
842 link_name = "wait4@FBSD_1.0"
843 )]
844 pub fn wait4(
845 pid: ::pid_t,
846 status: *mut ::c_int,
847 options: ::c_int,
848 rusage: *mut ::rusage,
849 ) -> ::pid_t;
850 #[cfg_attr(
851 all(target_os = "macos", target_arch = "x86"),
852 link_name = "getitimer$UNIX2003"
853 )]
854 pub fn getitimer(which: ::c_int, curr_value: *mut ::itimerval) -> ::c_int;
855 #[cfg_attr(
856 all(target_os = "macos", target_arch = "x86"),
857 link_name = "setitimer$UNIX2003"
858 )]
859 pub fn setitimer(
860 which: ::c_int,
861 new_value: *const ::itimerval,
862 old_value: *mut ::itimerval,
863 ) -> ::c_int;
864
865 pub fn regcomp(preg: *mut regex_t, pattern: *const ::c_char, cflags: ::c_int) -> ::c_int;
866
867 pub fn regexec(
868 preg: *const regex_t,
869 input: *const ::c_char,
870 nmatch: ::size_t,
871 pmatch: *mut regmatch_t,
872 eflags: ::c_int,
873 ) -> ::c_int;
874
875 pub fn regerror(
876 errcode: ::c_int,
877 preg: *const regex_t,
878 errbuf: *mut ::c_char,
879 errbuf_size: ::size_t,
880 ) -> ::size_t;
881
882 pub fn regfree(preg: *mut regex_t);
883
884 pub fn arc4random() -> u32;
885 pub fn arc4random_buf(buf: *mut ::c_void, size: ::size_t);
886 pub fn arc4random_uniform(l: u32) -> u32;
887
888 pub fn drand48() -> ::c_double;
889 pub fn erand48(xseed: *mut ::c_ushort) -> ::c_double;
890 pub fn lrand48() -> ::c_long;
891 pub fn nrand48(xseed: *mut ::c_ushort) -> ::c_long;
892 pub fn mrand48() -> ::c_long;
893 pub fn jrand48(xseed: *mut ::c_ushort) -> ::c_long;
894 pub fn srand48(seed: ::c_long);
895 pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort;
896 pub fn lcong48(p: *mut ::c_ushort);
897 pub fn getopt_long(
898 argc: ::c_int,
899 argv: *const *mut c_char,
900 optstring: *const c_char,
901 longopts: *const option,
902 longindex: *mut ::c_int,
903 ) -> ::c_int;
904
905 pub fn strftime(
906 buf: *mut ::c_char,
907 maxsize: ::size_t,
908 format: *const ::c_char,
909 timeptr: *const ::tm,
910 ) -> ::size_t;
911 pub fn strftime_l(
912 buf: *mut ::c_char,
913 maxsize: ::size_t,
914 format: *const ::c_char,
915 timeptr: *const ::tm,
916 locale: ::locale_t,
917 ) -> ::size_t;
918 }
919
920 cfg_if! {
921 if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] {
922 mod apple;
923 pub use self::apple::*;
924 } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] {
925 mod netbsdlike;
926 pub use self::netbsdlike::*;
927 } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] {
928 mod freebsdlike;
929 pub use self::freebsdlike::*;
930 } else {
931 // Unknown target_os
932 }
933 }