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