blob: 3ffb3b79cf9d205ec9e1c7471fe91e9bffdbd5c9 [file] [log] [blame]
Alex Crichtond3d77922015-09-11 17:03:39 -07001//! Definitions found commonly among almost all Unix derivatives
2//!
3//! More functions and definitions can be found in the more specific modules
4//! according to the platform in question.
5
Alex Crichton8a8bc662016-02-29 23:02:36 -08006use dox::Option;
7
Alex Crichtonc674e372015-09-18 16:22:00 -07008pub type pid_t = i32;
9pub type uid_t = u32;
10pub type gid_t = u32;
11pub type in_addr_t = u32;
12pub type in_port_t = u16;
Alex Crichton17910462015-09-22 19:11:04 -070013pub type sighandler_t = ::size_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -080014pub type cc_t = ::c_uchar;
Alex Crichtonc674e372015-09-18 16:22:00 -070015
Alex Crichtond6e07e22015-10-29 22:59:44 -070016pub enum DIR {}
17
Alex Crichton084f9ea2015-09-11 15:11:59 -070018s! {
19 pub struct utimbuf {
Alex Crichton50a42e22015-09-15 14:27:15 -070020 pub actime: time_t,
21 pub modtime: time_t,
22 }
23
24 pub struct timeval {
25 pub tv_sec: time_t,
26 pub tv_usec: suseconds_t,
27 }
28
29 pub struct timespec {
30 pub tv_sec: time_t,
31 pub tv_nsec: c_long,
32 }
33
34 pub struct rlimit {
35 pub rlim_cur: rlim_t,
36 pub rlim_max: rlim_t,
37 }
38
39 pub struct rusage {
40 pub ru_utime: timeval,
41 pub ru_stime: timeval,
42 pub ru_maxrss: c_long,
43 pub ru_ixrss: c_long,
44 pub ru_idrss: c_long,
45 pub ru_isrss: c_long,
46 pub ru_minflt: c_long,
47 pub ru_majflt: c_long,
48 pub ru_nswap: c_long,
49 pub ru_inblock: c_long,
50 pub ru_oublock: c_long,
51 pub ru_msgsnd: c_long,
52 pub ru_msgrcv: c_long,
53 pub ru_nsignals: c_long,
54 pub ru_nvcsw: c_long,
Alex Crichton15b83c22015-09-17 17:25:52 -070055 pub ru_nivcsw: c_long,
56
57 #[cfg(target_env = "musl")]
58 __reserved: [c_long; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070059 }
60
Alex Crichton49d7bca2015-11-27 09:40:37 -080061 #[cfg_attr(target_os = "netbsd", repr(packed))]
Alex Crichton50a42e22015-09-15 14:27:15 -070062 pub struct in_addr {
63 pub s_addr: in_addr_t,
64 }
65
66 pub struct in6_addr {
Alex Crichton316c3672015-09-16 14:32:59 -070067 pub s6_addr: [u8; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070068 __align: [u32; 0],
69 }
70
71 pub struct ip_mreq {
72 pub imr_multiaddr: in_addr,
73 pub imr_interface: in_addr,
74 }
Alex Crichtond8096012015-09-16 16:36:30 -070075
76 pub struct ipv6_mreq {
77 pub ipv6mr_multiaddr: in6_addr,
78 #[cfg(target_os = "android")]
Alex Crichton17910462015-09-22 19:11:04 -070079 pub ipv6mr_interface: ::c_int,
Alex Crichton24824002015-09-16 17:34:54 -070080 #[cfg(not(target_os = "android"))]
Alex Crichton17910462015-09-22 19:11:04 -070081 pub ipv6mr_interface: ::c_uint,
Alex Crichtond8096012015-09-16 16:36:30 -070082 }
Alex Crichton88d23e72015-11-02 17:03:19 -080083
David Hothamccacbe82015-11-14 17:19:12 +000084 pub struct hostent {
85 pub h_name: *mut ::c_char,
86 pub h_aliases: *mut *mut ::c_char,
87 pub h_addrtype: ::c_int,
88 pub h_length: ::c_int,
89 pub h_addr_list: *mut *mut ::c_char,
90 }
Alex Crichton8dce9ad2015-12-03 11:44:14 -080091
92 pub struct iovec {
93 pub iov_base: *mut ::c_void,
94 pub iov_len: ::size_t,
95 }
David Henningsson9d2493e2015-12-25 22:06:44 +010096
97 pub struct pollfd {
98 pub fd: ::c_int,
99 pub events: ::c_short,
100 pub revents: ::c_short,
101 }
Kamal Marhubi89a77002016-02-27 14:58:43 -0500102
103 pub struct winsize {
104 pub ws_row: ::c_ushort,
105 pub ws_col: ::c_ushort,
106 pub ws_xpixel: ::c_ushort,
107 pub ws_ypixel: ::c_ushort,
108 }
Alex Crichton084f9ea2015-09-11 15:11:59 -0700109}
110
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700111pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
112pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
113pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
114
Alex Crichtonf8119012015-12-02 10:30:29 -0800115pub const DT_FIFO: u8 = 1;
116pub const DT_CHR: u8 = 2;
117pub const DT_DIR: u8 = 4;
118pub const DT_BLK: u8 = 6;
119pub const DT_REG: u8 = 8;
120pub const DT_LNK: u8 = 10;
121pub const DT_SOCK: u8 = 12;
122
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800123pub const FD_CLOEXEC: ::c_int = 0x1;
124
125pub const USRQUOTA: ::c_int = 0;
126pub const GRPQUOTA: ::c_int = 1;
127
128pub const SIGIOT: ::c_int = 6;
129
130pub const S_ISUID: ::c_int = 0x800;
131pub const S_ISGID: ::c_int = 0x400;
132pub const S_ISVTX: ::c_int = 0x200;
133
David Henningsson9d2493e2015-12-25 22:06:44 +0100134pub const POLLIN: ::c_short = 0x1;
135pub const POLLPRI: ::c_short = 0x2;
136pub const POLLOUT: ::c_short = 0x4;
137pub const POLLERR: ::c_short = 0x8;
138pub const POLLHUP: ::c_short = 0x10;
139pub const POLLNVAL: ::c_short = 0x20;
140
Kamal Marhubi0a5dcf02016-01-25 15:20:46 -0500141pub const IF_NAMESIZE: ::size_t = 16;
142
Alex Crichton29de5982016-02-04 13:48:13 -0800143pub const RTLD_LAZY: ::c_int = 0x1;
144
Alex Crichton2c57e362015-09-15 17:30:53 -0700145cfg_if! {
arcnmx527b63e2016-01-29 13:54:34 -0500146 if #[cfg(not(stdbuild))] {
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700147 // cargo build, don't pull in anything extra as the libstd dep
Alex Crichton2c57e362015-09-15 17:30:53 -0700148 // already pulls in all libs.
Jörg Krause8ad25202016-03-07 00:04:20 +0100149 } else if #[cfg(all(target_env = "musl", not(any(target_arch = "mips",
150 target_arch = "arm"))))] {
Alex Crichton2c57e362015-09-15 17:30:53 -0700151 #[link(name = "c", kind = "static")]
152 extern {}
Brian Anderson7d1d5752015-11-26 23:27:45 +0000153 } else if #[cfg(target_os = "emscripten")] {
154 #[link(name = "c")]
155 extern {}
Sebastian Wicki37d4bb92016-02-27 14:27:10 +0100156 } else if #[cfg(all(target_vendor = "rumprun", target_os = "netbsd"))] {
Alex Crichton8a8bc662016-02-29 23:02:36 -0800157 // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled
158 // in automatically by the linker. We avoid passing it explicitly, as it
Sebastian Wicki37d4bb92016-02-27 14:27:10 +0100159 // causes some versions of binutils to crash with an assertion failure.
160 #[link(name = "m")]
161 extern {}
Alex Crichton0c8e61a2015-11-22 10:14:13 -0800162 } else if #[cfg(any(target_os = "macos",
163 target_os = "ios",
Sébastien Marieb83e43b2015-11-26 19:54:24 +0100164 target_os = "android",
165 target_os = "openbsd",
166 target_os = "bitrig"))] {
Alex Crichton68a5c442015-11-20 09:28:12 -0800167 #[link(name = "c")]
168 #[link(name = "m")]
169 extern {}
Alex Crichton2c57e362015-09-15 17:30:53 -0700170 } else {
171 #[link(name = "c")]
172 #[link(name = "m")]
Alex Crichton68a5c442015-11-20 09:28:12 -0800173 #[link(name = "rt")]
Alex Crichton2c57e362015-09-15 17:30:53 -0700174 extern {}
175 }
176}
177
Alex Crichton5d6cf052015-09-11 14:52:34 -0700178extern {
Alex Crichton49d7bca2015-11-27 09:40:37 -0800179 #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
Alex Crichton17910462015-09-22 19:11:04 -0700180 pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700181 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
182 link_name = "connect$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700183 pub fn connect(socket: ::c_int, address: *const sockaddr,
184 len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700185 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
186 link_name = "bind$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700187 pub fn bind(socket: ::c_int, address: *const sockaddr,
188 address_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700189 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
190 link_name = "listen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700191 pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700192 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
193 link_name = "accept$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700194 pub fn accept(socket: ::c_int, address: *mut sockaddr,
195 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700196 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
197 link_name = "getpeername$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700198 pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
199 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700200 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
201 link_name = "getsockname$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700202 pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
203 address_len: *mut socklen_t) -> ::c_int;
204 pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700205 value: *const ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700206 option_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700207 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Steven Facklere6c00c22015-11-03 21:10:08 -0800208 link_name = "socketpair$UNIX2003")]
209 pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
210 socket_vector: *mut ::c_int) -> ::c_int;
211 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700212 link_name = "sendto$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700213 pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
214 flags: ::c_int, addr: *const sockaddr,
215 addrlen: socklen_t) -> ::ssize_t;
216 pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700217
218 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
219 link_name = "chmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700220 pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700221 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
222 link_name = "fchmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700223 pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700224
225 #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800226 #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700227 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700228
Alex Crichton17910462015-09-22 19:11:04 -0700229 pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700230
Alex Crichton084f9ea2015-09-11 15:11:59 -0700231 #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800232 #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700233 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700234
235 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
236 link_name = "popen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700237 pub fn popen(command: *const c_char,
238 mode: *const c_char) -> *mut ::FILE;
Alex Crichton17910462015-09-22 19:11:04 -0700239 pub fn pclose(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700240 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
241 link_name = "fdopen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700242 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
243 pub fn fileno(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700244
245 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
246 link_name = "open$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700247 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700248 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
249 link_name = "creat$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700250 pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700251 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
252 link_name = "fcntl$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700253 pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700254
255 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
256 link_name = "opendir$INODE64")]
257 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
258 link_name = "opendir$INODE64$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800259 #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700260 pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700261 #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800262 #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
Alex Crichton5d6cf052015-09-11 14:52:34 -0700263 pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
Alex Crichton74825222015-10-29 17:36:55 -0700264 result: *mut *mut ::dirent) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700265 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
266 link_name = "closedir$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700267 pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700268 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
269 link_name = "rewinddir$INODE64")]
270 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
271 link_name = "rewinddir$INODE64$UNIX2003")]
272 pub fn rewinddir(dirp: *mut ::DIR);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700273
Alex Crichton17910462015-09-22 19:11:04 -0700274 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
275 pub fn alarm(seconds: ::c_uint) -> ::c_uint;
276 pub fn chdir(dir: *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700277 pub fn chown(path: *const c_char, uid: uid_t,
Alex Crichton17910462015-09-22 19:11:04 -0700278 gid: gid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700279 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
280 link_name = "close$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700281 pub fn close(fd: ::c_int) -> ::c_int;
282 pub fn dup(fd: ::c_int) -> ::c_int;
283 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700284 pub fn execv(prog: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700285 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700286 pub fn execve(prog: *const c_char, argv: *const *const c_char,
287 envp: *const *const c_char)
Alex Crichton17910462015-09-22 19:11:04 -0700288 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700289 pub fn execvp(c: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700290 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700291 pub fn fork() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700292 pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
293 pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
Alex Crichton50a42e22015-09-15 14:27:15 -0700294 pub fn getegid() -> gid_t;
295 pub fn geteuid() -> uid_t;
296 pub fn getgid() -> gid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700297 pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
298 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700299 pub fn getlogin() -> *mut c_char;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700300 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
301 link_name = "getopt$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700302 pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
303 optstr: *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700304 pub fn getpgrp() -> pid_t;
305 pub fn getpid() -> pid_t;
306 pub fn getppid() -> pid_t;
307 pub fn getuid() -> uid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700308 pub fn isatty(fd: ::c_int) -> ::c_int;
309 pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700310 pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
Alex Crichton17910462015-09-22 19:11:04 -0700311 pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700312 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
313 link_name = "pause$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700314 pub fn pause() -> ::c_int;
315 pub fn pipe(fds: *mut ::c_int) -> ::c_int;
Tamir Duberstein0b102fd2016-01-06 18:16:05 -0500316 pub fn posix_memalign(memptr: *mut *mut ::c_void,
317 align: ::size_t,
318 size: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700319 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
320 link_name = "read$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700321 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
322 -> ::ssize_t;
323 pub fn rmdir(path: *const c_char) -> ::c_int;
324 pub fn setgid(gid: gid_t) -> ::c_int;
325 pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700326 pub fn setsid() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700327 pub fn setuid(uid: uid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700328 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
329 link_name = "sleep$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700330 pub fn sleep(secs: ::c_uint) -> ::c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700331 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700332 link_name = "nanosleep$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800333 #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700334 pub fn nanosleep(rqtp: *const timespec,
Alex Crichton17910462015-09-22 19:11:04 -0700335 rmtp: *mut timespec) -> ::c_int;
336 pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
337 pub fn ttyname(fd: ::c_int) -> *mut c_char;
338 pub fn unlink(c: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700339 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
340 link_name = "wait$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700341 pub fn wait(status: *mut ::c_int) -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700342 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
343 link_name = "waitpid$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700344 pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
Alex Crichton50a42e22015-09-15 14:27:15 -0700345 -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700346 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
347 link_name = "write$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700348 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
349 -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700350 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
351 link_name = "pread$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700352 pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
353 offset: off_t) -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700354 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
355 link_name = "pwrite$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700356 pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
357 offset: off_t) -> ::ssize_t;
Andy Caldwelldd54f292015-11-30 00:24:15 +0000358 pub fn umask(mask: mode_t) -> mode_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800359
360 #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
Alex Crichton17910462015-09-22 19:11:04 -0700361 pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700362
363 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
364 link_name = "kill$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700365 pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700366
Alex Crichton17910462015-09-22 19:11:04 -0700367 pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
368 pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
369 pub fn mlockall(flags: ::c_int) -> ::c_int;
370 pub fn munlockall() -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700371
372 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700373 link_name = "mmap$UNIX2003")]
374 pub fn mmap(addr: *mut ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700375 len: ::size_t,
376 prot: ::c_int,
377 flags: ::c_int,
378 fd: ::c_int,
Alex Crichton50a42e22015-09-15 14:27:15 -0700379 offset: off_t)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700380 -> *mut ::c_void;
381 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
382 link_name = "munmap$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700383 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700384
Alex Crichton17910462015-09-22 19:11:04 -0700385 pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800386 pub fn if_indextoname(ifindex: ::c_uint,
387 ifname: *mut ::c_char) -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700388
389 #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800390 #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700391 pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700392
Alex Crichton5d6cf052015-09-11 14:52:34 -0700393 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
394 link_name = "fsync$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700395 pub fn fsync(fd: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700396
Alex Crichton5d6cf052015-09-11 14:52:34 -0700397 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
398 link_name = "setenv$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700399 pub fn setenv(name: *const c_char, val: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700400 overwrite: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700401 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
402 link_name = "unsetenv$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800403 #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
Alex Crichton17910462015-09-22 19:11:04 -0700404 pub fn unsetenv(name: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700405
Alex Crichton50a42e22015-09-15 14:27:15 -0700406 pub fn symlink(path1: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700407 path2: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700408
Alex Crichton17910462015-09-22 19:11:04 -0700409 pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700410
Alex Crichton1ff96102015-09-17 15:09:02 -0700411 #[cfg_attr(target_os = "android", link_name = "bsd_signal")]
Alex Crichton17910462015-09-22 19:11:04 -0700412 pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700413
Alex Crichtonde9736d2015-09-17 15:47:44 -0700414 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
415 link_name = "getrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700416 pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700417 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
418 link_name = "setrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700419 pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800420 #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
Alex Crichton17910462015-09-22 19:11:04 -0700421 pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700422
Alex Crichton17910462015-09-22 19:11:04 -0700423 pub fn getdtablesize() -> ::c_int;
Alex Crichtonbaef6112015-09-19 23:20:53 -0700424 #[cfg_attr(any(target_os = "macos", target_os = "ios"),
425 link_name = "realpath$DARWIN_EXTSN")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700426 pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
427 -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700428
Alex Crichton17910462015-09-22 19:11:04 -0700429 pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700430
Jason Travis Smith270c7d42016-02-06 05:46:41 -0500431 #[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700432 pub fn gettimeofday(tp: *mut ::timeval,
433 tz: *mut ::c_void) -> ::c_int;
434
435 pub fn pthread_self() -> ::pthread_t;
436 pub fn pthread_create(native: *mut ::pthread_t,
437 attr: *const ::pthread_attr_t,
438 f: extern fn(*mut ::c_void) -> *mut ::c_void,
439 value: *mut ::c_void) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700440 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
441 link_name = "pthread_join$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700442 pub fn pthread_join(native: ::pthread_t,
443 value: *mut *mut ::c_void) -> ::c_int;
444 pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
445 pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
446 pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
447 stack_size: ::size_t) -> ::c_int;
448 pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
449 state: ::c_int) -> ::c_int;
450 pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800451 #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700452 pub fn sched_yield() -> ::c_int;
453 pub fn pthread_key_create(key: *mut pthread_key_t,
Alex Crichton8a8bc662016-02-29 23:02:36 -0800454 dtor: Option<unsafe extern fn(*mut ::c_void)>)
Alex Crichton17910462015-09-22 19:11:04 -0700455 -> ::c_int;
456 pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700457 pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
458 pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
Alex Crichton17910462015-09-22 19:11:04 -0700459 -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700460 pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
461 attr: *const pthread_mutexattr_t) -> ::c_int;
462 pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
463 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
464 pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
465 pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
466
467 pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700468 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
469 link_name = "pthread_mutexattr_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700470 pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
471 pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
472 _type: ::c_int) -> ::c_int;
473
Alex Crichtonde9736d2015-09-17 15:47:44 -0700474 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
475 link_name = "pthread_cond_wait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700476 pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
477 lock: *mut pthread_mutex_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700478 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
479 link_name = "pthread_cond_timedwait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700480 pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
481 lock: *mut pthread_mutex_t,
482 abstime: *const ::timespec) -> ::c_int;
483 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
484 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
485 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700486 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
487 link_name = "pthread_rwlock_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700488 pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700489 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
490 link_name = "pthread_rwlock_rdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700491 pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700492 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
493 link_name = "pthread_rwlock_tryrdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700494 pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700495 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
496 link_name = "pthread_rwlock_wrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700497 pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700498 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
499 link_name = "pthread_rwlock_trywrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700500 pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700501 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
502 link_name = "pthread_rwlock_unlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700503 pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700504 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
505 link_name = "pthread_sigmask$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700506 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
507 oldset: *mut sigset_t) -> ::c_int;
Tomasz MiÄ…skob0b33702016-02-15 11:00:11 +0100508 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700509
510 // #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")]
Alex Crichton17910462015-09-22 19:11:04 -0700511 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
512 buflen: ::size_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700513
514 pub fn getsockopt(sockfd: ::c_int,
515 level: ::c_int,
516 optname: ::c_int,
517 optval: *mut ::c_void,
518 optlen: *mut ::socklen_t) -> ::c_int;
519 pub fn raise(signum: ::c_int) -> ::c_int;
Sebastian Wickib7c3e5c2016-02-26 21:58:19 +0100520 #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700521 pub fn sigaction(signum: ::c_int,
522 act: *const sigaction,
523 oldact: *mut sigaction) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700524 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
525 link_name = "sigaltstack$UNIX2003")]
Sebastian Wickib7c3e5c2016-02-26 21:58:19 +0100526 #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
Alex Crichtonde9736d2015-09-17 15:47:44 -0700527 pub fn sigaltstack(ss: *const stack_t,
528 oss: *mut stack_t) -> ::c_int;
Philipp Matthias Schaeferc1982a42016-02-28 16:06:45 +0100529 #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
530 link_name = "sigwait$UNIX2003")]
531 pub fn sigwait(set: *const sigset_t,
532 sig: *mut ::c_int) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700533
Alex Crichton49d7bca2015-11-27 09:40:37 -0800534 #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700535 pub fn utimes(filename: *const ::c_char,
536 times: *const ::timeval) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700537 pub fn dlopen(filename: *const ::c_char,
538 flag: ::c_int) -> *mut ::c_void;
539 pub fn dlerror() -> *mut ::c_char;
540 pub fn dlsym(handle: *mut ::c_void,
541 symbol: *const ::c_char) -> *mut ::c_void;
542 pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
Alex Crichton88d23e72015-11-02 17:03:19 -0800543 pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
Alex Crichtonb9096d32015-11-03 10:08:44 -0800544
545 pub fn getaddrinfo(node: *const c_char,
546 service: *const c_char,
547 hints: *const addrinfo,
548 res: *mut *mut addrinfo) -> ::c_int;
549 pub fn freeaddrinfo(res: *mut addrinfo);
550 pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
Alex Crichton568705e2015-11-03 14:18:52 -0800551
Alex Crichton49d7bca2015-11-27 09:40:37 -0800552 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800553 pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800554 #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800555 pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
556 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
557 link_name = "mktime$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800558 #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800559 pub fn mktime(tm: *mut tm) -> time_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800560
561 #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
562 pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
563 dev: ::dev_t) -> ::c_int;
564 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
565 link_name = "writev$UNIX2003")]
Alex Crichton8a8bc662016-02-29 23:02:36 -0800566 pub fn writev(fd: ::c_int,
567 iov: *const ::iovec,
568 iovcnt: ::c_int) -> ::ssize_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800569 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
570 link_name = "readv$UNIX2003")]
Alex Crichton8a8bc662016-02-29 23:02:36 -0800571 pub fn readv(fd: ::c_int,
572 iov: *const ::iovec,
573 iovcnt: ::c_int) -> ::ssize_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800574 pub fn uname(buf: *mut ::utsname) -> ::c_int;
575 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
576 pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
577 pub fn chroot(name: *const ::c_char) -> ::c_int;
Alex Crichton881ef9b2015-12-01 09:04:13 -0800578 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
579 link_name = "usleep$UNIX2003")]
580 pub fn usleep(secs: ::c_uint) -> ::c_int;
581 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
582 link_name = "send$UNIX2003")]
583 pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
584 flags: ::c_int) -> ::ssize_t;
585 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
586 link_name = "recv$UNIX2003")]
587 pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
588 flags: ::c_int) -> ::ssize_t;
589 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
590 link_name = "putenv$UNIX2003")]
591 #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
592 pub fn putenv(string: *mut c_char) -> ::c_int;
593 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
594 link_name = "sendmsg$UNIX2003")]
Alex Crichton8a8bc662016-02-29 23:02:36 -0800595 pub fn sendmsg(fd: ::c_int,
596 msg: *const msghdr,
597 flags: ::c_int) -> ::ssize_t;
Alex Crichton881ef9b2015-12-01 09:04:13 -0800598 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
599 link_name = "recvmsg$UNIX2003")]
600 pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t;
David Henningsson9d2493e2015-12-25 22:06:44 +0100601 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
602 link_name = "poll$UNIX2003")]
603 pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
Alex Crichton993ea7e2016-03-01 13:23:53 -0800604 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
605 link_name = "select$1050")]
606 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
607 link_name = "select$UNIX2003")]
608 #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
609 pub fn select(nfds: ::c_int,
610 readfs: *mut fd_set,
611 writefds: *mut fd_set,
612 errorfds: *mut fd_set,
613 timeout: *mut timeval) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700614}
615
Alex Crichton8a8bc662016-02-29 23:02:36 -0800616// TODO: get rid of this cfg(not(...))
617#[cfg(not(target_os = "android"))] // " if " -- appease style checker
Alex Crichton1ff96102015-09-17 15:09:02 -0700618extern {
Alex Crichton17910462015-09-22 19:11:04 -0700619 pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700620 pub fn freeifaddrs(ifa: *mut ifaddrs);
Alex Crichtonde9736d2015-09-17 15:47:44 -0700621 #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800622 #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700623 pub fn glob(pattern: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700624 flags: ::c_int,
Alex Crichton8a8bc662016-02-29 23:02:36 -0800625 errfunc: Option<extern fn(epath: *const c_char,
626 errno: ::c_int) -> ::c_int>,
Alex Crichton17910462015-09-22 19:11:04 -0700627 pglob: *mut glob_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800628 #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700629 pub fn globfree(pglob: *mut glob_t);
630
Alex Crichton17910462015-09-22 19:11:04 -0700631 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
632 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700633
Alex Crichton17910462015-09-22 19:11:04 -0700634 pub fn shm_unlink(name: *const c_char) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700635
636 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
637 link_name = "seekdir$INODE64")]
638 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
639 link_name = "seekdir$INODE64$UNIX2003")]
640 pub fn seekdir(dirp: *mut ::DIR, loc: c_long);
641
642 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
643 link_name = "telldir$INODE64")]
644 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
645 link_name = "telldir$INODE64$UNIX2003")]
646 pub fn telldir(dirp: *mut ::DIR) -> c_long;
647
648 pub fn getsid(pid: pid_t) -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700649 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
650 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700651 pub fn readlink(path: *const c_char,
652 buf: *mut c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700653 bufsz: ::size_t)
654 -> ::ssize_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700655
656 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
657 link_name = "msync$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800658 #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
Alex Crichton17910462015-09-22 19:11:04 -0700659 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
660 pub fn sysconf(name: ::c_int) -> c_long;
Alex Crichton1ff96102015-09-17 15:09:02 -0700661 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton1ff96102015-09-17 15:09:02 -0700662 link_name = "recvfrom$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700663 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
664 flags: ::c_int, addr: *mut sockaddr,
665 addrlen: *mut socklen_t) -> ::ssize_t;
Alex Crichton17910462015-09-22 19:11:04 -0700666 pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700667
Alex Crichton49d7bca2015-11-27 09:40:37 -0800668 #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700669 pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800670 #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800671 pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800672 #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800673 pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800674 #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800675 pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800676 #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800677 pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700678 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700679 link_name = "pselect$1050")]
680 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
681 link_name = "pselect$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800682 #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700683 pub fn pselect(nfds: ::c_int,
684 readfs: *mut fd_set,
685 writefds: *mut fd_set,
686 errorfds: *mut fd_set,
687 timeout: *const timespec,
688 sigmask: *const sigset_t) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700689 pub fn fseeko(stream: *mut ::FILE,
690 offset: ::off_t,
691 whence: ::c_int) -> ::c_int;
692 pub fn ftello(stream: *mut ::FILE) -> ::off_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800693 #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800694 pub fn timegm(tm: *mut ::tm) -> time_t;
Dan Burkert85a76f82015-11-04 20:26:27 -0800695 pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
696 pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800697 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800698 link_name = "tcdrain$UNIX2003")]
699 pub fn tcdrain(fd: ::c_int) -> ::c_int;
700 pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
701 pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
702 pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
703 pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
704 pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
705 pub fn tcsetattr(fd: ::c_int,
706 optional_actions: ::c_int,
707 termios: *const ::termios) -> ::c_int;
708 pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
709 pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
710 pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
Kamal Marhubi511a7802016-02-15 00:40:19 -0500711 pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
712 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
713 pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
Alex Crichton87d00762016-02-29 21:12:44 -0800714 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700715}
Alex Crichtond3d77922015-09-11 17:03:39 -0700716
717cfg_if! {
Brian Anderson7d1d5752015-11-26 23:27:45 +0000718 if #[cfg(any(target_os = "linux",
719 target_os = "android",
720 target_os = "emscripten"))] {
Alex Crichton50a42e22015-09-15 14:27:15 -0700721 mod notbsd;
722 pub use self::notbsd::*;
723 } else if #[cfg(any(target_os = "macos",
Alex Crichtonbaef6112015-09-19 23:20:53 -0700724 target_os = "ios",
Alex Crichton50a42e22015-09-15 14:27:15 -0700725 target_os = "freebsd",
726 target_os = "dragonfly",
727 target_os = "openbsd",
728 target_os = "netbsd",
729 target_os = "bitrig"))] {
730 mod bsd;
731 pub use self::bsd::*;
Nikita Baksalyar702814f2016-01-28 10:30:54 +0300732 } else if #[cfg(target_os = "solaris")] {
733 mod solaris;
734 pub use self::solaris::*;
Alex Crichtond3d77922015-09-11 17:03:39 -0700735 } else {
Alex Crichton50a42e22015-09-15 14:27:15 -0700736 // ...
Alex Crichtond3d77922015-09-11 17:03:39 -0700737 }
738}