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