blob: fb42ccb9af8c0a28ac991af77a305ef793a0557b [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 Crichtonc674e372015-09-18 16:22:00 -07006pub type pid_t = i32;
7pub type uid_t = u32;
8pub type gid_t = u32;
9pub type in_addr_t = u32;
10pub type in_port_t = u16;
Alex Crichton17910462015-09-22 19:11:04 -070011pub type sighandler_t = ::size_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -080012pub type cc_t = ::c_uchar;
Alex Crichtonc674e372015-09-18 16:22:00 -070013
Alex Crichtond6e07e22015-10-29 22:59:44 -070014pub enum DIR {}
15
Alex Crichton084f9ea2015-09-11 15:11:59 -070016s! {
17 pub struct utimbuf {
Alex Crichton50a42e22015-09-15 14:27:15 -070018 pub actime: time_t,
19 pub modtime: time_t,
20 }
21
22 pub struct timeval {
23 pub tv_sec: time_t,
24 pub tv_usec: suseconds_t,
25 }
26
27 pub struct timespec {
28 pub tv_sec: time_t,
29 pub tv_nsec: c_long,
30 }
31
32 pub struct rlimit {
33 pub rlim_cur: rlim_t,
34 pub rlim_max: rlim_t,
35 }
36
37 pub struct rusage {
38 pub ru_utime: timeval,
39 pub ru_stime: timeval,
40 pub ru_maxrss: c_long,
41 pub ru_ixrss: c_long,
42 pub ru_idrss: c_long,
43 pub ru_isrss: c_long,
44 pub ru_minflt: c_long,
45 pub ru_majflt: c_long,
46 pub ru_nswap: c_long,
47 pub ru_inblock: c_long,
48 pub ru_oublock: c_long,
49 pub ru_msgsnd: c_long,
50 pub ru_msgrcv: c_long,
51 pub ru_nsignals: c_long,
52 pub ru_nvcsw: c_long,
Alex Crichton15b83c22015-09-17 17:25:52 -070053 pub ru_nivcsw: c_long,
54
55 #[cfg(target_env = "musl")]
56 __reserved: [c_long; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070057 }
58
Alex Crichton49d7bca2015-11-27 09:40:37 -080059 #[cfg_attr(target_os = "netbsd", repr(packed))]
Alex Crichton50a42e22015-09-15 14:27:15 -070060 pub struct in_addr {
61 pub s_addr: in_addr_t,
62 }
63
64 pub struct in6_addr {
Alex Crichton316c3672015-09-16 14:32:59 -070065 pub s6_addr: [u8; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070066 __align: [u32; 0],
67 }
68
69 pub struct ip_mreq {
70 pub imr_multiaddr: in_addr,
71 pub imr_interface: in_addr,
72 }
Alex Crichtond8096012015-09-16 16:36:30 -070073
74 pub struct ipv6_mreq {
75 pub ipv6mr_multiaddr: in6_addr,
76 #[cfg(target_os = "android")]
Alex Crichton17910462015-09-22 19:11:04 -070077 pub ipv6mr_interface: ::c_int,
Alex Crichton24824002015-09-16 17:34:54 -070078 #[cfg(not(target_os = "android"))]
Alex Crichton17910462015-09-22 19:11:04 -070079 pub ipv6mr_interface: ::c_uint,
Alex Crichtond8096012015-09-16 16:36:30 -070080 }
Alex Crichton88d23e72015-11-02 17:03:19 -080081
David Hothamccacbe82015-11-14 17:19:12 +000082 pub struct hostent {
83 pub h_name: *mut ::c_char,
84 pub h_aliases: *mut *mut ::c_char,
85 pub h_addrtype: ::c_int,
86 pub h_length: ::c_int,
87 pub h_addr_list: *mut *mut ::c_char,
88 }
Alex Crichton8dce9ad2015-12-03 11:44:14 -080089
90 pub struct iovec {
91 pub iov_base: *mut ::c_void,
92 pub iov_len: ::size_t,
93 }
David Henningsson9d2493e2015-12-25 22:06:44 +010094
95 pub struct pollfd {
96 pub fd: ::c_int,
97 pub events: ::c_short,
98 pub revents: ::c_short,
99 }
Alex Crichton084f9ea2015-09-11 15:11:59 -0700100}
101
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700102pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
103pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
104pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
105
Alex Crichtonf8119012015-12-02 10:30:29 -0800106pub const DT_FIFO: u8 = 1;
107pub const DT_CHR: u8 = 2;
108pub const DT_DIR: u8 = 4;
109pub const DT_BLK: u8 = 6;
110pub const DT_REG: u8 = 8;
111pub const DT_LNK: u8 = 10;
112pub const DT_SOCK: u8 = 12;
113
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800114pub const FD_CLOEXEC: ::c_int = 0x1;
115
116pub const USRQUOTA: ::c_int = 0;
117pub const GRPQUOTA: ::c_int = 1;
118
119pub const SIGIOT: ::c_int = 6;
120
121pub const S_ISUID: ::c_int = 0x800;
122pub const S_ISGID: ::c_int = 0x400;
123pub const S_ISVTX: ::c_int = 0x200;
124
David Henningsson9d2493e2015-12-25 22:06:44 +0100125pub const POLLIN: ::c_short = 0x1;
126pub const POLLPRI: ::c_short = 0x2;
127pub const POLLOUT: ::c_short = 0x4;
128pub const POLLERR: ::c_short = 0x8;
129pub const POLLHUP: ::c_short = 0x10;
130pub const POLLNVAL: ::c_short = 0x20;
131
Kamal Marhubi0a5dcf02016-01-25 15:20:46 -0500132pub const IF_NAMESIZE: ::size_t = 16;
133
Alex Crichton2c57e362015-09-15 17:30:53 -0700134cfg_if! {
135 if #[cfg(feature = "default")] {
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700136 // cargo build, don't pull in anything extra as the libstd dep
Alex Crichton2c57e362015-09-15 17:30:53 -0700137 // already pulls in all libs.
138 } else if #[cfg(target_env = "musl")] {
139 #[link(name = "c", kind = "static")]
140 extern {}
Brian Anderson7d1d5752015-11-26 23:27:45 +0000141 } else if #[cfg(target_os = "emscripten")] {
142 #[link(name = "c")]
143 extern {}
Alex Crichton0c8e61a2015-11-22 10:14:13 -0800144 } else if #[cfg(any(target_os = "macos",
145 target_os = "ios",
Sébastien Marieb83e43b2015-11-26 19:54:24 +0100146 target_os = "android",
147 target_os = "openbsd",
148 target_os = "bitrig"))] {
Alex Crichton68a5c442015-11-20 09:28:12 -0800149 #[link(name = "c")]
150 #[link(name = "m")]
151 extern {}
Alex Crichton2c57e362015-09-15 17:30:53 -0700152 } else {
153 #[link(name = "c")]
154 #[link(name = "m")]
Alex Crichton68a5c442015-11-20 09:28:12 -0800155 #[link(name = "rt")]
Alex Crichton2c57e362015-09-15 17:30:53 -0700156 extern {}
157 }
158}
159
Alex Crichton5d6cf052015-09-11 14:52:34 -0700160extern {
Alex Crichton49d7bca2015-11-27 09:40:37 -0800161 #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
Alex Crichton17910462015-09-22 19:11:04 -0700162 pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700163 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
164 link_name = "connect$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700165 pub fn connect(socket: ::c_int, address: *const sockaddr,
166 len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700167 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
168 link_name = "bind$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700169 pub fn bind(socket: ::c_int, address: *const sockaddr,
170 address_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700171 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
172 link_name = "listen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700173 pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700174 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
175 link_name = "accept$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700176 pub fn accept(socket: ::c_int, address: *mut sockaddr,
177 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700178 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
179 link_name = "getpeername$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700180 pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
181 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700182 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
183 link_name = "getsockname$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700184 pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
185 address_len: *mut socklen_t) -> ::c_int;
186 pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700187 value: *const ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700188 option_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700189 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Steven Facklere6c00c22015-11-03 21:10:08 -0800190 link_name = "socketpair$UNIX2003")]
191 pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
192 socket_vector: *mut ::c_int) -> ::c_int;
193 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700194 link_name = "sendto$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700195 pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
196 flags: ::c_int, addr: *const sockaddr,
197 addrlen: socklen_t) -> ::ssize_t;
198 pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700199
200 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
201 link_name = "chmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700202 pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700203 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
204 link_name = "fchmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700205 pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700206
207 #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800208 #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700209 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700210
Alex Crichton17910462015-09-22 19:11:04 -0700211 pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700212
Alex Crichton084f9ea2015-09-11 15:11:59 -0700213 #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800214 #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700215 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700216
217 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
218 link_name = "popen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700219 pub fn popen(command: *const c_char,
220 mode: *const c_char) -> *mut ::FILE;
Alex Crichton17910462015-09-22 19:11:04 -0700221 pub fn pclose(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700222 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
223 link_name = "fdopen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700224 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
225 pub fn fileno(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700226
227 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
228 link_name = "open$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700229 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700230 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
231 link_name = "creat$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700232 pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700233 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
234 link_name = "fcntl$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700235 pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700236
237 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
238 link_name = "opendir$INODE64")]
239 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
240 link_name = "opendir$INODE64$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800241 #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700242 pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700243 #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800244 #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
Alex Crichton5d6cf052015-09-11 14:52:34 -0700245 pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
Alex Crichton74825222015-10-29 17:36:55 -0700246 result: *mut *mut ::dirent) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700247 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
248 link_name = "closedir$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700249 pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700250 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
251 link_name = "rewinddir$INODE64")]
252 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
253 link_name = "rewinddir$INODE64$UNIX2003")]
254 pub fn rewinddir(dirp: *mut ::DIR);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700255
Alex Crichton17910462015-09-22 19:11:04 -0700256 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
257 pub fn alarm(seconds: ::c_uint) -> ::c_uint;
258 pub fn chdir(dir: *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700259 pub fn chown(path: *const c_char, uid: uid_t,
Alex Crichton17910462015-09-22 19:11:04 -0700260 gid: gid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700261 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
262 link_name = "close$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700263 pub fn close(fd: ::c_int) -> ::c_int;
264 pub fn dup(fd: ::c_int) -> ::c_int;
265 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700266 pub fn execv(prog: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700267 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700268 pub fn execve(prog: *const c_char, argv: *const *const c_char,
269 envp: *const *const c_char)
Alex Crichton17910462015-09-22 19:11:04 -0700270 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700271 pub fn execvp(c: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700272 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700273 pub fn fork() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700274 pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
275 pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
Alex Crichton50a42e22015-09-15 14:27:15 -0700276 pub fn getegid() -> gid_t;
277 pub fn geteuid() -> uid_t;
278 pub fn getgid() -> gid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700279 pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
280 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700281 pub fn getlogin() -> *mut c_char;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700282 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
283 link_name = "getopt$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700284 pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
285 optstr: *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700286 pub fn getpgrp() -> pid_t;
287 pub fn getpid() -> pid_t;
288 pub fn getppid() -> pid_t;
289 pub fn getuid() -> uid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700290 pub fn isatty(fd: ::c_int) -> ::c_int;
291 pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700292 pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
Alex Crichton17910462015-09-22 19:11:04 -0700293 pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700294 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
295 link_name = "pause$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700296 pub fn pause() -> ::c_int;
297 pub fn pipe(fds: *mut ::c_int) -> ::c_int;
Tamir Duberstein0b102fd2016-01-06 18:16:05 -0500298 pub fn posix_memalign(memptr: *mut *mut ::c_void,
299 align: ::size_t,
300 size: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700301 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
302 link_name = "read$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700303 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
304 -> ::ssize_t;
305 pub fn rmdir(path: *const c_char) -> ::c_int;
306 pub fn setgid(gid: gid_t) -> ::c_int;
307 pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700308 pub fn setsid() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700309 pub fn setuid(uid: uid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700310 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
311 link_name = "sleep$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700312 pub fn sleep(secs: ::c_uint) -> ::c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700313 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700314 link_name = "nanosleep$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800315 #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700316 pub fn nanosleep(rqtp: *const timespec,
Alex Crichton17910462015-09-22 19:11:04 -0700317 rmtp: *mut timespec) -> ::c_int;
318 pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
319 pub fn ttyname(fd: ::c_int) -> *mut c_char;
320 pub fn unlink(c: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700321 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
322 link_name = "wait$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700323 pub fn wait(status: *mut ::c_int) -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700324 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
325 link_name = "waitpid$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700326 pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
Alex Crichton50a42e22015-09-15 14:27:15 -0700327 -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700328 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
329 link_name = "write$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700330 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
331 -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700332 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
333 link_name = "pread$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700334 pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
335 offset: off_t) -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700336 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
337 link_name = "pwrite$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700338 pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
339 offset: off_t) -> ::ssize_t;
Andy Caldwelldd54f292015-11-30 00:24:15 +0000340 pub fn umask(mask: mode_t) -> mode_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800341
342 #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
Alex Crichton17910462015-09-22 19:11:04 -0700343 pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700344
345 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
346 link_name = "kill$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700347 pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700348
Alex Crichton17910462015-09-22 19:11:04 -0700349 pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
350 pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
351 pub fn mlockall(flags: ::c_int) -> ::c_int;
352 pub fn munlockall() -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700353
354 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700355 link_name = "mmap$UNIX2003")]
356 pub fn mmap(addr: *mut ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700357 len: ::size_t,
358 prot: ::c_int,
359 flags: ::c_int,
360 fd: ::c_int,
Alex Crichton50a42e22015-09-15 14:27:15 -0700361 offset: off_t)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700362 -> *mut ::c_void;
363 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
364 link_name = "munmap$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700365 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700366
Alex Crichton17910462015-09-22 19:11:04 -0700367 pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
Kamal Marhubi0a5dcf02016-01-25 15:20:46 -0500368 pub fn if_indextoname(ifindex: ::c_uint, ifname: *mut ::c_char) -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700369
370 #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800371 #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700372 pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700373
Alex Crichton5d6cf052015-09-11 14:52:34 -0700374 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
375 link_name = "fsync$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700376 pub fn fsync(fd: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700377
Alex Crichton5d6cf052015-09-11 14:52:34 -0700378 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
379 link_name = "setenv$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700380 pub fn setenv(name: *const c_char, val: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700381 overwrite: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700382 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
383 link_name = "unsetenv$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800384 #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
Alex Crichton17910462015-09-22 19:11:04 -0700385 pub fn unsetenv(name: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700386
Alex Crichton50a42e22015-09-15 14:27:15 -0700387 pub fn symlink(path1: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700388 path2: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700389
Alex Crichton17910462015-09-22 19:11:04 -0700390 pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700391
Alex Crichton1ff96102015-09-17 15:09:02 -0700392 #[cfg_attr(target_os = "android", link_name = "bsd_signal")]
Alex Crichton17910462015-09-22 19:11:04 -0700393 pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700394
Alex Crichtonde9736d2015-09-17 15:47:44 -0700395 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
396 link_name = "getrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700397 pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700398 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
399 link_name = "setrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700400 pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800401 #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
Alex Crichton17910462015-09-22 19:11:04 -0700402 pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700403
Alex Crichton17910462015-09-22 19:11:04 -0700404 pub fn getdtablesize() -> ::c_int;
Alex Crichtonbaef6112015-09-19 23:20:53 -0700405 #[cfg_attr(any(target_os = "macos", target_os = "ios"),
406 link_name = "realpath$DARWIN_EXTSN")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700407 pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
408 -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700409
Alex Crichton17910462015-09-22 19:11:04 -0700410 pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700411
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800412 #[cfg_attr(arget_os = "netbsd", link_name = "__gettimeofday50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700413 pub fn gettimeofday(tp: *mut ::timeval,
414 tz: *mut ::c_void) -> ::c_int;
415
416 pub fn pthread_self() -> ::pthread_t;
417 pub fn pthread_create(native: *mut ::pthread_t,
418 attr: *const ::pthread_attr_t,
419 f: extern fn(*mut ::c_void) -> *mut ::c_void,
420 value: *mut ::c_void) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700421 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
422 link_name = "pthread_join$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700423 pub fn pthread_join(native: ::pthread_t,
424 value: *mut *mut ::c_void) -> ::c_int;
425 pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
426 pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
427 pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
428 stack_size: ::size_t) -> ::c_int;
429 pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
430 state: ::c_int) -> ::c_int;
431 pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800432 #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700433 pub fn sched_yield() -> ::c_int;
434 pub fn pthread_key_create(key: *mut pthread_key_t,
Alex Crichton6de38162015-09-17 16:53:43 -0700435 dtor: ::dox::Option<unsafe extern fn(*mut ::c_void)>)
Alex Crichton17910462015-09-22 19:11:04 -0700436 -> ::c_int;
437 pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700438 pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
439 pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
Alex Crichton17910462015-09-22 19:11:04 -0700440 -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700441 pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
442 attr: *const pthread_mutexattr_t) -> ::c_int;
443 pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
444 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
445 pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
446 pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
447
448 pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700449 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
450 link_name = "pthread_mutexattr_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700451 pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
452 pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
453 _type: ::c_int) -> ::c_int;
454
Alex Crichtonde9736d2015-09-17 15:47:44 -0700455 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
456 link_name = "pthread_cond_wait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700457 pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
458 lock: *mut pthread_mutex_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700459 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
460 link_name = "pthread_cond_timedwait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700461 pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
462 lock: *mut pthread_mutex_t,
463 abstime: *const ::timespec) -> ::c_int;
464 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
465 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
466 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700467 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
468 link_name = "pthread_rwlock_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700469 pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700470 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
471 link_name = "pthread_rwlock_rdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700472 pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700473 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
474 link_name = "pthread_rwlock_tryrdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700475 pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700476 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
477 link_name = "pthread_rwlock_wrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700478 pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700479 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
480 link_name = "pthread_rwlock_trywrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700481 pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700482 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
483 link_name = "pthread_rwlock_unlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700484 pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700485 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
486 link_name = "pthread_sigmask$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700487 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
488 oldset: *mut sigset_t) -> ::c_int;
489
490 // #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")]
Alex Crichton17910462015-09-22 19:11:04 -0700491 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
492 buflen: ::size_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700493
494 pub fn getsockopt(sockfd: ::c_int,
495 level: ::c_int,
496 optname: ::c_int,
497 optval: *mut ::c_void,
498 optlen: *mut ::socklen_t) -> ::c_int;
499 pub fn raise(signum: ::c_int) -> ::c_int;
500 pub fn sigaction(signum: ::c_int,
501 act: *const sigaction,
502 oldact: *mut sigaction) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700503 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
504 link_name = "sigaltstack$UNIX2003")]
505 pub fn sigaltstack(ss: *const stack_t,
506 oss: *mut stack_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700507
Alex Crichton49d7bca2015-11-27 09:40:37 -0800508 #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700509 pub fn utimes(filename: *const ::c_char,
510 times: *const ::timeval) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700511 pub fn dlopen(filename: *const ::c_char,
512 flag: ::c_int) -> *mut ::c_void;
513 pub fn dlerror() -> *mut ::c_char;
514 pub fn dlsym(handle: *mut ::c_void,
515 symbol: *const ::c_char) -> *mut ::c_void;
516 pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
Alex Crichton88d23e72015-11-02 17:03:19 -0800517 pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
Alex Crichtonb9096d32015-11-03 10:08:44 -0800518
519 pub fn getaddrinfo(node: *const c_char,
520 service: *const c_char,
521 hints: *const addrinfo,
522 res: *mut *mut addrinfo) -> ::c_int;
523 pub fn freeaddrinfo(res: *mut addrinfo);
524 pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
Alex Crichton568705e2015-11-03 14:18:52 -0800525
Alex Crichton49d7bca2015-11-27 09:40:37 -0800526 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800527 pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800528 #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800529 pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
530 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
531 link_name = "mktime$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800532 #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800533 pub fn mktime(tm: *mut tm) -> time_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800534
535 #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
536 pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
537 dev: ::dev_t) -> ::c_int;
538 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
539 link_name = "writev$UNIX2003")]
540 pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
541 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
542 link_name = "readv$UNIX2003")]
543 pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
544 pub fn uname(buf: *mut ::utsname) -> ::c_int;
545 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
546 pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
547 pub fn chroot(name: *const ::c_char) -> ::c_int;
Alex Crichton881ef9b2015-12-01 09:04:13 -0800548 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
549 link_name = "usleep$UNIX2003")]
550 pub fn usleep(secs: ::c_uint) -> ::c_int;
551 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
552 link_name = "send$UNIX2003")]
553 pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
554 flags: ::c_int) -> ::ssize_t;
555 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
556 link_name = "recv$UNIX2003")]
557 pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
558 flags: ::c_int) -> ::ssize_t;
559 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
560 link_name = "putenv$UNIX2003")]
561 #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
562 pub fn putenv(string: *mut c_char) -> ::c_int;
563 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
564 link_name = "sendmsg$UNIX2003")]
565 pub fn sendmsg(fd: ::c_int, msg: *const msghdr, flags: ::c_int) -> ::ssize_t;
566 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
567 link_name = "recvmsg$UNIX2003")]
568 pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t;
David Henningsson9d2493e2015-12-25 22:06:44 +0100569 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
570 link_name = "poll$UNIX2003")]
571 pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700572}
573
574// TODO: get rid of this #[cfg(not(...))]
575#[cfg(not(target_os = "android"))]
576extern {
Alex Crichton17910462015-09-22 19:11:04 -0700577 pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700578 pub fn freeifaddrs(ifa: *mut ifaddrs);
Alex Crichtonde9736d2015-09-17 15:47:44 -0700579 #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800580 #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700581 pub fn glob(pattern: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700582 flags: ::c_int,
Alex Crichton1ff96102015-09-17 15:09:02 -0700583 errfunc: ::dox::Option<extern "C" fn(epath: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700584 errno: ::c_int) -> ::c_int>,
585 pglob: *mut glob_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800586 #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700587 pub fn globfree(pglob: *mut glob_t);
588
Alex Crichton17910462015-09-22 19:11:04 -0700589 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
590 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700591
Alex Crichton17910462015-09-22 19:11:04 -0700592 pub fn shm_unlink(name: *const c_char) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700593
594 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
595 link_name = "seekdir$INODE64")]
596 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
597 link_name = "seekdir$INODE64$UNIX2003")]
598 pub fn seekdir(dirp: *mut ::DIR, loc: c_long);
599
600 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
601 link_name = "telldir$INODE64")]
602 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
603 link_name = "telldir$INODE64$UNIX2003")]
604 pub fn telldir(dirp: *mut ::DIR) -> c_long;
605
606 pub fn getsid(pid: pid_t) -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700607 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
608 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700609 pub fn readlink(path: *const c_char,
610 buf: *mut c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700611 bufsz: ::size_t)
612 -> ::ssize_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700613
614 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
615 link_name = "msync$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800616 #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
Alex Crichton17910462015-09-22 19:11:04 -0700617 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
618 pub fn sysconf(name: ::c_int) -> c_long;
Alex Crichton1ff96102015-09-17 15:09:02 -0700619 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton1ff96102015-09-17 15:09:02 -0700620 link_name = "recvfrom$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700621 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
622 flags: ::c_int, addr: *mut sockaddr,
623 addrlen: *mut socklen_t) -> ::ssize_t;
Alex Crichton17910462015-09-22 19:11:04 -0700624 pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700625
Alex Crichton49d7bca2015-11-27 09:40:37 -0800626 #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700627 pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800628 #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800629 pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800630 #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800631 pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800632 #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800633 pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800634 #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800635 pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700636 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
637 link_name = "select$1050")]
638 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
639 link_name = "select$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800640 #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700641 pub fn select(nfds: ::c_int,
642 readfs: *mut fd_set,
643 writefds: *mut fd_set,
644 errorfds: *mut fd_set,
645 timeout: *mut timeval) -> ::c_int;
646 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
647 link_name = "pselect$1050")]
648 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
649 link_name = "pselect$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800650 #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700651 pub fn pselect(nfds: ::c_int,
652 readfs: *mut fd_set,
653 writefds: *mut fd_set,
654 errorfds: *mut fd_set,
655 timeout: *const timespec,
656 sigmask: *const sigset_t) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700657 pub fn fseeko(stream: *mut ::FILE,
658 offset: ::off_t,
659 whence: ::c_int) -> ::c_int;
660 pub fn ftello(stream: *mut ::FILE) -> ::off_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800661 #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800662 pub fn timegm(tm: *mut ::tm) -> time_t;
Dan Burkert85a76f82015-11-04 20:26:27 -0800663 pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
664 pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800665 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800666 link_name = "tcdrain$UNIX2003")]
667 pub fn tcdrain(fd: ::c_int) -> ::c_int;
668 pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
669 pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
670 pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
671 pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
672 pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
673 pub fn tcsetattr(fd: ::c_int,
674 optional_actions: ::c_int,
675 termios: *const ::termios) -> ::c_int;
676 pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
677 pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
678 pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700679}
Alex Crichtond3d77922015-09-11 17:03:39 -0700680
681cfg_if! {
Brian Anderson7d1d5752015-11-26 23:27:45 +0000682 if #[cfg(any(target_os = "linux",
683 target_os = "android",
684 target_os = "emscripten"))] {
Alex Crichton50a42e22015-09-15 14:27:15 -0700685 mod notbsd;
686 pub use self::notbsd::*;
687 } else if #[cfg(any(target_os = "macos",
Alex Crichtonbaef6112015-09-19 23:20:53 -0700688 target_os = "ios",
Alex Crichton50a42e22015-09-15 14:27:15 -0700689 target_os = "freebsd",
690 target_os = "dragonfly",
691 target_os = "openbsd",
692 target_os = "netbsd",
693 target_os = "bitrig"))] {
694 mod bsd;
695 pub use self::bsd::*;
Nikita Baksalyar702814f2016-01-28 10:30:54 +0300696 } else if #[cfg(target_os = "solaris")] {
697 mod solaris;
698 pub use self::solaris::*;
Alex Crichtond3d77922015-09-11 17:03:39 -0700699 } else {
Alex Crichton50a42e22015-09-15 14:27:15 -0700700 // ...
Alex Crichtond3d77922015-09-11 17:03:39 -0700701 }
702}