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