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