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