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