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