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