blob: 75caccbe167c19fcdbca7b7666f84de4383bc2ed [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 Crichtonc674e372015-09-18 16:22:00 -070012
Alex Crichtond6e07e22015-10-29 22:59:44 -070013pub enum DIR {}
14
Alex Crichton084f9ea2015-09-11 15:11:59 -070015s! {
16 pub struct utimbuf {
Alex Crichton50a42e22015-09-15 14:27:15 -070017 pub actime: time_t,
18 pub modtime: time_t,
19 }
20
21 pub struct timeval {
22 pub tv_sec: time_t,
23 pub tv_usec: suseconds_t,
24 }
25
26 pub struct timespec {
27 pub tv_sec: time_t,
28 pub tv_nsec: c_long,
29 }
30
31 pub struct rlimit {
32 pub rlim_cur: rlim_t,
33 pub rlim_max: rlim_t,
34 }
35
36 pub struct rusage {
37 pub ru_utime: timeval,
38 pub ru_stime: timeval,
39 pub ru_maxrss: c_long,
40 pub ru_ixrss: c_long,
41 pub ru_idrss: c_long,
42 pub ru_isrss: c_long,
43 pub ru_minflt: c_long,
44 pub ru_majflt: c_long,
45 pub ru_nswap: c_long,
46 pub ru_inblock: c_long,
47 pub ru_oublock: c_long,
48 pub ru_msgsnd: c_long,
49 pub ru_msgrcv: c_long,
50 pub ru_nsignals: c_long,
51 pub ru_nvcsw: c_long,
Alex Crichton15b83c22015-09-17 17:25:52 -070052 pub ru_nivcsw: c_long,
53
54 #[cfg(target_env = "musl")]
55 __reserved: [c_long; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070056 }
57
Alex Crichton49d7bca2015-11-27 09:40:37 -080058 #[cfg_attr(target_os = "netbsd", repr(packed))]
Alex Crichton50a42e22015-09-15 14:27:15 -070059 pub struct in_addr {
60 pub s_addr: in_addr_t,
61 }
62
63 pub struct in6_addr {
Alex Crichton316c3672015-09-16 14:32:59 -070064 pub s6_addr: [u8; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070065 __align: [u32; 0],
66 }
67
68 pub struct ip_mreq {
69 pub imr_multiaddr: in_addr,
70 pub imr_interface: in_addr,
71 }
Alex Crichtond8096012015-09-16 16:36:30 -070072
73 pub struct ipv6_mreq {
74 pub ipv6mr_multiaddr: in6_addr,
75 #[cfg(target_os = "android")]
Alex Crichton17910462015-09-22 19:11:04 -070076 pub ipv6mr_interface: ::c_int,
Alex Crichton24824002015-09-16 17:34:54 -070077 #[cfg(not(target_os = "android"))]
Alex Crichton17910462015-09-22 19:11:04 -070078 pub ipv6mr_interface: ::c_uint,
Alex Crichtond8096012015-09-16 16:36:30 -070079 }
Alex Crichton88d23e72015-11-02 17:03:19 -080080
David Hothamccacbe82015-11-14 17:19:12 +000081 pub struct hostent {
82 pub h_name: *mut ::c_char,
83 pub h_aliases: *mut *mut ::c_char,
84 pub h_addrtype: ::c_int,
85 pub h_length: ::c_int,
86 pub h_addr_list: *mut *mut ::c_char,
87 }
Alex Crichton084f9ea2015-09-11 15:11:59 -070088}
89
Alex Crichton17910462015-09-22 19:11:04 -070090pub const WNOHANG: ::c_int = 1;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070091pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
92pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
93pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
94
Alex Crichtonf8119012015-12-02 10:30:29 -080095pub const DT_FIFO: u8 = 1;
96pub const DT_CHR: u8 = 2;
97pub const DT_DIR: u8 = 4;
98pub const DT_BLK: u8 = 6;
99pub const DT_REG: u8 = 8;
100pub const DT_LNK: u8 = 10;
101pub const DT_SOCK: u8 = 12;
102
Alex Crichton2c57e362015-09-15 17:30:53 -0700103cfg_if! {
104 if #[cfg(feature = "default")] {
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700105 // cargo build, don't pull in anything extra as the libstd dep
Alex Crichton2c57e362015-09-15 17:30:53 -0700106 // already pulls in all libs.
107 } else if #[cfg(target_env = "musl")] {
108 #[link(name = "c", kind = "static")]
109 extern {}
Alex Crichton0c8e61a2015-11-22 10:14:13 -0800110 } else if #[cfg(any(target_os = "macos",
111 target_os = "ios",
Sébastien Marieb83e43b2015-11-26 19:54:24 +0100112 target_os = "android",
113 target_os = "openbsd",
114 target_os = "bitrig"))] {
Alex Crichton68a5c442015-11-20 09:28:12 -0800115 #[link(name = "c")]
116 #[link(name = "m")]
117 extern {}
Alex Crichton2c57e362015-09-15 17:30:53 -0700118 } else {
119 #[link(name = "c")]
120 #[link(name = "m")]
Alex Crichton68a5c442015-11-20 09:28:12 -0800121 #[link(name = "rt")]
Alex Crichton2c57e362015-09-15 17:30:53 -0700122 extern {}
123 }
124}
125
Alex Crichton5d6cf052015-09-11 14:52:34 -0700126extern {
Alex Crichton49d7bca2015-11-27 09:40:37 -0800127 #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
Alex Crichton17910462015-09-22 19:11:04 -0700128 pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700129 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
130 link_name = "connect$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700131 pub fn connect(socket: ::c_int, address: *const sockaddr,
132 len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700133 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
134 link_name = "bind$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700135 pub fn bind(socket: ::c_int, address: *const sockaddr,
136 address_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700137 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
138 link_name = "listen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700139 pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700140 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
141 link_name = "accept$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700142 pub fn accept(socket: ::c_int, address: *mut sockaddr,
143 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700144 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
145 link_name = "getpeername$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700146 pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
147 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700148 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
149 link_name = "getsockname$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700150 pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
151 address_len: *mut socklen_t) -> ::c_int;
152 pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700153 value: *const ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700154 option_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700155 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Steven Facklere6c00c22015-11-03 21:10:08 -0800156 link_name = "socketpair$UNIX2003")]
157 pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
158 socket_vector: *mut ::c_int) -> ::c_int;
159 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700160 link_name = "sendto$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700161 pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
162 flags: ::c_int, addr: *const sockaddr,
163 addrlen: socklen_t) -> ::ssize_t;
164 pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700165
166 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
167 link_name = "chmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700168 pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700169 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
170 link_name = "fchmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700171 pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700172
173 #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800174 #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700175 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700176
Alex Crichton17910462015-09-22 19:11:04 -0700177 pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700178
Alex Crichton084f9ea2015-09-11 15:11:59 -0700179 #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800180 #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700181 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700182
183 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
184 link_name = "popen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700185 pub fn popen(command: *const c_char,
186 mode: *const c_char) -> *mut ::FILE;
Alex Crichton17910462015-09-22 19:11:04 -0700187 pub fn pclose(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700188 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
189 link_name = "fdopen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700190 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
191 pub fn fileno(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700192
193 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
194 link_name = "open$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700195 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700196 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
197 link_name = "creat$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700198 pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700199 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
200 link_name = "fcntl$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700201 pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700202
203 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
204 link_name = "opendir$INODE64")]
205 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
206 link_name = "opendir$INODE64$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800207 #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700208 pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700209 #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800210 #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
Alex Crichton5d6cf052015-09-11 14:52:34 -0700211 pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
Alex Crichton74825222015-10-29 17:36:55 -0700212 result: *mut *mut ::dirent) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700213 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
214 link_name = "closedir$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700215 pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700216 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
217 link_name = "rewinddir$INODE64")]
218 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
219 link_name = "rewinddir$INODE64$UNIX2003")]
220 pub fn rewinddir(dirp: *mut ::DIR);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700221
Alex Crichton17910462015-09-22 19:11:04 -0700222 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
223 pub fn alarm(seconds: ::c_uint) -> ::c_uint;
224 pub fn chdir(dir: *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700225 pub fn chown(path: *const c_char, uid: uid_t,
Alex Crichton17910462015-09-22 19:11:04 -0700226 gid: gid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700227 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
228 link_name = "close$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700229 pub fn close(fd: ::c_int) -> ::c_int;
230 pub fn dup(fd: ::c_int) -> ::c_int;
231 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700232 pub fn execv(prog: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700233 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700234 pub fn execve(prog: *const c_char, argv: *const *const c_char,
235 envp: *const *const c_char)
Alex Crichton17910462015-09-22 19:11:04 -0700236 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700237 pub fn execvp(c: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700238 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700239 pub fn fork() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700240 pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
241 pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
Alex Crichton50a42e22015-09-15 14:27:15 -0700242 pub fn getegid() -> gid_t;
243 pub fn geteuid() -> uid_t;
244 pub fn getgid() -> gid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700245 pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
246 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700247 pub fn getlogin() -> *mut c_char;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700248 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
249 link_name = "getopt$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700250 pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
251 optstr: *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700252 pub fn getpgrp() -> pid_t;
253 pub fn getpid() -> pid_t;
254 pub fn getppid() -> pid_t;
255 pub fn getuid() -> uid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700256 pub fn isatty(fd: ::c_int) -> ::c_int;
257 pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700258 pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
Alex Crichton17910462015-09-22 19:11:04 -0700259 pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700260 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
261 link_name = "pause$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700262 pub fn pause() -> ::c_int;
263 pub fn pipe(fds: *mut ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700264 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
265 link_name = "read$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700266 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
267 -> ::ssize_t;
268 pub fn rmdir(path: *const c_char) -> ::c_int;
269 pub fn setgid(gid: gid_t) -> ::c_int;
270 pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700271 pub fn setsid() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700272 pub fn setuid(uid: uid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700273 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
274 link_name = "sleep$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700275 pub fn sleep(secs: ::c_uint) -> ::c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700276 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700277 link_name = "nanosleep$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800278 #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700279 pub fn nanosleep(rqtp: *const timespec,
Alex Crichton17910462015-09-22 19:11:04 -0700280 rmtp: *mut timespec) -> ::c_int;
281 pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
282 pub fn ttyname(fd: ::c_int) -> *mut c_char;
283 pub fn unlink(c: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700284 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
285 link_name = "wait$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700286 pub fn wait(status: *mut ::c_int) -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700287 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
288 link_name = "waitpid$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700289 pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
Alex Crichton50a42e22015-09-15 14:27:15 -0700290 -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700291 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
292 link_name = "write$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700293 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
294 -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700295 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
296 link_name = "pread$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700297 pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
298 offset: off_t) -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700299 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
300 link_name = "pwrite$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700301 pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
302 offset: off_t) -> ::ssize_t;
Andy Caldwelldd54f292015-11-30 00:24:15 +0000303 pub fn umask(mask: mode_t) -> mode_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800304
305 #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
Alex Crichton17910462015-09-22 19:11:04 -0700306 pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700307
308 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
309 link_name = "kill$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700310 pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700311
Alex Crichton17910462015-09-22 19:11:04 -0700312 pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
313 pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
314 pub fn mlockall(flags: ::c_int) -> ::c_int;
315 pub fn munlockall() -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700316
317 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700318 link_name = "mmap$UNIX2003")]
319 pub fn mmap(addr: *mut ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700320 len: ::size_t,
321 prot: ::c_int,
322 flags: ::c_int,
323 fd: ::c_int,
Alex Crichton50a42e22015-09-15 14:27:15 -0700324 offset: off_t)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700325 -> *mut ::c_void;
326 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
327 link_name = "munmap$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700328 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700329
Alex Crichton17910462015-09-22 19:11:04 -0700330 pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700331
332 #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800333 #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700334 pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700335
Alex Crichton5d6cf052015-09-11 14:52:34 -0700336 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
337 link_name = "fsync$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700338 pub fn fsync(fd: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700339
Alex Crichton5d6cf052015-09-11 14:52:34 -0700340 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
341 link_name = "setenv$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700342 pub fn setenv(name: *const c_char, val: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700343 overwrite: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700344 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
345 link_name = "unsetenv$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800346 #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
Alex Crichton17910462015-09-22 19:11:04 -0700347 pub fn unsetenv(name: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700348
Alex Crichton50a42e22015-09-15 14:27:15 -0700349 pub fn symlink(path1: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700350 path2: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700351
Alex Crichton17910462015-09-22 19:11:04 -0700352 pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700353
Alex Crichton1ff96102015-09-17 15:09:02 -0700354 #[cfg_attr(target_os = "android", link_name = "bsd_signal")]
Alex Crichton17910462015-09-22 19:11:04 -0700355 pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700356
Alex Crichtonde9736d2015-09-17 15:47:44 -0700357 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
358 link_name = "getrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700359 pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700360 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
361 link_name = "setrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700362 pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800363 #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
Alex Crichton17910462015-09-22 19:11:04 -0700364 pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700365
Alex Crichton17910462015-09-22 19:11:04 -0700366 pub fn getdtablesize() -> ::c_int;
Alex Crichtonbaef6112015-09-19 23:20:53 -0700367 #[cfg_attr(any(target_os = "macos", target_os = "ios"),
368 link_name = "realpath$DARWIN_EXTSN")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700369 pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
370 -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700371
Alex Crichton17910462015-09-22 19:11:04 -0700372 pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700373
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700374 pub fn gettimeofday(tp: *mut ::timeval,
375 tz: *mut ::c_void) -> ::c_int;
376
377 pub fn pthread_self() -> ::pthread_t;
378 pub fn pthread_create(native: *mut ::pthread_t,
379 attr: *const ::pthread_attr_t,
380 f: extern fn(*mut ::c_void) -> *mut ::c_void,
381 value: *mut ::c_void) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700382 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
383 link_name = "pthread_join$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700384 pub fn pthread_join(native: ::pthread_t,
385 value: *mut *mut ::c_void) -> ::c_int;
386 pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
387 pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
388 pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
389 stack_size: ::size_t) -> ::c_int;
390 pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
391 state: ::c_int) -> ::c_int;
392 pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800393 #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700394 pub fn sched_yield() -> ::c_int;
395 pub fn pthread_key_create(key: *mut pthread_key_t,
Alex Crichton6de38162015-09-17 16:53:43 -0700396 dtor: ::dox::Option<unsafe extern fn(*mut ::c_void)>)
Alex Crichton17910462015-09-22 19:11:04 -0700397 -> ::c_int;
398 pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700399 pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
400 pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
Alex Crichton17910462015-09-22 19:11:04 -0700401 -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700402 pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
403 attr: *const pthread_mutexattr_t) -> ::c_int;
404 pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
405 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
406 pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
407 pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
408
409 pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700410 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
411 link_name = "pthread_mutexattr_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700412 pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
413 pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
414 _type: ::c_int) -> ::c_int;
415
Alex Crichtonde9736d2015-09-17 15:47:44 -0700416 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
417 link_name = "pthread_cond_wait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700418 pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
419 lock: *mut pthread_mutex_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700420 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
421 link_name = "pthread_cond_timedwait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700422 pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
423 lock: *mut pthread_mutex_t,
424 abstime: *const ::timespec) -> ::c_int;
425 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
426 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
427 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700428 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
429 link_name = "pthread_rwlock_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700430 pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700431 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
432 link_name = "pthread_rwlock_rdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700433 pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700434 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
435 link_name = "pthread_rwlock_tryrdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700436 pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700437 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
438 link_name = "pthread_rwlock_wrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700439 pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700440 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
441 link_name = "pthread_rwlock_trywrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700442 pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700443 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
444 link_name = "pthread_rwlock_unlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700445 pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700446 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
447 link_name = "pthread_sigmask$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700448 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
449 oldset: *mut sigset_t) -> ::c_int;
450
451 // #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")]
Alex Crichton17910462015-09-22 19:11:04 -0700452 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
453 buflen: ::size_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700454
455 pub fn getsockopt(sockfd: ::c_int,
456 level: ::c_int,
457 optname: ::c_int,
458 optval: *mut ::c_void,
459 optlen: *mut ::socklen_t) -> ::c_int;
460 pub fn raise(signum: ::c_int) -> ::c_int;
461 pub fn sigaction(signum: ::c_int,
462 act: *const sigaction,
463 oldact: *mut sigaction) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700464 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
465 link_name = "sigaltstack$UNIX2003")]
466 pub fn sigaltstack(ss: *const stack_t,
467 oss: *mut stack_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700468
Alex Crichton49d7bca2015-11-27 09:40:37 -0800469 #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700470 pub fn utimes(filename: *const ::c_char,
471 times: *const ::timeval) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700472 pub fn dlopen(filename: *const ::c_char,
473 flag: ::c_int) -> *mut ::c_void;
474 pub fn dlerror() -> *mut ::c_char;
475 pub fn dlsym(handle: *mut ::c_void,
476 symbol: *const ::c_char) -> *mut ::c_void;
477 pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
Alex Crichton88d23e72015-11-02 17:03:19 -0800478 pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
Alex Crichtonb9096d32015-11-03 10:08:44 -0800479
480 pub fn getaddrinfo(node: *const c_char,
481 service: *const c_char,
482 hints: *const addrinfo,
483 res: *mut *mut addrinfo) -> ::c_int;
484 pub fn freeaddrinfo(res: *mut addrinfo);
485 pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
Alex Crichton568705e2015-11-03 14:18:52 -0800486
Alex Crichton49d7bca2015-11-27 09:40:37 -0800487 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800488 pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800489 #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800490 pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
491 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
492 link_name = "mktime$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800493 #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800494 pub fn mktime(tm: *mut tm) -> time_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700495}
496
497// TODO: get rid of this #[cfg(not(...))]
498#[cfg(not(target_os = "android"))]
499extern {
Alex Crichton17910462015-09-22 19:11:04 -0700500 pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700501 pub fn freeifaddrs(ifa: *mut ifaddrs);
Alex Crichtonde9736d2015-09-17 15:47:44 -0700502 #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800503 #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700504 pub fn glob(pattern: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700505 flags: ::c_int,
Alex Crichton1ff96102015-09-17 15:09:02 -0700506 errfunc: ::dox::Option<extern "C" fn(epath: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700507 errno: ::c_int) -> ::c_int>,
508 pglob: *mut glob_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800509 #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700510 pub fn globfree(pglob: *mut glob_t);
511
Alex Crichton17910462015-09-22 19:11:04 -0700512 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
513 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700514
Alex Crichton17910462015-09-22 19:11:04 -0700515 pub fn shm_unlink(name: *const c_char) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700516
517 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
518 link_name = "seekdir$INODE64")]
519 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
520 link_name = "seekdir$INODE64$UNIX2003")]
521 pub fn seekdir(dirp: *mut ::DIR, loc: c_long);
522
523 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
524 link_name = "telldir$INODE64")]
525 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
526 link_name = "telldir$INODE64$UNIX2003")]
527 pub fn telldir(dirp: *mut ::DIR) -> c_long;
528
529 pub fn getsid(pid: pid_t) -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700530 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
531 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700532 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
533 link_name = "putenv$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800534 #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
Alex Crichton17910462015-09-22 19:11:04 -0700535 pub fn putenv(string: *mut c_char) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700536 pub fn readlink(path: *const c_char,
537 buf: *mut c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700538 bufsz: ::size_t)
539 -> ::ssize_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700540
541 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
542 link_name = "msync$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800543 #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
Alex Crichton17910462015-09-22 19:11:04 -0700544 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
545 pub fn sysconf(name: ::c_int) -> c_long;
Alex Crichton1ff96102015-09-17 15:09:02 -0700546 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
547 link_name = "usleep$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700548 pub fn usleep(secs: ::c_uint) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700549 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
550 link_name = "recvfrom$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700551 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
552 flags: ::c_int, addr: *mut sockaddr,
553 addrlen: *mut socklen_t) -> ::ssize_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700554 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
555 link_name = "send$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700556 pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
557 flags: ::c_int) -> ::ssize_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700558 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
559 link_name = "recv$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700560 pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
561 flags: ::c_int) -> ::ssize_t;
562 pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700563
Alex Crichton49d7bca2015-11-27 09:40:37 -0800564 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700565 pub fn getpwuid_r(uid: ::uid_t,
566 pwd: *mut passwd,
567 buf: *mut ::c_char,
568 buflen: ::size_t,
569 result: *mut *mut passwd) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700570 pub fn posix_memalign(memptr: *mut *mut ::c_void,
571 align: ::size_t,
572 size: ::size_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800573 #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700574 pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800575 #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800576 pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800577 #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800578 pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800579 #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800580 pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800581 #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800582 pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700583 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
584 link_name = "select$1050")]
585 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
586 link_name = "select$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800587 #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700588 pub fn select(nfds: ::c_int,
589 readfs: *mut fd_set,
590 writefds: *mut fd_set,
591 errorfds: *mut fd_set,
592 timeout: *mut timeval) -> ::c_int;
593 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
594 link_name = "pselect$1050")]
595 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
596 link_name = "pselect$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800597 #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700598 pub fn pselect(nfds: ::c_int,
599 readfs: *mut fd_set,
600 writefds: *mut fd_set,
601 errorfds: *mut fd_set,
602 timeout: *const timespec,
603 sigmask: *const sigset_t) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700604 pub fn fseeko(stream: *mut ::FILE,
605 offset: ::off_t,
606 whence: ::c_int) -> ::c_int;
607 pub fn ftello(stream: *mut ::FILE) -> ::off_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800608 #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800609 pub fn timegm(tm: *mut ::tm) -> time_t;
Dan Burkert85a76f82015-11-04 20:26:27 -0800610 pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
611 pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700612}
Alex Crichtond3d77922015-09-11 17:03:39 -0700613
614cfg_if! {
Alex Crichton50a42e22015-09-15 14:27:15 -0700615 if #[cfg(any(target_os = "linux", target_os = "android"))] {
616 mod notbsd;
617 pub use self::notbsd::*;
618 } else if #[cfg(any(target_os = "macos",
Alex Crichtonbaef6112015-09-19 23:20:53 -0700619 target_os = "ios",
Alex Crichton50a42e22015-09-15 14:27:15 -0700620 target_os = "freebsd",
621 target_os = "dragonfly",
622 target_os = "openbsd",
623 target_os = "netbsd",
624 target_os = "bitrig"))] {
625 mod bsd;
626 pub use self::bsd::*;
Alex Crichtond3d77922015-09-11 17:03:39 -0700627 } else {
Alex Crichton50a42e22015-09-15 14:27:15 -0700628 // ...
Alex Crichtond3d77922015-09-11 17:03:39 -0700629 }
630}