]>
Commit | Line | Data |
---|---|---|
92a42be0 SL |
1 | //! 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 | ||
54a0048b SL |
6 | use dox::Option; |
7 | ||
92a42be0 SL |
8 | pub type pid_t = i32; |
9 | pub type uid_t = u32; | |
10 | pub type gid_t = u32; | |
11 | pub type in_addr_t = u32; | |
12 | pub type in_port_t = u16; | |
13 | pub type sighandler_t = ::size_t; | |
9cc50fc6 | 14 | pub type cc_t = ::c_uchar; |
92a42be0 SL |
15 | |
16 | pub enum DIR {} | |
a7813a04 | 17 | pub enum locale_t {} |
92a42be0 SL |
18 | |
19 | s! { | |
9e0c209e SL |
20 | 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 | ||
92a42be0 SL |
27 | pub struct utimbuf { |
28 | 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 | ||
abe05a73 XL |
37 | // linux x32 compatibility |
38 | // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 | |
92a42be0 SL |
39 | pub struct timespec { |
40 | pub tv_sec: time_t, | |
abe05a73 XL |
41 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
42 | pub tv_nsec: i64, | |
43 | #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] | |
44 | pub tv_nsec: ::c_long, | |
92a42be0 SL |
45 | } |
46 | ||
47 | pub struct rlimit { | |
48 | pub rlim_cur: rlim_t, | |
49 | pub rlim_max: rlim_t, | |
50 | } | |
51 | ||
52 | pub struct rusage { | |
53 | pub ru_utime: timeval, | |
54 | pub ru_stime: timeval, | |
55 | pub ru_maxrss: c_long, | |
abe05a73 XL |
56 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
57 | __pad1: u32, | |
92a42be0 | 58 | pub ru_ixrss: c_long, |
abe05a73 XL |
59 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
60 | __pad2: u32, | |
92a42be0 | 61 | pub ru_idrss: c_long, |
abe05a73 XL |
62 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
63 | __pad3: u32, | |
92a42be0 | 64 | pub ru_isrss: c_long, |
abe05a73 XL |
65 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
66 | __pad4: u32, | |
92a42be0 | 67 | pub ru_minflt: c_long, |
abe05a73 XL |
68 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
69 | __pad5: u32, | |
92a42be0 | 70 | pub ru_majflt: c_long, |
abe05a73 XL |
71 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
72 | __pad6: u32, | |
92a42be0 | 73 | pub ru_nswap: c_long, |
abe05a73 XL |
74 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
75 | __pad7: u32, | |
92a42be0 | 76 | pub ru_inblock: c_long, |
abe05a73 XL |
77 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
78 | __pad8: u32, | |
92a42be0 | 79 | pub ru_oublock: c_long, |
abe05a73 XL |
80 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
81 | __pad9: u32, | |
92a42be0 | 82 | pub ru_msgsnd: c_long, |
abe05a73 XL |
83 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
84 | __pad10: u32, | |
92a42be0 | 85 | pub ru_msgrcv: c_long, |
abe05a73 XL |
86 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
87 | __pad11: u32, | |
92a42be0 | 88 | pub ru_nsignals: c_long, |
abe05a73 XL |
89 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
90 | __pad12: u32, | |
92a42be0 | 91 | pub ru_nvcsw: c_long, |
abe05a73 XL |
92 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
93 | __pad13: u32, | |
92a42be0 | 94 | pub ru_nivcsw: c_long, |
abe05a73 XL |
95 | #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] |
96 | __pad14: u32, | |
92a42be0 | 97 | |
3b2f2976 | 98 | #[cfg(any(target_env = "musl", target_os = "emscripten"))] |
92a42be0 SL |
99 | __reserved: [c_long; 16], |
100 | } | |
101 | ||
9cc50fc6 | 102 | #[cfg_attr(target_os = "netbsd", repr(packed))] |
92a42be0 SL |
103 | pub struct in_addr { |
104 | pub s_addr: in_addr_t, | |
105 | } | |
106 | ||
107 | pub struct in6_addr { | |
108 | pub s6_addr: [u8; 16], | |
109 | __align: [u32; 0], | |
110 | } | |
111 | ||
112 | pub struct ip_mreq { | |
113 | pub imr_multiaddr: in_addr, | |
114 | pub imr_interface: in_addr, | |
115 | } | |
116 | ||
117 | pub struct ipv6_mreq { | |
118 | pub ipv6mr_multiaddr: in6_addr, | |
119 | #[cfg(target_os = "android")] | |
120 | pub ipv6mr_interface: ::c_int, | |
121 | #[cfg(not(target_os = "android"))] | |
122 | pub ipv6mr_interface: ::c_uint, | |
123 | } | |
124 | ||
92a42be0 SL |
125 | pub struct hostent { |
126 | pub h_name: *mut ::c_char, | |
127 | pub h_aliases: *mut *mut ::c_char, | |
128 | pub h_addrtype: ::c_int, | |
129 | pub h_length: ::c_int, | |
130 | pub h_addr_list: *mut *mut ::c_char, | |
131 | } | |
9cc50fc6 SL |
132 | |
133 | pub struct iovec { | |
134 | pub iov_base: *mut ::c_void, | |
135 | pub iov_len: ::size_t, | |
136 | } | |
137 | ||
138 | pub struct pollfd { | |
139 | pub fd: ::c_int, | |
140 | pub events: ::c_short, | |
141 | pub revents: ::c_short, | |
142 | } | |
54a0048b SL |
143 | |
144 | pub struct winsize { | |
145 | pub ws_row: ::c_ushort, | |
146 | pub ws_col: ::c_ushort, | |
147 | pub ws_xpixel: ::c_ushort, | |
148 | pub ws_ypixel: ::c_ushort, | |
149 | } | |
5bcae85e SL |
150 | |
151 | pub struct linger { | |
152 | pub l_onoff: ::c_int, | |
153 | pub l_linger: ::c_int, | |
154 | } | |
476ff2be SL |
155 | |
156 | pub struct sigval { | |
157 | // Actually a union of an int and a void* | |
158 | pub sival_ptr: *mut ::c_void | |
159 | } | |
041b39d2 XL |
160 | |
161 | // <sys/time.h> | |
162 | pub struct itimerval { | |
163 | pub it_interval: ::timeval, | |
164 | pub it_value: ::timeval, | |
165 | } | |
166 | ||
167 | // <sys/times.h> | |
168 | pub struct tms { | |
169 | pub tms_utime: ::clock_t, | |
170 | pub tms_stime: ::clock_t, | |
171 | pub tms_cutime: ::clock_t, | |
172 | pub tms_cstime: ::clock_t, | |
173 | } | |
abe05a73 XL |
174 | |
175 | pub struct servent { | |
176 | pub s_name: *mut ::c_char, | |
177 | pub s_aliases: *mut *mut ::c_char, | |
178 | pub s_port: ::c_int, | |
179 | pub s_proto: *mut ::c_char, | |
180 | } | |
181 | ||
182 | pub struct protoent { | |
183 | pub p_name: *mut ::c_char, | |
184 | pub p_aliases: *mut *mut ::c_char, | |
185 | pub p_proto: ::c_int, | |
186 | } | |
92a42be0 SL |
187 | } |
188 | ||
92a42be0 SL |
189 | pub const SIG_DFL: sighandler_t = 0 as sighandler_t; |
190 | pub const SIG_IGN: sighandler_t = 1 as sighandler_t; | |
191 | pub const SIG_ERR: sighandler_t = !0 as sighandler_t; | |
192 | ||
9cc50fc6 SL |
193 | pub const DT_FIFO: u8 = 1; |
194 | pub const DT_CHR: u8 = 2; | |
195 | pub const DT_DIR: u8 = 4; | |
196 | pub const DT_BLK: u8 = 6; | |
197 | pub const DT_REG: u8 = 8; | |
198 | pub const DT_LNK: u8 = 10; | |
199 | pub const DT_SOCK: u8 = 12; | |
200 | ||
201 | pub const FD_CLOEXEC: ::c_int = 0x1; | |
202 | ||
203 | pub const USRQUOTA: ::c_int = 0; | |
204 | pub const GRPQUOTA: ::c_int = 1; | |
205 | ||
206 | pub const SIGIOT: ::c_int = 6; | |
207 | ||
208 | pub const S_ISUID: ::c_int = 0x800; | |
209 | pub const S_ISGID: ::c_int = 0x400; | |
210 | pub const S_ISVTX: ::c_int = 0x200; | |
211 | ||
7453a54e SL |
212 | pub const IF_NAMESIZE: ::size_t = 16; |
213 | ||
a7813a04 XL |
214 | pub const LOG_EMERG: ::c_int = 0; |
215 | pub const LOG_ALERT: ::c_int = 1; | |
216 | pub const LOG_CRIT: ::c_int = 2; | |
217 | pub const LOG_ERR: ::c_int = 3; | |
218 | pub const LOG_WARNING: ::c_int = 4; | |
219 | pub const LOG_NOTICE: ::c_int = 5; | |
220 | pub const LOG_INFO: ::c_int = 6; | |
221 | pub const LOG_DEBUG: ::c_int = 7; | |
222 | ||
223 | pub const LOG_KERN: ::c_int = 0; | |
224 | pub const LOG_USER: ::c_int = 1 << 3; | |
225 | pub const LOG_MAIL: ::c_int = 2 << 3; | |
226 | pub const LOG_DAEMON: ::c_int = 3 << 3; | |
227 | pub const LOG_AUTH: ::c_int = 4 << 3; | |
228 | pub const LOG_SYSLOG: ::c_int = 5 << 3; | |
229 | pub const LOG_LPR: ::c_int = 6 << 3; | |
230 | pub const LOG_NEWS: ::c_int = 7 << 3; | |
231 | pub const LOG_UUCP: ::c_int = 8 << 3; | |
232 | pub const LOG_LOCAL0: ::c_int = 16 << 3; | |
233 | pub const LOG_LOCAL1: ::c_int = 17 << 3; | |
234 | pub const LOG_LOCAL2: ::c_int = 18 << 3; | |
235 | pub const LOG_LOCAL3: ::c_int = 19 << 3; | |
236 | pub const LOG_LOCAL4: ::c_int = 20 << 3; | |
237 | pub const LOG_LOCAL5: ::c_int = 21 << 3; | |
238 | pub const LOG_LOCAL6: ::c_int = 22 << 3; | |
239 | pub const LOG_LOCAL7: ::c_int = 23 << 3; | |
240 | ||
241 | pub const LOG_PID: ::c_int = 0x01; | |
242 | pub const LOG_CONS: ::c_int = 0x02; | |
243 | pub const LOG_ODELAY: ::c_int = 0x04; | |
244 | pub const LOG_NDELAY: ::c_int = 0x08; | |
245 | pub const LOG_NOWAIT: ::c_int = 0x10; | |
246 | ||
247 | pub const LOG_PRIMASK: ::c_int = 7; | |
248 | pub const LOG_FACMASK: ::c_int = 0x3f8; | |
249 | ||
3157f602 XL |
250 | pub const PRIO_PROCESS: ::c_int = 0; |
251 | pub const PRIO_PGRP: ::c_int = 1; | |
252 | pub const PRIO_USER: ::c_int = 2; | |
253 | ||
254 | pub const PRIO_MIN: ::c_int = -20; | |
255 | pub const PRIO_MAX: ::c_int = 20; | |
256 | ||
3b2f2976 XL |
257 | pub const IPPROTO_ICMP: ::c_int = 1; |
258 | pub const IPPROTO_ICMPV6: ::c_int = 58; | |
259 | pub const IPPROTO_TCP: ::c_int = 6; | |
260 | pub const IPPROTO_UDP: ::c_int = 17; | |
261 | pub const IPPROTO_IP: ::c_int = 0; | |
262 | pub const IPPROTO_IPV6: ::c_int = 41; | |
263 | ||
264 | pub const INADDR_LOOPBACK: in_addr_t = 2130706433; | |
265 | pub const INADDR_ANY: in_addr_t = 0; | |
266 | pub const INADDR_BROADCAST: in_addr_t = 4294967295; | |
267 | pub const INADDR_NONE: in_addr_t = 4294967295; | |
268 | ||
92a42be0 | 269 | cfg_if! { |
54a0048b SL |
270 | if #[cfg(dox)] { |
271 | // on dox builds don't pull in anything | |
3b2f2976 XL |
272 | } else if #[cfg(target_os = "l4re")] { |
273 | // required libraries for L4Re are linked externally, ATM | |
274 | } else if #[cfg(feature = "use_std")] { | |
275 | // cargo build, don't pull in anything extra as the libstd dep | |
92a42be0 | 276 | // already pulls in all libs. |
5bcae85e | 277 | } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] { |
476ff2be SL |
278 | #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))] |
279 | #[link(name = "c", cfg(not(target_feature = "crt-static")))] | |
92a42be0 | 280 | extern {} |
9cc50fc6 SL |
281 | } else if #[cfg(target_os = "emscripten")] { |
282 | #[link(name = "c")] | |
283 | extern {} | |
a7813a04 | 284 | } else if #[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))] { |
54a0048b SL |
285 | // Since we don't use -nodefaultlibs on Rumprun, libc is always pulled |
286 | // in automatically by the linker. We avoid passing it explicitly, as it | |
287 | // causes some versions of binutils to crash with an assertion failure. | |
288 | #[link(name = "m")] | |
289 | extern {} | |
92a42be0 SL |
290 | } else if #[cfg(any(target_os = "macos", |
291 | target_os = "ios", | |
292 | target_os = "android", | |
293 | target_os = "openbsd", | |
294 | target_os = "bitrig"))] { | |
295 | #[link(name = "c")] | |
296 | #[link(name = "m")] | |
297 | extern {} | |
9e0c209e SL |
298 | } else if #[cfg(target_os = "haiku")] { |
299 | #[link(name = "root")] | |
300 | #[link(name = "network")] | |
301 | extern {} | |
c30ab7b3 SL |
302 | } else if #[cfg(target_os = "fuchsia")] { |
303 | #[link(name = "c")] | |
3b2f2976 XL |
304 | #[link(name = "fdio")] |
305 | extern {} | |
306 | } else if #[cfg(target_env = "newlib")] { | |
307 | #[link(name = "c")] | |
308 | #[link(name = "m")] | |
c30ab7b3 | 309 | extern {} |
92a42be0 SL |
310 | } else { |
311 | #[link(name = "c")] | |
312 | #[link(name = "m")] | |
313 | #[link(name = "rt")] | |
cc61c64b | 314 | #[link(name = "pthread")] |
92a42be0 SL |
315 | extern {} |
316 | } | |
317 | } | |
318 | ||
319 | extern { | |
9e0c209e SL |
320 | #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")] |
321 | pub fn getpwnam(name: *const ::c_char) -> *mut passwd; | |
322 | #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")] | |
323 | pub fn getpwuid(uid: ::uid_t) -> *mut passwd; | |
324 | ||
a7813a04 XL |
325 | pub fn fprintf(stream: *mut ::FILE, |
326 | format: *const ::c_char, ...) -> ::c_int; | |
327 | pub fn printf(format: *const ::c_char, ...) -> ::c_int; | |
328 | pub fn snprintf(s: *mut ::c_char, n: ::size_t, | |
329 | format: *const ::c_char, ...) -> ::c_int; | |
330 | pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; | |
331 | pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int; | |
332 | pub fn scanf(format: *const ::c_char, ...) -> ::c_int; | |
333 | pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int; | |
9e0c209e SL |
334 | pub fn getchar_unlocked() -> ::c_int; |
335 | pub fn putchar_unlocked(c: ::c_int) -> ::c_int; | |
a7813a04 | 336 | |
9cc50fc6 | 337 | #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] |
92a42be0 SL |
338 | pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; |
339 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
340 | link_name = "connect$UNIX2003")] | |
341 | pub fn connect(socket: ::c_int, address: *const sockaddr, | |
342 | len: socklen_t) -> ::c_int; | |
92a42be0 SL |
343 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
344 | link_name = "listen$UNIX2003")] | |
345 | pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; | |
346 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
347 | link_name = "accept$UNIX2003")] | |
348 | pub fn accept(socket: ::c_int, address: *mut sockaddr, | |
349 | address_len: *mut socklen_t) -> ::c_int; | |
350 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
351 | link_name = "getpeername$UNIX2003")] | |
352 | pub fn getpeername(socket: ::c_int, address: *mut sockaddr, | |
353 | address_len: *mut socklen_t) -> ::c_int; | |
354 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
355 | link_name = "getsockname$UNIX2003")] | |
356 | pub fn getsockname(socket: ::c_int, address: *mut sockaddr, | |
357 | address_len: *mut socklen_t) -> ::c_int; | |
358 | pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int, | |
359 | value: *const ::c_void, | |
360 | option_len: socklen_t) -> ::c_int; | |
361 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
362 | link_name = "socketpair$UNIX2003")] | |
363 | pub fn socketpair(domain: ::c_int, type_: ::c_int, protocol: ::c_int, | |
364 | socket_vector: *mut ::c_int) -> ::c_int; | |
365 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
366 | link_name = "sendto$UNIX2003")] | |
367 | pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t, | |
368 | flags: ::c_int, addr: *const sockaddr, | |
369 | addrlen: socklen_t) -> ::ssize_t; | |
370 | pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; | |
371 | ||
372 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
373 | link_name = "chmod$UNIX2003")] | |
374 | pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int; | |
375 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
376 | link_name = "fchmod$UNIX2003")] | |
377 | pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int; | |
378 | ||
379 | #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] | |
9cc50fc6 | 380 | #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] |
92a42be0 SL |
381 | pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; |
382 | ||
383 | pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; | |
384 | ||
385 | #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] | |
9cc50fc6 | 386 | #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] |
92a42be0 SL |
387 | pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; |
388 | ||
92a42be0 SL |
389 | pub fn pclose(stream: *mut ::FILE) -> ::c_int; |
390 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
391 | link_name = "fdopen$UNIX2003")] | |
392 | pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; | |
393 | pub fn fileno(stream: *mut ::FILE) -> ::c_int; | |
394 | ||
395 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
396 | link_name = "open$UNIX2003")] | |
397 | pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; | |
398 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
399 | link_name = "creat$UNIX2003")] | |
400 | pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; | |
401 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
402 | link_name = "fcntl$UNIX2003")] | |
403 | pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; | |
404 | ||
405 | #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), | |
406 | link_name = "opendir$INODE64")] | |
407 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
408 | link_name = "opendir$INODE64$UNIX2003")] | |
9cc50fc6 | 409 | #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")] |
92a42be0 | 410 | pub fn opendir(dirname: *const c_char) -> *mut ::DIR; |
8bb4bdeb XL |
411 | #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")] |
412 | #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] | |
413 | pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; | |
92a42be0 | 414 | #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] |
9cc50fc6 | 415 | #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] |
8bb4bdeb | 416 | #[cfg_attr(target_os = "solaris", link_name = "__posix_readdir_r")] |
92a42be0 SL |
417 | pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, |
418 | result: *mut *mut ::dirent) -> ::c_int; | |
419 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
420 | link_name = "closedir$UNIX2003")] | |
421 | pub fn closedir(dirp: *mut ::DIR) -> ::c_int; | |
422 | #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), | |
423 | link_name = "rewinddir$INODE64")] | |
424 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
425 | link_name = "rewinddir$INODE64$UNIX2003")] | |
426 | pub fn rewinddir(dirp: *mut ::DIR); | |
427 | ||
cc61c64b XL |
428 | pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, |
429 | flags: ::c_int, ...) -> ::c_int; | |
cc61c64b XL |
430 | pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char, |
431 | mode: ::mode_t, flags: ::c_int) -> ::c_int; | |
432 | pub fn fchown(fd: ::c_int, | |
433 | owner: ::uid_t, | |
434 | group: ::gid_t) -> ::c_int; | |
435 | pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char, | |
436 | owner: ::uid_t, group: ::gid_t, | |
437 | flags: ::c_int) -> ::c_int; | |
438 | #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")] | |
439 | pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char, | |
440 | buf: *mut stat, flags: ::c_int) -> ::c_int; | |
441 | pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char, | |
442 | newdirfd: ::c_int, newpath: *const ::c_char, | |
443 | flags: ::c_int) -> ::c_int; | |
444 | pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char, | |
445 | mode: ::mode_t) -> ::c_int; | |
446 | pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char, | |
447 | buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t; | |
448 | pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char, | |
449 | newdirfd: ::c_int, newpath: *const ::c_char) | |
450 | -> ::c_int; | |
451 | pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int, | |
452 | linkpath: *const ::c_char) -> ::c_int; | |
453 | pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, | |
454 | flags: ::c_int) -> ::c_int; | |
455 | ||
92a42be0 SL |
456 | pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; |
457 | pub fn alarm(seconds: ::c_uint) -> ::c_uint; | |
458 | pub fn chdir(dir: *const c_char) -> ::c_int; | |
8bb4bdeb | 459 | pub fn fchdir(dirfd: ::c_int) -> ::c_int; |
92a42be0 SL |
460 | pub fn chown(path: *const c_char, uid: uid_t, |
461 | gid: gid_t) -> ::c_int; | |
5bcae85e SL |
462 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
463 | link_name = "lchown$UNIX2003")] | |
464 | pub fn lchown(path: *const c_char, uid: uid_t, | |
465 | gid: gid_t) -> ::c_int; | |
92a42be0 | 466 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
041b39d2 XL |
467 | link_name = "close$NOCANCEL$UNIX2003")] |
468 | #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), | |
469 | link_name = "close$NOCANCEL")] | |
92a42be0 SL |
470 | pub fn close(fd: ::c_int) -> ::c_int; |
471 | pub fn dup(fd: ::c_int) -> ::c_int; | |
472 | pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; | |
32a655c1 SL |
473 | pub fn execl(path: *const c_char, |
474 | arg0: *const c_char, ...) -> ::c_int; | |
475 | pub fn execle(path: *const ::c_char, | |
476 | arg0: *const ::c_char, ...) -> ::c_int; | |
477 | pub fn execlp(file: *const ::c_char, | |
478 | arg0: *const ::c_char, ...) -> ::c_int; | |
92a42be0 SL |
479 | pub fn execv(prog: *const c_char, |
480 | argv: *const *const c_char) -> ::c_int; | |
481 | pub fn execve(prog: *const c_char, argv: *const *const c_char, | |
482 | envp: *const *const c_char) | |
483 | -> ::c_int; | |
484 | pub fn execvp(c: *const c_char, | |
485 | argv: *const *const c_char) -> ::c_int; | |
486 | pub fn fork() -> pid_t; | |
487 | pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; | |
488 | pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; | |
489 | pub fn getegid() -> gid_t; | |
490 | pub fn geteuid() -> uid_t; | |
491 | pub fn getgid() -> gid_t; | |
492 | pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) | |
493 | -> ::c_int; | |
494 | pub fn getlogin() -> *mut c_char; | |
495 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
496 | link_name = "getopt$UNIX2003")] | |
497 | pub fn getopt(argc: ::c_int, argv: *const *mut c_char, | |
498 | optstr: *const c_char) -> ::c_int; | |
9e0c209e | 499 | pub fn getpgid(pid: pid_t) -> pid_t; |
92a42be0 SL |
500 | pub fn getpgrp() -> pid_t; |
501 | pub fn getpid() -> pid_t; | |
502 | pub fn getppid() -> pid_t; | |
503 | pub fn getuid() -> uid_t; | |
504 | pub fn isatty(fd: ::c_int) -> ::c_int; | |
505 | pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; | |
506 | pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; | |
507 | pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; | |
508 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
509 | link_name = "pause$UNIX2003")] | |
510 | pub fn pause() -> ::c_int; | |
511 | pub fn pipe(fds: *mut ::c_int) -> ::c_int; | |
9cc50fc6 SL |
512 | pub fn posix_memalign(memptr: *mut *mut ::c_void, |
513 | align: ::size_t, | |
514 | size: ::size_t) -> ::c_int; | |
92a42be0 SL |
515 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
516 | link_name = "read$UNIX2003")] | |
517 | pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) | |
518 | -> ::ssize_t; | |
519 | pub fn rmdir(path: *const c_char) -> ::c_int; | |
041b39d2 | 520 | pub fn seteuid(uid: uid_t) -> ::c_int; |
92a42be0 SL |
521 | pub fn setgid(gid: gid_t) -> ::c_int; |
522 | pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; | |
523 | pub fn setsid() -> pid_t; | |
524 | pub fn setuid(uid: uid_t) -> ::c_int; | |
525 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
526 | link_name = "sleep$UNIX2003")] | |
527 | pub fn sleep(secs: ::c_uint) -> ::c_uint; | |
528 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
529 | link_name = "nanosleep$UNIX2003")] | |
9cc50fc6 | 530 | #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] |
92a42be0 SL |
531 | pub fn nanosleep(rqtp: *const timespec, |
532 | rmtp: *mut timespec) -> ::c_int; | |
533 | pub fn tcgetpgrp(fd: ::c_int) -> pid_t; | |
476ff2be | 534 | pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int; |
92a42be0 SL |
535 | pub fn ttyname(fd: ::c_int) -> *mut c_char; |
536 | pub fn unlink(c: *const c_char) -> ::c_int; | |
537 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
538 | link_name = "wait$UNIX2003")] | |
539 | pub fn wait(status: *mut ::c_int) -> pid_t; | |
540 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
541 | link_name = "waitpid$UNIX2003")] | |
542 | pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) | |
543 | -> pid_t; | |
544 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
545 | link_name = "write$UNIX2003")] | |
546 | pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) | |
547 | -> ::ssize_t; | |
548 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
549 | link_name = "pread$UNIX2003")] | |
550 | pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, | |
551 | offset: off_t) -> ::ssize_t; | |
552 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
553 | link_name = "pwrite$UNIX2003")] | |
554 | pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, | |
555 | offset: off_t) -> ::ssize_t; | |
9cc50fc6 SL |
556 | pub fn umask(mask: mode_t) -> mode_t; |
557 | ||
558 | #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] | |
92a42be0 SL |
559 | pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; |
560 | ||
561 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
562 | link_name = "kill$UNIX2003")] | |
563 | pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; | |
564 | ||
565 | pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; | |
566 | pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; | |
567 | pub fn mlockall(flags: ::c_int) -> ::c_int; | |
568 | pub fn munlockall() -> ::c_int; | |
569 | ||
570 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
571 | link_name = "mmap$UNIX2003")] | |
572 | pub fn mmap(addr: *mut ::c_void, | |
573 | len: ::size_t, | |
574 | prot: ::c_int, | |
575 | flags: ::c_int, | |
576 | fd: ::c_int, | |
577 | offset: off_t) | |
578 | -> *mut ::c_void; | |
579 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
580 | link_name = "munmap$UNIX2003")] | |
581 | pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; | |
582 | ||
583 | pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint; | |
54a0048b SL |
584 | pub fn if_indextoname(ifindex: ::c_uint, |
585 | ifname: *mut ::c_char) -> *mut ::c_char; | |
92a42be0 SL |
586 | |
587 | #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] | |
9cc50fc6 | 588 | #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] |
92a42be0 SL |
589 | pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; |
590 | ||
591 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
592 | link_name = "fsync$UNIX2003")] | |
593 | pub fn fsync(fd: ::c_int) -> ::c_int; | |
594 | ||
595 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
596 | link_name = "setenv$UNIX2003")] | |
597 | pub fn setenv(name: *const c_char, val: *const c_char, | |
598 | overwrite: ::c_int) -> ::c_int; | |
599 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
600 | link_name = "unsetenv$UNIX2003")] | |
9cc50fc6 | 601 | #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")] |
92a42be0 SL |
602 | pub fn unsetenv(name: *const c_char) -> ::c_int; |
603 | ||
604 | pub fn symlink(path1: *const c_char, | |
605 | path2: *const c_char) -> ::c_int; | |
606 | ||
607 | pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; | |
608 | ||
92a42be0 SL |
609 | pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; |
610 | ||
611 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
612 | link_name = "getrlimit$UNIX2003")] | |
613 | pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int; | |
614 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
615 | link_name = "setrlimit$UNIX2003")] | |
616 | pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int; | |
9cc50fc6 | 617 | #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] |
92a42be0 SL |
618 | pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; |
619 | ||
92a42be0 SL |
620 | #[cfg_attr(any(target_os = "macos", target_os = "ios"), |
621 | link_name = "realpath$DARWIN_EXTSN")] | |
622 | pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) | |
623 | -> *mut ::c_char; | |
624 | ||
625 | pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; | |
626 | ||
7453a54e | 627 | #[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")] |
92a42be0 SL |
628 | pub fn gettimeofday(tp: *mut ::timeval, |
629 | tz: *mut ::c_void) -> ::c_int; | |
041b39d2 XL |
630 | #[cfg_attr(target_os = "netbsd", link_name = "__times13")] |
631 | pub fn times(buf: *mut ::tms) -> ::clock_t; | |
92a42be0 SL |
632 | |
633 | pub fn pthread_self() -> ::pthread_t; | |
92a42be0 SL |
634 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
635 | link_name = "pthread_join$UNIX2003")] | |
636 | pub fn pthread_join(native: ::pthread_t, | |
637 | value: *mut *mut ::c_void) -> ::c_int; | |
cc61c64b | 638 | pub fn pthread_exit(value: *mut ::c_void); |
92a42be0 SL |
639 | pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; |
640 | pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; | |
641 | pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, | |
642 | stack_size: ::size_t) -> ::c_int; | |
643 | pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, | |
644 | state: ::c_int) -> ::c_int; | |
645 | pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; | |
9cc50fc6 | 646 | #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")] |
92a42be0 SL |
647 | pub fn sched_yield() -> ::c_int; |
648 | pub fn pthread_key_create(key: *mut pthread_key_t, | |
54a0048b | 649 | dtor: Option<unsafe extern fn(*mut ::c_void)>) |
92a42be0 SL |
650 | -> ::c_int; |
651 | pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; | |
652 | pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; | |
653 | pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) | |
654 | -> ::c_int; | |
655 | pub fn pthread_mutex_init(lock: *mut pthread_mutex_t, | |
656 | attr: *const pthread_mutexattr_t) -> ::c_int; | |
657 | pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; | |
658 | pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; | |
659 | pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; | |
660 | pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; | |
661 | ||
662 | pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; | |
663 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
664 | link_name = "pthread_mutexattr_destroy$UNIX2003")] | |
665 | pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int; | |
666 | pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, | |
667 | _type: ::c_int) -> ::c_int; | |
668 | ||
5bcae85e SL |
669 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
670 | link_name = "pthread_cond_init$UNIX2003")] | |
671 | pub fn pthread_cond_init(cond: *mut pthread_cond_t, | |
672 | attr: *const pthread_condattr_t) -> ::c_int; | |
92a42be0 SL |
673 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
674 | link_name = "pthread_cond_wait$UNIX2003")] | |
675 | pub fn pthread_cond_wait(cond: *mut pthread_cond_t, | |
676 | lock: *mut pthread_mutex_t) -> ::c_int; | |
677 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
678 | link_name = "pthread_cond_timedwait$UNIX2003")] | |
679 | pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t, | |
680 | lock: *mut pthread_mutex_t, | |
681 | abstime: *const ::timespec) -> ::c_int; | |
682 | pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; | |
683 | pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; | |
684 | pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; | |
5bcae85e SL |
685 | pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int; |
686 | pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int; | |
3b2f2976 XL |
687 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
688 | link_name = "pthread_rwlock_init$UNIX2003")] | |
689 | pub fn pthread_rwlock_init(lock: *mut pthread_rwlock_t, | |
690 | attr: *const pthread_rwlockattr_t) -> ::c_int; | |
92a42be0 SL |
691 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
692 | link_name = "pthread_rwlock_destroy$UNIX2003")] | |
693 | pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; | |
694 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
695 | link_name = "pthread_rwlock_rdlock$UNIX2003")] | |
696 | pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; | |
697 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
698 | link_name = "pthread_rwlock_tryrdlock$UNIX2003")] | |
699 | pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; | |
700 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
701 | link_name = "pthread_rwlock_wrlock$UNIX2003")] | |
702 | pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; | |
703 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
704 | link_name = "pthread_rwlock_trywrlock$UNIX2003")] | |
705 | pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; | |
706 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
707 | link_name = "pthread_rwlock_unlock$UNIX2003")] | |
708 | pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; | |
3b2f2976 XL |
709 | pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int; |
710 | pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) | |
711 | -> ::c_int; | |
54a0048b SL |
712 | #[cfg_attr(all(target_os = "linux", not(target_env = "musl")), |
713 | link_name = "__xpg_strerror_r")] | |
92a42be0 SL |
714 | pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, |
715 | buflen: ::size_t) -> ::c_int; | |
716 | ||
717 | pub fn getsockopt(sockfd: ::c_int, | |
718 | level: ::c_int, | |
719 | optname: ::c_int, | |
720 | optval: *mut ::c_void, | |
721 | optlen: *mut ::socklen_t) -> ::c_int; | |
722 | pub fn raise(signum: ::c_int) -> ::c_int; | |
54a0048b | 723 | #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")] |
92a42be0 SL |
724 | pub fn sigaction(signum: ::c_int, |
725 | act: *const sigaction, | |
726 | oldact: *mut sigaction) -> ::c_int; | |
92a42be0 | 727 | |
9cc50fc6 | 728 | #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] |
92a42be0 SL |
729 | pub fn utimes(filename: *const ::c_char, |
730 | times: *const ::timeval) -> ::c_int; | |
731 | pub fn dlopen(filename: *const ::c_char, | |
732 | flag: ::c_int) -> *mut ::c_void; | |
733 | pub fn dlerror() -> *mut ::c_char; | |
734 | pub fn dlsym(handle: *mut ::c_void, | |
735 | symbol: *const ::c_char) -> *mut ::c_void; | |
736 | pub fn dlclose(handle: *mut ::c_void) -> ::c_int; | |
737 | pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; | |
738 | ||
739 | pub fn getaddrinfo(node: *const c_char, | |
740 | service: *const c_char, | |
741 | hints: *const addrinfo, | |
742 | res: *mut *mut addrinfo) -> ::c_int; | |
743 | pub fn freeaddrinfo(res: *mut addrinfo); | |
744 | pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; | |
7cac9316 XL |
745 | #[cfg_attr(any( |
746 | all(target_os = "linux", not(target_env = "musl")), | |
747 | target_os = "freebsd", | |
3b2f2976 XL |
748 | target_os = "dragonfly", |
749 | target_os = "haiku"), | |
7cac9316 XL |
750 | link_name = "__res_init")] |
751 | #[cfg_attr(any(target_os = "macos", target_os = "ios"), | |
752 | link_name = "res_9_init")] | |
753 | pub fn res_init() -> ::c_int; | |
92a42be0 | 754 | |
9cc50fc6 | 755 | #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] |
92a42be0 | 756 | pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; |
9cc50fc6 | 757 | #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] |
92a42be0 SL |
758 | pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; |
759 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
760 | link_name = "mktime$UNIX2003")] | |
9cc50fc6 | 761 | #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] |
92a42be0 | 762 | pub fn mktime(tm: *mut tm) -> time_t; |
9e0c209e SL |
763 | #[cfg_attr(target_os = "netbsd", link_name = "__time50")] |
764 | pub fn time(time: *mut time_t) -> time_t; | |
041b39d2 XL |
765 | #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] |
766 | pub fn gmtime(time_p: *const time_t) -> *mut tm; | |
9e0c209e | 767 | #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] |
041b39d2 | 768 | pub fn localtime(time_p: *const time_t) -> *mut tm; |
9cc50fc6 SL |
769 | |
770 | #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] | |
771 | pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, | |
772 | dev: ::dev_t) -> ::c_int; | |
9cc50fc6 | 773 | pub fn uname(buf: *mut ::utsname) -> ::c_int; |
9cc50fc6 | 774 | pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; |
abe05a73 XL |
775 | pub fn getservbyname(name: *const ::c_char, |
776 | proto: *const ::c_char) -> *mut servent; | |
777 | pub fn getprotobyname(name: *const ::c_char) -> *mut protoent; | |
778 | pub fn getprotobynumber(proto: ::c_int) -> *mut protoent; | |
9cc50fc6 SL |
779 | pub fn chroot(name: *const ::c_char) -> ::c_int; |
780 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
781 | link_name = "usleep$UNIX2003")] | |
782 | pub fn usleep(secs: ::c_uint) -> ::c_int; | |
783 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
784 | link_name = "send$UNIX2003")] | |
785 | pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, | |
786 | flags: ::c_int) -> ::ssize_t; | |
787 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
788 | link_name = "recv$UNIX2003")] | |
789 | pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, | |
790 | flags: ::c_int) -> ::ssize_t; | |
791 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
792 | link_name = "putenv$UNIX2003")] | |
793 | #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")] | |
794 | pub fn putenv(string: *mut c_char) -> ::c_int; | |
9cc50fc6 SL |
795 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
796 | link_name = "poll$UNIX2003")] | |
797 | pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; | |
54a0048b SL |
798 | #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), |
799 | link_name = "select$1050")] | |
800 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
801 | link_name = "select$UNIX2003")] | |
802 | #[cfg_attr(target_os = "netbsd", link_name = "__select50")] | |
803 | pub fn select(nfds: ::c_int, | |
804 | readfs: *mut fd_set, | |
805 | writefds: *mut fd_set, | |
806 | errorfds: *mut fd_set, | |
807 | timeout: *mut timeval) -> ::c_int; | |
808 | #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")] | |
809 | pub fn setlocale(category: ::c_int, | |
810 | locale: *const ::c_char) -> *mut ::c_char; | |
811 | pub fn localeconv() -> *mut lconv; | |
5bcae85e SL |
812 | |
813 | pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; | |
5bcae85e SL |
814 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
815 | link_name = "sem_wait$UNIX2003")] | |
816 | pub fn sem_wait(sem: *mut sem_t) -> ::c_int; | |
817 | pub fn sem_trywait(sem: *mut sem_t) -> ::c_int; | |
818 | pub fn sem_post(sem: *mut sem_t) -> ::c_int; | |
819 | pub fn sem_init(sem: *mut sem_t, | |
820 | pshared: ::c_int, | |
821 | value: ::c_uint) | |
822 | -> ::c_int; | |
cc61c64b XL |
823 | pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int; |
824 | pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int; | |
92a42be0 | 825 | |
92a42be0 SL |
826 | pub fn readlink(path: *const c_char, |
827 | buf: *mut c_char, | |
828 | bufsz: ::size_t) | |
829 | -> ::ssize_t; | |
830 | ||
9cc50fc6 | 831 | #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] |
92a42be0 | 832 | pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; |
9cc50fc6 | 833 | #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] |
92a42be0 | 834 | pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; |
9cc50fc6 | 835 | #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")] |
92a42be0 | 836 | pub fn sigfillset(set: *mut sigset_t) -> ::c_int; |
9cc50fc6 | 837 | #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")] |
92a42be0 | 838 | pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; |
9cc50fc6 | 839 | #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")] |
92a42be0 | 840 | pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int; |
cc61c64b | 841 | |
7cac9316 XL |
842 | #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")] |
843 | pub fn sigprocmask(how: ::c_int, | |
844 | set: *const sigset_t, | |
845 | oldset: *mut sigset_t) | |
846 | -> ::c_int; | |
041b39d2 XL |
847 | #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")] |
848 | pub fn sigpending(set: *mut sigset_t) -> ::c_int; | |
7cac9316 | 849 | |
cc61c64b XL |
850 | #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] |
851 | pub fn timegm(tm: *mut ::tm) -> time_t; | |
852 | ||
853 | pub fn getsid(pid: pid_t) -> pid_t; | |
854 | ||
855 | pub fn sysconf(name: ::c_int) -> ::c_long; | |
856 | ||
857 | pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; | |
858 | ||
92a42be0 SL |
859 | #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), |
860 | link_name = "pselect$1050")] | |
861 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), | |
862 | link_name = "pselect$UNIX2003")] | |
9cc50fc6 | 863 | #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] |
92a42be0 SL |
864 | pub fn pselect(nfds: ::c_int, |
865 | readfs: *mut fd_set, | |
866 | writefds: *mut fd_set, | |
867 | errorfds: *mut fd_set, | |
868 | timeout: *const timespec, | |
869 | sigmask: *const sigset_t) -> ::c_int; | |
870 | pub fn fseeko(stream: *mut ::FILE, | |
871 | offset: ::off_t, | |
872 | whence: ::c_int) -> ::c_int; | |
873 | pub fn ftello(stream: *mut ::FILE) -> ::off_t; | |
9cc50fc6 SL |
874 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
875 | link_name = "tcdrain$UNIX2003")] | |
876 | pub fn tcdrain(fd: ::c_int) -> ::c_int; | |
877 | pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t; | |
878 | pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t; | |
cc61c64b | 879 | pub fn cfmakeraw(termios: *mut ::termios); |
9cc50fc6 SL |
880 | pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; |
881 | pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; | |
cc61c64b | 882 | pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; |
9cc50fc6 SL |
883 | pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int; |
884 | pub fn tcsetattr(fd: ::c_int, | |
885 | optional_actions: ::c_int, | |
886 | termios: *const ::termios) -> ::c_int; | |
887 | pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int; | |
888 | pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int; | |
3b2f2976 | 889 | pub fn tcgetsid(fd: ::c_int) -> ::pid_t; |
9cc50fc6 | 890 | pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; |
7453a54e | 891 | pub fn mkstemp(template: *mut ::c_char) -> ::c_int; |
7453a54e | 892 | pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char; |
cc61c64b XL |
893 | |
894 | pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char; | |
a7813a04 XL |
895 | |
896 | pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int); | |
897 | pub fn closelog(); | |
898 | pub fn setlogmask(maskpri: ::c_int) -> ::c_int; | |
899 | pub fn syslog(priority: ::c_int, message: *const ::c_char, ...); | |
3157f602 XL |
900 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
901 | link_name = "nice$UNIX2003")] | |
902 | pub fn nice(incr: ::c_int) -> ::c_int; | |
c30ab7b3 SL |
903 | |
904 | pub fn grantpt(fd: ::c_int) -> ::c_int; | |
905 | pub fn posix_openpt(flags: ::c_int) -> ::c_int; | |
906 | pub fn ptsname(fd: ::c_int) -> *mut ::c_char; | |
907 | pub fn unlockpt(fd: ::c_int) -> ::c_int; | |
92a42be0 SL |
908 | } |
909 | ||
910 | cfg_if! { | |
041b39d2 XL |
911 | if #[cfg(target_env = "uclibc")] { |
912 | mod uclibc; | |
913 | pub use self::uclibc::*; | |
3b2f2976 XL |
914 | } else if #[cfg(target_env = "newlib")] { |
915 | mod newlib; | |
916 | pub use self::newlib::*; | |
041b39d2 XL |
917 | } else if #[cfg(any(target_os = "linux", |
918 | target_os = "android", | |
919 | target_os = "emscripten", | |
920 | target_os = "fuchsia"))] { | |
92a42be0 SL |
921 | mod notbsd; |
922 | pub use self::notbsd::*; | |
923 | } else if #[cfg(any(target_os = "macos", | |
924 | target_os = "ios", | |
925 | target_os = "freebsd", | |
926 | target_os = "dragonfly", | |
927 | target_os = "openbsd", | |
928 | target_os = "netbsd", | |
929 | target_os = "bitrig"))] { | |
930 | mod bsd; | |
931 | pub use self::bsd::*; | |
7453a54e SL |
932 | } else if #[cfg(target_os = "solaris")] { |
933 | mod solaris; | |
934 | pub use self::solaris::*; | |
9e0c209e SL |
935 | } else if #[cfg(target_os = "haiku")] { |
936 | mod haiku; | |
937 | pub use self::haiku::*; | |
92a42be0 | 938 | } else { |
54a0048b | 939 | // Unknown target_os |
92a42be0 SL |
940 | } |
941 | } |