blob: edc2484ba2c5ff4263b4d5d772826226c5f0c251 [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 }
Andrew Salmone976c372017-05-26 04:07:01 -0700127
128 pub struct itimerval {
129 pub it_interval: ::timeval,
130 pub it_value: ::timeval,
131 }
Alex Crichton084f9ea2015-09-11 15:11:59 -0700132}
133
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700134pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
135pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
136pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
137
Alex Crichtonf8119012015-12-02 10:30:29 -0800138pub const DT_FIFO: u8 = 1;
139pub const DT_CHR: u8 = 2;
140pub const DT_DIR: u8 = 4;
141pub const DT_BLK: u8 = 6;
142pub const DT_REG: u8 = 8;
143pub const DT_LNK: u8 = 10;
144pub const DT_SOCK: u8 = 12;
145
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800146pub const FD_CLOEXEC: ::c_int = 0x1;
147
148pub const USRQUOTA: ::c_int = 0;
149pub const GRPQUOTA: ::c_int = 1;
150
151pub const SIGIOT: ::c_int = 6;
152
153pub const S_ISUID: ::c_int = 0x800;
154pub const S_ISGID: ::c_int = 0x400;
155pub const S_ISVTX: ::c_int = 0x200;
156
David Henningsson9d2493e2015-12-25 22:06:44 +0100157pub const POLLIN: ::c_short = 0x1;
158pub const POLLPRI: ::c_short = 0x2;
159pub const POLLOUT: ::c_short = 0x4;
160pub const POLLERR: ::c_short = 0x8;
161pub const POLLHUP: ::c_short = 0x10;
162pub const POLLNVAL: ::c_short = 0x20;
163
Kamal Marhubi0a5dcf02016-01-25 15:20:46 -0500164pub const IF_NAMESIZE: ::size_t = 16;
165
Alex Crichton29de5982016-02-04 13:48:13 -0800166pub const RTLD_LAZY: ::c_int = 0x1;
167
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100168pub const LOG_EMERG: ::c_int = 0;
169pub const LOG_ALERT: ::c_int = 1;
170pub const LOG_CRIT: ::c_int = 2;
171pub const LOG_ERR: ::c_int = 3;
172pub const LOG_WARNING: ::c_int = 4;
173pub const LOG_NOTICE: ::c_int = 5;
174pub const LOG_INFO: ::c_int = 6;
175pub const LOG_DEBUG: ::c_int = 7;
176
177pub const LOG_KERN: ::c_int = 0;
178pub const LOG_USER: ::c_int = 1 << 3;
179pub const LOG_MAIL: ::c_int = 2 << 3;
180pub const LOG_DAEMON: ::c_int = 3 << 3;
181pub const LOG_AUTH: ::c_int = 4 << 3;
182pub const LOG_SYSLOG: ::c_int = 5 << 3;
183pub const LOG_LPR: ::c_int = 6 << 3;
184pub const LOG_NEWS: ::c_int = 7 << 3;
185pub const LOG_UUCP: ::c_int = 8 << 3;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100186pub const LOG_LOCAL0: ::c_int = 16 << 3;
187pub const LOG_LOCAL1: ::c_int = 17 << 3;
188pub const LOG_LOCAL2: ::c_int = 18 << 3;
189pub const LOG_LOCAL3: ::c_int = 19 << 3;
190pub const LOG_LOCAL4: ::c_int = 20 << 3;
191pub const LOG_LOCAL5: ::c_int = 21 << 3;
192pub const LOG_LOCAL6: ::c_int = 22 << 3;
193pub const LOG_LOCAL7: ::c_int = 23 << 3;
194
195pub const LOG_PID: ::c_int = 0x01;
196pub const LOG_CONS: ::c_int = 0x02;
197pub const LOG_ODELAY: ::c_int = 0x04;
198pub const LOG_NDELAY: ::c_int = 0x08;
199pub const LOG_NOWAIT: ::c_int = 0x10;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100200
201pub const LOG_PRIMASK: ::c_int = 7;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100202pub const LOG_FACMASK: ::c_int = 0x3f8;
203
Raphael Cohnfabef1d2016-05-19 14:28:40 +0100204pub const PRIO_PROCESS: ::c_int = 0;
205pub const PRIO_PGRP: ::c_int = 1;
206pub const PRIO_USER: ::c_int = 2;
207
208pub const PRIO_MIN: ::c_int = -20;
209pub const PRIO_MAX: ::c_int = 20;
210
Alex Crichton2c57e362015-09-15 17:30:53 -0700211cfg_if! {
Alex Crichtona28ec432016-04-01 10:43:06 -0700212 if #[cfg(dox)] {
213 // on dox builds don't pull in anything
214 } else if #[cfg(all(not(stdbuild), feature = "use_std"))] {
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700215 // cargo build, don't pull in anything extra as the libstd dep
Alex Crichton2c57e362015-09-15 17:30:53 -0700216 // already pulls in all libs.
Jorge Aparicio23a50922016-07-26 16:13:03 -0500217 } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] {
Alex Crichtonf9323d12016-10-31 16:44:29 -0700218 #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))]
219 #[link(name = "c", cfg(not(target_feature = "crt-static")))]
Alex Crichton2c57e362015-09-15 17:30:53 -0700220 extern {}
Brian Anderson7d1d5752015-11-26 23:27:45 +0000221 } else if #[cfg(target_os = "emscripten")] {
222 #[link(name = "c")]
223 extern {}
Alex Crichtondfd196e2016-04-11 10:16:45 -0700224 } else if #[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))] {
Alex Crichton8a8bc662016-02-29 23:02:36 -0800225 // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled
226 // in automatically by the linker. We avoid passing it explicitly, as it
Sebastian Wicki37d4bb92016-02-27 14:27:10 +0100227 // causes some versions of binutils to crash with an assertion failure.
228 #[link(name = "m")]
229 extern {}
Alex Crichton0c8e61a2015-11-22 10:14:13 -0800230 } else if #[cfg(any(target_os = "macos",
231 target_os = "ios",
Sébastien Marieb83e43b2015-11-26 19:54:24 +0100232 target_os = "android",
233 target_os = "openbsd",
234 target_os = "bitrig"))] {
Alex Crichton68a5c442015-11-20 09:28:12 -0800235 #[link(name = "c")]
236 #[link(name = "m")]
237 extern {}
Niels Sascha Reedijka3ff9552016-02-02 21:21:36 +0100238 } else if #[cfg(target_os = "haiku")] {
239 #[link(name = "root")]
240 #[link(name = "network")]
241 extern {}
Raph Levien517e86d2016-10-11 15:26:47 -0700242 } else if #[cfg(target_os = "fuchsia")] {
243 #[link(name = "c")]
244 #[link(name = "mxio")]
Raph Levien517e86d2016-10-11 15:26:47 -0700245 extern {}
Alex Crichton2c57e362015-09-15 17:30:53 -0700246 } else {
247 #[link(name = "c")]
248 #[link(name = "m")]
Alex Crichton68a5c442015-11-20 09:28:12 -0800249 #[link(name = "rt")]
Anatol Pomozova763fc52017-04-01 10:51:33 -0700250 #[link(name = "pthread")]
Alex Crichton2c57e362015-09-15 17:30:53 -0700251 extern {}
252 }
253}
254
Alex Crichton5d6cf052015-09-11 14:52:34 -0700255extern {
Knight263970d2016-07-31 16:58:17 +0800256 pub fn getgrnam(name: *const ::c_char) -> *mut group;
257 pub fn getgrgid(gid: ::gid_t) -> *mut group;
258
Knight19fb32a2016-07-31 17:00:15 +0800259 pub fn endpwent();
260 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
261 pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
262 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
263 pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
264
bluss1ebfe632016-04-13 18:44:56 +0200265 pub fn fprintf(stream: *mut ::FILE,
266 format: *const ::c_char, ...) -> ::c_int;
bluss9111f242016-04-13 18:13:13 +0200267 pub fn printf(format: *const ::c_char, ...) -> ::c_int;
268 pub fn snprintf(s: *mut ::c_char, n: ::size_t,
269 format: *const ::c_char, ...) -> ::c_int;
270 pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
271 pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
272 pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
273 pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
Martin Muñoz5ec77152016-09-25 16:31:30 -0400274 pub fn getchar_unlocked() -> ::c_int;
275 pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
bluss9111f242016-04-13 18:13:13 +0200276
Alex Crichton49d7bca2015-11-27 09:40:37 -0800277 #[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
Alex Crichton17910462015-09-22 19:11:04 -0700278 pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700279 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
280 link_name = "connect$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700281 pub fn connect(socket: ::c_int, address: *const sockaddr,
282 len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700283 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700284 link_name = "listen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700285 pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700286 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
287 link_name = "accept$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700288 pub fn accept(socket: ::c_int, address: *mut sockaddr,
289 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700290 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
291 link_name = "getpeername$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700292 pub fn getpeername(socket: ::c_int, address: *mut sockaddr,
293 address_len: *mut socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700294 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
295 link_name = "getsockname$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700296 pub fn getsockname(socket: ::c_int, address: *mut sockaddr,
297 address_len: *mut socklen_t) -> ::c_int;
298 pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -0700299 value: *const ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700300 option_len: socklen_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700301 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Steven Facklere6c00c22015-11-03 21:10:08 -0800302 link_name = "socketpair$UNIX2003")]
303 pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int,
304 socket_vector: *mut ::c_int) -> ::c_int;
305 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700306 link_name = "sendto$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700307 pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
308 flags: ::c_int, addr: *const sockaddr,
309 addrlen: socklen_t) -> ::ssize_t;
310 pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700311
312 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
313 link_name = "chmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700314 pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700315 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
316 link_name = "fchmod$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700317 pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700318
319 #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800320 #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700321 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700322
Alex Crichton17910462015-09-22 19:11:04 -0700323 pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700324
Alex Crichton084f9ea2015-09-11 15:11:59 -0700325 #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800326 #[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700327 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700328
329 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
330 link_name = "popen$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700331 pub fn popen(command: *const c_char,
332 mode: *const c_char) -> *mut ::FILE;
Alex Crichton17910462015-09-22 19:11:04 -0700333 pub fn pclose(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700334 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
335 link_name = "fdopen$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700336 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
337 pub fn fileno(stream: *mut ::FILE) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700338
339 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
340 link_name = "open$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700341 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700342 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
343 link_name = "creat$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700344 pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700345 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
346 link_name = "fcntl$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700347 pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700348
349 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
350 link_name = "opendir$INODE64")]
351 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
352 link_name = "opendir$INODE64$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800353 #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700354 pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
Raph Leviene0100782017-02-21 15:07:03 -0800355 #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")]
356 #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")]
Raph Levien02990f22017-02-21 19:13:16 -0800357 pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700358 #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800359 #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")]
Shawn Walker-Salas6740a8a2017-02-15 16:19:06 -0800360 #[cfg_attr(target_os = "solaris", link_name = "__posix_readdir_r")]
Alex Crichton5d6cf052015-09-11 14:52:34 -0700361 pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent,
Alex Crichton74825222015-10-29 17:36:55 -0700362 result: *mut *mut ::dirent) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700363 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
364 link_name = "closedir$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700365 pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700366 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
367 link_name = "rewinddir$INODE64")]
368 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
369 link_name = "rewinddir$INODE64$UNIX2003")]
370 pub fn rewinddir(dirp: *mut ::DIR);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700371
Jörg Thalheim64f89332017-03-20 16:10:01 +0100372 pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
373 flags: ::c_int, ...) -> ::c_int;
374 pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
375 mode: ::c_int, flags: ::c_int) -> ::c_int;
376 pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
377 mode: ::mode_t, flags: ::c_int) -> ::c_int;
Jörg Thalheime6864db2017-03-29 20:51:44 +0200378 pub fn fchown(fd: ::c_int,
379 owner: ::uid_t,
380 group: ::gid_t) -> ::c_int;
Jörg Thalheim64f89332017-03-20 16:10:01 +0100381 pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char,
382 owner: ::uid_t, group: ::gid_t,
383 flags: ::c_int) -> ::c_int;
384 #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")]
385 pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char,
386 buf: *mut stat, flags: ::c_int) -> ::c_int;
387 pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char,
388 newdirfd: ::c_int, newpath: *const ::c_char,
389 flags: ::c_int) -> ::c_int;
390 pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char,
391 mode: ::mode_t) -> ::c_int;
392 pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char,
393 buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t;
394 pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char,
395 newdirfd: ::c_int, newpath: *const ::c_char)
396 -> ::c_int;
397 pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int,
398 linkpath: *const ::c_char) -> ::c_int;
399 pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
400 flags: ::c_int) -> ::c_int;
401
Alex Crichton17910462015-09-22 19:11:04 -0700402 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
403 pub fn alarm(seconds: ::c_uint) -> ::c_uint;
404 pub fn chdir(dir: *const c_char) -> ::c_int;
Luca Bruno7a260792017-01-15 16:51:01 +0000405 pub fn fchdir(dirfd: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700406 pub fn chown(path: *const c_char, uid: uid_t,
Alex Crichton17910462015-09-22 19:11:04 -0700407 gid: gid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700408 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Knighte383ee72016-06-22 16:53:14 +0800409 link_name = "lchown$UNIX2003")]
410 pub fn lchown(path: *const c_char, uid: uid_t,
411 gid: gid_t) -> ::c_int;
412 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Bryant Mairs9b9f36a2017-05-18 10:06:36 -0700413 link_name = "close$NOCANCEL$UNIX2003")]
414 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
415 link_name = "close$NOCANCEL")]
Alex Crichton17910462015-09-22 19:11:04 -0700416 pub fn close(fd: ::c_int) -> ::c_int;
417 pub fn dup(fd: ::c_int) -> ::c_int;
418 pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
Philipp Kellerda3774f2016-12-28 14:22:47 +0100419 pub fn execl(path: *const c_char,
420 arg0: *const c_char, ...) -> ::c_int;
Philipp Keller9d562b92016-12-29 11:25:51 +0100421 pub fn execle(path: *const ::c_char,
Philipp Kellerda3774f2016-12-28 14:22:47 +0100422 arg0: *const ::c_char, ...) -> ::c_int;
423 pub fn execlp(file: *const ::c_char,
424 arg0: *const ::c_char, ...) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700425 pub fn execv(prog: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700426 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700427 pub fn execve(prog: *const c_char, argv: *const *const c_char,
428 envp: *const *const c_char)
Alex Crichton17910462015-09-22 19:11:04 -0700429 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700430 pub fn execvp(c: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700431 argv: *const *const c_char) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700432 pub fn fork() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700433 pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
434 pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
Alex Crichton50a42e22015-09-15 14:27:15 -0700435 pub fn getegid() -> gid_t;
436 pub fn geteuid() -> uid_t;
437 pub fn getgid() -> gid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700438 pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t)
439 -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700440 pub fn getlogin() -> *mut c_char;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700441 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
442 link_name = "getopt$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700443 pub fn getopt(argc: ::c_int, argv: *const *mut c_char,
444 optstr: *const c_char) -> ::c_int;
Corey Farwell68dba7a2016-08-03 08:21:45 -0400445 pub fn getpgid(pid: pid_t) -> pid_t;
Alex Crichton50a42e22015-09-15 14:27:15 -0700446 pub fn getpgrp() -> pid_t;
447 pub fn getpid() -> pid_t;
448 pub fn getppid() -> pid_t;
449 pub fn getuid() -> uid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700450 pub fn isatty(fd: ::c_int) -> ::c_int;
451 pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700452 pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
Alex Crichton17910462015-09-22 19:11:04 -0700453 pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700454 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
455 link_name = "pause$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700456 pub fn pause() -> ::c_int;
457 pub fn pipe(fds: *mut ::c_int) -> ::c_int;
Tamir Duberstein0b102fd2016-01-06 18:16:05 -0500458 pub fn posix_memalign(memptr: *mut *mut ::c_void,
459 align: ::size_t,
460 size: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700461 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
462 link_name = "read$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700463 pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
464 -> ::ssize_t;
465 pub fn rmdir(path: *const c_char) -> ::c_int;
466 pub fn setgid(gid: gid_t) -> ::c_int;
467 pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700468 pub fn setsid() -> pid_t;
Alex Crichton17910462015-09-22 19:11:04 -0700469 pub fn setuid(uid: uid_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700470 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
471 link_name = "sleep$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700472 pub fn sleep(secs: ::c_uint) -> ::c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700473 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700474 link_name = "nanosleep$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800475 #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700476 pub fn nanosleep(rqtp: *const timespec,
Alex Crichton17910462015-09-22 19:11:04 -0700477 rmtp: *mut timespec) -> ::c_int;
478 pub fn tcgetpgrp(fd: ::c_int) -> pid_t;
zethrac21a30c2016-10-27 16:01:18 -0400479 pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int;
Alex Crichton17910462015-09-22 19:11:04 -0700480 pub fn ttyname(fd: ::c_int) -> *mut c_char;
481 pub fn unlink(c: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700482 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
483 link_name = "wait$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700484 pub fn wait(status: *mut ::c_int) -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700485 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
486 link_name = "waitpid$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700487 pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
Alex Crichton50a42e22015-09-15 14:27:15 -0700488 -> pid_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700489 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
490 link_name = "write$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700491 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
492 -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700493 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
494 link_name = "pread$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700495 pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
496 offset: off_t) -> ::ssize_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700497 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
498 link_name = "pwrite$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700499 pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
500 offset: off_t) -> ::ssize_t;
Andy Caldwelldd54f292015-11-30 00:24:15 +0000501 pub fn umask(mask: mode_t) -> mode_t;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800502
503 #[cfg_attr(target_os = "netbsd", link_name = "__utime50")]
Alex Crichton17910462015-09-22 19:11:04 -0700504 pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700505
506 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
507 link_name = "kill$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700508 pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700509
Alex Crichton17910462015-09-22 19:11:04 -0700510 pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
511 pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int;
512 pub fn mlockall(flags: ::c_int) -> ::c_int;
513 pub fn munlockall() -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700514
515 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton5d6cf052015-09-11 14:52:34 -0700516 link_name = "mmap$UNIX2003")]
517 pub fn mmap(addr: *mut ::c_void,
Alex Crichton17910462015-09-22 19:11:04 -0700518 len: ::size_t,
519 prot: ::c_int,
520 flags: ::c_int,
521 fd: ::c_int,
Alex Crichton50a42e22015-09-15 14:27:15 -0700522 offset: off_t)
Alex Crichton5d6cf052015-09-11 14:52:34 -0700523 -> *mut ::c_void;
524 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
525 link_name = "munmap$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700526 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700527
Alex Crichton17910462015-09-22 19:11:04 -0700528 pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint;
Alex Crichton8a8bc662016-02-29 23:02:36 -0800529 pub fn if_indextoname(ifindex: ::c_uint,
530 ifname: *mut ::c_char) -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700531
532 #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800533 #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")]
Alex Crichton17910462015-09-22 19:11:04 -0700534 pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700535
Alex Crichton5d6cf052015-09-11 14:52:34 -0700536 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
537 link_name = "fsync$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700538 pub fn fsync(fd: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700539
Alex Crichton5d6cf052015-09-11 14:52:34 -0700540 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
541 link_name = "setenv$UNIX2003")]
Alex Crichton50a42e22015-09-15 14:27:15 -0700542 pub fn setenv(name: *const c_char, val: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700543 overwrite: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700544 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
545 link_name = "unsetenv$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800546 #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")]
Alex Crichton17910462015-09-22 19:11:04 -0700547 pub fn unsetenv(name: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700548
Alex Crichton50a42e22015-09-15 14:27:15 -0700549 pub fn symlink(path1: *const c_char,
Alex Crichton17910462015-09-22 19:11:04 -0700550 path2: *const c_char) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700551
Alex Crichton17910462015-09-22 19:11:04 -0700552 pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700553
Alex Crichton17910462015-09-22 19:11:04 -0700554 pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700555
Alex Crichtonde9736d2015-09-17 15:47:44 -0700556 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
557 link_name = "getrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700558 pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700559 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
560 link_name = "setrlimit$UNIX2003")]
Alex Crichton17910462015-09-22 19:11:04 -0700561 pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800562 #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
Alex Crichton17910462015-09-22 19:11:04 -0700563 pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700564
Alex Crichton17910462015-09-22 19:11:04 -0700565 pub fn getdtablesize() -> ::c_int;
Alex Crichtonbaef6112015-09-19 23:20:53 -0700566 #[cfg_attr(any(target_os = "macos", target_os = "ios"),
567 link_name = "realpath$DARWIN_EXTSN")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700568 pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
569 -> *mut ::c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700570
Alex Crichton17910462015-09-22 19:11:04 -0700571 pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
Alex Crichton50a42e22015-09-15 14:27:15 -0700572
Andrew Salmone976c372017-05-26 04:07:01 -0700573 #[cfg_attr(target_os = "netbsd", link_name = "__getitimer50")]
574 pub fn getitimer(which: ::c_int, curr_value: *mut ::itimerval) -> ::c_int;
575 #[cfg_attr(target_os = "netbsd", link_name = "__setitimer50")]
576 pub fn setitimer(which: ::c_int,
577 new_value: *::itimerval,
578 old_value: *::itimerval) -> ::c_int;
Jason Travis Smith270c7d42016-02-06 05:46:41 -0500579 #[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700580 pub fn gettimeofday(tp: *mut ::timeval,
581 tz: *mut ::c_void) -> ::c_int;
582
583 pub fn pthread_self() -> ::pthread_t;
584 pub fn pthread_create(native: *mut ::pthread_t,
585 attr: *const ::pthread_attr_t,
586 f: extern fn(*mut ::c_void) -> *mut ::c_void,
587 value: *mut ::c_void) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700588 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
589 link_name = "pthread_join$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700590 pub fn pthread_join(native: ::pthread_t,
591 value: *mut *mut ::c_void) -> ::c_int;
Marco A L Barbosa91924352017-04-20 15:01:52 -0300592 pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
593 parent: Option<unsafe extern fn()>,
594 child: Option<unsafe extern fn()>) -> ::c_int;
Philipp Keller828c64c2017-02-19 13:40:29 +0100595 pub fn pthread_exit(value: *mut ::c_void);
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700596 pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
597 pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
598 pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t,
599 stack_size: ::size_t) -> ::c_int;
600 pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t,
601 state: ::c_int) -> ::c_int;
602 pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800603 #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700604 pub fn sched_yield() -> ::c_int;
605 pub fn pthread_key_create(key: *mut pthread_key_t,
Alex Crichton8a8bc662016-02-29 23:02:36 -0800606 dtor: Option<unsafe extern fn(*mut ::c_void)>)
Alex Crichton17910462015-09-22 19:11:04 -0700607 -> ::c_int;
608 pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700609 pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
610 pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void)
Alex Crichton17910462015-09-22 19:11:04 -0700611 -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700612 pub fn pthread_mutex_init(lock: *mut pthread_mutex_t,
613 attr: *const pthread_mutexattr_t) -> ::c_int;
614 pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int;
615 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int;
616 pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int;
617 pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int;
618
619 pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700620 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
621 link_name = "pthread_mutexattr_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700622 pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int;
623 pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
624 _type: ::c_int) -> ::c_int;
625
Alex Crichtonde9736d2015-09-17 15:47:44 -0700626 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Tomasz MiÄ…skocb644852016-07-20 07:31:48 +0200627 link_name = "pthread_cond_init$UNIX2003")]
628 pub fn pthread_cond_init(cond: *mut pthread_cond_t,
629 attr: *const pthread_condattr_t) -> ::c_int;
630 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichtonde9736d2015-09-17 15:47:44 -0700631 link_name = "pthread_cond_wait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700632 pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
633 lock: *mut pthread_mutex_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700634 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
635 link_name = "pthread_cond_timedwait$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700636 pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t,
637 lock: *mut pthread_mutex_t,
638 abstime: *const ::timespec) -> ::c_int;
639 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
640 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
641 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
Tomasz MiÄ…skocb644852016-07-20 07:31:48 +0200642 pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
643 pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700644 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
645 link_name = "pthread_rwlock_destroy$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700646 pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700647 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
648 link_name = "pthread_rwlock_rdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700649 pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700650 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
651 link_name = "pthread_rwlock_tryrdlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700652 pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700653 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
654 link_name = "pthread_rwlock_wrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700655 pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700656 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
657 link_name = "pthread_rwlock_trywrlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700658 pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700659 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
660 link_name = "pthread_rwlock_unlock$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700661 pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700662 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
663 link_name = "pthread_sigmask$UNIX2003")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700664 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
665 oldset: *mut sigset_t) -> ::c_int;
Tomasz MiÄ…skob0b33702016-02-15 11:00:11 +0100666 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
NODA, Kai75a69bf2016-04-03 20:59:44 +0800667 #[cfg_attr(all(target_os = "linux", not(target_env = "musl")),
668 link_name = "__xpg_strerror_r")]
Alex Crichton17910462015-09-22 19:11:04 -0700669 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
670 buflen: ::size_t) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700671
672 pub fn getsockopt(sockfd: ::c_int,
673 level: ::c_int,
674 optname: ::c_int,
675 optval: *mut ::c_void,
676 optlen: *mut ::socklen_t) -> ::c_int;
677 pub fn raise(signum: ::c_int) -> ::c_int;
Sebastian Wickib7c3e5c2016-02-26 21:58:19 +0100678 #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700679 pub fn sigaction(signum: ::c_int,
680 act: *const sigaction,
681 oldact: *mut sigaction) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700682 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
683 link_name = "sigaltstack$UNIX2003")]
Sebastian Wickib7c3e5c2016-02-26 21:58:19 +0100684 #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
Alex Crichtonde9736d2015-09-17 15:47:44 -0700685 pub fn sigaltstack(ss: *const stack_t,
686 oss: *mut stack_t) -> ::c_int;
Philipp Matthias Schaeferc1982a42016-02-28 16:06:45 +0100687 #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
688 link_name = "sigwait$UNIX2003")]
Shawn Walker-Salas6740a8a2017-02-15 16:19:06 -0800689 #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
Philipp Matthias Schaeferc1982a42016-02-28 16:06:45 +0100690 pub fn sigwait(set: *const sigset_t,
691 sig: *mut ::c_int) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700692
Alex Crichton49d7bca2015-11-27 09:40:37 -0800693 #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700694 pub fn utimes(filename: *const ::c_char,
695 times: *const ::timeval) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700696 pub fn dlopen(filename: *const ::c_char,
697 flag: ::c_int) -> *mut ::c_void;
698 pub fn dlerror() -> *mut ::c_char;
699 pub fn dlsym(handle: *mut ::c_void,
700 symbol: *const ::c_char) -> *mut ::c_void;
701 pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
Alex Crichton88d23e72015-11-02 17:03:19 -0800702 pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
Alex Crichtonb9096d32015-11-03 10:08:44 -0800703
704 pub fn getaddrinfo(node: *const c_char,
705 service: *const c_char,
706 hints: *const addrinfo,
707 res: *mut *mut addrinfo) -> ::c_int;
708 pub fn freeaddrinfo(res: *mut addrinfo);
709 pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
Jon Gjengsetb3700e42017-05-03 13:41:00 -0400710 #[cfg_attr(any(
711 all(target_os = "linux", not(target_env = "musl")),
712 target_os = "freebsd",
713 target_os = "dragonfly"),
Jon Gjengsetef20ddb2017-04-26 22:39:52 -0400714 link_name = "__res_init")]
715 #[cfg_attr(any(target_os = "macos", target_os = "ios"),
716 link_name = "res_9_init")]
717 pub fn res_init() -> ::c_int;
Alex Crichton568705e2015-11-03 14:18:52 -0800718
Alex Crichton49d7bca2015-11-27 09:40:37 -0800719 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800720 pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
Alex Crichton49d7bca2015-11-27 09:40:37 -0800721 #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800722 pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
723 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
724 link_name = "mktime$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800725 #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
Alex Crichton568705e2015-11-03 14:18:52 -0800726 pub fn mktime(tm: *mut tm) -> time_t;
Philipp Kellera77ea862016-09-23 22:00:18 +0200727 #[cfg_attr(target_os = "netbsd", link_name = "__time50")]
728 pub fn time(time: *mut time_t) -> time_t;
Andrew Salmon7efffc12017-05-25 15:14:19 -0700729 #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
730 pub fn gmtime(time_p: *const time_t) -> *mut tm;
Philipp Kellera77ea862016-09-23 22:00:18 +0200731 #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
Andrew Salmon7efffc12017-05-25 15:14:19 -0700732 pub fn localtime(time_p: *const time_t) -> *mut tm;
Philipp Kellera77ea862016-09-23 22:00:18 +0200733
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800734 #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
735 pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
736 dev: ::dev_t) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800737 pub fn uname(buf: *mut ::utsname) -> ::c_int;
738 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
739 pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
740 pub fn chroot(name: *const ::c_char) -> ::c_int;
Alex Crichton881ef9b2015-12-01 09:04:13 -0800741 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
742 link_name = "usleep$UNIX2003")]
743 pub fn usleep(secs: ::c_uint) -> ::c_int;
744 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
745 link_name = "send$UNIX2003")]
746 pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t,
747 flags: ::c_int) -> ::ssize_t;
748 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
749 link_name = "recv$UNIX2003")]
750 pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
751 flags: ::c_int) -> ::ssize_t;
752 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
753 link_name = "putenv$UNIX2003")]
754 #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")]
755 pub fn putenv(string: *mut c_char) -> ::c_int;
756 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
David Henningsson9d2493e2015-12-25 22:06:44 +0100757 link_name = "poll$UNIX2003")]
758 pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
Alex Crichton993ea7e2016-03-01 13:23:53 -0800759 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
760 link_name = "select$1050")]
761 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
762 link_name = "select$UNIX2003")]
763 #[cfg_attr(target_os = "netbsd", link_name = "__select50")]
764 pub fn select(nfds: ::c_int,
765 readfs: *mut fd_set,
766 writefds: *mut fd_set,
767 errorfds: *mut fd_set,
768 timeout: *mut timeval) -> ::c_int;
A.J. Gardner5399c892016-03-30 23:09:25 -0500769 #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")]
A.J. Gardner2bd6f122016-03-30 00:55:49 -0500770 pub fn setlocale(category: ::c_int,
771 locale: *const ::c_char) -> *mut ::c_char;
A.J. Gardner110152c2016-03-30 00:36:43 -0500772 pub fn localeconv() -> *mut lconv;
Steven Fackler41699f72016-06-03 21:02:56 -0700773
774 pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
775 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
776 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
777 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
778 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
779 link_name = "sem_wait$UNIX2003")]
780 pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
781 pub fn sem_trywait(sem: *mut sem_t) -> ::c_int;
782 pub fn sem_post(sem: *mut sem_t) -> ::c_int;
783 pub fn sem_init(sem: *mut sem_t,
784 pshared: ::c_int,
785 value: ::c_uint)
786 -> ::c_int;
Marco A L Barbosabad80ba2017-02-21 16:58:03 -0300787 pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
788 pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
Marco A L Barbosa92ce5182017-02-23 18:15:02 -0300789
790 pub fn readlink(path: *const c_char,
791 buf: *mut c_char,
792 bufsz: ::size_t)
793 -> ::ssize_t;
794
795 #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
796 pub fn sigemptyset(set: *mut sigset_t) -> ::c_int;
797 #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")]
798 pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
799 #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")]
800 pub fn sigfillset(set: *mut sigset_t) -> ::c_int;
801 #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")]
802 pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int;
803 #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
804 pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
805
Matthew Kilgore53069832017-04-25 00:32:17 -0400806 #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
807 pub fn sigprocmask(how: ::c_int,
808 set: *const sigset_t,
809 oldset: *mut sigset_t)
810 -> ::c_int;
811
Marco A L Barbosa92ce5182017-02-23 18:15:02 -0300812 #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
813 pub fn timegm(tm: *mut ::tm) -> time_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700814
815 pub fn getsid(pid: pid_t) -> pid_t;
Alex Crichton1ff96102015-09-17 15:09:02 -0700816
Marco A L Barbosafab2d302017-02-27 16:41:57 -0300817 pub fn sysconf(name: ::c_int) -> ::c_long;
818
Alex Crichton17910462015-09-22 19:11:04 -0700819 pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
Alex Crichton1ff96102015-09-17 15:09:02 -0700820
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700821 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700822 link_name = "pselect$1050")]
823 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
824 link_name = "pselect$UNIX2003")]
Alex Crichton49d7bca2015-11-27 09:40:37 -0800825 #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")]
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700826 pub fn pselect(nfds: ::c_int,
827 readfs: *mut fd_set,
828 writefds: *mut fd_set,
829 errorfds: *mut fd_set,
830 timeout: *const timespec,
831 sigmask: *const sigset_t) -> ::c_int;
Alex Crichton74825222015-10-29 17:36:55 -0700832 pub fn fseeko(stream: *mut ::FILE,
833 offset: ::off_t,
834 whence: ::c_int) -> ::c_int;
835 pub fn ftello(stream: *mut ::FILE) -> ::off_t;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800836 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800837 link_name = "tcdrain$UNIX2003")]
838 pub fn tcdrain(fd: ::c_int) -> ::c_int;
839 pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t;
840 pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t;
Bryant Mairs39e554f2017-02-26 13:16:12 -0800841 pub fn cfmakeraw(termios: *mut ::termios);
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800842 pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
843 pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
Bryant Mairs39e554f2017-02-26 13:16:12 -0800844 pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800845 pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int;
846 pub fn tcsetattr(fd: ::c_int,
847 optional_actions: ::c_int,
848 termios: *const ::termios) -> ::c_int;
849 pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
850 pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
851 pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
Kamal Marhubi511a7802016-02-15 00:40:19 -0500852 pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
Kamal Marhubi511a7802016-02-15 00:40:19 -0500853 pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100854
Philipp Keller0d16c4a2016-12-30 22:26:18 +0100855 pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char;
Raphael Cohn7e0dbc32016-05-04 11:47:02 +0100856
857 pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
858 pub fn closelog();
859 pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
860 pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
Raphael Cohnfabef1d2016-05-19 14:28:40 +0100861 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
862 link_name = "nice$UNIX2003")]
863 pub fn nice(incr: ::c_int) -> ::c_int;
Robbie Harwoodb9f5c462016-10-18 20:50:11 -0400864
Robbie Harwoodb9f5c462016-10-18 20:50:11 -0400865 pub fn grantpt(fd: ::c_int) -> ::c_int;
866 pub fn posix_openpt(flags: ::c_int) -> ::c_int;
867 pub fn ptsname(fd: ::c_int) -> *mut ::c_char;
Robbie Harwoodb9f5c462016-10-18 20:50:11 -0400868 pub fn unlockpt(fd: ::c_int) -> ::c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700869}
Alex Crichtond3d77922015-09-11 17:03:39 -0700870
871cfg_if! {
Kelvin Ly6e4beb62017-04-24 21:08:24 -0400872 if #[cfg(target_env = "uclibc")] {
873 mod uclibc;
874 pub use self::uclibc::*;
875 } else if #[cfg(any(target_os = "linux",
Kelvin Lyc14178c2017-04-26 23:01:05 -0400876 target_os = "android",
877 target_os = "emscripten",
878 target_os = "fuchsia"))] {
Alex Crichton50a42e22015-09-15 14:27:15 -0700879 mod notbsd;
880 pub use self::notbsd::*;
881 } else if #[cfg(any(target_os = "macos",
Alex Crichtonbaef6112015-09-19 23:20:53 -0700882 target_os = "ios",
Alex Crichton50a42e22015-09-15 14:27:15 -0700883 target_os = "freebsd",
884 target_os = "dragonfly",
885 target_os = "openbsd",
886 target_os = "netbsd",
887 target_os = "bitrig"))] {
888 mod bsd;
889 pub use self::bsd::*;
Nikita Baksalyar702814f2016-01-28 10:30:54 +0300890 } else if #[cfg(target_os = "solaris")] {
891 mod solaris;
892 pub use self::solaris::*;
Niels Sascha Reedijka3ff9552016-02-02 21:21:36 +0100893 } else if #[cfg(target_os = "haiku")] {
894 mod haiku;
895 pub use self::haiku::*;
Alex Crichtond3d77922015-09-11 17:03:39 -0700896 } else {
Kamal Marhubi66c33752016-03-10 15:07:32 -0500897 // Unknown target_os
Alex Crichtond3d77922015-09-11 17:03:39 -0700898 }
899}