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