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