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