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