]> git.lizzy.rs Git - rust.git/blob - src/liblibc/lib.rs
bf0cc9b4ad5e1f24ad160c4d83d933aa343f79ff
[rust.git] / src / liblibc / lib.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![crate_name = "libc"]
12 #![crate_type = "rlib"]
13 #![cfg_attr(not(feature = "cargo-build"),
14             unstable(feature = "libc"))]
15 #![cfg_attr(not(feature = "cargo-build"), feature(staged_api))]
16 #![cfg_attr(not(feature = "cargo-build"), staged_api)]
17 #![cfg_attr(not(feature = "cargo-build"), feature(core))]
18 #![feature(no_std)]
19 #![no_std]
20 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
21        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
22        html_root_url = "http://doc.rust-lang.org/nightly/",
23        html_playground_url = "http://play.rust-lang.org/")]
24 #![cfg_attr(test, feature(test))]
25
26 //! Bindings for the C standard library and other platform libraries
27 //!
28 //! **NOTE:** These are *architecture and libc* specific. On Linux, these
29 //! bindings are only correct for glibc.
30 //!
31 //! This module contains bindings to the C standard library, organized into
32 //! modules by their defining standard.  Additionally, it contains some assorted
33 //! platform-specific definitions.  For convenience, most functions and types
34 //! are reexported, so `use libc::*` will import the available C bindings as
35 //! appropriate for the target platform. The exact set of functions available
36 //! are platform specific.
37 //!
38 //! *Note:* Because these definitions are platform-specific, some may not appear
39 //! in the generated documentation.
40 //!
41 //! We consider the following specs reasonably normative with respect to
42 //! interoperating with the C standard library (libc/msvcrt):
43 //!
44 //! * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995.
45 //! * ISO 9899:1999 ('C99' or 'C9x').
46 //! * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1').
47 //! * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3').
48 //! * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4').
49 //!
50 //! Note that any reference to the 1996 revision of POSIX, or any revs between
51 //! 1990 (when '88 was approved at ISO) and 2001 (when the next actual
52 //! revision-revision happened), are merely additions of other chapters (1b and
53 //! 1c) outside the core interfaces.
54 //!
55 //! Despite having several names each, these are *reasonably* coherent
56 //! point-in-time, list-of-definition sorts of specs. You can get each under a
57 //! variety of names but will wind up with the same definition in each case.
58 //!
59 //! See standards(7) in linux-manpages for more details.
60 //!
61 //! Our interface to these libraries is complicated by the non-universality of
62 //! conformance to any of them. About the only thing universally supported is
63 //! the first (C95), beyond that definitions quickly become absent on various
64 //! platforms.
65 //!
66 //! We therefore wind up dividing our module-space up (mostly for the sake of
67 //! sanity while editing, filling-in-details and eliminating duplication) into
68 //! definitions common-to-all (held in modules named c95, c99, posix88, posix01
69 //! and posix08) and definitions that appear only on *some* platforms (named
70 //! 'extra'). This would be things like significant OSX foundation kit, or Windows
71 //! library kernel32.dll, or various fancy glibc, Linux or BSD extensions.
72 //!
73 //! In addition to the per-platform 'extra' modules, we define a module of
74 //! 'common BSD' libc routines that never quite made it into POSIX but show up
75 //! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final
76 //! one from Berkeley after the lawsuits died down and the CSRG dissolved.
77
78 #![allow(bad_style, raw_pointer_derive)]
79 #[cfg(feature = "cargo-build")] extern crate "std" as core;
80 #[cfg(not(feature = "cargo-build"))] extern crate core;
81
82 #[cfg(test)] extern crate std;
83 #[cfg(test)] extern crate test;
84
85 // Explicit export lists for the intersection (provided here) mean that
86 // you can write more-platform-agnostic code if you stick to just these
87 // symbols.
88
89 pub use types::common::c95::{FILE, c_void, fpos_t};
90 pub use types::common::c99::{int8_t, int16_t, int32_t, int64_t};
91 pub use types::common::c99::{uint8_t, uint16_t, uint32_t, uint64_t};
92 pub use types::common::posix88::{DIR, dirent_t};
93 pub use types::os::common::posix01::{timeval};
94 pub use types::os::common::bsd44::{addrinfo, in_addr, in6_addr, sockaddr_storage};
95 pub use types::os::common::bsd44::{ip_mreq, ip6_mreq, sockaddr, sockaddr_un};
96 pub use types::os::common::bsd44::{sa_family_t, sockaddr_in, sockaddr_in6, socklen_t};
97 pub use types::os::arch::c95::{c_char, c_double, c_float, c_int, c_uint};
98 pub use types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong, wchar_t};
99 pub use types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t, c_schar};
100 pub use types::os::arch::c95::{size_t, time_t, suseconds_t};
101 pub use types::os::arch::c99::{c_longlong, c_ulonglong};
102 pub use types::os::arch::c99::{intptr_t, uintptr_t};
103 pub use types::os::arch::c99::{intmax_t, uintmax_t};
104 pub use types::os::arch::posix88::{dev_t, ino_t, mode_t};
105 pub use types::os::arch::posix88::{off_t, pid_t, ssize_t};
106
107 pub use consts::os::c95::{_IOFBF, _IOLBF, _IONBF, BUFSIZ, EOF};
108 pub use consts::os::c95::{EXIT_FAILURE, EXIT_SUCCESS};
109 pub use consts::os::c95::{FILENAME_MAX, FOPEN_MAX, L_tmpnam};
110 pub use consts::os::c95::{RAND_MAX, SEEK_CUR, SEEK_END};
111 pub use consts::os::c95::{SEEK_SET, TMP_MAX};
112 pub use consts::os::posix88::{F_OK, O_APPEND, O_CREAT, O_EXCL};
113 pub use consts::os::posix88::{O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
114 pub use consts::os::posix88::{R_OK, S_IEXEC, S_IFBLK, S_IFCHR};
115 pub use consts::os::posix88::{S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IFLNK};
116 pub use consts::os::posix88::{S_IREAD, S_IRUSR, S_IRWXU, S_IWUSR};
117 pub use consts::os::posix88::{STDERR_FILENO, STDIN_FILENO, S_IXUSR};
118 pub use consts::os::posix88::{STDOUT_FILENO, W_OK, X_OK};
119 pub use consts::os::bsd44::{AF_INET, AF_INET6, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW};
120 pub use consts::os::bsd44::{IPPROTO_IP, IPPROTO_IPV6, IPPROTO_TCP, TCP_NODELAY};
121 pub use consts::os::bsd44::{SOL_SOCKET, SO_KEEPALIVE, SO_ERROR};
122 pub use consts::os::bsd44::{SO_REUSEADDR, SO_BROADCAST, SHUT_WR, IP_MULTICAST_LOOP};
123 pub use consts::os::bsd44::{IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP};
124 pub use consts::os::bsd44::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
125 pub use consts::os::bsd44::{IP_MULTICAST_TTL, IP_TTL, IP_HDRINCL, SHUT_RD};
126 pub use consts::os::extra::{IPPROTO_RAW};
127
128 pub use funcs::c95::ctype::{isalnum, isalpha, iscntrl, isdigit};
129 pub use funcs::c95::ctype::{islower, isprint, ispunct, isspace};
130 pub use funcs::c95::ctype::{isupper, isxdigit, tolower, toupper};
131
132 pub use funcs::c95::stdio::{fclose, feof, ferror, fflush, fgetc};
133 pub use funcs::c95::stdio::{fgetpos, fgets, fopen, fputc, fputs};
134 pub use funcs::c95::stdio::{fread, freopen, fseek, fsetpos, ftell};
135 pub use funcs::c95::stdio::{fwrite, perror, puts, remove, rename, rewind};
136 pub use funcs::c95::stdio::{setbuf, setvbuf, tmpfile, ungetc};
137
138 pub use funcs::c95::stdlib::{abs, atof, atoi, calloc, exit, _exit, atexit};
139 pub use funcs::c95::stdlib::{free, getenv, labs, malloc, rand};
140 pub use funcs::c95::stdlib::{realloc, srand, strtod, strtol};
141 pub use funcs::c95::stdlib::{strtoul, system};
142
143 pub use funcs::c95::string::{memchr, memcmp};
144 pub use funcs::c95::string::{strcat, strchr, strcmp};
145 pub use funcs::c95::string::{strcoll, strcpy, strcspn, strerror};
146 pub use funcs::c95::string::{strlen, strncat, strncmp, strncpy};
147 pub use funcs::c95::string::{strpbrk, strrchr, strspn, strstr};
148 pub use funcs::c95::string::{strtok, strxfrm};
149
150 pub use funcs::posix88::fcntl::{open, creat};
151 pub use funcs::posix88::stat_::{chmod, fstat, mkdir, stat};
152 pub use funcs::posix88::stdio::{fdopen, fileno, pclose, popen};
153 pub use funcs::posix88::unistd::{access, chdir, close, dup, dup2};
154 pub use funcs::posix88::unistd::{execv, execve, execvp, getcwd};
155 pub use funcs::posix88::unistd::{getpid, isatty, lseek, pipe, read};
156 pub use funcs::posix88::unistd::{rmdir, unlink, write};
157
158 pub use funcs::bsd43::{socket, setsockopt, bind, send, recv, recvfrom};
159 pub use funcs::bsd43::{listen, sendto, accept, connect, getpeername, getsockname};
160 pub use funcs::bsd43::{shutdown};
161
162 // But we also reexport most everything
163 // if you're interested in writing platform-specific code.
164
165 // FIXME: This is a mess, but the design of this entire module needs to be
166 // reconsidered, so I'm not inclined to do better right now. As part of
167 // #11870 I removed all the pub globs here, leaving explicit reexports
168 // of everything that is actually used in-tree.
169 //
170 // So the following exports don't follow any particular plan.
171
172 #[cfg(unix)] pub use consts::os::sysconf::{_SC_PAGESIZE};
173 #[cfg(unix)] pub use consts::os::posix88::{PROT_READ, PROT_WRITE, PROT_EXEC};
174 #[cfg(unix)] pub use consts::os::posix88::{MAP_FIXED, MAP_FILE, MAP_ANON, MAP_PRIVATE, MAP_FAILED};
175 #[cfg(unix)] pub use consts::os::posix88::{EACCES, EBADF, EINVAL, ENODEV, ENOMEM};
176 #[cfg(unix)] pub use consts::os::posix88::{ECONNREFUSED, ECONNRESET, EPERM, EPIPE};
177 #[cfg(unix)] pub use consts::os::posix88::{ENOTCONN, ECONNABORTED, EADDRNOTAVAIL, EINTR};
178 #[cfg(unix)] pub use consts::os::posix88::{EADDRINUSE, ENOENT, EISDIR, EAGAIN, EWOULDBLOCK};
179 #[cfg(unix)] pub use consts::os::posix88::{ECANCELED, SIGINT, EINPROGRESS};
180 #[cfg(unix)] pub use consts::os::posix88::{ENOSYS, ENOTTY, ETIMEDOUT, EMFILE};
181 #[cfg(unix)] pub use consts::os::posix88::{SIGTERM, SIGKILL, SIGPIPE, PROT_NONE};
182 #[cfg(unix)] pub use consts::os::posix01::{SIG_IGN, F_GETFL, F_SETFL};
183 #[cfg(unix)] pub use consts::os::bsd44::{AF_UNIX};
184 #[cfg(unix)] pub use consts::os::extra::{O_NONBLOCK};
185
186 #[cfg(unix)] pub use types::os::common::posix01::{pthread_t, timespec, timezone};
187
188 #[cfg(unix)] pub use types::os::arch::posix88::{uid_t, gid_t};
189 #[cfg(unix)] pub use types::os::arch::posix01::{pthread_attr_t};
190 #[cfg(unix)] pub use types::os::arch::posix01::{stat, utimbuf};
191 #[cfg(unix)] pub use types::os::common::bsd44::{ifaddrs};
192 #[cfg(unix)] pub use funcs::posix88::unistd::{sysconf, setgid, setsid, setuid, pread, pwrite};
193 #[cfg(unix)] pub use funcs::posix88::unistd::{getgid, getuid, getsid};
194 #[cfg(unix)] pub use funcs::posix88::unistd::{_PC_NAME_MAX, utime, nanosleep, pathconf, link};
195 #[cfg(unix)] pub use funcs::posix88::unistd::{chown};
196 #[cfg(unix)] pub use funcs::posix88::mman::{mmap, munmap, mprotect};
197 #[cfg(unix)] pub use funcs::posix88::dirent::{opendir, readdir_r, closedir};
198 #[cfg(unix)] pub use funcs::posix88::fcntl::{fcntl};
199 #[cfg(unix)] pub use funcs::posix88::net::{if_nametoindex};
200 #[cfg(unix)] pub use funcs::posix01::stat_::{lstat};
201 #[cfg(unix)] pub use funcs::posix01::unistd::{fsync, ftruncate};
202 #[cfg(unix)] pub use funcs::posix01::unistd::{readlink, symlink};
203 #[cfg(unix)] pub use funcs::bsd43::{getifaddrs, freeifaddrs};
204
205 #[cfg(windows)] pub use consts::os::c95::{WSAECONNREFUSED, WSAECONNRESET, WSAEACCES};
206 #[cfg(windows)] pub use consts::os::c95::{WSAEWOULDBLOCK, WSAENOTCONN, WSAECONNABORTED};
207 #[cfg(windows)] pub use consts::os::c95::{WSAEADDRNOTAVAIL, WSAEADDRINUSE, WSAEINTR};
208 #[cfg(windows)] pub use consts::os::c95::{WSAEINPROGRESS, WSAEINVAL, WSAEMFILE};
209 #[cfg(windows)] pub use consts::os::extra::{ERROR_INSUFFICIENT_BUFFER};
210 #[cfg(windows)] pub use consts::os::extra::{O_BINARY, O_NOINHERIT, PAGE_NOACCESS};
211 #[cfg(windows)] pub use consts::os::extra::{PAGE_READONLY, PAGE_READWRITE, PAGE_EXECUTE};
212 #[cfg(windows)] pub use consts::os::extra::{PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE};
213 #[cfg(windows)] pub use consts::os::extra::{MEM_COMMIT, MEM_RESERVE, MEM_RELEASE};
214 #[cfg(windows)] pub use consts::os::extra::{FILE_MAP_READ, FILE_MAP_WRITE, FILE_MAP_EXECUTE};
215 #[cfg(windows)] pub use consts::os::extra::{ERROR_ALREADY_EXISTS, ERROR_NO_DATA};
216 #[cfg(windows)] pub use consts::os::extra::{ERROR_FILE_NOT_FOUND, ERROR_INVALID_NAME};
217 #[cfg(windows)] pub use consts::os::extra::{ERROR_BROKEN_PIPE, ERROR_INVALID_FUNCTION};
218 #[cfg(windows)] pub use consts::os::extra::{ERROR_CALL_NOT_IMPLEMENTED};
219 #[cfg(windows)] pub use consts::os::extra::{ERROR_NOTHING_TO_TERMINATE};
220 #[cfg(windows)] pub use consts::os::extra::{ERROR_INVALID_HANDLE};
221 #[cfg(windows)] pub use consts::os::extra::{TRUE, FALSE, INFINITE};
222 #[cfg(windows)] pub use consts::os::extra::{PROCESS_TERMINATE, PROCESS_QUERY_INFORMATION};
223 #[cfg(windows)] pub use consts::os::extra::{STILL_ACTIVE, DETACHED_PROCESS};
224 #[cfg(windows)] pub use consts::os::extra::{CREATE_NEW_PROCESS_GROUP, CREATE_UNICODE_ENVIRONMENT};
225 #[cfg(windows)] pub use consts::os::extra::{FILE_BEGIN, FILE_END, FILE_CURRENT};
226 #[cfg(windows)] pub use consts::os::extra::{FILE_GENERIC_READ, FILE_GENERIC_WRITE};
227 #[cfg(windows)] pub use consts::os::extra::{FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_SHARE_DELETE};
228 #[cfg(windows)] pub use consts::os::extra::{TRUNCATE_EXISTING, CREATE_ALWAYS, OPEN_EXISTING};
229 #[cfg(windows)] pub use consts::os::extra::{CREATE_NEW, FILE_APPEND_DATA, FILE_WRITE_DATA};
230 #[cfg(windows)] pub use consts::os::extra::{OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL};
231 #[cfg(windows)] pub use consts::os::extra::{FILE_FLAG_BACKUP_SEMANTICS, INVALID_HANDLE_VALUE};
232 #[cfg(windows)] pub use consts::os::extra::{MOVEFILE_REPLACE_EXISTING};
233 #[cfg(windows)] pub use consts::os::extra::{GENERIC_READ, GENERIC_WRITE};
234 #[cfg(windows)] pub use consts::os::extra::{VOLUME_NAME_DOS};
235 #[cfg(windows)] pub use consts::os::extra::{PIPE_ACCESS_DUPLEX, FILE_FLAG_FIRST_PIPE_INSTANCE};
236 #[cfg(windows)] pub use consts::os::extra::{FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE};
237 #[cfg(windows)] pub use consts::os::extra::{PIPE_READMODE_BYTE, PIPE_WAIT};
238 #[cfg(windows)] pub use consts::os::extra::{PIPE_UNLIMITED_INSTANCES, ERROR_ACCESS_DENIED};
239 #[cfg(windows)] pub use consts::os::extra::{FILE_WRITE_ATTRIBUTES, FILE_READ_ATTRIBUTES};
240 #[cfg(windows)] pub use consts::os::extra::{ERROR_PIPE_BUSY, ERROR_IO_PENDING};
241 #[cfg(windows)] pub use consts::os::extra::{ERROR_PIPE_CONNECTED, WAIT_OBJECT_0};
242 #[cfg(windows)] pub use consts::os::extra::{ERROR_NOT_FOUND};
243 #[cfg(windows)] pub use consts::os::extra::{ERROR_OPERATION_ABORTED};
244 #[cfg(windows)] pub use consts::os::extra::{FIONBIO};
245 #[cfg(windows)] pub use types::os::common::bsd44::{SOCKET};
246 #[cfg(windows)] pub use types::os::common::posix01::{stat, utimbuf};
247 #[cfg(windows)] pub use types::os::arch::extra::{HANDLE, BOOL, LPSECURITY_ATTRIBUTES};
248 #[cfg(windows)] pub use types::os::arch::extra::{LPCSTR, WORD, DWORD, BYTE, FILETIME};
249 #[cfg(windows)] pub use types::os::arch::extra::{LARGE_INTEGER, LPVOID, LONG};
250 #[cfg(windows)] pub use types::os::arch::extra::{time64_t, OVERLAPPED, LPCWSTR};
251 #[cfg(windows)] pub use types::os::arch::extra::{LPOVERLAPPED, SIZE_T, LPDWORD};
252 #[cfg(windows)] pub use types::os::arch::extra::{SECURITY_ATTRIBUTES, WIN32_FIND_DATAW};
253 #[cfg(windows)] pub use funcs::c95::string::{wcslen};
254 #[cfg(windows)] pub use funcs::posix88::stat_::{wstat, wutime, wchmod, wrmdir};
255 #[cfg(windows)] pub use funcs::bsd43::{closesocket};
256 #[cfg(windows)] pub use funcs::extra::kernel32::{GetCurrentDirectoryW, GetLastError};
257 #[cfg(windows)] pub use funcs::extra::kernel32::{GetEnvironmentVariableW, SetEnvironmentVariableW};
258 #[cfg(windows)] pub use funcs::extra::kernel32::{GetModuleFileNameW, SetCurrentDirectoryW};
259 #[cfg(windows)] pub use funcs::extra::kernel32::{GetSystemInfo, VirtualAlloc, VirtualFree};
260 #[cfg(windows)] pub use funcs::extra::kernel32::{CreateFileMappingW, MapViewOfFile};
261 #[cfg(windows)] pub use funcs::extra::kernel32::{UnmapViewOfFile, CloseHandle};
262 #[cfg(windows)] pub use funcs::extra::kernel32::{WaitForSingleObject, GetSystemTimeAsFileTime};
263 #[cfg(windows)] pub use funcs::extra::kernel32::{QueryPerformanceCounter};
264 #[cfg(windows)] pub use funcs::extra::kernel32::{QueryPerformanceFrequency};
265 #[cfg(windows)] pub use funcs::extra::kernel32::{GetExitCodeProcess, TerminateProcess};
266 #[cfg(windows)] pub use funcs::extra::kernel32::{ReadFile, WriteFile, SetFilePointerEx};
267 #[cfg(windows)] pub use funcs::extra::kernel32::{SetEndOfFile, CreateFileW};
268 #[cfg(windows)] pub use funcs::extra::kernel32::{CreateDirectoryW, FindFirstFileW};
269 #[cfg(windows)] pub use funcs::extra::kernel32::{FindNextFileW, FindClose, DeleteFileW};
270 #[cfg(windows)] pub use funcs::extra::kernel32::{CreateHardLinkW, CreateEventW};
271 #[cfg(windows)] pub use funcs::extra::kernel32::{FlushFileBuffers, CreateNamedPipeW};
272 #[cfg(windows)] pub use funcs::extra::kernel32::{SetNamedPipeHandleState, WaitNamedPipeW};
273 #[cfg(windows)] pub use funcs::extra::kernel32::{GetOverlappedResult, ConnectNamedPipe};
274 #[cfg(windows)] pub use funcs::extra::kernel32::{DisconnectNamedPipe, OpenProcess};
275 #[cfg(windows)] pub use funcs::extra::kernel32::{MoveFileExW, VirtualProtect};
276 #[cfg(windows)] pub use funcs::extra::kernel32::{RemoveDirectoryW};
277 #[cfg(windows)] pub use funcs::extra::msvcrt::{get_osfhandle, open_osfhandle};
278 #[cfg(windows)] pub use funcs::extra::winsock::{ioctlsocket};
279
280 #[cfg(any(target_os = "linux",
281           target_os = "android",
282           target_os = "freebsd",
283           target_os = "dragonfly",
284           target_os = "bitrig",
285           target_os = "openbsd"))]
286 pub use consts::os::posix01::{CLOCK_REALTIME, CLOCK_MONOTONIC};
287
288 #[cfg(any(target_os = "linux", target_os = "android"))]
289 pub use funcs::posix01::unistd::{fdatasync};
290 #[cfg(any(target_os = "linux", target_os = "android"))]
291 pub use types::os::arch::extra::{sockaddr_ll};
292 #[cfg(any(target_os = "linux", target_os = "android"))]
293 pub use consts::os::extra::{AF_PACKET};
294
295 #[cfg(all(unix, not(any(target_os = "freebsd", target_os = "bitrig", target_os = "openbsd"))))]
296 pub use consts::os::extra::{MAP_STACK};
297
298 #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
299 pub use consts::os::bsd44::{TCP_KEEPIDLE};
300
301 #[cfg(any(target_os = "macos", target_os = "ios"))]
302 pub use consts::os::bsd44::{TCP_KEEPALIVE};
303 #[cfg(any(target_os = "macos", target_os = "ios"))]
304 pub use consts::os::extra::{F_FULLFSYNC};
305
306 #[cfg(any(target_os = "macos", target_os = "ios"))]
307 pub use types::os::arch::extra::{mach_timebase_info};
308
309
310 #[cfg(not(windows))]
311 #[link(name = "c")]
312 #[link(name = "m")]
313 extern {}
314
315 pub mod types {
316
317     // Types tend to vary *per architecture* so we pull their definitions out
318     // into this module.
319
320     // Standard types that are opaque or common, so are not per-target.
321     pub mod common {
322         pub mod c95 {
323             /// Type used to construct void pointers for use with C.
324             ///
325             /// This type is only useful as a pointer target. Do not use it as a
326             /// return type for FFI functions which have the `void` return type in
327             /// C. Use the unit type `()` or omit the return type instead.
328             ///
329             /// For LLVM to recognize the void pointer type and by extension
330             /// functions like malloc(), we need to have it represented as i8* in
331             /// LLVM bitcode. The enum used here ensures this and prevents misuse
332             /// of the "raw" type by only having private variants.. We need two
333             /// variants, because the compiler complains about the repr attribute
334             /// otherwise.
335             #[repr(u8)]
336             pub enum c_void {
337                 __variant1,
338                 __variant2,
339             }
340
341             pub enum FILE {}
342             pub enum fpos_t {}
343         }
344         pub mod c99 {
345             pub type int8_t = i8;
346             pub type int16_t = i16;
347             pub type int32_t = i32;
348             pub type int64_t = i64;
349             pub type uint8_t = u8;
350             pub type uint16_t = u16;
351             pub type uint32_t = u32;
352             pub type uint64_t = u64;
353         }
354         pub mod posix88 {
355             pub enum DIR {}
356             pub enum dirent_t {}
357         }
358         pub mod posix01 {}
359         pub mod posix08 {}
360         pub mod bsd44 {}
361     }
362
363     // Standard types that are scalar but vary by OS and arch.
364
365     #[cfg(any(target_os = "linux", target_os = "android"))]
366     pub mod os {
367         pub mod common {
368             pub mod posix01 {
369                 use types::common::c95::{c_void};
370                 use types::os::arch::c95::{c_char, c_ulong, size_t,
371                                                  time_t, suseconds_t, c_long};
372
373                 pub type pthread_t = c_ulong;
374
375                 #[repr(C)]
376                 #[derive(Copy)] pub struct glob_t {
377                     pub gl_pathc: size_t,
378                     pub gl_pathv: *mut *mut c_char,
379                     pub gl_offs:  size_t,
380
381                     pub __unused1: *mut c_void,
382                     pub __unused2: *mut c_void,
383                     pub __unused3: *mut c_void,
384                     pub __unused4: *mut c_void,
385                     pub __unused5: *mut c_void,
386                 }
387
388                 #[repr(C)]
389                 #[derive(Copy)] pub struct timeval {
390                     pub tv_sec: time_t,
391                     pub tv_usec: suseconds_t,
392                 }
393
394                 #[repr(C)]
395                 #[derive(Copy)] pub struct timespec {
396                     pub tv_sec: time_t,
397                     pub tv_nsec: c_long,
398                 }
399
400                 #[derive(Copy)] pub enum timezone {}
401
402                 pub type sighandler_t = size_t;
403             }
404             pub mod bsd44 {
405                 use types::common::c95::{c_void};
406                 use types::os::arch::c95::{c_char, c_int, c_uint};
407
408                 pub type socklen_t = u32;
409                 pub type sa_family_t = u16;
410                 pub type in_port_t = u16;
411                 pub type in_addr_t = u32;
412                 #[repr(C)]
413                 #[derive(Copy)] pub struct sockaddr {
414                     pub sa_family: sa_family_t,
415                     pub sa_data: [u8; 14],
416                 }
417                 #[repr(C)]
418                 #[derive(Copy)] pub struct sockaddr_storage {
419                     pub ss_family: sa_family_t,
420                     pub __ss_align: i64,
421                     pub __ss_pad2: [u8; 112],
422                 }
423                 #[repr(C)]
424                 #[derive(Copy)] pub struct sockaddr_in {
425                     pub sin_family: sa_family_t,
426                     pub sin_port: in_port_t,
427                     pub sin_addr: in_addr,
428                     pub sin_zero: [u8; 8],
429                 }
430                 #[repr(C)]
431                 #[derive(Copy)] pub struct in_addr {
432                     pub s_addr: in_addr_t,
433                 }
434                 #[repr(C)]
435                 #[derive(Copy)] pub struct sockaddr_in6 {
436                     pub sin6_family: sa_family_t,
437                     pub sin6_port: in_port_t,
438                     pub sin6_flowinfo: u32,
439                     pub sin6_addr: in6_addr,
440                     pub sin6_scope_id: u32,
441                 }
442                 #[repr(C)]
443                 #[derive(Copy)] pub struct in6_addr {
444                     pub s6_addr: [u16; 8]
445                 }
446                 #[repr(C)]
447                 #[derive(Copy)] pub struct ip_mreq {
448                     pub imr_multiaddr: in_addr,
449                     pub imr_interface: in_addr,
450                 }
451                 #[repr(C)]
452                 #[derive(Copy)] pub struct ip6_mreq {
453                     pub ipv6mr_multiaddr: in6_addr,
454                     pub ipv6mr_interface: c_uint,
455                 }
456                 #[repr(C)]
457                 #[derive(Copy)] pub struct addrinfo {
458                     pub ai_flags: c_int,
459                     pub ai_family: c_int,
460                     pub ai_socktype: c_int,
461                     pub ai_protocol: c_int,
462                     pub ai_addrlen: socklen_t,
463
464                     #[cfg(target_os = "linux")]
465                     pub ai_addr: *mut sockaddr,
466
467                     #[cfg(target_os = "linux")]
468                     pub ai_canonname: *mut c_char,
469
470                     #[cfg(target_os = "android")]
471                     pub ai_canonname: *mut c_char,
472
473                     #[cfg(target_os = "android")]
474                     pub ai_addr: *mut sockaddr,
475
476                     pub ai_next: *mut addrinfo,
477                 }
478                 #[repr(C)]
479                 #[derive(Copy)] pub struct sockaddr_un {
480                     pub sun_family: sa_family_t,
481                     pub sun_path: [c_char; 108]
482                 }
483
484                 #[repr(C)]
485                 #[derive(Copy)] pub struct ifaddrs {
486                     pub ifa_next: *mut ifaddrs,
487                     pub ifa_name: *mut c_char,
488                     pub ifa_flags: c_uint,
489                     pub ifa_addr: *mut sockaddr,
490                     pub ifa_netmask: *mut sockaddr,
491                     pub ifa_ifu: *mut sockaddr, // FIXME This should be a union
492                     pub ifa_data: *mut c_void
493                 }
494
495             }
496         }
497
498         #[cfg(any(target_arch = "x86",
499                   target_arch = "arm",
500                   target_arch = "mips",
501                   target_arch = "mipsel",
502                   target_arch = "powerpc"))]
503         pub mod arch {
504             pub mod c95 {
505                 pub type c_char = i8;
506                 pub type c_schar = i8;
507                 pub type c_uchar = u8;
508                 pub type c_short = i16;
509                 pub type c_ushort = u16;
510                 pub type c_int = i32;
511                 pub type c_uint = u32;
512                 pub type c_long = i32;
513                 pub type c_ulong = u32;
514                 pub type c_float = f32;
515                 pub type c_double = f64;
516                 pub type size_t = u32;
517                 pub type ptrdiff_t = i32;
518                 pub type clock_t = i32;
519                 pub type time_t = i32;
520                 pub type suseconds_t = i32;
521                 pub type wchar_t = i32;
522             }
523             pub mod c99 {
524                 pub type c_longlong = i64;
525                 pub type c_ulonglong = u64;
526                 pub type intptr_t = i32;
527                 pub type uintptr_t = u32;
528                 pub type intmax_t = i64;
529                 pub type uintmax_t = u64;
530             }
531             #[cfg(any(target_arch = "x86",
532                       target_arch = "mips",
533                       target_arch = "mipsel",
534                       target_arch = "powerpc"))]
535             pub mod posix88 {
536                 pub type off_t = i32;
537                 pub type dev_t = u64;
538                 pub type ino_t = u32;
539                 pub type pid_t = i32;
540                 pub type uid_t = u32;
541                 pub type gid_t = u32;
542                 pub type useconds_t = u32;
543                 pub type mode_t = u32;
544                 pub type ssize_t = i32;
545             }
546             #[cfg(target_arch = "arm")]
547             pub mod posix88 {
548                 pub type off_t = i32;
549                 pub type dev_t = u32;
550                 pub type ino_t = u32;
551                 pub type pid_t = i32;
552                 pub type uid_t = u32;
553                 pub type gid_t = u32;
554                 pub type useconds_t = u32;
555                 pub type mode_t = u16;
556                 pub type ssize_t = i32;
557             }
558             #[cfg(any(target_arch = "x86",
559                       target_arch = "powerpc"))]
560             pub mod posix01 {
561                 use types::os::arch::c95::{c_short, c_long, time_t};
562                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
563                 use types::os::arch::posix88::{mode_t, off_t};
564                 use types::os::arch::posix88::{uid_t};
565
566                 pub type nlink_t = u32;
567                 pub type blksize_t = i32;
568                 pub type blkcnt_t = i32;
569
570                 #[repr(C)]
571                 #[derive(Copy)] pub struct stat {
572                     pub st_dev: dev_t,
573                     pub __pad1: c_short,
574                     pub st_ino: ino_t,
575                     pub st_mode: mode_t,
576                     pub st_nlink: nlink_t,
577                     pub st_uid: uid_t,
578                     pub st_gid: gid_t,
579                     pub st_rdev: dev_t,
580                     pub __pad2: c_short,
581                     pub st_size: off_t,
582                     pub st_blksize: blksize_t,
583                     pub st_blocks: blkcnt_t,
584                     pub st_atime: time_t,
585                     pub st_atime_nsec: c_long,
586                     pub st_mtime: time_t,
587                     pub st_mtime_nsec: c_long,
588                     pub st_ctime: time_t,
589                     pub st_ctime_nsec: c_long,
590                     pub __unused4: c_long,
591                     pub __unused5: c_long,
592                 }
593
594                 #[repr(C)]
595                 #[derive(Copy)] pub struct utimbuf {
596                     pub actime: time_t,
597                     pub modtime: time_t,
598                 }
599
600                 #[repr(C)]
601                 #[derive(Copy)] pub struct pthread_attr_t {
602                     pub __size: [u32; 9]
603                 }
604             }
605             #[cfg(target_arch = "arm")]
606             pub mod posix01 {
607                 use types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t};
608                 use types::os::arch::c99::{c_longlong, c_ulonglong};
609                 use types::os::arch::posix88::{uid_t, gid_t, ino_t};
610
611                 pub type nlink_t = u16;
612                 pub type blksize_t = u32;
613                 pub type blkcnt_t = u32;
614
615                 #[repr(C)]
616                 #[derive(Copy)] pub struct stat {
617                     pub st_dev: c_ulonglong,
618                     pub __pad0: [c_uchar; 4],
619                     pub __st_ino: ino_t,
620                     pub st_mode: c_uint,
621                     pub st_nlink: c_uint,
622                     pub st_uid: uid_t,
623                     pub st_gid: gid_t,
624                     pub st_rdev: c_ulonglong,
625                     pub __pad3: [c_uchar; 4],
626                     pub st_size: c_longlong,
627                     pub st_blksize: blksize_t,
628                     pub st_blocks: c_ulonglong,
629                     pub st_atime: time_t,
630                     pub st_atime_nsec: c_ulong,
631                     pub st_mtime: time_t,
632                     pub st_mtime_nsec: c_ulong,
633                     pub st_ctime: time_t,
634                     pub st_ctime_nsec: c_ulong,
635                     pub st_ino: c_ulonglong,
636                 }
637
638                 #[repr(C)]
639                 #[derive(Copy)] pub struct utimbuf {
640                     pub actime: time_t,
641                     pub modtime: time_t,
642                 }
643
644                 #[repr(C)]
645                 #[derive(Copy)] pub struct pthread_attr_t {
646                     pub __size: [u32; 9]
647                 }
648             }
649             #[cfg(any(target_arch = "mips",
650                       target_arch = "mipsel"))]
651             pub mod posix01 {
652                 use types::os::arch::c95::{c_long, c_ulong, time_t};
653                 use types::os::arch::posix88::{gid_t, ino_t};
654                 use types::os::arch::posix88::{mode_t, off_t};
655                 use types::os::arch::posix88::{uid_t};
656
657                 pub type nlink_t = u32;
658                 pub type blksize_t = i32;
659                 pub type blkcnt_t = i32;
660
661                 #[repr(C)]
662                 #[derive(Copy)] pub struct stat {
663                     pub st_dev: c_ulong,
664                     pub st_pad1: [c_long; 3],
665                     pub st_ino: ino_t,
666                     pub st_mode: mode_t,
667                     pub st_nlink: nlink_t,
668                     pub st_uid: uid_t,
669                     pub st_gid: gid_t,
670                     pub st_rdev: c_ulong,
671                     pub st_pad2: [c_long; 2],
672                     pub st_size: off_t,
673                     pub st_pad3: c_long,
674                     pub st_atime: time_t,
675                     pub st_atime_nsec: c_long,
676                     pub st_mtime: time_t,
677                     pub st_mtime_nsec: c_long,
678                     pub st_ctime: time_t,
679                     pub st_ctime_nsec: c_long,
680                     pub st_blksize: blksize_t,
681                     pub st_blocks: blkcnt_t,
682                     pub st_pad5: [c_long; 14],
683                 }
684
685                 #[repr(C)]
686                 #[derive(Copy)] pub struct utimbuf {
687                     pub actime: time_t,
688                     pub modtime: time_t,
689                 }
690
691                 #[repr(C)]
692                 #[derive(Copy)] pub struct pthread_attr_t {
693                     pub __size: [u32; 9]
694                 }
695             }
696             pub mod posix08 {}
697             pub mod bsd44 {}
698             pub mod extra {
699                 use types::os::arch::c95::{c_ushort, c_int, c_uchar};
700                 #[repr(C)]
701                 #[derive(Copy)] pub struct sockaddr_ll {
702                     pub sll_family: c_ushort,
703                     pub sll_protocol: c_ushort,
704                     pub sll_ifindex: c_int,
705                     pub sll_hatype: c_ushort,
706                     pub sll_pkttype: c_uchar,
707                     pub sll_halen: c_uchar,
708                     pub sll_addr: [c_uchar; 8]
709                 }
710             }
711
712         }
713
714         #[cfg(any(target_arch = "x86_64",
715                   target_arch = "aarch64"))]
716         pub mod arch {
717             pub mod c95 {
718                 #[cfg(not(target_arch = "aarch64"))]
719                 pub type c_char = i8;
720                 #[cfg(target_arch = "aarch64")]
721                 pub type c_char = u8;
722                 pub type c_schar = i8;
723                 pub type c_uchar = u8;
724                 pub type c_short = i16;
725                 pub type c_ushort = u16;
726                 pub type c_int = i32;
727                 pub type c_uint = u32;
728                 pub type c_long = i64;
729                 pub type c_ulong = u64;
730                 pub type c_float = f32;
731                 pub type c_double = f64;
732                 pub type size_t = u64;
733                 pub type ptrdiff_t = i64;
734                 pub type clock_t = i64;
735                 pub type time_t = i64;
736                 pub type suseconds_t = i64;
737                 #[cfg(not(target_arch = "aarch64"))]
738                 pub type wchar_t = i32;
739                 #[cfg(target_arch = "aarch64")]
740                 pub type wchar_t = u32;
741             }
742             pub mod c99 {
743                 pub type c_longlong = i64;
744                 pub type c_ulonglong = u64;
745                 pub type intptr_t = i64;
746                 pub type uintptr_t = u64;
747                 pub type intmax_t = i64;
748                 pub type uintmax_t = u64;
749             }
750             pub mod posix88 {
751                 pub type off_t = i64;
752                 pub type dev_t = u64;
753                 pub type ino_t = u64;
754                 pub type pid_t = i32;
755                 pub type uid_t = u32;
756                 pub type gid_t = u32;
757                 pub type useconds_t = u32;
758                 pub type mode_t = u32;
759                 pub type ssize_t = i64;
760             }
761             #[cfg(not(target_arch = "aarch64"))]
762             pub mod posix01 {
763                 use types::os::arch::c95::{c_int, c_long, time_t};
764                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
765                 use types::os::arch::posix88::{mode_t, off_t};
766                 use types::os::arch::posix88::{uid_t};
767
768                 pub type nlink_t = u64;
769                 pub type blksize_t = i64;
770                 pub type blkcnt_t = i64;
771
772                 #[repr(C)]
773                 #[derive(Copy)] pub struct stat {
774                     pub st_dev: dev_t,
775                     pub st_ino: ino_t,
776                     pub st_nlink: nlink_t,
777                     pub st_mode: mode_t,
778                     pub st_uid: uid_t,
779                     pub st_gid: gid_t,
780                     pub __pad0: c_int,
781                     pub st_rdev: dev_t,
782                     pub st_size: off_t,
783                     pub st_blksize: blksize_t,
784                     pub st_blocks: blkcnt_t,
785                     pub st_atime: time_t,
786                     pub st_atime_nsec: c_long,
787                     pub st_mtime: time_t,
788                     pub st_mtime_nsec: c_long,
789                     pub st_ctime: time_t,
790                     pub st_ctime_nsec: c_long,
791                     pub __unused: [c_long; 3],
792                 }
793
794                 #[repr(C)]
795                 #[derive(Copy)] pub struct utimbuf {
796                     pub actime: time_t,
797                     pub modtime: time_t,
798                 }
799
800                 #[repr(C)]
801                 #[derive(Copy)] pub struct pthread_attr_t {
802                     pub __size: [u64; 7]
803                 }
804             }
805             #[cfg(target_arch = "aarch64")]
806             pub mod posix01 {
807                 use types::os::arch::c95::{c_int, c_long, time_t};
808                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
809                 use types::os::arch::posix88::{mode_t, off_t};
810                 use types::os::arch::posix88::{uid_t};
811
812                 pub type nlink_t = u32;
813                 pub type blksize_t = i32;
814                 pub type blkcnt_t = i64;
815
816                 #[repr(C)]
817                 #[derive(Copy)] pub struct stat {
818                     pub st_dev: dev_t,
819                     pub st_ino: ino_t,
820                     pub st_mode: mode_t,
821                     pub st_nlink: nlink_t,
822                     pub st_uid: uid_t,
823                     pub st_gid: gid_t,
824                     pub st_rdev: dev_t,
825                     pub __pad1: dev_t,
826                     pub st_size: off_t,
827                     pub st_blksize: blksize_t,
828                     pub __pad2: c_int,
829                     pub st_blocks: blkcnt_t,
830                     pub st_atime: time_t,
831                     pub st_atime_nsec: c_long,
832                     pub st_mtime: time_t,
833                     pub st_mtime_nsec: c_long,
834                     pub st_ctime: time_t,
835                     pub st_ctime_nsec: c_long,
836                     pub __unused: [c_int; 2],
837                 }
838
839                 #[repr(C)]
840                 #[derive(Copy)] pub struct utimbuf {
841                     pub actime: time_t,
842                     pub modtime: time_t,
843                 }
844
845                 #[repr(C)]
846                 #[derive(Copy)] pub struct pthread_attr_t {
847                     pub __size: [u64; 8]
848                 }
849             }
850             pub mod posix08 {
851             }
852             pub mod bsd44 {
853             }
854             pub mod extra {
855                 use types::os::arch::c95::{c_ushort, c_int, c_uchar};
856                 #[derive(Copy)] pub struct sockaddr_ll {
857                     pub sll_family: c_ushort,
858                     pub sll_protocol: c_ushort,
859                     pub sll_ifindex: c_int,
860                     pub sll_hatype: c_ushort,
861                     pub sll_pkttype: c_uchar,
862                     pub sll_halen: c_uchar,
863                     pub sll_addr: [c_uchar; 8]
864                 }
865
866             }
867         }
868     }
869
870     #[cfg(target_os = "freebsd")]
871     pub mod os {
872         pub mod common {
873             pub mod posix01 {
874                 use types::common::c95::{c_void};
875                 use types::os::arch::c95::{c_char, c_int, size_t,
876                                                  time_t, suseconds_t, c_long};
877                 use types::os::arch::c99::{uintptr_t};
878
879                 pub type pthread_t = uintptr_t;
880
881                 #[repr(C)]
882                 #[derive(Copy)] pub struct glob_t {
883                     pub gl_pathc:  size_t,
884                     pub __unused1: size_t,
885                     pub gl_offs:   size_t,
886                     pub __unused2: c_int,
887                     pub gl_pathv:  *mut *mut c_char,
888
889                     pub __unused3: *mut c_void,
890
891                     pub __unused4: *mut c_void,
892                     pub __unused5: *mut c_void,
893                     pub __unused6: *mut c_void,
894                     pub __unused7: *mut c_void,
895                     pub __unused8: *mut c_void,
896                 }
897
898                 #[repr(C)]
899                 #[derive(Copy)] pub struct timeval {
900                     pub tv_sec: time_t,
901                     pub tv_usec: suseconds_t,
902                 }
903
904                 #[repr(C)]
905                 #[derive(Copy)] pub struct timespec {
906                     pub tv_sec: time_t,
907                     pub tv_nsec: c_long,
908                 }
909
910                 #[derive(Copy)] pub enum timezone {}
911
912                 pub type sighandler_t = size_t;
913             }
914             pub mod bsd44 {
915                 use types::common::c95::{c_void};
916                 use types::os::arch::c95::{c_char, c_int, c_uint};
917
918                 pub type socklen_t = u32;
919                 pub type sa_family_t = u8;
920                 pub type in_port_t = u16;
921                 pub type in_addr_t = u32;
922                 #[repr(C)]
923                 #[derive(Copy)] pub struct sockaddr {
924                     pub sa_len: u8,
925                     pub sa_family: sa_family_t,
926                     pub sa_data: [u8; 14],
927                 }
928                 #[repr(C)]
929                 #[derive(Copy)] pub struct sockaddr_storage {
930                     pub ss_len: u8,
931                     pub ss_family: sa_family_t,
932                     pub __ss_pad1: [u8; 6],
933                     pub __ss_align: i64,
934                     pub __ss_pad2: [u8; 112],
935                 }
936                 #[repr(C)]
937                 #[derive(Copy)] pub struct sockaddr_in {
938                     pub sin_len: u8,
939                     pub sin_family: sa_family_t,
940                     pub sin_port: in_port_t,
941                     pub sin_addr: in_addr,
942                     pub sin_zero: [u8; 8],
943                 }
944                 #[repr(C)]
945                 #[derive(Copy)] pub struct in_addr {
946                     pub s_addr: in_addr_t,
947                 }
948                 #[repr(C)]
949                 #[derive(Copy)] pub struct sockaddr_in6 {
950                     pub sin6_len: u8,
951                     pub sin6_family: sa_family_t,
952                     pub sin6_port: in_port_t,
953                     pub sin6_flowinfo: u32,
954                     pub sin6_addr: in6_addr,
955                     pub sin6_scope_id: u32,
956                 }
957                 #[repr(C)]
958                 #[derive(Copy)] pub struct in6_addr {
959                     pub s6_addr: [u16; 8]
960                 }
961                 #[repr(C)]
962                 #[derive(Copy)] pub struct ip_mreq {
963                     pub imr_multiaddr: in_addr,
964                     pub imr_interface: in_addr,
965                 }
966                 #[repr(C)]
967                 #[derive(Copy)] pub struct ip6_mreq {
968                     pub ipv6mr_multiaddr: in6_addr,
969                     pub ipv6mr_interface: c_uint,
970                 }
971                 #[repr(C)]
972                 #[derive(Copy)] pub struct addrinfo {
973                     pub ai_flags: c_int,
974                     pub ai_family: c_int,
975                     pub ai_socktype: c_int,
976                     pub ai_protocol: c_int,
977                     pub ai_addrlen: socklen_t,
978                     pub ai_canonname: *mut c_char,
979                     pub ai_addr: *mut sockaddr,
980                     pub ai_next: *mut addrinfo,
981                 }
982                 #[repr(C)]
983                 #[derive(Copy)] pub struct sockaddr_un {
984                     pub sun_len: u8,
985                     pub sun_family: sa_family_t,
986                     pub sun_path: [c_char; 104]
987                 }
988                 #[repr(C)]
989                 #[derive(Copy)] pub struct ifaddrs {
990                     pub ifa_next: *mut ifaddrs,
991                     pub ifa_name: *mut c_char,
992                     pub ifa_flags: c_uint,
993                     pub ifa_addr: *mut sockaddr,
994                     pub ifa_netmask: *mut sockaddr,
995                     pub ifa_dstaddr: *mut sockaddr,
996                     pub ifa_data: *mut c_void
997                 }
998
999
1000             }
1001         }
1002
1003         #[cfg(target_arch = "x86_64")]
1004         pub mod arch {
1005             pub mod c95 {
1006                 pub type c_char = i8;
1007                 pub type c_schar = i8;
1008                 pub type c_uchar = u8;
1009                 pub type c_short = i16;
1010                 pub type c_ushort = u16;
1011                 pub type c_int = i32;
1012                 pub type c_uint = u32;
1013                 pub type c_long = i64;
1014                 pub type c_ulong = u64;
1015                 pub type c_float = f32;
1016                 pub type c_double = f64;
1017                 pub type size_t = u64;
1018                 pub type ptrdiff_t = i64;
1019                 pub type clock_t = i32;
1020                 pub type time_t = i64;
1021                 pub type suseconds_t = i64;
1022                 pub type wchar_t = i32;
1023             }
1024             pub mod c99 {
1025                 pub type c_longlong = i64;
1026                 pub type c_ulonglong = u64;
1027                 pub type intptr_t = i64;
1028                 pub type uintptr_t = u64;
1029                 pub type intmax_t = i64;
1030                 pub type uintmax_t = u64;
1031             }
1032             pub mod posix88 {
1033                 pub type off_t = i64;
1034                 pub type dev_t = u32;
1035                 pub type ino_t = u32;
1036                 pub type pid_t = i32;
1037                 pub type uid_t = u32;
1038                 pub type gid_t = u32;
1039                 pub type useconds_t = u32;
1040                 pub type mode_t = u16;
1041                 pub type ssize_t = i64;
1042             }
1043             pub mod posix01 {
1044                 use types::common::c95::{c_void};
1045                 use types::common::c99::{uint8_t, uint32_t, int32_t};
1046                 use types::os::arch::c95::{c_long, time_t};
1047                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
1048                 use types::os::arch::posix88::{mode_t, off_t};
1049                 use types::os::arch::posix88::{uid_t};
1050
1051                 pub type nlink_t = u16;
1052                 pub type blksize_t = i64;
1053                 pub type blkcnt_t = i64;
1054                 pub type fflags_t = u32;
1055                 #[repr(C)]
1056                 #[derive(Copy)] pub struct stat {
1057                     pub st_dev: dev_t,
1058                     pub st_ino: ino_t,
1059                     pub st_mode: mode_t,
1060                     pub st_nlink: nlink_t,
1061                     pub st_uid: uid_t,
1062                     pub st_gid: gid_t,
1063                     pub st_rdev: dev_t,
1064                     pub st_atime: time_t,
1065                     pub st_atime_nsec: c_long,
1066                     pub st_mtime: time_t,
1067                     pub st_mtime_nsec: c_long,
1068                     pub st_ctime: time_t,
1069                     pub st_ctime_nsec: c_long,
1070                     pub st_size: off_t,
1071                     pub st_blocks: blkcnt_t,
1072                     pub st_blksize: blksize_t,
1073                     pub st_flags: fflags_t,
1074                     pub st_gen: uint32_t,
1075                     pub st_lspare: int32_t,
1076                     pub st_birthtime: time_t,
1077                     pub st_birthtime_nsec: c_long,
1078                     pub __unused: [uint8_t; 2],
1079                 }
1080
1081                 #[repr(C)]
1082                 #[derive(Copy)] pub struct utimbuf {
1083                     pub actime: time_t,
1084                     pub modtime: time_t,
1085                 }
1086
1087                 pub type pthread_attr_t = *mut c_void;
1088             }
1089             pub mod posix08 {
1090             }
1091             pub mod bsd44 {
1092             }
1093             pub mod extra {
1094             }
1095         }
1096     }
1097
1098     #[cfg(target_os = "dragonfly")]
1099     pub mod os {
1100         pub mod common {
1101             pub mod posix01 {
1102                 use types::common::c95::{c_void};
1103                 use types::os::arch::c95::{c_char, c_int, size_t,
1104                                                  time_t, suseconds_t, c_long};
1105                 use types::os::arch::c99::{uintptr_t};
1106
1107                 pub type pthread_t = uintptr_t;
1108
1109                 #[repr(C)]
1110                 #[derive(Copy)] pub struct glob_t {
1111                     pub gl_pathc:  size_t,
1112                     pub __unused1: size_t,
1113                     pub gl_offs:   size_t,
1114                     pub __unused2: c_int,
1115                     pub gl_pathv:  *mut *mut c_char,
1116
1117                     pub __unused3: *mut c_void,
1118
1119                     pub __unused4: *mut c_void,
1120                     pub __unused5: *mut c_void,
1121                     pub __unused6: *mut c_void,
1122                     pub __unused7: *mut c_void,
1123                     pub __unused8: *mut c_void,
1124                 }
1125
1126                 #[repr(C)]
1127                 #[derive(Copy)] pub struct timeval {
1128                     pub tv_sec: time_t,
1129                     pub tv_usec: suseconds_t,
1130                 }
1131
1132                 #[repr(C)]
1133                 #[derive(Copy)] pub struct timespec {
1134                     pub tv_sec: time_t,
1135                     pub tv_nsec: c_long,
1136                 }
1137
1138                 #[derive(Copy)] pub enum timezone {}
1139
1140                 pub type sighandler_t = size_t;
1141             }
1142             pub mod bsd44 {
1143                 use types::common::c95::{c_void};
1144                 use types::os::arch::c95::{c_char, c_int, c_uint};
1145
1146                 pub type socklen_t = u32;
1147                 pub type sa_family_t = u8;
1148                 pub type in_port_t = u16;
1149                 pub type in_addr_t = u32;
1150                 #[repr(C)]
1151                 #[derive(Copy)] pub struct sockaddr {
1152                     pub sa_len: u8,
1153                     pub sa_family: sa_family_t,
1154                     pub sa_data: [u8; 14],
1155                 }
1156                 #[repr(C)]
1157                 #[derive(Copy)] pub struct sockaddr_storage {
1158                     pub ss_len: u8,
1159                     pub ss_family: sa_family_t,
1160                     pub __ss_pad1: [u8; 6],
1161                     pub __ss_align: i64,
1162                     pub __ss_pad2: [u8; 112],
1163                 }
1164                 #[repr(C)]
1165                 #[derive(Copy)] pub struct sockaddr_in {
1166                     pub sin_len: u8,
1167                     pub sin_family: sa_family_t,
1168                     pub sin_port: in_port_t,
1169                     pub sin_addr: in_addr,
1170                     pub sin_zero: [u8; 8],
1171                 }
1172                 #[repr(C)]
1173                 #[derive(Copy)] pub struct in_addr {
1174                     pub s_addr: in_addr_t,
1175                 }
1176                 #[repr(C)]
1177                 #[derive(Copy)] pub struct sockaddr_in6 {
1178                     pub sin6_len: u8,
1179                     pub sin6_family: sa_family_t,
1180                     pub sin6_port: in_port_t,
1181                     pub sin6_flowinfo: u32,
1182                     pub sin6_addr: in6_addr,
1183                     pub sin6_scope_id: u32,
1184                 }
1185                 #[repr(C)]
1186                 #[derive(Copy)] pub struct in6_addr {
1187                     pub s6_addr: [u16; 8]
1188                 }
1189                 #[repr(C)]
1190                 #[derive(Copy)] pub struct ip_mreq {
1191                     pub imr_multiaddr: in_addr,
1192                     pub imr_interface: in_addr,
1193                 }
1194                 #[repr(C)]
1195                 #[derive(Copy)] pub struct ip6_mreq {
1196                     pub ipv6mr_multiaddr: in6_addr,
1197                     pub ipv6mr_interface: c_uint,
1198                 }
1199                 #[repr(C)]
1200                 #[derive(Copy)] pub struct addrinfo {
1201                     pub ai_flags: c_int,
1202                     pub ai_family: c_int,
1203                     pub ai_socktype: c_int,
1204                     pub ai_protocol: c_int,
1205                     pub ai_addrlen: socklen_t,
1206                     pub ai_canonname: *mut c_char,
1207                     pub ai_addr: *mut sockaddr,
1208                     pub ai_next: *mut addrinfo,
1209                 }
1210                 #[repr(C)]
1211                 #[derive(Copy)] pub struct sockaddr_un {
1212                     pub sun_len: u8,
1213                     pub sun_family: sa_family_t,
1214                     pub sun_path: [c_char; 104]
1215                 }
1216                 #[repr(C)]
1217                 #[derive(Copy)] pub struct ifaddrs {
1218                     pub ifa_next: *mut ifaddrs,
1219                     pub ifa_name: *mut c_char,
1220                     pub ifa_flags: c_uint,
1221                     pub ifa_addr: *mut sockaddr,
1222                     pub ifa_netmask: *mut sockaddr,
1223                     pub ifa_dstaddr: *mut sockaddr,
1224                     pub ifa_data: *mut c_void
1225                 }
1226
1227             }
1228         }
1229
1230         #[cfg(target_arch = "x86_64")]
1231         pub mod arch {
1232             pub mod c95 {
1233                 pub type c_char = i8;
1234                 pub type c_schar = i8;
1235                 pub type c_uchar = u8;
1236                 pub type c_short = i16;
1237                 pub type c_ushort = u16;
1238                 pub type c_int = i32;
1239                 pub type c_uint = u32;
1240                 pub type c_long = i64;
1241                 pub type c_ulong = u64;
1242                 pub type c_float = f32;
1243                 pub type c_double = f64;
1244                 pub type size_t = u64;
1245                 pub type ptrdiff_t = i64;
1246                 pub type clock_t = i32;
1247                 pub type time_t = i64;
1248                 pub type suseconds_t = i64;
1249                 pub type wchar_t = i32;
1250             }
1251             pub mod c99 {
1252                 pub type c_longlong = i64;
1253                 pub type c_ulonglong = u64;
1254                 pub type intptr_t = i64;
1255                 pub type uintptr_t = u64;
1256                 pub type intmax_t = i64;
1257                 pub type uintmax_t = u64;
1258             }
1259             pub mod posix88 {
1260                 pub type off_t = i64;
1261                 pub type dev_t = u32;
1262                 pub type ino_t = u32;
1263                 pub type pid_t = i32;
1264                 pub type uid_t = u32;
1265                 pub type gid_t = u32;
1266                 pub type useconds_t = u32;
1267                 pub type mode_t = u16;
1268                 pub type ssize_t = i64;
1269             }
1270             pub mod posix01 {
1271                 use types::common::c95::{c_void};
1272                 use types::common::c99::{uint16_t, uint32_t, int32_t, uint64_t, int64_t};
1273                 use types::os::arch::c95::{c_long, time_t};
1274                 use types::os::arch::posix88::{dev_t, gid_t};
1275                 use types::os::arch::posix88::{mode_t, off_t};
1276                 use types::os::arch::posix88::{uid_t};
1277
1278                 pub type nlink_t = u16;
1279                 pub type blksize_t = uint32_t;
1280                 pub type ino_t = uint64_t;
1281                 pub type blkcnt_t = i64;
1282                 pub type fflags_t = u32;
1283
1284                 #[repr(C)]
1285                 #[derive(Copy)] pub struct stat {
1286                     pub st_ino: ino_t,
1287                     pub st_nlink: nlink_t,
1288                     pub st_dev: dev_t,
1289                     pub st_mode: mode_t,
1290                     pub st_padding1: uint16_t,
1291                     pub st_uid: uid_t,
1292                     pub st_gid: gid_t,
1293                     pub st_rdev: dev_t,
1294                     pub st_atime: time_t,
1295                     pub st_atime_nsec: c_long,
1296                     pub st_mtime: time_t,
1297                     pub st_mtime_nsec: c_long,
1298                     pub st_ctime: time_t,
1299                     pub st_ctime_nsec: c_long,
1300                     pub st_size: off_t,
1301                     pub st_blocks: blkcnt_t,
1302                     pub st_blksize: blksize_t,
1303                     pub st_flags: fflags_t,
1304                     pub st_gen: uint32_t,
1305                     pub st_lspare: int32_t,
1306                     pub st_qspare1: int64_t,
1307                     pub st_qspare2: int64_t,
1308                 }
1309                 #[repr(C)]
1310                 #[derive(Copy)] pub struct utimbuf {
1311                     pub actime: time_t,
1312                     pub modtime: time_t,
1313                 }
1314
1315                 pub type pthread_attr_t = *mut c_void;
1316             }
1317             pub mod posix08 {
1318             }
1319             pub mod bsd44 {
1320             }
1321             pub mod extra {
1322             }
1323         }
1324     }
1325
1326     #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
1327     pub mod os {
1328         pub mod common {
1329             pub mod posix01 {
1330                 use types::common::c95::{c_void};
1331                 use types::os::arch::c95::{c_char, c_int, size_t,
1332                                                  time_t, suseconds_t, c_long};
1333                 use types::os::arch::c99::{uintptr_t};
1334
1335                 pub type pthread_t = uintptr_t;
1336
1337                 #[cfg(target_os = "bitrig")]
1338                 #[repr(C)]
1339                 #[derive(Copy)] pub struct glob_t {
1340                     pub gl_pathc:  c_int,
1341                     pub gl_matchc: c_int,
1342                     pub gl_offs:   c_int,
1343                     pub gl_flags:  c_int,
1344                     pub gl_pathv:  *mut *mut c_char,
1345                     pub __unused1: *mut c_void,
1346                     pub __unused2: *mut c_void,
1347                     pub __unused3: *mut c_void,
1348                     pub __unused4: *mut c_void,
1349                     pub __unused5: *mut c_void,
1350                     pub __unused6: *mut c_void,
1351                     pub __unused7: *mut c_void,
1352                 }
1353
1354                 #[cfg(target_os = "openbsd")]
1355                 #[repr(C)]
1356                 #[derive(Copy)] pub struct glob_t {
1357                     pub gl_pathc:  c_int,
1358                     pub __unused1: c_int,
1359                     pub gl_offs:   c_int,
1360                     pub __unused2: c_int,
1361                     pub gl_pathv:  *mut *mut c_char,
1362
1363                     pub __unused3: *mut c_void,
1364
1365                     pub __unused4: *mut c_void,
1366                     pub __unused5: *mut c_void,
1367                     pub __unused6: *mut c_void,
1368                     pub __unused7: *mut c_void,
1369                     pub __unused8: *mut c_void,
1370                     pub __unused9: *mut c_void,
1371                 }
1372
1373                 #[repr(C)]
1374                 #[derive(Copy)] pub struct timeval {
1375                     pub tv_sec: time_t,
1376                     pub tv_usec: suseconds_t,
1377                 }
1378
1379                 #[repr(C)]
1380                 #[derive(Copy)] pub struct timespec {
1381                     pub tv_sec: time_t,
1382                     pub tv_nsec: c_long,
1383                 }
1384
1385                 #[derive(Copy)] pub enum timezone {}
1386
1387                 pub type sighandler_t = size_t;
1388             }
1389             pub mod bsd44 {
1390                 use types::common::c95::{c_void};
1391                 use types::os::arch::c95::{c_char, c_int, c_uint};
1392
1393                 pub type socklen_t = u32;
1394                 pub type sa_family_t = u8;
1395                 pub type in_port_t = u16;
1396                 pub type in_addr_t = u32;
1397                 #[repr(C)]
1398                 #[derive(Copy)] pub struct sockaddr {
1399                     pub sa_len: u8,
1400                     pub sa_family: sa_family_t,
1401                     pub sa_data: [u8; 14],
1402                 }
1403                 #[repr(C)]
1404                 #[derive(Copy)] pub struct sockaddr_storage {
1405                     pub ss_len: u8,
1406                     pub ss_family: sa_family_t,
1407                     pub __ss_pad1: [u8; 6],
1408                     pub __ss_pad2: i64,
1409                     pub __ss_pad3: [u8; 240],
1410                 }
1411                 #[repr(C)]
1412                 #[derive(Copy)] pub struct sockaddr_in {
1413                     pub sin_len: u8,
1414                     pub sin_family: sa_family_t,
1415                     pub sin_port: in_port_t,
1416                     pub sin_addr: in_addr,
1417                     pub sin_zero: [u8; 8],
1418                 }
1419                 #[repr(C)]
1420                 #[derive(Copy)] pub struct in_addr {
1421                     pub s_addr: in_addr_t,
1422                 }
1423                 #[repr(C)]
1424                 #[derive(Copy)] pub struct sockaddr_in6 {
1425                     pub sin6_len: u8,
1426                     pub sin6_family: sa_family_t,
1427                     pub sin6_port: in_port_t,
1428                     pub sin6_flowinfo: u32,
1429                     pub sin6_addr: in6_addr,
1430                     pub sin6_scope_id: u32,
1431                 }
1432                 #[repr(C)]
1433                 #[derive(Copy)] pub struct in6_addr {
1434                     pub s6_addr: [u16; 8]
1435                 }
1436                 #[repr(C)]
1437                 #[derive(Copy)] pub struct ip_mreq {
1438                     pub imr_multiaddr: in_addr,
1439                     pub imr_interface: in_addr,
1440                 }
1441                 #[repr(C)]
1442                 #[derive(Copy)] pub struct ip6_mreq {
1443                     pub ipv6mr_multiaddr: in6_addr,
1444                     pub ipv6mr_interface: c_uint,
1445                 }
1446                 #[repr(C)]
1447                 #[derive(Copy)] pub struct addrinfo {
1448                     pub ai_flags: c_int,
1449                     pub ai_family: c_int,
1450                     pub ai_socktype: c_int,
1451                     pub ai_protocol: c_int,
1452                     pub ai_addrlen: socklen_t,
1453                     pub ai_addr: *mut sockaddr,
1454                     pub ai_canonname: *mut c_char,
1455                     pub ai_next: *mut addrinfo,
1456                 }
1457                 #[repr(C)]
1458                 #[derive(Copy)] pub struct sockaddr_un {
1459                     pub sun_len: u8,
1460                     pub sun_family: sa_family_t,
1461                     pub sun_path: [c_char; 104]
1462                 }
1463                 #[repr(C)]
1464                 #[derive(Copy)] pub struct ifaddrs {
1465                     pub ifa_next: *mut ifaddrs,
1466                     pub ifa_name: *mut c_char,
1467                     pub ifa_flags: c_uint,
1468                     pub ifa_addr: *mut sockaddr,
1469                     pub ifa_netmask: *mut sockaddr,
1470                     pub ifa_dstaddr: *mut sockaddr,
1471                     pub ifa_data: *mut c_void
1472                 }
1473             }
1474         }
1475
1476         #[cfg(target_arch = "x86_64")]
1477         pub mod arch {
1478             pub mod c95 {
1479                 pub type c_char = i8;
1480                 pub type c_schar = i8;
1481                 pub type c_uchar = u8;
1482                 pub type c_short = i16;
1483                 pub type c_ushort = u16;
1484                 pub type c_int = i32;
1485                 pub type c_uint = u32;
1486                 pub type c_long = i64;
1487                 pub type c_ulong = u64;
1488                 pub type c_float = f32;
1489                 pub type c_double = f64;
1490                 pub type size_t = u64;
1491                 pub type ptrdiff_t = i64;
1492                 pub type clock_t = i64;
1493                 pub type time_t = i64;
1494                 pub type suseconds_t = i64;
1495                 pub type wchar_t = i32;
1496             }
1497             pub mod c99 {
1498                 pub type c_longlong = i64;
1499                 pub type c_ulonglong = u64;
1500                 pub type intptr_t = i64;
1501                 pub type uintptr_t = u64;
1502                 pub type intmax_t = i64;
1503                 pub type uintmax_t = u64;
1504             }
1505             pub mod posix88 {
1506                 use types::os::arch::c95::{c_long};
1507                 pub type off_t = i64;
1508                 pub type dev_t = i32;
1509                 pub type ino_t = u64;
1510                 pub type pid_t = i32;
1511                 pub type uid_t = u32;
1512                 pub type gid_t = u32;
1513                 pub type useconds_t = u32;
1514                 pub type mode_t = u32;
1515                 pub type ssize_t = c_long;
1516             }
1517             pub mod posix01 {
1518                 use types::common::c95::{c_void};
1519                 use types::common::c99::{uint32_t, uint64_t};
1520                 use types::os::arch::c95::{c_long, time_t};
1521                 use types::os::arch::posix88::{dev_t, gid_t};
1522                 use types::os::arch::posix88::{mode_t, off_t};
1523                 use types::os::arch::posix88::{uid_t};
1524
1525                 pub type nlink_t = uint32_t;
1526                 pub type blksize_t = uint32_t;
1527                 pub type ino_t = uint64_t;
1528                 pub type blkcnt_t = i64;
1529                 pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t
1530
1531                 #[repr(C)]
1532                 #[derive(Copy)] pub struct stat {
1533                     pub st_mode: mode_t,
1534                     pub st_dev: dev_t,
1535                     pub st_ino: ino_t,
1536                     pub st_nlink: nlink_t,
1537                     pub st_uid: uid_t,
1538                     pub st_gid: gid_t,
1539                     pub st_rdev: dev_t,
1540                     pub st_atime: time_t,
1541                     pub st_atime_nsec: c_long,
1542                     pub st_mtime: time_t,
1543                     pub st_mtime_nsec: c_long,
1544                     pub st_ctime: time_t,
1545                     pub st_ctime_nsec: c_long,
1546                     pub st_size: off_t,
1547                     pub st_blocks: blkcnt_t,
1548                     pub st_blksize: blksize_t,
1549                     pub st_flags: fflags_t,
1550                     pub st_gen: uint32_t,
1551                     pub st_birthtime: time_t,
1552                     pub st_birthtime_nsec: c_long,
1553                 }
1554                 #[repr(C)]
1555                 #[derive(Copy)] pub struct utimbuf {
1556                     pub actime: time_t,
1557                     pub modtime: time_t,
1558                 }
1559
1560                 pub type pthread_attr_t = *mut c_void;
1561             }
1562             pub mod posix08 {
1563             }
1564             pub mod bsd44 {
1565             }
1566             pub mod extra {
1567             }
1568         }
1569     }
1570
1571     #[cfg(target_os = "windows")]
1572     pub mod os {
1573         pub mod common {
1574             pub mod posix01 {
1575                 use types::os::arch::c95::{c_short, time_t, c_long};
1576                 use types::os::arch::extra::{int64, time64_t};
1577                 use types::os::arch::posix88::{dev_t, ino_t};
1578
1579                 // pub Note: this is the struct called stat64 in Windows. Not stat,
1580                 // nor stati64.
1581                 #[repr(C)]
1582                 #[derive(Copy)] pub struct stat {
1583                     pub st_dev: dev_t,
1584                     pub st_ino: ino_t,
1585                     pub st_mode: u16,
1586                     pub st_nlink: c_short,
1587                     pub st_uid: c_short,
1588                     pub st_gid: c_short,
1589                     pub st_rdev: dev_t,
1590                     pub st_size: int64,
1591                     pub st_atime: time64_t,
1592                     pub st_mtime: time64_t,
1593                     pub st_ctime: time64_t,
1594                 }
1595
1596                 // note that this is called utimbuf64 in Windows
1597                 #[repr(C)]
1598                 #[derive(Copy)] pub struct utimbuf {
1599                     pub actime: time64_t,
1600                     pub modtime: time64_t,
1601                 }
1602
1603                 #[repr(C)]
1604                 #[derive(Copy)] pub struct timeval {
1605                     pub tv_sec: c_long,
1606                     pub tv_usec: c_long,
1607                 }
1608
1609                 #[repr(C)]
1610                 #[derive(Copy)] pub struct timespec {
1611                     pub tv_sec: time_t,
1612                     pub tv_nsec: c_long,
1613                 }
1614
1615                 #[derive(Copy)] pub enum timezone {}
1616             }
1617
1618             pub mod bsd44 {
1619                 use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1620                 use types::os::arch::c99::uintptr_t;
1621
1622                 pub type SOCKET = uintptr_t;
1623                 pub type socklen_t = c_int;
1624                 pub type sa_family_t = u16;
1625                 pub type in_port_t = u16;
1626                 pub type in_addr_t = u32;
1627                 #[repr(C)]
1628                 #[derive(Copy)] pub struct sockaddr {
1629                     pub sa_family: sa_family_t,
1630                     pub sa_data: [u8; 14],
1631                 }
1632                 #[repr(C)]
1633                 #[derive(Copy)] pub struct sockaddr_storage {
1634                     pub ss_family: sa_family_t,
1635                     pub __ss_pad1: [u8; 6],
1636                     pub __ss_align: i64,
1637                     pub __ss_pad2: [u8; 112],
1638                 }
1639                 #[repr(C)]
1640                 #[derive(Copy)] pub struct sockaddr_in {
1641                     pub sin_family: sa_family_t,
1642                     pub sin_port: in_port_t,
1643                     pub sin_addr: in_addr,
1644                     pub sin_zero: [u8; 8],
1645                 }
1646                 #[repr(C)]
1647                 #[derive(Copy)] pub struct in_addr {
1648                     pub s_addr: in_addr_t,
1649                 }
1650                 #[repr(C)]
1651                 #[derive(Copy)] pub struct sockaddr_in6 {
1652                     pub sin6_family: sa_family_t,
1653                     pub sin6_port: in_port_t,
1654                     pub sin6_flowinfo: u32,
1655                     pub sin6_addr: in6_addr,
1656                     pub sin6_scope_id: u32,
1657                 }
1658                 #[repr(C)]
1659                 #[derive(Copy)] pub struct in6_addr {
1660                     pub s6_addr: [u16; 8]
1661                 }
1662                 #[repr(C)]
1663                 #[derive(Copy)] pub struct ip_mreq {
1664                     pub imr_multiaddr: in_addr,
1665                     pub imr_interface: in_addr,
1666                 }
1667                 #[repr(C)]
1668                 #[derive(Copy)] pub struct ip6_mreq {
1669                     pub ipv6mr_multiaddr: in6_addr,
1670                     pub ipv6mr_interface: c_uint,
1671                 }
1672                 #[repr(C)]
1673                 #[derive(Copy)] pub struct addrinfo {
1674                     pub ai_flags: c_int,
1675                     pub ai_family: c_int,
1676                     pub ai_socktype: c_int,
1677                     pub ai_protocol: c_int,
1678                     pub ai_addrlen: size_t,
1679                     pub ai_canonname: *mut c_char,
1680                     pub ai_addr: *mut sockaddr,
1681                     pub ai_next: *mut addrinfo,
1682                 }
1683                 #[repr(C)]
1684                 #[derive(Copy)] pub struct sockaddr_un {
1685                     pub sun_family: sa_family_t,
1686                     pub sun_path: [c_char; 108]
1687                 }
1688             }
1689         }
1690
1691         pub mod arch {
1692             pub mod c95 {
1693                 pub type c_char = i8;
1694                 pub type c_schar = i8;
1695                 pub type c_uchar = u8;
1696                 pub type c_short = i16;
1697                 pub type c_ushort = u16;
1698                 pub type c_int = i32;
1699                 pub type c_uint = u32;
1700                 pub type c_long = i32;
1701                 pub type c_ulong = u32;
1702                 pub type c_float = f32;
1703                 pub type c_double = f64;
1704
1705                 #[cfg(target_arch = "x86")]
1706                 pub type size_t = u32;
1707                 #[cfg(target_arch = "x86_64")]
1708                 pub type size_t = u64;
1709
1710                 #[cfg(target_arch = "x86")]
1711                 pub type ptrdiff_t = i32;
1712                 #[cfg(target_arch = "x86_64")]
1713                 pub type ptrdiff_t = i64;
1714
1715                 pub type clock_t = i32;
1716
1717                 #[cfg(target_arch = "x86")]
1718                 pub type time_t = i32;
1719                 #[cfg(target_arch = "x86_64")]
1720                 pub type time_t = i64;
1721
1722                 #[cfg(target_arch = "x86")]
1723                 pub type suseconds_t = i32;
1724                 #[cfg(target_arch = "x86_64")]
1725                 pub type suseconds_t = i64;
1726
1727                 pub type wchar_t = u16;
1728             }
1729
1730             pub mod c99 {
1731                 pub type c_longlong = i64;
1732                 pub type c_ulonglong = u64;
1733
1734                 #[cfg(target_arch = "x86")]
1735                 pub type intptr_t = i32;
1736                 #[cfg(target_arch = "x86_64")]
1737                 pub type intptr_t = i64;
1738
1739                 #[cfg(target_arch = "x86")]
1740                 pub type uintptr_t = u32;
1741                 #[cfg(target_arch = "x86_64")]
1742                 pub type uintptr_t = u64;
1743
1744                 pub type intmax_t = i64;
1745                 pub type uintmax_t = u64;
1746             }
1747
1748             pub mod posix88 {
1749                 pub type off_t = i32;
1750                 pub type dev_t = u32;
1751                 pub type ino_t = u16;
1752
1753                 pub type pid_t = u32;
1754
1755                 pub type useconds_t = u32;
1756                 pub type mode_t = u16;
1757
1758                 #[cfg(target_arch = "x86")]
1759                 pub type ssize_t = i32;
1760                 #[cfg(target_arch = "x86_64")]
1761                 pub type ssize_t = i64;
1762             }
1763
1764             pub mod posix01 {
1765             }
1766             pub mod posix08 {
1767             }
1768             pub mod bsd44 {
1769             }
1770             pub mod extra {
1771                 use consts::os::extra::{MAX_PROTOCOL_CHAIN,
1772                                               WSAPROTOCOL_LEN};
1773                 use types::common::c95::c_void;
1774                 use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1775                 use types::os::arch::c95::{c_long, c_ulong};
1776                 use types::os::arch::c95::{wchar_t};
1777                 use types::os::arch::c99::{c_ulonglong, c_longlong, uintptr_t};
1778
1779                 pub type BOOL = c_int;
1780                 pub type BYTE = u8;
1781                 pub type BOOLEAN = BYTE;
1782                 pub type CCHAR = c_char;
1783                 pub type CHAR = c_char;
1784
1785                 pub type DWORD = c_ulong;
1786                 pub type DWORDLONG = c_ulonglong;
1787
1788                 pub type HANDLE = LPVOID;
1789                 pub type HINSTANCE = HANDLE;
1790                 pub type HMODULE = HINSTANCE;
1791
1792                 pub type LONG = c_long;
1793                 pub type PLONG = *mut c_long;
1794
1795                 #[cfg(target_arch = "x86")]
1796                 pub type LONG_PTR = c_long;
1797                 #[cfg(target_arch = "x86_64")]
1798                 pub type LONG_PTR = i64;
1799
1800                 pub type LARGE_INTEGER = c_longlong;
1801                 pub type PLARGE_INTEGER = *mut c_longlong;
1802
1803                 pub type LPCWSTR = *const WCHAR;
1804                 pub type LPCSTR = *const CHAR;
1805
1806                 pub type LPWSTR = *mut WCHAR;
1807                 pub type LPSTR = *mut CHAR;
1808
1809                 pub type LPWCH = *mut WCHAR;
1810                 pub type LPCH = *mut CHAR;
1811
1812                 #[repr(C)]
1813                 #[derive(Copy)] pub struct SECURITY_ATTRIBUTES {
1814                     pub nLength: DWORD,
1815                     pub lpSecurityDescriptor: LPVOID,
1816                     pub bInheritHandle: BOOL,
1817                 }
1818                 pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
1819
1820                 pub type LPVOID = *mut c_void;
1821                 pub type LPCVOID = *const c_void;
1822                 pub type LPBYTE = *mut BYTE;
1823                 pub type LPWORD = *mut WORD;
1824                 pub type LPDWORD = *mut DWORD;
1825                 pub type LPHANDLE = *mut HANDLE;
1826
1827                 pub type LRESULT = LONG_PTR;
1828                 pub type PBOOL = *mut BOOL;
1829                 pub type WCHAR = wchar_t;
1830                 pub type WORD = u16;
1831                 pub type SIZE_T = size_t;
1832
1833                 pub type time64_t = i64;
1834                 pub type int64 = i64;
1835
1836                 #[repr(C)]
1837                 #[derive(Copy)] pub struct STARTUPINFO {
1838                     pub cb: DWORD,
1839                     pub lpReserved: LPWSTR,
1840                     pub lpDesktop: LPWSTR,
1841                     pub lpTitle: LPWSTR,
1842                     pub dwX: DWORD,
1843                     pub dwY: DWORD,
1844                     pub dwXSize: DWORD,
1845                     pub dwYSize: DWORD,
1846                     pub dwXCountChars: DWORD,
1847                     pub dwYCountCharts: DWORD,
1848                     pub dwFillAttribute: DWORD,
1849                     pub dwFlags: DWORD,
1850                     pub wShowWindow: WORD,
1851                     pub cbReserved2: WORD,
1852                     pub lpReserved2: LPBYTE,
1853                     pub hStdInput: HANDLE,
1854                     pub hStdOutput: HANDLE,
1855                     pub hStdError: HANDLE,
1856                 }
1857                 pub type LPSTARTUPINFO = *mut STARTUPINFO;
1858
1859                 #[repr(C)]
1860                 #[derive(Copy)] pub struct PROCESS_INFORMATION {
1861                     pub hProcess: HANDLE,
1862                     pub hThread: HANDLE,
1863                     pub dwProcessId: DWORD,
1864                     pub dwThreadId: DWORD,
1865                 }
1866                 pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
1867
1868                 #[repr(C)]
1869                 #[derive(Copy)] pub struct SYSTEM_INFO {
1870                     pub wProcessorArchitecture: WORD,
1871                     pub wReserved: WORD,
1872                     pub dwPageSize: DWORD,
1873                     pub lpMinimumApplicationAddress: LPVOID,
1874                     pub lpMaximumApplicationAddress: LPVOID,
1875                     pub dwActiveProcessorMask: uintptr_t,
1876                     pub dwNumberOfProcessors: DWORD,
1877                     pub dwProcessorType: DWORD,
1878                     pub dwAllocationGranularity: DWORD,
1879                     pub wProcessorLevel: WORD,
1880                     pub wProcessorRevision: WORD,
1881                 }
1882                 pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
1883
1884                 #[repr(C)]
1885                 #[derive(Copy)] pub struct MEMORY_BASIC_INFORMATION {
1886                     pub BaseAddress: LPVOID,
1887                     pub AllocationBase: LPVOID,
1888                     pub AllocationProtect: DWORD,
1889                     pub RegionSize: SIZE_T,
1890                     pub State: DWORD,
1891                     pub Protect: DWORD,
1892                     pub Type: DWORD,
1893                 }
1894                 pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
1895
1896                 #[repr(C)]
1897                 #[derive(Copy)] pub struct OVERLAPPED {
1898                     pub Internal: *mut c_ulong,
1899                     pub InternalHigh: *mut c_ulong,
1900                     pub Offset: DWORD,
1901                     pub OffsetHigh: DWORD,
1902                     pub hEvent: HANDLE,
1903                 }
1904
1905                 pub type LPOVERLAPPED = *mut OVERLAPPED;
1906
1907                 #[repr(C)]
1908                 #[derive(Copy)] pub struct FILETIME {
1909                     pub dwLowDateTime: DWORD,
1910                     pub dwHighDateTime: DWORD,
1911                 }
1912
1913                 pub type LPFILETIME = *mut FILETIME;
1914
1915                 #[repr(C)]
1916                 #[derive(Copy)] pub struct GUID {
1917                     pub Data1: DWORD,
1918                     pub Data2: WORD,
1919                     pub Data3: WORD,
1920                     pub Data4: [BYTE; 8],
1921                 }
1922
1923                 #[repr(C)]
1924                 #[derive(Copy)] pub struct WSAPROTOCOLCHAIN {
1925                     pub ChainLen: c_int,
1926                     pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize],
1927                 }
1928
1929                 pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
1930
1931                 #[repr(C)]
1932                 #[derive(Copy)] pub struct WSAPROTOCOL_INFO {
1933                     pub dwServiceFlags1: DWORD,
1934                     pub dwServiceFlags2: DWORD,
1935                     pub dwServiceFlags3: DWORD,
1936                     pub dwServiceFlags4: DWORD,
1937                     pub dwProviderFlags: DWORD,
1938                     pub ProviderId: GUID,
1939                     pub dwCatalogEntryId: DWORD,
1940                     pub ProtocolChain: WSAPROTOCOLCHAIN,
1941                     pub iVersion: c_int,
1942                     pub iAddressFamily: c_int,
1943                     pub iMaxSockAddr: c_int,
1944                     pub iMinSockAddr: c_int,
1945                     pub iSocketType: c_int,
1946                     pub iProtocol: c_int,
1947                     pub iProtocolMaxOffset: c_int,
1948                     pub iNetworkByteOrder: c_int,
1949                     pub iSecurityScheme: c_int,
1950                     pub dwMessageSize: DWORD,
1951                     pub dwProviderReserved: DWORD,
1952                     pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1],
1953                 }
1954
1955                 pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
1956
1957                 pub type GROUP = c_uint;
1958
1959                 #[repr(C)]
1960                 #[derive(Copy)] pub struct WIN32_FIND_DATAW {
1961                     pub dwFileAttributes: DWORD,
1962                     pub ftCreationTime: FILETIME,
1963                     pub ftLastAccessTime: FILETIME,
1964                     pub ftLastWriteTime: FILETIME,
1965                     pub nFileSizeHigh: DWORD,
1966                     pub nFileSizeLow: DWORD,
1967                     pub dwReserved0: DWORD,
1968                     pub dwReserved1: DWORD,
1969                     pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
1970                     pub cAlternateFileName: [wchar_t; 14],
1971                 }
1972
1973                 pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
1974             }
1975         }
1976     }
1977
1978     #[cfg(any(target_os = "macos", target_os = "ios"))]
1979     pub mod os {
1980         pub mod common {
1981             pub mod posix01 {
1982                 use types::common::c95::c_void;
1983                 use types::os::arch::c95::{c_char, c_int, size_t, time_t};
1984                 use types::os::arch::c95::{suseconds_t, c_long};
1985                 use types::os::arch::c99::{uintptr_t};
1986
1987                 pub type pthread_t = uintptr_t;
1988
1989                 #[repr(C)]
1990                 #[derive(Copy)] pub struct glob_t {
1991                     pub gl_pathc:  size_t,
1992                     pub __unused1: c_int,
1993                     pub gl_offs:   size_t,
1994                     pub __unused2: c_int,
1995                     pub gl_pathv:  *mut *mut c_char,
1996
1997                     pub __unused3: *mut c_void,
1998
1999                     pub __unused4: *mut c_void,
2000                     pub __unused5: *mut c_void,
2001                     pub __unused6: *mut c_void,
2002                     pub __unused7: *mut c_void,
2003                     pub __unused8: *mut c_void,
2004                 }
2005
2006                 #[repr(C)]
2007                 #[derive(Copy)] pub struct timeval {
2008                     pub tv_sec: time_t,
2009                     pub tv_usec: suseconds_t,
2010                 }
2011
2012                 #[repr(C)]
2013                 #[derive(Copy)] pub struct timespec {
2014                     pub tv_sec: time_t,
2015                     pub tv_nsec: c_long,
2016                 }
2017
2018                 #[derive(Copy)] pub enum timezone {}
2019
2020                 pub type sighandler_t = size_t;
2021             }
2022
2023             pub mod bsd44 {
2024                 use types::common::c95::{c_void};
2025                 use types::os::arch::c95::{c_char, c_int, c_uint};
2026
2027                 pub type socklen_t = u32;
2028                 pub type sa_family_t = u8;
2029                 pub type in_port_t = u16;
2030                 pub type in_addr_t = u32;
2031                 #[repr(C)]
2032                 #[derive(Copy)] pub struct sockaddr {
2033                     pub sa_len: u8,
2034                     pub sa_family: sa_family_t,
2035                     pub sa_data: [u8; 14],
2036                 }
2037
2038                 #[repr(C)]
2039                 #[derive(Copy)] pub struct sockaddr_storage {
2040                     pub ss_len: u8,
2041                     pub ss_family: sa_family_t,
2042                     pub __ss_pad1: [u8; 6],
2043                     pub __ss_align: i64,
2044                     pub __ss_pad2: [u8; 112],
2045                 }
2046
2047                 #[repr(C)]
2048                 #[derive(Copy)] pub struct sockaddr_in {
2049                     pub sin_len: u8,
2050                     pub sin_family: sa_family_t,
2051                     pub sin_port: in_port_t,
2052                     pub sin_addr: in_addr,
2053                     pub sin_zero: [u8; 8],
2054                 }
2055
2056                 #[repr(C)]
2057                 #[derive(Copy)] pub struct in_addr {
2058                     pub s_addr: in_addr_t,
2059                 }
2060
2061                 #[repr(C)]
2062                 #[derive(Copy)] pub struct sockaddr_in6 {
2063                     pub sin6_len: u8,
2064                     pub sin6_family: sa_family_t,
2065                     pub sin6_port: in_port_t,
2066                     pub sin6_flowinfo: u32,
2067                     pub sin6_addr: in6_addr,
2068                     pub sin6_scope_id: u32,
2069                 }
2070
2071                 #[repr(C)]
2072                 #[derive(Copy)] pub struct in6_addr {
2073                     pub s6_addr: [u16; 8]
2074                 }
2075
2076                 #[repr(C)]
2077                 #[derive(Copy)] pub struct ip_mreq {
2078                     pub imr_multiaddr: in_addr,
2079                     pub imr_interface: in_addr,
2080                 }
2081
2082                 #[repr(C)]
2083                 #[derive(Copy)] pub struct ip6_mreq {
2084                     pub ipv6mr_multiaddr: in6_addr,
2085                     pub ipv6mr_interface: c_uint,
2086                 }
2087
2088                 #[repr(C)]
2089                 #[derive(Copy)] pub struct addrinfo {
2090                     pub ai_flags: c_int,
2091                     pub ai_family: c_int,
2092                     pub ai_socktype: c_int,
2093                     pub ai_protocol: c_int,
2094                     pub ai_addrlen: socklen_t,
2095                     pub ai_canonname: *mut c_char,
2096                     pub ai_addr: *mut sockaddr,
2097                     pub ai_next: *mut addrinfo,
2098                 }
2099
2100                 #[repr(C)]
2101                 #[derive(Copy)] pub struct sockaddr_un {
2102                     pub sun_len: u8,
2103                     pub sun_family: sa_family_t,
2104                     pub sun_path: [c_char; 104]
2105                 }
2106
2107                 #[repr(C)]
2108                 #[derive(Copy)] pub struct ifaddrs {
2109                     pub ifa_next: *mut ifaddrs,
2110                     pub ifa_name: *mut c_char,
2111                     pub ifa_flags: c_uint,
2112                     pub ifa_addr: *mut sockaddr,
2113                     pub ifa_netmask: *mut sockaddr,
2114                     pub ifa_dstaddr: *mut sockaddr,
2115                     pub ifa_data: *mut c_void
2116                 }
2117             }
2118         }
2119
2120         #[cfg(any(target_arch = "arm", target_arch = "x86"))]
2121         pub mod arch {
2122             pub mod c95 {
2123                 pub type c_char = i8;
2124                 pub type c_schar = i8;
2125                 pub type c_uchar = u8;
2126                 pub type c_short = i16;
2127                 pub type c_ushort = u16;
2128                 pub type c_int = i32;
2129                 pub type c_uint = u32;
2130                 pub type c_long = i32;
2131                 pub type c_ulong = u32;
2132                 pub type c_float = f32;
2133                 pub type c_double = f64;
2134                 pub type size_t = u32;
2135                 pub type ptrdiff_t = i32;
2136                 pub type clock_t = c_ulong;
2137                 pub type time_t = c_long;
2138                 pub type suseconds_t = i32;
2139                 pub type wchar_t = i32;
2140             }
2141             pub mod c99 {
2142                 pub type c_longlong = i64;
2143                 pub type c_ulonglong = u64;
2144                 pub type intptr_t = i32;
2145                 pub type uintptr_t = u32;
2146                 pub type intmax_t = i64;
2147                 pub type uintmax_t = u64;
2148             }
2149             pub mod posix88 {
2150                 use types::os::arch::c95::c_long;
2151
2152                 pub type off_t = i64;
2153                 pub type dev_t = i32;
2154                 pub type ino_t = u64;
2155                 pub type pid_t = i32;
2156                 pub type uid_t = u32;
2157                 pub type gid_t = u32;
2158                 pub type useconds_t = u32;
2159                 pub type mode_t = u16;
2160                 pub type ssize_t = c_long;
2161             }
2162             pub mod posix01 {
2163                 use types::common::c99::{int32_t, int64_t, uint32_t};
2164                 use types::os::arch::c95::{c_char, c_long, time_t};
2165                 use types::os::arch::posix88::{dev_t, gid_t, ino_t,
2166                                                      mode_t, off_t, uid_t};
2167
2168                 pub type nlink_t = u16;
2169                 pub type blksize_t = i32;
2170                 pub type blkcnt_t = i64;
2171
2172                 #[repr(C)]
2173                 #[derive(Copy)] pub struct stat {
2174                     pub st_dev: dev_t,
2175                     pub st_mode: mode_t,
2176                     pub st_nlink: nlink_t,
2177                     pub st_ino: ino_t,
2178                     pub st_uid: uid_t,
2179                     pub st_gid: gid_t,
2180                     pub st_rdev: dev_t,
2181                     pub st_atime: time_t,
2182                     pub st_atime_nsec: c_long,
2183                     pub st_mtime: time_t,
2184                     pub st_mtime_nsec: c_long,
2185                     pub st_ctime: time_t,
2186                     pub st_ctime_nsec: c_long,
2187                     pub st_birthtime: time_t,
2188                     pub st_birthtime_nsec: c_long,
2189                     pub st_size: off_t,
2190                     pub st_blocks: blkcnt_t,
2191                     pub st_blksize: blksize_t,
2192                     pub st_flags: uint32_t,
2193                     pub st_gen: uint32_t,
2194                     pub st_lspare: int32_t,
2195                     pub st_qspare: [int64_t; 2],
2196                 }
2197
2198                 #[repr(C)]
2199                 #[derive(Copy)] pub struct utimbuf {
2200                     pub actime: time_t,
2201                     pub modtime: time_t,
2202                 }
2203
2204                 #[repr(C)]
2205                 #[derive(Copy)] pub struct pthread_attr_t {
2206                     pub __sig: c_long,
2207                     pub __opaque: [c_char; 36]
2208                 }
2209             }
2210             pub mod posix08 {
2211             }
2212             pub mod bsd44 {
2213             }
2214             pub mod extra {
2215                 #[repr(C)]
2216                 #[derive(Copy)] pub struct mach_timebase_info {
2217                     pub numer: u32,
2218                     pub denom: u32,
2219                 }
2220
2221                 pub type mach_timebase_info_data_t = mach_timebase_info;
2222             }
2223         }
2224
2225         #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
2226         pub mod arch {
2227             pub mod c95 {
2228                 pub type c_char = i8;
2229                 pub type c_schar = i8;
2230                 pub type c_uchar = u8;
2231                 pub type c_short = i16;
2232                 pub type c_ushort = u16;
2233                 pub type c_int = i32;
2234                 pub type c_uint = u32;
2235                 pub type c_long = i64;
2236                 pub type c_ulong = u64;
2237                 pub type c_float = f32;
2238                 pub type c_double = f64;
2239                 pub type size_t = u64;
2240                 pub type ptrdiff_t = i64;
2241                 pub type clock_t = c_ulong;
2242                 pub type time_t = c_long;
2243                 pub type suseconds_t = i32;
2244                 pub type wchar_t = i32;
2245             }
2246             pub mod c99 {
2247                 pub type c_longlong = i64;
2248                 pub type c_ulonglong = u64;
2249                 pub type intptr_t = i64;
2250                 pub type uintptr_t = u64;
2251                 pub type intmax_t = i64;
2252                 pub type uintmax_t = u64;
2253             }
2254             pub mod posix88 {
2255                 use types::os::arch::c95::c_long;
2256
2257                 pub type off_t = i64;
2258                 pub type dev_t = i32;
2259                 pub type ino_t = u64;
2260                 pub type pid_t = i32;
2261                 pub type uid_t = u32;
2262                 pub type gid_t = u32;
2263                 pub type useconds_t = u32;
2264                 pub type mode_t = u16;
2265                 pub type ssize_t = c_long;
2266             }
2267             pub mod posix01 {
2268                 use types::common::c99::{int32_t, int64_t};
2269                 use types::common::c99::{uint32_t};
2270                 use types::os::arch::c95::{c_char, c_long, time_t};
2271                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
2272                 use types::os::arch::posix88::{mode_t, off_t, uid_t};
2273
2274                 pub type nlink_t = u16;
2275                 pub type blksize_t = i32;
2276                 pub type blkcnt_t = i64;
2277
2278                 #[repr(C)]
2279                 #[derive(Copy)] pub struct stat {
2280                     pub st_dev: dev_t,
2281                     pub st_mode: mode_t,
2282                     pub st_nlink: nlink_t,
2283                     pub st_ino: ino_t,
2284                     pub st_uid: uid_t,
2285                     pub st_gid: gid_t,
2286                     pub st_rdev: dev_t,
2287                     pub st_atime: time_t,
2288                     pub st_atime_nsec: c_long,
2289                     pub st_mtime: time_t,
2290                     pub st_mtime_nsec: c_long,
2291                     pub st_ctime: time_t,
2292                     pub st_ctime_nsec: c_long,
2293                     pub st_birthtime: time_t,
2294                     pub st_birthtime_nsec: c_long,
2295                     pub st_size: off_t,
2296                     pub st_blocks: blkcnt_t,
2297                     pub st_blksize: blksize_t,
2298                     pub st_flags: uint32_t,
2299                     pub st_gen: uint32_t,
2300                     pub st_lspare: int32_t,
2301                     pub st_qspare: [int64_t; 2],
2302                 }
2303
2304                 #[repr(C)]
2305                 #[derive(Copy)] pub struct utimbuf {
2306                     pub actime: time_t,
2307                     pub modtime: time_t,
2308                 }
2309
2310                 #[repr(C)]
2311                 #[derive(Copy)] pub struct pthread_attr_t {
2312                     pub __sig: c_long,
2313                     pub __opaque: [c_char; 56]
2314                 }
2315             }
2316             pub mod posix08 {
2317             }
2318             pub mod bsd44 {
2319             }
2320             pub mod extra {
2321                 #[repr(C)]
2322                 #[derive(Copy)] pub struct mach_timebase_info {
2323                     pub numer: u32,
2324                     pub denom: u32,
2325                 }
2326
2327                 pub type mach_timebase_info_data_t = mach_timebase_info;
2328             }
2329         }
2330     }
2331 }
2332
2333 pub mod consts {
2334     // Consts tend to vary per OS so we pull their definitions out
2335     // into this module.
2336
2337     #[cfg(target_os = "windows")]
2338     pub mod os {
2339         pub mod c95 {
2340             use types::os::arch::c95::{c_int, c_uint};
2341
2342             pub const EXIT_FAILURE : c_int = 1;
2343             pub const EXIT_SUCCESS : c_int = 0;
2344             pub const RAND_MAX : c_int = 32767;
2345             pub const EOF : c_int = -1;
2346             pub const SEEK_SET : c_int = 0;
2347             pub const SEEK_CUR : c_int = 1;
2348             pub const SEEK_END : c_int = 2;
2349             pub const _IOFBF : c_int = 0;
2350             pub const _IONBF : c_int = 4;
2351             pub const _IOLBF : c_int = 64;
2352             pub const BUFSIZ : c_uint = 512_u32;
2353             pub const FOPEN_MAX : c_uint = 20_u32;
2354             pub const FILENAME_MAX : c_uint = 260_u32;
2355             pub const L_tmpnam : c_uint = 16_u32;
2356             pub const TMP_MAX : c_uint = 32767_u32;
2357
2358             pub const WSAEINTR: c_int = 10004;
2359             pub const WSAEBADF: c_int = 10009;
2360             pub const WSAEACCES: c_int = 10013;
2361             pub const WSAEFAULT: c_int = 10014;
2362             pub const WSAEINVAL: c_int = 10022;
2363             pub const WSAEMFILE: c_int = 10024;
2364             pub const WSAEWOULDBLOCK: c_int = 10035;
2365             pub const WSAEINPROGRESS: c_int = 10036;
2366             pub const WSAEALREADY: c_int = 10037;
2367             pub const WSAENOTSOCK: c_int = 10038;
2368             pub const WSAEDESTADDRREQ: c_int = 10039;
2369             pub const WSAEMSGSIZE: c_int = 10040;
2370             pub const WSAEPROTOTYPE: c_int = 10041;
2371             pub const WSAENOPROTOOPT: c_int = 10042;
2372             pub const WSAEPROTONOSUPPORT: c_int = 10043;
2373             pub const WSAESOCKTNOSUPPORT: c_int = 10044;
2374             pub const WSAEOPNOTSUPP: c_int = 10045;
2375             pub const WSAEPFNOSUPPORT: c_int = 10046;
2376             pub const WSAEAFNOSUPPORT: c_int = 10047;
2377             pub const WSAEADDRINUSE: c_int = 10048;
2378             pub const WSAEADDRNOTAVAIL: c_int = 10049;
2379             pub const WSAENETDOWN: c_int = 10050;
2380             pub const WSAENETUNREACH: c_int = 10051;
2381             pub const WSAENETRESET: c_int = 10052;
2382             pub const WSAECONNABORTED: c_int = 10053;
2383             pub const WSAECONNRESET: c_int = 10054;
2384             pub const WSAENOBUFS: c_int = 10055;
2385             pub const WSAEISCONN: c_int = 10056;
2386             pub const WSAENOTCONN: c_int = 10057;
2387             pub const WSAESHUTDOWN: c_int = 10058;
2388             pub const WSAETOOMANYREFS: c_int = 10059;
2389             pub const WSAETIMEDOUT: c_int = 10060;
2390             pub const WSAECONNREFUSED: c_int = 10061;
2391             pub const WSAELOOP: c_int = 10062;
2392             pub const WSAENAMETOOLONG: c_int = 10063;
2393             pub const WSAEHOSTDOWN: c_int = 10064;
2394             pub const WSAEHOSTUNREACH: c_int = 10065;
2395             pub const WSAENOTEMPTY: c_int = 10066;
2396             pub const WSAEPROCLIM: c_int = 10067;
2397             pub const WSAEUSERS: c_int = 10068;
2398             pub const WSAEDQUOT: c_int = 10069;
2399             pub const WSAESTALE: c_int = 10070;
2400             pub const WSAEREMOTE: c_int = 10071;
2401             pub const WSASYSNOTREADY: c_int = 10091;
2402             pub const WSAVERNOTSUPPORTED: c_int = 10092;
2403             pub const WSANOTINITIALISED: c_int = 10093;
2404             pub const WSAEDISCON: c_int = 10101;
2405             pub const WSAENOMORE: c_int = 10102;
2406             pub const WSAECANCELLED: c_int = 10103;
2407             pub const WSAEINVALIDPROCTABLE: c_int = 10104;
2408             pub const WSAEINVALIDPROVIDER: c_int = 10105;
2409             pub const WSAEPROVIDERFAILEDINIT: c_int = 10106;
2410         }
2411         pub mod c99 {
2412         }
2413         pub mod posix88 {
2414             use types::os::arch::c95::c_int;
2415
2416             pub const O_RDONLY : c_int = 0;
2417             pub const O_WRONLY : c_int = 1;
2418             pub const O_RDWR : c_int = 2;
2419             pub const O_APPEND : c_int = 8;
2420             pub const O_CREAT : c_int = 256;
2421             pub const O_EXCL : c_int = 1024;
2422             pub const O_TRUNC : c_int = 512;
2423             pub const S_IFIFO : c_int = 4096;
2424             pub const S_IFCHR : c_int = 8192;
2425             pub const S_IFBLK : c_int = 12288;
2426             pub const S_IFDIR : c_int = 16384;
2427             pub const S_IFREG : c_int = 32768;
2428             pub const S_IFLNK : c_int = 40960;
2429             pub const S_IFMT : c_int = 61440;
2430             pub const S_IEXEC : c_int = 64;
2431             pub const S_IWRITE : c_int = 128;
2432             pub const S_IREAD : c_int = 256;
2433             pub const S_IRWXU : c_int = 448;
2434             pub const S_IXUSR : c_int = 64;
2435             pub const S_IWUSR : c_int = 128;
2436             pub const S_IRUSR : c_int = 256;
2437             pub const F_OK : c_int = 0;
2438             pub const R_OK : c_int = 4;
2439             pub const W_OK : c_int = 2;
2440             pub const X_OK : c_int = 1;
2441             pub const STDIN_FILENO : c_int = 0;
2442             pub const STDOUT_FILENO : c_int = 1;
2443             pub const STDERR_FILENO : c_int = 2;
2444         }
2445         pub mod posix01 {
2446         }
2447         pub mod posix08 {
2448         }
2449         pub mod bsd44 {
2450             use types::os::arch::c95::c_int;
2451
2452             pub const AF_INET: c_int = 2;
2453             pub const AF_INET6: c_int = 23;
2454             pub const SOCK_STREAM: c_int = 1;
2455             pub const SOCK_DGRAM: c_int = 2;
2456             pub const SOCK_RAW: c_int = 3;
2457             pub const IPPROTO_TCP: c_int = 6;
2458             pub const IPPROTO_IP: c_int = 0;
2459             pub const IPPROTO_IPV6: c_int = 41;
2460             pub const IP_MULTICAST_TTL: c_int = 10;
2461             pub const IP_MULTICAST_LOOP: c_int = 11;
2462             pub const IP_ADD_MEMBERSHIP: c_int = 12;
2463             pub const IP_DROP_MEMBERSHIP: c_int = 13;
2464             pub const IPV6_ADD_MEMBERSHIP: c_int = 5;
2465             pub const IPV6_DROP_MEMBERSHIP: c_int = 6;
2466             pub const IP_TTL: c_int = 4;
2467             pub const IP_HDRINCL: c_int = 2;
2468
2469             pub const TCP_NODELAY: c_int = 0x0001;
2470             pub const SOL_SOCKET: c_int = 0xffff;
2471             pub const SO_KEEPALIVE: c_int = 8;
2472             pub const SO_BROADCAST: c_int = 32;
2473             pub const SO_REUSEADDR: c_int = 4;
2474             pub const SO_ERROR: c_int = 0x1007;
2475
2476             pub const IFF_LOOPBACK: c_int = 4;
2477
2478             pub const SHUT_RD: c_int = 0;
2479             pub const SHUT_WR: c_int = 1;
2480             pub const SHUT_RDWR: c_int = 2;
2481         }
2482         pub mod extra {
2483             use SOCKET;
2484             use types::os::arch::c95::{c_int, c_long};
2485             use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE};
2486
2487             pub const TRUE : BOOL = 1;
2488             pub const FALSE : BOOL = 0;
2489
2490             pub const O_TEXT : c_int = 16384;
2491             pub const O_BINARY : c_int = 32768;
2492             pub const O_NOINHERIT: c_int = 128;
2493
2494             pub const ERROR_SUCCESS : c_int = 0;
2495             pub const ERROR_INVALID_FUNCTION: c_int = 1;
2496             pub const ERROR_FILE_NOT_FOUND: c_int = 2;
2497             pub const ERROR_ACCESS_DENIED: c_int = 5;
2498             pub const ERROR_INVALID_HANDLE : c_int = 6;
2499             pub const ERROR_BROKEN_PIPE: c_int = 109;
2500             pub const ERROR_DISK_FULL : c_int = 112;
2501             pub const ERROR_CALL_NOT_IMPLEMENTED : c_int = 120;
2502             pub const ERROR_INSUFFICIENT_BUFFER : c_int = 122;
2503             pub const ERROR_INVALID_NAME : c_int = 123;
2504             pub const ERROR_ALREADY_EXISTS : c_int = 183;
2505             pub const ERROR_PIPE_BUSY: c_int = 231;
2506             pub const ERROR_NO_DATA: c_int = 232;
2507             pub const ERROR_INVALID_ADDRESS : c_int = 487;
2508             pub const ERROR_PIPE_CONNECTED: c_int = 535;
2509             pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758;
2510             pub const ERROR_OPERATION_ABORTED: c_int = 995;
2511             pub const ERROR_IO_PENDING: c_int = 997;
2512             pub const ERROR_FILE_INVALID : c_int = 1006;
2513             pub const ERROR_NOT_FOUND: c_int = 1168;
2514             pub const INVALID_HANDLE_VALUE: HANDLE = -1 as HANDLE;
2515
2516             pub const DELETE : DWORD = 0x00010000;
2517             pub const READ_CONTROL : DWORD = 0x00020000;
2518             pub const SYNCHRONIZE : DWORD = 0x00100000;
2519             pub const WRITE_DAC : DWORD = 0x00040000;
2520             pub const WRITE_OWNER : DWORD = 0x00080000;
2521
2522             pub const PROCESS_CREATE_PROCESS : DWORD = 0x0080;
2523             pub const PROCESS_CREATE_THREAD : DWORD = 0x0002;
2524             pub const PROCESS_DUP_HANDLE : DWORD = 0x0040;
2525             pub const PROCESS_QUERY_INFORMATION : DWORD = 0x0400;
2526             pub const PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000;
2527             pub const PROCESS_SET_INFORMATION : DWORD = 0x0200;
2528             pub const PROCESS_SET_QUOTA : DWORD = 0x0100;
2529             pub const PROCESS_SUSPEND_RESUME : DWORD = 0x0800;
2530             pub const PROCESS_TERMINATE : DWORD = 0x0001;
2531             pub const PROCESS_VM_OPERATION : DWORD = 0x0008;
2532             pub const PROCESS_VM_READ : DWORD = 0x0010;
2533             pub const PROCESS_VM_WRITE : DWORD = 0x0020;
2534
2535             pub const STARTF_FORCEONFEEDBACK : DWORD = 0x00000040;
2536             pub const STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080;
2537             pub const STARTF_PREVENTPINNING : DWORD = 0x00002000;
2538             pub const STARTF_RUNFULLSCREEN : DWORD = 0x00000020;
2539             pub const STARTF_TITLEISAPPID : DWORD = 0x00001000;
2540             pub const STARTF_TITLEISLINKNAME : DWORD = 0x00000800;
2541             pub const STARTF_USECOUNTCHARS : DWORD = 0x00000008;
2542             pub const STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010;
2543             pub const STARTF_USEHOTKEY : DWORD = 0x00000200;
2544             pub const STARTF_USEPOSITION : DWORD = 0x00000004;
2545             pub const STARTF_USESHOWWINDOW : DWORD = 0x00000001;
2546             pub const STARTF_USESIZE : DWORD = 0x00000002;
2547             pub const STARTF_USESTDHANDLES : DWORD = 0x00000100;
2548
2549             pub const WAIT_ABANDONED : DWORD = 0x00000080;
2550             pub const WAIT_OBJECT_0 : DWORD = 0x00000000;
2551             pub const WAIT_TIMEOUT : DWORD = 0x00000102;
2552             pub const WAIT_FAILED : DWORD = -1;
2553
2554             pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001;
2555             pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002;
2556
2557             pub const INFINITE : DWORD = -1;
2558             pub const STILL_ACTIVE : DWORD = 259;
2559
2560             pub const MEM_COMMIT : DWORD = 0x00001000;
2561             pub const MEM_RESERVE : DWORD = 0x00002000;
2562             pub const MEM_DECOMMIT : DWORD = 0x00004000;
2563             pub const MEM_RELEASE : DWORD = 0x00008000;
2564             pub const MEM_RESET : DWORD = 0x00080000;
2565             pub const MEM_RESET_UNDO : DWORD = 0x1000000;
2566             pub const MEM_LARGE_PAGES : DWORD = 0x20000000;
2567             pub const MEM_PHYSICAL : DWORD = 0x00400000;
2568             pub const MEM_TOP_DOWN : DWORD = 0x00100000;
2569             pub const MEM_WRITE_WATCH : DWORD = 0x00200000;
2570
2571             pub const PAGE_EXECUTE : DWORD = 0x10;
2572             pub const PAGE_EXECUTE_READ : DWORD = 0x20;
2573             pub const PAGE_EXECUTE_READWRITE : DWORD = 0x40;
2574             pub const PAGE_EXECUTE_WRITECOPY : DWORD = 0x80;
2575             pub const PAGE_NOACCESS : DWORD = 0x01;
2576             pub const PAGE_READONLY : DWORD = 0x02;
2577             pub const PAGE_READWRITE : DWORD = 0x04;
2578             pub const PAGE_WRITECOPY : DWORD = 0x08;
2579             pub const PAGE_GUARD : DWORD = 0x100;
2580             pub const PAGE_NOCACHE : DWORD = 0x200;
2581             pub const PAGE_WRITECOMBINE : DWORD = 0x400;
2582
2583             pub const SEC_COMMIT : DWORD = 0x8000000;
2584             pub const SEC_IMAGE : DWORD = 0x1000000;
2585             pub const SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000;
2586             pub const SEC_LARGE_PAGES : DWORD = 0x80000000;
2587             pub const SEC_NOCACHE : DWORD = 0x10000000;
2588             pub const SEC_RESERVE : DWORD = 0x4000000;
2589             pub const SEC_WRITECOMBINE : DWORD = 0x40000000;
2590
2591             pub const FILE_MAP_ALL_ACCESS : DWORD = 0xf001f;
2592             pub const FILE_MAP_READ : DWORD = 0x4;
2593             pub const FILE_MAP_WRITE : DWORD = 0x2;
2594             pub const FILE_MAP_COPY : DWORD = 0x1;
2595             pub const FILE_MAP_EXECUTE : DWORD = 0x20;
2596
2597             pub const PROCESSOR_ARCHITECTURE_INTEL : WORD = 0;
2598             pub const PROCESSOR_ARCHITECTURE_ARM : WORD = 5;
2599             pub const PROCESSOR_ARCHITECTURE_IA64 : WORD = 6;
2600             pub const PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9;
2601             pub const PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff;
2602
2603             pub const MOVEFILE_COPY_ALLOWED: DWORD = 2;
2604             pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16;
2605             pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4;
2606             pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32;
2607             pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
2608             pub const MOVEFILE_WRITE_THROUGH: DWORD = 8;
2609
2610             pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1;
2611
2612             pub const FILE_SHARE_DELETE: DWORD = 0x4;
2613             pub const FILE_SHARE_READ: DWORD = 0x1;
2614             pub const FILE_SHARE_WRITE: DWORD = 0x2;
2615
2616             pub const CREATE_ALWAYS: DWORD = 2;
2617             pub const CREATE_NEW: DWORD = 1;
2618             pub const OPEN_ALWAYS: DWORD = 4;
2619             pub const OPEN_EXISTING: DWORD = 3;
2620             pub const TRUNCATE_EXISTING: DWORD = 5;
2621
2622             pub const FILE_APPEND_DATA: DWORD = 0x00000004;
2623             pub const FILE_READ_DATA: DWORD = 0x00000001;
2624             pub const FILE_WRITE_DATA: DWORD = 0x00000002;
2625
2626             pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20;
2627             pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800;
2628             pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40;
2629             pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
2630             pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000;
2631             pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2;
2632             pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000;
2633             pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80;
2634             pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000;
2635             pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000;
2636             pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000;
2637             pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
2638             pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
2639             pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200;
2640             pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4;
2641             pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100;
2642             pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000;
2643
2644             pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
2645             pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000;
2646             pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000;
2647             pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000;
2648             pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
2649             pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
2650             pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x0100000;
2651             pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000;
2652             pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000;
2653             pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000;
2654             pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000;
2655             pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
2656
2657             pub const FILE_NAME_NORMALIZED: DWORD = 0x0;
2658             pub const FILE_NAME_OPENED: DWORD = 0x8;
2659
2660             pub const VOLUME_NAME_DOS: DWORD = 0x0;
2661             pub const VOLUME_NAME_GUID: DWORD = 0x1;
2662             pub const VOLUME_NAME_NONE: DWORD = 0x4;
2663             pub const VOLUME_NAME_NT: DWORD = 0x2;
2664
2665             pub const GENERIC_READ: DWORD = 0x80000000;
2666             pub const GENERIC_WRITE: DWORD = 0x40000000;
2667             pub const GENERIC_EXECUTE: DWORD = 0x20000000;
2668             pub const GENERIC_ALL: DWORD = 0x10000000;
2669             pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
2670             pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080;
2671
2672             pub const STANDARD_RIGHTS_READ: DWORD = 0x20000;
2673             pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000;
2674             pub const FILE_WRITE_EA: DWORD = 0x00000010;
2675             pub const FILE_READ_EA: DWORD = 0x00000008;
2676             pub const FILE_GENERIC_READ: DWORD =
2677                 STANDARD_RIGHTS_READ | FILE_READ_DATA |
2678                 FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE;
2679             pub const FILE_GENERIC_WRITE: DWORD =
2680                 STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
2681                 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA |
2682                 SYNCHRONIZE;
2683
2684             pub const FILE_BEGIN: DWORD = 0;
2685             pub const FILE_CURRENT: DWORD = 1;
2686             pub const FILE_END: DWORD = 2;
2687
2688             pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
2689             pub const WSAPROTOCOL_LEN: DWORD = 255;
2690             pub const INVALID_SOCKET: SOCKET = !0;
2691
2692             pub const DETACHED_PROCESS: DWORD = 0x00000008;
2693             pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
2694             pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
2695
2696             pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003;
2697             pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
2698             pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
2699             pub const PIPE_TYPE_BYTE: DWORD = 0x00000000;
2700             pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004;
2701             pub const PIPE_READMODE_BYTE: DWORD = 0x00000000;
2702             pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002;
2703             pub const PIPE_WAIT: DWORD = 0x00000000;
2704             pub const PIPE_NOWAIT: DWORD = 0x00000001;
2705             pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000;
2706             pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008;
2707             pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255;
2708
2709             pub const IPPROTO_RAW: c_int = 255;
2710
2711             pub const FIONBIO: c_long = -0x7FFB9982;
2712         }
2713         pub mod sysconf {
2714         }
2715     }
2716
2717
2718     #[cfg(any(target_os = "linux", target_os = "android"))]
2719     pub mod os {
2720         pub mod c95 {
2721             use types::os::arch::c95::{c_int, c_uint};
2722
2723             pub const EXIT_FAILURE : c_int = 1;
2724             pub const EXIT_SUCCESS : c_int = 0;
2725             pub const RAND_MAX : c_int = 2147483647;
2726             pub const EOF : c_int = -1;
2727             pub const SEEK_SET : c_int = 0;
2728             pub const SEEK_CUR : c_int = 1;
2729             pub const SEEK_END : c_int = 2;
2730             pub const _IOFBF : c_int = 0;
2731             pub const _IONBF : c_int = 2;
2732             pub const _IOLBF : c_int = 1;
2733             pub const BUFSIZ : c_uint = 8192_u32;
2734             pub const FOPEN_MAX : c_uint = 16_u32;
2735             pub const FILENAME_MAX : c_uint = 4096_u32;
2736             pub const L_tmpnam : c_uint = 20_u32;
2737             pub const TMP_MAX : c_uint = 238328_u32;
2738         }
2739         pub mod c99 {
2740         }
2741         #[cfg(any(target_arch = "x86",
2742                   target_arch = "x86_64",
2743                   target_arch = "arm",
2744                   target_arch = "aarch64",
2745                   target_arch = "powerpc"))]
2746         pub mod posix88 {
2747             use types::os::arch::c95::c_int;
2748             use types::common::c95::c_void;
2749             use types::os::arch::posix88::mode_t;
2750
2751             pub const O_RDONLY : c_int = 0;
2752             pub const O_WRONLY : c_int = 1;
2753             pub const O_RDWR : c_int = 2;
2754             pub const O_APPEND : c_int = 1024;
2755             pub const O_CREAT : c_int = 64;
2756             pub const O_EXCL : c_int = 128;
2757             pub const O_TRUNC : c_int = 512;
2758             pub const S_IFIFO : mode_t = 4096;
2759             pub const S_IFCHR : mode_t = 8192;
2760             pub const S_IFBLK : mode_t = 24576;
2761             pub const S_IFDIR : mode_t = 16384;
2762             pub const S_IFREG : mode_t = 32768;
2763             pub const S_IFLNK : mode_t = 40960;
2764             pub const S_IFMT : mode_t = 61440;
2765             pub const S_IEXEC : mode_t = 64;
2766             pub const S_IWRITE : mode_t = 128;
2767             pub const S_IREAD : mode_t = 256;
2768             pub const S_IRWXU : mode_t = 448;
2769             pub const S_IXUSR : mode_t = 64;
2770             pub const S_IWUSR : mode_t = 128;
2771             pub const S_IRUSR : mode_t = 256;
2772             pub const F_OK : c_int = 0;
2773             pub const R_OK : c_int = 4;
2774             pub const W_OK : c_int = 2;
2775             pub const X_OK : c_int = 1;
2776             pub const STDIN_FILENO : c_int = 0;
2777             pub const STDOUT_FILENO : c_int = 1;
2778             pub const STDERR_FILENO : c_int = 2;
2779             pub const F_LOCK : c_int = 1;
2780             pub const F_TEST : c_int = 3;
2781             pub const F_TLOCK : c_int = 2;
2782             pub const F_ULOCK : c_int = 0;
2783             pub const SIGHUP : c_int = 1;
2784             pub const SIGINT : c_int = 2;
2785             pub const SIGQUIT : c_int = 3;
2786             pub const SIGILL : c_int = 4;
2787             pub const SIGABRT : c_int = 6;
2788             pub const SIGFPE : c_int = 8;
2789             pub const SIGKILL : c_int = 9;
2790             pub const SIGSEGV : c_int = 11;
2791             pub const SIGPIPE : c_int = 13;
2792             pub const SIGALRM : c_int = 14;
2793             pub const SIGTERM : c_int = 15;
2794
2795             pub const PROT_NONE : c_int = 0;
2796             pub const PROT_READ : c_int = 1;
2797             pub const PROT_WRITE : c_int = 2;
2798             pub const PROT_EXEC : c_int = 4;
2799
2800             pub const MAP_FILE : c_int = 0x0000;
2801             pub const MAP_SHARED : c_int = 0x0001;
2802             pub const MAP_PRIVATE : c_int = 0x0002;
2803             pub const MAP_FIXED : c_int = 0x0010;
2804             pub const MAP_ANON : c_int = 0x0020;
2805
2806             pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
2807
2808             pub const MCL_CURRENT : c_int = 0x0001;
2809             pub const MCL_FUTURE : c_int = 0x0002;
2810
2811             pub const MS_ASYNC : c_int = 0x0001;
2812             pub const MS_INVALIDATE : c_int = 0x0002;
2813             pub const MS_SYNC : c_int = 0x0004;
2814
2815             pub const EPERM : c_int = 1;
2816             pub const ENOENT : c_int = 2;
2817             pub const ESRCH : c_int = 3;
2818             pub const EINTR : c_int = 4;
2819             pub const EIO : c_int = 5;
2820             pub const ENXIO : c_int = 6;
2821             pub const E2BIG : c_int = 7;
2822             pub const ENOEXEC : c_int = 8;
2823             pub const EBADF : c_int = 9;
2824             pub const ECHILD : c_int = 10;
2825             pub const EAGAIN : c_int = 11;
2826             pub const ENOMEM : c_int = 12;
2827             pub const EACCES : c_int = 13;
2828             pub const EFAULT : c_int = 14;
2829             pub const ENOTBLK : c_int = 15;
2830             pub const EBUSY : c_int = 16;
2831             pub const EEXIST : c_int = 17;
2832             pub const EXDEV : c_int = 18;
2833             pub const ENODEV : c_int = 19;
2834             pub const ENOTDIR : c_int = 20;
2835             pub const EISDIR : c_int = 21;
2836             pub const EINVAL : c_int = 22;
2837             pub const ENFILE : c_int = 23;
2838             pub const EMFILE : c_int = 24;
2839             pub const ENOTTY : c_int = 25;
2840             pub const ETXTBSY : c_int = 26;
2841             pub const EFBIG : c_int = 27;
2842             pub const ENOSPC : c_int = 28;
2843             pub const ESPIPE : c_int = 29;
2844             pub const EROFS : c_int = 30;
2845             pub const EMLINK : c_int = 31;
2846             pub const EPIPE : c_int = 32;
2847             pub const EDOM : c_int = 33;
2848             pub const ERANGE : c_int = 34;
2849
2850             pub const EDEADLK: c_int = 35;
2851             pub const ENAMETOOLONG: c_int = 36;
2852             pub const ENOLCK: c_int = 37;
2853             pub const ENOSYS: c_int = 38;
2854             pub const ENOTEMPTY: c_int = 39;
2855             pub const ELOOP: c_int = 40;
2856             pub const EWOULDBLOCK: c_int = EAGAIN;
2857             pub const ENOMSG: c_int = 42;
2858             pub const EIDRM: c_int = 43;
2859             pub const ECHRNG: c_int = 44;
2860             pub const EL2NSYNC: c_int = 45;
2861             pub const EL3HLT: c_int = 46;
2862             pub const EL3RST: c_int = 47;
2863             pub const ELNRNG: c_int = 48;
2864             pub const EUNATCH: c_int = 49;
2865             pub const ENOCSI: c_int = 50;
2866             pub const EL2HLT: c_int = 51;
2867             pub const EBADE: c_int = 52;
2868             pub const EBADR: c_int = 53;
2869             pub const EXFULL: c_int = 54;
2870             pub const ENOANO: c_int = 55;
2871             pub const EBADRQC: c_int = 56;
2872             pub const EBADSLT: c_int = 57;
2873
2874             pub const EDEADLOCK: c_int = EDEADLK;
2875
2876             pub const EBFONT: c_int = 59;
2877             pub const ENOSTR: c_int = 60;
2878             pub const ENODATA: c_int = 61;
2879             pub const ETIME: c_int = 62;
2880             pub const ENOSR: c_int = 63;
2881             pub const ENONET: c_int = 64;
2882             pub const ENOPKG: c_int = 65;
2883             pub const EREMOTE: c_int = 66;
2884             pub const ENOLINK: c_int = 67;
2885             pub const EADV: c_int = 68;
2886             pub const ESRMNT: c_int = 69;
2887             pub const ECOMM: c_int = 70;
2888             pub const EPROTO: c_int = 71;
2889             pub const EMULTIHOP: c_int = 72;
2890             pub const EDOTDOT: c_int = 73;
2891             pub const EBADMSG: c_int = 74;
2892             pub const EOVERFLOW: c_int = 75;
2893             pub const ENOTUNIQ: c_int = 76;
2894             pub const EBADFD: c_int = 77;
2895             pub const EREMCHG: c_int = 78;
2896             pub const ELIBACC: c_int = 79;
2897             pub const ELIBBAD: c_int = 80;
2898             pub const ELIBSCN: c_int = 81;
2899             pub const ELIBMAX: c_int = 82;
2900             pub const ELIBEXEC: c_int = 83;
2901             pub const EILSEQ: c_int = 84;
2902             pub const ERESTART: c_int = 85;
2903             pub const ESTRPIPE: c_int = 86;
2904             pub const EUSERS: c_int = 87;
2905             pub const ENOTSOCK: c_int = 88;
2906             pub const EDESTADDRREQ: c_int = 89;
2907             pub const EMSGSIZE: c_int = 90;
2908             pub const EPROTOTYPE: c_int = 91;
2909             pub const ENOPROTOOPT: c_int = 92;
2910             pub const EPROTONOSUPPORT: c_int = 93;
2911             pub const ESOCKTNOSUPPORT: c_int = 94;
2912             pub const EOPNOTSUPP: c_int = 95;
2913             pub const EPFNOSUPPORT: c_int = 96;
2914             pub const EAFNOSUPPORT: c_int = 97;
2915             pub const EADDRINUSE: c_int = 98;
2916             pub const EADDRNOTAVAIL: c_int = 99;
2917             pub const ENETDOWN: c_int = 100;
2918             pub const ENETUNREACH: c_int = 101;
2919             pub const ENETRESET: c_int = 102;
2920             pub const ECONNABORTED: c_int = 103;
2921             pub const ECONNRESET: c_int = 104;
2922             pub const ENOBUFS: c_int = 105;
2923             pub const EISCONN: c_int = 106;
2924             pub const ENOTCONN: c_int = 107;
2925             pub const ESHUTDOWN: c_int = 108;
2926             pub const ETOOMANYREFS: c_int = 109;
2927             pub const ETIMEDOUT: c_int = 110;
2928             pub const ECONNREFUSED: c_int = 111;
2929             pub const EHOSTDOWN: c_int = 112;
2930             pub const EHOSTUNREACH: c_int = 113;
2931             pub const EALREADY: c_int = 114;
2932             pub const EINPROGRESS: c_int = 115;
2933             pub const ESTALE: c_int = 116;
2934             pub const EUCLEAN: c_int = 117;
2935             pub const ENOTNAM: c_int = 118;
2936             pub const ENAVAIL: c_int = 119;
2937             pub const EISNAM: c_int = 120;
2938             pub const EREMOTEIO: c_int = 121;
2939             pub const EDQUOT: c_int = 122;
2940
2941             pub const ENOMEDIUM: c_int = 123;
2942             pub const EMEDIUMTYPE: c_int = 124;
2943             pub const ECANCELED: c_int = 125;
2944             pub const ENOKEY: c_int = 126;
2945             pub const EKEYEXPIRED: c_int = 127;
2946             pub const EKEYREVOKED: c_int = 128;
2947             pub const EKEYREJECTED: c_int = 129;
2948
2949             pub const EOWNERDEAD: c_int = 130;
2950             pub const ENOTRECOVERABLE: c_int = 131;
2951
2952             pub const ERFKILL: c_int = 132;
2953
2954             pub const EHWPOISON: c_int = 133;
2955         }
2956
2957         #[cfg(any(target_arch = "mips",
2958                   target_arch = "mipsel"))]
2959         pub mod posix88 {
2960             use types::os::arch::c95::c_int;
2961             use types::common::c95::c_void;
2962             use types::os::arch::posix88::mode_t;
2963
2964             pub const O_RDONLY : c_int = 0;
2965             pub const O_WRONLY : c_int = 1;
2966             pub const O_RDWR : c_int = 2;
2967             pub const O_APPEND : c_int = 8;
2968             pub const O_CREAT : c_int = 256;
2969             pub const O_EXCL : c_int = 1024;
2970             pub const O_TRUNC : c_int = 512;
2971             pub const S_IFIFO : mode_t = 4096;
2972             pub const S_IFCHR : mode_t = 8192;
2973             pub const S_IFBLK : mode_t = 24576;
2974             pub const S_IFDIR : mode_t = 16384;
2975             pub const S_IFREG : mode_t = 32768;
2976             pub const S_IFLNK : mode_t = 40960;
2977             pub const S_IFMT : mode_t = 61440;
2978             pub const S_IEXEC : mode_t = 64;
2979             pub const S_IWRITE : mode_t = 128;
2980             pub const S_IREAD : mode_t = 256;
2981             pub const S_IRWXU : mode_t = 448;
2982             pub const S_IXUSR : mode_t = 64;
2983             pub const S_IWUSR : mode_t = 128;
2984             pub const S_IRUSR : mode_t = 256;
2985             pub const F_OK : c_int = 0;
2986             pub const R_OK : c_int = 4;
2987             pub const W_OK : c_int = 2;
2988             pub const X_OK : c_int = 1;
2989             pub const STDIN_FILENO : c_int = 0;
2990             pub const STDOUT_FILENO : c_int = 1;
2991             pub const STDERR_FILENO : c_int = 2;
2992             pub const F_LOCK : c_int = 1;
2993             pub const F_TEST : c_int = 3;
2994             pub const F_TLOCK : c_int = 2;
2995             pub const F_ULOCK : c_int = 0;
2996             pub const SIGHUP : c_int = 1;
2997             pub const SIGINT : c_int = 2;
2998             pub const SIGQUIT : c_int = 3;
2999             pub const SIGILL : c_int = 4;
3000             pub const SIGABRT : c_int = 6;
3001             pub const SIGFPE : c_int = 8;
3002             pub const SIGKILL : c_int = 9;
3003             pub const SIGSEGV : c_int = 11;
3004             pub const SIGPIPE : c_int = 13;
3005             pub const SIGALRM : c_int = 14;
3006             pub const SIGTERM : c_int = 15;
3007
3008             pub const PROT_NONE : c_int = 0;
3009             pub const PROT_READ : c_int = 1;
3010             pub const PROT_WRITE : c_int = 2;
3011             pub const PROT_EXEC : c_int = 4;
3012
3013             pub const MAP_FILE : c_int = 0x0000;
3014             pub const MAP_SHARED : c_int = 0x0001;
3015             pub const MAP_PRIVATE : c_int = 0x0002;
3016             pub const MAP_FIXED : c_int = 0x0010;
3017             pub const MAP_ANON : c_int = 0x0800;
3018
3019             pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
3020
3021             pub const MCL_CURRENT : c_int = 0x0001;
3022             pub const MCL_FUTURE : c_int = 0x0002;
3023
3024             pub const MS_ASYNC : c_int = 0x0001;
3025             pub const MS_INVALIDATE : c_int = 0x0002;
3026             pub const MS_SYNC : c_int = 0x0004;
3027
3028             pub const EPERM : c_int = 1;
3029             pub const ENOENT : c_int = 2;
3030             pub const ESRCH : c_int = 3;
3031             pub const EINTR : c_int = 4;
3032             pub const EIO : c_int = 5;
3033             pub const ENXIO : c_int = 6;
3034             pub const E2BIG : c_int = 7;
3035             pub const ENOEXEC : c_int = 8;
3036             pub const EBADF : c_int = 9;
3037             pub const ECHILD : c_int = 10;
3038             pub const EAGAIN : c_int = 11;
3039             pub const ENOMEM : c_int = 12;
3040             pub const EACCES : c_int = 13;
3041             pub const EFAULT : c_int = 14;
3042             pub const ENOTBLK : c_int = 15;
3043             pub const EBUSY : c_int = 16;
3044             pub const EEXIST : c_int = 17;
3045             pub const EXDEV : c_int = 18;
3046             pub const ENODEV : c_int = 19;
3047             pub const ENOTDIR : c_int = 20;
3048             pub const EISDIR : c_int = 21;
3049             pub const EINVAL : c_int = 22;
3050             pub const ENFILE : c_int = 23;
3051             pub const EMFILE : c_int = 24;
3052             pub const ENOTTY : c_int = 25;
3053             pub const ETXTBSY : c_int = 26;
3054             pub const EFBIG : c_int = 27;
3055             pub const ENOSPC : c_int = 28;
3056             pub const ESPIPE : c_int = 29;
3057             pub const EROFS : c_int = 30;
3058             pub const EMLINK : c_int = 31;
3059             pub const EPIPE : c_int = 32;
3060             pub const EDOM : c_int = 33;
3061             pub const ERANGE : c_int = 34;
3062
3063             pub const ENOMSG: c_int = 35;
3064             pub const EIDRM: c_int = 36;
3065             pub const ECHRNG: c_int = 37;
3066             pub const EL2NSYNC: c_int = 38;
3067             pub const EL3HLT: c_int = 39;
3068             pub const EL3RST: c_int = 40;
3069             pub const ELNRNG: c_int = 41;
3070             pub const EUNATCH: c_int = 42;
3071             pub const ENOCSI: c_int = 43;
3072             pub const EL2HLT: c_int = 44;
3073             pub const EDEADLK: c_int = 45;
3074             pub const ENOLCK: c_int = 46;
3075             pub const EBADE: c_int = 50;
3076             pub const EBADR: c_int = 51;
3077             pub const EXFULL: c_int = 52;
3078             pub const ENOANO: c_int = 53;
3079             pub const EBADRQC: c_int = 54;
3080             pub const EBADSLT: c_int = 55;
3081             pub const EDEADLOCK: c_int = 56;
3082             pub const EBFONT: c_int = 59;
3083             pub const ENOSTR: c_int = 60;
3084             pub const ENODATA: c_int = 61;
3085             pub const ETIME: c_int = 62;
3086             pub const ENOSR: c_int = 63;
3087             pub const ENONET: c_int = 64;
3088             pub const ENOPKG: c_int = 65;
3089             pub const EREMOTE: c_int = 66;
3090             pub const ENOLINK: c_int = 67;
3091             pub const EADV: c_int = 68;
3092             pub const ESRMNT: c_int = 69;
3093             pub const ECOMM: c_int = 70;
3094             pub const EPROTO: c_int = 71;
3095             pub const EDOTDOT: c_int = 73;
3096             pub const EMULTIHOP: c_int = 74;
3097             pub const EBADMSG: c_int = 77;
3098             pub const ENAMETOOLONG: c_int = 78;
3099             pub const EOVERFLOW: c_int = 79;
3100             pub const ENOTUNIQ: c_int = 80;
3101             pub const EBADFD: c_int = 81;
3102             pub const EREMCHG: c_int = 82;
3103             pub const ELIBACC: c_int = 83;
3104             pub const ELIBBAD: c_int = 84;
3105             pub const ELIBSCN: c_int = 95;
3106             pub const ELIBMAX: c_int = 86;
3107             pub const ELIBEXEC: c_int = 87;
3108             pub const EILSEQ: c_int = 88;
3109             pub const ENOSYS: c_int = 89;
3110             pub const ELOOP: c_int = 90;
3111             pub const ERESTART: c_int = 91;
3112             pub const ESTRPIPE: c_int = 92;
3113             pub const ENOTEMPTY: c_int = 93;
3114             pub const EUSERS: c_int = 94;
3115             pub const ENOTSOCK: c_int = 95;
3116             pub const EDESTADDRREQ: c_int = 96;
3117             pub const EMSGSIZE: c_int = 97;
3118             pub const EPROTOTYPE: c_int = 98;
3119             pub const ENOPROTOOPT: c_int = 99;
3120             pub const EPROTONOSUPPORT: c_int = 120;
3121             pub const ESOCKTNOSUPPORT: c_int = 121;
3122             pub const EOPNOTSUPP: c_int = 122;
3123             pub const EPFNOSUPPORT: c_int = 123;
3124             pub const EAFNOSUPPORT: c_int = 124;
3125             pub const EADDRINUSE: c_int = 125;
3126             pub const EADDRNOTAVAIL: c_int = 126;
3127             pub const ENETDOWN: c_int = 127;
3128             pub const ENETUNREACH: c_int = 128;
3129             pub const ENETRESET: c_int = 129;
3130             pub const ECONNABORTED: c_int = 130;
3131             pub const ECONNRESET: c_int = 131;
3132             pub const ENOBUFS: c_int = 132;
3133             pub const EISCONN: c_int = 133;
3134             pub const ENOTCONN: c_int = 134;
3135             pub const EUCLEAN: c_int = 135;
3136             pub const ENOTNAM: c_int = 137;
3137             pub const ENAVAIL: c_int = 138;
3138             pub const EISNAM: c_int = 139;
3139             pub const EREMOTEIO: c_int = 140;
3140             pub const ESHUTDOWN: c_int = 143;
3141             pub const ETOOMANYREFS: c_int = 144;
3142             pub const ETIMEDOUT: c_int = 145;
3143             pub const ECONNREFUSED: c_int = 146;
3144             pub const EHOSTDOWN: c_int = 147;
3145             pub const EHOSTUNREACH: c_int = 148;
3146             pub const EWOULDBLOCK: c_int = EAGAIN;
3147             pub const EALREADY: c_int = 149;
3148             pub const EINPROGRESS: c_int = 150;
3149             pub const ESTALE: c_int = 151;
3150             pub const ECANCELED: c_int = 158;
3151
3152             pub const ENOMEDIUM: c_int = 159;
3153             pub const EMEDIUMTYPE: c_int = 160;
3154             pub const ENOKEY: c_int = 161;
3155             pub const EKEYEXPIRED: c_int = 162;
3156             pub const EKEYREVOKED: c_int = 163;
3157             pub const EKEYREJECTED: c_int = 164;
3158
3159             pub const EOWNERDEAD: c_int = 165;
3160             pub const ENOTRECOVERABLE: c_int = 166;
3161
3162             pub const ERFKILL: c_int = 167;
3163
3164             pub const EHWPOISON: c_int = 168;
3165
3166             pub const EDQUOT: c_int = 1133;
3167         }
3168         pub mod posix01 {
3169             use types::os::arch::c95::{c_int, size_t};
3170
3171             pub const F_DUPFD : c_int = 0;
3172             pub const F_GETFD : c_int = 1;
3173             pub const F_SETFD : c_int = 2;
3174             pub const F_GETFL : c_int = 3;
3175             pub const F_SETFL : c_int = 4;
3176
3177             pub const SIGTRAP : c_int = 5;
3178             pub const SIGPIPE: c_int = 13;
3179             pub const SIG_IGN: size_t = 1;
3180
3181             pub const GLOB_ERR      : c_int = 1 << 0;
3182             pub const GLOB_MARK     : c_int = 1 << 1;
3183             pub const GLOB_NOSORT   : c_int = 1 << 2;
3184             pub const GLOB_DOOFFS   : c_int = 1 << 3;
3185             pub const GLOB_NOCHECK  : c_int = 1 << 4;
3186             pub const GLOB_APPEND   : c_int = 1 << 5;
3187             pub const GLOB_NOESCAPE : c_int = 1 << 6;
3188
3189             pub const GLOB_NOSPACE  : c_int = 1;
3190             pub const GLOB_ABORTED  : c_int = 2;
3191             pub const GLOB_NOMATCH  : c_int = 3;
3192
3193             pub const POSIX_MADV_NORMAL : c_int = 0;
3194             pub const POSIX_MADV_RANDOM : c_int = 1;
3195             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
3196             pub const POSIX_MADV_WILLNEED : c_int = 3;
3197             pub const POSIX_MADV_DONTNEED : c_int = 4;
3198
3199             pub const _SC_MQ_PRIO_MAX : c_int = 28;
3200             pub const _SC_IOV_MAX : c_int = 60;
3201             pub const _SC_GETGR_R_SIZE_MAX : c_int = 69;
3202             pub const _SC_GETPW_R_SIZE_MAX : c_int = 70;
3203             pub const _SC_LOGIN_NAME_MAX : c_int = 71;
3204             pub const _SC_TTY_NAME_MAX : c_int = 72;
3205             pub const _SC_THREADS : c_int = 67;
3206             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68;
3207             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73;
3208             pub const _SC_THREAD_KEYS_MAX : c_int = 74;
3209             pub const _SC_THREAD_STACK_MIN : c_int = 75;
3210             pub const _SC_THREAD_THREADS_MAX : c_int = 76;
3211             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77;
3212             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
3213             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79;
3214             pub const _SC_THREAD_PRIO_INHERIT : c_int = 80;
3215             pub const _SC_THREAD_PRIO_PROTECT : c_int = 81;
3216             pub const _SC_THREAD_PROCESS_SHARED : c_int = 82;
3217             pub const _SC_ATEXIT_MAX : c_int = 87;
3218             pub const _SC_XOPEN_VERSION : c_int = 89;
3219             pub const _SC_XOPEN_XCU_VERSION : c_int = 90;
3220             pub const _SC_XOPEN_UNIX : c_int = 91;
3221             pub const _SC_XOPEN_CRYPT : c_int = 92;
3222             pub const _SC_XOPEN_ENH_I18N : c_int = 93;
3223             pub const _SC_XOPEN_SHM : c_int = 94;
3224             pub const _SC_XOPEN_LEGACY : c_int = 129;
3225             pub const _SC_XOPEN_REALTIME : c_int = 130;
3226             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131;
3227
3228             pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
3229             pub const PTHREAD_CREATE_DETACHED: c_int = 1;
3230
3231             #[cfg(target_os = "android")]
3232             pub const PTHREAD_STACK_MIN: size_t = 8192;
3233
3234             #[cfg(all(target_os = "linux",
3235                       any(target_arch = "arm",
3236                           target_arch = "x86",
3237                           target_arch = "x86_64")))]
3238             pub const PTHREAD_STACK_MIN: size_t = 16384;
3239
3240             #[cfg(all(target_os = "linux",
3241                       any(target_arch = "mips",
3242                           target_arch = "mipsel",
3243                           target_arch = "aarch64",
3244                           target_arch = "powerpc")))]
3245             pub const PTHREAD_STACK_MIN: size_t = 131072;
3246
3247             pub const CLOCK_REALTIME: c_int = 0;
3248             pub const CLOCK_MONOTONIC: c_int = 1;
3249         }
3250         pub mod posix08 {
3251         }
3252         #[cfg(any(target_arch = "arm",
3253                   target_arch = "aarch64",
3254                   target_arch = "x86",
3255                   target_arch = "x86_64",
3256                   target_arch = "powerpc"))]
3257         pub mod bsd44 {
3258             use types::os::arch::c95::c_int;
3259
3260             pub const MADV_NORMAL : c_int = 0;
3261             pub const MADV_RANDOM : c_int = 1;
3262             pub const MADV_SEQUENTIAL : c_int = 2;
3263             pub const MADV_WILLNEED : c_int = 3;
3264             pub const MADV_DONTNEED : c_int = 4;
3265             pub const MADV_REMOVE : c_int = 9;
3266             pub const MADV_DONTFORK : c_int = 10;
3267             pub const MADV_DOFORK : c_int = 11;
3268             pub const MADV_MERGEABLE : c_int = 12;
3269             pub const MADV_UNMERGEABLE : c_int = 13;
3270             pub const MADV_HWPOISON : c_int = 100;
3271
3272             pub const IFF_LOOPBACK: c_int = 0x8;
3273
3274             pub const AF_UNIX: c_int = 1;
3275             pub const AF_INET: c_int = 2;
3276             pub const AF_INET6: c_int = 10;
3277             pub const SOCK_STREAM: c_int = 1;
3278             pub const SOCK_DGRAM: c_int = 2;
3279             pub const SOCK_RAW: c_int = 3;
3280             pub const IPPROTO_TCP: c_int = 6;
3281             pub const IPPROTO_IP: c_int = 0;
3282             pub const IPPROTO_IPV6: c_int = 41;
3283             pub const IP_MULTICAST_TTL: c_int = 33;
3284             pub const IP_MULTICAST_LOOP: c_int = 34;
3285             pub const IP_TTL: c_int = 2;
3286             pub const IP_HDRINCL: c_int = 3;
3287             pub const IP_ADD_MEMBERSHIP: c_int = 35;
3288             pub const IP_DROP_MEMBERSHIP: c_int = 36;
3289             pub const IPV6_ADD_MEMBERSHIP: c_int = 20;
3290             pub const IPV6_DROP_MEMBERSHIP: c_int = 21;
3291
3292             pub const TCP_NODELAY: c_int = 1;
3293             pub const SOL_SOCKET: c_int = 1;
3294             pub const SO_KEEPALIVE: c_int = 9;
3295             pub const SO_BROADCAST: c_int = 6;
3296             pub const SO_REUSEADDR: c_int = 2;
3297             pub const SO_ERROR: c_int = 4;
3298
3299             pub const SHUT_RD: c_int = 0;
3300             pub const SHUT_WR: c_int = 1;
3301             pub const SHUT_RDWR: c_int = 2;
3302         }
3303         #[cfg(any(target_arch = "mips",
3304                   target_arch = "mipsel"))]
3305         pub mod bsd44 {
3306             use types::os::arch::c95::c_int;
3307
3308             pub const MADV_NORMAL : c_int = 0;
3309             pub const MADV_RANDOM : c_int = 1;
3310             pub const MADV_SEQUENTIAL : c_int = 2;
3311             pub const MADV_WILLNEED : c_int = 3;
3312             pub const MADV_DONTNEED : c_int = 4;
3313             pub const MADV_REMOVE : c_int = 9;
3314             pub const MADV_DONTFORK : c_int = 10;
3315             pub const MADV_DOFORK : c_int = 11;
3316             pub const MADV_MERGEABLE : c_int = 12;
3317             pub const MADV_UNMERGEABLE : c_int = 13;
3318             pub const MADV_HWPOISON : c_int = 100;
3319
3320             pub const AF_UNIX: c_int = 1;
3321             pub const AF_INET: c_int = 2;
3322             pub const AF_INET6: c_int = 10;
3323             pub const SOCK_STREAM: c_int = 2;
3324             pub const SOCK_DGRAM: c_int = 1;
3325             pub const SOCK_RAW: c_int = 3;
3326             pub const IPPROTO_TCP: c_int = 6;
3327             pub const IPPROTO_IP: c_int = 0;
3328             pub const IPPROTO_IPV6: c_int = 41;
3329             pub const IP_MULTICAST_TTL: c_int = 33;
3330             pub const IP_MULTICAST_LOOP: c_int = 34;
3331             pub const IP_TTL: c_int = 2;
3332             pub const IP_HDRINCL: c_int = 3;
3333             pub const IP_ADD_MEMBERSHIP: c_int = 35;
3334             pub const IP_DROP_MEMBERSHIP: c_int = 36;
3335             pub const IPV6_ADD_MEMBERSHIP: c_int = 20;
3336             pub const IPV6_DROP_MEMBERSHIP: c_int = 21;
3337
3338             pub const TCP_NODELAY: c_int = 1;
3339             pub const SOL_SOCKET: c_int = 65535;
3340             pub const SO_KEEPALIVE: c_int = 8;
3341             pub const SO_BROADCAST: c_int = 32;
3342             pub const SO_REUSEADDR: c_int = 4;
3343             pub const SO_ERROR: c_int = 4103;
3344
3345             pub const SHUT_RD: c_int = 0;
3346             pub const SHUT_WR: c_int = 1;
3347             pub const SHUT_RDWR: c_int = 2;
3348         }
3349         #[cfg(any(target_arch = "x86",
3350                   target_arch = "x86_64",
3351                   target_arch = "arm",
3352                   target_arch = "aarch64",
3353                   target_arch = "powerpc"))]
3354         pub mod extra {
3355             use types::os::arch::c95::c_int;
3356
3357             pub const AF_PACKET : c_int = 17;
3358             pub const IPPROTO_RAW : c_int = 255;
3359
3360             pub const O_RSYNC : c_int = 1052672;
3361             pub const O_DSYNC : c_int = 4096;
3362             pub const O_NONBLOCK : c_int = 2048;
3363             pub const O_SYNC : c_int = 1052672;
3364
3365             pub const PROT_GROWSDOWN : c_int = 0x010000000;
3366             pub const PROT_GROWSUP : c_int = 0x020000000;
3367
3368             pub const MAP_TYPE : c_int = 0x000f;
3369             pub const MAP_ANONYMOUS : c_int = 0x0020;
3370             pub const MAP_32BIT : c_int = 0x0040;
3371             pub const MAP_GROWSDOWN : c_int = 0x0100;
3372             pub const MAP_DENYWRITE : c_int = 0x0800;
3373             pub const MAP_EXECUTABLE : c_int = 0x01000;
3374             pub const MAP_LOCKED : c_int = 0x02000;
3375             pub const MAP_NONRESERVE : c_int = 0x04000;
3376             pub const MAP_POPULATE : c_int = 0x08000;
3377             pub const MAP_NONBLOCK : c_int = 0x010000;
3378             pub const MAP_STACK : c_int = 0x020000;
3379         }
3380         #[cfg(any(target_arch = "mips",
3381                   target_arch = "mipsel"))]
3382         pub mod extra {
3383             use types::os::arch::c95::c_int;
3384
3385             pub const AF_PACKET : c_int = 17;
3386             pub const IPPROTO_RAW : c_int = 255;
3387
3388             pub const O_RSYNC : c_int = 16400;
3389             pub const O_DSYNC : c_int = 16;
3390             pub const O_NONBLOCK : c_int = 128;
3391             pub const O_SYNC : c_int = 16400;
3392
3393             pub const PROT_GROWSDOWN : c_int = 0x01000000;
3394             pub const PROT_GROWSUP : c_int = 0x02000000;
3395
3396             pub const MAP_TYPE : c_int = 0x000f;
3397             pub const MAP_ANONYMOUS : c_int = 0x0800;
3398             pub const MAP_GROWSDOWN : c_int = 0x01000;
3399             pub const MAP_DENYWRITE : c_int = 0x02000;
3400             pub const MAP_EXECUTABLE : c_int = 0x04000;
3401             pub const MAP_LOCKED : c_int = 0x08000;
3402             pub const MAP_NONRESERVE : c_int = 0x0400;
3403             pub const MAP_POPULATE : c_int = 0x010000;
3404             pub const MAP_NONBLOCK : c_int = 0x020000;
3405             pub const MAP_STACK : c_int = 0x040000;
3406         }
3407         #[cfg(target_os = "linux")]
3408         pub mod sysconf {
3409             use types::os::arch::c95::c_int;
3410
3411             pub const _SC_ARG_MAX : c_int = 0;
3412             pub const _SC_CHILD_MAX : c_int = 1;
3413             pub const _SC_CLK_TCK : c_int = 2;
3414             pub const _SC_NGROUPS_MAX : c_int = 3;
3415             pub const _SC_OPEN_MAX : c_int = 4;
3416             pub const _SC_STREAM_MAX : c_int = 5;
3417             pub const _SC_TZNAME_MAX : c_int = 6;
3418             pub const _SC_JOB_CONTROL : c_int = 7;
3419             pub const _SC_SAVED_IDS : c_int = 8;
3420             pub const _SC_REALTIME_SIGNALS : c_int = 9;
3421             pub const _SC_PRIORITY_SCHEDULING : c_int = 10;
3422             pub const _SC_TIMERS : c_int = 11;
3423             pub const _SC_ASYNCHRONOUS_IO : c_int = 12;
3424             pub const _SC_PRIORITIZED_IO : c_int = 13;
3425             pub const _SC_SYNCHRONIZED_IO : c_int = 14;
3426             pub const _SC_FSYNC : c_int = 15;
3427             pub const _SC_MAPPED_FILES : c_int = 16;
3428             pub const _SC_MEMLOCK : c_int = 17;
3429             pub const _SC_MEMLOCK_RANGE : c_int = 18;
3430             pub const _SC_MEMORY_PROTECTION : c_int = 19;
3431             pub const _SC_MESSAGE_PASSING : c_int = 20;
3432             pub const _SC_SEMAPHORES : c_int = 21;
3433             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 22;
3434             pub const _SC_AIO_LISTIO_MAX : c_int = 23;
3435             pub const _SC_AIO_MAX : c_int = 24;
3436             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 25;
3437             pub const _SC_DELAYTIMER_MAX : c_int = 26;
3438             pub const _SC_MQ_OPEN_MAX : c_int = 27;
3439             pub const _SC_VERSION : c_int = 29;
3440             pub const _SC_PAGESIZE : c_int = 30;
3441             pub const _SC_RTSIG_MAX : c_int = 31;
3442             pub const _SC_SEM_NSEMS_MAX : c_int = 32;
3443             pub const _SC_SEM_VALUE_MAX : c_int = 33;
3444             pub const _SC_SIGQUEUE_MAX : c_int = 34;
3445             pub const _SC_TIMER_MAX : c_int = 35;
3446             pub const _SC_BC_BASE_MAX : c_int = 36;
3447             pub const _SC_BC_DIM_MAX : c_int = 37;
3448             pub const _SC_BC_SCALE_MAX : c_int = 38;
3449             pub const _SC_BC_STRING_MAX : c_int = 39;
3450             pub const _SC_COLL_WEIGHTS_MAX : c_int = 40;
3451             pub const _SC_EXPR_NEST_MAX : c_int = 42;
3452             pub const _SC_LINE_MAX : c_int = 43;
3453             pub const _SC_RE_DUP_MAX : c_int = 44;
3454             pub const _SC_2_VERSION : c_int = 46;
3455             pub const _SC_2_C_BIND : c_int = 47;
3456             pub const _SC_2_C_DEV : c_int = 48;
3457             pub const _SC_2_FORT_DEV : c_int = 49;
3458             pub const _SC_2_FORT_RUN : c_int = 50;
3459             pub const _SC_2_SW_DEV : c_int = 51;
3460             pub const _SC_2_LOCALEDEF : c_int = 52;
3461             pub const _SC_2_CHAR_TERM : c_int = 95;
3462             pub const _SC_2_C_VERSION : c_int = 96;
3463             pub const _SC_2_UPE : c_int = 97;
3464             pub const _SC_XBS5_ILP32_OFF32 : c_int = 125;
3465             pub const _SC_XBS5_ILP32_OFFBIG : c_int = 126;
3466             pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 128;
3467         }
3468         #[cfg(target_os = "android")]
3469         pub mod sysconf {
3470             use types::os::arch::c95::c_int;
3471
3472             pub const _SC_ARG_MAX : c_int = 0;
3473             pub const _SC_BC_BASE_MAX : c_int = 1;
3474             pub const _SC_BC_DIM_MAX : c_int = 2;
3475             pub const _SC_BC_SCALE_MAX : c_int = 3;
3476             pub const _SC_BC_STRING_MAX : c_int = 4;
3477             pub const _SC_CHILD_MAX : c_int = 5;
3478             pub const _SC_CLK_TCK : c_int = 6;
3479             pub const _SC_COLL_WEIGHTS_MAX : c_int = 7;
3480             pub const _SC_EXPR_NEST_MAX : c_int = 8;
3481             pub const _SC_LINE_MAX : c_int = 9;
3482             pub const _SC_NGROUPS_MAX : c_int = 10;
3483             pub const _SC_OPEN_MAX : c_int = 11;
3484             pub const _SC_2_C_BIND : c_int = 13;
3485             pub const _SC_2_C_DEV : c_int = 14;
3486             pub const _SC_2_C_VERSION : c_int = 15;
3487             pub const _SC_2_CHAR_TERM : c_int = 16;
3488             pub const _SC_2_FORT_DEV : c_int = 17;
3489             pub const _SC_2_FORT_RUN : c_int = 18;
3490             pub const _SC_2_LOCALEDEF : c_int = 19;
3491             pub const _SC_2_SW_DEV : c_int = 20;
3492             pub const _SC_2_UPE : c_int = 21;
3493             pub const _SC_2_VERSION : c_int = 22;
3494             pub const _SC_JOB_CONTROL : c_int = 23;
3495             pub const _SC_SAVED_IDS : c_int = 24;
3496             pub const _SC_VERSION : c_int = 25;
3497             pub const _SC_RE_DUP_MAX : c_int = 26;
3498             pub const _SC_STREAM_MAX : c_int = 27;
3499             pub const _SC_TZNAME_MAX : c_int = 28;
3500             pub const _SC_PAGESIZE : c_int = 39;
3501         }
3502     }
3503
3504     #[cfg(any(target_os = "freebsd",
3505               target_os = "dragonfly"))]
3506     pub mod os {
3507         pub mod c95 {
3508             use types::os::arch::c95::{c_int, c_uint};
3509
3510             pub const EXIT_FAILURE : c_int = 1;
3511             pub const EXIT_SUCCESS : c_int = 0;
3512             pub const RAND_MAX : c_int = 2147483647;
3513             pub const EOF : c_int = -1;
3514             pub const SEEK_SET : c_int = 0;
3515             pub const SEEK_CUR : c_int = 1;
3516             pub const SEEK_END : c_int = 2;
3517             pub const _IOFBF : c_int = 0;
3518             pub const _IONBF : c_int = 2;
3519             pub const _IOLBF : c_int = 1;
3520             pub const BUFSIZ : c_uint = 1024_u32;
3521             pub const FOPEN_MAX : c_uint = 20_u32;
3522             pub const FILENAME_MAX : c_uint = 1024_u32;
3523             pub const L_tmpnam : c_uint = 1024_u32;
3524             pub const TMP_MAX : c_uint = 308915776_u32;
3525         }
3526         pub mod c99 {
3527         }
3528         pub mod posix88 {
3529             use types::common::c95::c_void;
3530             use types::os::arch::c95::c_int;
3531             use types::os::arch::posix88::mode_t;
3532
3533             pub const O_RDONLY : c_int = 0;
3534             pub const O_WRONLY : c_int = 1;
3535             pub const O_RDWR : c_int = 2;
3536             pub const O_APPEND : c_int = 8;
3537             pub const O_CREAT : c_int = 512;
3538             pub const O_EXCL : c_int = 2048;
3539             pub const O_TRUNC : c_int = 1024;
3540             pub const S_IFIFO : mode_t = 4096;
3541             pub const S_IFCHR : mode_t = 8192;
3542             pub const S_IFBLK : mode_t = 24576;
3543             pub const S_IFDIR : mode_t = 16384;
3544             pub const S_IFREG : mode_t = 32768;
3545             pub const S_IFLNK : mode_t = 40960;
3546             pub const S_IFMT : mode_t = 61440;
3547             pub const S_IEXEC : mode_t = 64;
3548             pub const S_IWRITE : mode_t = 128;
3549             pub const S_IREAD : mode_t = 256;
3550             pub const S_IRWXU : mode_t = 448;
3551             pub const S_IXUSR : mode_t = 64;
3552             pub const S_IWUSR : mode_t = 128;
3553             pub const S_IRUSR : mode_t = 256;
3554             pub const F_OK : c_int = 0;
3555             pub const R_OK : c_int = 4;
3556             pub const W_OK : c_int = 2;
3557             pub const X_OK : c_int = 1;
3558             pub const STDIN_FILENO : c_int = 0;
3559             pub const STDOUT_FILENO : c_int = 1;
3560             pub const STDERR_FILENO : c_int = 2;
3561             pub const F_LOCK : c_int = 1;
3562             pub const F_TEST : c_int = 3;
3563             pub const F_TLOCK : c_int = 2;
3564             pub const F_ULOCK : c_int = 0;
3565             pub const SIGHUP : c_int = 1;
3566             pub const SIGINT : c_int = 2;
3567             pub const SIGQUIT : c_int = 3;
3568             pub const SIGILL : c_int = 4;
3569             pub const SIGABRT : c_int = 6;
3570             pub const SIGFPE : c_int = 8;
3571             pub const SIGKILL : c_int = 9;
3572             pub const SIGSEGV : c_int = 11;
3573             pub const SIGPIPE : c_int = 13;
3574             pub const SIGALRM : c_int = 14;
3575             pub const SIGTERM : c_int = 15;
3576
3577             pub const PROT_NONE : c_int = 0;
3578             pub const PROT_READ : c_int = 1;
3579             pub const PROT_WRITE : c_int = 2;
3580             pub const PROT_EXEC : c_int = 4;
3581
3582             pub const MAP_FILE : c_int = 0x0000;
3583             pub const MAP_SHARED : c_int = 0x0001;
3584             pub const MAP_PRIVATE : c_int = 0x0002;
3585             pub const MAP_FIXED : c_int = 0x0010;
3586             pub const MAP_ANON : c_int = 0x1000;
3587
3588             pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
3589
3590             pub const MCL_CURRENT : c_int = 0x0001;
3591             pub const MCL_FUTURE : c_int = 0x0002;
3592
3593             pub const MS_SYNC : c_int = 0x0000;
3594             pub const MS_ASYNC : c_int = 0x0001;
3595             pub const MS_INVALIDATE : c_int = 0x0002;
3596
3597             pub const EPERM : c_int = 1;
3598             pub const ENOENT : c_int = 2;
3599             pub const ESRCH : c_int = 3;
3600             pub const EINTR : c_int = 4;
3601             pub const EIO : c_int = 5;
3602             pub const ENXIO : c_int = 6;
3603             pub const E2BIG : c_int = 7;
3604             pub const ENOEXEC : c_int = 8;
3605             pub const EBADF : c_int = 9;
3606             pub const ECHILD : c_int = 10;
3607             pub const EDEADLK : c_int = 11;
3608             pub const ENOMEM : c_int = 12;
3609             pub const EACCES : c_int = 13;
3610             pub const EFAULT : c_int = 14;
3611             pub const ENOTBLK : c_int = 15;
3612             pub const EBUSY : c_int = 16;
3613             pub const EEXIST : c_int = 17;
3614             pub const EXDEV : c_int = 18;
3615             pub const ENODEV : c_int = 19;
3616             pub const ENOTDIR : c_int = 20;
3617             pub const EISDIR : c_int = 21;
3618             pub const EINVAL : c_int = 22;
3619             pub const ENFILE : c_int = 23;
3620             pub const EMFILE : c_int = 24;
3621             pub const ENOTTY : c_int = 25;
3622             pub const ETXTBSY : c_int = 26;
3623             pub const EFBIG : c_int = 27;
3624             pub const ENOSPC : c_int = 28;
3625             pub const ESPIPE : c_int = 29;
3626             pub const EROFS : c_int = 30;
3627             pub const EMLINK : c_int = 31;
3628             pub const EPIPE : c_int = 32;
3629             pub const EDOM : c_int = 33;
3630             pub const ERANGE : c_int = 34;
3631             pub const EAGAIN : c_int = 35;
3632             pub const EWOULDBLOCK : c_int = 35;
3633             pub const EINPROGRESS : c_int = 36;
3634             pub const EALREADY : c_int = 37;
3635             pub const ENOTSOCK : c_int = 38;
3636             pub const EDESTADDRREQ : c_int = 39;
3637             pub const EMSGSIZE : c_int = 40;
3638             pub const EPROTOTYPE : c_int = 41;
3639             pub const ENOPROTOOPT : c_int = 42;
3640             pub const EPROTONOSUPPORT : c_int = 43;
3641             pub const ESOCKTNOSUPPORT : c_int = 44;
3642             pub const EOPNOTSUPP : c_int = 45;
3643             pub const EPFNOSUPPORT : c_int = 46;
3644             pub const EAFNOSUPPORT : c_int = 47;
3645             pub const EADDRINUSE : c_int = 48;
3646             pub const EADDRNOTAVAIL : c_int = 49;
3647             pub const ENETDOWN : c_int = 50;
3648             pub const ENETUNREACH : c_int = 51;
3649             pub const ENETRESET : c_int = 52;
3650             pub const ECONNABORTED : c_int = 53;
3651             pub const ECONNRESET : c_int = 54;
3652             pub const ENOBUFS : c_int = 55;
3653             pub const EISCONN : c_int = 56;
3654             pub const ENOTCONN : c_int = 57;
3655             pub const ESHUTDOWN : c_int = 58;
3656             pub const ETOOMANYREFS : c_int = 59;
3657             pub const ETIMEDOUT : c_int = 60;
3658             pub const ECONNREFUSED : c_int = 61;
3659             pub const ELOOP : c_int = 62;
3660             pub const ENAMETOOLONG : c_int = 63;
3661             pub const EHOSTDOWN : c_int = 64;
3662             pub const EHOSTUNREACH : c_int = 65;
3663             pub const ENOTEMPTY : c_int = 66;
3664             pub const EPROCLIM : c_int = 67;
3665             pub const EUSERS : c_int = 68;
3666             pub const EDQUOT : c_int = 69;
3667             pub const ESTALE : c_int = 70;
3668             pub const EREMOTE : c_int = 71;
3669             pub const EBADRPC : c_int = 72;
3670             pub const ERPCMISMATCH : c_int = 73;
3671             pub const EPROGUNAVAIL : c_int = 74;
3672             pub const EPROGMISMATCH : c_int = 75;
3673             pub const EPROCUNAVAIL : c_int = 76;
3674             pub const ENOLCK : c_int = 77;
3675             pub const ENOSYS : c_int = 78;
3676             pub const EFTYPE : c_int = 79;
3677             pub const EAUTH : c_int = 80;
3678             pub const ENEEDAUTH : c_int = 81;
3679             pub const EIDRM : c_int = 82;
3680             pub const ENOMSG : c_int = 83;
3681             pub const EOVERFLOW : c_int = 84;
3682             pub const ECANCELED : c_int = 85;
3683             pub const EILSEQ : c_int = 86;
3684             pub const ENOATTR : c_int = 87;
3685             pub const EDOOFUS : c_int = 88;
3686             pub const EBADMSG : c_int = 89;
3687             pub const EMULTIHOP : c_int = 90;
3688             pub const ENOLINK : c_int = 91;
3689             pub const EPROTO : c_int = 92;
3690             pub const ENOMEDIUM : c_int = 93;
3691             pub const EUNUSED94 : c_int = 94;
3692             pub const EUNUSED95 : c_int = 95;
3693             pub const EUNUSED96 : c_int = 96;
3694             pub const EUNUSED97 : c_int = 97;
3695             pub const EUNUSED98 : c_int = 98;
3696             pub const EASYNC : c_int = 99;
3697             pub const ELAST : c_int = 99;
3698         }
3699         pub mod posix01 {
3700             use types::os::arch::c95::{c_int, size_t};
3701
3702             pub const F_DUPFD : c_int = 0;
3703             pub const F_GETFD : c_int = 1;
3704             pub const F_SETFD : c_int = 2;
3705             pub const F_GETFL : c_int = 3;
3706             pub const F_SETFL : c_int = 4;
3707
3708             pub const SIGTRAP : c_int = 5;
3709             pub const SIGPIPE: c_int = 13;
3710             pub const SIG_IGN: size_t = 1;
3711
3712             pub const GLOB_APPEND   : c_int = 0x0001;
3713             pub const GLOB_DOOFFS   : c_int = 0x0002;
3714             pub const GLOB_ERR      : c_int = 0x0004;
3715             pub const GLOB_MARK     : c_int = 0x0008;
3716             pub const GLOB_NOCHECK  : c_int = 0x0010;
3717             pub const GLOB_NOSORT   : c_int = 0x0020;
3718             pub const GLOB_NOESCAPE : c_int = 0x2000;
3719
3720             pub const GLOB_NOSPACE  : c_int = -1;
3721             pub const GLOB_ABORTED  : c_int = -2;
3722             pub const GLOB_NOMATCH  : c_int = -3;
3723
3724             pub const POSIX_MADV_NORMAL : c_int = 0;
3725             pub const POSIX_MADV_RANDOM : c_int = 1;
3726             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
3727             pub const POSIX_MADV_WILLNEED : c_int = 3;
3728             pub const POSIX_MADV_DONTNEED : c_int = 4;
3729
3730             pub const _SC_IOV_MAX : c_int = 56;
3731             pub const _SC_GETGR_R_SIZE_MAX : c_int = 70;
3732             pub const _SC_GETPW_R_SIZE_MAX : c_int = 71;
3733             pub const _SC_LOGIN_NAME_MAX : c_int = 73;
3734             pub const _SC_MQ_PRIO_MAX : c_int = 75;
3735             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82;
3736             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
3737             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
3738             pub const _SC_THREAD_KEYS_MAX : c_int = 86;
3739             pub const _SC_THREAD_PRIO_INHERIT : c_int = 87;
3740             pub const _SC_THREAD_PRIO_PROTECT : c_int = 88;
3741             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
3742             pub const _SC_THREAD_PROCESS_SHARED : c_int = 90;
3743             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
3744             pub const _SC_THREAD_STACK_MIN : c_int = 93;
3745             pub const _SC_THREAD_THREADS_MAX : c_int = 94;
3746             pub const _SC_THREADS : c_int = 96;
3747             pub const _SC_TTY_NAME_MAX : c_int = 101;
3748             pub const _SC_ATEXIT_MAX : c_int = 107;
3749             pub const _SC_XOPEN_CRYPT : c_int = 108;
3750             pub const _SC_XOPEN_ENH_I18N : c_int = 109;
3751             pub const _SC_XOPEN_LEGACY : c_int = 110;
3752             pub const _SC_XOPEN_REALTIME : c_int = 111;
3753             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112;
3754             pub const _SC_XOPEN_SHM : c_int = 113;
3755             pub const _SC_XOPEN_UNIX : c_int = 115;
3756             pub const _SC_XOPEN_VERSION : c_int = 116;
3757             pub const _SC_XOPEN_XCU_VERSION : c_int = 117;
3758
3759             pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
3760             pub const PTHREAD_CREATE_DETACHED: c_int = 1;
3761
3762             #[cfg(target_arch = "arm")]
3763             pub const PTHREAD_STACK_MIN: size_t = 4096;
3764
3765             #[cfg(all(target_os = "freebsd",
3766                       any(target_arch = "mips",
3767                           target_arch = "mipsel",
3768                           target_arch = "x86",
3769                           target_arch = "x86_64")))]
3770             pub const PTHREAD_STACK_MIN: size_t = 2048;
3771
3772             #[cfg(target_os = "dragonfly")]
3773             pub const PTHREAD_STACK_MIN: size_t = 1024;
3774
3775             pub const CLOCK_REALTIME: c_int = 0;
3776             pub const CLOCK_MONOTONIC: c_int = 4;
3777         }
3778         pub mod posix08 {
3779         }
3780         pub mod bsd44 {
3781             use types::os::arch::c95::c_int;
3782
3783             pub const MADV_NORMAL : c_int = 0;
3784             pub const MADV_RANDOM : c_int = 1;
3785             pub const MADV_SEQUENTIAL : c_int = 2;
3786             pub const MADV_WILLNEED : c_int = 3;
3787             pub const MADV_DONTNEED : c_int = 4;
3788             pub const MADV_FREE : c_int = 5;
3789             pub const MADV_NOSYNC : c_int = 6;
3790             pub const MADV_AUTOSYNC : c_int = 7;
3791             pub const MADV_NOCORE : c_int = 8;
3792             pub const MADV_CORE : c_int = 9;
3793             pub const MADV_PROTECT : c_int = 10;
3794
3795             pub const MINCORE_INCORE : c_int =  0x1;
3796             pub const MINCORE_REFERENCED : c_int = 0x2;
3797             pub const MINCORE_MODIFIED : c_int = 0x4;
3798             pub const MINCORE_REFERENCED_OTHER : c_int = 0x8;
3799             pub const MINCORE_MODIFIED_OTHER : c_int = 0x10;
3800             pub const MINCORE_SUPER : c_int = 0x20;
3801
3802             pub const AF_INET: c_int = 2;
3803             pub const AF_INET6: c_int = 28;
3804             pub const AF_UNIX: c_int = 1;
3805             pub const SOCK_STREAM: c_int = 1;
3806             pub const SOCK_DGRAM: c_int = 2;
3807             pub const SOCK_RAW: c_int = 3;
3808             pub const IPPROTO_TCP: c_int = 6;
3809             pub const IPPROTO_IP: c_int = 0;
3810             pub const IPPROTO_IPV6: c_int = 41;
3811             pub const IP_MULTICAST_TTL: c_int = 10;
3812             pub const IP_MULTICAST_LOOP: c_int = 11;
3813             pub const IP_TTL: c_int = 4;
3814             pub const IP_HDRINCL: c_int = 2;
3815             pub const IP_ADD_MEMBERSHIP: c_int = 12;
3816             pub const IP_DROP_MEMBERSHIP: c_int = 13;
3817             pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
3818             pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
3819
3820             pub const TCP_NODELAY: c_int = 1;
3821             pub const TCP_KEEPIDLE: c_int = 256;
3822             pub const SOL_SOCKET: c_int = 0xffff;
3823             pub const SO_KEEPALIVE: c_int = 0x0008;
3824             pub const SO_BROADCAST: c_int = 0x0020;
3825             pub const SO_REUSEADDR: c_int = 0x0004;
3826             pub const SO_ERROR: c_int = 0x1007;
3827
3828             pub const IFF_LOOPBACK: c_int = 0x8;
3829
3830             pub const SHUT_RD: c_int = 0;
3831             pub const SHUT_WR: c_int = 1;
3832             pub const SHUT_RDWR: c_int = 2;
3833         }
3834         pub mod extra {
3835             use types::os::arch::c95::c_int;
3836
3837             pub const O_SYNC : c_int = 128;
3838             pub const O_NONBLOCK : c_int = 4;
3839             pub const CTL_KERN: c_int = 1;
3840             pub const KERN_PROC: c_int = 14;
3841             #[cfg(target_os = "freebsd")]
3842             pub const KERN_PROC_PATHNAME: c_int = 12;
3843             #[cfg(target_os = "dragonfly")]
3844             pub const KERN_PROC_PATHNAME: c_int = 9;
3845
3846             pub const MAP_COPY : c_int = 0x0002;
3847             pub const MAP_RENAME : c_int = 0x0020;
3848             pub const MAP_NORESERVE : c_int = 0x0040;
3849             pub const MAP_HASSEMAPHORE : c_int = 0x0200;
3850             pub const MAP_STACK : c_int = 0x0400;
3851             pub const MAP_NOSYNC : c_int = 0x0800;
3852             pub const MAP_NOCORE : c_int = 0x020000;
3853
3854             pub const IPPROTO_RAW : c_int = 255;
3855         }
3856         pub mod sysconf {
3857             use types::os::arch::c95::c_int;
3858
3859             pub const _SC_ARG_MAX : c_int = 1;
3860             pub const _SC_CHILD_MAX : c_int = 2;
3861             pub const _SC_CLK_TCK : c_int = 3;
3862             pub const _SC_NGROUPS_MAX : c_int = 4;
3863             pub const _SC_OPEN_MAX : c_int = 5;
3864             pub const _SC_JOB_CONTROL : c_int = 6;
3865             pub const _SC_SAVED_IDS : c_int = 7;
3866             pub const _SC_VERSION : c_int = 8;
3867             pub const _SC_BC_BASE_MAX : c_int = 9;
3868             pub const _SC_BC_DIM_MAX : c_int = 10;
3869             pub const _SC_BC_SCALE_MAX : c_int = 11;
3870             pub const _SC_BC_STRING_MAX : c_int = 12;
3871             pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
3872             pub const _SC_EXPR_NEST_MAX : c_int = 14;
3873             pub const _SC_LINE_MAX : c_int = 15;
3874             pub const _SC_RE_DUP_MAX : c_int = 16;
3875             pub const _SC_2_VERSION : c_int = 17;
3876             pub const _SC_2_C_BIND : c_int = 18;
3877             pub const _SC_2_C_DEV : c_int = 19;
3878             pub const _SC_2_CHAR_TERM : c_int = 20;
3879             pub const _SC_2_FORT_DEV : c_int = 21;
3880             pub const _SC_2_FORT_RUN : c_int = 22;
3881             pub const _SC_2_LOCALEDEF : c_int = 23;
3882             pub const _SC_2_SW_DEV : c_int = 24;
3883             pub const _SC_2_UPE : c_int = 25;
3884             pub const _SC_STREAM_MAX : c_int = 26;
3885             pub const _SC_TZNAME_MAX : c_int = 27;
3886             pub const _SC_ASYNCHRONOUS_IO : c_int = 28;
3887             pub const _SC_MAPPED_FILES : c_int = 29;
3888             pub const _SC_MEMLOCK : c_int = 30;
3889             pub const _SC_MEMLOCK_RANGE : c_int = 31;
3890             pub const _SC_MEMORY_PROTECTION : c_int = 32;
3891             pub const _SC_MESSAGE_PASSING : c_int = 33;
3892             pub const _SC_PRIORITIZED_IO : c_int = 34;
3893             pub const _SC_PRIORITY_SCHEDULING : c_int = 35;
3894             pub const _SC_REALTIME_SIGNALS : c_int = 36;
3895             pub const _SC_SEMAPHORES : c_int = 37;
3896             pub const _SC_FSYNC : c_int = 38;
3897             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
3898             pub const _SC_SYNCHRONIZED_IO : c_int = 40;
3899             pub const _SC_TIMERS : c_int = 41;
3900             pub const _SC_AIO_LISTIO_MAX : c_int = 42;
3901             pub const _SC_AIO_MAX : c_int = 43;
3902             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
3903             pub const _SC_DELAYTIMER_MAX : c_int = 45;
3904             pub const _SC_MQ_OPEN_MAX : c_int = 46;
3905             pub const _SC_PAGESIZE : c_int = 47;
3906             pub const _SC_RTSIG_MAX : c_int = 48;
3907             pub const _SC_SEM_NSEMS_MAX : c_int = 49;
3908             pub const _SC_SEM_VALUE_MAX : c_int = 50;
3909             pub const _SC_SIGQUEUE_MAX : c_int = 51;
3910             pub const _SC_TIMER_MAX : c_int = 52;
3911         }
3912     }
3913
3914     #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
3915     pub mod os {
3916         pub mod c95 {
3917             use types::os::arch::c95::{c_int, c_uint};
3918
3919             pub const EXIT_FAILURE : c_int = 1;
3920             pub const EXIT_SUCCESS : c_int = 0;
3921             pub const RAND_MAX : c_int = 2147483647;
3922             pub const EOF : c_int = -1;
3923             pub const SEEK_SET : c_int = 0;
3924             pub const SEEK_CUR : c_int = 1;
3925             pub const SEEK_END : c_int = 2;
3926             pub const _IOFBF : c_int = 0;
3927             pub const _IONBF : c_int = 2;
3928             pub const _IOLBF : c_int = 1;
3929             pub const BUFSIZ : c_uint = 1024_u32;
3930             pub const FOPEN_MAX : c_uint = 20_u32;
3931             pub const FILENAME_MAX : c_uint = 1024_u32;
3932             pub const L_tmpnam : c_uint = 1024_u32;
3933             pub const TMP_MAX : c_uint = 308915776_u32;
3934         }
3935         pub mod c99 {
3936         }
3937         pub mod posix88 {
3938             use types::common::c95::c_void;
3939             use types::os::arch::c95::c_int;
3940             use types::os::arch::posix88::mode_t;
3941
3942             pub const O_RDONLY : c_int = 0;
3943             pub const O_WRONLY : c_int = 1;
3944             pub const O_RDWR : c_int = 2;
3945             pub const O_APPEND : c_int = 8;
3946             pub const O_CREAT : c_int = 512;
3947             pub const O_EXCL : c_int = 2048;
3948             pub const O_TRUNC : c_int = 1024;
3949             pub const S_IFIFO : mode_t = 4096;
3950             pub const S_IFCHR : mode_t = 8192;
3951             pub const S_IFBLK : mode_t = 24576;
3952             pub const S_IFDIR : mode_t = 16384;
3953             pub const S_IFREG : mode_t = 32768;
3954             pub const S_IFLNK : mode_t = 40960;
3955             pub const S_IFMT : mode_t = 61440;
3956             pub const S_IEXEC : mode_t = 64;
3957             pub const S_IWRITE : mode_t = 128;
3958             pub const S_IREAD : mode_t = 256;
3959             pub const S_IRWXU : mode_t = 448;
3960             pub const S_IXUSR : mode_t = 64;
3961             pub const S_IWUSR : mode_t = 128;
3962             pub const S_IRUSR : mode_t = 256;
3963             pub const F_OK : c_int = 0;
3964             pub const R_OK : c_int = 4;
3965             pub const W_OK : c_int = 2;
3966             pub const X_OK : c_int = 1;
3967             pub const STDIN_FILENO : c_int = 0;
3968             pub const STDOUT_FILENO : c_int = 1;
3969             pub const STDERR_FILENO : c_int = 2;
3970             pub const F_LOCK : c_int = 1;
3971             pub const F_TEST : c_int = 3;
3972             pub const F_TLOCK : c_int = 2;
3973             pub const F_ULOCK : c_int = 0;
3974             pub const SIGHUP : c_int = 1;
3975             pub const SIGINT : c_int = 2;
3976             pub const SIGQUIT : c_int = 3;
3977             pub const SIGILL : c_int = 4;
3978             pub const SIGABRT : c_int = 6;
3979             pub const SIGFPE : c_int = 8;
3980             pub const SIGKILL : c_int = 9;
3981             pub const SIGSEGV : c_int = 11;
3982             pub const SIGPIPE : c_int = 13;
3983             pub const SIGALRM : c_int = 14;
3984             pub const SIGTERM : c_int = 15;
3985
3986             pub const PROT_NONE : c_int = 0;
3987             pub const PROT_READ : c_int = 1;
3988             pub const PROT_WRITE : c_int = 2;
3989             pub const PROT_EXEC : c_int = 4;
3990
3991             pub const MAP_FILE : c_int = 0x0000;
3992             pub const MAP_SHARED : c_int = 0x0001;
3993             pub const MAP_PRIVATE : c_int = 0x0002;
3994             pub const MAP_FIXED : c_int = 0x0010;
3995             pub const MAP_ANON : c_int = 0x1000;
3996
3997             pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
3998
3999             pub const MCL_CURRENT : c_int = 0x0001;
4000             pub const MCL_FUTURE : c_int = 0x0002;
4001
4002             pub const MS_ASYNC : c_int = 0x0001;
4003             pub const MS_SYNC : c_int = 0x0002;
4004             pub const MS_INVALIDATE : c_int = 0x0004;
4005
4006             pub const EPERM : c_int = 1;
4007             pub const ENOENT : c_int = 2;
4008             pub const ESRCH : c_int = 3;
4009             pub const EINTR : c_int = 4;
4010             pub const EIO : c_int = 5;
4011             pub const ENXIO : c_int = 6;
4012             pub const E2BIG : c_int = 7;
4013             pub const ENOEXEC : c_int = 8;
4014             pub const EBADF : c_int = 9;
4015             pub const ECHILD : c_int = 10;
4016             pub const EDEADLK : c_int = 11;
4017             pub const ENOMEM : c_int = 12;
4018             pub const EACCES : c_int = 13;
4019             pub const EFAULT : c_int = 14;
4020             pub const ENOTBLK : c_int = 15;
4021             pub const EBUSY : c_int = 16;
4022             pub const EEXIST : c_int = 17;
4023             pub const EXDEV : c_int = 18;
4024             pub const ENODEV : c_int = 19;
4025             pub const ENOTDIR : c_int = 20;
4026             pub const EISDIR : c_int = 21;
4027             pub const EINVAL : c_int = 22;
4028             pub const ENFILE : c_int = 23;
4029             pub const EMFILE : c_int = 24;
4030             pub const ENOTTY : c_int = 25;
4031             pub const ETXTBSY : c_int = 26;
4032             pub const EFBIG : c_int = 27;
4033             pub const ENOSPC : c_int = 28;
4034             pub const ESPIPE : c_int = 29;
4035             pub const EROFS : c_int = 30;
4036             pub const EMLINK : c_int = 31;
4037             pub const EPIPE : c_int = 32;
4038             pub const EDOM : c_int = 33;
4039             pub const ERANGE : c_int = 34;
4040             pub const EAGAIN : c_int = 35;
4041             pub const EWOULDBLOCK : c_int = 35;
4042             pub const EINPROGRESS : c_int = 36;
4043             pub const EALREADY : c_int = 37;
4044             pub const ENOTSOCK : c_int = 38;
4045             pub const EDESTADDRREQ : c_int = 39;
4046             pub const EMSGSIZE : c_int = 40;
4047             pub const EPROTOTYPE : c_int = 41;
4048             pub const ENOPROTOOPT : c_int = 42;
4049             pub const EPROTONOSUPPORT : c_int = 43;
4050             pub const ESOCKTNOSUPPORT : c_int = 44;
4051             pub const EOPNOTSUPP : c_int = 45;
4052             pub const EPFNOSUPPORT : c_int = 46;
4053             pub const EAFNOSUPPORT : c_int = 47;
4054             pub const EADDRINUSE : c_int = 48;
4055             pub const EADDRNOTAVAIL : c_int = 49;
4056             pub const ENETDOWN : c_int = 50;
4057             pub const ENETUNREACH : c_int = 51;
4058             pub const ENETRESET : c_int = 52;
4059             pub const ECONNABORTED : c_int = 53;
4060             pub const ECONNRESET : c_int = 54;
4061             pub const ENOBUFS : c_int = 55;
4062             pub const EISCONN : c_int = 56;
4063             pub const ENOTCONN : c_int = 57;
4064             pub const ESHUTDOWN : c_int = 58;
4065             pub const ETOOMANYREFS : c_int = 59;
4066             pub const ETIMEDOUT : c_int = 60;
4067             pub const ECONNREFUSED : c_int = 61;
4068             pub const ELOOP : c_int = 62;
4069             pub const ENAMETOOLONG : c_int = 63;
4070             pub const EHOSTDOWN : c_int = 64;
4071             pub const EHOSTUNREACH : c_int = 65;
4072             pub const ENOTEMPTY : c_int = 66;
4073             pub const EPROCLIM : c_int = 67;
4074             pub const EUSERS : c_int = 68;
4075             pub const EDQUOT : c_int = 69;
4076             pub const ESTALE : c_int = 70;
4077             pub const EREMOTE : c_int = 71;
4078             pub const EBADRPC : c_int = 72;
4079             pub const ERPCMISMATCH : c_int = 73;
4080             pub const EPROGUNAVAIL : c_int = 74;
4081             pub const EPROGMISMATCH : c_int = 75;
4082             pub const EPROCUNAVAIL : c_int = 76;
4083             pub const ENOLCK : c_int = 77;
4084             pub const ENOSYS : c_int = 78;
4085             pub const EFTYPE : c_int = 79;
4086             pub const EAUTH : c_int = 80;
4087             pub const ENEEDAUTH : c_int = 81;
4088             pub const EIPSEC : c_int = 82;
4089             pub const ENOATTR : c_int = 83;
4090             pub const EILSEQ : c_int = 84;
4091             pub const ENOMEDIUM : c_int = 85;
4092             pub const EMEDIUMTYPE : c_int = 86;
4093             pub const EOVERFLOW : c_int = 87;
4094             pub const ECANCELED : c_int = 88;
4095             pub const EIDRM : c_int = 89;
4096             pub const ENOMSG : c_int = 90;
4097             pub const ENOTSUP : c_int = 91;
4098             pub const ELAST : c_int = 91; // must be equal to largest errno
4099         }
4100         pub mod posix01 {
4101             use types::os::arch::c95::{c_int, size_t};
4102
4103             pub const F_DUPFD : c_int = 0;
4104             pub const F_GETFD : c_int = 1;
4105             pub const F_SETFD : c_int = 2;
4106             pub const F_GETFL : c_int = 3;
4107             pub const F_SETFL : c_int = 4;
4108             pub const F_GETOWN : c_int = 5;
4109             pub const F_SETOWN : c_int = 6;
4110             pub const F_GETLK : c_int = 7;
4111             pub const F_SETLK : c_int = 8;
4112             pub const F_SETLKW : c_int = 9;
4113             pub const F_DUPFD_CLOEXEC : c_int = 10;
4114
4115             pub const SIGTRAP : c_int = 5;
4116             pub const SIGPIPE: c_int = 13;
4117             pub const SIG_IGN: size_t = 1;
4118
4119             pub const GLOB_APPEND   : c_int = 0x0001;
4120             pub const GLOB_DOOFFS   : c_int = 0x0002;
4121             pub const GLOB_ERR      : c_int = 0x0004;
4122             pub const GLOB_MARK     : c_int = 0x0008;
4123             pub const GLOB_NOCHECK  : c_int = 0x0010;
4124             pub const GLOB_NOSORT   : c_int = 0x0020;
4125             pub const GLOB_NOESCAPE : c_int = 0x1000;
4126
4127             pub const GLOB_NOSPACE  : c_int = -1;
4128             pub const GLOB_ABORTED  : c_int = -2;
4129             pub const GLOB_NOMATCH  : c_int = -3;
4130             pub const GLOB_NOSYS : c_int = -4;
4131
4132             pub const POSIX_MADV_NORMAL : c_int = 0;
4133             pub const POSIX_MADV_RANDOM : c_int = 1;
4134             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
4135             pub const POSIX_MADV_WILLNEED : c_int = 3;
4136             pub const POSIX_MADV_DONTNEED : c_int = 4;
4137
4138             pub const _SC_IOV_MAX : c_int = 51;
4139             pub const _SC_GETGR_R_SIZE_MAX : c_int = 100;
4140             pub const _SC_GETPW_R_SIZE_MAX : c_int = 101;
4141             pub const _SC_LOGIN_NAME_MAX : c_int = 102;
4142             pub const _SC_MQ_PRIO_MAX : c_int = 59;
4143             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77;
4144             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
4145             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80;
4146             pub const _SC_THREAD_KEYS_MAX : c_int = 81;
4147             pub const _SC_THREAD_PRIO_INHERIT : c_int = 82;
4148             pub const _SC_THREAD_PRIO_PROTECT : c_int = 83;
4149             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84;
4150             pub const _SC_THREAD_PROCESS_SHARED : c_int = 85;
4151             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103;
4152             pub const _SC_THREAD_STACK_MIN : c_int = 89;
4153             pub const _SC_THREAD_THREADS_MAX : c_int = 90;
4154             pub const _SC_THREADS : c_int = 91;
4155             pub const _SC_TTY_NAME_MAX : c_int = 107;
4156             pub const _SC_ATEXIT_MAX : c_int = 46;
4157             pub const _SC_XOPEN_CRYPT : c_int = 117;
4158             pub const _SC_XOPEN_ENH_I18N : c_int = 118;
4159             pub const _SC_XOPEN_LEGACY : c_int = 119;
4160             pub const _SC_XOPEN_REALTIME : c_int = 120;
4161             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121;
4162             pub const _SC_XOPEN_SHM : c_int = 30;
4163             pub const _SC_XOPEN_UNIX : c_int = 123;
4164             pub const _SC_XOPEN_VERSION : c_int = 125;
4165
4166             pub const PTHREAD_CREATE_JOINABLE : c_int = 0;
4167             pub const PTHREAD_CREATE_DETACHED : c_int = 1;
4168             pub const PTHREAD_STACK_MIN : size_t = 2048;
4169
4170             pub const CLOCK_REALTIME : c_int = 0;
4171             pub const CLOCK_MONOTONIC : c_int = 3;
4172         }
4173         pub mod posix08 {
4174         }
4175         pub mod bsd44 {
4176             use types::os::arch::c95::c_int;
4177
4178             pub const MADV_NORMAL : c_int = 0;
4179             pub const MADV_RANDOM : c_int = 1;
4180             pub const MADV_SEQUENTIAL : c_int = 2;
4181             pub const MADV_WILLNEED : c_int = 3;
4182             pub const MADV_DONTNEED : c_int = 4;
4183             pub const MADV_FREE : c_int = 6;
4184
4185             pub const AF_UNIX: c_int = 1;
4186             pub const AF_INET: c_int = 2;
4187             pub const AF_INET6: c_int = 24;
4188             pub const SOCK_STREAM: c_int = 1;
4189             pub const SOCK_DGRAM: c_int = 2;
4190             pub const SOCK_RAW: c_int = 3;
4191             pub const IPPROTO_TCP: c_int = 6;
4192             pub const IPPROTO_IP: c_int = 0;
4193             pub const IPPROTO_IPV6: c_int = 41;
4194             pub const IP_MULTICAST_TTL: c_int = 10;
4195             pub const IP_MULTICAST_LOOP: c_int = 11;
4196             pub const IP_TTL: c_int = 4;
4197             pub const IP_HDRINCL: c_int = 2;
4198             pub const IP_ADD_MEMBERSHIP: c_int = 12;
4199             pub const IP_DROP_MEMBERSHIP: c_int = 13;
4200             pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist
4201             pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist
4202
4203             pub const TCP_NODELAY: c_int = 0x01;
4204             pub const SOL_SOCKET: c_int = 0xffff;
4205             pub const SO_KEEPALIVE: c_int = 0x0008;
4206             pub const SO_BROADCAST: c_int = 0x0020;
4207             pub const SO_REUSEADDR: c_int = 0x0004;
4208             pub const SO_ERROR: c_int = 0x1007;
4209
4210             pub const IFF_LOOPBACK: c_int = 0x8;
4211
4212             pub const SHUT_RD: c_int = 0;
4213             pub const SHUT_WR: c_int = 1;
4214             pub const SHUT_RDWR: c_int = 2;
4215         }
4216         pub mod extra {
4217             use types::os::arch::c95::c_int;
4218
4219             pub const O_DSYNC : c_int = 128; // same as SYNC
4220             pub const O_SYNC : c_int = 128;
4221             pub const O_NONBLOCK : c_int = 4;
4222             pub const CTL_KERN : c_int = 1;
4223             pub const KERN_PROC : c_int = 66;
4224
4225             pub const MAP_COPY : c_int = 0x0002;
4226             pub const MAP_RENAME : c_int = 0x0000;
4227             pub const MAP_NORESERVE : c_int = 0x0000;
4228             pub const MAP_NOEXTEND : c_int = 0x0000;
4229             pub const MAP_HASSEMAPHORE : c_int = 0x0000;
4230
4231             pub const IPPROTO_RAW : c_int = 255;
4232
4233             pub const PATH_MAX: c_int = 1024;
4234         }
4235         pub mod sysconf {
4236             use types::os::arch::c95::c_int;
4237
4238             pub const _SC_ARG_MAX : c_int = 1;
4239             pub const _SC_CHILD_MAX : c_int = 2;
4240             pub const _SC_CLK_TCK : c_int = 3;
4241             pub const _SC_NGROUPS_MAX : c_int = 4;
4242             pub const _SC_OPEN_MAX : c_int = 5;
4243             pub const _SC_JOB_CONTROL : c_int = 6;
4244             pub const _SC_SAVED_IDS : c_int = 7;
4245             pub const _SC_VERSION : c_int = 8;
4246             pub const _SC_BC_BASE_MAX : c_int = 9;
4247             pub const _SC_BC_DIM_MAX : c_int = 10;
4248             pub const _SC_BC_SCALE_MAX : c_int = 11;
4249             pub const _SC_BC_STRING_MAX : c_int = 12;
4250             pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
4251             pub const _SC_EXPR_NEST_MAX : c_int = 14;
4252             pub const _SC_LINE_MAX : c_int = 15;
4253             pub const _SC_RE_DUP_MAX : c_int = 16;
4254             pub const _SC_2_VERSION : c_int = 17;
4255             pub const _SC_2_C_BIND : c_int = 18;
4256             pub const _SC_2_C_DEV : c_int = 19;
4257             pub const _SC_2_CHAR_TERM : c_int = 20;
4258             pub const _SC_2_FORT_DEV : c_int = 21;
4259             pub const _SC_2_FORT_RUN : c_int = 22;
4260             pub const _SC_2_LOCALEDEF : c_int = 23;
4261             pub const _SC_2_SW_DEV : c_int = 24;
4262             pub const _SC_2_UPE : c_int = 25;
4263             pub const _SC_STREAM_MAX : c_int = 26;
4264             pub const _SC_TZNAME_MAX : c_int = 27;
4265             pub const _SC_PAGESIZE : c_int = 28;
4266             pub const _SC_FSYNC : c_int = 29;
4267             pub const _SC_SEM_NSEMS_MAX : c_int = 31;
4268             pub const _SC_SEM_VALUE_MAX : c_int = 32;
4269             pub const _SC_AIO_LISTIO_MAX : c_int = 42;
4270             pub const _SC_AIO_MAX : c_int = 43;
4271             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
4272             pub const _SC_ASYNCHRONOUS_IO : c_int = 45;
4273             pub const _SC_DELAYTIMER_MAX : c_int = 50;
4274             pub const _SC_MAPPED_FILES : c_int = 53;
4275             pub const _SC_MEMLOCK : c_int = 54;
4276             pub const _SC_MEMLOCK_RANGE : c_int = 55;
4277             pub const _SC_MEMORY_PROTECTION : c_int = 56;
4278             pub const _SC_MESSAGE_PASSING : c_int = 57;
4279             pub const _SC_MQ_OPEN_MAX : c_int = 58;
4280             pub const _SC_PRIORITIZED_IO : c_int = 60;
4281             pub const _SC_PRIORITY_SCHEDULING : c_int = 61;
4282             pub const _SC_REALTIME_SIGNALS : c_int = 64;
4283             pub const _SC_RTSIG_MAX : c_int = 66;
4284             pub const _SC_SEMAPHORES : c_int = 67;
4285             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68;
4286             pub const _SC_SIGQUEUE_MAX : c_int = 70;
4287             pub const _SC_SYNCHRONIZED_IO : c_int = 75;
4288             pub const _SC_TIMER_MAX : c_int = 93;
4289             pub const _SC_TIMERS : c_int = 94;
4290         }
4291     }
4292
4293     #[cfg(any(target_os = "macos", target_os = "ios"))]
4294     pub mod os {
4295         pub mod c95 {
4296             use types::os::arch::c95::{c_int, c_uint};
4297
4298             pub const EXIT_FAILURE : c_int = 1;
4299             pub const EXIT_SUCCESS : c_int = 0;
4300             pub const RAND_MAX : c_int = 2147483647;
4301             pub const EOF : c_int = -1;
4302             pub const SEEK_SET : c_int = 0;
4303             pub const SEEK_CUR : c_int = 1;
4304             pub const SEEK_END : c_int = 2;
4305             pub const _IOFBF : c_int = 0;
4306             pub const _IONBF : c_int = 2;
4307             pub const _IOLBF : c_int = 1;
4308             pub const BUFSIZ : c_uint = 1024_u32;
4309             pub const FOPEN_MAX : c_uint = 20_u32;
4310             pub const FILENAME_MAX : c_uint = 1024_u32;
4311             pub const L_tmpnam : c_uint = 1024_u32;
4312             pub const TMP_MAX : c_uint = 308915776_u32;
4313         }
4314         pub mod c99 {
4315         }
4316         pub mod posix88 {
4317             use types::common::c95::c_void;
4318             use types::os::arch::c95::c_int;
4319             use types::os::arch::posix88::mode_t;
4320
4321             pub const O_RDONLY : c_int = 0;
4322             pub const O_WRONLY : c_int = 1;
4323             pub const O_RDWR : c_int = 2;
4324             pub const O_APPEND : c_int = 8;
4325             pub const O_CREAT : c_int = 512;
4326             pub const O_EXCL : c_int = 2048;
4327             pub const O_TRUNC : c_int = 1024;
4328             pub const S_IFIFO : mode_t = 4096;
4329             pub const S_IFCHR : mode_t = 8192;
4330             pub const S_IFBLK : mode_t = 24576;
4331             pub const S_IFDIR : mode_t = 16384;
4332             pub const S_IFREG : mode_t = 32768;
4333             pub const S_IFLNK : mode_t = 40960;
4334             pub const S_IFMT : mode_t = 61440;
4335             pub const S_IEXEC : mode_t = 64;
4336             pub const S_IWRITE : mode_t = 128;
4337             pub const S_IREAD : mode_t = 256;
4338             pub const S_IRWXU : mode_t = 448;
4339             pub const S_IXUSR : mode_t = 64;
4340             pub const S_IWUSR : mode_t = 128;
4341             pub const S_IRUSR : mode_t = 256;
4342             pub const F_OK : c_int = 0;
4343             pub const R_OK : c_int = 4;
4344             pub const W_OK : c_int = 2;
4345             pub const X_OK : c_int = 1;
4346             pub const STDIN_FILENO : c_int = 0;
4347             pub const STDOUT_FILENO : c_int = 1;
4348             pub const STDERR_FILENO : c_int = 2;
4349             pub const F_LOCK : c_int = 1;
4350             pub const F_TEST : c_int = 3;
4351             pub const F_TLOCK : c_int = 2;
4352             pub const F_ULOCK : c_int = 0;
4353             pub const SIGHUP : c_int = 1;
4354             pub const SIGINT : c_int = 2;
4355             pub const SIGQUIT : c_int = 3;
4356             pub const SIGILL : c_int = 4;
4357             pub const SIGABRT : c_int = 6;
4358             pub const SIGFPE : c_int = 8;
4359             pub const SIGKILL : c_int = 9;
4360             pub const SIGSEGV : c_int = 11;
4361             pub const SIGPIPE : c_int = 13;
4362             pub const SIGALRM : c_int = 14;
4363             pub const SIGTERM : c_int = 15;
4364
4365             pub const PROT_NONE : c_int = 0;
4366             pub const PROT_READ : c_int = 1;
4367             pub const PROT_WRITE : c_int = 2;
4368             pub const PROT_EXEC : c_int = 4;
4369
4370             pub const MAP_FILE : c_int = 0x0000;
4371             pub const MAP_SHARED : c_int = 0x0001;
4372             pub const MAP_PRIVATE : c_int = 0x0002;
4373             pub const MAP_FIXED : c_int = 0x0010;
4374             pub const MAP_ANON : c_int = 0x1000;
4375
4376             pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
4377
4378             pub const MCL_CURRENT : c_int = 0x0001;
4379             pub const MCL_FUTURE : c_int = 0x0002;
4380
4381             pub const MS_ASYNC : c_int = 0x0001;
4382             pub const MS_INVALIDATE : c_int = 0x0002;
4383             pub const MS_SYNC : c_int = 0x0010;
4384
4385             pub const MS_KILLPAGES : c_int = 0x0004;
4386             pub const MS_DEACTIVATE : c_int = 0x0008;
4387
4388             pub const EPERM : c_int = 1;
4389             pub const ENOENT : c_int = 2;
4390             pub const ESRCH : c_int = 3;
4391             pub const EINTR : c_int = 4;
4392             pub const EIO : c_int = 5;
4393             pub const ENXIO : c_int = 6;
4394             pub const E2BIG : c_int = 7;
4395             pub const ENOEXEC : c_int = 8;
4396             pub const EBADF : c_int = 9;
4397             pub const ECHILD : c_int = 10;
4398             pub const EDEADLK : c_int = 11;
4399             pub const ENOMEM : c_int = 12;
4400             pub const EACCES : c_int = 13;
4401             pub const EFAULT : c_int = 14;
4402             pub const ENOTBLK : c_int = 15;
4403             pub const EBUSY : c_int = 16;
4404             pub const EEXIST : c_int = 17;
4405             pub const EXDEV : c_int = 18;
4406             pub const ENODEV : c_int = 19;
4407             pub const ENOTDIR : c_int = 20;
4408             pub const EISDIR : c_int = 21;
4409             pub const EINVAL : c_int = 22;
4410             pub const ENFILE : c_int = 23;
4411             pub const EMFILE : c_int = 24;
4412             pub const ENOTTY : c_int = 25;
4413             pub const ETXTBSY : c_int = 26;
4414             pub const EFBIG : c_int = 27;
4415             pub const ENOSPC : c_int = 28;
4416             pub const ESPIPE : c_int = 29;
4417             pub const EROFS : c_int = 30;
4418             pub const EMLINK : c_int = 31;
4419             pub const EPIPE : c_int = 32;
4420             pub const EDOM : c_int = 33;
4421             pub const ERANGE : c_int = 34;
4422             pub const EAGAIN : c_int = 35;
4423             pub const EWOULDBLOCK : c_int = EAGAIN;
4424             pub const EINPROGRESS : c_int = 36;
4425             pub const EALREADY : c_int = 37;
4426             pub const ENOTSOCK : c_int = 38;
4427             pub const EDESTADDRREQ : c_int = 39;
4428             pub const EMSGSIZE : c_int = 40;
4429             pub const EPROTOTYPE : c_int = 41;
4430             pub const ENOPROTOOPT : c_int = 42;
4431             pub const EPROTONOSUPPORT : c_int = 43;
4432             pub const ESOCKTNOSUPPORT : c_int = 44;
4433             pub const ENOTSUP : c_int = 45;
4434             pub const EPFNOSUPPORT : c_int = 46;
4435             pub const EAFNOSUPPORT : c_int = 47;
4436             pub const EADDRINUSE : c_int = 48;
4437             pub const EADDRNOTAVAIL : c_int = 49;
4438             pub const ENETDOWN : c_int = 50;
4439             pub const ENETUNREACH : c_int = 51;
4440             pub const ENETRESET : c_int = 52;
4441             pub const ECONNABORTED : c_int = 53;
4442             pub const ECONNRESET : c_int = 54;
4443             pub const ENOBUFS : c_int = 55;
4444             pub const EISCONN : c_int = 56;
4445             pub const ENOTCONN : c_int = 57;
4446             pub const ESHUTDOWN : c_int = 58;
4447             pub const ETOOMANYREFS : c_int = 59;
4448             pub const ETIMEDOUT : c_int = 60;
4449             pub const ECONNREFUSED : c_int = 61;
4450             pub const ELOOP : c_int = 62;
4451             pub const ENAMETOOLONG : c_int = 63;
4452             pub const EHOSTDOWN : c_int = 64;
4453             pub const EHOSTUNREACH : c_int = 65;
4454             pub const ENOTEMPTY : c_int = 66;
4455             pub const EPROCLIM : c_int = 67;
4456             pub const EUSERS : c_int = 68;
4457             pub const EDQUOT : c_int = 69;
4458             pub const ESTALE : c_int = 70;
4459             pub const EREMOTE : c_int = 71;
4460             pub const EBADRPC : c_int = 72;
4461             pub const ERPCMISMATCH : c_int = 73;
4462             pub const EPROGUNAVAIL : c_int = 74;
4463             pub const EPROGMISMATCH : c_int = 75;
4464             pub const EPROCUNAVAIL : c_int = 76;
4465             pub const ENOLCK : c_int = 77;
4466             pub const ENOSYS : c_int = 78;
4467             pub const EFTYPE : c_int = 79;
4468             pub const EAUTH : c_int = 80;
4469             pub const ENEEDAUTH : c_int = 81;
4470             pub const EPWROFF : c_int = 82;
4471             pub const EDEVERR : c_int = 83;
4472             pub const EOVERFLOW : c_int = 84;
4473             pub const EBADEXEC : c_int = 85;
4474             pub const EBADARCH : c_int = 86;
4475             pub const ESHLIBVERS : c_int = 87;
4476             pub const EBADMACHO : c_int = 88;
4477             pub const ECANCELED : c_int = 89;
4478             pub const EIDRM : c_int = 90;
4479             pub const ENOMSG : c_int = 91;
4480             pub const EILSEQ : c_int = 92;
4481             pub const ENOATTR : c_int = 93;
4482             pub const EBADMSG : c_int = 94;
4483             pub const EMULTIHOP : c_int = 95;
4484             pub const ENODATA : c_int = 96;
4485             pub const ENOLINK : c_int = 97;
4486             pub const ENOSR : c_int = 98;
4487             pub const ENOSTR : c_int = 99;
4488             pub const EPROTO : c_int = 100;
4489             pub const ETIME : c_int = 101;
4490             pub const EOPNOTSUPP : c_int = 102;
4491             pub const ENOPOLICY : c_int = 103;
4492             pub const ENOTRECOVERABLE : c_int = 104;
4493             pub const EOWNERDEAD : c_int = 105;
4494             pub const EQFULL : c_int = 106;
4495             pub const ELAST : c_int = 106;
4496         }
4497         pub mod posix01 {
4498             use types::os::arch::c95::{c_int, size_t};
4499
4500             pub const F_DUPFD : c_int = 0;
4501             pub const F_GETFD : c_int = 1;
4502             pub const F_SETFD : c_int = 2;
4503             pub const F_GETFL : c_int = 3;
4504             pub const F_SETFL : c_int = 4;
4505
4506             pub const SIGTRAP : c_int = 5;
4507             pub const SIGPIPE: c_int = 13;
4508             pub const SIG_IGN: size_t = 1;
4509
4510             pub const GLOB_APPEND   : c_int = 0x0001;
4511             pub const GLOB_DOOFFS   : c_int = 0x0002;
4512             pub const GLOB_ERR      : c_int = 0x0004;
4513             pub const GLOB_MARK     : c_int = 0x0008;
4514             pub const GLOB_NOCHECK  : c_int = 0x0010;
4515             pub const GLOB_NOSORT   : c_int = 0x0020;
4516             pub const GLOB_NOESCAPE : c_int = 0x2000;
4517
4518             pub const GLOB_NOSPACE  : c_int = -1;
4519             pub const GLOB_ABORTED  : c_int = -2;
4520             pub const GLOB_NOMATCH  : c_int = -3;
4521
4522             pub const POSIX_MADV_NORMAL : c_int = 0;
4523             pub const POSIX_MADV_RANDOM : c_int = 1;
4524             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
4525             pub const POSIX_MADV_WILLNEED : c_int = 3;
4526             pub const POSIX_MADV_DONTNEED : c_int = 4;
4527
4528             pub const _SC_IOV_MAX : c_int = 56;
4529             pub const _SC_GETGR_R_SIZE_MAX : c_int = 70;
4530             pub const _SC_GETPW_R_SIZE_MAX : c_int = 71;
4531             pub const _SC_LOGIN_NAME_MAX : c_int = 73;
4532             pub const _SC_MQ_PRIO_MAX : c_int = 75;
4533             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82;
4534             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
4535             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
4536             pub const _SC_THREAD_KEYS_MAX : c_int = 86;
4537             pub const _SC_THREAD_PRIO_INHERIT : c_int = 87;
4538             pub const _SC_THREAD_PRIO_PROTECT : c_int = 88;
4539             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
4540             pub const _SC_THREAD_PROCESS_SHARED : c_int = 90;
4541             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
4542             pub const _SC_THREAD_STACK_MIN : c_int = 93;
4543             pub const _SC_THREAD_THREADS_MAX : c_int = 94;
4544             pub const _SC_THREADS : c_int = 96;
4545             pub const _SC_TTY_NAME_MAX : c_int = 101;
4546             pub const _SC_ATEXIT_MAX : c_int = 107;
4547             pub const _SC_XOPEN_CRYPT : c_int = 108;
4548             pub const _SC_XOPEN_ENH_I18N : c_int = 109;
4549             pub const _SC_XOPEN_LEGACY : c_int = 110;
4550             pub const _SC_XOPEN_REALTIME : c_int = 111;
4551             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112;
4552             pub const _SC_XOPEN_SHM : c_int = 113;
4553             pub const _SC_XOPEN_UNIX : c_int = 115;
4554             pub const _SC_XOPEN_VERSION : c_int = 116;
4555             pub const _SC_XOPEN_XCU_VERSION : c_int = 121;
4556
4557             pub const PTHREAD_CREATE_JOINABLE: c_int = 1;
4558             pub const PTHREAD_CREATE_DETACHED: c_int = 2;
4559             pub const PTHREAD_STACK_MIN: size_t = 8192;
4560         }
4561         pub mod posix08 {
4562         }
4563         pub mod bsd44 {
4564             use types::os::arch::c95::c_int;
4565
4566             pub const MADV_NORMAL : c_int = 0;
4567             pub const MADV_RANDOM : c_int = 1;
4568             pub const MADV_SEQUENTIAL : c_int = 2;
4569             pub const MADV_WILLNEED : c_int = 3;
4570             pub const MADV_DONTNEED : c_int = 4;
4571             pub const MADV_FREE : c_int = 5;
4572             pub const MADV_ZERO_WIRED_PAGES : c_int = 6;
4573             pub const MADV_FREE_REUSABLE : c_int = 7;
4574             pub const MADV_FREE_REUSE : c_int = 8;
4575             pub const MADV_CAN_REUSE : c_int = 9;
4576
4577             pub const MINCORE_INCORE : c_int =  0x1;
4578             pub const MINCORE_REFERENCED : c_int = 0x2;
4579             pub const MINCORE_MODIFIED : c_int = 0x4;
4580             pub const MINCORE_REFERENCED_OTHER : c_int = 0x8;
4581             pub const MINCORE_MODIFIED_OTHER : c_int = 0x10;
4582
4583             pub const AF_UNIX: c_int = 1;
4584             pub const AF_INET: c_int = 2;
4585             pub const AF_INET6: c_int = 30;
4586             pub const SOCK_STREAM: c_int = 1;
4587             pub const SOCK_DGRAM: c_int = 2;
4588             pub const SOCK_RAW: c_int = 3;
4589             pub const IPPROTO_TCP: c_int = 6;
4590             pub const IPPROTO_IP: c_int = 0;
4591             pub const IPPROTO_IPV6: c_int = 41;
4592             pub const IP_MULTICAST_TTL: c_int = 10;
4593             pub const IP_MULTICAST_LOOP: c_int = 11;
4594             pub const IP_TTL: c_int = 4;
4595             pub const IP_HDRINCL: c_int = 2;
4596             pub const IP_ADD_MEMBERSHIP: c_int = 12;
4597             pub const IP_DROP_MEMBERSHIP: c_int = 13;
4598             pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
4599             pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
4600
4601             pub const TCP_NODELAY: c_int = 0x01;
4602             pub const TCP_KEEPALIVE: c_int = 0x10;
4603             pub const SOL_SOCKET: c_int = 0xffff;
4604             pub const SO_KEEPALIVE: c_int = 0x0008;
4605             pub const SO_BROADCAST: c_int = 0x0020;
4606             pub const SO_REUSEADDR: c_int = 0x0004;
4607             pub const SO_ERROR: c_int = 0x1007;
4608
4609             pub const IFF_LOOPBACK: c_int = 0x8;
4610
4611             pub const SHUT_RD: c_int = 0;
4612             pub const SHUT_WR: c_int = 1;
4613             pub const SHUT_RDWR: c_int = 2;
4614         }
4615         pub mod extra {
4616             use types::os::arch::c95::c_int;
4617
4618             pub const O_DSYNC : c_int = 4194304;
4619             pub const O_SYNC : c_int = 128;
4620             pub const O_NONBLOCK : c_int = 4;
4621             pub const F_FULLFSYNC : c_int = 51;
4622
4623             pub const MAP_COPY : c_int = 0x0002;
4624             pub const MAP_RENAME : c_int = 0x0020;
4625             pub const MAP_NORESERVE : c_int = 0x0040;
4626             pub const MAP_NOEXTEND : c_int = 0x0100;
4627             pub const MAP_HASSEMAPHORE : c_int = 0x0200;
4628             pub const MAP_NOCACHE : c_int = 0x0400;
4629             pub const MAP_JIT : c_int = 0x0800;
4630             pub const MAP_STACK : c_int = 0;
4631
4632             pub const IPPROTO_RAW : c_int = 255;
4633         }
4634         pub mod sysconf {
4635             use types::os::arch::c95::c_int;
4636
4637             pub const _SC_ARG_MAX : c_int = 1;
4638             pub const _SC_CHILD_MAX : c_int = 2;
4639             pub const _SC_CLK_TCK : c_int = 3;
4640             pub const _SC_NGROUPS_MAX : c_int = 4;
4641             pub const _SC_OPEN_MAX : c_int = 5;
4642             pub const _SC_JOB_CONTROL : c_int = 6;
4643             pub const _SC_SAVED_IDS : c_int = 7;
4644             pub const _SC_VERSION : c_int = 8;
4645             pub const _SC_BC_BASE_MAX : c_int = 9;
4646             pub const _SC_BC_DIM_MAX : c_int = 10;
4647             pub const _SC_BC_SCALE_MAX : c_int = 11;
4648             pub const _SC_BC_STRING_MAX : c_int = 12;
4649             pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
4650             pub const _SC_EXPR_NEST_MAX : c_int = 14;
4651             pub const _SC_LINE_MAX : c_int = 15;
4652             pub const _SC_RE_DUP_MAX : c_int = 16;
4653             pub const _SC_2_VERSION : c_int = 17;
4654             pub const _SC_2_C_BIND : c_int = 18;
4655             pub const _SC_2_C_DEV : c_int = 19;
4656             pub const _SC_2_CHAR_TERM : c_int = 20;
4657             pub const _SC_2_FORT_DEV : c_int = 21;
4658             pub const _SC_2_FORT_RUN : c_int = 22;
4659             pub const _SC_2_LOCALEDEF : c_int = 23;
4660             pub const _SC_2_SW_DEV : c_int = 24;
4661             pub const _SC_2_UPE : c_int = 25;
4662             pub const _SC_STREAM_MAX : c_int = 26;
4663             pub const _SC_TZNAME_MAX : c_int = 27;
4664             pub const _SC_ASYNCHRONOUS_IO : c_int = 28;
4665             pub const _SC_PAGESIZE : c_int = 29;
4666             pub const _SC_MEMLOCK : c_int = 30;
4667             pub const _SC_MEMLOCK_RANGE : c_int = 31;
4668             pub const _SC_MEMORY_PROTECTION : c_int = 32;
4669             pub const _SC_MESSAGE_PASSING : c_int = 33;
4670             pub const _SC_PRIORITIZED_IO : c_int = 34;
4671             pub const _SC_PRIORITY_SCHEDULING : c_int = 35;
4672             pub const _SC_REALTIME_SIGNALS : c_int = 36;
4673             pub const _SC_SEMAPHORES : c_int = 37;
4674             pub const _SC_FSYNC : c_int = 38;
4675             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
4676             pub const _SC_SYNCHRONIZED_IO : c_int = 40;
4677             pub const _SC_TIMERS : c_int = 41;
4678             pub const _SC_AIO_LISTIO_MAX : c_int = 42;
4679             pub const _SC_AIO_MAX : c_int = 43;
4680             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
4681             pub const _SC_DELAYTIMER_MAX : c_int = 45;
4682             pub const _SC_MQ_OPEN_MAX : c_int = 46;
4683             pub const _SC_MAPPED_FILES : c_int = 47;
4684             pub const _SC_RTSIG_MAX : c_int = 48;
4685             pub const _SC_SEM_NSEMS_MAX : c_int = 49;
4686             pub const _SC_SEM_VALUE_MAX : c_int = 50;
4687             pub const _SC_SIGQUEUE_MAX : c_int = 51;
4688             pub const _SC_TIMER_MAX : c_int = 52;
4689             pub const _SC_XBS5_ILP32_OFF32 : c_int = 122;
4690             pub const _SC_XBS5_ILP32_OFFBIG : c_int = 123;
4691             pub const _SC_XBS5_LP64_OFF64 : c_int = 124;
4692             pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 125;
4693         }
4694     }
4695 }
4696
4697
4698 pub mod funcs {
4699     // Thankfully most of c95 is universally available and does not vary by OS
4700     // or anything. The same is not true of POSIX.
4701
4702     pub mod c95 {
4703         pub mod ctype {
4704             use types::os::arch::c95::{c_char, c_int};
4705
4706             extern {
4707                 pub fn isalnum(c: c_int) -> c_int;
4708                 pub fn isalpha(c: c_int) -> c_int;
4709                 pub fn iscntrl(c: c_int) -> c_int;
4710                 pub fn isdigit(c: c_int) -> c_int;
4711                 pub fn isgraph(c: c_int) -> c_int;
4712                 pub fn islower(c: c_int) -> c_int;
4713                 pub fn isprint(c: c_int) -> c_int;
4714                 pub fn ispunct(c: c_int) -> c_int;
4715                 pub fn isspace(c: c_int) -> c_int;
4716                 pub fn isupper(c: c_int) -> c_int;
4717                 pub fn isxdigit(c: c_int) -> c_int;
4718                 pub fn tolower(c: c_char) -> c_char;
4719                 pub fn toupper(c: c_char) -> c_char;
4720             }
4721         }
4722
4723         pub mod stdio {
4724             use types::common::c95::{FILE, c_void, fpos_t};
4725             use types::os::arch::c95::{c_char, c_int, c_long, size_t};
4726
4727             extern {
4728                 pub fn fopen(filename: *const c_char,
4729                              mode: *const c_char) -> *mut FILE;
4730                 pub fn freopen(filename: *const c_char, mode: *const c_char,
4731                                file: *mut FILE)
4732                                -> *mut FILE;
4733                 pub fn fflush(file: *mut FILE) -> c_int;
4734                 pub fn fclose(file: *mut FILE) -> c_int;
4735                 pub fn remove(filename: *const c_char) -> c_int;
4736                 pub fn rename(oldname: *const c_char,
4737                               newname: *const c_char) -> c_int;
4738                 pub fn tmpfile() -> *mut FILE;
4739                 pub fn setvbuf(stream: *mut FILE,
4740                                buffer: *mut c_char,
4741                                mode: c_int,
4742                                size: size_t)
4743                                -> c_int;
4744                 pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
4745                 // Omitted: printf and scanf variants.
4746                 pub fn fgetc(stream: *mut FILE) -> c_int;
4747                 pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
4748                              -> *mut c_char;
4749                 pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
4750                 pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int;
4751                 // Omitted: getc, getchar (might be macros).
4752
4753                 // Omitted: gets, so ridiculously unsafe that it should not
4754                 // survive.
4755
4756                 // Omitted: putc, putchar (might be macros).
4757                 pub fn puts(s: *const c_char) -> c_int;
4758                 pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
4759                 pub fn fread(ptr: *mut c_void,
4760                              size: size_t,
4761                              nobj: size_t,
4762                              stream: *mut FILE)
4763                              -> size_t;
4764                 pub fn fwrite(ptr: *const c_void,
4765                               size: size_t,
4766                               nobj: size_t,
4767                               stream: *mut FILE)
4768                               -> size_t;
4769                 pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int)
4770                              -> c_int;
4771                 pub fn ftell(stream: *mut FILE) -> c_long;
4772                 pub fn rewind(stream: *mut FILE);
4773                 pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
4774                 pub fn fsetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
4775                 pub fn feof(stream: *mut FILE) -> c_int;
4776                 pub fn ferror(stream: *mut FILE) -> c_int;
4777                 pub fn perror(s: *const c_char);
4778             }
4779         }
4780
4781         pub mod stdlib {
4782             use types::common::c95::c_void;
4783             use types::os::arch::c95::{c_char, c_double, c_int};
4784             use types::os::arch::c95::{c_long, c_uint, c_ulong};
4785             use types::os::arch::c95::{size_t};
4786
4787             extern {
4788                 pub fn abs(i: c_int) -> c_int;
4789                 pub fn labs(i: c_long) -> c_long;
4790                 // Omitted: div, ldiv (return pub type incomplete).
4791                 pub fn atof(s: *const c_char) -> c_double;
4792                 pub fn atoi(s: *const c_char) -> c_int;
4793                 pub fn strtod(s: *const c_char,
4794                               endp: *mut *mut c_char) -> c_double;
4795                 pub fn strtol(s: *const c_char,
4796                               endp: *mut *mut c_char, base: c_int) -> c_long;
4797                 pub fn strtoul(s: *const c_char, endp: *mut *mut c_char,
4798                                base: c_int) -> c_ulong;
4799                 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
4800                 pub fn malloc(size: size_t) -> *mut c_void;
4801                 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
4802                 pub fn free(p: *mut c_void);
4803
4804                 /// Exits the running program in a possibly dangerous manner.
4805                 ///
4806                 /// # Unsafety
4807                 ///
4808                 /// While this forces your program to exit, it does so in a way that has
4809                 /// consequences. This will skip all unwinding code, which means that anything
4810                 /// relying on unwinding for cleanup (such as flushing and closing a buffer to a
4811                 /// file) may act in an unexpected way.
4812                 ///
4813                 /// # Examples
4814                 ///
4815                 /// ```no_run
4816                 /// extern crate libc;
4817                 ///
4818                 /// fn main() {
4819                 ///     unsafe {
4820                 ///         libc::exit(1);
4821                 ///     }
4822                 /// }
4823                 /// ```
4824                 pub fn exit(status: c_int) -> !;
4825                 pub fn _exit(status: c_int) -> !;
4826                 pub fn atexit(cb: extern fn()) -> c_int;
4827                 pub fn system(s: *const c_char) -> c_int;
4828                 pub fn getenv(s: *const c_char) -> *mut c_char;
4829                 // Omitted: bsearch, qsort
4830                 pub fn rand() -> c_int;
4831                 pub fn srand(seed: c_uint);
4832             }
4833         }
4834
4835         pub mod string {
4836             use types::common::c95::c_void;
4837             use types::os::arch::c95::{c_char, c_int, size_t};
4838             use types::os::arch::c95::{wchar_t};
4839
4840             extern {
4841                 pub fn strcpy(dst: *mut c_char,
4842                               src: *const c_char) -> *mut c_char;
4843                 pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t)
4844                                -> *mut c_char;
4845                 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
4846                 pub fn strncat(s: *mut c_char, ct: *const c_char,
4847                                n: size_t) -> *mut c_char;
4848                 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
4849                 pub fn strncmp(cs: *const c_char, ct: *const c_char,
4850                                n: size_t) -> c_int;
4851                 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
4852                 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
4853                 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
4854                 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
4855                 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
4856                 pub fn strpbrk(cs: *const c_char,
4857                                ct: *const c_char) -> *mut c_char;
4858                 pub fn strstr(cs: *const c_char,
4859                               ct: *const c_char) -> *mut c_char;
4860                 pub fn strlen(cs: *const c_char) -> size_t;
4861                 pub fn strerror(n: c_int) -> *mut c_char;
4862                 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
4863                 pub fn strxfrm(s: *mut c_char, ct: *const c_char,
4864                                n: size_t) -> size_t;
4865                 pub fn wcslen(buf: *const wchar_t) -> size_t;
4866
4867                 // Omitted: memcpy, memmove, memset (provided by LLVM)
4868
4869                 // These are fine to execute on the Rust stack. They must be,
4870                 // in fact, because LLVM generates calls to them!
4871                 pub fn memcmp(cx: *const c_void, ct: *const c_void,
4872                               n: size_t) -> c_int;
4873                 pub fn memchr(cx: *const c_void, c: c_int,
4874                               n: size_t) -> *mut c_void;
4875             }
4876         }
4877     }
4878
4879     // Microsoft helpfully underscore-qualifies all of its POSIX-like symbols
4880     // to make sure you don't use them accidentally. It also randomly deviates
4881     // from the exact signatures you might otherwise expect, and omits much,
4882     // so be careful when trying to write portable code; it won't always work
4883     // with the same POSIX functions and types as other platforms.
4884
4885     #[cfg(target_os = "windows")]
4886     pub mod posix88 {
4887         pub mod stat_ {
4888             use types::os::common::posix01::{stat, utimbuf};
4889             use types::os::arch::c95::{c_int, c_char, wchar_t};
4890
4891             extern {
4892                 #[link_name = "_chmod"]
4893                 pub fn chmod(path: *const c_char, mode: c_int) -> c_int;
4894                 #[link_name = "_wchmod"]
4895                 pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int;
4896                 #[link_name = "_mkdir"]
4897                 pub fn mkdir(path: *const c_char) -> c_int;
4898                 #[link_name = "_wrmdir"]
4899                 pub fn wrmdir(path: *const wchar_t) -> c_int;
4900                 #[link_name = "_fstat64"]
4901                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
4902                 #[link_name = "_stat64"]
4903                 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
4904                 #[link_name = "_wstat64"]
4905                 pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int;
4906                 #[link_name = "_wutime64"]
4907                 pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int;
4908             }
4909         }
4910
4911         pub mod stdio {
4912             use types::common::c95::FILE;
4913             use types::os::arch::c95::{c_int, c_char};
4914
4915             extern {
4916                 #[link_name = "_popen"]
4917                 pub fn popen(command: *const c_char,
4918                              mode: *const c_char) -> *mut FILE;
4919                 #[link_name = "_pclose"]
4920                 pub fn pclose(stream: *mut FILE) -> c_int;
4921                 #[link_name = "_fdopen"]
4922                 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE;
4923                 #[link_name = "_fileno"]
4924                 pub fn fileno(stream: *mut FILE) -> c_int;
4925             }
4926         }
4927
4928         pub mod fcntl {
4929             use types::os::arch::c95::{c_int, c_char, wchar_t};
4930             extern {
4931                 #[link_name = "_open"]
4932                 pub fn open(path: *const c_char, oflag: c_int, mode: c_int)
4933                             -> c_int;
4934                 #[link_name = "_wopen"]
4935                 pub fn wopen(path: *const wchar_t, oflag: c_int, mode: c_int)
4936                             -> c_int;
4937                 #[link_name = "_creat"]
4938                 pub fn creat(path: *const c_char, mode: c_int) -> c_int;
4939             }
4940         }
4941
4942         pub mod dirent {
4943             // Not supplied at all.
4944         }
4945
4946         pub mod unistd {
4947             use types::common::c95::c_void;
4948             use types::os::arch::c95::{c_int, c_uint, c_char,
4949                                              c_long, size_t};
4950             use types::os::arch::c99::intptr_t;
4951
4952             extern {
4953                 #[link_name = "_access"]
4954                 pub fn access(path: *const c_char, amode: c_int) -> c_int;
4955                 #[link_name = "_chdir"]
4956                 pub fn chdir(dir: *const c_char) -> c_int;
4957                 #[link_name = "_close"]
4958                 pub fn close(fd: c_int) -> c_int;
4959                 #[link_name = "_dup"]
4960                 pub fn dup(fd: c_int) -> c_int;
4961                 #[link_name = "_dup2"]
4962                 pub fn dup2(src: c_int, dst: c_int) -> c_int;
4963                 #[link_name = "_execv"]
4964                 pub fn execv(prog: *const c_char,
4965                              argv: *mut *const c_char) -> intptr_t;
4966                 #[link_name = "_execve"]
4967                 pub fn execve(prog: *const c_char, argv: *mut *const c_char,
4968                               envp: *mut *const c_char)
4969                               -> c_int;
4970                 #[link_name = "_execvp"]
4971                 pub fn execvp(c: *const c_char,
4972                               argv: *mut *const c_char) -> c_int;
4973                 #[link_name = "_execvpe"]
4974                 pub fn execvpe(c: *const c_char, argv: *mut *const c_char,
4975                                envp: *mut *const c_char) -> c_int;
4976                 #[link_name = "_getcwd"]
4977                 pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
4978                 #[link_name = "_getpid"]
4979                 pub fn getpid() -> c_int;
4980                 #[link_name = "_isatty"]
4981                 pub fn isatty(fd: c_int) -> c_int;
4982                 #[link_name = "_lseek"]
4983                 pub fn lseek(fd: c_int, offset: c_long, origin: c_int)
4984                              -> c_long;
4985                 #[link_name = "_pipe"]
4986                 pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int)
4987                             -> c_int;
4988                 #[link_name = "_read"]
4989                 pub fn read(fd: c_int, buf: *mut c_void, count: c_uint)
4990                             -> c_int;
4991                 #[link_name = "_rmdir"]
4992                 pub fn rmdir(path: *const c_char) -> c_int;
4993                 #[link_name = "_unlink"]
4994                 pub fn unlink(c: *const c_char) -> c_int;
4995                 #[link_name = "_write"]
4996                 pub fn write(fd: c_int, buf: *const c_void,
4997                              count: c_uint) -> c_int;
4998             }
4999         }
5000
5001         pub mod mman {
5002         }
5003     }
5004
5005     #[cfg(any(target_os = "linux",
5006               target_os = "android",
5007               target_os = "macos",
5008               target_os = "ios",
5009               target_os = "freebsd",
5010               target_os = "dragonfly",
5011               target_os = "bitrig",
5012               target_os = "openbsd"))]
5013     pub mod posix88 {
5014         pub mod stat_ {
5015             use types::os::arch::c95::{c_char, c_int};
5016             use types::os::arch::posix01::stat;
5017             use types::os::arch::posix88::mode_t;
5018
5019             extern {
5020                 pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
5021                 pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
5022
5023                 #[cfg(any(target_os = "linux",
5024                           target_os = "freebsd",
5025                           target_os = "dragonfly",
5026                           target_os = "bitrig",
5027                           target_os = "openbsd",
5028                           target_os = "android",
5029                           target_os = "ios"))]
5030                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
5031
5032                 #[cfg(target_os = "macos")]
5033                 #[link_name = "fstat64"]
5034                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
5035
5036                 pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
5037                 pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
5038
5039                 #[cfg(any(target_os = "linux",
5040                           target_os = "freebsd",
5041                           target_os = "dragonfly",
5042                           target_os = "bitrig",
5043                           target_os = "openbsd",
5044                           target_os = "android",
5045                           target_os = "ios"))]
5046                 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
5047
5048                 #[cfg(target_os = "macos")]
5049                 #[link_name = "stat64"]
5050                 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
5051             }
5052         }
5053
5054         pub mod stdio {
5055             use types::common::c95::FILE;
5056             use types::os::arch::c95::{c_char, c_int};
5057
5058             extern {
5059                 pub fn popen(command: *const c_char,
5060                              mode: *const c_char) -> *mut FILE;
5061                 pub fn pclose(stream: *mut FILE) -> c_int;
5062                 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE;
5063                 pub fn fileno(stream: *mut FILE) -> c_int;
5064             }
5065         }
5066
5067         pub mod fcntl {
5068             use types::os::arch::c95::{c_char, c_int};
5069             use types::os::arch::posix88::mode_t;
5070
5071             extern {
5072                 pub fn open(path: *const c_char, oflag: c_int, mode: mode_t)
5073                             -> c_int;
5074                 pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
5075                 pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
5076             }
5077         }
5078
5079         pub mod dirent {
5080             use types::common::posix88::{DIR, dirent_t};
5081             use types::os::arch::c95::{c_char, c_int, c_long};
5082
5083             // NB: On OS X opendir and readdir have two versions,
5084             // one for 32-bit kernelspace and one for 64.
5085             // We should be linking to the 64-bit ones, called
5086             // opendir$INODE64, etc. but for some reason rustc
5087             // doesn't link it correctly on i686, so we're going
5088             // through a C function that mysteriously does work.
5089
5090             extern {
5091                 #[link_name="rust_opendir"]
5092                 pub fn opendir(dirname: *const c_char) -> *mut DIR;
5093                 #[link_name="rust_readdir_r"]
5094                 pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent_t,
5095                                   result: *mut *mut dirent_t) -> c_int;
5096             }
5097
5098             extern {
5099                 pub fn closedir(dirp: *mut DIR) -> c_int;
5100                 pub fn rewinddir(dirp: *mut DIR);
5101                 pub fn seekdir(dirp: *mut DIR, loc: c_long);
5102                 pub fn telldir(dirp: *mut DIR) -> c_long;
5103             }
5104         }
5105
5106         pub mod unistd {
5107             use types::common::c95::c_void;
5108             use types::os::arch::c95::{c_char, c_int, c_long, c_uint};
5109             use types::os::arch::c95::{size_t};
5110             use types::os::common::posix01::timespec;
5111             use types::os::arch::posix01::utimbuf;
5112             use types::os::arch::posix88::{gid_t, off_t, pid_t};
5113             use types::os::arch::posix88::{ssize_t, uid_t};
5114
5115             pub const _PC_NAME_MAX: c_int = 4;
5116
5117             extern {
5118                 pub fn access(path: *const c_char, amode: c_int) -> c_int;
5119                 pub fn alarm(seconds: c_uint) -> c_uint;
5120                 pub fn chdir(dir: *const c_char) -> c_int;
5121                 pub fn chown(path: *const c_char, uid: uid_t,
5122                              gid: gid_t) -> c_int;
5123                 pub fn close(fd: c_int) -> c_int;
5124                 pub fn dup(fd: c_int) -> c_int;
5125                 pub fn dup2(src: c_int, dst: c_int) -> c_int;
5126                 pub fn execv(prog: *const c_char,
5127                              argv: *mut *const c_char) -> c_int;
5128                 pub fn execve(prog: *const c_char, argv: *mut *const c_char,
5129                               envp: *mut *const c_char)
5130                               -> c_int;
5131                 pub fn execvp(c: *const c_char,
5132                               argv: *mut *const c_char) -> c_int;
5133                 pub fn fork() -> pid_t;
5134                 pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
5135                 pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
5136                 pub fn getegid() -> gid_t;
5137                 pub fn geteuid() -> uid_t;
5138                 pub fn getgid() -> gid_t ;
5139                 pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t)
5140                                  -> c_int;
5141                 pub fn getlogin() -> *mut c_char;
5142                 pub fn getopt(argc: c_int, argv: *mut *const c_char,
5143                               optstr: *const c_char) -> c_int;
5144                 pub fn getpgrp() -> pid_t;
5145                 pub fn getpid() -> pid_t;
5146                 pub fn getppid() -> pid_t;
5147                 pub fn getuid() -> uid_t;
5148                 pub fn getsid(pid: pid_t) -> pid_t;
5149                 pub fn isatty(fd: c_int) -> c_int;
5150                 pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
5151                 pub fn lseek(fd: c_int, offset: off_t, whence: c_int)
5152                              -> off_t;
5153                 pub fn pathconf(path: *mut c_char, name: c_int) -> c_long;
5154                 pub fn pause() -> c_int;
5155                 pub fn pipe(fds: *mut c_int) -> c_int;
5156                 pub fn read(fd: c_int, buf: *mut c_void, count: size_t)
5157                             -> ssize_t;
5158                 pub fn rmdir(path: *const c_char) -> c_int;
5159                 pub fn setgid(gid: gid_t) -> c_int;
5160                 pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
5161                 pub fn setsid() -> pid_t;
5162                 pub fn setuid(uid: uid_t) -> c_int;
5163                 pub fn sleep(secs: c_uint) -> c_uint;
5164                 pub fn usleep(secs: c_uint) -> c_int;
5165                 pub fn nanosleep(rqtp: *const timespec,
5166                                  rmtp: *mut timespec) -> c_int;
5167                 pub fn sysconf(name: c_int) -> c_long;
5168                 pub fn tcgetpgrp(fd: c_int) -> pid_t;
5169                 pub fn ttyname(fd: c_int) -> *mut c_char;
5170                 pub fn unlink(c: *const c_char) -> c_int;
5171                 pub fn write(fd: c_int, buf: *const c_void, count: size_t)
5172                              -> ssize_t;
5173                 pub fn pread(fd: c_int, buf: *mut c_void, count: size_t,
5174                              offset: off_t) -> ssize_t;
5175                 pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t,
5176                               offset: off_t) -> ssize_t;
5177                 pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int;
5178             }
5179         }
5180
5181         pub mod signal {
5182             use types::os::arch::c95::{c_int};
5183             use types::os::arch::posix88::{pid_t};
5184
5185             extern {
5186                 pub fn kill(pid: pid_t, sig: c_int) -> c_int;
5187             }
5188         }
5189
5190         pub mod mman {
5191             use types::common::c95::{c_void};
5192             use types::os::arch::c95::{size_t, c_int, c_char};
5193             use types::os::arch::posix88::{mode_t, off_t};
5194
5195             extern {
5196                 pub fn mlock(addr: *const c_void, len: size_t) -> c_int;
5197                 pub fn munlock(addr: *const c_void, len: size_t) -> c_int;
5198                 pub fn mlockall(flags: c_int) -> c_int;
5199                 pub fn munlockall() -> c_int;
5200
5201                 pub fn mmap(addr: *mut c_void,
5202                             len: size_t,
5203                             prot: c_int,
5204                             flags: c_int,
5205                             fd: c_int,
5206                             offset: off_t)
5207                             -> *mut c_void;
5208                 pub fn munmap(addr: *mut c_void, len: size_t) -> c_int;
5209
5210                 pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int)
5211                                 -> c_int;
5212
5213                 pub fn msync(addr: *mut c_void, len: size_t, flags: c_int)
5214                              -> c_int;
5215                 pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t)
5216                                 -> c_int;
5217                 pub fn shm_unlink(name: *const c_char) -> c_int;
5218             }
5219         }
5220
5221         pub mod net {
5222             use types::os::arch::c95::{c_char, c_uint};
5223
5224             extern {
5225                 pub fn if_nametoindex(ifname: *const c_char) -> c_uint;
5226             }
5227         }
5228
5229     }
5230
5231     #[cfg(any(target_os = "linux",
5232               target_os = "android",
5233               target_os = "macos",
5234               target_os = "ios",
5235               target_os = "freebsd",
5236               target_os = "dragonfly",
5237               target_os = "bitrig",
5238               target_os = "openbsd"))]
5239     pub mod posix01 {
5240         pub mod stat_ {
5241             use types::os::arch::c95::{c_char, c_int};
5242             use types::os::arch::posix01::stat;
5243
5244             extern {
5245                 #[cfg(any(target_os = "linux",
5246                           target_os = "freebsd",
5247                           target_os = "dragonfly",
5248                           target_os = "bitrig",
5249                           target_os = "openbsd",
5250                           target_os = "android",
5251                           target_os = "ios"))]
5252                 pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
5253
5254                 #[cfg(target_os = "macos")]
5255                 #[link_name = "lstat64"]
5256                 pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
5257             }
5258         }
5259
5260         pub mod unistd {
5261             use types::os::arch::c95::{c_char, c_int, size_t};
5262             use types::os::arch::posix88::{ssize_t, off_t};
5263
5264             extern {
5265                 pub fn readlink(path: *const c_char,
5266                                 buf: *mut c_char,
5267                                 bufsz: size_t)
5268                                 -> ssize_t;
5269
5270                 pub fn fsync(fd: c_int) -> c_int;
5271
5272                 #[cfg(any(target_os = "linux", target_os = "android"))]
5273                 pub fn fdatasync(fd: c_int) -> c_int;
5274
5275                 pub fn setenv(name: *const c_char, val: *const c_char,
5276                               overwrite: c_int) -> c_int;
5277                 pub fn unsetenv(name: *const c_char) -> c_int;
5278                 pub fn putenv(string: *mut c_char) -> c_int;
5279
5280                 pub fn symlink(path1: *const c_char,
5281                                path2: *const c_char) -> c_int;
5282
5283                 pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
5284             }
5285         }
5286
5287         pub mod signal {
5288             use types::os::arch::c95::c_int;
5289             use types::os::common::posix01::sighandler_t;
5290
5291             #[cfg(not(all(target_os = "android", target_arch = "arm")))]
5292             extern {
5293                 pub fn signal(signum: c_int,
5294                               handler: sighandler_t) -> sighandler_t;
5295             }
5296
5297             #[cfg(all(target_os = "android", target_arch = "arm"))]
5298             extern {
5299                 #[link_name = "bsd_signal"]
5300                 pub fn signal(signum: c_int,
5301                               handler: sighandler_t) -> sighandler_t;
5302             }
5303         }
5304
5305         pub mod glob {
5306             use types::os::arch::c95::{c_char, c_int};
5307             use types::os::common::posix01::{glob_t};
5308
5309             extern {
5310                 pub fn glob(pattern: *const c_char,
5311                             flags: c_int,
5312                             errfunc: ::core::option::Option<extern "C" fn(epath: *const c_char,
5313                                                               errno: c_int) -> c_int>,
5314                             pglob: *mut glob_t);
5315                 pub fn globfree(pglob: *mut glob_t);
5316             }
5317         }
5318
5319         pub mod mman {
5320             use types::common::c95::{c_void};
5321             use types::os::arch::c95::{c_int, size_t};
5322
5323             extern {
5324                 pub fn posix_madvise(addr: *mut c_void,
5325                                      len: size_t,
5326                                      advice: c_int)
5327                                      -> c_int;
5328             }
5329         }
5330     }
5331
5332     #[cfg(target_os = "windows")]
5333     pub mod posix01 {
5334         pub mod stat_ {
5335         }
5336
5337         pub mod unistd {
5338         }
5339
5340         pub mod glob {
5341         }
5342
5343         pub mod mman {
5344         }
5345
5346         pub mod net {
5347         }
5348     }
5349
5350
5351     #[cfg(any(target_os = "windows",
5352               target_os = "linux",
5353               target_os = "android",
5354               target_os = "macos",
5355               target_os = "ios",
5356               target_os = "freebsd",
5357               target_os = "dragonfly",
5358               target_os = "bitrig",
5359               target_os = "openbsd"))]
5360     pub mod posix08 {
5361         pub mod unistd {
5362         }
5363     }
5364
5365     #[cfg(not(windows))]
5366     pub mod bsd43 {
5367         use types::common::c95::{c_void};
5368         use types::os::common::bsd44::{socklen_t, sockaddr, ifaddrs};
5369         use types::os::arch::c95::{c_int, size_t};
5370         use types::os::arch::posix88::ssize_t;
5371
5372         extern "system" {
5373             pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
5374             pub fn connect(socket: c_int, address: *const sockaddr,
5375                            len: socklen_t) -> c_int;
5376             pub fn bind(socket: c_int, address: *const sockaddr,
5377                         address_len: socklen_t) -> c_int;
5378             pub fn listen(socket: c_int, backlog: c_int) -> c_int;
5379             pub fn accept(socket: c_int, address: *mut sockaddr,
5380                           address_len: *mut socklen_t) -> c_int;
5381             pub fn getpeername(socket: c_int, address: *mut sockaddr,
5382                                address_len: *mut socklen_t) -> c_int;
5383             pub fn getsockname(socket: c_int, address: *mut sockaddr,
5384                                address_len: *mut socklen_t) -> c_int;
5385             pub fn setsockopt(socket: c_int, level: c_int, name: c_int,
5386                               value: *const c_void,
5387                               option_len: socklen_t) -> c_int;
5388             pub fn recv(socket: c_int, buf: *mut c_void, len: size_t,
5389                         flags: c_int) -> ssize_t;
5390             pub fn send(socket: c_int, buf: *const c_void, len: size_t,
5391                         flags: c_int) -> ssize_t;
5392             pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t,
5393                             flags: c_int, addr: *mut sockaddr,
5394                             addrlen: *mut socklen_t) -> ssize_t;
5395             pub fn sendto(socket: c_int, buf: *const c_void, len: size_t,
5396                           flags: c_int, addr: *const sockaddr,
5397                           addrlen: socklen_t) -> ssize_t;
5398             pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int;
5399             pub fn freeifaddrs(ifa: *mut ifaddrs);
5400             pub fn shutdown(socket: c_int, how: c_int) -> c_int;
5401         }
5402     }
5403
5404     #[cfg(windows)]
5405     pub mod bsd43 {
5406         use types::common::c95::{c_void};
5407         use types::os::common::bsd44::{socklen_t, sockaddr, SOCKET};
5408         use types::os::arch::c95::c_int;
5409         use types::os::arch::posix88::ssize_t;
5410
5411         extern "system" {
5412             pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET;
5413             pub fn connect(socket: SOCKET, address: *const sockaddr,
5414                            len: socklen_t) -> c_int;
5415             pub fn bind(socket: SOCKET, address: *const sockaddr,
5416                         address_len: socklen_t) -> c_int;
5417             pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
5418             pub fn accept(socket: SOCKET, address: *mut sockaddr,
5419                           address_len: *mut socklen_t) -> SOCKET;
5420             pub fn getpeername(socket: SOCKET, address: *mut sockaddr,
5421                                address_len: *mut socklen_t) -> c_int;
5422             pub fn getsockname(socket: SOCKET, address: *mut sockaddr,
5423                                address_len: *mut socklen_t) -> c_int;
5424             pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int,
5425                               value: *const c_void,
5426                               option_len: socklen_t) -> c_int;
5427             pub fn closesocket(socket: SOCKET) -> c_int;
5428             pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
5429                         flags: c_int) -> c_int;
5430             pub fn send(socket: SOCKET, buf: *const c_void, len: c_int,
5431                         flags: c_int) -> c_int;
5432             pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int,
5433                             flags: c_int, addr: *mut sockaddr,
5434                             addrlen: *mut c_int) -> ssize_t;
5435             pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int,
5436                           flags: c_int, addr: *const sockaddr,
5437                           addrlen: c_int) -> c_int;
5438             pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
5439         }
5440     }
5441
5442     #[cfg(any(target_os = "macos",
5443               target_os = "ios",
5444               target_os = "freebsd",
5445               target_os = "dragonfly",
5446               target_os = "bitrig",
5447               target_os = "openbsd"))]
5448     pub mod bsd44 {
5449         use types::common::c95::{c_void};
5450         use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t};
5451
5452         extern {
5453             pub fn ioctl(d: c_int, request: c_ulong, ...) -> c_int;
5454             pub fn sysctl(name: *mut c_int,
5455                           namelen: c_uint,
5456                           oldp: *mut c_void,
5457                           oldlenp: *mut size_t,
5458                           newp: *mut c_void,
5459                           newlen: size_t)
5460                           -> c_int;
5461             pub fn sysctlbyname(name: *const c_char,
5462                                 oldp: *mut c_void,
5463                                 oldlenp: *mut size_t,
5464                                 newp: *mut c_void,
5465                                 newlen: size_t)
5466                                 -> c_int;
5467             pub fn sysctlnametomib(name: *const c_char,
5468                                    mibp: *mut c_int,
5469                                    sizep: *mut size_t)
5470                                    -> c_int;
5471             pub fn getdtablesize() -> c_int;
5472             pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)
5473                            -> c_int;
5474             pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
5475                            -> c_int;
5476             pub fn realpath(pathname: *const c_char, resolved: *mut c_char)
5477                             -> *mut c_char;
5478         }
5479     }
5480
5481     #[cfg(any(target_os = "linux", target_os = "android"))]
5482     pub mod bsd44 {
5483         use types::common::c95::{c_void};
5484         use types::os::arch::c95::{c_uchar, c_int, size_t};
5485
5486         extern {
5487             #[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
5488             pub fn getdtablesize() -> c_int;
5489             pub fn ioctl(d: c_int, request: c_int, ...) -> c_int;
5490             pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)
5491                            -> c_int;
5492             pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
5493                            -> c_int;
5494         }
5495     }
5496
5497
5498     #[cfg(target_os = "windows")]
5499     pub mod bsd44 {
5500     }
5501
5502     #[cfg(any(target_os = "macos", target_os = "ios"))]
5503     pub mod extra {
5504         use types::os::arch::c95::{c_char, c_int};
5505
5506         extern {
5507             pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
5508                                         -> c_int;
5509         }
5510     }
5511
5512     #[cfg(any(target_os = "freebsd",
5513               target_os = "dragonfly",
5514               target_os = "bitrig",
5515               target_os = "openbsd"))]
5516     pub mod extra {
5517     }
5518
5519     #[cfg(any(target_os = "linux", target_os = "android"))]
5520     pub mod extra {
5521     }
5522
5523
5524     #[cfg(target_os = "windows")]
5525     pub mod extra {
5526
5527         pub mod kernel32 {
5528             use types::os::arch::c95::{c_uint};
5529             use types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE,
5530                                                LPCWSTR, LPWSTR,
5531                                                LPWCH, LPDWORD, LPVOID,
5532                                                LPCVOID, LPOVERLAPPED,
5533                                                LPSECURITY_ATTRIBUTES,
5534                                                LPSTARTUPINFO,
5535                                                LPPROCESS_INFORMATION,
5536                                                LPMEMORY_BASIC_INFORMATION,
5537                                                LPSYSTEM_INFO, HANDLE, LPHANDLE,
5538                                                LARGE_INTEGER, PLARGE_INTEGER,
5539                                                LPFILETIME, LPWIN32_FIND_DATAW};
5540
5541             extern "system" {
5542                 pub fn GetEnvironmentVariableW(n: LPCWSTR,
5543                                                v: LPWSTR,
5544                                                nsize: DWORD)
5545                                                -> DWORD;
5546                 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
5547                                                -> BOOL;
5548                 pub fn GetEnvironmentStringsW() -> LPWCH;
5549                 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
5550                 pub fn GetModuleFileNameW(hModule: HMODULE,
5551                                           lpFilename: LPWSTR,
5552                                           nSize: DWORD)
5553                                           -> DWORD;
5554                 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
5555                                         lpSecurityAttributes:
5556                                         LPSECURITY_ATTRIBUTES)
5557                                         -> BOOL;
5558                 pub fn CopyFileW(lpExistingFileName: LPCWSTR,
5559                                  lpNewFileName: LPCWSTR,
5560                                  bFailIfExists: BOOL)
5561                                  -> BOOL;
5562                 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
5563                 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
5564                 pub fn GetCurrentDirectoryW(nBufferLength: DWORD,
5565                                             lpBuffer: LPWSTR)
5566                                             -> DWORD;
5567                 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
5568                 pub fn GetLastError() -> DWORD;
5569                 pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW)
5570                                       -> HANDLE;
5571                 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
5572                                      -> BOOL;
5573                 pub fn FindClose(findFile: HANDLE) -> BOOL;
5574                 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
5575                                        hSourceHandle: HANDLE,
5576                                        hTargetProcessHandle: HANDLE,
5577                                        lpTargetHandle: LPHANDLE,
5578                                        dwDesiredAccess: DWORD,
5579                                        bInheritHandle: BOOL,
5580                                        dwOptions: DWORD)
5581                                        -> BOOL;
5582                 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
5583                 pub fn OpenProcess(dwDesiredAccess: DWORD,
5584                                    bInheritHandle: BOOL,
5585                                    dwProcessId: DWORD)
5586                                    -> HANDLE;
5587                 pub fn GetCurrentProcess() -> HANDLE;
5588                 pub fn CreateProcessW(lpApplicationName: LPCWSTR,
5589                                       lpCommandLine: LPWSTR,
5590                                       lpProcessAttributes:
5591                                       LPSECURITY_ATTRIBUTES,
5592                                       lpThreadAttributes:
5593                                       LPSECURITY_ATTRIBUTES,
5594                                       bInheritHandles: BOOL,
5595                                       dwCreationFlags: DWORD,
5596                                       lpEnvironment: LPVOID,
5597                                       lpCurrentDirectory: LPCWSTR,
5598                                       lpStartupInfo: LPSTARTUPINFO,
5599                                       lpProcessInformation:
5600                                       LPPROCESS_INFORMATION)
5601                                       -> BOOL;
5602                 pub fn WaitForSingleObject(hHandle: HANDLE,
5603                                            dwMilliseconds: DWORD)
5604                                            -> DWORD;
5605                 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint)
5606                                         -> BOOL;
5607                 pub fn GetExitCodeProcess(hProcess: HANDLE,
5608                                           lpExitCode: LPDWORD)
5609                                           -> BOOL;
5610                 pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO);
5611                 pub fn VirtualAlloc(lpAddress: LPVOID,
5612                                     dwSize: SIZE_T,
5613                                     flAllocationType: DWORD,
5614                                     flProtect: DWORD)
5615                                     -> LPVOID;
5616                 pub fn VirtualFree(lpAddress: LPVOID,
5617                                    dwSize: SIZE_T,
5618                                    dwFreeType: DWORD)
5619                                    -> BOOL;
5620                 pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL;
5621                 pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T)
5622                                      -> BOOL;
5623                 pub fn VirtualProtect(lpAddress: LPVOID,
5624                                       dwSize: SIZE_T,
5625                                       flNewProtect: DWORD,
5626                                       lpflOldProtect: LPDWORD)
5627                                       -> BOOL;
5628                 pub fn VirtualQuery(lpAddress: LPCVOID,
5629                                     lpBuffer: LPMEMORY_BASIC_INFORMATION,
5630                                     dwLength: SIZE_T)
5631                                     -> SIZE_T;
5632                 pub fn CreateFileMappingW(hFile: HANDLE,
5633                                           lpAttributes: LPSECURITY_ATTRIBUTES,
5634                                           flProtect: DWORD,
5635                                           dwMaximumSizeHigh: DWORD,
5636                                           dwMaximumSizeLow: DWORD,
5637                                           lpName: LPCWSTR)
5638                                           -> HANDLE;
5639                 pub fn MapViewOfFile(hFileMappingObject: HANDLE,
5640                                      dwDesiredAccess: DWORD,
5641                                      dwFileOffsetHigh: DWORD,
5642                                      dwFileOffsetLow: DWORD,
5643                                      dwNumberOfBytesToMap: SIZE_T)
5644                                      -> LPVOID;
5645                 pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL;
5646                 pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
5647                                    lpNewFileName: LPCWSTR,
5648                                    dwFlags: DWORD) -> BOOL;
5649                 pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
5650                                        lpTargetFileName: LPCWSTR,
5651                                        lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
5652                                         -> BOOL;
5653                 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
5654                 pub fn CreateFileW(lpFileName: LPCWSTR,
5655                                    dwDesiredAccess: DWORD,
5656                                    dwShareMode: DWORD,
5657                                    lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
5658                                    dwCreationDisposition: DWORD,
5659                                    dwFlagsAndAttributes: DWORD,
5660                                    hTemplateFile: HANDLE) -> HANDLE;
5661                 pub fn ReadFile(hFile: HANDLE,
5662                                 lpBuffer: LPVOID,
5663                                 nNumberOfBytesToRead: DWORD,
5664                                 lpNumberOfBytesRead: LPDWORD,
5665                                 lpOverlapped: LPOVERLAPPED) -> BOOL;
5666                 pub fn WriteFile(hFile: HANDLE,
5667                                  lpBuffer: LPVOID,
5668                                  nNumberOfBytesToRead: DWORD,
5669                                  lpNumberOfBytesRead: LPDWORD,
5670                                  lpOverlapped: LPOVERLAPPED) -> BOOL;
5671                 pub fn SetFilePointerEx(hFile: HANDLE,
5672                                         liDistanceToMove: LARGE_INTEGER,
5673                                         lpNewFilePointer: PLARGE_INTEGER,
5674                                         dwMoveMethod: DWORD) -> BOOL;
5675                 pub fn SetEndOfFile(hFile: HANDLE) -> BOOL;
5676
5677                 pub fn GetSystemTimeAsFileTime(
5678                             lpSystemTimeAsFileTime: LPFILETIME);
5679
5680                 pub fn QueryPerformanceFrequency(
5681                             lpFrequency: *mut LARGE_INTEGER) -> BOOL;
5682                 pub fn QueryPerformanceCounter(
5683                             lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL;
5684
5685                 pub fn GetCurrentProcessId() -> DWORD;
5686                 pub fn CreateNamedPipeW(
5687                             lpName: LPCWSTR,
5688                             dwOpenMode: DWORD,
5689                             dwPipeMode: DWORD,
5690                             nMaxInstances: DWORD,
5691                             nOutBufferSize: DWORD,
5692                             nInBufferSize: DWORD,
5693                             nDefaultTimeOut: DWORD,
5694                             lpSecurityAttributes: LPSECURITY_ATTRIBUTES
5695                             ) -> HANDLE;
5696                 pub fn ConnectNamedPipe(hNamedPipe: HANDLE,
5697                                         lpOverlapped: LPOVERLAPPED) -> BOOL;
5698                 pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR,
5699                                       nTimeOut: DWORD) -> BOOL;
5700                 pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE,
5701                                                lpMode: LPDWORD,
5702                                                lpMaxCollectionCount: LPDWORD,
5703                                                lpCollectDataTimeout: LPDWORD)
5704                                                             -> BOOL;
5705                 pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES,
5706                                     bManualReset: BOOL,
5707                                     bInitialState: BOOL,
5708                                     lpName: LPCWSTR) -> HANDLE;
5709                 pub fn GetOverlappedResult(hFile: HANDLE,
5710                                            lpOverlapped: LPOVERLAPPED,
5711                                            lpNumberOfBytesTransferred: LPDWORD,
5712                                            bWait: BOOL) -> BOOL;
5713                 pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL;
5714             }
5715         }
5716
5717         pub mod msvcrt {
5718             use types::os::arch::c95::{c_int, c_long};
5719             use types::os::arch::c99::intptr_t;
5720
5721             extern {
5722                 #[link_name = "_commit"]
5723                 pub fn commit(fd: c_int) -> c_int;
5724
5725                 #[link_name = "_get_osfhandle"]
5726                 pub fn get_osfhandle(fd: c_int) -> c_long;
5727
5728                 #[link_name = "_open_osfhandle"]
5729                 pub fn open_osfhandle(osfhandle: intptr_t,
5730                                       flags: c_int) -> c_int;
5731             }
5732         }
5733
5734         pub mod winsock {
5735             use types::os::arch::c95::{c_int, c_long, c_ulong};
5736             use types::os::common::bsd44::SOCKET;
5737
5738             extern "system" {
5739                 pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
5740             }
5741         }
5742     }
5743 }
5744
5745 #[doc(hidden)]
5746 pub fn issue_14344_workaround() {} // FIXME #14344 force linkage to happen correctly
5747
5748 #[test] fn work_on_windows() { } // FIXME #10872 needed for a happy windows