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