]> git.lizzy.rs Git - rust.git/blob - src/libstd/libc.rs
678704fe0983308ee45bd5a6afbc051f76834721
[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* Rustdoc does not indicate reexports currently. Also, because these
23 * definitions are platform-specific, some may not
24 * appear in the generated documentation.
25 *
26 * We consider the following specs reasonably normative with respect
27 * to interoperating with the C standard library (libc/msvcrt):
28 *
29 * * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995.
30 * * ISO 9899:1999 ('C99' or 'C9x').
31 * * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1').
32 * * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3').
33 * * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4').
34 *
35 * Note that any reference to the 1996 revision of POSIX, or any revs
36 * between 1990 (when '88 was approved at ISO) and 2001 (when the next
37 * actual revision-revision happened), are merely additions of other
38 * chapters (1b and 1c) outside the core interfaces.
39 *
40 * Despite having several names each, these are *reasonably* coherent
41 * point-in-time, list-of-definition sorts of specs. You can get each under a
42 * variety of names but will wind up with the same definition in each case.
43 *
44 * See standards(7) in linux-manpages for more details.
45 *
46 * Our interface to these libraries is complicated by the non-universality of
47 * conformance to any of them. About the only thing universally supported is
48 * the first (C95), beyond that definitions quickly become absent on various
49 * platforms.
50 *
51 * We therefore wind up dividing our module-space up (mostly for the sake of
52 * sanity while editing, filling-in-details and eliminating duplication) into
53 * definitions common-to-all (held in modules named c95, c99, posix88, posix01
54 * and posix08) and definitions that appear only on *some* platforms (named
55 * 'extra'). This would be things like significant OSX foundation kit, or
56 * win32 library kernel32.dll, or various fancy glibc, linux or BSD
57 * extensions.
58 *
59 * In addition to the per-platform 'extra' modules, we define a module of
60 * 'common BSD' libc routines that never quite made it into POSIX but show up
61 * in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the
62 * final one from Berkeley after the lawsuits died down and the CSRG
63 * dissolved.
64 */
65
66 #[allow(non_camel_case_types)];
67 #[allow(non_uppercase_statics)];
68 #[allow(missing_doc)];
69
70 // Initial glob-exports mean that all the contents of all the modules
71 // wind up exported, if you're interested in writing platform-specific code.
72
73 pub use libc::types::common::c95::*;
74 pub use libc::types::common::c99::*;
75 pub use libc::types::common::posix88::*;
76 pub use libc::types::common::posix01::*;
77 pub use libc::types::common::posix08::*;
78 pub use libc::types::common::bsd44::*;
79 pub use libc::types::os::common::posix01::*;
80 pub use libc::types::os::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
96 pub use libc::funcs::c95::ctype::*;
97 pub use libc::funcs::c95::stdio::*;
98 pub use libc::funcs::c95::stdlib::*;
99 pub use libc::funcs::c95::string::*;
100
101 pub use libc::funcs::posix88::stat_::*;
102 pub use libc::funcs::posix88::stdio::*;
103 pub use libc::funcs::posix88::fcntl::*;
104 pub use libc::funcs::posix88::dirent::*;
105 pub use libc::funcs::posix88::unistd::*;
106 pub use libc::funcs::posix88::mman::*;
107
108 pub use libc::funcs::posix01::stat_::*;
109 pub use libc::funcs::posix01::unistd::*;
110 pub use libc::funcs::posix01::glob::*;
111 pub use libc::funcs::posix01::mman::*;
112 pub use libc::funcs::posix08::unistd::*;
113
114 pub use libc::funcs::bsd44::*;
115 pub use libc::funcs::extra::*;
116
117 #[cfg(target_os = "win32")]
118 pub use libc::funcs::extra::kernel32::*;
119 #[cfg(target_os = "win32")]
120 pub use libc::funcs::extra::msvcrt::*;
121
122 // Explicit export lists for the intersection (provided here) mean that
123 // you can write more-platform-agnostic code if you stick to just these
124 // symbols.
125
126 pub use libc::types::common::c95::{FILE, c_void, fpos_t};
127 pub use libc::types::common::posix88::{DIR, dirent_t};
128 pub use libc::types::os::arch::c95::{c_char, c_double, c_float, c_int};
129 pub use libc::types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong};
130 pub use libc::types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t};
131 pub use libc::types::os::arch::c95::{size_t, time_t};
132 pub use libc::types::os::arch::c99::{c_longlong, c_ulonglong, intptr_t};
133 pub use libc::types::os::arch::c99::{uintptr_t};
134 pub use libc::types::os::arch::posix88::{dev_t, dirent_t, ino_t, mode_t};
135 pub use libc::types::os::arch::posix88::{off_t, pid_t, ssize_t};
136
137 pub use libc::consts::os::c95::{_IOFBF, _IOLBF, _IONBF, BUFSIZ, EOF};
138 pub use libc::consts::os::c95::{EXIT_FAILURE, EXIT_SUCCESS};
139 pub use libc::consts::os::c95::{FILENAME_MAX, FOPEN_MAX, L_tmpnam};
140 pub use libc::consts::os::c95::{RAND_MAX, SEEK_CUR, SEEK_END};
141 pub use libc::consts::os::c95::{SEEK_SET, TMP_MAX};
142 pub use libc::consts::os::posix88::{F_OK, O_APPEND, O_CREAT, O_EXCL};
143 pub use libc::consts::os::posix88::{O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
144 pub use libc::consts::os::posix88::{R_OK, S_IEXEC, S_IFBLK, S_IFCHR};
145 pub use libc::consts::os::posix88::{S_IFDIR, S_IFIFO, S_IFMT, S_IFREG};
146 pub use libc::consts::os::posix88::{S_IREAD, S_IRUSR, S_IRWXU, S_IWUSR};
147 pub use libc::consts::os::posix88::{STDERR_FILENO, STDIN_FILENO};
148 pub use libc::consts::os::posix88::{STDOUT_FILENO, W_OK, X_OK};
149
150 pub use libc::funcs::c95::ctype::{isalnum, isalpha, iscntrl, isdigit};
151 pub use libc::funcs::c95::ctype::{islower, isprint, ispunct, isspace};
152 pub use libc::funcs::c95::ctype::{isupper, isxdigit, tolower, toupper};
153
154 pub use libc::funcs::c95::stdio::{fclose, feof, ferror, fflush, fgetc};
155 pub use libc::funcs::c95::stdio::{fgetpos, fgets, fopen, fputc, fputs};
156 pub use libc::funcs::c95::stdio::{fread, freopen, fseek, fsetpos, ftell};
157 pub use libc::funcs::c95::stdio::{fwrite, perror, puts, remove, rewind};
158 pub use libc::funcs::c95::stdio::{setbuf, setvbuf, tmpfile, ungetc};
159
160 pub use libc::funcs::c95::stdlib::{abort, abs, atof, atoi, calloc, exit};
161 pub use libc::funcs::c95::stdlib::{free, getenv, labs, malloc, rand};
162 pub use libc::funcs::c95::stdlib::{realloc, srand, strtod, strtol};
163 pub use libc::funcs::c95::stdlib::{strtoul, system};
164
165 pub use libc::funcs::c95::string::{memchr, memcmp};
166 pub use libc::funcs::c95::string::{strcat, strchr, strcmp};
167 pub use libc::funcs::c95::string::{strcoll, strcpy, strcspn, strerror};
168 pub use libc::funcs::c95::string::{strlen, strncat, strncmp, strncpy};
169 pub use libc::funcs::c95::string::{strpbrk, strrchr, strspn, strstr};
170 pub use libc::funcs::c95::string::{strtok, strxfrm};
171
172 pub use libc::funcs::posix88::fcntl::{open, creat};
173 pub use libc::funcs::posix88::stat_::{chmod, fstat, mkdir, stat};
174 pub use libc::funcs::posix88::stdio::{fdopen, fileno, pclose, popen};
175 pub use libc::funcs::posix88::unistd::{access, chdir, close, dup, dup2};
176 pub use libc::funcs::posix88::unistd::{execv, execve, execvp, getcwd};
177 pub use libc::funcs::posix88::unistd::{getpid, isatty, lseek, pipe, read};
178 pub use libc::funcs::posix88::unistd::{rmdir, unlink, write};
179
180
181 pub mod types {
182
183     // Types tend to vary *per architecture* so we pull their definitions out
184     // into this module.
185
186     // Standard types that are opaque or common, so are not per-target.
187     pub mod common {
188         pub mod c95 {
189             /**
190             Type used to construct void pointers for use with C.
191
192             This type is only useful as a pointer target. Do not use it as a
193             return type for FFI functions which have the `void` return type in
194             C. Use the unit type `()` or omit the return type instead.
195             */
196             pub enum c_void {}
197             pub enum FILE {}
198             pub enum fpos_t {}
199         }
200         pub mod c99 {
201             pub type int8_t = i8;
202             pub type int16_t = i16;
203             pub type int32_t = i32;
204             pub type int64_t = i64;
205             pub type uint8_t = u8;
206             pub type uint16_t = u16;
207             pub type uint32_t = u32;
208             pub type uint64_t = u64;
209         }
210         pub mod posix88 {
211             pub enum DIR {}
212             pub enum dirent_t {}
213         }
214         pub mod posix01 {}
215         pub mod posix08 {}
216         pub mod bsd44 {}
217     }
218
219     // Standard types that are scalar but vary by OS and arch.
220
221     #[cfg(target_os = "linux")]
222     #[cfg(target_os = "android")]
223     pub mod os {
224         pub mod common {
225             pub mod posix01 {
226                 use libc::types::common::c95::{c_void};
227                 use libc::types::os::arch::c95::{c_char, size_t};
228                 pub struct glob_t {
229                     gl_pathc: size_t,
230                     gl_pathv: **c_char,
231                     gl_offs:  size_t,
232
233                     __unused1: *c_void,
234                     __unused2: *c_void,
235                     __unused3: *c_void,
236                     __unused4: *c_void,
237                     __unused5: *c_void,
238                 }
239             }
240         }
241
242         #[cfg(target_arch = "x86")]
243         #[cfg(target_arch = "arm")]
244         #[cfg(target_arch = "mips")]
245         pub mod arch {
246             pub mod c95 {
247                 pub type c_char = i8;
248                 pub type c_schar = i8;
249                 pub type c_uchar = u8;
250                 pub type c_short = i16;
251                 pub type c_ushort = u16;
252                 pub type c_int = i32;
253                 pub type c_uint = u32;
254                 pub type c_long = i32;
255                 pub type c_ulong = u32;
256                 pub type c_float = f32;
257                 pub type c_double = f64;
258                 pub type size_t = u32;
259                 pub type ptrdiff_t = i32;
260                 pub type clock_t = i32;
261                 pub type time_t = i32;
262                 pub type wchar_t = i32;
263             }
264             pub mod c99 {
265                 pub type c_longlong = i64;
266                 pub type c_ulonglong = u64;
267                 pub type intptr_t = int;
268                 pub type uintptr_t = uint;
269             }
270             #[cfg(target_arch = "x86")]
271             #[cfg(target_arch = "mips")]
272             pub mod posix88 {
273                 pub type off_t = i32;
274                 pub type dev_t = u64;
275                 pub type ino_t = u32;
276                 pub type pid_t = i32;
277                 pub type uid_t = u32;
278                 pub type gid_t = u32;
279                 pub type useconds_t = u32;
280                 pub type mode_t = u32;
281                 pub type ssize_t = i32;
282             }
283             #[cfg(target_arch = "arm")]
284             pub mod posix88 {
285                 pub type off_t = i32;
286                 pub type dev_t = u32;
287                 pub type ino_t = u32;
288                 pub type pid_t = i32;
289                 pub type uid_t = u32;
290                 pub type gid_t = u32;
291                 pub type useconds_t = u32;
292                 pub type mode_t = u16;
293                 pub type ssize_t = i32;
294             }
295             #[cfg(target_arch = "x86")]
296             #[cfg(target_arch = "mips")]
297             pub mod posix01 {
298                 use libc::types::os::arch::c95::{c_short, c_long, time_t};
299                 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
300                 use libc::types::os::arch::posix88::{mode_t, off_t};
301                 use libc::types::os::arch::posix88::{uid_t};
302
303                 pub type nlink_t = u32;
304                 pub type blksize_t = i32;
305                 pub type blkcnt_t = i32;
306
307                 #[cfg(target_arch = "x86")]
308                 pub struct stat {
309                     st_dev: dev_t,
310                     __pad1: c_short,
311                     st_ino: ino_t,
312                     st_mode: mode_t,
313                     st_nlink: nlink_t,
314                     st_uid: uid_t,
315                     st_gid: gid_t,
316                     st_rdev: dev_t,
317                     __pad2: c_short,
318                     st_size: off_t,
319                     st_blksize: blksize_t,
320                     st_blocks: blkcnt_t,
321                     st_atime: time_t,
322                     st_atime_nsec: c_long,
323                     st_mtime: time_t,
324                     st_mtime_nsec: c_long,
325                     st_ctime: time_t,
326                     st_ctime_nsec: c_long,
327                     __unused4: c_long,
328                     __unused5: c_long,
329                 }
330
331                 #[cfg(target_arch = "mips")]
332                 pub struct stat {
333                     st_dev: c_ulong,
334                     st_pad1: [c_long, ..3],
335                     st_ino: ino_t,
336                     st_mode: mode_t,
337                     st_nlink: nlink_t,
338                     st_uid: uid_t,
339                     st_gid: gid_t,
340                     st_rdev: c_ulong,
341                     st_pad2: [c_long, ..2],
342                     st_size: off_t,
343                     st_pad3: c_long,
344                     st_atime: time_t,
345                     st_atime_nsec: c_long,
346                     st_mtime: time_t,
347                     st_mtime_nsec: c_long,
348                     st_ctime: time_t,
349                     st_ctime_nsec: c_long,
350                     st_blksize: blksize_t,
351                     st_blocks: blkcnt_t,
352                     st_pad5: [c_long, ..14],
353                 }
354             }
355             #[cfg(target_arch = "arm")]
356             pub mod posix01 {
357                 use libc::types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t};
358                 use libc::types::os::arch::c99::{c_longlong, c_ulonglong};
359                 use libc::types::os::arch::posix88::{uid_t, gid_t, ino_t};
360
361                 pub type nlink_t = u16;
362                 pub type blksize_t = u32;
363                 pub type blkcnt_t = u32;
364
365                 pub struct stat {
366                     st_dev: c_ulonglong,
367                     __pad0: [c_uchar, ..4],
368                     __st_ino: ino_t,
369                     st_mode: c_uint,
370                     st_nlink: c_uint,
371                     st_uid: uid_t,
372                     st_gid: gid_t,
373                     st_rdev: c_ulonglong,
374                     __pad3: [c_uchar, ..4],
375                     st_size: c_longlong,
376                     st_blksize: blksize_t,
377                     st_blocks: c_ulonglong,
378                     st_atime: time_t,
379                     st_atime_nsec: c_ulong,
380                     st_mtime: time_t,
381                     st_mtime_nsec: c_ulong,
382                     st_ctime: time_t,
383                     st_ctime_nsec: c_ulong,
384                     st_ino: c_ulonglong
385                 }
386             }
387             pub mod posix08 {}
388             pub mod bsd44 {}
389             pub mod extra {}
390         }
391
392         #[cfg(target_arch = "x86_64")]
393         pub mod arch {
394             pub mod c95 {
395                 pub type c_char = i8;
396                 pub type c_schar = i8;
397                 pub type c_uchar = u8;
398                 pub type c_short = i16;
399                 pub type c_ushort = u16;
400                 pub type c_int = i32;
401                 pub type c_uint = u32;
402                 pub type c_long = i64;
403                 pub type c_ulong = u64;
404                 pub type c_float = f32;
405                 pub type c_double = f64;
406                 pub type size_t = u64;
407                 pub type ptrdiff_t = i64;
408                 pub type clock_t = i64;
409                 pub type time_t = i64;
410                 pub type wchar_t = i32;
411             }
412             pub mod c99 {
413                 pub type c_longlong = i64;
414                 pub type c_ulonglong = u64;
415                 pub type intptr_t = int;
416                 pub type uintptr_t = uint;
417             }
418             pub mod posix88 {
419                 pub type off_t = i64;
420                 pub type dev_t = u64;
421                 pub type ino_t = u64;
422                 pub type pid_t = i32;
423                 pub type uid_t = u32;
424                 pub type gid_t = u32;
425                 pub type useconds_t = u32;
426                 pub type mode_t = u32;
427                 pub type ssize_t = i64;
428             }
429             pub mod posix01 {
430                 use libc::types::os::arch::c95::{c_int, c_long, time_t};
431                 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
432                 use libc::types::os::arch::posix88::{mode_t, off_t};
433                 use libc::types::os::arch::posix88::{uid_t};
434
435                 pub type nlink_t = u64;
436                 pub type blksize_t = i64;
437                 pub type blkcnt_t = i64;
438                 pub struct stat {
439                     st_dev: dev_t,
440                     st_ino: ino_t,
441                     st_nlink: nlink_t,
442                     st_mode: mode_t,
443                     st_uid: uid_t,
444                     st_gid: gid_t,
445                     __pad0: c_int,
446                     st_rdev: dev_t,
447                     st_size: off_t,
448                     st_blksize: blksize_t,
449                     st_blocks: blkcnt_t,
450                     st_atime: time_t,
451                     st_atime_nsec: c_long,
452                     st_mtime: time_t,
453                     st_mtime_nsec: c_long,
454                     st_ctime: time_t,
455                     st_ctime_nsec: c_long,
456                     __unused: [c_long, ..3],
457                 }
458             }
459             pub mod posix08 {
460             }
461             pub mod bsd44 {
462             }
463             pub mod extra {
464             }
465         }
466     }
467
468     #[cfg(target_os = "freebsd")]
469     pub mod os {
470         pub mod common {
471             pub mod posix01 {
472                 use libc::types::common::c95::{c_void};
473                 use libc::types::os::arch::c95::{c_char, c_int, size_t};
474                 pub struct glob_t {
475                     gl_pathc:  size_t,
476                     __unused1: size_t,
477                     gl_offs:   size_t,
478                     __unused2: c_int,
479                     gl_pathv:  **c_char,
480
481                     __unused3: *c_void,
482
483                     __unused4: *c_void,
484                     __unused5: *c_void,
485                     __unused6: *c_void,
486                     __unused7: *c_void,
487                     __unused8: *c_void,
488                 }
489             }
490         }
491
492         #[cfg(target_arch = "x86_64")]
493         pub mod arch {
494             pub mod c95 {
495                 pub type c_char = i8;
496                 pub type c_schar = i8;
497                 pub type c_uchar = u8;
498                 pub type c_short = i16;
499                 pub type c_ushort = u16;
500                 pub type c_int = i32;
501                 pub type c_uint = u32;
502                 pub type c_long = i64;
503                 pub type c_ulong = u64;
504                 pub type c_float = f32;
505                 pub type c_double = f64;
506                 pub type size_t = u64;
507                 pub type ptrdiff_t = i64;
508                 pub type clock_t = i32;
509                 pub type time_t = i64;
510                 pub type wchar_t = i32;
511             }
512             pub mod c99 {
513                 pub type c_longlong = i64;
514                 pub type c_ulonglong = u64;
515                 pub type intptr_t = int;
516                 pub type uintptr_t = uint;
517             }
518             pub mod posix88 {
519                 pub type off_t = i64;
520                 pub type dev_t = u32;
521                 pub type ino_t = u32;
522                 pub type pid_t = i32;
523                 pub type uid_t = u32;
524                 pub type gid_t = u32;
525                 pub type useconds_t = u32;
526                 pub type mode_t = u16;
527                 pub type ssize_t = i64;
528             }
529             pub mod posix01 {
530                 use libc::types::common::c99::{uint8_t, uint32_t, int32_t};
531                 use libc::types::os::arch::c95::{c_long, time_t};
532                 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
533                 use libc::types::os::arch::posix88::{mode_t, off_t};
534                 use libc::types::os::arch::posix88::{uid_t};
535
536                 pub type nlink_t = u16;
537                 pub type blksize_t = i64;
538                 pub type blkcnt_t = i64;
539                 pub type fflags_t = u32;
540                 pub struct stat {
541                     st_dev: dev_t,
542                     st_ino: ino_t,
543                     st_mode: mode_t,
544                     st_nlink: nlink_t,
545                     st_uid: uid_t,
546                     st_gid: gid_t,
547                     st_rdev: dev_t,
548                     st_atime: time_t,
549                     st_atime_nsec: c_long,
550                     st_mtime: time_t,
551                     st_mtime_nsec: c_long,
552                     st_ctime: time_t,
553                     st_ctime_nsec: c_long,
554                     st_size: off_t,
555                     st_blocks: blkcnt_t,
556                     st_blksize: blksize_t,
557                     st_flags: fflags_t,
558                     st_gen: uint32_t,
559                     st_lspare: int32_t,
560                     st_birthtime: time_t,
561                     st_birthtime_nsec: c_long,
562                     __unused: [uint8_t, ..2],
563                 }
564             }
565             pub mod posix08 {
566             }
567             pub mod bsd44 {
568             }
569             pub mod extra {
570             }
571         }
572     }
573
574     #[cfg(target_os = "win32")]
575     pub mod os {
576         pub mod common {
577             pub mod posix01 {
578                 use libc::types::os::arch::c95::c_short;
579                 use libc::types::os::arch::extra::{int64, time64_t};
580                 use libc::types::os::arch::posix88::{dev_t, ino_t};
581                 use libc::types::os::arch::posix88::mode_t;
582
583                 // Note: this is the struct called stat64 in win32. Not stat,
584                 // nor stati64.
585                 pub struct stat {
586                     st_dev: dev_t,
587                     st_ino: ino_t,
588                     st_mode: mode_t,
589                     st_nlink: c_short,
590                     st_uid: c_short,
591                     st_gid: c_short,
592                     st_rdev: dev_t,
593                     st_size: int64,
594                     st_atime: time64_t,
595                     st_mtime: time64_t,
596                     st_ctime: time64_t,
597                 }
598             }
599         }
600
601         #[cfg(target_arch = "x86")]
602         pub mod arch {
603             pub mod c95 {
604                 pub type c_char = i8;
605                 pub type c_schar = i8;
606                 pub type c_uchar = u8;
607                 pub type c_short = i16;
608                 pub type c_ushort = u16;
609                 pub type c_int = i32;
610                 pub type c_uint = u32;
611                 pub type c_long = i32;
612                 pub type c_ulong = u32;
613                 pub type c_float = f32;
614                 pub type c_double = f64;
615                 pub type size_t = u32;
616                 pub type ptrdiff_t = i32;
617                 pub type clock_t = i32;
618                 pub type time_t = i32;
619                 pub type wchar_t = u16;
620             }
621             pub mod c99 {
622                 pub type c_longlong = i64;
623                 pub type c_ulonglong = u64;
624                 pub type intptr_t = int;
625                 pub type uintptr_t = uint;
626             }
627             pub mod posix88 {
628                 pub type off_t = i32;
629                 pub type dev_t = u32;
630                 pub type ino_t = i16;
631                 pub type pid_t = i32;
632                 pub type useconds_t = u32;
633                 pub type mode_t = u16;
634                 pub type ssize_t = i32;
635             }
636             pub mod posix01 {
637             }
638             pub mod posix08 {
639             }
640             pub mod bsd44 {
641             }
642             pub mod extra {
643                 use ptr;
644                 use libc::types::common::c95::c_void;
645                 use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
646                 use libc::types::os::arch::c95::{c_long, c_ulong};
647                 use libc::types::os::arch::c95::{wchar_t};
648                 use libc::types::os::arch::c99::{c_ulonglong};
649
650                 pub type BOOL = c_int;
651                 pub type BYTE = u8;
652                 pub type CCHAR = c_char;
653                 pub type CHAR = c_char;
654
655                 pub type DWORD = c_ulong;
656                 pub type DWORDLONG = c_ulonglong;
657
658                 pub type HANDLE = LPVOID;
659                 pub type HMODULE = c_uint;
660
661                 pub type LONG_PTR = c_long;
662
663                 pub type LPCWSTR = *WCHAR;
664                 pub type LPCSTR = *CHAR;
665                 pub type LPCTSTR = *CHAR;
666                 pub type LPTCH = *CHAR;
667
668                 pub type LPWSTR = *mut WCHAR;
669                 pub type LPSTR = *mut CHAR;
670                 pub type LPTSTR = *mut CHAR;
671
672                 // Not really, but opaque to us.
673                 pub type LPSECURITY_ATTRIBUTES = LPVOID;
674
675                 pub type LPVOID = *mut c_void;
676                 pub type LPCVOID = *c_void;
677                 pub type LPBYTE = *mut BYTE;
678                 pub type LPWORD = *mut WORD;
679                 pub type LPDWORD = *mut DWORD;
680                 pub type LPHANDLE = *mut HANDLE;
681
682                 pub type LRESULT = LONG_PTR;
683                 pub type PBOOL = *mut BOOL;
684                 pub type WCHAR = wchar_t;
685                 pub type WORD = u16;
686                 pub type SIZE_T = size_t;
687
688                 pub type time64_t = i64;
689                 pub type int64 = i64;
690
691                 pub struct STARTUPINFO {
692                     cb: DWORD,
693                     lpReserved: LPTSTR,
694                     lpDesktop: LPTSTR,
695                     lpTitle: LPTSTR,
696                     dwX: DWORD,
697                     dwY: DWORD,
698                     dwXSize: DWORD,
699                     dwYSize: DWORD,
700                     dwXCountChars: DWORD,
701                     dwYCountCharts: DWORD,
702                     dwFillAttribute: DWORD,
703                     dwFlags: DWORD,
704                     wShowWindow: WORD,
705                     cbReserved2: WORD,
706                     lpReserved2: LPBYTE,
707                     hStdInput: HANDLE,
708                     hStdOutput: HANDLE,
709                     hStdError: HANDLE
710                 }
711                 pub type LPSTARTUPINFO = *mut STARTUPINFO;
712
713                 pub struct PROCESS_INFORMATION {
714                     hProcess: HANDLE,
715                     hThread: HANDLE,
716                     dwProcessId: DWORD,
717                     dwThreadId: DWORD
718                 }
719                 pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
720
721                 pub struct SYSTEM_INFO {
722                     wProcessorArchitecture: WORD,
723                     wReserved: WORD,
724                     dwPageSize: DWORD,
725                     lpMinimumApplicationAddress: LPVOID,
726                     lpMaximumApplicationAddress: LPVOID,
727                     dwActiveProcessorMask: DWORD,
728                     dwNumberOfProcessors: DWORD,
729                     dwProcessorType: DWORD,
730                     dwAllocationGranularity: DWORD,
731                     wProcessorLevel: WORD,
732                     wProcessorRevision: WORD
733                 }
734                 pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
735
736                 impl SYSTEM_INFO {
737                     pub fn new() -> SYSTEM_INFO {
738                         SYSTEM_INFO {
739                             wProcessorArchitecture: 0,
740                             wReserved: 0,
741                             dwPageSize: 0,
742                             lpMinimumApplicationAddress: ptr::mut_null(),
743                             lpMaximumApplicationAddress: ptr::mut_null(),
744                             dwActiveProcessorMask: 0,
745                             dwNumberOfProcessors: 0,
746                             dwProcessorType: 0,
747                             dwAllocationGranularity: 0,
748                             wProcessorLevel: 0,
749                             wProcessorRevision: 0
750                         }
751                     }
752                 }
753
754                 pub struct MEMORY_BASIC_INFORMATION {
755                     BaseAddress: LPVOID,
756                     AllocationBase: LPVOID,
757                     AllocationProtect: DWORD,
758                     RegionSize: SIZE_T,
759                     State: DWORD,
760                     Protect: DWORD,
761                     Type: DWORD
762                 }
763                 pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
764             }
765         }
766     }
767
768     #[cfg(target_os = "macos")]
769     pub mod os {
770         pub mod common {
771             pub mod posix01 {
772                 use libc::types::common::c95::{c_void};
773                 use libc::types::os::arch::c95::{c_char, c_int, size_t};
774                 pub struct glob_t {
775                     gl_pathc:  size_t,
776                     __unused1: c_int,
777                     gl_offs:   size_t,
778                     __unused2: c_int,
779                     gl_pathv:  **c_char,
780
781                     __unused3: *c_void,
782
783                     __unused4: *c_void,
784                     __unused5: *c_void,
785                     __unused6: *c_void,
786                     __unused7: *c_void,
787                     __unused8: *c_void,
788                 }
789             }
790         }
791
792         #[cfg(target_arch = "x86")]
793         pub mod arch {
794             pub mod c95 {
795                 pub type c_char = i8;
796                 pub type c_schar = i8;
797                 pub type c_uchar = u8;
798                 pub type c_short = i16;
799                 pub type c_ushort = u16;
800                 pub type c_int = i32;
801                 pub type c_uint = u32;
802                 pub type c_long = i32;
803                 pub type c_ulong = u32;
804                 pub type c_float = f32;
805                 pub type c_double = f64;
806                 pub type size_t = u32;
807                 pub type ptrdiff_t = i32;
808                 pub type clock_t = u32;
809                 pub type time_t = i32;
810                 pub type wchar_t = i32;
811             }
812             pub mod c99 {
813                 pub type c_longlong = i64;
814                 pub type c_ulonglong = u64;
815                 pub type intptr_t = int;
816                 pub type uintptr_t = uint;
817             }
818             pub mod posix88 {
819                 pub type off_t = i64;
820                 pub type dev_t = i32;
821                 pub type ino_t = u64;
822                 pub type pid_t = i32;
823                 pub type uid_t = u32;
824                 pub type gid_t = u32;
825                 pub type useconds_t = u32;
826                 pub type mode_t = u16;
827                 pub type ssize_t = i32;
828             }
829             pub mod posix01 {
830                 use libc::types::common::c99::{int32_t, int64_t, uint32_t};
831                 use libc::types::os::arch::c95::{c_long, time_t};
832                 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t,
833                                                      mode_t, off_t, uid_t};
834
835                 pub type nlink_t = u16;
836                 pub type blksize_t = i64;
837                 pub type blkcnt_t = i32;
838
839                 pub struct stat {
840                     st_dev: dev_t,
841                     st_mode: mode_t,
842                     st_nlink: nlink_t,
843                     st_ino: ino_t,
844                     st_uid: uid_t,
845                     st_gid: gid_t,
846                     st_rdev: dev_t,
847                     st_atime: time_t,
848                     st_atime_nsec: c_long,
849                     st_mtime: time_t,
850                     st_mtime_nsec: c_long,
851                     st_ctime: time_t,
852                     st_ctime_nsec: c_long,
853                     st_birthtime: time_t,
854                     st_birthtime_nsec: c_long,
855                     st_size: off_t,
856                     st_blocks: blkcnt_t,
857                     st_blksize: blksize_t,
858                     st_flags: uint32_t,
859                     st_gen: uint32_t,
860                     st_lspare: int32_t,
861                     st_qspare: [int64_t, ..2],
862                 }
863             }
864             pub mod posix08 {
865             }
866             pub mod bsd44 {
867             }
868             pub mod extra {
869             }
870         }
871
872         #[cfg(target_arch = "x86_64")]
873         pub mod arch {
874             pub mod c95 {
875                 pub type c_char = i8;
876                 pub type c_schar = i8;
877                 pub type c_uchar = u8;
878                 pub type c_short = i16;
879                 pub type c_ushort = u16;
880                 pub type c_int = i32;
881                 pub type c_uint = u32;
882                 pub type c_long = i64;
883                 pub type c_ulong = u64;
884                 pub type c_float = f32;
885                 pub type c_double = f64;
886                 pub type size_t = u64;
887                 pub type ptrdiff_t = i64;
888                 pub type clock_t = u64;
889                 pub type time_t = i64;
890                 pub type wchar_t = i32;
891             }
892             pub mod c99 {
893                 pub type c_longlong = i64;
894                 pub type c_ulonglong = u64;
895                 pub type intptr_t = int;
896                 pub type uintptr_t = uint;
897             }
898             pub mod posix88 {
899                 pub type off_t = i64;
900                 pub type dev_t = i32;
901                 pub type ino_t = u64;
902                 pub type pid_t = i32;
903                 pub type uid_t = u32;
904                 pub type gid_t = u32;
905                 pub type useconds_t = u32;
906                 pub type mode_t = u16;
907                 pub type ssize_t = i64;
908             }
909             pub mod posix01 {
910                 use libc::types::common::c99::{int32_t, int64_t};
911                 use libc::types::common::c99::{uint32_t};
912                 use libc::types::os::arch::c95::{c_long, time_t};
913                 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
914                 use libc::types::os::arch::posix88::{mode_t, off_t, uid_t};
915
916                 pub type nlink_t = u16;
917                 pub type blksize_t = i64;
918                 pub type blkcnt_t = i32;
919
920                 pub struct stat {
921                     st_dev: dev_t,
922                     st_mode: mode_t,
923                     st_nlink: nlink_t,
924                     st_ino: ino_t,
925                     st_uid: uid_t,
926                     st_gid: gid_t,
927                     st_rdev: dev_t,
928                     st_atime: time_t,
929                     st_atime_nsec: c_long,
930                     st_mtime: time_t,
931                     st_mtime_nsec: c_long,
932                     st_ctime: time_t,
933                     st_ctime_nsec: c_long,
934                     st_birthtime: time_t,
935                     st_birthtime_nsec: c_long,
936                     st_size: off_t,
937                     st_blocks: blkcnt_t,
938                     st_blksize: blksize_t,
939                     st_flags: uint32_t,
940                     st_gen: uint32_t,
941                     st_lspare: int32_t,
942                     st_qspare: [int64_t, ..2],
943                 }
944             }
945             pub mod posix08 {
946             }
947             pub mod bsd44 {
948             }
949             pub mod extra {
950             }
951         }
952     }
953 }
954
955 pub mod consts {
956     // Consts tend to vary per OS so we pull their definitions out
957     // into this module.
958
959     #[cfg(target_os = "win32")]
960     pub mod os {
961         pub mod c95 {
962             use libc::types::os::arch::c95::{c_int, c_uint};
963
964             pub static EXIT_FAILURE : c_int = 1;
965             pub static EXIT_SUCCESS : c_int = 0;
966             pub static RAND_MAX : c_int = 32767;
967             pub static EOF : c_int = -1;
968             pub static SEEK_SET : c_int = 0;
969             pub static SEEK_CUR : c_int = 1;
970             pub static SEEK_END : c_int = 2;
971             pub static _IOFBF : c_int = 0;
972             pub static _IONBF : c_int = 4;
973             pub static _IOLBF : c_int = 64;
974             pub static BUFSIZ : c_uint = 512_u32;
975             pub static FOPEN_MAX : c_uint = 20_u32;
976             pub static FILENAME_MAX : c_uint = 260_u32;
977             pub static L_tmpnam : c_uint = 16_u32;
978             pub static TMP_MAX : c_uint = 32767_u32;
979         }
980         pub mod c99 {
981         }
982         pub mod posix88 {
983             use libc::types::os::arch::c95::c_int;
984
985             pub static O_RDONLY : c_int = 0;
986             pub static O_WRONLY : c_int = 1;
987             pub static O_RDWR : c_int = 2;
988             pub static O_APPEND : c_int = 8;
989             pub static O_CREAT : c_int = 256;
990             pub static O_EXCL : c_int = 1024;
991             pub static O_TRUNC : c_int = 512;
992             pub static S_IFIFO : c_int = 4096;
993             pub static S_IFCHR : c_int = 8192;
994             pub static S_IFBLK : c_int = 12288;
995             pub static S_IFDIR : c_int = 16384;
996             pub static S_IFREG : c_int = 32768;
997             pub static S_IFMT : c_int = 61440;
998             pub static S_IEXEC : c_int = 64;
999             pub static S_IWRITE : c_int = 128;
1000             pub static S_IREAD : c_int = 256;
1001             pub static S_IRWXU : c_int = 448;
1002             pub static S_IXUSR : c_int = 64;
1003             pub static S_IWUSR : c_int = 128;
1004             pub static S_IRUSR : c_int = 256;
1005             pub static F_OK : c_int = 0;
1006             pub static R_OK : c_int = 4;
1007             pub static W_OK : c_int = 2;
1008             pub static X_OK : c_int = 1;
1009             pub static STDIN_FILENO : c_int = 0;
1010             pub static STDOUT_FILENO : c_int = 1;
1011             pub static STDERR_FILENO : c_int = 2;
1012         }
1013         pub mod posix01 {
1014         }
1015         pub mod posix08 {
1016         }
1017         pub mod bsd44 {
1018         }
1019         pub mod extra {
1020             use libc::types::os::arch::c95::c_int;
1021             use libc::types::os::arch::extra::{WORD, DWORD, BOOL};
1022
1023             pub static TRUE : BOOL = 1;
1024             pub static FALSE : BOOL = 0;
1025
1026             pub static O_TEXT : c_int = 16384;
1027             pub static O_BINARY : c_int = 32768;
1028             pub static O_NOINHERIT: c_int = 128;
1029
1030             pub static ERROR_SUCCESS : c_int = 0;
1031             pub static ERROR_INVALID_HANDLE : c_int = 6;
1032             pub static ERROR_DISK_FULL : c_int = 112;
1033             pub static ERROR_INSUFFICIENT_BUFFER : c_int = 122;
1034             pub static ERROR_ALREADY_EXISTS : c_int = 183;
1035             pub static ERROR_INVALID_ADDRESS : c_int = 487;
1036             pub static ERROR_FILE_INVALID : c_int = 1006;
1037             pub static INVALID_HANDLE_VALUE: c_int = -1;
1038
1039             pub static DELETE : DWORD = 0x00010000;
1040             pub static READ_CONTROL : DWORD = 0x00020000;
1041             pub static SYNCHRONIZE : DWORD = 0x00100000;
1042             pub static WRITE_DAC : DWORD = 0x00040000;
1043             pub static WRITE_OWNER : DWORD = 0x00080000;
1044
1045             pub static PROCESS_CREATE_PROCESS : DWORD = 0x0080;
1046             pub static PROCESS_CREATE_THREAD : DWORD = 0x0002;
1047             pub static PROCESS_DUP_HANDLE : DWORD = 0x0040;
1048             pub static PROCESS_QUERY_INFORMATION : DWORD = 0x0400;
1049             pub static PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000;
1050             pub static PROCESS_SET_INFORMATION : DWORD = 0x0200;
1051             pub static PROCESS_SET_QUOTA : DWORD = 0x0100;
1052             pub static PROCESS_SUSPEND_RESUME : DWORD = 0x0800;
1053             pub static PROCESS_TERMINATE : DWORD = 0x0001;
1054             pub static PROCESS_VM_OPERATION : DWORD = 0x0008;
1055             pub static PROCESS_VM_READ : DWORD = 0x0010;
1056             pub static PROCESS_VM_WRITE : DWORD = 0x0020;
1057
1058             pub static STARTF_FORCEONFEEDBACK : DWORD = 0x00000040;
1059             pub static STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080;
1060             pub static STARTF_PREVENTPINNING : DWORD = 0x00002000;
1061             pub static STARTF_RUNFULLSCREEN : DWORD = 0x00000020;
1062             pub static STARTF_TITLEISAPPID : DWORD = 0x00001000;
1063             pub static STARTF_TITLEISLINKNAME : DWORD = 0x00000800;
1064             pub static STARTF_USECOUNTCHARS : DWORD = 0x00000008;
1065             pub static STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010;
1066             pub static STARTF_USEHOTKEY : DWORD = 0x00000200;
1067             pub static STARTF_USEPOSITION : DWORD = 0x00000004;
1068             pub static STARTF_USESHOWWINDOW : DWORD = 0x00000001;
1069             pub static STARTF_USESIZE : DWORD = 0x00000002;
1070             pub static STARTF_USESTDHANDLES : DWORD = 0x00000100;
1071
1072             pub static WAIT_ABANDONED : DWORD = 0x00000080;
1073             pub static WAIT_OBJECT_0 : DWORD = 0x00000000;
1074             pub static WAIT_TIMEOUT : DWORD = 0x00000102;
1075             pub static WAIT_FAILED : DWORD = -1;
1076
1077             pub static DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001;
1078             pub static DUPLICATE_SAME_ACCESS : DWORD = 0x00000002;
1079
1080             pub static INFINITE : DWORD = -1;
1081             pub static STILL_ACTIVE : DWORD = 259;
1082
1083             pub static MEM_COMMIT : DWORD = 0x00001000;
1084             pub static MEM_RESERVE : DWORD = 0x00002000;
1085             pub static MEM_DECOMMIT : DWORD = 0x00004000;
1086             pub static MEM_RELEASE : DWORD = 0x00008000;
1087             pub static MEM_RESET : DWORD = 0x00080000;
1088             pub static MEM_RESET_UNDO : DWORD = 0x1000000;
1089             pub static MEM_LARGE_PAGES : DWORD = 0x20000000;
1090             pub static MEM_PHYSICAL : DWORD = 0x00400000;
1091             pub static MEM_TOP_DOWN : DWORD = 0x00100000;
1092             pub static MEM_WRITE_WATCH : DWORD = 0x00200000;
1093
1094             pub static PAGE_EXECUTE : DWORD = 0x10;
1095             pub static PAGE_EXECUTE_READ : DWORD = 0x20;
1096             pub static PAGE_EXECUTE_READWRITE : DWORD = 0x40;
1097             pub static PAGE_EXECUTE_WRITECOPY : DWORD = 0x80;
1098             pub static PAGE_NOACCESS : DWORD = 0x01;
1099             pub static PAGE_READONLY : DWORD = 0x02;
1100             pub static PAGE_READWRITE : DWORD = 0x04;
1101             pub static PAGE_WRITECOPY : DWORD = 0x08;
1102             pub static PAGE_GUARD : DWORD = 0x100;
1103             pub static PAGE_NOCACHE : DWORD = 0x200;
1104             pub static PAGE_WRITECOMBINE : DWORD = 0x400;
1105
1106             pub static SEC_COMMIT : DWORD = 0x8000000;
1107             pub static SEC_IMAGE : DWORD = 0x1000000;
1108             pub static SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000;
1109             pub static SEC_LARGE_PAGES : DWORD = 0x80000000;
1110             pub static SEC_NOCACHE : DWORD = 0x10000000;
1111             pub static SEC_RESERVE : DWORD = 0x4000000;
1112             pub static SEC_WRITECOMBINE : DWORD = 0x40000000;
1113
1114             pub static FILE_MAP_ALL_ACCESS : DWORD = 0xf001f;
1115             pub static FILE_MAP_READ : DWORD = 0x4;
1116             pub static FILE_MAP_WRITE : DWORD = 0x2;
1117             pub static FILE_MAP_COPY : DWORD = 0x1;
1118             pub static FILE_MAP_EXECUTE : DWORD = 0x20;
1119
1120             pub static PROCESSOR_ARCHITECTURE_INTEL : WORD = 0;
1121             pub static PROCESSOR_ARCHITECTURE_ARM : WORD = 5;
1122             pub static PROCESSOR_ARCHITECTURE_IA64 : WORD = 6;
1123             pub static PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9;
1124             pub static PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff;
1125         }
1126     }
1127
1128
1129     #[cfg(target_os = "linux")]
1130     #[cfg(target_os = "android")]
1131     pub mod os {
1132         pub mod c95 {
1133             use libc::types::os::arch::c95::{c_int, c_uint};
1134
1135             pub static EXIT_FAILURE : c_int = 1;
1136             pub static EXIT_SUCCESS : c_int = 0;
1137             pub static RAND_MAX : c_int = 2147483647;
1138             pub static EOF : c_int = -1;
1139             pub static SEEK_SET : c_int = 0;
1140             pub static SEEK_CUR : c_int = 1;
1141             pub static SEEK_END : c_int = 2;
1142             pub static _IOFBF : c_int = 0;
1143             pub static _IONBF : c_int = 2;
1144             pub static _IOLBF : c_int = 1;
1145             pub static BUFSIZ : c_uint = 8192_u32;
1146             pub static FOPEN_MAX : c_uint = 16_u32;
1147             pub static FILENAME_MAX : c_uint = 4096_u32;
1148             pub static L_tmpnam : c_uint = 20_u32;
1149             pub static TMP_MAX : c_uint = 238328_u32;
1150         }
1151         pub mod c99 {
1152         }
1153         #[cfg(target_arch = "x86")]
1154         #[cfg(target_arch = "x86_64")]
1155         #[cfg(target_arch = "arm")]
1156         pub mod posix88 {
1157             use libc::types::os::arch::c95::c_int;
1158             use libc::types::common::c95::c_void;
1159
1160             pub static O_RDONLY : c_int = 0;
1161             pub static O_WRONLY : c_int = 1;
1162             pub static O_RDWR : c_int = 2;
1163             pub static O_APPEND : c_int = 1024;
1164             pub static O_CREAT : c_int = 64;
1165             pub static O_EXCL : c_int = 128;
1166             pub static O_TRUNC : c_int = 512;
1167             pub static S_IFIFO : c_int = 4096;
1168             pub static S_IFCHR : c_int = 8192;
1169             pub static S_IFBLK : c_int = 24576;
1170             pub static S_IFDIR : c_int = 16384;
1171             pub static S_IFREG : c_int = 32768;
1172             pub static S_IFMT : c_int = 61440;
1173             pub static S_IEXEC : c_int = 64;
1174             pub static S_IWRITE : c_int = 128;
1175             pub static S_IREAD : c_int = 256;
1176             pub static S_IRWXU : c_int = 448;
1177             pub static S_IXUSR : c_int = 64;
1178             pub static S_IWUSR : c_int = 128;
1179             pub static S_IRUSR : c_int = 256;
1180             pub static F_OK : c_int = 0;
1181             pub static R_OK : c_int = 4;
1182             pub static W_OK : c_int = 2;
1183             pub static X_OK : c_int = 1;
1184             pub static STDIN_FILENO : c_int = 0;
1185             pub static STDOUT_FILENO : c_int = 1;
1186             pub static STDERR_FILENO : c_int = 2;
1187             pub static F_LOCK : c_int = 1;
1188             pub static F_TEST : c_int = 3;
1189             pub static F_TLOCK : c_int = 2;
1190             pub static F_ULOCK : c_int = 0;
1191             pub static SIGHUP : c_int = 1;
1192             pub static SIGINT : c_int = 2;
1193             pub static SIGQUIT : c_int = 3;
1194             pub static SIGILL : c_int = 4;
1195             pub static SIGABRT : c_int = 6;
1196             pub static SIGFPE : c_int = 8;
1197             pub static SIGKILL : c_int = 9;
1198             pub static SIGSEGV : c_int = 11;
1199             pub static SIGPIPE : c_int = 13;
1200             pub static SIGALRM : c_int = 14;
1201             pub static SIGTERM : c_int = 15;
1202
1203             pub static PROT_NONE : c_int = 0;
1204             pub static PROT_READ : c_int = 1;
1205             pub static PROT_WRITE : c_int = 2;
1206             pub static PROT_EXEC : c_int = 4;
1207
1208             pub static MAP_FILE : c_int = 0x0000;
1209             pub static MAP_SHARED : c_int = 0x0001;
1210             pub static MAP_PRIVATE : c_int = 0x0002;
1211             pub static MAP_FIXED : c_int = 0x0010;
1212             pub static MAP_ANON : c_int = 0x0020;
1213
1214             pub static MAP_FAILED : *c_void = -1 as *c_void;
1215
1216             pub static MCL_CURRENT : c_int = 0x0001;
1217             pub static MCL_FUTURE : c_int = 0x0002;
1218
1219             pub static MS_ASYNC : c_int = 0x0001;
1220             pub static MS_INVALIDATE : c_int = 0x0002;
1221             pub static MS_SYNC : c_int = 0x0004;
1222
1223             pub static _SC_ARG_MAX : c_int = 0;
1224             pub static _SC_CHILD_MAX : c_int = 1;
1225             pub static _SC_CLK_TCK : c_int = 2;
1226             pub static _SC_NGROUPS_MAX : c_int = 3;
1227             pub static _SC_OPEN_MAX : c_int = 4;
1228             pub static _SC_STREAM_MAX : c_int = 5;
1229             pub static _SC_TZNAME_MAX : c_int = 6;
1230             pub static _SC_JOB_CONTROL : c_int = 7;
1231             pub static _SC_SAVED_IDS : c_int = 8;
1232             pub static _SC_REALTIME_SIGNALS : c_int = 9;
1233             pub static _SC_PRIORITY_SCHEDULING : c_int = 10;
1234             pub static _SC_TIMERS : c_int = 11;
1235             pub static _SC_ASYNCHRONOUS_IO : c_int = 12;
1236             pub static _SC_PRIORITIZED_IO : c_int = 13;
1237             pub static _SC_SYNCHRONIZED_IO : c_int = 14;
1238             pub static _SC_FSYNC : c_int = 15;
1239             pub static _SC_MAPPED_FILES : c_int = 16;
1240             pub static _SC_MEMLOCK : c_int = 17;
1241             pub static _SC_MEMLOCK_RANGE : c_int = 18;
1242             pub static _SC_MEMORY_PROTECTION : c_int = 19;
1243             pub static _SC_MESSAGE_PASSING : c_int = 20;
1244             pub static _SC_SEMAPHORES : c_int = 21;
1245             pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 22;
1246             pub static _SC_AIO_LISTIO_MAX : c_int = 23;
1247             pub static _SC_AIO_MAX : c_int = 24;
1248             pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 25;
1249             pub static _SC_DELAYTIMER_MAX : c_int = 26;
1250             pub static _SC_MQ_OPEN_MAX : c_int = 27;
1251             pub static _SC_VERSION : c_int = 29;
1252             pub static _SC_PAGESIZE : c_int = 30;
1253             pub static _SC_RTSIG_MAX : c_int = 31;
1254             pub static _SC_SEM_NSEMS_MAX : c_int = 32;
1255             pub static _SC_SEM_VALUE_MAX : c_int = 33;
1256             pub static _SC_SIGQUEUE_MAX : c_int = 34;
1257             pub static _SC_TIMER_MAX : c_int = 35;
1258             pub static _SC_BC_BASE_MAX : c_int = 36;
1259             pub static _SC_BC_DIM_MAX : c_int = 37;
1260             pub static _SC_BC_SCALE_MAX : c_int = 38;
1261             pub static _SC_BC_STRING_MAX : c_int = 39;
1262             pub static _SC_COLL_WEIGHTS_MAX : c_int = 40;
1263             pub static _SC_EXPR_NEST_MAX : c_int = 42;
1264             pub static _SC_LINE_MAX : c_int = 43;
1265             pub static _SC_RE_DUP_MAX : c_int = 44;
1266             pub static _SC_2_VERSION : c_int = 46;
1267             pub static _SC_2_C_BIND : c_int = 47;
1268             pub static _SC_2_C_DEV : c_int = 48;
1269             pub static _SC_2_FORT_DEV : c_int = 49;
1270             pub static _SC_2_FORT_RUN : c_int = 50;
1271             pub static _SC_2_SW_DEV : c_int = 51;
1272             pub static _SC_2_LOCALEDEF : c_int = 52;
1273             pub static _SC_2_CHAR_TERM : c_int = 95;
1274             pub static _SC_2_C_VERSION : c_int = 96;
1275             pub static _SC_2_UPE : c_int = 97;
1276             pub static _SC_XBS5_ILP32_OFF32 : c_int = 125;
1277             pub static _SC_XBS5_ILP32_OFFBIG : c_int = 126;
1278             pub static _SC_XBS5_LPBIG_OFFBIG : c_int = 128;
1279
1280             pub static EPERM : c_int = 1;
1281             pub static ENOENT : c_int = 2;
1282             pub static ESRCH : c_int = 3;
1283             pub static EINTR : c_int = 4;
1284             pub static EIO : c_int = 5;
1285             pub static ENXIO : c_int = 6;
1286             pub static E2BIG : c_int = 7;
1287             pub static ENOEXEC : c_int = 8;
1288             pub static EBADF : c_int = 9;
1289             pub static ECHILD : c_int = 10;
1290             pub static EAGAIN : c_int = 11;
1291             pub static ENOMEM : c_int = 12;
1292             pub static EACCES : c_int = 13;
1293             pub static EFAULT : c_int = 14;
1294             pub static ENOTBLK : c_int = 15;
1295             pub static EBUSY : c_int = 16;
1296             pub static EEXIST : c_int = 17;
1297             pub static EXDEV : c_int = 18;
1298             pub static ENODEV : c_int = 19;
1299             pub static ENOTDIR : c_int = 20;
1300             pub static EISDIR : c_int = 21;
1301             pub static EINVAL : c_int = 22;
1302             pub static ENFILE : c_int = 23;
1303             pub static EMFILE : c_int = 24;
1304             pub static ENOTTY : c_int = 25;
1305             pub static ETXTBSY : c_int = 26;
1306             pub static EFBIG : c_int = 27;
1307             pub static ENOSPC : c_int = 28;
1308             pub static ESPIPE : c_int = 29;
1309             pub static EROFS : c_int = 30;
1310             pub static EMLINK : c_int = 31;
1311             pub static EPIPE : c_int = 32;
1312             pub static EDOM : c_int = 33;
1313             pub static ERANGE : c_int = 34;
1314
1315             pub static EDEADLK: c_int = 35;
1316             pub static ENAMETOOLONG: c_int = 36;
1317             pub static ENOLCK: c_int = 37;
1318             pub static ENOSYS: c_int = 38;
1319             pub static ENOTEMPTY: c_int = 39;
1320             pub static ELOOP: c_int = 40;
1321             pub static EWOULDBLOCK: c_int = EAGAIN;
1322             pub static ENOMSG: c_int = 42;
1323             pub static EIDRM: c_int = 43;
1324             pub static ECHRNG: c_int = 44;
1325             pub static EL2NSYNC: c_int = 45;
1326             pub static EL3HLT: c_int = 46;
1327             pub static EL3RST: c_int = 47;
1328             pub static ELNRNG: c_int = 48;
1329             pub static EUNATCH: c_int = 49;
1330             pub static ENOCSI: c_int = 50;
1331             pub static EL2HLT: c_int = 51;
1332             pub static EBADE: c_int = 52;
1333             pub static EBADR: c_int = 53;
1334             pub static EXFULL: c_int = 54;
1335             pub static ENOANO: c_int = 55;
1336             pub static EBADRQC: c_int = 56;
1337             pub static EBADSLT: c_int = 57;
1338
1339             pub static EDEADLOCK: c_int = EDEADLK;
1340
1341             pub static EBFONT: c_int = 59;
1342             pub static ENOSTR: c_int = 60;
1343             pub static ENODATA: c_int = 61;
1344             pub static ETIME: c_int = 62;
1345             pub static ENOSR: c_int = 63;
1346             pub static ENONET: c_int = 64;
1347             pub static ENOPKG: c_int = 65;
1348             pub static EREMOTE: c_int = 66;
1349             pub static ENOLINK: c_int = 67;
1350             pub static EADV: c_int = 68;
1351             pub static ESRMNT: c_int = 69;
1352             pub static ECOMM: c_int = 70;
1353             pub static EPROTO: c_int = 71;
1354             pub static EMULTIHOP: c_int = 72;
1355             pub static EDOTDOT: c_int = 73;
1356             pub static EBADMSG: c_int = 74;
1357             pub static EOVERFLOW: c_int = 75;
1358             pub static ENOTUNIQ: c_int = 76;
1359             pub static EBADFD: c_int = 77;
1360             pub static EREMCHG: c_int = 78;
1361             pub static ELIBACC: c_int = 79;
1362             pub static ELIBBAD: c_int = 80;
1363             pub static ELIBSCN: c_int = 81;
1364             pub static ELIBMAX: c_int = 82;
1365             pub static ELIBEXEC: c_int = 83;
1366             pub static EILSEQ: c_int = 84;
1367             pub static ERESTART: c_int = 85;
1368             pub static ESTRPIPE: c_int = 86;
1369             pub static EUSERS: c_int = 87;
1370             pub static ENOTSOCK: c_int = 88;
1371             pub static EDESTADDRREQ: c_int = 89;
1372             pub static EMSGSIZE: c_int = 90;
1373             pub static EPROTOTYPE: c_int = 91;
1374             pub static ENOPROTOOPT: c_int = 92;
1375             pub static EPROTONOSUPPORT: c_int = 93;
1376             pub static ESOCKTNOSUPPORT: c_int = 94;
1377             pub static EOPNOTSUPP: c_int = 95;
1378             pub static EPFNOSUPPORT: c_int = 96;
1379             pub static EAFNOSUPPORT: c_int = 97;
1380             pub static EADDRINUSE: c_int = 98;
1381             pub static EADDRNOTAVAIL: c_int = 99;
1382             pub static ENETDOWN: c_int = 100;
1383             pub static ENETUNREACH: c_int = 101;
1384             pub static ENETRESET: c_int = 102;
1385             pub static ECONNABORTED: c_int = 103;
1386             pub static ECONNRESET: c_int = 104;
1387             pub static ENOBUFS: c_int = 105;
1388             pub static EISCONN: c_int = 106;
1389             pub static ENOTCONN: c_int = 107;
1390             pub static ESHUTDOWN: c_int = 108;
1391             pub static ETOOMANYREFS: c_int = 109;
1392             pub static ETIMEDOUT: c_int = 110;
1393             pub static ECONNREFUSED: c_int = 111;
1394             pub static EHOSTDOWN: c_int = 112;
1395             pub static EHOSTUNREACH: c_int = 113;
1396             pub static EALREADY: c_int = 114;
1397             pub static EINPROGRESS: c_int = 115;
1398             pub static ESTALE: c_int = 116;
1399             pub static EUCLEAN: c_int = 117;
1400             pub static ENOTNAM: c_int = 118;
1401             pub static ENAVAIL: c_int = 119;
1402             pub static EISNAM: c_int = 120;
1403             pub static EREMOTEIO: c_int = 121;
1404             pub static EDQUOT: c_int = 122;
1405
1406             pub static ENOMEDIUM: c_int = 123;
1407             pub static EMEDIUMTYPE: c_int = 124;
1408             pub static ECANCELED: c_int = 125;
1409             pub static ENOKEY: c_int = 126;
1410             pub static EKEYEXPIRED: c_int = 127;
1411             pub static EKEYREVOKED: c_int = 128;
1412             pub static EKEYREJECTED: c_int = 129;
1413
1414             pub static EOWNERDEAD: c_int = 130;
1415             pub static ENOTRECOVERABLE: c_int = 131;
1416
1417             pub static ERFKILL: c_int = 132;
1418
1419             pub static EHWPOISON: c_int = 133;
1420         }
1421
1422         #[cfg(target_arch = "mips")]
1423         pub mod posix88 {
1424             use libc::types::os::arch::c95::c_int;
1425             use libc::types::common::c95::c_void;
1426
1427             pub static O_RDONLY : c_int = 0;
1428             pub static O_WRONLY : c_int = 1;
1429             pub static O_RDWR : c_int = 2;
1430             pub static O_APPEND : c_int = 8;
1431             pub static O_CREAT : c_int = 256;
1432             pub static O_EXCL : c_int = 1024;
1433             pub static O_TRUNC : c_int = 512;
1434             pub static S_IFIFO : c_int = 4096;
1435             pub static S_IFCHR : c_int = 8192;
1436             pub static S_IFBLK : c_int = 24576;
1437             pub static S_IFDIR : c_int = 16384;
1438             pub static S_IFREG : c_int = 32768;
1439             pub static S_IFMT : c_int = 61440;
1440             pub static S_IEXEC : c_int = 64;
1441             pub static S_IWRITE : c_int = 128;
1442             pub static S_IREAD : c_int = 256;
1443             pub static S_IRWXU : c_int = 448;
1444             pub static S_IXUSR : c_int = 64;
1445             pub static S_IWUSR : c_int = 128;
1446             pub static S_IRUSR : c_int = 256;
1447             pub static F_OK : c_int = 0;
1448             pub static R_OK : c_int = 4;
1449             pub static W_OK : c_int = 2;
1450             pub static X_OK : c_int = 1;
1451             pub static STDIN_FILENO : c_int = 0;
1452             pub static STDOUT_FILENO : c_int = 1;
1453             pub static STDERR_FILENO : c_int = 2;
1454             pub static F_LOCK : c_int = 1;
1455             pub static F_TEST : c_int = 3;
1456             pub static F_TLOCK : c_int = 2;
1457             pub static F_ULOCK : c_int = 0;
1458             pub static SIGHUP : c_int = 1;
1459             pub static SIGINT : c_int = 2;
1460             pub static SIGQUIT : c_int = 3;
1461             pub static SIGILL : c_int = 4;
1462             pub static SIGABRT : c_int = 6;
1463             pub static SIGFPE : c_int = 8;
1464             pub static SIGKILL : c_int = 9;
1465             pub static SIGSEGV : c_int = 11;
1466             pub static SIGPIPE : c_int = 13;
1467             pub static SIGALRM : c_int = 14;
1468             pub static SIGTERM : c_int = 15;
1469
1470             pub static PROT_NONE : c_int = 0;
1471             pub static PROT_READ : c_int = 1;
1472             pub static PROT_WRITE : c_int = 2;
1473             pub static PROT_EXEC : c_int = 4;
1474
1475             pub static MAP_FILE : c_int = 0x0000;
1476             pub static MAP_SHARED : c_int = 0x0001;
1477             pub static MAP_PRIVATE : c_int = 0x0002;
1478             pub static MAP_FIXED : c_int = 0x0010;
1479             pub static MAP_ANON : c_int = 0x0020;
1480
1481             pub static MAP_FAILED : *c_void = -1 as *c_void;
1482
1483             pub static MCL_CURRENT : c_int = 0x0001;
1484             pub static MCL_FUTURE : c_int = 0x0002;
1485
1486             pub static MS_ASYNC : c_int = 0x0001;
1487             pub static MS_INVALIDATE : c_int = 0x0002;
1488             pub static MS_SYNC : c_int = 0x0004;
1489
1490             pub static _SC_ARG_MAX : c_int = 0;
1491             pub static _SC_CHILD_MAX : c_int = 1;
1492             pub static _SC_CLK_TCK : c_int = 2;
1493             pub static _SC_NGROUPS_MAX : c_int = 3;
1494             pub static _SC_OPEN_MAX : c_int = 4;
1495             pub static _SC_STREAM_MAX : c_int = 5;
1496             pub static _SC_TZNAME_MAX : c_int = 6;
1497             pub static _SC_JOB_CONTROL : c_int = 7;
1498             pub static _SC_SAVED_IDS : c_int = 8;
1499             pub static _SC_REALTIME_SIGNALS : c_int = 9;
1500             pub static _SC_PRIORITY_SCHEDULING : c_int = 10;
1501             pub static _SC_TIMERS : c_int = 11;
1502             pub static _SC_ASYNCHRONOUS_IO : c_int = 12;
1503             pub static _SC_PRIORITIZED_IO : c_int = 13;
1504             pub static _SC_SYNCHRONIZED_IO : c_int = 14;
1505             pub static _SC_FSYNC : c_int = 15;
1506             pub static _SC_MAPPED_FILES : c_int = 16;
1507             pub static _SC_MEMLOCK : c_int = 17;
1508             pub static _SC_MEMLOCK_RANGE : c_int = 18;
1509             pub static _SC_MEMORY_PROTECTION : c_int = 19;
1510             pub static _SC_MESSAGE_PASSING : c_int = 20;
1511             pub static _SC_SEMAPHORES : c_int = 21;
1512             pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 22;
1513             pub static _SC_AIO_LISTIO_MAX : c_int = 23;
1514             pub static _SC_AIO_MAX : c_int = 24;
1515             pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 25;
1516             pub static _SC_DELAYTIMER_MAX : c_int = 26;
1517             pub static _SC_MQ_OPEN_MAX : c_int = 27;
1518             pub static _SC_VERSION : c_int = 29;
1519             pub static _SC_PAGESIZE : c_int = 30;
1520             pub static _SC_RTSIG_MAX : c_int = 31;
1521             pub static _SC_SEM_NSEMS_MAX : c_int = 32;
1522             pub static _SC_SEM_VALUE_MAX : c_int = 33;
1523             pub static _SC_SIGQUEUE_MAX : c_int = 34;
1524             pub static _SC_TIMER_MAX : c_int = 35;
1525             pub static _SC_BC_BASE_MAX : c_int = 36;
1526             pub static _SC_BC_DIM_MAX : c_int = 37;
1527             pub static _SC_BC_SCALE_MAX : c_int = 38;
1528             pub static _SC_BC_STRING_MAX : c_int = 39;
1529             pub static _SC_COLL_WEIGHTS_MAX : c_int = 40;
1530             pub static _SC_EXPR_NEST_MAX : c_int = 42;
1531             pub static _SC_LINE_MAX : c_int = 43;
1532             pub static _SC_RE_DUP_MAX : c_int = 44;
1533             pub static _SC_2_VERSION : c_int = 46;
1534             pub static _SC_2_C_BIND : c_int = 47;
1535             pub static _SC_2_C_DEV : c_int = 48;
1536             pub static _SC_2_FORT_DEV : c_int = 49;
1537             pub static _SC_2_FORT_RUN : c_int = 50;
1538             pub static _SC_2_SW_DEV : c_int = 51;
1539             pub static _SC_2_LOCALEDEF : c_int = 52;
1540             pub static _SC_2_CHAR_TERM : c_int = 95;
1541             pub static _SC_2_C_VERSION : c_int = 96;
1542             pub static _SC_2_UPE : c_int = 97;
1543             pub static _SC_XBS5_ILP32_OFF32 : c_int = 125;
1544             pub static _SC_XBS5_ILP32_OFFBIG : c_int = 126;
1545             pub static _SC_XBS5_LPBIG_OFFBIG : c_int = 128;
1546
1547             pub static EPERM : c_int = 1;
1548             pub static ENOENT : c_int = 2;
1549             pub static ESRCH : c_int = 3;
1550             pub static EINTR : c_int = 4;
1551             pub static EIO : c_int = 5;
1552             pub static ENXIO : c_int = 6;
1553             pub static E2BIG : c_int = 7;
1554             pub static ENOEXEC : c_int = 8;
1555             pub static EBADF : c_int = 9;
1556             pub static ECHILD : c_int = 10;
1557             pub static EAGAIN : c_int = 11;
1558             pub static ENOMEM : c_int = 12;
1559             pub static EACCES : c_int = 13;
1560             pub static EFAULT : c_int = 14;
1561             pub static ENOTBLK : c_int = 15;
1562             pub static EBUSY : c_int = 16;
1563             pub static EEXIST : c_int = 17;
1564             pub static EXDEV : c_int = 18;
1565             pub static ENODEV : c_int = 19;
1566             pub static ENOTDIR : c_int = 20;
1567             pub static EISDIR : c_int = 21;
1568             pub static EINVAL : c_int = 22;
1569             pub static ENFILE : c_int = 23;
1570             pub static EMFILE : c_int = 24;
1571             pub static ENOTTY : c_int = 25;
1572             pub static ETXTBSY : c_int = 26;
1573             pub static EFBIG : c_int = 27;
1574             pub static ENOSPC : c_int = 28;
1575             pub static ESPIPE : c_int = 29;
1576             pub static EROFS : c_int = 30;
1577             pub static EMLINK : c_int = 31;
1578             pub static EPIPE : c_int = 32;
1579             pub static EDOM : c_int = 33;
1580             pub static ERANGE : c_int = 34;
1581         }
1582         pub mod posix01 {
1583             use libc::types::os::arch::c95::c_int;
1584
1585             pub static SIGTRAP : c_int = 5;
1586
1587             pub static GLOB_ERR      : c_int = 1 << 0;
1588             pub static GLOB_MARK     : c_int = 1 << 1;
1589             pub static GLOB_NOSORT   : c_int = 1 << 2;
1590             pub static GLOB_DOOFFS   : c_int = 1 << 3;
1591             pub static GLOB_NOCHECK  : c_int = 1 << 4;
1592             pub static GLOB_APPEND   : c_int = 1 << 5;
1593             pub static GLOB_NOESCAPE : c_int = 1 << 6;
1594
1595             pub static GLOB_NOSPACE  : c_int = 1;
1596             pub static GLOB_ABORTED  : c_int = 2;
1597             pub static GLOB_NOMATCH  : c_int = 3;
1598
1599             pub static POSIX_MADV_NORMAL : c_int = 0;
1600             pub static POSIX_MADV_RANDOM : c_int = 1;
1601             pub static POSIX_MADV_SEQUENTIAL : c_int = 2;
1602             pub static POSIX_MADV_WILLNEED : c_int = 3;
1603             pub static POSIX_MADV_DONTNEED : c_int = 4;
1604
1605             pub static _SC_MQ_PRIO_MAX : c_int = 28;
1606             pub static _SC_IOV_MAX : c_int = 60;
1607             pub static _SC_GETGR_R_SIZE_MAX : c_int = 69;
1608             pub static _SC_GETPW_R_SIZE_MAX : c_int = 70;
1609             pub static _SC_LOGIN_NAME_MAX : c_int = 71;
1610             pub static _SC_TTY_NAME_MAX : c_int = 72;
1611             pub static _SC_THREADS : c_int = 67;
1612             pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 68;
1613             pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73;
1614             pub static _SC_THREAD_KEYS_MAX : c_int = 74;
1615             pub static _SC_THREAD_STACK_MIN : c_int = 75;
1616             pub static _SC_THREAD_THREADS_MAX : c_int = 76;
1617             pub static _SC_THREAD_ATTR_STACKADDR : c_int = 77;
1618             pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
1619             pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79;
1620             pub static _SC_THREAD_PRIO_INHERIT : c_int = 80;
1621             pub static _SC_THREAD_PRIO_PROTECT : c_int = 81;
1622             pub static _SC_THREAD_PROCESS_SHARED : c_int = 82;
1623             pub static _SC_ATEXIT_MAX : c_int = 87;
1624             pub static _SC_XOPEN_VERSION : c_int = 89;
1625             pub static _SC_XOPEN_XCU_VERSION : c_int = 90;
1626             pub static _SC_XOPEN_UNIX : c_int = 91;
1627             pub static _SC_XOPEN_CRYPT : c_int = 92;
1628             pub static _SC_XOPEN_ENH_I18N : c_int = 93;
1629             pub static _SC_XOPEN_SHM : c_int = 94;
1630             pub static _SC_XOPEN_LEGACY : c_int = 129;
1631             pub static _SC_XOPEN_REALTIME : c_int = 130;
1632             pub static _SC_XOPEN_REALTIME_THREADS : c_int = 131;
1633         }
1634         pub mod posix08 {
1635         }
1636         pub mod bsd44 {
1637             use libc::types::os::arch::c95::c_int;
1638
1639             pub static MADV_NORMAL : c_int = 0;
1640             pub static MADV_RANDOM : c_int = 1;
1641             pub static MADV_SEQUENTIAL : c_int = 2;
1642             pub static MADV_WILLNEED : c_int = 3;
1643             pub static MADV_DONTNEED : c_int = 4;
1644             pub static MADV_REMOVE : c_int = 9;
1645             pub static MADV_DONTFORK : c_int = 10;
1646             pub static MADV_DOFORK : c_int = 11;
1647             pub static MADV_MERGEABLE : c_int = 12;
1648             pub static MADV_UNMERGEABLE : c_int = 13;
1649             pub static MADV_HWPOISON : c_int = 100;
1650         }
1651         #[cfg(target_arch = "x86")]
1652         #[cfg(target_arch = "x86_64")]
1653         #[cfg(target_arch = "arm")]
1654         pub mod extra {
1655             use libc::types::os::arch::c95::c_int;
1656
1657             pub static O_RSYNC : c_int = 1052672;
1658             pub static O_DSYNC : c_int = 4096;
1659             pub static O_SYNC : c_int = 1052672;
1660
1661             pub static PROT_GROWSDOWN : c_int = 0x010000000;
1662             pub static PROT_GROWSUP : c_int = 0x020000000;
1663
1664             pub static MAP_TYPE : c_int = 0x000f;
1665             pub static MAP_ANONONYMOUS : c_int = 0x0020;
1666             pub static MAP_32BIT : c_int = 0x0040;
1667             pub static MAP_GROWSDOWN : c_int = 0x0100;
1668             pub static MAP_DENYWRITE : c_int = 0x0800;
1669             pub static MAP_EXECUTABLE : c_int = 0x01000;
1670             pub static MAP_LOCKED : c_int = 0x02000;
1671             pub static MAP_NONRESERVE : c_int = 0x04000;
1672             pub static MAP_POPULATE : c_int = 0x08000;
1673             pub static MAP_NONBLOCK : c_int = 0x010000;
1674             pub static MAP_STACK : c_int = 0x020000;
1675         }
1676         #[cfg(target_arch = "mips")]
1677         pub mod extra {
1678             use libc::types::os::arch::c95::c_int;
1679
1680             pub static O_RSYNC : c_int = 16400;
1681             pub static O_DSYNC : c_int = 16;
1682             pub static O_SYNC : c_int = 16400;
1683
1684             pub static PROT_GROWSDOWN : c_int = 0x010000000;
1685             pub static PROT_GROWSUP : c_int = 0x020000000;
1686
1687             pub static MAP_TYPE : c_int = 0x000f;
1688             pub static MAP_ANONONYMOUS : c_int = 0x0020;
1689             pub static MAP_32BIT : c_int = 0x0040;
1690             pub static MAP_GROWSDOWN : c_int = 0x0100;
1691             pub static MAP_DENYWRITE : c_int = 0x0800;
1692             pub static MAP_EXECUTABLE : c_int = 0x01000;
1693             pub static MAP_LOCKED : c_int = 0x02000;
1694             pub static MAP_NONRESERVE : c_int = 0x04000;
1695             pub static MAP_POPULATE : c_int = 0x08000;
1696             pub static MAP_NONBLOCK : c_int = 0x010000;
1697             pub static MAP_STACK : c_int = 0x020000;
1698         }
1699     }
1700
1701     #[cfg(target_os = "freebsd")]
1702     pub mod os {
1703         pub mod c95 {
1704             use libc::types::os::arch::c95::{c_int, c_uint};
1705
1706             pub static EXIT_FAILURE : c_int = 1;
1707             pub static EXIT_SUCCESS : c_int = 0;
1708             pub static RAND_MAX : c_int = 2147483647;
1709             pub static EOF : c_int = -1;
1710             pub static SEEK_SET : c_int = 0;
1711             pub static SEEK_CUR : c_int = 1;
1712             pub static SEEK_END : c_int = 2;
1713             pub static _IOFBF : c_int = 0;
1714             pub static _IONBF : c_int = 2;
1715             pub static _IOLBF : c_int = 1;
1716             pub static BUFSIZ : c_uint = 1024_u32;
1717             pub static FOPEN_MAX : c_uint = 20_u32;
1718             pub static FILENAME_MAX : c_uint = 1024_u32;
1719             pub static L_tmpnam : c_uint = 1024_u32;
1720             pub static TMP_MAX : c_uint = 308915776_u32;
1721         }
1722         pub mod c99 {
1723         }
1724         pub mod posix88 {
1725             use libc::types::common::c95::c_void;
1726             use libc::types::os::arch::c95::c_int;
1727
1728             pub static O_RDONLY : c_int = 0;
1729             pub static O_WRONLY : c_int = 1;
1730             pub static O_RDWR : c_int = 2;
1731             pub static O_APPEND : c_int = 8;
1732             pub static O_CREAT : c_int = 512;
1733             pub static O_EXCL : c_int = 2048;
1734             pub static O_TRUNC : c_int = 1024;
1735             pub static S_IFIFO : c_int = 4096;
1736             pub static S_IFCHR : c_int = 8192;
1737             pub static S_IFBLK : c_int = 24576;
1738             pub static S_IFDIR : c_int = 16384;
1739             pub static S_IFREG : c_int = 32768;
1740             pub static S_IFMT : c_int = 61440;
1741             pub static S_IEXEC : c_int = 64;
1742             pub static S_IWRITE : c_int = 128;
1743             pub static S_IREAD : c_int = 256;
1744             pub static S_IRWXU : c_int = 448;
1745             pub static S_IXUSR : c_int = 64;
1746             pub static S_IWUSR : c_int = 128;
1747             pub static S_IRUSR : c_int = 256;
1748             pub static F_OK : c_int = 0;
1749             pub static R_OK : c_int = 4;
1750             pub static W_OK : c_int = 2;
1751             pub static X_OK : c_int = 1;
1752             pub static STDIN_FILENO : c_int = 0;
1753             pub static STDOUT_FILENO : c_int = 1;
1754             pub static STDERR_FILENO : c_int = 2;
1755             pub static F_LOCK : c_int = 1;
1756             pub static F_TEST : c_int = 3;
1757             pub static F_TLOCK : c_int = 2;
1758             pub static F_ULOCK : c_int = 0;
1759             pub static SIGHUP : c_int = 1;
1760             pub static SIGINT : c_int = 2;
1761             pub static SIGQUIT : c_int = 3;
1762             pub static SIGILL : c_int = 4;
1763             pub static SIGABRT : c_int = 6;
1764             pub static SIGFPE : c_int = 8;
1765             pub static SIGKILL : c_int = 9;
1766             pub static SIGSEGV : c_int = 11;
1767             pub static SIGPIPE : c_int = 13;
1768             pub static SIGALRM : c_int = 14;
1769             pub static SIGTERM : c_int = 15;
1770
1771             pub static PROT_NONE : c_int = 0;
1772             pub static PROT_READ : c_int = 1;
1773             pub static PROT_WRITE : c_int = 2;
1774             pub static PROT_EXEC : c_int = 4;
1775
1776             pub static MAP_FILE : c_int = 0x0000;
1777             pub static MAP_SHARED : c_int = 0x0001;
1778             pub static MAP_PRIVATE : c_int = 0x0002;
1779             pub static MAP_FIXED : c_int = 0x0010;
1780             pub static MAP_ANON : c_int = 0x1000;
1781
1782             pub static MAP_FAILED : *c_void = -1 as *c_void;
1783
1784             pub static MCL_CURRENT : c_int = 0x0001;
1785             pub static MCL_FUTURE : c_int = 0x0002;
1786
1787             pub static MS_SYNC : c_int = 0x0000;
1788             pub static MS_ASYNC : c_int = 0x0001;
1789             pub static MS_INVALIDATE : c_int = 0x0002;
1790
1791             pub static _SC_ARG_MAX : c_int = 1;
1792             pub static _SC_CHILD_MAX : c_int = 2;
1793             pub static _SC_CLK_TCK : c_int = 3;
1794             pub static _SC_NGROUPS_MAX : c_int = 4;
1795             pub static _SC_OPEN_MAX : c_int = 5;
1796             pub static _SC_JOB_CONTROL : c_int = 6;
1797             pub static _SC_SAVED_IDS : c_int = 7;
1798             pub static _SC_VERSION : c_int = 8;
1799             pub static _SC_BC_BASE_MAX : c_int = 9;
1800             pub static _SC_BC_DIM_MAX : c_int = 10;
1801             pub static _SC_BC_SCALE_MAX : c_int = 11;
1802             pub static _SC_BC_STRING_MAX : c_int = 12;
1803             pub static _SC_COLL_WEIGHTS_MAX : c_int = 13;
1804             pub static _SC_EXPR_NEST_MAX : c_int = 14;
1805             pub static _SC_LINE_MAX : c_int = 15;
1806             pub static _SC_RE_DUP_MAX : c_int = 16;
1807             pub static _SC_2_VERSION : c_int = 17;
1808             pub static _SC_2_C_BIND : c_int = 18;
1809             pub static _SC_2_C_DEV : c_int = 19;
1810             pub static _SC_2_CHAR_TERM : c_int = 20;
1811             pub static _SC_2_FORT_DEV : c_int = 21;
1812             pub static _SC_2_FORT_RUN : c_int = 22;
1813             pub static _SC_2_LOCALEDEF : c_int = 23;
1814             pub static _SC_2_SW_DEV : c_int = 24;
1815             pub static _SC_2_UPE : c_int = 25;
1816             pub static _SC_STREAM_MAX : c_int = 26;
1817             pub static _SC_TZNAME_MAX : c_int = 27;
1818             pub static _SC_ASYNCHRONOUS_IO : c_int = 28;
1819             pub static _SC_MAPPED_FILES : c_int = 29;
1820             pub static _SC_MEMLOCK : c_int = 30;
1821             pub static _SC_MEMLOCK_RANGE : c_int = 31;
1822             pub static _SC_MEMORY_PROTECTION : c_int = 32;
1823             pub static _SC_MESSAGE_PASSING : c_int = 33;
1824             pub static _SC_PRIORITIZED_IO : c_int = 34;
1825             pub static _SC_PRIORITY_SCHEDULING : c_int = 35;
1826             pub static _SC_REALTIME_SIGNALS : c_int = 36;
1827             pub static _SC_SEMAPHORES : c_int = 37;
1828             pub static _SC_FSYNC : c_int = 38;
1829             pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
1830             pub static _SC_SYNCHRONIZED_IO : c_int = 40;
1831             pub static _SC_TIMERS : c_int = 41;
1832             pub static _SC_AIO_LISTIO_MAX : c_int = 42;
1833             pub static _SC_AIO_MAX : c_int = 43;
1834             pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
1835             pub static _SC_DELAYTIMER_MAX : c_int = 45;
1836             pub static _SC_MQ_OPEN_MAX : c_int = 46;
1837             pub static _SC_PAGESIZE : c_int = 47;
1838             pub static _SC_RTSIG_MAX : c_int = 48;
1839             pub static _SC_SEM_NSEMS_MAX : c_int = 49;
1840             pub static _SC_SEM_VALUE_MAX : c_int = 50;
1841             pub static _SC_SIGQUEUE_MAX : c_int = 51;
1842             pub static _SC_TIMER_MAX : c_int = 52;
1843
1844             pub static EPERM : c_int = 1;
1845             pub static ENOENT : c_int = 2;
1846             pub static ESRCH : c_int = 3;
1847             pub static EINTR : c_int = 4;
1848             pub static EIO : c_int = 5;
1849             pub static ENXIO : c_int = 6;
1850             pub static E2BIG : c_int = 7;
1851             pub static ENOEXEC : c_int = 8;
1852             pub static EBADF : c_int = 9;
1853             pub static ECHILD : c_int = 10;
1854             pub static EDEADLK : c_int = 11;
1855             pub static ENOMEM : c_int = 12;
1856             pub static EACCES : c_int = 13;
1857             pub static EFAULT : c_int = 14;
1858             pub static ENOTBLK : c_int = 15;
1859             pub static EBUSY : c_int = 16;
1860             pub static EEXIST : c_int = 17;
1861             pub static EXDEV : c_int = 18;
1862             pub static ENODEV : c_int = 19;
1863             pub static ENOTDIR : c_int = 20;
1864             pub static EISDIR : c_int = 21;
1865             pub static EINVAL : c_int = 22;
1866             pub static ENFILE : c_int = 23;
1867             pub static EMFILE : c_int = 24;
1868             pub static ENOTTY : c_int = 25;
1869             pub static ETXTBSY : c_int = 26;
1870             pub static EFBIG : c_int = 27;
1871             pub static ENOSPC : c_int = 28;
1872             pub static ESPIPE : c_int = 29;
1873             pub static EROFS : c_int = 30;
1874             pub static EMLINK : c_int = 31;
1875             pub static EPIPE : c_int = 32;
1876             pub static EDOM : c_int = 33;
1877             pub static ERANGE : c_int = 34;
1878             pub static EAGAIN : c_int = 35;
1879             pub static EWOULDBLOCK : c_int = 35;
1880             pub static EINPROGRESS : c_int = 36;
1881             pub static EALREADY : c_int = 37;
1882             pub static ENOTSOCK : c_int = 38;
1883             pub static EDESTADDRREQ : c_int = 39;
1884             pub static EMSGSIZE : c_int = 40;
1885             pub static EPROTOTYPE : c_int = 41;
1886             pub static ENOPROTOOPT : c_int = 42;
1887             pub static EPROTONOSUPPORT : c_int = 43;
1888             pub static ESOCKTNOSUPPORT : c_int = 44;
1889             pub static EOPNOTSUPP : c_int = 45;
1890             pub static EPFNOSUPPORT : c_int = 46;
1891             pub static EAFNOSUPPORT : c_int = 47;
1892             pub static EADDRINUSE : c_int = 48;
1893             pub static EADDRNOTAVAIL : c_int = 49;
1894             pub static ENETDOWN : c_int = 50;
1895             pub static ENETUNREACH : c_int = 51;
1896             pub static ENETRESET : c_int = 52;
1897             pub static ECONNABORTED : c_int = 53;
1898             pub static ECONNRESET : c_int = 54;
1899             pub static ENOBUFS : c_int = 55;
1900             pub static EISCONN : c_int = 56;
1901             pub static ENOTCONN : c_int = 57;
1902             pub static ESHUTDOWN : c_int = 58;
1903             pub static ETOOMANYREFS : c_int = 59;
1904             pub static ETIMEDOUT : c_int = 60;
1905             pub static ECONNREFUSED : c_int = 61;
1906             pub static ELOOP : c_int = 62;
1907             pub static ENAMETOOLONG : c_int = 63;
1908             pub static EHOSTDOWN : c_int = 64;
1909             pub static EHOSTUNREACH : c_int = 65;
1910             pub static ENOTEMPTY : c_int = 66;
1911             pub static EPROCLIM : c_int = 67;
1912             pub static EUSERS : c_int = 68;
1913             pub static EDQUOT : c_int = 69;
1914             pub static ESTALE : c_int = 70;
1915             pub static EREMOTE : c_int = 71;
1916             pub static EBADRPC : c_int = 72;
1917             pub static ERPCMISMATCH : c_int = 73;
1918             pub static EPROGUNAVAIL : c_int = 74;
1919             pub static EPROGMISMATCH : c_int = 75;
1920             pub static EPROCUNAVAIL : c_int = 76;
1921             pub static ENOLCK : c_int = 77;
1922             pub static ENOSYS : c_int = 78;
1923             pub static EFTYPE : c_int = 79;
1924             pub static EAUTH : c_int = 80;
1925             pub static ENEEDAUTH : c_int = 81;
1926             pub static EIDRM : c_int = 82;
1927             pub static ENOMSG : c_int = 83;
1928             pub static EOVERFLOW : c_int = 84;
1929             pub static ECANCELED : c_int = 85;
1930             pub static EILSEQ : c_int = 86;
1931             pub static ENOATTR : c_int = 87;
1932             pub static EDOOFUS : c_int = 88;
1933             pub static EBADMSG : c_int = 89;
1934             pub static EMULTIHOP : c_int = 90;
1935             pub static ENOLINK : c_int = 91;
1936             pub static EPROTO : c_int = 92;
1937             pub static ENOMEDIUM : c_int = 93;
1938             pub static EUNUSED94 : c_int = 94;
1939             pub static EUNUSED95 : c_int = 95;
1940             pub static EUNUSED96 : c_int = 96;
1941             pub static EUNUSED97 : c_int = 97;
1942             pub static EUNUSED98 : c_int = 98;
1943             pub static EASYNC : c_int = 99;
1944             pub static ELAST : c_int = 99;
1945         }
1946         pub mod posix01 {
1947             use libc::types::os::arch::c95::c_int;
1948
1949             pub static SIGTRAP : c_int = 5;
1950
1951             pub static GLOB_APPEND   : c_int = 0x0001;
1952             pub static GLOB_DOOFFS   : c_int = 0x0002;
1953             pub static GLOB_ERR      : c_int = 0x0004;
1954             pub static GLOB_MARK     : c_int = 0x0008;
1955             pub static GLOB_NOCHECK  : c_int = 0x0010;
1956             pub static GLOB_NOSORT   : c_int = 0x0020;
1957             pub static GLOB_NOESCAPE : c_int = 0x2000;
1958
1959             pub static GLOB_NOSPACE  : c_int = -1;
1960             pub static GLOB_ABORTED  : c_int = -2;
1961             pub static GLOB_NOMATCH  : c_int = -3;
1962
1963             pub static POSIX_MADV_NORMAL : c_int = 0;
1964             pub static POSIX_MADV_RANDOM : c_int = 1;
1965             pub static POSIX_MADV_SEQUENTIAL : c_int = 2;
1966             pub static POSIX_MADV_WILLNEED : c_int = 3;
1967             pub static POSIX_MADV_DONTNEED : c_int = 4;
1968
1969             pub static _SC_IOV_MAX : c_int = 56;
1970             pub static _SC_GETGR_R_SIZE_MAX : c_int = 70;
1971             pub static _SC_GETPW_R_SIZE_MAX : c_int = 71;
1972             pub static _SC_LOGIN_NAME_MAX : c_int = 73;
1973             pub static _SC_MQ_PRIO_MAX : c_int = 75;
1974             pub static _SC_THREAD_ATTR_STACKADDR : c_int = 82;
1975             pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
1976             pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
1977             pub static _SC_THREAD_KEYS_MAX : c_int = 86;
1978             pub static _SC_THREAD_PRIO_INHERIT : c_int = 87;
1979             pub static _SC_THREAD_PRIO_PROTECT : c_int = 88;
1980             pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
1981             pub static _SC_THREAD_PROCESS_SHARED : c_int = 90;
1982             pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
1983             pub static _SC_THREAD_STACK_MIN : c_int = 93;
1984             pub static _SC_THREAD_THREADS_MAX : c_int = 94;
1985             pub static _SC_THREADS : c_int = 96;
1986             pub static _SC_TTY_NAME_MAX : c_int = 101;
1987             pub static _SC_ATEXIT_MAX : c_int = 107;
1988             pub static _SC_XOPEN_CRYPT : c_int = 108;
1989             pub static _SC_XOPEN_ENH_I18N : c_int = 109;
1990             pub static _SC_XOPEN_LEGACY : c_int = 110;
1991             pub static _SC_XOPEN_REALTIME : c_int = 111;
1992             pub static _SC_XOPEN_REALTIME_THREADS : c_int = 112;
1993             pub static _SC_XOPEN_SHM : c_int = 113;
1994             pub static _SC_XOPEN_UNIX : c_int = 115;
1995             pub static _SC_XOPEN_VERSION : c_int = 116;
1996             pub static _SC_XOPEN_XCU_VERSION : c_int = 117;
1997         }
1998         pub mod posix08 {
1999         }
2000         pub mod bsd44 {
2001             use libc::types::os::arch::c95::c_int;
2002
2003             pub static MADV_NORMAL : c_int = 0;
2004             pub static MADV_RANDOM : c_int = 1;
2005             pub static MADV_SEQUENTIAL : c_int = 2;
2006             pub static MADV_WILLNEED : c_int = 3;
2007             pub static MADV_DONTNEED : c_int = 4;
2008             pub static MADV_FREE : c_int = 5;
2009             pub static MADV_NOSYNC : c_int = 6;
2010             pub static MADV_AUTOSYNC : c_int = 7;
2011             pub static MADV_NOCORE : c_int = 8;
2012             pub static MADV_CORE : c_int = 9;
2013             pub static MADV_PROTECT : c_int = 10;
2014
2015             pub static MINCORE_INCORE : c_int =  0x1;
2016             pub static MINCORE_REFERENCED : c_int = 0x2;
2017             pub static MINCORE_MODIFIED : c_int = 0x4;
2018             pub static MINCORE_REFERENCED_OTHER : c_int = 0x8;
2019             pub static MINCORE_MODIFIED_OTHER : c_int = 0x10;
2020             pub static MINCORE_SUPER : c_int = 0x20;
2021         }
2022         pub mod extra {
2023             use libc::types::os::arch::c95::c_int;
2024
2025             pub static O_SYNC : c_int = 128;
2026             pub static CTL_KERN: c_int = 1;
2027             pub static KERN_PROC: c_int = 14;
2028             pub static KERN_PROC_PATHNAME: c_int = 12;
2029
2030             pub static MAP_COPY : c_int = 0x0002;
2031             pub static MAP_RENAME : c_int = 0x0020;
2032             pub static MAP_NORESERVE : c_int = 0x0040;
2033             pub static MAP_HASSEMAPHORE : c_int = 0x0200;
2034             pub static MAP_STACK : c_int = 0x0400;
2035             pub static MAP_NOSYNC : c_int = 0x0800;
2036             pub static MAP_NOCORE : c_int = 0x020000;
2037         }
2038     }
2039
2040     #[cfg(target_os = "macos")]
2041     pub mod os {
2042         pub mod c95 {
2043             use libc::types::os::arch::c95::{c_int, c_uint};
2044
2045             pub static EXIT_FAILURE : c_int = 1;
2046             pub static EXIT_SUCCESS : c_int = 0;
2047             pub static RAND_MAX : c_int = 2147483647;
2048             pub static EOF : c_int = -1;
2049             pub static SEEK_SET : c_int = 0;
2050             pub static SEEK_CUR : c_int = 1;
2051             pub static SEEK_END : c_int = 2;
2052             pub static _IOFBF : c_int = 0;
2053             pub static _IONBF : c_int = 2;
2054             pub static _IOLBF : c_int = 1;
2055             pub static BUFSIZ : c_uint = 1024_u32;
2056             pub static FOPEN_MAX : c_uint = 20_u32;
2057             pub static FILENAME_MAX : c_uint = 1024_u32;
2058             pub static L_tmpnam : c_uint = 1024_u32;
2059             pub static TMP_MAX : c_uint = 308915776_u32;
2060         }
2061         pub mod c99 {
2062         }
2063         pub mod posix88 {
2064             use libc::types::common::c95::c_void;
2065             use libc::types::os::arch::c95::c_int;
2066
2067             pub static O_RDONLY : c_int = 0;
2068             pub static O_WRONLY : c_int = 1;
2069             pub static O_RDWR : c_int = 2;
2070             pub static O_APPEND : c_int = 8;
2071             pub static O_CREAT : c_int = 512;
2072             pub static O_EXCL : c_int = 2048;
2073             pub static O_TRUNC : c_int = 1024;
2074             pub static S_IFIFO : c_int = 4096;
2075             pub static S_IFCHR : c_int = 8192;
2076             pub static S_IFBLK : c_int = 24576;
2077             pub static S_IFDIR : c_int = 16384;
2078             pub static S_IFREG : c_int = 32768;
2079             pub static S_IFMT : c_int = 61440;
2080             pub static S_IEXEC : c_int = 64;
2081             pub static S_IWRITE : c_int = 128;
2082             pub static S_IREAD : c_int = 256;
2083             pub static S_IRWXU : c_int = 448;
2084             pub static S_IXUSR : c_int = 64;
2085             pub static S_IWUSR : c_int = 128;
2086             pub static S_IRUSR : c_int = 256;
2087             pub static F_OK : c_int = 0;
2088             pub static R_OK : c_int = 4;
2089             pub static W_OK : c_int = 2;
2090             pub static X_OK : c_int = 1;
2091             pub static STDIN_FILENO : c_int = 0;
2092             pub static STDOUT_FILENO : c_int = 1;
2093             pub static STDERR_FILENO : c_int = 2;
2094             pub static F_LOCK : c_int = 1;
2095             pub static F_TEST : c_int = 3;
2096             pub static F_TLOCK : c_int = 2;
2097             pub static F_ULOCK : c_int = 0;
2098             pub static SIGHUP : c_int = 1;
2099             pub static SIGINT : c_int = 2;
2100             pub static SIGQUIT : c_int = 3;
2101             pub static SIGILL : c_int = 4;
2102             pub static SIGABRT : c_int = 6;
2103             pub static SIGFPE : c_int = 8;
2104             pub static SIGKILL : c_int = 9;
2105             pub static SIGSEGV : c_int = 11;
2106             pub static SIGPIPE : c_int = 13;
2107             pub static SIGALRM : c_int = 14;
2108             pub static SIGTERM : c_int = 15;
2109
2110             pub static PROT_NONE : c_int = 0;
2111             pub static PROT_READ : c_int = 1;
2112             pub static PROT_WRITE : c_int = 2;
2113             pub static PROT_EXEC : c_int = 4;
2114
2115             pub static MAP_FILE : c_int = 0x0000;
2116             pub static MAP_SHARED : c_int = 0x0001;
2117             pub static MAP_PRIVATE : c_int = 0x0002;
2118             pub static MAP_FIXED : c_int = 0x0010;
2119             pub static MAP_ANON : c_int = 0x1000;
2120
2121             pub static MAP_FAILED : *c_void = -1 as *c_void;
2122
2123             pub static MCL_CURRENT : c_int = 0x0001;
2124             pub static MCL_FUTURE : c_int = 0x0002;
2125
2126             pub static MS_ASYNC : c_int = 0x0001;
2127             pub static MS_INVALIDATE : c_int = 0x0002;
2128             pub static MS_SYNC : c_int = 0x0010;
2129
2130             pub static MS_KILLPAGES : c_int = 0x0004;
2131             pub static MS_DEACTIVATE : c_int = 0x0008;
2132
2133             pub static _SC_ARG_MAX : c_int = 1;
2134             pub static _SC_CHILD_MAX : c_int = 2;
2135             pub static _SC_CLK_TCK : c_int = 3;
2136             pub static _SC_NGROUPS_MAX : c_int = 4;
2137             pub static _SC_OPEN_MAX : c_int = 5;
2138             pub static _SC_JOB_CONTROL : c_int = 6;
2139             pub static _SC_SAVED_IDS : c_int = 7;
2140             pub static _SC_VERSION : c_int = 8;
2141             pub static _SC_BC_BASE_MAX : c_int = 9;
2142             pub static _SC_BC_DIM_MAX : c_int = 10;
2143             pub static _SC_BC_SCALE_MAX : c_int = 11;
2144             pub static _SC_BC_STRING_MAX : c_int = 12;
2145             pub static _SC_COLL_WEIGHTS_MAX : c_int = 13;
2146             pub static _SC_EXPR_NEST_MAX : c_int = 14;
2147             pub static _SC_LINE_MAX : c_int = 15;
2148             pub static _SC_RE_DUP_MAX : c_int = 16;
2149             pub static _SC_2_VERSION : c_int = 17;
2150             pub static _SC_2_C_BIND : c_int = 18;
2151             pub static _SC_2_C_DEV : c_int = 19;
2152             pub static _SC_2_CHAR_TERM : c_int = 20;
2153             pub static _SC_2_FORT_DEV : c_int = 21;
2154             pub static _SC_2_FORT_RUN : c_int = 22;
2155             pub static _SC_2_LOCALEDEF : c_int = 23;
2156             pub static _SC_2_SW_DEV : c_int = 24;
2157             pub static _SC_2_UPE : c_int = 25;
2158             pub static _SC_STREAM_MAX : c_int = 26;
2159             pub static _SC_TZNAME_MAX : c_int = 27;
2160             pub static _SC_ASYNCHRONOUS_IO : c_int = 28;
2161             pub static _SC_PAGESIZE : c_int = 29;
2162             pub static _SC_MEMLOCK : c_int = 30;
2163             pub static _SC_MEMLOCK_RANGE : c_int = 31;
2164             pub static _SC_MEMORY_PROTECTION : c_int = 32;
2165             pub static _SC_MESSAGE_PASSING : c_int = 33;
2166             pub static _SC_PRIORITIZED_IO : c_int = 34;
2167             pub static _SC_PRIORITY_SCHEDULING : c_int = 35;
2168             pub static _SC_REALTIME_SIGNALS : c_int = 36;
2169             pub static _SC_SEMAPHORES : c_int = 37;
2170             pub static _SC_FSYNC : c_int = 38;
2171             pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
2172             pub static _SC_SYNCHRONIZED_IO : c_int = 40;
2173             pub static _SC_TIMERS : c_int = 41;
2174             pub static _SC_AIO_LISTIO_MAX : c_int = 42;
2175             pub static _SC_AIO_MAX : c_int = 43;
2176             pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
2177             pub static _SC_DELAYTIMER_MAX : c_int = 45;
2178             pub static _SC_MQ_OPEN_MAX : c_int = 46;
2179             pub static _SC_MAPPED_FILES : c_int = 47;
2180             pub static _SC_RTSIG_MAX : c_int = 48;
2181             pub static _SC_SEM_NSEMS_MAX : c_int = 49;
2182             pub static _SC_SEM_VALUE_MAX : c_int = 50;
2183             pub static _SC_SIGQUEUE_MAX : c_int = 51;
2184             pub static _SC_TIMER_MAX : c_int = 52;
2185             pub static _SC_XBS5_ILP32_OFF32 : c_int = 122;
2186             pub static _SC_XBS5_ILP32_OFFBIG : c_int = 123;
2187             pub static _SC_XBS5_LP64_OFF64 : c_int = 124;
2188             pub static _SC_XBS5_LPBIG_OFFBIG : c_int = 125;
2189
2190             pub static EPERM : c_int = 1;
2191             pub static ENOENT : c_int = 2;
2192             pub static ESRCH : c_int = 3;
2193             pub static EINTR : c_int = 4;
2194             pub static EIO : c_int = 5;
2195             pub static ENXIO : c_int = 6;
2196             pub static E2BIG : c_int = 7;
2197             pub static ENOEXEC : c_int = 8;
2198             pub static EBADF : c_int = 9;
2199             pub static ECHILD : c_int = 10;
2200             pub static EDEADLK : c_int = 11;
2201             pub static ENOMEM : c_int = 12;
2202             pub static EACCES : c_int = 13;
2203             pub static EFAULT : c_int = 14;
2204             pub static ENOTBLK : c_int = 15;
2205             pub static EBUSY : c_int = 16;
2206             pub static EEXIST : c_int = 17;
2207             pub static EXDEV : c_int = 18;
2208             pub static ENODEV : c_int = 19;
2209             pub static ENOTDIR : c_int = 20;
2210             pub static EISDIR : c_int = 21;
2211             pub static EINVAL : c_int = 22;
2212             pub static ENFILE : c_int = 23;
2213             pub static EMFILE : c_int = 24;
2214             pub static ENOTTY : c_int = 25;
2215             pub static ETXTBSY : c_int = 26;
2216             pub static EFBIG : c_int = 27;
2217             pub static ENOSPC : c_int = 28;
2218             pub static ESPIPE : c_int = 29;
2219             pub static EROFS : c_int = 30;
2220             pub static EMLINK : c_int = 31;
2221             pub static EPIPE : c_int = 32;
2222             pub static EDOM : c_int = 33;
2223             pub static ERANGE : c_int = 34;
2224             pub static EAGAIN : c_int = 35;
2225             pub static EWOULDBLOCK : c_int = EAGAIN;
2226             pub static EINPROGRESS : c_int = 36;
2227             pub static EALREADY : c_int = 37;
2228             pub static ENOTSOCK : c_int = 38;
2229             pub static EDESTADDRREQ : c_int = 39;
2230             pub static EMSGSIZE : c_int = 40;
2231             pub static EPROTOTYPE : c_int = 41;
2232             pub static ENOPROTOOPT : c_int = 42;
2233             pub static EPROTONOSUPPORT : c_int = 43;
2234             pub static ESOCKTNOSUPPORT : c_int = 44;
2235             pub static ENOTSUP : c_int = 45;
2236             pub static EPFNOSUPPORT : c_int = 46;
2237             pub static EAFNOSUPPORT : c_int = 47;
2238             pub static EADDRINUSE : c_int = 48;
2239             pub static EADDRNOTAVAIL : c_int = 49;
2240             pub static ENETDOWN : c_int = 50;
2241             pub static ENETUNREACH : c_int = 51;
2242             pub static ENETRESET : c_int = 52;
2243             pub static ECONNABORTED : c_int = 53;
2244             pub static ECONNRESET : c_int = 54;
2245             pub static ENOBUFS : c_int = 55;
2246             pub static EISCONN : c_int = 56;
2247             pub static ENOTCONN : c_int = 57;
2248             pub static ESHUTDOWN : c_int = 58;
2249             pub static ETOOMANYREFS : c_int = 59;
2250             pub static ETIMEDOUT : c_int = 60;
2251             pub static ECONNREFUSED : c_int = 61;
2252             pub static ELOOP : c_int = 62;
2253             pub static ENAMETOOLONG : c_int = 63;
2254             pub static EHOSTDOWN : c_int = 64;
2255             pub static EHOSTUNREACH : c_int = 65;
2256             pub static ENOTEMPTY : c_int = 66;
2257             pub static EPROCLIM : c_int = 67;
2258             pub static EUSERS : c_int = 68;
2259             pub static EDQUOT : c_int = 69;
2260             pub static ESTALE : c_int = 70;
2261             pub static EREMOTE : c_int = 71;
2262             pub static EBADRPC : c_int = 72;
2263             pub static ERPCMISMATCH : c_int = 73;
2264             pub static EPROGUNAVAIL : c_int = 74;
2265             pub static EPROGMISMATCH : c_int = 75;
2266             pub static EPROCUNAVAIL : c_int = 76;
2267             pub static ENOLCK : c_int = 77;
2268             pub static ENOSYS : c_int = 78;
2269             pub static EFTYPE : c_int = 79;
2270             pub static EAUTH : c_int = 80;
2271             pub static ENEEDAUTH : c_int = 81;
2272             pub static EPWROFF : c_int = 82;
2273             pub static EDEVERR : c_int = 83;
2274             pub static EOVERFLOW : c_int = 84;
2275             pub static EBADEXEC : c_int = 85;
2276             pub static EBADARCH : c_int = 86;
2277             pub static ESHLIBVERS : c_int = 87;
2278             pub static EBADMACHO : c_int = 88;
2279             pub static ECANCELED : c_int = 89;
2280             pub static EIDRM : c_int = 90;
2281             pub static ENOMSG : c_int = 91;
2282             pub static EILSEQ : c_int = 92;
2283             pub static ENOATTR : c_int = 93;
2284             pub static EBADMSG : c_int = 94;
2285             pub static EMULTIHOP : c_int = 95;
2286             pub static ENODATA : c_int = 96;
2287             pub static ENOLINK : c_int = 97;
2288             pub static ENOSR : c_int = 98;
2289             pub static ENOSTR : c_int = 99;
2290             pub static EPROTO : c_int = 100;
2291             pub static ETIME : c_int = 101;
2292             pub static EOPNOTSUPP : c_int = 102;
2293             pub static ENOPOLICY : c_int = 103;
2294             pub static ENOTRECOVERABLE : c_int = 104;
2295             pub static EOWNERDEAD : c_int = 105;
2296             pub static EQFULL : c_int = 106;
2297             pub static ELAST : c_int = 106;
2298         }
2299         pub mod posix01 {
2300             use libc::types::os::arch::c95::c_int;
2301
2302             pub static SIGTRAP : c_int = 5;
2303
2304             pub static GLOB_APPEND   : c_int = 0x0001;
2305             pub static GLOB_DOOFFS   : c_int = 0x0002;
2306             pub static GLOB_ERR      : c_int = 0x0004;
2307             pub static GLOB_MARK     : c_int = 0x0008;
2308             pub static GLOB_NOCHECK  : c_int = 0x0010;
2309             pub static GLOB_NOSORT   : c_int = 0x0020;
2310             pub static GLOB_NOESCAPE : c_int = 0x2000;
2311
2312             pub static GLOB_NOSPACE  : c_int = -1;
2313             pub static GLOB_ABORTED  : c_int = -2;
2314             pub static GLOB_NOMATCH  : c_int = -3;
2315
2316             pub static POSIX_MADV_NORMAL : c_int = 0;
2317             pub static POSIX_MADV_RANDOM : c_int = 1;
2318             pub static POSIX_MADV_SEQUENTIAL : c_int = 2;
2319             pub static POSIX_MADV_WILLNEED : c_int = 3;
2320             pub static POSIX_MADV_DONTNEED : c_int = 4;
2321
2322             pub static _SC_IOV_MAX : c_int = 56;
2323             pub static _SC_GETGR_R_SIZE_MAX : c_int = 70;
2324             pub static _SC_GETPW_R_SIZE_MAX : c_int = 71;
2325             pub static _SC_LOGIN_NAME_MAX : c_int = 73;
2326             pub static _SC_MQ_PRIO_MAX : c_int = 75;
2327             pub static _SC_THREAD_ATTR_STACKADDR : c_int = 82;
2328             pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
2329             pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
2330             pub static _SC_THREAD_KEYS_MAX : c_int = 86;
2331             pub static _SC_THREAD_PRIO_INHERIT : c_int = 87;
2332             pub static _SC_THREAD_PRIO_PROTECT : c_int = 88;
2333             pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
2334             pub static _SC_THREAD_PROCESS_SHARED : c_int = 90;
2335             pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
2336             pub static _SC_THREAD_STACK_MIN : c_int = 93;
2337             pub static _SC_THREAD_THREADS_MAX : c_int = 94;
2338             pub static _SC_THREADS : c_int = 96;
2339             pub static _SC_TTY_NAME_MAX : c_int = 101;
2340             pub static _SC_ATEXIT_MAX : c_int = 107;
2341             pub static _SC_XOPEN_CRYPT : c_int = 108;
2342             pub static _SC_XOPEN_ENH_I18N : c_int = 109;
2343             pub static _SC_XOPEN_LEGACY : c_int = 110;
2344             pub static _SC_XOPEN_REALTIME : c_int = 111;
2345             pub static _SC_XOPEN_REALTIME_THREADS : c_int = 112;
2346             pub static _SC_XOPEN_SHM : c_int = 113;
2347             pub static _SC_XOPEN_UNIX : c_int = 115;
2348             pub static _SC_XOPEN_VERSION : c_int = 116;
2349             pub static _SC_XOPEN_XCU_VERSION : c_int = 121;
2350         }
2351         pub mod posix08 {
2352         }
2353         pub mod bsd44 {
2354             use libc::types::os::arch::c95::c_int;
2355
2356             pub static MADV_NORMAL : c_int = 0;
2357             pub static MADV_RANDOM : c_int = 1;
2358             pub static MADV_SEQUENTIAL : c_int = 2;
2359             pub static MADV_WILLNEED : c_int = 3;
2360             pub static MADV_DONTNEED : c_int = 4;
2361             pub static MADV_FREE : c_int = 5;
2362             pub static MADV_ZERO_WIRED_PAGES : c_int = 6;
2363             pub static MADV_FREE_REUSABLE : c_int = 7;
2364             pub static MADV_FREE_REUSE : c_int = 8;
2365             pub static MADV_CAN_REUSE : c_int = 9;
2366
2367             pub static MINCORE_INCORE : c_int =  0x1;
2368             pub static MINCORE_REFERENCED : c_int = 0x2;
2369             pub static MINCORE_MODIFIED : c_int = 0x4;
2370             pub static MINCORE_REFERENCED_OTHER : c_int = 0x8;
2371             pub static MINCORE_MODIFIED_OTHER : c_int = 0x10;
2372         }
2373         pub mod extra {
2374             use libc::types::os::arch::c95::c_int;
2375
2376             pub static O_DSYNC : c_int = 4194304;
2377             pub static O_SYNC : c_int = 128;
2378             pub static F_FULLFSYNC : c_int = 51;
2379
2380             pub static MAP_COPY : c_int = 0x0002;
2381             pub static MAP_RENAME : c_int = 0x0020;
2382             pub static MAP_NORESERVE : c_int = 0x0040;
2383             pub static MAP_NOEXTEND : c_int = 0x0100;
2384             pub static MAP_HASSEMAPHORE : c_int = 0x0200;
2385             pub static MAP_NOCACHE : c_int = 0x0400;
2386             pub static MAP_JIT : c_int = 0x0800;
2387         }
2388     }
2389 }
2390
2391
2392 pub mod funcs {
2393     // Thankfull most of c95 is universally available and does not vary by OS
2394     // or anything. The same is not true of POSIX.
2395
2396     pub mod c95 {
2397         #[nolink]
2398         #[abi = "cdecl"]
2399         pub mod ctype {
2400             use libc::types::os::arch::c95::{c_char, c_int};
2401
2402             extern {
2403                 pub fn isalnum(c: c_int) -> c_int;
2404                 pub fn isalpha(c: c_int) -> c_int;
2405                 pub fn iscntrl(c: c_int) -> c_int;
2406                 pub fn isdigit(c: c_int) -> c_int;
2407                 pub fn isgraph(c: c_int) -> c_int;
2408                 pub fn islower(c: c_int) -> c_int;
2409                 pub fn isprint(c: c_int) -> c_int;
2410                 pub fn ispunct(c: c_int) -> c_int;
2411                 pub fn isspace(c: c_int) -> c_int;
2412                 pub fn isupper(c: c_int) -> c_int;
2413                 pub fn isxdigit(c: c_int) -> c_int;
2414                 pub fn tolower(c: c_char) -> c_char;
2415                 pub fn toupper(c: c_char) -> c_char;
2416             }
2417         }
2418
2419         #[nolink]
2420         #[abi = "cdecl"]
2421         pub mod stdio {
2422             use libc::types::common::c95::{FILE, c_void, fpos_t};
2423             use libc::types::os::arch::c95::{c_char, c_int, c_long, size_t};
2424
2425             extern {
2426                 pub fn fopen(filename: *c_char, mode: *c_char) -> *FILE;
2427                 pub fn freopen(filename: *c_char, mode: *c_char, file: *FILE)
2428                                -> *FILE;
2429                 pub fn fflush(file: *FILE) -> c_int;
2430                 pub fn fclose(file: *FILE) -> c_int;
2431                 pub fn remove(filename: *c_char) -> c_int;
2432                 pub fn rename(oldname: *c_char, newname: *c_char) -> c_int;
2433                 pub fn tmpfile() -> *FILE;
2434                 pub fn setvbuf(stream: *FILE,
2435                                buffer: *c_char,
2436                                mode: c_int,
2437                                size: size_t)
2438                                -> c_int;
2439                 pub fn setbuf(stream: *FILE, buf: *c_char);
2440                 // Omitted: printf and scanf variants.
2441                 pub fn fgetc(stream: *FILE) -> c_int;
2442                 #[fast_ffi]
2443                 pub fn fgets(buf: *mut c_char, n: c_int, stream: *FILE)
2444                              -> *c_char;
2445                 #[fast_ffi]
2446                 pub fn fputc(c: c_int, stream: *FILE) -> c_int;
2447                 #[fast_ffi]
2448                 pub fn fputs(s: *c_char, stream: *FILE) -> *c_char;
2449                 // Omitted: getc, getchar (might be macros).
2450
2451                 // Omitted: gets, so ridiculously unsafe that it should not
2452                 // survive.
2453
2454                 // Omitted: putc, putchar (might be macros).
2455                 pub fn puts(s: *c_char) -> c_int;
2456                 pub fn ungetc(c: c_int, stream: *FILE) -> c_int;
2457                 #[fast_ffi]
2458                 pub fn fread(ptr: *mut c_void,
2459                              size: size_t,
2460                              nobj: size_t,
2461                              stream: *FILE)
2462                              -> size_t;
2463                 #[fast_ffi]
2464                 pub fn fwrite(ptr: *c_void,
2465                               size: size_t,
2466                               nobj: size_t,
2467                               stream: *FILE)
2468                               -> size_t;
2469                 pub fn fseek(stream: *FILE, offset: c_long, whence: c_int)
2470                              -> c_int;
2471                 pub fn ftell(stream: *FILE) -> c_long;
2472                 pub fn rewind(stream: *FILE);
2473                 pub fn fgetpos(stream: *FILE, ptr: *fpos_t) -> c_int;
2474                 pub fn fsetpos(stream: *FILE, ptr: *fpos_t) -> c_int;
2475                 pub fn feof(stream: *FILE) -> c_int;
2476                 pub fn ferror(stream: *FILE) -> c_int;
2477                 pub fn perror(s: *c_char);
2478             }
2479         }
2480
2481         #[nolink]
2482         #[abi = "cdecl"]
2483         pub mod stdlib {
2484             use libc::types::common::c95::c_void;
2485             use libc::types::os::arch::c95::{c_char, c_double, c_int};
2486             use libc::types::os::arch::c95::{c_long, c_uint, c_ulong};
2487             use libc::types::os::arch::c95::{size_t};
2488
2489             extern {
2490                 pub fn abs(i: c_int) -> c_int;
2491                 pub fn labs(i: c_long) -> c_long;
2492                 // Omitted: div, ldiv (return pub type incomplete).
2493                 pub fn atof(s: *c_char) -> c_double;
2494                 pub fn atoi(s: *c_char) -> c_int;
2495                 pub fn strtod(s: *c_char, endp: **c_char) -> c_double;
2496                 pub fn strtol(s: *c_char, endp: **c_char, base: c_int)
2497                               -> c_long;
2498                 pub fn strtoul(s: *c_char, endp: **c_char, base: c_int)
2499                                -> c_ulong;
2500                 #[fast_ffi]
2501                 pub fn calloc(nobj: size_t, size: size_t) -> *c_void;
2502                 #[fast_ffi]
2503                 pub fn malloc(size: size_t) -> *c_void;
2504                 #[fast_ffi]
2505                 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
2506                 #[fast_ffi]
2507                 pub fn free(p: *c_void);
2508                 pub fn abort() -> !;
2509                 pub fn exit(status: c_int) -> !;
2510                 // Omitted: atexit.
2511                 pub fn system(s: *c_char) -> c_int;
2512                 pub fn getenv(s: *c_char) -> *c_char;
2513                 // Omitted: bsearch, qsort
2514                 pub fn rand() -> c_int;
2515                 pub fn srand(seed: c_uint);
2516             }
2517         }
2518
2519         #[nolink]
2520         #[abi = "cdecl"]
2521         pub mod string {
2522             use libc::types::common::c95::c_void;
2523             use libc::types::os::arch::c95::{c_char, c_int, size_t};
2524             use libc::types::os::arch::c95::{wchar_t};
2525
2526             extern {
2527                 pub fn strcpy(dst: *c_char, src: *c_char) -> *c_char;
2528                 pub fn strncpy(dst: *c_char, src: *c_char, n: size_t)
2529                                -> *c_char;
2530                 pub fn strcat(s: *c_char, ct: *c_char) -> *c_char;
2531                 pub fn strncat(s: *c_char, ct: *c_char, n: size_t) -> *c_char;
2532                 pub fn strcmp(cs: *c_char, ct: *c_char) -> c_int;
2533                 pub fn strncmp(cs: *c_char, ct: *c_char, n: size_t) -> c_int;
2534                 pub fn strcoll(cs: *c_char, ct: *c_char) -> c_int;
2535                 pub fn strchr(cs: *c_char, c: c_int) -> *c_char;
2536                 pub fn strrchr(cs: *c_char, c: c_int) -> *c_char;
2537                 pub fn strspn(cs: *c_char, ct: *c_char) -> size_t;
2538                 pub fn strcspn(cs: *c_char, ct: *c_char) -> size_t;
2539                 pub fn strpbrk(cs: *c_char, ct: *c_char) -> *c_char;
2540                 pub fn strstr(cs: *c_char, ct: *c_char) -> *c_char;
2541                 pub fn strlen(cs: *c_char) -> size_t;
2542                 pub fn strerror(n: c_int) -> *c_char;
2543                 pub fn strtok(s: *c_char, t: *c_char) -> *c_char;
2544                 pub fn strxfrm(s: *c_char, ct: *c_char, n: size_t) -> size_t;
2545                 pub fn wcslen(buf: *wchar_t) -> size_t;
2546
2547                 // Omitted: memcpy, memmove, memset (provided by LLVM)
2548
2549                 // These are fine to execute on the Rust stack. They must be,
2550                 // in fact, because LLVM generates calls to them!
2551                 #[rust_stack]
2552                 #[inline]
2553                 pub fn memcmp(cx: *c_void, ct: *c_void, n: size_t) -> c_int;
2554                 #[rust_stack]
2555                 #[inline]
2556                 pub fn memchr(cx: *c_void, c: c_int, n: size_t) -> *c_void;
2557             }
2558         }
2559     }
2560
2561     // Microsoft helpfully underscore-qualifies all of its POSIX-like symbols
2562     // to make sure you don't use them accidentally. It also randomly deviates
2563     // from the exact signatures you might otherwise expect, and omits much,
2564     // so be careful when trying to write portable code; it won't always work
2565     // with the same POSIX functions and types as other platforms.
2566
2567     #[cfg(target_os = "win32")]
2568     pub mod posix88 {
2569         #[nolink]
2570         #[abi = "cdecl"]
2571         pub mod stat_ {
2572             use libc::types::os::common::posix01::stat;
2573             use libc::types::os::arch::c95::{c_int, c_char};
2574
2575             extern {
2576                 #[link_name = "_chmod"]
2577                 pub fn chmod(path: *c_char, mode: c_int) -> c_int;
2578                 #[link_name = "_mkdir"]
2579                 pub fn mkdir(path: *c_char) -> c_int;
2580                 #[link_name = "_fstat64"]
2581                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
2582                 #[link_name = "_stat64"]
2583                 pub fn stat(path: *c_char, buf: *mut stat) -> c_int;
2584             }
2585         }
2586
2587         #[nolink]
2588         #[abi = "cdecl"]
2589         pub mod stdio {
2590             use libc::types::common::c95::FILE;
2591             use libc::types::os::arch::c95::{c_int, c_char};
2592
2593             extern {
2594                 #[link_name = "_popen"]
2595                 pub fn popen(command: *c_char, mode: *c_char) -> *FILE;
2596                 #[link_name = "_pclose"]
2597                 pub fn pclose(stream: *FILE) -> c_int;
2598                 #[link_name = "_fdopen"]
2599                 #[fast_ffi]
2600                 pub fn fdopen(fd: c_int, mode: *c_char) -> *FILE;
2601                 #[link_name = "_fileno"]
2602                 pub fn fileno(stream: *FILE) -> c_int;
2603             }
2604         }
2605
2606         #[nolink]
2607         #[abi = "cdecl"]
2608         pub mod fcntl {
2609             use libc::types::os::arch::c95::{c_int, c_char};
2610             extern {
2611                 #[link_name = "_open"]
2612                 pub fn open(path: *c_char, oflag: c_int, mode: c_int)
2613                             -> c_int;
2614                 #[link_name = "_creat"]
2615                 pub fn creat(path: *c_char, mode: c_int) -> c_int;
2616             }
2617         }
2618
2619         #[nolink]
2620         #[abi = "cdecl"]
2621         pub mod dirent {
2622             // Not supplied at all.
2623         }
2624
2625         #[nolink]
2626         #[abi = "cdecl"]
2627         pub mod unistd {
2628             use libc::types::common::c95::c_void;
2629             use libc::types::os::arch::c95::{c_int, c_uint, c_char,
2630                                              c_long, size_t};
2631             use libc::types::os::arch::c99::intptr_t;
2632
2633             extern {
2634                 #[link_name = "_access"]
2635                 pub fn access(path: *c_char, amode: c_int) -> c_int;
2636                 #[link_name = "_chdir"]
2637                 pub fn chdir(dir: *c_char) -> c_int;
2638                 #[link_name = "_close"]
2639                 pub fn close(fd: c_int) -> c_int;
2640                 #[link_name = "_dup"]
2641                 pub fn dup(fd: c_int) -> c_int;
2642                 #[link_name = "_dup2"]
2643                 pub fn dup2(src: c_int, dst: c_int) -> c_int;
2644                 #[link_name = "_execv"]
2645                 pub fn execv(prog: *c_char, argv: **c_char) -> intptr_t;
2646                 #[link_name = "_execve"]
2647                 pub fn execve(prog: *c_char, argv: **c_char, envp: **c_char)
2648                               -> c_int;
2649                 #[link_name = "_execvp"]
2650                 pub fn execvp(c: *c_char, argv: **c_char) -> c_int;
2651                 #[link_name = "_execvpe"]
2652                 pub fn execvpe(c: *c_char, argv: **c_char, envp: **c_char)
2653                                -> c_int;
2654                 #[link_name = "_getcwd"]
2655                 pub fn getcwd(buf: *mut c_char, size: size_t) -> *c_char;
2656                 #[link_name = "_getpid"]
2657                 pub fn getpid() -> c_int;
2658                 #[link_name = "_isatty"]
2659                 pub fn isatty(fd: c_int) -> c_int;
2660                 #[link_name = "_lseek"]
2661                 pub fn lseek(fd: c_int, offset: c_long, origin: c_int)
2662                              -> c_long;
2663                 #[link_name = "_pipe"]
2664                 pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int)
2665                             -> c_int;
2666                 #[link_name = "_read"]
2667                 #[fast_ffi]
2668                 pub fn read(fd: c_int, buf: *mut c_void, count: c_uint)
2669                             -> c_int;
2670                 #[link_name = "_rmdir"]
2671                 pub fn rmdir(path: *c_char) -> c_int;
2672                 #[link_name = "_unlink"]
2673                 pub fn unlink(c: *c_char) -> c_int;
2674                 #[link_name = "_write"]
2675                 #[fast_ffi]
2676                 pub fn write(fd: c_int, buf: *c_void, count: c_uint) -> c_int;
2677             }
2678         }
2679
2680         pub mod mman {
2681         }
2682     }
2683
2684
2685     #[cfg(target_os = "linux")]
2686     #[cfg(target_os = "android")]
2687     #[cfg(target_os = "macos")]
2688     #[cfg(target_os = "freebsd")]
2689     pub mod posix88 {
2690         pub mod stat_ {
2691             use libc::types::os::arch::c95::{c_char, c_int};
2692             use libc::types::os::arch::posix01::stat;
2693             use libc::types::os::arch::posix88::mode_t;
2694
2695             #[nolink]
2696             #[abi = "cdecl"]
2697             extern {
2698                 pub fn chmod(path: *c_char, mode: mode_t) -> c_int;
2699                 pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
2700
2701                 #[cfg(target_os = "linux")]
2702                 #[cfg(target_os = "freebsd")]
2703                 #[cfg(target_os = "android")]
2704                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
2705
2706                 #[cfg(target_os = "macos")]
2707                 #[link_name = "fstat64"]
2708                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
2709
2710                 pub fn mkdir(path: *c_char, mode: mode_t) -> c_int;
2711                 pub fn mkfifo(path: *c_char, mode: mode_t) -> c_int;
2712
2713                 #[cfg(target_os = "linux")]
2714                 #[cfg(target_os = "freebsd")]
2715                 #[cfg(target_os = "android")]
2716                 pub fn stat(path: *c_char, buf: *mut stat) -> c_int;
2717
2718                 #[cfg(target_os = "macos")]
2719                 #[link_name = "stat64"]
2720                 pub fn stat(path: *c_char, buf: *mut stat) -> c_int;
2721             }
2722         }
2723
2724         #[nolink]
2725         #[abi = "cdecl"]
2726         pub mod stdio {
2727             use libc::types::common::c95::FILE;
2728             use libc::types::os::arch::c95::{c_char, c_int};
2729
2730             extern {
2731                 pub fn popen(command: *c_char, mode: *c_char) -> *FILE;
2732                 pub fn pclose(stream: *FILE) -> c_int;
2733                 pub fn fdopen(fd: c_int, mode: *c_char) -> *FILE;
2734                 pub fn fileno(stream: *FILE) -> c_int;
2735             }
2736         }
2737
2738         #[nolink]
2739         #[abi = "cdecl"]
2740         pub mod fcntl {
2741             use libc::types::os::arch::c95::{c_char, c_int};
2742             use libc::types::os::arch::posix88::mode_t;
2743
2744             extern {
2745                 pub fn open(path: *c_char, oflag: c_int, mode: c_int)
2746                             -> c_int;
2747                 pub fn creat(path: *c_char, mode: mode_t) -> c_int;
2748                 pub fn fcntl(fd: c_int, cmd: c_int) -> c_int;
2749             }
2750         }
2751
2752         #[nolink]
2753         #[abi = "cdecl"]
2754         pub mod dirent {
2755             use libc::types::common::posix88::{DIR, dirent_t};
2756             use libc::types::os::arch::c95::{c_char, c_int, c_long};
2757
2758             // NB: On OS X opendir and readdir have two versions,
2759             // one for 32-bit kernelspace and one for 64.
2760             // We should be linking to the 64-bit ones, called
2761             // opendir$INODE64, etc. but for some reason rustc
2762             // doesn't link it correctly on i686, so we're going
2763             // through a C function that mysteriously does work.
2764             pub unsafe fn opendir(dirname: *c_char) -> *DIR {
2765                 rust_opendir(dirname)
2766             }
2767             pub unsafe fn readdir(dirp: *DIR) -> *dirent_t {
2768                 rust_readdir(dirp)
2769             }
2770
2771             extern {
2772                 fn rust_opendir(dirname: *c_char) -> *DIR;
2773                 fn rust_readdir(dirp: *DIR) -> *dirent_t;
2774             }
2775
2776             extern {
2777                 pub fn closedir(dirp: *DIR) -> c_int;
2778                 pub fn rewinddir(dirp: *DIR);
2779                 pub fn seekdir(dirp: *DIR, loc: c_long);
2780                 pub fn telldir(dirp: *DIR) -> c_long;
2781             }
2782         }
2783
2784         #[nolink]
2785         #[abi = "cdecl"]
2786         pub mod unistd {
2787             use libc::types::common::c95::c_void;
2788             use libc::types::os::arch::c95::{c_char, c_int, c_long, c_uint};
2789             use libc::types::os::arch::c95::{size_t};
2790             use libc::types::os::arch::posix88::{gid_t, off_t, pid_t};
2791             use libc::types::os::arch::posix88::{ssize_t, uid_t};
2792
2793             extern {
2794                 pub fn access(path: *c_char, amode: c_int) -> c_int;
2795                 pub fn alarm(seconds: c_uint) -> c_uint;
2796                 pub fn chdir(dir: *c_char) -> c_int;
2797                 pub fn chown(path: *c_char, uid: uid_t, gid: gid_t) -> c_int;
2798                 pub fn close(fd: c_int) -> c_int;
2799                 pub fn dup(fd: c_int) -> c_int;
2800                 pub fn dup2(src: c_int, dst: c_int) -> c_int;
2801                 pub fn execv(prog: *c_char, argv: **c_char) -> c_int;
2802                 pub fn execve(prog: *c_char, argv: **c_char, envp: **c_char)
2803                               -> c_int;
2804                 pub fn execvp(c: *c_char, argv: **c_char) -> c_int;
2805                 pub fn fork() -> pid_t;
2806                 pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
2807                 pub fn getcwd(buf: *mut c_char, size: size_t) -> *c_char;
2808                 pub fn getegid() -> gid_t;
2809                 pub fn geteuid() -> uid_t;
2810                 pub fn getgid() -> gid_t ;
2811                 pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t)
2812                                  -> c_int;
2813                 pub fn getlogin() -> *c_char;
2814                 pub fn getopt(argc: c_int, argv: **c_char, optstr: *c_char)
2815                               -> c_int;
2816                 pub fn getpgrp() -> pid_t;
2817                 pub fn getpid() -> pid_t;
2818                 pub fn getppid() -> pid_t;
2819                 pub fn getuid() -> uid_t;
2820                 pub fn isatty(fd: c_int) -> c_int;
2821                 pub fn link(src: *c_char, dst: *c_char) -> c_int;
2822                 pub fn lseek(fd: c_int, offset: off_t, whence: c_int)
2823                              -> off_t;
2824                 pub fn pathconf(path: *c_char, name: c_int) -> c_long;
2825                 pub fn pause() -> c_int;
2826                 pub fn pipe(fds: *mut c_int) -> c_int;
2827                 #[fast_ffi]
2828                 pub fn read(fd: c_int, buf: *mut c_void, count: size_t)
2829                             -> ssize_t;
2830                 pub fn rmdir(path: *c_char) -> c_int;
2831                 pub fn setgid(gid: gid_t) -> c_int;
2832                 pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
2833                 pub fn setsid() -> pid_t;
2834                 pub fn setuid(uid: uid_t) -> c_int;
2835                 pub fn sleep(secs: c_uint) -> c_uint;
2836                 pub fn sysconf(name: c_int) -> c_long;
2837                 pub fn tcgetpgrp(fd: c_int) -> pid_t;
2838                 pub fn ttyname(fd: c_int) -> *c_char;
2839                 pub fn unlink(c: *c_char) -> c_int;
2840                 #[fast_ffi]
2841                 pub fn write(fd: c_int, buf: *c_void, count: size_t)
2842                              -> ssize_t;
2843             }
2844         }
2845
2846         #[nolink]
2847         #[abi = "cdecl"]
2848         pub mod signal {
2849             use libc::types::os::arch::c95::{c_int};
2850             use libc::types::os::arch::posix88::{pid_t};
2851
2852             extern {
2853                 pub fn kill(pid: pid_t, sig: c_int) -> c_int;
2854             }
2855         }
2856
2857         #[nolink]
2858         #[abi = "cdecl"]
2859         pub mod mman {
2860             use libc::types::common::c95::{c_void};
2861             use libc::types::os::arch::c95::{size_t, c_int, c_char};
2862             use libc::types::os::arch::posix88::{mode_t, off_t};
2863
2864             extern {
2865                 pub fn mlock(addr: *c_void, len: size_t) -> c_int;
2866                 pub fn munlock(addr: *c_void, len: size_t) -> c_int;
2867                 pub fn mlockall(flags: c_int) -> c_int;
2868                 pub fn munlockall() -> c_int;
2869
2870                 pub fn mmap(addr: *c_void,
2871                             len: size_t,
2872                             prot: c_int,
2873                             flags: c_int,
2874                             fd: c_int,
2875                             offset: off_t)
2876                             -> *mut c_void;
2877                 pub fn munmap(addr: *c_void, len: size_t) -> c_int;
2878
2879                 pub fn mprotect(addr: *c_void, len: size_t, prot: c_int)
2880                                 -> c_int;
2881
2882                 pub fn msync(addr: *c_void, len: size_t, flags: c_int)
2883                              -> c_int;
2884                 pub fn shm_open(name: *c_char, oflag: c_int, mode: mode_t)
2885                                 -> c_int;
2886                 pub fn shm_unlink(name: *c_char) -> c_int;
2887             }
2888         }
2889     }
2890
2891     #[cfg(target_os = "linux")]
2892     #[cfg(target_os = "android")]
2893     #[cfg(target_os = "macos")]
2894     #[cfg(target_os = "freebsd")]
2895     pub mod posix01 {
2896         #[nolink]
2897         #[abi = "cdecl"]
2898         pub mod stat_ {
2899             use libc::types::os::arch::c95::{c_char, c_int};
2900             use libc::types::os::arch::posix01::stat;
2901
2902             extern {
2903                 #[cfg(target_os = "linux")]
2904                 #[cfg(target_os = "freebsd")]
2905                 #[cfg(target_os = "android")]
2906                 pub fn lstat(path: *c_char, buf: *mut stat) -> c_int;
2907
2908                 #[cfg(target_os = "macos")]
2909                 #[link_name = "lstat64"]
2910                 pub fn lstat(path: *c_char, buf: *mut stat) -> c_int;
2911             }
2912         }
2913
2914         #[nolink]
2915         #[abi = "cdecl"]
2916         pub mod unistd {
2917             use libc::types::os::arch::c95::{c_char, c_int, size_t};
2918             use libc::types::os::arch::posix88::{ssize_t};
2919
2920             extern {
2921                 pub fn readlink(path: *c_char,
2922                                 buf: *mut c_char,
2923                                 bufsz: size_t)
2924                                 -> ssize_t;
2925
2926                 pub fn fsync(fd: c_int) -> c_int;
2927
2928                 #[cfg(target_os = "linux")]
2929                 #[cfg(target_os = "android")]
2930                 pub fn fdatasync(fd: c_int) -> c_int;
2931
2932                 pub fn setenv(name: *c_char, val: *c_char, overwrite: c_int)
2933                               -> c_int;
2934                 pub fn unsetenv(name: *c_char) -> c_int;
2935                 pub fn putenv(string: *c_char) -> c_int;
2936
2937                 pub fn symlink(path1: *c_char, path2: *c_char) -> c_int;
2938             }
2939         }
2940
2941         #[nolink]
2942         #[abi = "cdecl"]
2943         pub mod wait {
2944             use libc::types::os::arch::c95::{c_int};
2945             use libc::types::os::arch::posix88::{pid_t};
2946
2947             extern {
2948                 pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int)
2949                                -> pid_t;
2950             }
2951         }
2952
2953         #[nolink]
2954         #[abi = "cdecl"]
2955         pub mod glob {
2956             use libc::types::common::c95::{c_void};
2957             use libc::types::os::arch::c95::{c_char, c_int};
2958             use libc::types::os::common::posix01::{glob_t};
2959
2960             extern {
2961                 pub fn glob(pattern: *c_char,
2962                             flags: c_int,
2963                             errfunc: *c_void, // XXX callback
2964                             pglob: *mut glob_t);
2965                 pub fn globfree(pglob: *mut glob_t);
2966             }
2967         }
2968
2969         #[nolink]
2970         #[abi = "cdecl"]
2971         pub mod mman {
2972             use libc::types::common::c95::{c_void};
2973             use libc::types::os::arch::c95::{c_int, size_t};
2974
2975             extern {
2976                 pub fn posix_madvise(addr: *c_void,
2977                                      len: size_t,
2978                                      advice: c_int)
2979                                      -> c_int;
2980             }
2981         }
2982     }
2983
2984     #[cfg(target_os = "win32")]
2985     pub mod posix01 {
2986         pub mod stat_ {
2987         }
2988
2989         pub mod unistd {
2990         }
2991
2992         pub mod glob {
2993         }
2994
2995         pub mod mman {
2996         }
2997     }
2998
2999
3000     #[cfg(target_os = "win32")]
3001     #[cfg(target_os = "linux")]
3002     #[cfg(target_os = "android")]
3003     #[cfg(target_os = "macos")]
3004     #[cfg(target_os = "freebsd")]
3005     pub mod posix08 {
3006         pub mod unistd {
3007         }
3008     }
3009
3010
3011     #[cfg(target_os = "macos")]
3012     #[cfg(target_os = "freebsd")]
3013     pub mod bsd44 {
3014         use libc::types::common::c95::{c_void};
3015         use libc::types::os::arch::c95::{c_char, c_uchar, c_int, c_uint,
3016                                          size_t};
3017
3018         #[abi = "cdecl"]
3019         extern {
3020             pub fn sysctl(name: *c_int,
3021                           namelen: c_uint,
3022                           oldp: *mut c_void,
3023                           oldlenp: *mut size_t,
3024                           newp: *c_void,
3025                           newlen: size_t)
3026                           -> c_int;
3027             pub fn sysctlbyname(name: *c_char,
3028                                 oldp: *mut c_void,
3029                                 oldlenp: *mut size_t,
3030                                 newp: *c_void,
3031                                 newlen: size_t)
3032                                 -> c_int;
3033             pub fn sysctlnametomib(name: *c_char,
3034                                    mibp: *mut c_int,
3035                                    sizep: *mut size_t)
3036                                    -> c_int;
3037             pub fn getdtablesize() -> c_int;
3038             pub fn madvise(addr: *c_void, len: size_t, advice: c_int)
3039                            -> c_int;
3040             pub fn mincore(addr: *c_void, len: size_t, vec: *c_uchar)
3041                            -> c_int;
3042         }
3043     }
3044
3045
3046     #[cfg(target_os = "linux")]
3047     #[cfg(target_os = "android")]
3048     pub mod bsd44 {
3049         use libc::types::common::c95::{c_void};
3050         use libc::types::os::arch::c95::{c_uchar, c_int, size_t};
3051
3052         #[abi = "cdecl"]
3053         extern {
3054             pub fn getdtablesize() -> c_int;
3055             pub fn madvise(addr: *c_void, len: size_t, advice: c_int)
3056                            -> c_int;
3057             pub fn mincore(addr: *c_void, len: size_t, vec: *c_uchar)
3058                            -> c_int;
3059         }
3060     }
3061
3062
3063     #[cfg(target_os = "win32")]
3064     pub mod bsd44 {
3065     }
3066
3067     #[cfg(target_os = "macos")]
3068     #[nolink]
3069     pub mod extra {
3070         use libc::types::os::arch::c95::{c_char, c_int};
3071
3072         #[abi = "cdecl"]
3073         extern {
3074             pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
3075                                         -> c_int;
3076         }
3077     }
3078
3079     #[cfg(target_os = "freebsd")]
3080     pub mod extra {
3081     }
3082
3083     #[cfg(target_os = "linux")]
3084     #[cfg(target_os = "android")]
3085     pub mod extra {
3086     }
3087
3088
3089     #[cfg(target_os = "win32")]
3090     pub mod extra {
3091
3092         pub mod kernel32 {
3093             use libc::types::os::arch::c95::{c_uint};
3094             use libc::types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE};
3095             use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPCTSTR,
3096                                                LPTSTR, LPTCH, LPDWORD, LPVOID,
3097                                                LPCVOID};
3098             use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, LPSTARTUPINFO,
3099                                                LPPROCESS_INFORMATION,
3100                                                LPMEMORY_BASIC_INFORMATION,
3101                                                LPSYSTEM_INFO};
3102             use libc::types::os::arch::extra::{HANDLE, LPHANDLE};
3103
3104             #[abi = "stdcall"]
3105             extern "stdcall" {
3106                 pub fn GetEnvironmentVariableW(n: LPCWSTR,
3107                                                v: LPWSTR,
3108                                                nsize: DWORD)
3109                                                -> DWORD;
3110                 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
3111                                                -> BOOL;
3112                 pub fn GetEnvironmentStringsA() -> LPTCH;
3113                 pub fn FreeEnvironmentStringsA(env_ptr: LPTCH) -> BOOL;
3114                 pub fn GetModuleFileNameW(hModule: HMODULE,
3115                                           lpFilename: LPWSTR,
3116                                           nSize: DWORD)
3117                                           -> DWORD;
3118                 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
3119                                         lpSecurityAttributes:
3120                                         LPSECURITY_ATTRIBUTES)
3121                                         -> BOOL;
3122                 pub fn CopyFileW(lpExistingFileName: LPCWSTR,
3123                                         lpNewFileName: LPCWSTR,
3124                                         bFailIfExists: BOOL)
3125                                         -> BOOL;
3126                 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
3127                 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
3128                 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
3129                 pub fn GetLastError() -> DWORD;
3130                 pub fn FindFirstFileW(fileName: *u16, findFileData: HANDLE)
3131                                       -> HANDLE;
3132                 pub fn FindNextFileW(findFile: HANDLE, findFileData: HANDLE)
3133                                      -> BOOL;
3134                 pub fn FindClose(findFile: HANDLE) -> BOOL;
3135                 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
3136                                        hSourceHandle: HANDLE,
3137                                        hTargetProcessHandle: HANDLE,
3138                                        lpTargetHandle: LPHANDLE,
3139                                        dwDesiredAccess: DWORD,
3140                                        bInheritHandle: BOOL,
3141                                        dwOptions: DWORD)
3142                                        -> BOOL;
3143                 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
3144                 pub fn OpenProcess(dwDesiredAccess: DWORD,
3145                                    bInheritHandle: BOOL,
3146                                    dwProcessId: DWORD)
3147                                    -> HANDLE;
3148                 pub fn GetCurrentProcess() -> HANDLE;
3149                 pub fn CreateProcessA(lpApplicationName: LPCTSTR,
3150                                       lpCommandLine: LPTSTR,
3151                                       lpProcessAttributes:
3152                                       LPSECURITY_ATTRIBUTES,
3153                                       lpThreadAttributes:
3154                                       LPSECURITY_ATTRIBUTES,
3155                                       bInheritHandles: BOOL,
3156                                       dwCreationFlags: DWORD,
3157                                       lpEnvironment: LPVOID,
3158                                       lpCurrentDirectory: LPCTSTR,
3159                                       lpStartupInfo: LPSTARTUPINFO,
3160                                       lpProcessInformation:
3161                                       LPPROCESS_INFORMATION)
3162                                       -> BOOL;
3163                 pub fn WaitForSingleObject(hHandle: HANDLE,
3164                                            dwMilliseconds: DWORD)
3165                                            -> DWORD;
3166                 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint)
3167                                         -> BOOL;
3168                 pub fn GetExitCodeProcess(hProcess: HANDLE,
3169                                           lpExitCode: LPDWORD)
3170                                           -> BOOL;
3171                 pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO);
3172                 pub fn VirtualAlloc(lpAddress: LPVOID,
3173                                     dwSize: SIZE_T,
3174                                     flAllocationType: DWORD,
3175                                     flProtect: DWORD)
3176                                     -> LPVOID;
3177                 pub fn VirtualFree(lpAddress: LPVOID,
3178                                    dwSize: SIZE_T,
3179                                    dwFreeType: DWORD)
3180                                    -> BOOL;
3181                 pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL;
3182                 pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T)
3183                                      -> BOOL;
3184                 pub fn VirtualProtect(lpAddress: LPVOID,
3185                                       dwSize: SIZE_T,
3186                                       flNewProtect: DWORD,
3187                                       lpflOldProtect: LPDWORD)
3188                                       -> BOOL;
3189                 pub fn VirtualQuery(lpAddress: LPCVOID,
3190                                     lpBuffer: LPMEMORY_BASIC_INFORMATION,
3191                                     dwLength: SIZE_T)
3192                                     -> SIZE_T;
3193                 pub fn CreateFileMappingW(hFile: HANDLE,
3194                                           lpAttributes: LPSECURITY_ATTRIBUTES,
3195                                           flProtect: DWORD,
3196                                           dwMaximumSizeHigh: DWORD,
3197                                           dwMaximumSizeLow: DWORD,
3198                                           lpName: LPCTSTR)
3199                                           -> HANDLE;
3200                 pub fn MapViewOfFile(hFileMappingObject: HANDLE,
3201                                      dwDesiredAccess: DWORD,
3202                                      dwFileOffsetHigh: DWORD,
3203                                      dwFileOffsetLow: DWORD,
3204                                      dwNumberOfBytesToMap: SIZE_T)
3205                                      -> LPVOID;
3206                 pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL;
3207             }
3208         }
3209
3210         pub mod msvcrt {
3211             use libc::types::os::arch::c95::{c_int, c_long};
3212
3213             #[abi = "cdecl"]
3214             #[nolink]
3215             extern {
3216                 #[link_name = "_commit"]
3217                 pub fn commit(fd: c_int) -> c_int;
3218
3219                 #[link_name = "_get_osfhandle"]
3220                 pub fn get_osfhandle(fd: c_int) -> c_long;
3221             }
3222         }
3223     }
3224 }