blob: f05e6337cd5db551ad4cb136e22945a6abb1468d [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 Crichton084f9ea2015-09-11 15:11:59 -07006s! {
7 pub struct utimbuf {
Alex Crichton50a42e22015-09-15 14:27:15 -07008 pub actime: time_t,
9 pub modtime: time_t,
10 }
11
12 pub struct timeval {
13 pub tv_sec: time_t,
14 pub tv_usec: suseconds_t,
15 }
16
17 pub struct timespec {
18 pub tv_sec: time_t,
19 pub tv_nsec: c_long,
20 }
21
22 pub struct rlimit {
23 pub rlim_cur: rlim_t,
24 pub rlim_max: rlim_t,
25 }
26
27 pub struct rusage {
28 pub ru_utime: timeval,
29 pub ru_stime: timeval,
30 pub ru_maxrss: c_long,
31 pub ru_ixrss: c_long,
32 pub ru_idrss: c_long,
33 pub ru_isrss: c_long,
34 pub ru_minflt: c_long,
35 pub ru_majflt: c_long,
36 pub ru_nswap: c_long,
37 pub ru_inblock: c_long,
38 pub ru_oublock: c_long,
39 pub ru_msgsnd: c_long,
40 pub ru_msgrcv: c_long,
41 pub ru_nsignals: c_long,
42 pub ru_nvcsw: c_long,
43 pub ru_nivcsw: c_long
44 }
45
46 pub struct in_addr {
47 pub s_addr: in_addr_t,
48 }
49
50 pub struct in6_addr {
Alex Crichton316c3672015-09-16 14:32:59 -070051 pub s6_addr: [u8; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070052 __align: [u32; 0],
53 }
54
55 pub struct ip_mreq {
56 pub imr_multiaddr: in_addr,
57 pub imr_interface: in_addr,
58 }
Alex Crichtond8096012015-09-16 16:36:30 -070059
60 pub struct ipv6_mreq {
61 pub ipv6mr_multiaddr: in6_addr,
62 #[cfg(target_os = "android")]
Alex Crichtond8096012015-09-16 16:36:30 -070063 pub ipv6mr_interface: c_int,
Alex Crichton24824002015-09-16 17:34:54 -070064 #[cfg(not(target_os = "android"))]
65 pub ipv6mr_interface: c_uint,
Alex Crichtond8096012015-09-16 16:36:30 -070066 }
Alex Crichton084f9ea2015-09-11 15:11:59 -070067}
68
Alex Crichton2c57e362015-09-15 17:30:53 -070069cfg_if! {
70 if #[cfg(feature = "default")] {
71 // cargo build, don't pull in anything extra as the libstd libc dep
72 // already pulls in all libs.
73 } else if #[cfg(target_env = "musl")] {
74 #[link(name = "c", kind = "static")]
75 extern {}
76 } else {
77 #[link(name = "c")]
78 #[link(name = "m")]
79 extern {}
80 }
81}
82
Alex Crichton5d6cf052015-09-11 14:52:34 -070083extern {
Alex Crichton50a42e22015-09-15 14:27:15 -070084 pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -070085 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
86 link_name = "connect$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -070087 pub fn connect(socket: c_int, address: *const sockaddr,
88 len: socklen_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -070089 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
90 link_name = "bind$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -070091 pub fn bind(socket: c_int, address: *const sockaddr,
92 address_len: socklen_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -070093 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
94 link_name = "listen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -070095 pub fn listen(socket: c_int, backlog: c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -070096 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
97 link_name = "accept$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -070098 pub fn accept(socket: c_int, address: *mut sockaddr,
99 address_len: *mut socklen_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700100 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
101 link_name = "getpeername$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700102 pub fn getpeername(socket: c_int, address: *mut sockaddr,
103 address_len: *mut socklen_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700104 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
105 link_name = "getsockname$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700106 pub fn getsockname(socket: c_int, address: *mut sockaddr,
107 address_len: *mut socklen_t) -> c_int;
108 pub fn setsockopt(socket: c_int, level: c_int, name: c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700109 value: *const ::c_void,
Alex Crichton50a42e22015-09-15 14:27:15 -0700110 option_len: socklen_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700111 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700112 link_name = "sendto$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700113 pub fn sendto(socket: c_int, buf: *const ::c_void, len: size_t,
114 flags: c_int, addr: *const sockaddr,
115 addrlen: socklen_t) -> ssize_t;
116 pub fn shutdown(socket: c_int, how: c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700117
118 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
119 link_name = "chmod$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700120 pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700121 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
122 link_name = "fchmod$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700123 pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700124
125 #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700126 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700127
Alex Crichton50a42e22015-09-15 14:27:15 -0700128 pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700129
Alex Crichton084f9ea2015-09-11 15:11:59 -0700130 #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700131 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700132
133 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
134 link_name = "popen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700135 pub fn popen(command: *const c_char,
136 mode: *const c_char) -> *mut ::FILE;
137 pub fn pclose(stream: *mut ::FILE) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700138 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
139 link_name = "fdopen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700140 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut ::FILE;
141 pub fn fileno(stream: *mut ::FILE) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700142
143 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
144 link_name = "open$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700145 pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700146 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
147 link_name = "creat$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700148 pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700149 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
150 link_name = "fcntl$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700151 pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700152
153 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
154 link_name = "opendir$INODE64")]
155 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
156 link_name = "opendir$INODE64$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700157 pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700158 #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
159 pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
Alex Crichton50a42e22015-09-15 14:27:15 -0700160 result: *mut *mut ::dirent) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700161 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
162 link_name = "closedir$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700163 pub fn closedir(dirp: *mut ::DIR) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700164 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
165 link_name = "rewinddir$INODE64")]
166 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
167 link_name = "rewinddir$INODE64$UNIX2003")]
168 pub fn rewinddir(dirp: *mut ::DIR);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700169
Alex Crichton50a42e22015-09-15 14:27:15 -0700170 pub fn access(path: *const c_char, amode: c_int) -> c_int;
171 pub fn alarm(seconds: c_uint) -> c_uint;
172 pub fn chdir(dir: *const c_char) -> c_int;
173 pub fn chown(path: *const c_char, uid: uid_t,
174 gid: gid_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700175 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
176 link_name = "close$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700177 pub fn close(fd: c_int) -> c_int;
178 pub fn dup(fd: c_int) -> c_int;
179 pub fn dup2(src: c_int, dst: c_int) -> c_int;
180 pub fn execv(prog: *const c_char,
181 argv: *const *const c_char) -> c_int;
182 pub fn execve(prog: *const c_char, argv: *const *const c_char,
183 envp: *const *const c_char)
184 -> c_int;
185 pub fn execvp(c: *const c_char,
186 argv: *const *const c_char) -> c_int;
187 pub fn fork() -> pid_t;
188 pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
189 pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
190 pub fn getegid() -> gid_t;
191 pub fn geteuid() -> uid_t;
192 pub fn getgid() -> gid_t;
193 pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t)
194 -> c_int;
195 pub fn getlogin() -> *mut c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700196 // GNU getopt(3) modifies its arguments despite the
197 // char * const [] prototype; see the manpage.
Alex Crichton50a42e22015-09-15 14:27:15 -0700198 pub fn getopt(argc: c_int, argv: *mut *mut c_char,
199 optstr: *const c_char) -> c_int;
200 pub fn getpgrp() -> pid_t;
201 pub fn getpid() -> pid_t;
202 pub fn getppid() -> pid_t;
203 pub fn getuid() -> uid_t;
204 pub fn isatty(fd: c_int) -> c_int;
205 pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
206 pub fn lseek(fd: c_int, offset: off_t, whence: c_int)
207 -> off_t;
208 pub fn pathconf(path: *const c_char, name: c_int) -> c_long;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700209 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
210 link_name = "pause$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700211 pub fn pause() -> c_int;
212 pub fn pipe(fds: *mut c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700213 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
214 link_name = "read$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700215 pub fn read(fd: c_int, buf: *mut ::c_void, count: size_t)
216 -> ssize_t;
217 pub fn rmdir(path: *const c_char) -> c_int;
218 pub fn setgid(gid: gid_t) -> c_int;
219 pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
220 pub fn setsid() -> pid_t;
221 pub fn setuid(uid: uid_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700222 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
223 link_name = "sleep$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700224 pub fn sleep(secs: c_uint) -> c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700225 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700226 link_name = "nanosleep$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700227 pub fn nanosleep(rqtp: *const timespec,
228 rmtp: *mut timespec) -> c_int;
229 pub fn tcgetpgrp(fd: c_int) -> pid_t;
230 pub fn ttyname(fd: c_int) -> *mut c_char;
231 pub fn unlink(c: *const c_char) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700232 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
233 link_name = "wait$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700234 pub fn wait(status: *mut c_int) -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700235 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
236 link_name = "waitpid$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700237 pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int)
238 -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700239 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
240 link_name = "write$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700241 pub fn write(fd: c_int, buf: *const ::c_void, count: size_t)
242 -> ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700243 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
244 link_name = "pread$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700245 pub fn pread(fd: c_int, buf: *mut ::c_void, count: size_t,
246 offset: off_t) -> ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700247 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
248 link_name = "pwrite$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700249 pub fn pwrite(fd: c_int, buf: *const ::c_void, count: size_t,
250 offset: off_t) -> ssize_t;
251 pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700252
253 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
254 link_name = "kill$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700255 pub fn kill(pid: pid_t, sig: c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700256
Alex Crichton50a42e22015-09-15 14:27:15 -0700257 pub fn mlock(addr: *const ::c_void, len: size_t) -> c_int;
258 pub fn munlock(addr: *const ::c_void, len: size_t) -> c_int;
259 pub fn mlockall(flags: c_int) -> c_int;
260 pub fn munlockall() -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700261
262 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700263 link_name = "mmap$UNIX2003")]
264 pub fn mmap(addr: *mut ::c_void,
Alex Crichton50a42e22015-09-15 14:27:15 -0700265 len: size_t,
266 prot: c_int,
267 flags: c_int,
268 fd: c_int,
269 offset: off_t)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700270 -> *mut ::c_void;
271 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
272 link_name = "munmap$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700273 pub fn munmap(addr: *mut ::c_void, len: size_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700274
Alex Crichton50a42e22015-09-15 14:27:15 -0700275 pub fn if_nametoindex(ifname: *const c_char) -> c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700276
277 #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700278 pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700279
Alex Crichton5d6cf052015-09-11 14:52:34 -0700280 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
281 link_name = "fsync$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700282 pub fn fsync(fd: c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700283
Alex Crichton5d6cf052015-09-11 14:52:34 -0700284 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
285 link_name = "setenv$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700286 pub fn setenv(name: *const c_char, val: *const c_char,
287 overwrite: c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700288 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
289 link_name = "unsetenv$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700290 pub fn unsetenv(name: *const c_char) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700291
Alex Crichton50a42e22015-09-15 14:27:15 -0700292 pub fn symlink(path1: *const c_char,
293 path2: *const c_char) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700294
Alex Crichton50a42e22015-09-15 14:27:15 -0700295 pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700296
Alex Crichton50a42e22015-09-15 14:27:15 -0700297 pub fn signal(signum: c_int,
298 handler: sighandler_t) -> sighandler_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700299
Alex Crichton50a42e22015-09-15 14:27:15 -0700300 pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int;
301 pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int;
302 pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700303
Alex Crichton50a42e22015-09-15 14:27:15 -0700304 pub fn getdtablesize() -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700305 #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700306 pub fn realpath(pathname: *const c_char, resolved: *mut c_char)
307 -> *mut c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700308
Alex Crichton50a42e22015-09-15 14:27:15 -0700309 pub fn flock(fd: c_int, operation: c_int) -> c_int;
310}
311
Alex Crichton52605872015-09-15 16:49:37 -0700312// TODO: get rid of this #[cfg(not(...))]
Alex Crichton50a42e22015-09-15 14:27:15 -0700313#[cfg(not(target_os = "android"))]
314extern {
315 pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int;
316 pub fn freeifaddrs(ifa: *mut ifaddrs);
317 pub fn glob(pattern: *const c_char,
318 flags: c_int,
Alex Crichton24abc4f2015-09-16 23:54:56 -0700319 errfunc: ::dox::Option<extern "C" fn(epath: *const c_char,
320 errno: c_int) -> c_int>,
Alex Crichton50a42e22015-09-15 14:27:15 -0700321 pglob: *mut glob_t);
322 pub fn globfree(pglob: *mut glob_t);
323
324 pub fn posix_madvise(addr: *mut ::c_void, len: size_t, advice: c_int)
325 -> c_int;
326
327 pub fn shm_unlink(name: *const c_char) -> c_int;
328
329 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
330 link_name = "seekdir$INODE64")]
331 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
332 link_name = "seekdir$INODE64$UNIX2003")]
333 pub fn seekdir(dirp: *mut ::DIR, loc: c_long);
334
335 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
336 link_name = "telldir$INODE64")]
337 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
338 link_name = "telldir$INODE64$UNIX2003")]
339 pub fn telldir(dirp: *mut ::DIR) -> c_long;
340
341 pub fn getsid(pid: pid_t) -> pid_t;
342 pub fn madvise(addr: *mut ::c_void, len: size_t, advice: c_int)
343 -> c_int;
344 pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int;
345 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
346 link_name = "putenv$UNIX2003")]
347 pub fn putenv(string: *mut c_char) -> c_int;
348 pub fn readlink(path: *const c_char,
349 buf: *mut c_char,
350 bufsz: size_t)
351 -> ssize_t;
352
353 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
354 link_name = "msync$UNIX2003")]
355 pub fn msync(addr: *mut ::c_void, len: size_t, flags: c_int) -> c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700356 pub fn sysconf(name: c_int) -> c_long;
357 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
358 link_name = "usleep$UNIX2003")]
359 pub fn usleep(secs: c_uint) -> c_int;
360 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
361 link_name = "recvfrom$UNIX2003")]
362 pub fn recvfrom(socket: c_int, buf: *mut ::c_void, len: size_t,
363 flags: c_int, addr: *mut sockaddr,
364 addrlen: *mut socklen_t) -> ssize_t;
365 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
366 link_name = "send$UNIX2003")]
367 pub fn send(socket: c_int, buf: *const ::c_void, len: size_t,
368 flags: c_int) -> ssize_t;
369 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
370 link_name = "recv$UNIX2003")]
371 pub fn recv(socket: c_int, buf: *mut ::c_void, len: size_t,
372 flags: c_int) -> ssize_t;
373 pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700374}
Alex Crichtond3d77922015-09-11 17:03:39 -0700375
376cfg_if! {
Alex Crichton50a42e22015-09-15 14:27:15 -0700377 if #[cfg(any(target_os = "linux", target_os = "android"))] {
378 mod notbsd;
379 pub use self::notbsd::*;
380 } else if #[cfg(any(target_os = "macos",
381 target_os = "freebsd",
382 target_os = "dragonfly",
383 target_os = "openbsd",
384 target_os = "netbsd",
385 target_os = "bitrig"))] {
386 mod bsd;
387 pub use self::bsd::*;
Alex Crichtond3d77922015-09-11 17:03:39 -0700388 } else {
Alex Crichton50a42e22015-09-15 14:27:15 -0700389 // ...
Alex Crichtond3d77922015-09-11 17:03:39 -0700390 }
391}