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