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