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