blob: b2c64a8882391298c1e9a3ac0d6c7f3a32a7155f [file] [log] [blame]
Alex Crichtond3d77922015-09-11 17:03:39 -07001//! Definitions found commonly among almost all Unix derivatives
2//!
3//! More functions and definitions can be found in the more specific modules
4//! according to the platform in question.
5
Alex Crichton8a8bc662016-02-29 23:02:36 -08006use dox::Option;
7
Alex Crichtonc674e372015-09-18 16:22:00 -07008pub type pid_t = i32;
9pub type uid_t = u32;
10pub type gid_t = u32;
11pub type in_addr_t = u32;
12pub type in_port_t = u16;
Alex Crichton17910462015-09-22 19:11:04 -070013pub type sighandler_t = ::size_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -080014pub type cc_t = ::c_uchar;
Alex Crichtonc674e372015-09-18 16:22:00 -070015
Alex Crichtond6e07e22015-10-29 22:59:44 -070016pub enum DIR {}
A.J. Gardner24c84f12016-03-31 20:08:03 -050017pub enum locale_t {}
Alex Crichtond6e07e22015-10-29 22:59:44 -070018
Alex Crichton084f9ea2015-09-11 15:11:59 -070019s! {
Knight263970d2016-07-31 16:58:17 +080020 pub struct group {
21 pub gr_name: *mut ::c_char,
22 pub gr_passwd: *mut ::c_char,
23 pub gr_gid: ::gid_t,
24 pub gr_mem: *mut *mut ::c_char,
25 }
26
Alex Crichton084f9ea2015-09-11 15:11:59 -070027 pub struct utimbuf {
Alex Crichton50a42e22015-09-15 14:27:15 -070028 pub actime: time_t,
29 pub modtime: time_t,
30 }
31
32 pub struct timeval {
33 pub tv_sec: time_t,
34 pub tv_usec: suseconds_t,
35 }
36
37 pub struct timespec {
38 pub tv_sec: time_t,
39 pub tv_nsec: c_long,
40 }
41
42 pub struct rlimit {
43 pub rlim_cur: rlim_t,
44 pub rlim_max: rlim_t,
45 }
46
47 pub struct rusage {
48 pub ru_utime: timeval,
49 pub ru_stime: timeval,
50 pub ru_maxrss: c_long,
51 pub ru_ixrss: c_long,
52 pub ru_idrss: c_long,
53 pub ru_isrss: c_long,
54 pub ru_minflt: c_long,
55 pub ru_majflt: c_long,
56 pub ru_nswap: c_long,
57 pub ru_inblock: c_long,
58 pub ru_oublock: c_long,
59 pub ru_msgsnd: c_long,
60 pub ru_msgrcv: c_long,
61 pub ru_nsignals: c_long,
62 pub ru_nvcsw: c_long,
Alex Crichton15b83c22015-09-17 17:25:52 -070063 pub ru_nivcsw: c_long,
64
Jorge Aparicio23a50922016-07-26 16:13:03 -050065 #[cfg(any(target_env = "musl"))]
Alex Crichton15b83c22015-09-17 17:25:52 -070066 __reserved: [c_long; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070067 }
68
Alex Crichton49d7bca2015-11-27 09:40:37 -080069 #[cfg_attr(target_os = "netbsd", repr(packed))]
Alex Crichton50a42e22015-09-15 14:27:15 -070070 pub struct in_addr {
71 pub s_addr: in_addr_t,
72 }
73
74 pub struct in6_addr {
Alex Crichton316c3672015-09-16 14:32:59 -070075 pub s6_addr: [u8; 16],
Alex Crichton50a42e22015-09-15 14:27:15 -070076 __align: [u32; 0],
77 }
78
79 pub struct ip_mreq {
80 pub imr_multiaddr: in_addr,
81 pub imr_interface: in_addr,
82 }
Alex Crichtond8096012015-09-16 16:36:30 -070083
84 pub struct ipv6_mreq {
85 pub ipv6mr_multiaddr: in6_addr,
86 #[cfg(target_os = "android")]
Alex Crichton17910462015-09-22 19:11:04 -070087 pub ipv6mr_interface: ::c_int,
Alex Crichton24824002015-09-16 17:34:54 -070088 #[cfg(not(target_os = "android"))]
Alex Crichton17910462015-09-22 19:11:04 -070089 pub ipv6mr_interface: ::c_uint,
Alex Crichtond8096012015-09-16 16:36:30 -070090 }
Alex Crichton88d23e72015-11-02 17:03:19 -080091
David Hothamccacbe82015-11-14 17:19:12 +000092 pub struct hostent {
93 pub h_name: *mut ::c_char,
94 pub h_aliases: *mut *mut ::c_char,
95 pub h_addrtype: ::c_int,
96 pub h_length: ::c_int,
97 pub h_addr_list: *mut *mut ::c_char,
98 }
Alex Crichton8dce9ad2015-12-03 11:44:14 -080099
100 pub struct iovec {
101 pub iov_base: *mut ::c_void,
102 pub iov_len: ::size_t,
103 }
David Henningsson9d2493e2015-12-25 22:06:44 +0100104
105 pub struct pollfd {
106 pub fd: ::c_int,
107 pub events: ::c_short,
108 pub revents: ::c_short,
109 }
Kamal Marhubi89a77002016-02-27 14:58:43 -0500110
111 pub struct winsize {
112 pub ws_row: ::c_ushort,
113 pub ws_col: ::c_ushort,
114 pub ws_xpixel: ::c_ushort,
115 pub ws_ypixel: ::c_ushort,
116 }
sateffen69e89a12016-07-11 08:36:52 +0000117
118 pub struct linger {
119 pub l_onoff: ::c_int,
120 pub l_linger: ::c_int,
121 }
Alan Somers9245e072016-11-13 13:52:34 -0700122
123 pub struct sigval {
124 // Actually a union of an int and a void*
125 pub sival_ptr: *mut ::c_void
126 }
Alex Crichton084f9ea2015-09-11 15:11:59 -0700127}
128
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700129pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
130pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
131pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
132
Alex Crichtonf8119012015-12-02 10:30:29 -0800133pub const DT_FIFO: u8 = 1;
134pub const DT_CHR: u8 = 2;
135pub const DT_DIR: u8 = 4;
136pub const DT_BLK: u8 = 6;
137pub const DT_REG: u8 = 8;
138pub const DT_LNK: u8 = 10;
139pub const DT_SOCK: u8 = 12;
140
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800141pub const FD_CLOEXEC: ::c_int = 0x1;
142
143pub const USRQUOTA: ::c_int = 0;
144pub const GRPQUOTA: ::c_int = 1;
145
146pub const SIGIOT: ::c_int = 6;
147
148pub const S_ISUID: ::c_int = 0x800;
149pub const S_ISGID: ::c_int = 0x400;
150pub const S_ISVTX: ::c_int = 0x200;
151
David Henningsson9d2493e2015-12-25 22:06:44 +0100152pub const POLLIN: ::c_short = 0x1;
153pub const POLLPRI: ::c_short = 0x2;
154pub const POLLOUT: ::c_short = 0x4;
155pub const POLLERR: ::c_short = 0x8;
156pub const POLLHUP: ::c_short = 0x10;
157pub const POLLNVAL: ::c_short = 0x20;
158
Kamal Marhubi0a5dcf02016-01-25 15:20:46 -0500159pub const IF_NAMESIZE: ::size_t = 16;
160
Alex Crichton29de5982016-02-04 13:48:13 -0800161pub const RTLD_LAZY: ::c_int = 0x1;
162
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100163pub const LOG_EMERG: ::c_int = 0;
164pub const LOG_ALERT: ::c_int = 1;
165pub const LOG_CRIT: ::c_int = 2;
166pub const LOG_ERR: ::c_int = 3;
167pub const LOG_WARNING: ::c_int = 4;
168pub const LOG_NOTICE: ::c_int = 5;
169pub const LOG_INFO: ::c_int = 6;
170pub const LOG_DEBUG: ::c_int = 7;
171
172pub const LOG_KERN: ::c_int = 0;
173pub const LOG_USER: ::c_int = 1 << 3;
174pub const LOG_MAIL: ::c_int = 2 << 3;
175pub const LOG_DAEMON: ::c_int = 3 << 3;
176pub const LOG_AUTH: ::c_int = 4 << 3;
177pub const LOG_SYSLOG: ::c_int = 5 << 3;
178pub const LOG_LPR: ::c_int = 6 << 3;
179pub const LOG_NEWS: ::c_int = 7 << 3;
180pub const LOG_UUCP: ::c_int = 8 << 3;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100181pub const LOG_LOCAL0: ::c_int = 16 << 3;
182pub const LOG_LOCAL1: ::c_int = 17 << 3;
183pub const LOG_LOCAL2: ::c_int = 18 << 3;
184pub const LOG_LOCAL3: ::c_int = 19 << 3;
185pub const LOG_LOCAL4: ::c_int = 20 << 3;
186pub const LOG_LOCAL5: ::c_int = 21 << 3;
187pub const LOG_LOCAL6: ::c_int = 22 << 3;
188pub const LOG_LOCAL7: ::c_int = 23 << 3;
189
190pub const LOG_PID: ::c_int = 0x01;
191pub const LOG_CONS: ::c_int = 0x02;
192pub const LOG_ODELAY: ::c_int = 0x04;
193pub const LOG_NDELAY: ::c_int = 0x08;
194pub const LOG_NOWAIT: ::c_int = 0x10;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100195
196pub const LOG_PRIMASK: ::c_int = 7;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100197pub const LOG_FACMASK: ::c_int = 0x3f8;
198
Raphael Cohnfabef1d2016-05-19 14:28:40 +0100199pub const PRIO_PROCESS: ::c_int = 0;
200pub const PRIO_PGRP: ::c_int = 1;
201pub const PRIO_USER: ::c_int = 2;
202
203pub const PRIO_MIN: ::c_int = -20;
204pub const PRIO_MAX: ::c_int = 20;
205
Alex Crichton2c57e362015-09-15 17:30:53 -0700206cfg_if! {
Alex Crichtona28ec432016-04-01 10:43:06 -0700207 if #[cfg(dox)] {
208 // on dox builds don't pull in anything
209 } else if #[cfg(all(not(stdbuild), feature = "use_std"))] {
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700210 // cargo build, don't pull in anything extra as the libstd dep
Alex Crichton2c57e362015-09-15 17:30:53 -0700211 // already pulls in all libs.
Jorge Aparicio23a50922016-07-26 16:13:03 -0500212 } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] {
Alex Crichtonf9323d12016-10-31 16:44:29 -0700213 #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
214 #[link(name = "c", cfg(not(target_feature = "crt-static")))]
Alex Crichton2c57e362015-09-15 17:30:53 -0700215 extern {}
Brian Anderson7d1d5752015-11-26 23:27:45 +0000216 } else if #[cfg(target_os = "emscripten")] {
217 #[link(name = "c")]
218 extern {}
Alex Crichtondfd196e2016-04-11 10:16:45 -0700219 } else if #[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))] {
Alex Crichton8a8bc662016-02-29 23:02:36 -0800220 // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled
221 // in automatically by the linker. We avoid passing it explicitly, as it
Sebastian Wicki37d4bb92016-02-27 14:27:10 +0100222 // causes some versions of binutils to crash with an assertion failure.
223 #[link(name = "m")]
224 extern {}
Alex Crichton0c8e61a2015-11-22 10:14:13 -0800225 } else if #[cfg(any(target_os = "macos",
226 target_os = "ios",
Sébastien Marieb83e43b2015-11-26 19:54:24 +0100227 target_os = "android",
228 target_os = "openbsd",
229 target_os = "bitrig"))] {
Alex Crichton68a5c442015-11-20 09:28:12 -0800230 #[link(name = "c")]
231 #[link(name = "m")]
232 extern {}
Niels Sascha Reedijka3ff9552016-02-02 21:21:36 +0100233 } else if #[cfg(target_os = "haiku")] {
234 #[link(name = "root")]
235 #[link(name = "network")]
236 extern {}
Raph Levien517e86d2016-10-11 15:26:47 -0700237 } else if #[cfg(target_os = "fuchsia")] {
238 #[link(name = "c")]
239 #[link(name = "mxio")]
Raph Levien517e86d2016-10-11 15:26:47 -0700240 extern {}
Alex Crichton2c57e362015-09-15 17:30:53 -0700241 } else {
242 #[link(name = "c")]
243 #[link(name = "m")]
Alex Crichton68a5c442015-11-20 09:28:12 -0800244 #[link(name = "rt")]
Alex Crichton2c57e362015-09-15 17:30:53 -0700245 extern {}
246 }
247}
248
Alex Crichton5d6cf052015-09-11 14:52:34 -0700249extern {
Knight263970d2016-07-31 16:58:17 +0800250 pub fn getgrnam(name: *const ::c_char) -> *mut group;
251 pub fn getgrgid(gid: ::gid_t) -> *mut group;
252
Knight19fb32a2016-07-31 17:00:15 +0800253 pub fn endpwent();
254 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
255 pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
256 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
257 pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
258
bluss1ebfe632016-04-13 18:44:56 +0200259 pub fn fprintf(stream: *mut ::FILE,
260 format: *const ::c_char, ...) -> ::c_int;
bluss9111f242016-04-13 18:13:13 +0200261 pub fn printf(format: *const ::c_char, ...) -> ::c_int;
262 pub fn snprintf(s: *mut ::c_char, n: ::size_t,
263 format: *const ::c_char, ...) -> ::c_int;
264 pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
265 pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
266 pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
267 pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
Martin Muñoz5ec77152016-09-25 16:31:30 -0400268 pub fn getchar_unlocked() -> ::c_int;
269 pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
bluss9111f242016-04-13 18:13:13 +0200270
Alex Crichton49d7bca2015-11-27 09:40:37 -0800271 #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
Alex Crichton17910462015-09-22 19:11:04 -0700272 pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700273 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
274 link_name = "connect$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700275 pub fn connect(socket: ::c_int, address: *const sockaddr,
276 len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700277 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
278 link_name = "bind$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700279 pub fn bind(socket: ::c_int, address: *const sockaddr,
280 address_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700281 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
282 link_name = "listen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700283 pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700284 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
285 link_name = "accept$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700286 pub fn accept(socket: ::c_int, address: *mut sockaddr,
287 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700288 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
289 link_name = "getpeername$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700290 pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
291 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700292 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
293 link_name = "getsockname$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700294 pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
295 address_len: *mut socklen_t) -> ::c_int;
296 pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700297 value: *const ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700298 option_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700299 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Steven Facklere6c00c22015-11-03 21:10:08 -0800300 link_name = "socketpair$UNIX2003")]
301 pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
302 socket_vector: *mut ::c_int) -> ::c_int;
303 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700304 link_name = "sendto$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700305 pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
306 flags: ::c_int, addr: *const sockaddr,
307 addrlen: socklen_t) -> ::ssize_t;
308 pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700309
310 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
311 link_name = "chmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700312 pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700313 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
314 link_name = "fchmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700315 pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700316
317 #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800318 #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700319 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700320
Alex Crichton17910462015-09-22 19:11:04 -0700321 pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700322
Alex Crichton084f9ea2015-09-11 15:11:59 -0700323 #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800324 #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700325 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700326
327 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
328 link_name = "popen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700329 pub fn popen(command: *const c_char,
330 mode: *const c_char) -> *mut ::FILE;
Alex Crichton17910462015-09-22 19:11:04 -0700331 pub fn pclose(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700332 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
333 link_name = "fdopen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700334 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
335 pub fn fileno(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700336
337 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
338 link_name = "open$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700339 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700340 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
341 link_name = "creat$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700342 pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700343 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
344 link_name = "fcntl$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700345 pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700346
347 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
348 link_name = "opendir$INODE64")]
349 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
350 link_name = "opendir$INODE64$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800351 #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700352 pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700353 #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800354 #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
Shawn Walker-Salas6740a8a2017-02-15 16:19:06 -0800355 #[cfg_attr(target_os = "solaris", link_name = "__posix_readdir_r")]
Alex Crichton5d6cf052015-09-11 14:52:34 -0700356 pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
Alex Crichton74825222015-10-29 17:36:55 -0700357 result: *mut *mut ::dirent) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700358 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
359 link_name = "closedir$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700360 pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700361 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
362 link_name = "rewinddir$INODE64")]
363 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
364 link_name = "rewinddir$INODE64$UNIX2003")]
365 pub fn rewinddir(dirp: *mut ::DIR);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700366
Alex Crichton17910462015-09-22 19:11:04 -0700367 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
368 pub fn alarm(seconds: ::c_uint) -> ::c_uint;
369 pub fn chdir(dir: *const c_char) -> ::c_int;
Luca Bruno7a260792017-01-15 16:51:01 +0000370 pub fn fchdir(dirfd: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700371 pub fn chown(path: *const c_char, uid: uid_t,
Alex Crichton17910462015-09-22 19:11:04 -0700372 gid: gid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700373 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Knighte383ee72016-06-22 16:53:14 +0800374 link_name = "lchown$UNIX2003")]
375 pub fn lchown(path: *const c_char, uid: uid_t,
376 gid: gid_t) -> ::c_int;
377 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700378 link_name = "close$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700379 pub fn close(fd: ::c_int) -> ::c_int;
380 pub fn dup(fd: ::c_int) -> ::c_int;
381 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
Philipp Kellerda3774f2016-12-28 14:22:47 +0100382 pub fn execl(path: *const c_char,
383 arg0: *const c_char, ...) -> ::c_int;
Philipp Keller9d562b92016-12-29 11:25:51 +0100384 pub fn execle(path: *const ::c_char,
Philipp Kellerda3774f2016-12-28 14:22:47 +0100385 arg0: *const ::c_char, ...) -> ::c_int;
386 pub fn execlp(file: *const ::c_char,
387 arg0: *const ::c_char, ...) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700388 pub fn execv(prog: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700389 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700390 pub fn execve(prog: *const c_char, argv: *const *const c_char,
391 envp: *const *const c_char)
Alex Crichton17910462015-09-22 19:11:04 -0700392 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700393 pub fn execvp(c: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700394 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700395 pub fn fork() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700396 pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
397 pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
Alex Crichton50a42e22015-09-15 14:27:15 -0700398 pub fn getegid() -> gid_t;
399 pub fn geteuid() -> uid_t;
400 pub fn getgid() -> gid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700401 pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
402 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700403 pub fn getlogin() -> *mut c_char;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700404 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
405 link_name = "getopt$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700406 pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
407 optstr: *const c_char) -> ::c_int;
Corey Farwell68dba7a2016-08-03 08:21:45 -0400408 pub fn getpgid(pid: pid_t) -> pid_t;
Alex Crichton50a42e22015-09-15 14:27:15 -0700409 pub fn getpgrp() -> pid_t;
410 pub fn getpid() -> pid_t;
411 pub fn getppid() -> pid_t;
412 pub fn getuid() -> uid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700413 pub fn isatty(fd: ::c_int) -> ::c_int;
414 pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700415 pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
Alex Crichton17910462015-09-22 19:11:04 -0700416 pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700417 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
418 link_name = "pause$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700419 pub fn pause() -> ::c_int;
420 pub fn pipe(fds: *mut ::c_int) -> ::c_int;
Tamir Duberstein0b102fd2016-01-06 18:16:05 -0500421 pub fn posix_memalign(memptr: *mut *mut ::c_void,
422 align: ::size_t,
423 size: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700424 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
425 link_name = "read$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700426 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
427 -> ::ssize_t;
428 pub fn rmdir(path: *const c_char) -> ::c_int;
429 pub fn setgid(gid: gid_t) -> ::c_int;
430 pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700431 pub fn setsid() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700432 pub fn setuid(uid: uid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700433 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
434 link_name = "sleep$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700435 pub fn sleep(secs: ::c_uint) -> ::c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700436 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700437 link_name = "nanosleep$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800438 #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700439 pub fn nanosleep(rqtp: *const timespec,
Alex Crichton17910462015-09-22 19:11:04 -0700440 rmtp: *mut timespec) -> ::c_int;
441 pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
zethrac21a30c2016-10-27 16:01:18 -0400442 pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
Alex Crichton17910462015-09-22 19:11:04 -0700443 pub fn ttyname(fd: ::c_int) -> *mut c_char;
444 pub fn unlink(c: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700445 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
446 link_name = "wait$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700447 pub fn wait(status: *mut ::c_int) -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700448 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
449 link_name = "waitpid$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700450 pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
Alex Crichton50a42e22015-09-15 14:27:15 -0700451 -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700452 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
453 link_name = "write$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700454 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
455 -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700456 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
457 link_name = "pread$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700458 pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
459 offset: off_t) -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700460 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
461 link_name = "pwrite$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700462 pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
463 offset: off_t) -> ::ssize_t;
Andy Caldwelldd54f292015-11-30 00:24:15 +0000464 pub fn umask(mask: mode_t) -> mode_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800465
466 #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
Alex Crichton17910462015-09-22 19:11:04 -0700467 pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700468
469 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
470 link_name = "kill$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700471 pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700472
Alex Crichton17910462015-09-22 19:11:04 -0700473 pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
474 pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
475 pub fn mlockall(flags: ::c_int) -> ::c_int;
476 pub fn munlockall() -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700477
478 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700479 link_name = "mmap$UNIX2003")]
480 pub fn mmap(addr: *mut ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700481 len: ::size_t,
482 prot: ::c_int,
483 flags: ::c_int,
484 fd: ::c_int,
Alex Crichton50a42e22015-09-15 14:27:15 -0700485 offset: off_t)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700486 -> *mut ::c_void;
487 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
488 link_name = "munmap$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700489 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700490
Alex Crichton17910462015-09-22 19:11:04 -0700491 pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800492 pub fn if_indextoname(ifindex: ::c_uint,
493 ifname: *mut ::c_char) -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700494
495 #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800496 #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700497 pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700498
Alex Crichton5d6cf052015-09-11 14:52:34 -0700499 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
500 link_name = "fsync$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700501 pub fn fsync(fd: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700502
Alex Crichton5d6cf052015-09-11 14:52:34 -0700503 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
504 link_name = "setenv$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700505 pub fn setenv(name: *const c_char, val: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700506 overwrite: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700507 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
508 link_name = "unsetenv$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800509 #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
Alex Crichton17910462015-09-22 19:11:04 -0700510 pub fn unsetenv(name: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700511
Alex Crichton50a42e22015-09-15 14:27:15 -0700512 pub fn symlink(path1: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700513 path2: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700514
Alex Crichton17910462015-09-22 19:11:04 -0700515 pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700516
Alex Crichton17910462015-09-22 19:11:04 -0700517 pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700518
Alex Crichtonde9736d2015-09-17 15:47:44 -0700519 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
520 link_name = "getrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700521 pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700522 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
523 link_name = "setrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700524 pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800525 #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
Alex Crichton17910462015-09-22 19:11:04 -0700526 pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700527
Alex Crichton17910462015-09-22 19:11:04 -0700528 pub fn getdtablesize() -> ::c_int;
Alex Crichtonbaef6112015-09-19 23:20:53 -0700529 #[cfg_attr(any(target_os = "macos", target_os = "ios"),
530 link_name = "realpath$DARWIN_EXTSN")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700531 pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
532 -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700533
Alex Crichton17910462015-09-22 19:11:04 -0700534 pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700535
Jason Travis Smith270c7d42016-02-06 05:46:41 -0500536 #[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700537 pub fn gettimeofday(tp: *mut ::timeval,
538 tz: *mut ::c_void) -> ::c_int;
539
540 pub fn pthread_self() -> ::pthread_t;
541 pub fn pthread_create(native: *mut ::pthread_t,
542 attr: *const ::pthread_attr_t,
543 f: extern fn(*mut ::c_void) -> *mut ::c_void,
544 value: *mut ::c_void) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700545 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
546 link_name = "pthread_join$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700547 pub fn pthread_join(native: ::pthread_t,
548 value: *mut *mut ::c_void) -> ::c_int;
549 pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
550 pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
551 pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
552 stack_size: ::size_t) -> ::c_int;
553 pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
554 state: ::c_int) -> ::c_int;
555 pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800556 #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700557 pub fn sched_yield() -> ::c_int;
558 pub fn pthread_key_create(key: *mut pthread_key_t,
Alex Crichton8a8bc662016-02-29 23:02:36 -0800559 dtor: Option<unsafe extern fn(*mut ::c_void)>)
Alex Crichton17910462015-09-22 19:11:04 -0700560 -> ::c_int;
561 pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700562 pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
563 pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
Alex Crichton17910462015-09-22 19:11:04 -0700564 -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700565 pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
566 attr: *const pthread_mutexattr_t) -> ::c_int;
567 pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
568 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
569 pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
570 pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
571
572 pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700573 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
574 link_name = "pthread_mutexattr_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700575 pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
576 pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
577 _type: ::c_int) -> ::c_int;
578
Alex Crichtonde9736d2015-09-17 15:47:44 -0700579 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Tomasz MiÄ…skocb644852016-07-20 07:31:48 +0200580 link_name = "pthread_cond_init$UNIX2003")]
581 pub fn pthread_cond_init(cond: *mut pthread_cond_t,
582 attr: *const pthread_condattr_t) -> ::c_int;
583 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichtonde9736d2015-09-17 15:47:44 -0700584 link_name = "pthread_cond_wait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700585 pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
586 lock: *mut pthread_mutex_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700587 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
588 link_name = "pthread_cond_timedwait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700589 pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
590 lock: *mut pthread_mutex_t,
591 abstime: *const ::timespec) -> ::c_int;
592 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
593 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
594 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
Tomasz MiÄ…skocb644852016-07-20 07:31:48 +0200595 pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
596 pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700597 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
598 link_name = "pthread_rwlock_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700599 pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700600 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
601 link_name = "pthread_rwlock_rdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700602 pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700603 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
604 link_name = "pthread_rwlock_tryrdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700605 pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700606 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
607 link_name = "pthread_rwlock_wrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700608 pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700609 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
610 link_name = "pthread_rwlock_trywrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700611 pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700612 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
613 link_name = "pthread_rwlock_unlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700614 pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700615 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
616 link_name = "pthread_sigmask$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700617 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
618 oldset: *mut sigset_t) -> ::c_int;
Tomasz MiÄ…skob0b33702016-02-15 11:00:11 +0100619 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
NODA, Kai75a69bf2016-04-03 20:59:44 +0800620 #[cfg_attr(all(target_os = "linux", not(target_env = "musl")),
621 link_name = "__xpg_strerror_r")]
Alex Crichton17910462015-09-22 19:11:04 -0700622 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
623 buflen: ::size_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700624
625 pub fn getsockopt(sockfd: ::c_int,
626 level: ::c_int,
627 optname: ::c_int,
628 optval: *mut ::c_void,
629 optlen: *mut ::socklen_t) -> ::c_int;
630 pub fn raise(signum: ::c_int) -> ::c_int;
Sebastian Wickib7c3e5c2016-02-26 21:58:19 +0100631 #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700632 pub fn sigaction(signum: ::c_int,
633 act: *const sigaction,
634 oldact: *mut sigaction) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700635 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
636 link_name = "sigaltstack$UNIX2003")]
Sebastian Wickib7c3e5c2016-02-26 21:58:19 +0100637 #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
Alex Crichtonde9736d2015-09-17 15:47:44 -0700638 pub fn sigaltstack(ss: *const stack_t,
639 oss: *mut stack_t) -> ::c_int;
Philipp Matthias Schaeferc1982a42016-02-28 16:06:45 +0100640 #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
641 link_name = "sigwait$UNIX2003")]
Shawn Walker-Salas6740a8a2017-02-15 16:19:06 -0800642 #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
Philipp Matthias Schaeferc1982a42016-02-28 16:06:45 +0100643 pub fn sigwait(set: *const sigset_t,
644 sig: *mut ::c_int) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700645
Alex Crichton49d7bca2015-11-27 09:40:37 -0800646 #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700647 pub fn utimes(filename: *const ::c_char,
648 times: *const ::timeval) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700649 pub fn dlopen(filename: *const ::c_char,
650 flag: ::c_int) -> *mut ::c_void;
651 pub fn dlerror() -> *mut ::c_char;
652 pub fn dlsym(handle: *mut ::c_void,
653 symbol: *const ::c_char) -> *mut ::c_void;
654 pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
Alex Crichton88d23e72015-11-02 17:03:19 -0800655 pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
Alex Crichtonb9096d32015-11-03 10:08:44 -0800656
657 pub fn getaddrinfo(node: *const c_char,
658 service: *const c_char,
659 hints: *const addrinfo,
660 res: *mut *mut addrinfo) -> ::c_int;
661 pub fn freeaddrinfo(res: *mut addrinfo);
662 pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
Alex Crichton568705e2015-11-03 14:18:52 -0800663
Alex Crichton49d7bca2015-11-27 09:40:37 -0800664 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800665 pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800666 #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800667 pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
668 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
669 link_name = "mktime$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800670 #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800671 pub fn mktime(tm: *mut tm) -> time_t;
Philipp Kellera77ea862016-09-23 22:00:18 +0200672 #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
673 pub fn time(time: *mut time_t) -> time_t;
674 #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
675 pub fn localtime(time: *const time_t) -> *mut tm;
Philipp Kellera77ea862016-09-23 22:00:18 +0200676
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800677 #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
678 pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
679 dev: ::dev_t) -> ::c_int;
680 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
681 link_name = "writev$UNIX2003")]
Alex Crichton8a8bc662016-02-29 23:02:36 -0800682 pub fn writev(fd: ::c_int,
683 iov: *const ::iovec,
684 iovcnt: ::c_int) -> ::ssize_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800685 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
686 link_name = "readv$UNIX2003")]
Alex Crichton8a8bc662016-02-29 23:02:36 -0800687 pub fn readv(fd: ::c_int,
688 iov: *const ::iovec,
689 iovcnt: ::c_int) -> ::ssize_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800690 pub fn uname(buf: *mut ::utsname) -> ::c_int;
691 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
692 pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
693 pub fn chroot(name: *const ::c_char) -> ::c_int;
Alex Crichton881ef9b2015-12-01 09:04:13 -0800694 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
695 link_name = "usleep$UNIX2003")]
696 pub fn usleep(secs: ::c_uint) -> ::c_int;
697 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
698 link_name = "send$UNIX2003")]
699 pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
700 flags: ::c_int) -> ::ssize_t;
701 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
702 link_name = "recv$UNIX2003")]
703 pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
704 flags: ::c_int) -> ::ssize_t;
705 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
706 link_name = "putenv$UNIX2003")]
707 #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
708 pub fn putenv(string: *mut c_char) -> ::c_int;
709 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
710 link_name = "sendmsg$UNIX2003")]
Alex Crichton8a8bc662016-02-29 23:02:36 -0800711 pub fn sendmsg(fd: ::c_int,
712 msg: *const msghdr,
713 flags: ::c_int) -> ::ssize_t;
Alex Crichton881ef9b2015-12-01 09:04:13 -0800714 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
715 link_name = "recvmsg$UNIX2003")]
716 pub fn recvmsg(fd: ::c_int, msg: *mut msghdr, flags: ::c_int) -> ::ssize_t;
David Henningsson9d2493e2015-12-25 22:06:44 +0100717 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
718 link_name = "poll$UNIX2003")]
719 pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
Alex Crichton993ea7e2016-03-01 13:23:53 -0800720 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
721 link_name = "select$1050")]
722 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
723 link_name = "select$UNIX2003")]
724 #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
725 pub fn select(nfds: ::c_int,
726 readfs: *mut fd_set,
727 writefds: *mut fd_set,
728 errorfds: *mut fd_set,
729 timeout: *mut timeval) -> ::c_int;
A.J. Gardner5399c892016-03-30 23:09:25 -0500730 #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
A.J. Gardner2bd6f122016-03-30 00:55:49 -0500731 pub fn setlocale(category: ::c_int,
732 locale: *const ::c_char) -> *mut ::c_char;
A.J. Gardner110152c2016-03-30 00:36:43 -0500733 pub fn localeconv() -> *mut lconv;
Steven Fackler41699f72016-06-03 21:02:56 -0700734
735 pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
736 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
737 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
738 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
739 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
740 link_name = "sem_wait$UNIX2003")]
741 pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
742 pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
743 pub fn sem_post(sem: *mut sem_t) -> ::c_int;
744 pub fn sem_init(sem: *mut sem_t,
745 pshared: ::c_int,
746 value: ::c_uint)
747 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700748}
749
Alex Crichton8a8bc662016-02-29 23:02:36 -0800750// TODO: get rid of this cfg(not(...))
751#[cfg(not(target_os = "android"))] // " if " -- appease style checker
Alex Crichton1ff96102015-09-17 15:09:02 -0700752extern {
Alex Crichtonde9736d2015-09-17 15:47:44 -0700753 #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800754 #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700755 pub fn glob(pattern: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700756 flags: ::c_int,
Alex Crichton8a8bc662016-02-29 23:02:36 -0800757 errfunc: Option<extern fn(epath: *const c_char,
758 errno: ::c_int) -> ::c_int>,
Alex Crichton17910462015-09-22 19:11:04 -0700759 pglob: *mut glob_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800760 #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700761 pub fn globfree(pglob: *mut glob_t);
762
Alex Crichton17910462015-09-22 19:11:04 -0700763 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
764 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700765
Alex Crichton17910462015-09-22 19:11:04 -0700766 pub fn shm_unlink(name: *const c_char) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700767
768 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
769 link_name = "seekdir$INODE64")]
770 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
771 link_name = "seekdir$INODE64$UNIX2003")]
772 pub fn seekdir(dirp: *mut ::DIR, loc: c_long);
773
774 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
775 link_name = "telldir$INODE64")]
776 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
777 link_name = "telldir$INODE64$UNIX2003")]
778 pub fn telldir(dirp: *mut ::DIR) -> c_long;
779
780 pub fn getsid(pid: pid_t) -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700781 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
782 -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700783 pub fn readlink(path: *const c_char,
784 buf: *mut c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700785 bufsz: ::size_t)
786 -> ::ssize_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700787
788 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
789 link_name = "msync$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800790 #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
Alex Crichton17910462015-09-22 19:11:04 -0700791 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
792 pub fn sysconf(name: ::c_int) -> c_long;
Alex Crichton1ff96102015-09-17 15:09:02 -0700793 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton1ff96102015-09-17 15:09:02 -0700794 link_name = "recvfrom$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700795 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
796 flags: ::c_int, addr: *mut sockaddr,
797 addrlen: *mut socklen_t) -> ::ssize_t;
Alex Crichton17910462015-09-22 19:11:04 -0700798 pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700799
Alex Crichton49d7bca2015-11-27 09:40:37 -0800800 #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
Alex Crichton1ff96102015-09-17 15:09:02 -0700801 pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800802 #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800803 pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800804 #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800805 pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800806 #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800807 pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800808 #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
Alex Crichtonfe5f36b2015-11-02 17:06:59 -0800809 pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700810 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700811 link_name = "pselect$1050")]
812 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
813 link_name = "pselect$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800814 #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700815 pub fn pselect(nfds: ::c_int,
816 readfs: *mut fd_set,
817 writefds: *mut fd_set,
818 errorfds: *mut fd_set,
819 timeout: *const timespec,
820 sigmask: *const sigset_t) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700821 pub fn fseeko(stream: *mut ::FILE,
822 offset: ::off_t,
823 whence: ::c_int) -> ::c_int;
824 pub fn ftello(stream: *mut ::FILE) -> ::off_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800825 #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800826 pub fn timegm(tm: *mut ::tm) -> time_t;
Dan Burkert85a76f82015-11-04 20:26:27 -0800827 pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
828 pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800829 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800830 link_name = "tcdrain$UNIX2003")]
831 pub fn tcdrain(fd: ::c_int) -> ::c_int;
832 pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
833 pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
834 pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
835 pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
836 pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
837 pub fn tcsetattr(fd: ::c_int,
838 optional_actions: ::c_int,
839 termios: *const ::termios) -> ::c_int;
840 pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
841 pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
842 pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
Kamal Marhubi511a7802016-02-15 00:40:19 -0500843 pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
844 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
845 pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
Alex Crichton87d00762016-02-29 21:12:44 -0800846 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
A.J. Gardner24c84f12016-03-31 20:08:03 -0500847 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100848
849 pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
850 pub fn closelog();
851 pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
852 pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
Raphael Cohnfabef1d2016-05-19 14:28:40 +0100853 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
854 link_name = "nice$UNIX2003")]
855 pub fn nice(incr: ::c_int) -> ::c_int;
Robbie Harwoodb9f5c462016-10-18 20:50:11 -0400856
Robbie Harwoodb9f5c462016-10-18 20:50:11 -0400857 pub fn grantpt(fd: ::c_int) -> ::c_int;
858 pub fn posix_openpt(flags: ::c_int) -> ::c_int;
859 pub fn ptsname(fd: ::c_int) -> *mut ::c_char;
Robbie Harwoodb9f5c462016-10-18 20:50:11 -0400860 pub fn unlockpt(fd: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700861}
Alex Crichtond3d77922015-09-11 17:03:39 -0700862
863cfg_if! {
Brian Anderson7d1d5752015-11-26 23:27:45 +0000864 if #[cfg(any(target_os = "linux",
865 target_os = "android",
Raph Levien517e86d2016-10-11 15:26:47 -0700866 target_os = "emscripten",
867 target_os = "fuchsia"))] {
Alex Crichton50a42e22015-09-15 14:27:15 -0700868 mod notbsd;
869 pub use self::notbsd::*;
870 } else if #[cfg(any(target_os = "macos",
Alex Crichtonbaef6112015-09-19 23:20:53 -0700871 target_os = "ios",
Alex Crichton50a42e22015-09-15 14:27:15 -0700872 target_os = "freebsd",
873 target_os = "dragonfly",
874 target_os = "openbsd",
875 target_os = "netbsd",
876 target_os = "bitrig"))] {
877 mod bsd;
878 pub use self::bsd::*;
Nikita Baksalyar702814f2016-01-28 10:30:54 +0300879 } else if #[cfg(target_os = "solaris")] {
880 mod solaris;
881 pub use self::solaris::*;
Niels Sascha Reedijka3ff9552016-02-02 21:21:36 +0100882 } else if #[cfg(target_os = "haiku")] {
883 mod haiku;
884 pub use self::haiku::*;
Alex Crichtond3d77922015-09-11 17:03:39 -0700885 } else {
Kamal Marhubi66c33752016-03-10 15:07:32 -0500886 // Unknown target_os
Alex Crichtond3d77922015-09-11 17:03:39 -0700887 }
888}