]> git.proxmox.com Git - rustc.git/blame - src/liblibc/src/unix/bsd/mod.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / liblibc / src / unix / bsd / mod.rs
CommitLineData
cc61c64b 1use dox::{mem, Option};
7453a54e 2
92a42be0
SL
3pub type c_char = i8;
4pub type wchar_t = i32;
5pub type off_t = i64;
6pub type useconds_t = u32;
7pub type blkcnt_t = i64;
8pub type socklen_t = u32;
9pub type sa_family_t = u8;
10pub type pthread_t = ::uintptr_t;
9cc50fc6 11pub type nfds_t = ::c_uint;
92a42be0
SL
12
13s! {
14 pub struct sockaddr {
15 pub sa_len: u8,
16 pub sa_family: sa_family_t,
17 pub sa_data: [::c_char; 14],
18 }
19
92a42be0
SL
20 pub struct sockaddr_in6 {
21 pub sin6_len: u8,
22 pub sin6_family: sa_family_t,
23 pub sin6_port: ::in_port_t,
24 pub sin6_flowinfo: u32,
25 pub sin6_addr: ::in6_addr,
26 pub sin6_scope_id: u32,
27 }
28
29 pub struct sockaddr_un {
30 pub sun_len: u8,
31 pub sun_family: sa_family_t,
32 pub sun_path: [c_char; 104]
33 }
34
35 pub struct passwd {
36 pub pw_name: *mut ::c_char,
37 pub pw_passwd: *mut ::c_char,
38 pub pw_uid: ::uid_t,
39 pub pw_gid: ::gid_t,
40 pub pw_change: ::time_t,
41 pub pw_class: *mut ::c_char,
42 pub pw_gecos: *mut ::c_char,
43 pub pw_dir: *mut ::c_char,
44 pub pw_shell: *mut ::c_char,
45 pub pw_expire: ::time_t,
46
9cc50fc6
SL
47 #[cfg(not(any(target_os = "macos",
48 target_os = "ios",
49 target_os = "netbsd",
50 target_os = "openbsd")))]
92a42be0
SL
51 pub pw_fields: ::c_int,
52 }
53
54 pub struct ifaddrs {
55 pub ifa_next: *mut ifaddrs,
56 pub ifa_name: *mut ::c_char,
57 pub ifa_flags: ::c_uint,
58 pub ifa_addr: *mut ::sockaddr,
59 pub ifa_netmask: *mut ::sockaddr,
60 pub ifa_dstaddr: *mut ::sockaddr,
61 pub ifa_data: *mut ::c_void
62 }
63
64 pub struct fd_set {
7453a54e 65 #[cfg(all(target_pointer_width = "64",
54a0048b 66 any(target_os = "freebsd", target_os = "dragonfly")))]
7453a54e
SL
67 fds_bits: [i64; FD_SETSIZE / 64],
68 #[cfg(not(all(target_pointer_width = "64",
54a0048b 69 any(target_os = "freebsd", target_os = "dragonfly"))))]
92a42be0
SL
70 fds_bits: [i32; FD_SETSIZE / 32],
71 }
72
73 pub struct tm {
74 pub tm_sec: ::c_int,
75 pub tm_min: ::c_int,
76 pub tm_hour: ::c_int,
77 pub tm_mday: ::c_int,
78 pub tm_mon: ::c_int,
79 pub tm_year: ::c_int,
80 pub tm_wday: ::c_int,
81 pub tm_yday: ::c_int,
82 pub tm_isdst: ::c_int,
83 pub tm_gmtoff: ::c_long,
84 pub tm_zone: *mut ::c_char,
85 }
9cc50fc6
SL
86
87 pub struct utsname {
54a0048b 88 #[cfg(not(target_os = "dragonfly"))]
9cc50fc6 89 pub sysname: [::c_char; 256],
54a0048b
SL
90 #[cfg(target_os = "dragonfly")]
91 pub sysname: [::c_char; 32],
92 #[cfg(not(target_os = "dragonfly"))]
9cc50fc6 93 pub nodename: [::c_char; 256],
54a0048b
SL
94 #[cfg(target_os = "dragonfly")]
95 pub nodename: [::c_char; 32],
96 #[cfg(not(target_os = "dragonfly"))]
9cc50fc6 97 pub release: [::c_char; 256],
54a0048b
SL
98 #[cfg(target_os = "dragonfly")]
99 pub release: [::c_char; 32],
100 #[cfg(not(target_os = "dragonfly"))]
9cc50fc6 101 pub version: [::c_char; 256],
54a0048b
SL
102 #[cfg(target_os = "dragonfly")]
103 pub version: [::c_char; 32],
104 #[cfg(not(target_os = "dragonfly"))]
9cc50fc6 105 pub machine: [::c_char; 256],
54a0048b
SL
106 #[cfg(target_os = "dragonfly")]
107 pub machine: [::c_char; 32],
9cc50fc6
SL
108 }
109
110 pub struct msghdr {
111 pub msg_name: *mut ::c_void,
112 pub msg_namelen: ::socklen_t,
113 pub msg_iov: *mut ::iovec,
114 pub msg_iovlen: ::c_int,
115 pub msg_control: *mut ::c_void,
116 pub msg_controllen: ::socklen_t,
117 pub msg_flags: ::c_int,
118 }
119
32a655c1
SL
120 pub struct cmsghdr {
121 pub cmsg_len: ::socklen_t,
122 pub cmsg_level: ::c_int,
123 pub cmsg_type: ::c_int,
124 }
125
9cc50fc6
SL
126 pub struct fsid_t {
127 __fsid_val: [::int32_t; 2],
128 }
5bcae85e
SL
129
130 pub struct if_nameindex {
131 pub if_index: ::c_uint,
132 pub if_name: *mut ::c_char,
133 }
92a42be0
SL
134}
135
54a0048b
SL
136pub const LC_ALL: ::c_int = 0;
137pub const LC_COLLATE: ::c_int = 1;
138pub const LC_CTYPE: ::c_int = 2;
139pub const LC_MONETARY: ::c_int = 3;
140pub const LC_NUMERIC: ::c_int = 4;
141pub const LC_TIME: ::c_int = 5;
142pub const LC_MESSAGES: ::c_int = 6;
143
92a42be0
SL
144pub const FIOCLEX: ::c_ulong = 0x20006601;
145pub const FIONBIO: ::c_ulong = 0x8004667e;
146
9cc50fc6
SL
147pub const PATH_MAX: ::c_int = 1024;
148
92a42be0
SL
149pub const SA_ONSTACK: ::c_int = 0x0001;
150pub const SA_SIGINFO: ::c_int = 0x0040;
151pub const SA_RESTART: ::c_int = 0x0002;
152pub const SA_RESETHAND: ::c_int = 0x0004;
153pub const SA_NOCLDSTOP: ::c_int = 0x0008;
154pub const SA_NODEFER: ::c_int = 0x0010;
155pub const SA_NOCLDWAIT: ::c_int = 0x0020;
156
7453a54e
SL
157pub const SS_ONSTACK: ::c_int = 1;
158pub const SS_DISABLE: ::c_int = 4;
159
92a42be0
SL
160pub const SIGCHLD: ::c_int = 20;
161pub const SIGBUS: ::c_int = 10;
9cc50fc6
SL
162pub const SIGUSR1: ::c_int = 30;
163pub const SIGUSR2: ::c_int = 31;
164pub const SIGCONT: ::c_int = 19;
165pub const SIGSTOP: ::c_int = 17;
166pub const SIGTSTP: ::c_int = 18;
167pub const SIGURG: ::c_int = 16;
168pub const SIGIO: ::c_int = 23;
169pub const SIGSYS: ::c_int = 12;
170pub const SIGTTIN: ::c_int = 21;
171pub const SIGTTOU: ::c_int = 22;
172pub const SIGXCPU: ::c_int = 24;
173pub const SIGXFSZ: ::c_int = 25;
174pub const SIGVTALRM: ::c_int = 26;
175pub const SIGPROF: ::c_int = 27;
176pub const SIGWINCH: ::c_int = 28;
a7813a04 177pub const SIGINFO: ::c_int = 29;
9cc50fc6 178
92a42be0 179pub const SIG_SETMASK: ::c_int = 3;
9cc50fc6
SL
180pub const SIG_BLOCK: ::c_int = 0x1;
181pub const SIG_UNBLOCK: ::c_int = 0x2;
92a42be0 182
3b2f2976
XL
183pub const IP_MULTICAST_IF: ::c_int = 9;
184pub const IP_MULTICAST_TTL: ::c_int = 10;
185pub const IP_MULTICAST_LOOP: ::c_int = 11;
186
92a42be0
SL
187pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
188pub const IPV6_V6ONLY: ::c_int = 27;
189
92a42be0 190pub const ST_RDONLY: ::c_ulong = 1;
92a42be0 191
3b2f2976
XL
192pub const SCM_RIGHTS: ::c_int = 0x01;
193
9cc50fc6
SL
194pub const NCCS: usize = 20;
195
3b2f2976
XL
196pub const O_ACCMODE: ::c_int = 0x3;
197pub const O_RDONLY: ::c_int = 0;
198pub const O_WRONLY: ::c_int = 1;
199pub const O_RDWR: ::c_int = 2;
200pub const O_APPEND: ::c_int = 8;
201pub const O_CREAT: ::c_int = 512;
202pub const O_TRUNC: ::c_int = 1024;
203pub const O_EXCL: ::c_int = 2048;
9cc50fc6 204pub const O_ASYNC: ::c_int = 0x40;
3b2f2976
XL
205pub const O_SYNC: ::c_int = 0x80;
206pub const O_NONBLOCK: ::c_int = 0x4;
9cc50fc6 207pub const O_NOFOLLOW: ::c_int = 0x100;
3b2f2976
XL
208pub const O_SHLOCK: ::c_int = 0x10;
209pub const O_EXLOCK: ::c_int = 0x20;
210pub const O_FSYNC: ::c_int = O_SYNC;
211pub const O_NDELAY: ::c_int = O_NONBLOCK;
9cc50fc6 212
9cc50fc6 213pub const F_GETOWN: ::c_int = 5;
9cc50fc6
SL
214pub const F_SETOWN: ::c_int = 6;
215
216pub const MNT_FORCE: ::c_int = 0x80000;
217
218pub const Q_SYNC: ::c_int = 0x600;
219pub const Q_QUOTAON: ::c_int = 0x100;
220pub const Q_QUOTAOFF: ::c_int = 0x200;
9cc50fc6
SL
221
222pub const TCIOFF: ::c_int = 3;
223pub const TCION: ::c_int = 4;
224pub const TCOOFF: ::c_int = 1;
225pub const TCOON: ::c_int = 2;
226pub const TCIFLUSH: ::c_int = 1;
227pub const TCOFLUSH: ::c_int = 2;
228pub const TCIOFLUSH: ::c_int = 3;
229pub const TCSANOW: ::c_int = 0;
230pub const TCSADRAIN: ::c_int = 1;
231pub const TCSAFLUSH: ::c_int = 2;
9cc50fc6
SL
232pub const VEOF: usize = 0;
233pub const VEOL: usize = 1;
234pub const VEOL2: usize = 2;
235pub const VERASE: usize = 3;
236pub const VWERASE: usize = 4;
237pub const VKILL: usize = 5;
238pub const VREPRINT: usize = 6;
239pub const VINTR: usize = 8;
240pub const VQUIT: usize = 9;
241pub const VSUSP: usize = 10;
3b2f2976 242pub const VDSUSP: usize = 11;
9cc50fc6
SL
243pub const VSTART: usize = 12;
244pub const VSTOP: usize = 13;
245pub const VLNEXT: usize = 14;
246pub const VDISCARD: usize = 15;
247pub const VMIN: usize = 16;
248pub const VTIME: usize = 17;
3b2f2976
XL
249pub const VSTATUS: usize = 18;
250pub const _POSIX_VDISABLE: ::cc_t = 0xff;
9cc50fc6
SL
251pub const IGNBRK: ::tcflag_t = 0x00000001;
252pub const BRKINT: ::tcflag_t = 0x00000002;
253pub const IGNPAR: ::tcflag_t = 0x00000004;
254pub const PARMRK: ::tcflag_t = 0x00000008;
255pub const INPCK: ::tcflag_t = 0x00000010;
256pub const ISTRIP: ::tcflag_t = 0x00000020;
257pub const INLCR: ::tcflag_t = 0x00000040;
258pub const IGNCR: ::tcflag_t = 0x00000080;
259pub const ICRNL: ::tcflag_t = 0x00000100;
260pub const IXON: ::tcflag_t = 0x00000200;
261pub const IXOFF: ::tcflag_t = 0x00000400;
262pub const IXANY: ::tcflag_t = 0x00000800;
263pub const IMAXBEL: ::tcflag_t = 0x00002000;
264pub const OPOST: ::tcflag_t = 0x1;
265pub const ONLCR: ::tcflag_t = 0x2;
cc61c64b
XL
266pub const OXTABS: ::tcflag_t = 0x4;
267pub const ONOEOT: ::tcflag_t = 0x8;
3b2f2976 268pub const CIGNORE: ::tcflag_t = 0x00000001;
9cc50fc6
SL
269pub const CSIZE: ::tcflag_t = 0x00000300;
270pub const CS5: ::tcflag_t = 0x00000000;
271pub const CS6: ::tcflag_t = 0x00000100;
272pub const CS7: ::tcflag_t = 0x00000200;
273pub const CS8: ::tcflag_t = 0x00000300;
274pub const CSTOPB: ::tcflag_t = 0x00000400;
275pub const CREAD: ::tcflag_t = 0x00000800;
276pub const PARENB: ::tcflag_t = 0x00001000;
277pub const PARODD: ::tcflag_t = 0x00002000;
278pub const HUPCL: ::tcflag_t = 0x00004000;
279pub const CLOCAL: ::tcflag_t = 0x00008000;
280pub const ECHOKE: ::tcflag_t = 0x00000001;
281pub const ECHOE: ::tcflag_t = 0x00000002;
282pub const ECHOK: ::tcflag_t = 0x00000004;
283pub const ECHO: ::tcflag_t = 0x00000008;
284pub const ECHONL: ::tcflag_t = 0x00000010;
285pub const ECHOPRT: ::tcflag_t = 0x00000020;
286pub const ECHOCTL: ::tcflag_t = 0x00000040;
287pub const ISIG: ::tcflag_t = 0x00000080;
288pub const ICANON: ::tcflag_t = 0x00000100;
3b2f2976 289pub const ALTWERASE: ::tcflag_t = 0x00000200;
9cc50fc6
SL
290pub const IEXTEN: ::tcflag_t = 0x00000400;
291pub const EXTPROC: ::tcflag_t = 0x00000800;
292pub const TOSTOP: ::tcflag_t = 0x00400000;
293pub const FLUSHO: ::tcflag_t = 0x00800000;
3b2f2976 294pub const NOKERNINFO: ::tcflag_t = 0x02000000;
9cc50fc6
SL
295pub const PENDIN: ::tcflag_t = 0x20000000;
296pub const NOFLSH: ::tcflag_t = 0x80000000;
3b2f2976 297pub const MDMBUF: ::tcflag_t = 0x00100000;
92a42be0 298
5bcae85e
SL
299pub const WNOHANG: ::c_int = 0x00000001;
300pub const WUNTRACED: ::c_int = 0x00000002;
7453a54e 301
abe05a73 302pub const RTLD_LAZY: ::c_int = 0x1;
7453a54e 303pub const RTLD_NOW: ::c_int = 0x2;
7cac9316 304pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void;
54a0048b 305pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
7cac9316 306pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void;
7453a54e 307
a7813a04
XL
308pub const LOG_CRON: ::c_int = 9 << 3;
309pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
310pub const LOG_FTP: ::c_int = 11 << 3;
311pub const LOG_PERROR: ::c_int = 0x20;
312
3b2f2976
XL
313pub const TCP_MAXSEG: ::c_int = 2;
314
a7813a04
XL
315pub const PIPE_BUF: usize = 512;
316
abe05a73
XL
317pub const POLLIN: ::c_short = 0x1;
318pub const POLLPRI: ::c_short = 0x2;
319pub const POLLOUT: ::c_short = 0x4;
320pub const POLLERR: ::c_short = 0x8;
321pub const POLLHUP: ::c_short = 0x10;
322pub const POLLNVAL: ::c_short = 0x20;
3b2f2976
XL
323pub const POLLRDNORM: ::c_short = 0x040;
324pub const POLLWRNORM: ::c_short = 0x004;
325pub const POLLRDBAND: ::c_short = 0x080;
326pub const POLLWRBAND: ::c_short = 0x100;
327
92a42be0
SL
328f! {
329 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
7453a54e 330 let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
92a42be0 331 let fd = fd as usize;
7453a54e 332 (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
92a42be0
SL
333 return
334 }
335
336 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
7453a54e 337 let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
92a42be0 338 let fd = fd as usize;
7453a54e 339 return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
92a42be0
SL
340 }
341
342 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
7453a54e 343 let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
92a42be0 344 let fd = fd as usize;
7453a54e 345 (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
92a42be0
SL
346 return
347 }
348
349 pub fn FD_ZERO(set: *mut fd_set) -> () {
350 for slot in (*set).fds_bits.iter_mut() {
351 *slot = 0;
352 }
353 }
354
5bcae85e
SL
355 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
356 status & 0o177
357 }
358
92a42be0 359 pub fn WIFEXITED(status: ::c_int) -> bool {
5bcae85e 360 (status & 0o177) == 0
92a42be0
SL
361 }
362
363 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
364 status >> 8
365 }
366
a7813a04
XL
367 pub fn WCOREDUMP(status: ::c_int) -> bool {
368 (status & 0o200) != 0
369 }
3b2f2976
XL
370
371 pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
372 (cmd << 8) | (type_ & 0x00ff)
373 }
92a42be0
SL
374}
375
376extern {
9e0c209e
SL
377 pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
378 pub fn freeifaddrs(ifa: *mut ::ifaddrs);
92a42be0
SL
379 pub fn setgroups(ngroups: ::c_int,
380 ptr: *const ::gid_t) -> ::c_int;
381 pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
9cc50fc6
SL
382 pub fn kqueue() -> ::c_int;
383 pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
384 pub fn syscall(num: ::c_int, ...) -> ::c_int;
9e0c209e
SL
385 #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
386 pub fn getpwent() -> *mut passwd;
387 pub fn setpwent();
3b2f2976 388 pub fn endpwent();
a7813a04
XL
389 pub fn getprogname() -> *const ::c_char;
390 pub fn setprogname(name: *const ::c_char);
391 pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
5bcae85e
SL
392 pub fn if_nameindex() -> *mut if_nameindex;
393 pub fn if_freenameindex(ptr: *mut if_nameindex);
8bb4bdeb
XL
394
395 pub fn getpeereid(socket: ::c_int,
396 euid: *mut ::uid_t,
397 egid: *mut ::gid_t) -> ::c_int;
cc61c64b
XL
398
399 #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
400 #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
401 pub fn glob(pattern: *const ::c_char,
402 flags: ::c_int,
403 errfunc: Option<extern fn(epath: *const ::c_char,
404 errno: ::c_int) -> ::c_int>,
405 pglob: *mut ::glob_t) -> ::c_int;
406 #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
407 pub fn globfree(pglob: *mut ::glob_t);
408
409 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
410 -> ::c_int;
411
412 pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
413
414 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
415 link_name = "seekdir$INODE64")]
416 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
417 link_name = "seekdir$INODE64$UNIX2003")]
418 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
419
420 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
421 link_name = "telldir$INODE64")]
422 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
423 link_name = "telldir$INODE64$UNIX2003")]
424 pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
425 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
426 -> ::c_int;
427
428 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
429 link_name = "msync$UNIX2003")]
430 #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
431 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
432
433 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
434 link_name = "recvfrom$UNIX2003")]
435 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
436 flags: ::c_int, addr: *mut ::sockaddr,
437 addrlen: *mut ::socklen_t) -> ::ssize_t;
438 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
439 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
440 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
441
442 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
443 link_name = "bind$UNIX2003")]
444 pub fn bind(socket: ::c_int, address: *const ::sockaddr,
445 address_len: ::socklen_t) -> ::c_int;
446
447 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
448 link_name = "writev$UNIX2003")]
449 pub fn writev(fd: ::c_int,
450 iov: *const ::iovec,
451 iovcnt: ::c_int) -> ::ssize_t;
452 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
453 link_name = "readv$UNIX2003")]
454 pub fn readv(fd: ::c_int,
455 iov: *const ::iovec,
456 iovcnt: ::c_int) -> ::ssize_t;
457
458 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
459 link_name = "sendmsg$UNIX2003")]
460 pub fn sendmsg(fd: ::c_int,
461 msg: *const ::msghdr,
462 flags: ::c_int) -> ::ssize_t;
463 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
464 link_name = "recvmsg$UNIX2003")]
465 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
466 -> ::ssize_t;
041b39d2
XL
467
468 pub fn sync();
3b2f2976
XL
469 #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
470 pub fn getgrgid_r(uid: ::uid_t,
471 grp: *mut ::group,
472 buf: *mut ::c_char,
473 buflen: ::size_t,
474 result: *mut *mut ::group) -> ::c_int;
475 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
476 link_name = "sigaltstack$UNIX2003")]
477 #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
478 pub fn sigaltstack(ss: *const stack_t,
479 oss: *mut stack_t) -> ::c_int;
480 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
481 pub fn getdtablesize() -> ::c_int;
482 #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
483 pub fn getgrnam_r(name: *const ::c_char,
484 grp: *mut ::group,
485 buf: *mut ::c_char,
486 buflen: ::size_t,
487 result: *mut *mut ::group) -> ::c_int;
488 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
489 link_name = "pthread_sigmask$UNIX2003")]
490 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
491 oldset: *mut sigset_t) -> ::c_int;
492 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
493 pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
abe05a73
XL
494 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
495 link_name = "pthread_cancel$UNIX2003")]
496 pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
3b2f2976
XL
497 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
498 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
499 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
500 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
501 #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
502 pub fn getpwnam_r(name: *const ::c_char,
503 pwd: *mut passwd,
504 buf: *mut ::c_char,
505 buflen: ::size_t,
506 result: *mut *mut passwd) -> ::c_int;
507 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
508 #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
509 pub fn getpwuid_r(uid: ::uid_t,
510 pwd: *mut passwd,
511 buf: *mut ::c_char,
512 buflen: ::size_t,
513 result: *mut *mut passwd) -> ::c_int;
514 #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
515 link_name = "sigwait$UNIX2003")]
516 #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
517 pub fn sigwait(set: *const sigset_t,
518 sig: *mut ::c_int) -> ::c_int;
519 pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
520 parent: Option<unsafe extern fn()>,
521 child: Option<unsafe extern fn()>) -> ::c_int;
522 pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
523 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
524 link_name = "popen$UNIX2003")]
525 pub fn popen(command: *const c_char,
526 mode: *const c_char) -> *mut ::FILE;
527 pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
528 mode: ::c_int, flags: ::c_int) -> ::c_int;
529 pub fn pthread_create(native: *mut ::pthread_t,
530 attr: *const ::pthread_attr_t,
531 f: extern fn(*mut ::c_void) -> *mut ::c_void,
532 value: *mut ::c_void) -> ::c_int;
92a42be0
SL
533}
534
535cfg_if! {
536 if #[cfg(any(target_os = "macos", target_os = "ios"))] {
537 mod apple;
538 pub use self::apple::*;
539 } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd",
540 target_os = "bitrig"))] {
9e0c209e
SL
541 mod netbsdlike;
542 pub use self::netbsdlike::*;
92a42be0
SL
543 } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] {
544 mod freebsdlike;
545 pub use self::freebsdlike::*;
546 } else {
54a0048b 547 // Unknown target_os
92a42be0
SL
548 }
549}