]> git.lizzy.rs Git - rust.git/blob - src/liblibc/lib.rs
f7e92d614746c909bc84e60da47cda5e224dea31
[rust.git] / src / liblibc / lib.rs
1 // Copyright 2012-2015 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 // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
12 #![cfg_attr(stage0, feature(custom_attribute))]
13 #![crate_name = "libc"]
14 #![crate_type = "rlib"]
15 #![cfg_attr(not(feature = "cargo-build"), unstable(feature = "libc"))]
16 #![cfg_attr(not(feature = "cargo-build"), feature(staged_api, core, no_std))]
17 #![cfg_attr(not(feature = "cargo-build"), staged_api)]
18 #![cfg_attr(not(feature = "cargo-build"), no_std)]
19 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
20        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
21        html_root_url = "http://doc.rust-lang.org/nightly/",
22        html_playground_url = "http://play.rust-lang.org/")]
23 #![cfg_attr(test, feature(test))]
24
25 //! Bindings for the C standard library and other platform libraries
26 //!
27 //! **NOTE:** These are *architecture and libc* specific. On Linux, these
28 //! bindings are only correct for glibc.
29 //!
30 //! This module contains bindings to the C standard library, organized into
31 //! modules by their defining standard.  Additionally, it contains some assorted
32 //! platform-specific definitions.  For convenience, most functions and types
33 //! are reexported, so `use libc::*` will import the available C bindings as
34 //! appropriate for the target platform. The exact set of functions available
35 //! are platform specific.
36 //!
37 //! *Note:* Because these definitions are platform-specific, some may not appear
38 //! in the generated documentation.
39 //!
40 //! We consider the following specs reasonably normative with respect to
41 //! interoperating with the C standard library (libc/msvcrt):
42 //!
43 //! * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995.
44 //! * ISO 9899:1999 ('C99' or 'C9x').
45 //! * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1').
46 //! * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3').
47 //! * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4').
48 //!
49 //! Note that any reference to the 1996 revision of POSIX, or any revs between
50 //! 1990 (when '88 was approved at ISO) and 2001 (when the next actual
51 //! revision-revision happened), are merely additions of other chapters (1b and
52 //! 1c) outside the core interfaces.
53 //!
54 //! Despite having several names each, these are *reasonably* coherent
55 //! point-in-time, list-of-definition sorts of specs. You can get each under a
56 //! variety of names but will wind up with the same definition in each case.
57 //!
58 //! See standards(7) in linux-manpages for more details.
59 //!
60 //! Our interface to these libraries is complicated by the non-universality of
61 //! conformance to any of them. About the only thing universally supported is
62 //! the first (C95), beyond that definitions quickly become absent on various
63 //! platforms.
64 //!
65 //! We therefore wind up dividing our module-space up (mostly for the sake of
66 //! sanity while editing, filling-in-details and eliminating duplication) into
67 //! definitions common-to-all (held in modules named c95, c99, posix88, posix01
68 //! and posix08) and definitions that appear only on *some* platforms (named
69 //! 'extra'). This would be things like significant OSX foundation kit, or Windows
70 //! library kernel32.dll, or various fancy glibc, Linux or BSD extensions.
71 //!
72 //! In addition to the per-platform 'extra' modules, we define a module of
73 //! 'common BSD' libc routines that never quite made it into POSIX but show up
74 //! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final
75 //! one from Berkeley after the lawsuits died down and the CSRG dissolved.
76
77 #![allow(bad_style, raw_pointer_derive)]
78 #![cfg_attr(target_os = "nacl", allow(unused_imports))]
79 #[cfg(feature = "cargo-build")] extern crate std as core;
80 #[cfg(not(feature = "cargo-build"))] extern crate core;
81
82 #[cfg(test)] extern crate std;
83 #[cfg(test)] extern crate test;
84
85 // Explicit export lists for the intersection (provided here) mean that
86 // you can write more-platform-agnostic code if you stick to just these
87 // symbols.
88
89 pub use types::common::c95::*;
90 pub use types::common::c99::*;
91 pub use types::common::posix88::*;
92 pub use types::os::common::posix01::*;
93 pub use types::os::common::bsd44::*;
94 pub use types::os::arch::c95::*;
95 pub use types::os::arch::c99::*;
96 pub use types::os::arch::posix88::*;
97 pub use types::os::arch::posix01::*;
98 pub use types::os::arch::extra::*;
99
100 pub use consts::os::c95::*;
101 pub use consts::os::posix88::*;
102 pub use consts::os::posix01::*;
103 pub use consts::os::bsd44::*;
104 pub use consts::os::extra::*;
105
106 pub use funcs::c95::ctype::*;
107 pub use funcs::c95::stdio::*;
108 pub use funcs::c95::stdlib::*;
109 pub use funcs::c95::string::*;
110 pub use funcs::posix88::fcntl::*;
111 pub use funcs::posix88::stat_::*;
112 pub use funcs::posix88::stdio::*;
113 pub use funcs::posix88::unistd::*;
114
115 pub use funcs::bsd43::*;
116
117 // But we also reexport most everything
118 // if you're interested in writing platform-specific code.
119
120 // FIXME: This is a mess, but the design of this entire module needs to be
121 // reconsidered, so I'm not inclined to do better right now. As part of
122 // #11870 I removed all the pub globs here, leaving explicit reexports
123 // of everything that is actually used in-tree.
124 //
125 // So the following exports don't follow any particular plan.
126
127 #[cfg(unix)] pub use consts::os::sysconf::*;
128
129 #[cfg(unix)] pub use funcs::posix88::mman::*;
130 #[cfg(unix)] pub use funcs::posix88::dirent::*;
131 #[cfg(unix)] pub use funcs::posix88::net::*;
132 #[cfg(unix)] pub use funcs::posix01::stat_::*;
133 #[cfg(unix)] pub use funcs::posix01::unistd::*;
134 #[cfg(unix)] pub use funcs::posix01::resource::*;
135
136
137 #[cfg(windows)] pub use funcs::extra::kernel32::*;
138 #[cfg(windows)] pub use funcs::extra::winsock::*;
139 #[cfg(windows)] pub use funcs::extra::msvcrt::*;
140
141 // On NaCl, these libraries are static. Thus it would be a Bad Idea to link them
142 // in when creating a test crate.
143 #[cfg(not(any(windows, all(target_os = "nacl", test))))]
144 #[link(name = "c")]
145 #[link(name = "m")]
146 extern {}
147
148 // libnacl provides functions that require a trip through the IRT to work.
149 // ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip
150 // to the kernel.
151 #[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))]
152 #[link(name = "nacl", kind = "static")]
153 extern {}
154
155 // pnaclmm provides a number of functions that the toolchain's Clang emits calls
156 // to when codegening atomic ops. All the functions within wrap various atomic
157 // operations.
158 // Yes, it could be linked by rustc explicitly, however by linking it here
159 // instead we save a bit of time where bins are involved (by not running the
160 // optimizations on the whole pnaclmm foreach binary built).
161 #[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))]
162 #[link(name = "pnaclmm", kind = "static")]
163 extern {}
164
165 pub mod types {
166
167     // Types tend to vary *per architecture* so we pull their definitions out
168     // into this module.
169
170     // Standard types that are opaque or common, so are not per-target.
171     pub mod common {
172         pub mod c95 {
173             /// Type used to construct void pointers for use with C.
174             ///
175             /// This type is only useful as a pointer target. Do not use it as a
176             /// return type for FFI functions which have the `void` return type in
177             /// C. Use the unit type `()` or omit the return type instead.
178             ///
179             /// For LLVM to recognize the void pointer type and by extension
180             /// functions like malloc(), we need to have it represented as i8* in
181             /// LLVM bitcode. The enum used here ensures this and prevents misuse
182             /// of the "raw" type by only having private variants.. We need two
183             /// variants, because the compiler complains about the repr attribute
184             /// otherwise.
185             #[repr(u8)]
186             pub enum c_void {
187                 __variant1,
188                 __variant2,
189             }
190
191             pub enum FILE {}
192             pub enum fpos_t {}
193         }
194         pub mod c99 {
195             pub type int8_t = i8;
196             pub type int16_t = i16;
197             pub type int32_t = i32;
198             pub type int64_t = i64;
199             pub type uint8_t = u8;
200             pub type uint16_t = u16;
201             pub type uint32_t = u32;
202             pub type uint64_t = u64;
203         }
204         pub mod posix88 {
205             pub enum DIR {}
206             pub enum dirent_t {}
207         }
208         pub mod posix01 {}
209         pub mod posix08 {}
210         pub mod bsd44 {}
211     }
212
213     // Standard types that are scalar but vary by OS and arch.
214
215     #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))]
216     pub mod os {
217         pub mod common {
218             pub mod posix01 {
219                 use types::common::c95::{c_void};
220                 use types::os::arch::c95::{c_char, c_ulong, size_t,
221                                                  time_t, suseconds_t, c_long};
222
223                 #[cfg(not(target_os = "nacl"))]
224                 pub type pthread_t = c_ulong;
225                 #[cfg(target_os = "nacl")]
226                 pub type pthread_t = *mut c_void;
227                 pub type rlim_t = u64;
228
229                 #[repr(C)]
230                 #[derive(Copy, Clone)] pub struct glob_t {
231                     pub gl_pathc: size_t,
232                     pub gl_pathv: *mut *mut c_char,
233                     pub gl_offs:  size_t,
234
235                     pub __unused1: *mut c_void,
236                     pub __unused2: *mut c_void,
237                     pub __unused3: *mut c_void,
238                     pub __unused4: *mut c_void,
239                     pub __unused5: *mut c_void,
240                 }
241
242                 #[repr(C)]
243                 #[derive(Copy, Clone)] pub struct timeval {
244                     pub tv_sec: time_t,
245                     pub tv_usec: suseconds_t,
246                 }
247
248                 #[repr(C)]
249                 #[derive(Copy, Clone)] pub struct timespec {
250                     pub tv_sec: time_t,
251                     pub tv_nsec: c_long,
252                 }
253
254                 pub enum timezone {}
255
256                 pub type sighandler_t = size_t;
257
258                 #[repr(C)]
259                 #[derive(Copy, Clone)]
260                 pub struct rlimit {
261                     pub rlim_cur: rlim_t,
262                     pub rlim_max: rlim_t,
263                 }
264             }
265
266             pub mod bsd43 {
267                 use types::os::common::posix01::timeval;
268                 use types::os::arch::c95::c_long;
269                 // This is also specified in POSIX 2001, but only has two fields. All implementors
270                 // implement BSD 4.3 version.
271                 #[repr(C)]
272                 #[derive(Copy, Clone)]
273                 pub struct rusage {
274                     pub ru_utime: timeval,
275                     pub ru_stime: timeval,
276                     pub ru_maxrss: c_long,
277                     pub ru_ixrss: c_long,
278                     pub ru_idrss: c_long,
279                     pub ru_isrss: c_long,
280                     pub ru_minflt: c_long,
281                     pub ru_majflt: c_long,
282                     pub ru_nswap: c_long,
283                     pub ru_inblock: c_long,
284                     pub ru_oublock: c_long,
285                     pub ru_msgsnd: c_long,
286                     pub ru_msgrcv: c_long,
287                     pub ru_nsignals: c_long,
288                     pub ru_nvcsw: c_long,
289                     pub ru_nivcsw: c_long
290                 }
291             }
292
293             pub mod bsd44 {
294                 use types::common::c95::{c_void};
295                 use types::os::arch::c95::{c_char, c_int, c_uint};
296
297                 pub type socklen_t = u32;
298                 pub type sa_family_t = u16;
299                 pub type in_port_t = u16;
300                 pub type in_addr_t = u32;
301                 #[repr(C)]
302                 #[derive(Copy, Clone)] pub struct sockaddr {
303                     pub sa_family: sa_family_t,
304                     pub sa_data: [u8; 14],
305                 }
306                 #[repr(C)]
307                 #[derive(Copy)] pub struct sockaddr_storage {
308                     pub ss_family: sa_family_t,
309                     pub __ss_align: isize,
310                     #[cfg(target_pointer_width = "32")]
311                     pub __ss_pad2: [u8; 128 - 2 * 4],
312                     #[cfg(target_pointer_width = "64")]
313                     pub __ss_pad2: [u8; 128 - 2 * 8],
314                 }
315                 impl ::core::clone::Clone for sockaddr_storage {
316                     fn clone(&self) -> sockaddr_storage { *self }
317                 }
318                 #[repr(C)]
319                 #[derive(Copy, Clone)] pub struct sockaddr_in {
320                     pub sin_family: sa_family_t,
321                     pub sin_port: in_port_t,
322                     pub sin_addr: in_addr,
323                     pub sin_zero: [u8; 8],
324                 }
325                 #[repr(C)]
326                 #[derive(Copy, Clone)] pub struct in_addr {
327                     pub s_addr: in_addr_t,
328                 }
329                 #[repr(C)]
330                 #[derive(Copy, Clone)] pub struct sockaddr_in6 {
331                     pub sin6_family: sa_family_t,
332                     pub sin6_port: in_port_t,
333                     pub sin6_flowinfo: u32,
334                     pub sin6_addr: in6_addr,
335                     pub sin6_scope_id: u32,
336                 }
337                 #[repr(C)]
338                 #[derive(Copy, Clone)] pub struct in6_addr {
339                     pub s6_addr: [u16; 8]
340                 }
341                 #[repr(C)]
342                 #[derive(Copy, Clone)] pub struct ip_mreq {
343                     pub imr_multiaddr: in_addr,
344                     pub imr_interface: in_addr,
345                 }
346                 #[repr(C)]
347                 #[derive(Copy, Clone)] pub struct ip6_mreq {
348                     pub ipv6mr_multiaddr: in6_addr,
349                     pub ipv6mr_interface: c_uint,
350                 }
351                 #[repr(C)]
352                 #[derive(Copy, Clone)] pub struct addrinfo {
353                     pub ai_flags: c_int,
354                     pub ai_family: c_int,
355                     pub ai_socktype: c_int,
356                     pub ai_protocol: c_int,
357                     pub ai_addrlen: socklen_t,
358
359                     #[cfg(target_os = "linux")]
360                     pub ai_addr: *mut sockaddr,
361
362                     #[cfg(target_os = "linux")]
363                     pub ai_canonname: *mut c_char,
364
365                     #[cfg(any(target_os = "android", target_os = "nacl"))]
366                     pub ai_canonname: *mut c_char,
367
368                     #[cfg(any(target_os = "android", target_os = "nacl"))]
369                     pub ai_addr: *mut sockaddr,
370
371                     pub ai_next: *mut addrinfo,
372                 }
373                 #[repr(C)]
374                 #[derive(Copy)] pub struct sockaddr_un {
375                     pub sun_family: sa_family_t,
376                     pub sun_path: [c_char; 108]
377                 }
378                 impl ::core::clone::Clone for sockaddr_un {
379                     fn clone(&self) -> sockaddr_un { *self }
380                 }
381
382                 #[repr(C)]
383                 #[derive(Copy, Clone)] pub struct ifaddrs {
384                     pub ifa_next: *mut ifaddrs,
385                     pub ifa_name: *mut c_char,
386                     pub ifa_flags: c_uint,
387                     pub ifa_addr: *mut sockaddr,
388                     pub ifa_netmask: *mut sockaddr,
389                     pub ifa_ifu: *mut sockaddr, // FIXME This should be a union
390                     pub ifa_data: *mut c_void
391                 }
392
393             }
394         }
395
396         #[cfg(any(target_arch = "x86",
397                   target_arch = "arm",
398                   target_arch = "mips",
399                   target_arch = "mipsel",
400                   target_arch = "powerpc",
401                   target_arch = "le32"))]
402         pub mod arch {
403             pub mod c95 {
404                 pub type c_char = i8;
405                 pub type c_schar = i8;
406                 pub type c_uchar = u8;
407                 pub type c_short = i16;
408                 pub type c_ushort = u16;
409                 pub type c_int = i32;
410                 pub type c_uint = u32;
411                 pub type c_long = i32;
412                 pub type c_ulong = u32;
413                 pub type c_float = f32;
414                 pub type c_double = f64;
415                 pub type size_t = u32;
416                 pub type ptrdiff_t = i32;
417                 pub type clock_t = i32;
418                 pub type time_t = i32;
419                 pub type suseconds_t = i32;
420                 pub type wchar_t = i32;
421             }
422             pub mod c99 {
423                 pub type c_longlong = i64;
424                 pub type c_ulonglong = u64;
425                 pub type intptr_t = i32;
426                 pub type uintptr_t = u32;
427                 pub type intmax_t = i64;
428                 pub type uintmax_t = u64;
429             }
430             #[cfg(any(target_arch = "x86",
431                       target_arch = "mips",
432                       target_arch = "mipsel",
433                       target_arch = "powerpc",
434                       target_arch = "le32",
435                       all(target_arch = "arm", not(target_os = "android"))))]
436             pub mod posix88 {
437                 pub type off_t = i32;
438                 pub type dev_t = u64;
439                 pub type ino_t = u32;
440                 pub type pid_t = i32;
441                 pub type uid_t = u32;
442                 pub type gid_t = u32;
443                 pub type useconds_t = u32;
444                 pub type mode_t = u32;
445                 pub type ssize_t = i32;
446             }
447             #[cfg(all(target_arch = "arm", target_os = "android"))]
448             pub mod posix88 {
449                 pub type off_t = i32;
450                 pub type dev_t = u32;
451                 pub type ino_t = u32;
452                 pub type pid_t = i32;
453                 pub type uid_t = u32;
454                 pub type gid_t = u32;
455                 pub type useconds_t = u32;
456                 pub type mode_t = u16;
457                 pub type ssize_t = i32;
458             }
459             #[cfg(any(target_arch = "x86",
460                       target_arch = "le32",
461                       target_arch = "powerpc",
462                       all(target_arch = "arm", not(target_os = "android"))))]
463             pub mod posix01 {
464                 use types::os::arch::c95::{c_short, c_long, time_t};
465                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
466                 use types::os::arch::posix88::{mode_t, off_t};
467                 use types::os::arch::posix88::{uid_t};
468
469                 pub type nlink_t = u32;
470                 pub type blksize_t = i32;
471                 pub type blkcnt_t = i32;
472
473                 #[repr(C)]
474                 #[derive(Copy, Clone)] pub struct stat {
475                     pub st_dev: dev_t,
476                     pub __pad1: c_short,
477                     pub st_ino: ino_t,
478                     pub st_mode: mode_t,
479                     pub st_nlink: nlink_t,
480                     pub st_uid: uid_t,
481                     pub st_gid: gid_t,
482                     pub st_rdev: dev_t,
483                     pub __pad2: c_short,
484                     pub st_size: off_t,
485                     pub st_blksize: blksize_t,
486                     pub st_blocks: blkcnt_t,
487                     pub st_atime: time_t,
488                     pub st_atime_nsec: c_long,
489                     pub st_mtime: time_t,
490                     pub st_mtime_nsec: c_long,
491                     pub st_ctime: time_t,
492                     pub st_ctime_nsec: c_long,
493                     pub __unused4: c_long,
494                     pub __unused5: c_long,
495                 }
496
497                 #[repr(C)]
498                 #[derive(Copy, Clone)] pub struct utimbuf {
499                     pub actime: time_t,
500                     pub modtime: time_t,
501                 }
502
503                 #[repr(C)]
504                 #[derive(Copy, Clone)] pub struct pthread_attr_t {
505                     pub __size: [u32; 9]
506                 }
507             }
508             #[cfg(all(target_arch = "arm", target_os = "android"))]
509             pub mod posix01 {
510                 use types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t};
511                 use types::os::arch::c99::{c_longlong, c_ulonglong};
512                 use types::os::arch::posix88::{uid_t, gid_t, ino_t};
513
514                 pub type nlink_t = u16;
515                 pub type blksize_t = u32;
516                 pub type blkcnt_t = u32;
517
518                 #[repr(C)]
519                 #[derive(Copy, Clone)] pub struct stat {
520                     pub st_dev: c_ulonglong,
521                     pub __pad0: [c_uchar; 4],
522                     pub __st_ino: ino_t,
523                     pub st_mode: c_uint,
524                     pub st_nlink: c_uint,
525                     pub st_uid: uid_t,
526                     pub st_gid: gid_t,
527                     pub st_rdev: c_ulonglong,
528                     pub __pad3: [c_uchar; 4],
529                     pub st_size: c_longlong,
530                     pub st_blksize: blksize_t,
531                     pub st_blocks: c_ulonglong,
532                     pub st_atime: time_t,
533                     pub st_atime_nsec: c_ulong,
534                     pub st_mtime: time_t,
535                     pub st_mtime_nsec: c_ulong,
536                     pub st_ctime: time_t,
537                     pub st_ctime_nsec: c_ulong,
538                     pub st_ino: c_ulonglong,
539                 }
540
541                 #[repr(C)]
542                 #[derive(Copy, Clone)] pub struct utimbuf {
543                     pub actime: time_t,
544                     pub modtime: time_t,
545                 }
546
547                 #[repr(C)]
548                 #[derive(Copy, Clone)] pub struct pthread_attr_t {
549                     pub __size: [u32; 9]
550                 }
551             }
552             #[cfg(any(target_arch = "mips",
553                       target_arch = "mipsel"))]
554             pub mod posix01 {
555                 use types::os::arch::c95::{c_long, c_ulong, time_t};
556                 use types::os::arch::posix88::{gid_t, ino_t};
557                 use types::os::arch::posix88::{mode_t, off_t};
558                 use types::os::arch::posix88::{uid_t};
559
560                 pub type nlink_t = u32;
561                 pub type blksize_t = i32;
562                 pub type blkcnt_t = i32;
563
564                 #[repr(C)]
565                 #[derive(Copy, Clone)] pub struct stat {
566                     pub st_dev: c_ulong,
567                     pub st_pad1: [c_long; 3],
568                     pub st_ino: ino_t,
569                     pub st_mode: mode_t,
570                     pub st_nlink: nlink_t,
571                     pub st_uid: uid_t,
572                     pub st_gid: gid_t,
573                     pub st_rdev: c_ulong,
574                     pub st_pad2: [c_long; 2],
575                     pub st_size: off_t,
576                     pub st_pad3: c_long,
577                     pub st_atime: time_t,
578                     pub st_atime_nsec: c_long,
579                     pub st_mtime: time_t,
580                     pub st_mtime_nsec: c_long,
581                     pub st_ctime: time_t,
582                     pub st_ctime_nsec: c_long,
583                     pub st_blksize: blksize_t,
584                     pub st_blocks: blkcnt_t,
585                     pub st_pad5: [c_long; 14],
586                 }
587
588                 #[repr(C)]
589                 #[derive(Copy, Clone)] pub struct utimbuf {
590                     pub actime: time_t,
591                     pub modtime: time_t,
592                 }
593
594                 #[repr(C)]
595                 #[derive(Copy, Clone)] pub struct pthread_attr_t {
596                     pub __size: [u32; 9]
597                 }
598             }
599             pub mod posix08 {}
600             pub mod bsd44 {}
601             pub mod extra {
602                 use types::os::arch::c95::{c_ushort, c_int, c_uchar};
603                 #[repr(C)]
604                 #[derive(Copy, Clone)] pub struct sockaddr_ll {
605                     pub sll_family: c_ushort,
606                     pub sll_protocol: c_ushort,
607                     pub sll_ifindex: c_int,
608                     pub sll_hatype: c_ushort,
609                     pub sll_pkttype: c_uchar,
610                     pub sll_halen: c_uchar,
611                     pub sll_addr: [c_uchar; 8]
612                 }
613             }
614
615         }
616
617         #[cfg(any(target_arch = "x86_64",
618                   target_arch = "aarch64"))]
619         pub mod arch {
620             pub mod c95 {
621                 #[cfg(not(target_arch = "aarch64"))]
622                 pub type c_char = i8;
623                 #[cfg(target_arch = "aarch64")]
624                 pub type c_char = u8;
625                 pub type c_schar = i8;
626                 pub type c_uchar = u8;
627                 pub type c_short = i16;
628                 pub type c_ushort = u16;
629                 pub type c_int = i32;
630                 pub type c_uint = u32;
631                 pub type c_long = i64;
632                 pub type c_ulong = u64;
633                 pub type c_float = f32;
634                 pub type c_double = f64;
635                 pub type size_t = u64;
636                 pub type ptrdiff_t = i64;
637                 pub type clock_t = i64;
638                 pub type time_t = i64;
639                 pub type suseconds_t = i64;
640                 #[cfg(not(target_arch = "aarch64"))]
641                 pub type wchar_t = i32;
642                 #[cfg(target_arch = "aarch64")]
643                 pub type wchar_t = u32;
644             }
645             pub mod c99 {
646                 pub type c_longlong = i64;
647                 pub type c_ulonglong = u64;
648                 pub type intptr_t = i64;
649                 pub type uintptr_t = u64;
650                 pub type intmax_t = i64;
651                 pub type uintmax_t = u64;
652             }
653             pub mod posix88 {
654                 pub type off_t = i64;
655                 pub type dev_t = u64;
656                 pub type ino_t = u64;
657                 pub type pid_t = i32;
658                 pub type uid_t = u32;
659                 pub type gid_t = u32;
660                 pub type useconds_t = u32;
661                 pub type mode_t = u32;
662                 pub type ssize_t = i64;
663             }
664             #[cfg(not(target_arch = "aarch64"))]
665             pub mod posix01 {
666                 use types::os::arch::c95::{c_int, c_long, time_t};
667                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
668                 use types::os::arch::posix88::{mode_t, off_t};
669                 use types::os::arch::posix88::{uid_t};
670
671                 pub type nlink_t = u64;
672                 pub type blksize_t = i64;
673                 pub type blkcnt_t = i64;
674
675                 #[repr(C)]
676                 #[derive(Copy, Clone)] pub struct stat {
677                     pub st_dev: dev_t,
678                     pub st_ino: ino_t,
679                     pub st_nlink: nlink_t,
680                     pub st_mode: mode_t,
681                     pub st_uid: uid_t,
682                     pub st_gid: gid_t,
683                     pub __pad0: c_int,
684                     pub st_rdev: dev_t,
685                     pub st_size: off_t,
686                     pub st_blksize: blksize_t,
687                     pub st_blocks: blkcnt_t,
688                     pub st_atime: time_t,
689                     pub st_atime_nsec: c_long,
690                     pub st_mtime: time_t,
691                     pub st_mtime_nsec: c_long,
692                     pub st_ctime: time_t,
693                     pub st_ctime_nsec: c_long,
694                     pub __unused: [c_long; 3],
695                 }
696
697                 #[repr(C)]
698                 #[derive(Copy, Clone)] pub struct utimbuf {
699                     pub actime: time_t,
700                     pub modtime: time_t,
701                 }
702
703                 #[repr(C)]
704                 #[derive(Copy, Clone)] pub struct pthread_attr_t {
705                     pub __size: [u64; 7]
706                 }
707             }
708             #[cfg(target_arch = "aarch64")]
709             pub mod posix01 {
710                 use types::os::arch::c95::{c_int, c_long, time_t};
711                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
712                 use types::os::arch::posix88::{mode_t, off_t};
713                 use types::os::arch::posix88::{uid_t};
714
715                 pub type nlink_t = u32;
716                 pub type blksize_t = i32;
717                 pub type blkcnt_t = i64;
718
719                 #[repr(C)]
720                 #[derive(Copy, Clone)] pub struct stat {
721                     pub st_dev: dev_t,
722                     pub st_ino: ino_t,
723                     pub st_mode: mode_t,
724                     pub st_nlink: nlink_t,
725                     pub st_uid: uid_t,
726                     pub st_gid: gid_t,
727                     pub st_rdev: dev_t,
728                     pub __pad1: dev_t,
729                     pub st_size: off_t,
730                     pub st_blksize: blksize_t,
731                     pub __pad2: c_int,
732                     pub st_blocks: blkcnt_t,
733                     pub st_atime: time_t,
734                     pub st_atime_nsec: c_long,
735                     pub st_mtime: time_t,
736                     pub st_mtime_nsec: c_long,
737                     pub st_ctime: time_t,
738                     pub st_ctime_nsec: c_long,
739                     pub __unused: [c_int; 2],
740                 }
741
742                 #[repr(C)]
743                 #[derive(Copy, Clone)] pub struct utimbuf {
744                     pub actime: time_t,
745                     pub modtime: time_t,
746                 }
747
748                 #[repr(C)]
749                 #[derive(Copy, Clone)] pub struct pthread_attr_t {
750                     pub __size: [u64; 8]
751                 }
752             }
753             pub mod posix08 {
754             }
755             pub mod bsd44 {
756             }
757             pub mod extra {
758                 use types::os::arch::c95::{c_ushort, c_int, c_uchar};
759                 #[derive(Copy, Clone)] pub struct sockaddr_ll {
760                     pub sll_family: c_ushort,
761                     pub sll_protocol: c_ushort,
762                     pub sll_ifindex: c_int,
763                     pub sll_hatype: c_ushort,
764                     pub sll_pkttype: c_uchar,
765                     pub sll_halen: c_uchar,
766                     pub sll_addr: [c_uchar; 8]
767                 }
768
769             }
770         }
771     }
772
773     #[cfg(target_os = "freebsd")]
774     pub mod os {
775         pub mod common {
776             pub mod posix01 {
777                 use types::common::c95::{c_void};
778                 use types::os::arch::c95::{c_char, c_int, size_t,
779                                                  time_t, suseconds_t, c_long};
780                 use types::os::arch::c99::{uintptr_t};
781
782                 pub type pthread_t = uintptr_t;
783                 pub type rlim_t = i64;
784
785                 #[repr(C)]
786                 #[derive(Copy, Clone)] pub struct glob_t {
787                     pub gl_pathc:  size_t,
788                     pub __unused1: size_t,
789                     pub gl_offs:   size_t,
790                     pub __unused2: c_int,
791                     pub gl_pathv:  *mut *mut c_char,
792
793                     pub __unused3: *mut c_void,
794
795                     pub __unused4: *mut c_void,
796                     pub __unused5: *mut c_void,
797                     pub __unused6: *mut c_void,
798                     pub __unused7: *mut c_void,
799                     pub __unused8: *mut c_void,
800                 }
801
802                 #[repr(C)]
803                 #[derive(Copy, Clone)] pub struct timeval {
804                     pub tv_sec: time_t,
805                     pub tv_usec: suseconds_t,
806                 }
807
808                 #[repr(C)]
809                 #[derive(Copy, Clone)] pub struct timespec {
810                     pub tv_sec: time_t,
811                     pub tv_nsec: c_long,
812                 }
813
814                 pub enum timezone {}
815
816                 pub type sighandler_t = size_t;
817
818                 #[repr(C)]
819                 #[derive(Copy, Clone)]
820                 pub struct rlimit {
821                     pub rlim_cur: rlim_t,
822                     pub rlim_max: rlim_t,
823                 }
824             }
825
826             pub mod bsd43 {
827                 use types::os::common::posix01::timeval;
828                 use types::os::arch::c95::c_long;
829                 #[repr(C)]
830                 #[derive(Copy, Clone)]
831                 pub struct rusage {
832                     pub ru_utime: timeval,
833                     pub ru_stime: timeval,
834                     pub ru_maxrss: c_long,
835                     pub ru_ixrss: c_long,
836                     pub ru_idrss: c_long,
837                     pub ru_isrss: c_long,
838                     pub ru_minflt: c_long,
839                     pub ru_majflt: c_long,
840                     pub ru_nswap: c_long,
841                     pub ru_inblock: c_long,
842                     pub ru_oublock: c_long,
843                     pub ru_msgsnd: c_long,
844                     pub ru_msgrcv: c_long,
845                     pub ru_nsignals: c_long,
846                     pub ru_nvcsw: c_long,
847                     pub ru_nivcsw: c_long
848                 }
849             }
850
851             pub mod bsd44 {
852                 use types::common::c95::{c_void};
853                 use types::os::arch::c95::{c_char, c_int, c_uint};
854
855                 pub type socklen_t = u32;
856                 pub type sa_family_t = u8;
857                 pub type in_port_t = u16;
858                 pub type in_addr_t = u32;
859                 #[repr(C)]
860                 #[derive(Copy, Clone)] pub struct sockaddr {
861                     pub sa_len: u8,
862                     pub sa_family: sa_family_t,
863                     pub sa_data: [u8; 14],
864                 }
865                 #[repr(C)]
866                 #[derive(Copy)] pub struct sockaddr_storage {
867                     pub ss_len: u8,
868                     pub ss_family: sa_family_t,
869                     pub __ss_pad1: [u8; 6],
870                     pub __ss_align: i64,
871                     pub __ss_pad2: [u8; 112],
872                 }
873                 impl ::core::clone::Clone for sockaddr_storage {
874                     fn clone(&self) -> sockaddr_storage { *self }
875                 }
876                 #[repr(C)]
877                 #[derive(Copy, Clone)] pub struct sockaddr_in {
878                     pub sin_len: u8,
879                     pub sin_family: sa_family_t,
880                     pub sin_port: in_port_t,
881                     pub sin_addr: in_addr,
882                     pub sin_zero: [u8; 8],
883                 }
884                 #[repr(C)]
885                 #[derive(Copy, Clone)] pub struct in_addr {
886                     pub s_addr: in_addr_t,
887                 }
888                 #[repr(C)]
889                 #[derive(Copy, Clone)] pub struct sockaddr_in6 {
890                     pub sin6_len: u8,
891                     pub sin6_family: sa_family_t,
892                     pub sin6_port: in_port_t,
893                     pub sin6_flowinfo: u32,
894                     pub sin6_addr: in6_addr,
895                     pub sin6_scope_id: u32,
896                 }
897                 #[repr(C)]
898                 #[derive(Copy, Clone)] pub struct in6_addr {
899                     pub s6_addr: [u16; 8]
900                 }
901                 #[repr(C)]
902                 #[derive(Copy, Clone)] pub struct ip_mreq {
903                     pub imr_multiaddr: in_addr,
904                     pub imr_interface: in_addr,
905                 }
906                 #[repr(C)]
907                 #[derive(Copy, Clone)] pub struct ip6_mreq {
908                     pub ipv6mr_multiaddr: in6_addr,
909                     pub ipv6mr_interface: c_uint,
910                 }
911                 #[repr(C)]
912                 #[derive(Copy, Clone)] pub struct addrinfo {
913                     pub ai_flags: c_int,
914                     pub ai_family: c_int,
915                     pub ai_socktype: c_int,
916                     pub ai_protocol: c_int,
917                     pub ai_addrlen: socklen_t,
918                     pub ai_canonname: *mut c_char,
919                     pub ai_addr: *mut sockaddr,
920                     pub ai_next: *mut addrinfo,
921                 }
922                 #[repr(C)]
923                 #[derive(Copy)] pub struct sockaddr_un {
924                     pub sun_len: u8,
925                     pub sun_family: sa_family_t,
926                     pub sun_path: [c_char; 104]
927                 }
928                 impl ::core::clone::Clone for sockaddr_un {
929                     fn clone(&self) -> sockaddr_un { *self }
930                 }
931                 #[repr(C)]
932                 #[derive(Copy, Clone)] pub struct ifaddrs {
933                     pub ifa_next: *mut ifaddrs,
934                     pub ifa_name: *mut c_char,
935                     pub ifa_flags: c_uint,
936                     pub ifa_addr: *mut sockaddr,
937                     pub ifa_netmask: *mut sockaddr,
938                     pub ifa_dstaddr: *mut sockaddr,
939                     pub ifa_data: *mut c_void
940                 }
941
942
943             }
944         }
945
946         #[cfg(target_arch = "x86_64")]
947         pub mod arch {
948             pub mod c95 {
949                 pub type c_char = i8;
950                 pub type c_schar = i8;
951                 pub type c_uchar = u8;
952                 pub type c_short = i16;
953                 pub type c_ushort = u16;
954                 pub type c_int = i32;
955                 pub type c_uint = u32;
956                 pub type c_long = i64;
957                 pub type c_ulong = u64;
958                 pub type c_float = f32;
959                 pub type c_double = f64;
960                 pub type size_t = u64;
961                 pub type ptrdiff_t = i64;
962                 pub type clock_t = i32;
963                 pub type time_t = i64;
964                 pub type suseconds_t = i64;
965                 pub type wchar_t = i32;
966             }
967             pub mod c99 {
968                 pub type c_longlong = i64;
969                 pub type c_ulonglong = u64;
970                 pub type intptr_t = i64;
971                 pub type uintptr_t = u64;
972                 pub type intmax_t = i64;
973                 pub type uintmax_t = u64;
974             }
975             pub mod posix88 {
976                 pub type off_t = i64;
977                 pub type dev_t = u32;
978                 pub type ino_t = u32;
979                 pub type pid_t = i32;
980                 pub type uid_t = u32;
981                 pub type gid_t = u32;
982                 pub type useconds_t = u32;
983                 pub type mode_t = u16;
984                 pub type ssize_t = i64;
985             }
986             pub mod posix01 {
987                 use types::common::c95::{c_void};
988                 use types::common::c99::{uint8_t, uint32_t, int32_t};
989                 use types::os::arch::c95::{c_long, time_t};
990                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
991                 use types::os::arch::posix88::{mode_t, off_t};
992                 use types::os::arch::posix88::{uid_t};
993
994                 pub type nlink_t = u16;
995                 pub type blksize_t = i64;
996                 pub type blkcnt_t = i64;
997                 pub type fflags_t = u32;
998                 #[repr(C)]
999                 #[derive(Copy, Clone)] pub struct stat {
1000                     pub st_dev: dev_t,
1001                     pub st_ino: ino_t,
1002                     pub st_mode: mode_t,
1003                     pub st_nlink: nlink_t,
1004                     pub st_uid: uid_t,
1005                     pub st_gid: gid_t,
1006                     pub st_rdev: dev_t,
1007                     pub st_atime: time_t,
1008                     pub st_atime_nsec: c_long,
1009                     pub st_mtime: time_t,
1010                     pub st_mtime_nsec: c_long,
1011                     pub st_ctime: time_t,
1012                     pub st_ctime_nsec: c_long,
1013                     pub st_size: off_t,
1014                     pub st_blocks: blkcnt_t,
1015                     pub st_blksize: blksize_t,
1016                     pub st_flags: fflags_t,
1017                     pub st_gen: uint32_t,
1018                     pub st_lspare: int32_t,
1019                     pub st_birthtime: time_t,
1020                     pub st_birthtime_nsec: c_long,
1021                     pub __unused: [uint8_t; 2],
1022                 }
1023
1024                 #[repr(C)]
1025                 #[derive(Copy, Clone)] pub struct utimbuf {
1026                     pub actime: time_t,
1027                     pub modtime: time_t,
1028                 }
1029
1030                 pub type pthread_attr_t = *mut c_void;
1031             }
1032             pub mod posix08 {
1033             }
1034             pub mod bsd44 {
1035             }
1036             pub mod extra {
1037             }
1038         }
1039     }
1040
1041     #[cfg(target_os = "dragonfly")]
1042     pub mod os {
1043         pub mod common {
1044             pub mod posix01 {
1045                 use types::common::c95::{c_void};
1046                 use types::os::arch::c95::{c_char, c_int, size_t,
1047                                                  time_t, suseconds_t, c_long};
1048                 use types::os::arch::c99::{uintptr_t};
1049
1050                 pub type pthread_t = uintptr_t;
1051                 pub type rlim_t = i64;
1052
1053                 #[repr(C)]
1054                 #[derive(Copy, Clone)] pub struct glob_t {
1055                     pub gl_pathc:  size_t,
1056                     pub __unused1: size_t,
1057                     pub gl_offs:   size_t,
1058                     pub __unused2: c_int,
1059                     pub gl_pathv:  *mut *mut c_char,
1060
1061                     pub __unused3: *mut c_void,
1062
1063                     pub __unused4: *mut c_void,
1064                     pub __unused5: *mut c_void,
1065                     pub __unused6: *mut c_void,
1066                     pub __unused7: *mut c_void,
1067                     pub __unused8: *mut c_void,
1068                 }
1069
1070                 #[repr(C)]
1071                 #[derive(Copy, Clone)] pub struct timeval {
1072                     pub tv_sec: time_t,
1073                     pub tv_usec: suseconds_t,
1074                 }
1075
1076                 #[repr(C)]
1077                 #[derive(Copy, Clone)] pub struct timespec {
1078                     pub tv_sec: time_t,
1079                     pub tv_nsec: c_long,
1080                 }
1081
1082                 pub enum timezone {}
1083
1084                 pub type sighandler_t = size_t;
1085
1086                 #[repr(C)]
1087                 #[derive(Copy, Clone)]
1088                 pub struct rlimit {
1089                     pub rlim_cur: rlim_t,
1090                     pub rlim_max: rlim_t,
1091                 }
1092             }
1093
1094             pub mod bsd43 {
1095                 use types::os::common::posix01::timeval;
1096                 use types::os::arch::c95::c_long;
1097                 #[repr(C)]
1098                 #[derive(Copy, Clone)]
1099                 pub struct rusage {
1100                     pub ru_utime: timeval,
1101                     pub ru_stime: timeval,
1102                     pub ru_maxrss: c_long,
1103                     pub ru_ixrss: c_long,
1104                     pub ru_idrss: c_long,
1105                     pub ru_isrss: c_long,
1106                     pub ru_minflt: c_long,
1107                     pub ru_majflt: c_long,
1108                     pub ru_nswap: c_long,
1109                     pub ru_inblock: c_long,
1110                     pub ru_oublock: c_long,
1111                     pub ru_msgsnd: c_long,
1112                     pub ru_msgrcv: c_long,
1113                     pub ru_nsignals: c_long,
1114                     pub ru_nvcsw: c_long,
1115                     pub ru_nivcsw: c_long
1116                 }
1117             }
1118
1119             pub mod bsd44 {
1120                 use types::common::c95::{c_void};
1121                 use types::os::arch::c95::{c_char, c_int, c_uint};
1122
1123                 pub type socklen_t = u32;
1124                 pub type sa_family_t = u8;
1125                 pub type in_port_t = u16;
1126                 pub type in_addr_t = u32;
1127                 #[repr(C)]
1128                 #[derive(Copy, Clone)] pub struct sockaddr {
1129                     pub sa_len: u8,
1130                     pub sa_family: sa_family_t,
1131                     pub sa_data: [u8; 14],
1132                 }
1133                 #[repr(C)]
1134                 #[derive(Copy)] pub struct sockaddr_storage {
1135                     pub ss_len: u8,
1136                     pub ss_family: sa_family_t,
1137                     pub __ss_pad1: [u8; 6],
1138                     pub __ss_align: i64,
1139                     pub __ss_pad2: [u8; 112],
1140                 }
1141                 impl ::core::clone::Clone for sockaddr_storage {
1142                     fn clone(&self) -> sockaddr_storage { *self }
1143                 }
1144                 #[repr(C)]
1145                 #[derive(Copy, Clone)] pub struct sockaddr_in {
1146                     pub sin_len: u8,
1147                     pub sin_family: sa_family_t,
1148                     pub sin_port: in_port_t,
1149                     pub sin_addr: in_addr,
1150                     pub sin_zero: [u8; 8],
1151                 }
1152                 #[repr(C)]
1153                 #[derive(Copy, Clone)] pub struct in_addr {
1154                     pub s_addr: in_addr_t,
1155                 }
1156                 #[repr(C)]
1157                 #[derive(Copy, Clone)] pub struct sockaddr_in6 {
1158                     pub sin6_len: u8,
1159                     pub sin6_family: sa_family_t,
1160                     pub sin6_port: in_port_t,
1161                     pub sin6_flowinfo: u32,
1162                     pub sin6_addr: in6_addr,
1163                     pub sin6_scope_id: u32,
1164                 }
1165                 #[repr(C)]
1166                 #[derive(Copy, Clone)] pub struct in6_addr {
1167                     pub s6_addr: [u16; 8]
1168                 }
1169                 #[repr(C)]
1170                 #[derive(Copy, Clone)] pub struct ip_mreq {
1171                     pub imr_multiaddr: in_addr,
1172                     pub imr_interface: in_addr,
1173                 }
1174                 #[repr(C)]
1175                 #[derive(Copy, Clone)] pub struct ip6_mreq {
1176                     pub ipv6mr_multiaddr: in6_addr,
1177                     pub ipv6mr_interface: c_uint,
1178                 }
1179                 #[repr(C)]
1180                 #[derive(Copy, Clone)] pub struct addrinfo {
1181                     pub ai_flags: c_int,
1182                     pub ai_family: c_int,
1183                     pub ai_socktype: c_int,
1184                     pub ai_protocol: c_int,
1185                     pub ai_addrlen: socklen_t,
1186                     pub ai_canonname: *mut c_char,
1187                     pub ai_addr: *mut sockaddr,
1188                     pub ai_next: *mut addrinfo,
1189                 }
1190                 #[repr(C)]
1191                 #[derive(Copy)] pub struct sockaddr_un {
1192                     pub sun_len: u8,
1193                     pub sun_family: sa_family_t,
1194                     pub sun_path: [c_char; 104]
1195                 }
1196                 impl ::core::clone::Clone for sockaddr_un {
1197                     fn clone(&self) -> sockaddr_un { *self }
1198                 }
1199                 #[repr(C)]
1200                 #[derive(Copy, Clone)] pub struct ifaddrs {
1201                     pub ifa_next: *mut ifaddrs,
1202                     pub ifa_name: *mut c_char,
1203                     pub ifa_flags: c_uint,
1204                     pub ifa_addr: *mut sockaddr,
1205                     pub ifa_netmask: *mut sockaddr,
1206                     pub ifa_dstaddr: *mut sockaddr,
1207                     pub ifa_data: *mut c_void
1208                 }
1209
1210             }
1211         }
1212
1213         #[cfg(target_arch = "x86_64")]
1214         pub mod arch {
1215             pub mod c95 {
1216                 pub type c_char = i8;
1217                 pub type c_schar = i8;
1218                 pub type c_uchar = u8;
1219                 pub type c_short = i16;
1220                 pub type c_ushort = u16;
1221                 pub type c_int = i32;
1222                 pub type c_uint = u32;
1223                 pub type c_long = i64;
1224                 pub type c_ulong = u64;
1225                 pub type c_float = f32;
1226                 pub type c_double = f64;
1227                 pub type size_t = u64;
1228                 pub type ptrdiff_t = i64;
1229                 pub type clock_t = i32;
1230                 pub type time_t = i64;
1231                 pub type suseconds_t = i64;
1232                 pub type wchar_t = i32;
1233             }
1234             pub mod c99 {
1235                 pub type c_longlong = i64;
1236                 pub type c_ulonglong = u64;
1237                 pub type intptr_t = i64;
1238                 pub type uintptr_t = u64;
1239                 pub type intmax_t = i64;
1240                 pub type uintmax_t = u64;
1241             }
1242             pub mod posix88 {
1243                 pub type off_t = i64;
1244                 pub type dev_t = u32;
1245                 pub type pid_t = i32;
1246                 pub type uid_t = u32;
1247                 pub type gid_t = u32;
1248                 pub type useconds_t = u32;
1249                 pub type mode_t = u16;
1250                 pub type ssize_t = i64;
1251             }
1252             pub mod posix01 {
1253                 use types::common::c95::{c_void};
1254                 use types::common::c99::{uint16_t, uint32_t, int32_t, uint64_t, int64_t};
1255                 use types::os::arch::c95::{c_long, time_t};
1256                 use types::os::arch::posix88::{dev_t, gid_t};
1257                 use types::os::arch::posix88::{mode_t, off_t};
1258                 use types::os::arch::posix88::{uid_t};
1259
1260                 pub type nlink_t = u16;
1261                 pub type blksize_t = uint32_t;
1262                 pub type ino_t = uint64_t;
1263                 pub type blkcnt_t = i64;
1264                 pub type fflags_t = u32;
1265
1266                 #[repr(C)]
1267                 #[derive(Copy, Clone)] pub struct stat {
1268                     pub st_ino: ino_t,
1269                     pub st_nlink: nlink_t,
1270                     pub st_dev: dev_t,
1271                     pub st_mode: mode_t,
1272                     pub st_padding1: uint16_t,
1273                     pub st_uid: uid_t,
1274                     pub st_gid: gid_t,
1275                     pub st_rdev: dev_t,
1276                     pub st_atime: time_t,
1277                     pub st_atime_nsec: c_long,
1278                     pub st_mtime: time_t,
1279                     pub st_mtime_nsec: c_long,
1280                     pub st_ctime: time_t,
1281                     pub st_ctime_nsec: c_long,
1282                     pub st_size: off_t,
1283                     pub st_blocks: blkcnt_t,
1284                     pub st_blksize: blksize_t,
1285                     pub st_flags: fflags_t,
1286                     pub st_gen: uint32_t,
1287                     pub st_lspare: int32_t,
1288                     pub st_qspare1: int64_t,
1289                     pub st_qspare2: int64_t,
1290                 }
1291                 #[repr(C)]
1292                 #[derive(Copy, Clone)] pub struct utimbuf {
1293                     pub actime: time_t,
1294                     pub modtime: time_t,
1295                 }
1296
1297                 pub type pthread_attr_t = *mut c_void;
1298             }
1299             pub mod posix08 {
1300             }
1301             pub mod bsd44 {
1302             }
1303             pub mod extra {
1304             }
1305         }
1306     }
1307
1308     #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
1309     pub mod os {
1310         pub mod common {
1311             pub mod posix01 {
1312                 use types::common::c95::{c_void};
1313                 use types::os::arch::c95::{c_char, c_int, size_t,
1314                                                  time_t, suseconds_t, c_long};
1315                 use types::os::arch::c99::{uintptr_t};
1316
1317                 pub type pthread_t = uintptr_t;
1318                 pub type rlim_t = u64;
1319
1320                 #[cfg(target_os = "bitrig")]
1321                 #[repr(C)]
1322                 #[derive(Copy, Clone)] pub struct glob_t {
1323                     pub gl_pathc:  c_int,
1324                     pub gl_matchc: c_int,
1325                     pub gl_offs:   c_int,
1326                     pub gl_flags:  c_int,
1327                     pub gl_pathv:  *mut *mut c_char,
1328                     pub __unused1: *mut c_void,
1329                     pub __unused2: *mut c_void,
1330                     pub __unused3: *mut c_void,
1331                     pub __unused4: *mut c_void,
1332                     pub __unused5: *mut c_void,
1333                     pub __unused6: *mut c_void,
1334                     pub __unused7: *mut c_void,
1335                 }
1336
1337                 #[cfg(target_os = "openbsd")]
1338                 #[repr(C)]
1339                 #[derive(Copy, Clone)] pub struct glob_t {
1340                     pub gl_pathc:  c_int,
1341                     pub __unused1: c_int,
1342                     pub gl_offs:   c_int,
1343                     pub __unused2: c_int,
1344                     pub gl_pathv:  *mut *mut c_char,
1345
1346                     pub __unused3: *mut c_void,
1347
1348                     pub __unused4: *mut c_void,
1349                     pub __unused5: *mut c_void,
1350                     pub __unused6: *mut c_void,
1351                     pub __unused7: *mut c_void,
1352                     pub __unused8: *mut c_void,
1353                     pub __unused9: *mut c_void,
1354                 }
1355
1356                 #[repr(C)]
1357                 #[derive(Copy, Clone)] pub struct timeval {
1358                     pub tv_sec: time_t,
1359                     pub tv_usec: suseconds_t,
1360                 }
1361
1362                 #[repr(C)]
1363                 #[derive(Copy, Clone)] pub struct timespec {
1364                     pub tv_sec: time_t,
1365                     pub tv_nsec: c_long,
1366                 }
1367
1368                 pub enum timezone {}
1369
1370                 pub type sighandler_t = size_t;
1371
1372                 #[repr(C)]
1373                 #[derive(Copy, Clone)]
1374                 pub struct rlimit {
1375                     pub rlim_cur: rlim_t,
1376                     pub rlim_max: rlim_t,
1377                 }
1378             }
1379
1380             pub mod bsd43 {
1381                 use types::os::common::posix01::timeval;
1382                 use types::os::arch::c95::c_long;
1383                 #[repr(C)]
1384                 #[derive(Copy, Clone)]
1385                 pub struct rusage {
1386                     pub ru_utime: timeval,
1387                     pub ru_stime: timeval,
1388                     pub ru_maxrss: c_long,
1389                     pub ru_ixrss: c_long,
1390                     pub ru_idrss: c_long,
1391                     pub ru_isrss: c_long,
1392                     pub ru_minflt: c_long,
1393                     pub ru_majflt: c_long,
1394                     pub ru_nswap: c_long,
1395                     pub ru_inblock: c_long,
1396                     pub ru_oublock: c_long,
1397                     pub ru_msgsnd: c_long,
1398                     pub ru_msgrcv: c_long,
1399                     pub ru_nsignals: c_long,
1400                     pub ru_nvcsw: c_long,
1401                     pub ru_nivcsw: c_long
1402                 }
1403             }
1404
1405             pub mod bsd44 {
1406                 use types::common::c95::{c_void};
1407                 use types::os::arch::c95::{c_char, c_int, c_uint};
1408
1409                 pub type socklen_t = u32;
1410                 pub type sa_family_t = u8;
1411                 pub type in_port_t = u16;
1412                 pub type in_addr_t = u32;
1413                 #[repr(C)]
1414                 #[derive(Copy, Clone)] pub struct sockaddr {
1415                     pub sa_len: u8,
1416                     pub sa_family: sa_family_t,
1417                     pub sa_data: [u8; 14],
1418                 }
1419                 #[repr(C)]
1420                 #[derive(Copy)] pub struct sockaddr_storage {
1421                     pub ss_len: u8,
1422                     pub ss_family: sa_family_t,
1423                     pub __ss_pad1: [u8; 6],
1424                     pub __ss_pad2: i64,
1425                     pub __ss_pad3: [u8; 240],
1426                 }
1427                 impl ::core::clone::Clone for sockaddr_storage {
1428                     fn clone(&self) -> sockaddr_storage { *self }
1429                 }
1430                 #[repr(C)]
1431                 #[derive(Copy, Clone)] pub struct sockaddr_in {
1432                     pub sin_len: u8,
1433                     pub sin_family: sa_family_t,
1434                     pub sin_port: in_port_t,
1435                     pub sin_addr: in_addr,
1436                     pub sin_zero: [u8; 8],
1437                 }
1438                 #[repr(C)]
1439                 #[derive(Copy, Clone)] pub struct in_addr {
1440                     pub s_addr: in_addr_t,
1441                 }
1442                 #[repr(C)]
1443                 #[derive(Copy, Clone)] pub struct sockaddr_in6 {
1444                     pub sin6_len: u8,
1445                     pub sin6_family: sa_family_t,
1446                     pub sin6_port: in_port_t,
1447                     pub sin6_flowinfo: u32,
1448                     pub sin6_addr: in6_addr,
1449                     pub sin6_scope_id: u32,
1450                 }
1451                 #[repr(C)]
1452                 #[derive(Copy, Clone)] pub struct in6_addr {
1453                     pub s6_addr: [u16; 8]
1454                 }
1455                 #[repr(C)]
1456                 #[derive(Copy, Clone)] pub struct ip_mreq {
1457                     pub imr_multiaddr: in_addr,
1458                     pub imr_interface: in_addr,
1459                 }
1460                 #[repr(C)]
1461                 #[derive(Copy, Clone)] pub struct ip6_mreq {
1462                     pub ipv6mr_multiaddr: in6_addr,
1463                     pub ipv6mr_interface: c_uint,
1464                 }
1465                 #[repr(C)]
1466                 #[derive(Copy, Clone)] pub struct addrinfo {
1467                     pub ai_flags: c_int,
1468                     pub ai_family: c_int,
1469                     pub ai_socktype: c_int,
1470                     pub ai_protocol: c_int,
1471                     pub ai_addrlen: socklen_t,
1472                     pub ai_addr: *mut sockaddr,
1473                     pub ai_canonname: *mut c_char,
1474                     pub ai_next: *mut addrinfo,
1475                 }
1476                 #[repr(C)]
1477                 #[derive(Copy)] pub struct sockaddr_un {
1478                     pub sun_len: u8,
1479                     pub sun_family: sa_family_t,
1480                     pub sun_path: [c_char; 104]
1481                 }
1482                 impl ::core::clone::Clone for sockaddr_un {
1483                     fn clone(&self) -> sockaddr_un { *self }
1484                 }
1485                 #[repr(C)]
1486                 #[derive(Copy, Clone)] pub struct ifaddrs {
1487                     pub ifa_next: *mut ifaddrs,
1488                     pub ifa_name: *mut c_char,
1489                     pub ifa_flags: c_uint,
1490                     pub ifa_addr: *mut sockaddr,
1491                     pub ifa_netmask: *mut sockaddr,
1492                     pub ifa_dstaddr: *mut sockaddr,
1493                     pub ifa_data: *mut c_void
1494                 }
1495             }
1496         }
1497
1498         #[cfg(target_arch = "x86_64")]
1499         pub mod arch {
1500             pub mod c95 {
1501                 pub type c_char = i8;
1502                 pub type c_schar = i8;
1503                 pub type c_uchar = u8;
1504                 pub type c_short = i16;
1505                 pub type c_ushort = u16;
1506                 pub type c_int = i32;
1507                 pub type c_uint = u32;
1508                 pub type c_long = i64;
1509                 pub type c_ulong = u64;
1510                 pub type c_float = f32;
1511                 pub type c_double = f64;
1512                 pub type size_t = u64;
1513                 pub type ptrdiff_t = i64;
1514                 pub type clock_t = i64;
1515                 pub type time_t = i64;
1516                 pub type suseconds_t = i64;
1517                 pub type wchar_t = i32;
1518             }
1519             pub mod c99 {
1520                 pub type c_longlong = i64;
1521                 pub type c_ulonglong = u64;
1522                 pub type intptr_t = i64;
1523                 pub type uintptr_t = u64;
1524                 pub type intmax_t = i64;
1525                 pub type uintmax_t = u64;
1526             }
1527             pub mod posix88 {
1528                 use types::os::arch::c95::{c_long};
1529                 pub type off_t = i64;
1530                 pub type dev_t = i32;
1531                 pub type pid_t = i32;
1532                 pub type uid_t = u32;
1533                 pub type gid_t = u32;
1534                 pub type useconds_t = u32;
1535                 pub type mode_t = u32;
1536                 pub type ssize_t = c_long;
1537             }
1538             pub mod posix01 {
1539                 use types::common::c95::{c_void};
1540                 use types::common::c99::{uint32_t, uint64_t};
1541                 use types::os::arch::c95::{c_long, time_t};
1542                 use types::os::arch::posix88::{dev_t, gid_t};
1543                 use types::os::arch::posix88::{mode_t, off_t};
1544                 use types::os::arch::posix88::{uid_t};
1545
1546                 pub type nlink_t = uint32_t;
1547                 pub type blksize_t = uint32_t;
1548                 pub type ino_t = uint64_t;
1549                 pub type blkcnt_t = i64;
1550                 pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t
1551
1552                 #[repr(C)]
1553                 #[derive(Copy, Clone)] pub struct stat {
1554                     pub st_mode: mode_t,
1555                     pub st_dev: dev_t,
1556                     pub st_ino: ino_t,
1557                     pub st_nlink: nlink_t,
1558                     pub st_uid: uid_t,
1559                     pub st_gid: gid_t,
1560                     pub st_rdev: dev_t,
1561                     pub st_atime: time_t,
1562                     pub st_atime_nsec: c_long,
1563                     pub st_mtime: time_t,
1564                     pub st_mtime_nsec: c_long,
1565                     pub st_ctime: time_t,
1566                     pub st_ctime_nsec: c_long,
1567                     pub st_size: off_t,
1568                     pub st_blocks: blkcnt_t,
1569                     pub st_blksize: blksize_t,
1570                     pub st_flags: fflags_t,
1571                     pub st_gen: uint32_t,
1572                     pub st_birthtime: time_t,
1573                     pub st_birthtime_nsec: c_long,
1574                 }
1575                 #[repr(C)]
1576                 #[derive(Copy, Clone)] pub struct utimbuf {
1577                     pub actime: time_t,
1578                     pub modtime: time_t,
1579                 }
1580
1581                 pub type pthread_attr_t = *mut c_void;
1582             }
1583             pub mod posix08 {
1584             }
1585             pub mod bsd44 {
1586             }
1587             pub mod extra {
1588             }
1589         }
1590     }
1591
1592     #[cfg(target_os = "windows")]
1593     pub mod os {
1594         pub mod common {
1595             pub mod posix01 {
1596                 use types::os::arch::c95::{c_short, time_t, c_long};
1597                 use types::os::arch::extra::{int64, time64_t};
1598                 use types::os::arch::posix88::{dev_t, ino_t};
1599
1600                 // pub Note: this is the struct called stat64 in Windows. Not stat,
1601                 // nor stati64.
1602                 #[repr(C)]
1603                 #[derive(Copy, Clone)] pub struct stat {
1604                     pub st_dev: dev_t,
1605                     pub st_ino: ino_t,
1606                     pub st_mode: u16,
1607                     pub st_nlink: c_short,
1608                     pub st_uid: c_short,
1609                     pub st_gid: c_short,
1610                     pub st_rdev: dev_t,
1611                     pub st_size: int64,
1612                     pub st_atime: time64_t,
1613                     pub st_mtime: time64_t,
1614                     pub st_ctime: time64_t,
1615                 }
1616
1617                 // note that this is called utimbuf64 in Windows
1618                 #[repr(C)]
1619                 #[derive(Copy, Clone)] pub struct utimbuf {
1620                     pub actime: time64_t,
1621                     pub modtime: time64_t,
1622                 }
1623
1624                 #[repr(C)]
1625                 #[derive(Copy, Clone)] pub struct timeval {
1626                     pub tv_sec: c_long,
1627                     pub tv_usec: c_long,
1628                 }
1629
1630                 #[repr(C)]
1631                 #[derive(Copy, Clone)] pub struct timespec {
1632                     pub tv_sec: time_t,
1633                     pub tv_nsec: c_long,
1634                 }
1635
1636                 pub enum timezone {}
1637             }
1638
1639             pub mod bsd44 {
1640                 use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1641                 use types::os::arch::c99::uintptr_t;
1642
1643                 pub type SOCKET = uintptr_t;
1644                 pub type socklen_t = c_int;
1645                 pub type sa_family_t = u16;
1646                 pub type in_port_t = u16;
1647                 pub type in_addr_t = u32;
1648                 #[repr(C)]
1649                 #[derive(Copy, Clone)] pub struct sockaddr {
1650                     pub sa_family: sa_family_t,
1651                     pub sa_data: [u8; 14],
1652                 }
1653                 #[repr(C)]
1654                 #[derive(Copy)] pub struct sockaddr_storage {
1655                     pub ss_family: sa_family_t,
1656                     pub __ss_pad1: [u8; 6],
1657                     pub __ss_align: i64,
1658                     pub __ss_pad2: [u8; 112],
1659                 }
1660                 impl ::core::clone::Clone for sockaddr_storage {
1661                     fn clone(&self) -> sockaddr_storage { *self }
1662                 }
1663                 #[repr(C)]
1664                 #[derive(Copy, Clone)] pub struct sockaddr_in {
1665                     pub sin_family: sa_family_t,
1666                     pub sin_port: in_port_t,
1667                     pub sin_addr: in_addr,
1668                     pub sin_zero: [u8; 8],
1669                 }
1670                 #[repr(C)]
1671                 #[derive(Copy, Clone)] pub struct in_addr {
1672                     pub s_addr: in_addr_t,
1673                 }
1674                 #[repr(C)]
1675                 #[derive(Copy, Clone)] pub struct sockaddr_in6 {
1676                     pub sin6_family: sa_family_t,
1677                     pub sin6_port: in_port_t,
1678                     pub sin6_flowinfo: u32,
1679                     pub sin6_addr: in6_addr,
1680                     pub sin6_scope_id: u32,
1681                 }
1682                 #[repr(C)]
1683                 #[derive(Copy, Clone)] pub struct in6_addr {
1684                     pub s6_addr: [u16; 8]
1685                 }
1686                 #[repr(C)]
1687                 #[derive(Copy, Clone)] pub struct ip_mreq {
1688                     pub imr_multiaddr: in_addr,
1689                     pub imr_interface: in_addr,
1690                 }
1691                 #[repr(C)]
1692                 #[derive(Copy, Clone)] pub struct ip6_mreq {
1693                     pub ipv6mr_multiaddr: in6_addr,
1694                     pub ipv6mr_interface: c_uint,
1695                 }
1696                 #[repr(C)]
1697                 #[derive(Copy, Clone)] pub struct addrinfo {
1698                     pub ai_flags: c_int,
1699                     pub ai_family: c_int,
1700                     pub ai_socktype: c_int,
1701                     pub ai_protocol: c_int,
1702                     pub ai_addrlen: size_t,
1703                     pub ai_canonname: *mut c_char,
1704                     pub ai_addr: *mut sockaddr,
1705                     pub ai_next: *mut addrinfo,
1706                 }
1707                 #[repr(C)]
1708                 #[derive(Copy)] pub struct sockaddr_un {
1709                     pub sun_family: sa_family_t,
1710                     pub sun_path: [c_char; 108]
1711                 }
1712                 impl ::core::clone::Clone for sockaddr_un {
1713                     fn clone(&self) -> sockaddr_un { *self }
1714                 }
1715             }
1716         }
1717
1718         pub mod arch {
1719             pub mod c95 {
1720                 pub type c_char = i8;
1721                 pub type c_schar = i8;
1722                 pub type c_uchar = u8;
1723                 pub type c_short = i16;
1724                 pub type c_ushort = u16;
1725                 pub type c_int = i32;
1726                 pub type c_uint = u32;
1727                 pub type c_long = i32;
1728                 pub type c_ulong = u32;
1729                 pub type c_float = f32;
1730                 pub type c_double = f64;
1731
1732                 #[cfg(target_arch = "x86")]
1733                 pub type size_t = u32;
1734                 #[cfg(target_arch = "x86_64")]
1735                 pub type size_t = u64;
1736
1737                 #[cfg(target_arch = "x86")]
1738                 pub type ptrdiff_t = i32;
1739                 #[cfg(target_arch = "x86_64")]
1740                 pub type ptrdiff_t = i64;
1741
1742                 pub type clock_t = i32;
1743
1744                 #[cfg(target_arch = "x86")]
1745                 pub type time_t = i32;
1746                 #[cfg(target_arch = "x86_64")]
1747                 pub type time_t = i64;
1748
1749                 #[cfg(target_arch = "x86")]
1750                 pub type suseconds_t = i32;
1751                 #[cfg(target_arch = "x86_64")]
1752                 pub type suseconds_t = i64;
1753
1754                 pub type wchar_t = u16;
1755             }
1756
1757             pub mod c99 {
1758                 pub type c_longlong = i64;
1759                 pub type c_ulonglong = u64;
1760
1761                 #[cfg(target_arch = "x86")]
1762                 pub type intptr_t = i32;
1763                 #[cfg(target_arch = "x86_64")]
1764                 pub type intptr_t = i64;
1765
1766                 #[cfg(target_arch = "x86")]
1767                 pub type uintptr_t = u32;
1768                 #[cfg(target_arch = "x86_64")]
1769                 pub type uintptr_t = u64;
1770
1771                 pub type intmax_t = i64;
1772                 pub type uintmax_t = u64;
1773             }
1774
1775             pub mod posix88 {
1776                 pub type off_t = i32;
1777                 pub type dev_t = u32;
1778                 pub type ino_t = u16;
1779
1780                 pub type pid_t = u32;
1781
1782                 pub type useconds_t = u32;
1783                 pub type mode_t = u16;
1784
1785                 #[cfg(target_arch = "x86")]
1786                 pub type ssize_t = i32;
1787                 #[cfg(target_arch = "x86_64")]
1788                 pub type ssize_t = i64;
1789             }
1790
1791             pub mod posix01 {
1792             }
1793             pub mod posix08 {
1794             }
1795             pub mod bsd44 {
1796             }
1797             pub mod extra {
1798                 use consts::os::extra::{MAX_PROTOCOL_CHAIN,
1799                                               WSAPROTOCOL_LEN};
1800                 use types::common::c95::c_void;
1801                 use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1802                 use types::os::arch::c95::{c_long, c_ulong};
1803                 use types::os::arch::c95::{wchar_t};
1804                 use types::os::arch::c99::{c_ulonglong, c_longlong, uintptr_t};
1805
1806                 pub type BOOL = c_int;
1807                 pub type BYTE = u8;
1808                 pub type BOOLEAN = BYTE;
1809                 pub type CCHAR = c_char;
1810                 pub type CHAR = c_char;
1811
1812                 pub type DWORD = c_ulong;
1813                 pub type DWORDLONG = c_ulonglong;
1814
1815                 pub type HANDLE = LPVOID;
1816                 pub type HINSTANCE = HANDLE;
1817                 pub type HMODULE = HINSTANCE;
1818
1819                 pub type LONG = c_long;
1820                 pub type PLONG = *mut c_long;
1821
1822                 #[cfg(target_arch = "x86")]
1823                 pub type LONG_PTR = c_long;
1824                 #[cfg(target_arch = "x86_64")]
1825                 pub type LONG_PTR = i64;
1826
1827                 pub type LARGE_INTEGER = c_longlong;
1828                 pub type PLARGE_INTEGER = *mut c_longlong;
1829
1830                 pub type LPCWSTR = *const WCHAR;
1831                 pub type LPCSTR = *const CHAR;
1832
1833                 pub type LPWSTR = *mut WCHAR;
1834                 pub type LPSTR = *mut CHAR;
1835
1836                 pub type LPWCH = *mut WCHAR;
1837                 pub type LPCH = *mut CHAR;
1838
1839                 #[repr(C)]
1840                 #[derive(Copy, Clone)] pub struct SECURITY_ATTRIBUTES {
1841                     pub nLength: DWORD,
1842                     pub lpSecurityDescriptor: LPVOID,
1843                     pub bInheritHandle: BOOL,
1844                 }
1845                 pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES;
1846
1847                 pub type LPVOID = *mut c_void;
1848                 pub type LPCVOID = *const c_void;
1849                 pub type LPBYTE = *mut BYTE;
1850                 pub type LPWORD = *mut WORD;
1851                 pub type LPDWORD = *mut DWORD;
1852                 pub type LPHANDLE = *mut HANDLE;
1853
1854                 pub type LRESULT = LONG_PTR;
1855                 pub type PBOOL = *mut BOOL;
1856                 pub type WCHAR = wchar_t;
1857                 pub type WORD = u16;
1858                 pub type SIZE_T = size_t;
1859
1860                 pub type time64_t = i64;
1861                 pub type int64 = i64;
1862
1863                 #[repr(C)]
1864                 #[derive(Copy, Clone)] pub struct STARTUPINFO {
1865                     pub cb: DWORD,
1866                     pub lpReserved: LPWSTR,
1867                     pub lpDesktop: LPWSTR,
1868                     pub lpTitle: LPWSTR,
1869                     pub dwX: DWORD,
1870                     pub dwY: DWORD,
1871                     pub dwXSize: DWORD,
1872                     pub dwYSize: DWORD,
1873                     pub dwXCountChars: DWORD,
1874                     pub dwYCountCharts: DWORD,
1875                     pub dwFillAttribute: DWORD,
1876                     pub dwFlags: DWORD,
1877                     pub wShowWindow: WORD,
1878                     pub cbReserved2: WORD,
1879                     pub lpReserved2: LPBYTE,
1880                     pub hStdInput: HANDLE,
1881                     pub hStdOutput: HANDLE,
1882                     pub hStdError: HANDLE,
1883                 }
1884                 pub type LPSTARTUPINFO = *mut STARTUPINFO;
1885
1886                 #[repr(C)]
1887                 #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION {
1888                     pub hProcess: HANDLE,
1889                     pub hThread: HANDLE,
1890                     pub dwProcessId: DWORD,
1891                     pub dwThreadId: DWORD,
1892                 }
1893                 pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
1894
1895                 #[repr(C)]
1896                 #[derive(Copy, Clone)] pub struct SYSTEM_INFO {
1897                     pub wProcessorArchitecture: WORD,
1898                     pub wReserved: WORD,
1899                     pub dwPageSize: DWORD,
1900                     pub lpMinimumApplicationAddress: LPVOID,
1901                     pub lpMaximumApplicationAddress: LPVOID,
1902                     pub dwActiveProcessorMask: uintptr_t,
1903                     pub dwNumberOfProcessors: DWORD,
1904                     pub dwProcessorType: DWORD,
1905                     pub dwAllocationGranularity: DWORD,
1906                     pub wProcessorLevel: WORD,
1907                     pub wProcessorRevision: WORD,
1908                 }
1909                 pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
1910
1911                 #[repr(C)]
1912                 #[derive(Copy, Clone)] pub struct MEMORY_BASIC_INFORMATION {
1913                     pub BaseAddress: LPVOID,
1914                     pub AllocationBase: LPVOID,
1915                     pub AllocationProtect: DWORD,
1916                     pub RegionSize: SIZE_T,
1917                     pub State: DWORD,
1918                     pub Protect: DWORD,
1919                     pub Type: DWORD,
1920                 }
1921                 pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
1922
1923                 #[repr(C)]
1924                 #[derive(Copy, Clone)] pub struct OVERLAPPED {
1925                     pub Internal: *mut c_ulong,
1926                     pub InternalHigh: *mut c_ulong,
1927                     pub Offset: DWORD,
1928                     pub OffsetHigh: DWORD,
1929                     pub hEvent: HANDLE,
1930                 }
1931
1932                 pub type LPOVERLAPPED = *mut OVERLAPPED;
1933
1934                 #[repr(C)]
1935                 #[derive(Copy, Clone)] pub struct FILETIME {
1936                     pub dwLowDateTime: DWORD,
1937                     pub dwHighDateTime: DWORD,
1938                 }
1939
1940                 pub type LPFILETIME = *mut FILETIME;
1941
1942                 #[repr(C)]
1943                 #[derive(Copy, Clone)] pub struct GUID {
1944                     pub Data1: DWORD,
1945                     pub Data2: WORD,
1946                     pub Data3: WORD,
1947                     pub Data4: [BYTE; 8],
1948                 }
1949
1950                 #[repr(C)]
1951                 #[derive(Copy, Clone)] pub struct WSAPROTOCOLCHAIN {
1952                     pub ChainLen: c_int,
1953                     pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize],
1954                 }
1955
1956                 pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
1957
1958                 #[repr(C)]
1959                 #[derive(Copy)] pub struct WSAPROTOCOL_INFO {
1960                     pub dwServiceFlags1: DWORD,
1961                     pub dwServiceFlags2: DWORD,
1962                     pub dwServiceFlags3: DWORD,
1963                     pub dwServiceFlags4: DWORD,
1964                     pub dwProviderFlags: DWORD,
1965                     pub ProviderId: GUID,
1966                     pub dwCatalogEntryId: DWORD,
1967                     pub ProtocolChain: WSAPROTOCOLCHAIN,
1968                     pub iVersion: c_int,
1969                     pub iAddressFamily: c_int,
1970                     pub iMaxSockAddr: c_int,
1971                     pub iMinSockAddr: c_int,
1972                     pub iSocketType: c_int,
1973                     pub iProtocol: c_int,
1974                     pub iProtocolMaxOffset: c_int,
1975                     pub iNetworkByteOrder: c_int,
1976                     pub iSecurityScheme: c_int,
1977                     pub dwMessageSize: DWORD,
1978                     pub dwProviderReserved: DWORD,
1979                     pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1],
1980                 }
1981                 impl ::core::clone::Clone for WSAPROTOCOL_INFO {
1982                     fn clone(&self) -> WSAPROTOCOL_INFO { *self }
1983                 }
1984
1985                 pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO;
1986
1987                 pub type GROUP = c_uint;
1988
1989                 #[repr(C)]
1990                 #[derive(Copy)] pub struct WIN32_FIND_DATAW {
1991                     pub dwFileAttributes: DWORD,
1992                     pub ftCreationTime: FILETIME,
1993                     pub ftLastAccessTime: FILETIME,
1994                     pub ftLastWriteTime: FILETIME,
1995                     pub nFileSizeHigh: DWORD,
1996                     pub nFileSizeLow: DWORD,
1997                     pub dwReserved0: DWORD,
1998                     pub dwReserved1: DWORD,
1999                     pub cFileName: [wchar_t; 260], // #define MAX_PATH 260
2000                     pub cAlternateFileName: [wchar_t; 14],
2001                 }
2002                 impl ::core::clone::Clone for WIN32_FIND_DATAW {
2003                     fn clone(&self) -> WIN32_FIND_DATAW { *self }
2004                 }
2005
2006                 pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW;
2007             }
2008         }
2009     }
2010
2011     #[cfg(any(target_os = "macos", target_os = "ios"))]
2012     pub mod os {
2013         pub mod common {
2014             pub mod posix01 {
2015                 use types::common::c95::c_void;
2016                 use types::os::arch::c95::{c_char, c_int, size_t, time_t};
2017                 use types::os::arch::c95::{suseconds_t, c_long};
2018                 use types::os::arch::c99::{uintptr_t};
2019
2020                 pub type pthread_t = uintptr_t;
2021                 pub type rlim_t = u64;
2022
2023                 #[repr(C)]
2024                 #[derive(Copy, Clone)] pub struct glob_t {
2025                     pub gl_pathc:  size_t,
2026                     pub __unused1: c_int,
2027                     pub gl_offs:   size_t,
2028                     pub __unused2: c_int,
2029                     pub gl_pathv:  *mut *mut c_char,
2030
2031                     pub __unused3: *mut c_void,
2032
2033                     pub __unused4: *mut c_void,
2034                     pub __unused5: *mut c_void,
2035                     pub __unused6: *mut c_void,
2036                     pub __unused7: *mut c_void,
2037                     pub __unused8: *mut c_void,
2038                 }
2039
2040                 #[repr(C)]
2041                 #[derive(Copy, Clone)] pub struct timeval {
2042                     pub tv_sec: time_t,
2043                     pub tv_usec: suseconds_t,
2044                 }
2045
2046                 #[repr(C)]
2047                 #[derive(Copy, Clone)] pub struct timespec {
2048                     pub tv_sec: time_t,
2049                     pub tv_nsec: c_long,
2050                 }
2051
2052                 pub enum timezone {}
2053
2054                 pub type sighandler_t = size_t;
2055
2056                 #[repr(C)]
2057                 #[derive(Copy, Clone)]
2058                 pub struct rlimit {
2059                     pub rlim_cur: rlim_t,
2060                     pub rlim_max: rlim_t,
2061                 }
2062             }
2063
2064             pub mod bsd43 {
2065                 use types::os::common::posix01::timeval;
2066                 use types::os::arch::c95::c_long;
2067                 #[repr(C)]
2068                 #[derive(Copy, Clone)]
2069                 pub struct rusage {
2070                     pub ru_utime: timeval,
2071                     pub ru_stime: timeval,
2072                     pub ru_maxrss: c_long,
2073                     pub ru_ixrss: c_long,
2074                     pub ru_idrss: c_long,
2075                     pub ru_isrss: c_long,
2076                     pub ru_minflt: c_long,
2077                     pub ru_majflt: c_long,
2078                     pub ru_nswap: c_long,
2079                     pub ru_inblock: c_long,
2080                     pub ru_oublock: c_long,
2081                     pub ru_msgsnd: c_long,
2082                     pub ru_msgrcv: c_long,
2083                     pub ru_nsignals: c_long,
2084                     pub ru_nvcsw: c_long,
2085                     pub ru_nivcsw: c_long
2086                 }
2087             }
2088
2089             pub mod bsd44 {
2090                 use types::common::c95::{c_void};
2091                 use types::os::arch::c95::{c_char, c_int, c_uint};
2092
2093                 pub type socklen_t = u32;
2094                 pub type sa_family_t = u8;
2095                 pub type in_port_t = u16;
2096                 pub type in_addr_t = u32;
2097                 #[repr(C)]
2098                 #[derive(Copy, Clone)] pub struct sockaddr {
2099                     pub sa_len: u8,
2100                     pub sa_family: sa_family_t,
2101                     pub sa_data: [u8; 14],
2102                 }
2103
2104                 #[repr(C)]
2105                 #[derive(Copy)] pub struct sockaddr_storage {
2106                     pub ss_len: u8,
2107                     pub ss_family: sa_family_t,
2108                     pub __ss_pad1: [u8; 6],
2109                     pub __ss_align: i64,
2110                     pub __ss_pad2: [u8; 112],
2111                 }
2112                 impl ::core::clone::Clone for sockaddr_storage {
2113                     fn clone(&self) -> sockaddr_storage { *self }
2114                 }
2115
2116                 #[repr(C)]
2117                 #[derive(Copy, Clone)] pub struct sockaddr_in {
2118                     pub sin_len: u8,
2119                     pub sin_family: sa_family_t,
2120                     pub sin_port: in_port_t,
2121                     pub sin_addr: in_addr,
2122                     pub sin_zero: [u8; 8],
2123                 }
2124
2125                 #[repr(C)]
2126                 #[derive(Copy, Clone)] pub struct in_addr {
2127                     pub s_addr: in_addr_t,
2128                 }
2129
2130                 #[repr(C)]
2131                 #[derive(Copy, Clone)] pub struct sockaddr_in6 {
2132                     pub sin6_len: u8,
2133                     pub sin6_family: sa_family_t,
2134                     pub sin6_port: in_port_t,
2135                     pub sin6_flowinfo: u32,
2136                     pub sin6_addr: in6_addr,
2137                     pub sin6_scope_id: u32,
2138                 }
2139
2140                 #[repr(C)]
2141                 #[derive(Copy, Clone)] pub struct in6_addr {
2142                     pub s6_addr: [u16; 8]
2143                 }
2144
2145                 #[repr(C)]
2146                 #[derive(Copy, Clone)] pub struct ip_mreq {
2147                     pub imr_multiaddr: in_addr,
2148                     pub imr_interface: in_addr,
2149                 }
2150
2151                 #[repr(C)]
2152                 #[derive(Copy, Clone)] pub struct ip6_mreq {
2153                     pub ipv6mr_multiaddr: in6_addr,
2154                     pub ipv6mr_interface: c_uint,
2155                 }
2156
2157                 #[repr(C)]
2158                 #[derive(Copy, Clone)] pub struct addrinfo {
2159                     pub ai_flags: c_int,
2160                     pub ai_family: c_int,
2161                     pub ai_socktype: c_int,
2162                     pub ai_protocol: c_int,
2163                     pub ai_addrlen: socklen_t,
2164                     pub ai_canonname: *mut c_char,
2165                     pub ai_addr: *mut sockaddr,
2166                     pub ai_next: *mut addrinfo,
2167                 }
2168
2169                 #[repr(C)]
2170                 #[derive(Copy)] pub struct sockaddr_un {
2171                     pub sun_len: u8,
2172                     pub sun_family: sa_family_t,
2173                     pub sun_path: [c_char; 104]
2174                 }
2175                 impl ::core::clone::Clone for sockaddr_un {
2176                     fn clone(&self) -> sockaddr_un { *self }
2177                 }
2178
2179                 #[repr(C)]
2180                 #[derive(Copy, Clone)] pub struct ifaddrs {
2181                     pub ifa_next: *mut ifaddrs,
2182                     pub ifa_name: *mut c_char,
2183                     pub ifa_flags: c_uint,
2184                     pub ifa_addr: *mut sockaddr,
2185                     pub ifa_netmask: *mut sockaddr,
2186                     pub ifa_dstaddr: *mut sockaddr,
2187                     pub ifa_data: *mut c_void
2188                 }
2189             }
2190         }
2191
2192         #[cfg(any(target_arch = "arm", target_arch = "x86"))]
2193         pub mod arch {
2194             pub mod c95 {
2195                 pub type c_char = i8;
2196                 pub type c_schar = i8;
2197                 pub type c_uchar = u8;
2198                 pub type c_short = i16;
2199                 pub type c_ushort = u16;
2200                 pub type c_int = i32;
2201                 pub type c_uint = u32;
2202                 pub type c_long = i32;
2203                 pub type c_ulong = u32;
2204                 pub type c_float = f32;
2205                 pub type c_double = f64;
2206                 pub type size_t = u32;
2207                 pub type ptrdiff_t = i32;
2208                 pub type clock_t = c_ulong;
2209                 pub type time_t = c_long;
2210                 pub type suseconds_t = i32;
2211                 pub type wchar_t = i32;
2212             }
2213             pub mod c99 {
2214                 pub type c_longlong = i64;
2215                 pub type c_ulonglong = u64;
2216                 pub type intptr_t = i32;
2217                 pub type uintptr_t = u32;
2218                 pub type intmax_t = i64;
2219                 pub type uintmax_t = u64;
2220             }
2221             pub mod posix88 {
2222                 use types::os::arch::c95::c_long;
2223
2224                 pub type off_t = i64;
2225                 pub type dev_t = i32;
2226                 pub type ino_t = u64;
2227                 pub type pid_t = i32;
2228                 pub type uid_t = u32;
2229                 pub type gid_t = u32;
2230                 pub type useconds_t = u32;
2231                 pub type mode_t = u16;
2232                 pub type ssize_t = c_long;
2233             }
2234             pub mod posix01 {
2235                 use types::common::c99::{int32_t, int64_t, uint32_t};
2236                 use types::os::arch::c95::{c_char, c_long, time_t};
2237                 use types::os::arch::posix88::{dev_t, gid_t, ino_t,
2238                                                      mode_t, off_t, uid_t};
2239
2240                 pub type nlink_t = u16;
2241                 pub type blksize_t = i32;
2242                 pub type blkcnt_t = i64;
2243
2244                 #[repr(C)]
2245                 #[derive(Copy, Clone)] pub struct stat {
2246                     pub st_dev: dev_t,
2247                     pub st_mode: mode_t,
2248                     pub st_nlink: nlink_t,
2249                     pub st_ino: ino_t,
2250                     pub st_uid: uid_t,
2251                     pub st_gid: gid_t,
2252                     pub st_rdev: dev_t,
2253                     pub st_atime: time_t,
2254                     pub st_atime_nsec: c_long,
2255                     pub st_mtime: time_t,
2256                     pub st_mtime_nsec: c_long,
2257                     pub st_ctime: time_t,
2258                     pub st_ctime_nsec: c_long,
2259                     pub st_birthtime: time_t,
2260                     pub st_birthtime_nsec: c_long,
2261                     pub st_size: off_t,
2262                     pub st_blocks: blkcnt_t,
2263                     pub st_blksize: blksize_t,
2264                     pub st_flags: uint32_t,
2265                     pub st_gen: uint32_t,
2266                     pub st_lspare: int32_t,
2267                     pub st_qspare: [int64_t; 2],
2268                 }
2269
2270                 #[repr(C)]
2271                 #[derive(Copy, Clone)] pub struct utimbuf {
2272                     pub actime: time_t,
2273                     pub modtime: time_t,
2274                 }
2275
2276                 #[repr(C)]
2277                 #[derive(Copy)] pub struct pthread_attr_t {
2278                     pub __sig: c_long,
2279                     pub __opaque: [c_char; 36]
2280                 }
2281                 impl ::core::clone::Clone for pthread_attr_t {
2282                     fn clone(&self) -> pthread_attr_t { *self }
2283                 }
2284             }
2285             pub mod posix08 {
2286             }
2287             pub mod bsd44 {
2288             }
2289             pub mod extra {
2290                 #[repr(C)]
2291                 #[derive(Copy, Clone)] pub struct mach_timebase_info {
2292                     pub numer: u32,
2293                     pub denom: u32,
2294                 }
2295
2296                 pub type mach_timebase_info_data_t = mach_timebase_info;
2297             }
2298         }
2299
2300         #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
2301         pub mod arch {
2302             pub mod c95 {
2303                 pub type c_char = i8;
2304                 pub type c_schar = i8;
2305                 pub type c_uchar = u8;
2306                 pub type c_short = i16;
2307                 pub type c_ushort = u16;
2308                 pub type c_int = i32;
2309                 pub type c_uint = u32;
2310                 pub type c_long = i64;
2311                 pub type c_ulong = u64;
2312                 pub type c_float = f32;
2313                 pub type c_double = f64;
2314                 pub type size_t = u64;
2315                 pub type ptrdiff_t = i64;
2316                 pub type clock_t = c_ulong;
2317                 pub type time_t = c_long;
2318                 pub type suseconds_t = i32;
2319                 pub type wchar_t = i32;
2320             }
2321             pub mod c99 {
2322                 pub type c_longlong = i64;
2323                 pub type c_ulonglong = u64;
2324                 pub type intptr_t = i64;
2325                 pub type uintptr_t = u64;
2326                 pub type intmax_t = i64;
2327                 pub type uintmax_t = u64;
2328             }
2329             pub mod posix88 {
2330                 use types::os::arch::c95::c_long;
2331
2332                 pub type off_t = i64;
2333                 pub type dev_t = i32;
2334                 pub type ino_t = u64;
2335                 pub type pid_t = i32;
2336                 pub type uid_t = u32;
2337                 pub type gid_t = u32;
2338                 pub type useconds_t = u32;
2339                 pub type mode_t = u16;
2340                 pub type ssize_t = c_long;
2341             }
2342             pub mod posix01 {
2343                 use types::common::c99::{int32_t, int64_t};
2344                 use types::common::c99::{uint32_t};
2345                 use types::os::arch::c95::{c_char, c_long, time_t};
2346                 use types::os::arch::posix88::{dev_t, gid_t, ino_t};
2347                 use types::os::arch::posix88::{mode_t, off_t, uid_t};
2348
2349                 pub type nlink_t = u16;
2350                 pub type blksize_t = i32;
2351                 pub type blkcnt_t = i64;
2352
2353                 #[repr(C)]
2354                 #[derive(Copy, Clone)] pub struct stat {
2355                     pub st_dev: dev_t,
2356                     pub st_mode: mode_t,
2357                     pub st_nlink: nlink_t,
2358                     pub st_ino: ino_t,
2359                     pub st_uid: uid_t,
2360                     pub st_gid: gid_t,
2361                     pub st_rdev: dev_t,
2362                     pub st_atime: time_t,
2363                     pub st_atime_nsec: c_long,
2364                     pub st_mtime: time_t,
2365                     pub st_mtime_nsec: c_long,
2366                     pub st_ctime: time_t,
2367                     pub st_ctime_nsec: c_long,
2368                     pub st_birthtime: time_t,
2369                     pub st_birthtime_nsec: c_long,
2370                     pub st_size: off_t,
2371                     pub st_blocks: blkcnt_t,
2372                     pub st_blksize: blksize_t,
2373                     pub st_flags: uint32_t,
2374                     pub st_gen: uint32_t,
2375                     pub st_lspare: int32_t,
2376                     pub st_qspare: [int64_t; 2],
2377                 }
2378
2379                 #[repr(C)]
2380                 #[derive(Copy, Clone)] pub struct utimbuf {
2381                     pub actime: time_t,
2382                     pub modtime: time_t,
2383                 }
2384
2385                 #[repr(C)]
2386                 #[derive(Copy)] pub struct pthread_attr_t {
2387                     pub __sig: c_long,
2388                     pub __opaque: [c_char; 56]
2389                 }
2390                 impl ::core::clone::Clone for pthread_attr_t {
2391                     fn clone(&self) -> pthread_attr_t { *self }
2392                 }
2393             }
2394             pub mod posix08 {
2395             }
2396             pub mod bsd44 {
2397             }
2398             pub mod extra {
2399                 #[repr(C)]
2400                 #[derive(Copy, Clone)] pub struct mach_timebase_info {
2401                     pub numer: u32,
2402                     pub denom: u32,
2403                 }
2404
2405                 pub type mach_timebase_info_data_t = mach_timebase_info;
2406             }
2407         }
2408     }
2409 }
2410
2411 pub mod consts {
2412     // Consts tend to vary per OS so we pull their definitions out
2413     // into this module.
2414
2415     #[cfg(target_os = "windows")]
2416     pub mod os {
2417         pub mod c95 {
2418             use types::os::arch::c95::{c_int, c_uint};
2419
2420             pub const EXIT_FAILURE : c_int = 1;
2421             pub const EXIT_SUCCESS : c_int = 0;
2422             pub const RAND_MAX : c_int = 32767;
2423             pub const EOF : c_int = -1;
2424             pub const SEEK_SET : c_int = 0;
2425             pub const SEEK_CUR : c_int = 1;
2426             pub const SEEK_END : c_int = 2;
2427             pub const _IOFBF : c_int = 0;
2428             pub const _IONBF : c_int = 4;
2429             pub const _IOLBF : c_int = 64;
2430             pub const BUFSIZ : c_uint = 512;
2431             pub const FOPEN_MAX : c_uint = 20;
2432             pub const FILENAME_MAX : c_uint = 260;
2433             pub const L_tmpnam : c_uint = 16;
2434             pub const TMP_MAX : c_uint = 32767;
2435
2436             pub const WSAEINTR: c_int = 10004;
2437             pub const WSAEBADF: c_int = 10009;
2438             pub const WSAEACCES: c_int = 10013;
2439             pub const WSAEFAULT: c_int = 10014;
2440             pub const WSAEINVAL: c_int = 10022;
2441             pub const WSAEMFILE: c_int = 10024;
2442             pub const WSAEWOULDBLOCK: c_int = 10035;
2443             pub const WSAEINPROGRESS: c_int = 10036;
2444             pub const WSAEALREADY: c_int = 10037;
2445             pub const WSAENOTSOCK: c_int = 10038;
2446             pub const WSAEDESTADDRREQ: c_int = 10039;
2447             pub const WSAEMSGSIZE: c_int = 10040;
2448             pub const WSAEPROTOTYPE: c_int = 10041;
2449             pub const WSAENOPROTOOPT: c_int = 10042;
2450             pub const WSAEPROTONOSUPPORT: c_int = 10043;
2451             pub const WSAESOCKTNOSUPPORT: c_int = 10044;
2452             pub const WSAEOPNOTSUPP: c_int = 10045;
2453             pub const WSAEPFNOSUPPORT: c_int = 10046;
2454             pub const WSAEAFNOSUPPORT: c_int = 10047;
2455             pub const WSAEADDRINUSE: c_int = 10048;
2456             pub const WSAEADDRNOTAVAIL: c_int = 10049;
2457             pub const WSAENETDOWN: c_int = 10050;
2458             pub const WSAENETUNREACH: c_int = 10051;
2459             pub const WSAENETRESET: c_int = 10052;
2460             pub const WSAECONNABORTED: c_int = 10053;
2461             pub const WSAECONNRESET: c_int = 10054;
2462             pub const WSAENOBUFS: c_int = 10055;
2463             pub const WSAEISCONN: c_int = 10056;
2464             pub const WSAENOTCONN: c_int = 10057;
2465             pub const WSAESHUTDOWN: c_int = 10058;
2466             pub const WSAETOOMANYREFS: c_int = 10059;
2467             pub const WSAETIMEDOUT: c_int = 10060;
2468             pub const WSAECONNREFUSED: c_int = 10061;
2469             pub const WSAELOOP: c_int = 10062;
2470             pub const WSAENAMETOOLONG: c_int = 10063;
2471             pub const WSAEHOSTDOWN: c_int = 10064;
2472             pub const WSAEHOSTUNREACH: c_int = 10065;
2473             pub const WSAENOTEMPTY: c_int = 10066;
2474             pub const WSAEPROCLIM: c_int = 10067;
2475             pub const WSAEUSERS: c_int = 10068;
2476             pub const WSAEDQUOT: c_int = 10069;
2477             pub const WSAESTALE: c_int = 10070;
2478             pub const WSAEREMOTE: c_int = 10071;
2479             pub const WSASYSNOTREADY: c_int = 10091;
2480             pub const WSAVERNOTSUPPORTED: c_int = 10092;
2481             pub const WSANOTINITIALISED: c_int = 10093;
2482             pub const WSAEDISCON: c_int = 10101;
2483             pub const WSAENOMORE: c_int = 10102;
2484             pub const WSAECANCELLED: c_int = 10103;
2485             pub const WSAEINVALIDPROCTABLE: c_int = 10104;
2486             pub const WSAEINVALIDPROVIDER: c_int = 10105;
2487             pub const WSAEPROVIDERFAILEDINIT: c_int = 10106;
2488         }
2489         pub mod c99 {
2490         }
2491         pub mod posix88 {
2492             use types::os::arch::c95::c_int;
2493             use types::os::arch::posix88::mode_t;
2494
2495             pub const O_RDONLY : c_int = 0;
2496             pub const O_WRONLY : c_int = 1;
2497             pub const O_RDWR : c_int = 2;
2498             pub const O_APPEND : c_int = 8;
2499             pub const O_CREAT : c_int = 256;
2500             pub const O_EXCL : c_int = 1024;
2501             pub const O_TRUNC : c_int = 512;
2502             pub const S_IFIFO : c_int = 4096;
2503             pub const S_IFCHR : c_int = 8192;
2504             pub const S_IFBLK : c_int = 12288;
2505             pub const S_IFDIR : c_int = 16384;
2506             pub const S_IFREG : c_int = 32768;
2507             pub const S_IFLNK : c_int = 40960;
2508             pub const S_IFMT : c_int = 61440;
2509             pub const S_IEXEC : c_int = 64;
2510             pub const S_IWRITE : c_int = 128;
2511             pub const S_IREAD : c_int = 256;
2512             pub const S_IRWXU : c_int = 448;
2513             pub const S_IXUSR : c_int = 64;
2514             pub const S_IWUSR : c_int = 128;
2515             pub const S_IRUSR : c_int = 256;
2516             pub const S_IRWXG : mode_t = 56;
2517             pub const S_IXGRP : mode_t = 8;
2518             pub const S_IWGRP : mode_t = 16;
2519             pub const S_IRGRP : mode_t = 32;
2520             pub const S_IRWXO : mode_t = 7;
2521             pub const S_IXOTH : mode_t = 1;
2522             pub const S_IWOTH : mode_t = 2;
2523             pub const S_IROTH : mode_t = 4;
2524             pub const F_OK : c_int = 0;
2525             pub const R_OK : c_int = 4;
2526             pub const W_OK : c_int = 2;
2527             pub const X_OK : c_int = 1;
2528             pub const STDIN_FILENO : c_int = 0;
2529             pub const STDOUT_FILENO : c_int = 1;
2530             pub const STDERR_FILENO : c_int = 2;
2531         }
2532         pub mod posix01 {
2533         }
2534         pub mod posix08 {
2535         }
2536         pub mod bsd44 {
2537             use types::os::arch::c95::c_int;
2538
2539             pub const AF_INET: c_int = 2;
2540             pub const AF_INET6: c_int = 23;
2541             pub const SOCK_STREAM: c_int = 1;
2542             pub const SOCK_DGRAM: c_int = 2;
2543             pub const SOCK_RAW: c_int = 3;
2544             pub const IPPROTO_TCP: c_int = 6;
2545             pub const IPPROTO_IP: c_int = 0;
2546             pub const IPPROTO_IPV6: c_int = 41;
2547             pub const IP_MULTICAST_TTL: c_int = 10;
2548             pub const IP_MULTICAST_LOOP: c_int = 11;
2549             pub const IP_ADD_MEMBERSHIP: c_int = 12;
2550             pub const IP_DROP_MEMBERSHIP: c_int = 13;
2551             pub const IPV6_ADD_MEMBERSHIP: c_int = 5;
2552             pub const IPV6_DROP_MEMBERSHIP: c_int = 6;
2553             pub const IP_TTL: c_int = 4;
2554             pub const IP_HDRINCL: c_int = 2;
2555
2556             pub const TCP_NODELAY: c_int = 0x0001;
2557             pub const SOL_SOCKET: c_int = 0xffff;
2558
2559             pub const SO_DEBUG: c_int = 0x0001;
2560             pub const SO_ACCEPTCONN: c_int = 0x0002;
2561             pub const SO_REUSEADDR: c_int = 0x0004;
2562             pub const SO_KEEPALIVE: c_int = 0x0008;
2563             pub const SO_DONTROUTE: c_int = 0x0010;
2564             pub const SO_BROADCAST: c_int = 0x0020;
2565             pub const SO_USELOOPBACK: c_int = 0x0040;
2566             pub const SO_LINGER: c_int = 0x0080;
2567             pub const SO_OOBINLINE: c_int = 0x0100;
2568             pub const SO_SNDBUF: c_int = 0x1001;
2569             pub const SO_RCVBUF: c_int = 0x1002;
2570             pub const SO_SNDLOWAT: c_int = 0x1003;
2571             pub const SO_RCVLOWAT: c_int = 0x1004;
2572             pub const SO_SNDTIMEO: c_int = 0x1005;
2573             pub const SO_RCVTIMEO: c_int = 0x1006;
2574             pub const SO_ERROR: c_int = 0x1007;
2575             pub const SO_TYPE: c_int = 0x1008;
2576
2577             pub const IFF_LOOPBACK: c_int = 4;
2578
2579             pub const SHUT_RD: c_int = 0;
2580             pub const SHUT_WR: c_int = 1;
2581             pub const SHUT_RDWR: c_int = 2;
2582         }
2583         pub mod extra {
2584             use types::os::common::bsd44::SOCKET;
2585             use types::os::arch::c95::{c_int, c_long};
2586             use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE};
2587
2588             pub const TRUE : BOOL = 1;
2589             pub const FALSE : BOOL = 0;
2590
2591             pub const O_TEXT : c_int = 16384;
2592             pub const O_BINARY : c_int = 32768;
2593             pub const O_NOINHERIT: c_int = 128;
2594
2595             pub const ERROR_SUCCESS : c_int = 0;
2596             pub const ERROR_INVALID_FUNCTION: c_int = 1;
2597             pub const ERROR_FILE_NOT_FOUND: c_int = 2;
2598             pub const ERROR_ACCESS_DENIED: c_int = 5;
2599             pub const ERROR_INVALID_HANDLE : c_int = 6;
2600             pub const ERROR_BROKEN_PIPE: c_int = 109;
2601             pub const ERROR_DISK_FULL : c_int = 112;
2602             pub const ERROR_CALL_NOT_IMPLEMENTED : c_int = 120;
2603             pub const ERROR_INSUFFICIENT_BUFFER : c_int = 122;
2604             pub const ERROR_INVALID_NAME : c_int = 123;
2605             pub const ERROR_ALREADY_EXISTS : c_int = 183;
2606             pub const ERROR_PIPE_BUSY: c_int = 231;
2607             pub const ERROR_NO_DATA: c_int = 232;
2608             pub const ERROR_INVALID_ADDRESS : c_int = 487;
2609             pub const ERROR_PIPE_CONNECTED: c_int = 535;
2610             pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758;
2611             pub const ERROR_OPERATION_ABORTED: c_int = 995;
2612             pub const ERROR_IO_PENDING: c_int = 997;
2613             pub const ERROR_FILE_INVALID : c_int = 1006;
2614             pub const ERROR_NOT_FOUND: c_int = 1168;
2615             pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
2616
2617             pub const DELETE : DWORD = 0x00010000;
2618             pub const READ_CONTROL : DWORD = 0x00020000;
2619             pub const SYNCHRONIZE : DWORD = 0x00100000;
2620             pub const WRITE_DAC : DWORD = 0x00040000;
2621             pub const WRITE_OWNER : DWORD = 0x00080000;
2622
2623             pub const PROCESS_CREATE_PROCESS : DWORD = 0x0080;
2624             pub const PROCESS_CREATE_THREAD : DWORD = 0x0002;
2625             pub const PROCESS_DUP_HANDLE : DWORD = 0x0040;
2626             pub const PROCESS_QUERY_INFORMATION : DWORD = 0x0400;
2627             pub const PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000;
2628             pub const PROCESS_SET_INFORMATION : DWORD = 0x0200;
2629             pub const PROCESS_SET_QUOTA : DWORD = 0x0100;
2630             pub const PROCESS_SUSPEND_RESUME : DWORD = 0x0800;
2631             pub const PROCESS_TERMINATE : DWORD = 0x0001;
2632             pub const PROCESS_VM_OPERATION : DWORD = 0x0008;
2633             pub const PROCESS_VM_READ : DWORD = 0x0010;
2634             pub const PROCESS_VM_WRITE : DWORD = 0x0020;
2635
2636             pub const STARTF_FORCEONFEEDBACK : DWORD = 0x00000040;
2637             pub const STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080;
2638             pub const STARTF_PREVENTPINNING : DWORD = 0x00002000;
2639             pub const STARTF_RUNFULLSCREEN : DWORD = 0x00000020;
2640             pub const STARTF_TITLEISAPPID : DWORD = 0x00001000;
2641             pub const STARTF_TITLEISLINKNAME : DWORD = 0x00000800;
2642             pub const STARTF_USECOUNTCHARS : DWORD = 0x00000008;
2643             pub const STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010;
2644             pub const STARTF_USEHOTKEY : DWORD = 0x00000200;
2645             pub const STARTF_USEPOSITION : DWORD = 0x00000004;
2646             pub const STARTF_USESHOWWINDOW : DWORD = 0x00000001;
2647             pub const STARTF_USESIZE : DWORD = 0x00000002;
2648             pub const STARTF_USESTDHANDLES : DWORD = 0x00000100;
2649
2650             pub const WAIT_ABANDONED : DWORD = 0x00000080;
2651             pub const WAIT_OBJECT_0 : DWORD = 0x00000000;
2652             pub const WAIT_TIMEOUT : DWORD = 0x00000102;
2653             pub const WAIT_FAILED : DWORD = !0;
2654
2655             pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001;
2656             pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002;
2657
2658             pub const INFINITE : DWORD = !0;
2659             pub const STILL_ACTIVE : DWORD = 259;
2660
2661             pub const MEM_COMMIT : DWORD = 0x00001000;
2662             pub const MEM_RESERVE : DWORD = 0x00002000;
2663             pub const MEM_DECOMMIT : DWORD = 0x00004000;
2664             pub const MEM_RELEASE : DWORD = 0x00008000;
2665             pub const MEM_RESET : DWORD = 0x00080000;
2666             pub const MEM_RESET_UNDO : DWORD = 0x1000000;
2667             pub const MEM_LARGE_PAGES : DWORD = 0x20000000;
2668             pub const MEM_PHYSICAL : DWORD = 0x00400000;
2669             pub const MEM_TOP_DOWN : DWORD = 0x00100000;
2670             pub const MEM_WRITE_WATCH : DWORD = 0x00200000;
2671
2672             pub const PAGE_EXECUTE : DWORD = 0x10;
2673             pub const PAGE_EXECUTE_READ : DWORD = 0x20;
2674             pub const PAGE_EXECUTE_READWRITE : DWORD = 0x40;
2675             pub const PAGE_EXECUTE_WRITECOPY : DWORD = 0x80;
2676             pub const PAGE_NOACCESS : DWORD = 0x01;
2677             pub const PAGE_READONLY : DWORD = 0x02;
2678             pub const PAGE_READWRITE : DWORD = 0x04;
2679             pub const PAGE_WRITECOPY : DWORD = 0x08;
2680             pub const PAGE_GUARD : DWORD = 0x100;
2681             pub const PAGE_NOCACHE : DWORD = 0x200;
2682             pub const PAGE_WRITECOMBINE : DWORD = 0x400;
2683
2684             pub const SEC_COMMIT : DWORD = 0x8000000;
2685             pub const SEC_IMAGE : DWORD = 0x1000000;
2686             pub const SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000;
2687             pub const SEC_LARGE_PAGES : DWORD = 0x80000000;
2688             pub const SEC_NOCACHE : DWORD = 0x10000000;
2689             pub const SEC_RESERVE : DWORD = 0x4000000;
2690             pub const SEC_WRITECOMBINE : DWORD = 0x40000000;
2691
2692             pub const FILE_MAP_ALL_ACCESS : DWORD = 0xf001f;
2693             pub const FILE_MAP_READ : DWORD = 0x4;
2694             pub const FILE_MAP_WRITE : DWORD = 0x2;
2695             pub const FILE_MAP_COPY : DWORD = 0x1;
2696             pub const FILE_MAP_EXECUTE : DWORD = 0x20;
2697
2698             pub const PROCESSOR_ARCHITECTURE_INTEL : WORD = 0;
2699             pub const PROCESSOR_ARCHITECTURE_ARM : WORD = 5;
2700             pub const PROCESSOR_ARCHITECTURE_IA64 : WORD = 6;
2701             pub const PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9;
2702             pub const PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff;
2703
2704             pub const MOVEFILE_COPY_ALLOWED: DWORD = 2;
2705             pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16;
2706             pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4;
2707             pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32;
2708             pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1;
2709             pub const MOVEFILE_WRITE_THROUGH: DWORD = 8;
2710
2711             pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1;
2712
2713             pub const FILE_SHARE_DELETE: DWORD = 0x4;
2714             pub const FILE_SHARE_READ: DWORD = 0x1;
2715             pub const FILE_SHARE_WRITE: DWORD = 0x2;
2716
2717             pub const CREATE_ALWAYS: DWORD = 2;
2718             pub const CREATE_NEW: DWORD = 1;
2719             pub const OPEN_ALWAYS: DWORD = 4;
2720             pub const OPEN_EXISTING: DWORD = 3;
2721             pub const TRUNCATE_EXISTING: DWORD = 5;
2722
2723             pub const FILE_APPEND_DATA: DWORD = 0x00000004;
2724             pub const FILE_READ_DATA: DWORD = 0x00000001;
2725             pub const FILE_WRITE_DATA: DWORD = 0x00000002;
2726
2727             pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20;
2728             pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800;
2729             pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40;
2730             pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10;
2731             pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000;
2732             pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2;
2733             pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000;
2734             pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80;
2735             pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000;
2736             pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000;
2737             pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000;
2738             pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1;
2739             pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400;
2740             pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200;
2741             pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4;
2742             pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100;
2743             pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000;
2744
2745             pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000;
2746             pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000;
2747             pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000;
2748             pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000;
2749             pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000;
2750             pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
2751             pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x0100000;
2752             pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000;
2753             pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000;
2754             pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000;
2755             pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000;
2756             pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
2757
2758             pub const FILE_NAME_NORMALIZED: DWORD = 0x0;
2759             pub const FILE_NAME_OPENED: DWORD = 0x8;
2760
2761             pub const VOLUME_NAME_DOS: DWORD = 0x0;
2762             pub const VOLUME_NAME_GUID: DWORD = 0x1;
2763             pub const VOLUME_NAME_NONE: DWORD = 0x4;
2764             pub const VOLUME_NAME_NT: DWORD = 0x2;
2765
2766             pub const GENERIC_READ: DWORD = 0x80000000;
2767             pub const GENERIC_WRITE: DWORD = 0x40000000;
2768             pub const GENERIC_EXECUTE: DWORD = 0x20000000;
2769             pub const GENERIC_ALL: DWORD = 0x10000000;
2770             pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100;
2771             pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080;
2772
2773             pub const STANDARD_RIGHTS_READ: DWORD = 0x20000;
2774             pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000;
2775             pub const FILE_WRITE_EA: DWORD = 0x00000010;
2776             pub const FILE_READ_EA: DWORD = 0x00000008;
2777             pub const FILE_GENERIC_READ: DWORD =
2778                 STANDARD_RIGHTS_READ | FILE_READ_DATA |
2779                 FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE;
2780             pub const FILE_GENERIC_WRITE: DWORD =
2781                 STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA |
2782                 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA |
2783                 SYNCHRONIZE;
2784
2785             pub const FILE_BEGIN: DWORD = 0;
2786             pub const FILE_CURRENT: DWORD = 1;
2787             pub const FILE_END: DWORD = 2;
2788
2789             pub const MAX_PROTOCOL_CHAIN: DWORD = 7;
2790             pub const WSAPROTOCOL_LEN: DWORD = 255;
2791             pub const INVALID_SOCKET: SOCKET = !0;
2792
2793             pub const DETACHED_PROCESS: DWORD = 0x00000008;
2794             pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200;
2795             pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400;
2796
2797             pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003;
2798             pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
2799             pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
2800             pub const PIPE_TYPE_BYTE: DWORD = 0x00000000;
2801             pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004;
2802             pub const PIPE_READMODE_BYTE: DWORD = 0x00000000;
2803             pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002;
2804             pub const PIPE_WAIT: DWORD = 0x00000000;
2805             pub const PIPE_NOWAIT: DWORD = 0x00000001;
2806             pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000;
2807             pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008;
2808             pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255;
2809
2810             pub const IPPROTO_RAW: c_int = 255;
2811
2812             pub const FIONBIO: c_long = -0x7FFB9982;
2813         }
2814         pub mod sysconf {
2815         }
2816     }
2817
2818
2819     #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))]
2820     pub mod os {
2821         pub mod c95 {
2822             use types::os::arch::c95::{c_int, c_uint};
2823
2824             pub const EXIT_FAILURE : c_int = 1;
2825             pub const EXIT_SUCCESS : c_int = 0;
2826             pub const RAND_MAX : c_int = 2147483647;
2827             pub const EOF : c_int = -1;
2828             pub const SEEK_SET : c_int = 0;
2829             pub const SEEK_CUR : c_int = 1;
2830             pub const SEEK_END : c_int = 2;
2831             pub const _IOFBF : c_int = 0;
2832             pub const _IONBF : c_int = 2;
2833             pub const _IOLBF : c_int = 1;
2834             pub const BUFSIZ : c_uint = 8192;
2835             pub const FOPEN_MAX : c_uint = 16;
2836             pub const FILENAME_MAX : c_uint = 4096;
2837             pub const L_tmpnam : c_uint = 20;
2838             pub const TMP_MAX : c_uint = 238328;
2839         }
2840         pub mod c99 {
2841         }
2842         #[cfg(any(target_arch = "x86",
2843                   target_arch = "x86_64",
2844                   target_arch = "arm",
2845                   target_arch = "aarch64",
2846                   target_arch = "le32",
2847                   target_arch = "powerpc"))]
2848         pub mod posix88 {
2849             use types::os::arch::c95::c_int;
2850             use types::common::c95::c_void;
2851             use types::os::arch::posix88::mode_t;
2852
2853             pub const O_RDONLY : c_int = 0;
2854             pub const O_WRONLY : c_int = 1;
2855             pub const O_RDWR : c_int = 2;
2856             pub const O_APPEND : c_int = 1024;
2857             pub const O_CREAT : c_int = 64;
2858             pub const O_EXCL : c_int = 128;
2859             pub const O_NOCTTY : c_int = 256;
2860             pub const O_TRUNC : c_int = 512;
2861             pub const S_IFIFO : mode_t = 4096;
2862             pub const S_IFCHR : mode_t = 8192;
2863             pub const S_IFBLK : mode_t = 24576;
2864             pub const S_IFDIR : mode_t = 16384;
2865             pub const S_IFREG : mode_t = 32768;
2866             pub const S_IFLNK : mode_t = 40960;
2867             pub const S_IFMT : mode_t = 61440;
2868             pub const S_IEXEC : mode_t = 64;
2869             pub const S_IWRITE : mode_t = 128;
2870             pub const S_IREAD : mode_t = 256;
2871             pub const S_IRWXU : mode_t = 448;
2872             pub const S_IXUSR : mode_t = 64;
2873             pub const S_IWUSR : mode_t = 128;
2874             pub const S_IRUSR : mode_t = 256;
2875             pub const S_IRWXG : mode_t = 56;
2876             pub const S_IXGRP : mode_t = 8;
2877             pub const S_IWGRP : mode_t = 16;
2878             pub const S_IRGRP : mode_t = 32;
2879             pub const S_IRWXO : mode_t = 7;
2880             pub const S_IXOTH : mode_t = 1;
2881             pub const S_IWOTH : mode_t = 2;
2882             pub const S_IROTH : mode_t = 4;
2883             pub const F_OK : c_int = 0;
2884             pub const R_OK : c_int = 4;
2885             pub const W_OK : c_int = 2;
2886             pub const X_OK : c_int = 1;
2887             pub const STDIN_FILENO : c_int = 0;
2888             pub const STDOUT_FILENO : c_int = 1;
2889             pub const STDERR_FILENO : c_int = 2;
2890             pub const F_LOCK : c_int = 1;
2891             pub const F_TEST : c_int = 3;
2892             pub const F_TLOCK : c_int = 2;
2893             pub const F_ULOCK : c_int = 0;
2894             pub const SIGHUP : c_int = 1;
2895             pub const SIGINT : c_int = 2;
2896             pub const SIGQUIT : c_int = 3;
2897             pub const SIGILL : c_int = 4;
2898             pub const SIGABRT : c_int = 6;
2899             pub const SIGFPE : c_int = 8;
2900             pub const SIGKILL : c_int = 9;
2901             pub const SIGSEGV : c_int = 11;
2902             pub const SIGPIPE : c_int = 13;
2903             pub const SIGALRM : c_int = 14;
2904             pub const SIGTERM : c_int = 15;
2905
2906             pub const PROT_NONE : c_int = 0;
2907             pub const PROT_READ : c_int = 1;
2908             pub const PROT_WRITE : c_int = 2;
2909             pub const PROT_EXEC : c_int = 4;
2910
2911             pub const MAP_FILE : c_int = 0x0000;
2912             pub const MAP_SHARED : c_int = 0x0001;
2913             pub const MAP_PRIVATE : c_int = 0x0002;
2914             pub const MAP_FIXED : c_int = 0x0010;
2915             pub const MAP_ANON : c_int = 0x0020;
2916
2917             pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
2918
2919             pub const MCL_CURRENT : c_int = 0x0001;
2920             pub const MCL_FUTURE : c_int = 0x0002;
2921
2922             pub const MS_ASYNC : c_int = 0x0001;
2923             pub const MS_INVALIDATE : c_int = 0x0002;
2924             pub const MS_SYNC : c_int = 0x0004;
2925
2926             pub const EPERM : c_int = 1;
2927             pub const ENOENT : c_int = 2;
2928             pub const ESRCH : c_int = 3;
2929             pub const EINTR : c_int = 4;
2930             pub const EIO : c_int = 5;
2931             pub const ENXIO : c_int = 6;
2932             pub const E2BIG : c_int = 7;
2933             pub const ENOEXEC : c_int = 8;
2934             pub const EBADF : c_int = 9;
2935             pub const ECHILD : c_int = 10;
2936             pub const EAGAIN : c_int = 11;
2937             pub const ENOMEM : c_int = 12;
2938             pub const EACCES : c_int = 13;
2939             pub const EFAULT : c_int = 14;
2940             pub const ENOTBLK : c_int = 15;
2941             pub const EBUSY : c_int = 16;
2942             pub const EEXIST : c_int = 17;
2943             pub const EXDEV : c_int = 18;
2944             pub const ENODEV : c_int = 19;
2945             pub const ENOTDIR : c_int = 20;
2946             pub const EISDIR : c_int = 21;
2947             pub const EINVAL : c_int = 22;
2948             pub const ENFILE : c_int = 23;
2949             pub const EMFILE : c_int = 24;
2950             pub const ENOTTY : c_int = 25;
2951             pub const ETXTBSY : c_int = 26;
2952             pub const EFBIG : c_int = 27;
2953             pub const ENOSPC : c_int = 28;
2954             pub const ESPIPE : c_int = 29;
2955             pub const EROFS : c_int = 30;
2956             pub const EMLINK : c_int = 31;
2957             pub const EPIPE : c_int = 32;
2958             pub const EDOM : c_int = 33;
2959             pub const ERANGE : c_int = 34;
2960
2961             pub const EDEADLK: c_int = 35;
2962             pub const ENAMETOOLONG: c_int = 36;
2963             pub const ENOLCK: c_int = 37;
2964             pub const ENOSYS: c_int = 38;
2965             pub const ENOTEMPTY: c_int = 39;
2966             pub const ELOOP: c_int = 40;
2967             pub const EWOULDBLOCK: c_int = EAGAIN;
2968             pub const ENOMSG: c_int = 42;
2969             pub const EIDRM: c_int = 43;
2970             pub const ECHRNG: c_int = 44;
2971             pub const EL2NSYNC: c_int = 45;
2972             pub const EL3HLT: c_int = 46;
2973             pub const EL3RST: c_int = 47;
2974             pub const ELNRNG: c_int = 48;
2975             pub const EUNATCH: c_int = 49;
2976             pub const ENOCSI: c_int = 50;
2977             pub const EL2HLT: c_int = 51;
2978             pub const EBADE: c_int = 52;
2979             pub const EBADR: c_int = 53;
2980             pub const EXFULL: c_int = 54;
2981             pub const ENOANO: c_int = 55;
2982             pub const EBADRQC: c_int = 56;
2983             pub const EBADSLT: c_int = 57;
2984
2985             pub const EDEADLOCK: c_int = EDEADLK;
2986
2987             pub const EBFONT: c_int = 59;
2988             pub const ENOSTR: c_int = 60;
2989             pub const ENODATA: c_int = 61;
2990             pub const ETIME: c_int = 62;
2991             pub const ENOSR: c_int = 63;
2992             pub const ENONET: c_int = 64;
2993             pub const ENOPKG: c_int = 65;
2994             pub const EREMOTE: c_int = 66;
2995             pub const ENOLINK: c_int = 67;
2996             pub const EADV: c_int = 68;
2997             pub const ESRMNT: c_int = 69;
2998             pub const ECOMM: c_int = 70;
2999             pub const EPROTO: c_int = 71;
3000             pub const EMULTIHOP: c_int = 72;
3001             pub const EDOTDOT: c_int = 73;
3002             pub const EBADMSG: c_int = 74;
3003             pub const EOVERFLOW: c_int = 75;
3004             pub const ENOTUNIQ: c_int = 76;
3005             pub const EBADFD: c_int = 77;
3006             pub const EREMCHG: c_int = 78;
3007             pub const ELIBACC: c_int = 79;
3008             pub const ELIBBAD: c_int = 80;
3009             pub const ELIBSCN: c_int = 81;
3010             pub const ELIBMAX: c_int = 82;
3011             pub const ELIBEXEC: c_int = 83;
3012             pub const EILSEQ: c_int = 84;
3013             pub const ERESTART: c_int = 85;
3014             pub const ESTRPIPE: c_int = 86;
3015             pub const EUSERS: c_int = 87;
3016             pub const ENOTSOCK: c_int = 88;
3017             pub const EDESTADDRREQ: c_int = 89;
3018             pub const EMSGSIZE: c_int = 90;
3019             pub const EPROTOTYPE: c_int = 91;
3020             pub const ENOPROTOOPT: c_int = 92;
3021             pub const EPROTONOSUPPORT: c_int = 93;
3022             pub const ESOCKTNOSUPPORT: c_int = 94;
3023             pub const EOPNOTSUPP: c_int = 95;
3024             pub const EPFNOSUPPORT: c_int = 96;
3025             pub const EAFNOSUPPORT: c_int = 97;
3026             pub const EADDRINUSE: c_int = 98;
3027             pub const EADDRNOTAVAIL: c_int = 99;
3028             pub const ENETDOWN: c_int = 100;
3029             pub const ENETUNREACH: c_int = 101;
3030             pub const ENETRESET: c_int = 102;
3031             pub const ECONNABORTED: c_int = 103;
3032             pub const ECONNRESET: c_int = 104;
3033             pub const ENOBUFS: c_int = 105;
3034             pub const EISCONN: c_int = 106;
3035             pub const ENOTCONN: c_int = 107;
3036             pub const ESHUTDOWN: c_int = 108;
3037             pub const ETOOMANYREFS: c_int = 109;
3038             pub const ETIMEDOUT: c_int = 110;
3039             pub const ECONNREFUSED: c_int = 111;
3040             pub const EHOSTDOWN: c_int = 112;
3041             pub const EHOSTUNREACH: c_int = 113;
3042             pub const EALREADY: c_int = 114;
3043             pub const EINPROGRESS: c_int = 115;
3044             pub const ESTALE: c_int = 116;
3045             pub const EUCLEAN: c_int = 117;
3046             pub const ENOTNAM: c_int = 118;
3047             pub const ENAVAIL: c_int = 119;
3048             pub const EISNAM: c_int = 120;
3049             pub const EREMOTEIO: c_int = 121;
3050             pub const EDQUOT: c_int = 122;
3051
3052             pub const ENOMEDIUM: c_int = 123;
3053             pub const EMEDIUMTYPE: c_int = 124;
3054             pub const ECANCELED: c_int = 125;
3055             pub const ENOKEY: c_int = 126;
3056             pub const EKEYEXPIRED: c_int = 127;
3057             pub const EKEYREVOKED: c_int = 128;
3058             pub const EKEYREJECTED: c_int = 129;
3059
3060             pub const EOWNERDEAD: c_int = 130;
3061             pub const ENOTRECOVERABLE: c_int = 131;
3062
3063             pub const ERFKILL: c_int = 132;
3064
3065             pub const EHWPOISON: c_int = 133;
3066         }
3067
3068         #[cfg(any(target_arch = "mips",
3069                   target_arch = "mipsel"))]
3070         pub mod posix88 {
3071             use types::os::arch::c95::c_int;
3072             use types::common::c95::c_void;
3073             use types::os::arch::posix88::mode_t;
3074
3075             pub const O_RDONLY : c_int = 0;
3076             pub const O_WRONLY : c_int = 1;
3077             pub const O_RDWR : c_int = 2;
3078             pub const O_APPEND : c_int = 8;
3079             pub const O_CREAT : c_int = 256;
3080             pub const O_EXCL : c_int = 1024;
3081             pub const O_NOCTTY : c_int = 2048;
3082             pub const O_TRUNC : c_int = 512;
3083             pub const S_IFIFO : mode_t = 4096;
3084             pub const S_IFCHR : mode_t = 8192;
3085             pub const S_IFBLK : mode_t = 24576;
3086             pub const S_IFDIR : mode_t = 16384;
3087             pub const S_IFREG : mode_t = 32768;
3088             pub const S_IFLNK : mode_t = 40960;
3089             pub const S_IFMT : mode_t = 61440;
3090             pub const S_IEXEC : mode_t = 64;
3091             pub const S_IWRITE : mode_t = 128;
3092             pub const S_IREAD : mode_t = 256;
3093             pub const S_IRWXU : mode_t = 448;
3094             pub const S_IXUSR : mode_t = 64;
3095             pub const S_IWUSR : mode_t = 128;
3096             pub const S_IRUSR : mode_t = 256;
3097             pub const S_IRWXG : mode_t = 56;
3098             pub const S_IXGRP : mode_t = 8;
3099             pub const S_IWGRP : mode_t = 16;
3100             pub const S_IRGRP : mode_t = 32;
3101             pub const S_IRWXO : mode_t = 7;
3102             pub const S_IXOTH : mode_t = 1;
3103             pub const S_IWOTH : mode_t = 2;
3104             pub const S_IROTH : mode_t = 4;
3105             pub const F_OK : c_int = 0;
3106             pub const R_OK : c_int = 4;
3107             pub const W_OK : c_int = 2;
3108             pub const X_OK : c_int = 1;
3109             pub const STDIN_FILENO : c_int = 0;
3110             pub const STDOUT_FILENO : c_int = 1;
3111             pub const STDERR_FILENO : c_int = 2;
3112             pub const F_LOCK : c_int = 1;
3113             pub const F_TEST : c_int = 3;
3114             pub const F_TLOCK : c_int = 2;
3115             pub const F_ULOCK : c_int = 0;
3116             pub const SIGHUP : c_int = 1;
3117             pub const SIGINT : c_int = 2;
3118             pub const SIGQUIT : c_int = 3;
3119             pub const SIGILL : c_int = 4;
3120             pub const SIGABRT : c_int = 6;
3121             pub const SIGFPE : c_int = 8;
3122             pub const SIGKILL : c_int = 9;
3123             pub const SIGSEGV : c_int = 11;
3124             pub const SIGPIPE : c_int = 13;
3125             pub const SIGALRM : c_int = 14;
3126             pub const SIGTERM : c_int = 15;
3127
3128             pub const PROT_NONE : c_int = 0;
3129             pub const PROT_READ : c_int = 1;
3130             pub const PROT_WRITE : c_int = 2;
3131             pub const PROT_EXEC : c_int = 4;
3132
3133             pub const MAP_FILE : c_int = 0x0000;
3134             pub const MAP_SHARED : c_int = 0x0001;
3135             pub const MAP_PRIVATE : c_int = 0x0002;
3136             pub const MAP_FIXED : c_int = 0x0010;
3137             pub const MAP_ANON : c_int = 0x0800;
3138
3139             pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
3140
3141             pub const MCL_CURRENT : c_int = 0x0001;
3142             pub const MCL_FUTURE : c_int = 0x0002;
3143
3144             pub const MS_ASYNC : c_int = 0x0001;
3145             pub const MS_INVALIDATE : c_int = 0x0002;
3146             pub const MS_SYNC : c_int = 0x0004;
3147
3148             pub const EPERM : c_int = 1;
3149             pub const ENOENT : c_int = 2;
3150             pub const ESRCH : c_int = 3;
3151             pub const EINTR : c_int = 4;
3152             pub const EIO : c_int = 5;
3153             pub const ENXIO : c_int = 6;
3154             pub const E2BIG : c_int = 7;
3155             pub const ENOEXEC : c_int = 8;
3156             pub const EBADF : c_int = 9;
3157             pub const ECHILD : c_int = 10;
3158             pub const EAGAIN : c_int = 11;
3159             pub const ENOMEM : c_int = 12;
3160             pub const EACCES : c_int = 13;
3161             pub const EFAULT : c_int = 14;
3162             pub const ENOTBLK : c_int = 15;
3163             pub const EBUSY : c_int = 16;
3164             pub const EEXIST : c_int = 17;
3165             pub const EXDEV : c_int = 18;
3166             pub const ENODEV : c_int = 19;
3167             pub const ENOTDIR : c_int = 20;
3168             pub const EISDIR : c_int = 21;
3169             pub const EINVAL : c_int = 22;
3170             pub const ENFILE : c_int = 23;
3171             pub const EMFILE : c_int = 24;
3172             pub const ENOTTY : c_int = 25;
3173             pub const ETXTBSY : c_int = 26;
3174             pub const EFBIG : c_int = 27;
3175             pub const ENOSPC : c_int = 28;
3176             pub const ESPIPE : c_int = 29;
3177             pub const EROFS : c_int = 30;
3178             pub const EMLINK : c_int = 31;
3179             pub const EPIPE : c_int = 32;
3180             pub const EDOM : c_int = 33;
3181             pub const ERANGE : c_int = 34;
3182
3183             pub const ENOMSG: c_int = 35;
3184             pub const EIDRM: c_int = 36;
3185             pub const ECHRNG: c_int = 37;
3186             pub const EL2NSYNC: c_int = 38;
3187             pub const EL3HLT: c_int = 39;
3188             pub const EL3RST: c_int = 40;
3189             pub const ELNRNG: c_int = 41;
3190             pub const EUNATCH: c_int = 42;
3191             pub const ENOCSI: c_int = 43;
3192             pub const EL2HLT: c_int = 44;
3193             pub const EDEADLK: c_int = 45;
3194             pub const ENOLCK: c_int = 46;
3195             pub const EBADE: c_int = 50;
3196             pub const EBADR: c_int = 51;
3197             pub const EXFULL: c_int = 52;
3198             pub const ENOANO: c_int = 53;
3199             pub const EBADRQC: c_int = 54;
3200             pub const EBADSLT: c_int = 55;
3201             pub const EDEADLOCK: c_int = 56;
3202             pub const EBFONT: c_int = 59;
3203             pub const ENOSTR: c_int = 60;
3204             pub const ENODATA: c_int = 61;
3205             pub const ETIME: c_int = 62;
3206             pub const ENOSR: c_int = 63;
3207             pub const ENONET: c_int = 64;
3208             pub const ENOPKG: c_int = 65;
3209             pub const EREMOTE: c_int = 66;
3210             pub const ENOLINK: c_int = 67;
3211             pub const EADV: c_int = 68;
3212             pub const ESRMNT: c_int = 69;
3213             pub const ECOMM: c_int = 70;
3214             pub const EPROTO: c_int = 71;
3215             pub const EDOTDOT: c_int = 73;
3216             pub const EMULTIHOP: c_int = 74;
3217             pub const EBADMSG: c_int = 77;
3218             pub const ENAMETOOLONG: c_int = 78;
3219             pub const EOVERFLOW: c_int = 79;
3220             pub const ENOTUNIQ: c_int = 80;
3221             pub const EBADFD: c_int = 81;
3222             pub const EREMCHG: c_int = 82;
3223             pub const ELIBACC: c_int = 83;
3224             pub const ELIBBAD: c_int = 84;
3225             pub const ELIBSCN: c_int = 95;
3226             pub const ELIBMAX: c_int = 86;
3227             pub const ELIBEXEC: c_int = 87;
3228             pub const EILSEQ: c_int = 88;
3229             pub const ENOSYS: c_int = 89;
3230             pub const ELOOP: c_int = 90;
3231             pub const ERESTART: c_int = 91;
3232             pub const ESTRPIPE: c_int = 92;
3233             pub const ENOTEMPTY: c_int = 93;
3234             pub const EUSERS: c_int = 94;
3235             pub const ENOTSOCK: c_int = 95;
3236             pub const EDESTADDRREQ: c_int = 96;
3237             pub const EMSGSIZE: c_int = 97;
3238             pub const EPROTOTYPE: c_int = 98;
3239             pub const ENOPROTOOPT: c_int = 99;
3240             pub const EPROTONOSUPPORT: c_int = 120;
3241             pub const ESOCKTNOSUPPORT: c_int = 121;
3242             pub const EOPNOTSUPP: c_int = 122;
3243             pub const EPFNOSUPPORT: c_int = 123;
3244             pub const EAFNOSUPPORT: c_int = 124;
3245             pub const EADDRINUSE: c_int = 125;
3246             pub const EADDRNOTAVAIL: c_int = 126;
3247             pub const ENETDOWN: c_int = 127;
3248             pub const ENETUNREACH: c_int = 128;
3249             pub const ENETRESET: c_int = 129;
3250             pub const ECONNABORTED: c_int = 130;
3251             pub const ECONNRESET: c_int = 131;
3252             pub const ENOBUFS: c_int = 132;
3253             pub const EISCONN: c_int = 133;
3254             pub const ENOTCONN: c_int = 134;
3255             pub const EUCLEAN: c_int = 135;
3256             pub const ENOTNAM: c_int = 137;
3257             pub const ENAVAIL: c_int = 138;
3258             pub const EISNAM: c_int = 139;
3259             pub const EREMOTEIO: c_int = 140;
3260             pub const ESHUTDOWN: c_int = 143;
3261             pub const ETOOMANYREFS: c_int = 144;
3262             pub const ETIMEDOUT: c_int = 145;
3263             pub const ECONNREFUSED: c_int = 146;
3264             pub const EHOSTDOWN: c_int = 147;
3265             pub const EHOSTUNREACH: c_int = 148;
3266             pub const EWOULDBLOCK: c_int = EAGAIN;
3267             pub const EALREADY: c_int = 149;
3268             pub const EINPROGRESS: c_int = 150;
3269             pub const ESTALE: c_int = 151;
3270             pub const ECANCELED: c_int = 158;
3271
3272             pub const ENOMEDIUM: c_int = 159;
3273             pub const EMEDIUMTYPE: c_int = 160;
3274             pub const ENOKEY: c_int = 161;
3275             pub const EKEYEXPIRED: c_int = 162;
3276             pub const EKEYREVOKED: c_int = 163;
3277             pub const EKEYREJECTED: c_int = 164;
3278
3279             pub const EOWNERDEAD: c_int = 165;
3280             pub const ENOTRECOVERABLE: c_int = 166;
3281
3282             pub const ERFKILL: c_int = 167;
3283
3284             pub const EHWPOISON: c_int = 168;
3285
3286             pub const EDQUOT: c_int = 1133;
3287         }
3288         #[cfg(not(target_os = "nacl"))]
3289         pub mod posix01 {
3290             use types::os::arch::c95::{c_int, size_t};
3291             use types::os::common::posix01::rlim_t;
3292
3293             pub const F_DUPFD : c_int = 0;
3294             pub const F_GETFD : c_int = 1;
3295             pub const F_SETFD : c_int = 2;
3296             pub const F_GETFL : c_int = 3;
3297             pub const F_SETFL : c_int = 4;
3298
3299             pub const SIGTRAP : c_int = 5;
3300             pub const SIG_IGN: size_t = 1;
3301
3302             pub const GLOB_ERR      : c_int = 1 << 0;
3303             pub const GLOB_MARK     : c_int = 1 << 1;
3304             pub const GLOB_NOSORT   : c_int = 1 << 2;
3305             pub const GLOB_DOOFFS   : c_int = 1 << 3;
3306             pub const GLOB_NOCHECK  : c_int = 1 << 4;
3307             pub const GLOB_APPEND   : c_int = 1 << 5;
3308             pub const GLOB_NOESCAPE : c_int = 1 << 6;
3309
3310             pub const GLOB_NOSPACE  : c_int = 1;
3311             pub const GLOB_ABORTED  : c_int = 2;
3312             pub const GLOB_NOMATCH  : c_int = 3;
3313
3314             pub const POSIX_MADV_NORMAL : c_int = 0;
3315             pub const POSIX_MADV_RANDOM : c_int = 1;
3316             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
3317             pub const POSIX_MADV_WILLNEED : c_int = 3;
3318             pub const POSIX_MADV_DONTNEED : c_int = 4;
3319
3320             pub const _SC_MQ_PRIO_MAX : c_int = 28;
3321             pub const _SC_IOV_MAX : c_int = 60;
3322             pub const _SC_GETGR_R_SIZE_MAX : c_int = 69;
3323             pub const _SC_GETPW_R_SIZE_MAX : c_int = 70;
3324             pub const _SC_LOGIN_NAME_MAX : c_int = 71;
3325             pub const _SC_TTY_NAME_MAX : c_int = 72;
3326             pub const _SC_THREADS : c_int = 67;
3327             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68;
3328             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73;
3329             pub const _SC_THREAD_KEYS_MAX : c_int = 74;
3330             pub const _SC_THREAD_STACK_MIN : c_int = 75;
3331             pub const _SC_THREAD_THREADS_MAX : c_int = 76;
3332             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77;
3333             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
3334             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79;
3335             pub const _SC_THREAD_PRIO_INHERIT : c_int = 80;
3336             pub const _SC_THREAD_PRIO_PROTECT : c_int = 81;
3337             pub const _SC_THREAD_PROCESS_SHARED : c_int = 82;
3338             pub const _SC_ATEXIT_MAX : c_int = 87;
3339             pub const _SC_XOPEN_VERSION : c_int = 89;
3340             pub const _SC_XOPEN_XCU_VERSION : c_int = 90;
3341             pub const _SC_XOPEN_UNIX : c_int = 91;
3342             pub const _SC_XOPEN_CRYPT : c_int = 92;
3343             pub const _SC_XOPEN_ENH_I18N : c_int = 93;
3344             pub const _SC_XOPEN_SHM : c_int = 94;
3345             pub const _SC_XOPEN_LEGACY : c_int = 129;
3346             pub const _SC_XOPEN_REALTIME : c_int = 130;
3347             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131;
3348
3349
3350
3351             pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
3352             pub const PTHREAD_CREATE_DETACHED: c_int = 1;
3353
3354             #[cfg(target_os = "android")]
3355             pub const PTHREAD_STACK_MIN: size_t = 8192;
3356
3357             #[cfg(all(target_os = "linux",
3358                       any(target_arch = "arm",
3359                           target_arch = "x86",
3360                           target_arch = "x86_64")))]
3361             pub const PTHREAD_STACK_MIN: size_t = 16384;
3362
3363             #[cfg(all(target_os = "linux",
3364                       any(target_arch = "mips",
3365                           target_arch = "mipsel",
3366                           target_arch = "aarch64",
3367                           target_arch = "powerpc")))]
3368             pub const PTHREAD_STACK_MIN: size_t = 131072;
3369
3370             pub const CLOCK_REALTIME: c_int = 0;
3371             pub const CLOCK_MONOTONIC: c_int = 1;
3372
3373             pub const RLIMIT_CPU: c_int = 0;
3374             pub const RLIMIT_FSIZE: c_int = 1;
3375             pub const RLIMIT_DATA: c_int = 2;
3376             pub const RLIMIT_STACK: c_int = 3;
3377             pub const RLIMIT_CORE: c_int = 4;
3378             pub const RLIMIT_RSS: c_int = 5;
3379             pub const RLIMIT_NOFILE: c_int = 7;
3380             pub const RLIMIT_AS: c_int = 9;
3381             pub const RLIMIT_NPROC: c_int = 6;
3382             pub const RLIMIT_MEMLOCK: c_int = 8;
3383             pub const RLIMIT_LOCKS: c_int = 10;
3384             pub const RLIMIT_SIGPENDING: c_int = 11;
3385             pub const RLIMIT_MSGQUEUE: c_int = 12;
3386             pub const RLIMIT_NICE: c_int = 13;
3387             pub const RLIMIT_RTPRIO: c_int = 14;
3388             pub const RLIMIT_RTTIME: c_int = 15;
3389             pub const RLIMIT_NLIMITS: c_int = 16;
3390             pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff;
3391             pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
3392             pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
3393
3394             pub const RUSAGE_SELF: c_int = 0;
3395             pub const RUSAGE_CHILDREN: c_int = -1;
3396             pub const RUSAGE_THREAD: c_int = 1;
3397         }
3398         #[cfg(target_os = "nacl")]
3399         pub mod posix01 {
3400             use types::os::arch::c95::{c_int, size_t};
3401             use types::os::common::posix01::rlim_t;
3402
3403             pub const F_DUPFD : c_int = 0;
3404             pub const F_GETFD : c_int = 1;
3405             pub const F_SETFD : c_int = 2;
3406             pub const F_GETFL : c_int = 3;
3407             pub const F_SETFL : c_int = 4;
3408
3409             pub const SIGTRAP : c_int = 5;
3410             pub const SIG_IGN: size_t = 1;
3411
3412             pub const GLOB_ERR      : c_int = 1 << 0;
3413             pub const GLOB_MARK     : c_int = 1 << 1;
3414             pub const GLOB_NOSORT   : c_int = 1 << 2;
3415             pub const GLOB_DOOFFS   : c_int = 1 << 3;
3416             pub const GLOB_NOCHECK  : c_int = 1 << 4;
3417             pub const GLOB_APPEND   : c_int = 1 << 5;
3418             pub const GLOB_NOESCAPE : c_int = 1 << 6;
3419
3420             pub const GLOB_NOSPACE  : c_int = 1;
3421             pub const GLOB_ABORTED  : c_int = 2;
3422             pub const GLOB_NOMATCH  : c_int = 3;
3423
3424             pub const POSIX_MADV_NORMAL : c_int = 0;
3425             pub const POSIX_MADV_RANDOM : c_int = 1;
3426             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
3427             pub const POSIX_MADV_WILLNEED : c_int = 3;
3428             pub const POSIX_MADV_DONTNEED : c_int = 4;
3429
3430             pub const _SC_MQ_PRIO_MAX : c_int = 28;
3431             pub const _SC_IOV_MAX : c_int = 60;
3432             pub const _SC_GETGR_R_SIZE_MAX : c_int = 69;
3433             pub const _SC_GETPW_R_SIZE_MAX : c_int = 70;
3434             pub const _SC_LOGIN_NAME_MAX : c_int = 71;
3435             pub const _SC_TTY_NAME_MAX : c_int = 72;
3436             pub const _SC_THREADS : c_int = 67;
3437             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68;
3438             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73;
3439             pub const _SC_THREAD_KEYS_MAX : c_int = 74;
3440             pub const _SC_THREAD_STACK_MIN : c_int = 75;
3441             pub const _SC_THREAD_THREADS_MAX : c_int = 76;
3442             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77;
3443             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
3444             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79;
3445             pub const _SC_THREAD_PRIO_INHERIT : c_int = 80;
3446             pub const _SC_THREAD_PRIO_PROTECT : c_int = 81;
3447             pub const _SC_THREAD_PROCESS_SHARED : c_int = 82;
3448             pub const _SC_ATEXIT_MAX : c_int = 87;
3449             pub const _SC_XOPEN_VERSION : c_int = 89;
3450             pub const _SC_XOPEN_XCU_VERSION : c_int = 90;
3451             pub const _SC_XOPEN_UNIX : c_int = 91;
3452             pub const _SC_XOPEN_CRYPT : c_int = 92;
3453             pub const _SC_XOPEN_ENH_I18N : c_int = 93;
3454             pub const _SC_XOPEN_SHM : c_int = 94;
3455             pub const _SC_XOPEN_LEGACY : c_int = 129;
3456             pub const _SC_XOPEN_REALTIME : c_int = 130;
3457             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131;
3458
3459             pub const PTHREAD_CREATE_JOINABLE: c_int = 1;
3460             pub const PTHREAD_CREATE_DETACHED: c_int = 0;
3461
3462             pub const PTHREAD_STACK_MIN: size_t = 1024;
3463
3464             pub const CLOCK_REALTIME: c_int = 0;
3465             pub const CLOCK_MONOTONIC: c_int = 1;
3466
3467             pub const RLIMIT_CPU: c_int = 0;
3468             pub const RLIMIT_FSIZE: c_int = 1;
3469             pub const RLIMIT_DATA: c_int = 2;
3470             pub const RLIMIT_STACK: c_int = 3;
3471             pub const RLIMIT_CORE: c_int = 4;
3472             pub const RLIMIT_RSS: c_int = 5;
3473             pub const RLIMIT_NOFILE: c_int = 7;
3474             pub const RLIMIT_AS: c_int = 9;
3475             pub const RLIMIT_NPROC: c_int = 6;
3476             pub const RLIMIT_MEMLOCK: c_int = 8;
3477             pub const RLIMIT_LOCKS: c_int = 10;
3478             pub const RLIMIT_SIGPENDING: c_int = 11;
3479             pub const RLIMIT_MSGQUEUE: c_int = 12;
3480             pub const RLIMIT_NICE: c_int = 13;
3481             pub const RLIMIT_RTPRIO: c_int = 14;
3482             pub const RLIMIT_RTTIME: c_int = 15;
3483             pub const RLIMIT_NLIMITS: c_int = 16;
3484
3485             pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff;
3486             pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
3487             pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
3488
3489             pub const RUSAGE_SELF: c_int = 0;
3490             pub const RUSAGE_CHILDREN: c_int = -1;
3491             pub const RUSAGE_THREAD: c_int = 1;
3492         }
3493         pub mod posix08 {
3494         }
3495         #[cfg(any(target_arch = "arm",
3496                   target_arch = "aarch64",
3497                   target_arch = "x86",
3498                   target_arch = "x86_64",
3499                   target_arch = "le32",
3500                   target_arch = "powerpc"))]
3501         pub mod bsd44 {
3502             use types::os::arch::c95::c_int;
3503
3504             pub const MADV_NORMAL : c_int = 0;
3505             pub const MADV_RANDOM : c_int = 1;
3506             pub const MADV_SEQUENTIAL : c_int = 2;
3507             pub const MADV_WILLNEED : c_int = 3;
3508             pub const MADV_DONTNEED : c_int = 4;
3509             pub const MADV_REMOVE : c_int = 9;
3510             pub const MADV_DONTFORK : c_int = 10;
3511             pub const MADV_DOFORK : c_int = 11;
3512             pub const MADV_MERGEABLE : c_int = 12;
3513             pub const MADV_UNMERGEABLE : c_int = 13;
3514             pub const MADV_HWPOISON : c_int = 100;
3515
3516             pub const IFF_LOOPBACK: c_int = 0x8;
3517
3518             pub const AF_UNIX: c_int = 1;
3519             pub const AF_INET: c_int = 2;
3520             pub const AF_INET6: c_int = 10;
3521             pub const SOCK_STREAM: c_int = 1;
3522             pub const SOCK_DGRAM: c_int = 2;
3523             pub const SOCK_RAW: c_int = 3;
3524             pub const IPPROTO_TCP: c_int = 6;
3525             pub const IPPROTO_IP: c_int = 0;
3526             pub const IPPROTO_IPV6: c_int = 41;
3527             pub const IP_MULTICAST_TTL: c_int = 33;
3528             pub const IP_MULTICAST_LOOP: c_int = 34;
3529             pub const IP_TTL: c_int = 2;
3530             pub const IP_HDRINCL: c_int = 3;
3531             pub const IP_ADD_MEMBERSHIP: c_int = 35;
3532             pub const IP_DROP_MEMBERSHIP: c_int = 36;
3533             pub const IPV6_ADD_MEMBERSHIP: c_int = 20;
3534             pub const IPV6_DROP_MEMBERSHIP: c_int = 21;
3535
3536             pub const TCP_NODELAY: c_int = 1;
3537             pub const SOL_SOCKET: c_int = 1;
3538
3539             pub const SO_DEBUG: c_int = 1;
3540             pub const SO_REUSEADDR: c_int = 2;
3541             pub const SO_TYPE: c_int = 3;
3542             pub const SO_ERROR: c_int = 4;
3543             pub const SO_DONTROUTE: c_int = 5;
3544             pub const SO_BROADCAST: c_int = 6;
3545             pub const SO_SNDBUF: c_int = 7;
3546             pub const SO_RCVBUF: c_int = 8;
3547             pub const SO_KEEPALIVE: c_int = 9;
3548             pub const SO_OOBINLINE: c_int = 10;
3549             pub const SO_LINGER: c_int = 13;
3550             pub const SO_REUSEPORT: c_int = 15;
3551             pub const SO_RCVLOWAT: c_int = 18;
3552             pub const SO_SNDLOWAT: c_int = 19;
3553             pub const SO_RCVTIMEO: c_int = 20;
3554             pub const SO_SNDTIMEO: c_int = 21;
3555             pub const SO_ACCEPTCONN: c_int = 30;
3556
3557             pub const SHUT_RD: c_int = 0;
3558             pub const SHUT_WR: c_int = 1;
3559             pub const SHUT_RDWR: c_int = 2;
3560         }
3561         #[cfg(any(target_arch = "mips",
3562                   target_arch = "mipsel"))]
3563         pub mod bsd44 {
3564             use types::os::arch::c95::c_int;
3565
3566             pub const MADV_NORMAL : c_int = 0;
3567             pub const MADV_RANDOM : c_int = 1;
3568             pub const MADV_SEQUENTIAL : c_int = 2;
3569             pub const MADV_WILLNEED : c_int = 3;
3570             pub const MADV_DONTNEED : c_int = 4;
3571             pub const MADV_REMOVE : c_int = 9;
3572             pub const MADV_DONTFORK : c_int = 10;
3573             pub const MADV_DOFORK : c_int = 11;
3574             pub const MADV_MERGEABLE : c_int = 12;
3575             pub const MADV_UNMERGEABLE : c_int = 13;
3576             pub const MADV_HWPOISON : c_int = 100;
3577
3578             pub const AF_UNIX: c_int = 1;
3579             pub const AF_INET: c_int = 2;
3580             pub const AF_INET6: c_int = 10;
3581             pub const SOCK_STREAM: c_int = 2;
3582             pub const SOCK_DGRAM: c_int = 1;
3583             pub const SOCK_RAW: c_int = 3;
3584             pub const IPPROTO_TCP: c_int = 6;
3585             pub const IPPROTO_IP: c_int = 0;
3586             pub const IPPROTO_IPV6: c_int = 41;
3587             pub const IP_MULTICAST_TTL: c_int = 33;
3588             pub const IP_MULTICAST_LOOP: c_int = 34;
3589             pub const IP_TTL: c_int = 2;
3590             pub const IP_HDRINCL: c_int = 3;
3591             pub const IP_ADD_MEMBERSHIP: c_int = 35;
3592             pub const IP_DROP_MEMBERSHIP: c_int = 36;
3593             pub const IPV6_ADD_MEMBERSHIP: c_int = 20;
3594             pub const IPV6_DROP_MEMBERSHIP: c_int = 21;
3595
3596             pub const TCP_NODELAY: c_int = 1;
3597             pub const SOL_SOCKET: c_int = 65535;
3598
3599             pub const SO_DEBUG: c_int = 0x0001;
3600             pub const SO_REUSEADDR: c_int = 0x0004;
3601             pub const SO_KEEPALIVE: c_int = 0x0008;
3602             pub const SO_DONTROUTE: c_int = 0x0010;
3603             pub const SO_BROADCAST: c_int = 0x0020;
3604             pub const SO_LINGER: c_int = 0x0080;
3605             pub const SO_OOBINLINE: c_int = 0x100;
3606             pub const SO_REUSEPORT: c_int = 0x0200;
3607             pub const SO_SNDBUF: c_int = 0x1001;
3608             pub const SO_RCVBUF: c_int = 0x1002;
3609             pub const SO_SNDLOWAT: c_int = 0x1003;
3610             pub const SO_RCVLOWAT: c_int = 0x1004;
3611             pub const SO_SNDTIMEO: c_int = 0x1005;
3612             pub const SO_RCVTIMEO: c_int = 0x1006;
3613             pub const SO_ERROR: c_int = 0x1007;
3614             pub const SO_TYPE: c_int = 0x1008;
3615             pub const SO_ACCEPTCONN: c_int = 0x1009;
3616
3617             pub const SHUT_RD: c_int = 0;
3618             pub const SHUT_WR: c_int = 1;
3619             pub const SHUT_RDWR: c_int = 2;
3620         }
3621         #[cfg(any(target_arch = "x86",
3622                   target_arch = "x86_64",
3623                   target_arch = "arm",
3624                   target_arch = "aarch64",
3625                   target_arch = "le32",
3626                   target_arch = "powerpc"))]
3627         pub mod extra {
3628             use types::os::arch::c95::c_int;
3629
3630             pub const AF_PACKET : c_int = 17;
3631             pub const IPPROTO_RAW : c_int = 255;
3632
3633             pub const O_RSYNC : c_int = 1052672;
3634             pub const O_DSYNC : c_int = 4096;
3635             pub const O_NONBLOCK : c_int = 2048;
3636             pub const O_SYNC : c_int = 1052672;
3637
3638             pub const PROT_GROWSDOWN : c_int = 0x010000000;
3639             pub const PROT_GROWSUP : c_int = 0x020000000;
3640
3641             pub const MAP_TYPE : c_int = 0x000f;
3642             pub const MAP_ANONYMOUS : c_int = 0x0020;
3643             pub const MAP_32BIT : c_int = 0x0040;
3644             pub const MAP_GROWSDOWN : c_int = 0x0100;
3645             pub const MAP_DENYWRITE : c_int = 0x0800;
3646             pub const MAP_EXECUTABLE : c_int = 0x01000;
3647             pub const MAP_LOCKED : c_int = 0x02000;
3648             pub const MAP_NORESERVE : c_int = 0x04000;
3649             pub const MAP_POPULATE : c_int = 0x08000;
3650             pub const MAP_NONBLOCK : c_int = 0x010000;
3651             pub const MAP_STACK : c_int = 0x020000;
3652         }
3653         #[cfg(any(target_arch = "mips",
3654                   target_arch = "mipsel"))]
3655         pub mod extra {
3656             use types::os::arch::c95::c_int;
3657
3658             pub const AF_PACKET : c_int = 17;
3659             pub const IPPROTO_RAW : c_int = 255;
3660
3661             pub const O_RSYNC : c_int = 16400;
3662             pub const O_DSYNC : c_int = 16;
3663             pub const O_NONBLOCK : c_int = 128;
3664             pub const O_SYNC : c_int = 16400;
3665
3666             pub const PROT_GROWSDOWN : c_int = 0x01000000;
3667             pub const PROT_GROWSUP : c_int = 0x02000000;
3668
3669             pub const MAP_TYPE : c_int = 0x000f;
3670             pub const MAP_ANONYMOUS : c_int = 0x0800;
3671             pub const MAP_GROWSDOWN : c_int = 0x01000;
3672             pub const MAP_DENYWRITE : c_int = 0x02000;
3673             pub const MAP_EXECUTABLE : c_int = 0x04000;
3674             pub const MAP_LOCKED : c_int = 0x08000;
3675             pub const MAP_NORESERVE : c_int = 0x0400;
3676             pub const MAP_POPULATE : c_int = 0x010000;
3677             pub const MAP_NONBLOCK : c_int = 0x020000;
3678             pub const MAP_STACK : c_int = 0x040000;
3679         }
3680         #[cfg(target_os = "linux")]
3681         pub mod sysconf {
3682             use types::os::arch::c95::c_int;
3683
3684             pub const _SC_ARG_MAX : c_int = 0;
3685             pub const _SC_CHILD_MAX : c_int = 1;
3686             pub const _SC_CLK_TCK : c_int = 2;
3687             pub const _SC_NGROUPS_MAX : c_int = 3;
3688             pub const _SC_OPEN_MAX : c_int = 4;
3689             pub const _SC_STREAM_MAX : c_int = 5;
3690             pub const _SC_TZNAME_MAX : c_int = 6;
3691             pub const _SC_JOB_CONTROL : c_int = 7;
3692             pub const _SC_SAVED_IDS : c_int = 8;
3693             pub const _SC_REALTIME_SIGNALS : c_int = 9;
3694             pub const _SC_PRIORITY_SCHEDULING : c_int = 10;
3695             pub const _SC_TIMERS : c_int = 11;
3696             pub const _SC_ASYNCHRONOUS_IO : c_int = 12;
3697             pub const _SC_PRIORITIZED_IO : c_int = 13;
3698             pub const _SC_SYNCHRONIZED_IO : c_int = 14;
3699             pub const _SC_FSYNC : c_int = 15;
3700             pub const _SC_MAPPED_FILES : c_int = 16;
3701             pub const _SC_MEMLOCK : c_int = 17;
3702             pub const _SC_MEMLOCK_RANGE : c_int = 18;
3703             pub const _SC_MEMORY_PROTECTION : c_int = 19;
3704             pub const _SC_MESSAGE_PASSING : c_int = 20;
3705             pub const _SC_SEMAPHORES : c_int = 21;
3706             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 22;
3707             pub const _SC_AIO_LISTIO_MAX : c_int = 23;
3708             pub const _SC_AIO_MAX : c_int = 24;
3709             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 25;
3710             pub const _SC_DELAYTIMER_MAX : c_int = 26;
3711             pub const _SC_MQ_OPEN_MAX : c_int = 27;
3712             pub const _SC_VERSION : c_int = 29;
3713             pub const _SC_PAGESIZE : c_int = 30;
3714             pub const _SC_RTSIG_MAX : c_int = 31;
3715             pub const _SC_SEM_NSEMS_MAX : c_int = 32;
3716             pub const _SC_SEM_VALUE_MAX : c_int = 33;
3717             pub const _SC_SIGQUEUE_MAX : c_int = 34;
3718             pub const _SC_TIMER_MAX : c_int = 35;
3719             pub const _SC_BC_BASE_MAX : c_int = 36;
3720             pub const _SC_BC_DIM_MAX : c_int = 37;
3721             pub const _SC_BC_SCALE_MAX : c_int = 38;
3722             pub const _SC_BC_STRING_MAX : c_int = 39;
3723             pub const _SC_COLL_WEIGHTS_MAX : c_int = 40;
3724             pub const _SC_EXPR_NEST_MAX : c_int = 42;
3725             pub const _SC_LINE_MAX : c_int = 43;
3726             pub const _SC_RE_DUP_MAX : c_int = 44;
3727             pub const _SC_2_VERSION : c_int = 46;
3728             pub const _SC_2_C_BIND : c_int = 47;
3729             pub const _SC_2_C_DEV : c_int = 48;
3730             pub const _SC_2_FORT_DEV : c_int = 49;
3731             pub const _SC_2_FORT_RUN : c_int = 50;
3732             pub const _SC_2_SW_DEV : c_int = 51;
3733             pub const _SC_2_LOCALEDEF : c_int = 52;
3734             pub const _SC_NPROCESSORS_ONLN : c_int = 84;
3735             pub const _SC_2_CHAR_TERM : c_int = 95;
3736             pub const _SC_2_C_VERSION : c_int = 96;
3737             pub const _SC_2_UPE : c_int = 97;
3738             pub const _SC_XBS5_ILP32_OFF32 : c_int = 125;
3739             pub const _SC_XBS5_ILP32_OFFBIG : c_int = 126;
3740             pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 128;
3741
3742         }
3743         #[cfg(target_os = "nacl")]
3744         pub mod sysconf {
3745             use types::os::arch::c95::c_int;
3746
3747             pub static _SC_SENDMSG_MAX_SIZE : c_int = 0;
3748             pub static _SC_NPROCESSORS_ONLN : c_int = 1;
3749             pub static _SC_PAGESIZE : c_int = 2;
3750         }
3751
3752         #[cfg(target_os = "macos")]
3753         pub mod sysconf {
3754             use types::os::arch::c95::c_int;
3755             pub static _SC_ARG_MAX : c_int = 1;
3756             pub static _SC_CHILD_MAX : c_int = 2;
3757             pub static _SC_CLK_TCK : c_int = 3;
3758             pub static _SC_NGROUPS_MAX : c_int = 4;
3759             pub static _SC_OPEN_MAX : c_int = 5;
3760             pub static _SC_JOB_CONTROL : c_int = 6;
3761             pub static _SC_SAVED_IDS : c_int = 7;
3762             pub static _SC_VERSION : c_int = 8;
3763             pub static _SC_BC_BASE_MAX : c_int = 9;
3764             pub static _SC_BC_DIM_MAX : c_int = 10;
3765             pub static _SC_BC_SCALE_MAX : c_int = 11;
3766             pub static _SC_BC_STRING_MAX : c_int = 12;
3767             pub static _SC_COLL_WEIGHTS_MAX : c_int = 13;
3768             pub static _SC_EXPR_NEST_MAX : c_int = 14;
3769             pub static _SC_LINE_MAX : c_int = 15;
3770             pub static _SC_RE_DUP_MAX : c_int = 16;
3771             pub static _SC_2_VERSION : c_int = 17;
3772             pub static _SC_2_C_BIND : c_int = 18;
3773             pub static _SC_2_C_DEV : c_int = 19;
3774             pub static _SC_2_CHAR_TERM : c_int = 20;
3775             pub static _SC_2_FORT_DEV : c_int = 21;
3776             pub static _SC_2_FORT_RUN : c_int = 22;
3777             pub static _SC_2_LOCALEDEF : c_int = 23;
3778             pub static _SC_2_SW_DEV : c_int = 24;
3779             pub static _SC_2_UPE : c_int = 25;
3780             pub static _SC_STREAM_MAX : c_int = 26;
3781             pub static _SC_TZNAME_MAX : c_int = 27;
3782             pub static _SC_ASYNCHRONOUS_IO : c_int = 28;
3783             pub static _SC_PAGESIZE : c_int = 29;
3784             pub static _SC_MEMLOCK : c_int = 30;
3785             pub static _SC_MEMLOCK_RANGE : c_int = 31;
3786             pub static _SC_MEMORY_PROTECTION : c_int = 32;
3787             pub static _SC_MESSAGE_PASSING : c_int = 33;
3788             pub static _SC_PRIORITIZED_IO : c_int = 34;
3789             pub static _SC_PRIORITY_SCHEDULING : c_int = 35;
3790             pub static _SC_REALTIME_SIGNALS : c_int = 36;
3791             pub static _SC_SEMAPHORES : c_int = 37;
3792             pub static _SC_FSYNC : c_int = 38;
3793             pub static _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
3794             pub static _SC_SYNCHRONIZED_IO : c_int = 40;
3795             pub static _SC_TIMERS : c_int = 41;
3796             pub static _SC_AIO_LISTIO_MAX : c_int = 42;
3797             pub static _SC_AIO_MAX : c_int = 43;
3798             pub static _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
3799             pub static _SC_DELAYTIMER_MAX : c_int = 45;
3800             pub static _SC_MQ_OPEN_MAX : c_int = 46;
3801             pub static _SC_MAPPED_FILES : c_int = 47;
3802             pub static _SC_RTSIG_MAX : c_int = 48;
3803             pub static _SC_SEM_NSEMS_MAX : c_int = 49;
3804             pub static _SC_SEM_VALUE_MAX : c_int =50;
3805             pub static _SC_SIGQUEUE_MAX : c_int = 51;
3806             pub static _SC_TIMER_MAX : c_int = 52;
3807             pub static _SC_NPROCESSORS_CONF : c_int = 57;
3808             pub static _SC_NPROCESSORS_ONLN : c_int = 58;
3809             pub static _SC_2_PBS : c_int = 59;
3810             pub static _SC_2_PBS_ACCOUNTING : c_int = 60;
3811             pub static _SC_2_PBS_CHECKPOINT : c_int = 61;
3812             pub static _SC_2_PBS_LOCATE : c_int = 62;
3813             pub static _SC_2_PBS_MESSAGE : c_int = 63;
3814             pub static _SC_2_PBS_TRACK : c_int = 64;
3815             pub static _SC_ADVISORY_INFO : c_int = 65;
3816             pub static _SC_BARRIERS : c_int = 66;
3817             pub static _SC_CLOCK_SELECTION : c_int = 67;
3818             pub static _SC_CPUTIME : c_int = 68;
3819             pub static _SC_FILE_LOCKING : c_int = 69;
3820             pub static _SC_GETGR_R_SIZE_MAX : c_int = 70;
3821             pub static _SC_GETPW_R_SIZE_MAX : c_int = 71;
3822             pub static _SC_HOST_NAME_MAX : c_int = 72;
3823             pub static _SC_LOGIN_NAME_MAX : c_int = 73;
3824             pub static _SC_MONOTONIC_CLOCK : c_int = 74;
3825             pub static _SC_MQ_PRIO_MAX : c_int = 75;
3826             pub static _SC_READER_WRITER_LOCKS : c_int = 76;
3827             pub static _SC_REGEXP : c_int = 77;
3828             pub static _SC_SHELL : c_int = 78;
3829             pub static _SC_SPAWN : c_int = 79;
3830             pub static _SC_SPIN_LOCKS : c_int = 80;
3831             pub static _SC_SPORADIC_SERVER : c_int = 81;
3832             pub static _SC_THREAD_ATTR_STACKADDR : c_int = 82;
3833             pub static _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
3834             pub static _SC_THREAD_CPUTIME : c_int = 84;
3835             pub static _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
3836             pub static _SC_THREAD_KEYS_MAX : c_int = 86;
3837             pub static _SC_THREAD_PRIO_INHERIT : c_int = 87;
3838             pub static _SC_THREAD_PRIO_PROTECT : c_int = 88;
3839             pub static _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
3840             pub static _SC_THREAD_PROCESS_SHARED : c_int = 90;
3841             pub static _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
3842             pub static _SC_THREAD_SPORADIC_SERVER : c_int = 92;
3843             pub static _SC_THREAD_STACK_MIN : c_int = 93;
3844             pub static _SC_THREAD_THREADS_MAX : c_int = 94;
3845             pub static _SC_TIMEOUTS : c_int = 95;
3846             pub static _SC_THREADS : c_int = 96;
3847             pub static _SC_TRACE : c_int = 97;
3848             pub static _SC_TRACE_EVENT_FILTER: c_int = 98;
3849             pub static _SC_TRACE_INHERIT: c_int = 99;
3850             pub static _SC_TRACE_LOG: c_int = 100;
3851             pub static _SC_TTY_NAME_MAX: c_int = 101;
3852             pub static _SC_TYPED_MEMORY_OBJECTS: c_int = 102;
3853             pub static _SC_V6_ILP32_OFF32: c_int = 103;
3854             pub static _SC_V6_ILP32_OFFBIG: c_int = 104;
3855             pub static _SC_V6_LP64_OFF64: c_int = 105;
3856             pub static _SC_V6_LPBIG_OFFBIG: c_int = 106;
3857             pub static _SC_IPV6: c_int = 118;
3858             pub static _SC_RAW_SOCKETS: c_int = 119;
3859             pub static _SC_SYMLOOP_MAX: c_int = 120;
3860             pub static _SC_ATEXIT_MAX: c_int = 107;
3861             pub static _SC_IOV_MAX: c_int = 56;
3862             pub static _SC_PAGE_SIZE: cint = _SC_PAGESIZE;
3863             pub static _SC_XOPEN_CRYPT: c_int = 108;
3864             pub static _SC_XOPEN_ENH_I18N: c_int = 109;
3865             pub static _SC_XOPEN_LEGACY: c_int = 110;
3866             pub static _SC_XOPEN_REALTIME: c_int = 111;
3867             pub static _SC_XOPEN_REALTIME_THREADS: c_int = 112;
3868             pub static _SC_XOPEN_SHM: c_int = 113;
3869             pub static _SC_XOPEN_STREAMS: c_int = 114;
3870             pub static _SC_XOPEN_UNIX: c_int = 115;
3871             pub static _SC_XOPEN_VERSION: c_int = 116;
3872             pub static _SC_XOPEN_XCU_VERSION: c_int = 121;
3873             pub static _SC_XBS5_ILP32_OFF32: c_int = 122;
3874             pub static _SC_XBS5_ILP32_OFFBIG: c_int = 123;
3875             pub static _SC_XBS5_LP64_OFF64: c_int = 124;
3876             pub static _SC_XBS5_LPBIG_OFFBIG: c_int = 125;
3877             pub static _SC_SS_REPL_MAX: c_int = 126;
3878             pub static _SC_TRACE_EVENT_NAME_MAX: c_int = 127;
3879             pub static _SC_TRACE_NAME_MAX: c_int = 128;
3880             pub static _SC_TRACE_SYS_MAX: c_int = 129;
3881             pub static _SC_TRACE_USER_EVENT_MAX: c_int = 130;
3882             pub static _SC_PASS_MAX: c_int = 131;
3883         }
3884
3885         #[cfg(target_os = "android")]
3886         pub mod sysconf {
3887             use types::os::arch::c95::c_int;
3888
3889             pub const _SC_ARG_MAX : c_int = 0;
3890             pub const _SC_BC_BASE_MAX : c_int = 1;
3891             pub const _SC_BC_DIM_MAX : c_int = 2;
3892             pub const _SC_BC_SCALE_MAX : c_int = 3;
3893             pub const _SC_BC_STRING_MAX : c_int = 4;
3894             pub const _SC_CHILD_MAX : c_int = 5;
3895             pub const _SC_CLK_TCK : c_int = 6;
3896             pub const _SC_COLL_WEIGHTS_MAX : c_int = 7;
3897             pub const _SC_EXPR_NEST_MAX : c_int = 8;
3898             pub const _SC_LINE_MAX : c_int = 9;
3899             pub const _SC_NGROUPS_MAX : c_int = 10;
3900             pub const _SC_OPEN_MAX : c_int = 11;
3901             pub const _SC_2_C_BIND : c_int = 13;
3902             pub const _SC_2_C_DEV : c_int = 14;
3903             pub const _SC_2_C_VERSION : c_int = 15;
3904             pub const _SC_2_CHAR_TERM : c_int = 16;
3905             pub const _SC_2_FORT_DEV : c_int = 17;
3906             pub const _SC_2_FORT_RUN : c_int = 18;
3907             pub const _SC_2_LOCALEDEF : c_int = 19;
3908             pub const _SC_2_SW_DEV : c_int = 20;
3909             pub const _SC_2_UPE : c_int = 21;
3910             pub const _SC_2_VERSION : c_int = 22;
3911             pub const _SC_JOB_CONTROL : c_int = 23;
3912             pub const _SC_SAVED_IDS : c_int = 24;
3913             pub const _SC_VERSION : c_int = 25;
3914             pub const _SC_RE_DUP_MAX : c_int = 26;
3915             pub const _SC_STREAM_MAX : c_int = 27;
3916             pub const _SC_TZNAME_MAX : c_int = 28;
3917             pub const _SC_PAGESIZE : c_int = 39;
3918         }
3919     }
3920
3921     #[cfg(any(target_os = "freebsd",
3922               target_os = "dragonfly"))]
3923     pub mod os {
3924         pub mod c95 {
3925             use types::os::arch::c95::{c_int, c_uint};
3926
3927             pub const EXIT_FAILURE : c_int = 1;
3928             pub const EXIT_SUCCESS : c_int = 0;
3929             pub const RAND_MAX : c_int = 2147483647;
3930             pub const EOF : c_int = -1;
3931             pub const SEEK_SET : c_int = 0;
3932             pub const SEEK_CUR : c_int = 1;
3933             pub const SEEK_END : c_int = 2;
3934             pub const _IOFBF : c_int = 0;
3935             pub const _IONBF : c_int = 2;
3936             pub const _IOLBF : c_int = 1;
3937             pub const BUFSIZ : c_uint = 1024;
3938             pub const FOPEN_MAX : c_uint = 20;
3939             pub const FILENAME_MAX : c_uint = 1024;
3940             pub const L_tmpnam : c_uint = 1024;
3941             pub const TMP_MAX : c_uint = 308915776;
3942         }
3943         pub mod c99 {
3944         }
3945         pub mod posix88 {
3946             use types::common::c95::c_void;
3947             use types::os::arch::c95::c_int;
3948             use types::os::arch::posix88::mode_t;
3949
3950             pub const O_RDONLY : c_int = 0;
3951             pub const O_WRONLY : c_int = 1;
3952             pub const O_RDWR : c_int = 2;
3953             pub const O_APPEND : c_int = 8;
3954             pub const O_CREAT : c_int = 512;
3955             pub const O_EXCL : c_int = 2048;
3956             pub const O_NOCTTY : c_int = 32768;
3957             pub const O_TRUNC : c_int = 1024;
3958             pub const S_IFIFO : mode_t = 4096;
3959             pub const S_IFCHR : mode_t = 8192;
3960             pub const S_IFBLK : mode_t = 24576;
3961             pub const S_IFDIR : mode_t = 16384;
3962             pub const S_IFREG : mode_t = 32768;
3963             pub const S_IFLNK : mode_t = 40960;
3964             pub const S_IFMT : mode_t = 61440;
3965             pub const S_IEXEC : mode_t = 64;
3966             pub const S_IWRITE : mode_t = 128;
3967             pub const S_IREAD : mode_t = 256;
3968             pub const S_IRWXU : mode_t = 448;
3969             pub const S_IXUSR : mode_t = 64;
3970             pub const S_IWUSR : mode_t = 128;
3971             pub const S_IRUSR : mode_t = 256;
3972             pub const S_IRWXG : mode_t = 56;
3973             pub const S_IXGRP : mode_t = 8;
3974             pub const S_IWGRP : mode_t = 16;
3975             pub const S_IRGRP : mode_t = 32;
3976             pub const S_IRWXO : mode_t = 7;
3977             pub const S_IXOTH : mode_t = 1;
3978             pub const S_IWOTH : mode_t = 2;
3979             pub const S_IROTH : mode_t = 4;
3980             pub const F_OK : c_int = 0;
3981             pub const R_OK : c_int = 4;
3982             pub const W_OK : c_int = 2;
3983             pub const X_OK : c_int = 1;
3984             pub const STDIN_FILENO : c_int = 0;
3985             pub const STDOUT_FILENO : c_int = 1;
3986             pub const STDERR_FILENO : c_int = 2;
3987             pub const F_LOCK : c_int = 1;
3988             pub const F_TEST : c_int = 3;
3989             pub const F_TLOCK : c_int = 2;
3990             pub const F_ULOCK : c_int = 0;
3991             pub const SIGHUP : c_int = 1;
3992             pub const SIGINT : c_int = 2;
3993             pub const SIGQUIT : c_int = 3;
3994             pub const SIGILL : c_int = 4;
3995             pub const SIGABRT : c_int = 6;
3996             pub const SIGFPE : c_int = 8;
3997             pub const SIGKILL : c_int = 9;
3998             pub const SIGSEGV : c_int = 11;
3999             pub const SIGPIPE : c_int = 13;
4000             pub const SIGALRM : c_int = 14;
4001             pub const SIGTERM : c_int = 15;
4002
4003             pub const PROT_NONE : c_int = 0;
4004             pub const PROT_READ : c_int = 1;
4005             pub const PROT_WRITE : c_int = 2;
4006             pub const PROT_EXEC : c_int = 4;
4007
4008             pub const MAP_FILE : c_int = 0x0000;
4009             pub const MAP_SHARED : c_int = 0x0001;
4010             pub const MAP_PRIVATE : c_int = 0x0002;
4011             pub const MAP_FIXED : c_int = 0x0010;
4012             pub const MAP_ANON : c_int = 0x1000;
4013
4014             pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
4015
4016             pub const MCL_CURRENT : c_int = 0x0001;
4017             pub const MCL_FUTURE : c_int = 0x0002;
4018
4019             pub const MS_SYNC : c_int = 0x0000;
4020             pub const MS_ASYNC : c_int = 0x0001;
4021             pub const MS_INVALIDATE : c_int = 0x0002;
4022
4023             pub const EPERM : c_int = 1;
4024             pub const ENOENT : c_int = 2;
4025             pub const ESRCH : c_int = 3;
4026             pub const EINTR : c_int = 4;
4027             pub const EIO : c_int = 5;
4028             pub const ENXIO : c_int = 6;
4029             pub const E2BIG : c_int = 7;
4030             pub const ENOEXEC : c_int = 8;
4031             pub const EBADF : c_int = 9;
4032             pub const ECHILD : c_int = 10;
4033             pub const EDEADLK : c_int = 11;
4034             pub const ENOMEM : c_int = 12;
4035             pub const EACCES : c_int = 13;
4036             pub const EFAULT : c_int = 14;
4037             pub const ENOTBLK : c_int = 15;
4038             pub const EBUSY : c_int = 16;
4039             pub const EEXIST : c_int = 17;
4040             pub const EXDEV : c_int = 18;
4041             pub const ENODEV : c_int = 19;
4042             pub const ENOTDIR : c_int = 20;
4043             pub const EISDIR : c_int = 21;
4044             pub const EINVAL : c_int = 22;
4045             pub const ENFILE : c_int = 23;
4046             pub const EMFILE : c_int = 24;
4047             pub const ENOTTY : c_int = 25;
4048             pub const ETXTBSY : c_int = 26;
4049             pub const EFBIG : c_int = 27;
4050             pub const ENOSPC : c_int = 28;
4051             pub const ESPIPE : c_int = 29;
4052             pub const EROFS : c_int = 30;
4053             pub const EMLINK : c_int = 31;
4054             pub const EPIPE : c_int = 32;
4055             pub const EDOM : c_int = 33;
4056             pub const ERANGE : c_int = 34;
4057             pub const EAGAIN : c_int = 35;
4058             pub const EWOULDBLOCK : c_int = 35;
4059             pub const EINPROGRESS : c_int = 36;
4060             pub const EALREADY : c_int = 37;
4061             pub const ENOTSOCK : c_int = 38;
4062             pub const EDESTADDRREQ : c_int = 39;
4063             pub const EMSGSIZE : c_int = 40;
4064             pub const EPROTOTYPE : c_int = 41;
4065             pub const ENOPROTOOPT : c_int = 42;
4066             pub const EPROTONOSUPPORT : c_int = 43;
4067             pub const ESOCKTNOSUPPORT : c_int = 44;
4068             pub const EOPNOTSUPP : c_int = 45;
4069             pub const EPFNOSUPPORT : c_int = 46;
4070             pub const EAFNOSUPPORT : c_int = 47;
4071             pub const EADDRINUSE : c_int = 48;
4072             pub const EADDRNOTAVAIL : c_int = 49;
4073             pub const ENETDOWN : c_int = 50;
4074             pub const ENETUNREACH : c_int = 51;
4075             pub const ENETRESET : c_int = 52;
4076             pub const ECONNABORTED : c_int = 53;
4077             pub const ECONNRESET : c_int = 54;
4078             pub const ENOBUFS : c_int = 55;
4079             pub const EISCONN : c_int = 56;
4080             pub const ENOTCONN : c_int = 57;
4081             pub const ESHUTDOWN : c_int = 58;
4082             pub const ETOOMANYREFS : c_int = 59;
4083             pub const ETIMEDOUT : c_int = 60;
4084             pub const ECONNREFUSED : c_int = 61;
4085             pub const ELOOP : c_int = 62;
4086             pub const ENAMETOOLONG : c_int = 63;
4087             pub const EHOSTDOWN : c_int = 64;
4088             pub const EHOSTUNREACH : c_int = 65;
4089             pub const ENOTEMPTY : c_int = 66;
4090             pub const EPROCLIM : c_int = 67;
4091             pub const EUSERS : c_int = 68;
4092             pub const EDQUOT : c_int = 69;
4093             pub const ESTALE : c_int = 70;
4094             pub const EREMOTE : c_int = 71;
4095             pub const EBADRPC : c_int = 72;
4096             pub const ERPCMISMATCH : c_int = 73;
4097             pub const EPROGUNAVAIL : c_int = 74;
4098             pub const EPROGMISMATCH : c_int = 75;
4099             pub const EPROCUNAVAIL : c_int = 76;
4100             pub const ENOLCK : c_int = 77;
4101             pub const ENOSYS : c_int = 78;
4102             pub const EFTYPE : c_int = 79;
4103             pub const EAUTH : c_int = 80;
4104             pub const ENEEDAUTH : c_int = 81;
4105             pub const EIDRM : c_int = 82;
4106             pub const ENOMSG : c_int = 83;
4107             pub const EOVERFLOW : c_int = 84;
4108             pub const ECANCELED : c_int = 85;
4109             pub const EILSEQ : c_int = 86;
4110             pub const ENOATTR : c_int = 87;
4111             pub const EDOOFUS : c_int = 88;
4112             pub const EBADMSG : c_int = 89;
4113             pub const EMULTIHOP : c_int = 90;
4114             pub const ENOLINK : c_int = 91;
4115             pub const EPROTO : c_int = 92;
4116             pub const ENOMEDIUM : c_int = 93;
4117             pub const EUNUSED94 : c_int = 94;
4118             pub const EUNUSED95 : c_int = 95;
4119             pub const EUNUSED96 : c_int = 96;
4120             pub const EUNUSED97 : c_int = 97;
4121             pub const EUNUSED98 : c_int = 98;
4122             pub const EASYNC : c_int = 99;
4123             pub const ELAST : c_int = 99;
4124         }
4125         pub mod posix01 {
4126             use types::os::arch::c95::{c_int, size_t};
4127             use types::os::common::posix01::rlim_t;
4128
4129             pub const F_DUPFD : c_int = 0;
4130             pub const F_GETFD : c_int = 1;
4131             pub const F_SETFD : c_int = 2;
4132             pub const F_GETFL : c_int = 3;
4133             pub const F_SETFL : c_int = 4;
4134
4135             pub const SIGTRAP : c_int = 5;
4136             pub const SIG_IGN: size_t = 1;
4137
4138             pub const GLOB_APPEND   : c_int = 0x0001;
4139             pub const GLOB_DOOFFS   : c_int = 0x0002;
4140             pub const GLOB_ERR      : c_int = 0x0004;
4141             pub const GLOB_MARK     : c_int = 0x0008;
4142             pub const GLOB_NOCHECK  : c_int = 0x0010;
4143             pub const GLOB_NOSORT   : c_int = 0x0020;
4144             pub const GLOB_NOESCAPE : c_int = 0x2000;
4145
4146             pub const GLOB_NOSPACE  : c_int = -1;
4147             pub const GLOB_ABORTED  : c_int = -2;
4148             pub const GLOB_NOMATCH  : c_int = -3;
4149
4150             pub const POSIX_MADV_NORMAL : c_int = 0;
4151             pub const POSIX_MADV_RANDOM : c_int = 1;
4152             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
4153             pub const POSIX_MADV_WILLNEED : c_int = 3;
4154             pub const POSIX_MADV_DONTNEED : c_int = 4;
4155
4156             pub const _SC_IOV_MAX : c_int = 56;
4157             pub const _SC_GETGR_R_SIZE_MAX : c_int = 70;
4158             pub const _SC_GETPW_R_SIZE_MAX : c_int = 71;
4159             pub const _SC_LOGIN_NAME_MAX : c_int = 73;
4160             pub const _SC_MQ_PRIO_MAX : c_int = 75;
4161             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82;
4162             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
4163             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
4164             pub const _SC_THREAD_KEYS_MAX : c_int = 86;
4165             pub const _SC_THREAD_PRIO_INHERIT : c_int = 87;
4166             pub const _SC_THREAD_PRIO_PROTECT : c_int = 88;
4167             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
4168             pub const _SC_THREAD_PROCESS_SHARED : c_int = 90;
4169             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
4170             pub const _SC_THREAD_STACK_MIN : c_int = 93;
4171             pub const _SC_THREAD_THREADS_MAX : c_int = 94;
4172             pub const _SC_THREADS : c_int = 96;
4173             pub const _SC_TTY_NAME_MAX : c_int = 101;
4174             pub const _SC_ATEXIT_MAX : c_int = 107;
4175             pub const _SC_XOPEN_CRYPT : c_int = 108;
4176             pub const _SC_XOPEN_ENH_I18N : c_int = 109;
4177             pub const _SC_XOPEN_LEGACY : c_int = 110;
4178             pub const _SC_XOPEN_REALTIME : c_int = 111;
4179             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112;
4180             pub const _SC_XOPEN_SHM : c_int = 113;
4181             pub const _SC_XOPEN_UNIX : c_int = 115;
4182             pub const _SC_XOPEN_VERSION : c_int = 116;
4183             pub const _SC_XOPEN_XCU_VERSION : c_int = 117;
4184
4185             pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
4186             pub const PTHREAD_CREATE_DETACHED: c_int = 1;
4187
4188             #[cfg(target_arch = "arm")]
4189             pub const PTHREAD_STACK_MIN: size_t = 4096;
4190
4191             #[cfg(all(target_os = "freebsd",
4192                       any(target_arch = "mips",
4193                           target_arch = "mipsel",
4194                           target_arch = "x86",
4195                           target_arch = "x86_64")))]
4196             pub const PTHREAD_STACK_MIN: size_t = 2048;
4197
4198             #[cfg(target_os = "dragonfly")]
4199             pub const PTHREAD_STACK_MIN: size_t = 1024;
4200
4201             pub const CLOCK_REALTIME: c_int = 0;
4202             pub const CLOCK_MONOTONIC: c_int = 4;
4203
4204             pub const RLIMIT_CPU: c_int = 0;
4205             pub const RLIMIT_FSIZE: c_int = 1;
4206             pub const RLIMIT_DATA: c_int = 2;
4207             pub const RLIMIT_STACK: c_int = 3;
4208             pub const RLIMIT_CORE: c_int = 4;
4209             pub const RLIMIT_RSS: c_int = 5;
4210             pub const RLIMIT_MEMLOCK: c_int = 6;
4211             pub const RLIMIT_NPROC: c_int = 7;
4212             pub const RLIMIT_NOFILE: c_int = 8;
4213             pub const RLIMIT_SBSIZE: c_int = 9;
4214             pub const RLIMIT_VMEM: c_int = 10;
4215             pub const RLIMIT_AS: c_int = RLIMIT_VMEM;
4216             pub const RLIMIT_NPTS: c_int = 11;
4217             pub const RLIMIT_SWAP: c_int = 12;
4218             pub const RLIMIT_KQUEUES: c_int = 13;
4219
4220             pub const RLIM_NLIMITS: rlim_t = 14;
4221             pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
4222
4223             pub const RUSAGE_SELF: c_int = 0;
4224             pub const RUSAGE_CHILDREN: c_int = -1;
4225             pub const RUSAGE_THREAD: c_int = 1;
4226         }
4227         pub mod posix08 {
4228         }
4229         pub mod bsd44 {
4230             use types::os::arch::c95::c_int;
4231
4232             pub const MADV_NORMAL : c_int = 0;
4233             pub const MADV_RANDOM : c_int = 1;
4234             pub const MADV_SEQUENTIAL : c_int = 2;
4235             pub const MADV_WILLNEED : c_int = 3;
4236             pub const MADV_DONTNEED : c_int = 4;
4237             pub const MADV_FREE : c_int = 5;
4238             pub const MADV_NOSYNC : c_int = 6;
4239             pub const MADV_AUTOSYNC : c_int = 7;
4240             pub const MADV_NOCORE : c_int = 8;
4241             pub const MADV_CORE : c_int = 9;
4242             pub const MADV_PROTECT : c_int = 10;
4243
4244             pub const MINCORE_INCORE : c_int =  0x1;
4245             pub const MINCORE_REFERENCED : c_int = 0x2;
4246             pub const MINCORE_MODIFIED : c_int = 0x4;
4247             pub const MINCORE_REFERENCED_OTHER : c_int = 0x8;
4248             pub const MINCORE_MODIFIED_OTHER : c_int = 0x10;
4249             pub const MINCORE_SUPER : c_int = 0x20;
4250
4251             pub const AF_INET: c_int = 2;
4252             pub const AF_INET6: c_int = 28;
4253             pub const AF_UNIX: c_int = 1;
4254             pub const SOCK_STREAM: c_int = 1;
4255             pub const SOCK_DGRAM: c_int = 2;
4256             pub const SOCK_RAW: c_int = 3;
4257             pub const IPPROTO_TCP: c_int = 6;
4258             pub const IPPROTO_IP: c_int = 0;
4259             pub const IPPROTO_IPV6: c_int = 41;
4260             pub const IP_MULTICAST_TTL: c_int = 10;
4261             pub const IP_MULTICAST_LOOP: c_int = 11;
4262             pub const IP_TTL: c_int = 4;
4263             pub const IP_HDRINCL: c_int = 2;
4264             pub const IP_ADD_MEMBERSHIP: c_int = 12;
4265             pub const IP_DROP_MEMBERSHIP: c_int = 13;
4266             pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
4267             pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
4268
4269             pub const TCP_NODELAY: c_int = 1;
4270             pub const TCP_KEEPIDLE: c_int = 256;
4271             pub const SOL_SOCKET: c_int = 0xffff;
4272             pub const SO_DEBUG: c_int = 0x01;
4273             pub const SO_ACCEPTCONN: c_int = 0x0002;
4274             pub const SO_REUSEADDR: c_int = 0x0004;
4275             pub const SO_KEEPALIVE: c_int = 0x0008;
4276             pub const SO_DONTROUTE: c_int = 0x0010;
4277             pub const SO_BROADCAST: c_int = 0x0020;
4278             pub const SO_USELOOPBACK: c_int = 0x0040;
4279             pub const SO_LINGER: c_int = 0x0080;
4280             pub const SO_OOBINLINE: c_int = 0x0100;
4281             pub const SO_REUSEPORT: c_int = 0x0200;
4282             pub const SO_SNDBUF: c_int = 0x1001;
4283             pub const SO_RCVBUF: c_int = 0x1002;
4284             pub const SO_SNDLOWAT: c_int = 0x1003;
4285             pub const SO_RCVLOWAT: c_int = 0x1004;
4286             pub const SO_SNDTIMEO: c_int = 0x1005;
4287             pub const SO_RCVTIMEO: c_int = 0x1006;
4288             pub const SO_ERROR: c_int = 0x1007;
4289             pub const SO_TYPE: c_int = 0x1008;
4290
4291             pub const IFF_LOOPBACK: c_int = 0x8;
4292
4293             pub const SHUT_RD: c_int = 0;
4294             pub const SHUT_WR: c_int = 1;
4295             pub const SHUT_RDWR: c_int = 2;
4296         }
4297         pub mod extra {
4298             use types::os::arch::c95::c_int;
4299
4300             pub const O_SYNC : c_int = 128;
4301             pub const O_NONBLOCK : c_int = 4;
4302             pub const CTL_KERN: c_int = 1;
4303             pub const KERN_PROC: c_int = 14;
4304             #[cfg(target_os = "freebsd")]
4305             pub const KERN_PROC_PATHNAME: c_int = 12;
4306             #[cfg(target_os = "dragonfly")]
4307             pub const KERN_PROC_PATHNAME: c_int = 9;
4308
4309             pub const MAP_COPY : c_int = 0x0002;
4310             pub const MAP_RENAME : c_int = 0x0020;
4311             pub const MAP_NORESERVE : c_int = 0x0040;
4312             pub const MAP_HASSEMAPHORE : c_int = 0x0200;
4313             pub const MAP_STACK : c_int = 0x0400;
4314             pub const MAP_NOSYNC : c_int = 0x0800;
4315             pub const MAP_NOCORE : c_int = 0x020000;
4316
4317             pub const IPPROTO_RAW : c_int = 255;
4318         }
4319         pub mod sysconf {
4320             use types::os::arch::c95::c_int;
4321
4322             pub const _SC_ARG_MAX : c_int = 1;
4323             pub const _SC_CHILD_MAX : c_int = 2;
4324             pub const _SC_CLK_TCK : c_int = 3;
4325             pub const _SC_NGROUPS_MAX : c_int = 4;
4326             pub const _SC_OPEN_MAX : c_int = 5;
4327             pub const _SC_JOB_CONTROL : c_int = 6;
4328             pub const _SC_SAVED_IDS : c_int = 7;
4329             pub const _SC_VERSION : c_int = 8;
4330             pub const _SC_BC_BASE_MAX : c_int = 9;
4331             pub const _SC_BC_DIM_MAX : c_int = 10;
4332             pub const _SC_BC_SCALE_MAX : c_int = 11;
4333             pub const _SC_BC_STRING_MAX : c_int = 12;
4334             pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
4335             pub const _SC_EXPR_NEST_MAX : c_int = 14;
4336             pub const _SC_LINE_MAX : c_int = 15;
4337             pub const _SC_RE_DUP_MAX : c_int = 16;
4338             pub const _SC_2_VERSION : c_int = 17;
4339             pub const _SC_2_C_BIND : c_int = 18;
4340             pub const _SC_2_C_DEV : c_int = 19;
4341             pub const _SC_2_CHAR_TERM : c_int = 20;
4342             pub const _SC_2_FORT_DEV : c_int = 21;
4343             pub const _SC_2_FORT_RUN : c_int = 22;
4344             pub const _SC_2_LOCALEDEF : c_int = 23;
4345             pub const _SC_2_SW_DEV : c_int = 24;
4346             pub const _SC_2_UPE : c_int = 25;
4347             pub const _SC_STREAM_MAX : c_int = 26;
4348             pub const _SC_TZNAME_MAX : c_int = 27;
4349             pub const _SC_ASYNCHRONOUS_IO : c_int = 28;
4350             pub const _SC_MAPPED_FILES : c_int = 29;
4351             pub const _SC_MEMLOCK : c_int = 30;
4352             pub const _SC_MEMLOCK_RANGE : c_int = 31;
4353             pub const _SC_MEMORY_PROTECTION : c_int = 32;
4354             pub const _SC_MESSAGE_PASSING : c_int = 33;
4355             pub const _SC_PRIORITIZED_IO : c_int = 34;
4356             pub const _SC_PRIORITY_SCHEDULING : c_int = 35;
4357             pub const _SC_REALTIME_SIGNALS : c_int = 36;
4358             pub const _SC_SEMAPHORES : c_int = 37;
4359             pub const _SC_FSYNC : c_int = 38;
4360             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
4361             pub const _SC_SYNCHRONIZED_IO : c_int = 40;
4362             pub const _SC_TIMERS : c_int = 41;
4363             pub const _SC_AIO_LISTIO_MAX : c_int = 42;
4364             pub const _SC_AIO_MAX : c_int = 43;
4365             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
4366             pub const _SC_DELAYTIMER_MAX : c_int = 45;
4367             pub const _SC_MQ_OPEN_MAX : c_int = 46;
4368             pub const _SC_PAGESIZE : c_int = 47;
4369             pub const _SC_RTSIG_MAX : c_int = 48;
4370             pub const _SC_SEM_NSEMS_MAX : c_int = 49;
4371             pub const _SC_SEM_VALUE_MAX : c_int = 50;
4372             pub const _SC_SIGQUEUE_MAX : c_int = 51;
4373             pub const _SC_TIMER_MAX : c_int = 52;
4374         }
4375     }
4376
4377     #[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
4378     pub mod os {
4379         pub mod c95 {
4380             use types::os::arch::c95::{c_int, c_uint};
4381
4382             pub const EXIT_FAILURE : c_int = 1;
4383             pub const EXIT_SUCCESS : c_int = 0;
4384             pub const RAND_MAX : c_int = 2147483647;
4385             pub const EOF : c_int = -1;
4386             pub const SEEK_SET : c_int = 0;
4387             pub const SEEK_CUR : c_int = 1;
4388             pub const SEEK_END : c_int = 2;
4389             pub const _IOFBF : c_int = 0;
4390             pub const _IONBF : c_int = 2;
4391             pub const _IOLBF : c_int = 1;
4392             pub const BUFSIZ : c_uint = 1024;
4393             pub const FOPEN_MAX : c_uint = 20;
4394             pub const FILENAME_MAX : c_uint = 1024;
4395             pub const L_tmpnam : c_uint = 1024;
4396             pub const TMP_MAX : c_uint = 308915776;
4397         }
4398         pub mod c99 {
4399         }
4400         pub mod posix88 {
4401             use types::common::c95::c_void;
4402             use types::os::arch::c95::c_int;
4403             use types::os::arch::posix88::mode_t;
4404
4405             pub const O_RDONLY : c_int = 0;
4406             pub const O_WRONLY : c_int = 1;
4407             pub const O_RDWR : c_int = 2;
4408             pub const O_APPEND : c_int = 8;
4409             pub const O_CREAT : c_int = 512;
4410             pub const O_EXCL : c_int = 2048;
4411             pub const O_NOCTTY : c_int = 32768;
4412             pub const O_TRUNC : c_int = 1024;
4413             pub const S_IFIFO : mode_t = 4096;
4414             pub const S_IFCHR : mode_t = 8192;
4415             pub const S_IFBLK : mode_t = 24576;
4416             pub const S_IFDIR : mode_t = 16384;
4417             pub const S_IFREG : mode_t = 32768;
4418             pub const S_IFLNK : mode_t = 40960;
4419             pub const S_IFMT : mode_t = 61440;
4420             pub const S_IEXEC : mode_t = 64;
4421             pub const S_IWRITE : mode_t = 128;
4422             pub const S_IREAD : mode_t = 256;
4423             pub const S_IRWXU : mode_t = 448;
4424             pub const S_IXUSR : mode_t = 64;
4425             pub const S_IWUSR : mode_t = 128;
4426             pub const S_IRUSR : mode_t = 256;
4427             pub const S_IRWXG : mode_t = 56;
4428             pub const S_IXGRP : mode_t = 8;
4429             pub const S_IWGRP : mode_t = 16;
4430             pub const S_IRGRP : mode_t = 32;
4431             pub const S_IRWXO : mode_t = 7;
4432             pub const S_IXOTH : mode_t = 1;
4433             pub const S_IWOTH : mode_t = 2;
4434             pub const S_IROTH : mode_t = 4;
4435             pub const F_OK : c_int = 0;
4436             pub const R_OK : c_int = 4;
4437             pub const W_OK : c_int = 2;
4438             pub const X_OK : c_int = 1;
4439             pub const STDIN_FILENO : c_int = 0;
4440             pub const STDOUT_FILENO : c_int = 1;
4441             pub const STDERR_FILENO : c_int = 2;
4442             pub const F_LOCK : c_int = 1;
4443             pub const F_TEST : c_int = 3;
4444             pub const F_TLOCK : c_int = 2;
4445             pub const F_ULOCK : c_int = 0;
4446             pub const SIGHUP : c_int = 1;
4447             pub const SIGINT : c_int = 2;
4448             pub const SIGQUIT : c_int = 3;
4449             pub const SIGILL : c_int = 4;
4450             pub const SIGABRT : c_int = 6;
4451             pub const SIGFPE : c_int = 8;
4452             pub const SIGKILL : c_int = 9;
4453             pub const SIGSEGV : c_int = 11;
4454             pub const SIGPIPE : c_int = 13;
4455             pub const SIGALRM : c_int = 14;
4456             pub const SIGTERM : c_int = 15;
4457
4458             pub const PROT_NONE : c_int = 0;
4459             pub const PROT_READ : c_int = 1;
4460             pub const PROT_WRITE : c_int = 2;
4461             pub const PROT_EXEC : c_int = 4;
4462
4463             pub const MAP_FILE : c_int = 0x0000;
4464             pub const MAP_SHARED : c_int = 0x0001;
4465             pub const MAP_PRIVATE : c_int = 0x0002;
4466             pub const MAP_FIXED : c_int = 0x0010;
4467             pub const MAP_ANON : c_int = 0x1000;
4468
4469             pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
4470
4471             pub const MCL_CURRENT : c_int = 0x0001;
4472             pub const MCL_FUTURE : c_int = 0x0002;
4473
4474             pub const MS_ASYNC : c_int = 0x0001;
4475             pub const MS_SYNC : c_int = 0x0002;
4476             pub const MS_INVALIDATE : c_int = 0x0004;
4477
4478             pub const EPERM : c_int = 1;
4479             pub const ENOENT : c_int = 2;
4480             pub const ESRCH : c_int = 3;
4481             pub const EINTR : c_int = 4;
4482             pub const EIO : c_int = 5;
4483             pub const ENXIO : c_int = 6;
4484             pub const E2BIG : c_int = 7;
4485             pub const ENOEXEC : c_int = 8;
4486             pub const EBADF : c_int = 9;
4487             pub const ECHILD : c_int = 10;
4488             pub const EDEADLK : c_int = 11;
4489             pub const ENOMEM : c_int = 12;
4490             pub const EACCES : c_int = 13;
4491             pub const EFAULT : c_int = 14;
4492             pub const ENOTBLK : c_int = 15;
4493             pub const EBUSY : c_int = 16;
4494             pub const EEXIST : c_int = 17;
4495             pub const EXDEV : c_int = 18;
4496             pub const ENODEV : c_int = 19;
4497             pub const ENOTDIR : c_int = 20;
4498             pub const EISDIR : c_int = 21;
4499             pub const EINVAL : c_int = 22;
4500             pub const ENFILE : c_int = 23;
4501             pub const EMFILE : c_int = 24;
4502             pub const ENOTTY : c_int = 25;
4503             pub const ETXTBSY : c_int = 26;
4504             pub const EFBIG : c_int = 27;
4505             pub const ENOSPC : c_int = 28;
4506             pub const ESPIPE : c_int = 29;
4507             pub const EROFS : c_int = 30;
4508             pub const EMLINK : c_int = 31;
4509             pub const EPIPE : c_int = 32;
4510             pub const EDOM : c_int = 33;
4511             pub const ERANGE : c_int = 34;
4512             pub const EAGAIN : c_int = 35;
4513             pub const EWOULDBLOCK : c_int = 35;
4514             pub const EINPROGRESS : c_int = 36;
4515             pub const EALREADY : c_int = 37;
4516             pub const ENOTSOCK : c_int = 38;
4517             pub const EDESTADDRREQ : c_int = 39;
4518             pub const EMSGSIZE : c_int = 40;
4519             pub const EPROTOTYPE : c_int = 41;
4520             pub const ENOPROTOOPT : c_int = 42;
4521             pub const EPROTONOSUPPORT : c_int = 43;
4522             pub const ESOCKTNOSUPPORT : c_int = 44;
4523             pub const EOPNOTSUPP : c_int = 45;
4524             pub const EPFNOSUPPORT : c_int = 46;
4525             pub const EAFNOSUPPORT : c_int = 47;
4526             pub const EADDRINUSE : c_int = 48;
4527             pub const EADDRNOTAVAIL : c_int = 49;
4528             pub const ENETDOWN : c_int = 50;
4529             pub const ENETUNREACH : c_int = 51;
4530             pub const ENETRESET : c_int = 52;
4531             pub const ECONNABORTED : c_int = 53;
4532             pub const ECONNRESET : c_int = 54;
4533             pub const ENOBUFS : c_int = 55;
4534             pub const EISCONN : c_int = 56;
4535             pub const ENOTCONN : c_int = 57;
4536             pub const ESHUTDOWN : c_int = 58;
4537             pub const ETOOMANYREFS : c_int = 59;
4538             pub const ETIMEDOUT : c_int = 60;
4539             pub const ECONNREFUSED : c_int = 61;
4540             pub const ELOOP : c_int = 62;
4541             pub const ENAMETOOLONG : c_int = 63;
4542             pub const EHOSTDOWN : c_int = 64;
4543             pub const EHOSTUNREACH : c_int = 65;
4544             pub const ENOTEMPTY : c_int = 66;
4545             pub const EPROCLIM : c_int = 67;
4546             pub const EUSERS : c_int = 68;
4547             pub const EDQUOT : c_int = 69;
4548             pub const ESTALE : c_int = 70;
4549             pub const EREMOTE : c_int = 71;
4550             pub const EBADRPC : c_int = 72;
4551             pub const ERPCMISMATCH : c_int = 73;
4552             pub const EPROGUNAVAIL : c_int = 74;
4553             pub const EPROGMISMATCH : c_int = 75;
4554             pub const EPROCUNAVAIL : c_int = 76;
4555             pub const ENOLCK : c_int = 77;
4556             pub const ENOSYS : c_int = 78;
4557             pub const EFTYPE : c_int = 79;
4558             pub const EAUTH : c_int = 80;
4559             pub const ENEEDAUTH : c_int = 81;
4560             pub const EIPSEC : c_int = 82;
4561             pub const ENOATTR : c_int = 83;
4562             pub const EILSEQ : c_int = 84;
4563             pub const ENOMEDIUM : c_int = 85;
4564             pub const EMEDIUMTYPE : c_int = 86;
4565             pub const EOVERFLOW : c_int = 87;
4566             pub const ECANCELED : c_int = 88;
4567             pub const EIDRM : c_int = 89;
4568             pub const ENOMSG : c_int = 90;
4569             pub const ENOTSUP : c_int = 91;
4570             pub const ELAST : c_int = 91; // must be equal to largest errno
4571         }
4572         pub mod posix01 {
4573             use types::os::arch::c95::{c_int, size_t};
4574             use types::os::common::posix01::rlim_t;
4575
4576             pub const F_DUPFD : c_int = 0;
4577             pub const F_GETFD : c_int = 1;
4578             pub const F_SETFD : c_int = 2;
4579             pub const F_GETFL : c_int = 3;
4580             pub const F_SETFL : c_int = 4;
4581             pub const F_GETOWN : c_int = 5;
4582             pub const F_SETOWN : c_int = 6;
4583             pub const F_GETLK : c_int = 7;
4584             pub const F_SETLK : c_int = 8;
4585             pub const F_SETLKW : c_int = 9;
4586             pub const F_DUPFD_CLOEXEC : c_int = 10;
4587
4588             pub const SIGTRAP : c_int = 5;
4589             pub const SIG_IGN: size_t = 1;
4590
4591             pub const GLOB_APPEND   : c_int = 0x0001;
4592             pub const GLOB_DOOFFS   : c_int = 0x0002;
4593             pub const GLOB_ERR      : c_int = 0x0004;
4594             pub const GLOB_MARK     : c_int = 0x0008;
4595             pub const GLOB_NOCHECK  : c_int = 0x0010;
4596             pub const GLOB_NOSORT   : c_int = 0x0020;
4597             pub const GLOB_NOESCAPE : c_int = 0x1000;
4598
4599             pub const GLOB_NOSPACE  : c_int = -1;
4600             pub const GLOB_ABORTED  : c_int = -2;
4601             pub const GLOB_NOMATCH  : c_int = -3;
4602             pub const GLOB_NOSYS : c_int = -4;
4603
4604             pub const POSIX_MADV_NORMAL : c_int = 0;
4605             pub const POSIX_MADV_RANDOM : c_int = 1;
4606             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
4607             pub const POSIX_MADV_WILLNEED : c_int = 3;
4608             pub const POSIX_MADV_DONTNEED : c_int = 4;
4609
4610             pub const _SC_IOV_MAX : c_int = 51;
4611             pub const _SC_GETGR_R_SIZE_MAX : c_int = 100;
4612             pub const _SC_GETPW_R_SIZE_MAX : c_int = 101;
4613             pub const _SC_LOGIN_NAME_MAX : c_int = 102;
4614             pub const _SC_MQ_PRIO_MAX : c_int = 59;
4615             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77;
4616             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
4617             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80;
4618             pub const _SC_THREAD_KEYS_MAX : c_int = 81;
4619             pub const _SC_THREAD_PRIO_INHERIT : c_int = 82;
4620             pub const _SC_THREAD_PRIO_PROTECT : c_int = 83;
4621             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84;
4622             pub const _SC_THREAD_PROCESS_SHARED : c_int = 85;
4623             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103;
4624             pub const _SC_THREAD_STACK_MIN : c_int = 89;
4625             pub const _SC_THREAD_THREADS_MAX : c_int = 90;
4626             pub const _SC_THREADS : c_int = 91;
4627             pub const _SC_TTY_NAME_MAX : c_int = 107;
4628             pub const _SC_ATEXIT_MAX : c_int = 46;
4629             pub const _SC_XOPEN_CRYPT : c_int = 117;
4630             pub const _SC_XOPEN_ENH_I18N : c_int = 118;
4631             pub const _SC_XOPEN_LEGACY : c_int = 119;
4632             pub const _SC_XOPEN_REALTIME : c_int = 120;
4633             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121;
4634             pub const _SC_XOPEN_SHM : c_int = 30;
4635             pub const _SC_XOPEN_UNIX : c_int = 123;
4636             pub const _SC_XOPEN_VERSION : c_int = 125;
4637
4638             pub const PTHREAD_CREATE_JOINABLE : c_int = 0;
4639             pub const PTHREAD_CREATE_DETACHED : c_int = 1;
4640             pub const PTHREAD_STACK_MIN : size_t = 2048;
4641
4642             pub const CLOCK_REALTIME : c_int = 0;
4643             pub const CLOCK_MONOTONIC : c_int = 3;
4644
4645             pub const RLIMIT_CPU: c_int = 0;
4646             pub const RLIMIT_FSIZE: c_int = 1;
4647             pub const RLIMIT_DATA: c_int = 2;
4648             pub const RLIMIT_STACK: c_int = 3;
4649             pub const RLIMIT_CORE: c_int = 4;
4650             pub const RLIMIT_RSS: c_int = 5;
4651             pub const RLIMIT_MEMLOCK: c_int = 6;
4652             pub const RLIMIT_NPROC: c_int = 7;
4653             pub const RLIMIT_NOFILE: c_int = 8;
4654             pub const RLIM_NLIMITS: c_int = 9;
4655
4656             pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
4657             pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
4658             pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
4659
4660             pub const RUSAGE_SELF: c_int = 0;
4661             pub const RUSAGE_CHILDREN: c_int = -1;
4662             pub const RUSAGE_THREAD: c_int = 1;
4663         }
4664         pub mod posix08 {
4665         }
4666         pub mod bsd44 {
4667             use types::os::arch::c95::c_int;
4668
4669             pub const MADV_NORMAL : c_int = 0;
4670             pub const MADV_RANDOM : c_int = 1;
4671             pub const MADV_SEQUENTIAL : c_int = 2;
4672             pub const MADV_WILLNEED : c_int = 3;
4673             pub const MADV_DONTNEED : c_int = 4;
4674             pub const MADV_FREE : c_int = 6;
4675
4676             pub const AF_UNIX: c_int = 1;
4677             pub const AF_INET: c_int = 2;
4678             pub const AF_INET6: c_int = 24;
4679             pub const SOCK_STREAM: c_int = 1;
4680             pub const SOCK_DGRAM: c_int = 2;
4681             pub const SOCK_RAW: c_int = 3;
4682             pub const IPPROTO_TCP: c_int = 6;
4683             pub const IPPROTO_IP: c_int = 0;
4684             pub const IPPROTO_IPV6: c_int = 41;
4685             pub const IP_MULTICAST_TTL: c_int = 10;
4686             pub const IP_MULTICAST_LOOP: c_int = 11;
4687             pub const IP_TTL: c_int = 4;
4688             pub const IP_HDRINCL: c_int = 2;
4689             pub const IP_ADD_MEMBERSHIP: c_int = 12;
4690             pub const IP_DROP_MEMBERSHIP: c_int = 13;
4691             pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist
4692             pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist
4693
4694             pub const TCP_NODELAY: c_int = 0x01;
4695             pub const SOL_SOCKET: c_int = 0xffff;
4696             pub const SO_DEBUG: c_int = 0x01;
4697             pub const SO_ACCEPTCONN: c_int = 0x0002;
4698             pub const SO_REUSEADDR: c_int = 0x0004;
4699             pub const SO_KEEPALIVE: c_int = 0x0008;
4700             pub const SO_DONTROUTE: c_int = 0x0010;
4701             pub const SO_BROADCAST: c_int = 0x0020;
4702             pub const SO_USELOOPBACK: c_int = 0x0040;
4703             pub const SO_LINGER: c_int = 0x0080;
4704             pub const SO_OOBINLINE: c_int = 0x0100;
4705             pub const SO_REUSEPORT: c_int = 0x0200;
4706             pub const SO_SNDBUF: c_int = 0x1001;
4707             pub const SO_RCVBUF: c_int = 0x1002;
4708             pub const SO_SNDLOWAT: c_int = 0x1003;
4709             pub const SO_RCVLOWAT: c_int = 0x1004;
4710             pub const SO_SNDTIMEO: c_int = 0x1005;
4711             pub const SO_RCVTIMEO: c_int = 0x1006;
4712             pub const SO_ERROR: c_int = 0x1007;
4713             pub const SO_TYPE: c_int = 0x1008;
4714
4715             pub const IFF_LOOPBACK: c_int = 0x8;
4716
4717             pub const SHUT_RD: c_int = 0;
4718             pub const SHUT_WR: c_int = 1;
4719             pub const SHUT_RDWR: c_int = 2;
4720         }
4721         pub mod extra {
4722             use types::os::arch::c95::c_int;
4723
4724             pub const O_DSYNC : c_int = 128; // same as SYNC
4725             pub const O_SYNC : c_int = 128;
4726             pub const O_NONBLOCK : c_int = 4;
4727             pub const CTL_KERN : c_int = 1;
4728             pub const KERN_PROC : c_int = 66;
4729
4730             pub const MAP_COPY : c_int = 0x0002;
4731             pub const MAP_RENAME : c_int = 0x0000;
4732             pub const MAP_NORESERVE : c_int = 0x0000;
4733             pub const MAP_NOEXTEND : c_int = 0x0000;
4734             pub const MAP_HASSEMAPHORE : c_int = 0x0000;
4735
4736             pub const IPPROTO_RAW : c_int = 255;
4737
4738             pub const PATH_MAX: c_int = 1024;
4739         }
4740         pub mod sysconf {
4741             use types::os::arch::c95::c_int;
4742
4743             pub const _SC_ARG_MAX : c_int = 1;
4744             pub const _SC_CHILD_MAX : c_int = 2;
4745             pub const _SC_CLK_TCK : c_int = 3;
4746             pub const _SC_NGROUPS_MAX : c_int = 4;
4747             pub const _SC_OPEN_MAX : c_int = 5;
4748             pub const _SC_JOB_CONTROL : c_int = 6;
4749             pub const _SC_SAVED_IDS : c_int = 7;
4750             pub const _SC_VERSION : c_int = 8;
4751             pub const _SC_BC_BASE_MAX : c_int = 9;
4752             pub const _SC_BC_DIM_MAX : c_int = 10;
4753             pub const _SC_BC_SCALE_MAX : c_int = 11;
4754             pub const _SC_BC_STRING_MAX : c_int = 12;
4755             pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
4756             pub const _SC_EXPR_NEST_MAX : c_int = 14;
4757             pub const _SC_LINE_MAX : c_int = 15;
4758             pub const _SC_RE_DUP_MAX : c_int = 16;
4759             pub const _SC_2_VERSION : c_int = 17;
4760             pub const _SC_2_C_BIND : c_int = 18;
4761             pub const _SC_2_C_DEV : c_int = 19;
4762             pub const _SC_2_CHAR_TERM : c_int = 20;
4763             pub const _SC_2_FORT_DEV : c_int = 21;
4764             pub const _SC_2_FORT_RUN : c_int = 22;
4765             pub const _SC_2_LOCALEDEF : c_int = 23;
4766             pub const _SC_2_SW_DEV : c_int = 24;
4767             pub const _SC_2_UPE : c_int = 25;
4768             pub const _SC_STREAM_MAX : c_int = 26;
4769             pub const _SC_TZNAME_MAX : c_int = 27;
4770             pub const _SC_PAGESIZE : c_int = 28;
4771             pub const _SC_FSYNC : c_int = 29;
4772             pub const _SC_SEM_NSEMS_MAX : c_int = 31;
4773             pub const _SC_SEM_VALUE_MAX : c_int = 32;
4774             pub const _SC_AIO_LISTIO_MAX : c_int = 42;
4775             pub const _SC_AIO_MAX : c_int = 43;
4776             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
4777             pub const _SC_ASYNCHRONOUS_IO : c_int = 45;
4778             pub const _SC_DELAYTIMER_MAX : c_int = 50;
4779             pub const _SC_MAPPED_FILES : c_int = 53;
4780             pub const _SC_MEMLOCK : c_int = 54;
4781             pub const _SC_MEMLOCK_RANGE : c_int = 55;
4782             pub const _SC_MEMORY_PROTECTION : c_int = 56;
4783             pub const _SC_MESSAGE_PASSING : c_int = 57;
4784             pub const _SC_MQ_OPEN_MAX : c_int = 58;
4785             pub const _SC_PRIORITIZED_IO : c_int = 60;
4786             pub const _SC_PRIORITY_SCHEDULING : c_int = 61;
4787             pub const _SC_REALTIME_SIGNALS : c_int = 64;
4788             pub const _SC_RTSIG_MAX : c_int = 66;
4789             pub const _SC_SEMAPHORES : c_int = 67;
4790             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68;
4791             pub const _SC_SIGQUEUE_MAX : c_int = 70;
4792             pub const _SC_SYNCHRONIZED_IO : c_int = 75;
4793             pub const _SC_TIMER_MAX : c_int = 93;
4794             pub const _SC_TIMERS : c_int = 94;
4795         }
4796     }
4797
4798     #[cfg(any(target_os = "macos", target_os = "ios"))]
4799     pub mod os {
4800         pub mod c95 {
4801             use types::os::arch::c95::{c_int, c_uint};
4802
4803             pub const EXIT_FAILURE : c_int = 1;
4804             pub const EXIT_SUCCESS : c_int = 0;
4805             pub const RAND_MAX : c_int = 2147483647;
4806             pub const EOF : c_int = -1;
4807             pub const SEEK_SET : c_int = 0;
4808             pub const SEEK_CUR : c_int = 1;
4809             pub const SEEK_END : c_int = 2;
4810             pub const _IOFBF : c_int = 0;
4811             pub const _IONBF : c_int = 2;
4812             pub const _IOLBF : c_int = 1;
4813             pub const BUFSIZ : c_uint = 1024;
4814             pub const FOPEN_MAX : c_uint = 20;
4815             pub const FILENAME_MAX : c_uint = 1024;
4816             pub const L_tmpnam : c_uint = 1024;
4817             pub const TMP_MAX : c_uint = 308915776;
4818         }
4819         pub mod c99 {
4820         }
4821         pub mod posix88 {
4822             use types::common::c95::c_void;
4823             use types::os::arch::c95::c_int;
4824             use types::os::arch::posix88::mode_t;
4825
4826             pub const O_RDONLY : c_int = 0;
4827             pub const O_WRONLY : c_int = 1;
4828             pub const O_RDWR : c_int = 2;
4829             pub const O_APPEND : c_int = 8;
4830             pub const O_CREAT : c_int = 512;
4831             pub const O_EXCL : c_int = 2048;
4832             pub const O_NOCTTY : c_int = 131072;
4833             pub const O_TRUNC : c_int = 1024;
4834             pub const S_IFIFO : mode_t = 4096;
4835             pub const S_IFCHR : mode_t = 8192;
4836             pub const S_IFBLK : mode_t = 24576;
4837             pub const S_IFDIR : mode_t = 16384;
4838             pub const S_IFREG : mode_t = 32768;
4839             pub const S_IFLNK : mode_t = 40960;
4840             pub const S_IFMT : mode_t = 61440;
4841             pub const S_IEXEC : mode_t = 64;
4842             pub const S_IWRITE : mode_t = 128;
4843             pub const S_IREAD : mode_t = 256;
4844             pub const S_IRWXU : mode_t = 448;
4845             pub const S_IXUSR : mode_t = 64;
4846             pub const S_IWUSR : mode_t = 128;
4847             pub const S_IRUSR : mode_t = 256;
4848             pub const S_IRWXG : mode_t = 56;
4849             pub const S_IXGRP : mode_t = 8;
4850             pub const S_IWGRP : mode_t = 16;
4851             pub const S_IRGRP : mode_t = 32;
4852             pub const S_IRWXO : mode_t = 7;
4853             pub const S_IXOTH : mode_t = 1;
4854             pub const S_IWOTH : mode_t = 2;
4855             pub const S_IROTH : mode_t = 4;
4856             pub const F_OK : c_int = 0;
4857             pub const R_OK : c_int = 4;
4858             pub const W_OK : c_int = 2;
4859             pub const X_OK : c_int = 1;
4860             pub const STDIN_FILENO : c_int = 0;
4861             pub const STDOUT_FILENO : c_int = 1;
4862             pub const STDERR_FILENO : c_int = 2;
4863             pub const F_LOCK : c_int = 1;
4864             pub const F_TEST : c_int = 3;
4865             pub const F_TLOCK : c_int = 2;
4866             pub const F_ULOCK : c_int = 0;
4867             pub const SIGHUP : c_int = 1;
4868             pub const SIGINT : c_int = 2;
4869             pub const SIGQUIT : c_int = 3;
4870             pub const SIGILL : c_int = 4;
4871             pub const SIGABRT : c_int = 6;
4872             pub const SIGFPE : c_int = 8;
4873             pub const SIGKILL : c_int = 9;
4874             pub const SIGSEGV : c_int = 11;
4875             pub const SIGPIPE : c_int = 13;
4876             pub const SIGALRM : c_int = 14;
4877             pub const SIGTERM : c_int = 15;
4878
4879             pub const PROT_NONE : c_int = 0;
4880             pub const PROT_READ : c_int = 1;
4881             pub const PROT_WRITE : c_int = 2;
4882             pub const PROT_EXEC : c_int = 4;
4883
4884             pub const MAP_FILE : c_int = 0x0000;
4885             pub const MAP_SHARED : c_int = 0x0001;
4886             pub const MAP_PRIVATE : c_int = 0x0002;
4887             pub const MAP_FIXED : c_int = 0x0010;
4888             pub const MAP_ANON : c_int = 0x1000;
4889
4890             pub const MAP_FAILED : *mut c_void = !0 as *mut c_void;
4891
4892             pub const MCL_CURRENT : c_int = 0x0001;
4893             pub const MCL_FUTURE : c_int = 0x0002;
4894
4895             pub const MS_ASYNC : c_int = 0x0001;
4896             pub const MS_INVALIDATE : c_int = 0x0002;
4897             pub const MS_SYNC : c_int = 0x0010;
4898
4899             pub const MS_KILLPAGES : c_int = 0x0004;
4900             pub const MS_DEACTIVATE : c_int = 0x0008;
4901
4902             pub const EPERM : c_int = 1;
4903             pub const ENOENT : c_int = 2;
4904             pub const ESRCH : c_int = 3;
4905             pub const EINTR : c_int = 4;
4906             pub const EIO : c_int = 5;
4907             pub const ENXIO : c_int = 6;
4908             pub const E2BIG : c_int = 7;
4909             pub const ENOEXEC : c_int = 8;
4910             pub const EBADF : c_int = 9;
4911             pub const ECHILD : c_int = 10;
4912             pub const EDEADLK : c_int = 11;
4913             pub const ENOMEM : c_int = 12;
4914             pub const EACCES : c_int = 13;
4915             pub const EFAULT : c_int = 14;
4916             pub const ENOTBLK : c_int = 15;
4917             pub const EBUSY : c_int = 16;
4918             pub const EEXIST : c_int = 17;
4919             pub const EXDEV : c_int = 18;
4920             pub const ENODEV : c_int = 19;
4921             pub const ENOTDIR : c_int = 20;
4922             pub const EISDIR : c_int = 21;
4923             pub const EINVAL : c_int = 22;
4924             pub const ENFILE : c_int = 23;
4925             pub const EMFILE : c_int = 24;
4926             pub const ENOTTY : c_int = 25;
4927             pub const ETXTBSY : c_int = 26;
4928             pub const EFBIG : c_int = 27;
4929             pub const ENOSPC : c_int = 28;
4930             pub const ESPIPE : c_int = 29;
4931             pub const EROFS : c_int = 30;
4932             pub const EMLINK : c_int = 31;
4933             pub const EPIPE : c_int = 32;
4934             pub const EDOM : c_int = 33;
4935             pub const ERANGE : c_int = 34;
4936             pub const EAGAIN : c_int = 35;
4937             pub const EWOULDBLOCK : c_int = EAGAIN;
4938             pub const EINPROGRESS : c_int = 36;
4939             pub const EALREADY : c_int = 37;
4940             pub const ENOTSOCK : c_int = 38;
4941             pub const EDESTADDRREQ : c_int = 39;
4942             pub const EMSGSIZE : c_int = 40;
4943             pub const EPROTOTYPE : c_int = 41;
4944             pub const ENOPROTOOPT : c_int = 42;
4945             pub const EPROTONOSUPPORT : c_int = 43;
4946             pub const ESOCKTNOSUPPORT : c_int = 44;
4947             pub const ENOTSUP : c_int = 45;
4948             pub const EPFNOSUPPORT : c_int = 46;
4949             pub const EAFNOSUPPORT : c_int = 47;
4950             pub const EADDRINUSE : c_int = 48;
4951             pub const EADDRNOTAVAIL : c_int = 49;
4952             pub const ENETDOWN : c_int = 50;
4953             pub const ENETUNREACH : c_int = 51;
4954             pub const ENETRESET : c_int = 52;
4955             pub const ECONNABORTED : c_int = 53;
4956             pub const ECONNRESET : c_int = 54;
4957             pub const ENOBUFS : c_int = 55;
4958             pub const EISCONN : c_int = 56;
4959             pub const ENOTCONN : c_int = 57;
4960             pub const ESHUTDOWN : c_int = 58;
4961             pub const ETOOMANYREFS : c_int = 59;
4962             pub const ETIMEDOUT : c_int = 60;
4963             pub const ECONNREFUSED : c_int = 61;
4964             pub const ELOOP : c_int = 62;
4965             pub const ENAMETOOLONG : c_int = 63;
4966             pub const EHOSTDOWN : c_int = 64;
4967             pub const EHOSTUNREACH : c_int = 65;
4968             pub const ENOTEMPTY : c_int = 66;
4969             pub const EPROCLIM : c_int = 67;
4970             pub const EUSERS : c_int = 68;
4971             pub const EDQUOT : c_int = 69;
4972             pub const ESTALE : c_int = 70;
4973             pub const EREMOTE : c_int = 71;
4974             pub const EBADRPC : c_int = 72;
4975             pub const ERPCMISMATCH : c_int = 73;
4976             pub const EPROGUNAVAIL : c_int = 74;
4977             pub const EPROGMISMATCH : c_int = 75;
4978             pub const EPROCUNAVAIL : c_int = 76;
4979             pub const ENOLCK : c_int = 77;
4980             pub const ENOSYS : c_int = 78;
4981             pub const EFTYPE : c_int = 79;
4982             pub const EAUTH : c_int = 80;
4983             pub const ENEEDAUTH : c_int = 81;
4984             pub const EPWROFF : c_int = 82;
4985             pub const EDEVERR : c_int = 83;
4986             pub const EOVERFLOW : c_int = 84;
4987             pub const EBADEXEC : c_int = 85;
4988             pub const EBADARCH : c_int = 86;
4989             pub const ESHLIBVERS : c_int = 87;
4990             pub const EBADMACHO : c_int = 88;
4991             pub const ECANCELED : c_int = 89;
4992             pub const EIDRM : c_int = 90;
4993             pub const ENOMSG : c_int = 91;
4994             pub const EILSEQ : c_int = 92;
4995             pub const ENOATTR : c_int = 93;
4996             pub const EBADMSG : c_int = 94;
4997             pub const EMULTIHOP : c_int = 95;
4998             pub const ENODATA : c_int = 96;
4999             pub const ENOLINK : c_int = 97;
5000             pub const ENOSR : c_int = 98;
5001             pub const ENOSTR : c_int = 99;
5002             pub const EPROTO : c_int = 100;
5003             pub const ETIME : c_int = 101;
5004             pub const EOPNOTSUPP : c_int = 102;
5005             pub const ENOPOLICY : c_int = 103;
5006             pub const ENOTRECOVERABLE : c_int = 104;
5007             pub const EOWNERDEAD : c_int = 105;
5008             pub const EQFULL : c_int = 106;
5009             pub const ELAST : c_int = 106;
5010         }
5011         pub mod posix01 {
5012             use types::os::arch::c95::{c_int, size_t};
5013             use types::os::common::posix01::rlim_t;
5014
5015             pub const F_DUPFD : c_int = 0;
5016             pub const F_GETFD : c_int = 1;
5017             pub const F_SETFD : c_int = 2;
5018             pub const F_GETFL : c_int = 3;
5019             pub const F_SETFL : c_int = 4;
5020
5021             pub const SIGTRAP : c_int = 5;
5022             pub const SIG_IGN: size_t = 1;
5023
5024             pub const GLOB_APPEND   : c_int = 0x0001;
5025             pub const GLOB_DOOFFS   : c_int = 0x0002;
5026             pub const GLOB_ERR      : c_int = 0x0004;
5027             pub const GLOB_MARK     : c_int = 0x0008;
5028             pub const GLOB_NOCHECK  : c_int = 0x0010;
5029             pub const GLOB_NOSORT   : c_int = 0x0020;
5030             pub const GLOB_NOESCAPE : c_int = 0x2000;
5031
5032             pub const GLOB_NOSPACE  : c_int = -1;
5033             pub const GLOB_ABORTED  : c_int = -2;
5034             pub const GLOB_NOMATCH  : c_int = -3;
5035
5036             pub const POSIX_MADV_NORMAL : c_int = 0;
5037             pub const POSIX_MADV_RANDOM : c_int = 1;
5038             pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
5039             pub const POSIX_MADV_WILLNEED : c_int = 3;
5040             pub const POSIX_MADV_DONTNEED : c_int = 4;
5041
5042             pub const _SC_IOV_MAX : c_int = 56;
5043             pub const _SC_GETGR_R_SIZE_MAX : c_int = 70;
5044             pub const _SC_GETPW_R_SIZE_MAX : c_int = 71;
5045             pub const _SC_LOGIN_NAME_MAX : c_int = 73;
5046             pub const _SC_MQ_PRIO_MAX : c_int = 75;
5047             pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82;
5048             pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83;
5049             pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85;
5050             pub const _SC_THREAD_KEYS_MAX : c_int = 86;
5051             pub const _SC_THREAD_PRIO_INHERIT : c_int = 87;
5052             pub const _SC_THREAD_PRIO_PROTECT : c_int = 88;
5053             pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89;
5054             pub const _SC_THREAD_PROCESS_SHARED : c_int = 90;
5055             pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91;
5056             pub const _SC_THREAD_STACK_MIN : c_int = 93;
5057             pub const _SC_THREAD_THREADS_MAX : c_int = 94;
5058             pub const _SC_THREADS : c_int = 96;
5059             pub const _SC_TTY_NAME_MAX : c_int = 101;
5060             pub const _SC_ATEXIT_MAX : c_int = 107;
5061             pub const _SC_XOPEN_CRYPT : c_int = 108;
5062             pub const _SC_XOPEN_ENH_I18N : c_int = 109;
5063             pub const _SC_XOPEN_LEGACY : c_int = 110;
5064             pub const _SC_XOPEN_REALTIME : c_int = 111;
5065             pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112;
5066             pub const _SC_XOPEN_SHM : c_int = 113;
5067             pub const _SC_XOPEN_UNIX : c_int = 115;
5068             pub const _SC_XOPEN_VERSION : c_int = 116;
5069             pub const _SC_XOPEN_XCU_VERSION : c_int = 121;
5070
5071             pub const PTHREAD_CREATE_JOINABLE: c_int = 1;
5072             pub const PTHREAD_CREATE_DETACHED: c_int = 2;
5073             pub const PTHREAD_STACK_MIN: size_t = 8192;
5074
5075             pub const RLIMIT_CPU: c_int = 0;
5076             pub const RLIMIT_FSIZE: c_int = 1;
5077             pub const RLIMIT_DATA: c_int = 2;
5078             pub const RLIMIT_STACK: c_int = 3;
5079             pub const RLIMIT_CORE: c_int = 4;
5080             pub const RLIMIT_AS: c_int = 5;
5081             pub const RLIMIT_MEMLOCK: c_int = 6;
5082             pub const RLIMIT_NPROC: c_int = 7;
5083             pub const RLIMIT_NOFILE: c_int = 8;
5084             pub const RLIM_NLIMITS: c_int = 9;
5085             pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000;
5086
5087             pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff;
5088
5089             pub const RUSAGE_SELF: c_int = 0;
5090             pub const RUSAGE_CHILDREN: c_int = -1;
5091             pub const RUSAGE_THREAD: c_int = 1;
5092         }
5093         pub mod posix08 {
5094         }
5095         pub mod bsd44 {
5096             use types::os::arch::c95::c_int;
5097
5098             pub const MADV_NORMAL : c_int = 0;
5099             pub const MADV_RANDOM : c_int = 1;
5100             pub const MADV_SEQUENTIAL : c_int = 2;
5101             pub const MADV_WILLNEED : c_int = 3;
5102             pub const MADV_DONTNEED : c_int = 4;
5103             pub const MADV_FREE : c_int = 5;
5104             pub const MADV_ZERO_WIRED_PAGES : c_int = 6;
5105             pub const MADV_FREE_REUSABLE : c_int = 7;
5106             pub const MADV_FREE_REUSE : c_int = 8;
5107             pub const MADV_CAN_REUSE : c_int = 9;
5108
5109             pub const MINCORE_INCORE : c_int =  0x1;
5110             pub const MINCORE_REFERENCED : c_int = 0x2;
5111             pub const MINCORE_MODIFIED : c_int = 0x4;
5112             pub const MINCORE_REFERENCED_OTHER : c_int = 0x8;
5113             pub const MINCORE_MODIFIED_OTHER : c_int = 0x10;
5114
5115             pub const AF_UNIX: c_int = 1;
5116             pub const AF_INET: c_int = 2;
5117             pub const AF_INET6: c_int = 30;
5118             pub const SOCK_STREAM: c_int = 1;
5119             pub const SOCK_DGRAM: c_int = 2;
5120             pub const SOCK_RAW: c_int = 3;
5121             pub const IPPROTO_TCP: c_int = 6;
5122             pub const IPPROTO_IP: c_int = 0;
5123             pub const IPPROTO_IPV6: c_int = 41;
5124             pub const IP_MULTICAST_TTL: c_int = 10;
5125             pub const IP_MULTICAST_LOOP: c_int = 11;
5126             pub const IP_TTL: c_int = 4;
5127             pub const IP_HDRINCL: c_int = 2;
5128             pub const IP_ADD_MEMBERSHIP: c_int = 12;
5129             pub const IP_DROP_MEMBERSHIP: c_int = 13;
5130             pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
5131             pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
5132
5133             pub const TCP_NODELAY: c_int = 0x01;
5134             pub const TCP_KEEPALIVE: c_int = 0x10;
5135             pub const SOL_SOCKET: c_int = 0xffff;
5136
5137             pub const SO_DEBUG: c_int = 0x01;
5138             pub const SO_ACCEPTCONN: c_int = 0x0002;
5139             pub const SO_REUSEADDR: c_int = 0x0004;
5140             pub const SO_KEEPALIVE: c_int = 0x0008;
5141             pub const SO_DONTROUTE: c_int = 0x0010;
5142             pub const SO_BROADCAST: c_int = 0x0020;
5143             pub const SO_USELOOPBACK: c_int = 0x0040;
5144             pub const SO_LINGER: c_int = 0x0080;
5145             pub const SO_OOBINLINE: c_int = 0x0100;
5146             pub const SO_REUSEPORT: c_int = 0x0200;
5147             pub const SO_SNDBUF: c_int = 0x1001;
5148             pub const SO_RCVBUF: c_int = 0x1002;
5149             pub const SO_SNDLOWAT: c_int = 0x1003;
5150             pub const SO_RCVLOWAT: c_int = 0x1004;
5151             pub const SO_SNDTIMEO: c_int = 0x1005;
5152             pub const SO_RCVTIMEO: c_int = 0x1006;
5153             pub const SO_ERROR: c_int = 0x1007;
5154             pub const SO_TYPE: c_int = 0x1008;
5155
5156             pub const IFF_LOOPBACK: c_int = 0x8;
5157
5158             pub const SHUT_RD: c_int = 0;
5159             pub const SHUT_WR: c_int = 1;
5160             pub const SHUT_RDWR: c_int = 2;
5161         }
5162         pub mod extra {
5163             use types::os::arch::c95::c_int;
5164
5165             pub const O_DSYNC : c_int = 4194304;
5166             pub const O_SYNC : c_int = 128;
5167             pub const O_NONBLOCK : c_int = 4;
5168             pub const F_FULLFSYNC : c_int = 51;
5169
5170             pub const MAP_COPY : c_int = 0x0002;
5171             pub const MAP_RENAME : c_int = 0x0020;
5172             pub const MAP_NORESERVE : c_int = 0x0040;
5173             pub const MAP_NOEXTEND : c_int = 0x0100;
5174             pub const MAP_HASSEMAPHORE : c_int = 0x0200;
5175             pub const MAP_NOCACHE : c_int = 0x0400;
5176             pub const MAP_JIT : c_int = 0x0800;
5177             pub const MAP_STACK : c_int = 0;
5178
5179             pub const IPPROTO_RAW : c_int = 255;
5180
5181             pub const SO_NREAD: c_int = 0x1020;
5182             pub const SO_NKE: c_int = 0x1021;
5183             pub const SO_NOSIGPIPE: c_int = 0x1022;
5184             pub const SO_NOADDRERR: c_int = 0x1023;
5185             pub const SO_NWRITE: c_int = 0x1024;
5186             pub const SO_DONTTRUNC: c_int = 0x2000;
5187             pub const SO_WANTMORE: c_int = 0x4000;
5188             pub const SO_WANTOOBFLAG: c_int = 0x8000;
5189         }
5190         pub mod sysconf {
5191             use types::os::arch::c95::c_int;
5192
5193             pub const _SC_ARG_MAX : c_int = 1;
5194             pub const _SC_CHILD_MAX : c_int = 2;
5195             pub const _SC_CLK_TCK : c_int = 3;
5196             pub const _SC_NGROUPS_MAX : c_int = 4;
5197             pub const _SC_OPEN_MAX : c_int = 5;
5198             pub const _SC_JOB_CONTROL : c_int = 6;
5199             pub const _SC_SAVED_IDS : c_int = 7;
5200             pub const _SC_VERSION : c_int = 8;
5201             pub const _SC_BC_BASE_MAX : c_int = 9;
5202             pub const _SC_BC_DIM_MAX : c_int = 10;
5203             pub const _SC_BC_SCALE_MAX : c_int = 11;
5204             pub const _SC_BC_STRING_MAX : c_int = 12;
5205             pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
5206             pub const _SC_EXPR_NEST_MAX : c_int = 14;
5207             pub const _SC_LINE_MAX : c_int = 15;
5208             pub const _SC_RE_DUP_MAX : c_int = 16;
5209             pub const _SC_2_VERSION : c_int = 17;
5210             pub const _SC_2_C_BIND : c_int = 18;
5211             pub const _SC_2_C_DEV : c_int = 19;
5212             pub const _SC_2_CHAR_TERM : c_int = 20;
5213             pub const _SC_2_FORT_DEV : c_int = 21;
5214             pub const _SC_2_FORT_RUN : c_int = 22;
5215             pub const _SC_2_LOCALEDEF : c_int = 23;
5216             pub const _SC_2_SW_DEV : c_int = 24;
5217             pub const _SC_2_UPE : c_int = 25;
5218             pub const _SC_STREAM_MAX : c_int = 26;
5219             pub const _SC_TZNAME_MAX : c_int = 27;
5220             pub const _SC_ASYNCHRONOUS_IO : c_int = 28;
5221             pub const _SC_PAGESIZE : c_int = 29;
5222             pub const _SC_MEMLOCK : c_int = 30;
5223             pub const _SC_MEMLOCK_RANGE : c_int = 31;
5224             pub const _SC_MEMORY_PROTECTION : c_int = 32;
5225             pub const _SC_MESSAGE_PASSING : c_int = 33;
5226             pub const _SC_PRIORITIZED_IO : c_int = 34;
5227             pub const _SC_PRIORITY_SCHEDULING : c_int = 35;
5228             pub const _SC_REALTIME_SIGNALS : c_int = 36;
5229             pub const _SC_SEMAPHORES : c_int = 37;
5230             pub const _SC_FSYNC : c_int = 38;
5231             pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39;
5232             pub const _SC_SYNCHRONIZED_IO : c_int = 40;
5233             pub const _SC_TIMERS : c_int = 41;
5234             pub const _SC_AIO_LISTIO_MAX : c_int = 42;
5235             pub const _SC_AIO_MAX : c_int = 43;
5236             pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
5237             pub const _SC_DELAYTIMER_MAX : c_int = 45;
5238             pub const _SC_MQ_OPEN_MAX : c_int = 46;
5239             pub const _SC_MAPPED_FILES : c_int = 47;
5240             pub const _SC_RTSIG_MAX : c_int = 48;
5241             pub const _SC_SEM_NSEMS_MAX : c_int = 49;
5242             pub const _SC_SEM_VALUE_MAX : c_int = 50;
5243             pub const _SC_SIGQUEUE_MAX : c_int = 51;
5244             pub const _SC_TIMER_MAX : c_int = 52;
5245             pub const _SC_XBS5_ILP32_OFF32 : c_int = 122;
5246             pub const _SC_XBS5_ILP32_OFFBIG : c_int = 123;
5247             pub const _SC_XBS5_LP64_OFF64 : c_int = 124;
5248             pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 125;
5249         }
5250     }
5251 }
5252
5253
5254 pub mod funcs {
5255     // Thankfully most of c95 is universally available and does not vary by OS
5256     // or anything. The same is not true of POSIX.
5257
5258     pub mod c95 {
5259         pub mod ctype {
5260             use types::os::arch::c95::{c_char, c_int};
5261
5262             extern {
5263                 pub fn isalnum(c: c_int) -> c_int;
5264                 pub fn isalpha(c: c_int) -> c_int;
5265                 pub fn iscntrl(c: c_int) -> c_int;
5266                 pub fn isdigit(c: c_int) -> c_int;
5267                 pub fn isgraph(c: c_int) -> c_int;
5268                 pub fn islower(c: c_int) -> c_int;
5269                 pub fn isprint(c: c_int) -> c_int;
5270                 pub fn ispunct(c: c_int) -> c_int;
5271                 pub fn isspace(c: c_int) -> c_int;
5272                 pub fn isupper(c: c_int) -> c_int;
5273                 pub fn isxdigit(c: c_int) -> c_int;
5274                 pub fn tolower(c: c_char) -> c_char;
5275                 pub fn toupper(c: c_char) -> c_char;
5276             }
5277         }
5278
5279         pub mod stdio {
5280             use types::common::c95::{FILE, c_void, fpos_t};
5281             use types::os::arch::c95::{c_char, c_int, c_long, size_t};
5282
5283             extern {
5284                 pub fn fopen(filename: *const c_char,
5285                              mode: *const c_char) -> *mut FILE;
5286                 pub fn freopen(filename: *const c_char, mode: *const c_char,
5287                                file: *mut FILE)
5288                                -> *mut FILE;
5289                 pub fn fflush(file: *mut FILE) -> c_int;
5290                 pub fn fclose(file: *mut FILE) -> c_int;
5291                 pub fn remove(filename: *const c_char) -> c_int;
5292                 pub fn rename(oldname: *const c_char,
5293                               newname: *const c_char) -> c_int;
5294                 pub fn tmpfile() -> *mut FILE;
5295                 pub fn setvbuf(stream: *mut FILE,
5296                                buffer: *mut c_char,
5297                                mode: c_int,
5298                                size: size_t)
5299                                -> c_int;
5300                 pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
5301                 // Omitted: printf and scanf variants.
5302                 pub fn fgetc(stream: *mut FILE) -> c_int;
5303                 pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
5304                              -> *mut c_char;
5305                 pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
5306                 pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int;
5307                 // Omitted: getc, getchar (might be macros).
5308
5309                 // Omitted: gets, so ridiculously unsafe that it should not
5310                 // survive.
5311
5312                 // Omitted: putc, putchar (might be macros).
5313                 pub fn puts(s: *const c_char) -> c_int;
5314                 pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
5315                 pub fn fread(ptr: *mut c_void,
5316                              size: size_t,
5317                              nobj: size_t,
5318                              stream: *mut FILE)
5319                              -> size_t;
5320                 pub fn fwrite(ptr: *const c_void,
5321                               size: size_t,
5322                               nobj: size_t,
5323                               stream: *mut FILE)
5324                               -> size_t;
5325                 pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int)
5326                              -> c_int;
5327                 pub fn ftell(stream: *mut FILE) -> c_long;
5328                 pub fn rewind(stream: *mut FILE);
5329                 pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
5330                 pub fn fsetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
5331                 pub fn feof(stream: *mut FILE) -> c_int;
5332                 pub fn ferror(stream: *mut FILE) -> c_int;
5333                 pub fn perror(s: *const c_char);
5334             }
5335         }
5336
5337         pub mod stdlib {
5338             use types::common::c95::c_void;
5339             use types::os::arch::c95::{c_char, c_double, c_int};
5340             use types::os::arch::c95::{c_long, c_uint, c_ulong};
5341             use types::os::arch::c95::{size_t};
5342
5343             extern {
5344                 pub fn abs(i: c_int) -> c_int;
5345                 pub fn labs(i: c_long) -> c_long;
5346                 // Omitted: div, ldiv (return pub type incomplete).
5347                 pub fn atof(s: *const c_char) -> c_double;
5348                 pub fn atoi(s: *const c_char) -> c_int;
5349                 pub fn strtod(s: *const c_char,
5350                               endp: *mut *mut c_char) -> c_double;
5351                 pub fn strtol(s: *const c_char,
5352                               endp: *mut *mut c_char, base: c_int) -> c_long;
5353                 pub fn strtoul(s: *const c_char, endp: *mut *mut c_char,
5354                                base: c_int) -> c_ulong;
5355                 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
5356                 pub fn malloc(size: size_t) -> *mut c_void;
5357                 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
5358                 pub fn free(p: *mut c_void);
5359
5360                 /// Exits the running program in a possibly dangerous manner.
5361                 ///
5362                 /// # Unsafety
5363                 ///
5364                 /// While this forces your program to exit, it does so in a way that has
5365                 /// consequences. This will skip all unwinding code, which means that anything
5366                 /// relying on unwinding for cleanup (such as flushing and closing a buffer to a
5367                 /// file) may act in an unexpected way.
5368                 ///
5369                 /// # Examples
5370                 ///
5371                 /// ```no_run,ignore
5372                 /// extern crate libc;
5373                 ///
5374                 /// fn main() {
5375                 ///     unsafe {
5376                 ///         libc::exit(1);
5377                 ///     }
5378                 /// }
5379                 /// ```
5380                 pub fn exit(status: c_int) -> !;
5381                 pub fn _exit(status: c_int) -> !;
5382                 pub fn atexit(cb: extern fn()) -> c_int;
5383                 pub fn system(s: *const c_char) -> c_int;
5384                 pub fn getenv(s: *const c_char) -> *mut c_char;
5385                 // Omitted: bsearch, qsort
5386                 pub fn rand() -> c_int;
5387                 pub fn srand(seed: c_uint);
5388             }
5389         }
5390
5391         pub mod string {
5392             use types::common::c95::c_void;
5393             use types::os::arch::c95::{c_char, c_int, size_t};
5394             use types::os::arch::c95::{wchar_t};
5395
5396             extern {
5397                 pub fn strcpy(dst: *mut c_char,
5398                               src: *const c_char) -> *mut c_char;
5399                 pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t)
5400                                -> *mut c_char;
5401                 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
5402                 pub fn strncat(s: *mut c_char, ct: *const c_char,
5403                                n: size_t) -> *mut c_char;
5404                 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
5405                 pub fn strncmp(cs: *const c_char, ct: *const c_char,
5406                                n: size_t) -> c_int;
5407                 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
5408                 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
5409                 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
5410                 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
5411                 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
5412                 pub fn strpbrk(cs: *const c_char,
5413                                ct: *const c_char) -> *mut c_char;
5414                 pub fn strstr(cs: *const c_char,
5415                               ct: *const c_char) -> *mut c_char;
5416                 pub fn strlen(cs: *const c_char) -> size_t;
5417                 pub fn strerror(n: c_int) -> *mut c_char;
5418                 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
5419                 pub fn strxfrm(s: *mut c_char, ct: *const c_char,
5420                                n: size_t) -> size_t;
5421                 pub fn wcslen(buf: *const wchar_t) -> size_t;
5422
5423                 // Omitted: memcpy, memmove, memset (provided by LLVM)
5424
5425                 // These are fine to execute on the Rust stack. They must be,
5426                 // in fact, because LLVM generates calls to them!
5427                 pub fn memcmp(cx: *const c_void, ct: *const c_void,
5428                               n: size_t) -> c_int;
5429                 pub fn memchr(cx: *const c_void, c: c_int,
5430                               n: size_t) -> *mut c_void;
5431             }
5432         }
5433     }
5434
5435     // Microsoft helpfully underscore-qualifies all of its POSIX-like symbols
5436     // to make sure you don't use them accidentally. It also randomly deviates
5437     // from the exact signatures you might otherwise expect, and omits much,
5438     // so be careful when trying to write portable code; it won't always work
5439     // with the same POSIX functions and types as other platforms.
5440
5441     #[cfg(target_os = "windows")]
5442     pub mod posix88 {
5443         pub mod stat_ {
5444             use types::os::common::posix01::{stat, utimbuf};
5445             use types::os::arch::c95::{c_int, c_char, wchar_t};
5446
5447             extern {
5448                 #[link_name = "_chmod"]
5449                 pub fn chmod(path: *const c_char, mode: c_int) -> c_int;
5450                 #[link_name = "_wchmod"]
5451                 pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int;
5452                 #[link_name = "_mkdir"]
5453                 pub fn mkdir(path: *const c_char) -> c_int;
5454                 #[link_name = "_wrmdir"]
5455                 pub fn wrmdir(path: *const wchar_t) -> c_int;
5456                 #[link_name = "_fstat64"]
5457                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
5458                 #[link_name = "_stat64"]
5459                 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
5460                 #[link_name = "_wstat64"]
5461                 pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int;
5462                 #[link_name = "_wutime64"]
5463                 pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int;
5464             }
5465         }
5466
5467         pub mod stdio {
5468             use types::common::c95::FILE;
5469             use types::os::arch::c95::{c_int, c_char};
5470
5471             extern {
5472                 #[link_name = "_popen"]
5473                 pub fn popen(command: *const c_char,
5474                              mode: *const c_char) -> *mut FILE;
5475                 #[link_name = "_pclose"]
5476                 pub fn pclose(stream: *mut FILE) -> c_int;
5477                 #[link_name = "_fdopen"]
5478                 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE;
5479                 #[link_name = "_fileno"]
5480                 pub fn fileno(stream: *mut FILE) -> c_int;
5481             }
5482         }
5483
5484         pub mod fcntl {
5485             use types::os::arch::c95::{c_int, c_char, wchar_t};
5486             extern {
5487                 #[link_name = "_open"]
5488                 pub fn open(path: *const c_char, oflag: c_int, mode: c_int)
5489                             -> c_int;
5490                 #[link_name = "_wopen"]
5491                 pub fn wopen(path: *const wchar_t, oflag: c_int, mode: c_int)
5492                             -> c_int;
5493                 #[link_name = "_creat"]
5494                 pub fn creat(path: *const c_char, mode: c_int) -> c_int;
5495             }
5496         }
5497
5498         pub mod dirent {
5499             // Not supplied at all.
5500         }
5501
5502         pub mod unistd {
5503             use types::common::c95::c_void;
5504             use types::os::arch::c95::{c_int, c_uint, c_char,
5505                                              c_long, size_t};
5506             use types::os::arch::c99::intptr_t;
5507
5508             extern {
5509                 #[link_name = "_access"]
5510                 pub fn access(path: *const c_char, amode: c_int) -> c_int;
5511                 #[link_name = "_chdir"]
5512                 pub fn chdir(dir: *const c_char) -> c_int;
5513                 #[link_name = "_close"]
5514                 pub fn close(fd: c_int) -> c_int;
5515                 #[link_name = "_dup"]
5516                 pub fn dup(fd: c_int) -> c_int;
5517                 #[link_name = "_dup2"]
5518                 pub fn dup2(src: c_int, dst: c_int) -> c_int;
5519                 #[link_name = "_execv"]
5520                 pub fn execv(prog: *const c_char,
5521                              argv: *mut *const c_char) -> intptr_t;
5522                 #[link_name = "_execve"]
5523                 pub fn execve(prog: *const c_char, argv: *mut *const c_char,
5524                               envp: *mut *const c_char)
5525                               -> c_int;
5526                 #[link_name = "_execvp"]
5527                 pub fn execvp(c: *const c_char,
5528                               argv: *mut *const c_char) -> c_int;
5529                 #[link_name = "_execvpe"]
5530                 pub fn execvpe(c: *const c_char, argv: *mut *const c_char,
5531                                envp: *mut *const c_char) -> c_int;
5532                 #[link_name = "_getcwd"]
5533                 pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
5534                 #[link_name = "_getpid"]
5535                 pub fn getpid() -> c_int;
5536                 #[link_name = "_isatty"]
5537                 pub fn isatty(fd: c_int) -> c_int;
5538                 #[link_name = "_lseek"]
5539                 pub fn lseek(fd: c_int, offset: c_long, origin: c_int)
5540                              -> c_long;
5541                 #[link_name = "_pipe"]
5542                 pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int)
5543                             -> c_int;
5544                 #[link_name = "_read"]
5545                 pub fn read(fd: c_int, buf: *mut c_void, count: c_uint)
5546                             -> c_int;
5547                 #[link_name = "_rmdir"]
5548                 pub fn rmdir(path: *const c_char) -> c_int;
5549                 #[link_name = "_unlink"]
5550                 pub fn unlink(c: *const c_char) -> c_int;
5551                 #[link_name = "_write"]
5552                 pub fn write(fd: c_int, buf: *const c_void,
5553                              count: c_uint) -> c_int;
5554             }
5555         }
5556
5557         pub mod mman {
5558         }
5559     }
5560
5561     #[cfg(any(target_os = "linux",
5562               target_os = "android",
5563               target_os = "macos",
5564               target_os = "ios",
5565               target_os = "freebsd",
5566               target_os = "dragonfly",
5567               target_os = "bitrig",
5568               target_os = "openbsd",
5569               target_os = "nacl"))]
5570     pub mod posix88 {
5571         pub mod stat_ {
5572             use types::os::arch::c95::{c_char, c_int};
5573             use types::os::arch::posix01::stat;
5574             use types::os::arch::posix88::mode_t;
5575
5576             extern {
5577                 pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
5578                 pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
5579
5580                 #[cfg(any(target_os = "linux",
5581                           target_os = "freebsd",
5582                           target_os = "dragonfly",
5583                           target_os = "bitrig",
5584                           target_os = "openbsd",
5585                           target_os = "android",
5586                           target_os = "ios",
5587                           target_os = "nacl"))]
5588                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
5589
5590                 #[cfg(target_os = "macos")]
5591                 #[link_name = "fstat64"]
5592                 pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
5593
5594                 pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
5595                 #[cfg(not(target_os = "nacl"))]
5596                 pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
5597
5598                 #[cfg(any(target_os = "linux",
5599                           target_os = "freebsd",
5600                           target_os = "dragonfly",
5601                           target_os = "bitrig",
5602                           target_os = "openbsd",
5603                           target_os = "android",
5604                           target_os = "ios",
5605                           target_os = "nacl"))]
5606                 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
5607
5608                 #[cfg(target_os = "macos")]
5609                 #[link_name = "stat64"]
5610                 pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
5611             }
5612         }
5613
5614         pub mod stdio {
5615             use types::common::c95::FILE;
5616             use types::os::arch::c95::{c_char, c_int};
5617
5618             extern {
5619                 pub fn popen(command: *const c_char,
5620                              mode: *const c_char) -> *mut FILE;
5621                 pub fn pclose(stream: *mut FILE) -> c_int;
5622                 pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE;
5623                 pub fn fileno(stream: *mut FILE) -> c_int;
5624             }
5625         }
5626
5627         pub mod fcntl {
5628             use types::os::arch::c95::{c_char, c_int};
5629             use types::os::arch::posix88::mode_t;
5630
5631             mod open_shim {
5632                 extern {
5633                     #[cfg(any(target_os = "macos",
5634                               target_os = "ios"))]
5635                     pub fn open(path: *const ::c_char, oflag: ::c_int, ...)
5636                                 -> ::c_int;
5637
5638                     #[cfg(not(any(target_os = "macos",
5639                                   target_os = "ios")))]
5640                     pub fn open(path: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
5641                                 -> ::c_int;
5642                 }
5643             }
5644
5645             #[cfg(any(target_os = "macos",
5646                       target_os = "ios"))]
5647             #[inline]
5648             pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
5649                 use types::os::arch::c95::c_uint;
5650                 open_shim::open(path, oflag, mode as c_uint)
5651             }
5652
5653             #[cfg(not(any(target_os = "macos",
5654                           target_os = "ios")))]
5655             #[inline]
5656             pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
5657                 open_shim::open(path, oflag, mode)
5658             }
5659
5660             extern {
5661                 pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
5662                 pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
5663             }
5664         }
5665
5666         pub mod dirent {
5667             use types::common::posix88::{DIR, dirent_t};
5668             use types::os::arch::c95::{c_char, c_int, c_long};
5669
5670             // NB: On OS X opendir and readdir have two versions,
5671             // one for 32-bit kernelspace and one for 64.
5672             // We should be linking to the 64-bit ones, called
5673             // opendir$INODE64, etc. but for some reason rustc
5674             // doesn't link it correctly on i686, so we're going
5675             // through a C function that mysteriously does work.
5676
5677             extern {
5678                 #[link_name="rust_opendir"]
5679                 pub fn opendir(dirname: *const c_char) -> *mut DIR;
5680                 #[link_name="rust_readdir_r"]
5681                 pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent_t,
5682                                   result: *mut *mut dirent_t) -> c_int;
5683             }
5684
5685             extern {
5686                 pub fn closedir(dirp: *mut DIR) -> c_int;
5687                 pub fn rewinddir(dirp: *mut DIR);
5688                 pub fn seekdir(dirp: *mut DIR, loc: c_long);
5689                 pub fn telldir(dirp: *mut DIR) -> c_long;
5690             }
5691         }
5692
5693         pub mod unistd {
5694             use types::common::c95::c_void;
5695             use types::os::arch::c95::{c_char, c_int, c_long, c_uint};
5696             use types::os::arch::c95::{size_t};
5697             use types::os::common::posix01::timespec;
5698             use types::os::arch::posix01::utimbuf;
5699             use types::os::arch::posix88::{gid_t, off_t, pid_t};
5700             use types::os::arch::posix88::{ssize_t, uid_t};
5701
5702             pub const _PC_NAME_MAX: c_int = 4;
5703
5704             #[cfg(not(target_os = "nacl"))]
5705             extern {
5706                 pub fn access(path: *const c_char, amode: c_int) -> c_int;
5707                 pub fn alarm(seconds: c_uint) -> c_uint;
5708                 pub fn chdir(dir: *const c_char) -> c_int;
5709                 pub fn chown(path: *const c_char, uid: uid_t,
5710                              gid: gid_t) -> c_int;
5711                 pub fn close(fd: c_int) -> c_int;
5712                 pub fn dup(fd: c_int) -> c_int;
5713                 pub fn dup2(src: c_int, dst: c_int) -> c_int;
5714                 pub fn execv(prog: *const c_char,
5715                              argv: *mut *const c_char) -> c_int;
5716                 pub fn execve(prog: *const c_char, argv: *mut *const c_char,
5717                               envp: *mut *const c_char)
5718                               -> c_int;
5719                 pub fn execvp(c: *const c_char,
5720                               argv: *mut *const c_char) -> c_int;
5721                 pub fn fork() -> pid_t;
5722                 pub fn fpathconf(filedes: c_int, name: c_int) -> c_long;
5723                 pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
5724                 pub fn getegid() -> gid_t;
5725                 pub fn geteuid() -> uid_t;
5726                 pub fn getgid() -> gid_t;
5727                 pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t)
5728                                  -> c_int;
5729                 pub fn getlogin() -> *mut c_char;
5730                 pub fn getopt(argc: c_int, argv: *mut *const c_char,
5731                               optstr: *const c_char) -> c_int;
5732                 pub fn getpgrp() -> pid_t;
5733                 pub fn getpid() -> pid_t;
5734                 pub fn getppid() -> pid_t;
5735                 pub fn getuid() -> uid_t;
5736                 pub fn getsid(pid: pid_t) -> pid_t;
5737                 pub fn isatty(fd: c_int) -> c_int;
5738                 pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
5739                 pub fn lseek(fd: c_int, offset: off_t, whence: c_int)
5740                              -> off_t;
5741                 pub fn pathconf(path: *mut c_char, name: c_int) -> c_long;
5742                 pub fn pause() -> c_int;
5743                 pub fn pipe(fds: *mut c_int) -> c_int;
5744                 pub fn read(fd: c_int, buf: *mut c_void, count: size_t)
5745                             -> ssize_t;
5746                 pub fn rmdir(path: *const c_char) -> c_int;
5747                 pub fn setgid(gid: gid_t) -> c_int;
5748                 pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
5749                 pub fn setsid() -> pid_t;
5750                 pub fn setuid(uid: uid_t) -> c_int;
5751                 pub fn sleep(secs: c_uint) -> c_uint;
5752                 pub fn usleep(secs: c_uint) -> c_int;
5753                 pub fn nanosleep(rqtp: *const timespec,
5754                                  rmtp: *mut timespec) -> c_int;
5755                 pub fn sysconf(name: c_int) -> c_long;
5756                 pub fn tcgetpgrp(fd: c_int) -> pid_t;
5757                 pub fn ttyname(fd: c_int) -> *mut c_char;
5758                 pub fn unlink(c: *const c_char) -> c_int;
5759                 pub fn write(fd: c_int, buf: *const c_void, count: size_t)
5760                              -> ssize_t;
5761                 pub fn pread(fd: c_int, buf: *mut c_void, count: size_t,
5762                              offset: off_t) -> ssize_t;
5763                 pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t,
5764                               offset: off_t) -> ssize_t;
5765                 pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int;
5766             }
5767             #[cfg(target_os = "nacl")]
5768             extern {
5769                 pub fn access(path: *const c_char, amode: c_int) -> c_int;
5770                 pub fn chdir(dir: *const c_char) -> c_int;
5771                 pub fn chown(path: *const c_char, uid: uid_t,
5772                              gid: gid_t) -> c_int;
5773                 pub fn close(fd: c_int) -> c_int;
5774                 pub fn dup(fd: c_int) -> c_int;
5775                 pub fn dup2(src: c_int, dst: c_int) -> c_int;
5776                 pub fn execv(prog: *const c_char,
5777                              argv: *mut *const c_char) -> c_int;
5778                 pub fn execve(prog: *const c_char, argv: *mut *const c_char,
5779                               envp: *mut *const c_char)
5780                               -> c_int;
5781                 pub fn execvp(c: *const c_char,
5782                               argv: *mut *const c_char) -> c_int;
5783                 pub fn fork() -> pid_t;
5784                 pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char;
5785                 pub fn getegid() -> gid_t;
5786                 pub fn geteuid() -> uid_t;
5787                 pub fn getgid() -> gid_t;
5788                 pub fn getlogin() -> *mut c_char;
5789                 pub fn getopt(argc: c_int, argv: *mut *const c_char,
5790                               optstr: *const c_char) -> c_int;
5791                 pub fn getuid() -> uid_t;
5792                 pub fn getsid(pid: pid_t) -> pid_t;
5793                 pub fn isatty(fd: c_int) -> c_int;
5794                 pub fn link(src: *const c_char, dst: *const c_char) -> c_int;
5795                 pub fn lseek(fd: c_int, offset: off_t, whence: c_int)
5796                              -> off_t;
5797                 pub fn pipe(fds: *mut c_int) -> c_int;
5798                 pub fn read(fd: c_int, buf: *mut c_void, count: size_t)
5799                             -> ssize_t;
5800                 pub fn rmdir(path: *const c_char) -> c_int;
5801                 pub fn setgid(gid: gid_t) -> c_int;
5802                 pub fn setuid(uid: uid_t) -> c_int;
5803                 pub fn sleep(secs: c_uint) -> c_uint;
5804                 pub fn usleep(secs: c_uint) -> c_int;
5805                 pub fn nanosleep(rqtp: *const timespec,
5806                                  rmtp: *mut timespec) -> c_int;
5807                 pub fn sysconf(name: c_int) -> c_long;
5808                 pub fn ttyname(fd: c_int) -> *mut c_char;
5809                 pub fn unlink(c: *const c_char) -> c_int;
5810                 pub fn write(fd: c_int, buf: *const c_void, count: size_t)
5811                              -> ssize_t;
5812                 pub fn pread(fd: c_int, buf: *mut c_void, count: size_t,
5813                              offset: off_t) -> ssize_t;
5814                 pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t,
5815                               offset: off_t) -> ssize_t;
5816                 pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int;
5817             }
5818         }
5819
5820         pub mod signal {
5821             use types::os::arch::c95::{c_int};
5822             use types::os::arch::posix88::{pid_t};
5823
5824             extern {
5825                 pub fn kill(pid: pid_t, sig: c_int) -> c_int;
5826             }
5827         }
5828
5829         pub mod mman {
5830             use types::common::c95::{c_void};
5831             use types::os::arch::c95::{size_t, c_int, c_char};
5832             use types::os::arch::posix88::{mode_t, off_t};
5833
5834             #[cfg(not(target_os = "nacl"))]
5835             extern {
5836                 pub fn mlock(addr: *const c_void, len: size_t) -> c_int;
5837                 pub fn munlock(addr: *const c_void, len: size_t) -> c_int;
5838                 pub fn mlockall(flags: c_int) -> c_int;
5839                 pub fn munlockall() -> c_int;
5840
5841                 pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int)
5842                                 -> c_int;
5843
5844                 pub fn msync(addr: *mut c_void, len: size_t, flags: c_int)
5845                              -> c_int;
5846                 pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t)
5847                                 -> c_int;
5848                 pub fn shm_unlink(name: *const c_char) -> c_int;
5849             }
5850
5851             extern {
5852                 pub fn mmap(addr: *mut c_void,
5853                             len: size_t,
5854                             prot: c_int,
5855                             flags: c_int,
5856                             fd: c_int,
5857                             offset: off_t)
5858                             -> *mut c_void;
5859                 pub fn munmap(addr: *mut c_void, len: size_t) -> c_int;
5860
5861             }
5862         }
5863
5864         pub mod net {
5865             use types::os::arch::c95::{c_char, c_uint};
5866
5867             extern {
5868                 pub fn if_nametoindex(ifname: *const c_char) -> c_uint;
5869             }
5870         }
5871
5872     }
5873
5874     #[cfg(any(target_os = "linux",
5875               target_os = "android",
5876               target_os = "macos",
5877               target_os = "ios",
5878               target_os = "freebsd",
5879               target_os = "dragonfly",
5880               target_os = "bitrig",
5881               target_os = "openbsd",
5882               target_os = "nacl"))]
5883     pub mod posix01 {
5884         pub mod stat_ {
5885             use types::os::arch::c95::{c_char, c_int};
5886             use types::os::arch::posix01::stat;
5887
5888             extern {
5889                 #[cfg(any(target_os = "linux",
5890                           target_os = "freebsd",
5891                           target_os = "dragonfly",
5892                           target_os = "bitrig",
5893                           target_os = "openbsd",
5894                           target_os = "android",
5895                           target_os = "ios",
5896                           target_os = "nacl"))]
5897                 pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
5898
5899                 #[cfg(target_os = "macos")]
5900                 #[link_name = "lstat64"]
5901                 pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
5902             }
5903         }
5904
5905         pub mod unistd {
5906             use types::os::arch::c95::{c_char, c_int, size_t};
5907             use types::os::arch::posix88::{ssize_t, off_t};
5908
5909             extern {
5910                 pub fn readlink(path: *const c_char,
5911                                 buf: *mut c_char,
5912                                 bufsz: size_t)
5913                                 -> ssize_t;
5914
5915                 pub fn fsync(fd: c_int) -> c_int;
5916
5917                 #[cfg(any(target_os = "linux", target_os = "android"))]
5918                 pub fn fdatasync(fd: c_int) -> c_int;
5919
5920                 pub fn setenv(name: *const c_char, val: *const c_char,
5921                               overwrite: c_int) -> c_int;
5922                 pub fn unsetenv(name: *const c_char) -> c_int;
5923                 pub fn putenv(string: *mut c_char) -> c_int;
5924
5925                 pub fn symlink(path1: *const c_char,
5926                                path2: *const c_char) -> c_int;
5927
5928                 pub fn ftruncate(fd: c_int, length: off_t) -> c_int;
5929             }
5930         }
5931
5932         pub mod signal {
5933             use types::os::arch::c95::c_int;
5934             use types::os::common::posix01::sighandler_t;
5935
5936             #[cfg(not(all(target_os = "android", target_arch = "arm")))]
5937             extern {
5938                 pub fn signal(signum: c_int,
5939                               handler: sighandler_t) -> sighandler_t;
5940             }
5941
5942             #[cfg(all(target_os = "android", target_arch = "arm"))]
5943             extern {
5944                 #[link_name = "bsd_signal"]
5945                 pub fn signal(signum: c_int,
5946                               handler: sighandler_t) -> sighandler_t;
5947             }
5948         }
5949
5950         pub mod glob {
5951             use types::os::arch::c95::{c_char, c_int};
5952             use types::os::common::posix01::{glob_t};
5953
5954             extern {
5955                 pub fn glob(pattern: *const c_char,
5956                             flags: c_int,
5957                             errfunc: ::core::option::Option<extern "C" fn(epath: *const c_char,
5958                                                               errno: c_int) -> c_int>,
5959                             pglob: *mut glob_t);
5960                 pub fn globfree(pglob: *mut glob_t);
5961             }
5962         }
5963
5964         pub mod mman {
5965             use types::common::c95::{c_void};
5966             use types::os::arch::c95::{c_int, size_t};
5967
5968             #[cfg(not(target_os = "nacl"))]
5969             extern {
5970                 pub fn posix_madvise(addr: *mut c_void,
5971                                      len: size_t,
5972                                      advice: c_int)
5973                                      -> c_int;
5974             }
5975         }
5976
5977         pub mod resource {
5978             use types::os::arch::c95::c_int;
5979             use types::os::common::posix01::rlimit;
5980             use types::os::common::bsd43::rusage;
5981             extern {
5982                 pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int;
5983                 pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int;
5984                 pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int;
5985
5986             }
5987         }
5988     }
5989
5990     #[cfg(target_os = "windows")]
5991     pub mod posix01 {
5992         pub mod stat_ {
5993         }
5994
5995         pub mod unistd {
5996         }
5997
5998         pub mod glob {
5999         }
6000
6001         pub mod mman {
6002         }
6003
6004         pub mod net {
6005         }
6006     }
6007
6008
6009     #[cfg(any(target_os = "windows",
6010               target_os = "linux",
6011               target_os = "android",
6012               target_os = "macos",
6013               target_os = "ios",
6014               target_os = "freebsd",
6015               target_os = "dragonfly",
6016               target_os = "bitrig",
6017               target_os = "openbsd",
6018               target_os = "nacl"))]
6019     pub mod posix08 {
6020         pub mod unistd {
6021         }
6022     }
6023
6024     #[cfg(not(windows))]
6025     pub mod bsd43 {
6026         use types::common::c95::{c_void};
6027         use types::os::common::bsd44::{socklen_t, sockaddr, ifaddrs};
6028         use types::os::arch::c95::{c_int, size_t};
6029         use types::os::arch::posix88::ssize_t;
6030
6031         extern "system" {
6032             pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
6033             pub fn connect(socket: c_int, address: *const sockaddr,
6034                            len: socklen_t) -> c_int;
6035             pub fn bind(socket: c_int, address: *const sockaddr,
6036                         address_len: socklen_t) -> c_int;
6037             pub fn listen(socket: c_int, backlog: c_int) -> c_int;
6038             pub fn accept(socket: c_int, address: *mut sockaddr,
6039                           address_len: *mut socklen_t) -> c_int;
6040             pub fn getpeername(socket: c_int, address: *mut sockaddr,
6041                                address_len: *mut socklen_t) -> c_int;
6042             pub fn getsockname(socket: c_int, address: *mut sockaddr,
6043                                address_len: *mut socklen_t) -> c_int;
6044             pub fn setsockopt(socket: c_int, level: c_int, name: c_int,
6045                               value: *const c_void,
6046                               option_len: socklen_t) -> c_int;
6047             pub fn recv(socket: c_int, buf: *mut c_void, len: size_t,
6048                         flags: c_int) -> ssize_t;
6049             pub fn send(socket: c_int, buf: *const c_void, len: size_t,
6050                         flags: c_int) -> ssize_t;
6051             pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t,
6052                             flags: c_int, addr: *mut sockaddr,
6053                             addrlen: *mut socklen_t) -> ssize_t;
6054             pub fn sendto(socket: c_int, buf: *const c_void, len: size_t,
6055                           flags: c_int, addr: *const sockaddr,
6056                           addrlen: socklen_t) -> ssize_t;
6057             pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int;
6058             pub fn freeifaddrs(ifa: *mut ifaddrs);
6059             pub fn shutdown(socket: c_int, how: c_int) -> c_int;
6060         }
6061     }
6062
6063     #[cfg(windows)]
6064     pub mod bsd43 {
6065         use types::common::c95::{c_void};
6066         use types::os::common::bsd44::{socklen_t, sockaddr, SOCKET};
6067         use types::os::arch::c95::c_int;
6068         use types::os::arch::posix88::ssize_t;
6069
6070         extern "system" {
6071             pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET;
6072             pub fn connect(socket: SOCKET, address: *const sockaddr,
6073                            len: socklen_t) -> c_int;
6074             pub fn bind(socket: SOCKET, address: *const sockaddr,
6075                         address_len: socklen_t) -> c_int;
6076             pub fn listen(socket: SOCKET, backlog: c_int) -> c_int;
6077             pub fn accept(socket: SOCKET, address: *mut sockaddr,
6078                           address_len: *mut socklen_t) -> SOCKET;
6079             pub fn getpeername(socket: SOCKET, address: *mut sockaddr,
6080                                address_len: *mut socklen_t) -> c_int;
6081             pub fn getsockname(socket: SOCKET, address: *mut sockaddr,
6082                                address_len: *mut socklen_t) -> c_int;
6083             pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int,
6084                               value: *const c_void,
6085                               option_len: socklen_t) -> c_int;
6086             pub fn closesocket(socket: SOCKET) -> c_int;
6087             pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int,
6088                         flags: c_int) -> c_int;
6089             pub fn send(socket: SOCKET, buf: *const c_void, len: c_int,
6090                         flags: c_int) -> c_int;
6091             pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int,
6092                             flags: c_int, addr: *mut sockaddr,
6093                             addrlen: *mut c_int) -> ssize_t;
6094             pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int,
6095                           flags: c_int, addr: *const sockaddr,
6096                           addrlen: c_int) -> c_int;
6097             pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
6098         }
6099     }
6100
6101     #[cfg(any(target_os = "macos",
6102               target_os = "ios",
6103               target_os = "freebsd",
6104               target_os = "dragonfly",
6105               target_os = "bitrig",
6106               target_os = "openbsd"))]
6107     pub mod bsd44 {
6108         use types::common::c95::{c_void};
6109         use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t};
6110
6111         extern {
6112             pub fn ioctl(d: c_int, request: c_ulong, ...) -> c_int;
6113             pub fn sysctl(name: *mut c_int,
6114                           namelen: c_uint,
6115                           oldp: *mut c_void,
6116                           oldlenp: *mut size_t,
6117                           newp: *mut c_void,
6118                           newlen: size_t)
6119                           -> c_int;
6120             pub fn sysctlbyname(name: *const c_char,
6121                                 oldp: *mut c_void,
6122                                 oldlenp: *mut size_t,
6123                                 newp: *mut c_void,
6124                                 newlen: size_t)
6125                                 -> c_int;
6126             pub fn sysctlnametomib(name: *const c_char,
6127                                    mibp: *mut c_int,
6128                                    sizep: *mut size_t)
6129                                    -> c_int;
6130             pub fn getdtablesize() -> c_int;
6131             pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)
6132                            -> c_int;
6133             pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
6134                            -> c_int;
6135             pub fn realpath(pathname: *const c_char, resolved: *mut c_char)
6136                             -> *mut c_char;
6137         }
6138     }
6139
6140     #[cfg(any(target_os = "linux", target_os = "android"))]
6141     pub mod bsd44 {
6142         use types::common::c95::{c_void};
6143         use types::os::arch::c95::{c_uchar, c_int, size_t};
6144
6145         extern {
6146             #[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
6147             pub fn getdtablesize() -> c_int;
6148             pub fn ioctl(d: c_int, request: c_int, ...) -> c_int;
6149             pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)
6150                            -> c_int;
6151             pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar)
6152                            -> c_int;
6153         }
6154     }
6155
6156     #[cfg(target_os = "nacl")]
6157     pub mod bsd44 {
6158         use types::os::arch::c95::c_int;
6159         extern {
6160             pub fn getdtablesize() -> c_int;
6161         }
6162     }
6163
6164     #[cfg(target_os = "windows")]
6165     pub mod bsd44 {
6166     }
6167
6168     #[cfg(any(target_os = "macos", target_os = "ios"))]
6169     pub mod extra {
6170         use types::os::arch::c95::{c_char, c_int};
6171
6172         extern {
6173             pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
6174                                         -> c_int;
6175         }
6176     }
6177
6178     #[cfg(any(target_os = "freebsd",
6179               target_os = "dragonfly",
6180               target_os = "bitrig",
6181               target_os = "openbsd"))]
6182     pub mod extra {
6183     }
6184
6185     #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))]
6186     pub mod extra {
6187     }
6188
6189
6190     #[cfg(target_os = "windows")]
6191     pub mod extra {
6192
6193         pub mod kernel32 {
6194             use types::os::arch::c95::{c_uint};
6195             use types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE,
6196                                                LPCWSTR, LPWSTR,
6197                                                LPWCH, LPDWORD, LPVOID,
6198                                                LPCVOID, LPOVERLAPPED,
6199                                                LPSECURITY_ATTRIBUTES,
6200                                                LPSTARTUPINFO,
6201                                                LPPROCESS_INFORMATION,
6202                                                LPMEMORY_BASIC_INFORMATION,
6203                                                LPSYSTEM_INFO, HANDLE, LPHANDLE,
6204                                                LARGE_INTEGER, PLARGE_INTEGER,
6205                                                LPFILETIME, LPWIN32_FIND_DATAW};
6206
6207             extern "system" {
6208                 pub fn GetEnvironmentVariableW(n: LPCWSTR,
6209                                                v: LPWSTR,
6210                                                nsize: DWORD)
6211                                                -> DWORD;
6212                 pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
6213                                                -> BOOL;
6214                 pub fn GetEnvironmentStringsW() -> LPWCH;
6215                 pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL;
6216                 pub fn GetModuleFileNameW(hModule: HMODULE,
6217                                           lpFilename: LPWSTR,
6218                                           nSize: DWORD)
6219                                           -> DWORD;
6220                 pub fn CreateDirectoryW(lpPathName: LPCWSTR,
6221                                         lpSecurityAttributes:
6222                                         LPSECURITY_ATTRIBUTES)
6223                                         -> BOOL;
6224                 pub fn CopyFileW(lpExistingFileName: LPCWSTR,
6225                                  lpNewFileName: LPCWSTR,
6226                                  bFailIfExists: BOOL)
6227                                  -> BOOL;
6228                 pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
6229                 pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
6230                 pub fn GetCurrentDirectoryW(nBufferLength: DWORD,
6231                                             lpBuffer: LPWSTR)
6232                                             -> DWORD;
6233                 pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
6234                 pub fn GetLastError() -> DWORD;
6235                 pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW)
6236                                       -> HANDLE;
6237                 pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW)
6238                                      -> BOOL;
6239                 pub fn FindClose(findFile: HANDLE) -> BOOL;
6240                 pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
6241                                        hSourceHandle: HANDLE,
6242                                        hTargetProcessHandle: HANDLE,
6243                                        lpTargetHandle: LPHANDLE,
6244                                        dwDesiredAccess: DWORD,
6245                                        bInheritHandle: BOOL,
6246                                        dwOptions: DWORD)
6247                                        -> BOOL;
6248                 pub fn CloseHandle(hObject: HANDLE) -> BOOL;
6249                 pub fn OpenProcess(dwDesiredAccess: DWORD,
6250                                    bInheritHandle: BOOL,
6251                                    dwProcessId: DWORD)
6252                                    -> HANDLE;
6253                 pub fn GetCurrentProcess() -> HANDLE;
6254                 pub fn CreateProcessW(lpApplicationName: LPCWSTR,
6255                                       lpCommandLine: LPWSTR,
6256                                       lpProcessAttributes:
6257                                       LPSECURITY_ATTRIBUTES,
6258                                       lpThreadAttributes:
6259                                       LPSECURITY_ATTRIBUTES,
6260                                       bInheritHandles: BOOL,
6261                                       dwCreationFlags: DWORD,
6262                                       lpEnvironment: LPVOID,
6263                                       lpCurrentDirectory: LPCWSTR,
6264                                       lpStartupInfo: LPSTARTUPINFO,
6265                                       lpProcessInformation:
6266                                       LPPROCESS_INFORMATION)
6267                                       -> BOOL;
6268                 pub fn WaitForSingleObject(hHandle: HANDLE,
6269                                            dwMilliseconds: DWORD)
6270                                            -> DWORD;
6271                 pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint)
6272                                         -> BOOL;
6273                 pub fn GetExitCodeProcess(hProcess: HANDLE,
6274                                           lpExitCode: LPDWORD)
6275                                           -> BOOL;
6276                 pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO);
6277                 pub fn VirtualAlloc(lpAddress: LPVOID,
6278                                     dwSize: SIZE_T,
6279                                     flAllocationType: DWORD,
6280                                     flProtect: DWORD)
6281                                     -> LPVOID;
6282                 pub fn VirtualFree(lpAddress: LPVOID,
6283                                    dwSize: SIZE_T,
6284                                    dwFreeType: DWORD)
6285                                    -> BOOL;
6286                 pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL;
6287                 pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T)
6288                                      -> BOOL;
6289                 pub fn VirtualProtect(lpAddress: LPVOID,
6290                                       dwSize: SIZE_T,
6291                                       flNewProtect: DWORD,
6292                                       lpflOldProtect: LPDWORD)
6293                                       -> BOOL;
6294                 pub fn VirtualQuery(lpAddress: LPCVOID,
6295                                     lpBuffer: LPMEMORY_BASIC_INFORMATION,
6296                                     dwLength: SIZE_T)
6297                                     -> SIZE_T;
6298                 pub fn CreateFileMappingW(hFile: HANDLE,
6299                                           lpAttributes: LPSECURITY_ATTRIBUTES,
6300                                           flProtect: DWORD,
6301                                           dwMaximumSizeHigh: DWORD,
6302                                           dwMaximumSizeLow: DWORD,
6303                                           lpName: LPCWSTR)
6304                                           -> HANDLE;
6305                 pub fn MapViewOfFile(hFileMappingObject: HANDLE,
6306                                      dwDesiredAccess: DWORD,
6307                                      dwFileOffsetHigh: DWORD,
6308                                      dwFileOffsetLow: DWORD,
6309                                      dwNumberOfBytesToMap: SIZE_T)
6310                                      -> LPVOID;
6311                 pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL;
6312                 pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
6313                                    lpNewFileName: LPCWSTR,
6314                                    dwFlags: DWORD) -> BOOL;
6315                 pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
6316                                        lpTargetFileName: LPCWSTR,
6317                                        lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
6318                                         -> BOOL;
6319                 pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL;
6320                 pub fn CreateFileW(lpFileName: LPCWSTR,
6321                                    dwDesiredAccess: DWORD,
6322                                    dwShareMode: DWORD,
6323                                    lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
6324                                    dwCreationDisposition: DWORD,
6325                                    dwFlagsAndAttributes: DWORD,
6326                                    hTemplateFile: HANDLE) -> HANDLE;
6327                 pub fn ReadFile(hFile: HANDLE,
6328                                 lpBuffer: LPVOID,
6329                                 nNumberOfBytesToRead: DWORD,
6330                                 lpNumberOfBytesRead: LPDWORD,
6331                                 lpOverlapped: LPOVERLAPPED) -> BOOL;
6332                 pub fn WriteFile(hFile: HANDLE,
6333                                  lpBuffer: LPVOID,
6334                                  nNumberOfBytesToRead: DWORD,
6335                                  lpNumberOfBytesRead: LPDWORD,
6336                                  lpOverlapped: LPOVERLAPPED) -> BOOL;
6337                 pub fn SetFilePointerEx(hFile: HANDLE,
6338                                         liDistanceToMove: LARGE_INTEGER,
6339                                         lpNewFilePointer: PLARGE_INTEGER,
6340                                         dwMoveMethod: DWORD) -> BOOL;
6341                 pub fn SetEndOfFile(hFile: HANDLE) -> BOOL;
6342
6343                 pub fn GetSystemTimeAsFileTime(
6344                             lpSystemTimeAsFileTime: LPFILETIME);
6345
6346                 pub fn QueryPerformanceFrequency(
6347                             lpFrequency: *mut LARGE_INTEGER) -> BOOL;
6348                 pub fn QueryPerformanceCounter(
6349                             lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL;
6350
6351                 pub fn GetCurrentProcessId() -> DWORD;
6352                 pub fn CreateNamedPipeW(
6353                             lpName: LPCWSTR,
6354                             dwOpenMode: DWORD,
6355                             dwPipeMode: DWORD,
6356                             nMaxInstances: DWORD,
6357                             nOutBufferSize: DWORD,
6358                             nInBufferSize: DWORD,
6359                             nDefaultTimeOut: DWORD,
6360                             lpSecurityAttributes: LPSECURITY_ATTRIBUTES
6361                             ) -> HANDLE;
6362                 pub fn ConnectNamedPipe(hNamedPipe: HANDLE,
6363                                         lpOverlapped: LPOVERLAPPED) -> BOOL;
6364                 pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR,
6365                                       nTimeOut: DWORD) -> BOOL;
6366                 pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE,
6367                                                lpMode: LPDWORD,
6368                                                lpMaxCollectionCount: LPDWORD,
6369                                                lpCollectDataTimeout: LPDWORD)
6370                                                             -> BOOL;
6371                 pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES,
6372                                     bManualReset: BOOL,
6373                                     bInitialState: BOOL,
6374                                     lpName: LPCWSTR) -> HANDLE;
6375                 pub fn GetOverlappedResult(hFile: HANDLE,
6376                                            lpOverlapped: LPOVERLAPPED,
6377                                            lpNumberOfBytesTransferred: LPDWORD,
6378                                            bWait: BOOL) -> BOOL;
6379                 pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL;
6380             }
6381         }
6382
6383         pub mod msvcrt {
6384             use types::os::arch::c95::{c_int, c_long};
6385             use types::os::arch::c99::intptr_t;
6386
6387             extern {
6388                 #[link_name = "_commit"]
6389                 pub fn commit(fd: c_int) -> c_int;
6390
6391                 #[link_name = "_get_osfhandle"]
6392                 pub fn get_osfhandle(fd: c_int) -> c_long;
6393
6394                 #[link_name = "_open_osfhandle"]
6395                 pub fn open_osfhandle(osfhandle: intptr_t,
6396                                       flags: c_int) -> c_int;
6397             }
6398         }
6399
6400         pub mod winsock {
6401             use types::os::arch::c95::{c_int, c_long, c_ulong};
6402             use types::os::common::bsd44::SOCKET;
6403
6404             extern "system" {
6405                 pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int;
6406             }
6407         }
6408     }
6409 }
6410
6411 #[doc(hidden)]
6412 pub fn issue_14344_workaround() {} // FIXME #14344 force linkage to happen correctly
6413
6414 #[test] fn work_on_windows() { } // FIXME #10872 needed for a happy windows