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