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