From dafaca90f0950c17e81e420172b9661c77d128fb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 21:50:47 -0700 Subject: [PATCH 001/194] Initial import of liblibc --- .gitmodules | 3 - Cargo.toml | 9 - rust | 1 - src/lib.rs | 6509 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 6509 insertions(+), 13 deletions(-) delete mode 160000 rust create mode 100644 src/lib.rs diff --git a/.gitmodules b/.gitmodules index 8822b0ca7dc25..e69de29bb2d1d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "rust"] - path = rust - url = https://github.com/rust-lang/rust diff --git a/Cargo.toml b/Cargo.toml index fa79c0f9af611..e6b56d4bc5c6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,12 +12,3 @@ description = """ A library for types and bindings to native C functions often found in libc or other common platform libraries. """ -include = ["Cargo.toml", "rust/src/liblibc/*"] - -[features] -default = ["cargo-build"] -cargo-build = [] - -[lib] -name = "libc" -path = "rust/src/liblibc/lib.rs" diff --git a/rust b/rust deleted file mode 160000 index 753a6a9e29d4c..0000000000000 --- a/rust +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 753a6a9e29d4c8b4ee92345051fef61908c276b6 diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000000000..e9a6bef823aff --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,6509 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/", + html_playground_url = "https://play.rust-lang.org/")] + +//! Bindings for the C standard library and other platform libraries +//! +//! **NOTE:** These are *architecture and libc* specific. On Linux, these +//! bindings are only correct for glibc. +//! +//! This module contains bindings to the C standard library, organized into +//! modules by their defining standard. Additionally, it contains some assorted +//! platform-specific definitions. For convenience, most functions and types +//! are reexported, so `use libc::*` will import the available C bindings as +//! appropriate for the target platform. The exact set of functions available +//! are platform specific. +//! +//! *Note:* Because these definitions are platform-specific, some may not appear +//! in the generated documentation. +//! +//! We consider the following specs reasonably normative with respect to +//! interoperating with the C standard library (libc/msvcrt): +//! +//! * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995. +//! * ISO 9899:1999 ('C99' or 'C9x'). +//! * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1'). +//! * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3'). +//! * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4'). +//! +//! Note that any reference to the 1996 revision of POSIX, or any revs between +//! 1990 (when '88 was approved at ISO) and 2001 (when the next actual +//! revision-revision happened), are merely additions of other chapters (1b and +//! 1c) outside the core interfaces. +//! +//! Despite having several names each, these are *reasonably* coherent +//! point-in-time, list-of-definition sorts of specs. You can get each under a +//! variety of names but will wind up with the same definition in each case. +//! +//! See standards(7) in linux-manpages for more details. +//! +//! Our interface to these libraries is complicated by the non-universality of +//! conformance to any of them. About the only thing universally supported is +//! the first (C95), beyond that definitions quickly become absent on various +//! platforms. +//! +//! We therefore wind up dividing our module-space up (mostly for the sake of +//! sanity while editing, filling-in-details and eliminating duplication) into +//! definitions common-to-all (held in modules named c95, c99, posix88, posix01 +//! and posix08) and definitions that appear only on *some* platforms (named +//! 'extra'). This would be things like significant OSX foundation kit, or Windows +//! library kernel32.dll, or various fancy glibc, Linux or BSD extensions. +//! +//! In addition to the per-platform 'extra' modules, we define a module of +//! 'common BSD' libc routines that never quite made it into POSIX but show up +//! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final +//! one from Berkeley after the lawsuits died down and the CSRG dissolved. + +#![allow(bad_style, raw_pointer_derive)] + +// Explicit export lists for the intersection (provided here) mean that +// you can write more-platform-agnostic code if you stick to just these +// symbols. + +pub use types::common::c95::*; +pub use types::common::c99::*; +pub use types::common::posix88::*; +pub use types::os::common::posix01::*; +pub use types::os::common::bsd44::*; +pub use types::os::arch::c95::*; +pub use types::os::arch::c99::*; +pub use types::os::arch::posix88::*; +pub use types::os::arch::posix01::*; +pub use types::os::arch::extra::*; + +pub use consts::os::c95::*; +pub use consts::os::posix88::*; +pub use consts::os::posix01::*; +pub use consts::os::bsd44::*; +pub use consts::os::extra::*; + +pub use funcs::c95::ctype::*; +pub use funcs::c95::stdio::*; +pub use funcs::c95::stdlib::*; +pub use funcs::c95::string::*; +pub use funcs::posix88::fcntl::*; +pub use funcs::posix88::stat_::*; +pub use funcs::posix88::stdio::*; +pub use funcs::posix88::unistd::*; + +pub use funcs::bsd43::*; + +// But we also reexport most everything +// if you're interested in writing platform-specific code. + +// FIXME: This is a mess, but the design of this entire module needs to be +// reconsidered, so I'm not inclined to do better right now. As part of +// #11870 I removed all the pub globs here, leaving explicit reexports +// of everything that is actually used in-tree. +// +// So the following exports don't follow any particular plan. + +#[cfg(unix)] pub use consts::os::sysconf::*; + +#[cfg(unix)] pub use funcs::posix88::mman::*; +#[cfg(unix)] pub use funcs::posix88::dirent::*; +#[cfg(unix)] pub use funcs::posix88::net::*; +#[cfg(unix)] pub use funcs::posix01::stat_::*; +#[cfg(unix)] pub use funcs::posix01::unistd::*; +#[cfg(unix)] pub use funcs::posix01::resource::*; + + +#[cfg(windows)] pub use funcs::extra::kernel32::*; +#[cfg(windows)] pub use funcs::extra::winsock::*; +#[cfg(windows)] pub use funcs::extra::msvcrt::*; + +// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them +// in when creating a test crate. +#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))] +#[link(name = "c")] +#[link(name = "m")] +extern {} + +// When compiling rust with musl, statically include libc.a in liblibc.rlib. +// A cargo build of the libc crate will therefore automatically pick up the +// libc.a symbols because liblibc is transitively linked to by the stdlib. +#[cfg(all(target_env = "musl", not(feature = "cargo-build"), not(test)))] +#[link(name = "c", kind = "static")] +extern {} + +#[cfg(all(windows, target_env = "msvc"))] +#[link(name = "kernel32")] +#[link(name = "shell32")] +#[link(name = "msvcrt")] +extern {} + +// libnacl provides functions that require a trip through the IRT to work. +// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip +// to the kernel. +#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] +#[link(name = "nacl", kind = "static")] +extern {} + +// pnaclmm provides a number of functions that the toolchain's Clang emits calls +// to when codegening atomic ops. All the functions within wrap various atomic +// operations. +// Yes, it could be linked by rustc explicitly, however by linking it here +// instead we save a bit of time where bins are involved (by not running the +// optimizations on the whole pnaclmm foreach binary built). +#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] +#[link(name = "pnaclmm", kind = "static")] +extern {} + +pub mod types { + + // Types tend to vary *per architecture* so we pull their definitions out + // into this module. + + // Standard types that are opaque or common, so are not per-target. + pub mod common { + pub mod c95 { + /// Type used to construct void pointers for use with C. + /// + /// This type is only useful as a pointer target. Do not use it as a + /// return type for FFI functions which have the `void` return type in + /// C. Use the unit type `()` or omit the return type instead. + /// + /// For LLVM to recognize the void pointer type and by extension + /// functions like malloc(), we need to have it represented as i8* in + /// LLVM bitcode. The enum used here ensures this and prevents misuse + /// of the "raw" type by only having private variants.. We need two + /// variants, because the compiler complains about the repr attribute + /// otherwise. + #[repr(u8)] + pub enum c_void { + __variant1, + __variant2, + } + + pub enum FILE {} + pub enum fpos_t {} + } + pub mod c99 { + pub type int8_t = i8; + pub type int16_t = i16; + pub type int32_t = i32; + pub type int64_t = i64; + pub type uint8_t = u8; + pub type uint16_t = u16; + pub type uint32_t = u32; + pub type uint64_t = u64; + } + pub mod posix88 { + pub enum DIR {} + pub enum dirent_t {} + } + pub mod posix01 {} + pub mod posix08 {} + pub mod bsd44 {} + } + + // Standard types that are scalar but vary by OS and arch. + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_ulong, size_t, + time_t, suseconds_t, c_long}; + + #[cfg(not(target_os = "nacl"))] + pub type pthread_t = c_ulong; + #[cfg(target_os = "nacl")] + pub type pthread_t = *mut c_void; + pub type rlim_t = u64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + + pub __unused1: *mut c_void, + pub __unused2: *mut c_void, + pub __unused3: *mut c_void, + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + // This is also specified in POSIX 2001, but only has two fields. All implementors + // implement BSD 4.3 version. + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u16; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_family: sa_family_t, + pub __ss_align: isize, + #[cfg(target_pointer_width = "32")] + pub __ss_pad2: [u8; 128 - 2 * 4], + #[cfg(target_pointer_width = "64")] + pub __ss_pad2: [u8; 128 - 2 * 8], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + + #[cfg(target_os = "linux")] + pub ai_addr: *mut sockaddr, + + #[cfg(target_os = "linux")] + pub ai_canonname: *mut c_char, + + #[cfg(any(target_os = "android", target_os = "nacl"))] + pub ai_canonname: *mut c_char, + + #[cfg(any(target_os = "android", target_os = "nacl"))] + pub ai_addr: *mut sockaddr, + + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_ifu: *mut sockaddr, // FIXME This should be a union + pub ifa_data: *mut c_void + } + + } + } + + #[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel", + target_arch = "powerpc", + target_arch = "le32"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u32; + pub type ptrdiff_t = i32; + pub type clock_t = i32; + pub type time_t = i32; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i32; + pub type uintptr_t = u32; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + #[cfg(any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "powerpc", + target_arch = "le32", + all(any(target_arch = "arm", target_arch = "x86"), + not(target_os = "android"))))] + pub mod posix88 { + pub type off_t = i32; + pub type dev_t = u64; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u32; + pub type ssize_t = i32; + } + #[cfg(all(any(target_arch = "arm", target_arch = "x86"), + target_os = "android"))] + pub mod posix88 { + pub type off_t = i32; + pub type dev_t = u32; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i32; + } + #[cfg(any(target_arch = "x86", + target_arch = "le32", + target_arch = "powerpc", + all(any(target_arch = "arm", target_arch = "x86"), + not(target_os = "android"))))] + pub mod posix01 { + use types::os::arch::c95::{c_short, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u32; + pub type blksize_t = i32; + pub type blkcnt_t = i32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub __pad1: c_short, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad2: c_short, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub __unused4: c_long, + pub __unused5: c_long, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u32; 9] + } + } + #[cfg(all(any(target_arch = "arm", target_arch = "x86"), + target_os = "android"))] + pub mod posix01 { + use types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t}; + use types::os::arch::c99::{c_longlong, c_ulonglong}; + use types::os::arch::posix88::{uid_t, gid_t, ino_t}; + + pub type nlink_t = u16; + pub type blksize_t = u32; + pub type blkcnt_t = u32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: c_ulonglong, + pub __pad0: [c_uchar; 4], + pub __st_ino: ino_t, + pub st_mode: c_uint, + pub st_nlink: c_uint, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: c_ulonglong, + pub __pad3: [c_uchar; 4], + pub st_size: c_longlong, + pub st_blksize: blksize_t, + pub st_blocks: c_ulonglong, + pub st_atime: time_t, + pub st_atime_nsec: c_ulong, + pub st_mtime: time_t, + pub st_mtime_nsec: c_ulong, + pub st_ctime: time_t, + pub st_ctime_nsec: c_ulong, + pub st_ino: c_ulonglong, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u32; 9] + } + } + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod posix01 { + use types::os::arch::c95::{c_long, c_ulong, time_t}; + use types::os::arch::posix88::{gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u32; + pub type blksize_t = i32; + pub type blkcnt_t = i32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: c_ulong, + pub st_pad1: [c_long; 3], + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: c_ulong, + pub st_pad2: [c_long; 2], + pub st_size: off_t, + pub st_pad3: c_long, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_pad5: [c_long; 14], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u32; 9] + } + } + pub mod posix08 {} + pub mod bsd44 {} + pub mod extra { + use types::os::arch::c95::{c_ushort, c_int, c_uchar}; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_ll { + pub sll_family: c_ushort, + pub sll_protocol: c_ushort, + pub sll_ifindex: c_int, + pub sll_hatype: c_ushort, + pub sll_pkttype: c_uchar, + pub sll_halen: c_uchar, + pub sll_addr: [c_uchar; 8] + } + } + + } + + #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64"))] + pub mod arch { + pub mod c95 { + #[cfg(not(target_arch = "aarch64"))] + pub type c_char = i8; + #[cfg(target_arch = "aarch64")] + pub type c_char = u8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i64; + pub type time_t = i64; + pub type suseconds_t = i64; + #[cfg(not(target_arch = "aarch64"))] + pub type wchar_t = i32; + #[cfg(target_arch = "aarch64")] + pub type wchar_t = u32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u64; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u32; + pub type ssize_t = i64; + } + #[cfg(not(target_arch = "aarch64"))] + pub mod posix01 { + use types::os::arch::c95::{c_int, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u64; + pub type blksize_t = i64; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_mode: mode_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub __pad0: c_int, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub __unused: [c_long; 3], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u64; 7] + } + } + #[cfg(target_arch = "aarch64")] + pub mod posix01 { + use types::os::arch::c95::{c_int, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u32; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad1: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub __pad2: c_int, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub __unused: [c_int; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct pthread_attr_t { + pub __size: [u64; 8] + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + use types::os::arch::c95::{c_ushort, c_int, c_uchar}; + #[derive(Copy, Clone)] pub struct sockaddr_ll { + pub sll_family: c_ushort, + pub sll_protocol: c_ushort, + pub sll_ifindex: c_int, + pub sll_hatype: c_ushort, + pub sll_pkttype: c_uchar, + pub sll_halen: c_uchar, + pub sll_addr: [c_uchar; 8] + } + + } + } + } + + #[cfg(target_os = "freebsd")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub __unused1: size_t, + pub gl_offs: size_t, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + + + } + } + + #[cfg(target_arch = "x86")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u32; + pub type ptrdiff_t = i32; + pub type clock_t = i32; + pub type time_t = i32; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i32; + pub type uintptr_t = u32; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u32; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i32; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint32_t, int32_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = u32; + pub type blkcnt_t = i64; + pub type fflags_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub __unused: [u8; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i32; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u32; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i64; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint32_t, int32_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = u32; + pub type blkcnt_t = i64; + pub type fflags_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + + #[cfg(target_os = "dragonfly")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub __unused1: size_t, + pub gl_offs: size_t, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i32; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i64; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint16_t, uint32_t, int32_t, uint64_t, int64_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = uint32_t; + pub type ino_t = uint64_t; + pub type blkcnt_t = i64; + pub type fflags_t = u32; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_padding1: uint16_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare1: int64_t, + pub st_qspare2: int64_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + + #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = u64; + + #[cfg(target_os = "bitrig")] + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: c_int, + pub gl_matchc: c_int, + pub gl_offs: c_int, + pub gl_flags: c_int, + pub gl_pathv: *mut *mut c_char, + pub __unused1: *mut c_void, + pub __unused2: *mut c_void, + pub __unused3: *mut c_void, + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + } + + #[cfg(any(target_os = "netbsd", target_os="openbsd"))] + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: c_int, + pub __unused1: c_int, + pub gl_offs: c_int, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + pub __unused9: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_pad2: i64, + pub __ss_pad3: [u8; 240], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i64; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::{c_long}; + pub type off_t = i64; + pub type dev_t = i32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u32; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint32_t, uint64_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = uint32_t; + pub type blksize_t = uint32_t; + pub type ino_t = uint64_t; + pub type blkcnt_t = i64; + pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_mode: mode_t, + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + + #[cfg(target_os = "windows")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::os::arch::c95::{c_short, time_t, c_long}; + use types::os::arch::extra::{int64, time64_t}; + use types::os::arch::posix88::{dev_t, ino_t}; + + // pub Note: this is the struct called stat64 in Windows. Not stat, + // nor stati64. + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: u16, + pub st_nlink: c_short, + pub st_uid: c_short, + pub st_gid: c_short, + pub st_rdev: dev_t, + pub st_size: int64, + pub st_atime: time64_t, + pub st_mtime: time64_t, + pub st_ctime: time64_t, + } + + // note that this is called utimbuf64 in Windows + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time64_t, + pub modtime: time64_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + } + + pub mod bsd44 { + use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; + use types::os::arch::c99::uintptr_t; + + pub type SOCKET = uintptr_t; + pub type socklen_t = c_int; + pub type sa_family_t = u16; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: size_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + } + } + + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + + #[cfg(target_arch = "x86")] + pub type size_t = u32; + #[cfg(target_arch = "x86_64")] + pub type size_t = u64; + + #[cfg(target_arch = "x86")] + pub type ptrdiff_t = i32; + #[cfg(target_arch = "x86_64")] + pub type ptrdiff_t = i64; + + pub type clock_t = i32; + + #[cfg(target_arch = "x86")] + pub type time_t = i32; + #[cfg(target_arch = "x86_64")] + pub type time_t = i64; + + #[cfg(target_arch = "x86")] + pub type suseconds_t = i32; + #[cfg(target_arch = "x86_64")] + pub type suseconds_t = i64; + + pub type wchar_t = u16; + } + + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + + #[cfg(target_arch = "x86")] + pub type intptr_t = i32; + #[cfg(target_arch = "x86_64")] + pub type intptr_t = i64; + + #[cfg(target_arch = "x86")] + pub type uintptr_t = u32; + #[cfg(target_arch = "x86_64")] + pub type uintptr_t = u64; + + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + + pub mod posix88 { + pub type off_t = i32; + pub type dev_t = u32; + pub type ino_t = u16; + + pub type pid_t = u32; + + pub type useconds_t = u32; + pub type mode_t = u16; + + #[cfg(target_arch = "x86")] + pub type ssize_t = i32; + #[cfg(target_arch = "x86_64")] + pub type ssize_t = i64; + } + + pub mod posix01 { + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + use consts::os::extra::{MAX_PROTOCOL_CHAIN, + WSAPROTOCOL_LEN}; + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; + use types::os::arch::c95::{c_long, c_ulong}; + use types::os::arch::c95::{wchar_t}; + use types::os::arch::c99::{c_ulonglong, c_longlong, uintptr_t}; + + pub type BOOL = c_int; + pub type BYTE = u8; + pub type BOOLEAN = BYTE; + pub type CCHAR = c_char; + pub type CHAR = c_char; + + pub type DWORD = c_ulong; + pub type DWORDLONG = c_ulonglong; + + pub type HANDLE = LPVOID; + pub type HINSTANCE = HANDLE; + pub type HMODULE = HINSTANCE; + + pub type LONG = c_long; + pub type PLONG = *mut c_long; + + #[cfg(target_arch = "x86")] + pub type LONG_PTR = c_long; + #[cfg(target_arch = "x86_64")] + pub type LONG_PTR = i64; + + pub type LARGE_INTEGER = c_longlong; + pub type PLARGE_INTEGER = *mut c_longlong; + + pub type LPCWSTR = *const WCHAR; + pub type LPCSTR = *const CHAR; + + pub type LPWSTR = *mut WCHAR; + pub type LPSTR = *mut CHAR; + + pub type LPWCH = *mut WCHAR; + pub type LPCH = *mut CHAR; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct SECURITY_ATTRIBUTES { + pub nLength: DWORD, + pub lpSecurityDescriptor: LPVOID, + pub bInheritHandle: BOOL, + } + pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; + + pub type LPVOID = *mut c_void; + pub type LPCVOID = *const c_void; + pub type LPBYTE = *mut BYTE; + pub type LPWORD = *mut WORD; + pub type LPDWORD = *mut DWORD; + pub type LPHANDLE = *mut HANDLE; + + pub type LRESULT = LONG_PTR; + pub type PBOOL = *mut BOOL; + pub type WCHAR = wchar_t; + pub type WORD = u16; + pub type SIZE_T = size_t; + + pub type time64_t = i64; + pub type int64 = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct STARTUPINFO { + pub cb: DWORD, + pub lpReserved: LPWSTR, + pub lpDesktop: LPWSTR, + pub lpTitle: LPWSTR, + pub dwX: DWORD, + pub dwY: DWORD, + pub dwXSize: DWORD, + pub dwYSize: DWORD, + pub dwXCountChars: DWORD, + pub dwYCountCharts: DWORD, + pub dwFillAttribute: DWORD, + pub dwFlags: DWORD, + pub wShowWindow: WORD, + pub cbReserved2: WORD, + pub lpReserved2: LPBYTE, + pub hStdInput: HANDLE, + pub hStdOutput: HANDLE, + pub hStdError: HANDLE, + } + pub type LPSTARTUPINFO = *mut STARTUPINFO; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION { + pub hProcess: HANDLE, + pub hThread: HANDLE, + pub dwProcessId: DWORD, + pub dwThreadId: DWORD, + } + pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct SYSTEM_INFO { + pub wProcessorArchitecture: WORD, + pub wReserved: WORD, + pub dwPageSize: DWORD, + pub lpMinimumApplicationAddress: LPVOID, + pub lpMaximumApplicationAddress: LPVOID, + pub dwActiveProcessorMask: uintptr_t, + pub dwNumberOfProcessors: DWORD, + pub dwProcessorType: DWORD, + pub dwAllocationGranularity: DWORD, + pub wProcessorLevel: WORD, + pub wProcessorRevision: WORD, + } + pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct MEMORY_BASIC_INFORMATION { + pub BaseAddress: LPVOID, + pub AllocationBase: LPVOID, + pub AllocationProtect: DWORD, + pub RegionSize: SIZE_T, + pub State: DWORD, + pub Protect: DWORD, + pub Type: DWORD, + } + pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct OVERLAPPED { + pub Internal: *mut c_ulong, + pub InternalHigh: *mut c_ulong, + pub Offset: DWORD, + pub OffsetHigh: DWORD, + pub hEvent: HANDLE, + } + + pub type LPOVERLAPPED = *mut OVERLAPPED; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct FILETIME { + pub dwLowDateTime: DWORD, + pub dwHighDateTime: DWORD, + } + + pub type LPFILETIME = *mut FILETIME; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct GUID { + pub Data1: DWORD, + pub Data2: WORD, + pub Data3: WORD, + pub Data4: [BYTE; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct WSAPROTOCOLCHAIN { + pub ChainLen: c_int, + pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], + } + + pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; + + #[repr(C)] + #[derive(Copy)] pub struct WSAPROTOCOL_INFO { + pub dwServiceFlags1: DWORD, + pub dwServiceFlags2: DWORD, + pub dwServiceFlags3: DWORD, + pub dwServiceFlags4: DWORD, + pub dwProviderFlags: DWORD, + pub ProviderId: GUID, + pub dwCatalogEntryId: DWORD, + pub ProtocolChain: WSAPROTOCOLCHAIN, + pub iVersion: c_int, + pub iAddressFamily: c_int, + pub iMaxSockAddr: c_int, + pub iMinSockAddr: c_int, + pub iSocketType: c_int, + pub iProtocol: c_int, + pub iProtocolMaxOffset: c_int, + pub iNetworkByteOrder: c_int, + pub iSecurityScheme: c_int, + pub dwMessageSize: DWORD, + pub dwProviderReserved: DWORD, + pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], + } + impl Clone for WSAPROTOCOL_INFO { + fn clone(&self) -> WSAPROTOCOL_INFO { *self } + } + + pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; + + pub type GROUP = c_uint; + + #[repr(C)] + #[derive(Copy)] pub struct WIN32_FIND_DATAW { + pub dwFileAttributes: DWORD, + pub ftCreationTime: FILETIME, + pub ftLastAccessTime: FILETIME, + pub ftLastWriteTime: FILETIME, + pub nFileSizeHigh: DWORD, + pub nFileSizeLow: DWORD, + pub dwReserved0: DWORD, + pub dwReserved1: DWORD, + pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 + pub cAlternateFileName: [wchar_t; 14], + } + impl Clone for WIN32_FIND_DATAW { + fn clone(&self) -> WIN32_FIND_DATAW { *self } + } + + pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; + } + } + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, size_t, time_t}; + use types::os::arch::c95::{suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = u64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + pub __unused1: c_int, + pub gl_offs: size_t, + pub __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + pub __unused3: *mut c_void, + + pub __unused4: *mut c_void, + pub __unused5: *mut c_void, + pub __unused6: *mut c_void, + pub __unused7: *mut c_void, + pub __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + pub __ss_pad1: [u8; 6], + pub __ss_align: i64, + pub __ss_pad2: [u8; 112], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8] + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + } + } + + #[cfg(any(target_arch = "arm", target_arch = "x86"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u32; + pub type ptrdiff_t = i32; + pub type clock_t = c_ulong; + pub type time_t = c_long; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i32; + pub type uintptr_t = u32; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::c_long; + + pub type off_t = i64; + pub type dev_t = i32; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c99::{int32_t, int64_t, uint32_t}; + use types::os::arch::c95::{c_char, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t, + mode_t, off_t, uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: uint32_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare: [int64_t; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy)] pub struct pthread_attr_t { + pub __sig: c_long, + pub __opaque: [c_char; 36] + } + impl Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + #[repr(C)] + #[derive(Copy, Clone)] pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub type mach_timebase_info_data_t = mach_timebase_info; + } + } + + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = c_ulong; + pub type time_t = c_long; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::c_long; + + pub type off_t = i64; + pub type dev_t = i32; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c99::{int32_t, int64_t}; + use types::common::c99::{uint32_t}; + use types::os::arch::c95::{c_char, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t, uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: uint32_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare: [int64_t; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy)] pub struct pthread_attr_t { + pub __sig: c_long, + pub __opaque: [c_char; 56] + } + impl Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + #[repr(C)] + #[derive(Copy, Clone)] pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub type mach_timebase_info_data_t = mach_timebase_info; + } + } + } +} + +pub mod consts { + // Consts tend to vary per OS so we pull their definitions out + // into this module. + + #[cfg(target_os = "windows")] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 32767; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 4; + pub const _IOLBF : c_int = 64; + pub const BUFSIZ : c_uint = 512; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 260; + pub const L_tmpnam : c_uint = 16; + pub const TMP_MAX : c_uint = 32767; + + pub const WSAEINTR: c_int = 10004; + pub const WSAEBADF: c_int = 10009; + pub const WSAEACCES: c_int = 10013; + pub const WSAEFAULT: c_int = 10014; + pub const WSAEINVAL: c_int = 10022; + pub const WSAEMFILE: c_int = 10024; + pub const WSAEWOULDBLOCK: c_int = 10035; + pub const WSAEINPROGRESS: c_int = 10036; + pub const WSAEALREADY: c_int = 10037; + pub const WSAENOTSOCK: c_int = 10038; + pub const WSAEDESTADDRREQ: c_int = 10039; + pub const WSAEMSGSIZE: c_int = 10040; + pub const WSAEPROTOTYPE: c_int = 10041; + pub const WSAENOPROTOOPT: c_int = 10042; + pub const WSAEPROTONOSUPPORT: c_int = 10043; + pub const WSAESOCKTNOSUPPORT: c_int = 10044; + pub const WSAEOPNOTSUPP: c_int = 10045; + pub const WSAEPFNOSUPPORT: c_int = 10046; + pub const WSAEAFNOSUPPORT: c_int = 10047; + pub const WSAEADDRINUSE: c_int = 10048; + pub const WSAEADDRNOTAVAIL: c_int = 10049; + pub const WSAENETDOWN: c_int = 10050; + pub const WSAENETUNREACH: c_int = 10051; + pub const WSAENETRESET: c_int = 10052; + pub const WSAECONNABORTED: c_int = 10053; + pub const WSAECONNRESET: c_int = 10054; + pub const WSAENOBUFS: c_int = 10055; + pub const WSAEISCONN: c_int = 10056; + pub const WSAENOTCONN: c_int = 10057; + pub const WSAESHUTDOWN: c_int = 10058; + pub const WSAETOOMANYREFS: c_int = 10059; + pub const WSAETIMEDOUT: c_int = 10060; + pub const WSAECONNREFUSED: c_int = 10061; + pub const WSAELOOP: c_int = 10062; + pub const WSAENAMETOOLONG: c_int = 10063; + pub const WSAEHOSTDOWN: c_int = 10064; + pub const WSAEHOSTUNREACH: c_int = 10065; + pub const WSAENOTEMPTY: c_int = 10066; + pub const WSAEPROCLIM: c_int = 10067; + pub const WSAEUSERS: c_int = 10068; + pub const WSAEDQUOT: c_int = 10069; + pub const WSAESTALE: c_int = 10070; + pub const WSAEREMOTE: c_int = 10071; + pub const WSASYSNOTREADY: c_int = 10091; + pub const WSAVERNOTSUPPORTED: c_int = 10092; + pub const WSANOTINITIALISED: c_int = 10093; + pub const WSAEDISCON: c_int = 10101; + pub const WSAENOMORE: c_int = 10102; + pub const WSAECANCELLED: c_int = 10103; + pub const WSAEINVALIDPROCTABLE: c_int = 10104; + pub const WSAEINVALIDPROVIDER: c_int = 10105; + pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; + } + pub mod c99 { + } + pub mod posix88 { + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 256; + pub const O_EXCL : c_int = 1024; + pub const O_TRUNC : c_int = 512; + pub const S_IFIFO : c_int = 4096; + pub const S_IFCHR : c_int = 8192; + pub const S_IFBLK : c_int = 12288; + pub const S_IFDIR : c_int = 16384; + pub const S_IFREG : c_int = 32768; + pub const S_IFLNK : c_int = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : c_int = 61440; + pub const S_IEXEC : c_int = 64; + pub const S_IWRITE : c_int = 128; + pub const S_IREAD : c_int = 256; + pub const S_IRWXU : c_int = 448; + pub const S_IXUSR : c_int = 64; + pub const S_IWUSR : c_int = 128; + pub const S_IRUSR : c_int = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + } + pub mod posix01 { + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 23; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 5; + pub const IPV6_DROP_MEMBERSHIP: c_int = 6; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + + pub const TCP_NODELAY: c_int = 0x0001; + pub const SOL_SOCKET: c_int = 0xffff; + + pub const SO_DEBUG: c_int = 0x0001; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 4; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + } + pub mod extra { + use types::os::common::bsd44::SOCKET; + use types::os::arch::c95::{c_int, c_long}; + use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE}; + + pub const TRUE : BOOL = 1; + pub const FALSE : BOOL = 0; + + pub const O_TEXT : c_int = 16384; + pub const O_BINARY : c_int = 32768; + pub const O_NOINHERIT: c_int = 128; + + pub const ERROR_SUCCESS : c_int = 0; + pub const ERROR_INVALID_FUNCTION: c_int = 1; + pub const ERROR_FILE_NOT_FOUND: c_int = 2; + pub const ERROR_ACCESS_DENIED: c_int = 5; + pub const ERROR_INVALID_HANDLE : c_int = 6; + pub const ERROR_BROKEN_PIPE: c_int = 109; + pub const ERROR_DISK_FULL : c_int = 112; + pub const ERROR_CALL_NOT_IMPLEMENTED : c_int = 120; + pub const ERROR_INSUFFICIENT_BUFFER : c_int = 122; + pub const ERROR_INVALID_NAME : c_int = 123; + pub const ERROR_ALREADY_EXISTS : c_int = 183; + pub const ERROR_PIPE_BUSY: c_int = 231; + pub const ERROR_NO_DATA: c_int = 232; + pub const ERROR_INVALID_ADDRESS : c_int = 487; + pub const ERROR_PIPE_CONNECTED: c_int = 535; + pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758; + pub const ERROR_OPERATION_ABORTED: c_int = 995; + pub const ERROR_IO_PENDING: c_int = 997; + pub const ERROR_FILE_INVALID : c_int = 1006; + pub const ERROR_NOT_FOUND: c_int = 1168; + pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; + + pub const DELETE : DWORD = 0x00010000; + pub const READ_CONTROL : DWORD = 0x00020000; + pub const SYNCHRONIZE : DWORD = 0x00100000; + pub const WRITE_DAC : DWORD = 0x00040000; + pub const WRITE_OWNER : DWORD = 0x00080000; + + pub const PROCESS_CREATE_PROCESS : DWORD = 0x0080; + pub const PROCESS_CREATE_THREAD : DWORD = 0x0002; + pub const PROCESS_DUP_HANDLE : DWORD = 0x0040; + pub const PROCESS_QUERY_INFORMATION : DWORD = 0x0400; + pub const PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000; + pub const PROCESS_SET_INFORMATION : DWORD = 0x0200; + pub const PROCESS_SET_QUOTA : DWORD = 0x0100; + pub const PROCESS_SUSPEND_RESUME : DWORD = 0x0800; + pub const PROCESS_TERMINATE : DWORD = 0x0001; + pub const PROCESS_VM_OPERATION : DWORD = 0x0008; + pub const PROCESS_VM_READ : DWORD = 0x0010; + pub const PROCESS_VM_WRITE : DWORD = 0x0020; + + pub const STARTF_FORCEONFEEDBACK : DWORD = 0x00000040; + pub const STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080; + pub const STARTF_PREVENTPINNING : DWORD = 0x00002000; + pub const STARTF_RUNFULLSCREEN : DWORD = 0x00000020; + pub const STARTF_TITLEISAPPID : DWORD = 0x00001000; + pub const STARTF_TITLEISLINKNAME : DWORD = 0x00000800; + pub const STARTF_USECOUNTCHARS : DWORD = 0x00000008; + pub const STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010; + pub const STARTF_USEHOTKEY : DWORD = 0x00000200; + pub const STARTF_USEPOSITION : DWORD = 0x00000004; + pub const STARTF_USESHOWWINDOW : DWORD = 0x00000001; + pub const STARTF_USESIZE : DWORD = 0x00000002; + pub const STARTF_USESTDHANDLES : DWORD = 0x00000100; + + pub const WAIT_ABANDONED : DWORD = 0x00000080; + pub const WAIT_OBJECT_0 : DWORD = 0x00000000; + pub const WAIT_TIMEOUT : DWORD = 0x00000102; + pub const WAIT_FAILED : DWORD = !0; + + pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001; + pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002; + + pub const INFINITE : DWORD = !0; + pub const STILL_ACTIVE : DWORD = 259; + + pub const MEM_COMMIT : DWORD = 0x00001000; + pub const MEM_RESERVE : DWORD = 0x00002000; + pub const MEM_DECOMMIT : DWORD = 0x00004000; + pub const MEM_RELEASE : DWORD = 0x00008000; + pub const MEM_RESET : DWORD = 0x00080000; + pub const MEM_RESET_UNDO : DWORD = 0x1000000; + pub const MEM_LARGE_PAGES : DWORD = 0x20000000; + pub const MEM_PHYSICAL : DWORD = 0x00400000; + pub const MEM_TOP_DOWN : DWORD = 0x00100000; + pub const MEM_WRITE_WATCH : DWORD = 0x00200000; + + pub const PAGE_EXECUTE : DWORD = 0x10; + pub const PAGE_EXECUTE_READ : DWORD = 0x20; + pub const PAGE_EXECUTE_READWRITE : DWORD = 0x40; + pub const PAGE_EXECUTE_WRITECOPY : DWORD = 0x80; + pub const PAGE_NOACCESS : DWORD = 0x01; + pub const PAGE_READONLY : DWORD = 0x02; + pub const PAGE_READWRITE : DWORD = 0x04; + pub const PAGE_WRITECOPY : DWORD = 0x08; + pub const PAGE_GUARD : DWORD = 0x100; + pub const PAGE_NOCACHE : DWORD = 0x200; + pub const PAGE_WRITECOMBINE : DWORD = 0x400; + + pub const SEC_COMMIT : DWORD = 0x8000000; + pub const SEC_IMAGE : DWORD = 0x1000000; + pub const SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000; + pub const SEC_LARGE_PAGES : DWORD = 0x80000000; + pub const SEC_NOCACHE : DWORD = 0x10000000; + pub const SEC_RESERVE : DWORD = 0x4000000; + pub const SEC_WRITECOMBINE : DWORD = 0x40000000; + + pub const FILE_MAP_ALL_ACCESS : DWORD = 0xf001f; + pub const FILE_MAP_READ : DWORD = 0x4; + pub const FILE_MAP_WRITE : DWORD = 0x2; + pub const FILE_MAP_COPY : DWORD = 0x1; + pub const FILE_MAP_EXECUTE : DWORD = 0x20; + + pub const PROCESSOR_ARCHITECTURE_INTEL : WORD = 0; + pub const PROCESSOR_ARCHITECTURE_ARM : WORD = 5; + pub const PROCESSOR_ARCHITECTURE_IA64 : WORD = 6; + pub const PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9; + pub const PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff; + + pub const MOVEFILE_COPY_ALLOWED: DWORD = 2; + pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16; + pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4; + pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32; + pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1; + pub const MOVEFILE_WRITE_THROUGH: DWORD = 8; + + pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1; + + pub const FILE_SHARE_DELETE: DWORD = 0x4; + pub const FILE_SHARE_READ: DWORD = 0x1; + pub const FILE_SHARE_WRITE: DWORD = 0x2; + + pub const CREATE_ALWAYS: DWORD = 2; + pub const CREATE_NEW: DWORD = 1; + pub const OPEN_ALWAYS: DWORD = 4; + pub const OPEN_EXISTING: DWORD = 3; + pub const TRUNCATE_EXISTING: DWORD = 5; + + pub const FILE_APPEND_DATA: DWORD = 0x00000004; + pub const FILE_READ_DATA: DWORD = 0x00000001; + pub const FILE_WRITE_DATA: DWORD = 0x00000002; + + pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20; + pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800; + pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40; + pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10; + pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000; + pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2; + pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000; + pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80; + pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000; + pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000; + pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000; + pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1; + pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400; + pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200; + pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4; + pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100; + pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000; + + pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; + pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; + pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; + pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; + pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; + pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; + pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x0100000; + pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; + pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; + pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; + pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; + pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; + + pub const FILE_NAME_NORMALIZED: DWORD = 0x0; + pub const FILE_NAME_OPENED: DWORD = 0x8; + + pub const VOLUME_NAME_DOS: DWORD = 0x0; + pub const VOLUME_NAME_GUID: DWORD = 0x1; + pub const VOLUME_NAME_NONE: DWORD = 0x4; + pub const VOLUME_NAME_NT: DWORD = 0x2; + + pub const GENERIC_READ: DWORD = 0x80000000; + pub const GENERIC_WRITE: DWORD = 0x40000000; + pub const GENERIC_EXECUTE: DWORD = 0x20000000; + pub const GENERIC_ALL: DWORD = 0x10000000; + pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100; + pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080; + + pub const STANDARD_RIGHTS_READ: DWORD = 0x20000; + pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000; + pub const FILE_WRITE_EA: DWORD = 0x00000010; + pub const FILE_READ_EA: DWORD = 0x00000008; + pub const FILE_GENERIC_READ: DWORD = + STANDARD_RIGHTS_READ | FILE_READ_DATA | + FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; + pub const FILE_GENERIC_WRITE: DWORD = + STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | + FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | + SYNCHRONIZE; + + pub const FILE_BEGIN: DWORD = 0; + pub const FILE_CURRENT: DWORD = 1; + pub const FILE_END: DWORD = 2; + + pub const MAX_PROTOCOL_CHAIN: DWORD = 7; + pub const WSAPROTOCOL_LEN: DWORD = 255; + pub const INVALID_SOCKET: SOCKET = !0; + + pub const DETACHED_PROCESS: DWORD = 0x00000008; + pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; + pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; + + pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; + pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; + pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; + pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; + pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; + pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; + pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; + pub const PIPE_WAIT: DWORD = 0x00000000; + pub const PIPE_NOWAIT: DWORD = 0x00000001; + pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; + pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; + pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; + + pub const IPPROTO_RAW: c_int = 255; + + pub const FIONBIO: c_long = -0x7FFB9982; + } + pub mod sysconf { + } + } + + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 8192; + pub const FOPEN_MAX : c_uint = 16; + pub const FILENAME_MAX : c_uint = 4096; + pub const L_tmpnam : c_uint = 20; + pub const TMP_MAX : c_uint = 238328; + } + pub mod c99 { + } + #[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "le32", + target_arch = "powerpc"))] + pub mod posix88 { + use types::os::arch::c95::c_int; + use types::common::c95::c_void; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 1024; + pub const O_CREAT : c_int = 64; + pub const O_EXCL : c_int = 128; + pub const O_NOCTTY : c_int = 256; + pub const O_TRUNC : c_int = 512; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x0020; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + pub const MS_SYNC : c_int = 0x0004; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EAGAIN : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + + pub const EDEADLK: c_int = 35; + pub const ENAMETOOLONG: c_int = 36; + pub const ENOLCK: c_int = 37; + pub const ENOSYS: c_int = 38; + pub const ENOTEMPTY: c_int = 39; + pub const ELOOP: c_int = 40; + pub const EWOULDBLOCK: c_int = EAGAIN; + pub const ENOMSG: c_int = 42; + pub const EIDRM: c_int = 43; + pub const ECHRNG: c_int = 44; + pub const EL2NSYNC: c_int = 45; + pub const EL3HLT: c_int = 46; + pub const EL3RST: c_int = 47; + pub const ELNRNG: c_int = 48; + pub const EUNATCH: c_int = 49; + pub const ENOCSI: c_int = 50; + pub const EL2HLT: c_int = 51; + pub const EBADE: c_int = 52; + pub const EBADR: c_int = 53; + pub const EXFULL: c_int = 54; + pub const ENOANO: c_int = 55; + pub const EBADRQC: c_int = 56; + pub const EBADSLT: c_int = 57; + + pub const EDEADLOCK: c_int = EDEADLK; + + pub const EBFONT: c_int = 59; + pub const ENOSTR: c_int = 60; + pub const ENODATA: c_int = 61; + pub const ETIME: c_int = 62; + pub const ENOSR: c_int = 63; + pub const ENONET: c_int = 64; + pub const ENOPKG: c_int = 65; + pub const EREMOTE: c_int = 66; + pub const ENOLINK: c_int = 67; + pub const EADV: c_int = 68; + pub const ESRMNT: c_int = 69; + pub const ECOMM: c_int = 70; + pub const EPROTO: c_int = 71; + pub const EMULTIHOP: c_int = 72; + pub const EDOTDOT: c_int = 73; + pub const EBADMSG: c_int = 74; + pub const EOVERFLOW: c_int = 75; + pub const ENOTUNIQ: c_int = 76; + pub const EBADFD: c_int = 77; + pub const EREMCHG: c_int = 78; + pub const ELIBACC: c_int = 79; + pub const ELIBBAD: c_int = 80; + pub const ELIBSCN: c_int = 81; + pub const ELIBMAX: c_int = 82; + pub const ELIBEXEC: c_int = 83; + pub const EILSEQ: c_int = 84; + pub const ERESTART: c_int = 85; + pub const ESTRPIPE: c_int = 86; + pub const EUSERS: c_int = 87; + pub const ENOTSOCK: c_int = 88; + pub const EDESTADDRREQ: c_int = 89; + pub const EMSGSIZE: c_int = 90; + pub const EPROTOTYPE: c_int = 91; + pub const ENOPROTOOPT: c_int = 92; + pub const EPROTONOSUPPORT: c_int = 93; + pub const ESOCKTNOSUPPORT: c_int = 94; + pub const EOPNOTSUPP: c_int = 95; + pub const EPFNOSUPPORT: c_int = 96; + pub const EAFNOSUPPORT: c_int = 97; + pub const EADDRINUSE: c_int = 98; + pub const EADDRNOTAVAIL: c_int = 99; + pub const ENETDOWN: c_int = 100; + pub const ENETUNREACH: c_int = 101; + pub const ENETRESET: c_int = 102; + pub const ECONNABORTED: c_int = 103; + pub const ECONNRESET: c_int = 104; + pub const ENOBUFS: c_int = 105; + pub const EISCONN: c_int = 106; + pub const ENOTCONN: c_int = 107; + pub const ESHUTDOWN: c_int = 108; + pub const ETOOMANYREFS: c_int = 109; + pub const ETIMEDOUT: c_int = 110; + pub const ECONNREFUSED: c_int = 111; + pub const EHOSTDOWN: c_int = 112; + pub const EHOSTUNREACH: c_int = 113; + pub const EALREADY: c_int = 114; + pub const EINPROGRESS: c_int = 115; + pub const ESTALE: c_int = 116; + pub const EUCLEAN: c_int = 117; + pub const ENOTNAM: c_int = 118; + pub const ENAVAIL: c_int = 119; + pub const EISNAM: c_int = 120; + pub const EREMOTEIO: c_int = 121; + pub const EDQUOT: c_int = 122; + + pub const ENOMEDIUM: c_int = 123; + pub const EMEDIUMTYPE: c_int = 124; + pub const ECANCELED: c_int = 125; + pub const ENOKEY: c_int = 126; + pub const EKEYEXPIRED: c_int = 127; + pub const EKEYREVOKED: c_int = 128; + pub const EKEYREJECTED: c_int = 129; + + pub const EOWNERDEAD: c_int = 130; + pub const ENOTRECOVERABLE: c_int = 131; + + pub const ERFKILL: c_int = 132; + + pub const EHWPOISON: c_int = 133; + } + + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod posix88 { + use types::os::arch::c95::c_int; + use types::common::c95::c_void; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 256; + pub const O_EXCL : c_int = 1024; + pub const O_NOCTTY : c_int = 2048; + pub const O_TRUNC : c_int = 512; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x0800; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + pub const MS_SYNC : c_int = 0x0004; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EAGAIN : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + + pub const ENOMSG: c_int = 35; + pub const EIDRM: c_int = 36; + pub const ECHRNG: c_int = 37; + pub const EL2NSYNC: c_int = 38; + pub const EL3HLT: c_int = 39; + pub const EL3RST: c_int = 40; + pub const ELNRNG: c_int = 41; + pub const EUNATCH: c_int = 42; + pub const ENOCSI: c_int = 43; + pub const EL2HLT: c_int = 44; + pub const EDEADLK: c_int = 45; + pub const ENOLCK: c_int = 46; + pub const EBADE: c_int = 50; + pub const EBADR: c_int = 51; + pub const EXFULL: c_int = 52; + pub const ENOANO: c_int = 53; + pub const EBADRQC: c_int = 54; + pub const EBADSLT: c_int = 55; + pub const EDEADLOCK: c_int = 56; + pub const EBFONT: c_int = 59; + pub const ENOSTR: c_int = 60; + pub const ENODATA: c_int = 61; + pub const ETIME: c_int = 62; + pub const ENOSR: c_int = 63; + pub const ENONET: c_int = 64; + pub const ENOPKG: c_int = 65; + pub const EREMOTE: c_int = 66; + pub const ENOLINK: c_int = 67; + pub const EADV: c_int = 68; + pub const ESRMNT: c_int = 69; + pub const ECOMM: c_int = 70; + pub const EPROTO: c_int = 71; + pub const EDOTDOT: c_int = 73; + pub const EMULTIHOP: c_int = 74; + pub const EBADMSG: c_int = 77; + pub const ENAMETOOLONG: c_int = 78; + pub const EOVERFLOW: c_int = 79; + pub const ENOTUNIQ: c_int = 80; + pub const EBADFD: c_int = 81; + pub const EREMCHG: c_int = 82; + pub const ELIBACC: c_int = 83; + pub const ELIBBAD: c_int = 84; + pub const ELIBSCN: c_int = 95; + pub const ELIBMAX: c_int = 86; + pub const ELIBEXEC: c_int = 87; + pub const EILSEQ: c_int = 88; + pub const ENOSYS: c_int = 89; + pub const ELOOP: c_int = 90; + pub const ERESTART: c_int = 91; + pub const ESTRPIPE: c_int = 92; + pub const ENOTEMPTY: c_int = 93; + pub const EUSERS: c_int = 94; + pub const ENOTSOCK: c_int = 95; + pub const EDESTADDRREQ: c_int = 96; + pub const EMSGSIZE: c_int = 97; + pub const EPROTOTYPE: c_int = 98; + pub const ENOPROTOOPT: c_int = 99; + pub const EPROTONOSUPPORT: c_int = 120; + pub const ESOCKTNOSUPPORT: c_int = 121; + pub const EOPNOTSUPP: c_int = 122; + pub const EPFNOSUPPORT: c_int = 123; + pub const EAFNOSUPPORT: c_int = 124; + pub const EADDRINUSE: c_int = 125; + pub const EADDRNOTAVAIL: c_int = 126; + pub const ENETDOWN: c_int = 127; + pub const ENETUNREACH: c_int = 128; + pub const ENETRESET: c_int = 129; + pub const ECONNABORTED: c_int = 130; + pub const ECONNRESET: c_int = 131; + pub const ENOBUFS: c_int = 132; + pub const EISCONN: c_int = 133; + pub const ENOTCONN: c_int = 134; + pub const EUCLEAN: c_int = 135; + pub const ENOTNAM: c_int = 137; + pub const ENAVAIL: c_int = 138; + pub const EISNAM: c_int = 139; + pub const EREMOTEIO: c_int = 140; + pub const ESHUTDOWN: c_int = 143; + pub const ETOOMANYREFS: c_int = 144; + pub const ETIMEDOUT: c_int = 145; + pub const ECONNREFUSED: c_int = 146; + pub const EHOSTDOWN: c_int = 147; + pub const EHOSTUNREACH: c_int = 148; + pub const EWOULDBLOCK: c_int = EAGAIN; + pub const EALREADY: c_int = 149; + pub const EINPROGRESS: c_int = 150; + pub const ESTALE: c_int = 151; + pub const ECANCELED: c_int = 158; + + pub const ENOMEDIUM: c_int = 159; + pub const EMEDIUMTYPE: c_int = 160; + pub const ENOKEY: c_int = 161; + pub const EKEYEXPIRED: c_int = 162; + pub const EKEYREVOKED: c_int = 163; + pub const EKEYREJECTED: c_int = 164; + + pub const EOWNERDEAD: c_int = 165; + pub const ENOTRECOVERABLE: c_int = 166; + + pub const ERFKILL: c_int = 167; + + pub const EHWPOISON: c_int = 168; + + pub const EDQUOT: c_int = 1133; + } + #[cfg(not(target_os = "nacl"))] + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const O_ACCMODE : c_int = 3; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_ERR : c_int = 1 << 0; + pub const GLOB_MARK : c_int = 1 << 1; + pub const GLOB_NOSORT : c_int = 1 << 2; + pub const GLOB_DOOFFS : c_int = 1 << 3; + pub const GLOB_NOCHECK : c_int = 1 << 4; + pub const GLOB_APPEND : c_int = 1 << 5; + pub const GLOB_NOESCAPE : c_int = 1 << 6; + + pub const GLOB_NOSPACE : c_int = 1; + pub const GLOB_ABORTED : c_int = 2; + pub const GLOB_NOMATCH : c_int = 3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_MQ_PRIO_MAX : c_int = 28; + pub const _SC_IOV_MAX : c_int = 60; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 69; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 70; + pub const _SC_LOGIN_NAME_MAX : c_int = 71; + pub const _SC_TTY_NAME_MAX : c_int = 72; + pub const _SC_THREADS : c_int = 67; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73; + pub const _SC_THREAD_KEYS_MAX : c_int = 74; + pub const _SC_THREAD_STACK_MIN : c_int = 75; + pub const _SC_THREAD_THREADS_MAX : c_int = 76; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 80; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 81; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 82; + pub const _SC_ATEXIT_MAX : c_int = 87; + pub const _SC_XOPEN_VERSION : c_int = 89; + pub const _SC_XOPEN_XCU_VERSION : c_int = 90; + pub const _SC_XOPEN_UNIX : c_int = 91; + pub const _SC_XOPEN_CRYPT : c_int = 92; + pub const _SC_XOPEN_ENH_I18N : c_int = 93; + pub const _SC_XOPEN_SHM : c_int = 94; + pub const _SC_XOPEN_LEGACY : c_int = 129; + pub const _SC_XOPEN_REALTIME : c_int = 130; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131; + + + + pub const PTHREAD_CREATE_JOINABLE: c_int = 0; + pub const PTHREAD_CREATE_DETACHED: c_int = 1; + + #[cfg(target_os = "android")] + pub const PTHREAD_STACK_MIN: size_t = 8192; + + #[cfg(all(target_os = "linux", + any(target_arch = "arm", + target_arch = "x86", + target_arch = "x86_64")))] + pub const PTHREAD_STACK_MIN: size_t = 16384; + + #[cfg(all(target_os = "linux", + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "aarch64", + target_arch = "powerpc")))] + pub const PTHREAD_STACK_MIN: size_t = 131072; + + pub const CLOCK_REALTIME: c_int = 0; + pub const CLOCK_MONOTONIC: c_int = 1; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_NOFILE: c_int = 7; + pub const RLIMIT_AS: c_int = 9; + pub const RLIMIT_NPROC: c_int = 6; + pub const RLIMIT_MEMLOCK: c_int = 8; + pub const RLIMIT_LOCKS: c_int = 10; + pub const RLIMIT_SIGPENDING: c_int = 11; + pub const RLIMIT_MSGQUEUE: c_int = 12; + pub const RLIMIT_NICE: c_int = 13; + pub const RLIMIT_RTPRIO: c_int = 14; + pub const RLIMIT_RTTIME: c_int = 15; + pub const RLIMIT_NLIMITS: c_int = 16; + pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; + pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + #[cfg(target_os = "nacl")] + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_ERR : c_int = 1 << 0; + pub const GLOB_MARK : c_int = 1 << 1; + pub const GLOB_NOSORT : c_int = 1 << 2; + pub const GLOB_DOOFFS : c_int = 1 << 3; + pub const GLOB_NOCHECK : c_int = 1 << 4; + pub const GLOB_APPEND : c_int = 1 << 5; + pub const GLOB_NOESCAPE : c_int = 1 << 6; + + pub const GLOB_NOSPACE : c_int = 1; + pub const GLOB_ABORTED : c_int = 2; + pub const GLOB_NOMATCH : c_int = 3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_MQ_PRIO_MAX : c_int = 28; + pub const _SC_IOV_MAX : c_int = 60; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 69; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 70; + pub const _SC_LOGIN_NAME_MAX : c_int = 71; + pub const _SC_TTY_NAME_MAX : c_int = 72; + pub const _SC_THREADS : c_int = 67; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73; + pub const _SC_THREAD_KEYS_MAX : c_int = 74; + pub const _SC_THREAD_STACK_MIN : c_int = 75; + pub const _SC_THREAD_THREADS_MAX : c_int = 76; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 80; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 81; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 82; + pub const _SC_ATEXIT_MAX : c_int = 87; + pub const _SC_XOPEN_VERSION : c_int = 89; + pub const _SC_XOPEN_XCU_VERSION : c_int = 90; + pub const _SC_XOPEN_UNIX : c_int = 91; + pub const _SC_XOPEN_CRYPT : c_int = 92; + pub const _SC_XOPEN_ENH_I18N : c_int = 93; + pub const _SC_XOPEN_SHM : c_int = 94; + pub const _SC_XOPEN_LEGACY : c_int = 129; + pub const _SC_XOPEN_REALTIME : c_int = 130; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 1; + pub const PTHREAD_CREATE_DETACHED: c_int = 0; + + pub const PTHREAD_STACK_MIN: size_t = 1024; + + pub const CLOCK_REALTIME: c_int = 0; + pub const CLOCK_MONOTONIC: c_int = 1; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_NOFILE: c_int = 7; + pub const RLIMIT_AS: c_int = 9; + pub const RLIMIT_NPROC: c_int = 6; + pub const RLIMIT_MEMLOCK: c_int = 8; + pub const RLIMIT_LOCKS: c_int = 10; + pub const RLIMIT_SIGPENDING: c_int = 11; + pub const RLIMIT_MSGQUEUE: c_int = 12; + pub const RLIMIT_NICE: c_int = 13; + pub const RLIMIT_RTPRIO: c_int = 14; + pub const RLIMIT_RTTIME: c_int = 15; + pub const RLIMIT_NLIMITS: c_int = 16; + + pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; + pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + #[cfg(any(target_arch = "arm", + target_arch = "aarch64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "le32", + target_arch = "powerpc"))] + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_REMOVE : c_int = 9; + pub const MADV_DONTFORK : c_int = 10; + pub const MADV_DOFORK : c_int = 11; + pub const MADV_MERGEABLE : c_int = 12; + pub const MADV_UNMERGEABLE : c_int = 13; + pub const MADV_HWPOISON : c_int = 100; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 10; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 33; + pub const IP_MULTICAST_LOOP: c_int = 34; + pub const IP_TTL: c_int = 2; + pub const IP_HDRINCL: c_int = 3; + pub const IP_ADD_MEMBERSHIP: c_int = 35; + pub const IP_DROP_MEMBERSHIP: c_int = 36; + pub const IPV6_ADD_MEMBERSHIP: c_int = 20; + pub const IPV6_DROP_MEMBERSHIP: c_int = 21; + + pub const TCP_NODELAY: c_int = 1; + pub const TCP_MAXSEG: c_int = 2; + pub const TCP_CORK: c_int = 3; + pub const TCP_KEEPIDLE: c_int = 4; + pub const TCP_KEEPINTVL: c_int = 5; + pub const TCP_KEEPCNT: c_int = 6; + pub const TCP_SYNCNT: c_int = 7; + pub const TCP_LINGER2: c_int = 8; + pub const TCP_DEFER_ACCEPT: c_int = 9; + pub const TCP_WINDOW_CLAMP: c_int = 10; + pub const TCP_INFO: c_int = 11; + pub const TCP_QUICKACK: c_int = 12; + pub const TCP_CONGESTION: c_int = 13; + pub const TCP_MD5SIG: c_int = 14; + pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; + pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; + pub const TCP_THIN_DUPACK: c_int = 17; + pub const TCP_USER_TIMEOUT: c_int = 18; + pub const TCP_REPAIR: c_int = 19; + pub const TCP_REPAIR_QUEUE: c_int = 20; + pub const TCP_QUEUE_SEQ: c_int = 21; + pub const TCP_REPAIR_OPTIONS: c_int = 22; + pub const TCP_FASTOPEN: c_int = 23; + pub const TCP_TIMESTAMP: c_int = 24; + + pub const SOL_SOCKET: c_int = 1; + + pub const SO_DEBUG: c_int = 1; + pub const SO_REUSEADDR: c_int = 2; + pub const SO_TYPE: c_int = 3; + pub const SO_ERROR: c_int = 4; + pub const SO_DONTROUTE: c_int = 5; + pub const SO_BROADCAST: c_int = 6; + pub const SO_SNDBUF: c_int = 7; + pub const SO_RCVBUF: c_int = 8; + pub const SO_KEEPALIVE: c_int = 9; + pub const SO_OOBINLINE: c_int = 10; + pub const SO_LINGER: c_int = 13; + pub const SO_REUSEPORT: c_int = 15; + pub const SO_RCVLOWAT: c_int = 18; + pub const SO_SNDLOWAT: c_int = 19; + pub const SO_RCVTIMEO: c_int = 20; + pub const SO_SNDTIMEO: c_int = 21; + pub const SO_ACCEPTCONN: c_int = 30; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_REMOVE : c_int = 9; + pub const MADV_DONTFORK : c_int = 10; + pub const MADV_DOFORK : c_int = 11; + pub const MADV_MERGEABLE : c_int = 12; + pub const MADV_UNMERGEABLE : c_int = 13; + pub const MADV_HWPOISON : c_int = 100; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 10; + pub const SOCK_STREAM: c_int = 2; + pub const SOCK_DGRAM: c_int = 1; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 33; + pub const IP_MULTICAST_LOOP: c_int = 34; + pub const IP_TTL: c_int = 2; + pub const IP_HDRINCL: c_int = 3; + pub const IP_ADD_MEMBERSHIP: c_int = 35; + pub const IP_DROP_MEMBERSHIP: c_int = 36; + pub const IPV6_ADD_MEMBERSHIP: c_int = 20; + pub const IPV6_DROP_MEMBERSHIP: c_int = 21; + + pub const TCP_NODELAY: c_int = 1; + pub const TCP_MAXSEG: c_int = 2; + pub const TCP_CORK: c_int = 3; + pub const TCP_KEEPIDLE: c_int = 4; + pub const TCP_KEEPINTVL: c_int = 5; + pub const TCP_KEEPCNT: c_int = 6; + pub const TCP_SYNCNT: c_int = 7; + pub const TCP_LINGER2: c_int = 8; + pub const TCP_DEFER_ACCEPT: c_int = 9; + pub const TCP_WINDOW_CLAMP: c_int = 10; + pub const TCP_INFO: c_int = 11; + pub const TCP_QUICKACK: c_int = 12; + pub const TCP_CONGESTION: c_int = 13; + pub const TCP_MD5SIG: c_int = 14; + pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; + pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; + pub const TCP_THIN_DUPACK: c_int = 17; + pub const TCP_USER_TIMEOUT: c_int = 18; + pub const TCP_REPAIR: c_int = 19; + pub const TCP_REPAIR_QUEUE: c_int = 20; + pub const TCP_QUEUE_SEQ: c_int = 21; + pub const TCP_REPAIR_OPTIONS: c_int = 22; + pub const TCP_FASTOPEN: c_int = 23; + pub const TCP_TIMESTAMP: c_int = 24; + + pub const SOL_SOCKET: c_int = 65535; + + pub const SO_DEBUG: c_int = 0x0001; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + pub const SO_ACCEPTCONN: c_int = 0x1009; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + #[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "le32", + target_arch = "powerpc"))] + pub mod extra { + use types::os::arch::c95::c_int; + + pub const AF_PACKET : c_int = 17; + pub const IPPROTO_RAW : c_int = 255; + + pub const O_RSYNC : c_int = 1052672; + pub const O_DSYNC : c_int = 4096; + pub const O_NONBLOCK : c_int = 2048; + pub const O_SYNC : c_int = 1052672; + + pub const PROT_GROWSDOWN : c_int = 0x010000000; + pub const PROT_GROWSUP : c_int = 0x020000000; + + pub const MAP_TYPE : c_int = 0x000f; + pub const MAP_ANONYMOUS : c_int = 0x0020; + pub const MAP_32BIT : c_int = 0x0040; + pub const MAP_GROWSDOWN : c_int = 0x0100; + pub const MAP_DENYWRITE : c_int = 0x0800; + pub const MAP_EXECUTABLE : c_int = 0x01000; + pub const MAP_LOCKED : c_int = 0x02000; + pub const MAP_NORESERVE : c_int = 0x04000; + pub const MAP_POPULATE : c_int = 0x08000; + pub const MAP_NONBLOCK : c_int = 0x010000; + pub const MAP_STACK : c_int = 0x020000; + } + #[cfg(any(target_arch = "mips", + target_arch = "mipsel"))] + pub mod extra { + use types::os::arch::c95::c_int; + + pub const AF_PACKET : c_int = 17; + pub const IPPROTO_RAW : c_int = 255; + + pub const O_RSYNC : c_int = 16400; + pub const O_DSYNC : c_int = 16; + pub const O_NONBLOCK : c_int = 128; + pub const O_SYNC : c_int = 16400; + + pub const PROT_GROWSDOWN : c_int = 0x01000000; + pub const PROT_GROWSUP : c_int = 0x02000000; + + pub const MAP_TYPE : c_int = 0x000f; + pub const MAP_ANONYMOUS : c_int = 0x0800; + pub const MAP_GROWSDOWN : c_int = 0x01000; + pub const MAP_DENYWRITE : c_int = 0x02000; + pub const MAP_EXECUTABLE : c_int = 0x04000; + pub const MAP_LOCKED : c_int = 0x08000; + pub const MAP_NORESERVE : c_int = 0x0400; + pub const MAP_POPULATE : c_int = 0x010000; + pub const MAP_NONBLOCK : c_int = 0x020000; + pub const MAP_STACK : c_int = 0x040000; + } + #[cfg(target_os = "linux")] + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 0; + pub const _SC_CHILD_MAX : c_int = 1; + pub const _SC_CLK_TCK : c_int = 2; + pub const _SC_NGROUPS_MAX : c_int = 3; + pub const _SC_OPEN_MAX : c_int = 4; + pub const _SC_STREAM_MAX : c_int = 5; + pub const _SC_TZNAME_MAX : c_int = 6; + pub const _SC_JOB_CONTROL : c_int = 7; + pub const _SC_SAVED_IDS : c_int = 8; + pub const _SC_REALTIME_SIGNALS : c_int = 9; + pub const _SC_PRIORITY_SCHEDULING : c_int = 10; + pub const _SC_TIMERS : c_int = 11; + pub const _SC_ASYNCHRONOUS_IO : c_int = 12; + pub const _SC_PRIORITIZED_IO : c_int = 13; + pub const _SC_SYNCHRONIZED_IO : c_int = 14; + pub const _SC_FSYNC : c_int = 15; + pub const _SC_MAPPED_FILES : c_int = 16; + pub const _SC_MEMLOCK : c_int = 17; + pub const _SC_MEMLOCK_RANGE : c_int = 18; + pub const _SC_MEMORY_PROTECTION : c_int = 19; + pub const _SC_MESSAGE_PASSING : c_int = 20; + pub const _SC_SEMAPHORES : c_int = 21; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 22; + pub const _SC_AIO_LISTIO_MAX : c_int = 23; + pub const _SC_AIO_MAX : c_int = 24; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 25; + pub const _SC_DELAYTIMER_MAX : c_int = 26; + pub const _SC_MQ_OPEN_MAX : c_int = 27; + pub const _SC_VERSION : c_int = 29; + pub const _SC_PAGESIZE : c_int = 30; + pub const _SC_RTSIG_MAX : c_int = 31; + pub const _SC_SEM_NSEMS_MAX : c_int = 32; + pub const _SC_SEM_VALUE_MAX : c_int = 33; + pub const _SC_SIGQUEUE_MAX : c_int = 34; + pub const _SC_TIMER_MAX : c_int = 35; + pub const _SC_BC_BASE_MAX : c_int = 36; + pub const _SC_BC_DIM_MAX : c_int = 37; + pub const _SC_BC_SCALE_MAX : c_int = 38; + pub const _SC_BC_STRING_MAX : c_int = 39; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 40; + pub const _SC_EXPR_NEST_MAX : c_int = 42; + pub const _SC_LINE_MAX : c_int = 43; + pub const _SC_RE_DUP_MAX : c_int = 44; + pub const _SC_2_VERSION : c_int = 46; + pub const _SC_2_C_BIND : c_int = 47; + pub const _SC_2_C_DEV : c_int = 48; + pub const _SC_2_FORT_DEV : c_int = 49; + pub const _SC_2_FORT_RUN : c_int = 50; + pub const _SC_2_SW_DEV : c_int = 51; + pub const _SC_2_LOCALEDEF : c_int = 52; + pub const _SC_NPROCESSORS_ONLN : c_int = 84; + pub const _SC_2_CHAR_TERM : c_int = 95; + pub const _SC_2_C_VERSION : c_int = 96; + pub const _SC_2_UPE : c_int = 97; + pub const _SC_XBS5_ILP32_OFF32 : c_int = 125; + pub const _SC_XBS5_ILP32_OFFBIG : c_int = 126; + pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 128; + + } + #[cfg(target_os = "nacl")] + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub static _SC_SENDMSG_MAX_SIZE : c_int = 0; + pub static _SC_NPROCESSORS_ONLN : c_int = 1; + pub static _SC_PAGESIZE : c_int = 2; + } + + #[cfg(target_os = "android")] + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 0; + pub const _SC_BC_BASE_MAX : c_int = 1; + pub const _SC_BC_DIM_MAX : c_int = 2; + pub const _SC_BC_SCALE_MAX : c_int = 3; + pub const _SC_BC_STRING_MAX : c_int = 4; + pub const _SC_CHILD_MAX : c_int = 5; + pub const _SC_CLK_TCK : c_int = 6; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 7; + pub const _SC_EXPR_NEST_MAX : c_int = 8; + pub const _SC_LINE_MAX : c_int = 9; + pub const _SC_NGROUPS_MAX : c_int = 10; + pub const _SC_OPEN_MAX : c_int = 11; + pub const _SC_2_C_BIND : c_int = 13; + pub const _SC_2_C_DEV : c_int = 14; + pub const _SC_2_C_VERSION : c_int = 15; + pub const _SC_2_CHAR_TERM : c_int = 16; + pub const _SC_2_FORT_DEV : c_int = 17; + pub const _SC_2_FORT_RUN : c_int = 18; + pub const _SC_2_LOCALEDEF : c_int = 19; + pub const _SC_2_SW_DEV : c_int = 20; + pub const _SC_2_UPE : c_int = 21; + pub const _SC_2_VERSION : c_int = 22; + pub const _SC_JOB_CONTROL : c_int = 23; + pub const _SC_SAVED_IDS : c_int = 24; + pub const _SC_VERSION : c_int = 25; + pub const _SC_RE_DUP_MAX : c_int = 26; + pub const _SC_STREAM_MAX : c_int = 27; + pub const _SC_TZNAME_MAX : c_int = 28; + pub const _SC_PAGESIZE : c_int = 39; + } + } + + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 32768; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_SYNC : c_int = 0x0000; + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = 35; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const EOPNOTSUPP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EIDRM : c_int = 82; + pub const ENOMSG : c_int = 83; + pub const EOVERFLOW : c_int = 84; + pub const ECANCELED : c_int = 85; + pub const EILSEQ : c_int = 86; + pub const ENOATTR : c_int = 87; + pub const EDOOFUS : c_int = 88; + pub const EBADMSG : c_int = 89; + pub const EMULTIHOP : c_int = 90; + pub const ENOLINK : c_int = 91; + pub const EPROTO : c_int = 92; + pub const ENOMEDIUM : c_int = 93; + pub const EUNUSED94 : c_int = 94; + pub const EUNUSED95 : c_int = 95; + pub const EUNUSED96 : c_int = 96; + pub const EUNUSED97 : c_int = 97; + pub const EUNUSED98 : c_int = 98; + pub const EASYNC : c_int = 99; + pub const ELAST : c_int = 99; + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x2000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 56; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; + pub const _SC_LOGIN_NAME_MAX : c_int = 73; + pub const _SC_MQ_PRIO_MAX : c_int = 75; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; + pub const _SC_THREAD_KEYS_MAX : c_int = 86; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; + pub const _SC_THREAD_STACK_MIN : c_int = 93; + pub const _SC_THREAD_THREADS_MAX : c_int = 94; + pub const _SC_THREADS : c_int = 96; + pub const _SC_TTY_NAME_MAX : c_int = 101; + pub const _SC_ATEXIT_MAX : c_int = 107; + pub const _SC_XOPEN_CRYPT : c_int = 108; + pub const _SC_XOPEN_ENH_I18N : c_int = 109; + pub const _SC_XOPEN_LEGACY : c_int = 110; + pub const _SC_XOPEN_REALTIME : c_int = 111; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; + pub const _SC_XOPEN_SHM : c_int = 113; + pub const _SC_XOPEN_UNIX : c_int = 115; + pub const _SC_XOPEN_VERSION : c_int = 116; + pub const _SC_XOPEN_XCU_VERSION : c_int = 117; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 0; + pub const PTHREAD_CREATE_DETACHED: c_int = 1; + + #[cfg(target_arch = "arm")] + pub const PTHREAD_STACK_MIN: size_t = 4096; + + #[cfg(all(target_os = "freebsd", + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "x86", + target_arch = "x86_64")))] + pub const PTHREAD_STACK_MIN: size_t = 2048; + + #[cfg(target_os = "dragonfly")] + pub const PTHREAD_STACK_MIN: size_t = 1024; + + pub const CLOCK_REALTIME: c_int = 0; + pub const CLOCK_MONOTONIC: c_int = 4; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIMIT_SBSIZE: c_int = 9; + pub const RLIMIT_VMEM: c_int = 10; + pub const RLIMIT_AS: c_int = RLIMIT_VMEM; + pub const RLIMIT_NPTS: c_int = 11; + pub const RLIMIT_SWAP: c_int = 12; + pub const RLIMIT_KQUEUES: c_int = 13; + + pub const RLIM_NLIMITS: rlim_t = 14; + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 5; + pub const MADV_NOSYNC : c_int = 6; + pub const MADV_AUTOSYNC : c_int = 7; + pub const MADV_NOCORE : c_int = 8; + pub const MADV_CORE : c_int = 9; + pub const MADV_PROTECT : c_int = 10; + + pub const MINCORE_INCORE : c_int = 0x1; + pub const MINCORE_REFERENCED : c_int = 0x2; + pub const MINCORE_MODIFIED : c_int = 0x4; + pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; + pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; + pub const MINCORE_SUPER : c_int = 0x20; + + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 28; + pub const AF_UNIX: c_int = 1; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + + pub const TCP_NODELAY: c_int = 1; + pub const TCP_KEEPIDLE: c_int = 256; + pub const SOL_SOCKET: c_int = 0xffff; + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const CTL_KERN: c_int = 1; + pub const KERN_PROC: c_int = 14; + #[cfg(target_os = "freebsd")] + pub const KERN_PROC_PATHNAME: c_int = 12; + #[cfg(target_os = "dragonfly")] + pub const KERN_PROC_PATHNAME: c_int = 9; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0020; + pub const MAP_NORESERVE : c_int = 0x0040; + pub const MAP_HASSEMAPHORE : c_int = 0x0200; + pub const MAP_STACK : c_int = 0x0400; + pub const MAP_NOSYNC : c_int = 0x0800; + pub const MAP_NOCORE : c_int = 0x020000; + + pub const IPPROTO_RAW : c_int = 255; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_ASYNCHRONOUS_IO : c_int = 28; + pub const _SC_MAPPED_FILES : c_int = 29; + pub const _SC_MEMLOCK : c_int = 30; + pub const _SC_MEMLOCK_RANGE : c_int = 31; + pub const _SC_MEMORY_PROTECTION : c_int = 32; + pub const _SC_MESSAGE_PASSING : c_int = 33; + pub const _SC_PRIORITIZED_IO : c_int = 34; + pub const _SC_PRIORITY_SCHEDULING : c_int = 35; + pub const _SC_REALTIME_SIGNALS : c_int = 36; + pub const _SC_SEMAPHORES : c_int = 37; + pub const _SC_FSYNC : c_int = 38; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; + pub const _SC_SYNCHRONIZED_IO : c_int = 40; + pub const _SC_TIMERS : c_int = 41; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_DELAYTIMER_MAX : c_int = 45; + pub const _SC_MQ_OPEN_MAX : c_int = 46; + pub const _SC_PAGESIZE : c_int = 47; + pub const _SC_RTSIG_MAX : c_int = 48; + pub const _SC_SEM_NSEMS_MAX : c_int = 49; + pub const _SC_SEM_VALUE_MAX : c_int = 50; + pub const _SC_SIGQUEUE_MAX : c_int = 51; + pub const _SC_TIMER_MAX : c_int = 52; + } + } + + #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 32768; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_SYNC : c_int = 0x0002; + pub const MS_INVALIDATE : c_int = 0x0004; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = 35; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const EOPNOTSUPP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EIPSEC : c_int = 82; + pub const ENOATTR : c_int = 83; + pub const EILSEQ : c_int = 84; + pub const ENOMEDIUM : c_int = 85; + pub const EMEDIUMTYPE : c_int = 86; + pub const EOVERFLOW : c_int = 87; + pub const ECANCELED : c_int = 88; + pub const EIDRM : c_int = 89; + pub const ENOMSG : c_int = 90; + pub const ENOTSUP : c_int = 91; + pub const ELAST : c_int = 91; // must be equal to largest errno + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + pub const F_GETOWN : c_int = 5; + pub const F_SETOWN : c_int = 6; + pub const F_GETLK : c_int = 7; + pub const F_SETLK : c_int = 8; + pub const F_SETLKW : c_int = 9; + pub const F_DUPFD_CLOEXEC : c_int = 10; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x1000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + pub const GLOB_NOSYS : c_int = -4; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 51; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 100; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 101; + pub const _SC_LOGIN_NAME_MAX : c_int = 102; + pub const _SC_MQ_PRIO_MAX : c_int = 59; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80; + pub const _SC_THREAD_KEYS_MAX : c_int = 81; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 82; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 83; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 85; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103; + pub const _SC_THREAD_STACK_MIN : c_int = 89; + pub const _SC_THREAD_THREADS_MAX : c_int = 90; + pub const _SC_THREADS : c_int = 91; + pub const _SC_TTY_NAME_MAX : c_int = 107; + pub const _SC_ATEXIT_MAX : c_int = 46; + pub const _SC_XOPEN_CRYPT : c_int = 117; + pub const _SC_XOPEN_ENH_I18N : c_int = 118; + pub const _SC_XOPEN_LEGACY : c_int = 119; + pub const _SC_XOPEN_REALTIME : c_int = 120; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121; + pub const _SC_XOPEN_SHM : c_int = 30; + pub const _SC_XOPEN_UNIX : c_int = 123; + pub const _SC_XOPEN_VERSION : c_int = 125; + + pub const PTHREAD_CREATE_JOINABLE : c_int = 0; + pub const PTHREAD_CREATE_DETACHED : c_int = 1; + pub const PTHREAD_STACK_MIN : size_t = 2048; + + pub const CLOCK_REALTIME : c_int = 0; + pub const CLOCK_MONOTONIC : c_int = 3; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIM_NLIMITS: c_int = 9; + + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; + pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 6; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 24; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist + + pub const TCP_NODELAY: c_int = 0x01; + pub const SOL_SOCKET: c_int = 0xffff; + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_DSYNC : c_int = 128; // same as SYNC + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const CTL_KERN : c_int = 1; + pub const KERN_PROC : c_int = 66; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0000; + pub const MAP_NORESERVE : c_int = 0x0000; + pub const MAP_NOEXTEND : c_int = 0x0000; + pub const MAP_HASSEMAPHORE : c_int = 0x0000; + + pub const IPPROTO_RAW : c_int = 255; + + pub const PATH_MAX: c_int = 1024; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_PAGESIZE : c_int = 28; + pub const _SC_FSYNC : c_int = 29; + pub const _SC_SEM_NSEMS_MAX : c_int = 31; + pub const _SC_SEM_VALUE_MAX : c_int = 32; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_ASYNCHRONOUS_IO : c_int = 45; + pub const _SC_DELAYTIMER_MAX : c_int = 50; + pub const _SC_MAPPED_FILES : c_int = 53; + pub const _SC_MEMLOCK : c_int = 54; + pub const _SC_MEMLOCK_RANGE : c_int = 55; + pub const _SC_MEMORY_PROTECTION : c_int = 56; + pub const _SC_MESSAGE_PASSING : c_int = 57; + pub const _SC_MQ_OPEN_MAX : c_int = 58; + pub const _SC_PRIORITIZED_IO : c_int = 60; + pub const _SC_PRIORITY_SCHEDULING : c_int = 61; + pub const _SC_REALTIME_SIGNALS : c_int = 64; + pub const _SC_RTSIG_MAX : c_int = 66; + pub const _SC_SEMAPHORES : c_int = 67; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68; + pub const _SC_SIGQUEUE_MAX : c_int = 70; + pub const _SC_SYNCHRONIZED_IO : c_int = 75; + pub const _SC_TIMER_MAX : c_int = 93; + pub const _SC_TIMERS : c_int = 94; + } + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 131072; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + pub const MS_SYNC : c_int = 0x0010; + + pub const MS_KILLPAGES : c_int = 0x0004; + pub const MS_DEACTIVATE : c_int = 0x0008; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = EAGAIN; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const ENOTSUP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EPWROFF : c_int = 82; + pub const EDEVERR : c_int = 83; + pub const EOVERFLOW : c_int = 84; + pub const EBADEXEC : c_int = 85; + pub const EBADARCH : c_int = 86; + pub const ESHLIBVERS : c_int = 87; + pub const EBADMACHO : c_int = 88; + pub const ECANCELED : c_int = 89; + pub const EIDRM : c_int = 90; + pub const ENOMSG : c_int = 91; + pub const EILSEQ : c_int = 92; + pub const ENOATTR : c_int = 93; + pub const EBADMSG : c_int = 94; + pub const EMULTIHOP : c_int = 95; + pub const ENODATA : c_int = 96; + pub const ENOLINK : c_int = 97; + pub const ENOSR : c_int = 98; + pub const ENOSTR : c_int = 99; + pub const EPROTO : c_int = 100; + pub const ETIME : c_int = 101; + pub const EOPNOTSUPP : c_int = 102; + pub const ENOPOLICY : c_int = 103; + pub const ENOTRECOVERABLE : c_int = 104; + pub const EOWNERDEAD : c_int = 105; + pub const EQFULL : c_int = 106; + pub const ELAST : c_int = 106; + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const O_ACCMODE : c_int = 3; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x2000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 56; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; + pub const _SC_LOGIN_NAME_MAX : c_int = 73; + pub const _SC_MQ_PRIO_MAX : c_int = 75; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; + pub const _SC_THREAD_KEYS_MAX : c_int = 86; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; + pub const _SC_THREAD_STACK_MIN : c_int = 93; + pub const _SC_THREAD_THREADS_MAX : c_int = 94; + pub const _SC_THREADS : c_int = 96; + pub const _SC_TTY_NAME_MAX : c_int = 101; + pub const _SC_ATEXIT_MAX : c_int = 107; + pub const _SC_XOPEN_CRYPT : c_int = 108; + pub const _SC_XOPEN_ENH_I18N : c_int = 109; + pub const _SC_XOPEN_LEGACY : c_int = 110; + pub const _SC_XOPEN_REALTIME : c_int = 111; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; + pub const _SC_XOPEN_SHM : c_int = 113; + pub const _SC_XOPEN_UNIX : c_int = 115; + pub const _SC_XOPEN_VERSION : c_int = 116; + pub const _SC_XOPEN_XCU_VERSION : c_int = 121; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 1; + pub const PTHREAD_CREATE_DETACHED: c_int = 2; + pub const PTHREAD_STACK_MIN: size_t = 8192; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_AS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIM_NLIMITS: c_int = 9; + pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; + + pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 5; + pub const MADV_ZERO_WIRED_PAGES : c_int = 6; + pub const MADV_FREE_REUSABLE : c_int = 7; + pub const MADV_FREE_REUSE : c_int = 8; + pub const MADV_CAN_REUSE : c_int = 9; + + pub const MINCORE_INCORE : c_int = 0x1; + pub const MINCORE_REFERENCED : c_int = 0x2; + pub const MINCORE_MODIFIED : c_int = 0x4; + pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; + pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 30; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + + pub const TCP_NODELAY: c_int = 0x01; + pub const TCP_KEEPALIVE: c_int = 0x10; + pub const SOL_SOCKET: c_int = 0xffff; + + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_DSYNC : c_int = 4194304; + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const F_GETPATH : c_int = 50; + pub const F_FULLFSYNC : c_int = 51; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0020; + pub const MAP_NORESERVE : c_int = 0x0040; + pub const MAP_NOEXTEND : c_int = 0x0100; + pub const MAP_HASSEMAPHORE : c_int = 0x0200; + pub const MAP_NOCACHE : c_int = 0x0400; + pub const MAP_JIT : c_int = 0x0800; + pub const MAP_STACK : c_int = 0; + + pub const IPPROTO_RAW : c_int = 255; + + pub const SO_NREAD: c_int = 0x1020; + pub const SO_NKE: c_int = 0x1021; + pub const SO_NOSIGPIPE: c_int = 0x1022; + pub const SO_NOADDRERR: c_int = 0x1023; + pub const SO_NWRITE: c_int = 0x1024; + pub const SO_DONTTRUNC: c_int = 0x2000; + pub const SO_WANTMORE: c_int = 0x4000; + pub const SO_WANTOOBFLAG: c_int = 0x8000; + + pub const PATH_MAX: c_int = 1024; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_ASYNCHRONOUS_IO : c_int = 28; + pub const _SC_PAGESIZE : c_int = 29; + pub const _SC_MEMLOCK : c_int = 30; + pub const _SC_MEMLOCK_RANGE : c_int = 31; + pub const _SC_MEMORY_PROTECTION : c_int = 32; + pub const _SC_MESSAGE_PASSING : c_int = 33; + pub const _SC_PRIORITIZED_IO : c_int = 34; + pub const _SC_PRIORITY_SCHEDULING : c_int = 35; + pub const _SC_REALTIME_SIGNALS : c_int = 36; + pub const _SC_SEMAPHORES : c_int = 37; + pub const _SC_FSYNC : c_int = 38; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; + pub const _SC_SYNCHRONIZED_IO : c_int = 40; + pub const _SC_TIMERS : c_int = 41; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_DELAYTIMER_MAX : c_int = 45; + pub const _SC_MQ_OPEN_MAX : c_int = 46; + pub const _SC_MAPPED_FILES : c_int = 47; + pub const _SC_RTSIG_MAX : c_int = 48; + pub const _SC_SEM_NSEMS_MAX : c_int = 49; + pub const _SC_SEM_VALUE_MAX : c_int = 50; + pub const _SC_SIGQUEUE_MAX : c_int = 51; + pub const _SC_TIMER_MAX : c_int = 52; + pub const _SC_NPROCESSORS_CONF : c_int = 57; + pub const _SC_NPROCESSORS_ONLN : c_int = 58; + pub const _SC_2_PBS : c_int = 59; + pub const _SC_2_PBS_ACCOUNTING : c_int = 60; + pub const _SC_2_PBS_CHECKPOINT : c_int = 61; + pub const _SC_2_PBS_LOCATE : c_int = 62; + pub const _SC_2_PBS_MESSAGE : c_int = 63; + pub const _SC_2_PBS_TRACK : c_int = 64; + pub const _SC_ADVISORY_INFO : c_int = 65; + pub const _SC_BARRIERS : c_int = 66; + pub const _SC_CLOCK_SELECTION : c_int = 67; + pub const _SC_CPUTIME : c_int = 68; + pub const _SC_FILE_LOCKING : c_int = 69; + pub const _SC_HOST_NAME_MAX : c_int = 72; + pub const _SC_MONOTONIC_CLOCK : c_int = 74; + pub const _SC_READER_WRITER_LOCKS : c_int = 76; + pub const _SC_REGEXP : c_int = 77; + pub const _SC_SHELL : c_int = 78; + pub const _SC_SPAWN : c_int = 79; + pub const _SC_SPIN_LOCKS : c_int = 80; + pub const _SC_SPORADIC_SERVER : c_int = 81; + pub const _SC_THREAD_CPUTIME : c_int = 84; + pub const _SC_THREAD_SPORADIC_SERVER : c_int = 92; + pub const _SC_TIMEOUTS : c_int = 95; + pub const _SC_TRACE : c_int = 97; + pub const _SC_TRACE_EVENT_FILTER : c_int = 98; + pub const _SC_TRACE_INHERIT : c_int = 99; + pub const _SC_TRACE_LOG : c_int = 100; + pub const _SC_TYPED_MEMORY_OBJECTS : c_int = 102; + pub const _SC_V6_ILP32_OFF32 : c_int = 103; + pub const _SC_V6_ILP32_OFFBIG : c_int = 104; + pub const _SC_V6_LP64_OFF64 : c_int = 105; + pub const _SC_V6_LPBIG_OFFBIG : c_int = 106; + pub const _SC_IPV6 : c_int = 118; + pub const _SC_RAW_SOCKETS : c_int = 119; + pub const _SC_SYMLOOP_MAX : c_int = 120; + pub const _SC_PAGE_SIZE : c_int = _SC_PAGESIZE; + pub const _SC_XOPEN_STREAMS : c_int = 114; + pub const _SC_XBS5_ILP32_OFF32 : c_int = 122; + pub const _SC_XBS5_ILP32_OFFBIG : c_int = 123; + pub const _SC_XBS5_LP64_OFF64 : c_int = 124; + pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 125; + pub const _SC_SS_REPL_MAX : c_int = 126; + pub const _SC_TRACE_EVENT_NAME_MAX : c_int = 127; + pub const _SC_TRACE_NAME_MAX : c_int = 128; + pub const _SC_TRACE_SYS_MAX : c_int = 129; + pub const _SC_TRACE_USER_EVENT_MAX : c_int = 130; + pub const _SC_PASS_MAX : c_int = 131; + } + } +} + + +pub mod funcs { + // Thankfully most of c95 is universally available and does not vary by OS + // or anything. The same is not true of POSIX. + + pub mod c95 { + pub mod ctype { + use types::os::arch::c95::{c_char, c_int}; + + extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_char) -> c_char; + pub fn toupper(c: c_char) -> c_char; + } + } + + pub mod stdio { + use types::common::c95::{FILE, c_void, fpos_t}; + use types::os::arch::c95::{c_char, c_int, c_long, size_t}; + + extern { + pub fn fopen(filename: *const c_char, + mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) + -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, + newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t) + -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + // Omitted: printf and scanf variants. + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; + // Omitted: getc, getchar (might be macros). + + // Omitted: gets, so ridiculously unsafe that it should not + // survive. + + // Omitted: putc, putchar (might be macros). + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE) + -> size_t; + pub fn fwrite(ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE) + -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) + -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + } + } + + pub mod stdlib { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_double, c_int}; + use types::os::arch::c95::{c_long, c_uint, c_ulong}; + use types::os::arch::c95::{size_t}; + + extern { + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + // Omitted: div, ldiv (return pub type incomplete). + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn strtod(s: *const c_char, + endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, + endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + // Omitted: bsearch, qsort + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + } + } + + pub mod string { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, size_t}; + use types::os::arch::c95::{wchar_t}; + + extern { + pub fn strcpy(dst: *mut c_char, + src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) + -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, + n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, + n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strpbrk(cs: *const c_char, + ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, + ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, + n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + + // Omitted: memcpy, memmove, memset (provided by LLVM) + + // These are fine to execute on the Rust stack. They must be, + // in fact, because LLVM generates calls to them! + pub fn memcmp(cx: *const c_void, ct: *const c_void, + n: size_t) -> c_int; + pub fn memchr(cx: *const c_void, c: c_int, + n: size_t) -> *mut c_void; + } + } + } + + // Microsoft helpfully underscore-qualifies all of its POSIX-like symbols + // to make sure you don't use them accidentally. It also randomly deviates + // from the exact signatures you might otherwise expect, and omits much, + // so be careful when trying to write portable code; it won't always work + // with the same POSIX functions and types as other platforms. + + #[cfg(target_os = "windows")] + pub mod posix88 { + pub mod stat_ { + use types::os::common::posix01::{stat, utimbuf}; + use types::os::arch::c95::{c_int, c_char, wchar_t}; + + extern { + #[link_name = "_chmod"] + pub fn chmod(path: *const c_char, mode: c_int) -> c_int; + #[link_name = "_wchmod"] + pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; + #[link_name = "_mkdir"] + pub fn mkdir(path: *const c_char) -> c_int; + #[link_name = "_wrmdir"] + pub fn wrmdir(path: *const wchar_t) -> c_int; + #[link_name = "_fstat64"] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + #[link_name = "_stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + #[link_name = "_wstat64"] + pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; + #[link_name = "_wutime64"] + pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; + } + } + + pub mod stdio { + use types::common::c95::FILE; + use types::os::arch::c95::{c_int, c_char}; + + extern { + #[link_name = "_popen"] + pub fn popen(command: *const c_char, + mode: *const c_char) -> *mut FILE; + #[link_name = "_pclose"] + pub fn pclose(stream: *mut FILE) -> c_int; + #[link_name = "_fdopen"] + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; + #[link_name = "_fileno"] + pub fn fileno(stream: *mut FILE) -> c_int; + } + } + + pub mod fcntl { + use types::os::arch::c95::{c_int, c_char, wchar_t}; + extern { + #[link_name = "_open"] + pub fn open(path: *const c_char, oflag: c_int, mode: c_int) + -> c_int; + #[link_name = "_wopen"] + pub fn wopen(path: *const wchar_t, oflag: c_int, mode: c_int) + -> c_int; + #[link_name = "_creat"] + pub fn creat(path: *const c_char, mode: c_int) -> c_int; + } + } + + pub mod dirent { + // Not supplied at all. + } + + pub mod unistd { + use types::common::c95::c_void; + use types::os::arch::c95::{c_int, c_uint, c_char, + c_long, size_t}; + use types::os::arch::c99::intptr_t; + + extern { + #[link_name = "_access"] + pub fn access(path: *const c_char, amode: c_int) -> c_int; + #[link_name = "_chdir"] + pub fn chdir(dir: *const c_char) -> c_int; + #[link_name = "_close"] + pub fn close(fd: c_int) -> c_int; + #[link_name = "_dup"] + pub fn dup(fd: c_int) -> c_int; + #[link_name = "_dup2"] + pub fn dup2(src: c_int, dst: c_int) -> c_int; + #[link_name = "_execv"] + pub fn execv(prog: *const c_char, + argv: *const *const c_char) -> intptr_t; + #[link_name = "_execve"] + pub fn execve(prog: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) + -> c_int; + #[link_name = "_execvp"] + pub fn execvp(c: *const c_char, + argv: *const *const c_char) -> c_int; + #[link_name = "_execvpe"] + pub fn execvpe(c: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) -> c_int; + #[link_name = "_getcwd"] + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + #[link_name = "_getpid"] + pub fn getpid() -> c_int; + #[link_name = "_isatty"] + pub fn isatty(fd: c_int) -> c_int; + #[link_name = "_lseek"] + pub fn lseek(fd: c_int, offset: c_long, origin: c_int) + -> c_long; + #[link_name = "_pipe"] + pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) + -> c_int; + #[link_name = "_read"] + pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) + -> c_int; + #[link_name = "_rmdir"] + pub fn rmdir(path: *const c_char) -> c_int; + #[link_name = "_unlink"] + pub fn unlink(c: *const c_char) -> c_int; + #[link_name = "_write"] + pub fn write(fd: c_int, buf: *const c_void, + count: c_uint) -> c_int; + } + } + + pub mod mman { + } + } + + #[cfg(any(target_os = "linux", + target_os = "android", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd", + target_os = "nacl"))] + pub mod posix88 { + pub mod stat_ { + use types::os::arch::c95::{c_char, c_int}; + use types::os::arch::posix01::stat; + use types::os::arch::posix88::mode_t; + + extern { + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd", + target_os = "android", + target_os = "ios", + target_os = "nacl"))] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + + #[cfg(target_os = "macos")] + #[link_name = "fstat64"] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; + #[cfg(not(target_os = "nacl"))] + pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd", + target_os = "android", + target_os = "ios", + target_os = "nacl"))] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + + #[cfg(target_os = "macos")] + #[link_name = "stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + } + } + + pub mod stdio { + use types::common::c95::FILE; + use types::os::arch::c95::{c_char, c_int}; + + extern { + pub fn popen(command: *const c_char, + mode: *const c_char) -> *mut FILE; + pub fn pclose(stream: *mut FILE) -> c_int; + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; + pub fn fileno(stream: *mut FILE) -> c_int; + } + } + + pub mod fcntl { + use types::os::arch::c95::{c_char, c_int}; + use types::os::arch::posix88::mode_t; + + mod open_shim { + extern { + #[cfg(any(target_os = "macos", + target_os = "ios"))] + pub fn open(path: *const ::c_char, oflag: ::c_int, ...) + -> ::c_int; + + #[cfg(not(any(target_os = "macos", + target_os = "ios")))] + pub fn open(path: *const ::c_char, oflag: ::c_int, mode: ::mode_t) + -> ::c_int; + } + } + + #[cfg(any(target_os = "macos", + target_os = "ios"))] + #[inline] + pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { + use types::os::arch::c95::c_uint; + open_shim::open(path, oflag, mode as c_uint) + } + + #[cfg(not(any(target_os = "macos", + target_os = "ios")))] + #[inline] + pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { + open_shim::open(path, oflag, mode) + } + + extern { + pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; + } + } + + pub mod dirent { + use types::common::posix88::{DIR, dirent_t}; + use types::os::arch::c95::{c_char, c_int, c_long}; + + // NB: On OS X opendir and readdir have two versions, + // one for 32-bit kernelspace and one for 64. + // We should be linking to the 64-bit ones, called + // opendir$INODE64, etc. but for some reason rustc + // doesn't link it correctly on i686, so we're going + // through a C function that mysteriously does work. + + extern { + #[link_name="rust_opendir"] + pub fn opendir(dirname: *const c_char) -> *mut DIR; + #[link_name="rust_readdir_r"] + pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent_t, + result: *mut *mut dirent_t) -> c_int; + } + + extern { + pub fn closedir(dirp: *mut DIR) -> c_int; + pub fn rewinddir(dirp: *mut DIR); + pub fn seekdir(dirp: *mut DIR, loc: c_long); + pub fn telldir(dirp: *mut DIR) -> c_long; + } + } + + pub mod unistd { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, c_long, c_uint}; + use types::os::arch::c95::{size_t}; + use types::os::common::posix01::timespec; + use types::os::arch::posix01::utimbuf; + use types::os::arch::posix88::{gid_t, off_t, pid_t}; + use types::os::arch::posix88::{ssize_t, uid_t}; + + pub const _PC_NAME_MAX: c_int = 4; + + #[cfg(not(target_os = "nacl"))] + extern { + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn alarm(seconds: c_uint) -> c_uint; + pub fn chdir(dir: *const c_char) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, + gid: gid_t) -> c_int; + pub fn close(fd: c_int) -> c_int; + pub fn dup(fd: c_int) -> c_int; + pub fn dup2(src: c_int, dst: c_int) -> c_int; + pub fn execv(prog: *const c_char, + argv: *const *const c_char) -> c_int; + pub fn execve(prog: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) + -> c_int; + pub fn execvp(c: *const c_char, + argv: *const *const c_char) -> c_int; + pub fn fork() -> pid_t; + pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) + -> c_int; + pub fn getlogin() -> *mut c_char; + // GNU getopt(3) modifies its arguments despite the + // char * const [] prototype; see the manpage. + pub fn getopt(argc: c_int, argv: *mut *mut c_char, + optstr: *const c_char) -> c_int; + pub fn getpgrp() -> pid_t; + pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getuid() -> uid_t; + pub fn getsid(pid: pid_t) -> pid_t; + pub fn isatty(fd: c_int) -> c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) + -> off_t; + pub fn pathconf(path: *mut c_char, name: c_int) -> c_long; + pub fn pause() -> c_int; + pub fn pipe(fds: *mut c_int) -> c_int; + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) + -> ssize_t; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn setgid(gid: gid_t) -> c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; + pub fn setsid() -> pid_t; + pub fn setuid(uid: uid_t) -> c_int; + pub fn sleep(secs: c_uint) -> c_uint; + pub fn usleep(secs: c_uint) -> c_int; + pub fn nanosleep(rqtp: *const timespec, + rmtp: *mut timespec) -> c_int; + pub fn sysconf(name: c_int) -> c_long; + pub fn tcgetpgrp(fd: c_int) -> pid_t; + pub fn ttyname(fd: c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> c_int; + pub fn wait(status: *const c_int) -> pid_t; + pub fn waitpid(pid: pid_t, status: *const c_int, options: c_int) + -> pid_t; + pub fn write(fd: c_int, buf: *const c_void, count: size_t) + -> ssize_t; + pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; + } + #[cfg(target_os = "nacl")] + extern { + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn chdir(dir: *const c_char) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, + gid: gid_t) -> c_int; + pub fn close(fd: c_int) -> c_int; + pub fn dup(fd: c_int) -> c_int; + pub fn dup2(src: c_int, dst: c_int) -> c_int; + pub fn execv(prog: *const c_char, + argv: *const *const c_char) -> c_int; + pub fn execve(prog: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) + -> c_int; + pub fn execvp(c: *const c_char, + argv: *const *const c_char) -> c_int; + pub fn fork() -> pid_t; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getlogin() -> *mut c_char; + pub fn getopt(argc: c_int, argv: *const *const c_char, + optstr: *const c_char) -> c_int; + pub fn getuid() -> uid_t; + pub fn getsid(pid: pid_t) -> pid_t; + pub fn isatty(fd: c_int) -> c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) + -> off_t; + pub fn pipe(fds: *mut c_int) -> c_int; + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) + -> ssize_t; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn setgid(gid: gid_t) -> c_int; + pub fn setuid(uid: uid_t) -> c_int; + pub fn sleep(secs: c_uint) -> c_uint; + pub fn usleep(secs: c_uint) -> c_int; + pub fn nanosleep(rqtp: *const timespec, + rmtp: *mut timespec) -> c_int; + pub fn sysconf(name: c_int) -> c_long; + pub fn ttyname(fd: c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> c_int; + pub fn wait(status: *const c_int) -> pid_t; + pub fn waitpid(pid: pid_t, status: *const c_int, options: c_int) + -> pid_t; + pub fn write(fd: c_int, buf: *const c_void, count: size_t) + -> ssize_t; + pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; + } + } + + pub mod signal { + use types::os::arch::c95::{c_int}; + use types::os::arch::posix88::{pid_t}; + + extern { + pub fn kill(pid: pid_t, sig: c_int) -> c_int; + } + } + + pub mod mman { + use types::common::c95::{c_void}; + use types::os::arch::c95::{size_t, c_int, c_char}; + use types::os::arch::posix88::{mode_t, off_t}; + + #[cfg(not(target_os = "nacl"))] + extern { + pub fn mlock(addr: *const c_void, len: size_t) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlockall() -> c_int; + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) + -> c_int; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) + -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) + -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + } + + extern { + pub fn mmap(addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t) + -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + } + } + + pub mod net { + use types::os::arch::c95::{c_char, c_uint}; + + extern { + pub fn if_nametoindex(ifname: *const c_char) -> c_uint; + } + } + + } + + #[cfg(any(target_os = "linux", + target_os = "android", + target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd", + target_os = "nacl"))] + pub mod posix01 { + pub mod stat_ { + use types::os::arch::c95::{c_char, c_int}; + use types::os::arch::posix01::stat; + + extern { + #[cfg(any(target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd", + target_os = "android", + target_os = "ios", + target_os = "nacl"))] + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + + #[cfg(target_os = "macos")] + #[link_name = "lstat64"] + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + } + } + + pub mod unistd { + use types::os::arch::c95::{c_char, c_int, size_t}; + use types::os::arch::posix88::{ssize_t, off_t}; + + extern { + pub fn readlink(path: *const c_char, + buf: *mut c_char, + bufsz: size_t) + -> ssize_t; + + pub fn fsync(fd: c_int) -> c_int; + + #[cfg(any(target_os = "linux", target_os = "android"))] + pub fn fdatasync(fd: c_int) -> c_int; + + pub fn setenv(name: *const c_char, val: *const c_char, + overwrite: c_int) -> c_int; + pub fn unsetenv(name: *const c_char) -> c_int; + pub fn putenv(string: *mut c_char) -> c_int; + + pub fn symlink(path1: *const c_char, + path2: *const c_char) -> c_int; + + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + } + } + + pub mod signal { + use types::os::arch::c95::c_int; + use types::os::common::posix01::sighandler_t; + + #[cfg(not(all(target_os = "android", any(target_arch = "arm", + target_arch = "x86"))))] + extern { + pub fn signal(signum: c_int, + handler: sighandler_t) -> sighandler_t; + } + + #[cfg(all(target_os = "android", any(target_arch = "arm", + target_arch = "x86")))] + extern { + #[link_name = "bsd_signal"] + pub fn signal(signum: c_int, + handler: sighandler_t) -> sighandler_t; + } + } + + pub mod glob { + use types::os::arch::c95::{c_char, c_int}; + use types::os::common::posix01::{glob_t}; + + extern { + pub fn glob(pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut glob_t); + pub fn globfree(pglob: *mut glob_t); + } + } + + pub mod mman { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_int, size_t}; + + #[cfg(not(target_os = "nacl"))] + extern { + pub fn posix_madvise(addr: *mut c_void, + len: size_t, + advice: c_int) + -> c_int; + } + } + + pub mod resource { + use types::os::arch::c95::c_int; + use types::os::common::posix01::rlimit; + use types::os::common::bsd43::rusage; + extern { + pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; + pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; + + } + } + } + + #[cfg(target_os = "windows")] + pub mod posix01 { + pub mod stat_ { + } + + pub mod unistd { + } + + pub mod glob { + } + + pub mod mman { + } + + pub mod net { + } + } + + + #[cfg(any(target_os = "android", + target_os = "bitrig", + target_os = "dragonfly", + target_os = "ios", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "nacl", + target_os = "netbsd", + target_os = "openbsd", + target_os = "windows"))] + pub mod posix08 { + pub mod unistd { + } + } + + #[cfg(not(windows))] + pub mod bsd43 { + use types::common::c95::{c_void}; + use types::os::common::bsd44::{socklen_t, sockaddr, ifaddrs}; + use types::os::arch::c95::{c_int, size_t}; + use types::os::arch::posix88::ssize_t; + + extern "system" { + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; + pub fn connect(socket: c_int, address: *const sockaddr, + len: socklen_t) -> c_int; + pub fn bind(socket: c_int, address: *const sockaddr, + address_len: socklen_t) -> c_int; + pub fn listen(socket: c_int, backlog: c_int) -> c_int; + pub fn accept(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn getpeername(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn getsockname(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn setsockopt(socket: c_int, level: c_int, name: c_int, + value: *const c_void, + option_len: socklen_t) -> c_int; + pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, + flags: c_int) -> ssize_t; + pub fn send(socket: c_int, buf: *const c_void, len: size_t, + flags: c_int) -> ssize_t; + pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ssize_t; + pub fn sendto(socket: c_int, buf: *const c_void, len: size_t, + flags: c_int, addr: *const sockaddr, + addrlen: socklen_t) -> ssize_t; + pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut ifaddrs); + pub fn shutdown(socket: c_int, how: c_int) -> c_int; + } + } + + #[cfg(windows)] + pub mod bsd43 { + use types::common::c95::{c_void}; + use types::os::common::bsd44::{socklen_t, sockaddr, SOCKET}; + use types::os::arch::c95::c_int; + + extern "system" { + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; + pub fn connect(socket: SOCKET, address: *const sockaddr, + len: socklen_t) -> c_int; + pub fn bind(socket: SOCKET, address: *const sockaddr, + address_len: socklen_t) -> c_int; + pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; + pub fn accept(socket: SOCKET, address: *mut sockaddr, + address_len: *mut socklen_t) -> SOCKET; + pub fn getpeername(socket: SOCKET, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn getsockname(socket: SOCKET, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, + value: *const c_void, + option_len: socklen_t) -> c_int; + pub fn closesocket(socket: SOCKET) -> c_int; + pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, + flags: c_int) -> c_int; + pub fn send(socket: SOCKET, buf: *const c_void, len: c_int, + flags: c_int) -> c_int; + pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut c_int) -> c_int; + pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int, + flags: c_int, addr: *const sockaddr, + addrlen: c_int) -> c_int; + pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; + } + } + + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd"))] + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t}; + + extern { + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + pub fn sysctl(name: *mut c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn sysctlbyname(name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn sysctlnametomib(name: *const c_char, + mibp: *mut c_int, + sizep: *mut size_t) + -> c_int; + pub fn getdtablesize() -> c_int; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) + -> c_int; + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) + -> c_int; + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) + -> *mut c_char; + pub fn flock(fd: c_int, operation: c_int) -> c_int; + } + } + + #[cfg(any(target_os = "linux", target_os = "android"))] + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_uchar, c_int, size_t}; + #[cfg(not(feature = "cargo-build"))] + use types::os::arch::c95::c_ulong; + + extern { + #[cfg(not(all(target_os = "android", target_arch = "aarch64")))] + pub fn getdtablesize() -> c_int; + + // Note that the correct signature of ioctl broke some crates on + // crates.io, so for now we keep the broken signature for crates.io + // but we fix it locally in the main Rust distribution. Once a new + // major version of libc is released on crates.io this #[cfg] should + // go away. + #[cfg(feature = "cargo-build")] + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + #[cfg(not(feature = "cargo-build"))] + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) + -> c_int; + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) + -> c_int; + pub fn flock(fd: c_int, operation: c_int) -> c_int; + } + } + + #[cfg(target_os = "nacl")] + pub mod bsd44 { + use types::os::arch::c95::c_int; + extern { + pub fn getdtablesize() -> c_int; + } + } + + #[cfg(target_os = "windows")] + pub mod bsd44 { + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod extra { + use types::os::arch::c95::{c_char, c_int}; + + extern { + pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32) + -> c_int; + } + } + + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd"))] + pub mod extra { + } + + #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] + pub mod extra { + } + + + #[cfg(target_os = "windows")] + pub mod extra { + + pub mod kernel32 { + use types::os::arch::c95::{c_uint}; + use types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE, + LPCWSTR, LPWSTR, + LPWCH, LPDWORD, LPVOID, + LPCVOID, LPOVERLAPPED, + LPSECURITY_ATTRIBUTES, + LPSTARTUPINFO, + LPPROCESS_INFORMATION, + LPMEMORY_BASIC_INFORMATION, + LPSYSTEM_INFO, HANDLE, LPHANDLE, + LARGE_INTEGER, PLARGE_INTEGER, + LPFILETIME, LPWIN32_FIND_DATAW}; + + extern "system" { + pub fn GetEnvironmentVariableW(n: LPCWSTR, + v: LPWSTR, + nsize: DWORD) + -> DWORD; + pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) + -> BOOL; + pub fn GetEnvironmentStringsW() -> LPWCH; + pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL; + pub fn GetModuleFileNameW(hModule: HMODULE, + lpFilename: LPWSTR, + nSize: DWORD) + -> DWORD; + pub fn CreateDirectoryW(lpPathName: LPCWSTR, + lpSecurityAttributes: + LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn CopyFileW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + bFailIfExists: BOOL) + -> BOOL; + pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL; + pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetCurrentDirectoryW(nBufferLength: DWORD, + lpBuffer: LPWSTR) + -> DWORD; + pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetLastError() -> DWORD; + pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) + -> HANDLE; + pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) + -> BOOL; + pub fn FindClose(findFile: HANDLE) -> BOOL; + pub fn DuplicateHandle(hSourceProcessHandle: HANDLE, + hSourceHandle: HANDLE, + hTargetProcessHandle: HANDLE, + lpTargetHandle: LPHANDLE, + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwOptions: DWORD) + -> BOOL; + pub fn CloseHandle(hObject: HANDLE) -> BOOL; + pub fn OpenProcess(dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwProcessId: DWORD) + -> HANDLE; + pub fn GetCurrentProcess() -> HANDLE; + pub fn CreateProcessW(lpApplicationName: LPCWSTR, + lpCommandLine: LPWSTR, + lpProcessAttributes: + LPSECURITY_ATTRIBUTES, + lpThreadAttributes: + LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpEnvironment: LPVOID, + lpCurrentDirectory: LPCWSTR, + lpStartupInfo: LPSTARTUPINFO, + lpProcessInformation: + LPPROCESS_INFORMATION) + -> BOOL; + pub fn WaitForSingleObject(hHandle: HANDLE, + dwMilliseconds: DWORD) + -> DWORD; + pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) + -> BOOL; + pub fn GetExitCodeProcess(hProcess: HANDLE, + lpExitCode: LPDWORD) + -> BOOL; + pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); + pub fn VirtualAlloc(lpAddress: LPVOID, + dwSize: SIZE_T, + flAllocationType: DWORD, + flProtect: DWORD) + -> LPVOID; + pub fn VirtualFree(lpAddress: LPVOID, + dwSize: SIZE_T, + dwFreeType: DWORD) + -> BOOL; + pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; + pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) + -> BOOL; + pub fn VirtualProtect(lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, + lpflOldProtect: LPDWORD) + -> BOOL; + pub fn VirtualQuery(lpAddress: LPCVOID, + lpBuffer: LPMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T) + -> SIZE_T; + pub fn CreateFileMappingW(hFile: HANDLE, + lpAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR) + -> HANDLE; + pub fn MapViewOfFile(hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, + dwNumberOfBytesToMap: SIZE_T) + -> LPVOID; + pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; + pub fn MoveFileExW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + dwFlags: DWORD) -> BOOL; + pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR, + lpTargetFileName: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; + pub fn CreateFileW(lpFileName: LPCWSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE) -> HANDLE; + pub fn ReadFile(hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToRead: DWORD, + lpNumberOfBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WriteFile(hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToWrite: DWORD, + lpNumberOfBytesWritten: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn SetFilePointerEx(hFile: HANDLE, + liDistanceToMove: LARGE_INTEGER, + lpNewFilePointer: PLARGE_INTEGER, + dwMoveMethod: DWORD) -> BOOL; + pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; + + pub fn GetSystemTimeAsFileTime( + lpSystemTimeAsFileTime: LPFILETIME); + + pub fn QueryPerformanceFrequency( + lpFrequency: *mut LARGE_INTEGER) -> BOOL; + pub fn QueryPerformanceCounter( + lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL; + + pub fn GetCurrentProcessId() -> DWORD; + pub fn CreateNamedPipeW( + lpName: LPCWSTR, + dwOpenMode: DWORD, + dwPipeMode: DWORD, + nMaxInstances: DWORD, + nOutBufferSize: DWORD, + nInBufferSize: DWORD, + nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES + ) -> HANDLE; + pub fn ConnectNamedPipe(hNamedPipe: HANDLE, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, + nTimeOut: DWORD) -> BOOL; + pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE, + lpMode: LPDWORD, + lpMaxCollectionCount: LPDWORD, + lpCollectDataTimeout: LPDWORD) + -> BOOL; + pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + bInitialState: BOOL, + lpName: LPCWSTR) -> HANDLE; + pub fn GetOverlappedResult(hFile: HANDLE, + lpOverlapped: LPOVERLAPPED, + lpNumberOfBytesTransferred: LPDWORD, + bWait: BOOL) -> BOOL; + pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; + } + } + + pub mod msvcrt { + use types::os::arch::c95::{c_int, c_long}; + use types::os::arch::c99::intptr_t; + + extern { + #[link_name = "_commit"] + pub fn commit(fd: c_int) -> c_int; + + #[link_name = "_get_osfhandle"] + pub fn get_osfhandle(fd: c_int) -> c_long; + + #[link_name = "_open_osfhandle"] + pub fn open_osfhandle(osfhandle: intptr_t, + flags: c_int) -> c_int; + } + } + + pub mod winsock { + use types::os::arch::c95::{c_int, c_long, c_ulong}; + use types::os::common::bsd44::SOCKET; + + extern "system" { + pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int; + } + } + } +} From 8e5f0cd827041b0713d6f302504ec66fbe251e5e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 22:46:19 -0700 Subject: [PATCH 002/194] Add skeleton testing framework --- .gitignore | 4 +- libc-test/Cargo.lock | 100 +++++++++++++++++++++++++++++++ libc-test/Cargo.toml | 17 ++++++ libc-test/build.rs | 130 +++++++++++++++++++++++++++++++++++++++++ libc-test/src/lib.rs | 0 libc-test/tests/all.rs | 5 ++ 6 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 libc-test/Cargo.lock create mode 100644 libc-test/Cargo.toml create mode 100644 libc-test/build.rs create mode 100644 libc-test/src/lib.rs create mode 100644 libc-test/tests/all.rs diff --git a/.gitignore b/.gitignore index 4fffb2f89cbd8..a9d37c560c6ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/target -/Cargo.lock +target +Cargo.lock diff --git a/libc-test/Cargo.lock b/libc-test/Cargo.lock new file mode 100644 index 0000000000000..23d47b0a50e2c --- /dev/null +++ b/libc-test/Cargo.lock @@ -0,0 +1,100 @@ +[root] +name = "libc-test" +version = "0.1.0" +dependencies = [ + "gcc 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.10", + "syntex_syntax 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "advapi32-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "gcc" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.1.10" + +[[package]] +name = "libc" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-serialize" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "syntex_syntax" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "term 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "term" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-xid" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml new file mode 100644 index 0000000000000..dfad9b72730b9 --- /dev/null +++ b/libc-test/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "libc-test" +version = "0.1.0" +authors = ["Alex Crichton "] +build = "build.rs" + +[dependencies] +libc = { path = ".." } + +[build-dependencies] +syntex_syntax = "*" +gcc = "0.3" + +[lib] +name = "libc_test" +test = false +doctest = false diff --git a/libc-test/build.rs b/libc-test/build.rs new file mode 100644 index 0000000000000..556e7575a7b08 --- /dev/null +++ b/libc-test/build.rs @@ -0,0 +1,130 @@ +#![allow(unused_must_use)] + +extern crate gcc; +extern crate syntex_syntax as syntax; + +use std::env; +use std::fs::File; +use std::io::BufWriter; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; + +use syntax::ast; +use syntax::parse::token::InternedString; +use syntax::attr; +use syntax::parse::{self, ParseSess}; +use syntax::visit::{self, Visitor}; + +struct TestGenerator { + rust: Box, + c: Box, +} + +fn main() { + let sess = ParseSess::new(); + + let src = Path::new("../src/lib.rs"); + let cfg = Vec::new(); + let mut krate = parse::parse_crate_from_file(src, cfg, &sess); + build_cfg(&mut krate.config); + + let mut gated_cfgs = Vec::new(); + let krate = syntax::config::strip_unconfigured_items(&sess.span_diagnostic, + krate, + &mut gated_cfgs); + + let out = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let rust_out = BufWriter::new(File::create(out.join("all.rs")).unwrap()); + let mut c_out = BufWriter::new(File::create(out.join("all.c")).unwrap()); + + writeln!(c_out, " +#include +#include +#include +#include +#include +#include +"); + + visit::walk_crate(&mut TestGenerator { + rust: Box::new(rust_out), + c: Box::new(c_out), + }, &krate); + + gcc::Config::new() + .file(out.join("all.c")) + .compile("liball.a"); +} + +fn build_cfg(cfg: &mut ast::CrateConfig) { + let target = env::var("TARGET").unwrap(); + + let (arch, target_pointer_width) = if target.starts_with("x86_64") { + ("x86_64", "64") + } else if target.starts_with("i686") { + ("x86", "32") + } else { + panic!("unknown arch/pointer width: {}", target) + }; + let (os, family, env) = if target.contains("unknown-linux") { + ("linux", "unix", "gnu") + } else { + panic!("unknown os/family width: {}", target) + }; + + let mk = attr::mk_name_value_item_str; + let s = InternedString::new; + cfg.push(attr::mk_word_item(s(family))); + cfg.push(mk(s("target_os"), s(os))); + cfg.push(mk(s("target_family"), s(family))); + cfg.push(mk(s("target_arch"), s(arch))); + // skip endianness + cfg.push(mk(s("target_pointer_width"), s(target_pointer_width))); + cfg.push(mk(s("target_env"), s(env))); +} + +impl TestGenerator { + fn typedef(&mut self, ty: &str) { + let cty = if ty.starts_with("c_") { + let rest = ty[2..].replace("long", " long"); + if rest.starts_with("u") { + format!("unsigned {}", &rest[1..]) + } else { + rest + } + } else { + (match ty { + ty => ty, + }).to_string() + }; + writeln!(self.c, r#" + uint64_t ty_{ty}_size() {{ + return sizeof({cty}); + }} + "#, ty = ty, cty = cty); + writeln!(self.rust, r#" + #[test] + fn test_{ty}_size() {{ + extern {{ fn ty_{ty}_size() -> u64; }} + assert_eq!(mem::size_of::() as u64, + unsafe {{ ty_{ty}_size() }}); + }} + "#, ty = ty); + } +} + +impl<'v> Visitor<'v> for TestGenerator { + fn visit_item(&mut self, i: &'v ast::Item) { + match i.node { + ast::ItemTy(_, ref generics) => { + assert!(generics.lifetimes.len() == 0); + assert!(generics.ty_params.len() == 0); + assert!(generics.where_clause.predicates.len() == 0); + self.typedef(&i.ident.to_string()); + } + + _ => {} + } + visit::walk_item(self, i) + } +} diff --git a/libc-test/src/lib.rs b/libc-test/src/lib.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs new file mode 100644 index 0000000000000..1f615b3cfeb7a --- /dev/null +++ b/libc-test/tests/all.rs @@ -0,0 +1,5 @@ +extern crate libc; +extern crate libc_test; + +#[cfg(test)] +include!(concat!(env!("OUT_DIR"), "/all.rs")); From 1608306b1b448ccde5a04836095014699d91442c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 22:59:24 -0700 Subject: [PATCH 003/194] Get size/align tests working for typedefs --- libc-test/build.rs | 45 +++++++++++++++++++++++++++++++----------- libc-test/tests/all.rs | 2 ++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 556e7575a7b08..7bfa8720a6dab 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -21,12 +21,13 @@ struct TestGenerator { } fn main() { - let sess = ParseSess::new(); + let target = env::var("TARGET").unwrap(); + let sess = ParseSess::new(); let src = Path::new("../src/lib.rs"); let cfg = Vec::new(); let mut krate = parse::parse_crate_from_file(src, cfg, &sess); - build_cfg(&mut krate.config); + build_cfg(&mut krate.config, &target); let mut gated_cfgs = Vec::new(); let krate = syntax::config::strip_unconfigured_items(&sess.span_diagnostic, @@ -41,10 +42,20 @@ fn main() { #include #include #include +#include +#include #include +#include #include #include +#include +"); + + if target.contains("apple-darwin") { + writeln!(c_out, " +#include "); + } visit::walk_crate(&mut TestGenerator { rust: Box::new(rust_out), @@ -56,9 +67,7 @@ fn main() { .compile("liball.a"); } -fn build_cfg(cfg: &mut ast::CrateConfig) { - let target = env::var("TARGET").unwrap(); - +fn build_cfg(cfg: &mut ast::CrateConfig, target: &str) { let (arch, target_pointer_width) = if target.starts_with("x86_64") { ("x86_64", "64") } else if target.starts_with("i686") { @@ -68,6 +77,8 @@ fn build_cfg(cfg: &mut ast::CrateConfig) { }; let (os, family, env) = if target.contains("unknown-linux") { ("linux", "unix", "gnu") + } else if target.contains("apple-darwin") { + ("macos", "unix", "") } else { panic!("unknown os/family width: {}", target) }; @@ -89,25 +100,35 @@ impl TestGenerator { let rest = ty[2..].replace("long", " long"); if rest.starts_with("u") { format!("unsigned {}", &rest[1..]) + } else if rest.starts_with("s") && rest != "short" { + format!("signed {}", &rest[1..]) } else { rest } } else { (match ty { + "sighandler_t" => return, ty => ty, }).to_string() }; + writeln!(self.c, r#" - uint64_t ty_{ty}_size() {{ - return sizeof({cty}); - }} + uint64_t ty_{ty}_size() {{ return sizeof({cty}); }} + uint64_t ty_{ty}_align() {{ return alignof({cty}); }} "#, ty = ty, cty = cty); writeln!(self.rust, r#" #[test] - fn test_{ty}_size() {{ - extern {{ fn ty_{ty}_size() -> u64; }} - assert_eq!(mem::size_of::() as u64, - unsafe {{ ty_{ty}_size() }}); + fn sanity_{ty}() {{ + extern {{ + fn ty_{ty}_size() -> u64; + fn ty_{ty}_align() -> u64; + }} + unsafe {{ + assert_eq!(mem::size_of::() as u64, + ty_{ty}_size()); + assert_eq!(mem::align_of::() as u64, + ty_{ty}_align()); + }} }} "#, ty = ty); } diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 1f615b3cfeb7a..94a0600013d30 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -1,5 +1,7 @@ extern crate libc; extern crate libc_test; +use std::mem; + #[cfg(test)] include!(concat!(env!("OUT_DIR"), "/all.rs")); From a9adfbf56cdc0999d120fe5150e72874ddfcda7b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 23:21:27 -0700 Subject: [PATCH 004/194] Test size/align of structs --- libc-test/build.rs | 85 ++++++++++++++++++++++++++++++++---------- libc-test/tests/all.rs | 3 ++ src/lib.rs | 18 ++++++--- 3 files changed, 80 insertions(+), 26 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7bfa8720a6dab..bcdb412c2abec 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -10,14 +10,16 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use syntax::ast; +use syntax::diagnostic::SpanHandler; use syntax::parse::token::InternedString; -use syntax::attr; +use syntax::attr::{self, ReprAttr}; use syntax::parse::{self, ParseSess}; use syntax::visit::{self, Visitor}; -struct TestGenerator { +struct TestGenerator<'a> { rust: Box, c: Box, + sh: &'a SpanHandler, } fn main() { @@ -39,15 +41,24 @@ fn main() { let mut c_out = BufWriter::new(File::create(out.join("all.c")).unwrap()); writeln!(c_out, " +#include +#include +#include #include #include +#include #include #include #include #include #include +#include +#include +#include #include +#include #include +#include #include "); @@ -60,6 +71,7 @@ fn main() { visit::walk_crate(&mut TestGenerator { rust: Box::new(rust_out), c: Box::new(c_out), + sh: &sess.span_diagnostic, }, &krate); gcc::Config::new() @@ -94,8 +106,8 @@ fn build_cfg(cfg: &mut ast::CrateConfig, target: &str) { cfg.push(mk(s("target_env"), s(env))); } -impl TestGenerator { - fn typedef(&mut self, ty: &str) { +impl<'a> TestGenerator<'a> { + fn test_type(&mut self, ty: &str) { let cty = if ty.starts_with("c_") { let rest = ty[2..].replace("long", " long"); if rest.starts_with("u") { @@ -111,37 +123,70 @@ impl TestGenerator { ty => ty, }).to_string() }; + self.test_size_align(ty, &cty); + } + + fn test_struct(&mut self, ty: &str, _s: &ast::StructDef) { + let cty = if ty.starts_with("pthread") || ty == "glob_t" { + ty.to_string() + } else if ty == "ip6_mreq" { + "struct ipv6_mreq".to_string() + } else { + format!("struct {}", ty) + }; + self.test_size_align(ty, &cty); + } + fn test_size_align(&mut self, rust: &str, c: &str) { writeln!(self.c, r#" - uint64_t ty_{ty}_size() {{ return sizeof({cty}); }} - uint64_t ty_{ty}_align() {{ return alignof({cty}); }} - "#, ty = ty, cty = cty); + uint64_t __test_size_{ty}() {{ return sizeof({cty}); }} + uint64_t __test_align_{ty}() {{ return alignof({cty}); }} + "#, ty = rust, cty = c); writeln!(self.rust, r#" #[test] - fn sanity_{ty}() {{ + fn size_align_{ty}() {{ extern {{ - fn ty_{ty}_size() -> u64; - fn ty_{ty}_align() -> u64; + fn __test_size_{ty}() -> u64; + fn __test_align_{ty}() -> u64; }} unsafe {{ - assert_eq!(mem::size_of::() as u64, - ty_{ty}_size()); - assert_eq!(mem::align_of::() as u64, - ty_{ty}_align()); + let a = mem::size_of::<{ty}>() as u64; + let b = __test_size_{ty}(); + assert!(a == b, "bad size: rust {{}} != c {{}}", a, b); + let a = mem::align_of::<{ty}>() as u64; + let b = __test_align_{ty}(); + assert!(a == b, "bad align: rust {{}} != c {{}}", a, b); }} }} - "#, ty = ty); + "#, ty = rust); + } + + fn assert_no_generics(&self, _i: &ast::Item, generics: &ast::Generics) { + assert!(generics.lifetimes.len() == 0); + assert!(generics.ty_params.len() == 0); + assert!(generics.where_clause.predicates.len() == 0); } } -impl<'v> Visitor<'v> for TestGenerator { +impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { fn visit_item(&mut self, i: &'v ast::Item) { match i.node { ast::ItemTy(_, ref generics) => { - assert!(generics.lifetimes.len() == 0); - assert!(generics.ty_params.len() == 0); - assert!(generics.where_clause.predicates.len() == 0); - self.typedef(&i.ident.to_string()); + self.assert_no_generics(i, generics); + self.test_type(&i.ident.to_string()); + } + + ast::ItemStruct(ref s, ref generics) => { + self.assert_no_generics(i, generics); + let is_c = i.attrs.iter().any(|a| { + attr::find_repr_attrs(self.sh, a).iter().any(|a| { + *a == ReprAttr::ReprExtern + }) + }); + if !is_c { + panic!("{} is not marked #[repr(C)]", i.ident); + } + self.test_struct(&i.ident.to_string(), s); } _ => {} diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 94a0600013d30..447e3557d69df 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -3,5 +3,8 @@ extern crate libc_test; use std::mem; +use libc::*; +use libc::types::os::common::bsd43::*; + #[cfg(test)] include!(concat!(env!("OUT_DIR"), "/all.rs")); diff --git a/src/lib.rs b/src/lib.rs index e9a6bef823aff..46a53d0563e5c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,7 +334,8 @@ pub mod types { } #[repr(C)] #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8] + pub s6_addr: [u16; 8], + __align: [u32; 0], } #[repr(C)] #[derive(Copy, Clone)] pub struct ip_mreq { @@ -897,7 +898,8 @@ pub mod types { } #[repr(C)] #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8] + pub s6_addr: [u16; 8], + __align: [u32; 0], } #[repr(C)] #[derive(Copy, Clone)] pub struct ip_mreq { @@ -1258,7 +1260,8 @@ pub mod types { } #[repr(C)] #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8] + pub s6_addr: [u16; 8], + __align: [u32; 0], } #[repr(C)] #[derive(Copy, Clone)] pub struct ip_mreq { @@ -1544,7 +1547,8 @@ pub mod types { } #[repr(C)] #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8] + pub s6_addr: [u16; 8], + __align: [u32; 0], } #[repr(C)] #[derive(Copy, Clone)] pub struct ip_mreq { @@ -1775,7 +1779,8 @@ pub mod types { } #[repr(C)] #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8] + pub s6_addr: [u16; 8], + __align: [u32; 0], } #[repr(C)] #[derive(Copy, Clone)] pub struct ip_mreq { @@ -2233,7 +2238,8 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8] + pub s6_addr: [u16; 8], + __align: [u32; 0], } #[repr(C)] From 3e5155b345ab4b5f9d8e9b26c3da562234dcb88b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 23:46:19 -0700 Subject: [PATCH 005/194] Test struct field offsets/sizes --- libc-test/build.rs | 82 ++++++++++++++++++++++++--------- libc-test/tests/all.rs | 12 +++++ src/lib.rs | 100 ++++++++++++++++++++--------------------- 3 files changed, 124 insertions(+), 70 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index bcdb412c2abec..dda79a4b22571 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -109,13 +109,11 @@ fn build_cfg(cfg: &mut ast::CrateConfig, target: &str) { impl<'a> TestGenerator<'a> { fn test_type(&mut self, ty: &str) { let cty = if ty.starts_with("c_") { - let rest = ty[2..].replace("long", " long"); - if rest.starts_with("u") { - format!("unsigned {}", &rest[1..]) - } else if rest.starts_with("s") && rest != "short" { - format!("signed {}", &rest[1..]) - } else { - rest + match &ty[2..].replace("long", " long")[..] { + s if s.starts_with("u") => format!("unsigned {}", &s[1..]), + "short" => format!("short"), + s if s.starts_with("s") => format!("signed {}", &s[1..]), + s => s.to_string(), } } else { (match ty { @@ -126,15 +124,61 @@ impl<'a> TestGenerator<'a> { self.test_size_align(ty, &cty); } - fn test_struct(&mut self, ty: &str, _s: &ast::StructDef) { - let cty = if ty.starts_with("pthread") || ty == "glob_t" { - ty.to_string() - } else if ty == "ip6_mreq" { - "struct ipv6_mreq".to_string() - } else { - format!("struct {}", ty) + fn test_struct(&mut self, ty: &str, s: &ast::StructDef) { + let cty = match ty { + t if ty.starts_with("pthread") => t.to_string(), + "glob_t" => "glob_t".to_string(), + "ip6_mreq" => "struct ipv6_mreq".to_string(), + s => format!("struct {}", s), }; self.test_size_align(ty, &cty); + + writeln!(self.rust, r#" + #[test] + fn field_offset_size_{ty}() {{ + "#, ty = ty); + for field in s.fields.iter() { + let name = match field.node.kind { + ast::NamedField(name, ast::Public) => name, + ast::NamedField(_, ast::Inherited) => continue, + ast::UnnamedField(..) => panic!("no tuple structs in FFI"), + }; + + let cname = match &name.to_string()[..] { + s if s.ends_with("_nsec") && ty == "stat" => { + s.replace("_nsec", "spec.tv_nsec") + } + s => s.to_string(), + }; + + writeln!(self.c, r#" + uint64_t __test_offset_{ty}_{rust_field}() {{ + return offsetof({cty}, {c_field}); + }} + uint64_t __test_size_{ty}_{rust_field}() {{ + {cty}* foo = NULL; + return sizeof(foo->{c_field}); + }} + "#, ty = ty, cty = cty, rust_field = name, c_field = cname); + writeln!(self.rust, r#" + extern {{ + fn __test_offset_{ty}_{field}() -> u64; + fn __test_size_{ty}_{field}() -> u64; + }} + unsafe {{ + let foo = 0 as *const {ty}; + same(offset_of!({ty}, {field}), + __test_offset_{ty}_{field}(), + "field offset {field} of {ty}"); + same(mem::size_of_val(&(*foo).{field}) as u64, + __test_size_{ty}_{field}(), + "field size {field} of {ty}"); + }} + "#, ty = ty, field = name); + } + writeln!(self.rust, r#" + }} + "#); } fn test_size_align(&mut self, rust: &str, c: &str) { @@ -150,12 +194,10 @@ impl<'a> TestGenerator<'a> { fn __test_align_{ty}() -> u64; }} unsafe {{ - let a = mem::size_of::<{ty}>() as u64; - let b = __test_size_{ty}(); - assert!(a == b, "bad size: rust {{}} != c {{}}", a, b); - let a = mem::align_of::<{ty}>() as u64; - let b = __test_align_{ty}(); - assert!(a == b, "bad align: rust {{}} != c {{}}", a, b); + same(mem::size_of::<{ty}>() as u64, + __test_size_{ty}(), "size"); + same(mem::align_of::<{ty}>() as u64, + __test_align_{ty}(), "align"); }} }} "#, ty = rust); diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 447e3557d69df..b717c8a59ee2f 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -6,5 +6,17 @@ use std::mem; use libc::*; use libc::types::os::common::bsd43::*; +fn same(rust: u64, c: u64, attr: &str) { + if rust != c { + panic!("bad {}: rust: {} != c {}", attr, rust, c); + } +} + +macro_rules! offset_of { + ($ty:ident, $field:ident) => ( + (&((*(0 as *const $ty)).$field)) as *const _ as u64 + ) +} + #[cfg(test)] include!(concat!(env!("OUT_DIR"), "/all.rs")); diff --git a/src/lib.rs b/src/lib.rs index 46a53d0563e5c..bd57a1554e7fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -230,11 +230,11 @@ pub mod types { pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, - pub __unused1: *mut c_void, - pub __unused2: *mut c_void, - pub __unused3: *mut c_void, - pub __unused4: *mut c_void, - pub __unused5: *mut c_void, + __unused1: *mut c_void, + __unused2: *mut c_void, + __unused3: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, } #[repr(C)] @@ -491,8 +491,8 @@ pub mod types { pub st_mtime_nsec: c_long, pub st_ctime: time_t, pub st_ctime_nsec: c_long, - pub __unused4: c_long, - pub __unused5: c_long, + __unused4: c_long, + __unused5: c_long, } #[repr(C)] @@ -693,7 +693,7 @@ pub mod types { pub st_mtime_nsec: c_long, pub st_ctime: time_t, pub st_ctime_nsec: c_long, - pub __unused: [c_long; 3], + __unused: [c_long; 3], } #[repr(C)] @@ -738,7 +738,7 @@ pub mod types { pub st_mtime_nsec: c_long, pub st_ctime: time_t, pub st_ctime_nsec: c_long, - pub __unused: [c_int; 2], + __unused: [c_int; 2], } #[repr(C)] @@ -787,18 +787,18 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: size_t, - pub __unused1: size_t, + __unused1: size_t, pub gl_offs: size_t, - pub __unused2: c_int, + __unused2: c_int, pub gl_pathv: *mut *mut c_char, - pub __unused3: *mut c_void, + __unused3: *mut c_void, - pub __unused4: *mut c_void, - pub __unused5: *mut c_void, - pub __unused6: *mut c_void, - pub __unused7: *mut c_void, - pub __unused8: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, } #[repr(C)] @@ -1021,7 +1021,7 @@ pub mod types { pub st_lspare: int32_t, pub st_birthtime: time_t, pub st_birthtime_nsec: c_long, - pub __unused: [u8; 8], + __unused: [u8; 8], } #[repr(C)] @@ -1149,18 +1149,18 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: size_t, - pub __unused1: size_t, + __unused1: size_t, pub gl_offs: size_t, - pub __unused2: c_int, + __unused2: c_int, pub gl_pathv: *mut *mut c_char, - pub __unused3: *mut c_void, + __unused3: *mut c_void, - pub __unused4: *mut c_void, - pub __unused5: *mut c_void, - pub __unused6: *mut c_void, - pub __unused7: *mut c_void, - pub __unused8: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, } #[repr(C)] @@ -1422,32 +1422,32 @@ pub mod types { pub gl_offs: c_int, pub gl_flags: c_int, pub gl_pathv: *mut *mut c_char, - pub __unused1: *mut c_void, - pub __unused2: *mut c_void, - pub __unused3: *mut c_void, - pub __unused4: *mut c_void, - pub __unused5: *mut c_void, - pub __unused6: *mut c_void, - pub __unused7: *mut c_void, + __unused1: *mut c_void, + __unused2: *mut c_void, + __unused3: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, } #[cfg(any(target_os = "netbsd", target_os="openbsd"))] #[repr(C)] #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: c_int, - pub __unused1: c_int, + __unused1: c_int, pub gl_offs: c_int, - pub __unused2: c_int, + __unused2: c_int, pub gl_pathv: *mut *mut c_char, - pub __unused3: *mut c_void, + __unused3: *mut c_void, - pub __unused4: *mut c_void, - pub __unused5: *mut c_void, - pub __unused6: *mut c_void, - pub __unused7: *mut c_void, - pub __unused8: *mut c_void, - pub __unused9: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, + __unused9: *mut c_void, } #[repr(C)] @@ -2122,18 +2122,18 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct glob_t { pub gl_pathc: size_t, - pub __unused1: c_int, + __unused1: c_int, pub gl_offs: size_t, - pub __unused2: c_int, + __unused2: c_int, pub gl_pathv: *mut *mut c_char, - pub __unused3: *mut c_void, + __unused3: *mut c_void, - pub __unused4: *mut c_void, - pub __unused5: *mut c_void, - pub __unused6: *mut c_void, - pub __unused7: *mut c_void, - pub __unused8: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, } #[repr(C)] From 6036c18009e62a03479cc3be9ff878569e460597 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 23:48:14 -0700 Subject: [PATCH 006/194] Run travis everywhere! --- .travis.yml | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64422b3506272..830f48e005c4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,33 @@ language: rust +rust: + - 1.0.0 + - beta + - nightly sudo: false -before_install: - - git submodule update --init --recursive +install: + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi + - export TARGET=$ARCH-$OS + - curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz + - tar xf rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz + - rm -rf $HOME/rust/lib/rustlib/$TARGET + - mv rust-$TRAVIS_RUST_VERSION-$TARGET/rustc/lib/rustlib/$TARGET $HOME/rust/lib/rustlib +before_script: + - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - - cargo build --verbose - - cargo doc --verbose -after_success: | - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - echo '' > target/doc/index.html && - pip install ghp-import --user $USER && - $HOME/.local/bin/ghp-import -n target/doc && - git push -fq https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages - -env: - global: - secure: MZGg+symX6/fcY7TsQ1LkJ28V/CUevNZgs3MiilgvnlgTjqn7BU7gbTvwhLdVZq04/EQ1hTeVzrFGpBfcCUVHYKmP2vooEFJJ+bDGEvyD8ChwCB4nV+NmxF5+NwCi3+Y+0pBgKbt2BasJ+MXkGJpRyFozis6loMWbXTzZzL9jjU= + - cargo test --target $TARGET + - cargo test --target $TARGET --manifest-path libc-test/Cargo.toml + - cargo doc --no-deps notifications: email: on_success: never +addons: + apt: + packages: + - gcc-multilib + matrix: + - ARCH=x86_64 + - ARCH=i686 + +os: + - linux + - osx From 984477bed4e5a851578b7e2210334dfc87ec6e83 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 23:49:09 -0700 Subject: [PATCH 007/194] Add back in env for travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 830f48e005c4b..35992d4d6bca2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ addons: apt: packages: - gcc-multilib +env: matrix: - ARCH=x86_64 - ARCH=i686 From f522b139f8e084f331d8dbe6ffc91117f7f9c0b4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 10:41:55 -0700 Subject: [PATCH 008/194] Make all padding and such private --- src/lib.rs | 71 +++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bd57a1554e7fc..da74253266d50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -304,11 +304,11 @@ pub mod types { #[repr(C)] #[derive(Copy)] pub struct sockaddr_storage { pub ss_family: sa_family_t, - pub __ss_align: isize, + __ss_align: isize, #[cfg(target_pointer_width = "32")] - pub __ss_pad2: [u8; 128 - 2 * 4], + __ss_pad2: [u8; 128 - 2 * 4], #[cfg(target_pointer_width = "64")] - pub __ss_pad2: [u8; 128 - 2 * 8], + __ss_pad2: [u8; 128 - 2 * 8], } impl Clone for sockaddr_storage { fn clone(&self) -> sockaddr_storage { *self } @@ -474,14 +474,14 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, - pub __pad1: c_short, + __pad1: c_short, pub st_ino: ino_t, pub st_mode: mode_t, pub st_nlink: nlink_t, pub st_uid: uid_t, pub st_gid: gid_t, pub st_rdev: dev_t, - pub __pad2: c_short, + __pad2: c_short, pub st_size: off_t, pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, @@ -503,7 +503,7 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct pthread_attr_t { - pub __size: [u32; 9] + __size: [u32; 9] } } #[cfg(all(any(target_arch = "arm", target_arch = "x86"), @@ -520,14 +520,14 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct stat { pub st_dev: c_ulonglong, - pub __pad0: [c_uchar; 4], - pub __st_ino: ino_t, + __pad0: [c_uchar; 4], + __st_ino: ino_t, pub st_mode: c_uint, pub st_nlink: c_uint, pub st_uid: uid_t, pub st_gid: gid_t, pub st_rdev: c_ulonglong, - pub __pad3: [c_uchar; 4], + __pad3: [c_uchar; 4], pub st_size: c_longlong, pub st_blksize: blksize_t, pub st_blocks: c_ulonglong, @@ -548,7 +548,7 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct pthread_attr_t { - pub __size: [u32; 9] + __size: [u32; 9] } } #[cfg(any(target_arch = "mips", @@ -595,7 +595,7 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct pthread_attr_t { - pub __size: [u32; 9] + __size: [u32; 9] } } pub mod posix08 {} @@ -682,7 +682,7 @@ pub mod types { pub st_mode: mode_t, pub st_uid: uid_t, pub st_gid: gid_t, - pub __pad0: c_int, + __pad0: c_int, pub st_rdev: dev_t, pub st_size: off_t, pub st_blksize: blksize_t, @@ -704,7 +704,7 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct pthread_attr_t { - pub __size: [u64; 7] + __size: [u64; 7] } } #[cfg(target_arch = "aarch64")] @@ -727,10 +727,10 @@ pub mod types { pub st_uid: uid_t, pub st_gid: gid_t, pub st_rdev: dev_t, - pub __pad1: dev_t, + __pad1: dev_t, pub st_size: off_t, pub st_blksize: blksize_t, - pub __pad2: c_int, + __pad2: c_int, pub st_blocks: blkcnt_t, pub st_atime: time_t, pub st_atime_nsec: c_long, @@ -749,7 +749,7 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct pthread_attr_t { - pub __size: [u64; 8] + __size: [u64; 8] } } pub mod posix08 { @@ -758,6 +758,7 @@ pub mod types { } pub mod extra { use types::os::arch::c95::{c_ushort, c_int, c_uchar}; + #[repr(C)] #[derive(Copy, Clone)] pub struct sockaddr_ll { pub sll_family: c_ushort, pub sll_protocol: c_ushort, @@ -868,9 +869,9 @@ pub mod types { #[derive(Copy)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, - pub __ss_pad1: [u8; 6], - pub __ss_align: i64, - pub __ss_pad2: [u8; 112], + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], } impl Clone for sockaddr_storage { fn clone(&self) -> sockaddr_storage { *self } @@ -1230,9 +1231,9 @@ pub mod types { #[derive(Copy)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, - pub __ss_pad1: [u8; 6], - pub __ss_align: i64, - pub __ss_pad2: [u8; 112], + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], } impl Clone for sockaddr_storage { fn clone(&self) -> sockaddr_storage { *self } @@ -1517,9 +1518,9 @@ pub mod types { #[derive(Copy)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, - pub __ss_pad1: [u8; 6], - pub __ss_pad2: i64, - pub __ss_pad3: [u8; 240], + __ss_pad1: [u8; 6], + __ss_pad2: i64, + __ss_pad3: [u8; 240], } impl Clone for sockaddr_storage { fn clone(&self) -> sockaddr_storage { *self } @@ -1751,9 +1752,9 @@ pub mod types { #[repr(C)] #[derive(Copy)] pub struct sockaddr_storage { pub ss_family: sa_family_t, - pub __ss_pad1: [u8; 6], - pub __ss_align: i64, - pub __ss_pad2: [u8; 112], + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], } impl Clone for sockaddr_storage { fn clone(&self) -> sockaddr_storage { *self } @@ -2204,9 +2205,9 @@ pub mod types { #[derive(Copy)] pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, - pub __ss_pad1: [u8; 6], - pub __ss_align: i64, - pub __ss_pad2: [u8; 112], + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], } impl Clone for sockaddr_storage { fn clone(&self) -> sockaddr_storage { *self } @@ -2375,8 +2376,8 @@ pub mod types { #[repr(C)] #[derive(Copy)] pub struct pthread_attr_t { - pub __sig: c_long, - pub __opaque: [c_char; 36] + __sig: c_long, + __opaque: [c_char; 36] } impl Clone for pthread_attr_t { fn clone(&self) -> pthread_attr_t { *self } @@ -2484,8 +2485,8 @@ pub mod types { #[repr(C)] #[derive(Copy)] pub struct pthread_attr_t { - pub __sig: c_long, - pub __opaque: [c_char; 56] + __sig: c_long, + __opaque: [c_char; 56] } impl Clone for pthread_attr_t { fn clone(&self) -> pthread_attr_t { *self } From 310d623acfb124e8ca6a0d2ac8840bf22c12402a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 10:56:31 -0700 Subject: [PATCH 009/194] Tweak script, fix on linux --- libc-test/build.rs | 287 ++++++++++++++++++++++++++++----------------- 1 file changed, 181 insertions(+), 106 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index dda79a4b22571..f7c0129e49b59 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1,8 +1,7 @@ -#![allow(unused_must_use)] - extern crate gcc; extern crate syntex_syntax as syntax; +use std::collections::HashSet; use std::env; use std::fs::File; use std::io::BufWriter; @@ -16,127 +15,195 @@ use syntax::attr::{self, ReprAttr}; use syntax::parse::{self, ParseSess}; use syntax::visit::{self, Visitor}; +macro_rules! t { + ($e:expr) => (match $e { + Ok(e) => e, + Err(e) => panic!("{} failed with {}", stringify!($e), e), + }) +} + struct TestGenerator<'a> { + target: String, rust: Box, c: Box, sh: &'a SpanHandler, + structs: HashSet, } -fn main() { - let target = env::var("TARGET").unwrap(); +struct StructFinder { + structs: HashSet, +} + +impl<'a> TestGenerator<'a> { + fn headers(&self) -> Vec<&'static str> { + let mut base = vec![ + "glob.h", + "ifaddrs.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "pthread.h", + "signal.h", + "stdalign.h", + "stddef.h", + "stdint.h", + "sys/resource.h", + "sys/socket.h", + "sys/stat.h", + "sys/time.h", + "sys/types.h", + "sys/un.h", + "time.h", + "unistd.h", + "utime.h", + "wchar.h", + ]; + + if self.target.contains("apple-darwin") { + base.push("mach/mach_time.h"); + } + if self.target.contains("unknown-linux") { + base.push("linux/if_packet.h"); + base.push("net/ethernet.h"); + } + return base + } + + fn rust2c(&self, ty: &str) -> String { + match ty { + t if t.starts_with("c_") => { + match &ty[2..].replace("long", " long")[..] { + s if s.starts_with("u") => format!("unsigned {}", &s[1..]), + "short" => format!("short"), + s if s.starts_with("s") => format!("signed {}", &s[1..]), + s => s.to_string(), + } + } + "ip6_mreq" => "struct ipv6_mreq".to_string(), + "glob_t" => "glob_t".to_string(), + t if t.starts_with("pthread") => t.to_string(), + + t if self.structs.contains(t) => format!("struct {}", t), + + t => t.to_string(), + } + } + + fn rust2cfield(&self, struct_: &str, field: &str) -> String { + match field { + s if s.ends_with("_nsec") && struct_ == "stat" => { + if self.target.contains("apple-darwin") { + s.replace("_nsec", "spec.tv_nsec") + } else { + s.replace("e_nsec", ".tv_nsec") + } + } + s => s.to_string(), + } + } + + fn cfg_list(&self) -> Vec<(&'static str, Option<&'static str>)> { + let mut ret = Vec::new(); + let (arch, target_pointer_width) = if self.target.starts_with("x86_64") { + ("x86_64", "64") + } else if self.target.starts_with("i686") { + ("x86", "32") + } else { + panic!("unknown arch/pointer width: {}", self.target) + }; + let (os, family, env) = if self.target.contains("unknown-linux") { + ("linux", "unix", "gnu") + } else if self.target.contains("apple-darwin") { + ("macos", "unix", "") + } else { + panic!("unknown os/family width: {}", self.target) + }; + + ret.push((family, None)); + ret.push(("target_os", Some(os))); + ret.push(("target_family", Some(family))); + ret.push(("target_arch", Some(arch))); + // skip endianness + ret.push(("target_pointer_width", Some(target_pointer_width))); + ret.push(("target_env", Some(env))); + + return ret + } +} + +fn main() { + // Prep the test generator + let target = t!(env::var("TARGET")); + let out = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let rust_out = BufWriter::new(t!(File::create(out.join("all.rs")))); + let c_out = BufWriter::new(t!(File::create(out.join("all.c")))); let sess = ParseSess::new(); + let mut tg = TestGenerator { + target: target, + rust: Box::new(rust_out), + c: Box::new(c_out), + sh: &sess.span_diagnostic, + structs: HashSet::new(), + }; + + // Parse the libc crate let src = Path::new("../src/lib.rs"); let cfg = Vec::new(); let mut krate = parse::parse_crate_from_file(src, cfg, &sess); - build_cfg(&mut krate.config, &target); + // Strip the crate down to just what's configured for our target + for (k, v) in tg.cfg_list() { + let s = InternedString::new; + krate.config.push(match v { + Some(v) => attr::mk_name_value_item_str(s(k), s(v)), + None => attr::mk_word_item(s(k)), + }); + } let mut gated_cfgs = Vec::new(); let krate = syntax::config::strip_unconfigured_items(&sess.span_diagnostic, krate, &mut gated_cfgs); - let out = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let rust_out = BufWriter::new(File::create(out.join("all.rs")).unwrap()); - let mut c_out = BufWriter::new(File::create(out.join("all.c")).unwrap()); - - writeln!(c_out, " -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -"); - - if target.contains("apple-darwin") { - writeln!(c_out, " -#include -"); - } + // Probe the crate to find all structs (used to convert type names to names + // in C). + let mut structs = StructFinder { + structs: HashSet::new(), + }; + visit::walk_crate(&mut structs, &krate); + tg.structs = structs.structs; - visit::walk_crate(&mut TestGenerator { - rust: Box::new(rust_out), - c: Box::new(c_out), - sh: &sess.span_diagnostic, - }, &krate); + // Walk the crate, emitting test cases for everything found + for header in tg.headers() { + t!(writeln!(tg.c, "#include <{}>", header)); + } + visit::walk_crate(&mut tg, &krate); + drop(tg); + // Compile our C shim to be linked into tests gcc::Config::new() .file(out.join("all.c")) .compile("liball.a"); } -fn build_cfg(cfg: &mut ast::CrateConfig, target: &str) { - let (arch, target_pointer_width) = if target.starts_with("x86_64") { - ("x86_64", "64") - } else if target.starts_with("i686") { - ("x86", "32") - } else { - panic!("unknown arch/pointer width: {}", target) - }; - let (os, family, env) = if target.contains("unknown-linux") { - ("linux", "unix", "gnu") - } else if target.contains("apple-darwin") { - ("macos", "unix", "") - } else { - panic!("unknown os/family width: {}", target) - }; - - let mk = attr::mk_name_value_item_str; - let s = InternedString::new; - cfg.push(attr::mk_word_item(s(family))); - cfg.push(mk(s("target_os"), s(os))); - cfg.push(mk(s("target_family"), s(family))); - cfg.push(mk(s("target_arch"), s(arch))); - // skip endianness - cfg.push(mk(s("target_pointer_width"), s(target_pointer_width))); - cfg.push(mk(s("target_env"), s(env))); -} - impl<'a> TestGenerator<'a> { fn test_type(&mut self, ty: &str) { - let cty = if ty.starts_with("c_") { - match &ty[2..].replace("long", " long")[..] { - s if s.starts_with("u") => format!("unsigned {}", &s[1..]), - "short" => format!("short"), - s if s.starts_with("s") => format!("signed {}", &s[1..]), - s => s.to_string(), - } - } else { - (match ty { - "sighandler_t" => return, - ty => ty, - }).to_string() - }; - self.test_size_align(ty, &cty); + match ty { + "sighandler_t" => return, + _ => {} + } + let c = self.rust2c(ty); + self.test_size_align(ty, &c); } fn test_struct(&mut self, ty: &str, s: &ast::StructDef) { - let cty = match ty { - t if ty.starts_with("pthread") => t.to_string(), - "glob_t" => "glob_t".to_string(), - "ip6_mreq" => "struct ipv6_mreq".to_string(), - s => format!("struct {}", s), - }; + let cty = self.rust2c(ty); self.test_size_align(ty, &cty); - writeln!(self.rust, r#" + t!(writeln!(self.rust, r#" #[test] fn field_offset_size_{ty}() {{ - "#, ty = ty); + "#, ty = ty)); for field in s.fields.iter() { let name = match field.node.kind { ast::NamedField(name, ast::Public) => name, @@ -144,14 +211,9 @@ impl<'a> TestGenerator<'a> { ast::UnnamedField(..) => panic!("no tuple structs in FFI"), }; - let cname = match &name.to_string()[..] { - s if s.ends_with("_nsec") && ty == "stat" => { - s.replace("_nsec", "spec.tv_nsec") - } - s => s.to_string(), - }; + let cfield = self.rust2cfield(ty, &name.to_string()); - writeln!(self.c, r#" + t!(writeln!(self.c, r#" uint64_t __test_offset_{ty}_{rust_field}() {{ return offsetof({cty}, {c_field}); }} @@ -159,8 +221,8 @@ impl<'a> TestGenerator<'a> { {cty}* foo = NULL; return sizeof(foo->{c_field}); }} - "#, ty = ty, cty = cty, rust_field = name, c_field = cname); - writeln!(self.rust, r#" + "#, ty = ty, cty = cty, rust_field = name, c_field = cfield)); + t!(writeln!(self.rust, r#" extern {{ fn __test_offset_{ty}_{field}() -> u64; fn __test_size_{ty}_{field}() -> u64; @@ -174,19 +236,19 @@ impl<'a> TestGenerator<'a> { __test_size_{ty}_{field}(), "field size {field} of {ty}"); }} - "#, ty = ty, field = name); + "#, ty = ty, field = name)); } - writeln!(self.rust, r#" + t!(writeln!(self.rust, r#" }} - "#); + "#)); } fn test_size_align(&mut self, rust: &str, c: &str) { - writeln!(self.c, r#" + t!(writeln!(self.c, r#" uint64_t __test_size_{ty}() {{ return sizeof({cty}); }} uint64_t __test_align_{ty}() {{ return alignof({cty}); }} - "#, ty = rust, cty = c); - writeln!(self.rust, r#" + "#, ty = rust, cty = c)); + t!(writeln!(self.rust, r#" #[test] fn size_align_{ty}() {{ extern {{ @@ -200,7 +262,7 @@ impl<'a> TestGenerator<'a> { __test_align_{ty}(), "align"); }} }} - "#, ty = rust); + "#, ty = rust)); } fn assert_no_generics(&self, _i: &ast::Item, generics: &ast::Generics) { @@ -236,3 +298,16 @@ impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { visit::walk_item(self, i) } } + +impl<'v> Visitor<'v> for StructFinder { + fn visit_item(&mut self, i: &'v ast::Item) { + match i.node { + ast::ItemStruct(..) => { + self.structs.insert(i.ident.to_string()); + } + + _ => {} + } + visit::walk_item(self, i) + } +} From b2a9107828fa8a9abbc091fa6e8bd8be19a0d930 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 10:56:41 -0700 Subject: [PATCH 010/194] Fix glob_t definition on linux --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index da74253266d50..bd99383790fcd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,8 +215,8 @@ pub mod types { pub mod common { pub mod posix01 { use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_ulong, size_t, - time_t, suseconds_t, c_long}; + use types::os::arch::c95::{c_char, c_ulong, size_t, c_int, + time_t, suseconds_t, c_long}; #[cfg(not(target_os = "nacl"))] pub type pthread_t = c_ulong; @@ -229,6 +229,7 @@ pub mod types { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, + pub gl_flags: c_int, __unused1: *mut c_void, __unused2: *mut c_void, From 429c2de620df76d1d0c06a0152b451ddb2e05158 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 10:57:31 -0700 Subject: [PATCH 011/194] Build on stable Rust --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 35992d4d6bca2..19cae59a515f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - 1.0.0 + - stable - beta - nightly sudo: false From f0129905d42576b123dea9df273a8a7b7d76c7b9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 10:59:37 -0700 Subject: [PATCH 012/194] Nope, let's try 1.2.0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 19cae59a515f0..d0571b75deda2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - stable + - 1.2.0 - beta - nightly sudo: false From f8b1b3d37b5bc19cf00f23c0277b3c06cbb9c6dd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 11:15:33 -0700 Subject: [PATCH 013/194] Try using a newer gcc on travis --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d0571b75deda2..3804260c4e26e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,14 +20,19 @@ script: notifications: email: on_success: never + +# Need gcc 4.7 for alignof/stdalign.h and we use multilib as we test both 32/64 addons: + sources: + - ubuntu-toolchain-r-test apt: packages: - - gcc-multilib + - gcc-4.7-multilib env: - matrix: - - ARCH=x86_64 - - ARCH=i686 + - ARCH=x86_64 CC=gcc-4.7 + - ARCH=x86_64 CC=clang + - ARCH=i686 CC=gcc-4.7 + - ARCH=i686 CC=clang os: - linux From 7ff62a4e5089be6a82275ceae26aacecaed6b27b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 11:29:20 -0700 Subject: [PATCH 014/194] Fix rlim_t for 32-bit linux --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bd99383790fcd..bab4d42a9fd0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -222,7 +222,7 @@ pub mod types { pub type pthread_t = c_ulong; #[cfg(target_os = "nacl")] pub type pthread_t = *mut c_void; - pub type rlim_t = u64; + pub type rlim_t = c_ulong; #[repr(C)] #[derive(Copy, Clone)] pub struct glob_t { @@ -3494,7 +3494,7 @@ pub mod consts { pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; pub const RLIMIT_NLIMITS: c_int = 16; - pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + pub const RLIM_INFINITY: rlim_t = !0; pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; From ec5538c968e37d051272979f361de890d0be5f59 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 13:01:15 -0700 Subject: [PATCH 015/194] OK, just use clang --- .travis.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3804260c4e26e..60635f92b8312 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,18 +20,8 @@ script: notifications: email: on_success: never - -# Need gcc 4.7 for alignof/stdalign.h and we use multilib as we test both 32/64 -addons: - sources: - - ubuntu-toolchain-r-test - apt: - packages: - - gcc-4.7-multilib env: - - ARCH=x86_64 CC=gcc-4.7 - ARCH=x86_64 CC=clang - - ARCH=i686 CC=gcc-4.7 - ARCH=i686 CC=clang os: From c8b895cee78b370a10cb7f9f0a05616736f93188 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 13:24:15 -0700 Subject: [PATCH 016/194] Attempt to fix 32-bit --- libc-test/build.rs | 2 +- libc-test/tests/all.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f7c0129e49b59..62d8b07f5e970 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -258,7 +258,7 @@ impl<'a> TestGenerator<'a> { unsafe {{ same(mem::size_of::<{ty}>() as u64, __test_size_{ty}(), "size"); - same(mem::align_of::<{ty}>() as u64, + same(align::<{ty}>() as u64, __test_align_{ty}(), "align"); }} }} diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index b717c8a59ee2f..fe3bd246ce4b6 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -1,6 +1,7 @@ extern crate libc; extern crate libc_test; +use std::any::{Any, TypeId}; use std::mem; use libc::*; @@ -12,6 +13,21 @@ fn same(rust: u64, c: u64, attr: &str) { } } +fn align() -> u64 { + // TODO: apparently these three types have less alignment in Rust on x86 + // than they do in C this difference should.. probably be reconciled. + // + // Perhaps #27195? + if cfg!(target_pointer_width = "32") { + if TypeId::of::() == TypeId::of::() || + TypeId::of::() == TypeId::of::() || + TypeId::of::() == TypeId::of::() { + return 8 + } + } + mem::align_of::() as u64 +} + macro_rules! offset_of { ($ty:ident, $field:ident) => ( (&((*(0 as *const $ty)).$field)) as *const _ as u64 From fc32c6d1f0d1caf5d90505154cbc9843ffe70b55 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 13:58:57 -0700 Subject: [PATCH 017/194] Keep installing gcc-multilib --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 60635f92b8312..c0cb38a9ce663 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,11 @@ script: - cargo test --target $TARGET - cargo test --target $TARGET --manifest-path libc-test/Cargo.toml - cargo doc --no-deps + +addons: + apt: + packages: + - gcc-multilib notifications: email: on_success: never From 0df7c1076eb76ef25315800a353c9969094a9be8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 16:35:37 -0700 Subject: [PATCH 018/194] Test constant values --- libc-test/build.rs | 70 +++++++++++++++++++++++++++++++++++++++++- libc-test/tests/all.rs | 25 +++++++++++++-- 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 62d8b07f5e970..d6d58bb9906ed 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -6,6 +6,7 @@ use std::env; use std::fs::File; use std::io::BufWriter; use std::io::prelude::*; +use std::iter; use std::path::{Path, PathBuf}; use syntax::ast; @@ -35,18 +36,34 @@ struct StructFinder { } impl<'a> TestGenerator<'a> { + fn defines(&self) -> Vec<&'static str> { + let mut ret = Vec::new(); + if self.target.contains("unknown-linux") { + ret.push("_GNU_SOURCE"); + } + return ret + } + fn headers(&self) -> Vec<&'static str> { let mut base = vec![ + "errno.h", + "fcntl.h", "glob.h", "ifaddrs.h", + "limits.h", + "net/if.h", "netdb.h", "netinet/in.h", "netinet/ip.h", + "netinet/tcp.h", "pthread.h", "signal.h", "stdalign.h", "stddef.h", "stdint.h", + "stdio.h", + "stdlib.h", + "sys/mman.h", "sys/resource.h", "sys/socket.h", "sys/stat.h", @@ -173,16 +190,24 @@ fn main() { visit::walk_crate(&mut structs, &krate); tg.structs = structs.structs; - // Walk the crate, emitting test cases for everything found + // Prep the C file by emitting header stuff + for define in tg.defines() { + t!(writeln!(tg.c, "#define {}", define)); + } for header in tg.headers() { t!(writeln!(tg.c, "#include <{}>", header)); } + + // Walk the crate, emitting test cases for everything found visit::walk_crate(&mut tg, &krate); drop(tg); // Compile our C shim to be linked into tests gcc::Config::new() .file(out.join("all.c")) + .flag("-Wall") + .flag("-Wextra") + .flag("-Werror") .compile("liball.a"); } @@ -265,11 +290,49 @@ impl<'a> TestGenerator<'a> { "#, ty = rust)); } + fn test_const(&mut self, name: &str, rust_ty: &str) { + let cty = self.rust2c(&rust_ty.replace("*mut ", "") + .replace("*const ", "")); + let ptrs = rust_ty.matches("*").count(); + let cty = format!("{}{}", cty, + iter::repeat("*").take(ptrs).collect::()); + let cast = if name == "SIG_IGN" {"(size_t)"} else {""}; + t!(writeln!(self.c, r#" + {cty} __test_const_{name}() {{ return {cast}({name}); }} + "#, name = name, cast = cast, cty = cty)); + t!(writeln!(self.rust, r#" + #[test] + fn const_{name}() {{ + extern {{ + fn __test_const_{name}() -> {ty}; + }} + unsafe {{ + same({name}, __test_const_{name}(), "value"); + }} + }} + "#, ty = rust_ty, name = name)); + } + fn assert_no_generics(&self, _i: &ast::Item, generics: &ast::Generics) { assert!(generics.lifetimes.len() == 0); assert!(generics.ty_params.len() == 0); assert!(generics.where_clause.predicates.len() == 0); } + + fn ty2name(&self, ty: &ast::Ty) -> String { + match ty.node { + ast::TyPath(_, ref path) => { + path.segments.last().unwrap().identifier.to_string() + } + ast::TyPtr(ref t) => { + format!("*{} {}", match t.mutbl { + ast::MutImmutable => "const", + ast::MutMutable => "mut", + }, self.ty2name(&t.ty)) + } + _ => panic!("unknown ty {:?}", ty), + } + } } impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { @@ -293,6 +356,11 @@ impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { self.test_struct(&i.ident.to_string(), s); } + ast::ItemConst(ref ty, _) => { + let ty = self.ty2name(ty); + self.test_const(&i.ident.to_string(), &ty); + } + _ => {} } visit::walk_item(self, i) diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index fe3bd246ce4b6..665747fb24f90 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -1,3 +1,5 @@ +#![allow(bad_style)] + extern crate libc; extern crate libc_test; @@ -7,9 +9,28 @@ use std::mem; use libc::*; use libc::types::os::common::bsd43::*; -fn same(rust: u64, c: u64, attr: &str) { +trait Pretty { + fn pretty(&self) -> String; +} + +impl Pretty for *const T { + fn pretty(&self) -> String { format!("{:?}", self) } +} +impl Pretty for *mut T { + fn pretty(&self) -> String { format!("{:?}", self) } +} +macro_rules! p { + ($($i:ident)*) => ($( + impl Pretty for $i { + fn pretty(&self) -> String { format!("{} ({:#x})", self, self) } + } + )*) +} +p! { i8 i16 i32 i64 u8 u16 u32 u64 usize isize } + +fn same(rust: T, c: T, attr: &str) { if rust != c { - panic!("bad {}: rust: {} != c {}", attr, rust, c); + panic!("bad {}: rust: {} != c {}", attr, rust.pretty(), c.pretty()); } } From 148033a070c0410ff6ab75f014db93d03e5b0260 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 16:35:45 -0700 Subject: [PATCH 019/194] Fix wrong constants on linux --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bab4d42a9fd0e..bb1c755c7f072 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3800,8 +3800,8 @@ pub mod consts { pub const O_NONBLOCK : c_int = 2048; pub const O_SYNC : c_int = 1052672; - pub const PROT_GROWSDOWN : c_int = 0x010000000; - pub const PROT_GROWSUP : c_int = 0x020000000; + pub const PROT_GROWSDOWN : c_int = 0x1000000; + pub const PROT_GROWSUP : c_int = 0x2000000; pub const MAP_TYPE : c_int = 0x000f; pub const MAP_ANONYMOUS : c_int = 0x0020; @@ -5780,7 +5780,7 @@ pub mod funcs { use types::os::arch::posix88::{gid_t, off_t, pid_t}; use types::os::arch::posix88::{ssize_t, uid_t}; - pub const _PC_NAME_MAX: c_int = 4; + pub const _PC_NAME_MAX: c_int = 3; #[cfg(not(target_os = "nacl"))] extern { From e1272fa74ae95cca9c315f2ca0ac082204c84520 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 16:43:49 -0700 Subject: [PATCH 020/194] Fix defines on x86_64 OSX --- src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bb1c755c7f072..234a642c9d489 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5131,11 +5131,10 @@ pub mod consts { pub const RLIM_NLIMITS: c_int = 9; pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; - pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; pub const RUSAGE_SELF: c_int = 0; pub const RUSAGE_CHILDREN: c_int = -1; - pub const RUSAGE_THREAD: c_int = 1; } pub mod posix08 { } @@ -5174,8 +5173,8 @@ pub mod consts { pub const IP_HDRINCL: c_int = 2; pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 12; - pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_JOIN_GROUP: c_int = 12; + pub const IPV6_LEAVE_GROUP: c_int = 13; pub const TCP_NODELAY: c_int = 0x01; pub const TCP_KEEPALIVE: c_int = 0x10; @@ -5227,7 +5226,6 @@ pub mod consts { pub const MAP_HASSEMAPHORE : c_int = 0x0200; pub const MAP_NOCACHE : c_int = 0x0400; pub const MAP_JIT : c_int = 0x0800; - pub const MAP_STACK : c_int = 0; pub const IPPROTO_RAW : c_int = 255; @@ -5780,7 +5778,7 @@ pub mod funcs { use types::os::arch::posix88::{gid_t, off_t, pid_t}; use types::os::arch::posix88::{ssize_t, uid_t}; - pub const _PC_NAME_MAX: c_int = 3; + pub const _PC_NAME_MAX: c_int = 4; #[cfg(not(target_os = "nacl"))] extern { From 126e50636c161b07ff160e3162af8405099e7695 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:03:40 -0700 Subject: [PATCH 021/194] Attempt to find header files --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index c0cb38a9ce663..5227a7ce9e9cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ rust: - nightly sudo: false install: + - grep -R TCP_THIN_LINEAR_TIMEOUTS /usr/include + - grep -R SO_REUSEPORT /usr/include + - exit 1 - if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi - export TARGET=$ARCH-$OS - curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz From e7afdd81ba949ad4c3ab2c50c2ac4c8c51cfaabc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:15:20 -0700 Subject: [PATCH 022/194] Handle when constants aren't defined --- libc-test/build.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d6d58bb9906ed..c62dbe0642343 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -298,16 +298,28 @@ impl<'a> TestGenerator<'a> { iter::repeat("*").take(ptrs).collect::()); let cast = if name == "SIG_IGN" {"(size_t)"} else {""}; t!(writeln!(self.c, r#" - {cty} __test_const_{name}() {{ return {cast}({name}); }} + int __test_const_{name}({cty} *out) {{ + int ret = 0; + #if defined({name}) + *out = {cast}({name}); + ret = 1; + #endif + return ret; + }} "#, name = name, cast = cast, cty = cty)); t!(writeln!(self.rust, r#" #[test] fn const_{name}() {{ extern {{ - fn __test_const_{name}() -> {ty}; + fn __test_const_{name}(out: *mut {ty}) -> c_int; }} unsafe {{ - same({name}, __test_const_{name}(), "value"); + let mut o = mem::zeroed(); + if __test_const_{name}(&mut o) == 0 {{ + panic!("not defined"); + }} else {{ + same({name}, o, "value"); + }} }} }} "#, ty = rust_ty, name = name)); From c37f22ccd245141c094c41c49754d031ec37234b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:15:31 -0700 Subject: [PATCH 023/194] Re-fix _PC_NAME_MAX --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 234a642c9d489..793cf52317264 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5778,6 +5778,9 @@ pub mod funcs { use types::os::arch::posix88::{gid_t, off_t, pid_t}; use types::os::arch::posix88::{ssize_t, uid_t}; + #[cfg(target_os = "macos")] + pub const _PC_NAME_MAX: c_int = 3; + #[cfg(target_os = "linux")] pub const _PC_NAME_MAX: c_int = 4; #[cfg(not(target_os = "nacl"))] From a5086b11a0f83ddd9a063ce28076a632dd00a54d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:16:10 -0700 Subject: [PATCH 024/194] Done probing --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5227a7ce9e9cf..c0cb38a9ce663 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ rust: - nightly sudo: false install: - - grep -R TCP_THIN_LINEAR_TIMEOUTS /usr/include - - grep -R SO_REUSEPORT /usr/include - - exit 1 - if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi - export TARGET=$ARCH-$OS - curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz From 6b853c7ca7ca9b4d9733570bfff88a30f18f245f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:25:21 -0700 Subject: [PATCH 025/194] What is wrong with _PC_NAME_MAX --- src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 793cf52317264..234a642c9d489 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5778,9 +5778,6 @@ pub mod funcs { use types::os::arch::posix88::{gid_t, off_t, pid_t}; use types::os::arch::posix88::{ssize_t, uid_t}; - #[cfg(target_os = "macos")] - pub const _PC_NAME_MAX: c_int = 3; - #[cfg(target_os = "linux")] pub const _PC_NAME_MAX: c_int = 4; #[cfg(not(target_os = "nacl"))] From ac2bd85245cd58530a16a66b177a2b6a52943e2c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:21:20 -0700 Subject: [PATCH 026/194] Windows MSVC support [ci skip] --- libc-test/build.rs | 75 ++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c62dbe0642343..7aa243f62a524 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -41,49 +41,64 @@ impl<'a> TestGenerator<'a> { if self.target.contains("unknown-linux") { ret.push("_GNU_SOURCE"); } + if self.target.contains("msvc") { + ret.push("alignof __alignof"); + } return ret } fn headers(&self) -> Vec<&'static str> { - let mut base = vec![ + let mut base = Vec::new(); + + if self.target.contains("windows") { + base.push("windows.h"); + } + + base.extend(&[ "errno.h", "fcntl.h", - "glob.h", - "ifaddrs.h", "limits.h", - "net/if.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "pthread.h", - "signal.h", - "stdalign.h", "stddef.h", "stdint.h", "stdio.h", "stdlib.h", - "sys/mman.h", - "sys/resource.h", - "sys/socket.h", "sys/stat.h", - "sys/time.h", "sys/types.h", - "sys/un.h", "time.h", - "unistd.h", - "utime.h", "wchar.h", - ]; + ]); if self.target.contains("apple-darwin") { base.push("mach/mach_time.h"); } + if self.target.contains("unknown-linux") { base.push("linux/if_packet.h"); base.push("net/ethernet.h"); } + if self.target.contains("windows") { + base.push("ws2tcpip.h"); + } else { + base.push("glob.h"); + base.push("ifaddrs.h"); + base.push("net/if.h"); + base.push("netdb.h"); + base.push("netinet/in.h"); + base.push("netinet/ip.h"); + base.push("netinet/tcp.h"); + base.push("pthread.h"); + base.push("signal.h"); + base.push("stdalign.h"); + base.push("sys/mman.h"); + base.push("sys/resource.h"); + base.push("sys/socket.h"); + base.push("sys/time.h"); + base.push("sys/un.h"); + base.push("utime.h"); + base.push("unistd.h"); + } + return base } @@ -133,6 +148,10 @@ impl<'a> TestGenerator<'a> { ("linux", "unix", "gnu") } else if self.target.contains("apple-darwin") { ("macos", "unix", "") + } else if self.target.contains("windows-msvc") { + ("windows", "windows", "msvc") + } else if self.target.contains("windows-gnu") { + ("windows", "windows", "gnu") } else { panic!("unknown os/family width: {}", self.target) }; @@ -200,15 +219,19 @@ fn main() { // Walk the crate, emitting test cases for everything found visit::walk_crate(&mut tg, &krate); - drop(tg); // Compile our C shim to be linked into tests - gcc::Config::new() - .file(out.join("all.c")) - .flag("-Wall") - .flag("-Wextra") - .flag("-Werror") - .compile("liball.a"); + let mut cfg = gcc::Config::new(); + cfg.file(out.join("all.c")); + + if tg.target.contains("msvc") { + cfg.flag("/W3").flag("/Wall").flag("/WX"); + } else { + cfg.flag("-Wall").flag("-Wextra").flag("-Werror"); + } + + drop(tg); + cfg.compile("liball.a"); } impl<'a> TestGenerator<'a> { From b01a8ccd7c5dc12af25857938d9303cac9edba78 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:37:22 -0700 Subject: [PATCH 027/194] Don't worry about unused parameters --- libc-test/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7aa243f62a524..390d5487417c3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -227,7 +227,8 @@ fn main() { if tg.target.contains("msvc") { cfg.flag("/W3").flag("/Wall").flag("/WX"); } else { - cfg.flag("-Wall").flag("-Wextra").flag("-Werror"); + cfg.flag("-Wall").flag("-Wextra").flag("-Werror") + .arg("-Wno-unused-parameter"); } drop(tg); From 671376bac3bca80fd508b267fcc1477841297690 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:39:03 -0700 Subject: [PATCH 028/194] No parameters in C --- libc-test/build.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 390d5487417c3..194d8f3625f39 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -263,10 +263,10 @@ impl<'a> TestGenerator<'a> { let cfield = self.rust2cfield(ty, &name.to_string()); t!(writeln!(self.c, r#" - uint64_t __test_offset_{ty}_{rust_field}() {{ + uint64_t __test_offset_{ty}_{rust_field}(void) {{ return offsetof({cty}, {c_field}); }} - uint64_t __test_size_{ty}_{rust_field}() {{ + uint64_t __test_size_{ty}_{rust_field}(void) {{ {cty}* foo = NULL; return sizeof(foo->{c_field}); }} @@ -294,8 +294,8 @@ impl<'a> TestGenerator<'a> { fn test_size_align(&mut self, rust: &str, c: &str) { t!(writeln!(self.c, r#" - uint64_t __test_size_{ty}() {{ return sizeof({cty}); }} - uint64_t __test_align_{ty}() {{ return alignof({cty}); }} + uint64_t __test_size_{ty}(void) {{ return sizeof({cty}); }} + uint64_t __test_align_{ty}(void) {{ return alignof({cty}); }} "#, ty = rust, cty = c)); t!(writeln!(self.rust, r#" #[test] From 5f624a579ce4192234bd7c2052dc74dc9fdf09b9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:39:21 -0700 Subject: [PATCH 029/194] arg => flag --- libc-test/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 194d8f3625f39..1f991f1d1716f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -78,7 +78,7 @@ impl<'a> TestGenerator<'a> { } if self.target.contains("windows") { - base.push("ws2tcpip.h"); + base.push("winsock.h"); } else { base.push("glob.h"); base.push("ifaddrs.h"); @@ -228,7 +228,7 @@ fn main() { cfg.flag("/W3").flag("/Wall").flag("/WX"); } else { cfg.flag("-Wall").flag("-Wextra").flag("-Werror") - .arg("-Wno-unused-parameter"); + .flag("-Wno-unused-parameter"); } drop(tg); From 13a6f2daf10e2e3b72cbfdf1bc7367ae57e0be3b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 18:10:58 -0700 Subject: [PATCH 030/194] More windows fixes [ci skip] --- libc-test/build.rs | 36 +++++++----- libc-test/tests/all.rs | 1 + src/lib.rs | 124 +++++++++++------------------------------ 3 files changed, 56 insertions(+), 105 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 1f991f1d1716f..7e22708ba0104 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -50,10 +50,6 @@ impl<'a> TestGenerator<'a> { fn headers(&self) -> Vec<&'static str> { let mut base = Vec::new(); - if self.target.contains("windows") { - base.push("windows.h"); - } - base.extend(&[ "errno.h", "fcntl.h", @@ -78,7 +74,10 @@ impl<'a> TestGenerator<'a> { } if self.target.contains("windows") { - base.push("winsock.h"); + base.push("winsock2.h"); + base.push("ws2ipdef.h"); + base.push("windows.h"); + base.push("sys/utime.h"); } else { base.push("glob.h"); base.push("ifaddrs.h"); @@ -103,6 +102,7 @@ impl<'a> TestGenerator<'a> { } fn rust2c(&self, ty: &str) -> String { + let windows = self.target.contains("windows"); match ty { t if t.starts_with("c_") => { match &ty[2..].replace("long", " long")[..] { @@ -116,8 +116,18 @@ impl<'a> TestGenerator<'a> { "glob_t" => "glob_t".to_string(), t if t.starts_with("pthread") => t.to_string(), - t if self.structs.contains(t) => format!("struct {}", t), + t if self.structs.contains(t) => { + if windows && ty.chars().next().unwrap().is_uppercase() { + t.to_string() + } else if windows && t == "stat" { + "struct __stat64".to_string() + } else { + format!("struct {}", t) + } + } + "time64_t" if windows => "__time64_t".to_string(), + "ssize_t" if windows => "SSIZE_T".to_string(), t => t.to_string(), } } @@ -225,7 +235,9 @@ fn main() { cfg.file(out.join("all.c")); if tg.target.contains("msvc") { - cfg.flag("/W3").flag("/Wall").flag("/WX"); + cfg.flag("/W3").flag("/Wall").flag("/WX") + .flag("/wd4820") // weird warning about adding padding? + .flag("/wd4100"); // don't warn about unused parameters } else { cfg.flag("-Wall").flag("-Wextra").flag("-Werror") .flag("-Wno-unused-parameter"); @@ -322,13 +334,9 @@ impl<'a> TestGenerator<'a> { iter::repeat("*").take(ptrs).collect::()); let cast = if name == "SIG_IGN" {"(size_t)"} else {""}; t!(writeln!(self.c, r#" - int __test_const_{name}({cty} *out) {{ - int ret = 0; - #if defined({name}) - *out = {cast}({name}); - ret = 1; - #endif - return ret; + int __test_const_{name}({cty} *outptr) {{ + *outptr = {cast}({name}); + return 1; }} "#, name = name, cast = cast, cty = cty)); t!(writeln!(self.rust, r#" diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 665747fb24f90..15ad2cff1d4cd 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -7,6 +7,7 @@ use std::any::{Any, TypeId}; use std::mem; use libc::*; +#[cfg(not(windows))] use libc::types::os::common::bsd43::*; trait Pretty { diff --git a/src/lib.rs b/src/lib.rs index 234a642c9d489..4000bd9685bae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1694,11 +1694,11 @@ pub mod types { pub mod common { pub mod posix01 { use types::os::arch::c95::{c_short, time_t, c_long}; - use types::os::arch::extra::{int64, time64_t}; + use types::os::arch::extra::{time64_t}; use types::os::arch::posix88::{dev_t, ino_t}; - // pub Note: this is the struct called stat64 in Windows. Not stat, - // nor stati64. + // pub Note: this is the struct called stat64 in Windows. Not + // stat, nor stati64. #[repr(C)] #[derive(Copy, Clone)] pub struct stat { pub st_dev: dev_t, @@ -1708,7 +1708,7 @@ pub mod types { pub st_uid: c_short, pub st_gid: c_short, pub st_rdev: dev_t, - pub st_size: int64, + pub st_size: i64, pub st_atime: time64_t, pub st_mtime: time64_t, pub st_ctime: time64_t, @@ -1741,18 +1741,14 @@ pub mod types { use types::os::arch::c99::uintptr_t; pub type SOCKET = uintptr_t; - pub type socklen_t = c_int; - pub type sa_family_t = u16; - pub type in_port_t = u16; - pub type in_addr_t = u32; #[repr(C)] #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_family: sa_family_t, + pub sa_family: u16, pub sa_data: [u8; 14], } #[repr(C)] #[derive(Copy)] pub struct sockaddr_storage { - pub ss_family: sa_family_t, + pub ss_family: u16, __ss_pad1: [u8; 6], __ss_align: i64, __ss_pad2: [u8; 112], @@ -1762,19 +1758,19 @@ pub mod types { } #[repr(C)] #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_family: sa_family_t, - pub sin_port: in_port_t, + pub sin_family: u16, + pub sin_port: u16, pub sin_addr: in_addr, pub sin_zero: [u8; 8], } #[repr(C)] #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, + pub s_addr: u32, } #[repr(C)] #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, + pub sin6_family: u16, + pub sin6_port: u16, pub sin6_flowinfo: u32, pub sin6_addr: in6_addr, pub sin6_scope_id: u32, @@ -1782,7 +1778,6 @@ pub mod types { #[repr(C)] #[derive(Copy, Clone)] pub struct in6_addr { pub s6_addr: [u16; 8], - __align: [u32; 0], } #[repr(C)] #[derive(Copy, Clone)] pub struct ip_mreq { @@ -1805,14 +1800,6 @@ pub mod types { pub ai_addr: *mut sockaddr, pub ai_next: *mut addrinfo, } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } } } @@ -1847,11 +1834,6 @@ pub mod types { #[cfg(target_arch = "x86_64")] pub type time_t = i64; - #[cfg(target_arch = "x86")] - pub type suseconds_t = i32; - #[cfg(target_arch = "x86_64")] - pub type suseconds_t = i64; - pub type wchar_t = u16; } @@ -1878,11 +1860,6 @@ pub mod types { pub type dev_t = u32; pub type ino_t = u16; - pub type pid_t = u32; - - pub type useconds_t = u32; - pub type mode_t = u16; - #[cfg(target_arch = "x86")] pub type ssize_t = i32; #[cfg(target_arch = "x86_64")] @@ -1959,10 +1936,9 @@ pub mod types { pub type SIZE_T = size_t; pub type time64_t = i64; - pub type int64 = i64; #[repr(C)] - #[derive(Copy, Clone)] pub struct STARTUPINFO { + #[derive(Copy, Clone)] pub struct STARTUPINFOW { pub cb: DWORD, pub lpReserved: LPWSTR, pub lpDesktop: LPWSTR, @@ -1972,7 +1948,7 @@ pub mod types { pub dwXSize: DWORD, pub dwYSize: DWORD, pub dwXCountChars: DWORD, - pub dwYCountCharts: DWORD, + pub dwYCountChars: DWORD, pub dwFillAttribute: DWORD, pub dwFlags: DWORD, pub wShowWindow: WORD, @@ -1982,7 +1958,7 @@ pub mod types { pub hStdOutput: HANDLE, pub hStdError: HANDLE, } - pub type LPSTARTUPINFO = *mut STARTUPINFO; + pub type LPSTARTUPINFOW = *mut STARTUPINFOW; #[repr(C)] #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION { @@ -2019,7 +1995,7 @@ pub mod types { pub Protect: DWORD, pub Type: DWORD, } - pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; + pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; #[repr(C)] #[derive(Copy, Clone)] pub struct OVERLAPPED { @@ -2532,8 +2508,8 @@ pub mod consts { pub const BUFSIZ : c_uint = 512; pub const FOPEN_MAX : c_uint = 20; pub const FILENAME_MAX : c_uint = 260; - pub const L_tmpnam : c_uint = 16; - pub const TMP_MAX : c_uint = 32767; + pub const L_tmpnam : c_uint = 260; + pub const TMP_MAX : c_uint = 0x7fff_ffff; pub const WSAEINTR: c_int = 10004; pub const WSAEBADF: c_int = 10009; @@ -2592,7 +2568,6 @@ pub mod consts { } pub mod posix88 { use types::os::arch::c95::c_int; - use types::os::arch::posix88::mode_t; pub const O_RDONLY : c_int = 0; pub const O_WRONLY : c_int = 1; @@ -2601,36 +2576,13 @@ pub mod consts { pub const O_CREAT : c_int = 256; pub const O_EXCL : c_int = 1024; pub const O_TRUNC : c_int = 512; - pub const S_IFIFO : c_int = 4096; pub const S_IFCHR : c_int = 8192; - pub const S_IFBLK : c_int = 12288; pub const S_IFDIR : c_int = 16384; pub const S_IFREG : c_int = 32768; - pub const S_IFLNK : c_int = 40960; - pub const S_IFSOCK : mode_t = 49152; pub const S_IFMT : c_int = 61440; pub const S_IEXEC : c_int = 64; pub const S_IWRITE : c_int = 128; pub const S_IREAD : c_int = 256; - pub const S_IRWXU : c_int = 448; - pub const S_IXUSR : c_int = 64; - pub const S_IWUSR : c_int = 128; - pub const S_IRUSR : c_int = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; } pub mod posix01 { } @@ -2651,8 +2603,8 @@ pub mod consts { pub const IP_MULTICAST_LOOP: c_int = 11; pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 5; - pub const IPV6_DROP_MEMBERSHIP: c_int = 6; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; pub const IP_TTL: c_int = 4; pub const IP_HDRINCL: c_int = 2; @@ -2679,9 +2631,9 @@ pub mod consts { pub const IFF_LOOPBACK: c_int = 4; - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; + pub const SD_RECEIVE: c_int = 0; + pub const SD_SEND: c_int = 1; + pub const SD_BOTH: c_int = 2; } pub mod extra { use types::os::common::bsd44::SOCKET; @@ -2851,7 +2803,7 @@ pub mod consts { pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; - pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x0100000; + pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000; pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; @@ -6155,25 +6107,25 @@ pub mod funcs { #[cfg(windows)] pub mod bsd43 { use types::common::c95::{c_void}; - use types::os::common::bsd44::{socklen_t, sockaddr, SOCKET}; + use types::os::common::bsd44::{sockaddr, SOCKET}; use types::os::arch::c95::c_int; extern "system" { pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; pub fn connect(socket: SOCKET, address: *const sockaddr, - len: socklen_t) -> c_int; + len: c_int) -> c_int; pub fn bind(socket: SOCKET, address: *const sockaddr, - address_len: socklen_t) -> c_int; + address_len: c_int) -> c_int; pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; pub fn accept(socket: SOCKET, address: *mut sockaddr, - address_len: *mut socklen_t) -> SOCKET; + address_len: *mut c_int) -> SOCKET; pub fn getpeername(socket: SOCKET, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; + address_len: *mut c_int) -> c_int; pub fn getsockname(socket: SOCKET, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; + address_len: *mut c_int) -> c_int; pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, value: *const c_void, - option_len: socklen_t) -> c_int; + option_len: c_int) -> c_int; pub fn closesocket(socket: SOCKET) -> c_int; pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, flags: c_int) -> c_int; @@ -6298,17 +6250,7 @@ pub mod funcs { pub mod kernel32 { use types::os::arch::c95::{c_uint}; - use types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE, - LPCWSTR, LPWSTR, - LPWCH, LPDWORD, LPVOID, - LPCVOID, LPOVERLAPPED, - LPSECURITY_ATTRIBUTES, - LPSTARTUPINFO, - LPPROCESS_INFORMATION, - LPMEMORY_BASIC_INFORMATION, - LPSYSTEM_INFO, HANDLE, LPHANDLE, - LARGE_INTEGER, PLARGE_INTEGER, - LPFILETIME, LPWIN32_FIND_DATAW}; + use types::os::arch::extra::*; extern "system" { pub fn GetEnvironmentVariableW(n: LPCWSTR, @@ -6367,7 +6309,7 @@ pub mod funcs { dwCreationFlags: DWORD, lpEnvironment: LPVOID, lpCurrentDirectory: LPCWSTR, - lpStartupInfo: LPSTARTUPINFO, + lpStartupInfo: LPSTARTUPINFOW, lpProcessInformation: LPPROCESS_INFORMATION) -> BOOL; @@ -6398,7 +6340,7 @@ pub mod funcs { lpflOldProtect: LPDWORD) -> BOOL; pub fn VirtualQuery(lpAddress: LPCVOID, - lpBuffer: LPMEMORY_BASIC_INFORMATION, + lpBuffer: PMEMORY_BASIC_INFORMATION, dwLength: SIZE_T) -> SIZE_T; pub fn CreateFileMappingW(hFile: HANDLE, From 26333d3147fd8ee14681a18d2c46b9bb0df96a04 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 17:17:16 -0700 Subject: [PATCH 031/194] Semi-pin to a version of syntex_syntax --- libc-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index dfad9b72730b9..e918ec21c125a 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" libc = { path = ".." } [build-dependencies] -syntex_syntax = "*" +syntex_syntax = "0.13.0" gcc = "0.3" [lib] From d7a154704407e7101313ef7670518b3bac36a3c7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 19:13:15 -0700 Subject: [PATCH 032/194] Try to fix _PC_NAME_MAX again --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 4000bd9685bae..86ba79ef0f167 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5730,6 +5730,9 @@ pub mod funcs { use types::os::arch::posix88::{gid_t, off_t, pid_t}; use types::os::arch::posix88::{ssize_t, uid_t}; + #[cfg(target_os = "linux")] + pub const _PC_NAME_MAX: c_int = 3; + #[cfg(target_os = "macos")] pub const _PC_NAME_MAX: c_int = 4; #[cfg(not(target_os = "nacl"))] From 2237882ddc57f426d4e84137de68cf128a31e6c7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 19:59:23 -0700 Subject: [PATCH 033/194] Test some functions! --- libc-test/build.rs | 195 ++++++++++++++++++++++++++++++----------- libc-test/tests/all.rs | 8 +- src/lib.rs | 61 +++---------- 3 files changed, 163 insertions(+), 101 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7e22708ba0104..4b64473b92b81 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -6,7 +6,6 @@ use std::env; use std::fs::File; use std::io::BufWriter; use std::io::prelude::*; -use std::iter; use std::path::{Path, PathBuf}; use syntax::ast; @@ -79,6 +78,8 @@ impl<'a> TestGenerator<'a> { base.push("windows.h"); base.push("sys/utime.h"); } else { + base.push("ctype.h"); + base.push("dirent.h"); base.push("glob.h"); base.push("ifaddrs.h"); base.push("net/if.h"); @@ -89,13 +90,16 @@ impl<'a> TestGenerator<'a> { base.push("pthread.h"); base.push("signal.h"); base.push("stdalign.h"); + base.push("sys/file.h"); + base.push("sys/ioctl.h"); base.push("sys/mman.h"); base.push("sys/resource.h"); base.push("sys/socket.h"); base.push("sys/time.h"); base.push("sys/un.h"); - base.push("utime.h"); + base.push("sys/wait.h"); base.push("unistd.h"); + base.push("utime.h"); } return base @@ -113,7 +117,10 @@ impl<'a> TestGenerator<'a> { } } "ip6_mreq" => "struct ipv6_mreq".to_string(), - "glob_t" => "glob_t".to_string(), + "glob_t" | + "FILE" | + "DIR" | + "fpos_t" => ty.to_string(), t if t.starts_with("pthread") => t.to_string(), t if self.structs.contains(t) => { @@ -253,12 +260,12 @@ impl<'a> TestGenerator<'a> { "sighandler_t" => return, _ => {} } - let c = self.rust2c(ty); + let c = self.rust_ty_to_c_ty(ty); self.test_size_align(ty, &c); } fn test_struct(&mut self, ty: &str, s: &ast::StructDef) { - let cty = self.rust2c(ty); + let cty = self.rust_ty_to_c_ty(ty); self.test_size_align(ty, &cty); t!(writeln!(self.rust, r#" @@ -326,12 +333,23 @@ impl<'a> TestGenerator<'a> { "#, ty = rust)); } + fn rust_ty_to_c_ty(&self, mut rust_ty: &str) -> String { + let mut cty = self.rust2c(&rust_ty.replace("*mut ", "") + .replace("*const ", "")); + while rust_ty.starts_with("*") { + if rust_ty.starts_with("*const") { + cty = format!("const {}*", cty); + rust_ty = &rust_ty[7..]; + } else { + cty = format!("{}*", cty); + rust_ty = &rust_ty[5..]; + } + } + return cty + } + fn test_const(&mut self, name: &str, rust_ty: &str) { - let cty = self.rust2c(&rust_ty.replace("*mut ", "") - .replace("*const ", "")); - let ptrs = rust_ty.matches("*").count(); - let cty = format!("{}{}", cty, - iter::repeat("*").take(ptrs).collect::()); + let cty = self.rust_ty_to_c_ty(rust_ty); let cast = if name == "SIG_IGN" {"(size_t)"} else {""}; t!(writeln!(self.c, r#" int __test_const_{name}({cty} *outptr) {{ @@ -357,10 +375,49 @@ impl<'a> TestGenerator<'a> { "#, ty = rust_ty, name = name)); } - fn assert_no_generics(&self, _i: &ast::Item, generics: &ast::Generics) { - assert!(generics.lifetimes.len() == 0); - assert!(generics.ty_params.len() == 0); - assert!(generics.where_clause.predicates.len() == 0); + fn test_extern_fn(&mut self, name: &str, args: &[String], ret: &str, + variadic: bool) { + match name { + // manually verified + "execv" | + "execve" | + "execvp" | + "glob" | + "getrlimit" | + "setrlimit" | + "getopt" => return, + _ => {} + } + let args = if args.len() == 0 && !variadic { + "void".to_string() + } else { + args.iter().map(|a| self.rust_ty_to_c_ty(a)).collect::>() + .connect(", ") + if variadic {", ..."} else {""} + }; + let cret = self.rust_ty_to_c_ty(ret); + t!(writeln!(self.c, r#" + {ret} (*__test_fn_{name}(void))({args}) {{ + return {name}; + }} + "#, name = name, args = args, ret = cret)); + t!(writeln!(self.rust, r#" + #[test] + fn fn_{name}() {{ + extern {{ + fn __test_fn_{name}() -> size_t; + }} + unsafe {{ + same({name} as usize, + __test_fn_{name}() as usize, "function pointer"); + }} + }} + "#, name = name)); + } + + fn assert_no_generics(&self, _i: ast::Ident, generics: &ast::Generics) { + assert!(generics.lifetimes.len() == 0); + assert!(generics.ty_params.len() == 0); + assert!(generics.where_clause.predicates.len() == 0); } fn ty2name(&self, ty: &ast::Ty) -> String { @@ -374,52 +431,90 @@ impl<'a> TestGenerator<'a> { ast::MutMutable => "mut", }, self.ty2name(&t.ty)) } + ast::TyBareFn(ref t) => { + assert!(t.lifetimes.len() == 0); + let (ret, mut args, variadic) = self.decl2rust(&t.decl); + assert!(!variadic); + if args.len() == 0 { + args.push("void".to_string()); + } + format!("{}(*)({})", ret, args.connect(", ")) + } _ => panic!("unknown ty {:?}", ty), } } + + fn decl2rust(&self, decl: &ast::FnDecl) -> (String, Vec, bool) { + let args = decl.inputs.iter().map(|arg| { + self.ty2name(&arg.ty) + }).collect::>(); + let ret = match decl.output { + ast::NoReturn(..) | + ast::DefaultReturn(..) => "void".to_string(), + ast::Return(ref t) => self.ty2name(t), + }; + (ret, args, decl.variadic) + } } impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { - fn visit_item(&mut self, i: &'v ast::Item) { - match i.node { - ast::ItemTy(_, ref generics) => { - self.assert_no_generics(i, generics); - self.test_type(&i.ident.to_string()); - } - - ast::ItemStruct(ref s, ref generics) => { - self.assert_no_generics(i, generics); - let is_c = i.attrs.iter().any(|a| { + fn visit_item(&mut self, i: &'v ast::Item) { + match i.node { + ast::ItemTy(_, ref generics) => { + self.assert_no_generics(i.ident, generics); + self.test_type(&i.ident.to_string()); + } + + ast::ItemStruct(ref s, ref generics) => { + self.assert_no_generics(i.ident, generics); + let is_c = i.attrs.iter().any(|a| { attr::find_repr_attrs(self.sh, a).iter().any(|a| { *a == ReprAttr::ReprExtern }) - }); - if !is_c { - panic!("{} is not marked #[repr(C)]", i.ident); - } - self.test_struct(&i.ident.to_string(), s); - } - - ast::ItemConst(ref ty, _) => { - let ty = self.ty2name(ty); - self.test_const(&i.ident.to_string(), &ty); - } - - _ => {} - } - visit::walk_item(self, i) - } + }); + if !is_c { + panic!("{} is not marked #[repr(C)]", i.ident); + } + self.test_struct(&i.ident.to_string(), s); + } + + ast::ItemConst(ref ty, _) => { + let ty = self.ty2name(ty); + self.test_const(&i.ident.to_string(), &ty); + } + + _ => {} + } + visit::walk_item(self, i) + } + + fn visit_foreign_item(&mut self, i: &'v ast::ForeignItem) { + match i.node { + ast::ForeignItemFn(ref decl, ref generics) => { + self.assert_no_generics(i.ident, generics); + let (ret, args, variadic) = self.decl2rust(decl); + self.test_extern_fn(&i.ident.to_string(), &args, &ret, + variadic); + } + ast::ForeignItemStatic(_, _) => { + } + } + visit::walk_foreign_item(self, i) + } } impl<'v> Visitor<'v> for StructFinder { - fn visit_item(&mut self, i: &'v ast::Item) { - match i.node { - ast::ItemStruct(..) => { - self.structs.insert(i.ident.to_string()); - } - - _ => {} - } - visit::walk_item(self, i) - } + fn visit_item(&mut self, i: &'v ast::Item) { + match i.node { + ast::ItemStruct(..) => { + self.structs.insert(i.ident.to_string()); + } + ast::ItemEnum(..) => { + self.structs.insert(i.ident.to_string()); + } + + _ => {} + } + visit::walk_item(self, i) + } } diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 15ad2cff1d4cd..298a3c9a9a7f8 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -7,8 +7,12 @@ use std::any::{Any, TypeId}; use std::mem; use libc::*; -#[cfg(not(windows))] -use libc::types::os::common::bsd43::*; +#[cfg(unix)] use libc::types::os::common::bsd43::*; +#[cfg(unix)] use libc::funcs::bsd44::*; +#[cfg(unix)] use libc::funcs::posix01::mman::*; +#[cfg(unix)] use libc::funcs::posix01::glob::*; +#[cfg(unix)] use libc::funcs::posix01::signal::*; +#[cfg(unix)] use libc::funcs::posix88::signal::*; trait Pretty { fn pretty(&self) -> String; diff --git a/src/lib.rs b/src/lib.rs index 86ba79ef0f167..4df3ee600f1ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -201,7 +201,7 @@ pub mod types { } pub mod posix88 { pub enum DIR {} - pub enum dirent_t {} + pub enum dirent {} } pub mod posix01 {} pub mod posix08 {} @@ -5306,7 +5306,7 @@ pub mod funcs { pub mod c95 { pub mod ctype { - use types::os::arch::c95::{c_char, c_int}; + use types::os::arch::c95::c_int; extern { pub fn isalnum(c: c_int) -> c_int; @@ -5320,8 +5320,8 @@ pub mod funcs { pub fn isspace(c: c_int) -> c_int; pub fn isupper(c: c_int) -> c_int; pub fn isxdigit(c: c_int) -> c_int; - pub fn tolower(c: c_char) -> c_char; - pub fn toupper(c: c_char) -> c_char; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; } } @@ -5376,7 +5376,7 @@ pub mod funcs { pub fn ftell(stream: *mut FILE) -> c_long; pub fn rewind(stream: *mut FILE); pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; - pub fn fsetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); @@ -5659,58 +5659,21 @@ pub mod funcs { use types::os::arch::c95::{c_char, c_int}; use types::os::arch::posix88::mode_t; - mod open_shim { - extern { - #[cfg(any(target_os = "macos", - target_os = "ios"))] - pub fn open(path: *const ::c_char, oflag: ::c_int, ...) - -> ::c_int; - - #[cfg(not(any(target_os = "macos", - target_os = "ios")))] - pub fn open(path: *const ::c_char, oflag: ::c_int, mode: ::mode_t) - -> ::c_int; - } - } - - #[cfg(any(target_os = "macos", - target_os = "ios"))] - #[inline] - pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { - use types::os::arch::c95::c_uint; - open_shim::open(path, oflag, mode as c_uint) - } - - #[cfg(not(any(target_os = "macos", - target_os = "ios")))] - #[inline] - pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { - open_shim::open(path, oflag, mode) - } - extern { + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; pub fn creat(path: *const c_char, mode: mode_t) -> c_int; pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; } } pub mod dirent { - use types::common::posix88::{DIR, dirent_t}; + use types::common::posix88::{DIR, dirent}; use types::os::arch::c95::{c_char, c_int, c_long}; - // NB: On OS X opendir and readdir have two versions, - // one for 32-bit kernelspace and one for 64. - // We should be linking to the 64-bit ones, called - // opendir$INODE64, etc. but for some reason rustc - // doesn't link it correctly on i686, so we're going - // through a C function that mysteriously does work. - extern { - #[link_name="rust_opendir"] pub fn opendir(dirname: *const c_char) -> *mut DIR; - #[link_name="rust_readdir_r"] - pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent_t, - result: *mut *mut dirent_t) -> c_int; + pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent, + result: *mut *mut dirent) -> c_int; } extern { @@ -5774,7 +5737,7 @@ pub mod funcs { pub fn link(src: *const c_char, dst: *const c_char) -> c_int; pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; - pub fn pathconf(path: *mut c_char, name: c_int) -> c_long; + pub fn pathconf(path: *const c_char, name: c_int) -> c_long; pub fn pause() -> c_int; pub fn pipe(fds: *mut c_int) -> c_int; pub fn read(fd: c_int, buf: *mut c_void, count: size_t) @@ -5792,8 +5755,8 @@ pub mod funcs { pub fn tcgetpgrp(fd: c_int) -> pid_t; pub fn ttyname(fd: c_int) -> *mut c_char; pub fn unlink(c: *const c_char) -> c_int; - pub fn wait(status: *const c_int) -> pid_t; - pub fn waitpid(pid: pid_t, status: *const c_int, options: c_int) + pub fn wait(status: *mut c_int) -> pid_t; + pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; From e8606192d80fb82cabf2b89cac19e77ab73238db Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 20:19:44 -0700 Subject: [PATCH 034/194] Get OSX tests compiling --- libc-test/build.rs | 4 ++++ libc-test/tests/all.rs | 3 ++- src/lib.rs | 16 ++++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4b64473b92b81..54f5a9fbcd747 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -64,6 +64,7 @@ impl<'a> TestGenerator<'a> { ]); if self.target.contains("apple-darwin") { + base.push("mach-o/dyld.h"); base.push("mach/mach_time.h"); } @@ -90,11 +91,13 @@ impl<'a> TestGenerator<'a> { base.push("pthread.h"); base.push("signal.h"); base.push("stdalign.h"); + base.push("string.h"); base.push("sys/file.h"); base.push("sys/ioctl.h"); base.push("sys/mman.h"); base.push("sys/resource.h"); base.push("sys/socket.h"); + base.push("sys/sysctl.h"); base.push("sys/time.h"); base.push("sys/un.h"); base.push("sys/wait.h"); @@ -385,6 +388,7 @@ impl<'a> TestGenerator<'a> { "glob" | "getrlimit" | "setrlimit" | + "signal" | "getopt" => return, _ => {} } diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 298a3c9a9a7f8..7fb6efb7e2658 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -1,4 +1,4 @@ -#![allow(bad_style)] +#![allow(bad_style, unused_imports)] extern crate libc; extern crate libc_test; @@ -13,6 +13,7 @@ use libc::*; #[cfg(unix)] use libc::funcs::posix01::glob::*; #[cfg(unix)] use libc::funcs::posix01::signal::*; #[cfg(unix)] use libc::funcs::posix88::signal::*; +#[cfg(target_os = "macos")] use libc::funcs::extra::*; trait Pretty { fn pretty(&self) -> String; diff --git a/src/lib.rs b/src/lib.rs index 4df3ee600f1ca..33493ad4e2951 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5834,7 +5834,7 @@ pub mod funcs { pub mod mman { use types::common::c95::{c_void}; use types::os::arch::c95::{size_t, c_int, c_char}; - use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{off_t}; #[cfg(not(target_os = "nacl"))] extern { @@ -5848,8 +5848,12 @@ pub mod funcs { pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) + #[cfg(target_os = "macos")] + pub fn shm_open(name: *const c_char, oflag: c_int, ...) -> c_int; + #[cfg(target_os = "linux")] + pub fn shm_open(name: *const c_char, oflag: c_int, + mode: ::mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; } @@ -6116,7 +6120,7 @@ pub mod funcs { target_os = "openbsd"))] pub mod bsd44 { use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t}; + use types::os::arch::c95::{c_char, c_int, c_uint, c_ulong, size_t}; extern { pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; @@ -6140,7 +6144,7 @@ pub mod funcs { pub fn getdtablesize() -> c_int; pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; - pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) + pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; @@ -6190,10 +6194,10 @@ pub mod funcs { #[cfg(any(target_os = "macos", target_os = "ios"))] pub mod extra { - use types::os::arch::c95::{c_char, c_int}; + use {c_char, c_int, uint32_t}; extern { - pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32) + pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut uint32_t) -> c_int; } } From 45ae2f4cd071d2c058ef031f1d7030d0b4719419 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 20:37:55 -0700 Subject: [PATCH 035/194] Fix linkage on OSX --- src/lib.rs | 139 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 110 insertions(+), 29 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 33493ad4e2951..5aa50af80c33c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5330,8 +5330,12 @@ pub mod funcs { use types::os::arch::c95::{c_char, c_int, c_long, size_t}; extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fopen$UNIX2003")] pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "freopen$UNIX2003")] pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; @@ -5352,6 +5356,8 @@ pub mod funcs { pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fputs$UNIX2003")] pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; // Omitted: getc, getchar (might be macros). @@ -5366,6 +5372,8 @@ pub mod funcs { nobj: size_t, stream: *mut FILE) -> size_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fwrite$UNIX2003")] pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, @@ -5395,6 +5403,8 @@ pub mod funcs { // Omitted: div, ldiv (return pub type incomplete). pub fn atof(s: *const c_char) -> c_double; pub fn atoi(s: *const c_char) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "strtod$UNIX2003")] pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; pub fn strtol(s: *const c_char, @@ -5408,6 +5418,8 @@ pub mod funcs { pub fn exit(status: c_int) -> !; pub fn _exit(status: c_int) -> !; pub fn atexit(cb: extern fn()) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "system$UNIX2003")] pub fn system(s: *const c_char) -> c_int; pub fn getenv(s: *const c_char) -> *mut c_char; // Omitted: bsearch, qsort @@ -5442,6 +5454,8 @@ pub mod funcs { pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; pub fn strlen(cs: *const c_char) -> size_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "strerror$UNIX2003")] pub fn strerror(n: c_int) -> *mut c_char; pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; pub fn strxfrm(s: *mut c_char, ct: *const c_char, @@ -5603,41 +5617,21 @@ pub mod funcs { use types::os::arch::posix88::mode_t; extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "chmod$UNIX2003")] pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fchmod$UNIX2003")] pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; - #[cfg(any(target_os = "linux", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd", - target_os = "android", - target_os = "ios", - target_os = "nacl"))] - pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; - - #[cfg(target_os = "macos")] - #[link_name = "fstat64"] + #[cfg_attr(target_os = "macos", link_name = "fstat64")] pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; #[cfg(not(target_os = "nacl"))] pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; - #[cfg(any(target_os = "linux", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd", - target_os = "android", - target_os = "ios", - target_os = "nacl"))] - pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; - - #[cfg(target_os = "macos")] - #[link_name = "stat64"] + #[cfg_attr(target_os = "macos", link_name = "stat64")] pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; } } @@ -5647,9 +5641,13 @@ pub mod funcs { use types::os::arch::c95::{c_char, c_int}; extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003")] pub fn popen(command: *const c_char, mode: *const c_char) -> *mut FILE; pub fn pclose(stream: *mut FILE) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fdopen$UNIX2003")] pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; pub fn fileno(stream: *mut FILE) -> c_int; } @@ -5660,8 +5658,14 @@ pub mod funcs { use types::os::arch::posix88::mode_t; extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "open$UNIX2003")] pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "creat$UNIX2003")] pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fcntl$UNIX2003")] pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; } } @@ -5671,15 +5675,31 @@ pub mod funcs { use types::os::arch::c95::{c_char, c_int, c_long}; extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "opendir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "opendir$INODE64$UNIX2003")] pub fn opendir(dirname: *const c_char) -> *mut DIR; + #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent, result: *mut *mut dirent) -> c_int; - } - - extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "closedir$UNIX2003")] pub fn closedir(dirp: *mut DIR) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "rewinddir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "rewinddir$INODE64$UNIX2003")] pub fn rewinddir(dirp: *mut DIR); + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003")] pub fn seekdir(dirp: *mut DIR, loc: c_long); + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003")] pub fn telldir(dirp: *mut DIR) -> c_long; } } @@ -5705,6 +5725,8 @@ pub mod funcs { pub fn chdir(dir: *const c_char) -> c_int; pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "close$UNIX2003")] pub fn close(fd: c_int) -> c_int; pub fn dup(fd: c_int) -> c_int; pub fn dup2(src: c_int, dst: c_int) -> c_int; @@ -5738,8 +5760,12 @@ pub mod funcs { pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pause$UNIX2003")] pub fn pause() -> c_int; pub fn pipe(fds: *mut c_int) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "read$UNIX2003")] pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; pub fn rmdir(path: *const c_char) -> c_int; @@ -5747,21 +5773,37 @@ pub mod funcs { pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; pub fn setsid() -> pid_t; pub fn setuid(uid: uid_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "sleep$UNIX2003")] pub fn sleep(secs: c_uint) -> c_uint; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "usleep$UNIX2003")] pub fn usleep(secs: c_uint) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "nanosleep$UNIX2003")] pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int; pub fn sysconf(name: c_int) -> c_long; pub fn tcgetpgrp(fd: c_int) -> pid_t; pub fn ttyname(fd: c_int) -> *mut c_char; pub fn unlink(c: *const c_char) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "wait$UNIX2003")] pub fn wait(status: *mut c_int) -> pid_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "waitpid$UNIX2003")] pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "write$UNIX2003")] pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pread$UNIX2003")] pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pwrite$UNIX2003")] pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t; pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; @@ -5827,6 +5869,8 @@ pub mod funcs { use types::os::arch::posix88::{pid_t}; extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "kill$UNIX2003")] pub fn kill(pid: pid_t, sig: c_int) -> c_int; } } @@ -5843,9 +5887,13 @@ pub mod funcs { pub fn mlockall(flags: c_int) -> c_int; pub fn munlockall() -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003")] pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; #[cfg(target_os = "macos")] @@ -5858,6 +5906,8 @@ pub mod funcs { } extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "mmap$UNIX2003")] pub fn mmap(addr: *mut c_void, len: size_t, prot: c_int, @@ -5865,6 +5915,8 @@ pub mod funcs { fd: c_int, offset: off_t) -> *mut c_void; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "munmap$UNIX2003")] pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; } @@ -5923,14 +5975,22 @@ pub mod funcs { bufsz: size_t) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fsync$UNIX2003")] pub fn fsync(fd: c_int) -> c_int; #[cfg(any(target_os = "linux", target_os = "android"))] pub fn fdatasync(fd: c_int) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "setenv$UNIX2003")] pub fn setenv(name: *const c_char, val: *const c_char, overwrite: c_int) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "unsetenv$UNIX2003")] pub fn unsetenv(name: *const c_char) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "putenv$UNIX2003")] pub fn putenv(string: *mut c_char) -> c_int; pub fn symlink(path1: *const c_char, @@ -6044,27 +6104,47 @@ pub mod funcs { extern "system" { pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "connect$UNIX2003")] pub fn connect(socket: c_int, address: *const sockaddr, len: socklen_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "bind$UNIX2003")] pub fn bind(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "listen$UNIX2003")] pub fn listen(socket: c_int, backlog: c_int) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "accept$UNIX2003")] pub fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "getpeername$UNIX2003")] pub fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "getsockname$UNIX2003")] pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; pub fn setsockopt(socket: c_int, level: c_int, name: c_int, value: *const c_void, option_len: socklen_t) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recv$UNIX2003")] pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "send$UNIX2003")] pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003")] pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "sendto$UNIX2003")] pub fn sendto(socket: c_int, buf: *const c_void, len: size_t, flags: c_int, addr: *const sockaddr, addrlen: socklen_t) -> ssize_t; @@ -6146,6 +6226,7 @@ pub mod funcs { -> c_int; pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; + #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; pub fn flock(fd: c_int, operation: c_int) -> c_int; From 7da9b10fc625c0af5de3f17a0d74f38b22a4c035 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 20:57:14 -0700 Subject: [PATCH 036/194] More windows compat [ci skip] --- libc-test/build.rs | 33 +++++++++++++++++++++++++-------- src/lib.rs | 18 +++++++++--------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 54f5a9fbcd747..d9aadc11f5d66 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -74,10 +74,14 @@ impl<'a> TestGenerator<'a> { } if self.target.contains("windows") { - base.push("winsock2.h"); - base.push("ws2ipdef.h"); - base.push("windows.h"); + base.push("winsock2.h"); // must be before windows.h + + base.push("direct.h"); + base.push("io.h"); base.push("sys/utime.h"); + base.push("windows.h"); + base.push("process.h"); + base.push("ws2ipdef.h"); } else { base.push("ctype.h"); base.push("dirent.h"); @@ -131,6 +135,8 @@ impl<'a> TestGenerator<'a> { t.to_string() } else if windows && t == "stat" { "struct __stat64".to_string() + } else if windows && t == "utimbuf" { + "struct __utimbuf64".to_string() } else { format!("struct {}", t) } @@ -247,7 +253,8 @@ fn main() { if tg.target.contains("msvc") { cfg.flag("/W3").flag("/Wall").flag("/WX") .flag("/wd4820") // weird warning about adding padding? - .flag("/wd4100"); // don't warn about unused parameters + .flag("/wd4100") // don't warn about unused parameters + .flag("/wd4996"); // don't warn about deprecated functions } else { cfg.flag("-Wall").flag("-Wextra").flag("-Werror") .flag("-Wno-unused-parameter"); @@ -378,13 +385,15 @@ impl<'a> TestGenerator<'a> { "#, ty = rust_ty, name = name)); } - fn test_extern_fn(&mut self, name: &str, args: &[String], ret: &str, + fn test_extern_fn(&mut self, name: &str, cname: &str, + args: &[String], ret: &str, variadic: bool) { match name { // manually verified "execv" | "execve" | "execvp" | + "execvpe" | "glob" | "getrlimit" | "setrlimit" | @@ -401,11 +410,12 @@ impl<'a> TestGenerator<'a> { let cret = self.rust_ty_to_c_ty(ret); t!(writeln!(self.c, r#" {ret} (*__test_fn_{name}(void))({args}) {{ - return {name}; + return {cname}; }} - "#, name = name, args = args, ret = cret)); + "#, name = name, cname = cname, args = args, ret = cret)); t!(writeln!(self.rust, r#" #[test] + #[cfg_attr(windows, ignore)] // FIXME -- dllimport weirdness? fn fn_{name}() {{ extern {{ fn __test_fn_{name}() -> size_t; @@ -497,7 +507,14 @@ impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { ast::ForeignItemFn(ref decl, ref generics) => { self.assert_no_generics(i.ident, generics); let (ret, args, variadic) = self.decl2rust(decl); - self.test_extern_fn(&i.ident.to_string(), &args, &ret, + let cname = match attr::first_attr_value_str_by_name(&i.attrs, + "link_name") { + Some(ref i) if !i.to_string().contains("$") => { + i.to_string() + } + _ => i.ident.to_string(), + }; + self.test_extern_fn(&i.ident.to_string(), &cname, &args, &ret, variadic); } ast::ForeignItemStatic(_, _) => { diff --git a/src/lib.rs b/src/lib.rs index 5aa50af80c33c..f17bc99f16877 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] +#![feature(linked_from)] //! Bindings for the C standard library and other platform libraries //! @@ -5397,6 +5398,8 @@ pub mod funcs { use types::os::arch::c95::{c_long, c_uint, c_ulong}; use types::os::arch::c95::{size_t}; + #[linked_from = "kernel32"] + #[link(name = "kernel32")] extern { pub fn abs(i: c_int) -> c_int; pub fn labs(i: c_long) -> c_long; @@ -5527,11 +5530,9 @@ pub mod funcs { use types::os::arch::c95::{c_int, c_char, wchar_t}; extern { #[link_name = "_open"] - pub fn open(path: *const c_char, oflag: c_int, mode: c_int) - -> c_int; + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; #[link_name = "_wopen"] - pub fn wopen(path: *const wchar_t, oflag: c_int, mode: c_int) - -> c_int; + pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int; #[link_name = "_creat"] pub fn creat(path: *const c_char, mode: c_int) -> c_int; } @@ -5543,8 +5544,7 @@ pub mod funcs { pub mod unistd { use types::common::c95::c_void; - use types::os::arch::c95::{c_int, c_uint, c_char, - c_long, size_t}; + use types::os::arch::c95::{c_int, c_uint, c_char, c_long}; use types::os::arch::c99::intptr_t; extern { @@ -5572,7 +5572,7 @@ pub mod funcs { pub fn execvpe(c: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> c_int; #[link_name = "_getcwd"] - pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char; #[link_name = "_getpid"] pub fn getpid() -> c_int; #[link_name = "_isatty"] @@ -6480,7 +6480,7 @@ pub mod funcs { } pub mod msvcrt { - use types::os::arch::c95::{c_int, c_long}; + use types::os::arch::c95::c_int; use types::os::arch::c99::intptr_t; extern { @@ -6488,7 +6488,7 @@ pub mod funcs { pub fn commit(fd: c_int) -> c_int; #[link_name = "_get_osfhandle"] - pub fn get_osfhandle(fd: c_int) -> c_long; + pub fn get_osfhandle(fd: c_int) -> intptr_t; #[link_name = "_open_osfhandle"] pub fn open_osfhandle(osfhandle: intptr_t, From 3bf33a4113c25653a7ce22302821dcaef28a681c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 22:01:52 -0700 Subject: [PATCH 037/194] Add appveyor config --- appveyor.yml | 18 ++++++++++++++++++ src/lib.rs | 3 --- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000000..fb6ccd13992de --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,18 @@ +environment: + matrix: + - TARGET: x86_64-pc-windows-msvc + - TARGET: i686-pc-windows-msvc + - TARGET: i686-pc-windows-gnu +install: + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" + - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - SET PATH=%PATH%;C:\MinGW\bin + - rustc -V + - cargo -V + +build: false + +test_script: + - cargo test + - cargo test --manifest-path libc-test/Cargo.toml diff --git a/src/lib.rs b/src/lib.rs index f17bc99f16877..86750ba20fd3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,6 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] -#![feature(linked_from)] //! Bindings for the C standard library and other platform libraries //! @@ -5398,8 +5397,6 @@ pub mod funcs { use types::os::arch::c95::{c_long, c_uint, c_ulong}; use types::os::arch::c95::{size_t}; - #[linked_from = "kernel32"] - #[link(name = "kernel32")] extern { pub fn abs(i: c_int) -> c_int; pub fn labs(i: c_long) -> c_long; From 4d0eb6d0851b7a8abaccd14910c0e4d40657d6e0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 22:20:55 -0700 Subject: [PATCH 038/194] Fix OSX --- src/lib.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 86750ba20fd3d..9c986d6a82154 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5621,14 +5621,14 @@ pub mod funcs { link_name = "fchmod$UNIX2003")] pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; - #[cfg_attr(target_os = "macos", link_name = "fstat64")] + #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; #[cfg(not(target_os = "nacl"))] pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; - #[cfg_attr(target_os = "macos", link_name = "stat64")] + #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; } } @@ -5945,19 +5945,7 @@ pub mod funcs { use types::os::arch::posix01::stat; extern { - #[cfg(any(target_os = "linux", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd", - target_os = "android", - target_os = "ios", - target_os = "nacl"))] - pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; - - #[cfg(target_os = "macos")] - #[link_name = "lstat64"] + #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; } } From dc376401f606f97600b15fb03f16d735609258d9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 22:59:15 -0700 Subject: [PATCH 039/194] Can we masquerade to get trusty tahr? --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c0cb38a9ce663..1526807cac772 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,11 @@ language: rust +sudo: required +services: + - docker rust: - 1.2.0 - beta - nightly -sudo: false install: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi - export TARGET=$ARCH-$OS From 31504843db59de21a84bdf6d188bd601a400f876 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Sep 2015 23:43:41 -0700 Subject: [PATCH 040/194] Windows 32-bit fixes --- libc-test/Cargo.lock | 4 +-- libc-test/Cargo.toml | 2 +- libc-test/build.rs | 83 +++++++++++++++++++++++++++++++++++++++----- src/lib.rs | 41 ++++++++++++++-------- src/macros.rs | 75 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 180 insertions(+), 25 deletions(-) create mode 100644 src/macros.rs diff --git a/libc-test/Cargo.lock b/libc-test/Cargo.lock index 23d47b0a50e2c..1726c5370150b 100644 --- a/libc-test/Cargo.lock +++ b/libc-test/Cargo.lock @@ -2,7 +2,7 @@ name = "libc-test" version = "0.1.0" dependencies = [ - "gcc 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.13 (git+https://github.com/alexcrichton/gcc-rs)", "libc 0.1.10", "syntex_syntax 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gcc" version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/alexcrichton/gcc-rs#e429c775dcbb03eb049bcb7f7215cf8d9ee3b837" dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index e918ec21c125a..bab5699f5be39 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -9,7 +9,7 @@ libc = { path = ".." } [build-dependencies] syntex_syntax = "0.13.0" -gcc = "0.3" +gcc = { git = "https://github.com/alexcrichton/gcc-rs" } [lib] name = "libc_test" diff --git a/libc-test/build.rs b/libc-test/build.rs index d9aadc11f5d66..9b4527ec16589 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -8,10 +8,13 @@ use std::io::BufWriter; use std::io::prelude::*; use std::path::{Path, PathBuf}; +use syntax::abi::Abi; use syntax::ast; -use syntax::diagnostic::SpanHandler; -use syntax::parse::token::InternedString; use syntax::attr::{self, ReprAttr}; +use syntax::diagnostic::SpanHandler; +use syntax::ext::base::SyntaxExtension; +use syntax::ext::expand; +use syntax::parse::token::{intern, InternedString}; use syntax::parse::{self, ParseSess}; use syntax::visit::{self, Visitor}; @@ -28,6 +31,7 @@ struct TestGenerator<'a> { c: Box, sh: &'a SpanHandler, structs: HashSet, + abi: Abi, } struct StructFinder { @@ -37,12 +41,21 @@ struct StructFinder { impl<'a> TestGenerator<'a> { fn defines(&self) -> Vec<&'static str> { let mut ret = Vec::new(); + + // Pull in extra goodies on linux if self.target.contains("unknown-linux") { ret.push("_GNU_SOURCE"); } + + // MSVC doesn't have stdalign.h so get alignof ourselves if self.target.contains("msvc") { ret.push("alignof __alignof"); } + + // Pull in extra goodies on mingw + if self.target.contains("windows") { + ret.push("_WIN32_WINNT 0x8000"); + } return ret } @@ -82,6 +95,11 @@ impl<'a> TestGenerator<'a> { base.push("windows.h"); base.push("process.h"); base.push("ws2ipdef.h"); + + if self.target.contains("gnu") { + base.push("stdalign.h"); + base.push("ws2tcpip.h"); + } } else { base.push("ctype.h"); base.push("dirent.h"); @@ -123,13 +141,19 @@ impl<'a> TestGenerator<'a> { s => s.to_string(), } } + // Perhaps this should be renamed in libc... "ip6_mreq" => "struct ipv6_mreq".to_string(), + + // Just pass all these through, no need for a "struct" prefix "glob_t" | "FILE" | "DIR" | "fpos_t" => ty.to_string(), t if t.starts_with("pthread") => t.to_string(), + // Windows uppercase structs don't have `struct` in front, there's a + // few special cases for windows, and then otherwise put `struct` in + // front of everything. t if self.structs.contains(t) => { if windows && ty.chars().next().unwrap().is_uppercase() { t.to_string() @@ -142,14 +166,18 @@ impl<'a> TestGenerator<'a> { } } + // Fixup a few types on windows that don't actually exist. "time64_t" if windows => "__time64_t".to_string(), "ssize_t" if windows => "SSIZE_T".to_string(), + t => t.to_string(), } } fn rust2cfield(&self, struct_: &str, field: &str) -> String { match field { + // Our stat *_nsec fields normally don't actually exist but are part + // of a timeval struct s if s.ends_with("_nsec") && struct_ == "stat" => { if self.target.contains("apple-darwin") { s.replace("_nsec", "spec.tv_nsec") @@ -207,12 +235,21 @@ fn main() { c: Box::new(c_out), sh: &sess.span_diagnostic, structs: HashSet::new(), + abi: Abi::C, }; // Parse the libc crate let src = Path::new("../src/lib.rs"); let cfg = Vec::new(); - let mut krate = parse::parse_crate_from_file(src, cfg, &sess); + let krate = parse::parse_crate_from_file(src, cfg, &sess); + + // expand macros + let ecfg = expand::ExpansionConfig::default("libc".to_string()); + let exts = vec![ + (intern("macro_rules"), SyntaxExtension::MacroRulesTT), + ]; + let mut krate = expand::expand_crate(&sess, ecfg, Vec::new(), + exts, &mut Vec::new(), krate); // Strip the crate down to just what's configured for our target for (k, v) in tg.cfg_list() { @@ -359,8 +396,22 @@ impl<'a> TestGenerator<'a> { } fn test_const(&mut self, name: &str, rust_ty: &str) { + let mingw = self.target.contains("windows-gnu"); + + // Apparently these don't exist in mingw headers? + match name { + "MEM_RESET_UNDO" | + "FILE_ATTRIBUTE_NO_SCRUB_DATA" | + "FILE_ATTRIBUTE_INTEGRITY_STREAM" | + "ERROR_NOTHING_TO_TERMINATE" if mingw => return, + _ => {} + } + let cty = self.rust_ty_to_c_ty(rust_ty); + + // SIG_IGN has weird types on platforms, just worry about it as a size_t let cast = if name == "SIG_IGN" {"(size_t)"} else {""}; + t!(writeln!(self.c, r#" int __test_const_{name}({cty} *outptr) {{ *outptr = {cast}({name}); @@ -387,7 +438,7 @@ impl<'a> TestGenerator<'a> { fn test_extern_fn(&mut self, name: &str, cname: &str, args: &[String], ret: &str, - variadic: bool) { + variadic: bool, abi: Abi) { match name { // manually verified "execv" | @@ -408,11 +459,20 @@ impl<'a> TestGenerator<'a> { .connect(", ") + if variadic {", ..."} else {""} }; let cret = self.rust_ty_to_c_ty(ret); + let abi = match abi { + Abi::C => "", + Abi::Stdcall => "__stdcall ", + Abi::System if self.target.contains("i686-pc-windows") => { + "__stdcall " + } + Abi::System => "", + a => panic!("unknown ABI: {}", a), + }; t!(writeln!(self.c, r#" - {ret} (*__test_fn_{name}(void))({args}) {{ + {ret} ({abi}*__test_fn_{name}(void))({args}) {{ return {cname}; }} - "#, name = name, cname = cname, args = args, ret = cret)); + "#, name = name, cname = cname, args = args, ret = cret, abi = abi)); t!(writeln!(self.rust, r#" #[test] #[cfg_attr(windows, ignore)] // FIXME -- dllimport weirdness? @@ -473,6 +533,7 @@ impl<'a> TestGenerator<'a> { impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { fn visit_item(&mut self, i: &'v ast::Item) { + let prev_abi = self.abi; match i.node { ast::ItemTy(_, ref generics) => { self.assert_no_generics(i.ident, generics); @@ -497,9 +558,14 @@ impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { self.test_const(&i.ident.to_string(), &ty); } + ast::ItemForeignMod(ref fm) => { + self.abi = fm.abi; + } + _ => {} } - visit::walk_item(self, i) + visit::walk_item(self, i); + self.abi = prev_abi; } fn visit_foreign_item(&mut self, i: &'v ast::ForeignItem) { @@ -514,8 +580,9 @@ impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { } _ => i.ident.to_string(), }; + let abi = self.abi; self.test_extern_fn(&i.ident.to_string(), &cname, &args, &ret, - variadic); + variadic, abi); } ast::ForeignItemStatic(_, _) => { } diff --git a/src/lib.rs b/src/lib.rs index 9c986d6a82154..fc2e6c2a2340e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,9 @@ #![allow(bad_style, raw_pointer_derive)] +#[macro_use] +mod macros; + // Explicit export lists for the intersection (provided here) mean that // you can write more-platform-agnostic code if you stick to just these // symbols. @@ -1829,10 +1832,13 @@ pub mod types { pub type clock_t = i32; - #[cfg(target_arch = "x86")] - pub type time_t = i32; - #[cfg(target_arch = "x86_64")] - pub type time_t = i64; + cfg_if! { + if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { + pub type time_t = i32; + } else { + pub type time_t = i64; + } + } pub type wchar_t = u16; } @@ -2508,8 +2514,6 @@ pub mod consts { pub const BUFSIZ : c_uint = 512; pub const FOPEN_MAX : c_uint = 20; pub const FILENAME_MAX : c_uint = 260; - pub const L_tmpnam : c_uint = 260; - pub const TMP_MAX : c_uint = 0x7fff_ffff; pub const WSAEINTR: c_int = 10004; pub const WSAEBADF: c_int = 10009; @@ -2563,6 +2567,16 @@ pub mod consts { pub const WSAEINVALIDPROCTABLE: c_int = 10104; pub const WSAEINVALIDPROVIDER: c_int = 10105; pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; + + cfg_if! { + if #[cfg(all(target_env = "gnu"))] { + pub const L_tmpnam : c_uint = 14; + pub const TMP_MAX : c_uint = 0x7fff; + } else { + pub const L_tmpnam : c_uint = 260; + pub const TMP_MAX : c_uint = 0x7fff_ffff; + } + } } pub mod c99 { } @@ -6141,9 +6155,8 @@ pub mod funcs { #[cfg(windows)] pub mod bsd43 { - use types::common::c95::{c_void}; use types::os::common::bsd44::{sockaddr, SOCKET}; - use types::os::arch::c95::c_int; + use types::os::arch::c95::{c_int, c_char}; extern "system" { pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; @@ -6159,17 +6172,17 @@ pub mod funcs { pub fn getsockname(socket: SOCKET, address: *mut sockaddr, address_len: *mut c_int) -> c_int; pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, - value: *const c_void, + value: *const c_char, option_len: c_int) -> c_int; pub fn closesocket(socket: SOCKET) -> c_int; - pub fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, + pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int, flags: c_int) -> c_int; - pub fn send(socket: SOCKET, buf: *const c_void, len: c_int, + pub fn send(socket: SOCKET, buf: *const c_char, len: c_int, flags: c_int) -> c_int; - pub fn recvfrom(socket: SOCKET, buf: *mut c_void, len: c_int, + pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int, flags: c_int, addr: *mut sockaddr, addrlen: *mut c_int) -> c_int; - pub fn sendto(socket: SOCKET, buf: *const c_void, len: c_int, + pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int, flags: c_int, addr: *const sockaddr, addrlen: c_int) -> c_int; pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; @@ -6414,7 +6427,7 @@ pub mod funcs { lpNumberOfBytesRead: LPDWORD, lpOverlapped: LPOVERLAPPED) -> BOOL; pub fn WriteFile(hFile: HANDLE, - lpBuffer: LPVOID, + lpBuffer: LPCVOID, nNumberOfBytesToWrite: DWORD, lpNumberOfBytesWritten: LPDWORD, lpOverlapped: LPOVERLAPPED) -> BOOL; diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000000000..3b096a53f1015 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,75 @@ +//! A macro for defining #[cfg] if-else statements. +//! +//! The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C +//! preprocessor macro by allowing definition of a cascade of `#[cfg]` cases, +//! emitting the implementation which matches first. +//! +//! This allows you to conveniently provide a long list #[cfg]'d blocks of code +//! without having to rewrite each clause multiple times. + +macro_rules! cfg_if { + ($( + if #[cfg($($meta:meta),*)] { $($it:item)* } + ) else * else { + $($it2:item)* + }) => { + __cfg_if_items! { + () ; + $( ( ($($meta),*) ($($it)*) ), )* + ( () ($($it2)*) ), + } + } +} + +#[doc(hidden)] +macro_rules! __cfg_if_items { + (($($not:meta,)*) ; ) => {}; + (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => { + __cfg_if_apply! { cfg(all($($m,)* not(any($($not),*)))), $($it)* } + __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* } + } +} + +#[doc(hidden)] +macro_rules! __cfg_if_apply { + ($m:meta, $($it:item)*) => { + $(#[$m] $it)* + } +} + +#[cfg(test)] +mod tests { + cfg_if! { + if #[cfg(test)] { + use std::option::Option as Option2; + fn works1() -> Option2 { Some(1) } + } else { + fn works1() -> Option { None } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works2() -> bool { false } + } else if #[cfg(test)] { + fn works2() -> bool { true } + } else { + fn works2() -> bool { false } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works3() -> bool { false } + } else { + fn works3() -> bool { true } + } + } + + #[test] + fn it_works() { + assert!(works1().is_some()); + assert!(works2()); + assert!(works3()); + } +} From 7ff0fdb49cbe6df6bf8885f7dc8741b9836dfb45 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 12:54:56 -0700 Subject: [PATCH 041/194] Tweak macros module --- src/macros.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 3b096a53f1015..1089a856ab2ee 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,8 +1,8 @@ //! A macro for defining #[cfg] if-else statements. //! -//! The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C -//! preprocessor macro by allowing definition of a cascade of `#[cfg]` cases, -//! emitting the implementation which matches first. +//! This is similar to the `if/elif` C preprocessor macro by allowing definition +//! of a cascade of `#[cfg]` cases, emitting the implementation which matches +//! first. //! //! This allows you to conveniently provide a long list #[cfg]'d blocks of code //! without having to rewrite each clause multiple times. @@ -21,7 +21,6 @@ macro_rules! cfg_if { } } -#[doc(hidden)] macro_rules! __cfg_if_items { (($($not:meta,)*) ; ) => {}; (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => { @@ -30,7 +29,6 @@ macro_rules! __cfg_if_items { } } -#[doc(hidden)] macro_rules! __cfg_if_apply { ($m:meta, $($it:item)*) => { $(#[$m] $it)* From 2d3608eb17c8935d0474bfc29a9d2460be0d3b4e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 12:55:05 -0700 Subject: [PATCH 042/194] Correct ip6_mreq => ipv6_mreq --- libc-test/build.rs | 2 -- src/lib.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 9b4527ec16589..a4c493f7e8263 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -141,8 +141,6 @@ impl<'a> TestGenerator<'a> { s => s.to_string(), } } - // Perhaps this should be renamed in libc... - "ip6_mreq" => "struct ipv6_mreq".to_string(), // Just pass all these through, no need for a "struct" prefix "glob_t" | diff --git a/src/lib.rs b/src/lib.rs index fc2e6c2a2340e..c6b5bd1496e41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -347,7 +347,7 @@ pub mod types { pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy, Clone)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } @@ -912,7 +912,7 @@ pub mod types { pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy, Clone)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } @@ -1274,7 +1274,7 @@ pub mod types { pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy, Clone)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } @@ -1561,7 +1561,7 @@ pub mod types { pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy, Clone)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } @@ -1788,7 +1788,7 @@ pub mod types { pub imr_interface: in_addr, } #[repr(C)] - #[derive(Copy, Clone)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } @@ -2233,7 +2233,7 @@ pub mod types { } #[repr(C)] - #[derive(Copy, Clone)] pub struct ip6_mreq { + #[derive(Copy, Clone)] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: c_uint, } From 5d6cf05d8ba70c93c60600d4bd9b9003e7780e51 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 14:52:34 -0700 Subject: [PATCH 043/194] Let's just juggle everything around! [ci skip] --- libc-test/tests/all.rs | 7 - src/apple.rs | 918 +++++ src/bsdlike.rs | 13 + src/freebsdlike.rs | 823 +++++ src/lib.rs | 6658 +--------------------------------- src/linkage.rs | 38 + src/linuxlike/android.rs | 31 + src/linuxlike/b32/android.rs | 29 + src/linuxlike/b32/mips.rs | 30 + src/linuxlike/b32/mod.rs | 78 + src/linuxlike/b64/aarch64.rs | 32 + src/linuxlike/b64/mod.rs | 41 + src/linuxlike/b64/x86_64.rs | 31 + src/linuxlike/linux.rs | 66 + src/linuxlike/mips.rs | 314 ++ src/linuxlike/mod.rs | 293 ++ src/linuxlike/notmips.rs | 319 ++ src/macos.rs | 0 src/macros.rs | 34 +- src/openbsdlike.rs | 713 ++++ src/unix.rs | 309 ++ src/windows.rs | 1153 ++++++ 22 files changed, 5428 insertions(+), 6502 deletions(-) create mode 100644 src/apple.rs create mode 100644 src/bsdlike.rs create mode 100644 src/freebsdlike.rs create mode 100644 src/linkage.rs create mode 100644 src/linuxlike/android.rs create mode 100644 src/linuxlike/b32/android.rs create mode 100644 src/linuxlike/b32/mips.rs create mode 100644 src/linuxlike/b32/mod.rs create mode 100644 src/linuxlike/b64/aarch64.rs create mode 100644 src/linuxlike/b64/mod.rs create mode 100644 src/linuxlike/b64/x86_64.rs create mode 100644 src/linuxlike/linux.rs create mode 100644 src/linuxlike/mips.rs create mode 100644 src/linuxlike/mod.rs create mode 100644 src/linuxlike/notmips.rs create mode 100644 src/macos.rs create mode 100644 src/openbsdlike.rs create mode 100644 src/unix.rs create mode 100644 src/windows.rs diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 7fb6efb7e2658..d397883b18057 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -7,13 +7,6 @@ use std::any::{Any, TypeId}; use std::mem; use libc::*; -#[cfg(unix)] use libc::types::os::common::bsd43::*; -#[cfg(unix)] use libc::funcs::bsd44::*; -#[cfg(unix)] use libc::funcs::posix01::mman::*; -#[cfg(unix)] use libc::funcs::posix01::glob::*; -#[cfg(unix)] use libc::funcs::posix01::signal::*; -#[cfg(unix)] use libc::funcs::posix88::signal::*; -#[cfg(target_os = "macos")] use libc::funcs::extra::*; trait Pretty { fn pretty(&self) -> String; diff --git a/src/apple.rs b/src/apple.rs new file mode 100644 index 0000000000000..bc5b1d36b6e4d --- /dev/null +++ b/src/apple.rs @@ -0,0 +1,918 @@ + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, size_t, time_t}; + use types::os::arch::c95::{suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = u64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + __unused1: c_int, + pub gl_offs: size_t, + __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + __unused3: *mut c_void, + + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8], + __align: [u32; 0], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + } + } + + #[cfg(any(target_arch = "arm", target_arch = "x86"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u32; + pub type ptrdiff_t = i32; + pub type clock_t = c_ulong; + pub type time_t = c_long; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i32; + pub type uintptr_t = u32; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::c_long; + + pub type off_t = i64; + pub type dev_t = i32; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c99::{int32_t, int64_t, uint32_t}; + use types::os::arch::c95::{c_char, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t, + mode_t, off_t, uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: uint32_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare: [int64_t; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy)] pub struct pthread_attr_t { + __sig: c_long, + __opaque: [c_char; 36] + } + impl Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + #[repr(C)] + #[derive(Copy, Clone)] pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub type mach_timebase_info_data_t = mach_timebase_info; + } + } + + #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = c_ulong; + pub type time_t = c_long; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::c_long; + + pub type off_t = i64; + pub type dev_t = i32; + pub type ino_t = u64; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c99::{int32_t, int64_t}; + use types::common::c99::{uint32_t}; + use types::os::arch::c95::{c_char, c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t, uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = i32; + pub type blkcnt_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: uint32_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_qspare: [int64_t; 2], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[repr(C)] + #[derive(Copy)] pub struct pthread_attr_t { + __sig: c_long, + __opaque: [c_char; 56] + } + impl Clone for pthread_attr_t { + fn clone(&self) -> pthread_attr_t { *self } + } + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + #[repr(C)] + #[derive(Copy, Clone)] pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub type mach_timebase_info_data_t = mach_timebase_info; + } + } + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + pub const _PC_NAME_MAX: c_int = 4; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 131072; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + pub const MS_SYNC : c_int = 0x0010; + + pub const MS_KILLPAGES : c_int = 0x0004; + pub const MS_DEACTIVATE : c_int = 0x0008; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = EAGAIN; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const ENOTSUP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EPWROFF : c_int = 82; + pub const EDEVERR : c_int = 83; + pub const EOVERFLOW : c_int = 84; + pub const EBADEXEC : c_int = 85; + pub const EBADARCH : c_int = 86; + pub const ESHLIBVERS : c_int = 87; + pub const EBADMACHO : c_int = 88; + pub const ECANCELED : c_int = 89; + pub const EIDRM : c_int = 90; + pub const ENOMSG : c_int = 91; + pub const EILSEQ : c_int = 92; + pub const ENOATTR : c_int = 93; + pub const EBADMSG : c_int = 94; + pub const EMULTIHOP : c_int = 95; + pub const ENODATA : c_int = 96; + pub const ENOLINK : c_int = 97; + pub const ENOSR : c_int = 98; + pub const ENOSTR : c_int = 99; + pub const EPROTO : c_int = 100; + pub const ETIME : c_int = 101; + pub const EOPNOTSUPP : c_int = 102; + pub const ENOPOLICY : c_int = 103; + pub const ENOTRECOVERABLE : c_int = 104; + pub const EOWNERDEAD : c_int = 105; + pub const EQFULL : c_int = 106; + pub const ELAST : c_int = 106; + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const O_ACCMODE : c_int = 3; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x2000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 56; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; + pub const _SC_LOGIN_NAME_MAX : c_int = 73; + pub const _SC_MQ_PRIO_MAX : c_int = 75; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; + pub const _SC_THREAD_KEYS_MAX : c_int = 86; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; + pub const _SC_THREAD_STACK_MIN : c_int = 93; + pub const _SC_THREAD_THREADS_MAX : c_int = 94; + pub const _SC_THREADS : c_int = 96; + pub const _SC_TTY_NAME_MAX : c_int = 101; + pub const _SC_ATEXIT_MAX : c_int = 107; + pub const _SC_XOPEN_CRYPT : c_int = 108; + pub const _SC_XOPEN_ENH_I18N : c_int = 109; + pub const _SC_XOPEN_LEGACY : c_int = 110; + pub const _SC_XOPEN_REALTIME : c_int = 111; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; + pub const _SC_XOPEN_SHM : c_int = 113; + pub const _SC_XOPEN_UNIX : c_int = 115; + pub const _SC_XOPEN_VERSION : c_int = 116; + pub const _SC_XOPEN_XCU_VERSION : c_int = 121; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 1; + pub const PTHREAD_CREATE_DETACHED: c_int = 2; + pub const PTHREAD_STACK_MIN: size_t = 8192; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_AS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIM_NLIMITS: c_int = 9; + pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; + + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 5; + pub const MADV_ZERO_WIRED_PAGES : c_int = 6; + pub const MADV_FREE_REUSABLE : c_int = 7; + pub const MADV_FREE_REUSE : c_int = 8; + pub const MADV_CAN_REUSE : c_int = 9; + + pub const MINCORE_INCORE : c_int = 0x1; + pub const MINCORE_REFERENCED : c_int = 0x2; + pub const MINCORE_MODIFIED : c_int = 0x4; + pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; + pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 30; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_JOIN_GROUP: c_int = 12; + pub const IPV6_LEAVE_GROUP: c_int = 13; + + pub const TCP_NODELAY: c_int = 0x01; + pub const TCP_KEEPALIVE: c_int = 0x10; + pub const SOL_SOCKET: c_int = 0xffff; + + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_DSYNC : c_int = 4194304; + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const F_GETPATH : c_int = 50; + pub const F_FULLFSYNC : c_int = 51; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0020; + pub const MAP_NORESERVE : c_int = 0x0040; + pub const MAP_NOEXTEND : c_int = 0x0100; + pub const MAP_HASSEMAPHORE : c_int = 0x0200; + pub const MAP_NOCACHE : c_int = 0x0400; + pub const MAP_JIT : c_int = 0x0800; + + pub const IPPROTO_RAW : c_int = 255; + + pub const SO_NREAD: c_int = 0x1020; + pub const SO_NKE: c_int = 0x1021; + pub const SO_NOSIGPIPE: c_int = 0x1022; + pub const SO_NOADDRERR: c_int = 0x1023; + pub const SO_NWRITE: c_int = 0x1024; + pub const SO_DONTTRUNC: c_int = 0x2000; + pub const SO_WANTMORE: c_int = 0x4000; + pub const SO_WANTOOBFLAG: c_int = 0x8000; + + pub const PATH_MAX: c_int = 1024; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_ASYNCHRONOUS_IO : c_int = 28; + pub const _SC_PAGESIZE : c_int = 29; + pub const _SC_MEMLOCK : c_int = 30; + pub const _SC_MEMLOCK_RANGE : c_int = 31; + pub const _SC_MEMORY_PROTECTION : c_int = 32; + pub const _SC_MESSAGE_PASSING : c_int = 33; + pub const _SC_PRIORITIZED_IO : c_int = 34; + pub const _SC_PRIORITY_SCHEDULING : c_int = 35; + pub const _SC_REALTIME_SIGNALS : c_int = 36; + pub const _SC_SEMAPHORES : c_int = 37; + pub const _SC_FSYNC : c_int = 38; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; + pub const _SC_SYNCHRONIZED_IO : c_int = 40; + pub const _SC_TIMERS : c_int = 41; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_DELAYTIMER_MAX : c_int = 45; + pub const _SC_MQ_OPEN_MAX : c_int = 46; + pub const _SC_MAPPED_FILES : c_int = 47; + pub const _SC_RTSIG_MAX : c_int = 48; + pub const _SC_SEM_NSEMS_MAX : c_int = 49; + pub const _SC_SEM_VALUE_MAX : c_int = 50; + pub const _SC_SIGQUEUE_MAX : c_int = 51; + pub const _SC_TIMER_MAX : c_int = 52; + pub const _SC_NPROCESSORS_CONF : c_int = 57; + pub const _SC_NPROCESSORS_ONLN : c_int = 58; + pub const _SC_2_PBS : c_int = 59; + pub const _SC_2_PBS_ACCOUNTING : c_int = 60; + pub const _SC_2_PBS_CHECKPOINT : c_int = 61; + pub const _SC_2_PBS_LOCATE : c_int = 62; + pub const _SC_2_PBS_MESSAGE : c_int = 63; + pub const _SC_2_PBS_TRACK : c_int = 64; + pub const _SC_ADVISORY_INFO : c_int = 65; + pub const _SC_BARRIERS : c_int = 66; + pub const _SC_CLOCK_SELECTION : c_int = 67; + pub const _SC_CPUTIME : c_int = 68; + pub const _SC_FILE_LOCKING : c_int = 69; + pub const _SC_HOST_NAME_MAX : c_int = 72; + pub const _SC_MONOTONIC_CLOCK : c_int = 74; + pub const _SC_READER_WRITER_LOCKS : c_int = 76; + pub const _SC_REGEXP : c_int = 77; + pub const _SC_SHELL : c_int = 78; + pub const _SC_SPAWN : c_int = 79; + pub const _SC_SPIN_LOCKS : c_int = 80; + pub const _SC_SPORADIC_SERVER : c_int = 81; + pub const _SC_THREAD_CPUTIME : c_int = 84; + pub const _SC_THREAD_SPORADIC_SERVER : c_int = 92; + pub const _SC_TIMEOUTS : c_int = 95; + pub const _SC_TRACE : c_int = 97; + pub const _SC_TRACE_EVENT_FILTER : c_int = 98; + pub const _SC_TRACE_INHERIT : c_int = 99; + pub const _SC_TRACE_LOG : c_int = 100; + pub const _SC_TYPED_MEMORY_OBJECTS : c_int = 102; + pub const _SC_V6_ILP32_OFF32 : c_int = 103; + pub const _SC_V6_ILP32_OFFBIG : c_int = 104; + pub const _SC_V6_LP64_OFF64 : c_int = 105; + pub const _SC_V6_LPBIG_OFFBIG : c_int = 106; + pub const _SC_IPV6 : c_int = 118; + pub const _SC_RAW_SOCKETS : c_int = 119; + pub const _SC_SYMLOOP_MAX : c_int = 120; + pub const _SC_PAGE_SIZE : c_int = _SC_PAGESIZE; + pub const _SC_XOPEN_STREAMS : c_int = 114; + pub const _SC_XBS5_ILP32_OFF32 : c_int = 122; + pub const _SC_XBS5_ILP32_OFFBIG : c_int = 123; + pub const _SC_XBS5_LP64_OFF64 : c_int = 124; + pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 125; + pub const _SC_SS_REPL_MAX : c_int = 126; + pub const _SC_TRACE_EVENT_NAME_MAX : c_int = 127; + pub const _SC_TRACE_NAME_MAX : c_int = 128; + pub const _SC_TRACE_SYS_MAX : c_int = 129; + pub const _SC_TRACE_USER_EVENT_MAX : c_int = 130; + pub const _SC_PASS_MAX : c_int = 131; + } + } + + #[cfg(any(target_os = "macos", target_os = "ios"))] + pub mod extra { + use {c_char, c_int, uint32_t}; + + extern { + pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut uint32_t) + -> c_int; + } + } diff --git a/src/bsdlike.rs b/src/bsdlike.rs new file mode 100644 index 0000000000000..2d6c8ab6da3ce --- /dev/null +++ b/src/bsdlike.rs @@ -0,0 +1,13 @@ + +extern { + pub fn sysctlbyname(name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn sysctlnametomib(name: *const ::c_char, + mibp: *mut ::c_int, + sizep: *mut ::size_t) + -> ::c_int; +} diff --git a/src/freebsdlike.rs b/src/freebsdlike.rs new file mode 100644 index 0000000000000..a5c228cdfd0a5 --- /dev/null +++ b/src/freebsdlike.rs @@ -0,0 +1,823 @@ + + #[cfg(target_os = "freebsd")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: size_t, + __unused1: size_t, + pub gl_offs: size_t, + __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + __unused3: *mut c_void, + + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8], + __align: [u32; 0], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + + + } + } + + #[cfg(target_arch = "x86")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u32; + pub type ptrdiff_t = i32; + pub type clock_t = i32; + pub type time_t = i32; + pub type suseconds_t = i32; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i32; + pub type uintptr_t = u32; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u32; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i32; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint32_t, int32_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = u32; + pub type blkcnt_t = i64; + pub type fflags_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + __unused: [u8; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i32; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + pub type off_t = i64; + pub type dev_t = u32; + pub type ino_t = u32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u16; + pub type ssize_t = i64; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint32_t, int32_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t, ino_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = u16; + pub type blksize_t = u32; + pub type blkcnt_t = i64; + pub type fflags_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_lspare: int32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 32768; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_SYNC : c_int = 0x0000; + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_INVALIDATE : c_int = 0x0002; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = 35; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const EOPNOTSUPP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EIDRM : c_int = 82; + pub const ENOMSG : c_int = 83; + pub const EOVERFLOW : c_int = 84; + pub const ECANCELED : c_int = 85; + pub const EILSEQ : c_int = 86; + pub const ENOATTR : c_int = 87; + pub const EDOOFUS : c_int = 88; + pub const EBADMSG : c_int = 89; + pub const EMULTIHOP : c_int = 90; + pub const ENOLINK : c_int = 91; + pub const EPROTO : c_int = 92; + pub const ENOMEDIUM : c_int = 93; + pub const EUNUSED94 : c_int = 94; + pub const EUNUSED95 : c_int = 95; + pub const EUNUSED96 : c_int = 96; + pub const EUNUSED97 : c_int = 97; + pub const EUNUSED98 : c_int = 98; + pub const EASYNC : c_int = 99; + pub const ELAST : c_int = 99; + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x2000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 56; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; + pub const _SC_LOGIN_NAME_MAX : c_int = 73; + pub const _SC_MQ_PRIO_MAX : c_int = 75; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; + pub const _SC_THREAD_KEYS_MAX : c_int = 86; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; + pub const _SC_THREAD_STACK_MIN : c_int = 93; + pub const _SC_THREAD_THREADS_MAX : c_int = 94; + pub const _SC_THREADS : c_int = 96; + pub const _SC_TTY_NAME_MAX : c_int = 101; + pub const _SC_ATEXIT_MAX : c_int = 107; + pub const _SC_XOPEN_CRYPT : c_int = 108; + pub const _SC_XOPEN_ENH_I18N : c_int = 109; + pub const _SC_XOPEN_LEGACY : c_int = 110; + pub const _SC_XOPEN_REALTIME : c_int = 111; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; + pub const _SC_XOPEN_SHM : c_int = 113; + pub const _SC_XOPEN_UNIX : c_int = 115; + pub const _SC_XOPEN_VERSION : c_int = 116; + pub const _SC_XOPEN_XCU_VERSION : c_int = 117; + + pub const PTHREAD_CREATE_JOINABLE: c_int = 0; + pub const PTHREAD_CREATE_DETACHED: c_int = 1; + + #[cfg(target_arch = "arm")] + pub const PTHREAD_STACK_MIN: size_t = 4096; + + #[cfg(all(target_os = "freebsd", + any(target_arch = "mips", + target_arch = "mipsel", + target_arch = "x86", + target_arch = "x86_64")))] + pub const PTHREAD_STACK_MIN: size_t = 2048; + + #[cfg(target_os = "dragonfly")] + pub const PTHREAD_STACK_MIN: size_t = 1024; + + pub const CLOCK_REALTIME: c_int = 0; + pub const CLOCK_MONOTONIC: c_int = 4; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIMIT_SBSIZE: c_int = 9; + pub const RLIMIT_VMEM: c_int = 10; + pub const RLIMIT_AS: c_int = RLIMIT_VMEM; + pub const RLIMIT_NPTS: c_int = 11; + pub const RLIMIT_SWAP: c_int = 12; + pub const RLIMIT_KQUEUES: c_int = 13; + + pub const RLIM_NLIMITS: rlim_t = 14; + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 5; + pub const MADV_NOSYNC : c_int = 6; + pub const MADV_AUTOSYNC : c_int = 7; + pub const MADV_NOCORE : c_int = 8; + pub const MADV_CORE : c_int = 9; + pub const MADV_PROTECT : c_int = 10; + + pub const MINCORE_INCORE : c_int = 0x1; + pub const MINCORE_REFERENCED : c_int = 0x2; + pub const MINCORE_MODIFIED : c_int = 0x4; + pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; + pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; + pub const MINCORE_SUPER : c_int = 0x20; + + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 28; + pub const AF_UNIX: c_int = 1; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + + pub const TCP_NODELAY: c_int = 1; + pub const TCP_KEEPIDLE: c_int = 256; + pub const SOL_SOCKET: c_int = 0xffff; + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const CTL_KERN: c_int = 1; + pub const KERN_PROC: c_int = 14; + #[cfg(target_os = "freebsd")] + pub const KERN_PROC_PATHNAME: c_int = 12; + #[cfg(target_os = "dragonfly")] + pub const KERN_PROC_PATHNAME: c_int = 9; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0020; + pub const MAP_NORESERVE : c_int = 0x0040; + pub const MAP_HASSEMAPHORE : c_int = 0x0200; + pub const MAP_STACK : c_int = 0x0400; + pub const MAP_NOSYNC : c_int = 0x0800; + pub const MAP_NOCORE : c_int = 0x020000; + + pub const IPPROTO_RAW : c_int = 255; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_ASYNCHRONOUS_IO : c_int = 28; + pub const _SC_MAPPED_FILES : c_int = 29; + pub const _SC_MEMLOCK : c_int = 30; + pub const _SC_MEMLOCK_RANGE : c_int = 31; + pub const _SC_MEMORY_PROTECTION : c_int = 32; + pub const _SC_MESSAGE_PASSING : c_int = 33; + pub const _SC_PRIORITIZED_IO : c_int = 34; + pub const _SC_PRIORITY_SCHEDULING : c_int = 35; + pub const _SC_REALTIME_SIGNALS : c_int = 36; + pub const _SC_SEMAPHORES : c_int = 37; + pub const _SC_FSYNC : c_int = 38; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; + pub const _SC_SYNCHRONIZED_IO : c_int = 40; + pub const _SC_TIMERS : c_int = 41; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_DELAYTIMER_MAX : c_int = 45; + pub const _SC_MQ_OPEN_MAX : c_int = 46; + pub const _SC_PAGESIZE : c_int = 47; + pub const _SC_RTSIG_MAX : c_int = 48; + pub const _SC_SEM_NSEMS_MAX : c_int = 49; + pub const _SC_SEM_VALUE_MAX : c_int = 50; + pub const _SC_SIGQUEUE_MAX : c_int = 51; + pub const _SC_TIMER_MAX : c_int = 52; + } + } diff --git a/src/lib.rs b/src/lib.rs index c6b5bd1496e41..1d6b50d78a602 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6499 +8,185 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] - -//! Bindings for the C standard library and other platform libraries -//! -//! **NOTE:** These are *architecture and libc* specific. On Linux, these -//! bindings are only correct for glibc. -//! -//! This module contains bindings to the C standard library, organized into -//! modules by their defining standard. Additionally, it contains some assorted -//! platform-specific definitions. For convenience, most functions and types -//! are reexported, so `use libc::*` will import the available C bindings as -//! appropriate for the target platform. The exact set of functions available -//! are platform specific. -//! -//! *Note:* Because these definitions are platform-specific, some may not appear -//! in the generated documentation. -//! -//! We consider the following specs reasonably normative with respect to -//! interoperating with the C standard library (libc/msvcrt): -//! -//! * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995. -//! * ISO 9899:1999 ('C99' or 'C9x'). -//! * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1'). -//! * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3'). -//! * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4'). -//! -//! Note that any reference to the 1996 revision of POSIX, or any revs between -//! 1990 (when '88 was approved at ISO) and 2001 (when the next actual -//! revision-revision happened), are merely additions of other chapters (1b and -//! 1c) outside the core interfaces. -//! -//! Despite having several names each, these are *reasonably* coherent -//! point-in-time, list-of-definition sorts of specs. You can get each under a -//! variety of names but will wind up with the same definition in each case. -//! -//! See standards(7) in linux-manpages for more details. -//! -//! Our interface to these libraries is complicated by the non-universality of -//! conformance to any of them. About the only thing universally supported is -//! the first (C95), beyond that definitions quickly become absent on various -//! platforms. -//! -//! We therefore wind up dividing our module-space up (mostly for the sake of -//! sanity while editing, filling-in-details and eliminating duplication) into -//! definitions common-to-all (held in modules named c95, c99, posix88, posix01 -//! and posix08) and definitions that appear only on *some* platforms (named -//! 'extra'). This would be things like significant OSX foundation kit, or Windows -//! library kernel32.dll, or various fancy glibc, Linux or BSD extensions. -//! -//! In addition to the per-platform 'extra' modules, we define a module of -//! 'common BSD' libc routines that never quite made it into POSIX but show up -//! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final -//! one from Berkeley after the lawsuits died down and the CSRG dissolved. - #![allow(bad_style, raw_pointer_derive)] -#[macro_use] -mod macros; - -// Explicit export lists for the intersection (provided here) mean that -// you can write more-platform-agnostic code if you stick to just these -// symbols. - -pub use types::common::c95::*; -pub use types::common::c99::*; -pub use types::common::posix88::*; -pub use types::os::common::posix01::*; -pub use types::os::common::bsd44::*; -pub use types::os::arch::c95::*; -pub use types::os::arch::c99::*; -pub use types::os::arch::posix88::*; -pub use types::os::arch::posix01::*; -pub use types::os::arch::extra::*; - -pub use consts::os::c95::*; -pub use consts::os::posix88::*; -pub use consts::os::posix01::*; -pub use consts::os::bsd44::*; -pub use consts::os::extra::*; - -pub use funcs::c95::ctype::*; -pub use funcs::c95::stdio::*; -pub use funcs::c95::stdlib::*; -pub use funcs::c95::string::*; -pub use funcs::posix88::fcntl::*; -pub use funcs::posix88::stat_::*; -pub use funcs::posix88::stdio::*; -pub use funcs::posix88::unistd::*; - -pub use funcs::bsd43::*; - -// But we also reexport most everything -// if you're interested in writing platform-specific code. - -// FIXME: This is a mess, but the design of this entire module needs to be -// reconsidered, so I'm not inclined to do better right now. As part of -// #11870 I removed all the pub globs here, leaving explicit reexports -// of everything that is actually used in-tree. -// -// So the following exports don't follow any particular plan. - -#[cfg(unix)] pub use consts::os::sysconf::*; - -#[cfg(unix)] pub use funcs::posix88::mman::*; -#[cfg(unix)] pub use funcs::posix88::dirent::*; -#[cfg(unix)] pub use funcs::posix88::net::*; -#[cfg(unix)] pub use funcs::posix01::stat_::*; -#[cfg(unix)] pub use funcs::posix01::unistd::*; -#[cfg(unix)] pub use funcs::posix01::resource::*; - - -#[cfg(windows)] pub use funcs::extra::kernel32::*; -#[cfg(windows)] pub use funcs::extra::winsock::*; -#[cfg(windows)] pub use funcs::extra::msvcrt::*; - -// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them -// in when creating a test crate. -#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))] -#[link(name = "c")] -#[link(name = "m")] -extern {} - -// When compiling rust with musl, statically include libc.a in liblibc.rlib. -// A cargo build of the libc crate will therefore automatically pick up the -// libc.a symbols because liblibc is transitively linked to by the stdlib. -#[cfg(all(target_env = "musl", not(feature = "cargo-build"), not(test)))] -#[link(name = "c", kind = "static")] -extern {} - -#[cfg(all(windows, target_env = "msvc"))] -#[link(name = "kernel32")] -#[link(name = "shell32")] -#[link(name = "msvcrt")] -extern {} - -// libnacl provides functions that require a trip through the IRT to work. -// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip -// to the kernel. -#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] -#[link(name = "nacl", kind = "static")] -extern {} - -// pnaclmm provides a number of functions that the toolchain's Clang emits calls -// to when codegening atomic ops. All the functions within wrap various atomic -// operations. -// Yes, it could be linked by rustc explicitly, however by linking it here -// instead we save a bit of time where bins are involved (by not running the -// optimizations on the whole pnaclmm foreach binary built). -#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] -#[link(name = "pnaclmm", kind = "static")] -extern {} - -pub mod types { - - // Types tend to vary *per architecture* so we pull their definitions out - // into this module. - - // Standard types that are opaque or common, so are not per-target. - pub mod common { - pub mod c95 { - /// Type used to construct void pointers for use with C. - /// - /// This type is only useful as a pointer target. Do not use it as a - /// return type for FFI functions which have the `void` return type in - /// C. Use the unit type `()` or omit the return type instead. - /// - /// For LLVM to recognize the void pointer type and by extension - /// functions like malloc(), we need to have it represented as i8* in - /// LLVM bitcode. The enum used here ensures this and prevents misuse - /// of the "raw" type by only having private variants.. We need two - /// variants, because the compiler complains about the repr attribute - /// otherwise. - #[repr(u8)] - pub enum c_void { - __variant1, - __variant2, - } - - pub enum FILE {} - pub enum fpos_t {} - } - pub mod c99 { - pub type int8_t = i8; - pub type int16_t = i16; - pub type int32_t = i32; - pub type int64_t = i64; - pub type uint8_t = u8; - pub type uint16_t = u16; - pub type uint32_t = u32; - pub type uint64_t = u64; - } - pub mod posix88 { - pub enum DIR {} - pub enum dirent {} - } - pub mod posix01 {} - pub mod posix08 {} - pub mod bsd44 {} - } - - // Standard types that are scalar but vary by OS and arch. - - #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_ulong, size_t, c_int, - time_t, suseconds_t, c_long}; - - #[cfg(not(target_os = "nacl"))] - pub type pthread_t = c_ulong; - #[cfg(target_os = "nacl")] - pub type pthread_t = *mut c_void; - pub type rlim_t = c_ulong; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: size_t, - pub gl_pathv: *mut *mut c_char, - pub gl_offs: size_t, - pub gl_flags: c_int, - - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - // This is also specified in POSIX 2001, but only has two fields. All implementors - // implement BSD 4.3 version. - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u16; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_family: sa_family_t, - __ss_align: isize, - #[cfg(target_pointer_width = "32")] - __ss_pad2: [u8; 128 - 2 * 4], - #[cfg(target_pointer_width = "64")] - __ss_pad2: [u8; 128 - 2 * 8], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - - #[cfg(target_os = "linux")] - pub ai_addr: *mut sockaddr, - - #[cfg(target_os = "linux")] - pub ai_canonname: *mut c_char, - - #[cfg(any(target_os = "android", target_os = "nacl"))] - pub ai_canonname: *mut c_char, - - #[cfg(any(target_os = "android", target_os = "nacl"))] - pub ai_addr: *mut sockaddr, - - pub ai_next: *mut addrinfo, - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_ifu: *mut sockaddr, // FIXME This should be a union - pub ifa_data: *mut c_void - } - - } - } - - #[cfg(any(target_arch = "x86", - target_arch = "arm", - target_arch = "mips", - target_arch = "mipsel", - target_arch = "powerpc", - target_arch = "le32"))] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i32; - pub type c_ulong = u32; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u32; - pub type ptrdiff_t = i32; - pub type clock_t = i32; - pub type time_t = i32; - pub type suseconds_t = i32; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i32; - pub type uintptr_t = u32; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - #[cfg(any(target_arch = "mips", - target_arch = "mipsel", - target_arch = "powerpc", - target_arch = "le32", - all(any(target_arch = "arm", target_arch = "x86"), - not(target_os = "android"))))] - pub mod posix88 { - pub type off_t = i32; - pub type dev_t = u64; - pub type ino_t = u32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u32; - pub type ssize_t = i32; - } - #[cfg(all(any(target_arch = "arm", target_arch = "x86"), - target_os = "android"))] - pub mod posix88 { - pub type off_t = i32; - pub type dev_t = u32; - pub type ino_t = u32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = i32; - } - #[cfg(any(target_arch = "x86", - target_arch = "le32", - target_arch = "powerpc", - all(any(target_arch = "arm", target_arch = "x86"), - not(target_os = "android"))))] - pub mod posix01 { - use types::os::arch::c95::{c_short, c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u32; - pub type blksize_t = i32; - pub type blkcnt_t = i32; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - __pad1: c_short, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - __pad2: c_short, - pub st_size: off_t, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - __unused4: c_long, - __unused5: c_long, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct pthread_attr_t { - __size: [u32; 9] - } - } - #[cfg(all(any(target_arch = "arm", target_arch = "x86"), - target_os = "android"))] - pub mod posix01 { - use types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t}; - use types::os::arch::c99::{c_longlong, c_ulonglong}; - use types::os::arch::posix88::{uid_t, gid_t, ino_t}; - - pub type nlink_t = u16; - pub type blksize_t = u32; - pub type blkcnt_t = u32; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: c_ulonglong, - __pad0: [c_uchar; 4], - __st_ino: ino_t, - pub st_mode: c_uint, - pub st_nlink: c_uint, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: c_ulonglong, - __pad3: [c_uchar; 4], - pub st_size: c_longlong, - pub st_blksize: blksize_t, - pub st_blocks: c_ulonglong, - pub st_atime: time_t, - pub st_atime_nsec: c_ulong, - pub st_mtime: time_t, - pub st_mtime_nsec: c_ulong, - pub st_ctime: time_t, - pub st_ctime_nsec: c_ulong, - pub st_ino: c_ulonglong, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct pthread_attr_t { - __size: [u32; 9] - } - } - #[cfg(any(target_arch = "mips", - target_arch = "mipsel"))] - pub mod posix01 { - use types::os::arch::c95::{c_long, c_ulong, time_t}; - use types::os::arch::posix88::{gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u32; - pub type blksize_t = i32; - pub type blkcnt_t = i32; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: c_ulong, - pub st_pad1: [c_long; 3], - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: c_ulong, - pub st_pad2: [c_long; 2], - pub st_size: off_t, - pub st_pad3: c_long, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_pad5: [c_long; 14], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct pthread_attr_t { - __size: [u32; 9] - } - } - pub mod posix08 {} - pub mod bsd44 {} - pub mod extra { - use types::os::arch::c95::{c_ushort, c_int, c_uchar}; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_ll { - pub sll_family: c_ushort, - pub sll_protocol: c_ushort, - pub sll_ifindex: c_int, - pub sll_hatype: c_ushort, - pub sll_pkttype: c_uchar, - pub sll_halen: c_uchar, - pub sll_addr: [c_uchar; 8] - } - } - - } - - #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64"))] - pub mod arch { - pub mod c95 { - #[cfg(not(target_arch = "aarch64"))] - pub type c_char = i8; - #[cfg(target_arch = "aarch64")] - pub type c_char = u8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = i64; - pub type time_t = i64; - pub type suseconds_t = i64; - #[cfg(not(target_arch = "aarch64"))] - pub type wchar_t = i32; - #[cfg(target_arch = "aarch64")] - pub type wchar_t = u32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - pub type off_t = i64; - pub type dev_t = u64; - pub type ino_t = u64; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u32; - pub type ssize_t = i64; - } - #[cfg(not(target_arch = "aarch64"))] - pub mod posix01 { - use types::os::arch::c95::{c_int, c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u64; - pub type blksize_t = i64; - pub type blkcnt_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_nlink: nlink_t, - pub st_mode: mode_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - __pad0: c_int, - pub st_rdev: dev_t, - pub st_size: off_t, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - __unused: [c_long; 3], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct pthread_attr_t { - __size: [u64; 7] - } - } - #[cfg(target_arch = "aarch64")] - pub mod posix01 { - use types::os::arch::c95::{c_int, c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u32; - pub type blksize_t = i32; - pub type blkcnt_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - __pad1: dev_t, - pub st_size: off_t, - pub st_blksize: blksize_t, - __pad2: c_int, - pub st_blocks: blkcnt_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - __unused: [c_int; 2], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct pthread_attr_t { - __size: [u64; 8] - } - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - use types::os::arch::c95::{c_ushort, c_int, c_uchar}; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_ll { - pub sll_family: c_ushort, - pub sll_protocol: c_ushort, - pub sll_ifindex: c_int, - pub sll_hatype: c_ushort, - pub sll_pkttype: c_uchar, - pub sll_halen: c_uchar, - pub sll_addr: [c_uchar; 8] - } - - } - } - } - - #[cfg(target_os = "freebsd")] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, size_t, - time_t, suseconds_t, c_long}; - use types::os::arch::c99::{uintptr_t}; - - pub type pthread_t = uintptr_t; - pub type rlim_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: size_t, - __unused1: size_t, - pub gl_offs: size_t, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, - - __unused3: *mut c_void, - - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u8; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - - - } - } - - #[cfg(target_arch = "x86")] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i32; - pub type c_ulong = u32; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u32; - pub type ptrdiff_t = i32; - pub type clock_t = i32; - pub type time_t = i32; - pub type suseconds_t = i32; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i32; - pub type uintptr_t = u32; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - pub type off_t = i64; - pub type dev_t = u32; - pub type ino_t = u32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = i32; - } - pub mod posix01 { - use types::common::c95::{c_void}; - use types::common::c99::{uint32_t, int32_t}; - use types::os::arch::c95::{c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = u32; - pub type blkcnt_t = i64; - pub type fflags_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: fflags_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - __unused: [u8; 8], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - pub type pthread_attr_t = *mut c_void; - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - } - } - - #[cfg(target_arch = "x86_64")] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = i32; - pub type time_t = i64; - pub type suseconds_t = i64; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - pub type off_t = i64; - pub type dev_t = u32; - pub type ino_t = u32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = i64; - } - pub mod posix01 { - use types::common::c95::{c_void}; - use types::common::c99::{uint32_t, int32_t}; - use types::os::arch::c95::{c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = u32; - pub type blkcnt_t = i64; - pub type fflags_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: fflags_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - pub type pthread_attr_t = *mut c_void; - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - } - } - } - - #[cfg(target_os = "dragonfly")] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, size_t, - time_t, suseconds_t, c_long}; - use types::os::arch::c99::{uintptr_t}; - - pub type pthread_t = uintptr_t; - pub type rlim_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: size_t, - __unused1: size_t, - pub gl_offs: size_t, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, - - __unused3: *mut c_void, - - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u8; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - - } - } - - #[cfg(target_arch = "x86_64")] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = i32; - pub type time_t = i64; - pub type suseconds_t = i64; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - pub type off_t = i64; - pub type dev_t = u32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = i64; - } - pub mod posix01 { - use types::common::c95::{c_void}; - use types::common::c99::{uint16_t, uint32_t, int32_t, uint64_t, int64_t}; - use types::os::arch::c95::{c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = uint32_t; - pub type ino_t = uint64_t; - pub type blkcnt_t = i64; - pub type fflags_t = u32; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_ino: ino_t, - pub st_nlink: nlink_t, - pub st_dev: dev_t, - pub st_mode: mode_t, - pub st_padding1: uint16_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: fflags_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_qspare1: int64_t, - pub st_qspare2: int64_t, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - pub type pthread_attr_t = *mut c_void; - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - } - } - } - - #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, size_t, - time_t, suseconds_t, c_long}; - use types::os::arch::c99::{uintptr_t}; - - pub type pthread_t = uintptr_t; - pub type rlim_t = u64; - - #[cfg(target_os = "bitrig")] - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: c_int, - pub gl_matchc: c_int, - pub gl_offs: c_int, - pub gl_flags: c_int, - pub gl_pathv: *mut *mut c_char, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - } - - #[cfg(any(target_os = "netbsd", target_os="openbsd"))] - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: c_int, - __unused1: c_int, - pub gl_offs: c_int, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, - - __unused3: *mut c_void, - - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, - __unused9: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u8; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_pad2: i64, - __ss_pad3: [u8; 240], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_addr: *mut sockaddr, - pub ai_canonname: *mut c_char, - pub ai_next: *mut addrinfo, - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - } - } - - #[cfg(target_arch = "x86_64")] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = i64; - pub type time_t = i64; - pub type suseconds_t = i64; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - use types::os::arch::c95::{c_long}; - pub type off_t = i64; - pub type dev_t = i32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u32; - pub type ssize_t = c_long; - } - pub mod posix01 { - use types::common::c95::{c_void}; - use types::common::c99::{uint32_t, uint64_t}; - use types::os::arch::c95::{c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = uint32_t; - pub type blksize_t = uint32_t; - pub type ino_t = uint64_t; - pub type blkcnt_t = i64; - pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t +#[macro_use] mod macros; - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_mode: mode_t, - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: fflags_t, - pub st_gen: uint32_t, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - pub type pthread_attr_t = *mut c_void; - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - } - } - } - - #[cfg(target_os = "windows")] - pub mod os { - pub mod common { - pub mod posix01 { - use types::os::arch::c95::{c_short, time_t, c_long}; - use types::os::arch::extra::{time64_t}; - use types::os::arch::posix88::{dev_t, ino_t}; - - // pub Note: this is the struct called stat64 in Windows. Not - // stat, nor stati64. - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: u16, - pub st_nlink: c_short, - pub st_uid: c_short, - pub st_gid: c_short, - pub st_rdev: dev_t, - pub st_size: i64, - pub st_atime: time64_t, - pub st_mtime: time64_t, - pub st_ctime: time64_t, - } - - // note that this is called utimbuf64 in Windows - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time64_t, - pub modtime: time64_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: c_long, - pub tv_usec: c_long, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - } - - pub mod bsd44 { - use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; - use types::os::arch::c99::uintptr_t; - - pub type SOCKET = uintptr_t; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_family: u16, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_family: u16, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_family: u16, - pub sin_port: u16, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_family: u16, - pub sin6_port: u16, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: size_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - } - } - - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i32; - pub type c_ulong = u32; - pub type c_float = f32; - pub type c_double = f64; - - #[cfg(target_arch = "x86")] - pub type size_t = u32; - #[cfg(target_arch = "x86_64")] - pub type size_t = u64; - - #[cfg(target_arch = "x86")] - pub type ptrdiff_t = i32; - #[cfg(target_arch = "x86_64")] - pub type ptrdiff_t = i64; - - pub type clock_t = i32; - - cfg_if! { - if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { - pub type time_t = i32; - } else { - pub type time_t = i64; - } - } - - pub type wchar_t = u16; - } - - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - - #[cfg(target_arch = "x86")] - pub type intptr_t = i32; - #[cfg(target_arch = "x86_64")] - pub type intptr_t = i64; - - #[cfg(target_arch = "x86")] - pub type uintptr_t = u32; - #[cfg(target_arch = "x86_64")] - pub type uintptr_t = u64; - - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - - pub mod posix88 { - pub type off_t = i32; - pub type dev_t = u32; - pub type ino_t = u16; - - #[cfg(target_arch = "x86")] - pub type ssize_t = i32; - #[cfg(target_arch = "x86_64")] - pub type ssize_t = i64; - } - - pub mod posix01 { - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - use consts::os::extra::{MAX_PROTOCOL_CHAIN, - WSAPROTOCOL_LEN}; - use types::common::c95::c_void; - use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; - use types::os::arch::c95::{c_long, c_ulong}; - use types::os::arch::c95::{wchar_t}; - use types::os::arch::c99::{c_ulonglong, c_longlong, uintptr_t}; - - pub type BOOL = c_int; - pub type BYTE = u8; - pub type BOOLEAN = BYTE; - pub type CCHAR = c_char; - pub type CHAR = c_char; - - pub type DWORD = c_ulong; - pub type DWORDLONG = c_ulonglong; - - pub type HANDLE = LPVOID; - pub type HINSTANCE = HANDLE; - pub type HMODULE = HINSTANCE; - - pub type LONG = c_long; - pub type PLONG = *mut c_long; - - #[cfg(target_arch = "x86")] - pub type LONG_PTR = c_long; - #[cfg(target_arch = "x86_64")] - pub type LONG_PTR = i64; - - pub type LARGE_INTEGER = c_longlong; - pub type PLARGE_INTEGER = *mut c_longlong; - - pub type LPCWSTR = *const WCHAR; - pub type LPCSTR = *const CHAR; - - pub type LPWSTR = *mut WCHAR; - pub type LPSTR = *mut CHAR; - - pub type LPWCH = *mut WCHAR; - pub type LPCH = *mut CHAR; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct SECURITY_ATTRIBUTES { - pub nLength: DWORD, - pub lpSecurityDescriptor: LPVOID, - pub bInheritHandle: BOOL, - } - pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; - - pub type LPVOID = *mut c_void; - pub type LPCVOID = *const c_void; - pub type LPBYTE = *mut BYTE; - pub type LPWORD = *mut WORD; - pub type LPDWORD = *mut DWORD; - pub type LPHANDLE = *mut HANDLE; - - pub type LRESULT = LONG_PTR; - pub type PBOOL = *mut BOOL; - pub type WCHAR = wchar_t; - pub type WORD = u16; - pub type SIZE_T = size_t; - - pub type time64_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct STARTUPINFOW { - pub cb: DWORD, - pub lpReserved: LPWSTR, - pub lpDesktop: LPWSTR, - pub lpTitle: LPWSTR, - pub dwX: DWORD, - pub dwY: DWORD, - pub dwXSize: DWORD, - pub dwYSize: DWORD, - pub dwXCountChars: DWORD, - pub dwYCountChars: DWORD, - pub dwFillAttribute: DWORD, - pub dwFlags: DWORD, - pub wShowWindow: WORD, - pub cbReserved2: WORD, - pub lpReserved2: LPBYTE, - pub hStdInput: HANDLE, - pub hStdOutput: HANDLE, - pub hStdError: HANDLE, - } - pub type LPSTARTUPINFOW = *mut STARTUPINFOW; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION { - pub hProcess: HANDLE, - pub hThread: HANDLE, - pub dwProcessId: DWORD, - pub dwThreadId: DWORD, - } - pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct SYSTEM_INFO { - pub wProcessorArchitecture: WORD, - pub wReserved: WORD, - pub dwPageSize: DWORD, - pub lpMinimumApplicationAddress: LPVOID, - pub lpMaximumApplicationAddress: LPVOID, - pub dwActiveProcessorMask: uintptr_t, - pub dwNumberOfProcessors: DWORD, - pub dwProcessorType: DWORD, - pub dwAllocationGranularity: DWORD, - pub wProcessorLevel: WORD, - pub wProcessorRevision: WORD, - } - pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct MEMORY_BASIC_INFORMATION { - pub BaseAddress: LPVOID, - pub AllocationBase: LPVOID, - pub AllocationProtect: DWORD, - pub RegionSize: SIZE_T, - pub State: DWORD, - pub Protect: DWORD, - pub Type: DWORD, - } - pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct OVERLAPPED { - pub Internal: *mut c_ulong, - pub InternalHigh: *mut c_ulong, - pub Offset: DWORD, - pub OffsetHigh: DWORD, - pub hEvent: HANDLE, - } - - pub type LPOVERLAPPED = *mut OVERLAPPED; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct FILETIME { - pub dwLowDateTime: DWORD, - pub dwHighDateTime: DWORD, - } - - pub type LPFILETIME = *mut FILETIME; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct GUID { - pub Data1: DWORD, - pub Data2: WORD, - pub Data3: WORD, - pub Data4: [BYTE; 8], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct WSAPROTOCOLCHAIN { - pub ChainLen: c_int, - pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], - } - - pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; - - #[repr(C)] - #[derive(Copy)] pub struct WSAPROTOCOL_INFO { - pub dwServiceFlags1: DWORD, - pub dwServiceFlags2: DWORD, - pub dwServiceFlags3: DWORD, - pub dwServiceFlags4: DWORD, - pub dwProviderFlags: DWORD, - pub ProviderId: GUID, - pub dwCatalogEntryId: DWORD, - pub ProtocolChain: WSAPROTOCOLCHAIN, - pub iVersion: c_int, - pub iAddressFamily: c_int, - pub iMaxSockAddr: c_int, - pub iMinSockAddr: c_int, - pub iSocketType: c_int, - pub iProtocol: c_int, - pub iProtocolMaxOffset: c_int, - pub iNetworkByteOrder: c_int, - pub iSecurityScheme: c_int, - pub dwMessageSize: DWORD, - pub dwProviderReserved: DWORD, - pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], - } - impl Clone for WSAPROTOCOL_INFO { - fn clone(&self) -> WSAPROTOCOL_INFO { *self } - } - - pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; - - pub type GROUP = c_uint; - - #[repr(C)] - #[derive(Copy)] pub struct WIN32_FIND_DATAW { - pub dwFileAttributes: DWORD, - pub ftCreationTime: FILETIME, - pub ftLastAccessTime: FILETIME, - pub ftLastWriteTime: FILETIME, - pub nFileSizeHigh: DWORD, - pub nFileSizeLow: DWORD, - pub dwReserved0: DWORD, - pub dwReserved1: DWORD, - pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 - pub cAlternateFileName: [wchar_t; 14], - } - impl Clone for WIN32_FIND_DATAW { - fn clone(&self) -> WIN32_FIND_DATAW { *self } - } +#[repr(u8)] +pub enum c_void { + __variant1, + __variant2, +} - pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; - } - } +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub enum FILE {} +pub enum fpos_t {} +pub enum DIR {} +pub enum dirent {} + +cfg_if! { + if #[cfg(any(target_os = "macos", target_os = "ios"))] { + mod apple; + pub use apple::*; + } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd", + target_os = "dragonfly"))] { + mod openbsdlike; + pub use openbsdlike::*; + } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] { + mod freebsdlike; + pub use freebsdlike::*; + } else if #[cfg(any(target_os = "android", target_os = "linux"))] { + mod linuxlike; + pub use linuxlike::*; + } else if #[cfg(windows)] { + mod windows; + pub use windows::*; + } else { + // ... } +} - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::c_void; - use types::os::arch::c95::{c_char, c_int, size_t, time_t}; - use types::os::arch::c95::{suseconds_t, c_long}; - use types::os::arch::c99::{uintptr_t}; - - pub type pthread_t = uintptr_t; - pub type rlim_t = u64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: size_t, - __unused1: c_int, - pub gl_offs: size_t, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, - - __unused3: *mut c_void, - - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u8; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - } - } - - #[cfg(any(target_arch = "arm", target_arch = "x86"))] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i32; - pub type c_ulong = u32; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u32; - pub type ptrdiff_t = i32; - pub type clock_t = c_ulong; - pub type time_t = c_long; - pub type suseconds_t = i32; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i32; - pub type uintptr_t = u32; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - use types::os::arch::c95::c_long; - - pub type off_t = i64; - pub type dev_t = i32; - pub type ino_t = u64; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = c_long; - } - pub mod posix01 { - use types::common::c99::{int32_t, int64_t, uint32_t}; - use types::os::arch::c95::{c_char, c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t, - mode_t, off_t, uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = i32; - pub type blkcnt_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_ino: ino_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: uint32_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_qspare: [int64_t; 2], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { - __sig: c_long, - __opaque: [c_char; 36] - } - impl Clone for pthread_attr_t { - fn clone(&self) -> pthread_attr_t { *self } - } - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - #[repr(C)] - #[derive(Copy, Clone)] pub struct mach_timebase_info { - pub numer: u32, - pub denom: u32, - } - - pub type mach_timebase_info_data_t = mach_timebase_info; - } - } - - #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = c_ulong; - pub type time_t = c_long; - pub type suseconds_t = i32; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - use types::os::arch::c95::c_long; - - pub type off_t = i64; - pub type dev_t = i32; - pub type ino_t = u64; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = c_long; - } - pub mod posix01 { - use types::common::c99::{int32_t, int64_t}; - use types::common::c99::{uint32_t}; - use types::os::arch::c95::{c_char, c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t, uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = i32; - pub type blkcnt_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_ino: ino_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: uint32_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_qspare: [int64_t; 2], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { - __sig: c_long, - __opaque: [c_char; 56] - } - impl Clone for pthread_attr_t { - fn clone(&self) -> pthread_attr_t { *self } - } - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - #[repr(C)] - #[derive(Copy, Clone)] pub struct mach_timebase_info { - pub numer: u32, - pub denom: u32, - } - - pub type mach_timebase_info_data_t = mach_timebase_info; - } - } +#[cfg(unix)] mod unix; +#[cfg(unix)] pub use unix::*; + +cfg_if! { + if #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd"))] { + mod bsdlike; + pub use bsdlike::*; + } else { + // non bsds... } } -pub mod consts { - // Consts tend to vary per OS so we pull their definitions out - // into this module. - - #[cfg(target_os = "windows")] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 32767; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 4; - pub const _IOLBF : c_int = 64; - pub const BUFSIZ : c_uint = 512; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 260; - - pub const WSAEINTR: c_int = 10004; - pub const WSAEBADF: c_int = 10009; - pub const WSAEACCES: c_int = 10013; - pub const WSAEFAULT: c_int = 10014; - pub const WSAEINVAL: c_int = 10022; - pub const WSAEMFILE: c_int = 10024; - pub const WSAEWOULDBLOCK: c_int = 10035; - pub const WSAEINPROGRESS: c_int = 10036; - pub const WSAEALREADY: c_int = 10037; - pub const WSAENOTSOCK: c_int = 10038; - pub const WSAEDESTADDRREQ: c_int = 10039; - pub const WSAEMSGSIZE: c_int = 10040; - pub const WSAEPROTOTYPE: c_int = 10041; - pub const WSAENOPROTOOPT: c_int = 10042; - pub const WSAEPROTONOSUPPORT: c_int = 10043; - pub const WSAESOCKTNOSUPPORT: c_int = 10044; - pub const WSAEOPNOTSUPP: c_int = 10045; - pub const WSAEPFNOSUPPORT: c_int = 10046; - pub const WSAEAFNOSUPPORT: c_int = 10047; - pub const WSAEADDRINUSE: c_int = 10048; - pub const WSAEADDRNOTAVAIL: c_int = 10049; - pub const WSAENETDOWN: c_int = 10050; - pub const WSAENETUNREACH: c_int = 10051; - pub const WSAENETRESET: c_int = 10052; - pub const WSAECONNABORTED: c_int = 10053; - pub const WSAECONNRESET: c_int = 10054; - pub const WSAENOBUFS: c_int = 10055; - pub const WSAEISCONN: c_int = 10056; - pub const WSAENOTCONN: c_int = 10057; - pub const WSAESHUTDOWN: c_int = 10058; - pub const WSAETOOMANYREFS: c_int = 10059; - pub const WSAETIMEDOUT: c_int = 10060; - pub const WSAECONNREFUSED: c_int = 10061; - pub const WSAELOOP: c_int = 10062; - pub const WSAENAMETOOLONG: c_int = 10063; - pub const WSAEHOSTDOWN: c_int = 10064; - pub const WSAEHOSTUNREACH: c_int = 10065; - pub const WSAENOTEMPTY: c_int = 10066; - pub const WSAEPROCLIM: c_int = 10067; - pub const WSAEUSERS: c_int = 10068; - pub const WSAEDQUOT: c_int = 10069; - pub const WSAESTALE: c_int = 10070; - pub const WSAEREMOTE: c_int = 10071; - pub const WSASYSNOTREADY: c_int = 10091; - pub const WSAVERNOTSUPPORTED: c_int = 10092; - pub const WSANOTINITIALISED: c_int = 10093; - pub const WSAEDISCON: c_int = 10101; - pub const WSAENOMORE: c_int = 10102; - pub const WSAECANCELLED: c_int = 10103; - pub const WSAEINVALIDPROCTABLE: c_int = 10104; - pub const WSAEINVALIDPROVIDER: c_int = 10105; - pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; - - cfg_if! { - if #[cfg(all(target_env = "gnu"))] { - pub const L_tmpnam : c_uint = 14; - pub const TMP_MAX : c_uint = 0x7fff; - } else { - pub const L_tmpnam : c_uint = 260; - pub const TMP_MAX : c_uint = 0x7fff_ffff; - } - } - } - pub mod c99 { - } - pub mod posix88 { - use types::os::arch::c95::c_int; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 256; - pub const O_EXCL : c_int = 1024; - pub const O_TRUNC : c_int = 512; - pub const S_IFCHR : c_int = 8192; - pub const S_IFDIR : c_int = 16384; - pub const S_IFREG : c_int = 32768; - pub const S_IFMT : c_int = 61440; - pub const S_IEXEC : c_int = 64; - pub const S_IWRITE : c_int = 128; - pub const S_IREAD : c_int = 256; - } - pub mod posix01 { - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 23; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 12; - pub const IPV6_DROP_MEMBERSHIP: c_int = 13; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - - pub const TCP_NODELAY: c_int = 0x0001; - pub const SOL_SOCKET: c_int = 0xffff; - - pub const SO_DEBUG: c_int = 0x0001; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 4; - - pub const SD_RECEIVE: c_int = 0; - pub const SD_SEND: c_int = 1; - pub const SD_BOTH: c_int = 2; - } - pub mod extra { - use types::os::common::bsd44::SOCKET; - use types::os::arch::c95::{c_int, c_long}; - use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE}; - - pub const TRUE : BOOL = 1; - pub const FALSE : BOOL = 0; - - pub const O_TEXT : c_int = 16384; - pub const O_BINARY : c_int = 32768; - pub const O_NOINHERIT: c_int = 128; - - pub const ERROR_SUCCESS : c_int = 0; - pub const ERROR_INVALID_FUNCTION: c_int = 1; - pub const ERROR_FILE_NOT_FOUND: c_int = 2; - pub const ERROR_ACCESS_DENIED: c_int = 5; - pub const ERROR_INVALID_HANDLE : c_int = 6; - pub const ERROR_BROKEN_PIPE: c_int = 109; - pub const ERROR_DISK_FULL : c_int = 112; - pub const ERROR_CALL_NOT_IMPLEMENTED : c_int = 120; - pub const ERROR_INSUFFICIENT_BUFFER : c_int = 122; - pub const ERROR_INVALID_NAME : c_int = 123; - pub const ERROR_ALREADY_EXISTS : c_int = 183; - pub const ERROR_PIPE_BUSY: c_int = 231; - pub const ERROR_NO_DATA: c_int = 232; - pub const ERROR_INVALID_ADDRESS : c_int = 487; - pub const ERROR_PIPE_CONNECTED: c_int = 535; - pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758; - pub const ERROR_OPERATION_ABORTED: c_int = 995; - pub const ERROR_IO_PENDING: c_int = 997; - pub const ERROR_FILE_INVALID : c_int = 1006; - pub const ERROR_NOT_FOUND: c_int = 1168; - pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; - - pub const DELETE : DWORD = 0x00010000; - pub const READ_CONTROL : DWORD = 0x00020000; - pub const SYNCHRONIZE : DWORD = 0x00100000; - pub const WRITE_DAC : DWORD = 0x00040000; - pub const WRITE_OWNER : DWORD = 0x00080000; - - pub const PROCESS_CREATE_PROCESS : DWORD = 0x0080; - pub const PROCESS_CREATE_THREAD : DWORD = 0x0002; - pub const PROCESS_DUP_HANDLE : DWORD = 0x0040; - pub const PROCESS_QUERY_INFORMATION : DWORD = 0x0400; - pub const PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000; - pub const PROCESS_SET_INFORMATION : DWORD = 0x0200; - pub const PROCESS_SET_QUOTA : DWORD = 0x0100; - pub const PROCESS_SUSPEND_RESUME : DWORD = 0x0800; - pub const PROCESS_TERMINATE : DWORD = 0x0001; - pub const PROCESS_VM_OPERATION : DWORD = 0x0008; - pub const PROCESS_VM_READ : DWORD = 0x0010; - pub const PROCESS_VM_WRITE : DWORD = 0x0020; - - pub const STARTF_FORCEONFEEDBACK : DWORD = 0x00000040; - pub const STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080; - pub const STARTF_PREVENTPINNING : DWORD = 0x00002000; - pub const STARTF_RUNFULLSCREEN : DWORD = 0x00000020; - pub const STARTF_TITLEISAPPID : DWORD = 0x00001000; - pub const STARTF_TITLEISLINKNAME : DWORD = 0x00000800; - pub const STARTF_USECOUNTCHARS : DWORD = 0x00000008; - pub const STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010; - pub const STARTF_USEHOTKEY : DWORD = 0x00000200; - pub const STARTF_USEPOSITION : DWORD = 0x00000004; - pub const STARTF_USESHOWWINDOW : DWORD = 0x00000001; - pub const STARTF_USESIZE : DWORD = 0x00000002; - pub const STARTF_USESTDHANDLES : DWORD = 0x00000100; - - pub const WAIT_ABANDONED : DWORD = 0x00000080; - pub const WAIT_OBJECT_0 : DWORD = 0x00000000; - pub const WAIT_TIMEOUT : DWORD = 0x00000102; - pub const WAIT_FAILED : DWORD = !0; - - pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001; - pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002; - - pub const INFINITE : DWORD = !0; - pub const STILL_ACTIVE : DWORD = 259; - - pub const MEM_COMMIT : DWORD = 0x00001000; - pub const MEM_RESERVE : DWORD = 0x00002000; - pub const MEM_DECOMMIT : DWORD = 0x00004000; - pub const MEM_RELEASE : DWORD = 0x00008000; - pub const MEM_RESET : DWORD = 0x00080000; - pub const MEM_RESET_UNDO : DWORD = 0x1000000; - pub const MEM_LARGE_PAGES : DWORD = 0x20000000; - pub const MEM_PHYSICAL : DWORD = 0x00400000; - pub const MEM_TOP_DOWN : DWORD = 0x00100000; - pub const MEM_WRITE_WATCH : DWORD = 0x00200000; - - pub const PAGE_EXECUTE : DWORD = 0x10; - pub const PAGE_EXECUTE_READ : DWORD = 0x20; - pub const PAGE_EXECUTE_READWRITE : DWORD = 0x40; - pub const PAGE_EXECUTE_WRITECOPY : DWORD = 0x80; - pub const PAGE_NOACCESS : DWORD = 0x01; - pub const PAGE_READONLY : DWORD = 0x02; - pub const PAGE_READWRITE : DWORD = 0x04; - pub const PAGE_WRITECOPY : DWORD = 0x08; - pub const PAGE_GUARD : DWORD = 0x100; - pub const PAGE_NOCACHE : DWORD = 0x200; - pub const PAGE_WRITECOMBINE : DWORD = 0x400; - - pub const SEC_COMMIT : DWORD = 0x8000000; - pub const SEC_IMAGE : DWORD = 0x1000000; - pub const SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000; - pub const SEC_LARGE_PAGES : DWORD = 0x80000000; - pub const SEC_NOCACHE : DWORD = 0x10000000; - pub const SEC_RESERVE : DWORD = 0x4000000; - pub const SEC_WRITECOMBINE : DWORD = 0x40000000; - - pub const FILE_MAP_ALL_ACCESS : DWORD = 0xf001f; - pub const FILE_MAP_READ : DWORD = 0x4; - pub const FILE_MAP_WRITE : DWORD = 0x2; - pub const FILE_MAP_COPY : DWORD = 0x1; - pub const FILE_MAP_EXECUTE : DWORD = 0x20; - - pub const PROCESSOR_ARCHITECTURE_INTEL : WORD = 0; - pub const PROCESSOR_ARCHITECTURE_ARM : WORD = 5; - pub const PROCESSOR_ARCHITECTURE_IA64 : WORD = 6; - pub const PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9; - pub const PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff; - - pub const MOVEFILE_COPY_ALLOWED: DWORD = 2; - pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16; - pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4; - pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32; - pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1; - pub const MOVEFILE_WRITE_THROUGH: DWORD = 8; - - pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1; - - pub const FILE_SHARE_DELETE: DWORD = 0x4; - pub const FILE_SHARE_READ: DWORD = 0x1; - pub const FILE_SHARE_WRITE: DWORD = 0x2; - - pub const CREATE_ALWAYS: DWORD = 2; - pub const CREATE_NEW: DWORD = 1; - pub const OPEN_ALWAYS: DWORD = 4; - pub const OPEN_EXISTING: DWORD = 3; - pub const TRUNCATE_EXISTING: DWORD = 5; - - pub const FILE_APPEND_DATA: DWORD = 0x00000004; - pub const FILE_READ_DATA: DWORD = 0x00000001; - pub const FILE_WRITE_DATA: DWORD = 0x00000002; - - pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20; - pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800; - pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40; - pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10; - pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000; - pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2; - pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000; - pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80; - pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000; - pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000; - pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000; - pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1; - pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400; - pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200; - pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4; - pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100; - pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000; - - pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; - pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; - pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; - pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; - pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; - pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; - pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000; - pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; - pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; - pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; - pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; - pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; - - pub const FILE_NAME_NORMALIZED: DWORD = 0x0; - pub const FILE_NAME_OPENED: DWORD = 0x8; - - pub const VOLUME_NAME_DOS: DWORD = 0x0; - pub const VOLUME_NAME_GUID: DWORD = 0x1; - pub const VOLUME_NAME_NONE: DWORD = 0x4; - pub const VOLUME_NAME_NT: DWORD = 0x2; - - pub const GENERIC_READ: DWORD = 0x80000000; - pub const GENERIC_WRITE: DWORD = 0x40000000; - pub const GENERIC_EXECUTE: DWORD = 0x20000000; - pub const GENERIC_ALL: DWORD = 0x10000000; - pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100; - pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080; - - pub const STANDARD_RIGHTS_READ: DWORD = 0x20000; - pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000; - pub const FILE_WRITE_EA: DWORD = 0x00000010; - pub const FILE_READ_EA: DWORD = 0x00000008; - pub const FILE_GENERIC_READ: DWORD = - STANDARD_RIGHTS_READ | FILE_READ_DATA | - FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; - pub const FILE_GENERIC_WRITE: DWORD = - STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | - FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | - SYNCHRONIZE; - - pub const FILE_BEGIN: DWORD = 0; - pub const FILE_CURRENT: DWORD = 1; - pub const FILE_END: DWORD = 2; - - pub const MAX_PROTOCOL_CHAIN: DWORD = 7; - pub const WSAPROTOCOL_LEN: DWORD = 255; - pub const INVALID_SOCKET: SOCKET = !0; - - pub const DETACHED_PROCESS: DWORD = 0x00000008; - pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; - pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; - - pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; - pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; - pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; - pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; - pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; - pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; - pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; - pub const PIPE_WAIT: DWORD = 0x00000000; - pub const PIPE_NOWAIT: DWORD = 0x00000001; - pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; - pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; - pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; - - pub const IPPROTO_RAW: c_int = 255; - - pub const FIONBIO: c_long = -0x7FFB9982; - } - pub mod sysconf { - } - } - - - #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 2147483647; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 2; - pub const _IOLBF : c_int = 1; - pub const BUFSIZ : c_uint = 8192; - pub const FOPEN_MAX : c_uint = 16; - pub const FILENAME_MAX : c_uint = 4096; - pub const L_tmpnam : c_uint = 20; - pub const TMP_MAX : c_uint = 238328; - } - pub mod c99 { - } - #[cfg(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "le32", - target_arch = "powerpc"))] - pub mod posix88 { - use types::os::arch::c95::c_int; - use types::common::c95::c_void; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 1024; - pub const O_CREAT : c_int = 64; - pub const O_EXCL : c_int = 128; - pub const O_NOCTTY : c_int = 256; - pub const O_TRUNC : c_int = 512; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x0020; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_INVALIDATE : c_int = 0x0002; - pub const MS_SYNC : c_int = 0x0004; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EAGAIN : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - - pub const EDEADLK: c_int = 35; - pub const ENAMETOOLONG: c_int = 36; - pub const ENOLCK: c_int = 37; - pub const ENOSYS: c_int = 38; - pub const ENOTEMPTY: c_int = 39; - pub const ELOOP: c_int = 40; - pub const EWOULDBLOCK: c_int = EAGAIN; - pub const ENOMSG: c_int = 42; - pub const EIDRM: c_int = 43; - pub const ECHRNG: c_int = 44; - pub const EL2NSYNC: c_int = 45; - pub const EL3HLT: c_int = 46; - pub const EL3RST: c_int = 47; - pub const ELNRNG: c_int = 48; - pub const EUNATCH: c_int = 49; - pub const ENOCSI: c_int = 50; - pub const EL2HLT: c_int = 51; - pub const EBADE: c_int = 52; - pub const EBADR: c_int = 53; - pub const EXFULL: c_int = 54; - pub const ENOANO: c_int = 55; - pub const EBADRQC: c_int = 56; - pub const EBADSLT: c_int = 57; - - pub const EDEADLOCK: c_int = EDEADLK; - - pub const EBFONT: c_int = 59; - pub const ENOSTR: c_int = 60; - pub const ENODATA: c_int = 61; - pub const ETIME: c_int = 62; - pub const ENOSR: c_int = 63; - pub const ENONET: c_int = 64; - pub const ENOPKG: c_int = 65; - pub const EREMOTE: c_int = 66; - pub const ENOLINK: c_int = 67; - pub const EADV: c_int = 68; - pub const ESRMNT: c_int = 69; - pub const ECOMM: c_int = 70; - pub const EPROTO: c_int = 71; - pub const EMULTIHOP: c_int = 72; - pub const EDOTDOT: c_int = 73; - pub const EBADMSG: c_int = 74; - pub const EOVERFLOW: c_int = 75; - pub const ENOTUNIQ: c_int = 76; - pub const EBADFD: c_int = 77; - pub const EREMCHG: c_int = 78; - pub const ELIBACC: c_int = 79; - pub const ELIBBAD: c_int = 80; - pub const ELIBSCN: c_int = 81; - pub const ELIBMAX: c_int = 82; - pub const ELIBEXEC: c_int = 83; - pub const EILSEQ: c_int = 84; - pub const ERESTART: c_int = 85; - pub const ESTRPIPE: c_int = 86; - pub const EUSERS: c_int = 87; - pub const ENOTSOCK: c_int = 88; - pub const EDESTADDRREQ: c_int = 89; - pub const EMSGSIZE: c_int = 90; - pub const EPROTOTYPE: c_int = 91; - pub const ENOPROTOOPT: c_int = 92; - pub const EPROTONOSUPPORT: c_int = 93; - pub const ESOCKTNOSUPPORT: c_int = 94; - pub const EOPNOTSUPP: c_int = 95; - pub const EPFNOSUPPORT: c_int = 96; - pub const EAFNOSUPPORT: c_int = 97; - pub const EADDRINUSE: c_int = 98; - pub const EADDRNOTAVAIL: c_int = 99; - pub const ENETDOWN: c_int = 100; - pub const ENETUNREACH: c_int = 101; - pub const ENETRESET: c_int = 102; - pub const ECONNABORTED: c_int = 103; - pub const ECONNRESET: c_int = 104; - pub const ENOBUFS: c_int = 105; - pub const EISCONN: c_int = 106; - pub const ENOTCONN: c_int = 107; - pub const ESHUTDOWN: c_int = 108; - pub const ETOOMANYREFS: c_int = 109; - pub const ETIMEDOUT: c_int = 110; - pub const ECONNREFUSED: c_int = 111; - pub const EHOSTDOWN: c_int = 112; - pub const EHOSTUNREACH: c_int = 113; - pub const EALREADY: c_int = 114; - pub const EINPROGRESS: c_int = 115; - pub const ESTALE: c_int = 116; - pub const EUCLEAN: c_int = 117; - pub const ENOTNAM: c_int = 118; - pub const ENAVAIL: c_int = 119; - pub const EISNAM: c_int = 120; - pub const EREMOTEIO: c_int = 121; - pub const EDQUOT: c_int = 122; - - pub const ENOMEDIUM: c_int = 123; - pub const EMEDIUMTYPE: c_int = 124; - pub const ECANCELED: c_int = 125; - pub const ENOKEY: c_int = 126; - pub const EKEYEXPIRED: c_int = 127; - pub const EKEYREVOKED: c_int = 128; - pub const EKEYREJECTED: c_int = 129; - - pub const EOWNERDEAD: c_int = 130; - pub const ENOTRECOVERABLE: c_int = 131; - - pub const ERFKILL: c_int = 132; - - pub const EHWPOISON: c_int = 133; - } - - #[cfg(any(target_arch = "mips", - target_arch = "mipsel"))] - pub mod posix88 { - use types::os::arch::c95::c_int; - use types::common::c95::c_void; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 256; - pub const O_EXCL : c_int = 1024; - pub const O_NOCTTY : c_int = 2048; - pub const O_TRUNC : c_int = 512; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x0800; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_INVALIDATE : c_int = 0x0002; - pub const MS_SYNC : c_int = 0x0004; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EAGAIN : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - - pub const ENOMSG: c_int = 35; - pub const EIDRM: c_int = 36; - pub const ECHRNG: c_int = 37; - pub const EL2NSYNC: c_int = 38; - pub const EL3HLT: c_int = 39; - pub const EL3RST: c_int = 40; - pub const ELNRNG: c_int = 41; - pub const EUNATCH: c_int = 42; - pub const ENOCSI: c_int = 43; - pub const EL2HLT: c_int = 44; - pub const EDEADLK: c_int = 45; - pub const ENOLCK: c_int = 46; - pub const EBADE: c_int = 50; - pub const EBADR: c_int = 51; - pub const EXFULL: c_int = 52; - pub const ENOANO: c_int = 53; - pub const EBADRQC: c_int = 54; - pub const EBADSLT: c_int = 55; - pub const EDEADLOCK: c_int = 56; - pub const EBFONT: c_int = 59; - pub const ENOSTR: c_int = 60; - pub const ENODATA: c_int = 61; - pub const ETIME: c_int = 62; - pub const ENOSR: c_int = 63; - pub const ENONET: c_int = 64; - pub const ENOPKG: c_int = 65; - pub const EREMOTE: c_int = 66; - pub const ENOLINK: c_int = 67; - pub const EADV: c_int = 68; - pub const ESRMNT: c_int = 69; - pub const ECOMM: c_int = 70; - pub const EPROTO: c_int = 71; - pub const EDOTDOT: c_int = 73; - pub const EMULTIHOP: c_int = 74; - pub const EBADMSG: c_int = 77; - pub const ENAMETOOLONG: c_int = 78; - pub const EOVERFLOW: c_int = 79; - pub const ENOTUNIQ: c_int = 80; - pub const EBADFD: c_int = 81; - pub const EREMCHG: c_int = 82; - pub const ELIBACC: c_int = 83; - pub const ELIBBAD: c_int = 84; - pub const ELIBSCN: c_int = 95; - pub const ELIBMAX: c_int = 86; - pub const ELIBEXEC: c_int = 87; - pub const EILSEQ: c_int = 88; - pub const ENOSYS: c_int = 89; - pub const ELOOP: c_int = 90; - pub const ERESTART: c_int = 91; - pub const ESTRPIPE: c_int = 92; - pub const ENOTEMPTY: c_int = 93; - pub const EUSERS: c_int = 94; - pub const ENOTSOCK: c_int = 95; - pub const EDESTADDRREQ: c_int = 96; - pub const EMSGSIZE: c_int = 97; - pub const EPROTOTYPE: c_int = 98; - pub const ENOPROTOOPT: c_int = 99; - pub const EPROTONOSUPPORT: c_int = 120; - pub const ESOCKTNOSUPPORT: c_int = 121; - pub const EOPNOTSUPP: c_int = 122; - pub const EPFNOSUPPORT: c_int = 123; - pub const EAFNOSUPPORT: c_int = 124; - pub const EADDRINUSE: c_int = 125; - pub const EADDRNOTAVAIL: c_int = 126; - pub const ENETDOWN: c_int = 127; - pub const ENETUNREACH: c_int = 128; - pub const ENETRESET: c_int = 129; - pub const ECONNABORTED: c_int = 130; - pub const ECONNRESET: c_int = 131; - pub const ENOBUFS: c_int = 132; - pub const EISCONN: c_int = 133; - pub const ENOTCONN: c_int = 134; - pub const EUCLEAN: c_int = 135; - pub const ENOTNAM: c_int = 137; - pub const ENAVAIL: c_int = 138; - pub const EISNAM: c_int = 139; - pub const EREMOTEIO: c_int = 140; - pub const ESHUTDOWN: c_int = 143; - pub const ETOOMANYREFS: c_int = 144; - pub const ETIMEDOUT: c_int = 145; - pub const ECONNREFUSED: c_int = 146; - pub const EHOSTDOWN: c_int = 147; - pub const EHOSTUNREACH: c_int = 148; - pub const EWOULDBLOCK: c_int = EAGAIN; - pub const EALREADY: c_int = 149; - pub const EINPROGRESS: c_int = 150; - pub const ESTALE: c_int = 151; - pub const ECANCELED: c_int = 158; - - pub const ENOMEDIUM: c_int = 159; - pub const EMEDIUMTYPE: c_int = 160; - pub const ENOKEY: c_int = 161; - pub const EKEYEXPIRED: c_int = 162; - pub const EKEYREVOKED: c_int = 163; - pub const EKEYREJECTED: c_int = 164; - - pub const EOWNERDEAD: c_int = 165; - pub const ENOTRECOVERABLE: c_int = 166; - - pub const ERFKILL: c_int = 167; - - pub const EHWPOISON: c_int = 168; - - pub const EDQUOT: c_int = 1133; - } - #[cfg(not(target_os = "nacl"))] - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - - pub const O_ACCMODE : c_int = 3; - - pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; - - pub const GLOB_ERR : c_int = 1 << 0; - pub const GLOB_MARK : c_int = 1 << 1; - pub const GLOB_NOSORT : c_int = 1 << 2; - pub const GLOB_DOOFFS : c_int = 1 << 3; - pub const GLOB_NOCHECK : c_int = 1 << 4; - pub const GLOB_APPEND : c_int = 1 << 5; - pub const GLOB_NOESCAPE : c_int = 1 << 6; - - pub const GLOB_NOSPACE : c_int = 1; - pub const GLOB_ABORTED : c_int = 2; - pub const GLOB_NOMATCH : c_int = 3; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_MQ_PRIO_MAX : c_int = 28; - pub const _SC_IOV_MAX : c_int = 60; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 69; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 70; - pub const _SC_LOGIN_NAME_MAX : c_int = 71; - pub const _SC_TTY_NAME_MAX : c_int = 72; - pub const _SC_THREADS : c_int = 67; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73; - pub const _SC_THREAD_KEYS_MAX : c_int = 74; - pub const _SC_THREAD_STACK_MIN : c_int = 75; - pub const _SC_THREAD_THREADS_MAX : c_int = 76; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 80; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 81; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 82; - pub const _SC_ATEXIT_MAX : c_int = 87; - pub const _SC_XOPEN_VERSION : c_int = 89; - pub const _SC_XOPEN_XCU_VERSION : c_int = 90; - pub const _SC_XOPEN_UNIX : c_int = 91; - pub const _SC_XOPEN_CRYPT : c_int = 92; - pub const _SC_XOPEN_ENH_I18N : c_int = 93; - pub const _SC_XOPEN_SHM : c_int = 94; - pub const _SC_XOPEN_LEGACY : c_int = 129; - pub const _SC_XOPEN_REALTIME : c_int = 130; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131; - - - - pub const PTHREAD_CREATE_JOINABLE: c_int = 0; - pub const PTHREAD_CREATE_DETACHED: c_int = 1; - - #[cfg(target_os = "android")] - pub const PTHREAD_STACK_MIN: size_t = 8192; - - #[cfg(all(target_os = "linux", - any(target_arch = "arm", - target_arch = "x86", - target_arch = "x86_64")))] - pub const PTHREAD_STACK_MIN: size_t = 16384; - - #[cfg(all(target_os = "linux", - any(target_arch = "mips", - target_arch = "mipsel", - target_arch = "aarch64", - target_arch = "powerpc")))] - pub const PTHREAD_STACK_MIN: size_t = 131072; - - pub const CLOCK_REALTIME: c_int = 0; - pub const CLOCK_MONOTONIC: c_int = 1; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_RSS: c_int = 5; - pub const RLIMIT_NOFILE: c_int = 7; - pub const RLIMIT_AS: c_int = 9; - pub const RLIMIT_NPROC: c_int = 6; - pub const RLIMIT_MEMLOCK: c_int = 8; - pub const RLIMIT_LOCKS: c_int = 10; - pub const RLIMIT_SIGPENDING: c_int = 11; - pub const RLIMIT_MSGQUEUE: c_int = 12; - pub const RLIMIT_NICE: c_int = 13; - pub const RLIMIT_RTPRIO: c_int = 14; - pub const RLIMIT_RTTIME: c_int = 15; - pub const RLIMIT_NLIMITS: c_int = 16; - pub const RLIM_INFINITY: rlim_t = !0; - pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; - pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - pub const RUSAGE_THREAD: c_int = 1; - } - #[cfg(target_os = "nacl")] - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - - pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; - - pub const GLOB_ERR : c_int = 1 << 0; - pub const GLOB_MARK : c_int = 1 << 1; - pub const GLOB_NOSORT : c_int = 1 << 2; - pub const GLOB_DOOFFS : c_int = 1 << 3; - pub const GLOB_NOCHECK : c_int = 1 << 4; - pub const GLOB_APPEND : c_int = 1 << 5; - pub const GLOB_NOESCAPE : c_int = 1 << 6; - - pub const GLOB_NOSPACE : c_int = 1; - pub const GLOB_ABORTED : c_int = 2; - pub const GLOB_NOMATCH : c_int = 3; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_MQ_PRIO_MAX : c_int = 28; - pub const _SC_IOV_MAX : c_int = 60; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 69; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 70; - pub const _SC_LOGIN_NAME_MAX : c_int = 71; - pub const _SC_TTY_NAME_MAX : c_int = 72; - pub const _SC_THREADS : c_int = 67; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 68; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 73; - pub const _SC_THREAD_KEYS_MAX : c_int = 74; - pub const _SC_THREAD_STACK_MIN : c_int = 75; - pub const _SC_THREAD_THREADS_MAX : c_int = 76; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 79; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 80; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 81; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 82; - pub const _SC_ATEXIT_MAX : c_int = 87; - pub const _SC_XOPEN_VERSION : c_int = 89; - pub const _SC_XOPEN_XCU_VERSION : c_int = 90; - pub const _SC_XOPEN_UNIX : c_int = 91; - pub const _SC_XOPEN_CRYPT : c_int = 92; - pub const _SC_XOPEN_ENH_I18N : c_int = 93; - pub const _SC_XOPEN_SHM : c_int = 94; - pub const _SC_XOPEN_LEGACY : c_int = 129; - pub const _SC_XOPEN_REALTIME : c_int = 130; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 131; - - pub const PTHREAD_CREATE_JOINABLE: c_int = 1; - pub const PTHREAD_CREATE_DETACHED: c_int = 0; - - pub const PTHREAD_STACK_MIN: size_t = 1024; - - pub const CLOCK_REALTIME: c_int = 0; - pub const CLOCK_MONOTONIC: c_int = 1; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_RSS: c_int = 5; - pub const RLIMIT_NOFILE: c_int = 7; - pub const RLIMIT_AS: c_int = 9; - pub const RLIMIT_NPROC: c_int = 6; - pub const RLIMIT_MEMLOCK: c_int = 8; - pub const RLIMIT_LOCKS: c_int = 10; - pub const RLIMIT_SIGPENDING: c_int = 11; - pub const RLIMIT_MSGQUEUE: c_int = 12; - pub const RLIMIT_NICE: c_int = 13; - pub const RLIMIT_RTPRIO: c_int = 14; - pub const RLIMIT_RTTIME: c_int = 15; - pub const RLIMIT_NLIMITS: c_int = 16; - - pub const RLIM_INFINITY: rlim_t = 0xffff_ffff_ffff_ffff; - pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; - pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - pub const RUSAGE_THREAD: c_int = 1; - } - pub mod posix08 { - } - #[cfg(any(target_arch = "arm", - target_arch = "aarch64", - target_arch = "x86", - target_arch = "x86_64", - target_arch = "le32", - target_arch = "powerpc"))] - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_REMOVE : c_int = 9; - pub const MADV_DONTFORK : c_int = 10; - pub const MADV_DOFORK : c_int = 11; - pub const MADV_MERGEABLE : c_int = 12; - pub const MADV_UNMERGEABLE : c_int = 13; - pub const MADV_HWPOISON : c_int = 100; - - pub const IFF_LOOPBACK: c_int = 0x8; - - pub const AF_UNIX: c_int = 1; - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 10; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 33; - pub const IP_MULTICAST_LOOP: c_int = 34; - pub const IP_TTL: c_int = 2; - pub const IP_HDRINCL: c_int = 3; - pub const IP_ADD_MEMBERSHIP: c_int = 35; - pub const IP_DROP_MEMBERSHIP: c_int = 36; - pub const IPV6_ADD_MEMBERSHIP: c_int = 20; - pub const IPV6_DROP_MEMBERSHIP: c_int = 21; - - pub const TCP_NODELAY: c_int = 1; - pub const TCP_MAXSEG: c_int = 2; - pub const TCP_CORK: c_int = 3; - pub const TCP_KEEPIDLE: c_int = 4; - pub const TCP_KEEPINTVL: c_int = 5; - pub const TCP_KEEPCNT: c_int = 6; - pub const TCP_SYNCNT: c_int = 7; - pub const TCP_LINGER2: c_int = 8; - pub const TCP_DEFER_ACCEPT: c_int = 9; - pub const TCP_WINDOW_CLAMP: c_int = 10; - pub const TCP_INFO: c_int = 11; - pub const TCP_QUICKACK: c_int = 12; - pub const TCP_CONGESTION: c_int = 13; - pub const TCP_MD5SIG: c_int = 14; - pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; - pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; - pub const TCP_THIN_DUPACK: c_int = 17; - pub const TCP_USER_TIMEOUT: c_int = 18; - pub const TCP_REPAIR: c_int = 19; - pub const TCP_REPAIR_QUEUE: c_int = 20; - pub const TCP_QUEUE_SEQ: c_int = 21; - pub const TCP_REPAIR_OPTIONS: c_int = 22; - pub const TCP_FASTOPEN: c_int = 23; - pub const TCP_TIMESTAMP: c_int = 24; - - pub const SOL_SOCKET: c_int = 1; - - pub const SO_DEBUG: c_int = 1; - pub const SO_REUSEADDR: c_int = 2; - pub const SO_TYPE: c_int = 3; - pub const SO_ERROR: c_int = 4; - pub const SO_DONTROUTE: c_int = 5; - pub const SO_BROADCAST: c_int = 6; - pub const SO_SNDBUF: c_int = 7; - pub const SO_RCVBUF: c_int = 8; - pub const SO_KEEPALIVE: c_int = 9; - pub const SO_OOBINLINE: c_int = 10; - pub const SO_LINGER: c_int = 13; - pub const SO_REUSEPORT: c_int = 15; - pub const SO_RCVLOWAT: c_int = 18; - pub const SO_SNDLOWAT: c_int = 19; - pub const SO_RCVTIMEO: c_int = 20; - pub const SO_SNDTIMEO: c_int = 21; - pub const SO_ACCEPTCONN: c_int = 30; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - #[cfg(any(target_arch = "mips", - target_arch = "mipsel"))] - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_REMOVE : c_int = 9; - pub const MADV_DONTFORK : c_int = 10; - pub const MADV_DOFORK : c_int = 11; - pub const MADV_MERGEABLE : c_int = 12; - pub const MADV_UNMERGEABLE : c_int = 13; - pub const MADV_HWPOISON : c_int = 100; - - pub const AF_UNIX: c_int = 1; - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 10; - pub const SOCK_STREAM: c_int = 2; - pub const SOCK_DGRAM: c_int = 1; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 33; - pub const IP_MULTICAST_LOOP: c_int = 34; - pub const IP_TTL: c_int = 2; - pub const IP_HDRINCL: c_int = 3; - pub const IP_ADD_MEMBERSHIP: c_int = 35; - pub const IP_DROP_MEMBERSHIP: c_int = 36; - pub const IPV6_ADD_MEMBERSHIP: c_int = 20; - pub const IPV6_DROP_MEMBERSHIP: c_int = 21; - - pub const TCP_NODELAY: c_int = 1; - pub const TCP_MAXSEG: c_int = 2; - pub const TCP_CORK: c_int = 3; - pub const TCP_KEEPIDLE: c_int = 4; - pub const TCP_KEEPINTVL: c_int = 5; - pub const TCP_KEEPCNT: c_int = 6; - pub const TCP_SYNCNT: c_int = 7; - pub const TCP_LINGER2: c_int = 8; - pub const TCP_DEFER_ACCEPT: c_int = 9; - pub const TCP_WINDOW_CLAMP: c_int = 10; - pub const TCP_INFO: c_int = 11; - pub const TCP_QUICKACK: c_int = 12; - pub const TCP_CONGESTION: c_int = 13; - pub const TCP_MD5SIG: c_int = 14; - pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; - pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; - pub const TCP_THIN_DUPACK: c_int = 17; - pub const TCP_USER_TIMEOUT: c_int = 18; - pub const TCP_REPAIR: c_int = 19; - pub const TCP_REPAIR_QUEUE: c_int = 20; - pub const TCP_QUEUE_SEQ: c_int = 21; - pub const TCP_REPAIR_OPTIONS: c_int = 22; - pub const TCP_FASTOPEN: c_int = 23; - pub const TCP_TIMESTAMP: c_int = 24; - - pub const SOL_SOCKET: c_int = 65535; - - pub const SO_DEBUG: c_int = 0x0001; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x100; - pub const SO_REUSEPORT: c_int = 0x0200; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - pub const SO_ACCEPTCONN: c_int = 0x1009; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - #[cfg(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "le32", - target_arch = "powerpc"))] - pub mod extra { - use types::os::arch::c95::c_int; - - pub const AF_PACKET : c_int = 17; - pub const IPPROTO_RAW : c_int = 255; - - pub const O_RSYNC : c_int = 1052672; - pub const O_DSYNC : c_int = 4096; - pub const O_NONBLOCK : c_int = 2048; - pub const O_SYNC : c_int = 1052672; - - pub const PROT_GROWSDOWN : c_int = 0x1000000; - pub const PROT_GROWSUP : c_int = 0x2000000; - - pub const MAP_TYPE : c_int = 0x000f; - pub const MAP_ANONYMOUS : c_int = 0x0020; - pub const MAP_32BIT : c_int = 0x0040; - pub const MAP_GROWSDOWN : c_int = 0x0100; - pub const MAP_DENYWRITE : c_int = 0x0800; - pub const MAP_EXECUTABLE : c_int = 0x01000; - pub const MAP_LOCKED : c_int = 0x02000; - pub const MAP_NORESERVE : c_int = 0x04000; - pub const MAP_POPULATE : c_int = 0x08000; - pub const MAP_NONBLOCK : c_int = 0x010000; - pub const MAP_STACK : c_int = 0x020000; - } - #[cfg(any(target_arch = "mips", - target_arch = "mipsel"))] - pub mod extra { - use types::os::arch::c95::c_int; - - pub const AF_PACKET : c_int = 17; - pub const IPPROTO_RAW : c_int = 255; - - pub const O_RSYNC : c_int = 16400; - pub const O_DSYNC : c_int = 16; - pub const O_NONBLOCK : c_int = 128; - pub const O_SYNC : c_int = 16400; - - pub const PROT_GROWSDOWN : c_int = 0x01000000; - pub const PROT_GROWSUP : c_int = 0x02000000; - - pub const MAP_TYPE : c_int = 0x000f; - pub const MAP_ANONYMOUS : c_int = 0x0800; - pub const MAP_GROWSDOWN : c_int = 0x01000; - pub const MAP_DENYWRITE : c_int = 0x02000; - pub const MAP_EXECUTABLE : c_int = 0x04000; - pub const MAP_LOCKED : c_int = 0x08000; - pub const MAP_NORESERVE : c_int = 0x0400; - pub const MAP_POPULATE : c_int = 0x010000; - pub const MAP_NONBLOCK : c_int = 0x020000; - pub const MAP_STACK : c_int = 0x040000; - } - #[cfg(target_os = "linux")] - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 0; - pub const _SC_CHILD_MAX : c_int = 1; - pub const _SC_CLK_TCK : c_int = 2; - pub const _SC_NGROUPS_MAX : c_int = 3; - pub const _SC_OPEN_MAX : c_int = 4; - pub const _SC_STREAM_MAX : c_int = 5; - pub const _SC_TZNAME_MAX : c_int = 6; - pub const _SC_JOB_CONTROL : c_int = 7; - pub const _SC_SAVED_IDS : c_int = 8; - pub const _SC_REALTIME_SIGNALS : c_int = 9; - pub const _SC_PRIORITY_SCHEDULING : c_int = 10; - pub const _SC_TIMERS : c_int = 11; - pub const _SC_ASYNCHRONOUS_IO : c_int = 12; - pub const _SC_PRIORITIZED_IO : c_int = 13; - pub const _SC_SYNCHRONIZED_IO : c_int = 14; - pub const _SC_FSYNC : c_int = 15; - pub const _SC_MAPPED_FILES : c_int = 16; - pub const _SC_MEMLOCK : c_int = 17; - pub const _SC_MEMLOCK_RANGE : c_int = 18; - pub const _SC_MEMORY_PROTECTION : c_int = 19; - pub const _SC_MESSAGE_PASSING : c_int = 20; - pub const _SC_SEMAPHORES : c_int = 21; - pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 22; - pub const _SC_AIO_LISTIO_MAX : c_int = 23; - pub const _SC_AIO_MAX : c_int = 24; - pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 25; - pub const _SC_DELAYTIMER_MAX : c_int = 26; - pub const _SC_MQ_OPEN_MAX : c_int = 27; - pub const _SC_VERSION : c_int = 29; - pub const _SC_PAGESIZE : c_int = 30; - pub const _SC_RTSIG_MAX : c_int = 31; - pub const _SC_SEM_NSEMS_MAX : c_int = 32; - pub const _SC_SEM_VALUE_MAX : c_int = 33; - pub const _SC_SIGQUEUE_MAX : c_int = 34; - pub const _SC_TIMER_MAX : c_int = 35; - pub const _SC_BC_BASE_MAX : c_int = 36; - pub const _SC_BC_DIM_MAX : c_int = 37; - pub const _SC_BC_SCALE_MAX : c_int = 38; - pub const _SC_BC_STRING_MAX : c_int = 39; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 40; - pub const _SC_EXPR_NEST_MAX : c_int = 42; - pub const _SC_LINE_MAX : c_int = 43; - pub const _SC_RE_DUP_MAX : c_int = 44; - pub const _SC_2_VERSION : c_int = 46; - pub const _SC_2_C_BIND : c_int = 47; - pub const _SC_2_C_DEV : c_int = 48; - pub const _SC_2_FORT_DEV : c_int = 49; - pub const _SC_2_FORT_RUN : c_int = 50; - pub const _SC_2_SW_DEV : c_int = 51; - pub const _SC_2_LOCALEDEF : c_int = 52; - pub const _SC_NPROCESSORS_ONLN : c_int = 84; - pub const _SC_2_CHAR_TERM : c_int = 95; - pub const _SC_2_C_VERSION : c_int = 96; - pub const _SC_2_UPE : c_int = 97; - pub const _SC_XBS5_ILP32_OFF32 : c_int = 125; - pub const _SC_XBS5_ILP32_OFFBIG : c_int = 126; - pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 128; - - } - #[cfg(target_os = "nacl")] - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub static _SC_SENDMSG_MAX_SIZE : c_int = 0; - pub static _SC_NPROCESSORS_ONLN : c_int = 1; - pub static _SC_PAGESIZE : c_int = 2; - } - - #[cfg(target_os = "android")] - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 0; - pub const _SC_BC_BASE_MAX : c_int = 1; - pub const _SC_BC_DIM_MAX : c_int = 2; - pub const _SC_BC_SCALE_MAX : c_int = 3; - pub const _SC_BC_STRING_MAX : c_int = 4; - pub const _SC_CHILD_MAX : c_int = 5; - pub const _SC_CLK_TCK : c_int = 6; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 7; - pub const _SC_EXPR_NEST_MAX : c_int = 8; - pub const _SC_LINE_MAX : c_int = 9; - pub const _SC_NGROUPS_MAX : c_int = 10; - pub const _SC_OPEN_MAX : c_int = 11; - pub const _SC_2_C_BIND : c_int = 13; - pub const _SC_2_C_DEV : c_int = 14; - pub const _SC_2_C_VERSION : c_int = 15; - pub const _SC_2_CHAR_TERM : c_int = 16; - pub const _SC_2_FORT_DEV : c_int = 17; - pub const _SC_2_FORT_RUN : c_int = 18; - pub const _SC_2_LOCALEDEF : c_int = 19; - pub const _SC_2_SW_DEV : c_int = 20; - pub const _SC_2_UPE : c_int = 21; - pub const _SC_2_VERSION : c_int = 22; - pub const _SC_JOB_CONTROL : c_int = 23; - pub const _SC_SAVED_IDS : c_int = 24; - pub const _SC_VERSION : c_int = 25; - pub const _SC_RE_DUP_MAX : c_int = 26; - pub const _SC_STREAM_MAX : c_int = 27; - pub const _SC_TZNAME_MAX : c_int = 28; - pub const _SC_PAGESIZE : c_int = 39; - } - } - - #[cfg(any(target_os = "freebsd", - target_os = "dragonfly"))] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 2147483647; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 2; - pub const _IOLBF : c_int = 1; - pub const BUFSIZ : c_uint = 1024; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 1024; - pub const L_tmpnam : c_uint = 1024; - pub const TMP_MAX : c_uint = 308915776; - } - pub mod c99 { - } - pub mod posix88 { - use types::common::c95::c_void; - use types::os::arch::c95::c_int; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 512; - pub const O_EXCL : c_int = 2048; - pub const O_NOCTTY : c_int = 32768; - pub const O_TRUNC : c_int = 1024; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x1000; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_SYNC : c_int = 0x0000; - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_INVALIDATE : c_int = 0x0002; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EDEADLK : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - pub const EAGAIN : c_int = 35; - pub const EWOULDBLOCK : c_int = 35; - pub const EINPROGRESS : c_int = 36; - pub const EALREADY : c_int = 37; - pub const ENOTSOCK : c_int = 38; - pub const EDESTADDRREQ : c_int = 39; - pub const EMSGSIZE : c_int = 40; - pub const EPROTOTYPE : c_int = 41; - pub const ENOPROTOOPT : c_int = 42; - pub const EPROTONOSUPPORT : c_int = 43; - pub const ESOCKTNOSUPPORT : c_int = 44; - pub const EOPNOTSUPP : c_int = 45; - pub const EPFNOSUPPORT : c_int = 46; - pub const EAFNOSUPPORT : c_int = 47; - pub const EADDRINUSE : c_int = 48; - pub const EADDRNOTAVAIL : c_int = 49; - pub const ENETDOWN : c_int = 50; - pub const ENETUNREACH : c_int = 51; - pub const ENETRESET : c_int = 52; - pub const ECONNABORTED : c_int = 53; - pub const ECONNRESET : c_int = 54; - pub const ENOBUFS : c_int = 55; - pub const EISCONN : c_int = 56; - pub const ENOTCONN : c_int = 57; - pub const ESHUTDOWN : c_int = 58; - pub const ETOOMANYREFS : c_int = 59; - pub const ETIMEDOUT : c_int = 60; - pub const ECONNREFUSED : c_int = 61; - pub const ELOOP : c_int = 62; - pub const ENAMETOOLONG : c_int = 63; - pub const EHOSTDOWN : c_int = 64; - pub const EHOSTUNREACH : c_int = 65; - pub const ENOTEMPTY : c_int = 66; - pub const EPROCLIM : c_int = 67; - pub const EUSERS : c_int = 68; - pub const EDQUOT : c_int = 69; - pub const ESTALE : c_int = 70; - pub const EREMOTE : c_int = 71; - pub const EBADRPC : c_int = 72; - pub const ERPCMISMATCH : c_int = 73; - pub const EPROGUNAVAIL : c_int = 74; - pub const EPROGMISMATCH : c_int = 75; - pub const EPROCUNAVAIL : c_int = 76; - pub const ENOLCK : c_int = 77; - pub const ENOSYS : c_int = 78; - pub const EFTYPE : c_int = 79; - pub const EAUTH : c_int = 80; - pub const ENEEDAUTH : c_int = 81; - pub const EIDRM : c_int = 82; - pub const ENOMSG : c_int = 83; - pub const EOVERFLOW : c_int = 84; - pub const ECANCELED : c_int = 85; - pub const EILSEQ : c_int = 86; - pub const ENOATTR : c_int = 87; - pub const EDOOFUS : c_int = 88; - pub const EBADMSG : c_int = 89; - pub const EMULTIHOP : c_int = 90; - pub const ENOLINK : c_int = 91; - pub const EPROTO : c_int = 92; - pub const ENOMEDIUM : c_int = 93; - pub const EUNUSED94 : c_int = 94; - pub const EUNUSED95 : c_int = 95; - pub const EUNUSED96 : c_int = 96; - pub const EUNUSED97 : c_int = 97; - pub const EUNUSED98 : c_int = 98; - pub const EASYNC : c_int = 99; - pub const ELAST : c_int = 99; - } - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - - pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; - - pub const GLOB_APPEND : c_int = 0x0001; - pub const GLOB_DOOFFS : c_int = 0x0002; - pub const GLOB_ERR : c_int = 0x0004; - pub const GLOB_MARK : c_int = 0x0008; - pub const GLOB_NOCHECK : c_int = 0x0010; - pub const GLOB_NOSORT : c_int = 0x0020; - pub const GLOB_NOESCAPE : c_int = 0x2000; - - pub const GLOB_NOSPACE : c_int = -1; - pub const GLOB_ABORTED : c_int = -2; - pub const GLOB_NOMATCH : c_int = -3; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_IOV_MAX : c_int = 56; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; - pub const _SC_LOGIN_NAME_MAX : c_int = 73; - pub const _SC_MQ_PRIO_MAX : c_int = 75; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; - pub const _SC_THREAD_KEYS_MAX : c_int = 86; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; - pub const _SC_THREAD_STACK_MIN : c_int = 93; - pub const _SC_THREAD_THREADS_MAX : c_int = 94; - pub const _SC_THREADS : c_int = 96; - pub const _SC_TTY_NAME_MAX : c_int = 101; - pub const _SC_ATEXIT_MAX : c_int = 107; - pub const _SC_XOPEN_CRYPT : c_int = 108; - pub const _SC_XOPEN_ENH_I18N : c_int = 109; - pub const _SC_XOPEN_LEGACY : c_int = 110; - pub const _SC_XOPEN_REALTIME : c_int = 111; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; - pub const _SC_XOPEN_SHM : c_int = 113; - pub const _SC_XOPEN_UNIX : c_int = 115; - pub const _SC_XOPEN_VERSION : c_int = 116; - pub const _SC_XOPEN_XCU_VERSION : c_int = 117; - - pub const PTHREAD_CREATE_JOINABLE: c_int = 0; - pub const PTHREAD_CREATE_DETACHED: c_int = 1; - - #[cfg(target_arch = "arm")] - pub const PTHREAD_STACK_MIN: size_t = 4096; - - #[cfg(all(target_os = "freebsd", - any(target_arch = "mips", - target_arch = "mipsel", - target_arch = "x86", - target_arch = "x86_64")))] - pub const PTHREAD_STACK_MIN: size_t = 2048; - - #[cfg(target_os = "dragonfly")] - pub const PTHREAD_STACK_MIN: size_t = 1024; - - pub const CLOCK_REALTIME: c_int = 0; - pub const CLOCK_MONOTONIC: c_int = 4; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_RSS: c_int = 5; - pub const RLIMIT_MEMLOCK: c_int = 6; - pub const RLIMIT_NPROC: c_int = 7; - pub const RLIMIT_NOFILE: c_int = 8; - pub const RLIMIT_SBSIZE: c_int = 9; - pub const RLIMIT_VMEM: c_int = 10; - pub const RLIMIT_AS: c_int = RLIMIT_VMEM; - pub const RLIMIT_NPTS: c_int = 11; - pub const RLIMIT_SWAP: c_int = 12; - pub const RLIMIT_KQUEUES: c_int = 13; - - pub const RLIM_NLIMITS: rlim_t = 14; - pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - pub const RUSAGE_THREAD: c_int = 1; - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_FREE : c_int = 5; - pub const MADV_NOSYNC : c_int = 6; - pub const MADV_AUTOSYNC : c_int = 7; - pub const MADV_NOCORE : c_int = 8; - pub const MADV_CORE : c_int = 9; - pub const MADV_PROTECT : c_int = 10; - - pub const MINCORE_INCORE : c_int = 0x1; - pub const MINCORE_REFERENCED : c_int = 0x2; - pub const MINCORE_MODIFIED : c_int = 0x4; - pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; - pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; - pub const MINCORE_SUPER : c_int = 0x20; - - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 28; - pub const AF_UNIX: c_int = 1; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 12; - pub const IPV6_DROP_MEMBERSHIP: c_int = 13; - - pub const TCP_NODELAY: c_int = 1; - pub const TCP_KEEPIDLE: c_int = 256; - pub const SOL_SOCKET: c_int = 0xffff; - pub const SO_DEBUG: c_int = 0x01; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_REUSEPORT: c_int = 0x0200; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 0x8; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - pub mod extra { - use types::os::arch::c95::c_int; - - pub const O_SYNC : c_int = 128; - pub const O_NONBLOCK : c_int = 4; - pub const CTL_KERN: c_int = 1; - pub const KERN_PROC: c_int = 14; - #[cfg(target_os = "freebsd")] - pub const KERN_PROC_PATHNAME: c_int = 12; - #[cfg(target_os = "dragonfly")] - pub const KERN_PROC_PATHNAME: c_int = 9; - - pub const MAP_COPY : c_int = 0x0002; - pub const MAP_RENAME : c_int = 0x0020; - pub const MAP_NORESERVE : c_int = 0x0040; - pub const MAP_HASSEMAPHORE : c_int = 0x0200; - pub const MAP_STACK : c_int = 0x0400; - pub const MAP_NOSYNC : c_int = 0x0800; - pub const MAP_NOCORE : c_int = 0x020000; - - pub const IPPROTO_RAW : c_int = 255; - } - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 1; - pub const _SC_CHILD_MAX : c_int = 2; - pub const _SC_CLK_TCK : c_int = 3; - pub const _SC_NGROUPS_MAX : c_int = 4; - pub const _SC_OPEN_MAX : c_int = 5; - pub const _SC_JOB_CONTROL : c_int = 6; - pub const _SC_SAVED_IDS : c_int = 7; - pub const _SC_VERSION : c_int = 8; - pub const _SC_BC_BASE_MAX : c_int = 9; - pub const _SC_BC_DIM_MAX : c_int = 10; - pub const _SC_BC_SCALE_MAX : c_int = 11; - pub const _SC_BC_STRING_MAX : c_int = 12; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; - pub const _SC_EXPR_NEST_MAX : c_int = 14; - pub const _SC_LINE_MAX : c_int = 15; - pub const _SC_RE_DUP_MAX : c_int = 16; - pub const _SC_2_VERSION : c_int = 17; - pub const _SC_2_C_BIND : c_int = 18; - pub const _SC_2_C_DEV : c_int = 19; - pub const _SC_2_CHAR_TERM : c_int = 20; - pub const _SC_2_FORT_DEV : c_int = 21; - pub const _SC_2_FORT_RUN : c_int = 22; - pub const _SC_2_LOCALEDEF : c_int = 23; - pub const _SC_2_SW_DEV : c_int = 24; - pub const _SC_2_UPE : c_int = 25; - pub const _SC_STREAM_MAX : c_int = 26; - pub const _SC_TZNAME_MAX : c_int = 27; - pub const _SC_ASYNCHRONOUS_IO : c_int = 28; - pub const _SC_MAPPED_FILES : c_int = 29; - pub const _SC_MEMLOCK : c_int = 30; - pub const _SC_MEMLOCK_RANGE : c_int = 31; - pub const _SC_MEMORY_PROTECTION : c_int = 32; - pub const _SC_MESSAGE_PASSING : c_int = 33; - pub const _SC_PRIORITIZED_IO : c_int = 34; - pub const _SC_PRIORITY_SCHEDULING : c_int = 35; - pub const _SC_REALTIME_SIGNALS : c_int = 36; - pub const _SC_SEMAPHORES : c_int = 37; - pub const _SC_FSYNC : c_int = 38; - pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; - pub const _SC_SYNCHRONIZED_IO : c_int = 40; - pub const _SC_TIMERS : c_int = 41; - pub const _SC_AIO_LISTIO_MAX : c_int = 42; - pub const _SC_AIO_MAX : c_int = 43; - pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; - pub const _SC_DELAYTIMER_MAX : c_int = 45; - pub const _SC_MQ_OPEN_MAX : c_int = 46; - pub const _SC_PAGESIZE : c_int = 47; - pub const _SC_RTSIG_MAX : c_int = 48; - pub const _SC_SEM_NSEMS_MAX : c_int = 49; - pub const _SC_SEM_VALUE_MAX : c_int = 50; - pub const _SC_SIGQUEUE_MAX : c_int = 51; - pub const _SC_TIMER_MAX : c_int = 52; - } - } - - #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 2147483647; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 2; - pub const _IOLBF : c_int = 1; - pub const BUFSIZ : c_uint = 1024; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 1024; - pub const L_tmpnam : c_uint = 1024; - pub const TMP_MAX : c_uint = 308915776; - } - pub mod c99 { - } - pub mod posix88 { - use types::common::c95::c_void; - use types::os::arch::c95::c_int; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 512; - pub const O_EXCL : c_int = 2048; - pub const O_NOCTTY : c_int = 32768; - pub const O_TRUNC : c_int = 1024; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x1000; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_SYNC : c_int = 0x0002; - pub const MS_INVALIDATE : c_int = 0x0004; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EDEADLK : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - pub const EAGAIN : c_int = 35; - pub const EWOULDBLOCK : c_int = 35; - pub const EINPROGRESS : c_int = 36; - pub const EALREADY : c_int = 37; - pub const ENOTSOCK : c_int = 38; - pub const EDESTADDRREQ : c_int = 39; - pub const EMSGSIZE : c_int = 40; - pub const EPROTOTYPE : c_int = 41; - pub const ENOPROTOOPT : c_int = 42; - pub const EPROTONOSUPPORT : c_int = 43; - pub const ESOCKTNOSUPPORT : c_int = 44; - pub const EOPNOTSUPP : c_int = 45; - pub const EPFNOSUPPORT : c_int = 46; - pub const EAFNOSUPPORT : c_int = 47; - pub const EADDRINUSE : c_int = 48; - pub const EADDRNOTAVAIL : c_int = 49; - pub const ENETDOWN : c_int = 50; - pub const ENETUNREACH : c_int = 51; - pub const ENETRESET : c_int = 52; - pub const ECONNABORTED : c_int = 53; - pub const ECONNRESET : c_int = 54; - pub const ENOBUFS : c_int = 55; - pub const EISCONN : c_int = 56; - pub const ENOTCONN : c_int = 57; - pub const ESHUTDOWN : c_int = 58; - pub const ETOOMANYREFS : c_int = 59; - pub const ETIMEDOUT : c_int = 60; - pub const ECONNREFUSED : c_int = 61; - pub const ELOOP : c_int = 62; - pub const ENAMETOOLONG : c_int = 63; - pub const EHOSTDOWN : c_int = 64; - pub const EHOSTUNREACH : c_int = 65; - pub const ENOTEMPTY : c_int = 66; - pub const EPROCLIM : c_int = 67; - pub const EUSERS : c_int = 68; - pub const EDQUOT : c_int = 69; - pub const ESTALE : c_int = 70; - pub const EREMOTE : c_int = 71; - pub const EBADRPC : c_int = 72; - pub const ERPCMISMATCH : c_int = 73; - pub const EPROGUNAVAIL : c_int = 74; - pub const EPROGMISMATCH : c_int = 75; - pub const EPROCUNAVAIL : c_int = 76; - pub const ENOLCK : c_int = 77; - pub const ENOSYS : c_int = 78; - pub const EFTYPE : c_int = 79; - pub const EAUTH : c_int = 80; - pub const ENEEDAUTH : c_int = 81; - pub const EIPSEC : c_int = 82; - pub const ENOATTR : c_int = 83; - pub const EILSEQ : c_int = 84; - pub const ENOMEDIUM : c_int = 85; - pub const EMEDIUMTYPE : c_int = 86; - pub const EOVERFLOW : c_int = 87; - pub const ECANCELED : c_int = 88; - pub const EIDRM : c_int = 89; - pub const ENOMSG : c_int = 90; - pub const ENOTSUP : c_int = 91; - pub const ELAST : c_int = 91; // must be equal to largest errno - } - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - pub const F_GETOWN : c_int = 5; - pub const F_SETOWN : c_int = 6; - pub const F_GETLK : c_int = 7; - pub const F_SETLK : c_int = 8; - pub const F_SETLKW : c_int = 9; - pub const F_DUPFD_CLOEXEC : c_int = 10; - - pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; - - pub const GLOB_APPEND : c_int = 0x0001; - pub const GLOB_DOOFFS : c_int = 0x0002; - pub const GLOB_ERR : c_int = 0x0004; - pub const GLOB_MARK : c_int = 0x0008; - pub const GLOB_NOCHECK : c_int = 0x0010; - pub const GLOB_NOSORT : c_int = 0x0020; - pub const GLOB_NOESCAPE : c_int = 0x1000; - - pub const GLOB_NOSPACE : c_int = -1; - pub const GLOB_ABORTED : c_int = -2; - pub const GLOB_NOMATCH : c_int = -3; - pub const GLOB_NOSYS : c_int = -4; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_IOV_MAX : c_int = 51; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 100; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 101; - pub const _SC_LOGIN_NAME_MAX : c_int = 102; - pub const _SC_MQ_PRIO_MAX : c_int = 59; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80; - pub const _SC_THREAD_KEYS_MAX : c_int = 81; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 82; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 83; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 85; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103; - pub const _SC_THREAD_STACK_MIN : c_int = 89; - pub const _SC_THREAD_THREADS_MAX : c_int = 90; - pub const _SC_THREADS : c_int = 91; - pub const _SC_TTY_NAME_MAX : c_int = 107; - pub const _SC_ATEXIT_MAX : c_int = 46; - pub const _SC_XOPEN_CRYPT : c_int = 117; - pub const _SC_XOPEN_ENH_I18N : c_int = 118; - pub const _SC_XOPEN_LEGACY : c_int = 119; - pub const _SC_XOPEN_REALTIME : c_int = 120; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121; - pub const _SC_XOPEN_SHM : c_int = 30; - pub const _SC_XOPEN_UNIX : c_int = 123; - pub const _SC_XOPEN_VERSION : c_int = 125; - - pub const PTHREAD_CREATE_JOINABLE : c_int = 0; - pub const PTHREAD_CREATE_DETACHED : c_int = 1; - pub const PTHREAD_STACK_MIN : size_t = 2048; - - pub const CLOCK_REALTIME : c_int = 0; - pub const CLOCK_MONOTONIC : c_int = 3; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_RSS: c_int = 5; - pub const RLIMIT_MEMLOCK: c_int = 6; - pub const RLIMIT_NPROC: c_int = 7; - pub const RLIMIT_NOFILE: c_int = 8; - pub const RLIM_NLIMITS: c_int = 9; - - pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; - pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; - pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - pub const RUSAGE_THREAD: c_int = 1; - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_FREE : c_int = 6; - - pub const AF_UNIX: c_int = 1; - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 24; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist - pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist - - pub const TCP_NODELAY: c_int = 0x01; - pub const SOL_SOCKET: c_int = 0xffff; - pub const SO_DEBUG: c_int = 0x01; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_REUSEPORT: c_int = 0x0200; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 0x8; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - pub mod extra { - use types::os::arch::c95::c_int; - - pub const O_DSYNC : c_int = 128; // same as SYNC - pub const O_SYNC : c_int = 128; - pub const O_NONBLOCK : c_int = 4; - pub const CTL_KERN : c_int = 1; - pub const KERN_PROC : c_int = 66; - - pub const MAP_COPY : c_int = 0x0002; - pub const MAP_RENAME : c_int = 0x0000; - pub const MAP_NORESERVE : c_int = 0x0000; - pub const MAP_NOEXTEND : c_int = 0x0000; - pub const MAP_HASSEMAPHORE : c_int = 0x0000; - - pub const IPPROTO_RAW : c_int = 255; - - pub const PATH_MAX: c_int = 1024; - } - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 1; - pub const _SC_CHILD_MAX : c_int = 2; - pub const _SC_CLK_TCK : c_int = 3; - pub const _SC_NGROUPS_MAX : c_int = 4; - pub const _SC_OPEN_MAX : c_int = 5; - pub const _SC_JOB_CONTROL : c_int = 6; - pub const _SC_SAVED_IDS : c_int = 7; - pub const _SC_VERSION : c_int = 8; - pub const _SC_BC_BASE_MAX : c_int = 9; - pub const _SC_BC_DIM_MAX : c_int = 10; - pub const _SC_BC_SCALE_MAX : c_int = 11; - pub const _SC_BC_STRING_MAX : c_int = 12; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; - pub const _SC_EXPR_NEST_MAX : c_int = 14; - pub const _SC_LINE_MAX : c_int = 15; - pub const _SC_RE_DUP_MAX : c_int = 16; - pub const _SC_2_VERSION : c_int = 17; - pub const _SC_2_C_BIND : c_int = 18; - pub const _SC_2_C_DEV : c_int = 19; - pub const _SC_2_CHAR_TERM : c_int = 20; - pub const _SC_2_FORT_DEV : c_int = 21; - pub const _SC_2_FORT_RUN : c_int = 22; - pub const _SC_2_LOCALEDEF : c_int = 23; - pub const _SC_2_SW_DEV : c_int = 24; - pub const _SC_2_UPE : c_int = 25; - pub const _SC_STREAM_MAX : c_int = 26; - pub const _SC_TZNAME_MAX : c_int = 27; - pub const _SC_PAGESIZE : c_int = 28; - pub const _SC_FSYNC : c_int = 29; - pub const _SC_SEM_NSEMS_MAX : c_int = 31; - pub const _SC_SEM_VALUE_MAX : c_int = 32; - pub const _SC_AIO_LISTIO_MAX : c_int = 42; - pub const _SC_AIO_MAX : c_int = 43; - pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; - pub const _SC_ASYNCHRONOUS_IO : c_int = 45; - pub const _SC_DELAYTIMER_MAX : c_int = 50; - pub const _SC_MAPPED_FILES : c_int = 53; - pub const _SC_MEMLOCK : c_int = 54; - pub const _SC_MEMLOCK_RANGE : c_int = 55; - pub const _SC_MEMORY_PROTECTION : c_int = 56; - pub const _SC_MESSAGE_PASSING : c_int = 57; - pub const _SC_MQ_OPEN_MAX : c_int = 58; - pub const _SC_PRIORITIZED_IO : c_int = 60; - pub const _SC_PRIORITY_SCHEDULING : c_int = 61; - pub const _SC_REALTIME_SIGNALS : c_int = 64; - pub const _SC_RTSIG_MAX : c_int = 66; - pub const _SC_SEMAPHORES : c_int = 67; - pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68; - pub const _SC_SIGQUEUE_MAX : c_int = 70; - pub const _SC_SYNCHRONIZED_IO : c_int = 75; - pub const _SC_TIMER_MAX : c_int = 93; - pub const _SC_TIMERS : c_int = 94; - } - } - - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 2147483647; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 2; - pub const _IOLBF : c_int = 1; - pub const BUFSIZ : c_uint = 1024; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 1024; - pub const L_tmpnam : c_uint = 1024; - pub const TMP_MAX : c_uint = 308915776; - } - pub mod c99 { - } - pub mod posix88 { - use types::common::c95::c_void; - use types::os::arch::c95::c_int; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 512; - pub const O_EXCL : c_int = 2048; - pub const O_NOCTTY : c_int = 131072; - pub const O_TRUNC : c_int = 1024; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x1000; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_INVALIDATE : c_int = 0x0002; - pub const MS_SYNC : c_int = 0x0010; - - pub const MS_KILLPAGES : c_int = 0x0004; - pub const MS_DEACTIVATE : c_int = 0x0008; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EDEADLK : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - pub const EAGAIN : c_int = 35; - pub const EWOULDBLOCK : c_int = EAGAIN; - pub const EINPROGRESS : c_int = 36; - pub const EALREADY : c_int = 37; - pub const ENOTSOCK : c_int = 38; - pub const EDESTADDRREQ : c_int = 39; - pub const EMSGSIZE : c_int = 40; - pub const EPROTOTYPE : c_int = 41; - pub const ENOPROTOOPT : c_int = 42; - pub const EPROTONOSUPPORT : c_int = 43; - pub const ESOCKTNOSUPPORT : c_int = 44; - pub const ENOTSUP : c_int = 45; - pub const EPFNOSUPPORT : c_int = 46; - pub const EAFNOSUPPORT : c_int = 47; - pub const EADDRINUSE : c_int = 48; - pub const EADDRNOTAVAIL : c_int = 49; - pub const ENETDOWN : c_int = 50; - pub const ENETUNREACH : c_int = 51; - pub const ENETRESET : c_int = 52; - pub const ECONNABORTED : c_int = 53; - pub const ECONNRESET : c_int = 54; - pub const ENOBUFS : c_int = 55; - pub const EISCONN : c_int = 56; - pub const ENOTCONN : c_int = 57; - pub const ESHUTDOWN : c_int = 58; - pub const ETOOMANYREFS : c_int = 59; - pub const ETIMEDOUT : c_int = 60; - pub const ECONNREFUSED : c_int = 61; - pub const ELOOP : c_int = 62; - pub const ENAMETOOLONG : c_int = 63; - pub const EHOSTDOWN : c_int = 64; - pub const EHOSTUNREACH : c_int = 65; - pub const ENOTEMPTY : c_int = 66; - pub const EPROCLIM : c_int = 67; - pub const EUSERS : c_int = 68; - pub const EDQUOT : c_int = 69; - pub const ESTALE : c_int = 70; - pub const EREMOTE : c_int = 71; - pub const EBADRPC : c_int = 72; - pub const ERPCMISMATCH : c_int = 73; - pub const EPROGUNAVAIL : c_int = 74; - pub const EPROGMISMATCH : c_int = 75; - pub const EPROCUNAVAIL : c_int = 76; - pub const ENOLCK : c_int = 77; - pub const ENOSYS : c_int = 78; - pub const EFTYPE : c_int = 79; - pub const EAUTH : c_int = 80; - pub const ENEEDAUTH : c_int = 81; - pub const EPWROFF : c_int = 82; - pub const EDEVERR : c_int = 83; - pub const EOVERFLOW : c_int = 84; - pub const EBADEXEC : c_int = 85; - pub const EBADARCH : c_int = 86; - pub const ESHLIBVERS : c_int = 87; - pub const EBADMACHO : c_int = 88; - pub const ECANCELED : c_int = 89; - pub const EIDRM : c_int = 90; - pub const ENOMSG : c_int = 91; - pub const EILSEQ : c_int = 92; - pub const ENOATTR : c_int = 93; - pub const EBADMSG : c_int = 94; - pub const EMULTIHOP : c_int = 95; - pub const ENODATA : c_int = 96; - pub const ENOLINK : c_int = 97; - pub const ENOSR : c_int = 98; - pub const ENOSTR : c_int = 99; - pub const EPROTO : c_int = 100; - pub const ETIME : c_int = 101; - pub const EOPNOTSUPP : c_int = 102; - pub const ENOPOLICY : c_int = 103; - pub const ENOTRECOVERABLE : c_int = 104; - pub const EOWNERDEAD : c_int = 105; - pub const EQFULL : c_int = 106; - pub const ELAST : c_int = 106; - } - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - - pub const O_ACCMODE : c_int = 3; - - pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; - - pub const GLOB_APPEND : c_int = 0x0001; - pub const GLOB_DOOFFS : c_int = 0x0002; - pub const GLOB_ERR : c_int = 0x0004; - pub const GLOB_MARK : c_int = 0x0008; - pub const GLOB_NOCHECK : c_int = 0x0010; - pub const GLOB_NOSORT : c_int = 0x0020; - pub const GLOB_NOESCAPE : c_int = 0x2000; - - pub const GLOB_NOSPACE : c_int = -1; - pub const GLOB_ABORTED : c_int = -2; - pub const GLOB_NOMATCH : c_int = -3; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_IOV_MAX : c_int = 56; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; - pub const _SC_LOGIN_NAME_MAX : c_int = 73; - pub const _SC_MQ_PRIO_MAX : c_int = 75; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; - pub const _SC_THREAD_KEYS_MAX : c_int = 86; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; - pub const _SC_THREAD_STACK_MIN : c_int = 93; - pub const _SC_THREAD_THREADS_MAX : c_int = 94; - pub const _SC_THREADS : c_int = 96; - pub const _SC_TTY_NAME_MAX : c_int = 101; - pub const _SC_ATEXIT_MAX : c_int = 107; - pub const _SC_XOPEN_CRYPT : c_int = 108; - pub const _SC_XOPEN_ENH_I18N : c_int = 109; - pub const _SC_XOPEN_LEGACY : c_int = 110; - pub const _SC_XOPEN_REALTIME : c_int = 111; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; - pub const _SC_XOPEN_SHM : c_int = 113; - pub const _SC_XOPEN_UNIX : c_int = 115; - pub const _SC_XOPEN_VERSION : c_int = 116; - pub const _SC_XOPEN_XCU_VERSION : c_int = 121; - - pub const PTHREAD_CREATE_JOINABLE: c_int = 1; - pub const PTHREAD_CREATE_DETACHED: c_int = 2; - pub const PTHREAD_STACK_MIN: size_t = 8192; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_AS: c_int = 5; - pub const RLIMIT_MEMLOCK: c_int = 6; - pub const RLIMIT_NPROC: c_int = 7; - pub const RLIMIT_NOFILE: c_int = 8; - pub const RLIM_NLIMITS: c_int = 9; - pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; - - pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_FREE : c_int = 5; - pub const MADV_ZERO_WIRED_PAGES : c_int = 6; - pub const MADV_FREE_REUSABLE : c_int = 7; - pub const MADV_FREE_REUSE : c_int = 8; - pub const MADV_CAN_REUSE : c_int = 9; - - pub const MINCORE_INCORE : c_int = 0x1; - pub const MINCORE_REFERENCED : c_int = 0x2; - pub const MINCORE_MODIFIED : c_int = 0x4; - pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; - pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; - - pub const AF_UNIX: c_int = 1; - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 30; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_JOIN_GROUP: c_int = 12; - pub const IPV6_LEAVE_GROUP: c_int = 13; - - pub const TCP_NODELAY: c_int = 0x01; - pub const TCP_KEEPALIVE: c_int = 0x10; - pub const SOL_SOCKET: c_int = 0xffff; - - pub const SO_DEBUG: c_int = 0x01; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_REUSEPORT: c_int = 0x0200; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 0x8; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - pub mod extra { - use types::os::arch::c95::c_int; - - pub const O_DSYNC : c_int = 4194304; - pub const O_SYNC : c_int = 128; - pub const O_NONBLOCK : c_int = 4; - pub const F_GETPATH : c_int = 50; - pub const F_FULLFSYNC : c_int = 51; - - pub const MAP_COPY : c_int = 0x0002; - pub const MAP_RENAME : c_int = 0x0020; - pub const MAP_NORESERVE : c_int = 0x0040; - pub const MAP_NOEXTEND : c_int = 0x0100; - pub const MAP_HASSEMAPHORE : c_int = 0x0200; - pub const MAP_NOCACHE : c_int = 0x0400; - pub const MAP_JIT : c_int = 0x0800; - - pub const IPPROTO_RAW : c_int = 255; - - pub const SO_NREAD: c_int = 0x1020; - pub const SO_NKE: c_int = 0x1021; - pub const SO_NOSIGPIPE: c_int = 0x1022; - pub const SO_NOADDRERR: c_int = 0x1023; - pub const SO_NWRITE: c_int = 0x1024; - pub const SO_DONTTRUNC: c_int = 0x2000; - pub const SO_WANTMORE: c_int = 0x4000; - pub const SO_WANTOOBFLAG: c_int = 0x8000; - - pub const PATH_MAX: c_int = 1024; - } - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 1; - pub const _SC_CHILD_MAX : c_int = 2; - pub const _SC_CLK_TCK : c_int = 3; - pub const _SC_NGROUPS_MAX : c_int = 4; - pub const _SC_OPEN_MAX : c_int = 5; - pub const _SC_JOB_CONTROL : c_int = 6; - pub const _SC_SAVED_IDS : c_int = 7; - pub const _SC_VERSION : c_int = 8; - pub const _SC_BC_BASE_MAX : c_int = 9; - pub const _SC_BC_DIM_MAX : c_int = 10; - pub const _SC_BC_SCALE_MAX : c_int = 11; - pub const _SC_BC_STRING_MAX : c_int = 12; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; - pub const _SC_EXPR_NEST_MAX : c_int = 14; - pub const _SC_LINE_MAX : c_int = 15; - pub const _SC_RE_DUP_MAX : c_int = 16; - pub const _SC_2_VERSION : c_int = 17; - pub const _SC_2_C_BIND : c_int = 18; - pub const _SC_2_C_DEV : c_int = 19; - pub const _SC_2_CHAR_TERM : c_int = 20; - pub const _SC_2_FORT_DEV : c_int = 21; - pub const _SC_2_FORT_RUN : c_int = 22; - pub const _SC_2_LOCALEDEF : c_int = 23; - pub const _SC_2_SW_DEV : c_int = 24; - pub const _SC_2_UPE : c_int = 25; - pub const _SC_STREAM_MAX : c_int = 26; - pub const _SC_TZNAME_MAX : c_int = 27; - pub const _SC_ASYNCHRONOUS_IO : c_int = 28; - pub const _SC_PAGESIZE : c_int = 29; - pub const _SC_MEMLOCK : c_int = 30; - pub const _SC_MEMLOCK_RANGE : c_int = 31; - pub const _SC_MEMORY_PROTECTION : c_int = 32; - pub const _SC_MESSAGE_PASSING : c_int = 33; - pub const _SC_PRIORITIZED_IO : c_int = 34; - pub const _SC_PRIORITY_SCHEDULING : c_int = 35; - pub const _SC_REALTIME_SIGNALS : c_int = 36; - pub const _SC_SEMAPHORES : c_int = 37; - pub const _SC_FSYNC : c_int = 38; - pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; - pub const _SC_SYNCHRONIZED_IO : c_int = 40; - pub const _SC_TIMERS : c_int = 41; - pub const _SC_AIO_LISTIO_MAX : c_int = 42; - pub const _SC_AIO_MAX : c_int = 43; - pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; - pub const _SC_DELAYTIMER_MAX : c_int = 45; - pub const _SC_MQ_OPEN_MAX : c_int = 46; - pub const _SC_MAPPED_FILES : c_int = 47; - pub const _SC_RTSIG_MAX : c_int = 48; - pub const _SC_SEM_NSEMS_MAX : c_int = 49; - pub const _SC_SEM_VALUE_MAX : c_int = 50; - pub const _SC_SIGQUEUE_MAX : c_int = 51; - pub const _SC_TIMER_MAX : c_int = 52; - pub const _SC_NPROCESSORS_CONF : c_int = 57; - pub const _SC_NPROCESSORS_ONLN : c_int = 58; - pub const _SC_2_PBS : c_int = 59; - pub const _SC_2_PBS_ACCOUNTING : c_int = 60; - pub const _SC_2_PBS_CHECKPOINT : c_int = 61; - pub const _SC_2_PBS_LOCATE : c_int = 62; - pub const _SC_2_PBS_MESSAGE : c_int = 63; - pub const _SC_2_PBS_TRACK : c_int = 64; - pub const _SC_ADVISORY_INFO : c_int = 65; - pub const _SC_BARRIERS : c_int = 66; - pub const _SC_CLOCK_SELECTION : c_int = 67; - pub const _SC_CPUTIME : c_int = 68; - pub const _SC_FILE_LOCKING : c_int = 69; - pub const _SC_HOST_NAME_MAX : c_int = 72; - pub const _SC_MONOTONIC_CLOCK : c_int = 74; - pub const _SC_READER_WRITER_LOCKS : c_int = 76; - pub const _SC_REGEXP : c_int = 77; - pub const _SC_SHELL : c_int = 78; - pub const _SC_SPAWN : c_int = 79; - pub const _SC_SPIN_LOCKS : c_int = 80; - pub const _SC_SPORADIC_SERVER : c_int = 81; - pub const _SC_THREAD_CPUTIME : c_int = 84; - pub const _SC_THREAD_SPORADIC_SERVER : c_int = 92; - pub const _SC_TIMEOUTS : c_int = 95; - pub const _SC_TRACE : c_int = 97; - pub const _SC_TRACE_EVENT_FILTER : c_int = 98; - pub const _SC_TRACE_INHERIT : c_int = 99; - pub const _SC_TRACE_LOG : c_int = 100; - pub const _SC_TYPED_MEMORY_OBJECTS : c_int = 102; - pub const _SC_V6_ILP32_OFF32 : c_int = 103; - pub const _SC_V6_ILP32_OFFBIG : c_int = 104; - pub const _SC_V6_LP64_OFF64 : c_int = 105; - pub const _SC_V6_LPBIG_OFFBIG : c_int = 106; - pub const _SC_IPV6 : c_int = 118; - pub const _SC_RAW_SOCKETS : c_int = 119; - pub const _SC_SYMLOOP_MAX : c_int = 120; - pub const _SC_PAGE_SIZE : c_int = _SC_PAGESIZE; - pub const _SC_XOPEN_STREAMS : c_int = 114; - pub const _SC_XBS5_ILP32_OFF32 : c_int = 122; - pub const _SC_XBS5_ILP32_OFFBIG : c_int = 123; - pub const _SC_XBS5_LP64_OFF64 : c_int = 124; - pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 125; - pub const _SC_SS_REPL_MAX : c_int = 126; - pub const _SC_TRACE_EVENT_NAME_MAX : c_int = 127; - pub const _SC_TRACE_NAME_MAX : c_int = 128; - pub const _SC_TRACE_SYS_MAX : c_int = 129; - pub const _SC_TRACE_USER_EVENT_MAX : c_int = 130; - pub const _SC_PASS_MAX : c_int = 131; - } - } -} - - -pub mod funcs { - // Thankfully most of c95 is universally available and does not vary by OS - // or anything. The same is not true of POSIX. - - pub mod c95 { - pub mod ctype { - use types::os::arch::c95::c_int; - - extern { - pub fn isalnum(c: c_int) -> c_int; - pub fn isalpha(c: c_int) -> c_int; - pub fn iscntrl(c: c_int) -> c_int; - pub fn isdigit(c: c_int) -> c_int; - pub fn isgraph(c: c_int) -> c_int; - pub fn islower(c: c_int) -> c_int; - pub fn isprint(c: c_int) -> c_int; - pub fn ispunct(c: c_int) -> c_int; - pub fn isspace(c: c_int) -> c_int; - pub fn isupper(c: c_int) -> c_int; - pub fn isxdigit(c: c_int) -> c_int; - pub fn tolower(c: c_int) -> c_int; - pub fn toupper(c: c_int) -> c_int; - } - } - - pub mod stdio { - use types::common::c95::{FILE, c_void, fpos_t}; - use types::os::arch::c95::{c_char, c_int, c_long, size_t}; - - extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fopen$UNIX2003")] - pub fn fopen(filename: *const c_char, - mode: *const c_char) -> *mut FILE; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "freopen$UNIX2003")] - pub fn freopen(filename: *const c_char, mode: *const c_char, - file: *mut FILE) - -> *mut FILE; - pub fn fflush(file: *mut FILE) -> c_int; - pub fn fclose(file: *mut FILE) -> c_int; - pub fn remove(filename: *const c_char) -> c_int; - pub fn rename(oldname: *const c_char, - newname: *const c_char) -> c_int; - pub fn tmpfile() -> *mut FILE; - pub fn setvbuf(stream: *mut FILE, - buffer: *mut c_char, - mode: c_int, - size: size_t) - -> c_int; - pub fn setbuf(stream: *mut FILE, buf: *mut c_char); - // Omitted: printf and scanf variants. - pub fn fgetc(stream: *mut FILE) -> c_int; - pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) - -> *mut c_char; - pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fputs$UNIX2003")] - pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; - // Omitted: getc, getchar (might be macros). - - // Omitted: gets, so ridiculously unsafe that it should not - // survive. - - // Omitted: putc, putchar (might be macros). - pub fn puts(s: *const c_char) -> c_int; - pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; - pub fn fread(ptr: *mut c_void, - size: size_t, - nobj: size_t, - stream: *mut FILE) - -> size_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fwrite$UNIX2003")] - pub fn fwrite(ptr: *const c_void, - size: size_t, - nobj: size_t, - stream: *mut FILE) - -> size_t; - pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) - -> c_int; - pub fn ftell(stream: *mut FILE) -> c_long; - pub fn rewind(stream: *mut FILE); - pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; - pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; - pub fn feof(stream: *mut FILE) -> c_int; - pub fn ferror(stream: *mut FILE) -> c_int; - pub fn perror(s: *const c_char); - } - } - - pub mod stdlib { - use types::common::c95::c_void; - use types::os::arch::c95::{c_char, c_double, c_int}; - use types::os::arch::c95::{c_long, c_uint, c_ulong}; - use types::os::arch::c95::{size_t}; - - extern { - pub fn abs(i: c_int) -> c_int; - pub fn labs(i: c_long) -> c_long; - // Omitted: div, ldiv (return pub type incomplete). - pub fn atof(s: *const c_char) -> c_double; - pub fn atoi(s: *const c_char) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "strtod$UNIX2003")] - pub fn strtod(s: *const c_char, - endp: *mut *mut c_char) -> c_double; - pub fn strtol(s: *const c_char, - endp: *mut *mut c_char, base: c_int) -> c_long; - pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, - base: c_int) -> c_ulong; - pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; - pub fn malloc(size: size_t) -> *mut c_void; - pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; - pub fn free(p: *mut c_void); - pub fn exit(status: c_int) -> !; - pub fn _exit(status: c_int) -> !; - pub fn atexit(cb: extern fn()) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "system$UNIX2003")] - pub fn system(s: *const c_char) -> c_int; - pub fn getenv(s: *const c_char) -> *mut c_char; - // Omitted: bsearch, qsort - pub fn rand() -> c_int; - pub fn srand(seed: c_uint); - } - } - - pub mod string { - use types::common::c95::c_void; - use types::os::arch::c95::{c_char, c_int, size_t}; - use types::os::arch::c95::{wchar_t}; - - extern { - pub fn strcpy(dst: *mut c_char, - src: *const c_char) -> *mut c_char; - pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) - -> *mut c_char; - pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; - pub fn strncat(s: *mut c_char, ct: *const c_char, - n: size_t) -> *mut c_char; - pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; - pub fn strncmp(cs: *const c_char, ct: *const c_char, - n: size_t) -> c_int; - pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; - pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; - pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; - pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; - pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; - pub fn strpbrk(cs: *const c_char, - ct: *const c_char) -> *mut c_char; - pub fn strstr(cs: *const c_char, - ct: *const c_char) -> *mut c_char; - pub fn strlen(cs: *const c_char) -> size_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "strerror$UNIX2003")] - pub fn strerror(n: c_int) -> *mut c_char; - pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; - pub fn strxfrm(s: *mut c_char, ct: *const c_char, - n: size_t) -> size_t; - pub fn wcslen(buf: *const wchar_t) -> size_t; - - // Omitted: memcpy, memmove, memset (provided by LLVM) - - // These are fine to execute on the Rust stack. They must be, - // in fact, because LLVM generates calls to them! - pub fn memcmp(cx: *const c_void, ct: *const c_void, - n: size_t) -> c_int; - pub fn memchr(cx: *const c_void, c: c_int, - n: size_t) -> *mut c_void; - } - } - } - - // Microsoft helpfully underscore-qualifies all of its POSIX-like symbols - // to make sure you don't use them accidentally. It also randomly deviates - // from the exact signatures you might otherwise expect, and omits much, - // so be careful when trying to write portable code; it won't always work - // with the same POSIX functions and types as other platforms. - - #[cfg(target_os = "windows")] - pub mod posix88 { - pub mod stat_ { - use types::os::common::posix01::{stat, utimbuf}; - use types::os::arch::c95::{c_int, c_char, wchar_t}; - - extern { - #[link_name = "_chmod"] - pub fn chmod(path: *const c_char, mode: c_int) -> c_int; - #[link_name = "_wchmod"] - pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; - #[link_name = "_mkdir"] - pub fn mkdir(path: *const c_char) -> c_int; - #[link_name = "_wrmdir"] - pub fn wrmdir(path: *const wchar_t) -> c_int; - #[link_name = "_fstat64"] - pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; - #[link_name = "_stat64"] - pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; - #[link_name = "_wstat64"] - pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; - #[link_name = "_wutime64"] - pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; - } - } - - pub mod stdio { - use types::common::c95::FILE; - use types::os::arch::c95::{c_int, c_char}; - - extern { - #[link_name = "_popen"] - pub fn popen(command: *const c_char, - mode: *const c_char) -> *mut FILE; - #[link_name = "_pclose"] - pub fn pclose(stream: *mut FILE) -> c_int; - #[link_name = "_fdopen"] - pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; - #[link_name = "_fileno"] - pub fn fileno(stream: *mut FILE) -> c_int; - } - } - - pub mod fcntl { - use types::os::arch::c95::{c_int, c_char, wchar_t}; - extern { - #[link_name = "_open"] - pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; - #[link_name = "_wopen"] - pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int; - #[link_name = "_creat"] - pub fn creat(path: *const c_char, mode: c_int) -> c_int; - } - } - - pub mod dirent { - // Not supplied at all. - } - - pub mod unistd { - use types::common::c95::c_void; - use types::os::arch::c95::{c_int, c_uint, c_char, c_long}; - use types::os::arch::c99::intptr_t; - - extern { - #[link_name = "_access"] - pub fn access(path: *const c_char, amode: c_int) -> c_int; - #[link_name = "_chdir"] - pub fn chdir(dir: *const c_char) -> c_int; - #[link_name = "_close"] - pub fn close(fd: c_int) -> c_int; - #[link_name = "_dup"] - pub fn dup(fd: c_int) -> c_int; - #[link_name = "_dup2"] - pub fn dup2(src: c_int, dst: c_int) -> c_int; - #[link_name = "_execv"] - pub fn execv(prog: *const c_char, - argv: *const *const c_char) -> intptr_t; - #[link_name = "_execve"] - pub fn execve(prog: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) - -> c_int; - #[link_name = "_execvp"] - pub fn execvp(c: *const c_char, - argv: *const *const c_char) -> c_int; - #[link_name = "_execvpe"] - pub fn execvpe(c: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) -> c_int; - #[link_name = "_getcwd"] - pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char; - #[link_name = "_getpid"] - pub fn getpid() -> c_int; - #[link_name = "_isatty"] - pub fn isatty(fd: c_int) -> c_int; - #[link_name = "_lseek"] - pub fn lseek(fd: c_int, offset: c_long, origin: c_int) - -> c_long; - #[link_name = "_pipe"] - pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) - -> c_int; - #[link_name = "_read"] - pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) - -> c_int; - #[link_name = "_rmdir"] - pub fn rmdir(path: *const c_char) -> c_int; - #[link_name = "_unlink"] - pub fn unlink(c: *const c_char) -> c_int; - #[link_name = "_write"] - pub fn write(fd: c_int, buf: *const c_void, - count: c_uint) -> c_int; - } - } - - pub mod mman { - } - } - - #[cfg(any(target_os = "linux", - target_os = "android", - target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd", - target_os = "nacl"))] - pub mod posix88 { - pub mod stat_ { - use types::os::arch::c95::{c_char, c_int}; - use types::os::arch::posix01::stat; - use types::os::arch::posix88::mode_t; - - extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "chmod$UNIX2003")] - pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fchmod$UNIX2003")] - pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; - - #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] - pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; - - pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; - #[cfg(not(target_os = "nacl"))] - pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; - - #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] - pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; - } - } - - pub mod stdio { - use types::common::c95::FILE; - use types::os::arch::c95::{c_char, c_int}; - - extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "popen$UNIX2003")] - pub fn popen(command: *const c_char, - mode: *const c_char) -> *mut FILE; - pub fn pclose(stream: *mut FILE) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fdopen$UNIX2003")] - pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; - pub fn fileno(stream: *mut FILE) -> c_int; - } - } - - pub mod fcntl { - use types::os::arch::c95::{c_char, c_int}; - use types::os::arch::posix88::mode_t; - - extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "open$UNIX2003")] - pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "creat$UNIX2003")] - pub fn creat(path: *const c_char, mode: mode_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fcntl$UNIX2003")] - pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; - } - } - - pub mod dirent { - use types::common::posix88::{DIR, dirent}; - use types::os::arch::c95::{c_char, c_int, c_long}; - - extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "opendir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "opendir$INODE64$UNIX2003")] - pub fn opendir(dirname: *const c_char) -> *mut DIR; - #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] - pub fn readdir_r(dirp: *mut DIR, entry: *mut dirent, - result: *mut *mut dirent) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "closedir$UNIX2003")] - pub fn closedir(dirp: *mut DIR) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "rewinddir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "rewinddir$INODE64$UNIX2003")] - pub fn rewinddir(dirp: *mut DIR); - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "seekdir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "seekdir$INODE64$UNIX2003")] - pub fn seekdir(dirp: *mut DIR, loc: c_long); - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "telldir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "telldir$INODE64$UNIX2003")] - pub fn telldir(dirp: *mut DIR) -> c_long; - } - } - - pub mod unistd { - use types::common::c95::c_void; - use types::os::arch::c95::{c_char, c_int, c_long, c_uint}; - use types::os::arch::c95::{size_t}; - use types::os::common::posix01::timespec; - use types::os::arch::posix01::utimbuf; - use types::os::arch::posix88::{gid_t, off_t, pid_t}; - use types::os::arch::posix88::{ssize_t, uid_t}; - - #[cfg(target_os = "linux")] - pub const _PC_NAME_MAX: c_int = 3; - #[cfg(target_os = "macos")] - pub const _PC_NAME_MAX: c_int = 4; - - #[cfg(not(target_os = "nacl"))] - extern { - pub fn access(path: *const c_char, amode: c_int) -> c_int; - pub fn alarm(seconds: c_uint) -> c_uint; - pub fn chdir(dir: *const c_char) -> c_int; - pub fn chown(path: *const c_char, uid: uid_t, - gid: gid_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "close$UNIX2003")] - pub fn close(fd: c_int) -> c_int; - pub fn dup(fd: c_int) -> c_int; - pub fn dup2(src: c_int, dst: c_int) -> c_int; - pub fn execv(prog: *const c_char, - argv: *const *const c_char) -> c_int; - pub fn execve(prog: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) - -> c_int; - pub fn execvp(c: *const c_char, - argv: *const *const c_char) -> c_int; - pub fn fork() -> pid_t; - pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; - pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; - pub fn getegid() -> gid_t; - pub fn geteuid() -> uid_t; - pub fn getgid() -> gid_t; - pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) - -> c_int; - pub fn getlogin() -> *mut c_char; - // GNU getopt(3) modifies its arguments despite the - // char * const [] prototype; see the manpage. - pub fn getopt(argc: c_int, argv: *mut *mut c_char, - optstr: *const c_char) -> c_int; - pub fn getpgrp() -> pid_t; - pub fn getpid() -> pid_t; - pub fn getppid() -> pid_t; - pub fn getuid() -> uid_t; - pub fn getsid(pid: pid_t) -> pid_t; - pub fn isatty(fd: c_int) -> c_int; - pub fn link(src: *const c_char, dst: *const c_char) -> c_int; - pub fn lseek(fd: c_int, offset: off_t, whence: c_int) - -> off_t; - pub fn pathconf(path: *const c_char, name: c_int) -> c_long; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pause$UNIX2003")] - pub fn pause() -> c_int; - pub fn pipe(fds: *mut c_int) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "read$UNIX2003")] - pub fn read(fd: c_int, buf: *mut c_void, count: size_t) - -> ssize_t; - pub fn rmdir(path: *const c_char) -> c_int; - pub fn setgid(gid: gid_t) -> c_int; - pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; - pub fn setsid() -> pid_t; - pub fn setuid(uid: uid_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "sleep$UNIX2003")] - pub fn sleep(secs: c_uint) -> c_uint; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "usleep$UNIX2003")] - pub fn usleep(secs: c_uint) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "nanosleep$UNIX2003")] - pub fn nanosleep(rqtp: *const timespec, - rmtp: *mut timespec) -> c_int; - pub fn sysconf(name: c_int) -> c_long; - pub fn tcgetpgrp(fd: c_int) -> pid_t; - pub fn ttyname(fd: c_int) -> *mut c_char; - pub fn unlink(c: *const c_char) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "wait$UNIX2003")] - pub fn wait(status: *mut c_int) -> pid_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "waitpid$UNIX2003")] - pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) - -> pid_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "write$UNIX2003")] - pub fn write(fd: c_int, buf: *const c_void, count: size_t) - -> ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pread$UNIX2003")] - pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, - offset: off_t) -> ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "pwrite$UNIX2003")] - pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, - offset: off_t) -> ssize_t; - pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; - } - #[cfg(target_os = "nacl")] - extern { - pub fn access(path: *const c_char, amode: c_int) -> c_int; - pub fn chdir(dir: *const c_char) -> c_int; - pub fn chown(path: *const c_char, uid: uid_t, - gid: gid_t) -> c_int; - pub fn close(fd: c_int) -> c_int; - pub fn dup(fd: c_int) -> c_int; - pub fn dup2(src: c_int, dst: c_int) -> c_int; - pub fn execv(prog: *const c_char, - argv: *const *const c_char) -> c_int; - pub fn execve(prog: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) - -> c_int; - pub fn execvp(c: *const c_char, - argv: *const *const c_char) -> c_int; - pub fn fork() -> pid_t; - pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; - pub fn getegid() -> gid_t; - pub fn geteuid() -> uid_t; - pub fn getgid() -> gid_t; - pub fn getlogin() -> *mut c_char; - pub fn getopt(argc: c_int, argv: *const *const c_char, - optstr: *const c_char) -> c_int; - pub fn getuid() -> uid_t; - pub fn getsid(pid: pid_t) -> pid_t; - pub fn isatty(fd: c_int) -> c_int; - pub fn link(src: *const c_char, dst: *const c_char) -> c_int; - pub fn lseek(fd: c_int, offset: off_t, whence: c_int) - -> off_t; - pub fn pipe(fds: *mut c_int) -> c_int; - pub fn read(fd: c_int, buf: *mut c_void, count: size_t) - -> ssize_t; - pub fn rmdir(path: *const c_char) -> c_int; - pub fn setgid(gid: gid_t) -> c_int; - pub fn setuid(uid: uid_t) -> c_int; - pub fn sleep(secs: c_uint) -> c_uint; - pub fn usleep(secs: c_uint) -> c_int; - pub fn nanosleep(rqtp: *const timespec, - rmtp: *mut timespec) -> c_int; - pub fn sysconf(name: c_int) -> c_long; - pub fn ttyname(fd: c_int) -> *mut c_char; - pub fn unlink(c: *const c_char) -> c_int; - pub fn wait(status: *const c_int) -> pid_t; - pub fn waitpid(pid: pid_t, status: *const c_int, options: c_int) - -> pid_t; - pub fn write(fd: c_int, buf: *const c_void, count: size_t) - -> ssize_t; - pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, - offset: off_t) -> ssize_t; - pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, - offset: off_t) -> ssize_t; - pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; - } - } - - pub mod signal { - use types::os::arch::c95::{c_int}; - use types::os::arch::posix88::{pid_t}; - - extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "kill$UNIX2003")] - pub fn kill(pid: pid_t, sig: c_int) -> c_int; - } - } - - pub mod mman { - use types::common::c95::{c_void}; - use types::os::arch::c95::{size_t, c_int, c_char}; - use types::os::arch::posix88::{off_t}; - - #[cfg(not(target_os = "nacl"))] - extern { - pub fn mlock(addr: *const c_void, len: size_t) -> c_int; - pub fn munlock(addr: *const c_void, len: size_t) -> c_int; - pub fn mlockall(flags: c_int) -> c_int; - pub fn munlockall() -> c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "mprotect$UNIX2003")] - pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) - -> c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "msync$UNIX2003")] - pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) - -> c_int; - #[cfg(target_os = "macos")] - pub fn shm_open(name: *const c_char, oflag: c_int, ...) - -> c_int; - #[cfg(target_os = "linux")] - pub fn shm_open(name: *const c_char, oflag: c_int, - mode: ::mode_t) -> c_int; - pub fn shm_unlink(name: *const c_char) -> c_int; - } - - extern { - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "mmap$UNIX2003")] - pub fn mmap(addr: *mut c_void, - len: size_t, - prot: c_int, - flags: c_int, - fd: c_int, - offset: off_t) - -> *mut c_void; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "munmap$UNIX2003")] - pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; - - } - } - - pub mod net { - use types::os::arch::c95::{c_char, c_uint}; - - extern { - pub fn if_nametoindex(ifname: *const c_char) -> c_uint; - } - } - - } - - #[cfg(any(target_os = "linux", - target_os = "android", - target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd", - target_os = "nacl"))] - pub mod posix01 { - pub mod stat_ { - use types::os::arch::c95::{c_char, c_int}; - use types::os::arch::posix01::stat; - - extern { - #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] - pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; - } - } - - pub mod unistd { - use types::os::arch::c95::{c_char, c_int, size_t}; - use types::os::arch::posix88::{ssize_t, off_t}; - - extern { - pub fn readlink(path: *const c_char, - buf: *mut c_char, - bufsz: size_t) - -> ssize_t; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "fsync$UNIX2003")] - pub fn fsync(fd: c_int) -> c_int; - - #[cfg(any(target_os = "linux", target_os = "android"))] - pub fn fdatasync(fd: c_int) -> c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "setenv$UNIX2003")] - pub fn setenv(name: *const c_char, val: *const c_char, - overwrite: c_int) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "unsetenv$UNIX2003")] - pub fn unsetenv(name: *const c_char) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "putenv$UNIX2003")] - pub fn putenv(string: *mut c_char) -> c_int; - - pub fn symlink(path1: *const c_char, - path2: *const c_char) -> c_int; - - pub fn ftruncate(fd: c_int, length: off_t) -> c_int; - } - } - - pub mod signal { - use types::os::arch::c95::c_int; - use types::os::common::posix01::sighandler_t; - - #[cfg(not(all(target_os = "android", any(target_arch = "arm", - target_arch = "x86"))))] - extern { - pub fn signal(signum: c_int, - handler: sighandler_t) -> sighandler_t; - } - - #[cfg(all(target_os = "android", any(target_arch = "arm", - target_arch = "x86")))] - extern { - #[link_name = "bsd_signal"] - pub fn signal(signum: c_int, - handler: sighandler_t) -> sighandler_t; - } - } - - pub mod glob { - use types::os::arch::c95::{c_char, c_int}; - use types::os::common::posix01::{glob_t}; - - extern { - pub fn glob(pattern: *const c_char, - flags: c_int, - errfunc: Option c_int>, - pglob: *mut glob_t); - pub fn globfree(pglob: *mut glob_t); - } - } - - pub mod mman { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_int, size_t}; - - #[cfg(not(target_os = "nacl"))] - extern { - pub fn posix_madvise(addr: *mut c_void, - len: size_t, - advice: c_int) - -> c_int; - } - } - - pub mod resource { - use types::os::arch::c95::c_int; - use types::os::common::posix01::rlimit; - use types::os::common::bsd43::rusage; - extern { - pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; - pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; - pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; - - } - } - } - - #[cfg(target_os = "windows")] - pub mod posix01 { - pub mod stat_ { - } - - pub mod unistd { - } - - pub mod glob { - } - - pub mod mman { - } - - pub mod net { - } - } - - - #[cfg(any(target_os = "android", - target_os = "bitrig", - target_os = "dragonfly", - target_os = "ios", - target_os = "freebsd", - target_os = "linux", - target_os = "macos", - target_os = "nacl", - target_os = "netbsd", - target_os = "openbsd", - target_os = "windows"))] - pub mod posix08 { - pub mod unistd { - } - } - - #[cfg(not(windows))] - pub mod bsd43 { - use types::common::c95::{c_void}; - use types::os::common::bsd44::{socklen_t, sockaddr, ifaddrs}; - use types::os::arch::c95::{c_int, size_t}; - use types::os::arch::posix88::ssize_t; - - extern "system" { - pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "connect$UNIX2003")] - pub fn connect(socket: c_int, address: *const sockaddr, - len: socklen_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "bind$UNIX2003")] - pub fn bind(socket: c_int, address: *const sockaddr, - address_len: socklen_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "listen$UNIX2003")] - pub fn listen(socket: c_int, backlog: c_int) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "accept$UNIX2003")] - pub fn accept(socket: c_int, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "getpeername$UNIX2003")] - pub fn getpeername(socket: c_int, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "getsockname$UNIX2003")] - pub fn getsockname(socket: c_int, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; - pub fn setsockopt(socket: c_int, level: c_int, name: c_int, - value: *const c_void, - option_len: socklen_t) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recv$UNIX2003")] - pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, - flags: c_int) -> ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "send$UNIX2003")] - pub fn send(socket: c_int, buf: *const c_void, len: size_t, - flags: c_int) -> ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recvfrom$UNIX2003")] - pub fn recvfrom(socket: c_int, buf: *mut c_void, len: size_t, - flags: c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "sendto$UNIX2003")] - pub fn sendto(socket: c_int, buf: *const c_void, len: size_t, - flags: c_int, addr: *const sockaddr, - addrlen: socklen_t) -> ssize_t; - pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; - pub fn freeifaddrs(ifa: *mut ifaddrs); - pub fn shutdown(socket: c_int, how: c_int) -> c_int; - } - } - - #[cfg(windows)] - pub mod bsd43 { - use types::os::common::bsd44::{sockaddr, SOCKET}; - use types::os::arch::c95::{c_int, c_char}; - - extern "system" { - pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; - pub fn connect(socket: SOCKET, address: *const sockaddr, - len: c_int) -> c_int; - pub fn bind(socket: SOCKET, address: *const sockaddr, - address_len: c_int) -> c_int; - pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; - pub fn accept(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> SOCKET; - pub fn getpeername(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> c_int; - pub fn getsockname(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> c_int; - pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, - value: *const c_char, - option_len: c_int) -> c_int; - pub fn closesocket(socket: SOCKET) -> c_int; - pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int, - flags: c_int) -> c_int; - pub fn send(socket: SOCKET, buf: *const c_char, len: c_int, - flags: c_int) -> c_int; - pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int, - flags: c_int, addr: *mut sockaddr, - addrlen: *mut c_int) -> c_int; - pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int, - flags: c_int, addr: *const sockaddr, - addrlen: c_int) -> c_int; - pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; - } - } - - #[cfg(any(target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd"))] - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint, c_ulong, size_t}; - - extern { - pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; - pub fn sysctl(name: *mut c_int, - namelen: c_uint, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn sysctlbyname(name: *const c_char, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn sysctlnametomib(name: *const c_char, - mibp: *mut c_int, - sizep: *mut size_t) - -> c_int; - pub fn getdtablesize() -> c_int; - pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) - -> c_int; - pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) - -> c_int; - #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] - pub fn realpath(pathname: *const c_char, resolved: *mut c_char) - -> *mut c_char; - pub fn flock(fd: c_int, operation: c_int) -> c_int; - } - } - - #[cfg(any(target_os = "linux", target_os = "android"))] - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_uchar, c_int, size_t}; - #[cfg(not(feature = "cargo-build"))] - use types::os::arch::c95::c_ulong; - - extern { - #[cfg(not(all(target_os = "android", target_arch = "aarch64")))] - pub fn getdtablesize() -> c_int; - - // Note that the correct signature of ioctl broke some crates on - // crates.io, so for now we keep the broken signature for crates.io - // but we fix it locally in the main Rust distribution. Once a new - // major version of libc is released on crates.io this #[cfg] should - // go away. - #[cfg(feature = "cargo-build")] - pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; - #[cfg(not(feature = "cargo-build"))] - pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; - pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) - -> c_int; - pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) - -> c_int; - pub fn flock(fd: c_int, operation: c_int) -> c_int; - } - } - - #[cfg(target_os = "nacl")] - pub mod bsd44 { - use types::os::arch::c95::c_int; - extern { - pub fn getdtablesize() -> c_int; - } - } - - #[cfg(target_os = "windows")] - pub mod bsd44 { - } - - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub mod extra { - use {c_char, c_int, uint32_t}; - - extern { - pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut uint32_t) - -> c_int; - } - } - - #[cfg(any(target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd"))] - pub mod extra { - } - - #[cfg(any(target_os = "linux", target_os = "android", target_os = "nacl"))] - pub mod extra { - } - - - #[cfg(target_os = "windows")] - pub mod extra { - - pub mod kernel32 { - use types::os::arch::c95::{c_uint}; - use types::os::arch::extra::*; - - extern "system" { - pub fn GetEnvironmentVariableW(n: LPCWSTR, - v: LPWSTR, - nsize: DWORD) - -> DWORD; - pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) - -> BOOL; - pub fn GetEnvironmentStringsW() -> LPWCH; - pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL; - pub fn GetModuleFileNameW(hModule: HMODULE, - lpFilename: LPWSTR, - nSize: DWORD) - -> DWORD; - pub fn CreateDirectoryW(lpPathName: LPCWSTR, - lpSecurityAttributes: - LPSECURITY_ATTRIBUTES) - -> BOOL; - pub fn CopyFileW(lpExistingFileName: LPCWSTR, - lpNewFileName: LPCWSTR, - bFailIfExists: BOOL) - -> BOOL; - pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL; - pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; - pub fn GetCurrentDirectoryW(nBufferLength: DWORD, - lpBuffer: LPWSTR) - -> DWORD; - pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; - pub fn GetLastError() -> DWORD; - pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) - -> HANDLE; - pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) - -> BOOL; - pub fn FindClose(findFile: HANDLE) -> BOOL; - pub fn DuplicateHandle(hSourceProcessHandle: HANDLE, - hSourceHandle: HANDLE, - hTargetProcessHandle: HANDLE, - lpTargetHandle: LPHANDLE, - dwDesiredAccess: DWORD, - bInheritHandle: BOOL, - dwOptions: DWORD) - -> BOOL; - pub fn CloseHandle(hObject: HANDLE) -> BOOL; - pub fn OpenProcess(dwDesiredAccess: DWORD, - bInheritHandle: BOOL, - dwProcessId: DWORD) - -> HANDLE; - pub fn GetCurrentProcess() -> HANDLE; - pub fn CreateProcessW(lpApplicationName: LPCWSTR, - lpCommandLine: LPWSTR, - lpProcessAttributes: - LPSECURITY_ATTRIBUTES, - lpThreadAttributes: - LPSECURITY_ATTRIBUTES, - bInheritHandles: BOOL, - dwCreationFlags: DWORD, - lpEnvironment: LPVOID, - lpCurrentDirectory: LPCWSTR, - lpStartupInfo: LPSTARTUPINFOW, - lpProcessInformation: - LPPROCESS_INFORMATION) - -> BOOL; - pub fn WaitForSingleObject(hHandle: HANDLE, - dwMilliseconds: DWORD) - -> DWORD; - pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) - -> BOOL; - pub fn GetExitCodeProcess(hProcess: HANDLE, - lpExitCode: LPDWORD) - -> BOOL; - pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); - pub fn VirtualAlloc(lpAddress: LPVOID, - dwSize: SIZE_T, - flAllocationType: DWORD, - flProtect: DWORD) - -> LPVOID; - pub fn VirtualFree(lpAddress: LPVOID, - dwSize: SIZE_T, - dwFreeType: DWORD) - -> BOOL; - pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; - pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) - -> BOOL; - pub fn VirtualProtect(lpAddress: LPVOID, - dwSize: SIZE_T, - flNewProtect: DWORD, - lpflOldProtect: LPDWORD) - -> BOOL; - pub fn VirtualQuery(lpAddress: LPCVOID, - lpBuffer: PMEMORY_BASIC_INFORMATION, - dwLength: SIZE_T) - -> SIZE_T; - pub fn CreateFileMappingW(hFile: HANDLE, - lpAttributes: LPSECURITY_ATTRIBUTES, - flProtect: DWORD, - dwMaximumSizeHigh: DWORD, - dwMaximumSizeLow: DWORD, - lpName: LPCWSTR) - -> HANDLE; - pub fn MapViewOfFile(hFileMappingObject: HANDLE, - dwDesiredAccess: DWORD, - dwFileOffsetHigh: DWORD, - dwFileOffsetLow: DWORD, - dwNumberOfBytesToMap: SIZE_T) - -> LPVOID; - pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; - pub fn MoveFileExW(lpExistingFileName: LPCWSTR, - lpNewFileName: LPCWSTR, - dwFlags: DWORD) -> BOOL; - pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR, - lpTargetFileName: LPCWSTR, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES) - -> BOOL; - pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; - pub fn CreateFileW(lpFileName: LPCWSTR, - dwDesiredAccess: DWORD, - dwShareMode: DWORD, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES, - dwCreationDisposition: DWORD, - dwFlagsAndAttributes: DWORD, - hTemplateFile: HANDLE) -> HANDLE; - pub fn ReadFile(hFile: HANDLE, - lpBuffer: LPVOID, - nNumberOfBytesToRead: DWORD, - lpNumberOfBytesRead: LPDWORD, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn WriteFile(hFile: HANDLE, - lpBuffer: LPCVOID, - nNumberOfBytesToWrite: DWORD, - lpNumberOfBytesWritten: LPDWORD, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn SetFilePointerEx(hFile: HANDLE, - liDistanceToMove: LARGE_INTEGER, - lpNewFilePointer: PLARGE_INTEGER, - dwMoveMethod: DWORD) -> BOOL; - pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; - - pub fn GetSystemTimeAsFileTime( - lpSystemTimeAsFileTime: LPFILETIME); - - pub fn QueryPerformanceFrequency( - lpFrequency: *mut LARGE_INTEGER) -> BOOL; - pub fn QueryPerformanceCounter( - lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL; - - pub fn GetCurrentProcessId() -> DWORD; - pub fn CreateNamedPipeW( - lpName: LPCWSTR, - dwOpenMode: DWORD, - dwPipeMode: DWORD, - nMaxInstances: DWORD, - nOutBufferSize: DWORD, - nInBufferSize: DWORD, - nDefaultTimeOut: DWORD, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES - ) -> HANDLE; - pub fn ConnectNamedPipe(hNamedPipe: HANDLE, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, - nTimeOut: DWORD) -> BOOL; - pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE, - lpMode: LPDWORD, - lpMaxCollectionCount: LPDWORD, - lpCollectDataTimeout: LPDWORD) - -> BOOL; - pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES, - bManualReset: BOOL, - bInitialState: BOOL, - lpName: LPCWSTR) -> HANDLE; - pub fn GetOverlappedResult(hFile: HANDLE, - lpOverlapped: LPOVERLAPPED, - lpNumberOfBytesTransferred: LPDWORD, - bWait: BOOL) -> BOOL; - pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; - } - } - - pub mod msvcrt { - use types::os::arch::c95::c_int; - use types::os::arch::c99::intptr_t; - - extern { - #[link_name = "_commit"] - pub fn commit(fd: c_int) -> c_int; - - #[link_name = "_get_osfhandle"] - pub fn get_osfhandle(fd: c_int) -> intptr_t; - - #[link_name = "_open_osfhandle"] - pub fn open_osfhandle(osfhandle: intptr_t, - flags: c_int) -> c_int; - } - } - - pub mod winsock { - use types::os::arch::c95::{c_int, c_long, c_ulong}; - use types::os::common::bsd44::SOCKET; - - extern "system" { - pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int; - } - } - } +extern { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fopen$UNIX2003")] + pub fn fopen(filename: *const c_char, + mode: *const c_char) -> *mut FILE; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "freopen$UNIX2003")] + pub fn freopen(filename: *const c_char, mode: *const c_char, + file: *mut FILE) + -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, + newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, + buffer: *mut c_char, + mode: c_int, + size: size_t) + -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + // Omitted: printf and scanf variants. + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) + -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fputs$UNIX2003")] + pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE) + -> size_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fwrite$UNIX2003")] + pub fn fwrite(ptr: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut FILE) + -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) + -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "strtod$UNIX2003")] + pub fn strtod(s: *const c_char, + endp: *mut *mut c_char) -> c_double; + pub fn strtol(s: *const c_char, + endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, + base: c_int) -> c_ulong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern fn()) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "system$UNIX2003")] + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) + -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "strerror$UNIX2003")] + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; } diff --git a/src/linkage.rs b/src/linkage.rs new file mode 100644 index 0000000000000..721325c684d2e --- /dev/null +++ b/src/linkage.rs @@ -0,0 +1,38 @@ + +// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them +// in when creating a test crate. +#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))] +#[link(name = "c")] +#[link(name = "m")] +extern {} + +// When compiling rust with musl, statically include libc.a in liblibc.rlib. +// A cargo build of the libc crate will therefore automatically pick up the +// libc.a symbols because liblibc is transitively linked to by the stdlib. +#[cfg(all(target_env = "musl", not(feature = "cargo-build"), not(test)))] +#[link(name = "c", kind = "static")] +extern {} + +#[cfg(all(windows, target_env = "msvc"))] +#[link(name = "kernel32")] +#[link(name = "shell32")] +#[link(name = "msvcrt")] +extern {} + +// libnacl provides functions that require a trip through the IRT to work. +// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip +// to the kernel. +#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] +#[link(name = "nacl", kind = "static")] +extern {} + +// pnaclmm provides a number of functions that the toolchain's Clang emits calls +// to when codegening atomic ops. All the functions within wrap various atomic +// operations. +// Yes, it could be linked by rustc explicitly, however by linking it here +// instead we save a bit of time where bins are involved (by not running the +// optimizations on the whole pnaclmm foreach binary built). +#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] +#[link(name = "pnaclmm", kind = "static")] +extern {} + diff --git a/src/linuxlike/android.rs b/src/linuxlike/android.rs new file mode 100644 index 0000000000000..825fd1febd540 --- /dev/null +++ b/src/linuxlike/android.rs @@ -0,0 +1,31 @@ +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_BC_BASE_MAX: c_int = 1; +pub const _SC_BC_DIM_MAX: c_int = 2; +pub const _SC_BC_SCALE_MAX: c_int = 3; +pub const _SC_BC_STRING_MAX: c_int = 4; +pub const _SC_CHILD_MAX: c_int = 5; +pub const _SC_CLK_TCK: c_int = 6; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 7; +pub const _SC_EXPR_NEST_MAX: c_int = 8; +pub const _SC_LINE_MAX: c_int = 9; +pub const _SC_NGROUPS_MAX: c_int = 10; +pub const _SC_OPEN_MAX: c_int = 11; +pub const _SC_2_C_BIND: c_int = 13; +pub const _SC_2_C_DEV: c_int = 14; +pub const _SC_2_C_VERSION: c_int = 15; +pub const _SC_2_CHAR_TERM: c_int = 16; +pub const _SC_2_FORT_DEV: c_int = 17; +pub const _SC_2_FORT_RUN: c_int = 18; +pub const _SC_2_LOCALEDEF: c_int = 19; +pub const _SC_2_SW_DEV: c_int = 20; +pub const _SC_2_UPE: c_int = 21; +pub const _SC_2_VERSION: c_int = 22; +pub const _SC_JOB_CONTROL: c_int = 23; +pub const _SC_SAVED_IDS: c_int = 24; +pub const _SC_VERSION: c_int = 25; +pub const _SC_RE_DUP_MAX: c_int = 26; +pub const _SC_STREAM_MAX: c_int = 27; +pub const _SC_TZNAME_MAX: c_int = 28; +pub const _SC_PAGESIZE: c_int = 39; + +pub const PTHREAD_STACK_MIN: size_t = 8192; diff --git a/src/linuxlike/b32/android.rs b/src/linuxlike/b32/android.rs new file mode 100644 index 0000000000000..5ec3f7c92be59 --- /dev/null +++ b/src/linuxlike/b32/android.rs @@ -0,0 +1,29 @@ +pub type blkcnt_t = u32; +pub type blksize_t = u32; +pub type dev_t = u32; +pub type mode_t = u16; +pub type nlink_t = u16; + +s! { + pub struct stat { + pub st_dev: c_ulonglong, + __pad0: [c_uchar; 4], + __st_ino: ino_t, + pub st_mode: c_uint, + pub st_nlink: c_uint, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: c_ulonglong, + __pad3: [c_uchar; 4], + pub st_size: c_longlong, + pub st_blksize: blksize_t, + pub st_blocks: c_ulonglong, + pub st_atime: time_t, + pub st_atime_nsec: c_ulong, + pub st_mtime: time_t, + pub st_mtime_nsec: c_ulong, + pub st_ctime: time_t, + pub st_ctime_nsec: c_ulong, + pub st_ino: c_ulonglong, + } +} diff --git a/src/linuxlike/b32/mips.rs b/src/linuxlike/b32/mips.rs new file mode 100644 index 0000000000000..cbf0825664cb0 --- /dev/null +++ b/src/linuxlike/b32/mips.rs @@ -0,0 +1,30 @@ +pub type blkcnt_t = i32; +pub type blksize_t = i32; +pub type dev_t = u64; +pub type mode_t = u32; +pub type nlink_t = u32; + +s! { + pub struct stat { + pub st_dev: c_ulong, + pub st_pad1: [c_long; 3], + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: c_ulong, + pub st_pad2: [c_long; 2], + pub st_size: off_t, + pub st_pad3: c_long, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_pad5: [c_long; 14], + } +} diff --git a/src/linuxlike/b32/mod.rs b/src/linuxlike/b32/mod.rs new file mode 100644 index 0000000000000..d6c3e4a007f3b --- /dev/null +++ b/src/linuxlike/b32/mod.rs @@ -0,0 +1,78 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u32; +pub type ptrdiff_t = i32; +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i32; +pub type uintptr_t = u32; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i32; +pub type ino_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type ssize_t = i32; + +s! { + pub struct pthread_attr_t { + __size: [u32; 9] + } +} + +cfg_if! { + if #[cfg(target_os = "android")] { + mod android; + pub use self::android::*; + } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { + mod mips; + pub use self::mips::*; + } else { + pub type dev_t = u64; + pub type mode_t = u32; + pub type nlink_t = u32; + pub type blksize_t = i32; + pub type blkcnt_t = i32; + + s! { + pub struct stat { + pub st_dev: dev_t, + __pad1: c_short, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + __pad2: c_short, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + __unused4: c_long, + __unused5: c_long, + } + } + } +} + diff --git a/src/linuxlike/b64/aarch64.rs b/src/linuxlike/b64/aarch64.rs new file mode 100644 index 0000000000000..d395cb2e50f8b --- /dev/null +++ b/src/linuxlike/b64/aarch64.rs @@ -0,0 +1,32 @@ +pub type nlink_t = u32; +pub type blksize_t = i32; +pub type c_char = u8; +pub type wchar_t = u32; + +s! { + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + __pad1: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + __pad2: c_int, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + __unused: [c_int; 2], + } + + pub struct pthread_attr_t { + __size: [u64; 8] + } +} diff --git a/src/linuxlike/b64/mod.rs b/src/linuxlike/b64/mod.rs new file mode 100644 index 0000000000000..1fb7cfdfe1068 --- /dev/null +++ b/src/linuxlike/b64/mod.rs @@ -0,0 +1,41 @@ +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u64; +pub type ptrdiff_t = i64; +pub type clock_t = i64; +pub type time_t = i64; +pub type suseconds_t = i64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i64; +pub type uintptr_t = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i64; +pub type dev_t = u64; +pub type ino_t = u64; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type mode_t = u32; +pub type ssize_t = i64; +pub type blkcnt_t = i64; + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/src/linuxlike/b64/x86_64.rs b/src/linuxlike/b64/x86_64.rs new file mode 100644 index 0000000000000..1d5a988d36a8f --- /dev/null +++ b/src/linuxlike/b64/x86_64.rs @@ -0,0 +1,31 @@ +pub type nlink_t = u64; +pub type blksize_t = i64; +pub type c_char = i8; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + __pad0: ::c_int, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 3], + } + + pub struct pthread_attr_t { + __size: [u64; 7] + } +} diff --git a/src/linuxlike/linux.rs b/src/linuxlike/linux.rs new file mode 100644 index 0000000000000..4bf33c3a76f67 --- /dev/null +++ b/src/linuxlike/linux.rs @@ -0,0 +1,66 @@ +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_STREAM_MAX: ::c_int = 5; +pub const _SC_TZNAME_MAX: ::c_int = 6; +pub const _SC_JOB_CONTROL: ::c_int = 7; +pub const _SC_SAVED_IDS: ::c_int = 8; +pub const _SC_REALTIME_SIGNALS: ::c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; +pub const _SC_TIMERS: ::c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; +pub const _SC_PRIORITIZED_IO: ::c_int = 13; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; +pub const _SC_FSYNC: ::c_int = 15; +pub const _SC_MAPPED_FILES: ::c_int = 16; +pub const _SC_MEMLOCK: ::c_int = 17; +pub const _SC_MEMLOCK_RANGE: ::c_int = 18; +pub const _SC_MEMORY_PROTECTION: ::c_int = 19; +pub const _SC_MESSAGE_PASSING: ::c_int = 20; +pub const _SC_SEMAPHORES: ::c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; +pub const _SC_AIO_MAX: ::c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; +pub const _SC_DELAYTIMER_MAX: ::c_int = 26; +pub const _SC_MQ_OPEN_MAX: ::c_int = 27; +pub const _SC_VERSION: ::c_int = 29; +pub const _SC_PAGESIZE: ::c_int = 30; +pub const _SC_RTSIG_MAX: ::c_int = 31; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; +pub const _SC_SEM_VALUE_MAX: ::c_int = 33; +pub const _SC_SIGQUEUE_MAX: ::c_int = 34; +pub const _SC_TIMER_MAX: ::c_int = 35; +pub const _SC_BC_BASE_MAX: ::c_int = 36; +pub const _SC_BC_DIM_MAX: ::c_int = 37; +pub const _SC_BC_SCALE_MAX: ::c_int = 38; +pub const _SC_BC_STRING_MAX: ::c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; +pub const _SC_EXPR_NEST_MAX: ::c_int = 42; +pub const _SC_LINE_MAX: ::c_int = 43; +pub const _SC_RE_DUP_MAX: ::c_int = 44; +pub const _SC_2_VERSION: ::c_int = 46; +pub const _SC_2_C_BIND: ::c_int = 47; +pub const _SC_2_C_DEV: ::c_int = 48; +pub const _SC_2_FORT_DEV: ::c_int = 49; +pub const _SC_2_FORT_RUN: ::c_int = 50; +pub const _SC_2_SW_DEV: ::c_int = 51; +pub const _SC_2_LOCALEDEF: ::c_int = 52; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; +pub const _SC_2_CHAR_TERM: ::c_int = 95; +pub const _SC_2_C_VERSION: ::c_int = 96; +pub const _SC_2_UPE: ::c_int = 97; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; + +cfg_if! { + if #[cfg(any(target_arch = "arm", target_arch = "x86", + target_arch = "x86_64"))] { + pub const PTHREAD_STACK_MIN: ::size_t = 16384; + } else { + pub const PTHREAD_STACK_MIN: ::size_t = 131072; + } +} diff --git a/src/linuxlike/mips.rs b/src/linuxlike/mips.rs new file mode 100644 index 0000000000000..748bd5a5948c5 --- /dev/null +++ b/src/linuxlike/mips.rs @@ -0,0 +1,314 @@ +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 256; +pub const O_EXCL: c_int = 1024; +pub const O_NOCTTY: c_int = 2048; +pub const O_TRUNC: c_int = 512; +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_ANON: c_int = 0x0800; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; +pub const MS_SYNC: c_int = 0x0004; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; + +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EDEADLK: c_int = 45; +pub const ENOLCK: c_int = 46; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; +pub const EMULTIHOP: c_int = 74; +pub const EBADMSG: c_int = 77; +pub const ENAMETOOLONG: c_int = 78; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 95; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ENOSYS: c_int = 89; +pub const ELOOP: c_int = 90; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const ENOTEMPTY: c_int = 93; +pub const EUSERS: c_int = 94; +pub const ENOTSOCK: c_int = 95; +pub const EDESTADDRREQ: c_int = 96; +pub const EMSGSIZE: c_int = 97; +pub const EPROTOTYPE: c_int = 98; +pub const ENOPROTOOPT: c_int = 99; +pub const EPROTONOSUPPORT: c_int = 120; +pub const ESOCKTNOSUPPORT: c_int = 121; +pub const EOPNOTSUPP: c_int = 122; +pub const EPFNOSUPPORT: c_int = 123; +pub const EAFNOSUPPORT: c_int = 124; +pub const EADDRINUSE: c_int = 125; +pub const EADDRNOTAVAIL: c_int = 126; +pub const ENETDOWN: c_int = 127; +pub const ENETUNREACH: c_int = 128; +pub const ENETRESET: c_int = 129; +pub const ECONNABORTED: c_int = 130; +pub const ECONNRESET: c_int = 131; +pub const ENOBUFS: c_int = 132; +pub const EISCONN: c_int = 133; +pub const ENOTCONN: c_int = 134; +pub const EUCLEAN: c_int = 135; +pub const ENOTNAM: c_int = 137; +pub const ENAVAIL: c_int = 138; +pub const EISNAM: c_int = 139; +pub const EREMOTEIO: c_int = 140; +pub const ESHUTDOWN: c_int = 143; +pub const ETOOMANYREFS: c_int = 144; +pub const ETIMEDOUT: c_int = 145; +pub const ECONNREFUSED: c_int = 146; +pub const EHOSTDOWN: c_int = 147; +pub const EHOSTUNREACH: c_int = 148; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EALREADY: c_int = 149; +pub const EINPROGRESS: c_int = 150; +pub const ESTALE: c_int = 151; +pub const ECANCELED: c_int = 158; +pub const ENOMEDIUM: c_int = 159; +pub const EMEDIUMTYPE: c_int = 160; +pub const ENOKEY: c_int = 161; +pub const EKEYEXPIRED: c_int = 162; +pub const EKEYREVOKED: c_int = 163; +pub const EKEYREJECTED: c_int = 164; +pub const EOWNERDEAD: c_int = 165; +pub const ENOTRECOVERABLE: c_int = 166; +pub const ERFKILL: c_int = 167; +pub const EHWPOISON: c_int = 168; +pub const EDQUOT: c_int = 1133; + +pub const AF_PACKET: c_int = 17; +pub const IPPROTO_RAW: c_int = 255; + +pub const O_RSYNC: c_int = 16400; +pub const O_DSYNC: c_int = 16; +pub const O_NONBLOCK: c_int = 128; +pub const O_SYNC: c_int = 16400; + +pub const PROT_GROWSDOWN: c_int = 0x01000000; +pub const PROT_GROWSUP: c_int = 0x02000000; + +pub const MAP_TYPE: c_int = 0x000f; +pub const MAP_ANONYMOUS: c_int = 0x0800; +pub const MAP_GROWSDOWN: c_int = 0x01000; +pub const MAP_DENYWRITE: c_int = 0x02000; +pub const MAP_EXECUTABLE: c_int = 0x04000; +pub const MAP_LOCKED: c_int = 0x08000; +pub const MAP_NORESERVE: c_int = 0x0400; +pub const MAP_POPULATE: c_int = 0x010000; +pub const MAP_NONBLOCK: c_int = 0x020000; +pub const MAP_STACK: c_int = 0x040000; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_REMOVE: c_int = 9; +pub const MADV_DONTFORK: c_int = 10; +pub const MADV_DOFORK: c_int = 11; +pub const MADV_MERGEABLE: c_int = 12; +pub const MADV_UNMERGEABLE: c_int = 13; +pub const MADV_HWPOISON: c_int = 100; + +pub const AF_UNIX: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_INET6: c_int = 10; +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; +pub const SOCK_RAW: c_int = 3; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_IPV6: c_int = 41; +pub const IP_MULTICAST_TTL: c_int = 33; +pub const IP_MULTICAST_LOOP: c_int = 34; +pub const IP_TTL: c_int = 2; +pub const IP_HDRINCL: c_int = 3; +pub const IP_ADD_MEMBERSHIP: c_int = 35; +pub const IP_DROP_MEMBERSHIP: c_int = 36; +pub const IPV6_ADD_MEMBERSHIP: c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: c_int = 21; + +pub const TCP_NODELAY: c_int = 1; +pub const TCP_MAXSEG: c_int = 2; +pub const TCP_CORK: c_int = 3; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; +pub const TCP_SYNCNT: c_int = 7; +pub const TCP_LINGER2: c_int = 8; +pub const TCP_DEFER_ACCEPT: c_int = 9; +pub const TCP_WINDOW_CLAMP: c_int = 10; +pub const TCP_INFO: c_int = 11; +pub const TCP_QUICKACK: c_int = 12; +pub const TCP_CONGESTION: c_int = 13; +pub const TCP_MD5SIG: c_int = 14; +pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; +pub const TCP_THIN_DUPACK: c_int = 17; +pub const TCP_USER_TIMEOUT: c_int = 18; +pub const TCP_REPAIR: c_int = 19; +pub const TCP_REPAIR_QUEUE: c_int = 20; +pub const TCP_QUEUE_SEQ: c_int = 21; +pub const TCP_REPAIR_OPTIONS: c_int = 22; +pub const TCP_FASTOPEN: c_int = 23; +pub const TCP_TIMESTAMP: c_int = 24; + +pub const SOL_SOCKET: c_int = 65535; + +pub const SO_DEBUG: c_int = 0x0001; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_ACCEPTCONN: c_int = 0x1009; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; diff --git a/src/linuxlike/mod.rs b/src/linuxlike/mod.rs new file mode 100644 index 0000000000000..f545a01f99c0f --- /dev/null +++ b/src/linuxlike/mod.rs @@ -0,0 +1,293 @@ +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type pthread_t = c_ulong; +pub type rlim_t = c_ulong; +pub type sa_family_t = u16; +pub type sighandler_t = size_t; +pub type socklen_t = u32; + +pub enum timezone {} + +s! { + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_align: isize, + #[cfg(target_pointer_width = "32")] + __ss_pad2: [u8; 128 - 2 * 4], + #[cfg(target_pointer_width = "64")] + __ss_pad2: [u8; 128 - 2 * 8], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + pub struct in6_addr { + pub s6_addr: [u16; 8], + __align: [u32; 0], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + + #[cfg(target_os = "linux")] + pub ai_addr: *mut sockaddr, + + pub ai_canonname: *mut c_char, + + #[cfg(any(target_os = "android", target_os = "nacl"))] + pub ai_addr: *mut sockaddr, + + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108] + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_ifu: *mut sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + + pub struct sockaddr_ll { + pub sll_family: c_ushort, + pub sll_protocol: c_ushort, + pub sll_ifindex: c_int, + pub sll_hatype: c_ushort, + pub sll_pkttype: c_uchar, + pub sll_halen: c_uchar, + pub sll_addr: [c_uchar; 8] + } + + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } +} + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 2147483647; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const BUFSIZ: c_uint = 8192; +pub const FOPEN_MAX: c_uint = 16; +pub const FILENAME_MAX: c_uint = 4096; +pub const L_tmpnam: c_uint = 20; +pub const TMP_MAX: c_uint = 238328; +pub const _PC_NAME_MAX: c_int = 3; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; + +pub const O_ACCMODE: c_int = 3; + +pub const SIGTRAP: c_int = 5; +pub const SIG_IGN: size_t = 1; + +pub const GLOB_ERR : c_int = 1 << 0; +pub const GLOB_MARK : c_int = 1 << 1; +pub const GLOB_NOSORT : c_int = 1 << 2; +pub const GLOB_DOOFFS : c_int = 1 << 3; +pub const GLOB_NOCHECK : c_int = 1 << 4; +pub const GLOB_APPEND : c_int = 1 << 5; +pub const GLOB_NOESCAPE: c_int = 1 << 6; + +pub const GLOB_NOSPACE : c_int = 1; +pub const GLOB_ABORTED : c_int = 2; +pub const GLOB_NOMATCH : c_int = 3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; + +pub const CLOCK_REALTIME: c_int = 0; +pub const CLOCK_MONOTONIC: c_int = 1; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_AS: c_int = 9; +pub const RLIMIT_NPROC: c_int = 6; +pub const RLIMIT_MEMLOCK: c_int = 8; +pub const RLIMIT_LOCKS: c_int = 10; +pub const RLIMIT_SIGPENDING: c_int = 11; +pub const RLIMIT_MSGQUEUE: c_int = 12; +pub const RLIMIT_NICE: c_int = 13; +pub const RLIMIT_RTPRIO: c_int = 14; +pub const RLIMIT_RTTIME: c_int = 15; +pub const RLIMIT_NLIMITS: c_int = 16; +pub const RLIM_INFINITY: rlim_t = !0; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; +pub const RUSAGE_THREAD: c_int = 1; + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod b32; + pub use self::b32::*; + } else { + mod b64; + pub use self::b64::*; + } +} + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { + mod mips; + pub use self::mips::*; + } else { + mod notmips; + pub use self::notmips::*; + } +} + +cfg_if! { + if #[cfg(target_os = "linux")] { + mod linux; + pub use self::linux::*; + } else if #[cfg(target_os = "android")] { + mod android; + pub use self::android::*; + } else { + // ... + } +} diff --git a/src/linuxlike/notmips.rs b/src/linuxlike/notmips.rs new file mode 100644 index 0000000000000..5da166d6c5e86 --- /dev/null +++ b/src/linuxlike/notmips.rs @@ -0,0 +1,319 @@ +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_TRUNC: ::c_int = 512; +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IEXEC: ::mode_t = 64; +pub const S_IWRITE: ::mode_t = 128; +pub const S_IREAD: ::mode_t = 256; +pub const S_IRWXU: ::mode_t = 448; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IRWXG: ::mode_t = 56; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IRWXO: ::mode_t = 7; +pub const S_IXOTH: ::mode_t = 1; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IROTH: ::mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x0020; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0004; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const EWOULDBLOCK: ::c_int = EAGAIN; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; + +pub const EDEADLOCK: ::c_int = EDEADLK; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EMULTIHOP: ::c_int = 72; +pub const EDOTDOT: ::c_int = 73; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const AF_PACKET: ::c_int = 17; +pub const IPPROTO_RAW: ::c_int = 255; + +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; + +pub const PROT_GROWSDOWN: ::c_int = 0x1000000; +pub const PROT_GROWSUP: ::c_int = 0x2000000; + +pub const MAP_TYPE: ::c_int = 0x000f; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_32BIT: ::c_int = 0x0040; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_REMOVE: ::c_int = 9; +pub const MADV_DONTFORK: ::c_int = 10; +pub const MADV_DOFORK: ::c_int = 11; +pub const MADV_MERGEABLE: ::c_int = 12; +pub const MADV_UNMERGEABLE: ::c_int = 13; +pub const MADV_HWPOISON: ::c_int = 100; + +pub const IFF_LOOPBACK: ::c_int = 0x8; + +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 10; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_TTL: ::c_int = 2; +pub const IP_HDRINCL: ::c_int = 3; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; +pub const TCP_CORK: ::c_int = 3; +pub const TCP_KEEPIDLE: ::c_int = 4; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_SYNCNT: ::c_int = 7; +pub const TCP_LINGER2: ::c_int = 8; +pub const TCP_DEFER_ACCEPT: ::c_int = 9; +pub const TCP_WINDOW_CLAMP: ::c_int = 10; +pub const TCP_INFO: ::c_int = 11; +pub const TCP_QUICKACK: ::c_int = 12; +pub const TCP_CONGESTION: ::c_int = 13; +pub const TCP_MD5SIG: ::c_int = 14; +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const SO_DEBUG: ::c_int = 1; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_LINGER: ::c_int = 13; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; diff --git a/src/macos.rs b/src/macos.rs new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/macros.rs b/src/macros.rs index 1089a856ab2ee..0c58de5fd26e5 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,12 +1,11 @@ -//! A macro for defining #[cfg] if-else statements. -//! -//! This is similar to the `if/elif` C preprocessor macro by allowing definition -//! of a cascade of `#[cfg]` cases, emitting the implementation which matches -//! first. -//! -//! This allows you to conveniently provide a long list #[cfg]'d blocks of code -//! without having to rewrite each clause multiple times. - +/// A macro for defining #[cfg] if-else statements. +/// +/// This is similar to the `if/elif` C preprocessor macro by allowing definition +/// of a cascade of `#[cfg]` cases, emitting the implementation which matches +/// first. +/// +/// This allows you to conveniently provide a long list #[cfg]'d blocks of code +/// without having to rewrite each clause multiple times. macro_rules! cfg_if { ($( if #[cfg($($meta:meta),*)] { $($it:item)* } @@ -35,6 +34,23 @@ macro_rules! __cfg_if_apply { } } +macro_rules! s { + ($(pub struct $i:ident { $($field:tt)* })*) => ($( + __item! { + #[repr(C)] + pub struct $i { $($field)* } + } + impl Copy for $i {} + impl Clone for $i { + fn clone(&self) -> $i { *self } + } + )*) +} + +macro_rules! __item { + ($i:item) => ($i) +} + #[cfg(test)] mod tests { cfg_if! { diff --git a/src/openbsdlike.rs b/src/openbsdlike.rs new file mode 100644 index 0000000000000..d3c0f5f50d755 --- /dev/null +++ b/src/openbsdlike.rs @@ -0,0 +1,713 @@ + + #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))] + pub mod os { + pub mod common { + pub mod posix01 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, size_t, + time_t, suseconds_t, c_long}; + use types::os::arch::c99::{uintptr_t}; + + pub type pthread_t = uintptr_t; + pub type rlim_t = u64; + + #[cfg(target_os = "bitrig")] + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: c_int, + pub gl_matchc: c_int, + pub gl_offs: c_int, + pub gl_flags: c_int, + pub gl_pathv: *mut *mut c_char, + __unused1: *mut c_void, + __unused2: *mut c_void, + __unused3: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + } + + #[cfg(any(target_os = "netbsd", target_os="openbsd"))] + #[repr(C)] + #[derive(Copy, Clone)] pub struct glob_t { + pub gl_pathc: c_int, + __unused1: c_int, + pub gl_offs: c_int, + __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + __unused3: *mut c_void, + + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, + __unused9: *mut c_void, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + + pub type sighandler_t = size_t; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + } + + pub mod bsd43 { + use types::os::common::posix01::timeval; + use types::os::arch::c95::c_long; + #[repr(C)] + #[derive(Copy, Clone)] + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + } + + pub mod bsd44 { + use types::common::c95::{c_void}; + use types::os::arch::c95::{c_char, c_int, c_uint}; + + pub type socklen_t = u32; + pub type sa_family_t = u8; + pub type in_port_t = u16; + pub type in_addr_t = u32; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: i64, + __ss_pad3: [u8; 240], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: in_addr_t, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8], + __align: [u32; 0], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + impl Clone for sockaddr_un { + fn clone(&self) -> sockaddr_un { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void + } + } + } + + #[cfg(target_arch = "x86_64")] + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i64; + pub type c_ulong = u64; + pub type c_float = f32; + pub type c_double = f64; + pub type size_t = u64; + pub type ptrdiff_t = i64; + pub type clock_t = i64; + pub type time_t = i64; + pub type suseconds_t = i64; + pub type wchar_t = i32; + } + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + pub type intptr_t = i64; + pub type uintptr_t = u64; + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + pub mod posix88 { + use types::os::arch::c95::{c_long}; + pub type off_t = i64; + pub type dev_t = i32; + pub type pid_t = i32; + pub type uid_t = u32; + pub type gid_t = u32; + pub type useconds_t = u32; + pub type mode_t = u32; + pub type ssize_t = c_long; + } + pub mod posix01 { + use types::common::c95::{c_void}; + use types::common::c99::{uint32_t, uint64_t}; + use types::os::arch::c95::{c_long, time_t}; + use types::os::arch::posix88::{dev_t, gid_t}; + use types::os::arch::posix88::{mode_t, off_t}; + use types::os::arch::posix88::{uid_t}; + + pub type nlink_t = uint32_t; + pub type blksize_t = uint32_t; + pub type ino_t = uint64_t; + pub type blkcnt_t = i64; + pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t + + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_mode: mode_t, + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + pub type pthread_attr_t = *mut c_void; + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + } + } + } + + #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 2147483647; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 2; + pub const _IOLBF : c_int = 1; + pub const BUFSIZ : c_uint = 1024; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 1024; + pub const L_tmpnam : c_uint = 1024; + pub const TMP_MAX : c_uint = 308915776; + } + pub mod c99 { + } + pub mod posix88 { + use types::common::c95::c_void; + use types::os::arch::c95::c_int; + use types::os::arch::posix88::mode_t; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 512; + pub const O_EXCL : c_int = 2048; + pub const O_NOCTTY : c_int = 32768; + pub const O_TRUNC : c_int = 1024; + pub const S_IFIFO : mode_t = 4096; + pub const S_IFCHR : mode_t = 8192; + pub const S_IFBLK : mode_t = 24576; + pub const S_IFDIR : mode_t = 16384; + pub const S_IFREG : mode_t = 32768; + pub const S_IFLNK : mode_t = 40960; + pub const S_IFSOCK : mode_t = 49152; + pub const S_IFMT : mode_t = 61440; + pub const S_IEXEC : mode_t = 64; + pub const S_IWRITE : mode_t = 128; + pub const S_IREAD : mode_t = 256; + pub const S_IRWXU : mode_t = 448; + pub const S_IXUSR : mode_t = 64; + pub const S_IWUSR : mode_t = 128; + pub const S_IRUSR : mode_t = 256; + pub const S_IRWXG : mode_t = 56; + pub const S_IXGRP : mode_t = 8; + pub const S_IWGRP : mode_t = 16; + pub const S_IRGRP : mode_t = 32; + pub const S_IRWXO : mode_t = 7; + pub const S_IXOTH : mode_t = 1; + pub const S_IWOTH : mode_t = 2; + pub const S_IROTH : mode_t = 4; + pub const F_OK : c_int = 0; + pub const R_OK : c_int = 4; + pub const W_OK : c_int = 2; + pub const X_OK : c_int = 1; + pub const STDIN_FILENO : c_int = 0; + pub const STDOUT_FILENO : c_int = 1; + pub const STDERR_FILENO : c_int = 2; + pub const F_LOCK : c_int = 1; + pub const F_TEST : c_int = 3; + pub const F_TLOCK : c_int = 2; + pub const F_ULOCK : c_int = 0; + pub const SIGHUP : c_int = 1; + pub const SIGINT : c_int = 2; + pub const SIGQUIT : c_int = 3; + pub const SIGILL : c_int = 4; + pub const SIGABRT : c_int = 6; + pub const SIGFPE : c_int = 8; + pub const SIGKILL : c_int = 9; + pub const SIGSEGV : c_int = 11; + pub const SIGPIPE : c_int = 13; + pub const SIGALRM : c_int = 14; + pub const SIGTERM : c_int = 15; + + pub const PROT_NONE : c_int = 0; + pub const PROT_READ : c_int = 1; + pub const PROT_WRITE : c_int = 2; + pub const PROT_EXEC : c_int = 4; + + pub const MAP_FILE : c_int = 0x0000; + pub const MAP_SHARED : c_int = 0x0001; + pub const MAP_PRIVATE : c_int = 0x0002; + pub const MAP_FIXED : c_int = 0x0010; + pub const MAP_ANON : c_int = 0x1000; + + pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + + pub const MCL_CURRENT : c_int = 0x0001; + pub const MCL_FUTURE : c_int = 0x0002; + + pub const MS_ASYNC : c_int = 0x0001; + pub const MS_SYNC : c_int = 0x0002; + pub const MS_INVALIDATE : c_int = 0x0004; + + pub const EPERM : c_int = 1; + pub const ENOENT : c_int = 2; + pub const ESRCH : c_int = 3; + pub const EINTR : c_int = 4; + pub const EIO : c_int = 5; + pub const ENXIO : c_int = 6; + pub const E2BIG : c_int = 7; + pub const ENOEXEC : c_int = 8; + pub const EBADF : c_int = 9; + pub const ECHILD : c_int = 10; + pub const EDEADLK : c_int = 11; + pub const ENOMEM : c_int = 12; + pub const EACCES : c_int = 13; + pub const EFAULT : c_int = 14; + pub const ENOTBLK : c_int = 15; + pub const EBUSY : c_int = 16; + pub const EEXIST : c_int = 17; + pub const EXDEV : c_int = 18; + pub const ENODEV : c_int = 19; + pub const ENOTDIR : c_int = 20; + pub const EISDIR : c_int = 21; + pub const EINVAL : c_int = 22; + pub const ENFILE : c_int = 23; + pub const EMFILE : c_int = 24; + pub const ENOTTY : c_int = 25; + pub const ETXTBSY : c_int = 26; + pub const EFBIG : c_int = 27; + pub const ENOSPC : c_int = 28; + pub const ESPIPE : c_int = 29; + pub const EROFS : c_int = 30; + pub const EMLINK : c_int = 31; + pub const EPIPE : c_int = 32; + pub const EDOM : c_int = 33; + pub const ERANGE : c_int = 34; + pub const EAGAIN : c_int = 35; + pub const EWOULDBLOCK : c_int = 35; + pub const EINPROGRESS : c_int = 36; + pub const EALREADY : c_int = 37; + pub const ENOTSOCK : c_int = 38; + pub const EDESTADDRREQ : c_int = 39; + pub const EMSGSIZE : c_int = 40; + pub const EPROTOTYPE : c_int = 41; + pub const ENOPROTOOPT : c_int = 42; + pub const EPROTONOSUPPORT : c_int = 43; + pub const ESOCKTNOSUPPORT : c_int = 44; + pub const EOPNOTSUPP : c_int = 45; + pub const EPFNOSUPPORT : c_int = 46; + pub const EAFNOSUPPORT : c_int = 47; + pub const EADDRINUSE : c_int = 48; + pub const EADDRNOTAVAIL : c_int = 49; + pub const ENETDOWN : c_int = 50; + pub const ENETUNREACH : c_int = 51; + pub const ENETRESET : c_int = 52; + pub const ECONNABORTED : c_int = 53; + pub const ECONNRESET : c_int = 54; + pub const ENOBUFS : c_int = 55; + pub const EISCONN : c_int = 56; + pub const ENOTCONN : c_int = 57; + pub const ESHUTDOWN : c_int = 58; + pub const ETOOMANYREFS : c_int = 59; + pub const ETIMEDOUT : c_int = 60; + pub const ECONNREFUSED : c_int = 61; + pub const ELOOP : c_int = 62; + pub const ENAMETOOLONG : c_int = 63; + pub const EHOSTDOWN : c_int = 64; + pub const EHOSTUNREACH : c_int = 65; + pub const ENOTEMPTY : c_int = 66; + pub const EPROCLIM : c_int = 67; + pub const EUSERS : c_int = 68; + pub const EDQUOT : c_int = 69; + pub const ESTALE : c_int = 70; + pub const EREMOTE : c_int = 71; + pub const EBADRPC : c_int = 72; + pub const ERPCMISMATCH : c_int = 73; + pub const EPROGUNAVAIL : c_int = 74; + pub const EPROGMISMATCH : c_int = 75; + pub const EPROCUNAVAIL : c_int = 76; + pub const ENOLCK : c_int = 77; + pub const ENOSYS : c_int = 78; + pub const EFTYPE : c_int = 79; + pub const EAUTH : c_int = 80; + pub const ENEEDAUTH : c_int = 81; + pub const EIPSEC : c_int = 82; + pub const ENOATTR : c_int = 83; + pub const EILSEQ : c_int = 84; + pub const ENOMEDIUM : c_int = 85; + pub const EMEDIUMTYPE : c_int = 86; + pub const EOVERFLOW : c_int = 87; + pub const ECANCELED : c_int = 88; + pub const EIDRM : c_int = 89; + pub const ENOMSG : c_int = 90; + pub const ENOTSUP : c_int = 91; + pub const ELAST : c_int = 91; // must be equal to largest errno + } + pub mod posix01 { + use types::os::arch::c95::{c_int, size_t}; + use types::os::common::posix01::rlim_t; + + pub const F_DUPFD : c_int = 0; + pub const F_GETFD : c_int = 1; + pub const F_SETFD : c_int = 2; + pub const F_GETFL : c_int = 3; + pub const F_SETFL : c_int = 4; + pub const F_GETOWN : c_int = 5; + pub const F_SETOWN : c_int = 6; + pub const F_GETLK : c_int = 7; + pub const F_SETLK : c_int = 8; + pub const F_SETLKW : c_int = 9; + pub const F_DUPFD_CLOEXEC : c_int = 10; + + pub const SIGTRAP : c_int = 5; + pub const SIG_IGN: size_t = 1; + + pub const GLOB_APPEND : c_int = 0x0001; + pub const GLOB_DOOFFS : c_int = 0x0002; + pub const GLOB_ERR : c_int = 0x0004; + pub const GLOB_MARK : c_int = 0x0008; + pub const GLOB_NOCHECK : c_int = 0x0010; + pub const GLOB_NOSORT : c_int = 0x0020; + pub const GLOB_NOESCAPE : c_int = 0x1000; + + pub const GLOB_NOSPACE : c_int = -1; + pub const GLOB_ABORTED : c_int = -2; + pub const GLOB_NOMATCH : c_int = -3; + pub const GLOB_NOSYS : c_int = -4; + + pub const POSIX_MADV_NORMAL : c_int = 0; + pub const POSIX_MADV_RANDOM : c_int = 1; + pub const POSIX_MADV_SEQUENTIAL : c_int = 2; + pub const POSIX_MADV_WILLNEED : c_int = 3; + pub const POSIX_MADV_DONTNEED : c_int = 4; + + pub const _SC_IOV_MAX : c_int = 51; + pub const _SC_GETGR_R_SIZE_MAX : c_int = 100; + pub const _SC_GETPW_R_SIZE_MAX : c_int = 101; + pub const _SC_LOGIN_NAME_MAX : c_int = 102; + pub const _SC_MQ_PRIO_MAX : c_int = 59; + pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; + pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; + pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80; + pub const _SC_THREAD_KEYS_MAX : c_int = 81; + pub const _SC_THREAD_PRIO_INHERIT : c_int = 82; + pub const _SC_THREAD_PRIO_PROTECT : c_int = 83; + pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84; + pub const _SC_THREAD_PROCESS_SHARED : c_int = 85; + pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103; + pub const _SC_THREAD_STACK_MIN : c_int = 89; + pub const _SC_THREAD_THREADS_MAX : c_int = 90; + pub const _SC_THREADS : c_int = 91; + pub const _SC_TTY_NAME_MAX : c_int = 107; + pub const _SC_ATEXIT_MAX : c_int = 46; + pub const _SC_XOPEN_CRYPT : c_int = 117; + pub const _SC_XOPEN_ENH_I18N : c_int = 118; + pub const _SC_XOPEN_LEGACY : c_int = 119; + pub const _SC_XOPEN_REALTIME : c_int = 120; + pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121; + pub const _SC_XOPEN_SHM : c_int = 30; + pub const _SC_XOPEN_UNIX : c_int = 123; + pub const _SC_XOPEN_VERSION : c_int = 125; + + pub const PTHREAD_CREATE_JOINABLE : c_int = 0; + pub const PTHREAD_CREATE_DETACHED : c_int = 1; + pub const PTHREAD_STACK_MIN : size_t = 2048; + + pub const CLOCK_REALTIME : c_int = 0; + pub const CLOCK_MONOTONIC : c_int = 3; + + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_MEMLOCK: c_int = 6; + pub const RLIMIT_NPROC: c_int = 7; + pub const RLIMIT_NOFILE: c_int = 8; + pub const RLIM_NLIMITS: c_int = 9; + + pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; + pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + + pub const RUSAGE_SELF: c_int = 0; + pub const RUSAGE_CHILDREN: c_int = -1; + pub const RUSAGE_THREAD: c_int = 1; + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const MADV_NORMAL : c_int = 0; + pub const MADV_RANDOM : c_int = 1; + pub const MADV_SEQUENTIAL : c_int = 2; + pub const MADV_WILLNEED : c_int = 3; + pub const MADV_DONTNEED : c_int = 4; + pub const MADV_FREE : c_int = 6; + + pub const AF_UNIX: c_int = 1; + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 24; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist + + pub const TCP_NODELAY: c_int = 0x01; + pub const SOL_SOCKET: c_int = 0xffff; + pub const SO_DEBUG: c_int = 0x01; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_REUSEPORT: c_int = 0x0200; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 0x8; + + pub const SHUT_RD: c_int = 0; + pub const SHUT_WR: c_int = 1; + pub const SHUT_RDWR: c_int = 2; + + pub const LOCK_SH: c_int = 1; + pub const LOCK_EX: c_int = 2; + pub const LOCK_NB: c_int = 4; + pub const LOCK_UN: c_int = 8; + } + pub mod extra { + use types::os::arch::c95::c_int; + + pub const O_DSYNC : c_int = 128; // same as SYNC + pub const O_SYNC : c_int = 128; + pub const O_NONBLOCK : c_int = 4; + pub const CTL_KERN : c_int = 1; + pub const KERN_PROC : c_int = 66; + + pub const MAP_COPY : c_int = 0x0002; + pub const MAP_RENAME : c_int = 0x0000; + pub const MAP_NORESERVE : c_int = 0x0000; + pub const MAP_NOEXTEND : c_int = 0x0000; + pub const MAP_HASSEMAPHORE : c_int = 0x0000; + + pub const IPPROTO_RAW : c_int = 255; + + pub const PATH_MAX: c_int = 1024; + } + pub mod sysconf { + use types::os::arch::c95::c_int; + + pub const _SC_ARG_MAX : c_int = 1; + pub const _SC_CHILD_MAX : c_int = 2; + pub const _SC_CLK_TCK : c_int = 3; + pub const _SC_NGROUPS_MAX : c_int = 4; + pub const _SC_OPEN_MAX : c_int = 5; + pub const _SC_JOB_CONTROL : c_int = 6; + pub const _SC_SAVED_IDS : c_int = 7; + pub const _SC_VERSION : c_int = 8; + pub const _SC_BC_BASE_MAX : c_int = 9; + pub const _SC_BC_DIM_MAX : c_int = 10; + pub const _SC_BC_SCALE_MAX : c_int = 11; + pub const _SC_BC_STRING_MAX : c_int = 12; + pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; + pub const _SC_EXPR_NEST_MAX : c_int = 14; + pub const _SC_LINE_MAX : c_int = 15; + pub const _SC_RE_DUP_MAX : c_int = 16; + pub const _SC_2_VERSION : c_int = 17; + pub const _SC_2_C_BIND : c_int = 18; + pub const _SC_2_C_DEV : c_int = 19; + pub const _SC_2_CHAR_TERM : c_int = 20; + pub const _SC_2_FORT_DEV : c_int = 21; + pub const _SC_2_FORT_RUN : c_int = 22; + pub const _SC_2_LOCALEDEF : c_int = 23; + pub const _SC_2_SW_DEV : c_int = 24; + pub const _SC_2_UPE : c_int = 25; + pub const _SC_STREAM_MAX : c_int = 26; + pub const _SC_TZNAME_MAX : c_int = 27; + pub const _SC_PAGESIZE : c_int = 28; + pub const _SC_FSYNC : c_int = 29; + pub const _SC_SEM_NSEMS_MAX : c_int = 31; + pub const _SC_SEM_VALUE_MAX : c_int = 32; + pub const _SC_AIO_LISTIO_MAX : c_int = 42; + pub const _SC_AIO_MAX : c_int = 43; + pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; + pub const _SC_ASYNCHRONOUS_IO : c_int = 45; + pub const _SC_DELAYTIMER_MAX : c_int = 50; + pub const _SC_MAPPED_FILES : c_int = 53; + pub const _SC_MEMLOCK : c_int = 54; + pub const _SC_MEMLOCK_RANGE : c_int = 55; + pub const _SC_MEMORY_PROTECTION : c_int = 56; + pub const _SC_MESSAGE_PASSING : c_int = 57; + pub const _SC_MQ_OPEN_MAX : c_int = 58; + pub const _SC_PRIORITIZED_IO : c_int = 60; + pub const _SC_PRIORITY_SCHEDULING : c_int = 61; + pub const _SC_REALTIME_SIGNALS : c_int = 64; + pub const _SC_RTSIG_MAX : c_int = 66; + pub const _SC_SEMAPHORES : c_int = 67; + pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68; + pub const _SC_SIGQUEUE_MAX : c_int = 70; + pub const _SC_SYNCHRONIZED_IO : c_int = 75; + pub const _SC_TIMER_MAX : c_int = 93; + pub const _SC_TIMERS : c_int = 94; + } + } + diff --git a/src/unix.rs b/src/unix.rs new file mode 100644 index 0000000000000..223351aeea39e --- /dev/null +++ b/src/unix.rs @@ -0,0 +1,309 @@ +extern { + pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "connect$UNIX2003")] + pub fn connect(socket: ::c_int, address: *const ::sockaddr, + len: ::socklen_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "bind$UNIX2003")] + pub fn bind(socket: ::c_int, address: *const ::sockaddr, + address_len: ::socklen_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "listen$UNIX2003")] + pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "accept$UNIX2003")] + pub fn accept(socket: ::c_int, address: *mut ::sockaddr, + address_len: *mut ::socklen_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "getpeername$UNIX2003")] + pub fn getpeername(socket: ::c_int, address: *mut ::sockaddr, + address_len: *mut ::socklen_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "getsockname$UNIX2003")] + pub fn getsockname(socket: ::c_int, address: *mut ::sockaddr, + address_len: *mut ::socklen_t) -> ::c_int; + pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int, + value: *const ::c_void, + option_len: ::socklen_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recv$UNIX2003")] + pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "send$UNIX2003")] + pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003")] + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "sendto$UNIX2003")] + pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_int, addr: *const ::sockaddr, + addrlen: ::socklen_t) -> ::ssize_t; + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "chmod$UNIX2003")] + pub fn chmod(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fchmod$UNIX2003")] + pub fn fchmod(fd: ::c_int, mode: ::mode_t) -> ::c_int; + + #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] + pub fn fstat(fildes: ::c_int, buf: *mut ::stat) -> ::c_int; + + pub fn mkdir(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + pub fn mkfifo(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + + #[cfg_attr(target_os = "macos", link_name = "::stat$INODE64")] + pub fn stat(path: *const ::c_char, buf: *mut ::stat) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003")] + pub fn popen(command: *const ::c_char, + mode: *const ::c_char) -> *mut ::FILE; + pub fn pclose(stream: *mut ::FILE) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fdopen$UNIX2003")] + pub fn fdopen(fd: ::c_int, mode: *const ::c_char) -> *mut ::FILE; + pub fn fileno(stream: *mut ::FILE) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "open$UNIX2003")] + pub fn open(path: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "creat$UNIX2003")] + pub fn creat(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fcntl$UNIX2003")] + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "opendir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "opendir$INODE64$UNIX2003")] + pub fn opendir(dirname: *const ::c_char) -> *mut ::DIR; + #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] + pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, + result: *mut *mut ::dirent) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "closedir$UNIX2003")] + pub fn closedir(dirp: *mut ::DIR) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "rewinddir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "rewinddir$INODE64$UNIX2003")] + pub fn rewinddir(dirp: *mut ::DIR); + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003")] + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003")] + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + + pub fn access(path: *const ::c_char, amode: ::c_int) -> ::c_int; + pub fn alarm(seconds: ::c_uint) -> ::c_uint; + pub fn chdir(dir: *const ::c_char) -> ::c_int; + pub fn chown(path: *const ::c_char, uid: ::uid_t, + gid: ::gid_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "close$UNIX2003")] + pub fn close(fd: ::c_int) -> ::c_int; + pub fn dup(fd: ::c_int) -> ::c_int; + pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; + pub fn execv(prog: *const ::c_char, + argv: *const *const ::c_char) -> ::c_int; + pub fn execve(prog: *const ::c_char, argv: *const *const ::c_char, + envp: *const *const ::c_char) + -> ::c_int; + pub fn execvp(c: *const ::c_char, + argv: *const *const ::c_char) -> ::c_int; + pub fn fork() -> ::pid_t; + pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> ::c_long; + pub fn getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char; + pub fn getegid() -> ::gid_t; + pub fn geteuid() -> ::uid_t; + pub fn getgid() -> ::gid_t; + pub fn getgroups(ngroups_max: ::c_int, groups: *mut ::gid_t) + -> ::c_int; + pub fn getlogin() -> *mut ::c_char; + // GNU getopt(3) modifies its arguments despite the + // char * const [] prototype; see the manpage. + pub fn getopt(argc: ::c_int, argv: *mut *mut ::c_char, + optstr: *const ::c_char) -> ::c_int; + pub fn getpgrp() -> ::pid_t; + pub fn getpid() -> ::pid_t; + pub fn getppid() -> ::pid_t; + pub fn getuid() -> ::uid_t; + pub fn getsid(pid: ::pid_t) -> ::pid_t; + pub fn isatty(fd: ::c_int) -> ::c_int; + pub fn link(src: *const ::c_char, dst: *const ::c_char) -> ::c_int; + pub fn lseek(fd: ::c_int, offset: ::off_t, whence: ::c_int) + -> ::off_t; + pub fn pathconf(path: *const ::c_char, name: ::c_int) -> ::c_long; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pause$UNIX2003")] + pub fn pause() -> ::c_int; + pub fn pipe(fds: *mut ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "read$UNIX2003")] + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) + -> ::ssize_t; + pub fn rmdir(path: *const ::c_char) -> ::c_int; + pub fn setgid(gid: ::gid_t) -> ::c_int; + pub fn setpgid(pid: ::pid_t, pgid: ::pid_t) -> ::c_int; + pub fn setsid() -> ::pid_t; + pub fn setuid(uid: ::uid_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "sleep$UNIX2003")] + pub fn sleep(secs: ::c_uint) -> ::c_uint; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "usleep$UNIX2003")] + pub fn usleep(secs: ::c_uint) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "nanosleep$UNIX2003")] + pub fn nanosleep(rqtp: *const ::timespec, + rmtp: *mut ::timespec) -> ::c_int; + pub fn sysconf(name: ::c_int) -> ::c_long; + pub fn tcgetpgrp(fd: ::c_int) -> ::pid_t; + pub fn ttyname(fd: ::c_int) -> *mut ::c_char; + pub fn unlink(c: *const ::c_char) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "wait$UNIX2003")] + pub fn wait(status: *mut ::c_int) -> ::pid_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "waitpid$UNIX2003")] + pub fn waitpid(pid: ::pid_t, status: *mut ::c_int, options: ::c_int) + -> ::pid_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "write$UNIX2003")] + pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) + -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pread$UNIX2003")] + pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, + offset: ::off_t) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pwrite$UNIX2003")] + pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, + offset: ::off_t) -> ::ssize_t; + pub fn utime(file: *const ::c_char, buf: *const ::utimbuf) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "kill$UNIX2003")] + pub fn kill(pid: ::pid_t, sig: ::c_int) -> ::c_int; + + pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn mlockall(flags: ::c_int) -> ::c_int; + pub fn munlockall() -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "mprotect$UNIX2003")] + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003")] + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) + -> ::c_int; + #[cfg(target_os = "macos")] + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) + -> ::c_int; + #[cfg(target_os = "linux")] + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, + mode: ::mode_t) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "mmap$UNIX2003")] + pub fn mmap(addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: ::off_t) + -> *mut ::c_void; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "munmap$UNIX2003")] + pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; + + pub fn if_nametoindex(ifname: *const ::c_char) -> ::c_uint; + + #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] + pub fn lstat(path: *const ::c_char, buf: *mut ::stat) -> ::c_int; + + pub fn readlink(path: *const ::c_char, + buf: *mut ::c_char, + bufsz: ::size_t) + -> ::ssize_t; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "fsync$UNIX2003")] + pub fn fsync(fd: ::c_int) -> ::c_int; + + #[cfg(any(target_os = "linux", target_os = "android"))] + pub fn fdatasync(fd: ::c_int) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "setenv$UNIX2003")] + pub fn setenv(name: *const ::c_char, val: *const ::c_char, + overwrite: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "unsetenv$UNIX2003")] + pub fn unsetenv(name: *const ::c_char) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "putenv$UNIX2003")] + pub fn putenv(string: *mut ::c_char) -> ::c_int; + + pub fn symlink(path1: *const ::c_char, + path2: *const ::c_char) -> ::c_int; + + pub fn ftruncate(fd: ::c_int, length: ::off_t) -> ::c_int; + + pub fn signal(signum: ::c_int, + handler: ::sighandler_t) -> ::sighandler_t; + + pub fn glob(pattern: *const ::c_char, + flags: ::c_int, + errfunc: Option ::c_int>, + pglob: *mut ::glob_t); + pub fn globfree(pglob: *mut ::glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn getrusage(resource: ::c_int, usage: *mut ::rusage) -> ::c_int; + + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn getdtablesize() -> ::c_int; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) + -> ::c_int; + #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] + pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) + -> *mut ::c_char; + + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; +} diff --git a/src/windows.rs b/src/windows.rs new file mode 100644 index 0000000000000..90b04919c68c8 --- /dev/null +++ b/src/windows.rs @@ -0,0 +1,1153 @@ + + + #[cfg(target_os = "windows")] + pub mod os { + pub mod common { + pub mod posix01 { + use types::os::arch::c95::{c_short, time_t, c_long}; + use types::os::arch::extra::{time64_t}; + use types::os::arch::posix88::{dev_t, ino_t}; + + // pub Note: this is the struct called stat64 in Windows. Not + // stat, nor stati64. + #[repr(C)] + #[derive(Copy, Clone)] pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: u16, + pub st_nlink: c_short, + pub st_uid: c_short, + pub st_gid: c_short, + pub st_rdev: dev_t, + pub st_size: i64, + pub st_atime: time64_t, + pub st_mtime: time64_t, + pub st_ctime: time64_t, + } + + // note that this is called utimbuf64 in Windows + #[repr(C)] + #[derive(Copy, Clone)] pub struct utimbuf { + pub actime: time64_t, + pub modtime: time64_t, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub enum timezone {} + } + + pub mod bsd44 { + use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; + use types::os::arch::c99::uintptr_t; + + pub type SOCKET = uintptr_t; + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr { + pub sa_family: u16, + pub sa_data: [u8; 14], + } + #[repr(C)] + #[derive(Copy)] pub struct sockaddr_storage { + pub ss_family: u16, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + impl Clone for sockaddr_storage { + fn clone(&self) -> sockaddr_storage { *self } + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in { + pub sin_family: u16, + pub sin_port: u16, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in_addr { + pub s_addr: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct sockaddr_in6 { + pub sin6_family: u16, + pub sin6_port: u16, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct in6_addr { + pub s6_addr: [u16; 8], + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + #[repr(C)] + #[derive(Copy, Clone)] pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: size_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + } + } + + pub mod arch { + pub mod c95 { + pub type c_char = i8; + pub type c_schar = i8; + pub type c_uchar = u8; + pub type c_short = i16; + pub type c_ushort = u16; + pub type c_int = i32; + pub type c_uint = u32; + pub type c_long = i32; + pub type c_ulong = u32; + pub type c_float = f32; + pub type c_double = f64; + + #[cfg(target_arch = "x86")] + pub type size_t = u32; + #[cfg(target_arch = "x86_64")] + pub type size_t = u64; + + #[cfg(target_arch = "x86")] + pub type ptrdiff_t = i32; + #[cfg(target_arch = "x86_64")] + pub type ptrdiff_t = i64; + + pub type clock_t = i32; + + cfg_if! { + if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { + pub type time_t = i32; + } else { + pub type time_t = i64; + } + } + + pub type wchar_t = u16; + } + + pub mod c99 { + pub type c_longlong = i64; + pub type c_ulonglong = u64; + + #[cfg(target_arch = "x86")] + pub type intptr_t = i32; + #[cfg(target_arch = "x86_64")] + pub type intptr_t = i64; + + #[cfg(target_arch = "x86")] + pub type uintptr_t = u32; + #[cfg(target_arch = "x86_64")] + pub type uintptr_t = u64; + + pub type intmax_t = i64; + pub type uintmax_t = u64; + } + + pub mod posix88 { + pub type off_t = i32; + pub type dev_t = u32; + pub type ino_t = u16; + + #[cfg(target_arch = "x86")] + pub type ssize_t = i32; + #[cfg(target_arch = "x86_64")] + pub type ssize_t = i64; + } + + pub mod posix01 { + } + pub mod posix08 { + } + pub mod bsd44 { + } + pub mod extra { + use consts::os::extra::{MAX_PROTOCOL_CHAIN, + WSAPROTOCOL_LEN}; + use types::common::c95::c_void; + use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; + use types::os::arch::c95::{c_long, c_ulong}; + use types::os::arch::c95::{wchar_t}; + use types::os::arch::c99::{c_ulonglong, c_longlong, uintptr_t}; + + pub type BOOL = c_int; + pub type BYTE = u8; + pub type BOOLEAN = BYTE; + pub type CCHAR = c_char; + pub type CHAR = c_char; + + pub type DWORD = c_ulong; + pub type DWORDLONG = c_ulonglong; + + pub type HANDLE = LPVOID; + pub type HINSTANCE = HANDLE; + pub type HMODULE = HINSTANCE; + + pub type LONG = c_long; + pub type PLONG = *mut c_long; + + #[cfg(target_arch = "x86")] + pub type LONG_PTR = c_long; + #[cfg(target_arch = "x86_64")] + pub type LONG_PTR = i64; + + pub type LARGE_INTEGER = c_longlong; + pub type PLARGE_INTEGER = *mut c_longlong; + + pub type LPCWSTR = *const WCHAR; + pub type LPCSTR = *const CHAR; + + pub type LPWSTR = *mut WCHAR; + pub type LPSTR = *mut CHAR; + + pub type LPWCH = *mut WCHAR; + pub type LPCH = *mut CHAR; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct SECURITY_ATTRIBUTES { + pub nLength: DWORD, + pub lpSecurityDescriptor: LPVOID, + pub bInheritHandle: BOOL, + } + pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; + + pub type LPVOID = *mut c_void; + pub type LPCVOID = *const c_void; + pub type LPBYTE = *mut BYTE; + pub type LPWORD = *mut WORD; + pub type LPDWORD = *mut DWORD; + pub type LPHANDLE = *mut HANDLE; + + pub type LRESULT = LONG_PTR; + pub type PBOOL = *mut BOOL; + pub type WCHAR = wchar_t; + pub type WORD = u16; + pub type SIZE_T = size_t; + + pub type time64_t = i64; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct STARTUPINFOW { + pub cb: DWORD, + pub lpReserved: LPWSTR, + pub lpDesktop: LPWSTR, + pub lpTitle: LPWSTR, + pub dwX: DWORD, + pub dwY: DWORD, + pub dwXSize: DWORD, + pub dwYSize: DWORD, + pub dwXCountChars: DWORD, + pub dwYCountChars: DWORD, + pub dwFillAttribute: DWORD, + pub dwFlags: DWORD, + pub wShowWindow: WORD, + pub cbReserved2: WORD, + pub lpReserved2: LPBYTE, + pub hStdInput: HANDLE, + pub hStdOutput: HANDLE, + pub hStdError: HANDLE, + } + pub type LPSTARTUPINFOW = *mut STARTUPINFOW; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION { + pub hProcess: HANDLE, + pub hThread: HANDLE, + pub dwProcessId: DWORD, + pub dwThreadId: DWORD, + } + pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct SYSTEM_INFO { + pub wProcessorArchitecture: WORD, + pub wReserved: WORD, + pub dwPageSize: DWORD, + pub lpMinimumApplicationAddress: LPVOID, + pub lpMaximumApplicationAddress: LPVOID, + pub dwActiveProcessorMask: uintptr_t, + pub dwNumberOfProcessors: DWORD, + pub dwProcessorType: DWORD, + pub dwAllocationGranularity: DWORD, + pub wProcessorLevel: WORD, + pub wProcessorRevision: WORD, + } + pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct MEMORY_BASIC_INFORMATION { + pub BaseAddress: LPVOID, + pub AllocationBase: LPVOID, + pub AllocationProtect: DWORD, + pub RegionSize: SIZE_T, + pub State: DWORD, + pub Protect: DWORD, + pub Type: DWORD, + } + pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct OVERLAPPED { + pub Internal: *mut c_ulong, + pub InternalHigh: *mut c_ulong, + pub Offset: DWORD, + pub OffsetHigh: DWORD, + pub hEvent: HANDLE, + } + + pub type LPOVERLAPPED = *mut OVERLAPPED; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct FILETIME { + pub dwLowDateTime: DWORD, + pub dwHighDateTime: DWORD, + } + + pub type LPFILETIME = *mut FILETIME; + + #[repr(C)] + #[derive(Copy, Clone)] pub struct GUID { + pub Data1: DWORD, + pub Data2: WORD, + pub Data3: WORD, + pub Data4: [BYTE; 8], + } + + #[repr(C)] + #[derive(Copy, Clone)] pub struct WSAPROTOCOLCHAIN { + pub ChainLen: c_int, + pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], + } + + pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; + + #[repr(C)] + #[derive(Copy)] pub struct WSAPROTOCOL_INFO { + pub dwServiceFlags1: DWORD, + pub dwServiceFlags2: DWORD, + pub dwServiceFlags3: DWORD, + pub dwServiceFlags4: DWORD, + pub dwProviderFlags: DWORD, + pub ProviderId: GUID, + pub dwCatalogEntryId: DWORD, + pub ProtocolChain: WSAPROTOCOLCHAIN, + pub iVersion: c_int, + pub iAddressFamily: c_int, + pub iMaxSockAddr: c_int, + pub iMinSockAddr: c_int, + pub iSocketType: c_int, + pub iProtocol: c_int, + pub iProtocolMaxOffset: c_int, + pub iNetworkByteOrder: c_int, + pub iSecurityScheme: c_int, + pub dwMessageSize: DWORD, + pub dwProviderReserved: DWORD, + pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], + } + impl Clone for WSAPROTOCOL_INFO { + fn clone(&self) -> WSAPROTOCOL_INFO { *self } + } + + pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; + + pub type GROUP = c_uint; + + #[repr(C)] + #[derive(Copy)] pub struct WIN32_FIND_DATAW { + pub dwFileAttributes: DWORD, + pub ftCreationTime: FILETIME, + pub ftLastAccessTime: FILETIME, + pub ftLastWriteTime: FILETIME, + pub nFileSizeHigh: DWORD, + pub nFileSizeLow: DWORD, + pub dwReserved0: DWORD, + pub dwReserved1: DWORD, + pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 + pub cAlternateFileName: [wchar_t; 14], + } + impl Clone for WIN32_FIND_DATAW { + fn clone(&self) -> WIN32_FIND_DATAW { *self } + } + + pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; + } + } + } + #[cfg(target_os = "windows")] + pub mod os { + pub mod c95 { + use types::os::arch::c95::{c_int, c_uint}; + + pub const EXIT_FAILURE : c_int = 1; + pub const EXIT_SUCCESS : c_int = 0; + pub const RAND_MAX : c_int = 32767; + pub const EOF : c_int = -1; + pub const SEEK_SET : c_int = 0; + pub const SEEK_CUR : c_int = 1; + pub const SEEK_END : c_int = 2; + pub const _IOFBF : c_int = 0; + pub const _IONBF : c_int = 4; + pub const _IOLBF : c_int = 64; + pub const BUFSIZ : c_uint = 512; + pub const FOPEN_MAX : c_uint = 20; + pub const FILENAME_MAX : c_uint = 260; + + pub const WSAEINTR: c_int = 10004; + pub const WSAEBADF: c_int = 10009; + pub const WSAEACCES: c_int = 10013; + pub const WSAEFAULT: c_int = 10014; + pub const WSAEINVAL: c_int = 10022; + pub const WSAEMFILE: c_int = 10024; + pub const WSAEWOULDBLOCK: c_int = 10035; + pub const WSAEINPROGRESS: c_int = 10036; + pub const WSAEALREADY: c_int = 10037; + pub const WSAENOTSOCK: c_int = 10038; + pub const WSAEDESTADDRREQ: c_int = 10039; + pub const WSAEMSGSIZE: c_int = 10040; + pub const WSAEPROTOTYPE: c_int = 10041; + pub const WSAENOPROTOOPT: c_int = 10042; + pub const WSAEPROTONOSUPPORT: c_int = 10043; + pub const WSAESOCKTNOSUPPORT: c_int = 10044; + pub const WSAEOPNOTSUPP: c_int = 10045; + pub const WSAEPFNOSUPPORT: c_int = 10046; + pub const WSAEAFNOSUPPORT: c_int = 10047; + pub const WSAEADDRINUSE: c_int = 10048; + pub const WSAEADDRNOTAVAIL: c_int = 10049; + pub const WSAENETDOWN: c_int = 10050; + pub const WSAENETUNREACH: c_int = 10051; + pub const WSAENETRESET: c_int = 10052; + pub const WSAECONNABORTED: c_int = 10053; + pub const WSAECONNRESET: c_int = 10054; + pub const WSAENOBUFS: c_int = 10055; + pub const WSAEISCONN: c_int = 10056; + pub const WSAENOTCONN: c_int = 10057; + pub const WSAESHUTDOWN: c_int = 10058; + pub const WSAETOOMANYREFS: c_int = 10059; + pub const WSAETIMEDOUT: c_int = 10060; + pub const WSAECONNREFUSED: c_int = 10061; + pub const WSAELOOP: c_int = 10062; + pub const WSAENAMETOOLONG: c_int = 10063; + pub const WSAEHOSTDOWN: c_int = 10064; + pub const WSAEHOSTUNREACH: c_int = 10065; + pub const WSAENOTEMPTY: c_int = 10066; + pub const WSAEPROCLIM: c_int = 10067; + pub const WSAEUSERS: c_int = 10068; + pub const WSAEDQUOT: c_int = 10069; + pub const WSAESTALE: c_int = 10070; + pub const WSAEREMOTE: c_int = 10071; + pub const WSASYSNOTREADY: c_int = 10091; + pub const WSAVERNOTSUPPORTED: c_int = 10092; + pub const WSANOTINITIALISED: c_int = 10093; + pub const WSAEDISCON: c_int = 10101; + pub const WSAENOMORE: c_int = 10102; + pub const WSAECANCELLED: c_int = 10103; + pub const WSAEINVALIDPROCTABLE: c_int = 10104; + pub const WSAEINVALIDPROVIDER: c_int = 10105; + pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; + + cfg_if! { + if #[cfg(all(target_env = "gnu"))] { + pub const L_tmpnam : c_uint = 14; + pub const TMP_MAX : c_uint = 0x7fff; + } else { + pub const L_tmpnam : c_uint = 260; + pub const TMP_MAX : c_uint = 0x7fff_ffff; + } + } + } + pub mod c99 { + } + pub mod posix88 { + use types::os::arch::c95::c_int; + + pub const O_RDONLY : c_int = 0; + pub const O_WRONLY : c_int = 1; + pub const O_RDWR : c_int = 2; + pub const O_APPEND : c_int = 8; + pub const O_CREAT : c_int = 256; + pub const O_EXCL : c_int = 1024; + pub const O_TRUNC : c_int = 512; + pub const S_IFCHR : c_int = 8192; + pub const S_IFDIR : c_int = 16384; + pub const S_IFREG : c_int = 32768; + pub const S_IFMT : c_int = 61440; + pub const S_IEXEC : c_int = 64; + pub const S_IWRITE : c_int = 128; + pub const S_IREAD : c_int = 256; + } + pub mod posix01 { + } + pub mod posix08 { + } + pub mod bsd44 { + use types::os::arch::c95::c_int; + + pub const AF_INET: c_int = 2; + pub const AF_INET6: c_int = 23; + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + pub const SOCK_RAW: c_int = 3; + pub const IPPROTO_TCP: c_int = 6; + pub const IPPROTO_IP: c_int = 0; + pub const IPPROTO_IPV6: c_int = 41; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + pub const IPV6_ADD_MEMBERSHIP: c_int = 12; + pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + pub const IP_TTL: c_int = 4; + pub const IP_HDRINCL: c_int = 2; + + pub const TCP_NODELAY: c_int = 0x0001; + pub const SOL_SOCKET: c_int = 0xffff; + + pub const SO_DEBUG: c_int = 0x0001; + pub const SO_ACCEPTCONN: c_int = 0x0002; + pub const SO_REUSEADDR: c_int = 0x0004; + pub const SO_KEEPALIVE: c_int = 0x0008; + pub const SO_DONTROUTE: c_int = 0x0010; + pub const SO_BROADCAST: c_int = 0x0020; + pub const SO_USELOOPBACK: c_int = 0x0040; + pub const SO_LINGER: c_int = 0x0080; + pub const SO_OOBINLINE: c_int = 0x0100; + pub const SO_SNDBUF: c_int = 0x1001; + pub const SO_RCVBUF: c_int = 0x1002; + pub const SO_SNDLOWAT: c_int = 0x1003; + pub const SO_RCVLOWAT: c_int = 0x1004; + pub const SO_SNDTIMEO: c_int = 0x1005; + pub const SO_RCVTIMEO: c_int = 0x1006; + pub const SO_ERROR: c_int = 0x1007; + pub const SO_TYPE: c_int = 0x1008; + + pub const IFF_LOOPBACK: c_int = 4; + + pub const SD_RECEIVE: c_int = 0; + pub const SD_SEND: c_int = 1; + pub const SD_BOTH: c_int = 2; + } + pub mod extra { + use types::os::common::bsd44::SOCKET; + use types::os::arch::c95::{c_int, c_long}; + use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE}; + + pub const TRUE : BOOL = 1; + pub const FALSE : BOOL = 0; + + pub const O_TEXT : c_int = 16384; + pub const O_BINARY : c_int = 32768; + pub const O_NOINHERIT: c_int = 128; + + pub const ERROR_SUCCESS : c_int = 0; + pub const ERROR_INVALID_FUNCTION: c_int = 1; + pub const ERROR_FILE_NOT_FOUND: c_int = 2; + pub const ERROR_ACCESS_DENIED: c_int = 5; + pub const ERROR_INVALID_HANDLE : c_int = 6; + pub const ERROR_BROKEN_PIPE: c_int = 109; + pub const ERROR_DISK_FULL : c_int = 112; + pub const ERROR_CALL_NOT_IMPLEMENTED : c_int = 120; + pub const ERROR_INSUFFICIENT_BUFFER : c_int = 122; + pub const ERROR_INVALID_NAME : c_int = 123; + pub const ERROR_ALREADY_EXISTS : c_int = 183; + pub const ERROR_PIPE_BUSY: c_int = 231; + pub const ERROR_NO_DATA: c_int = 232; + pub const ERROR_INVALID_ADDRESS : c_int = 487; + pub const ERROR_PIPE_CONNECTED: c_int = 535; + pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758; + pub const ERROR_OPERATION_ABORTED: c_int = 995; + pub const ERROR_IO_PENDING: c_int = 997; + pub const ERROR_FILE_INVALID : c_int = 1006; + pub const ERROR_NOT_FOUND: c_int = 1168; + pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; + + pub const DELETE : DWORD = 0x00010000; + pub const READ_CONTROL : DWORD = 0x00020000; + pub const SYNCHRONIZE : DWORD = 0x00100000; + pub const WRITE_DAC : DWORD = 0x00040000; + pub const WRITE_OWNER : DWORD = 0x00080000; + + pub const PROCESS_CREATE_PROCESS : DWORD = 0x0080; + pub const PROCESS_CREATE_THREAD : DWORD = 0x0002; + pub const PROCESS_DUP_HANDLE : DWORD = 0x0040; + pub const PROCESS_QUERY_INFORMATION : DWORD = 0x0400; + pub const PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000; + pub const PROCESS_SET_INFORMATION : DWORD = 0x0200; + pub const PROCESS_SET_QUOTA : DWORD = 0x0100; + pub const PROCESS_SUSPEND_RESUME : DWORD = 0x0800; + pub const PROCESS_TERMINATE : DWORD = 0x0001; + pub const PROCESS_VM_OPERATION : DWORD = 0x0008; + pub const PROCESS_VM_READ : DWORD = 0x0010; + pub const PROCESS_VM_WRITE : DWORD = 0x0020; + + pub const STARTF_FORCEONFEEDBACK : DWORD = 0x00000040; + pub const STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080; + pub const STARTF_PREVENTPINNING : DWORD = 0x00002000; + pub const STARTF_RUNFULLSCREEN : DWORD = 0x00000020; + pub const STARTF_TITLEISAPPID : DWORD = 0x00001000; + pub const STARTF_TITLEISLINKNAME : DWORD = 0x00000800; + pub const STARTF_USECOUNTCHARS : DWORD = 0x00000008; + pub const STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010; + pub const STARTF_USEHOTKEY : DWORD = 0x00000200; + pub const STARTF_USEPOSITION : DWORD = 0x00000004; + pub const STARTF_USESHOWWINDOW : DWORD = 0x00000001; + pub const STARTF_USESIZE : DWORD = 0x00000002; + pub const STARTF_USESTDHANDLES : DWORD = 0x00000100; + + pub const WAIT_ABANDONED : DWORD = 0x00000080; + pub const WAIT_OBJECT_0 : DWORD = 0x00000000; + pub const WAIT_TIMEOUT : DWORD = 0x00000102; + pub const WAIT_FAILED : DWORD = !0; + + pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001; + pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002; + + pub const INFINITE : DWORD = !0; + pub const STILL_ACTIVE : DWORD = 259; + + pub const MEM_COMMIT : DWORD = 0x00001000; + pub const MEM_RESERVE : DWORD = 0x00002000; + pub const MEM_DECOMMIT : DWORD = 0x00004000; + pub const MEM_RELEASE : DWORD = 0x00008000; + pub const MEM_RESET : DWORD = 0x00080000; + pub const MEM_RESET_UNDO : DWORD = 0x1000000; + pub const MEM_LARGE_PAGES : DWORD = 0x20000000; + pub const MEM_PHYSICAL : DWORD = 0x00400000; + pub const MEM_TOP_DOWN : DWORD = 0x00100000; + pub const MEM_WRITE_WATCH : DWORD = 0x00200000; + + pub const PAGE_EXECUTE : DWORD = 0x10; + pub const PAGE_EXECUTE_READ : DWORD = 0x20; + pub const PAGE_EXECUTE_READWRITE : DWORD = 0x40; + pub const PAGE_EXECUTE_WRITECOPY : DWORD = 0x80; + pub const PAGE_NOACCESS : DWORD = 0x01; + pub const PAGE_READONLY : DWORD = 0x02; + pub const PAGE_READWRITE : DWORD = 0x04; + pub const PAGE_WRITECOPY : DWORD = 0x08; + pub const PAGE_GUARD : DWORD = 0x100; + pub const PAGE_NOCACHE : DWORD = 0x200; + pub const PAGE_WRITECOMBINE : DWORD = 0x400; + + pub const SEC_COMMIT : DWORD = 0x8000000; + pub const SEC_IMAGE : DWORD = 0x1000000; + pub const SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000; + pub const SEC_LARGE_PAGES : DWORD = 0x80000000; + pub const SEC_NOCACHE : DWORD = 0x10000000; + pub const SEC_RESERVE : DWORD = 0x4000000; + pub const SEC_WRITECOMBINE : DWORD = 0x40000000; + + pub const FILE_MAP_ALL_ACCESS : DWORD = 0xf001f; + pub const FILE_MAP_READ : DWORD = 0x4; + pub const FILE_MAP_WRITE : DWORD = 0x2; + pub const FILE_MAP_COPY : DWORD = 0x1; + pub const FILE_MAP_EXECUTE : DWORD = 0x20; + + pub const PROCESSOR_ARCHITECTURE_INTEL : WORD = 0; + pub const PROCESSOR_ARCHITECTURE_ARM : WORD = 5; + pub const PROCESSOR_ARCHITECTURE_IA64 : WORD = 6; + pub const PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9; + pub const PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff; + + pub const MOVEFILE_COPY_ALLOWED: DWORD = 2; + pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16; + pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4; + pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32; + pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1; + pub const MOVEFILE_WRITE_THROUGH: DWORD = 8; + + pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1; + + pub const FILE_SHARE_DELETE: DWORD = 0x4; + pub const FILE_SHARE_READ: DWORD = 0x1; + pub const FILE_SHARE_WRITE: DWORD = 0x2; + + pub const CREATE_ALWAYS: DWORD = 2; + pub const CREATE_NEW: DWORD = 1; + pub const OPEN_ALWAYS: DWORD = 4; + pub const OPEN_EXISTING: DWORD = 3; + pub const TRUNCATE_EXISTING: DWORD = 5; + + pub const FILE_APPEND_DATA: DWORD = 0x00000004; + pub const FILE_READ_DATA: DWORD = 0x00000001; + pub const FILE_WRITE_DATA: DWORD = 0x00000002; + + pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20; + pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800; + pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40; + pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10; + pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000; + pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2; + pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000; + pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80; + pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000; + pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000; + pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000; + pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1; + pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400; + pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200; + pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4; + pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100; + pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000; + + pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; + pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; + pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; + pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; + pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; + pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; + pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000; + pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; + pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; + pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; + pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; + pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; + + pub const FILE_NAME_NORMALIZED: DWORD = 0x0; + pub const FILE_NAME_OPENED: DWORD = 0x8; + + pub const VOLUME_NAME_DOS: DWORD = 0x0; + pub const VOLUME_NAME_GUID: DWORD = 0x1; + pub const VOLUME_NAME_NONE: DWORD = 0x4; + pub const VOLUME_NAME_NT: DWORD = 0x2; + + pub const GENERIC_READ: DWORD = 0x80000000; + pub const GENERIC_WRITE: DWORD = 0x40000000; + pub const GENERIC_EXECUTE: DWORD = 0x20000000; + pub const GENERIC_ALL: DWORD = 0x10000000; + pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100; + pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080; + + pub const STANDARD_RIGHTS_READ: DWORD = 0x20000; + pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000; + pub const FILE_WRITE_EA: DWORD = 0x00000010; + pub const FILE_READ_EA: DWORD = 0x00000008; + pub const FILE_GENERIC_READ: DWORD = + STANDARD_RIGHTS_READ | FILE_READ_DATA | + FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; + pub const FILE_GENERIC_WRITE: DWORD = + STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | + FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | + SYNCHRONIZE; + + pub const FILE_BEGIN: DWORD = 0; + pub const FILE_CURRENT: DWORD = 1; + pub const FILE_END: DWORD = 2; + + pub const MAX_PROTOCOL_CHAIN: DWORD = 7; + pub const WSAPROTOCOL_LEN: DWORD = 255; + pub const INVALID_SOCKET: SOCKET = !0; + + pub const DETACHED_PROCESS: DWORD = 0x00000008; + pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; + pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; + + pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; + pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; + pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; + pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; + pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; + pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; + pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; + pub const PIPE_WAIT: DWORD = 0x00000000; + pub const PIPE_NOWAIT: DWORD = 0x00000001; + pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; + pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; + pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; + + pub const IPPROTO_RAW: c_int = 255; + + pub const FIONBIO: c_long = -0x7FFB9982; + } + pub mod sysconf { + } + } + + + + #[cfg(target_os = "windows")] + pub mod posix88 { + pub mod stat_ { + use types::os::common::posix01::{stat, utimbuf}; + use types::os::arch::c95::{c_int, c_char, wchar_t}; + + extern { + #[link_name = "_chmod"] + pub fn chmod(path: *const c_char, mode: c_int) -> c_int; + #[link_name = "_wchmod"] + pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; + #[link_name = "_mkdir"] + pub fn mkdir(path: *const c_char) -> c_int; + #[link_name = "_wrmdir"] + pub fn wrmdir(path: *const wchar_t) -> c_int; + #[link_name = "_fstat64"] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + #[link_name = "_stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + #[link_name = "_wstat64"] + pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; + #[link_name = "_wutime64"] + pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; + } + } + + pub mod stdio { + use types::common::c95::FILE; + use types::os::arch::c95::{c_int, c_char}; + + extern { + #[link_name = "_popen"] + pub fn popen(command: *const c_char, + mode: *const c_char) -> *mut FILE; + #[link_name = "_pclose"] + pub fn pclose(stream: *mut FILE) -> c_int; + #[link_name = "_fdopen"] + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; + #[link_name = "_fileno"] + pub fn fileno(stream: *mut FILE) -> c_int; + } + } + + pub mod fcntl { + use types::os::arch::c95::{c_int, c_char, wchar_t}; + extern { + #[link_name = "_open"] + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + #[link_name = "_wopen"] + pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int; + #[link_name = "_creat"] + pub fn creat(path: *const c_char, mode: c_int) -> c_int; + } + } + + pub mod dirent { + // Not supplied at all. + } + + pub mod unistd { + use types::common::c95::c_void; + use types::os::arch::c95::{c_int, c_uint, c_char, c_long}; + use types::os::arch::c99::intptr_t; + + extern { + #[link_name = "_access"] + pub fn access(path: *const c_char, amode: c_int) -> c_int; + #[link_name = "_chdir"] + pub fn chdir(dir: *const c_char) -> c_int; + #[link_name = "_close"] + pub fn close(fd: c_int) -> c_int; + #[link_name = "_dup"] + pub fn dup(fd: c_int) -> c_int; + #[link_name = "_dup2"] + pub fn dup2(src: c_int, dst: c_int) -> c_int; + #[link_name = "_execv"] + pub fn execv(prog: *const c_char, + argv: *const *const c_char) -> intptr_t; + #[link_name = "_execve"] + pub fn execve(prog: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) + -> c_int; + #[link_name = "_execvp"] + pub fn execvp(c: *const c_char, + argv: *const *const c_char) -> c_int; + #[link_name = "_execvpe"] + pub fn execvpe(c: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) -> c_int; + #[link_name = "_getcwd"] + pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char; + #[link_name = "_getpid"] + pub fn getpid() -> c_int; + #[link_name = "_isatty"] + pub fn isatty(fd: c_int) -> c_int; + #[link_name = "_lseek"] + pub fn lseek(fd: c_int, offset: c_long, origin: c_int) + -> c_long; + #[link_name = "_pipe"] + pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) + -> c_int; + #[link_name = "_read"] + pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) + -> c_int; + #[link_name = "_rmdir"] + pub fn rmdir(path: *const c_char) -> c_int; + #[link_name = "_unlink"] + pub fn unlink(c: *const c_char) -> c_int; + #[link_name = "_write"] + pub fn write(fd: c_int, buf: *const c_void, + count: c_uint) -> c_int; + } + } + + pub mod mman { + } + } + + + #[cfg(target_os = "windows")] + pub mod extra { + + pub mod kernel32 { + use types::os::arch::c95::{c_uint}; + use types::os::arch::extra::*; + + extern "system" { + pub fn GetEnvironmentVariableW(n: LPCWSTR, + v: LPWSTR, + nsize: DWORD) + -> DWORD; + pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) + -> BOOL; + pub fn GetEnvironmentStringsW() -> LPWCH; + pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL; + pub fn GetModuleFileNameW(hModule: HMODULE, + lpFilename: LPWSTR, + nSize: DWORD) + -> DWORD; + pub fn CreateDirectoryW(lpPathName: LPCWSTR, + lpSecurityAttributes: + LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn CopyFileW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + bFailIfExists: BOOL) + -> BOOL; + pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL; + pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetCurrentDirectoryW(nBufferLength: DWORD, + lpBuffer: LPWSTR) + -> DWORD; + pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetLastError() -> DWORD; + pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) + -> HANDLE; + pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) + -> BOOL; + pub fn FindClose(findFile: HANDLE) -> BOOL; + pub fn DuplicateHandle(hSourceProcessHandle: HANDLE, + hSourceHandle: HANDLE, + hTargetProcessHandle: HANDLE, + lpTargetHandle: LPHANDLE, + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwOptions: DWORD) + -> BOOL; + pub fn CloseHandle(hObject: HANDLE) -> BOOL; + pub fn OpenProcess(dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwProcessId: DWORD) + -> HANDLE; + pub fn GetCurrentProcess() -> HANDLE; + pub fn CreateProcessW(lpApplicationName: LPCWSTR, + lpCommandLine: LPWSTR, + lpProcessAttributes: + LPSECURITY_ATTRIBUTES, + lpThreadAttributes: + LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpEnvironment: LPVOID, + lpCurrentDirectory: LPCWSTR, + lpStartupInfo: LPSTARTUPINFOW, + lpProcessInformation: + LPPROCESS_INFORMATION) + -> BOOL; + pub fn WaitForSingleObject(hHandle: HANDLE, + dwMilliseconds: DWORD) + -> DWORD; + pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) + -> BOOL; + pub fn GetExitCodeProcess(hProcess: HANDLE, + lpExitCode: LPDWORD) + -> BOOL; + pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); + pub fn VirtualAlloc(lpAddress: LPVOID, + dwSize: SIZE_T, + flAllocationType: DWORD, + flProtect: DWORD) + -> LPVOID; + pub fn VirtualFree(lpAddress: LPVOID, + dwSize: SIZE_T, + dwFreeType: DWORD) + -> BOOL; + pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; + pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) + -> BOOL; + pub fn VirtualProtect(lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, + lpflOldProtect: LPDWORD) + -> BOOL; + pub fn VirtualQuery(lpAddress: LPCVOID, + lpBuffer: PMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T) + -> SIZE_T; + pub fn CreateFileMappingW(hFile: HANDLE, + lpAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR) + -> HANDLE; + pub fn MapViewOfFile(hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, + dwNumberOfBytesToMap: SIZE_T) + -> LPVOID; + pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; + pub fn MoveFileExW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + dwFlags: DWORD) -> BOOL; + pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR, + lpTargetFileName: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; + pub fn CreateFileW(lpFileName: LPCWSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE) -> HANDLE; + pub fn ReadFile(hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToRead: DWORD, + lpNumberOfBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WriteFile(hFile: HANDLE, + lpBuffer: LPCVOID, + nNumberOfBytesToWrite: DWORD, + lpNumberOfBytesWritten: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn SetFilePointerEx(hFile: HANDLE, + liDistanceToMove: LARGE_INTEGER, + lpNewFilePointer: PLARGE_INTEGER, + dwMoveMethod: DWORD) -> BOOL; + pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; + + pub fn GetSystemTimeAsFileTime( + lpSystemTimeAsFileTime: LPFILETIME); + + pub fn QueryPerformanceFrequency( + lpFrequency: *mut LARGE_INTEGER) -> BOOL; + pub fn QueryPerformanceCounter( + lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL; + + pub fn GetCurrentProcessId() -> DWORD; + pub fn CreateNamedPipeW( + lpName: LPCWSTR, + dwOpenMode: DWORD, + dwPipeMode: DWORD, + nMaxInstances: DWORD, + nOutBufferSize: DWORD, + nInBufferSize: DWORD, + nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES + ) -> HANDLE; + pub fn ConnectNamedPipe(hNamedPipe: HANDLE, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, + nTimeOut: DWORD) -> BOOL; + pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE, + lpMode: LPDWORD, + lpMaxCollectionCount: LPDWORD, + lpCollectDataTimeout: LPDWORD) + -> BOOL; + pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + bInitialState: BOOL, + lpName: LPCWSTR) -> HANDLE; + pub fn GetOverlappedResult(hFile: HANDLE, + lpOverlapped: LPOVERLAPPED, + lpNumberOfBytesTransferred: LPDWORD, + bWait: BOOL) -> BOOL; + pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; + } + } + + pub mod msvcrt { + use types::os::arch::c95::c_int; + use types::os::arch::c99::intptr_t; + + extern { + #[link_name = "_commit"] + pub fn commit(fd: c_int) -> c_int; + + #[link_name = "_get_osfhandle"] + pub fn get_osfhandle(fd: c_int) -> intptr_t; + + #[link_name = "_open_osfhandle"] + pub fn open_osfhandle(osfhandle: intptr_t, + flags: c_int) -> c_int; + } + } + + pub mod winsock { + use types::os::arch::c95::{c_int, c_long, c_ulong}; + use types::os::common::bsd44::SOCKET; + + extern "system" { + pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int; + } + } + } + + #[cfg(windows)] + pub mod bsd43 { + use types::os::common::bsd44::{sockaddr, SOCKET}; + use types::os::arch::c95::{c_int, c_char}; + + extern "system" { + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; + pub fn connect(socket: SOCKET, address: *const sockaddr, + len: c_int) -> c_int; + pub fn bind(socket: SOCKET, address: *const sockaddr, + address_len: c_int) -> c_int; + pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; + pub fn accept(socket: SOCKET, address: *mut sockaddr, + address_len: *mut c_int) -> SOCKET; + pub fn getpeername(socket: SOCKET, address: *mut sockaddr, + address_len: *mut c_int) -> c_int; + pub fn getsockname(socket: SOCKET, address: *mut sockaddr, + address_len: *mut c_int) -> c_int; + pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, + value: *const c_char, + option_len: c_int) -> c_int; + pub fn closesocket(socket: SOCKET) -> c_int; + pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int, + flags: c_int) -> c_int; + pub fn send(socket: SOCKET, buf: *const c_char, len: c_int, + flags: c_int) -> c_int; + pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut c_int) -> c_int; + pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int, + flags: c_int, addr: *const sockaddr, + addrlen: c_int) -> c_int; + pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; + } + } From 084f9ea0e558171095ad562ce0400323966a38c1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 15:11:59 -0700 Subject: [PATCH 044/194] Get OSX working --- src/apple.rs | 918 ------------------------------------------- src/apple/b32.rs | 13 + src/apple/b64.rs | 13 + src/apple/mod.rs | 697 ++++++++++++++++++++++++++++++++ src/bsdlike.rs | 13 - src/lib.rs | 35 +- src/linuxlike/mod.rs | 5 - src/unix.rs | 18 +- 8 files changed, 763 insertions(+), 949 deletions(-) delete mode 100644 src/apple.rs create mode 100644 src/apple/b32.rs create mode 100644 src/apple/b64.rs create mode 100644 src/apple/mod.rs delete mode 100644 src/bsdlike.rs diff --git a/src/apple.rs b/src/apple.rs deleted file mode 100644 index bc5b1d36b6e4d..0000000000000 --- a/src/apple.rs +++ /dev/null @@ -1,918 +0,0 @@ - - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::c_void; - use types::os::arch::c95::{c_char, c_int, size_t, time_t}; - use types::os::arch::c95::{suseconds_t, c_long}; - use types::os::arch::c99::{uintptr_t}; - - pub type pthread_t = uintptr_t; - pub type rlim_t = u64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: size_t, - __unused1: c_int, - pub gl_offs: size_t, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, - - __unused3: *mut c_void, - - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u8; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - } - } - - #[cfg(any(target_arch = "arm", target_arch = "x86"))] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i32; - pub type c_ulong = u32; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u32; - pub type ptrdiff_t = i32; - pub type clock_t = c_ulong; - pub type time_t = c_long; - pub type suseconds_t = i32; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i32; - pub type uintptr_t = u32; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - use types::os::arch::c95::c_long; - - pub type off_t = i64; - pub type dev_t = i32; - pub type ino_t = u64; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = c_long; - } - pub mod posix01 { - use types::common::c99::{int32_t, int64_t, uint32_t}; - use types::os::arch::c95::{c_char, c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t, - mode_t, off_t, uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = i32; - pub type blkcnt_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_ino: ino_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: uint32_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_qspare: [int64_t; 2], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { - __sig: c_long, - __opaque: [c_char; 36] - } - impl Clone for pthread_attr_t { - fn clone(&self) -> pthread_attr_t { *self } - } - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - #[repr(C)] - #[derive(Copy, Clone)] pub struct mach_timebase_info { - pub numer: u32, - pub denom: u32, - } - - pub type mach_timebase_info_data_t = mach_timebase_info; - } - } - - #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = c_ulong; - pub type time_t = c_long; - pub type suseconds_t = i32; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - use types::os::arch::c95::c_long; - - pub type off_t = i64; - pub type dev_t = i32; - pub type ino_t = u64; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = c_long; - } - pub mod posix01 { - use types::common::c99::{int32_t, int64_t}; - use types::common::c99::{uint32_t}; - use types::os::arch::c95::{c_char, c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t, uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = i32; - pub type blkcnt_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_ino: ino_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: uint32_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_qspare: [int64_t; 2], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - #[repr(C)] - #[derive(Copy)] pub struct pthread_attr_t { - __sig: c_long, - __opaque: [c_char; 56] - } - impl Clone for pthread_attr_t { - fn clone(&self) -> pthread_attr_t { *self } - } - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - #[repr(C)] - #[derive(Copy, Clone)] pub struct mach_timebase_info { - pub numer: u32, - pub denom: u32, - } - - pub type mach_timebase_info_data_t = mach_timebase_info; - } - } - } - - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 2147483647; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 2; - pub const _IOLBF : c_int = 1; - pub const BUFSIZ : c_uint = 1024; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 1024; - pub const L_tmpnam : c_uint = 1024; - pub const TMP_MAX : c_uint = 308915776; - pub const _PC_NAME_MAX: c_int = 4; - } - pub mod c99 { - } - pub mod posix88 { - use types::common::c95::c_void; - use types::os::arch::c95::c_int; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 512; - pub const O_EXCL : c_int = 2048; - pub const O_NOCTTY : c_int = 131072; - pub const O_TRUNC : c_int = 1024; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x1000; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_INVALIDATE : c_int = 0x0002; - pub const MS_SYNC : c_int = 0x0010; - - pub const MS_KILLPAGES : c_int = 0x0004; - pub const MS_DEACTIVATE : c_int = 0x0008; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EDEADLK : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - pub const EAGAIN : c_int = 35; - pub const EWOULDBLOCK : c_int = EAGAIN; - pub const EINPROGRESS : c_int = 36; - pub const EALREADY : c_int = 37; - pub const ENOTSOCK : c_int = 38; - pub const EDESTADDRREQ : c_int = 39; - pub const EMSGSIZE : c_int = 40; - pub const EPROTOTYPE : c_int = 41; - pub const ENOPROTOOPT : c_int = 42; - pub const EPROTONOSUPPORT : c_int = 43; - pub const ESOCKTNOSUPPORT : c_int = 44; - pub const ENOTSUP : c_int = 45; - pub const EPFNOSUPPORT : c_int = 46; - pub const EAFNOSUPPORT : c_int = 47; - pub const EADDRINUSE : c_int = 48; - pub const EADDRNOTAVAIL : c_int = 49; - pub const ENETDOWN : c_int = 50; - pub const ENETUNREACH : c_int = 51; - pub const ENETRESET : c_int = 52; - pub const ECONNABORTED : c_int = 53; - pub const ECONNRESET : c_int = 54; - pub const ENOBUFS : c_int = 55; - pub const EISCONN : c_int = 56; - pub const ENOTCONN : c_int = 57; - pub const ESHUTDOWN : c_int = 58; - pub const ETOOMANYREFS : c_int = 59; - pub const ETIMEDOUT : c_int = 60; - pub const ECONNREFUSED : c_int = 61; - pub const ELOOP : c_int = 62; - pub const ENAMETOOLONG : c_int = 63; - pub const EHOSTDOWN : c_int = 64; - pub const EHOSTUNREACH : c_int = 65; - pub const ENOTEMPTY : c_int = 66; - pub const EPROCLIM : c_int = 67; - pub const EUSERS : c_int = 68; - pub const EDQUOT : c_int = 69; - pub const ESTALE : c_int = 70; - pub const EREMOTE : c_int = 71; - pub const EBADRPC : c_int = 72; - pub const ERPCMISMATCH : c_int = 73; - pub const EPROGUNAVAIL : c_int = 74; - pub const EPROGMISMATCH : c_int = 75; - pub const EPROCUNAVAIL : c_int = 76; - pub const ENOLCK : c_int = 77; - pub const ENOSYS : c_int = 78; - pub const EFTYPE : c_int = 79; - pub const EAUTH : c_int = 80; - pub const ENEEDAUTH : c_int = 81; - pub const EPWROFF : c_int = 82; - pub const EDEVERR : c_int = 83; - pub const EOVERFLOW : c_int = 84; - pub const EBADEXEC : c_int = 85; - pub const EBADARCH : c_int = 86; - pub const ESHLIBVERS : c_int = 87; - pub const EBADMACHO : c_int = 88; - pub const ECANCELED : c_int = 89; - pub const EIDRM : c_int = 90; - pub const ENOMSG : c_int = 91; - pub const EILSEQ : c_int = 92; - pub const ENOATTR : c_int = 93; - pub const EBADMSG : c_int = 94; - pub const EMULTIHOP : c_int = 95; - pub const ENODATA : c_int = 96; - pub const ENOLINK : c_int = 97; - pub const ENOSR : c_int = 98; - pub const ENOSTR : c_int = 99; - pub const EPROTO : c_int = 100; - pub const ETIME : c_int = 101; - pub const EOPNOTSUPP : c_int = 102; - pub const ENOPOLICY : c_int = 103; - pub const ENOTRECOVERABLE : c_int = 104; - pub const EOWNERDEAD : c_int = 105; - pub const EQFULL : c_int = 106; - pub const ELAST : c_int = 106; - } - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - - pub const O_ACCMODE : c_int = 3; - - pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; - - pub const GLOB_APPEND : c_int = 0x0001; - pub const GLOB_DOOFFS : c_int = 0x0002; - pub const GLOB_ERR : c_int = 0x0004; - pub const GLOB_MARK : c_int = 0x0008; - pub const GLOB_NOCHECK : c_int = 0x0010; - pub const GLOB_NOSORT : c_int = 0x0020; - pub const GLOB_NOESCAPE : c_int = 0x2000; - - pub const GLOB_NOSPACE : c_int = -1; - pub const GLOB_ABORTED : c_int = -2; - pub const GLOB_NOMATCH : c_int = -3; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_IOV_MAX : c_int = 56; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; - pub const _SC_LOGIN_NAME_MAX : c_int = 73; - pub const _SC_MQ_PRIO_MAX : c_int = 75; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; - pub const _SC_THREAD_KEYS_MAX : c_int = 86; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; - pub const _SC_THREAD_STACK_MIN : c_int = 93; - pub const _SC_THREAD_THREADS_MAX : c_int = 94; - pub const _SC_THREADS : c_int = 96; - pub const _SC_TTY_NAME_MAX : c_int = 101; - pub const _SC_ATEXIT_MAX : c_int = 107; - pub const _SC_XOPEN_CRYPT : c_int = 108; - pub const _SC_XOPEN_ENH_I18N : c_int = 109; - pub const _SC_XOPEN_LEGACY : c_int = 110; - pub const _SC_XOPEN_REALTIME : c_int = 111; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; - pub const _SC_XOPEN_SHM : c_int = 113; - pub const _SC_XOPEN_UNIX : c_int = 115; - pub const _SC_XOPEN_VERSION : c_int = 116; - pub const _SC_XOPEN_XCU_VERSION : c_int = 121; - - pub const PTHREAD_CREATE_JOINABLE: c_int = 1; - pub const PTHREAD_CREATE_DETACHED: c_int = 2; - pub const PTHREAD_STACK_MIN: size_t = 8192; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_AS: c_int = 5; - pub const RLIMIT_MEMLOCK: c_int = 6; - pub const RLIMIT_NPROC: c_int = 7; - pub const RLIMIT_NOFILE: c_int = 8; - pub const RLIM_NLIMITS: c_int = 9; - pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; - - pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_FREE : c_int = 5; - pub const MADV_ZERO_WIRED_PAGES : c_int = 6; - pub const MADV_FREE_REUSABLE : c_int = 7; - pub const MADV_FREE_REUSE : c_int = 8; - pub const MADV_CAN_REUSE : c_int = 9; - - pub const MINCORE_INCORE : c_int = 0x1; - pub const MINCORE_REFERENCED : c_int = 0x2; - pub const MINCORE_MODIFIED : c_int = 0x4; - pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; - pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; - - pub const AF_UNIX: c_int = 1; - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 30; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_JOIN_GROUP: c_int = 12; - pub const IPV6_LEAVE_GROUP: c_int = 13; - - pub const TCP_NODELAY: c_int = 0x01; - pub const TCP_KEEPALIVE: c_int = 0x10; - pub const SOL_SOCKET: c_int = 0xffff; - - pub const SO_DEBUG: c_int = 0x01; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_REUSEPORT: c_int = 0x0200; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 0x8; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - pub mod extra { - use types::os::arch::c95::c_int; - - pub const O_DSYNC : c_int = 4194304; - pub const O_SYNC : c_int = 128; - pub const O_NONBLOCK : c_int = 4; - pub const F_GETPATH : c_int = 50; - pub const F_FULLFSYNC : c_int = 51; - - pub const MAP_COPY : c_int = 0x0002; - pub const MAP_RENAME : c_int = 0x0020; - pub const MAP_NORESERVE : c_int = 0x0040; - pub const MAP_NOEXTEND : c_int = 0x0100; - pub const MAP_HASSEMAPHORE : c_int = 0x0200; - pub const MAP_NOCACHE : c_int = 0x0400; - pub const MAP_JIT : c_int = 0x0800; - - pub const IPPROTO_RAW : c_int = 255; - - pub const SO_NREAD: c_int = 0x1020; - pub const SO_NKE: c_int = 0x1021; - pub const SO_NOSIGPIPE: c_int = 0x1022; - pub const SO_NOADDRERR: c_int = 0x1023; - pub const SO_NWRITE: c_int = 0x1024; - pub const SO_DONTTRUNC: c_int = 0x2000; - pub const SO_WANTMORE: c_int = 0x4000; - pub const SO_WANTOOBFLAG: c_int = 0x8000; - - pub const PATH_MAX: c_int = 1024; - } - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 1; - pub const _SC_CHILD_MAX : c_int = 2; - pub const _SC_CLK_TCK : c_int = 3; - pub const _SC_NGROUPS_MAX : c_int = 4; - pub const _SC_OPEN_MAX : c_int = 5; - pub const _SC_JOB_CONTROL : c_int = 6; - pub const _SC_SAVED_IDS : c_int = 7; - pub const _SC_VERSION : c_int = 8; - pub const _SC_BC_BASE_MAX : c_int = 9; - pub const _SC_BC_DIM_MAX : c_int = 10; - pub const _SC_BC_SCALE_MAX : c_int = 11; - pub const _SC_BC_STRING_MAX : c_int = 12; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; - pub const _SC_EXPR_NEST_MAX : c_int = 14; - pub const _SC_LINE_MAX : c_int = 15; - pub const _SC_RE_DUP_MAX : c_int = 16; - pub const _SC_2_VERSION : c_int = 17; - pub const _SC_2_C_BIND : c_int = 18; - pub const _SC_2_C_DEV : c_int = 19; - pub const _SC_2_CHAR_TERM : c_int = 20; - pub const _SC_2_FORT_DEV : c_int = 21; - pub const _SC_2_FORT_RUN : c_int = 22; - pub const _SC_2_LOCALEDEF : c_int = 23; - pub const _SC_2_SW_DEV : c_int = 24; - pub const _SC_2_UPE : c_int = 25; - pub const _SC_STREAM_MAX : c_int = 26; - pub const _SC_TZNAME_MAX : c_int = 27; - pub const _SC_ASYNCHRONOUS_IO : c_int = 28; - pub const _SC_PAGESIZE : c_int = 29; - pub const _SC_MEMLOCK : c_int = 30; - pub const _SC_MEMLOCK_RANGE : c_int = 31; - pub const _SC_MEMORY_PROTECTION : c_int = 32; - pub const _SC_MESSAGE_PASSING : c_int = 33; - pub const _SC_PRIORITIZED_IO : c_int = 34; - pub const _SC_PRIORITY_SCHEDULING : c_int = 35; - pub const _SC_REALTIME_SIGNALS : c_int = 36; - pub const _SC_SEMAPHORES : c_int = 37; - pub const _SC_FSYNC : c_int = 38; - pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; - pub const _SC_SYNCHRONIZED_IO : c_int = 40; - pub const _SC_TIMERS : c_int = 41; - pub const _SC_AIO_LISTIO_MAX : c_int = 42; - pub const _SC_AIO_MAX : c_int = 43; - pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; - pub const _SC_DELAYTIMER_MAX : c_int = 45; - pub const _SC_MQ_OPEN_MAX : c_int = 46; - pub const _SC_MAPPED_FILES : c_int = 47; - pub const _SC_RTSIG_MAX : c_int = 48; - pub const _SC_SEM_NSEMS_MAX : c_int = 49; - pub const _SC_SEM_VALUE_MAX : c_int = 50; - pub const _SC_SIGQUEUE_MAX : c_int = 51; - pub const _SC_TIMER_MAX : c_int = 52; - pub const _SC_NPROCESSORS_CONF : c_int = 57; - pub const _SC_NPROCESSORS_ONLN : c_int = 58; - pub const _SC_2_PBS : c_int = 59; - pub const _SC_2_PBS_ACCOUNTING : c_int = 60; - pub const _SC_2_PBS_CHECKPOINT : c_int = 61; - pub const _SC_2_PBS_LOCATE : c_int = 62; - pub const _SC_2_PBS_MESSAGE : c_int = 63; - pub const _SC_2_PBS_TRACK : c_int = 64; - pub const _SC_ADVISORY_INFO : c_int = 65; - pub const _SC_BARRIERS : c_int = 66; - pub const _SC_CLOCK_SELECTION : c_int = 67; - pub const _SC_CPUTIME : c_int = 68; - pub const _SC_FILE_LOCKING : c_int = 69; - pub const _SC_HOST_NAME_MAX : c_int = 72; - pub const _SC_MONOTONIC_CLOCK : c_int = 74; - pub const _SC_READER_WRITER_LOCKS : c_int = 76; - pub const _SC_REGEXP : c_int = 77; - pub const _SC_SHELL : c_int = 78; - pub const _SC_SPAWN : c_int = 79; - pub const _SC_SPIN_LOCKS : c_int = 80; - pub const _SC_SPORADIC_SERVER : c_int = 81; - pub const _SC_THREAD_CPUTIME : c_int = 84; - pub const _SC_THREAD_SPORADIC_SERVER : c_int = 92; - pub const _SC_TIMEOUTS : c_int = 95; - pub const _SC_TRACE : c_int = 97; - pub const _SC_TRACE_EVENT_FILTER : c_int = 98; - pub const _SC_TRACE_INHERIT : c_int = 99; - pub const _SC_TRACE_LOG : c_int = 100; - pub const _SC_TYPED_MEMORY_OBJECTS : c_int = 102; - pub const _SC_V6_ILP32_OFF32 : c_int = 103; - pub const _SC_V6_ILP32_OFFBIG : c_int = 104; - pub const _SC_V6_LP64_OFF64 : c_int = 105; - pub const _SC_V6_LPBIG_OFFBIG : c_int = 106; - pub const _SC_IPV6 : c_int = 118; - pub const _SC_RAW_SOCKETS : c_int = 119; - pub const _SC_SYMLOOP_MAX : c_int = 120; - pub const _SC_PAGE_SIZE : c_int = _SC_PAGESIZE; - pub const _SC_XOPEN_STREAMS : c_int = 114; - pub const _SC_XBS5_ILP32_OFF32 : c_int = 122; - pub const _SC_XBS5_ILP32_OFFBIG : c_int = 123; - pub const _SC_XBS5_LP64_OFF64 : c_int = 124; - pub const _SC_XBS5_LPBIG_OFFBIG : c_int = 125; - pub const _SC_SS_REPL_MAX : c_int = 126; - pub const _SC_TRACE_EVENT_NAME_MAX : c_int = 127; - pub const _SC_TRACE_NAME_MAX : c_int = 128; - pub const _SC_TRACE_SYS_MAX : c_int = 129; - pub const _SC_TRACE_USER_EVENT_MAX : c_int = 130; - pub const _SC_PASS_MAX : c_int = 131; - } - } - - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub mod extra { - use {c_char, c_int, uint32_t}; - - extern { - pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut uint32_t) - -> c_int; - } - } diff --git a/src/apple/b32.rs b/src/apple/b32.rs new file mode 100644 index 0000000000000..b4cc8cff43e9b --- /dev/null +++ b/src/apple/b32.rs @@ -0,0 +1,13 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type size_t = u32; +pub type ptrdiff_t = i32; +pub type intptr_t = i32; +pub type uintptr_t = u32; + +s! { + pub struct pthread_attr_t { + __sig: c_long, + __opaque: [::c_char; 36] + } +} diff --git a/src/apple/b64.rs b/src/apple/b64.rs new file mode 100644 index 0000000000000..ebdfb67571137 --- /dev/null +++ b/src/apple/b64.rs @@ -0,0 +1,13 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type size_t = u64; +pub type ptrdiff_t = i64; +pub type intptr_t = i64; +pub type uintptr_t = u64; + +s! { + pub struct pthread_attr_t { + __sig: ::c_long, + __opaque: [::c_char; 56] + } +} diff --git a/src/apple/mod.rs b/src/apple/mod.rs new file mode 100644 index 0000000000000..ed98e3e806e21 --- /dev/null +++ b/src/apple/mod.rs @@ -0,0 +1,697 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type clock_t = c_ulong; +pub type time_t = c_long; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type off_t = i64; +pub type dev_t = i32; +pub type ino_t = u64; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type mode_t = u16; +pub type ssize_t = c_long; + +pub type nlink_t = u16; +pub type blksize_t = i32; +pub type blkcnt_t = i64; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type in_port_t = u16; +pub type in_addr_t = u32; +pub type pthread_t = uintptr_t; +pub type rlim_t = u64; +pub type sighandler_t = size_t; +pub type mach_timebase_info_data_t = mach_timebase_info; + +pub enum timezone {} + +s! { + pub struct glob_t { + pub gl_pathc: size_t, + __unused1: c_int, + pub gl_offs: size_t, + __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + __unused3: *mut ::c_void, + + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + __unused8: *mut ::c_void, + } + + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + pub struct in6_addr { + pub s6_addr: [u16; 8], + __align: [u32; 0], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut ::c_void + } + + pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: ::uint32_t, + pub st_gen: ::uint32_t, + pub st_lspare: ::int32_t, + pub st_qspare: [::int64_t; 2], + } + +} + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 2147483647; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; +pub const L_tmpnam: c_uint = 1024; +pub const TMP_MAX: c_uint = 308915776; +pub const _PC_NAME_MAX: c_int = 4; + +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 512; +pub const O_EXCL: c_int = 2048; +pub const O_NOCTTY: c_int = 131072; +pub const O_TRUNC: c_int = 1024; +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_ANON: c_int = 0x1000; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; +pub const MS_SYNC: c_int = 0x0010; + +pub const MS_KILLPAGES: c_int = 0x0004; +pub const MS_DEACTIVATE: c_int = 0x0008; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EDEADLK: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EAGAIN: c_int = 35; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EINPROGRESS: c_int = 36; +pub const EALREADY: c_int = 37; +pub const ENOTSOCK: c_int = 38; +pub const EDESTADDRREQ: c_int = 39; +pub const EMSGSIZE: c_int = 40; +pub const EPROTOTYPE: c_int = 41; +pub const ENOPROTOOPT: c_int = 42; +pub const EPROTONOSUPPORT: c_int = 43; +pub const ESOCKTNOSUPPORT: c_int = 44; +pub const ENOTSUP: c_int = 45; +pub const EPFNOSUPPORT: c_int = 46; +pub const EAFNOSUPPORT: c_int = 47; +pub const EADDRINUSE: c_int = 48; +pub const EADDRNOTAVAIL: c_int = 49; +pub const ENETDOWN: c_int = 50; +pub const ENETUNREACH: c_int = 51; +pub const ENETRESET: c_int = 52; +pub const ECONNABORTED: c_int = 53; +pub const ECONNRESET: c_int = 54; +pub const ENOBUFS: c_int = 55; +pub const EISCONN: c_int = 56; +pub const ENOTCONN: c_int = 57; +pub const ESHUTDOWN: c_int = 58; +pub const ETOOMANYREFS: c_int = 59; +pub const ETIMEDOUT: c_int = 60; +pub const ECONNREFUSED: c_int = 61; +pub const ELOOP: c_int = 62; +pub const ENAMETOOLONG: c_int = 63; +pub const EHOSTDOWN: c_int = 64; +pub const EHOSTUNREACH: c_int = 65; +pub const ENOTEMPTY: c_int = 66; +pub const EPROCLIM: c_int = 67; +pub const EUSERS: c_int = 68; +pub const EDQUOT: c_int = 69; +pub const ESTALE: c_int = 70; +pub const EREMOTE: c_int = 71; +pub const EBADRPC: c_int = 72; +pub const ERPCMISMATCH: c_int = 73; +pub const EPROGUNAVAIL: c_int = 74; +pub const EPROGMISMATCH: c_int = 75; +pub const EPROCUNAVAIL: c_int = 76; +pub const ENOLCK: c_int = 77; +pub const ENOSYS: c_int = 78; +pub const EFTYPE: c_int = 79; +pub const EAUTH: c_int = 80; +pub const ENEEDAUTH: c_int = 81; +pub const EPWROFF: c_int = 82; +pub const EDEVERR: c_int = 83; +pub const EOVERFLOW: c_int = 84; +pub const EBADEXEC: c_int = 85; +pub const EBADARCH: c_int = 86; +pub const ESHLIBVERS: c_int = 87; +pub const EBADMACHO: c_int = 88; +pub const ECANCELED: c_int = 89; +pub const EIDRM: c_int = 90; +pub const ENOMSG: c_int = 91; +pub const EILSEQ: c_int = 92; +pub const ENOATTR: c_int = 93; +pub const EBADMSG: c_int = 94; +pub const EMULTIHOP: c_int = 95; +pub const ENODATA: c_int = 96; +pub const ENOLINK: c_int = 97; +pub const ENOSR: c_int = 98; +pub const ENOSTR: c_int = 99; +pub const EPROTO: c_int = 100; +pub const ETIME: c_int = 101; +pub const EOPNOTSUPP: c_int = 102; +pub const ENOPOLICY: c_int = 103; +pub const ENOTRECOVERABLE: c_int = 104; +pub const EOWNERDEAD: c_int = 105; +pub const EQFULL: c_int = 106; +pub const ELAST: c_int = 106; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; + +pub const O_ACCMODE: c_int = 3; + +pub const SIGTRAP: c_int = 5; +pub const SIG_IGN: size_t = 1; + +pub const GLOB_APPEND : c_int = 0x0001; +pub const GLOB_DOOFFS : c_int = 0x0002; +pub const GLOB_ERR : c_int = 0x0004; +pub const GLOB_MARK : c_int = 0x0008; +pub const GLOB_NOCHECK : c_int = 0x0010; +pub const GLOB_NOSORT : c_int = 0x0020; +pub const GLOB_NOESCAPE: c_int = 0x2000; + +pub const GLOB_NOSPACE : c_int = -1; +pub const GLOB_ABORTED : c_int = -2; +pub const GLOB_NOMATCH : c_int = -3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const _SC_IOV_MAX: c_int = 56; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 70; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 71; +pub const _SC_LOGIN_NAME_MAX: c_int = 73; +pub const _SC_MQ_PRIO_MAX: c_int = 75; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 82; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 83; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 85; +pub const _SC_THREAD_KEYS_MAX: c_int = 86; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 87; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 88; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 89; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 90; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 91; +pub const _SC_THREAD_STACK_MIN: c_int = 93; +pub const _SC_THREAD_THREADS_MAX: c_int = 94; +pub const _SC_THREADS: c_int = 96; +pub const _SC_TTY_NAME_MAX: c_int = 101; +pub const _SC_ATEXIT_MAX: c_int = 107; +pub const _SC_XOPEN_CRYPT: c_int = 108; +pub const _SC_XOPEN_ENH_I18N: c_int = 109; +pub const _SC_XOPEN_LEGACY: c_int = 110; +pub const _SC_XOPEN_REALTIME: c_int = 111; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 112; +pub const _SC_XOPEN_SHM: c_int = 113; +pub const _SC_XOPEN_UNIX: c_int = 115; +pub const _SC_XOPEN_VERSION: c_int = 116; +pub const _SC_XOPEN_XCU_VERSION: c_int = 121; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 1; +pub const PTHREAD_CREATE_DETACHED: c_int = 2; +pub const PTHREAD_STACK_MIN: size_t = 8192; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_AS: c_int = 5; +pub const RLIMIT_MEMLOCK: c_int = 6; +pub const RLIMIT_NPROC: c_int = 7; +pub const RLIMIT_NOFILE: c_int = 8; +pub const RLIM_NLIMITS: c_int = 9; +pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; + +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_FREE: c_int = 5; +pub const MADV_ZERO_WIRED_PAGES: c_int = 6; +pub const MADV_FREE_REUSABLE: c_int = 7; +pub const MADV_FREE_REUSE: c_int = 8; +pub const MADV_CAN_REUSE: c_int = 9; + +pub const MINCORE_INCORE: c_int = 0x1; +pub const MINCORE_REFERENCED: c_int = 0x2; +pub const MINCORE_MODIFIED: c_int = 0x4; +pub const MINCORE_REFERENCED_OTHER: c_int = 0x8; +pub const MINCORE_MODIFIED_OTHER: c_int = 0x10; + +pub const AF_UNIX: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_INET6: c_int = 30; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_IPV6: c_int = 41; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_TTL: c_int = 4; +pub const IP_HDRINCL: c_int = 2; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; + +pub const TCP_NODELAY: c_int = 0x01; +pub const TCP_KEEPALIVE: c_int = 0x10; +pub const SOL_SOCKET: c_int = 0xffff; + +pub const SO_DEBUG: c_int = 0x01; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; + +pub const IFF_LOOPBACK: c_int = 0x8; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const O_DSYNC: c_int = 4194304; +pub const O_SYNC: c_int = 128; +pub const O_NONBLOCK: c_int = 4; +pub const F_GETPATH: c_int = 50; +pub const F_FULLFSYNC: c_int = 51; + +pub const MAP_COPY: c_int = 0x0002; +pub const MAP_RENAME: c_int = 0x0020; +pub const MAP_NORESERVE: c_int = 0x0040; +pub const MAP_NOEXTEND: c_int = 0x0100; +pub const MAP_HASSEMAPHORE: c_int = 0x0200; +pub const MAP_NOCACHE: c_int = 0x0400; +pub const MAP_JIT: c_int = 0x0800; + +pub const IPPROTO_RAW: c_int = 255; + +pub const SO_NREAD: c_int = 0x1020; +pub const SO_NKE: c_int = 0x1021; +pub const SO_NOSIGPIPE: c_int = 0x1022; +pub const SO_NOADDRERR: c_int = 0x1023; +pub const SO_NWRITE: c_int = 0x1024; +pub const SO_DONTTRUNC: c_int = 0x2000; +pub const SO_WANTMORE: c_int = 0x4000; +pub const SO_WANTOOBFLAG: c_int = 0x8000; + +pub const PATH_MAX: c_int = 1024; + +pub const _SC_ARG_MAX: c_int = 1; +pub const _SC_CHILD_MAX: c_int = 2; +pub const _SC_CLK_TCK: c_int = 3; +pub const _SC_NGROUPS_MAX: c_int = 4; +pub const _SC_OPEN_MAX: c_int = 5; +pub const _SC_JOB_CONTROL: c_int = 6; +pub const _SC_SAVED_IDS: c_int = 7; +pub const _SC_VERSION: c_int = 8; +pub const _SC_BC_BASE_MAX: c_int = 9; +pub const _SC_BC_DIM_MAX: c_int = 10; +pub const _SC_BC_SCALE_MAX: c_int = 11; +pub const _SC_BC_STRING_MAX: c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 13; +pub const _SC_EXPR_NEST_MAX: c_int = 14; +pub const _SC_LINE_MAX: c_int = 15; +pub const _SC_RE_DUP_MAX: c_int = 16; +pub const _SC_2_VERSION: c_int = 17; +pub const _SC_2_C_BIND: c_int = 18; +pub const _SC_2_C_DEV: c_int = 19; +pub const _SC_2_CHAR_TERM: c_int = 20; +pub const _SC_2_FORT_DEV: c_int = 21; +pub const _SC_2_FORT_RUN: c_int = 22; +pub const _SC_2_LOCALEDEF: c_int = 23; +pub const _SC_2_SW_DEV: c_int = 24; +pub const _SC_2_UPE: c_int = 25; +pub const _SC_STREAM_MAX: c_int = 26; +pub const _SC_TZNAME_MAX: c_int = 27; +pub const _SC_ASYNCHRONOUS_IO: c_int = 28; +pub const _SC_PAGESIZE: c_int = 29; +pub const _SC_MEMLOCK: c_int = 30; +pub const _SC_MEMLOCK_RANGE: c_int = 31; +pub const _SC_MEMORY_PROTECTION: c_int = 32; +pub const _SC_MESSAGE_PASSING: c_int = 33; +pub const _SC_PRIORITIZED_IO: c_int = 34; +pub const _SC_PRIORITY_SCHEDULING: c_int = 35; +pub const _SC_REALTIME_SIGNALS: c_int = 36; +pub const _SC_SEMAPHORES: c_int = 37; +pub const _SC_FSYNC: c_int = 38; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 39; +pub const _SC_SYNCHRONIZED_IO: c_int = 40; +pub const _SC_TIMERS: c_int = 41; +pub const _SC_AIO_LISTIO_MAX: c_int = 42; +pub const _SC_AIO_MAX: c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44; +pub const _SC_DELAYTIMER_MAX: c_int = 45; +pub const _SC_MQ_OPEN_MAX: c_int = 46; +pub const _SC_MAPPED_FILES: c_int = 47; +pub const _SC_RTSIG_MAX: c_int = 48; +pub const _SC_SEM_NSEMS_MAX: c_int = 49; +pub const _SC_SEM_VALUE_MAX: c_int = 50; +pub const _SC_SIGQUEUE_MAX: c_int = 51; +pub const _SC_TIMER_MAX: c_int = 52; +pub const _SC_NPROCESSORS_CONF: c_int = 57; +pub const _SC_NPROCESSORS_ONLN: c_int = 58; +pub const _SC_2_PBS: c_int = 59; +pub const _SC_2_PBS_ACCOUNTING: c_int = 60; +pub const _SC_2_PBS_CHECKPOINT: c_int = 61; +pub const _SC_2_PBS_LOCATE: c_int = 62; +pub const _SC_2_PBS_MESSAGE: c_int = 63; +pub const _SC_2_PBS_TRACK: c_int = 64; +pub const _SC_ADVISORY_INFO: c_int = 65; +pub const _SC_BARRIERS: c_int = 66; +pub const _SC_CLOCK_SELECTION: c_int = 67; +pub const _SC_CPUTIME: c_int = 68; +pub const _SC_FILE_LOCKING: c_int = 69; +pub const _SC_HOST_NAME_MAX: c_int = 72; +pub const _SC_MONOTONIC_CLOCK: c_int = 74; +pub const _SC_READER_WRITER_LOCKS: c_int = 76; +pub const _SC_REGEXP: c_int = 77; +pub const _SC_SHELL: c_int = 78; +pub const _SC_SPAWN: c_int = 79; +pub const _SC_SPIN_LOCKS: c_int = 80; +pub const _SC_SPORADIC_SERVER: c_int = 81; +pub const _SC_THREAD_CPUTIME: c_int = 84; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 92; +pub const _SC_TIMEOUTS: c_int = 95; +pub const _SC_TRACE: c_int = 97; +pub const _SC_TRACE_EVENT_FILTER: c_int = 98; +pub const _SC_TRACE_INHERIT: c_int = 99; +pub const _SC_TRACE_LOG: c_int = 100; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 102; +pub const _SC_V6_ILP32_OFF32: c_int = 103; +pub const _SC_V6_ILP32_OFFBIG: c_int = 104; +pub const _SC_V6_LP64_OFF64: c_int = 105; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 106; +pub const _SC_IPV6: c_int = 118; +pub const _SC_RAW_SOCKETS: c_int = 119; +pub const _SC_SYMLOOP_MAX: c_int = 120; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_XOPEN_STREAMS: c_int = 114; +pub const _SC_XBS5_ILP32_OFF32: c_int = 122; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 123; +pub const _SC_XBS5_LP64_OFF64: c_int = 124; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 125; +pub const _SC_SS_REPL_MAX: c_int = 126; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 127; +pub const _SC_TRACE_NAME_MAX: c_int = 128; +pub const _SC_TRACE_SYS_MAX: c_int = 129; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130; +pub const _SC_PASS_MAX: c_int = 131; + +extern { + pub fn _NSGetExecutablePath(buf: *mut c_char, + bufsize: *mut ::uint32_t) -> c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "arm", target_arch = "x86"))] { + mod b32; + pub use self::b32::*; + } else if #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] { + mod b64; + pub use self::b64::*; + } else { + // unknown arch... + } +} diff --git a/src/bsdlike.rs b/src/bsdlike.rs deleted file mode 100644 index 2d6c8ab6da3ce..0000000000000 --- a/src/bsdlike.rs +++ /dev/null @@ -1,13 +0,0 @@ - -extern { - pub fn sysctlbyname(name: *const ::c_char, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn sysctlnametomib(name: *const ::c_char, - mibp: *mut ::c_int, - sizep: *mut ::size_t) - -> ::c_int; -} diff --git a/src/lib.rs b/src/lib.rs index 1d6b50d78a602..da0669dd642c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,10 +65,39 @@ cfg_if! { target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] { - mod bsdlike; - pub use bsdlike::*; + extern { + pub fn sysctl(name: *mut c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) + -> c_int; + pub fn sysctlbyname(name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn sysctlnametomib(name: *const c_char, + mibp: *mut c_int, + sizep: *mut size_t) + -> c_int; + } } else { - // non bsds... + extern { + pub fn sysctl(name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) + -> c_int; + } } } diff --git a/src/linuxlike/mod.rs b/src/linuxlike/mod.rs index f545a01f99c0f..10a485401d8ec 100644 --- a/src/linuxlike/mod.rs +++ b/src/linuxlike/mod.rs @@ -147,11 +147,6 @@ s! { pub sll_halen: c_uchar, pub sll_addr: [c_uchar; 8] } - - pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } } pub const EXIT_FAILURE: c_int = 1; diff --git a/src/unix.rs b/src/unix.rs index 223351aeea39e..bfff00949ad18 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -1,3 +1,10 @@ +s! { + pub struct utimbuf { + pub actime: ::time_t, + pub modtime: ::time_t, + } +} + extern { pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -61,7 +68,7 @@ extern { pub fn mkdir(path: *const ::c_char, mode: ::mode_t) -> ::c_int; pub fn mkfifo(path: *const ::c_char, mode: ::mode_t) -> ::c_int; - #[cfg_attr(target_os = "macos", link_name = "::stat$INODE64")] + #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] pub fn stat(path: *const ::c_char, buf: *mut ::stat) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -288,18 +295,9 @@ extern { pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; pub fn getrusage(resource: ::c_int, usage: *mut ::rusage) -> ::c_int; - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; pub fn getdtablesize() -> ::c_int; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) - -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char; From f81e3d36722d89cf373070ee820b8c715aa78f51 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 15:27:09 -0700 Subject: [PATCH 045/194] Compat back to 1.0.0 --- .travis.yml | 2 +- libc-test/build.rs | 4 ++-- libc-test/tests/all.rs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1526807cac772..c760cf5d9ac25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: required services: - docker rust: - - 1.2.0 + - 1.0.0 - beta - nightly install: diff --git a/libc-test/build.rs b/libc-test/build.rs index a4c493f7e8263..ae8c21bc94231 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -62,7 +62,7 @@ impl<'a> TestGenerator<'a> { fn headers(&self) -> Vec<&'static str> { let mut base = Vec::new(); - base.extend(&[ + base.extend([ "errno.h", "fcntl.h", "limits.h", @@ -74,7 +74,7 @@ impl<'a> TestGenerator<'a> { "sys/types.h", "time.h", "wchar.h", - ]); + ].iter().cloned()); if self.target.contains("apple-darwin") { base.push("mach-o/dyld.h"); diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index d397883b18057..42a743c4f3d20 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -33,6 +33,7 @@ fn same(rust: T, c: T, attr: &str) { } } +#[allow(deprecated)] fn align() -> u64 { // TODO: apparently these three types have less alignment in Rust on x86 // than they do in C this difference should.. probably be reconciled. @@ -45,7 +46,7 @@ fn align() -> u64 { return 8 } } - mem::align_of::() as u64 + mem::min_align_of::() as u64 } macro_rules! offset_of { From 6b8bdcac2232c0d7f52e0f8bece62caeae1f5cbe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 15:21:13 -0700 Subject: [PATCH 046/194] Remove stray file --- src/macos.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/macos.rs diff --git a/src/macos.rs b/src/macos.rs deleted file mode 100644 index e69de29bb2d1d..0000000000000 From e001d8cc3bd834f87946b30327e5690ebbc8836f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 15:22:07 -0700 Subject: [PATCH 047/194] Remove now stray comment --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index da0669dd642c1..626b5d561831c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -137,7 +137,6 @@ extern { size: size_t) -> c_int; pub fn setbuf(stream: *mut FILE, buf: *mut c_char); - // Omitted: printf and scanf variants. pub fn fgetc(stream: *mut FILE) -> c_int; pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; From bfc6ebc92bad17a7d0d50d66e4ddae24d0263c8c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 15:29:40 -0700 Subject: [PATCH 048/194] Windows working again --- src/lib.rs | 22 +- src/windows.rs | 2072 ++++++++++++++++++++++-------------------------- 2 files changed, 941 insertions(+), 1153 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 626b5d561831c..910b9483b3cfc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,7 +86,7 @@ cfg_if! { sizep: *mut size_t) -> c_int; } - } else { + } else if #[cfg(unix)] { extern { pub fn sysctl(name: *mut c_int, namelen: c_int, @@ -98,6 +98,8 @@ cfg_if! { pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) -> c_int; } + } else { + // ... } } @@ -123,23 +125,19 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "freopen$UNIX2003")] pub fn freopen(filename: *const c_char, mode: *const c_char, - file: *mut FILE) - -> *mut FILE; + file: *mut FILE) -> *mut FILE; pub fn fflush(file: *mut FILE) -> c_int; pub fn fclose(file: *mut FILE) -> c_int; pub fn remove(filename: *const c_char) -> c_int; - pub fn rename(oldname: *const c_char, - newname: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; pub fn tmpfile() -> *mut FILE; pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, - size: size_t) - -> c_int; + size: size_t) -> c_int; pub fn setbuf(stream: *mut FILE, buf: *mut c_char); pub fn fgetc(stream: *mut FILE) -> c_int; - pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) - -> *mut c_char; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fputs$UNIX2003")] @@ -158,8 +156,7 @@ extern { nobj: size_t, stream: *mut FILE) -> size_t; - pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) - -> c_int; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; pub fn ftell(stream: *mut FILE) -> c_long; pub fn rewind(stream: *mut FILE); pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; @@ -173,8 +170,7 @@ extern { pub fn atoi(s: *const c_char) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "strtod$UNIX2003")] - pub fn strtod(s: *const c_char, - endp: *mut *mut c_char) -> c_double; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, diff --git a/src/windows.rs b/src/windows.rs index 90b04919c68c8..efa29dac63ebb 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,1153 +1,945 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type wchar_t = u16; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +cfg_if! { + if #[cfg(target_arch = "x86")] { + pub type intptr_t = i32; + pub type ptrdiff_t = i32; + pub type size_t = u32; + pub type ssize_t = i32; + pub type uintptr_t = u32; + pub type LONG_PTR = c_long; + } else if #[cfg(target_arch = "x86_64")] { + pub type intptr_t = i64; + pub type ptrdiff_t = i64; + pub type size_t = u64; + pub type ssize_t = i64; + pub type uintptr_t = u64; + pub type LONG_PTR = i64; + } else { + // unknown arch + } +} +pub type clock_t = i32; - #[cfg(target_os = "windows")] - pub mod os { - pub mod common { - pub mod posix01 { - use types::os::arch::c95::{c_short, time_t, c_long}; - use types::os::arch::extra::{time64_t}; - use types::os::arch::posix88::{dev_t, ino_t}; - - // pub Note: this is the struct called stat64 in Windows. Not - // stat, nor stati64. - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: u16, - pub st_nlink: c_short, - pub st_uid: c_short, - pub st_gid: c_short, - pub st_rdev: dev_t, - pub st_size: i64, - pub st_atime: time64_t, - pub st_mtime: time64_t, - pub st_ctime: time64_t, - } - - // note that this is called utimbuf64 in Windows - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time64_t, - pub modtime: time64_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: c_long, - pub tv_usec: c_long, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - } - - pub mod bsd44 { - use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; - use types::os::arch::c99::uintptr_t; - - pub type SOCKET = uintptr_t; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_family: u16, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_family: u16, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_family: u16, - pub sin_port: u16, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_family: u16, - pub sin6_port: u16, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: size_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - } - } - - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i32; - pub type c_ulong = u32; - pub type c_float = f32; - pub type c_double = f64; - - #[cfg(target_arch = "x86")] - pub type size_t = u32; - #[cfg(target_arch = "x86_64")] - pub type size_t = u64; - - #[cfg(target_arch = "x86")] - pub type ptrdiff_t = i32; - #[cfg(target_arch = "x86_64")] - pub type ptrdiff_t = i64; - - pub type clock_t = i32; - - cfg_if! { - if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { - pub type time_t = i32; - } else { - pub type time_t = i64; - } - } - - pub type wchar_t = u16; - } - - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - - #[cfg(target_arch = "x86")] - pub type intptr_t = i32; - #[cfg(target_arch = "x86_64")] - pub type intptr_t = i64; - - #[cfg(target_arch = "x86")] - pub type uintptr_t = u32; - #[cfg(target_arch = "x86_64")] - pub type uintptr_t = u64; - - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - - pub mod posix88 { - pub type off_t = i32; - pub type dev_t = u32; - pub type ino_t = u16; - - #[cfg(target_arch = "x86")] - pub type ssize_t = i32; - #[cfg(target_arch = "x86_64")] - pub type ssize_t = i64; - } - - pub mod posix01 { - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - use consts::os::extra::{MAX_PROTOCOL_CHAIN, - WSAPROTOCOL_LEN}; - use types::common::c95::c_void; - use types::os::arch::c95::{c_char, c_int, c_uint, size_t}; - use types::os::arch::c95::{c_long, c_ulong}; - use types::os::arch::c95::{wchar_t}; - use types::os::arch::c99::{c_ulonglong, c_longlong, uintptr_t}; - - pub type BOOL = c_int; - pub type BYTE = u8; - pub type BOOLEAN = BYTE; - pub type CCHAR = c_char; - pub type CHAR = c_char; - - pub type DWORD = c_ulong; - pub type DWORDLONG = c_ulonglong; - - pub type HANDLE = LPVOID; - pub type HINSTANCE = HANDLE; - pub type HMODULE = HINSTANCE; - - pub type LONG = c_long; - pub type PLONG = *mut c_long; - - #[cfg(target_arch = "x86")] - pub type LONG_PTR = c_long; - #[cfg(target_arch = "x86_64")] - pub type LONG_PTR = i64; - - pub type LARGE_INTEGER = c_longlong; - pub type PLARGE_INTEGER = *mut c_longlong; - - pub type LPCWSTR = *const WCHAR; - pub type LPCSTR = *const CHAR; - - pub type LPWSTR = *mut WCHAR; - pub type LPSTR = *mut CHAR; - - pub type LPWCH = *mut WCHAR; - pub type LPCH = *mut CHAR; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct SECURITY_ATTRIBUTES { - pub nLength: DWORD, - pub lpSecurityDescriptor: LPVOID, - pub bInheritHandle: BOOL, - } - pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; - - pub type LPVOID = *mut c_void; - pub type LPCVOID = *const c_void; - pub type LPBYTE = *mut BYTE; - pub type LPWORD = *mut WORD; - pub type LPDWORD = *mut DWORD; - pub type LPHANDLE = *mut HANDLE; - - pub type LRESULT = LONG_PTR; - pub type PBOOL = *mut BOOL; - pub type WCHAR = wchar_t; - pub type WORD = u16; - pub type SIZE_T = size_t; - - pub type time64_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct STARTUPINFOW { - pub cb: DWORD, - pub lpReserved: LPWSTR, - pub lpDesktop: LPWSTR, - pub lpTitle: LPWSTR, - pub dwX: DWORD, - pub dwY: DWORD, - pub dwXSize: DWORD, - pub dwYSize: DWORD, - pub dwXCountChars: DWORD, - pub dwYCountChars: DWORD, - pub dwFillAttribute: DWORD, - pub dwFlags: DWORD, - pub wShowWindow: WORD, - pub cbReserved2: WORD, - pub lpReserved2: LPBYTE, - pub hStdInput: HANDLE, - pub hStdOutput: HANDLE, - pub hStdError: HANDLE, - } - pub type LPSTARTUPINFOW = *mut STARTUPINFOW; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct PROCESS_INFORMATION { - pub hProcess: HANDLE, - pub hThread: HANDLE, - pub dwProcessId: DWORD, - pub dwThreadId: DWORD, - } - pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct SYSTEM_INFO { - pub wProcessorArchitecture: WORD, - pub wReserved: WORD, - pub dwPageSize: DWORD, - pub lpMinimumApplicationAddress: LPVOID, - pub lpMaximumApplicationAddress: LPVOID, - pub dwActiveProcessorMask: uintptr_t, - pub dwNumberOfProcessors: DWORD, - pub dwProcessorType: DWORD, - pub dwAllocationGranularity: DWORD, - pub wProcessorLevel: WORD, - pub wProcessorRevision: WORD, - } - pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct MEMORY_BASIC_INFORMATION { - pub BaseAddress: LPVOID, - pub AllocationBase: LPVOID, - pub AllocationProtect: DWORD, - pub RegionSize: SIZE_T, - pub State: DWORD, - pub Protect: DWORD, - pub Type: DWORD, - } - pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct OVERLAPPED { - pub Internal: *mut c_ulong, - pub InternalHigh: *mut c_ulong, - pub Offset: DWORD, - pub OffsetHigh: DWORD, - pub hEvent: HANDLE, - } - - pub type LPOVERLAPPED = *mut OVERLAPPED; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct FILETIME { - pub dwLowDateTime: DWORD, - pub dwHighDateTime: DWORD, - } - - pub type LPFILETIME = *mut FILETIME; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct GUID { - pub Data1: DWORD, - pub Data2: WORD, - pub Data3: WORD, - pub Data4: [BYTE; 8], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct WSAPROTOCOLCHAIN { - pub ChainLen: c_int, - pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], - } - - pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; - - #[repr(C)] - #[derive(Copy)] pub struct WSAPROTOCOL_INFO { - pub dwServiceFlags1: DWORD, - pub dwServiceFlags2: DWORD, - pub dwServiceFlags3: DWORD, - pub dwServiceFlags4: DWORD, - pub dwProviderFlags: DWORD, - pub ProviderId: GUID, - pub dwCatalogEntryId: DWORD, - pub ProtocolChain: WSAPROTOCOLCHAIN, - pub iVersion: c_int, - pub iAddressFamily: c_int, - pub iMaxSockAddr: c_int, - pub iMinSockAddr: c_int, - pub iSocketType: c_int, - pub iProtocol: c_int, - pub iProtocolMaxOffset: c_int, - pub iNetworkByteOrder: c_int, - pub iSecurityScheme: c_int, - pub dwMessageSize: DWORD, - pub dwProviderReserved: DWORD, - pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], - } - impl Clone for WSAPROTOCOL_INFO { - fn clone(&self) -> WSAPROTOCOL_INFO { *self } - } - - pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; - - pub type GROUP = c_uint; - - #[repr(C)] - #[derive(Copy)] pub struct WIN32_FIND_DATAW { - pub dwFileAttributes: DWORD, - pub ftCreationTime: FILETIME, - pub ftLastAccessTime: FILETIME, - pub ftLastWriteTime: FILETIME, - pub nFileSizeHigh: DWORD, - pub nFileSizeLow: DWORD, - pub dwReserved0: DWORD, - pub dwReserved1: DWORD, - pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 - pub cAlternateFileName: [wchar_t; 14], - } - impl Clone for WIN32_FIND_DATAW { - fn clone(&self) -> WIN32_FIND_DATAW { *self } - } - - pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; - } - } +cfg_if! { + if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { + pub type time_t = i32; + } else { + pub type time_t = i64; } - #[cfg(target_os = "windows")] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 32767; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 4; - pub const _IOLBF : c_int = 64; - pub const BUFSIZ : c_uint = 512; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 260; - - pub const WSAEINTR: c_int = 10004; - pub const WSAEBADF: c_int = 10009; - pub const WSAEACCES: c_int = 10013; - pub const WSAEFAULT: c_int = 10014; - pub const WSAEINVAL: c_int = 10022; - pub const WSAEMFILE: c_int = 10024; - pub const WSAEWOULDBLOCK: c_int = 10035; - pub const WSAEINPROGRESS: c_int = 10036; - pub const WSAEALREADY: c_int = 10037; - pub const WSAENOTSOCK: c_int = 10038; - pub const WSAEDESTADDRREQ: c_int = 10039; - pub const WSAEMSGSIZE: c_int = 10040; - pub const WSAEPROTOTYPE: c_int = 10041; - pub const WSAENOPROTOOPT: c_int = 10042; - pub const WSAEPROTONOSUPPORT: c_int = 10043; - pub const WSAESOCKTNOSUPPORT: c_int = 10044; - pub const WSAEOPNOTSUPP: c_int = 10045; - pub const WSAEPFNOSUPPORT: c_int = 10046; - pub const WSAEAFNOSUPPORT: c_int = 10047; - pub const WSAEADDRINUSE: c_int = 10048; - pub const WSAEADDRNOTAVAIL: c_int = 10049; - pub const WSAENETDOWN: c_int = 10050; - pub const WSAENETUNREACH: c_int = 10051; - pub const WSAENETRESET: c_int = 10052; - pub const WSAECONNABORTED: c_int = 10053; - pub const WSAECONNRESET: c_int = 10054; - pub const WSAENOBUFS: c_int = 10055; - pub const WSAEISCONN: c_int = 10056; - pub const WSAENOTCONN: c_int = 10057; - pub const WSAESHUTDOWN: c_int = 10058; - pub const WSAETOOMANYREFS: c_int = 10059; - pub const WSAETIMEDOUT: c_int = 10060; - pub const WSAECONNREFUSED: c_int = 10061; - pub const WSAELOOP: c_int = 10062; - pub const WSAENAMETOOLONG: c_int = 10063; - pub const WSAEHOSTDOWN: c_int = 10064; - pub const WSAEHOSTUNREACH: c_int = 10065; - pub const WSAENOTEMPTY: c_int = 10066; - pub const WSAEPROCLIM: c_int = 10067; - pub const WSAEUSERS: c_int = 10068; - pub const WSAEDQUOT: c_int = 10069; - pub const WSAESTALE: c_int = 10070; - pub const WSAEREMOTE: c_int = 10071; - pub const WSASYSNOTREADY: c_int = 10091; - pub const WSAVERNOTSUPPORTED: c_int = 10092; - pub const WSANOTINITIALISED: c_int = 10093; - pub const WSAEDISCON: c_int = 10101; - pub const WSAENOMORE: c_int = 10102; - pub const WSAECANCELLED: c_int = 10103; - pub const WSAEINVALIDPROCTABLE: c_int = 10104; - pub const WSAEINVALIDPROVIDER: c_int = 10105; - pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; - - cfg_if! { - if #[cfg(all(target_env = "gnu"))] { - pub const L_tmpnam : c_uint = 14; - pub const TMP_MAX : c_uint = 0x7fff; - } else { - pub const L_tmpnam : c_uint = 260; - pub const TMP_MAX : c_uint = 0x7fff_ffff; - } - } - } - pub mod c99 { - } - pub mod posix88 { - use types::os::arch::c95::c_int; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 256; - pub const O_EXCL : c_int = 1024; - pub const O_TRUNC : c_int = 512; - pub const S_IFCHR : c_int = 8192; - pub const S_IFDIR : c_int = 16384; - pub const S_IFREG : c_int = 32768; - pub const S_IFMT : c_int = 61440; - pub const S_IEXEC : c_int = 64; - pub const S_IWRITE : c_int = 128; - pub const S_IREAD : c_int = 256; - } - pub mod posix01 { - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 23; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 12; - pub const IPV6_DROP_MEMBERSHIP: c_int = 13; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - - pub const TCP_NODELAY: c_int = 0x0001; - pub const SOL_SOCKET: c_int = 0xffff; - - pub const SO_DEBUG: c_int = 0x0001; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 4; - - pub const SD_RECEIVE: c_int = 0; - pub const SD_SEND: c_int = 1; - pub const SD_BOTH: c_int = 2; - } - pub mod extra { - use types::os::common::bsd44::SOCKET; - use types::os::arch::c95::{c_int, c_long}; - use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE}; - - pub const TRUE : BOOL = 1; - pub const FALSE : BOOL = 0; - - pub const O_TEXT : c_int = 16384; - pub const O_BINARY : c_int = 32768; - pub const O_NOINHERIT: c_int = 128; - - pub const ERROR_SUCCESS : c_int = 0; - pub const ERROR_INVALID_FUNCTION: c_int = 1; - pub const ERROR_FILE_NOT_FOUND: c_int = 2; - pub const ERROR_ACCESS_DENIED: c_int = 5; - pub const ERROR_INVALID_HANDLE : c_int = 6; - pub const ERROR_BROKEN_PIPE: c_int = 109; - pub const ERROR_DISK_FULL : c_int = 112; - pub const ERROR_CALL_NOT_IMPLEMENTED : c_int = 120; - pub const ERROR_INSUFFICIENT_BUFFER : c_int = 122; - pub const ERROR_INVALID_NAME : c_int = 123; - pub const ERROR_ALREADY_EXISTS : c_int = 183; - pub const ERROR_PIPE_BUSY: c_int = 231; - pub const ERROR_NO_DATA: c_int = 232; - pub const ERROR_INVALID_ADDRESS : c_int = 487; - pub const ERROR_PIPE_CONNECTED: c_int = 535; - pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758; - pub const ERROR_OPERATION_ABORTED: c_int = 995; - pub const ERROR_IO_PENDING: c_int = 997; - pub const ERROR_FILE_INVALID : c_int = 1006; - pub const ERROR_NOT_FOUND: c_int = 1168; - pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; - - pub const DELETE : DWORD = 0x00010000; - pub const READ_CONTROL : DWORD = 0x00020000; - pub const SYNCHRONIZE : DWORD = 0x00100000; - pub const WRITE_DAC : DWORD = 0x00040000; - pub const WRITE_OWNER : DWORD = 0x00080000; - - pub const PROCESS_CREATE_PROCESS : DWORD = 0x0080; - pub const PROCESS_CREATE_THREAD : DWORD = 0x0002; - pub const PROCESS_DUP_HANDLE : DWORD = 0x0040; - pub const PROCESS_QUERY_INFORMATION : DWORD = 0x0400; - pub const PROCESS_QUERY_LIMITED_INFORMATION : DWORD = 0x1000; - pub const PROCESS_SET_INFORMATION : DWORD = 0x0200; - pub const PROCESS_SET_QUOTA : DWORD = 0x0100; - pub const PROCESS_SUSPEND_RESUME : DWORD = 0x0800; - pub const PROCESS_TERMINATE : DWORD = 0x0001; - pub const PROCESS_VM_OPERATION : DWORD = 0x0008; - pub const PROCESS_VM_READ : DWORD = 0x0010; - pub const PROCESS_VM_WRITE : DWORD = 0x0020; - - pub const STARTF_FORCEONFEEDBACK : DWORD = 0x00000040; - pub const STARTF_FORCEOFFFEEDBACK : DWORD = 0x00000080; - pub const STARTF_PREVENTPINNING : DWORD = 0x00002000; - pub const STARTF_RUNFULLSCREEN : DWORD = 0x00000020; - pub const STARTF_TITLEISAPPID : DWORD = 0x00001000; - pub const STARTF_TITLEISLINKNAME : DWORD = 0x00000800; - pub const STARTF_USECOUNTCHARS : DWORD = 0x00000008; - pub const STARTF_USEFILLATTRIBUTE : DWORD = 0x00000010; - pub const STARTF_USEHOTKEY : DWORD = 0x00000200; - pub const STARTF_USEPOSITION : DWORD = 0x00000004; - pub const STARTF_USESHOWWINDOW : DWORD = 0x00000001; - pub const STARTF_USESIZE : DWORD = 0x00000002; - pub const STARTF_USESTDHANDLES : DWORD = 0x00000100; - - pub const WAIT_ABANDONED : DWORD = 0x00000080; - pub const WAIT_OBJECT_0 : DWORD = 0x00000000; - pub const WAIT_TIMEOUT : DWORD = 0x00000102; - pub const WAIT_FAILED : DWORD = !0; - - pub const DUPLICATE_CLOSE_SOURCE : DWORD = 0x00000001; - pub const DUPLICATE_SAME_ACCESS : DWORD = 0x00000002; - - pub const INFINITE : DWORD = !0; - pub const STILL_ACTIVE : DWORD = 259; - - pub const MEM_COMMIT : DWORD = 0x00001000; - pub const MEM_RESERVE : DWORD = 0x00002000; - pub const MEM_DECOMMIT : DWORD = 0x00004000; - pub const MEM_RELEASE : DWORD = 0x00008000; - pub const MEM_RESET : DWORD = 0x00080000; - pub const MEM_RESET_UNDO : DWORD = 0x1000000; - pub const MEM_LARGE_PAGES : DWORD = 0x20000000; - pub const MEM_PHYSICAL : DWORD = 0x00400000; - pub const MEM_TOP_DOWN : DWORD = 0x00100000; - pub const MEM_WRITE_WATCH : DWORD = 0x00200000; - - pub const PAGE_EXECUTE : DWORD = 0x10; - pub const PAGE_EXECUTE_READ : DWORD = 0x20; - pub const PAGE_EXECUTE_READWRITE : DWORD = 0x40; - pub const PAGE_EXECUTE_WRITECOPY : DWORD = 0x80; - pub const PAGE_NOACCESS : DWORD = 0x01; - pub const PAGE_READONLY : DWORD = 0x02; - pub const PAGE_READWRITE : DWORD = 0x04; - pub const PAGE_WRITECOPY : DWORD = 0x08; - pub const PAGE_GUARD : DWORD = 0x100; - pub const PAGE_NOCACHE : DWORD = 0x200; - pub const PAGE_WRITECOMBINE : DWORD = 0x400; - - pub const SEC_COMMIT : DWORD = 0x8000000; - pub const SEC_IMAGE : DWORD = 0x1000000; - pub const SEC_IMAGE_NO_EXECUTE : DWORD = 0x11000000; - pub const SEC_LARGE_PAGES : DWORD = 0x80000000; - pub const SEC_NOCACHE : DWORD = 0x10000000; - pub const SEC_RESERVE : DWORD = 0x4000000; - pub const SEC_WRITECOMBINE : DWORD = 0x40000000; - - pub const FILE_MAP_ALL_ACCESS : DWORD = 0xf001f; - pub const FILE_MAP_READ : DWORD = 0x4; - pub const FILE_MAP_WRITE : DWORD = 0x2; - pub const FILE_MAP_COPY : DWORD = 0x1; - pub const FILE_MAP_EXECUTE : DWORD = 0x20; - - pub const PROCESSOR_ARCHITECTURE_INTEL : WORD = 0; - pub const PROCESSOR_ARCHITECTURE_ARM : WORD = 5; - pub const PROCESSOR_ARCHITECTURE_IA64 : WORD = 6; - pub const PROCESSOR_ARCHITECTURE_AMD64 : WORD = 9; - pub const PROCESSOR_ARCHITECTURE_UNKNOWN : WORD = 0xffff; - - pub const MOVEFILE_COPY_ALLOWED: DWORD = 2; - pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16; - pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4; - pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32; - pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1; - pub const MOVEFILE_WRITE_THROUGH: DWORD = 8; - - pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1; - - pub const FILE_SHARE_DELETE: DWORD = 0x4; - pub const FILE_SHARE_READ: DWORD = 0x1; - pub const FILE_SHARE_WRITE: DWORD = 0x2; - - pub const CREATE_ALWAYS: DWORD = 2; - pub const CREATE_NEW: DWORD = 1; - pub const OPEN_ALWAYS: DWORD = 4; - pub const OPEN_EXISTING: DWORD = 3; - pub const TRUNCATE_EXISTING: DWORD = 5; - - pub const FILE_APPEND_DATA: DWORD = 0x00000004; - pub const FILE_READ_DATA: DWORD = 0x00000001; - pub const FILE_WRITE_DATA: DWORD = 0x00000002; - - pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20; - pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800; - pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40; - pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10; - pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000; - pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2; - pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000; - pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80; - pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000; - pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000; - pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000; - pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1; - pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400; - pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200; - pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4; - pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100; - pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000; - - pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; - pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; - pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; - pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; - pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; - pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; - pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000; - pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; - pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; - pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; - pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; - pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; - - pub const FILE_NAME_NORMALIZED: DWORD = 0x0; - pub const FILE_NAME_OPENED: DWORD = 0x8; - - pub const VOLUME_NAME_DOS: DWORD = 0x0; - pub const VOLUME_NAME_GUID: DWORD = 0x1; - pub const VOLUME_NAME_NONE: DWORD = 0x4; - pub const VOLUME_NAME_NT: DWORD = 0x2; - - pub const GENERIC_READ: DWORD = 0x80000000; - pub const GENERIC_WRITE: DWORD = 0x40000000; - pub const GENERIC_EXECUTE: DWORD = 0x20000000; - pub const GENERIC_ALL: DWORD = 0x10000000; - pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100; - pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080; - - pub const STANDARD_RIGHTS_READ: DWORD = 0x20000; - pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000; - pub const FILE_WRITE_EA: DWORD = 0x00000010; - pub const FILE_READ_EA: DWORD = 0x00000008; - pub const FILE_GENERIC_READ: DWORD = - STANDARD_RIGHTS_READ | FILE_READ_DATA | - FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; - pub const FILE_GENERIC_WRITE: DWORD = - STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | - FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | - SYNCHRONIZE; - - pub const FILE_BEGIN: DWORD = 0; - pub const FILE_CURRENT: DWORD = 1; - pub const FILE_END: DWORD = 2; - - pub const MAX_PROTOCOL_CHAIN: DWORD = 7; - pub const WSAPROTOCOL_LEN: DWORD = 255; - pub const INVALID_SOCKET: SOCKET = !0; - - pub const DETACHED_PROCESS: DWORD = 0x00000008; - pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; - pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; - - pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; - pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; - pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; - pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; - pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; - pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; - pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; - pub const PIPE_WAIT: DWORD = 0x00000000; - pub const PIPE_NOWAIT: DWORD = 0x00000001; - pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; - pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; - pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; - - pub const IPPROTO_RAW: c_int = 255; - - pub const FIONBIO: c_long = -0x7FFB9982; - } - pub mod sysconf { - } +} + +pub type off_t = i32; +pub type dev_t = u32; +pub type ino_t = u16; +pub enum timezone {} +pub type time64_t = i64; + +pub type BOOL = c_int; +pub type BYTE = u8; +pub type BOOLEAN = BYTE; +pub type CCHAR = c_char; +pub type CHAR = c_char; +pub type DWORD = c_ulong; +pub type DWORDLONG = c_ulonglong; +pub type HANDLE = LPVOID; +pub type HINSTANCE = HANDLE; +pub type HMODULE = HINSTANCE; +pub type LONG = c_long; +pub type PLONG = *mut c_long; +pub type LARGE_INTEGER = c_longlong; +pub type PLARGE_INTEGER = *mut c_longlong; +pub type LPCWSTR = *const WCHAR; +pub type LPCSTR = *const CHAR; +pub type LPWSTR = *mut WCHAR; +pub type LPSTR = *mut CHAR; +pub type LPWCH = *mut WCHAR; +pub type LPCH = *mut CHAR; +pub type SOCKET = uintptr_t; +pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; +pub type LPVOID = *mut ::c_void; +pub type LPCVOID = *const ::c_void; +pub type LPBYTE = *mut BYTE; +pub type LPWORD = *mut WORD; +pub type LPDWORD = *mut DWORD; +pub type LPHANDLE = *mut HANDLE; +pub type LRESULT = LONG_PTR; +pub type PBOOL = *mut BOOL; +pub type WCHAR = wchar_t; +pub type WORD = u16; +pub type SIZE_T = size_t; +pub type GROUP = c_uint; +pub type LPSTARTUPINFOW = *mut STARTUPINFOW; +pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; +pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; +pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; +pub type LPOVERLAPPED = *mut OVERLAPPED; +pub type LPFILETIME = *mut FILETIME; +pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; +pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; +pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; + +s! { + // note this is the struct called stat64 in Windows. Not stat, nor stati64. + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: u16, + pub st_nlink: c_short, + pub st_uid: c_short, + pub st_gid: c_short, + pub st_rdev: dev_t, + pub st_size: i64, + pub st_atime: time64_t, + pub st_mtime: time64_t, + pub st_ctime: time64_t, } + // note that this is called utimbuf64 in Windows + pub struct utimbuf { + pub actime: time64_t, + pub modtime: time64_t, + } + pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } - #[cfg(target_os = "windows")] - pub mod posix88 { - pub mod stat_ { - use types::os::common::posix01::{stat, utimbuf}; - use types::os::arch::c95::{c_int, c_char, wchar_t}; - - extern { - #[link_name = "_chmod"] - pub fn chmod(path: *const c_char, mode: c_int) -> c_int; - #[link_name = "_wchmod"] - pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; - #[link_name = "_mkdir"] - pub fn mkdir(path: *const c_char) -> c_int; - #[link_name = "_wrmdir"] - pub fn wrmdir(path: *const wchar_t) -> c_int; - #[link_name = "_fstat64"] - pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; - #[link_name = "_stat64"] - pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; - #[link_name = "_wstat64"] - pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; - #[link_name = "_wutime64"] - pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; - } - } - - pub mod stdio { - use types::common::c95::FILE; - use types::os::arch::c95::{c_int, c_char}; - - extern { - #[link_name = "_popen"] - pub fn popen(command: *const c_char, - mode: *const c_char) -> *mut FILE; - #[link_name = "_pclose"] - pub fn pclose(stream: *mut FILE) -> c_int; - #[link_name = "_fdopen"] - pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut FILE; - #[link_name = "_fileno"] - pub fn fileno(stream: *mut FILE) -> c_int; - } - } - - pub mod fcntl { - use types::os::arch::c95::{c_int, c_char, wchar_t}; - extern { - #[link_name = "_open"] - pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; - #[link_name = "_wopen"] - pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int; - #[link_name = "_creat"] - pub fn creat(path: *const c_char, mode: c_int) -> c_int; - } - } - - pub mod dirent { - // Not supplied at all. - } - - pub mod unistd { - use types::common::c95::c_void; - use types::os::arch::c95::{c_int, c_uint, c_char, c_long}; - use types::os::arch::c99::intptr_t; - - extern { - #[link_name = "_access"] - pub fn access(path: *const c_char, amode: c_int) -> c_int; - #[link_name = "_chdir"] - pub fn chdir(dir: *const c_char) -> c_int; - #[link_name = "_close"] - pub fn close(fd: c_int) -> c_int; - #[link_name = "_dup"] - pub fn dup(fd: c_int) -> c_int; - #[link_name = "_dup2"] - pub fn dup2(src: c_int, dst: c_int) -> c_int; - #[link_name = "_execv"] - pub fn execv(prog: *const c_char, - argv: *const *const c_char) -> intptr_t; - #[link_name = "_execve"] - pub fn execve(prog: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) - -> c_int; - #[link_name = "_execvp"] - pub fn execvp(c: *const c_char, - argv: *const *const c_char) -> c_int; - #[link_name = "_execvpe"] - pub fn execvpe(c: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) -> c_int; - #[link_name = "_getcwd"] - pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char; - #[link_name = "_getpid"] - pub fn getpid() -> c_int; - #[link_name = "_isatty"] - pub fn isatty(fd: c_int) -> c_int; - #[link_name = "_lseek"] - pub fn lseek(fd: c_int, offset: c_long, origin: c_int) - -> c_long; - #[link_name = "_pipe"] - pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) - -> c_int; - #[link_name = "_read"] - pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) - -> c_int; - #[link_name = "_rmdir"] - pub fn rmdir(path: *const c_char) -> c_int; - #[link_name = "_unlink"] - pub fn unlink(c: *const c_char) -> c_int; - #[link_name = "_write"] - pub fn write(fd: c_int, buf: *const c_void, - count: c_uint) -> c_int; - } - } - - pub mod mman { - } + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, } + pub struct sockaddr { + pub sa_family: u16, + pub sa_data: [u8; 14], + } - #[cfg(target_os = "windows")] - pub mod extra { - - pub mod kernel32 { - use types::os::arch::c95::{c_uint}; - use types::os::arch::extra::*; - - extern "system" { - pub fn GetEnvironmentVariableW(n: LPCWSTR, - v: LPWSTR, - nsize: DWORD) - -> DWORD; - pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) - -> BOOL; - pub fn GetEnvironmentStringsW() -> LPWCH; - pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL; - pub fn GetModuleFileNameW(hModule: HMODULE, - lpFilename: LPWSTR, - nSize: DWORD) - -> DWORD; - pub fn CreateDirectoryW(lpPathName: LPCWSTR, - lpSecurityAttributes: - LPSECURITY_ATTRIBUTES) - -> BOOL; - pub fn CopyFileW(lpExistingFileName: LPCWSTR, - lpNewFileName: LPCWSTR, - bFailIfExists: BOOL) - -> BOOL; - pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL; - pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; - pub fn GetCurrentDirectoryW(nBufferLength: DWORD, - lpBuffer: LPWSTR) - -> DWORD; - pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; - pub fn GetLastError() -> DWORD; - pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) - -> HANDLE; - pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) - -> BOOL; - pub fn FindClose(findFile: HANDLE) -> BOOL; - pub fn DuplicateHandle(hSourceProcessHandle: HANDLE, - hSourceHandle: HANDLE, - hTargetProcessHandle: HANDLE, - lpTargetHandle: LPHANDLE, - dwDesiredAccess: DWORD, - bInheritHandle: BOOL, - dwOptions: DWORD) - -> BOOL; - pub fn CloseHandle(hObject: HANDLE) -> BOOL; - pub fn OpenProcess(dwDesiredAccess: DWORD, - bInheritHandle: BOOL, - dwProcessId: DWORD) - -> HANDLE; - pub fn GetCurrentProcess() -> HANDLE; - pub fn CreateProcessW(lpApplicationName: LPCWSTR, - lpCommandLine: LPWSTR, - lpProcessAttributes: - LPSECURITY_ATTRIBUTES, - lpThreadAttributes: - LPSECURITY_ATTRIBUTES, - bInheritHandles: BOOL, - dwCreationFlags: DWORD, - lpEnvironment: LPVOID, - lpCurrentDirectory: LPCWSTR, - lpStartupInfo: LPSTARTUPINFOW, - lpProcessInformation: - LPPROCESS_INFORMATION) - -> BOOL; - pub fn WaitForSingleObject(hHandle: HANDLE, - dwMilliseconds: DWORD) - -> DWORD; - pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) - -> BOOL; - pub fn GetExitCodeProcess(hProcess: HANDLE, - lpExitCode: LPDWORD) - -> BOOL; - pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); - pub fn VirtualAlloc(lpAddress: LPVOID, - dwSize: SIZE_T, - flAllocationType: DWORD, - flProtect: DWORD) - -> LPVOID; - pub fn VirtualFree(lpAddress: LPVOID, - dwSize: SIZE_T, - dwFreeType: DWORD) - -> BOOL; - pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; - pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) - -> BOOL; - pub fn VirtualProtect(lpAddress: LPVOID, - dwSize: SIZE_T, - flNewProtect: DWORD, - lpflOldProtect: LPDWORD) - -> BOOL; - pub fn VirtualQuery(lpAddress: LPCVOID, - lpBuffer: PMEMORY_BASIC_INFORMATION, - dwLength: SIZE_T) - -> SIZE_T; - pub fn CreateFileMappingW(hFile: HANDLE, - lpAttributes: LPSECURITY_ATTRIBUTES, - flProtect: DWORD, - dwMaximumSizeHigh: DWORD, - dwMaximumSizeLow: DWORD, - lpName: LPCWSTR) - -> HANDLE; - pub fn MapViewOfFile(hFileMappingObject: HANDLE, - dwDesiredAccess: DWORD, - dwFileOffsetHigh: DWORD, - dwFileOffsetLow: DWORD, - dwNumberOfBytesToMap: SIZE_T) - -> LPVOID; - pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; - pub fn MoveFileExW(lpExistingFileName: LPCWSTR, - lpNewFileName: LPCWSTR, - dwFlags: DWORD) -> BOOL; - pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR, - lpTargetFileName: LPCWSTR, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES) - -> BOOL; - pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; - pub fn CreateFileW(lpFileName: LPCWSTR, - dwDesiredAccess: DWORD, - dwShareMode: DWORD, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES, - dwCreationDisposition: DWORD, - dwFlagsAndAttributes: DWORD, - hTemplateFile: HANDLE) -> HANDLE; - pub fn ReadFile(hFile: HANDLE, - lpBuffer: LPVOID, - nNumberOfBytesToRead: DWORD, - lpNumberOfBytesRead: LPDWORD, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn WriteFile(hFile: HANDLE, - lpBuffer: LPCVOID, - nNumberOfBytesToWrite: DWORD, - lpNumberOfBytesWritten: LPDWORD, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn SetFilePointerEx(hFile: HANDLE, - liDistanceToMove: LARGE_INTEGER, - lpNewFilePointer: PLARGE_INTEGER, - dwMoveMethod: DWORD) -> BOOL; - pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; - - pub fn GetSystemTimeAsFileTime( - lpSystemTimeAsFileTime: LPFILETIME); - - pub fn QueryPerformanceFrequency( - lpFrequency: *mut LARGE_INTEGER) -> BOOL; - pub fn QueryPerformanceCounter( - lpPerformanceCount: *mut LARGE_INTEGER) -> BOOL; - - pub fn GetCurrentProcessId() -> DWORD; - pub fn CreateNamedPipeW( - lpName: LPCWSTR, - dwOpenMode: DWORD, - dwPipeMode: DWORD, - nMaxInstances: DWORD, - nOutBufferSize: DWORD, - nInBufferSize: DWORD, - nDefaultTimeOut: DWORD, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES - ) -> HANDLE; - pub fn ConnectNamedPipe(hNamedPipe: HANDLE, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, - nTimeOut: DWORD) -> BOOL; - pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE, - lpMode: LPDWORD, - lpMaxCollectionCount: LPDWORD, - lpCollectDataTimeout: LPDWORD) - -> BOOL; - pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES, - bManualReset: BOOL, - bInitialState: BOOL, - lpName: LPCWSTR) -> HANDLE; - pub fn GetOverlappedResult(hFile: HANDLE, - lpOverlapped: LPOVERLAPPED, - lpNumberOfBytesTransferred: LPDWORD, - bWait: BOOL) -> BOOL; - pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; - } - } - - pub mod msvcrt { - use types::os::arch::c95::c_int; - use types::os::arch::c99::intptr_t; - - extern { - #[link_name = "_commit"] - pub fn commit(fd: c_int) -> c_int; - - #[link_name = "_get_osfhandle"] - pub fn get_osfhandle(fd: c_int) -> intptr_t; - - #[link_name = "_open_osfhandle"] - pub fn open_osfhandle(osfhandle: intptr_t, - flags: c_int) -> c_int; - } - } - - pub mod winsock { - use types::os::arch::c95::{c_int, c_long, c_ulong}; - use types::os::common::bsd44::SOCKET; - - extern "system" { - pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int; - } - } + pub struct sockaddr_storage { + pub ss_family: u16, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + + pub struct sockaddr_in { + pub sin_family: u16, + pub sin_port: u16, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + pub struct in_addr { + pub s_addr: u32, + } + + pub struct sockaddr_in6 { + pub sin6_family: u16, + pub sin6_port: u16, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, } - #[cfg(windows)] - pub mod bsd43 { - use types::os::common::bsd44::{sockaddr, SOCKET}; - use types::os::arch::c95::{c_int, c_char}; - - extern "system" { - pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; - pub fn connect(socket: SOCKET, address: *const sockaddr, - len: c_int) -> c_int; - pub fn bind(socket: SOCKET, address: *const sockaddr, - address_len: c_int) -> c_int; - pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; - pub fn accept(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> SOCKET; - pub fn getpeername(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> c_int; - pub fn getsockname(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> c_int; - pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, - value: *const c_char, - option_len: c_int) -> c_int; - pub fn closesocket(socket: SOCKET) -> c_int; - pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int, - flags: c_int) -> c_int; - pub fn send(socket: SOCKET, buf: *const c_char, len: c_int, - flags: c_int) -> c_int; - pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int, - flags: c_int, addr: *mut sockaddr, - addrlen: *mut c_int) -> c_int; - pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int, - flags: c_int, addr: *const sockaddr, - addrlen: c_int) -> c_int; - pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; - } + pub struct in6_addr { + pub s6_addr: [u16; 8], } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: size_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct SECURITY_ATTRIBUTES { + pub nLength: DWORD, + pub lpSecurityDescriptor: LPVOID, + pub bInheritHandle: BOOL, + } + + pub struct STARTUPINFOW { + pub cb: DWORD, + pub lpReserved: LPWSTR, + pub lpDesktop: LPWSTR, + pub lpTitle: LPWSTR, + pub dwX: DWORD, + pub dwY: DWORD, + pub dwXSize: DWORD, + pub dwYSize: DWORD, + pub dwXCountChars: DWORD, + pub dwYCountChars: DWORD, + pub dwFillAttribute: DWORD, + pub dwFlags: DWORD, + pub wShowWindow: WORD, + pub cbReserved2: WORD, + pub lpReserved2: LPBYTE, + pub hStdInput: HANDLE, + pub hStdOutput: HANDLE, + pub hStdError: HANDLE, + } + + pub struct PROCESS_INFORMATION { + pub hProcess: HANDLE, + pub hThread: HANDLE, + pub dwProcessId: DWORD, + pub dwThreadId: DWORD, + } + + pub struct SYSTEM_INFO { + pub wProcessorArchitecture: WORD, + pub wReserved: WORD, + pub dwPageSize: DWORD, + pub lpMinimumApplicationAddress: LPVOID, + pub lpMaximumApplicationAddress: LPVOID, + pub dwActiveProcessorMask: uintptr_t, + pub dwNumberOfProcessors: DWORD, + pub dwProcessorType: DWORD, + pub dwAllocationGranularity: DWORD, + pub wProcessorLevel: WORD, + pub wProcessorRevision: WORD, + } + + pub struct MEMORY_BASIC_INFORMATION { + pub BaseAddress: LPVOID, + pub AllocationBase: LPVOID, + pub AllocationProtect: DWORD, + pub RegionSize: SIZE_T, + pub State: DWORD, + pub Protect: DWORD, + pub Type: DWORD, + } + + pub struct OVERLAPPED { + pub Internal: *mut c_ulong, + pub InternalHigh: *mut c_ulong, + pub Offset: DWORD, + pub OffsetHigh: DWORD, + pub hEvent: HANDLE, + } + + pub struct FILETIME { + pub dwLowDateTime: DWORD, + pub dwHighDateTime: DWORD, + } + + pub struct GUID { + pub Data1: DWORD, + pub Data2: WORD, + pub Data3: WORD, + pub Data4: [BYTE; 8], + } + + pub struct WSAPROTOCOLCHAIN { + pub ChainLen: c_int, + pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], + } + + pub struct WSAPROTOCOL_INFO { + pub dwServiceFlags1: DWORD, + pub dwServiceFlags2: DWORD, + pub dwServiceFlags3: DWORD, + pub dwServiceFlags4: DWORD, + pub dwProviderFlags: DWORD, + pub ProviderId: GUID, + pub dwCatalogEntryId: DWORD, + pub ProtocolChain: WSAPROTOCOLCHAIN, + pub iVersion: c_int, + pub iAddressFamily: c_int, + pub iMaxSockAddr: c_int, + pub iMinSockAddr: c_int, + pub iSocketType: c_int, + pub iProtocol: c_int, + pub iProtocolMaxOffset: c_int, + pub iNetworkByteOrder: c_int, + pub iSecurityScheme: c_int, + pub dwMessageSize: DWORD, + pub dwProviderReserved: DWORD, + pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], + } + + pub struct WIN32_FIND_DATAW { + pub dwFileAttributes: DWORD, + pub ftCreationTime: FILETIME, + pub ftLastAccessTime: FILETIME, + pub ftLastWriteTime: FILETIME, + pub nFileSizeHigh: DWORD, + pub nFileSizeLow: DWORD, + pub dwReserved0: DWORD, + pub dwReserved1: DWORD, + pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 + pub cAlternateFileName: [wchar_t; 14], + } +} + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 32767; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 4; +pub const _IOLBF: c_int = 64; +pub const BUFSIZ: c_uint = 512; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 260; + +pub const WSAEINTR: c_int = 10004; +pub const WSAEBADF: c_int = 10009; +pub const WSAEACCES: c_int = 10013; +pub const WSAEFAULT: c_int = 10014; +pub const WSAEINVAL: c_int = 10022; +pub const WSAEMFILE: c_int = 10024; +pub const WSAEWOULDBLOCK: c_int = 10035; +pub const WSAEINPROGRESS: c_int = 10036; +pub const WSAEALREADY: c_int = 10037; +pub const WSAENOTSOCK: c_int = 10038; +pub const WSAEDESTADDRREQ: c_int = 10039; +pub const WSAEMSGSIZE: c_int = 10040; +pub const WSAEPROTOTYPE: c_int = 10041; +pub const WSAENOPROTOOPT: c_int = 10042; +pub const WSAEPROTONOSUPPORT: c_int = 10043; +pub const WSAESOCKTNOSUPPORT: c_int = 10044; +pub const WSAEOPNOTSUPP: c_int = 10045; +pub const WSAEPFNOSUPPORT: c_int = 10046; +pub const WSAEAFNOSUPPORT: c_int = 10047; +pub const WSAEADDRINUSE: c_int = 10048; +pub const WSAEADDRNOTAVAIL: c_int = 10049; +pub const WSAENETDOWN: c_int = 10050; +pub const WSAENETUNREACH: c_int = 10051; +pub const WSAENETRESET: c_int = 10052; +pub const WSAECONNABORTED: c_int = 10053; +pub const WSAECONNRESET: c_int = 10054; +pub const WSAENOBUFS: c_int = 10055; +pub const WSAEISCONN: c_int = 10056; +pub const WSAENOTCONN: c_int = 10057; +pub const WSAESHUTDOWN: c_int = 10058; +pub const WSAETOOMANYREFS: c_int = 10059; +pub const WSAETIMEDOUT: c_int = 10060; +pub const WSAECONNREFUSED: c_int = 10061; +pub const WSAELOOP: c_int = 10062; +pub const WSAENAMETOOLONG: c_int = 10063; +pub const WSAEHOSTDOWN: c_int = 10064; +pub const WSAEHOSTUNREACH: c_int = 10065; +pub const WSAENOTEMPTY: c_int = 10066; +pub const WSAEPROCLIM: c_int = 10067; +pub const WSAEUSERS: c_int = 10068; +pub const WSAEDQUOT: c_int = 10069; +pub const WSAESTALE: c_int = 10070; +pub const WSAEREMOTE: c_int = 10071; +pub const WSASYSNOTREADY: c_int = 10091; +pub const WSAVERNOTSUPPORTED: c_int = 10092; +pub const WSANOTINITIALISED: c_int = 10093; +pub const WSAEDISCON: c_int = 10101; +pub const WSAENOMORE: c_int = 10102; +pub const WSAECANCELLED: c_int = 10103; +pub const WSAEINVALIDPROCTABLE: c_int = 10104; +pub const WSAEINVALIDPROVIDER: c_int = 10105; +pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; + +cfg_if! { + if #[cfg(all(target_env = "gnu"))] { + pub const L_tmpnam: c_uint = 14; + pub const TMP_MAX: c_uint = 0x7fff; + } else { + pub const L_tmpnam: c_uint = 260; + pub const TMP_MAX: c_uint = 0x7fff_ffff; + } +} + +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 256; +pub const O_EXCL: c_int = 1024; +pub const O_TRUNC: c_int = 512; +pub const S_IFCHR: c_int = 8192; +pub const S_IFDIR: c_int = 16384; +pub const S_IFREG: c_int = 32768; +pub const S_IFMT: c_int = 61440; +pub const S_IEXEC: c_int = 64; +pub const S_IWRITE: c_int = 128; +pub const S_IREAD: c_int = 256; + +pub const AF_INET: c_int = 2; +pub const AF_INET6: c_int = 23; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_IPV6: c_int = 41; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IPV6_ADD_MEMBERSHIP: c_int = 12; +pub const IPV6_DROP_MEMBERSHIP: c_int = 13; +pub const IP_TTL: c_int = 4; +pub const IP_HDRINCL: c_int = 2; + +pub const TCP_NODELAY: c_int = 0x0001; +pub const SOL_SOCKET: c_int = 0xffff; + +pub const SO_DEBUG: c_int = 0x0001; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; + +pub const IFF_LOOPBACK: c_int = 4; + +pub const SD_RECEIVE: c_int = 0; +pub const SD_SEND: c_int = 1; +pub const SD_BOTH: c_int = 2; + +pub const TRUE: BOOL = 1; +pub const FALSE: BOOL = 0; + +pub const O_TEXT: c_int = 16384; +pub const O_BINARY: c_int = 32768; +pub const O_NOINHERIT: c_int = 128; + +pub const ERROR_SUCCESS: c_int = 0; +pub const ERROR_INVALID_FUNCTION: c_int = 1; +pub const ERROR_FILE_NOT_FOUND: c_int = 2; +pub const ERROR_ACCESS_DENIED: c_int = 5; +pub const ERROR_INVALID_HANDLE: c_int = 6; +pub const ERROR_BROKEN_PIPE: c_int = 109; +pub const ERROR_DISK_FULL: c_int = 112; +pub const ERROR_CALL_NOT_IMPLEMENTED: c_int = 120; +pub const ERROR_INSUFFICIENT_BUFFER: c_int = 122; +pub const ERROR_INVALID_NAME: c_int = 123; +pub const ERROR_ALREADY_EXISTS: c_int = 183; +pub const ERROR_PIPE_BUSY: c_int = 231; +pub const ERROR_NO_DATA: c_int = 232; +pub const ERROR_INVALID_ADDRESS: c_int = 487; +pub const ERROR_PIPE_CONNECTED: c_int = 535; +pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758; +pub const ERROR_OPERATION_ABORTED: c_int = 995; +pub const ERROR_IO_PENDING: c_int = 997; +pub const ERROR_FILE_INVALID: c_int = 1006; +pub const ERROR_NOT_FOUND: c_int = 1168; +pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; + +pub const DELETE: DWORD = 0x00010000; +pub const READ_CONTROL: DWORD = 0x00020000; +pub const SYNCHRONIZE: DWORD = 0x00100000; +pub const WRITE_DAC: DWORD = 0x00040000; +pub const WRITE_OWNER: DWORD = 0x00080000; + +pub const PROCESS_CREATE_PROCESS: DWORD = 0x0080; +pub const PROCESS_CREATE_THREAD: DWORD = 0x0002; +pub const PROCESS_DUP_HANDLE: DWORD = 0x0040; +pub const PROCESS_QUERY_INFORMATION: DWORD = 0x0400; +pub const PROCESS_QUERY_LIMITED_INFORMATION: DWORD = 0x1000; +pub const PROCESS_SET_INFORMATION: DWORD = 0x0200; +pub const PROCESS_SET_QUOTA: DWORD = 0x0100; +pub const PROCESS_SUSPEND_RESUME: DWORD = 0x0800; +pub const PROCESS_TERMINATE: DWORD = 0x0001; +pub const PROCESS_VM_OPERATION: DWORD = 0x0008; +pub const PROCESS_VM_READ: DWORD = 0x0010; +pub const PROCESS_VM_WRITE: DWORD = 0x0020; + +pub const STARTF_FORCEONFEEDBACK: DWORD = 0x00000040; +pub const STARTF_FORCEOFFFEEDBACK: DWORD = 0x00000080; +pub const STARTF_PREVENTPINNING: DWORD = 0x00002000; +pub const STARTF_RUNFULLSCREEN: DWORD = 0x00000020; +pub const STARTF_TITLEISAPPID: DWORD = 0x00001000; +pub const STARTF_TITLEISLINKNAME: DWORD = 0x00000800; +pub const STARTF_USECOUNTCHARS: DWORD = 0x00000008; +pub const STARTF_USEFILLATTRIBUTE: DWORD = 0x00000010; +pub const STARTF_USEHOTKEY: DWORD = 0x00000200; +pub const STARTF_USEPOSITION: DWORD = 0x00000004; +pub const STARTF_USESHOWWINDOW: DWORD = 0x00000001; +pub const STARTF_USESIZE: DWORD = 0x00000002; +pub const STARTF_USESTDHANDLES: DWORD = 0x00000100; + +pub const WAIT_ABANDONED: DWORD = 0x00000080; +pub const WAIT_OBJECT_0: DWORD = 0x00000000; +pub const WAIT_TIMEOUT: DWORD = 0x00000102; +pub const WAIT_FAILED: DWORD = !0; + +pub const DUPLICATE_CLOSE_SOURCE: DWORD = 0x00000001; +pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002; + +pub const INFINITE: DWORD = !0; +pub const STILL_ACTIVE: DWORD = 259; + +pub const MEM_COMMIT: DWORD = 0x00001000; +pub const MEM_RESERVE: DWORD = 0x00002000; +pub const MEM_DECOMMIT: DWORD = 0x00004000; +pub const MEM_RELEASE: DWORD = 0x00008000; +pub const MEM_RESET: DWORD = 0x00080000; +pub const MEM_RESET_UNDO: DWORD = 0x1000000; +pub const MEM_LARGE_PAGES: DWORD = 0x20000000; +pub const MEM_PHYSICAL: DWORD = 0x00400000; +pub const MEM_TOP_DOWN: DWORD = 0x00100000; +pub const MEM_WRITE_WATCH: DWORD = 0x00200000; + +pub const PAGE_EXECUTE: DWORD = 0x10; +pub const PAGE_EXECUTE_READ: DWORD = 0x20; +pub const PAGE_EXECUTE_READWRITE: DWORD = 0x40; +pub const PAGE_EXECUTE_WRITECOPY: DWORD = 0x80; +pub const PAGE_NOACCESS: DWORD = 0x01; +pub const PAGE_READONLY: DWORD = 0x02; +pub const PAGE_READWRITE: DWORD = 0x04; +pub const PAGE_WRITECOPY: DWORD = 0x08; +pub const PAGE_GUARD: DWORD = 0x100; +pub const PAGE_NOCACHE: DWORD = 0x200; +pub const PAGE_WRITECOMBINE: DWORD = 0x400; + +pub const SEC_COMMIT: DWORD = 0x8000000; +pub const SEC_IMAGE: DWORD = 0x1000000; +pub const SEC_IMAGE_NO_EXECUTE: DWORD = 0x11000000; +pub const SEC_LARGE_PAGES: DWORD = 0x80000000; +pub const SEC_NOCACHE: DWORD = 0x10000000; +pub const SEC_RESERVE: DWORD = 0x4000000; +pub const SEC_WRITECOMBINE: DWORD = 0x40000000; + +pub const FILE_MAP_ALL_ACCESS: DWORD = 0xf001f; +pub const FILE_MAP_READ: DWORD = 0x4; +pub const FILE_MAP_WRITE: DWORD = 0x2; +pub const FILE_MAP_COPY: DWORD = 0x1; +pub const FILE_MAP_EXECUTE: DWORD = 0x20; + +pub const PROCESSOR_ARCHITECTURE_INTEL: WORD = 0; +pub const PROCESSOR_ARCHITECTURE_ARM: WORD = 5; +pub const PROCESSOR_ARCHITECTURE_IA64: WORD = 6; +pub const PROCESSOR_ARCHITECTURE_AMD64: WORD = 9; +pub const PROCESSOR_ARCHITECTURE_UNKNOWN: WORD = 0xffff; + +pub const MOVEFILE_COPY_ALLOWED: DWORD = 2; +pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16; +pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4; +pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32; +pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1; +pub const MOVEFILE_WRITE_THROUGH: DWORD = 8; + +pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1; + +pub const FILE_SHARE_DELETE: DWORD = 0x4; +pub const FILE_SHARE_READ: DWORD = 0x1; +pub const FILE_SHARE_WRITE: DWORD = 0x2; + +pub const CREATE_ALWAYS: DWORD = 2; +pub const CREATE_NEW: DWORD = 1; +pub const OPEN_ALWAYS: DWORD = 4; +pub const OPEN_EXISTING: DWORD = 3; +pub const TRUNCATE_EXISTING: DWORD = 5; + +pub const FILE_APPEND_DATA: DWORD = 0x00000004; +pub const FILE_READ_DATA: DWORD = 0x00000001; +pub const FILE_WRITE_DATA: DWORD = 0x00000002; + +pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20; +pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800; +pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40; +pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10; +pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000; +pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2; +pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000; +pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80; +pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000; +pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000; +pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000; +pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1; +pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400; +pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200; +pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4; +pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100; +pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000; + +pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; +pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; +pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; +pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; +pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; +pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; +pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000; +pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; +pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; +pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; +pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; +pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; + +pub const FILE_NAME_NORMALIZED: DWORD = 0x0; +pub const FILE_NAME_OPENED: DWORD = 0x8; + +pub const VOLUME_NAME_DOS: DWORD = 0x0; +pub const VOLUME_NAME_GUID: DWORD = 0x1; +pub const VOLUME_NAME_NONE: DWORD = 0x4; +pub const VOLUME_NAME_NT: DWORD = 0x2; + +pub const GENERIC_READ: DWORD = 0x80000000; +pub const GENERIC_WRITE: DWORD = 0x40000000; +pub const GENERIC_EXECUTE: DWORD = 0x20000000; +pub const GENERIC_ALL: DWORD = 0x10000000; +pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100; +pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080; + +pub const STANDARD_RIGHTS_READ: DWORD = 0x20000; +pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000; +pub const FILE_WRITE_EA: DWORD = 0x00000010; +pub const FILE_READ_EA: DWORD = 0x00000008; +pub const FILE_GENERIC_READ: DWORD = + STANDARD_RIGHTS_READ | FILE_READ_DATA | + FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; +pub const FILE_GENERIC_WRITE: DWORD = + STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | + FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | + SYNCHRONIZE; + +pub const FILE_BEGIN: DWORD = 0; +pub const FILE_CURRENT: DWORD = 1; +pub const FILE_END: DWORD = 2; + +pub const MAX_PROTOCOL_CHAIN: DWORD = 7; +pub const WSAPROTOCOL_LEN: DWORD = 255; +pub const INVALID_SOCKET: SOCKET = !0; + +pub const DETACHED_PROCESS: DWORD = 0x00000008; +pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; +pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; + +pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; +pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; +pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; +pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; +pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; +pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; +pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; +pub const PIPE_WAIT: DWORD = 0x00000000; +pub const PIPE_NOWAIT: DWORD = 0x00000001; +pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; +pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; +pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; + +pub const IPPROTO_RAW: c_int = 255; + +pub const FIONBIO: c_long = -0x7FFB9982; + +extern { + #[link_name = "_chmod"] + pub fn chmod(path: *const c_char, mode: c_int) -> c_int; + #[link_name = "_wchmod"] + pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; + #[link_name = "_mkdir"] + pub fn mkdir(path: *const c_char) -> c_int; + #[link_name = "_wrmdir"] + pub fn wrmdir(path: *const wchar_t) -> c_int; + #[link_name = "_fstat64"] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + #[link_name = "_stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + #[link_name = "_wstat64"] + pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; + #[link_name = "_wutime64"] + pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; + #[link_name = "_popen"] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; + #[link_name = "_pclose"] + pub fn pclose(stream: *mut ::FILE) -> c_int; + #[link_name = "_fdopen"] + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut ::FILE; + #[link_name = "_fileno"] + pub fn fileno(stream: *mut ::FILE) -> c_int; + #[link_name = "_open"] + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + #[link_name = "_wopen"] + pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int; + #[link_name = "_creat"] + pub fn creat(path: *const c_char, mode: c_int) -> c_int; + #[link_name = "_access"] + pub fn access(path: *const c_char, amode: c_int) -> c_int; + #[link_name = "_chdir"] + pub fn chdir(dir: *const c_char) -> c_int; + #[link_name = "_close"] + pub fn close(fd: c_int) -> c_int; + #[link_name = "_dup"] + pub fn dup(fd: c_int) -> c_int; + #[link_name = "_dup2"] + pub fn dup2(src: c_int, dst: c_int) -> c_int; + #[link_name = "_execv"] + pub fn execv(prog: *const c_char, argv: *const *const c_char) -> intptr_t; + #[link_name = "_execve"] + pub fn execve(prog: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) -> c_int; + #[link_name = "_execvp"] + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; + #[link_name = "_execvpe"] + pub fn execvpe(c: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) -> c_int; + #[link_name = "_getcwd"] + pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char; + #[link_name = "_getpid"] + pub fn getpid() -> c_int; + #[link_name = "_isatty"] + pub fn isatty(fd: c_int) -> c_int; + #[link_name = "_lseek"] + pub fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long; + #[link_name = "_pipe"] + pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) -> c_int; + #[link_name = "_read"] + pub fn read(fd: c_int, buf: *mut ::c_void, count: c_uint) -> c_int; + #[link_name = "_rmdir"] + pub fn rmdir(path: *const c_char) -> c_int; + #[link_name = "_unlink"] + pub fn unlink(c: *const c_char) -> c_int; + #[link_name = "_write"] + pub fn write(fd: c_int, buf: *const ::c_void, count: c_uint) -> c_int; + #[link_name = "_commit"] + pub fn commit(fd: c_int) -> c_int; + #[link_name = "_get_osfhandle"] + pub fn get_osfhandle(fd: c_int) -> intptr_t; + #[link_name = "_open_osfhandle"] + pub fn open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int; +} + +extern "system" { + pub fn GetEnvironmentVariableW(n: LPCWSTR, + v: LPWSTR, + nsize: DWORD) + -> DWORD; + pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) + -> BOOL; + pub fn GetEnvironmentStringsW() -> LPWCH; + pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL; + pub fn GetModuleFileNameW(hModule: HMODULE, + lpFilename: LPWSTR, + nSize: DWORD) + -> DWORD; + pub fn CreateDirectoryW(lpPathName: LPCWSTR, + lpSecurityAttributes: + LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn CopyFileW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + bFailIfExists: BOOL) + -> BOOL; + pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL; + pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetCurrentDirectoryW(nBufferLength: DWORD, + lpBuffer: LPWSTR) + -> DWORD; + pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; + pub fn GetLastError() -> DWORD; + pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) + -> HANDLE; + pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) + -> BOOL; + pub fn FindClose(findFile: HANDLE) -> BOOL; + pub fn DuplicateHandle(hSourceProcessHandle: HANDLE, + hSourceHandle: HANDLE, + hTargetProcessHandle: HANDLE, + lpTargetHandle: LPHANDLE, + dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwOptions: DWORD) + -> BOOL; + pub fn CloseHandle(hObject: HANDLE) -> BOOL; + pub fn OpenProcess(dwDesiredAccess: DWORD, + bInheritHandle: BOOL, + dwProcessId: DWORD) + -> HANDLE; + pub fn GetCurrentProcess() -> HANDLE; + pub fn CreateProcessW(lpApplicationName: LPCWSTR, + lpCommandLine: LPWSTR, + lpProcessAttributes: + LPSECURITY_ATTRIBUTES, + lpThreadAttributes: + LPSECURITY_ATTRIBUTES, + bInheritHandles: BOOL, + dwCreationFlags: DWORD, + lpEnvironment: LPVOID, + lpCurrentDirectory: LPCWSTR, + lpStartupInfo: LPSTARTUPINFOW, + lpProcessInformation: + LPPROCESS_INFORMATION) + -> BOOL; + pub fn WaitForSingleObject(hHandle: HANDLE, + dwMilliseconds: DWORD) + -> DWORD; + pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) + -> BOOL; + pub fn GetExitCodeProcess(hProcess: HANDLE, + lpExitCode: LPDWORD) + -> BOOL; + pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); + pub fn VirtualAlloc(lpAddress: LPVOID, + dwSize: SIZE_T, + flAllocationType: DWORD, + flProtect: DWORD) + -> LPVOID; + pub fn VirtualFree(lpAddress: LPVOID, + dwSize: SIZE_T, + dwFreeType: DWORD) + -> BOOL; + pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; + pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) + -> BOOL; + pub fn VirtualProtect(lpAddress: LPVOID, + dwSize: SIZE_T, + flNewProtect: DWORD, + lpflOldProtect: LPDWORD) + -> BOOL; + pub fn VirtualQuery(lpAddress: LPCVOID, + lpBuffer: PMEMORY_BASIC_INFORMATION, + dwLength: SIZE_T) + -> SIZE_T; + pub fn CreateFileMappingW(hFile: HANDLE, + lpAttributes: LPSECURITY_ATTRIBUTES, + flProtect: DWORD, + dwMaximumSizeHigh: DWORD, + dwMaximumSizeLow: DWORD, + lpName: LPCWSTR) + -> HANDLE; + pub fn MapViewOfFile(hFileMappingObject: HANDLE, + dwDesiredAccess: DWORD, + dwFileOffsetHigh: DWORD, + dwFileOffsetLow: DWORD, + dwNumberOfBytesToMap: SIZE_T) + -> LPVOID; + pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; + pub fn MoveFileExW(lpExistingFileName: LPCWSTR, + lpNewFileName: LPCWSTR, + dwFlags: DWORD) -> BOOL; + pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR, + lpTargetFileName: LPCWSTR, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES) + -> BOOL; + pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; + pub fn CreateFileW(lpFileName: LPCWSTR, + dwDesiredAccess: DWORD, + dwShareMode: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES, + dwCreationDisposition: DWORD, + dwFlagsAndAttributes: DWORD, + hTemplateFile: HANDLE) -> HANDLE; + pub fn ReadFile(hFile: HANDLE, + lpBuffer: LPVOID, + nNumberOfBytesToRead: DWORD, + lpNumberOfBytesRead: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WriteFile(hFile: HANDLE, + lpBuffer: LPCVOID, + nNumberOfBytesToWrite: DWORD, + lpNumberOfBytesWritten: LPDWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn SetFilePointerEx(hFile: HANDLE, + liDistanceToMove: LARGE_INTEGER, + lpNewFilePointer: PLARGE_INTEGER, + dwMoveMethod: DWORD) -> BOOL; + pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; + + pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME); + + pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL; + pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER) + -> BOOL; + + pub fn GetCurrentProcessId() -> DWORD; + pub fn CreateNamedPipeW( + lpName: LPCWSTR, + dwOpenMode: DWORD, + dwPipeMode: DWORD, + nMaxInstances: DWORD, + nOutBufferSize: DWORD, + nInBufferSize: DWORD, + nDefaultTimeOut: DWORD, + lpSecurityAttributes: LPSECURITY_ATTRIBUTES + ) -> HANDLE; + pub fn ConnectNamedPipe(hNamedPipe: HANDLE, + lpOverlapped: LPOVERLAPPED) -> BOOL; + pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, + nTimeOut: DWORD) -> BOOL; + pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE, + lpMode: LPDWORD, + lpMaxCollectionCount: LPDWORD, + lpCollectDataTimeout: LPDWORD) + -> BOOL; + pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES, + bManualReset: BOOL, + bInitialState: BOOL, + lpName: LPCWSTR) -> HANDLE; + pub fn GetOverlappedResult(hFile: HANDLE, + lpOverlapped: LPOVERLAPPED, + lpNumberOfBytesTransferred: LPDWORD, + bWait: BOOL) -> BOOL; + pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; + + pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int; + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; + pub fn connect(socket: SOCKET, address: *const sockaddr, + len: c_int) -> c_int; + pub fn bind(socket: SOCKET, address: *const sockaddr, + address_len: c_int) -> c_int; + pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; + pub fn accept(socket: SOCKET, address: *mut sockaddr, + address_len: *mut c_int) -> SOCKET; + pub fn getpeername(socket: SOCKET, address: *mut sockaddr, + address_len: *mut c_int) -> c_int; + pub fn getsockname(socket: SOCKET, address: *mut sockaddr, + address_len: *mut c_int) -> c_int; + pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, + value: *const c_char, + option_len: c_int) -> c_int; + pub fn closesocket(socket: SOCKET) -> c_int; + pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int, + flags: c_int) -> c_int; + pub fn send(socket: SOCKET, buf: *const c_char, len: c_int, + flags: c_int) -> c_int; + pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut c_int) -> c_int; + pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int, + flags: c_int, addr: *const sockaddr, + addrlen: c_int) -> c_int; + pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; +} From 4185dde445ae1aa095097a29f9f1110b680f1b24 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 16:02:04 -0700 Subject: [PATCH 049/194] Get android compiling --- src/linuxlike/android.rs | 60 ++++++++++++++++++------------------ src/linuxlike/b32/android.rs | 36 +++++++++++----------- src/linuxlike/b32/mod.rs | 33 ++------------------ src/linuxlike/b32/other.rs | 30 ++++++++++++++++++ 4 files changed, 80 insertions(+), 79 deletions(-) create mode 100644 src/linuxlike/b32/other.rs diff --git a/src/linuxlike/android.rs b/src/linuxlike/android.rs index 825fd1febd540..54465078bd2b9 100644 --- a/src/linuxlike/android.rs +++ b/src/linuxlike/android.rs @@ -1,31 +1,31 @@ -pub const _SC_ARG_MAX: c_int = 0; -pub const _SC_BC_BASE_MAX: c_int = 1; -pub const _SC_BC_DIM_MAX: c_int = 2; -pub const _SC_BC_SCALE_MAX: c_int = 3; -pub const _SC_BC_STRING_MAX: c_int = 4; -pub const _SC_CHILD_MAX: c_int = 5; -pub const _SC_CLK_TCK: c_int = 6; -pub const _SC_COLL_WEIGHTS_MAX: c_int = 7; -pub const _SC_EXPR_NEST_MAX: c_int = 8; -pub const _SC_LINE_MAX: c_int = 9; -pub const _SC_NGROUPS_MAX: c_int = 10; -pub const _SC_OPEN_MAX: c_int = 11; -pub const _SC_2_C_BIND: c_int = 13; -pub const _SC_2_C_DEV: c_int = 14; -pub const _SC_2_C_VERSION: c_int = 15; -pub const _SC_2_CHAR_TERM: c_int = 16; -pub const _SC_2_FORT_DEV: c_int = 17; -pub const _SC_2_FORT_RUN: c_int = 18; -pub const _SC_2_LOCALEDEF: c_int = 19; -pub const _SC_2_SW_DEV: c_int = 20; -pub const _SC_2_UPE: c_int = 21; -pub const _SC_2_VERSION: c_int = 22; -pub const _SC_JOB_CONTROL: c_int = 23; -pub const _SC_SAVED_IDS: c_int = 24; -pub const _SC_VERSION: c_int = 25; -pub const _SC_RE_DUP_MAX: c_int = 26; -pub const _SC_STREAM_MAX: c_int = 27; -pub const _SC_TZNAME_MAX: c_int = 28; -pub const _SC_PAGESIZE: c_int = 39; +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_BC_BASE_MAX: ::c_int = 1; +pub const _SC_BC_DIM_MAX: ::c_int = 2; +pub const _SC_BC_SCALE_MAX: ::c_int = 3; +pub const _SC_BC_STRING_MAX: ::c_int = 4; +pub const _SC_CHILD_MAX: ::c_int = 5; +pub const _SC_CLK_TCK: ::c_int = 6; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7; +pub const _SC_EXPR_NEST_MAX: ::c_int = 8; +pub const _SC_LINE_MAX: ::c_int = 9; +pub const _SC_NGROUPS_MAX: ::c_int = 10; +pub const _SC_OPEN_MAX: ::c_int = 11; +pub const _SC_2_C_BIND: ::c_int = 13; +pub const _SC_2_C_DEV: ::c_int = 14; +pub const _SC_2_C_VERSION: ::c_int = 15; +pub const _SC_2_CHAR_TERM: ::c_int = 16; +pub const _SC_2_FORT_DEV: ::c_int = 17; +pub const _SC_2_FORT_RUN: ::c_int = 18; +pub const _SC_2_LOCALEDEF: ::c_int = 19; +pub const _SC_2_SW_DEV: ::c_int = 20; +pub const _SC_2_UPE: ::c_int = 21; +pub const _SC_2_VERSION: ::c_int = 22; +pub const _SC_JOB_CONTROL: ::c_int = 23; +pub const _SC_SAVED_IDS: ::c_int = 24; +pub const _SC_VERSION: ::c_int = 25; +pub const _SC_RE_DUP_MAX: ::c_int = 26; +pub const _SC_STREAM_MAX: ::c_int = 27; +pub const _SC_TZNAME_MAX: ::c_int = 28; +pub const _SC_PAGESIZE: ::c_int = 39; -pub const PTHREAD_STACK_MIN: size_t = 8192; +pub const PTHREAD_STACK_MIN: ::size_t = 8192; diff --git a/src/linuxlike/b32/android.rs b/src/linuxlike/b32/android.rs index 5ec3f7c92be59..44578cddbfbfa 100644 --- a/src/linuxlike/b32/android.rs +++ b/src/linuxlike/b32/android.rs @@ -6,24 +6,24 @@ pub type nlink_t = u16; s! { pub struct stat { - pub st_dev: c_ulonglong, - __pad0: [c_uchar; 4], - __st_ino: ino_t, - pub st_mode: c_uint, - pub st_nlink: c_uint, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: c_ulonglong, - __pad3: [c_uchar; 4], - pub st_size: c_longlong, + pub st_dev: ::c_ulonglong, + __pad0: [::c_uchar; 4], + __st_ino: ::ino_t, + pub st_mode: ::c_uint, + pub st_nlink: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulonglong, + __pad3: [::c_uchar; 4], + pub st_size: ::c_longlong, pub st_blksize: blksize_t, - pub st_blocks: c_ulonglong, - pub st_atime: time_t, - pub st_atime_nsec: c_ulong, - pub st_mtime: time_t, - pub st_mtime_nsec: c_ulong, - pub st_ctime: time_t, - pub st_ctime_nsec: c_ulong, - pub st_ino: c_ulonglong, + pub st_blocks: ::c_ulonglong, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_ulong, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_ulong, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_ulong, + pub st_ino: ::c_ulonglong, } } diff --git a/src/linuxlike/b32/mod.rs b/src/linuxlike/b32/mod.rs index d6c3e4a007f3b..e38c39b780c93 100644 --- a/src/linuxlike/b32/mod.rs +++ b/src/linuxlike/b32/mod.rs @@ -43,36 +43,7 @@ cfg_if! { mod mips; pub use self::mips::*; } else { - pub type dev_t = u64; - pub type mode_t = u32; - pub type nlink_t = u32; - pub type blksize_t = i32; - pub type blkcnt_t = i32; - - s! { - pub struct stat { - pub st_dev: dev_t, - __pad1: c_short, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - __pad2: c_short, - pub st_size: off_t, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - __unused4: c_long, - __unused5: c_long, - } - } + mod other; + pub use other::*; } } - diff --git a/src/linuxlike/b32/other.rs b/src/linuxlike/b32/other.rs new file mode 100644 index 0000000000000..8111d76c8cb7b --- /dev/null +++ b/src/linuxlike/b32/other.rs @@ -0,0 +1,30 @@ +pub type blkcnt_t = i32; +pub type blksize_t = i32; +pub type dev_t = u64; +pub type mode_t = u32; +pub type nlink_t = u32; + +s! { + pub struct stat { + pub st_dev: dev_t, + __pad1: c_short, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + __pad2: c_short, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + __unused4: c_long, + __unused5: c_long, + } +} From d3d77922eb24621dfb7809996af61e86ca9d9a25 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 17:03:39 -0700 Subject: [PATCH 050/194] Get android tests working --- libc-test/build.rs | 31 +- src/apple/b32.rs | 2 + src/apple/b64.rs | 2 + src/apple/mod.rs | 4 + src/lib.rs | 61 +--- src/linuxlike/android.rs | 38 +++ src/linuxlike/b32/android.rs | 11 + src/linuxlike/b32/mips.rs | 6 + src/linuxlike/b32/mod.rs | 8 +- src/linuxlike/b32/other.rs | 7 + src/linuxlike/b64/aarch64.rs | 2 + src/linuxlike/b64/mod.rs | 2 + src/linuxlike/b64/x86_64.rs | 2 + src/linuxlike/linux.rs | 116 +++++++ src/linuxlike/mips.rs | 592 ++++++++++++++++++----------------- src/linuxlike/mod.rs | 393 +++++++++++++++++------ src/linuxlike/notmips.rs | 319 ------------------- src/unix/android.rs | 25 ++ src/{unix.rs => unix/mod.rs} | 87 +---- src/unix/other.rs | 117 +++++++ src/windows.rs | 2 + 21 files changed, 989 insertions(+), 838 deletions(-) delete mode 100644 src/linuxlike/notmips.rs create mode 100644 src/unix/android.rs rename src/{unix.rs => unix/mod.rs} (76%) create mode 100644 src/unix/other.rs diff --git a/libc-test/build.rs b/libc-test/build.rs index ae8c21bc94231..8858320b154f9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -52,6 +52,11 @@ impl<'a> TestGenerator<'a> { ret.push("alignof __alignof"); } + // android also doesn't have stdalign.h so get alignof ourselves + if self.target.contains("android") { + ret.push("alignof __alignof__"); + } + // Pull in extra goodies on mingw if self.target.contains("windows") { ret.push("_WIN32_WINNT 0x8000"); @@ -81,7 +86,8 @@ impl<'a> TestGenerator<'a> { base.push("mach/mach_time.h"); } - if self.target.contains("unknown-linux") { + if self.target.contains("unknown-linux") || + self.target.contains("android") { base.push("linux/if_packet.h"); base.push("net/ethernet.h"); } @@ -103,8 +109,6 @@ impl<'a> TestGenerator<'a> { } else { base.push("ctype.h"); base.push("dirent.h"); - base.push("glob.h"); - base.push("ifaddrs.h"); base.push("net/if.h"); base.push("netdb.h"); base.push("netinet/in.h"); @@ -112,19 +116,26 @@ impl<'a> TestGenerator<'a> { base.push("netinet/tcp.h"); base.push("pthread.h"); base.push("signal.h"); - base.push("stdalign.h"); base.push("string.h"); base.push("sys/file.h"); base.push("sys/ioctl.h"); base.push("sys/mman.h"); base.push("sys/resource.h"); base.push("sys/socket.h"); - base.push("sys/sysctl.h"); base.push("sys/time.h"); base.push("sys/un.h"); base.push("sys/wait.h"); base.push("unistd.h"); base.push("utime.h"); + + if self.target.contains("android") { + base.push("arpa/inet.h"); + } else { + base.push("glob.h"); + base.push("ifaddrs.h"); + base.push("stdalign.h"); + base.push("sys/sysctl.h"); + } } return base @@ -179,6 +190,8 @@ impl<'a> TestGenerator<'a> { s if s.ends_with("_nsec") && struct_ == "stat" => { if self.target.contains("apple-darwin") { s.replace("_nsec", "spec.tv_nsec") + } else if self.target.contains("android") { + s.to_string() } else { s.replace("e_nsec", ".tv_nsec") } @@ -193,6 +206,8 @@ impl<'a> TestGenerator<'a> { ("x86_64", "64") } else if self.target.starts_with("i686") { ("x86", "32") + } else if self.target.starts_with("arm") { + ("arm", "32") } else { panic!("unknown arch/pointer width: {}", self.target) }; @@ -204,6 +219,8 @@ impl<'a> TestGenerator<'a> { ("windows", "windows", "msvc") } else if self.target.contains("windows-gnu") { ("windows", "windows", "gnu") + } else if self.target.contains("android") { + ("android", "unix", "") } else { panic!("unknown os/family width: {}", self.target) }; @@ -302,7 +319,11 @@ fn main() { impl<'a> TestGenerator<'a> { fn test_type(&mut self, ty: &str) { match ty { + // sighandler_t is crazy across platforms "sighandler_t" => return, + + // Not actually defined on android, but it's not hurting anyone + "in_port_t" if self.target.contains("android") => return, _ => {} } let c = self.rust_ty_to_c_ty(ty); diff --git a/src/apple/b32.rs b/src/apple/b32.rs index b4cc8cff43e9b..62caa5fdd5d09 100644 --- a/src/apple/b32.rs +++ b/src/apple/b32.rs @@ -1,3 +1,5 @@ +//! 32-bit specific Apple (ios/darwin) definitions + pub type c_long = i32; pub type c_ulong = u32; pub type size_t = u32; diff --git a/src/apple/b64.rs b/src/apple/b64.rs index ebdfb67571137..65e1b9fcb34ef 100644 --- a/src/apple/b64.rs +++ b/src/apple/b64.rs @@ -1,3 +1,5 @@ +//! 64-bit specific Apple (ios/darwin) definitions + pub type c_long = i64; pub type c_ulong = u64; pub type size_t = u64; diff --git a/src/apple/mod.rs b/src/apple/mod.rs index ed98e3e806e21..ba43d98866287 100644 --- a/src/apple/mod.rs +++ b/src/apple/mod.rs @@ -1,3 +1,7 @@ +//! Apple (ios/darwin)-specific definitions +//! +//! This covers *-apple-* triples currently + pub type c_char = i8; pub type c_schar = i8; pub type c_uchar = u8; diff --git a/src/lib.rs b/src/lib.rs index 910b9483b3cfc..8677ad911bc13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,52 +57,6 @@ cfg_if! { #[cfg(unix)] mod unix; #[cfg(unix)] pub use unix::*; -cfg_if! { - if #[cfg(any(target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd"))] { - extern { - pub fn sysctl(name: *mut c_int, - namelen: c_uint, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) - -> c_int; - pub fn sysctlbyname(name: *const c_char, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn sysctlnametomib(name: *const c_char, - mibp: *mut c_int, - sizep: *mut size_t) - -> c_int; - } - } else if #[cfg(unix)] { - extern { - pub fn sysctl(name: *mut c_int, - namelen: c_int, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) - -> c_int; - } - } else { - // ... - } -} - extern { pub fn isalnum(c: c_int) -> c_int; pub fn isalpha(c: c_int) -> c_int; @@ -164,9 +118,6 @@ extern { pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); - pub fn abs(i: c_int) -> c_int; - pub fn labs(i: c_long) -> c_long; - pub fn atof(s: *const c_char) -> c_double; pub fn atoi(s: *const c_char) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "strtod$UNIX2003")] @@ -186,8 +137,6 @@ extern { link_name = "system$UNIX2003")] pub fn system(s: *const c_char) -> c_int; pub fn getenv(s: *const c_char) -> *mut c_char; - pub fn rand() -> c_int; - pub fn srand(seed: c_uint); pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) @@ -214,3 +163,13 @@ extern { pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; } + +// These are all inline functions on android +#[cfg(not(target_os = "android"))] +extern { + pub fn abs(i: c_int) -> c_int; + pub fn atof(s: *const c_char) -> c_double; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); +} diff --git a/src/linuxlike/android.rs b/src/linuxlike/android.rs index 54465078bd2b9..e8b7caa3034f8 100644 --- a/src/linuxlike/android.rs +++ b/src/linuxlike/android.rs @@ -1,3 +1,12 @@ +//! Android-specific definitions for linux-like values + +pub const BUFSIZ: ::c_uint = 1024; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const L_tmpnam: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 308915776; +pub const _PC_NAME_MAX: ::c_int = 4; + pub const _SC_ARG_MAX: ::c_int = 0; pub const _SC_BC_BASE_MAX: ::c_int = 1; pub const _SC_BC_DIM_MAX: ::c_int = 2; @@ -26,6 +35,35 @@ pub const _SC_VERSION: ::c_int = 25; pub const _SC_RE_DUP_MAX: ::c_int = 26; pub const _SC_STREAM_MAX: ::c_int = 27; pub const _SC_TZNAME_MAX: ::c_int = 28; +pub const _SC_XOPEN_CRYPT: ::c_int = 29; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 30; +pub const _SC_XOPEN_SHM: ::c_int = 31; +pub const _SC_XOPEN_VERSION: ::c_int = 32; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33; +pub const _SC_XOPEN_REALTIME: ::c_int = 34; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35; +pub const _SC_XOPEN_LEGACY: ::c_int = 36; +pub const _SC_ATEXIT_MAX: ::c_int = 37; +pub const _SC_IOV_MAX: ::c_int = 38; pub const _SC_PAGESIZE: ::c_int = 39; +pub const _SC_XOPEN_UNIX: ::c_int = 41; +pub const _SC_MQ_PRIO_MAX: ::c_int = 51; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 75; +pub const _SC_THREAD_STACK_MIN: ::c_int = 76; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 77; +pub const _SC_TTY_NAME_MAX: ::c_int = 78; +pub const _SC_THREADS: ::c_int = 79; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; pub const PTHREAD_STACK_MIN: ::size_t = 8192; + +pub const O_SYNC: ::c_int = 0x1000; diff --git a/src/linuxlike/b32/android.rs b/src/linuxlike/b32/android.rs index 44578cddbfbfa..290b3a001abeb 100644 --- a/src/linuxlike/b32/android.rs +++ b/src/linuxlike/b32/android.rs @@ -1,3 +1,5 @@ +//! Android specific definitions for 32-bit linux-like values + pub type blkcnt_t = u32; pub type blksize_t = u32; pub type dev_t = u32; @@ -26,4 +28,13 @@ s! { pub st_ctime_nsec: ::c_ulong, pub st_ino: ::c_ulonglong, } + + pub struct pthread_attr_t { + pub flags: ::uint32_t, + pub stack_base: *mut ::c_void, + pub stack_size: ::size_t, + pub guard_size: ::size_t, + pub sched_policy: ::int32_t, + pub sched_priority: ::int32_t, + } } diff --git a/src/linuxlike/b32/mips.rs b/src/linuxlike/b32/mips.rs index cbf0825664cb0..3c76e54271b1e 100644 --- a/src/linuxlike/b32/mips.rs +++ b/src/linuxlike/b32/mips.rs @@ -1,3 +1,5 @@ +//! MIPS specific definitions for 32-bit linux-like values + pub type blkcnt_t = i32; pub type blksize_t = i32; pub type dev_t = u64; @@ -27,4 +29,8 @@ s! { pub st_blocks: blkcnt_t, pub st_pad5: [c_long; 14], } + + pub struct pthread_attr_t { + __size: [u32; 9] + } } diff --git a/src/linuxlike/b32/mod.rs b/src/linuxlike/b32/mod.rs index e38c39b780c93..74a4b0b31e9e3 100644 --- a/src/linuxlike/b32/mod.rs +++ b/src/linuxlike/b32/mod.rs @@ -1,3 +1,5 @@ +//! 32-bit specific definitions for linux-like values + pub type c_char = i8; pub type c_schar = i8; pub type c_uchar = u8; @@ -29,12 +31,6 @@ pub type gid_t = u32; pub type useconds_t = u32; pub type ssize_t = i32; -s! { - pub struct pthread_attr_t { - __size: [u32; 9] - } -} - cfg_if! { if #[cfg(target_os = "android")] { mod android; diff --git a/src/linuxlike/b32/other.rs b/src/linuxlike/b32/other.rs index 8111d76c8cb7b..d598578cfb31c 100644 --- a/src/linuxlike/b32/other.rs +++ b/src/linuxlike/b32/other.rs @@ -1,3 +1,6 @@ +//! 32-bit specific definitions for linux-like values on platforms that aren't +//! MIPS or android + pub type blkcnt_t = i32; pub type blksize_t = i32; pub type dev_t = u64; @@ -27,4 +30,8 @@ s! { __unused4: c_long, __unused5: c_long, } + + pub struct pthread_attr_t { + __size: [u32; 9] + } } diff --git a/src/linuxlike/b64/aarch64.rs b/src/linuxlike/b64/aarch64.rs index d395cb2e50f8b..a22cd88bd3284 100644 --- a/src/linuxlike/b64/aarch64.rs +++ b/src/linuxlike/b64/aarch64.rs @@ -1,3 +1,5 @@ +//! AArch64-specific definitions for 64-bit linux-like values + pub type nlink_t = u32; pub type blksize_t = i32; pub type c_char = u8; diff --git a/src/linuxlike/b64/mod.rs b/src/linuxlike/b64/mod.rs index 1fb7cfdfe1068..3e6233fca4aba 100644 --- a/src/linuxlike/b64/mod.rs +++ b/src/linuxlike/b64/mod.rs @@ -1,3 +1,5 @@ +//! 64-bit specific definitions for linux-like values + pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/src/linuxlike/b64/x86_64.rs b/src/linuxlike/b64/x86_64.rs index 1d5a988d36a8f..da85b5265efc2 100644 --- a/src/linuxlike/b64/x86_64.rs +++ b/src/linuxlike/b64/x86_64.rs @@ -1,3 +1,5 @@ +//! x86_64-specific definitions for 64-bit linux-like values + pub type nlink_t = u64; pub type blksize_t = i64; pub type c_char = i8; diff --git a/src/linuxlike/linux.rs b/src/linuxlike/linux.rs index 4bf33c3a76f67..bbd724c481aad 100644 --- a/src/linuxlike/linux.rs +++ b/src/linuxlike/linux.rs @@ -1,3 +1,12 @@ +//! Linux-specific definitions for linux-like values + +pub const BUFSIZ: c_uint = 8192; +pub const FILENAME_MAX: c_uint = 4096; +pub const FOPEN_MAX: c_uint = 16; +pub const L_tmpnam: c_uint = 20; +pub const TMP_MAX: c_uint = 238328; +pub const _PC_NAME_MAX: c_int = 3; + pub const _SC_ARG_MAX: ::c_int = 0; pub const _SC_CHILD_MAX: ::c_int = 1; pub const _SC_CLK_TCK: ::c_int = 2; @@ -26,6 +35,7 @@ pub const _SC_AIO_MAX: ::c_int = 24; pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; pub const _SC_DELAYTIMER_MAX: ::c_int = 26; pub const _SC_MQ_OPEN_MAX: ::c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; pub const _SC_VERSION: ::c_int = 29; pub const _SC_PAGESIZE: ::c_int = 30; pub const _SC_RTSIG_MAX: ::c_int = 31; @@ -48,13 +58,119 @@ pub const _SC_2_FORT_DEV: ::c_int = 49; pub const _SC_2_FORT_RUN: ::c_int = 50; pub const _SC_2_SW_DEV: ::c_int = 51; pub const _SC_2_LOCALEDEF: ::c_int = 52; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; pub const _SC_2_CHAR_TERM: ::c_int = 95; pub const _SC_2_C_VERSION: ::c_int = 96; pub const _SC_2_UPE: ::c_int = 97; pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; + +s! { + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_ifu: *mut sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } +} + +pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; +pub const RUSAGE_THREAD: c_int = 1; + +pub const GLOB_ERR: ::c_int = 1 << 0; +pub const GLOB_MARK: ::c_int = 1 << 1; +pub const GLOB_NOSORT: ::c_int = 1 << 2; +pub const GLOB_DOOFFS: ::c_int = 1 << 3; +pub const GLOB_NOCHECK: ::c_int = 1 << 4; +pub const GLOB_APPEND: ::c_int = 1 << 5; +pub const GLOB_NOESCAPE: ::c_int = 1 << 6; + +pub const GLOB_NOSPACE: ::c_int = 1; +pub const GLOB_ABORTED: ::c_int = 2; +pub const GLOB_NOMATCH: ::c_int = 3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const S_IEXEC: ::mode_t = 64; +pub const S_IWRITE: ::mode_t = 128; +pub const S_IREAD: ::mode_t = 256; + +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; + +pub const ERFKILL: ::c_int = 132; +pub const EHWPOISON: ::c_int = 133; + +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; + +pub const MAP_32BIT: ::c_int = 0x0040; + +pub const TCP_MD5SIG: ::c_int = 14; +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; + +pub const SO_REUSEPORT: ::c_int = 15; cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "x86", diff --git a/src/linuxlike/mips.rs b/src/linuxlike/mips.rs index 748bd5a5948c5..d58481ad15ccc 100644 --- a/src/linuxlike/mips.rs +++ b/src/linuxlike/mips.rs @@ -1,314 +1,316 @@ -pub const O_RDONLY: c_int = 0; -pub const O_WRONLY: c_int = 1; -pub const O_RDWR: c_int = 2; -pub const O_APPEND: c_int = 8; -pub const O_CREAT: c_int = 256; -pub const O_EXCL: c_int = 1024; -pub const O_NOCTTY: c_int = 2048; -pub const O_TRUNC: c_int = 512; -pub const S_IFIFO: mode_t = 4096; -pub const S_IFCHR: mode_t = 8192; -pub const S_IFBLK: mode_t = 24576; -pub const S_IFDIR: mode_t = 16384; -pub const S_IFREG: mode_t = 32768; -pub const S_IFLNK: mode_t = 40960; -pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 61440; -pub const S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; -pub const S_IRWXU: mode_t = 448; -pub const S_IXUSR: mode_t = 64; -pub const S_IWUSR: mode_t = 128; -pub const S_IRUSR: mode_t = 256; -pub const S_IRWXG: mode_t = 56; -pub const S_IXGRP: mode_t = 8; -pub const S_IWGRP: mode_t = 16; -pub const S_IRGRP: mode_t = 32; -pub const S_IRWXO: mode_t = 7; -pub const S_IXOTH: mode_t = 1; -pub const S_IWOTH: mode_t = 2; -pub const S_IROTH: mode_t = 4; -pub const F_OK: c_int = 0; -pub const R_OK: c_int = 4; -pub const W_OK: c_int = 2; -pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; -pub const F_LOCK: c_int = 1; -pub const F_TEST: c_int = 3; -pub const F_TLOCK: c_int = 2; -pub const F_ULOCK: c_int = 0; -pub const SIGHUP: c_int = 1; -pub const SIGINT: c_int = 2; -pub const SIGQUIT: c_int = 3; -pub const SIGILL: c_int = 4; -pub const SIGABRT: c_int = 6; -pub const SIGFPE: c_int = 8; -pub const SIGKILL: c_int = 9; -pub const SIGSEGV: c_int = 11; -pub const SIGPIPE: c_int = 13; -pub const SIGALRM: c_int = 14; -pub const SIGTERM: c_int = 15; +//! MIPS-specific definitions for linux-like values -pub const PROT_NONE: c_int = 0; -pub const PROT_READ: c_int = 1; -pub const PROT_WRITE: c_int = 2; -pub const PROT_EXEC: c_int = 4; +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_NOCTTY: ::c_int = 2048; +pub const O_TRUNC: ::c_int = 512; +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IEXEC: ::mode_t = 64; +pub const S_IWRITE: ::mode_t = 128; +pub const S_IREAD: ::mode_t = 256; +pub const S_IRWXU: ::mode_t = 448; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IRWXG: ::mode_t = 56; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IRWXO: ::mode_t = 7; +pub const S_IXOTH: ::mode_t = 1; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IROTH: ::mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; -pub const MAP_FILE: c_int = 0x0000; -pub const MAP_SHARED: c_int = 0x0001; -pub const MAP_PRIVATE: c_int = 0x0002; -pub const MAP_FIXED: c_int = 0x0010; -pub const MAP_ANON: c_int = 0x0800; +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x0800; pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; -pub const MCL_CURRENT: c_int = 0x0001; -pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; -pub const MS_ASYNC: c_int = 0x0001; -pub const MS_INVALIDATE: c_int = 0x0002; -pub const MS_SYNC: c_int = 0x0004; +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0004; -pub const EPERM: c_int = 1; -pub const ENOENT: c_int = 2; -pub const ESRCH: c_int = 3; -pub const EINTR: c_int = 4; -pub const EIO: c_int = 5; -pub const ENXIO: c_int = 6; -pub const E2BIG: c_int = 7; -pub const ENOEXEC: c_int = 8; -pub const EBADF: c_int = 9; -pub const ECHILD: c_int = 10; -pub const EAGAIN: c_int = 11; -pub const ENOMEM: c_int = 12; -pub const EACCES: c_int = 13; -pub const EFAULT: c_int = 14; -pub const ENOTBLK: c_int = 15; -pub const EBUSY: c_int = 16; -pub const EEXIST: c_int = 17; -pub const EXDEV: c_int = 18; -pub const ENODEV: c_int = 19; -pub const ENOTDIR: c_int = 20; -pub const EISDIR: c_int = 21; -pub const EINVAL: c_int = 22; -pub const ENFILE: c_int = 23; -pub const EMFILE: c_int = 24; -pub const ENOTTY: c_int = 25; -pub const ETXTBSY: c_int = 26; -pub const EFBIG: c_int = 27; -pub const ENOSPC: c_int = 28; -pub const ESPIPE: c_int = 29; -pub const EROFS: c_int = 30; -pub const EMLINK: c_int = 31; -pub const EPIPE: c_int = 32; -pub const EDOM: c_int = 33; -pub const ERANGE: c_int = 34; +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; -pub const ENOMSG: c_int = 35; -pub const EIDRM: c_int = 36; -pub const ECHRNG: c_int = 37; -pub const EL2NSYNC: c_int = 38; -pub const EL3HLT: c_int = 39; -pub const EL3RST: c_int = 40; -pub const ELNRNG: c_int = 41; -pub const EUNATCH: c_int = 42; -pub const ENOCSI: c_int = 43; -pub const EL2HLT: c_int = 44; -pub const EDEADLK: c_int = 45; -pub const ENOLCK: c_int = 46; -pub const EBADE: c_int = 50; -pub const EBADR: c_int = 51; -pub const EXFULL: c_int = 52; -pub const ENOANO: c_int = 53; -pub const EBADRQC: c_int = 54; -pub const EBADSLT: c_int = 55; -pub const EDEADLOCK: c_int = 56; -pub const EBFONT: c_int = 59; -pub const ENOSTR: c_int = 60; -pub const ENODATA: c_int = 61; -pub const ETIME: c_int = 62; -pub const ENOSR: c_int = 63; -pub const ENONET: c_int = 64; -pub const ENOPKG: c_int = 65; -pub const EREMOTE: c_int = 66; -pub const ENOLINK: c_int = 67; -pub const EADV: c_int = 68; -pub const ESRMNT: c_int = 69; -pub const ECOMM: c_int = 70; -pub const EPROTO: c_int = 71; -pub const EDOTDOT: c_int = 73; -pub const EMULTIHOP: c_int = 74; -pub const EBADMSG: c_int = 77; -pub const ENAMETOOLONG: c_int = 78; -pub const EOVERFLOW: c_int = 79; -pub const ENOTUNIQ: c_int = 80; -pub const EBADFD: c_int = 81; -pub const EREMCHG: c_int = 82; -pub const ELIBACC: c_int = 83; -pub const ELIBBAD: c_int = 84; -pub const ELIBSCN: c_int = 95; -pub const ELIBMAX: c_int = 86; -pub const ELIBEXEC: c_int = 87; -pub const EILSEQ: c_int = 88; -pub const ENOSYS: c_int = 89; -pub const ELOOP: c_int = 90; -pub const ERESTART: c_int = 91; -pub const ESTRPIPE: c_int = 92; -pub const ENOTEMPTY: c_int = 93; -pub const EUSERS: c_int = 94; -pub const ENOTSOCK: c_int = 95; -pub const EDESTADDRREQ: c_int = 96; -pub const EMSGSIZE: c_int = 97; -pub const EPROTOTYPE: c_int = 98; -pub const ENOPROTOOPT: c_int = 99; -pub const EPROTONOSUPPORT: c_int = 120; -pub const ESOCKTNOSUPPORT: c_int = 121; -pub const EOPNOTSUPP: c_int = 122; -pub const EPFNOSUPPORT: c_int = 123; -pub const EAFNOSUPPORT: c_int = 124; -pub const EADDRINUSE: c_int = 125; -pub const EADDRNOTAVAIL: c_int = 126; -pub const ENETDOWN: c_int = 127; -pub const ENETUNREACH: c_int = 128; -pub const ENETRESET: c_int = 129; -pub const ECONNABORTED: c_int = 130; -pub const ECONNRESET: c_int = 131; -pub const ENOBUFS: c_int = 132; -pub const EISCONN: c_int = 133; -pub const ENOTCONN: c_int = 134; -pub const EUCLEAN: c_int = 135; -pub const ENOTNAM: c_int = 137; -pub const ENAVAIL: c_int = 138; -pub const EISNAM: c_int = 139; -pub const EREMOTEIO: c_int = 140; -pub const ESHUTDOWN: c_int = 143; -pub const ETOOMANYREFS: c_int = 144; -pub const ETIMEDOUT: c_int = 145; -pub const ECONNREFUSED: c_int = 146; -pub const EHOSTDOWN: c_int = 147; -pub const EHOSTUNREACH: c_int = 148; -pub const EWOULDBLOCK: c_int = EAGAIN; -pub const EALREADY: c_int = 149; -pub const EINPROGRESS: c_int = 150; -pub const ESTALE: c_int = 151; -pub const ECANCELED: c_int = 158; -pub const ENOMEDIUM: c_int = 159; -pub const EMEDIUMTYPE: c_int = 160; -pub const ENOKEY: c_int = 161; -pub const EKEYEXPIRED: c_int = 162; -pub const EKEYREVOKED: c_int = 163; -pub const EKEYREJECTED: c_int = 164; -pub const EOWNERDEAD: c_int = 165; -pub const ENOTRECOVERABLE: c_int = 166; -pub const ERFKILL: c_int = 167; -pub const EHWPOISON: c_int = 168; -pub const EDQUOT: c_int = 1133; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EDEADLK: ::c_int = 45; +pub const ENOLCK: ::c_int = 46; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; +pub const EMULTIHOP: ::c_int = 74; +pub const EBADMSG: ::c_int = 77; +pub const ENAMETOOLONG: ::c_int = 78; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 95; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ENOSYS: ::c_int = 89; +pub const ELOOP: ::c_int = 90; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const ENOTEMPTY: ::c_int = 93; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const EUCLEAN: ::c_int = 135; +pub const ENOTNAM: ::c_int = 137; +pub const ENAVAIL: ::c_int = 138; +pub const EISNAM: ::c_int = 139; +pub const EREMOTEIO: ::c_int = 140; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EWOULDBLOCK: ::c_int = EAGAIN; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; +pub const ECANCELED: ::c_int = 158; +pub const ENOMEDIUM: ::c_int = 159; +pub const EMEDIUMTYPE: ::c_int = 160; +pub const ENOKEY: ::c_int = 161; +pub const EKEYEXPIRED: ::c_int = 162; +pub const EKEYREVOKED: ::c_int = 163; +pub const EKEYREJECTED: ::c_int = 164; +pub const EOWNERDEAD: ::c_int = 165; +pub const ENOTRECOVERABLE: ::c_int = 166; +pub const ERFKILL: ::c_int = 167; +pub const EHWPOISON: ::c_int = 168; +pub const EDQUOT: ::c_int = 1133; -pub const AF_PACKET: c_int = 17; -pub const IPPROTO_RAW: c_int = 255; +pub const AF_PACKET: ::c_int = 17; +pub const IPPROTO_RAW: ::c_int = 255; -pub const O_RSYNC: c_int = 16400; -pub const O_DSYNC: c_int = 16; -pub const O_NONBLOCK: c_int = 128; -pub const O_SYNC: c_int = 16400; +pub const O_RSYNC: ::c_int = 16400; +pub const O_DSYNC: ::c_int = 16; +pub const O_NONBLOCK: ::c_int = 128; +pub const O_SYNC: ::c_int = 16400; -pub const PROT_GROWSDOWN: c_int = 0x01000000; -pub const PROT_GROWSUP: c_int = 0x02000000; +pub const PROT_GROWSDOWN: ::c_int = 0x01000000; +pub const PROT_GROWSUP: ::c_int = 0x02000000; -pub const MAP_TYPE: c_int = 0x000f; -pub const MAP_ANONYMOUS: c_int = 0x0800; -pub const MAP_GROWSDOWN: c_int = 0x01000; -pub const MAP_DENYWRITE: c_int = 0x02000; -pub const MAP_EXECUTABLE: c_int = 0x04000; -pub const MAP_LOCKED: c_int = 0x08000; -pub const MAP_NORESERVE: c_int = 0x0400; -pub const MAP_POPULATE: c_int = 0x010000; -pub const MAP_NONBLOCK: c_int = 0x020000; -pub const MAP_STACK: c_int = 0x040000; +pub const MAP_TYPE: ::c_int = 0x000f; +pub const MAP_ANONYMOUS: ::c_int = 0x0800; +pub const MAP_GROWSDOWN: ::c_int = 0x01000; +pub const MAP_DENYWRITE: ::c_int = 0x02000; +pub const MAP_EXECUTABLE: ::c_int = 0x04000; +pub const MAP_LOCKED: ::c_int = 0x08000; +pub const MAP_NORESERVE: ::c_int = 0x0400; +pub const MAP_POPULATE: ::c_int = 0x010000; +pub const MAP_NONBLOCK: ::c_int = 0x020000; +pub const MAP_STACK: ::c_int = 0x040000; -pub const MADV_NORMAL: c_int = 0; -pub const MADV_RANDOM: c_int = 1; -pub const MADV_SEQUENTIAL: c_int = 2; -pub const MADV_WILLNEED: c_int = 3; -pub const MADV_DONTNEED: c_int = 4; -pub const MADV_REMOVE: c_int = 9; -pub const MADV_DONTFORK: c_int = 10; -pub const MADV_DOFORK: c_int = 11; -pub const MADV_MERGEABLE: c_int = 12; -pub const MADV_UNMERGEABLE: c_int = 13; -pub const MADV_HWPOISON: c_int = 100; +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_REMOVE: ::c_int = 9; +pub const MADV_DONTFORK: ::c_int = 10; +pub const MADV_DOFORK: ::c_int = 11; +pub const MADV_MERGEABLE: ::c_int = 12; +pub const MADV_UNMERGEABLE: ::c_int = 13; +pub const MADV_HWPOISON: ::c_int = 100; -pub const AF_UNIX: c_int = 1; -pub const AF_INET: c_int = 2; -pub const AF_INET6: c_int = 10; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; -pub const SOCK_RAW: c_int = 3; -pub const IPPROTO_TCP: c_int = 6; -pub const IPPROTO_IP: c_int = 0; -pub const IPPROTO_IPV6: c_int = 41; -pub const IP_MULTICAST_TTL: c_int = 33; -pub const IP_MULTICAST_LOOP: c_int = 34; -pub const IP_TTL: c_int = 2; -pub const IP_HDRINCL: c_int = 3; -pub const IP_ADD_MEMBERSHIP: c_int = 35; -pub const IP_DROP_MEMBERSHIP: c_int = 36; -pub const IPV6_ADD_MEMBERSHIP: c_int = 20; -pub const IPV6_DROP_MEMBERSHIP: c_int = 21; +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 10; +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_DGRAM: ::c_int = 1; +pub const SOCK_RAW: ::c_int = 3; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_TTL: ::c_int = 2; +pub const IP_HDRINCL: ::c_int = 3; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; -pub const TCP_NODELAY: c_int = 1; -pub const TCP_MAXSEG: c_int = 2; -pub const TCP_CORK: c_int = 3; -pub const TCP_KEEPIDLE: c_int = 4; -pub const TCP_KEEPINTVL: c_int = 5; -pub const TCP_KEEPCNT: c_int = 6; -pub const TCP_SYNCNT: c_int = 7; -pub const TCP_LINGER2: c_int = 8; -pub const TCP_DEFER_ACCEPT: c_int = 9; -pub const TCP_WINDOW_CLAMP: c_int = 10; -pub const TCP_INFO: c_int = 11; -pub const TCP_QUICKACK: c_int = 12; -pub const TCP_CONGESTION: c_int = 13; -pub const TCP_MD5SIG: c_int = 14; -pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; -pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; -pub const TCP_THIN_DUPACK: c_int = 17; -pub const TCP_USER_TIMEOUT: c_int = 18; -pub const TCP_REPAIR: c_int = 19; -pub const TCP_REPAIR_QUEUE: c_int = 20; -pub const TCP_QUEUE_SEQ: c_int = 21; -pub const TCP_REPAIR_OPTIONS: c_int = 22; -pub const TCP_FASTOPEN: c_int = 23; -pub const TCP_TIMESTAMP: c_int = 24; +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; +pub const TCP_CORK: ::c_int = 3; +pub const TCP_KEEPIDLE: ::c_int = 4; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_SYNCNT: ::c_int = 7; +pub const TCP_LINGER2: ::c_int = 8; +pub const TCP_DEFER_ACCEPT: ::c_int = 9; +pub const TCP_WINDOW_CLAMP: ::c_int = 10; +pub const TCP_INFO: ::c_int = 11; +pub const TCP_QUICKACK: ::c_int = 12; +pub const TCP_CONGESTION: ::c_int = 13; +pub const TCP_MD5SIG: ::c_int = 14; +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; -pub const SOL_SOCKET: c_int = 65535; +pub const SOL_SOCKET: ::c_int = 65535; -pub const SO_DEBUG: c_int = 0x0001; -pub const SO_REUSEADDR: c_int = 0x0004; -pub const SO_KEEPALIVE: c_int = 0x0008; -pub const SO_DONTROUTE: c_int = 0x0010; -pub const SO_BROADCAST: c_int = 0x0020; -pub const SO_LINGER: c_int = 0x0080; -pub const SO_OOBINLINE: c_int = 0x100; -pub const SO_REUSEPORT: c_int = 0x0200; -pub const SO_SNDBUF: c_int = 0x1001; -pub const SO_RCVBUF: c_int = 0x1002; -pub const SO_SNDLOWAT: c_int = 0x1003; -pub const SO_RCVLOWAT: c_int = 0x1004; -pub const SO_SNDTIMEO: c_int = 0x1005; -pub const SO_RCVTIMEO: c_int = 0x1006; -pub const SO_ERROR: c_int = 0x1007; -pub const SO_TYPE: c_int = 0x1008; -pub const SO_ACCEPTCONN: c_int = 0x1009; +pub const SO_DEBUG: ::c_int = 0x0001; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_ACCEPTCONN: ::c_int = 0x1009; -pub const SHUT_RD: c_int = 0; -pub const SHUT_WR: c_int = 1; -pub const SHUT_RDWR: c_int = 2; +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; -pub const LOCK_SH: c_int = 1; -pub const LOCK_EX: c_int = 2; -pub const LOCK_NB: c_int = 4; -pub const LOCK_UN: c_int = 8; +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; diff --git a/src/linuxlike/mod.rs b/src/linuxlike/mod.rs index 10a485401d8ec..47b1bf93adc8c 100644 --- a/src/linuxlike/mod.rs +++ b/src/linuxlike/mod.rs @@ -1,3 +1,7 @@ +//! Linux-like values +//! +//! Currenly applies to the Linux and Android platforms + pub type in_addr_t = u32; pub type in_port_t = u16; pub type pthread_t = c_ulong; @@ -9,19 +13,6 @@ pub type socklen_t = u32; pub enum timezone {} s! { - pub struct glob_t { - pub gl_pathc: size_t, - pub gl_pathv: *mut *mut c_char, - pub gl_offs: size_t, - pub gl_flags: c_int, - - __unused1: *mut ::c_void, - __unused2: *mut ::c_void, - __unused3: *mut ::c_void, - __unused4: *mut ::c_void, - __unused5: *mut ::c_void, - } - pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, @@ -99,16 +90,6 @@ s! { pub sun_path: [c_char; 108] } - pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_ifu: *mut sockaddr, // FIXME This should be a union - pub ifa_data: *mut ::c_void - } - pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, @@ -159,12 +140,6 @@ pub const SEEK_END: c_int = 2; pub const _IOFBF: c_int = 0; pub const _IONBF: c_int = 2; pub const _IOLBF: c_int = 1; -pub const BUFSIZ: c_uint = 8192; -pub const FOPEN_MAX: c_uint = 16; -pub const FILENAME_MAX: c_uint = 4096; -pub const L_tmpnam: c_uint = 20; -pub const TMP_MAX: c_uint = 238328; -pub const _PC_NAME_MAX: c_int = 3; pub const F_DUPFD: c_int = 0; pub const F_GETFD: c_int = 1; @@ -177,53 +152,6 @@ pub const O_ACCMODE: c_int = 3; pub const SIGTRAP: c_int = 5; pub const SIG_IGN: size_t = 1; -pub const GLOB_ERR : c_int = 1 << 0; -pub const GLOB_MARK : c_int = 1 << 1; -pub const GLOB_NOSORT : c_int = 1 << 2; -pub const GLOB_DOOFFS : c_int = 1 << 3; -pub const GLOB_NOCHECK : c_int = 1 << 4; -pub const GLOB_APPEND : c_int = 1 << 5; -pub const GLOB_NOESCAPE: c_int = 1 << 6; - -pub const GLOB_NOSPACE : c_int = 1; -pub const GLOB_ABORTED : c_int = 2; -pub const GLOB_NOMATCH : c_int = 3; - -pub const POSIX_MADV_NORMAL: c_int = 0; -pub const POSIX_MADV_RANDOM: c_int = 1; -pub const POSIX_MADV_SEQUENTIAL: c_int = 2; -pub const POSIX_MADV_WILLNEED: c_int = 3; -pub const POSIX_MADV_DONTNEED: c_int = 4; - -pub const _SC_MQ_PRIO_MAX: c_int = 28; -pub const _SC_IOV_MAX: c_int = 60; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; -pub const _SC_LOGIN_NAME_MAX: c_int = 71; -pub const _SC_TTY_NAME_MAX: c_int = 72; -pub const _SC_THREADS: c_int = 67; -pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; -pub const _SC_THREAD_KEYS_MAX: c_int = 74; -pub const _SC_THREAD_STACK_MIN: c_int = 75; -pub const _SC_THREAD_THREADS_MAX: c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; -pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; -pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; -pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; -pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; -pub const _SC_ATEXIT_MAX: c_int = 87; -pub const _SC_XOPEN_VERSION: c_int = 89; -pub const _SC_XOPEN_XCU_VERSION: c_int = 90; -pub const _SC_XOPEN_UNIX: c_int = 91; -pub const _SC_XOPEN_CRYPT: c_int = 92; -pub const _SC_XOPEN_ENH_I18N: c_int = 93; -pub const _SC_XOPEN_SHM: c_int = 94; -pub const _SC_XOPEN_LEGACY: c_int = 129; -pub const _SC_XOPEN_REALTIME: c_int = 130; -pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; - pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 1; @@ -246,14 +174,309 @@ pub const RLIMIT_MSGQUEUE: c_int = 12; pub const RLIMIT_NICE: c_int = 13; pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; -pub const RLIMIT_NLIMITS: c_int = 16; pub const RLIM_INFINITY: rlim_t = !0; -pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; -pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; pub const RUSAGE_SELF: c_int = 0; pub const RUSAGE_CHILDREN: c_int = -1; -pub const RUSAGE_THREAD: c_int = 1; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_TRUNC: ::c_int = 512; +pub const S_IFIFO: ::mode_t = 4096; +pub const S_IFCHR: ::mode_t = 8192; +pub const S_IFBLK: ::mode_t = 24576; +pub const S_IFDIR: ::mode_t = 16384; +pub const S_IFREG: ::mode_t = 32768; +pub const S_IFLNK: ::mode_t = 40960; +pub const S_IFSOCK: ::mode_t = 49152; +pub const S_IFMT: ::mode_t = 61440; +pub const S_IRWXU: ::mode_t = 448; +pub const S_IXUSR: ::mode_t = 64; +pub const S_IWUSR: ::mode_t = 128; +pub const S_IRUSR: ::mode_t = 256; +pub const S_IRWXG: ::mode_t = 56; +pub const S_IXGRP: ::mode_t = 8; +pub const S_IWGRP: ::mode_t = 16; +pub const S_IRGRP: ::mode_t = 32; +pub const S_IRWXO: ::mode_t = 7; +pub const S_IXOTH: ::mode_t = 1; +pub const S_IWOTH: ::mode_t = 2; +pub const S_IROTH: ::mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x0020; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0004; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EAGAIN: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const EWOULDBLOCK: ::c_int = EAGAIN; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; + +pub const EDEADLOCK: ::c_int = EDEADLK; + +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EMULTIHOP: ::c_int = 72; +pub const EDOTDOT: ::c_int = 73; +pub const EBADMSG: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; + +pub const AF_PACKET: ::c_int = 17; +pub const IPPROTO_RAW: ::c_int = 255; + +pub const O_NONBLOCK: ::c_int = 2048; + +pub const PROT_GROWSDOWN: ::c_int = 0x1000000; +pub const PROT_GROWSUP: ::c_int = 0x2000000; + +pub const MAP_TYPE: ::c_int = 0x000f; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_REMOVE: ::c_int = 9; +pub const MADV_DONTFORK: ::c_int = 10; +pub const MADV_DOFORK: ::c_int = 11; +pub const MADV_MERGEABLE: ::c_int = 12; +pub const MADV_UNMERGEABLE: ::c_int = 13; +pub const MADV_HWPOISON: ::c_int = 100; + +pub const IFF_LOOPBACK: ::c_int = 0x8; + +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 10; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; +pub const IP_MULTICAST_TTL: ::c_int = 33; +pub const IP_MULTICAST_LOOP: ::c_int = 34; +pub const IP_TTL: ::c_int = 2; +pub const IP_HDRINCL: ::c_int = 3; +pub const IP_ADD_MEMBERSHIP: ::c_int = 35; +pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_MAXSEG: ::c_int = 2; +pub const TCP_CORK: ::c_int = 3; +pub const TCP_KEEPIDLE: ::c_int = 4; +pub const TCP_KEEPINTVL: ::c_int = 5; +pub const TCP_KEEPCNT: ::c_int = 6; +pub const TCP_SYNCNT: ::c_int = 7; +pub const TCP_LINGER2: ::c_int = 8; +pub const TCP_DEFER_ACCEPT: ::c_int = 9; +pub const TCP_WINDOW_CLAMP: ::c_int = 10; +pub const TCP_INFO: ::c_int = 11; +pub const TCP_QUICKACK: ::c_int = 12; +pub const TCP_CONGESTION: ::c_int = 13; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const SO_DEBUG: ::c_int = 1; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_LINGER: ::c_int = 13; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +extern { + pub fn fdatasync(fd: ::c_int) -> ::c_int; +} cfg_if! { if #[cfg(target_pointer_width = "32")] { @@ -265,16 +488,6 @@ cfg_if! { } } -cfg_if! { - if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { - mod mips; - pub use self::mips::*; - } else { - mod notmips; - pub use self::notmips::*; - } -} - cfg_if! { if #[cfg(target_os = "linux")] { mod linux; diff --git a/src/linuxlike/notmips.rs b/src/linuxlike/notmips.rs deleted file mode 100644 index 5da166d6c5e86..0000000000000 --- a/src/linuxlike/notmips.rs +++ /dev/null @@ -1,319 +0,0 @@ -pub const O_RDONLY: ::c_int = 0; -pub const O_WRONLY: ::c_int = 1; -pub const O_RDWR: ::c_int = 2; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; -pub const O_TRUNC: ::c_int = 512; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IEXEC: ::mode_t = 64; -pub const S_IWRITE: ::mode_t = 128; -pub const S_IREAD: ::mode_t = 256; -pub const S_IRWXU: ::mode_t = 448; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IRWXG: ::mode_t = 56; -pub const S_IXGRP: ::mode_t = 8; -pub const S_IWGRP: ::mode_t = 16; -pub const S_IRGRP: ::mode_t = 32; -pub const S_IRWXO: ::mode_t = 7; -pub const S_IXOTH: ::mode_t = 1; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IROTH: ::mode_t = 4; -pub const F_OK: ::c_int = 0; -pub const R_OK: ::c_int = 4; -pub const W_OK: ::c_int = 2; -pub const X_OK: ::c_int = 1; -pub const STDIN_FILENO: ::c_int = 0; -pub const STDOUT_FILENO: ::c_int = 1; -pub const STDERR_FILENO: ::c_int = 2; -pub const F_LOCK: ::c_int = 1; -pub const F_TEST: ::c_int = 3; -pub const F_TLOCK: ::c_int = 2; -pub const F_ULOCK: ::c_int = 0; -pub const SIGHUP: ::c_int = 1; -pub const SIGINT: ::c_int = 2; -pub const SIGQUIT: ::c_int = 3; -pub const SIGILL: ::c_int = 4; -pub const SIGABRT: ::c_int = 6; -pub const SIGFPE: ::c_int = 8; -pub const SIGKILL: ::c_int = 9; -pub const SIGSEGV: ::c_int = 11; -pub const SIGPIPE: ::c_int = 13; -pub const SIGALRM: ::c_int = 14; -pub const SIGTERM: ::c_int = 15; - -pub const PROT_NONE: ::c_int = 0; -pub const PROT_READ: ::c_int = 1; -pub const PROT_WRITE: ::c_int = 2; -pub const PROT_EXEC: ::c_int = 4; - -pub const MAP_FILE: ::c_int = 0x0000; -pub const MAP_SHARED: ::c_int = 0x0001; -pub const MAP_PRIVATE: ::c_int = 0x0002; -pub const MAP_FIXED: ::c_int = 0x0010; -pub const MAP_ANON: ::c_int = 0x0020; - -pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const MS_ASYNC: ::c_int = 0x0001; -pub const MS_INVALIDATE: ::c_int = 0x0002; -pub const MS_SYNC: ::c_int = 0x0004; - -pub const EPERM: ::c_int = 1; -pub const ENOENT: ::c_int = 2; -pub const ESRCH: ::c_int = 3; -pub const EINTR: ::c_int = 4; -pub const EIO: ::c_int = 5; -pub const ENXIO: ::c_int = 6; -pub const E2BIG: ::c_int = 7; -pub const ENOEXEC: ::c_int = 8; -pub const EBADF: ::c_int = 9; -pub const ECHILD: ::c_int = 10; -pub const EAGAIN: ::c_int = 11; -pub const ENOMEM: ::c_int = 12; -pub const EACCES: ::c_int = 13; -pub const EFAULT: ::c_int = 14; -pub const ENOTBLK: ::c_int = 15; -pub const EBUSY: ::c_int = 16; -pub const EEXIST: ::c_int = 17; -pub const EXDEV: ::c_int = 18; -pub const ENODEV: ::c_int = 19; -pub const ENOTDIR: ::c_int = 20; -pub const EISDIR: ::c_int = 21; -pub const EINVAL: ::c_int = 22; -pub const ENFILE: ::c_int = 23; -pub const EMFILE: ::c_int = 24; -pub const ENOTTY: ::c_int = 25; -pub const ETXTBSY: ::c_int = 26; -pub const EFBIG: ::c_int = 27; -pub const ENOSPC: ::c_int = 28; -pub const ESPIPE: ::c_int = 29; -pub const EROFS: ::c_int = 30; -pub const EMLINK: ::c_int = 31; -pub const EPIPE: ::c_int = 32; -pub const EDOM: ::c_int = 33; -pub const ERANGE: ::c_int = 34; - -pub const EDEADLK: ::c_int = 35; -pub const ENAMETOOLONG: ::c_int = 36; -pub const ENOLCK: ::c_int = 37; -pub const ENOSYS: ::c_int = 38; -pub const ENOTEMPTY: ::c_int = 39; -pub const ELOOP: ::c_int = 40; -pub const EWOULDBLOCK: ::c_int = EAGAIN; -pub const ENOMSG: ::c_int = 42; -pub const EIDRM: ::c_int = 43; -pub const ECHRNG: ::c_int = 44; -pub const EL2NSYNC: ::c_int = 45; -pub const EL3HLT: ::c_int = 46; -pub const EL3RST: ::c_int = 47; -pub const ELNRNG: ::c_int = 48; -pub const EUNATCH: ::c_int = 49; -pub const ENOCSI: ::c_int = 50; -pub const EL2HLT: ::c_int = 51; -pub const EBADE: ::c_int = 52; -pub const EBADR: ::c_int = 53; -pub const EXFULL: ::c_int = 54; -pub const ENOANO: ::c_int = 55; -pub const EBADRQC: ::c_int = 56; -pub const EBADSLT: ::c_int = 57; - -pub const EDEADLOCK: ::c_int = EDEADLK; - -pub const EBFONT: ::c_int = 59; -pub const ENOSTR: ::c_int = 60; -pub const ENODATA: ::c_int = 61; -pub const ETIME: ::c_int = 62; -pub const ENOSR: ::c_int = 63; -pub const ENONET: ::c_int = 64; -pub const ENOPKG: ::c_int = 65; -pub const EREMOTE: ::c_int = 66; -pub const ENOLINK: ::c_int = 67; -pub const EADV: ::c_int = 68; -pub const ESRMNT: ::c_int = 69; -pub const ECOMM: ::c_int = 70; -pub const EPROTO: ::c_int = 71; -pub const EMULTIHOP: ::c_int = 72; -pub const EDOTDOT: ::c_int = 73; -pub const EBADMSG: ::c_int = 74; -pub const EOVERFLOW: ::c_int = 75; -pub const ENOTUNIQ: ::c_int = 76; -pub const EBADFD: ::c_int = 77; -pub const EREMCHG: ::c_int = 78; -pub const ELIBACC: ::c_int = 79; -pub const ELIBBAD: ::c_int = 80; -pub const ELIBSCN: ::c_int = 81; -pub const ELIBMAX: ::c_int = 82; -pub const ELIBEXEC: ::c_int = 83; -pub const EILSEQ: ::c_int = 84; -pub const ERESTART: ::c_int = 85; -pub const ESTRPIPE: ::c_int = 86; -pub const EUSERS: ::c_int = 87; -pub const ENOTSOCK: ::c_int = 88; -pub const EDESTADDRREQ: ::c_int = 89; -pub const EMSGSIZE: ::c_int = 90; -pub const EPROTOTYPE: ::c_int = 91; -pub const ENOPROTOOPT: ::c_int = 92; -pub const EPROTONOSUPPORT: ::c_int = 93; -pub const ESOCKTNOSUPPORT: ::c_int = 94; -pub const EOPNOTSUPP: ::c_int = 95; -pub const EPFNOSUPPORT: ::c_int = 96; -pub const EAFNOSUPPORT: ::c_int = 97; -pub const EADDRINUSE: ::c_int = 98; -pub const EADDRNOTAVAIL: ::c_int = 99; -pub const ENETDOWN: ::c_int = 100; -pub const ENETUNREACH: ::c_int = 101; -pub const ENETRESET: ::c_int = 102; -pub const ECONNABORTED: ::c_int = 103; -pub const ECONNRESET: ::c_int = 104; -pub const ENOBUFS: ::c_int = 105; -pub const EISCONN: ::c_int = 106; -pub const ENOTCONN: ::c_int = 107; -pub const ESHUTDOWN: ::c_int = 108; -pub const ETOOMANYREFS: ::c_int = 109; -pub const ETIMEDOUT: ::c_int = 110; -pub const ECONNREFUSED: ::c_int = 111; -pub const EHOSTDOWN: ::c_int = 112; -pub const EHOSTUNREACH: ::c_int = 113; -pub const EALREADY: ::c_int = 114; -pub const EINPROGRESS: ::c_int = 115; -pub const ESTALE: ::c_int = 116; -pub const EUCLEAN: ::c_int = 117; -pub const ENOTNAM: ::c_int = 118; -pub const ENAVAIL: ::c_int = 119; -pub const EISNAM: ::c_int = 120; -pub const EREMOTEIO: ::c_int = 121; -pub const EDQUOT: ::c_int = 122; -pub const ENOMEDIUM: ::c_int = 123; -pub const EMEDIUMTYPE: ::c_int = 124; -pub const ECANCELED: ::c_int = 125; -pub const ENOKEY: ::c_int = 126; -pub const EKEYEXPIRED: ::c_int = 127; -pub const EKEYREVOKED: ::c_int = 128; -pub const EKEYREJECTED: ::c_int = 129; -pub const EOWNERDEAD: ::c_int = 130; -pub const ENOTRECOVERABLE: ::c_int = 131; -pub const ERFKILL: ::c_int = 132; -pub const EHWPOISON: ::c_int = 133; - -pub const AF_PACKET: ::c_int = 17; -pub const IPPROTO_RAW: ::c_int = 255; - -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; -pub const O_NONBLOCK: ::c_int = 2048; -pub const O_SYNC: ::c_int = 1052672; - -pub const PROT_GROWSDOWN: ::c_int = 0x1000000; -pub const PROT_GROWSUP: ::c_int = 0x2000000; - -pub const MAP_TYPE: ::c_int = 0x000f; -pub const MAP_ANONYMOUS: ::c_int = 0x0020; -pub const MAP_32BIT: ::c_int = 0x0040; -pub const MAP_GROWSDOWN: ::c_int = 0x0100; -pub const MAP_DENYWRITE: ::c_int = 0x0800; -pub const MAP_EXECUTABLE: ::c_int = 0x01000; -pub const MAP_LOCKED: ::c_int = 0x02000; -pub const MAP_NORESERVE: ::c_int = 0x04000; -pub const MAP_POPULATE: ::c_int = 0x08000; -pub const MAP_NONBLOCK: ::c_int = 0x010000; -pub const MAP_STACK: ::c_int = 0x020000; - -pub const MADV_NORMAL: ::c_int = 0; -pub const MADV_RANDOM: ::c_int = 1; -pub const MADV_SEQUENTIAL: ::c_int = 2; -pub const MADV_WILLNEED: ::c_int = 3; -pub const MADV_DONTNEED: ::c_int = 4; -pub const MADV_REMOVE: ::c_int = 9; -pub const MADV_DONTFORK: ::c_int = 10; -pub const MADV_DOFORK: ::c_int = 11; -pub const MADV_MERGEABLE: ::c_int = 12; -pub const MADV_UNMERGEABLE: ::c_int = 13; -pub const MADV_HWPOISON: ::c_int = 100; - -pub const IFF_LOOPBACK: ::c_int = 0x8; - -pub const AF_UNIX: ::c_int = 1; -pub const AF_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 10; -pub const SOCK_STREAM: ::c_int = 1; -pub const SOCK_DGRAM: ::c_int = 2; -pub const SOCK_RAW: ::c_int = 3; -pub const IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -pub const IP_MULTICAST_TTL: ::c_int = 33; -pub const IP_MULTICAST_LOOP: ::c_int = 34; -pub const IP_TTL: ::c_int = 2; -pub const IP_HDRINCL: ::c_int = 3; -pub const IP_ADD_MEMBERSHIP: ::c_int = 35; -pub const IP_DROP_MEMBERSHIP: ::c_int = 36; -pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; -pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; - -pub const TCP_NODELAY: ::c_int = 1; -pub const TCP_MAXSEG: ::c_int = 2; -pub const TCP_CORK: ::c_int = 3; -pub const TCP_KEEPIDLE: ::c_int = 4; -pub const TCP_KEEPINTVL: ::c_int = 5; -pub const TCP_KEEPCNT: ::c_int = 6; -pub const TCP_SYNCNT: ::c_int = 7; -pub const TCP_LINGER2: ::c_int = 8; -pub const TCP_DEFER_ACCEPT: ::c_int = 9; -pub const TCP_WINDOW_CLAMP: ::c_int = 10; -pub const TCP_INFO: ::c_int = 11; -pub const TCP_QUICKACK: ::c_int = 12; -pub const TCP_CONGESTION: ::c_int = 13; -pub const TCP_MD5SIG: ::c_int = 14; -pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; -pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; -pub const TCP_THIN_DUPACK: ::c_int = 17; -pub const TCP_USER_TIMEOUT: ::c_int = 18; -pub const TCP_REPAIR: ::c_int = 19; -pub const TCP_REPAIR_QUEUE: ::c_int = 20; -pub const TCP_QUEUE_SEQ: ::c_int = 21; -pub const TCP_REPAIR_OPTIONS: ::c_int = 22; -pub const TCP_FASTOPEN: ::c_int = 23; -pub const TCP_TIMESTAMP: ::c_int = 24; - -pub const SOL_SOCKET: ::c_int = 1; - -pub const SO_DEBUG: ::c_int = 1; -pub const SO_REUSEADDR: ::c_int = 2; -pub const SO_TYPE: ::c_int = 3; -pub const SO_ERROR: ::c_int = 4; -pub const SO_DONTROUTE: ::c_int = 5; -pub const SO_BROADCAST: ::c_int = 6; -pub const SO_SNDBUF: ::c_int = 7; -pub const SO_RCVBUF: ::c_int = 8; -pub const SO_KEEPALIVE: ::c_int = 9; -pub const SO_OOBINLINE: ::c_int = 10; -pub const SO_LINGER: ::c_int = 13; -pub const SO_REUSEPORT: ::c_int = 15; -pub const SO_RCVLOWAT: ::c_int = 18; -pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; -pub const SO_ACCEPTCONN: ::c_int = 30; - -pub const SHUT_RD: ::c_int = 0; -pub const SHUT_WR: ::c_int = 1; -pub const SHUT_RDWR: ::c_int = 2; - -pub const LOCK_SH: ::c_int = 1; -pub const LOCK_EX: ::c_int = 2; -pub const LOCK_NB: ::c_int = 4; -pub const LOCK_UN: ::c_int = 8; diff --git a/src/unix/android.rs b/src/unix/android.rs new file mode 100644 index 0000000000000..41e6971802f67 --- /dev/null +++ b/src/unix/android.rs @@ -0,0 +1,25 @@ +//! Android versions of standard Unix functions + +extern { + pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + pub fn putenv(string: *const ::c_char) -> ::c_int; + pub fn readlink(path: *const ::c_char, + buf: *mut ::c_char, + bufsz: ::size_t) + -> ::c_int; + pub fn msync(addr: *const ::c_void, len: ::size_t, + flags: ::c_int) -> ::c_int; + pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + pub fn sysconf(name: ::c_int) -> ::c_int; + pub fn usleep(secs: ::c_ulong) -> ::c_int; + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_uint, addr: *const ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; + pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_uint) -> ::ssize_t; + pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_uint) -> ::ssize_t; +} diff --git a/src/unix.rs b/src/unix/mod.rs similarity index 76% rename from src/unix.rs rename to src/unix/mod.rs index bfff00949ad18..ed98452400c75 100644 --- a/src/unix.rs +++ b/src/unix/mod.rs @@ -1,3 +1,8 @@ +//! Definitions found commonly among almost all Unix derivatives +//! +//! More functions and definitions can be found in the more specific modules +//! according to the platform in question. + s! { pub struct utimbuf { pub actime: ::time_t, @@ -33,26 +38,11 @@ extern { pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int, value: *const ::c_void, option_len: ::socklen_t) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recv$UNIX2003")] - pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "send$UNIX2003")] - pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, - flags: ::c_int) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recvfrom$UNIX2003")] - pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *mut ::sockaddr, - addrlen: *mut ::socklen_t) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003")] pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int, addr: *const ::sockaddr, addrlen: ::socklen_t) -> ::ssize_t; - pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; - pub fn freeifaddrs(ifa: *mut ::ifaddrs); pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -66,7 +56,6 @@ extern { pub fn fstat(fildes: ::c_int, buf: *mut ::stat) -> ::c_int; pub fn mkdir(path: *const ::c_char, mode: ::mode_t) -> ::c_int; - pub fn mkfifo(path: *const ::c_char, mode: ::mode_t) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] pub fn stat(path: *const ::c_char, buf: *mut ::stat) -> ::c_int; @@ -107,16 +96,6 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "rewinddir$INODE64$UNIX2003")] pub fn rewinddir(dirp: *mut ::DIR); - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "seekdir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "seekdir$INODE64$UNIX2003")] - pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "telldir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "telldir$INODE64$UNIX2003")] - pub fn telldir(dirp: *mut ::DIR) -> ::c_long; pub fn access(path: *const ::c_char, amode: ::c_int) -> ::c_int; pub fn alarm(seconds: ::c_uint) -> ::c_uint; @@ -152,7 +131,6 @@ extern { pub fn getpid() -> ::pid_t; pub fn getppid() -> ::pid_t; pub fn getuid() -> ::uid_t; - pub fn getsid(pid: ::pid_t) -> ::pid_t; pub fn isatty(fd: ::c_int) -> ::c_int; pub fn link(src: *const ::c_char, dst: *const ::c_char) -> ::c_int; pub fn lseek(fd: ::c_int, offset: ::off_t, whence: ::c_int) @@ -174,14 +152,10 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sleep$UNIX2003")] pub fn sleep(secs: ::c_uint) -> ::c_uint; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "usleep$UNIX2003")] - pub fn usleep(secs: ::c_uint) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "nanosleep$UNIX2003")] pub fn nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int; - pub fn sysconf(name: ::c_int) -> ::c_long; pub fn tcgetpgrp(fd: ::c_int) -> ::pid_t; pub fn ttyname(fd: ::c_int) -> *mut ::c_char; pub fn unlink(c: *const ::c_char) -> ::c_int; @@ -215,23 +189,6 @@ extern { pub fn mlockall(flags: ::c_int) -> ::c_int; pub fn munlockall() -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "mprotect$UNIX2003")] - pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) - -> ::c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "msync$UNIX2003")] - pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) - -> ::c_int; - #[cfg(target_os = "macos")] - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) - -> ::c_int; - #[cfg(target_os = "linux")] - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, - mode: ::mode_t) -> ::c_int; - pub fn shm_unlink(name: *const ::c_char) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mmap$UNIX2003")] pub fn mmap(addr: *mut ::c_void, @@ -250,18 +207,10 @@ extern { #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] pub fn lstat(path: *const ::c_char, buf: *mut ::stat) -> ::c_int; - pub fn readlink(path: *const ::c_char, - buf: *mut ::c_char, - bufsz: ::size_t) - -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fsync$UNIX2003")] pub fn fsync(fd: ::c_int) -> ::c_int; - #[cfg(any(target_os = "linux", target_os = "android"))] - pub fn fdatasync(fd: ::c_int) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "setenv$UNIX2003")] pub fn setenv(name: *const ::c_char, val: *const ::c_char, @@ -269,9 +218,6 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "unsetenv$UNIX2003")] pub fn unsetenv(name: *const ::c_char) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "putenv$UNIX2003")] - pub fn putenv(string: *mut ::c_char) -> ::c_int; pub fn symlink(path1: *const ::c_char, path2: *const ::c_char) -> ::c_int; @@ -281,27 +227,24 @@ extern { pub fn signal(signum: ::c_int, handler: ::sighandler_t) -> ::sighandler_t; - pub fn glob(pattern: *const ::c_char, - flags: ::c_int, - errfunc: Option ::c_int>, - pglob: *mut ::glob_t); - pub fn globfree(pglob: *mut ::glob_t); - - pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; pub fn getrusage(resource: ::c_int, usage: *mut ::rusage) -> ::c_int; pub fn getdtablesize() -> ::c_int; - pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; } + +cfg_if! { + if #[cfg(target_os = "android")] { + mod android; + pub use self::android::*; + } else { + mod other; + pub use self::other::*; + } +} diff --git a/src/unix/other.rs b/src/unix/other.rs new file mode 100644 index 0000000000000..f3b38a986bb8e --- /dev/null +++ b/src/unix/other.rs @@ -0,0 +1,117 @@ +//! All Unix OS-es that are not android + +extern { + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + pub fn glob(pattern: *const ::c_char, + flags: ::c_int, + errfunc: Option ::c_int>, + pglob: *mut ::glob_t); + pub fn globfree(pglob: *mut ::glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + + #[cfg(target_os = "macos")] + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) + -> ::c_int; + #[cfg(target_os = "linux")] + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, + mode: ::mode_t) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003")] + pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003")] + pub fn telldir(dirp: *mut ::DIR) -> ::c_long; + + pub fn getsid(pid: ::pid_t) -> ::pid_t; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "putenv$UNIX2003")] + pub fn putenv(string: *mut ::c_char) -> ::c_int; + pub fn readlink(path: *const ::c_char, + buf: *mut ::c_char, + bufsz: ::size_t) + -> ::ssize_t; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003")] + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "mprotect$UNIX2003")] + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + pub fn sysconf(name: ::c_int) -> ::c_long; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "usleep$UNIX2003")] + pub fn usleep(secs: ::c_uint) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003")] + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "send$UNIX2003")] + pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recv$UNIX2003")] + pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; + pub fn mkfifo(path: *const ::c_char, mode: ::mode_t) -> ::c_int; +} + +cfg_if! { + if #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd"))] { + extern { + pub fn sysctl(name: *mut c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) + -> c_int; + pub fn sysctlbyname(name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn sysctlnametomib(name: *const c_char, + mibp: *mut c_int, + sizep: *mut size_t) + -> c_int; + } + } else { + extern { + pub fn sysctl(name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t) + -> c_int; + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) + -> c_int; + } + } +} diff --git a/src/windows.rs b/src/windows.rs index efa29dac63ebb..159a311f8bafa 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,3 +1,5 @@ +//! Windows CRT definitions + pub type c_char = i8; pub type c_schar = i8; pub type c_uchar = u8; From c89d56bc1528c8aa4162e6b7baba5177348bf905 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 17:28:09 -0700 Subject: [PATCH 051/194] Fix style for linux --- src/linuxlike/linux.rs | 122 ++++++++++++++++++++--------------------- src/unix/other.rs | 56 +++++++++---------- 2 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/linuxlike/linux.rs b/src/linuxlike/linux.rs index bbd724c481aad..8f436ff123925 100644 --- a/src/linuxlike/linux.rs +++ b/src/linuxlike/linux.rs @@ -1,11 +1,36 @@ //! Linux-specific definitions for linux-like values -pub const BUFSIZ: c_uint = 8192; -pub const FILENAME_MAX: c_uint = 4096; -pub const FOPEN_MAX: c_uint = 16; -pub const L_tmpnam: c_uint = 20; -pub const TMP_MAX: c_uint = 238328; -pub const _PC_NAME_MAX: c_int = 3; +s! { + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_pathv: *mut *mut ::c_char, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct ifaddrs { + pub ifa_next: *mut ::ifaddrs, + pub ifa_name: *mut ::c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } +} + +pub const BUFSIZ: ::c_uint = 8192; +pub const FILENAME_MAX: ::c_uint = 4096; +pub const FOPEN_MAX: ::c_uint = 16; +pub const L_tmpnam: ::c_uint = 20; +pub const TMP_MAX: ::c_uint = 238328; +pub const _PC_NAME_MAX: ::c_int = 3; pub const _SC_ARG_MAX: ::c_int = 0; pub const _SC_CHILD_MAX: ::c_int = 1; @@ -35,7 +60,7 @@ pub const _SC_AIO_MAX: ::c_int = 24; pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; pub const _SC_DELAYTIMER_MAX: ::c_int = 26; pub const _SC_MQ_OPEN_MAX: ::c_int = 27; -pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_MQ_PRIO_MAX: ::c_int = 28; pub const _SC_VERSION: ::c_int = 29; pub const _SC_PAGESIZE: ::c_int = 30; pub const _SC_RTSIG_MAX: ::c_int = 31; @@ -58,69 +83,44 @@ pub const _SC_2_FORT_DEV: ::c_int = 49; pub const _SC_2_FORT_RUN: ::c_int = 50; pub const _SC_2_SW_DEV: ::c_int = 51; pub const _SC_2_LOCALEDEF: ::c_int = 52; -pub const _SC_IOV_MAX: c_int = 60; -pub const _SC_THREADS: c_int = 67; -pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; -pub const _SC_LOGIN_NAME_MAX: c_int = 71; -pub const _SC_TTY_NAME_MAX: c_int = 72; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; -pub const _SC_THREAD_KEYS_MAX: c_int = 74; -pub const _SC_THREAD_STACK_MIN: c_int = 75; -pub const _SC_THREAD_THREADS_MAX: c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; -pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; -pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; -pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_IOV_MAX: ::c_int = 60; +pub const _SC_THREADS: ::c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; +pub const _SC_TTY_NAME_MAX: ::c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; +pub const _SC_THREAD_STACK_MIN: ::c_int = 75; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; -pub const _SC_ATEXIT_MAX: c_int = 87; -pub const _SC_XOPEN_VERSION: c_int = 89; -pub const _SC_XOPEN_XCU_VERSION: c_int = 90; -pub const _SC_XOPEN_UNIX: c_int = 91; -pub const _SC_XOPEN_CRYPT: c_int = 92; -pub const _SC_XOPEN_ENH_I18N: c_int = 93; -pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_ATEXIT_MAX: ::c_int = 87; +pub const _SC_XOPEN_VERSION: ::c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; +pub const _SC_XOPEN_UNIX: ::c_int = 91; +pub const _SC_XOPEN_CRYPT: ::c_int = 92; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; +pub const _SC_XOPEN_SHM: ::c_int = 94; pub const _SC_2_CHAR_TERM: ::c_int = 95; pub const _SC_2_C_VERSION: ::c_int = 96; pub const _SC_2_UPE: ::c_int = 97; pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; -pub const _SC_XOPEN_LEGACY: c_int = 129; -pub const _SC_XOPEN_REALTIME: c_int = 130; -pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; - -s! { - pub struct glob_t { - pub gl_pathc: size_t, - pub gl_pathv: *mut *mut c_char, - pub gl_offs: size_t, - pub gl_flags: c_int, - - __unused1: *mut ::c_void, - __unused2: *mut ::c_void, - __unused3: *mut ::c_void, - __unused4: *mut ::c_void, - __unused5: *mut ::c_void, - } - - pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_ifu: *mut sockaddr, // FIXME This should be a union - pub ifa_data: *mut ::c_void - } -} +pub const _SC_XOPEN_LEGACY: ::c_int = 129; +pub const _SC_XOPEN_REALTIME: ::c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; pub const RLIMIT_NLIMITS: ::c_int = 16; -pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; -pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; -pub const RUSAGE_THREAD: c_int = 1; +pub const RLIM_SAVED_MAX: ::rlim_t = ::RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = ::RLIM_INFINITY; +pub const RUSAGE_THREAD: ::c_int = 1; pub const GLOB_ERR: ::c_int = 1 << 0; pub const GLOB_MARK: ::c_int = 1 << 1; diff --git a/src/unix/other.rs b/src/unix/other.rs index f3b38a986bb8e..c073a281d082e 100644 --- a/src/unix/other.rs +++ b/src/unix/other.rs @@ -81,37 +81,37 @@ cfg_if! { target_os = "netbsd", target_os = "openbsd"))] { extern { - pub fn sysctl(name: *mut c_int, - namelen: c_uint, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) - -> c_int; - pub fn sysctlbyname(name: *const c_char, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn sysctlnametomib(name: *const c_char, - mibp: *mut c_int, - sizep: *mut size_t) - -> c_int; + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn mincore(addr: *const ::c_void, len: ::size_t, + vec: *mut ::c_char) -> ::c_int; + pub fn sysctlbyname(name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn sysctlnametomib(name: *const ::c_char, + mibp: *mut ::c_int, + sizep: *mut ::size_t) + -> ::c_int; } } else { extern { - pub fn sysctl(name: *mut c_int, - namelen: c_int, - oldp: *mut c_void, - oldlenp: *mut size_t, - newp: *mut c_void, - newlen: size_t) - -> c_int; - pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) - -> c_int; + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn mincore(addr: *mut ::c_void, len: ::size_t, + vec: *mut ::c_uchar) -> ::c_int; } } } From 3dc9916803d976c41c9ba99d31cfe54aed92108d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 17:36:34 -0700 Subject: [PATCH 052/194] Fix compile on linux --- src/linuxlike/b32/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linuxlike/b32/mod.rs b/src/linuxlike/b32/mod.rs index 74a4b0b31e9e3..02f1c217f8272 100644 --- a/src/linuxlike/b32/mod.rs +++ b/src/linuxlike/b32/mod.rs @@ -40,6 +40,6 @@ cfg_if! { pub use self::mips::*; } else { mod other; - pub use other::*; + pub use self::other::*; } } From 95c90fa47e0bc4e99aea2b40b8ae32352dbfe111 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 17:37:30 -0700 Subject: [PATCH 053/194] Let's try running android --- .travis.yml | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index c760cf5d9ac25..6952891a5c6e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,35 +2,10 @@ language: rust sudo: required services: - docker +android: + components: + - android-19 rust: - 1.0.0 - - beta - - nightly -install: - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu; else OS=apple-darwin; fi - - export TARGET=$ARCH-$OS - - curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz - - tar xf rust-$TRAVIS_RUST_VERSION-$TARGET.tar.gz - - rm -rf $HOME/rust/lib/rustlib/$TARGET - - mv rust-$TRAVIS_RUST_VERSION-$TARGET/rustc/lib/rustlib/$TARGET $HOME/rust/lib/rustlib -before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH script: - - cargo test --target $TARGET - - cargo test --target $TARGET --manifest-path libc-test/Cargo.toml - - cargo doc --no-deps - -addons: - apt: - packages: - - gcc-multilib -notifications: - email: - on_success: never -env: - - ARCH=x86_64 CC=clang - - ARCH=i686 CC=clang - -os: - - linux - - osx + - arm-linux-androideabi-gcc From d2e41c10a4cdd42f251eb4f00ca2afb0fbe8f272 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Sep 2015 17:45:12 -0700 Subject: [PATCH 054/194] Fix compile on linux-32 --- src/linuxlike/b32/other.rs | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/linuxlike/b32/other.rs b/src/linuxlike/b32/other.rs index d598578cfb31c..02bc4abacdacd 100644 --- a/src/linuxlike/b32/other.rs +++ b/src/linuxlike/b32/other.rs @@ -9,26 +9,26 @@ pub type nlink_t = u32; s! { pub struct stat { - pub st_dev: dev_t, - __pad1: c_short, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - __pad2: c_short, - pub st_size: off_t, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - __unused4: c_long, - __unused5: c_long, + pub st_dev: ::dev_t, + __pad1: ::c_short, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_short, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused4: ::c_long, + __unused5: ::c_long, } pub struct pthread_attr_t { From 79199aff36ce7ec2ad3389fc80f2c6694ad54512 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 11:22:42 -0700 Subject: [PATCH 055/194] Add docker file to build android image --- Dockerfile | 64 +++++++++++++++++++++++++++++++++++ ci/android-accept-licenses.sh | 14 ++++++++ ci/cargo-config | 2 ++ ci/run.sh | 15 ++++++++ 4 files changed, 95 insertions(+) create mode 100644 Dockerfile create mode 100755 ci/android-accept-licenses.sh create mode 100644 ci/cargo-config create mode 100644 ci/run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..dc85a9cb0a7a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,64 @@ +FROM ubuntu:latest + +RUN mkdir /build +WORKDIR /build + +# Setup PATH to allow running android tools. +ENV PATH=$PATH:/build/android-ndk/bin +ENV PATH=$PATH:/build/android-sdk-linux/tools +ENV PATH=$PATH:/build/android-sdk-linux/platform-tools + +# So it looks like the default sdk gives us a 32-bit executable, but then it +# whines about it. Not sure how to download a 64-bit executable in the sdk so +# just let the 32-bit thing run for now. +ENV ANDROID_EMULATOR_FORCE_32BIT=true + +# Install necessary packages: +RUN dpkg --add-architecture i386 +RUN apt-get -y update +RUN apt-get -y install expect curl libncurses5:i386 libstdc++6:i386 zlib1g:i386 \ + openjdk-6-jre gcc-multilib + +# Prep the Android NDK +# +# See https://github.com/servo/servo/wiki/Building-for-Android +RUN curl -O http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2 +RUN tar xf android-ndk-r9c-linux-x86_64.tar.bz2 +RUN bash android-ndk-r9c/build/tools/make-standalone-toolchain.sh \ + --platform=android-18 \ + --toolchain=arm-linux-androideabi-4.8 \ + --install-dir=/build/android-ndk \ + --ndk-dir=/build/android-ndk-r9c \ + --arch=arm +RUN rm -rf android-ndk-r9c-linux-x86_64.tar.bz2 +RUN rm -rf android-ndk-r9c + +# Prep the SDK and emulator +# +# Note that the update process requires that we accept a bunch of licenses, and +# we can't just pipe `yes` into it for some reason, so we take the same strategy +# located in https://github.com/appunite/docker by just wrapping it in a script +# which apparently magically accepts the licenses. +RUN curl -O http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz +RUN tar xf android-sdk_r24.3.4-linux.tgz +COPY ci/android-accept-licenses.sh /build/android-accept-licenses.sh +RUN ["./android-accept-licenses.sh", \ + "android - update sdk -a --no-ui --filter platform-tools,android-18,sys-img-armeabi-v7a-android-18"] +RUN echo "no" | android create avd \ + --name test \ + --target android-18 \ + --abi armeabi-v7a +RUN rm -rf android-sdk_r24.3.4-linux.tgz +RUN rm android-accept-licenses.sh + +# Install rustc + extra targets +RUN curl https://static.rust-lang.org/rustup.sh | \ + sh -s -- --spec=nightly-2015-09-08 -y +RUN curl https://people.mozilla.org/~acrichton/libc-test/2015-09-08/arm-linux-androideabi.tar.gz | \ + tar xzf - -C /usr/local/lib/rustlib +RUN mkdir /root/.cargo +COPY ci/cargo-config /root/.cargo/config +ENV CARGO_TARGET_DIR=/root/target + +RUN mkdir /clone +WORKDIR /clone diff --git a/ci/android-accept-licenses.sh b/ci/android-accept-licenses.sh new file mode 100755 index 0000000000000..776adf6f42314 --- /dev/null +++ b/ci/android-accept-licenses.sh @@ -0,0 +1,14 @@ +#!/usr/bin/expect -f + +set timeout 1800 +set cmd [lindex $argv 0] +set licenses [lindex $argv 1] + +spawn {*}$cmd +expect { + "Do you accept the license '*'*" { + exp_send "y\r" + exp_continue + } + eof +} diff --git a/ci/cargo-config b/ci/cargo-config new file mode 100644 index 0000000000000..f1d42a30d0299 --- /dev/null +++ b/ci/cargo-config @@ -0,0 +1,2 @@ +[target.arm-linux-androideabi] +linker = "arm-linux-androideabi-gcc" diff --git a/ci/run.sh b/ci/run.sh new file mode 100644 index 0000000000000..3f1f3bfbe3a1b --- /dev/null +++ b/ci/run.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -ex + +TARGET=$1 +cargo test --manifest-path libc-test/Cargo.toml --no-run --target $TARGET + +if [ "$TARGET" = "arm-linux-androideabi" ]; then + emulator @test -no-window & + adb wait-for-device + adb push /root/target/$TARGET/debug/all-* /data/test + adb shell /data/test +else + cargo test --manifest-path libc-test/Cargo.toml --target $TARGET +fi From 83a30491ce9294afb374302e3d0856356738f83f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 16:15:48 -0700 Subject: [PATCH 056/194] Aight, let's try running everything on travis --- .travis.yml | 21 +++++++++++++++------ ci/run-travis.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 ci/run-travis.sh diff --git a/.travis.yml b/.travis.yml index 6952891a5c6e4..f9e14999dfabd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,20 @@ language: rust sudo: required -services: - - docker -android: - components: - - android-19 rust: - 1.0.0 + - beta + - stable +services: + - docker script: - - arm-linux-androideabi-gcc + - sh ci/run-travis.sh +os: + - linux + - osx +env: + - ARCH=i686 + - ARCH=x86_64 +matrix: + include: + - os: linux + TARGET: arm-linux-androideabi diff --git a/ci/run-travis.sh b/ci/run-travis.sh new file mode 100644 index 0000000000000..1902cfa66af8f --- /dev/null +++ b/ci/run-travis.sh @@ -0,0 +1,28 @@ +set -ex + +if [ "$TRAVIS_OS_NAME" = "linux"]; then + OS=unknown-linux-gnu +else + OS=apple-darwin +fi + +export HOST=$ARCH-$OS + +if [ "$TARGET" = "" ]; then + # Download and install the relevant target locally, then run tests + curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz + tar xf rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz + rm -rf $HOME/rust/lib/rustlib/$HOST + mv rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST \ + $HOME/rust/lib/rustlib + sh ci/run.sh $HOST + +elif [ "$TARGET" = "arm-linux-androideabi" ]; then + # Pull a pre-built docker image for testing android, then run tests entirely + # within that image. + docker pull alexcrichton/rust-libc-test + docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET +else + echo "Unknown target: $TARGET" + exit 1 +fi From 3f07aebd1dcb3267ce9f14256a19569fa556ba06 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 16:35:52 -0700 Subject: [PATCH 057/194] Use clang instead of cc --- ci/run-travis.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 1902cfa66af8f..596b6e58b8b5b 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -8,6 +8,9 @@ fi export HOST=$ARCH-$OS +# clang has better error messages and implements alignof more broadly +export CC=clang + if [ "$TARGET" = "" ]; then # Download and install the relevant target locally, then run tests curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz From b7de09c367cf0ce5b3d08662c96ab6597ef9f952 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 16:37:45 -0700 Subject: [PATCH 058/194] Temporarily only test docker --- .travis.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9e14999dfabd..427594834eeeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,19 @@ language: rust sudo: required -rust: - - 1.0.0 - - beta - - stable +# rust: +# - 1.0.0 +# - beta +# - stable services: - docker script: - sh ci/run-travis.sh -os: - - linux - - osx -env: - - ARCH=i686 - - ARCH=x86_64 +# os: +# - linux +# - osx +# env: +# - ARCH=i686 +# - ARCH=x86_64 matrix: include: - os: linux From ea4db3c449d3b795c36554ccb9c5f4d383c165e1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 16:38:21 -0700 Subject: [PATCH 059/194] Get android rust download working --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 427594834eeeb..4fa4a66de15ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,3 +18,4 @@ matrix: include: - os: linux TARGET: arm-linux-androideabi + rust: stable From 6ce2bae0911c66e07b5307d055639b741eb2a0f8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 16:41:02 -0700 Subject: [PATCH 060/194] Fix TARGET spec on android --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4fa4a66de15ff..cf6efe2a55c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,5 @@ script: matrix: include: - os: linux - TARGET: arm-linux-androideabi + env: TARGET=arm-linux-androideabi rust: stable From e47a450f34218254bc16b522875a72c37aa7c601 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 16:42:49 -0700 Subject: [PATCH 061/194] Fix shell syntax --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 596b6e58b8b5b..2e6613d15d7ef 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -1,6 +1,6 @@ set -ex -if [ "$TRAVIS_OS_NAME" = "linux"]; then +if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=unknown-linux-gnu else OS=apple-darwin From 985744fc79d22f1130bb230d023db20d88a761a0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 17:02:38 -0700 Subject: [PATCH 062/194] Run everything! --- .travis.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf6efe2a55c71..94ec9f3f67151 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,19 @@ language: rust sudo: required -# rust: -# - 1.0.0 -# - beta -# - stable +rust: + - 1.0.0 + - beta + - stable services: - docker script: - sh ci/run-travis.sh -# os: -# - linux -# - osx -# env: -# - ARCH=i686 -# - ARCH=x86_64 +os: + - linux + - osx +env: + - ARCH=i686 + - ARCH=x86_64 matrix: include: - os: linux From 16ceef2f7478c384e5fc9116f3fec7574f00ae82 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 17:25:04 -0700 Subject: [PATCH 063/194] Use nightly, not stable --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 94ec9f3f67151..300a5d6e34fc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: required rust: - 1.0.0 - beta - - stable + - nightly services: - docker script: From cf3b010fd4b862b4a5679eedc0103cd5d06c7ced Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 17:26:07 -0700 Subject: [PATCH 064/194] Install gcc-multilib on linux --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 300a5d6e34fc8..46d7ee40d1a21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,3 +19,7 @@ matrix: - os: linux env: TARGET=arm-linux-androideabi rust: stable +addons: + apt: + packages: + - gcc-multilib From a3c854d9217e5500c909b9705e84bf78159031f2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 22:03:11 -0700 Subject: [PATCH 065/194] Never notify on success for travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 46d7ee40d1a21..b83c2e30f0ad3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,3 +23,6 @@ addons: apt: packages: - gcc-multilib +notifications: + email: + on_success: never From 87fdebdeb2164309b5d343cf31339fa1dbdc7989 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 12 Sep 2015 22:24:01 -0700 Subject: [PATCH 066/194] Use MSYS2 on appveyor --- appveyor.yml | 14 ++++++++++++-- ci/msys2.ps1 | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 ci/msys2.ps1 diff --git a/appveyor.yml b/appveyor.yml index fb6ccd13992de..7c01515f6c3d2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,23 @@ environment: + global: + MSYS2_BASEVER: 20150512 matrix: + - TARGET: x86_64-pc-windows-gnu + MSYS2_ARCH: x86_64 + MSYS2_BITS: 64 + MSYSTEM: MINGW64 + - TARGET: i686-pc-windows-gnu + MSYS2_ARCH: i686 + MSYS2_BITS: 32 + MSYSTEM: MINGW32 - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc - - TARGET: i686-pc-windows-gnu install: + - ps: ci\msys2.ps1 - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - - SET PATH=%PATH%;C:\MinGW\bin + - if defined MSYS2_BITS set PATH=%PATH%;%CD%\msys2\mingw%MSYS2_BITS%\bin - rustc -V - cargo -V diff --git a/ci/msys2.ps1 b/ci/msys2.ps1 new file mode 100644 index 0000000000000..f57cc6b4e8555 --- /dev/null +++ b/ci/msys2.ps1 @@ -0,0 +1,20 @@ +If (!${env:MSYS2_ARCH}) { + Exit 0 +} + +Start-FileDownload ` + ("http://kent.dl.sourceforge.net/project/msys2/Base/" + ` + $env:MSYS2_ARCH + "/msys2-base-" + $env:MSYS2_ARCH + "-" + ` + $env:MSYS2_BASEVER + ".tar.xz") ` + -FileName "msys2.tar.xz" + +7z x msys2.tar.xz +7z x msys2.tar > $nul +Move-Item ("msys" + $env:MSYS2_BITS) msys2 +.\msys2\usr\bin\bash.exe -lc "" +.\msys2\usr\bin\bash.exe -lc ` + ("for i in {1..3}; do " + ` + "pacman --noconfirm -Suy mingw-w64-"+ $env:MSYS2_ARCH + "-gcc " + ` + "&& break || sleep 15; " + ` + "done") +.\msys2\autorebase.bat From 9e97afd91f57519268082c14a0be6a01b2f6d5b0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 11:16:53 -0700 Subject: [PATCH 067/194] Break apart src/unix/other.rs a bit Also sysctl isn't defined on MUSL --- libc-test/tests/all.rs | 2 ++ src/unix/other/bsdlike.rs | 22 +++++++++++++++ src/unix/{other.rs => other/mod.rs} | 42 +++-------------------------- src/unix/other/notbsd.rs | 14 ++++++++++ 4 files changed, 42 insertions(+), 38 deletions(-) create mode 100644 src/unix/other/bsdlike.rs rename src/unix/{other.rs => other/mod.rs} (66%) create mode 100644 src/unix/other/notbsd.rs diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 42a743c4f3d20..15d31814190b4 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -1,5 +1,7 @@ +#![feature(alloc_system)] #![allow(bad_style, unused_imports)] +extern crate alloc_system; extern crate libc; extern crate libc_test; diff --git a/src/unix/other/bsdlike.rs b/src/unix/other/bsdlike.rs new file mode 100644 index 0000000000000..2928c2eb1b846 --- /dev/null +++ b/src/unix/other/bsdlike.rs @@ -0,0 +1,22 @@ +extern { + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn mincore(addr: *const ::c_void, len: ::size_t, + vec: *mut ::c_char) -> ::c_int; + pub fn sysctlbyname(name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn sysctlnametomib(name: *const ::c_char, + mibp: *mut ::c_int, + sizep: *mut ::size_t) + -> ::c_int; +} diff --git a/src/unix/other.rs b/src/unix/other/mod.rs similarity index 66% rename from src/unix/other.rs rename to src/unix/other/mod.rs index c073a281d082e..4f2d20ab0ab49 100644 --- a/src/unix/other.rs +++ b/src/unix/other/mod.rs @@ -13,12 +13,6 @@ extern { pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - #[cfg(target_os = "macos")] - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) - -> ::c_int; - #[cfg(target_os = "linux")] - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, - mode: ::mode_t) -> ::c_int; pub fn shm_unlink(name: *const ::c_char) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), @@ -80,38 +74,10 @@ cfg_if! { target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] { - extern { - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_uint, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn mincore(addr: *const ::c_void, len: ::size_t, - vec: *mut ::c_char) -> ::c_int; - pub fn sysctlbyname(name: *const ::c_char, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn sysctlnametomib(name: *const ::c_char, - mibp: *mut ::c_int, - sizep: *mut ::size_t) - -> ::c_int; - } + mod bsdlike; + pub use self::bsdlike::*; } else { - extern { - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn mincore(addr: *mut ::c_void, len: ::size_t, - vec: *mut ::c_uchar) -> ::c_int; - } + mod notbsd; + pub use self::notbsd::*; } } diff --git a/src/unix/other/notbsd.rs b/src/unix/other/notbsd.rs new file mode 100644 index 0000000000000..f42ea1fe24de1 --- /dev/null +++ b/src/unix/other/notbsd.rs @@ -0,0 +1,14 @@ +extern { + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, + mode: ::mode_t) -> ::c_int; + #[cfg(not(target_env = "musl"))] + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn mincore(addr: *mut ::c_void, len: ::size_t, + vec: *mut ::c_uchar) -> ::c_int; +} From 1cf98aec585e39a85b16dc182839cee3458c6e28 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 11:19:02 -0700 Subject: [PATCH 068/194] Get MUSL working --- libc-test/build.rs | 6 ++++-- src/linuxlike/linux.rs | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8858320b154f9..de343db2d220a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -43,7 +43,7 @@ impl<'a> TestGenerator<'a> { let mut ret = Vec::new(); // Pull in extra goodies on linux - if self.target.contains("unknown-linux") { + if self.target.contains("unknown-linux-gnu") { ret.push("_GNU_SOURCE"); } @@ -211,8 +211,10 @@ impl<'a> TestGenerator<'a> { } else { panic!("unknown arch/pointer width: {}", self.target) }; - let (os, family, env) = if self.target.contains("unknown-linux") { + let (os, family, env) = if self.target.contains("unknown-linux-gnu") { ("linux", "unix", "gnu") + } else if self.target.contains("unknown-linux-musl") { + ("linux", "unix", "musl") } else if self.target.contains("apple-darwin") { ("macos", "unix", "") } else if self.target.contains("windows-msvc") { diff --git a/src/linuxlike/linux.rs b/src/linuxlike/linux.rs index 8f436ff123925..09e7f7a7a6a35 100644 --- a/src/linuxlike/linux.rs +++ b/src/linuxlike/linux.rs @@ -120,6 +120,8 @@ pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; pub const RLIMIT_NLIMITS: ::c_int = 16; pub const RLIM_SAVED_MAX: ::rlim_t = ::RLIM_INFINITY; pub const RLIM_SAVED_CUR: ::rlim_t = ::RLIM_INFINITY; + +#[cfg(not(target_env = "musl"))] pub const RUSAGE_THREAD: ::c_int = 1; pub const GLOB_ERR: ::c_int = 1 << 0; From acda0135604b711c1dbad10389ace4324afe9288 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 11:22:26 -0700 Subject: [PATCH 069/194] Add MUSL to CI --- .travis.yml | 3 +++ ci/run-travis.sh | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index b83c2e30f0ad3..f58638705763c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,9 @@ matrix: - os: linux env: TARGET=arm-linux-androideabi rust: stable + - os: linux + env: TARGET=x86_64-unknown-linux-musl + rust: nightly-2015-09-08 addons: apt: packages: diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 2e6613d15d7ef..b025db34f48ec 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -11,7 +11,16 @@ export HOST=$ARCH-$OS # clang has better error messages and implements alignof more broadly export CC=clang -if [ "$TARGET" = "" ]; then +if [ "$TARGET" = "arm-linux-androideabi" ]; then + # Pull a pre-built docker image for testing android, then run tests entirely + # within that image. + docker pull alexcrichton/rust-libc-test + docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET +elif [ "$TARGET" = "x86_64-unknown-linux-gnu" ]; then + curl -sO https://people.mozilla.org/~acrichton/libc-test/2015-09-08/x86_64-unknown-linux-musl.tar.gz | \ + tar xzf -C $HOME/rust/lib/rustlib + sh ci/run.sh $TARGET +else # Download and install the relevant target locally, then run tests curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz tar xf rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz @@ -19,13 +28,4 @@ if [ "$TARGET" = "" ]; then mv rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST \ $HOME/rust/lib/rustlib sh ci/run.sh $HOST - -elif [ "$TARGET" = "arm-linux-androideabi" ]; then - # Pull a pre-built docker image for testing android, then run tests entirely - # within that image. - docker pull alexcrichton/rust-libc-test - docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET -else - echo "Unknown target: $TARGET" - exit 1 fi From 40710378e2044c86b896a8f330716c01705f577a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 11:23:17 -0700 Subject: [PATCH 070/194] Correct android rust nightly version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f58638705763c..1c01adeb952b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: include: - os: linux env: TARGET=arm-linux-androideabi - rust: stable + rust: nightly-2015-09-08 - os: linux env: TARGET=x86_64-unknown-linux-musl rust: nightly-2015-09-08 From 2f846f3f6cd2889c092f9604a59e1249af0a78cf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 21:21:46 -0700 Subject: [PATCH 071/194] Fix test script --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index b025db34f48ec..dcaa5566b921c 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -16,7 +16,7 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then # within that image. docker pull alexcrichton/rust-libc-test docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET -elif [ "$TARGET" = "x86_64-unknown-linux-gnu" ]; then +elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then curl -sO https://people.mozilla.org/~acrichton/libc-test/2015-09-08/x86_64-unknown-linux-musl.tar.gz | \ tar xzf -C $HOME/rust/lib/rustlib sh ci/run.sh $TARGET From 1398566d67ba10481dba0089515e196f9625fe62 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 21:43:02 -0700 Subject: [PATCH 072/194] Revert alloc_system change --- libc-test/tests/all.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 15d31814190b4..42a743c4f3d20 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -1,7 +1,5 @@ -#![feature(alloc_system)] #![allow(bad_style, unused_imports)] -extern crate alloc_system; extern crate libc; extern crate libc_test; From 11b5ca497a6c83a18059fd6d7eb1cc924d94c69d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 22:10:18 -0700 Subject: [PATCH 073/194] Fix MUSL script --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index dcaa5566b921c..b5b08442c446e 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -18,7 +18,7 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then curl -sO https://people.mozilla.org/~acrichton/libc-test/2015-09-08/x86_64-unknown-linux-musl.tar.gz | \ - tar xzf -C $HOME/rust/lib/rustlib + tar xzf - -C $HOME/rust/lib/rustlib sh ci/run.sh $TARGET else # Download and install the relevant target locally, then run tests From 1e6056e573e82617ce05290ea0ee200648ddeda4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 22:59:06 -0700 Subject: [PATCH 074/194] Try to fix musl CI again --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index b5b08442c446e..a7d382f5e2851 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -17,7 +17,7 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then docker pull alexcrichton/rust-libc-test docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then - curl -sO https://people.mozilla.org/~acrichton/libc-test/2015-09-08/x86_64-unknown-linux-musl.tar.gz | \ + curl -s https://people.mozilla.org/~acrichton/libc-test/2015-09-08/x86_64-unknown-linux-musl.tar.gz | \ tar xzf - -C $HOME/rust/lib/rustlib sh ci/run.sh $TARGET else From 5a28433bb11ad4cdd0f7571f32304b5006facad4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 23:33:33 -0700 Subject: [PATCH 075/194] Run all tests manually Running a test per thread really doesn't play well with QEMU emulation, so just make it easy on ourselves and don't run threads. --- libc-test/Cargo.toml | 4 ++++ libc-test/build.rs | 45 ++++++++++++++++++++++++++++++++---------- libc-test/tests/all.rs | 7 ++++++- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index bab5699f5be39..fee56fee20282 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -15,3 +15,7 @@ gcc = { git = "https://github.com/alexcrichton/gcc-rs" } name = "libc_test" test = false doctest = false + +[[test]] +name = "all" +harness = false diff --git a/libc-test/build.rs b/libc-test/build.rs index de343db2d220a..60e8927b3540f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -32,6 +32,7 @@ struct TestGenerator<'a> { sh: &'a SpanHandler, structs: HashSet, abi: Abi, + tests: Vec, } struct StructFinder { @@ -253,6 +254,7 @@ fn main() { sh: &sess.span_diagnostic, structs: HashSet::new(), abi: Abi::C, + tests: Vec::new(), }; // Parse the libc crate @@ -299,6 +301,7 @@ fn main() { // Walk the crate, emitting test cases for everything found visit::walk_crate(&mut tg, &krate); + tg.emit_run_all(); // Compile our C shim to be linked into tests let mut cfg = gcc::Config::new(); @@ -336,9 +339,10 @@ impl<'a> TestGenerator<'a> { let cty = self.rust_ty_to_c_ty(ty); self.test_size_align(ty, &cty); + self.tests.push(format!("field_offset_size_{}", ty)); t!(writeln!(self.rust, r#" - #[test] fn field_offset_size_{ty}() {{ + println!("verifying struct {ty}"); "#, ty = ty)); for field in s.fields.iter() { let name = match field.node.kind { @@ -385,20 +389,21 @@ impl<'a> TestGenerator<'a> { uint64_t __test_align_{ty}(void) {{ return alignof({cty}); }} "#, ty = rust, cty = c)); t!(writeln!(self.rust, r#" - #[test] fn size_align_{ty}() {{ extern {{ fn __test_size_{ty}() -> u64; fn __test_align_{ty}() -> u64; }} + println!("verifying type {ty} align/size"); unsafe {{ same(mem::size_of::<{ty}>() as u64, - __test_size_{ty}(), "size"); + __test_size_{ty}(), "{ty} size"); same(align::<{ty}>() as u64, - __test_align_{ty}(), "align"); + __test_align_{ty}(), "{ty} align"); }} }} "#, ty = rust)); + self.tests.push(format!("size_align_{}", rust)); } fn rust_ty_to_c_ty(&self, mut rust_ty: &str) -> String { @@ -440,21 +445,22 @@ impl<'a> TestGenerator<'a> { }} "#, name = name, cast = cast, cty = cty)); t!(writeln!(self.rust, r#" - #[test] fn const_{name}() {{ extern {{ fn __test_const_{name}(out: *mut {ty}) -> c_int; }} + println!("verifying const {name} value"); unsafe {{ let mut o = mem::zeroed(); if __test_const_{name}(&mut o) == 0 {{ - panic!("not defined"); + panic!("{name} not defined"); }} else {{ - same({name}, o, "value"); + same({name}, o, "{name} value"); }} }} }} "#, ty = rust_ty, name = name)); + self.tests.push(format!("const_{}", name)); } fn test_extern_fn(&mut self, name: &str, cname: &str, @@ -495,18 +501,19 @@ impl<'a> TestGenerator<'a> { }} "#, name = name, cname = cname, args = args, ret = cret, abi = abi)); t!(writeln!(self.rust, r#" - #[test] - #[cfg_attr(windows, ignore)] // FIXME -- dllimport weirdness? fn fn_{name}() {{ extern {{ fn __test_fn_{name}() -> size_t; }} + println!("verifying function {name} pointer"); unsafe {{ same({name} as usize, - __test_fn_{name}() as usize, "function pointer"); + __test_fn_{name}() as usize, + "{name} function pointer"); }} }} "#, name = name)); + self.tests.push(format!("fn_{}", name)); } fn assert_no_generics(&self, _i: ast::Ident, generics: &ast::Generics) { @@ -550,6 +557,24 @@ impl<'a> TestGenerator<'a> { }; (ret, args, decl.variadic) } + + fn emit_run_all(&mut self) { + t!(writeln!(self.rust, " + fn run_all() {{ + ")); + for test in self.tests.iter() { + if test.starts_with("fn_") { + // FIXME: weird dllimport issues with windows? + t!(writeln!(self.rust, "if cfg!(not(windows)) {{ {}(); }}", + test)); + } else { + t!(writeln!(self.rust, "{}();", test)); + } + } + t!(writeln!(self.rust, " + }} + ")); + } } impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index 42a743c4f3d20..c0f9eca7b6265 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -55,5 +55,10 @@ macro_rules! offset_of { ) } -#[cfg(test)] include!(concat!(env!("OUT_DIR"), "/all.rs")); + +fn main() { + println!("RUNNING ALL TESTS"); + run_all(); + println!("PASSED"); +} From b9ca2325e9979c0a41882cffbe63194f9ede53ea Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 23:33:57 -0700 Subject: [PATCH 076/194] Fix arm-linux compile --- src/linuxlike/linux.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/linuxlike/linux.rs b/src/linuxlike/linux.rs index 09e7f7a7a6a35..025470e691282 100644 --- a/src/linuxlike/linux.rs +++ b/src/linuxlike/linux.rs @@ -158,6 +158,7 @@ pub const O_SYNC: ::c_int = 1052672; pub const O_RSYNC: ::c_int = 1052672; pub const O_DSYNC: ::c_int = 4096; +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub const MAP_32BIT: ::c_int = 0x0040; pub const TCP_MD5SIG: ::c_int = 14; From 23ab70b3cb5e75dc76444cf564322ca48e4f18f1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 23:38:27 -0700 Subject: [PATCH 077/194] Add CI for ARM linux --- .travis.yml | 3 +++ ci/cargo-config | 3 +++ ci/run-travis.sh | 12 ++++++++++-- ci/run.sh | 2 ++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c01adeb952b0..8cb864c42122e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,9 @@ matrix: - os: linux env: TARGET=x86_64-unknown-linux-musl rust: nightly-2015-09-08 + - os: linux + env: TARGET=arm-unknown-linux-gnueabihf + rust: nightly-2015-09-08 addons: apt: packages: diff --git a/ci/cargo-config b/ci/cargo-config index f1d42a30d0299..40b79f0631a90 100644 --- a/ci/cargo-config +++ b/ci/cargo-config @@ -1,2 +1,5 @@ [target.arm-linux-androideabi] linker = "arm-linux-androideabi-gcc" + +[target.arm-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc-4.7" diff --git a/ci/run-travis.sh b/ci/run-travis.sh index a7d382f5e2851..5fa078662074b 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -11,14 +11,22 @@ export HOST=$ARCH-$OS # clang has better error messages and implements alignof more broadly export CC=clang +EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 + if [ "$TARGET" = "arm-linux-androideabi" ]; then # Pull a pre-built docker image for testing android, then run tests entirely # within that image. docker pull alexcrichton/rust-libc-test docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then - curl -s https://people.mozilla.org/~acrichton/libc-test/2015-09-08/x86_64-unknown-linux-musl.tar.gz | \ - tar xzf - -C $HOME/rust/lib/rustlib + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + sh ci/run.sh $TARGET +elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + sudo apt-get install gcc-4.7-arm-linux-gnueabihf + mkdir .cargo + cp ci/cargo-config .cargo/config + export CC=arm-linux-gnueabihf-gcc-4.7 sh ci/run.sh $TARGET else # Download and install the relevant target locally, then run tests diff --git a/ci/run.sh b/ci/run.sh index 3f1f3bfbe3a1b..9e3e97038e299 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -10,6 +10,8 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then adb wait-for-device adb push /root/target/$TARGET/debug/all-* /data/test adb shell /data/test +elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then + qemu-arm -L /usr/arm-linux-gnueabi /root/target/$TARGET/debug/all-* else cargo test --manifest-path libc-test/Cargo.toml --target $TARGET fi From 517b76a472fceca8afc2dbf68e65e37027c30076 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 23:53:31 -0700 Subject: [PATCH 078/194] Install qemu-user as well --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 5fa078662074b..ce29aa5a87752 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -23,7 +23,7 @@ elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then sh ci/run.sh $TARGET elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - sudo apt-get install gcc-4.7-arm-linux-gnueabihf + sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user mkdir .cargo cp ci/cargo-config .cargo/config export CC=arm-linux-gnueabihf-gcc-4.7 From 89bfb308deace64c827ffd28e2156fad83a0b585 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 13 Sep 2015 23:53:55 -0700 Subject: [PATCH 079/194] Tweak ordering --- .travis.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cb864c42122e..c0842f4e23a46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,16 @@ language: rust sudo: required +matrix: + include: + - os: linux + env: TARGET=arm-unknown-linux-gnueabihf + rust: nightly-2015-09-08 + - os: linux + env: TARGET=arm-linux-androideabi + rust: nightly-2015-09-08 + - os: linux + env: TARGET=x86_64-unknown-linux-musl + rust: nightly-2015-09-08 rust: - 1.0.0 - beta @@ -14,17 +25,6 @@ os: env: - ARCH=i686 - ARCH=x86_64 -matrix: - include: - - os: linux - env: TARGET=arm-linux-androideabi - rust: nightly-2015-09-08 - - os: linux - env: TARGET=x86_64-unknown-linux-musl - rust: nightly-2015-09-08 - - os: linux - env: TARGET=arm-unknown-linux-gnueabihf - rust: nightly-2015-09-08 addons: apt: packages: From 841962104e5f80350723cd1ea641184e9fdec8bd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 00:11:58 -0700 Subject: [PATCH 080/194] Revert "Tweak ordering" This reverts commit 89bfb308deace64c827ffd28e2156fad83a0b585. --- .travis.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0842f4e23a46..8cb864c42122e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,5 @@ language: rust sudo: required -matrix: - include: - - os: linux - env: TARGET=arm-unknown-linux-gnueabihf - rust: nightly-2015-09-08 - - os: linux - env: TARGET=arm-linux-androideabi - rust: nightly-2015-09-08 - - os: linux - env: TARGET=x86_64-unknown-linux-musl - rust: nightly-2015-09-08 rust: - 1.0.0 - beta @@ -25,6 +14,17 @@ os: env: - ARCH=i686 - ARCH=x86_64 +matrix: + include: + - os: linux + env: TARGET=arm-linux-androideabi + rust: nightly-2015-09-08 + - os: linux + env: TARGET=x86_64-unknown-linux-musl + rust: nightly-2015-09-08 + - os: linux + env: TARGET=arm-unknown-linux-gnueabihf + rust: nightly-2015-09-08 addons: apt: packages: From 0c784713d7d3c3b9263e4ffd7529fab9cc5073a0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 00:12:16 -0700 Subject: [PATCH 081/194] Try to fix arm linux again --- ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run.sh b/ci/run.sh index 9e3e97038e299..c0ef96ca7a2ad 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -11,7 +11,7 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then adb push /root/target/$TARGET/debug/all-* /data/test adb shell /data/test elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then - qemu-arm -L /usr/arm-linux-gnueabi /root/target/$TARGET/debug/all-* + qemu-arm -L /usr/arm-linux-gnueabi target/$TARGET/debug/all-* else cargo test --manifest-path libc-test/Cargo.toml --target $TARGET fi From e6280d8669b5d956aa3ed752e8e56c36500d48cc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 00:35:15 -0700 Subject: [PATCH 082/194] Let's try again! --- ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run.sh b/ci/run.sh index c0ef96ca7a2ad..1f58dc9701d4f 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -11,7 +11,7 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then adb push /root/target/$TARGET/debug/all-* /data/test adb shell /data/test elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then - qemu-arm -L /usr/arm-linux-gnueabi target/$TARGET/debug/all-* + qemu-arm -L /usr/arm-linux-gnueabi libc-test/target/$TARGET/debug/all-* else cargo test --manifest-path libc-test/Cargo.toml --target $TARGET fi From 2333a527345deed743aeaf679648335f1391b0dd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 00:56:58 -0700 Subject: [PATCH 083/194] Fix arm... yet again... --- ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run.sh b/ci/run.sh index 1f58dc9701d4f..c365af6d50f7f 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -11,7 +11,7 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then adb push /root/target/$TARGET/debug/all-* /data/test adb shell /data/test elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then - qemu-arm -L /usr/arm-linux-gnueabi libc-test/target/$TARGET/debug/all-* + qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/all-* else cargo test --manifest-path libc-test/Cargo.toml --target $TARGET fi From 4aecc614c7426ee85d655e686560dda65b341f56 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 11:05:30 -0700 Subject: [PATCH 084/194] Fix all defn's/compiling for mips linux --- src/linuxlike/b32/mips.rs | 40 +-- src/linuxlike/linux/mips.rs | 131 ++++++++++ src/linuxlike/{linux.rs => linux/mod.rs} | 30 +-- src/linuxlike/linux/other.rs | 147 +++++++++++ src/linuxlike/mips.rs | 316 ----------------------- src/linuxlike/mod.rs | 126 --------- 6 files changed, 308 insertions(+), 482 deletions(-) create mode 100644 src/linuxlike/linux/mips.rs rename src/linuxlike/{linux.rs => linux/mod.rs} (89%) create mode 100644 src/linuxlike/linux/other.rs delete mode 100644 src/linuxlike/mips.rs diff --git a/src/linuxlike/b32/mips.rs b/src/linuxlike/b32/mips.rs index 3c76e54271b1e..b20504e99b43b 100644 --- a/src/linuxlike/b32/mips.rs +++ b/src/linuxlike/b32/mips.rs @@ -8,26 +8,26 @@ pub type nlink_t = u32; s! { pub struct stat { - pub st_dev: c_ulong, - pub st_pad1: [c_long; 3], - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: c_ulong, - pub st_pad2: [c_long; 2], - pub st_size: off_t, - pub st_pad3: c_long, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_pad5: [c_long; 14], + pub st_dev: ::c_ulong, + pub st_pad1: [::c_long; 3], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, + pub st_pad2: [::c_long; 2], + pub st_size: ::off_t, + pub st_pad3: ::c_long, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_pad5: [::c_long; 14], } pub struct pthread_attr_t { diff --git a/src/linuxlike/linux/mips.rs b/src/linuxlike/linux/mips.rs new file mode 100644 index 0000000000000..1889fe9c89364 --- /dev/null +++ b/src/linuxlike/linux/mips.rs @@ -0,0 +1,131 @@ +pub const RLIMIT_NOFILE: ::c_int = 5; +pub const RLIMIT_AS: ::c_int = 6; +pub const RLIMIT_RSS: ::c_int = 7; +pub const RLIMIT_NPROC: ::c_int = 8; +pub const RLIMIT_MEMLOCK: ::c_int = 9; +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; + +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_NOCTTY: ::c_int = 2048; +pub const O_NONBLOCK: ::c_int = 128; +pub const O_SYNC: ::c_int = 0x10; +pub const O_RSYNC: ::c_int = 0x10; +pub const O_DSYNC: ::c_int = 0x10; + +pub const EDEADLK: ::c_int = 45; +pub const ENAMETOOLONG: ::c_int = 78; +pub const ENOLCK: ::c_int = 46; +pub const ENOSYS: ::c_int = 89; +pub const ENOTEMPTY: ::c_int = 93; +pub const ELOOP: ::c_int = 90; +pub const ENOMSG: ::c_int = 35; +pub const EIDRM: ::c_int = 36; +pub const ECHRNG: ::c_int = 37; +pub const EL2NSYNC: ::c_int = 38; +pub const EL3HLT: ::c_int = 39; +pub const EL3RST: ::c_int = 40; +pub const ELNRNG: ::c_int = 41; +pub const EUNATCH: ::c_int = 42; +pub const ENOCSI: ::c_int = 43; +pub const EL2HLT: ::c_int = 44; +pub const EBADE: ::c_int = 50; +pub const EBADR: ::c_int = 51; +pub const EXFULL: ::c_int = 52; +pub const ENOANO: ::c_int = 53; +pub const EBADRQC: ::c_int = 54; +pub const EBADSLT: ::c_int = 55; +pub const EDEADLOCK: ::c_int = 56; +pub const EMULTIHOP: ::c_int = 74; +pub const EOVERFLOW: ::c_int = 79; +pub const ENOTUNIQ: ::c_int = 80; +pub const EBADFD: ::c_int = 81; +pub const EBADMSG: ::c_int = 77; +pub const EREMCHG: ::c_int = 82; +pub const ELIBACC: ::c_int = 83; +pub const ELIBBAD: ::c_int = 84; +pub const ELIBSCN: ::c_int = 85; +pub const ELIBMAX: ::c_int = 86; +pub const ELIBEXEC: ::c_int = 87; +pub const EILSEQ: ::c_int = 88; +pub const ERESTART: ::c_int = 91; +pub const ESTRPIPE: ::c_int = 92; +pub const EUSERS: ::c_int = 94; +pub const ENOTSOCK: ::c_int = 95; +pub const EDESTADDRREQ: ::c_int = 96; +pub const EMSGSIZE: ::c_int = 97; +pub const EPROTOTYPE: ::c_int = 98; +pub const ENOPROTOOPT: ::c_int = 99; +pub const EPROTONOSUPPORT: ::c_int = 120; +pub const ESOCKTNOSUPPORT: ::c_int = 121; +pub const EOPNOTSUPP: ::c_int = 122; +pub const EPFNOSUPPORT: ::c_int = 123; +pub const EAFNOSUPPORT: ::c_int = 124; +pub const EADDRINUSE: ::c_int = 125; +pub const EADDRNOTAVAIL: ::c_int = 126; +pub const ENETDOWN: ::c_int = 127; +pub const ENETUNREACH: ::c_int = 128; +pub const ENETRESET: ::c_int = 129; +pub const ECONNABORTED: ::c_int = 130; +pub const ECONNRESET: ::c_int = 131; +pub const ENOBUFS: ::c_int = 132; +pub const EISCONN: ::c_int = 133; +pub const ENOTCONN: ::c_int = 134; +pub const ESHUTDOWN: ::c_int = 143; +pub const ETOOMANYREFS: ::c_int = 144; +pub const ETIMEDOUT: ::c_int = 145; +pub const ECONNREFUSED: ::c_int = 146; +pub const EHOSTDOWN: ::c_int = 147; +pub const EHOSTUNREACH: ::c_int = 148; +pub const EALREADY: ::c_int = 149; +pub const EINPROGRESS: ::c_int = 150; +pub const ESTALE: ::c_int = 151; +pub const EUCLEAN: ::c_int = 135; +pub const ENOTNAM: ::c_int = 137; +pub const ENAVAIL: ::c_int = 138; +pub const EISNAM: ::c_int = 139; +pub const EREMOTEIO: ::c_int = 140; +pub const EDQUOT: ::c_int = 1133; +pub const ENOMEDIUM: ::c_int = 159; +pub const EMEDIUMTYPE: ::c_int = 160; +pub const ECANCELED: ::c_int = 158; +pub const ENOKEY: ::c_int = 161; +pub const EKEYEXPIRED: ::c_int = 162; +pub const EKEYREVOKED: ::c_int = 163; +pub const EKEYREJECTED: ::c_int = 164; +pub const EOWNERDEAD: ::c_int = 165; +pub const ENOTRECOVERABLE: ::c_int = 166; +pub const ERFKILL: ::c_int = 167; + +pub const MAP_NORESERVE: ::c_int = 0x400; +pub const MAP_ANON: ::c_int = 0x800; +pub const MAP_ANONYMOUS: ::c_int = 0x800; +pub const MAP_GROWSDOWN: ::c_int = 0x1000; +pub const MAP_DENYWRITE: ::c_int = 0x2000; +pub const MAP_EXECUTABLE: ::c_int = 0x4000; +pub const MAP_LOCKED: ::c_int = 0x8000; +pub const MAP_POPULATE: ::c_int = 0x10000; +pub const MAP_NONBLOCK: ::c_int = 0x20000; + +pub const SOCK_STREAM: ::c_int = 2; +pub const SOCK_DGRAM: ::c_int = 1; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_REUSEADDR: ::c_int = 4; +pub const SO_TYPE: ::c_int = 4104; +pub const SO_ERROR: ::c_int = 4103; +pub const SO_DONTROUTE: ::c_int = 16; +pub const SO_BROADCAST: ::c_int = 32; +pub const SO_SNDBUF: ::c_int = 4097; +pub const SO_RCVBUF: ::c_int = 4098; +pub const SO_KEEPALIVE: ::c_int = 8; +pub const SO_OOBINLINE: ::c_int = 256; +pub const SO_LINGER: ::c_int = 128; +pub const SO_RCVLOWAT: ::c_int = 4100; +pub const SO_SNDLOWAT: ::c_int = 4099; +pub const SO_RCVTIMEO: ::c_int = 4102; +pub const SO_SNDTIMEO: ::c_int = 4101; +pub const SO_ACCEPTCONN: ::c_int = 4105; diff --git a/src/linuxlike/linux.rs b/src/linuxlike/linux/mod.rs similarity index 89% rename from src/linuxlike/linux.rs rename to src/linuxlike/linux/mod.rs index 025470e691282..7d508aeb0200b 100644 --- a/src/linuxlike/linux.rs +++ b/src/linuxlike/linux/mod.rs @@ -117,7 +117,6 @@ pub const _SC_XOPEN_LEGACY: ::c_int = 129; pub const _SC_XOPEN_REALTIME: ::c_int = 130; pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; -pub const RLIMIT_NLIMITS: ::c_int = 16; pub const RLIM_SAVED_MAX: ::rlim_t = ::RLIM_INFINITY; pub const RLIM_SAVED_CUR: ::rlim_t = ::RLIM_INFINITY; @@ -151,29 +150,10 @@ pub const F_TEST: ::c_int = 3; pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; -pub const ERFKILL: ::c_int = 132; -pub const EHWPOISON: ::c_int = 133; - -pub const O_SYNC: ::c_int = 1052672; -pub const O_RSYNC: ::c_int = 1052672; -pub const O_DSYNC: ::c_int = 4096; - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub const MAP_32BIT: ::c_int = 0x0040; pub const TCP_MD5SIG: ::c_int = 14; -pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; -pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; -pub const TCP_THIN_DUPACK: ::c_int = 17; -pub const TCP_USER_TIMEOUT: ::c_int = 18; -pub const TCP_REPAIR: ::c_int = 19; -pub const TCP_REPAIR_QUEUE: ::c_int = 20; -pub const TCP_QUEUE_SEQ: ::c_int = 21; -pub const TCP_REPAIR_OPTIONS: ::c_int = 22; -pub const TCP_FASTOPEN: ::c_int = 23; -pub const TCP_TIMESTAMP: ::c_int = 24; - -pub const SO_REUSEPORT: ::c_int = 15; cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "x86", @@ -183,3 +163,13 @@ cfg_if! { pub const PTHREAD_STACK_MIN: ::size_t = 131072; } } + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { + mod mips; + pub use self::mips::*; + } else { + mod other; + pub use self::other::*; + } +} diff --git a/src/linuxlike/linux/other.rs b/src/linuxlike/linux/other.rs new file mode 100644 index 0000000000000..9e4668a1a870e --- /dev/null +++ b/src/linuxlike/linux/other.rs @@ -0,0 +1,147 @@ +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_RTTIME: ::c_int = 15; +pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIM_INFINITY: ::rlim_t = !0; + +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; + +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const SOL_SOCKET: ::c_int = 1; + +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_LINGER: ::c_int = 13; +pub const SO_RCVLOWAT: ::c_int = 18; +pub const SO_SNDLOWAT: ::c_int = 19; +pub const SO_RCVTIMEO: ::c_int = 20; +pub const SO_SNDTIMEO: ::c_int = 21; +pub const SO_ACCEPTCONN: ::c_int = 30; + +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; +pub const TCP_THIN_DUPACK: ::c_int = 17; +pub const TCP_USER_TIMEOUT: ::c_int = 18; +pub const TCP_REPAIR: ::c_int = 19; +pub const TCP_REPAIR_QUEUE: ::c_int = 20; +pub const TCP_QUEUE_SEQ: ::c_int = 21; +pub const TCP_REPAIR_OPTIONS: ::c_int = 22; +pub const TCP_FASTOPEN: ::c_int = 23; +pub const TCP_TIMESTAMP: ::c_int = 24; + +pub const SO_REUSEPORT: ::c_int = 15; diff --git a/src/linuxlike/mips.rs b/src/linuxlike/mips.rs deleted file mode 100644 index d58481ad15ccc..0000000000000 --- a/src/linuxlike/mips.rs +++ /dev/null @@ -1,316 +0,0 @@ -//! MIPS-specific definitions for linux-like values - -pub const O_RDONLY: ::c_int = 0; -pub const O_WRONLY: ::c_int = 1; -pub const O_RDWR: ::c_int = 2; -pub const O_APPEND: ::c_int = 8; -pub const O_CREAT: ::c_int = 256; -pub const O_EXCL: ::c_int = 1024; -pub const O_NOCTTY: ::c_int = 2048; -pub const O_TRUNC: ::c_int = 512; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IEXEC: ::mode_t = 64; -pub const S_IWRITE: ::mode_t = 128; -pub const S_IREAD: ::mode_t = 256; -pub const S_IRWXU: ::mode_t = 448; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IRWXG: ::mode_t = 56; -pub const S_IXGRP: ::mode_t = 8; -pub const S_IWGRP: ::mode_t = 16; -pub const S_IRGRP: ::mode_t = 32; -pub const S_IRWXO: ::mode_t = 7; -pub const S_IXOTH: ::mode_t = 1; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IROTH: ::mode_t = 4; -pub const F_OK: ::c_int = 0; -pub const R_OK: ::c_int = 4; -pub const W_OK: ::c_int = 2; -pub const X_OK: ::c_int = 1; -pub const STDIN_FILENO: ::c_int = 0; -pub const STDOUT_FILENO: ::c_int = 1; -pub const STDERR_FILENO: ::c_int = 2; -pub const F_LOCK: ::c_int = 1; -pub const F_TEST: ::c_int = 3; -pub const F_TLOCK: ::c_int = 2; -pub const F_ULOCK: ::c_int = 0; -pub const SIGHUP: ::c_int = 1; -pub const SIGINT: ::c_int = 2; -pub const SIGQUIT: ::c_int = 3; -pub const SIGILL: ::c_int = 4; -pub const SIGABRT: ::c_int = 6; -pub const SIGFPE: ::c_int = 8; -pub const SIGKILL: ::c_int = 9; -pub const SIGSEGV: ::c_int = 11; -pub const SIGPIPE: ::c_int = 13; -pub const SIGALRM: ::c_int = 14; -pub const SIGTERM: ::c_int = 15; - -pub const PROT_NONE: ::c_int = 0; -pub const PROT_READ: ::c_int = 1; -pub const PROT_WRITE: ::c_int = 2; -pub const PROT_EXEC: ::c_int = 4; - -pub const MAP_FILE: ::c_int = 0x0000; -pub const MAP_SHARED: ::c_int = 0x0001; -pub const MAP_PRIVATE: ::c_int = 0x0002; -pub const MAP_FIXED: ::c_int = 0x0010; -pub const MAP_ANON: ::c_int = 0x0800; - -pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; - -pub const MCL_CURRENT: ::c_int = 0x0001; -pub const MCL_FUTURE: ::c_int = 0x0002; - -pub const MS_ASYNC: ::c_int = 0x0001; -pub const MS_INVALIDATE: ::c_int = 0x0002; -pub const MS_SYNC: ::c_int = 0x0004; - -pub const EPERM: ::c_int = 1; -pub const ENOENT: ::c_int = 2; -pub const ESRCH: ::c_int = 3; -pub const EINTR: ::c_int = 4; -pub const EIO: ::c_int = 5; -pub const ENXIO: ::c_int = 6; -pub const E2BIG: ::c_int = 7; -pub const ENOEXEC: ::c_int = 8; -pub const EBADF: ::c_int = 9; -pub const ECHILD: ::c_int = 10; -pub const EAGAIN: ::c_int = 11; -pub const ENOMEM: ::c_int = 12; -pub const EACCES: ::c_int = 13; -pub const EFAULT: ::c_int = 14; -pub const ENOTBLK: ::c_int = 15; -pub const EBUSY: ::c_int = 16; -pub const EEXIST: ::c_int = 17; -pub const EXDEV: ::c_int = 18; -pub const ENODEV: ::c_int = 19; -pub const ENOTDIR: ::c_int = 20; -pub const EISDIR: ::c_int = 21; -pub const EINVAL: ::c_int = 22; -pub const ENFILE: ::c_int = 23; -pub const EMFILE: ::c_int = 24; -pub const ENOTTY: ::c_int = 25; -pub const ETXTBSY: ::c_int = 26; -pub const EFBIG: ::c_int = 27; -pub const ENOSPC: ::c_int = 28; -pub const ESPIPE: ::c_int = 29; -pub const EROFS: ::c_int = 30; -pub const EMLINK: ::c_int = 31; -pub const EPIPE: ::c_int = 32; -pub const EDOM: ::c_int = 33; -pub const ERANGE: ::c_int = 34; - -pub const ENOMSG: ::c_int = 35; -pub const EIDRM: ::c_int = 36; -pub const ECHRNG: ::c_int = 37; -pub const EL2NSYNC: ::c_int = 38; -pub const EL3HLT: ::c_int = 39; -pub const EL3RST: ::c_int = 40; -pub const ELNRNG: ::c_int = 41; -pub const EUNATCH: ::c_int = 42; -pub const ENOCSI: ::c_int = 43; -pub const EL2HLT: ::c_int = 44; -pub const EDEADLK: ::c_int = 45; -pub const ENOLCK: ::c_int = 46; -pub const EBADE: ::c_int = 50; -pub const EBADR: ::c_int = 51; -pub const EXFULL: ::c_int = 52; -pub const ENOANO: ::c_int = 53; -pub const EBADRQC: ::c_int = 54; -pub const EBADSLT: ::c_int = 55; -pub const EDEADLOCK: ::c_int = 56; -pub const EBFONT: ::c_int = 59; -pub const ENOSTR: ::c_int = 60; -pub const ENODATA: ::c_int = 61; -pub const ETIME: ::c_int = 62; -pub const ENOSR: ::c_int = 63; -pub const ENONET: ::c_int = 64; -pub const ENOPKG: ::c_int = 65; -pub const EREMOTE: ::c_int = 66; -pub const ENOLINK: ::c_int = 67; -pub const EADV: ::c_int = 68; -pub const ESRMNT: ::c_int = 69; -pub const ECOMM: ::c_int = 70; -pub const EPROTO: ::c_int = 71; -pub const EDOTDOT: ::c_int = 73; -pub const EMULTIHOP: ::c_int = 74; -pub const EBADMSG: ::c_int = 77; -pub const ENAMETOOLONG: ::c_int = 78; -pub const EOVERFLOW: ::c_int = 79; -pub const ENOTUNIQ: ::c_int = 80; -pub const EBADFD: ::c_int = 81; -pub const EREMCHG: ::c_int = 82; -pub const ELIBACC: ::c_int = 83; -pub const ELIBBAD: ::c_int = 84; -pub const ELIBSCN: ::c_int = 95; -pub const ELIBMAX: ::c_int = 86; -pub const ELIBEXEC: ::c_int = 87; -pub const EILSEQ: ::c_int = 88; -pub const ENOSYS: ::c_int = 89; -pub const ELOOP: ::c_int = 90; -pub const ERESTART: ::c_int = 91; -pub const ESTRPIPE: ::c_int = 92; -pub const ENOTEMPTY: ::c_int = 93; -pub const EUSERS: ::c_int = 94; -pub const ENOTSOCK: ::c_int = 95; -pub const EDESTADDRREQ: ::c_int = 96; -pub const EMSGSIZE: ::c_int = 97; -pub const EPROTOTYPE: ::c_int = 98; -pub const ENOPROTOOPT: ::c_int = 99; -pub const EPROTONOSUPPORT: ::c_int = 120; -pub const ESOCKTNOSUPPORT: ::c_int = 121; -pub const EOPNOTSUPP: ::c_int = 122; -pub const EPFNOSUPPORT: ::c_int = 123; -pub const EAFNOSUPPORT: ::c_int = 124; -pub const EADDRINUSE: ::c_int = 125; -pub const EADDRNOTAVAIL: ::c_int = 126; -pub const ENETDOWN: ::c_int = 127; -pub const ENETUNREACH: ::c_int = 128; -pub const ENETRESET: ::c_int = 129; -pub const ECONNABORTED: ::c_int = 130; -pub const ECONNRESET: ::c_int = 131; -pub const ENOBUFS: ::c_int = 132; -pub const EISCONN: ::c_int = 133; -pub const ENOTCONN: ::c_int = 134; -pub const EUCLEAN: ::c_int = 135; -pub const ENOTNAM: ::c_int = 137; -pub const ENAVAIL: ::c_int = 138; -pub const EISNAM: ::c_int = 139; -pub const EREMOTEIO: ::c_int = 140; -pub const ESHUTDOWN: ::c_int = 143; -pub const ETOOMANYREFS: ::c_int = 144; -pub const ETIMEDOUT: ::c_int = 145; -pub const ECONNREFUSED: ::c_int = 146; -pub const EHOSTDOWN: ::c_int = 147; -pub const EHOSTUNREACH: ::c_int = 148; -pub const EWOULDBLOCK: ::c_int = EAGAIN; -pub const EALREADY: ::c_int = 149; -pub const EINPROGRESS: ::c_int = 150; -pub const ESTALE: ::c_int = 151; -pub const ECANCELED: ::c_int = 158; -pub const ENOMEDIUM: ::c_int = 159; -pub const EMEDIUMTYPE: ::c_int = 160; -pub const ENOKEY: ::c_int = 161; -pub const EKEYEXPIRED: ::c_int = 162; -pub const EKEYREVOKED: ::c_int = 163; -pub const EKEYREJECTED: ::c_int = 164; -pub const EOWNERDEAD: ::c_int = 165; -pub const ENOTRECOVERABLE: ::c_int = 166; -pub const ERFKILL: ::c_int = 167; -pub const EHWPOISON: ::c_int = 168; -pub const EDQUOT: ::c_int = 1133; - -pub const AF_PACKET: ::c_int = 17; -pub const IPPROTO_RAW: ::c_int = 255; - -pub const O_RSYNC: ::c_int = 16400; -pub const O_DSYNC: ::c_int = 16; -pub const O_NONBLOCK: ::c_int = 128; -pub const O_SYNC: ::c_int = 16400; - -pub const PROT_GROWSDOWN: ::c_int = 0x01000000; -pub const PROT_GROWSUP: ::c_int = 0x02000000; - -pub const MAP_TYPE: ::c_int = 0x000f; -pub const MAP_ANONYMOUS: ::c_int = 0x0800; -pub const MAP_GROWSDOWN: ::c_int = 0x01000; -pub const MAP_DENYWRITE: ::c_int = 0x02000; -pub const MAP_EXECUTABLE: ::c_int = 0x04000; -pub const MAP_LOCKED: ::c_int = 0x08000; -pub const MAP_NORESERVE: ::c_int = 0x0400; -pub const MAP_POPULATE: ::c_int = 0x010000; -pub const MAP_NONBLOCK: ::c_int = 0x020000; -pub const MAP_STACK: ::c_int = 0x040000; - -pub const MADV_NORMAL: ::c_int = 0; -pub const MADV_RANDOM: ::c_int = 1; -pub const MADV_SEQUENTIAL: ::c_int = 2; -pub const MADV_WILLNEED: ::c_int = 3; -pub const MADV_DONTNEED: ::c_int = 4; -pub const MADV_REMOVE: ::c_int = 9; -pub const MADV_DONTFORK: ::c_int = 10; -pub const MADV_DOFORK: ::c_int = 11; -pub const MADV_MERGEABLE: ::c_int = 12; -pub const MADV_UNMERGEABLE: ::c_int = 13; -pub const MADV_HWPOISON: ::c_int = 100; - -pub const AF_UNIX: ::c_int = 1; -pub const AF_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 10; -pub const SOCK_STREAM: ::c_int = 2; -pub const SOCK_DGRAM: ::c_int = 1; -pub const SOCK_RAW: ::c_int = 3; -pub const IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; -pub const IP_MULTICAST_TTL: ::c_int = 33; -pub const IP_MULTICAST_LOOP: ::c_int = 34; -pub const IP_TTL: ::c_int = 2; -pub const IP_HDRINCL: ::c_int = 3; -pub const IP_ADD_MEMBERSHIP: ::c_int = 35; -pub const IP_DROP_MEMBERSHIP: ::c_int = 36; -pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; -pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; - -pub const TCP_NODELAY: ::c_int = 1; -pub const TCP_MAXSEG: ::c_int = 2; -pub const TCP_CORK: ::c_int = 3; -pub const TCP_KEEPIDLE: ::c_int = 4; -pub const TCP_KEEPINTVL: ::c_int = 5; -pub const TCP_KEEPCNT: ::c_int = 6; -pub const TCP_SYNCNT: ::c_int = 7; -pub const TCP_LINGER2: ::c_int = 8; -pub const TCP_DEFER_ACCEPT: ::c_int = 9; -pub const TCP_WINDOW_CLAMP: ::c_int = 10; -pub const TCP_INFO: ::c_int = 11; -pub const TCP_QUICKACK: ::c_int = 12; -pub const TCP_CONGESTION: ::c_int = 13; -pub const TCP_MD5SIG: ::c_int = 14; -pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; -pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; -pub const TCP_THIN_DUPACK: ::c_int = 17; -pub const TCP_USER_TIMEOUT: ::c_int = 18; -pub const TCP_REPAIR: ::c_int = 19; -pub const TCP_REPAIR_QUEUE: ::c_int = 20; -pub const TCP_QUEUE_SEQ: ::c_int = 21; -pub const TCP_REPAIR_OPTIONS: ::c_int = 22; -pub const TCP_FASTOPEN: ::c_int = 23; -pub const TCP_TIMESTAMP: ::c_int = 24; - -pub const SOL_SOCKET: ::c_int = 65535; - -pub const SO_DEBUG: ::c_int = 0x0001; -pub const SO_REUSEADDR: ::c_int = 0x0004; -pub const SO_KEEPALIVE: ::c_int = 0x0008; -pub const SO_DONTROUTE: ::c_int = 0x0010; -pub const SO_BROADCAST: ::c_int = 0x0020; -pub const SO_LINGER: ::c_int = 0x0080; -pub const SO_OOBINLINE: ::c_int = 0x100; -pub const SO_REUSEPORT: ::c_int = 0x0200; -pub const SO_SNDBUF: ::c_int = 0x1001; -pub const SO_RCVBUF: ::c_int = 0x1002; -pub const SO_SNDLOWAT: ::c_int = 0x1003; -pub const SO_RCVLOWAT: ::c_int = 0x1004; -pub const SO_SNDTIMEO: ::c_int = 0x1005; -pub const SO_RCVTIMEO: ::c_int = 0x1006; -pub const SO_ERROR: ::c_int = 0x1007; -pub const SO_TYPE: ::c_int = 0x1008; -pub const SO_ACCEPTCONN: ::c_int = 0x1009; - -pub const SHUT_RD: ::c_int = 0; -pub const SHUT_WR: ::c_int = 1; -pub const SHUT_RDWR: ::c_int = 2; - -pub const LOCK_SH: ::c_int = 1; -pub const LOCK_EX: ::c_int = 2; -pub const LOCK_NB: ::c_int = 4; -pub const LOCK_UN: ::c_int = 8; diff --git a/src/linuxlike/mod.rs b/src/linuxlike/mod.rs index 47b1bf93adc8c..6c3bd90827bef 100644 --- a/src/linuxlike/mod.rs +++ b/src/linuxlike/mod.rs @@ -163,18 +163,11 @@ pub const RLIMIT_FSIZE: c_int = 1; pub const RLIMIT_DATA: c_int = 2; pub const RLIMIT_STACK: c_int = 3; pub const RLIMIT_CORE: c_int = 4; -pub const RLIMIT_RSS: c_int = 5; -pub const RLIMIT_NOFILE: c_int = 7; -pub const RLIMIT_AS: c_int = 9; -pub const RLIMIT_NPROC: c_int = 6; -pub const RLIMIT_MEMLOCK: c_int = 8; pub const RLIMIT_LOCKS: c_int = 10; pub const RLIMIT_SIGPENDING: c_int = 11; pub const RLIMIT_MSGQUEUE: c_int = 12; pub const RLIMIT_NICE: c_int = 13; pub const RLIMIT_RTPRIO: c_int = 14; -pub const RLIMIT_RTTIME: c_int = 15; -pub const RLIM_INFINITY: rlim_t = !0; pub const RUSAGE_SELF: c_int = 0; pub const RUSAGE_CHILDREN: c_int = -1; @@ -182,10 +175,6 @@ pub const RUSAGE_CHILDREN: c_int = -1; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; pub const O_TRUNC: ::c_int = 512; pub const S_IFIFO: ::mode_t = 4096; pub const S_IFCHR: ::mode_t = 8192; @@ -235,7 +224,6 @@ pub const MAP_FILE: ::c_int = 0x0000; pub const MAP_SHARED: ::c_int = 0x0001; pub const MAP_PRIVATE: ::c_int = 0x0002; pub const MAP_FIXED: ::c_int = 0x0010; -pub const MAP_ANON: ::c_int = 0x0020; pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; @@ -280,32 +268,7 @@ pub const EMLINK: ::c_int = 31; pub const EPIPE: ::c_int = 32; pub const EDOM: ::c_int = 33; pub const ERANGE: ::c_int = 34; - -pub const EDEADLK: ::c_int = 35; -pub const ENAMETOOLONG: ::c_int = 36; -pub const ENOLCK: ::c_int = 37; -pub const ENOSYS: ::c_int = 38; -pub const ENOTEMPTY: ::c_int = 39; -pub const ELOOP: ::c_int = 40; pub const EWOULDBLOCK: ::c_int = EAGAIN; -pub const ENOMSG: ::c_int = 42; -pub const EIDRM: ::c_int = 43; -pub const ECHRNG: ::c_int = 44; -pub const EL2NSYNC: ::c_int = 45; -pub const EL3HLT: ::c_int = 46; -pub const EL3RST: ::c_int = 47; -pub const ELNRNG: ::c_int = 48; -pub const EUNATCH: ::c_int = 49; -pub const ENOCSI: ::c_int = 50; -pub const EL2HLT: ::c_int = 51; -pub const EBADE: ::c_int = 52; -pub const EBADR: ::c_int = 53; -pub const EXFULL: ::c_int = 54; -pub const ENOANO: ::c_int = 55; -pub const EBADRQC: ::c_int = 56; -pub const EBADSLT: ::c_int = 57; - -pub const EDEADLOCK: ::c_int = EDEADLK; pub const EBFONT: ::c_int = 59; pub const ENOSTR: ::c_int = 60; @@ -320,85 +283,15 @@ pub const EADV: ::c_int = 68; pub const ESRMNT: ::c_int = 69; pub const ECOMM: ::c_int = 70; pub const EPROTO: ::c_int = 71; -pub const EMULTIHOP: ::c_int = 72; pub const EDOTDOT: ::c_int = 73; -pub const EBADMSG: ::c_int = 74; -pub const EOVERFLOW: ::c_int = 75; -pub const ENOTUNIQ: ::c_int = 76; -pub const EBADFD: ::c_int = 77; -pub const EREMCHG: ::c_int = 78; -pub const ELIBACC: ::c_int = 79; -pub const ELIBBAD: ::c_int = 80; -pub const ELIBSCN: ::c_int = 81; -pub const ELIBMAX: ::c_int = 82; -pub const ELIBEXEC: ::c_int = 83; -pub const EILSEQ: ::c_int = 84; -pub const ERESTART: ::c_int = 85; -pub const ESTRPIPE: ::c_int = 86; -pub const EUSERS: ::c_int = 87; -pub const ENOTSOCK: ::c_int = 88; -pub const EDESTADDRREQ: ::c_int = 89; -pub const EMSGSIZE: ::c_int = 90; -pub const EPROTOTYPE: ::c_int = 91; -pub const ENOPROTOOPT: ::c_int = 92; -pub const EPROTONOSUPPORT: ::c_int = 93; -pub const ESOCKTNOSUPPORT: ::c_int = 94; -pub const EOPNOTSUPP: ::c_int = 95; -pub const EPFNOSUPPORT: ::c_int = 96; -pub const EAFNOSUPPORT: ::c_int = 97; -pub const EADDRINUSE: ::c_int = 98; -pub const EADDRNOTAVAIL: ::c_int = 99; -pub const ENETDOWN: ::c_int = 100; -pub const ENETUNREACH: ::c_int = 101; -pub const ENETRESET: ::c_int = 102; -pub const ECONNABORTED: ::c_int = 103; -pub const ECONNRESET: ::c_int = 104; -pub const ENOBUFS: ::c_int = 105; -pub const EISCONN: ::c_int = 106; -pub const ENOTCONN: ::c_int = 107; -pub const ESHUTDOWN: ::c_int = 108; -pub const ETOOMANYREFS: ::c_int = 109; -pub const ETIMEDOUT: ::c_int = 110; -pub const ECONNREFUSED: ::c_int = 111; -pub const EHOSTDOWN: ::c_int = 112; -pub const EHOSTUNREACH: ::c_int = 113; -pub const EALREADY: ::c_int = 114; -pub const EINPROGRESS: ::c_int = 115; -pub const ESTALE: ::c_int = 116; -pub const EUCLEAN: ::c_int = 117; -pub const ENOTNAM: ::c_int = 118; -pub const ENAVAIL: ::c_int = 119; -pub const EISNAM: ::c_int = 120; -pub const EREMOTEIO: ::c_int = 121; -pub const EDQUOT: ::c_int = 122; -pub const ENOMEDIUM: ::c_int = 123; -pub const EMEDIUMTYPE: ::c_int = 124; -pub const ECANCELED: ::c_int = 125; -pub const ENOKEY: ::c_int = 126; -pub const EKEYEXPIRED: ::c_int = 127; -pub const EKEYREVOKED: ::c_int = 128; -pub const EKEYREJECTED: ::c_int = 129; -pub const EOWNERDEAD: ::c_int = 130; -pub const ENOTRECOVERABLE: ::c_int = 131; pub const AF_PACKET: ::c_int = 17; pub const IPPROTO_RAW: ::c_int = 255; -pub const O_NONBLOCK: ::c_int = 2048; - pub const PROT_GROWSDOWN: ::c_int = 0x1000000; pub const PROT_GROWSUP: ::c_int = 0x2000000; pub const MAP_TYPE: ::c_int = 0x000f; -pub const MAP_ANONYMOUS: ::c_int = 0x0020; -pub const MAP_GROWSDOWN: ::c_int = 0x0100; -pub const MAP_DENYWRITE: ::c_int = 0x0800; -pub const MAP_EXECUTABLE: ::c_int = 0x01000; -pub const MAP_LOCKED: ::c_int = 0x02000; -pub const MAP_NORESERVE: ::c_int = 0x04000; -pub const MAP_POPULATE: ::c_int = 0x08000; -pub const MAP_NONBLOCK: ::c_int = 0x010000; -pub const MAP_STACK: ::c_int = 0x020000; pub const MADV_NORMAL: ::c_int = 0; pub const MADV_RANDOM: ::c_int = 1; @@ -417,8 +310,6 @@ pub const IFF_LOOPBACK: ::c_int = 0x8; pub const AF_UNIX: ::c_int = 1; pub const AF_INET: ::c_int = 2; pub const AF_INET6: ::c_int = 10; -pub const SOCK_STREAM: ::c_int = 1; -pub const SOCK_DGRAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 3; pub const IPPROTO_TCP: ::c_int = 6; pub const IPPROTO_IP: ::c_int = 0; @@ -446,24 +337,7 @@ pub const TCP_INFO: ::c_int = 11; pub const TCP_QUICKACK: ::c_int = 12; pub const TCP_CONGESTION: ::c_int = 13; -pub const SOL_SOCKET: ::c_int = 1; - pub const SO_DEBUG: ::c_int = 1; -pub const SO_REUSEADDR: ::c_int = 2; -pub const SO_TYPE: ::c_int = 3; -pub const SO_ERROR: ::c_int = 4; -pub const SO_DONTROUTE: ::c_int = 5; -pub const SO_BROADCAST: ::c_int = 6; -pub const SO_SNDBUF: ::c_int = 7; -pub const SO_RCVBUF: ::c_int = 8; -pub const SO_KEEPALIVE: ::c_int = 9; -pub const SO_OOBINLINE: ::c_int = 10; -pub const SO_LINGER: ::c_int = 13; -pub const SO_RCVLOWAT: ::c_int = 18; -pub const SO_SNDLOWAT: ::c_int = 19; -pub const SO_RCVTIMEO: ::c_int = 20; -pub const SO_SNDTIMEO: ::c_int = 21; -pub const SO_ACCEPTCONN: ::c_int = 30; pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; From 8fc95d25d4dc73a9353c58be04a3fbac4b13f984 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 11:06:20 -0700 Subject: [PATCH 085/194] Get tests for mips passing --- libc-test/build.rs | 8 ++++++-- libc-test/tests/all.rs | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 60e8927b3540f..04a34b1fcb707 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -54,7 +54,7 @@ impl<'a> TestGenerator<'a> { } // android also doesn't have stdalign.h so get alignof ourselves - if self.target.contains("android") { + if self.target.contains("android") || self.target.contains("mips") { ret.push("alignof __alignof__"); } @@ -134,7 +134,9 @@ impl<'a> TestGenerator<'a> { } else { base.push("glob.h"); base.push("ifaddrs.h"); - base.push("stdalign.h"); + if !self.target.contains("mips") { + base.push("stdalign.h"); + } base.push("sys/sysctl.h"); } } @@ -209,6 +211,8 @@ impl<'a> TestGenerator<'a> { ("x86", "32") } else if self.target.starts_with("arm") { ("arm", "32") + } else if self.target.starts_with("mips") { + ("mips", "32") } else { panic!("unknown arch/pointer width: {}", self.target) }; diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs index c0f9eca7b6265..a2f4daf70fe80 100644 --- a/libc-test/tests/all.rs +++ b/libc-test/tests/all.rs @@ -27,9 +27,12 @@ macro_rules! p { } p! { i8 i16 i32 i64 u8 u16 u32 u64 usize isize } +static mut FAILED: bool = false; + fn same(rust: T, c: T, attr: &str) { if rust != c { - panic!("bad {}: rust: {} != c {}", attr, rust.pretty(), c.pretty()); + println!("bad {}: rust: {} != c {}", attr, rust.pretty(), c.pretty()); + unsafe { FAILED = true; } } } @@ -60,5 +63,11 @@ include!(concat!(env!("OUT_DIR"), "/all.rs")); fn main() { println!("RUNNING ALL TESTS"); run_all(); - println!("PASSED"); + unsafe { + if FAILED { + panic!("some tests failed"); + } else { + println!("PASSED"); + } + } } From 944a7334264ce4d4536541f3ba55d60d459710eb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 11:27:10 -0700 Subject: [PATCH 086/194] Run MIPS on CI --- .travis.yml | 3 +++ ci/cargo-config | 3 +++ ci/run-travis.sh | 22 ++++++++++++++++------ ci/run.sh | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8cb864c42122e..e37ff6b203353 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,9 @@ matrix: - os: linux env: TARGET=arm-unknown-linux-gnueabihf rust: nightly-2015-09-08 + - os: linux + env: TARGET=mips-unknown-linux-gnu + rust: nightly-2015-09-08 addons: apt: packages: diff --git a/ci/cargo-config b/ci/cargo-config index 40b79f0631a90..5cf69a7ae1662 100644 --- a/ci/cargo-config +++ b/ci/cargo-config @@ -3,3 +3,6 @@ linker = "arm-linux-androideabi-gcc" [target.arm-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc-4.7" + +[target.arm-linux-androideabi] +linker = "mips-linux-gnu-gcc" diff --git a/ci/run-travis.sh b/ci/run-travis.sh index ce29aa5a87752..751e186190b52 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -17,17 +17,23 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then # Pull a pre-built docker image for testing android, then run tests entirely # within that image. docker pull alexcrichton/rust-libc-test - docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test sh ci/run.sh $TARGET + exec docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test \ + sh ci/run.sh $TARGET elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - sh ci/run.sh $TARGET elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user - mkdir .cargo - cp ci/cargo-config .cargo/config export CC=arm-linux-gnueabihf-gcc-4.7 - sh ci/run.sh $TARGET +elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + echo 'deb http://ftp.de.debian.org/debian squeeze main' | \ + sudo tee -a /etc/apt/sources.list + echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ + sudo tee -a /etc/apt/sources.list + sudo apt-get update + sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu + export CC=mips-linux-gnu-gcc else # Download and install the relevant target locally, then run tests curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz @@ -35,5 +41,9 @@ else rm -rf $HOME/rust/lib/rustlib/$HOST mv rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST \ $HOME/rust/lib/rustlib - sh ci/run.sh $HOST + TARGET=$HOST fi + +mkdir .cargo +cp ci/cargo-config .cargo/config +sh ci/run.sh $TARGET diff --git a/ci/run.sh b/ci/run.sh index c365af6d50f7f..43f13b62e329b 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -12,6 +12,8 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then adb shell /data/test elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/all-* +elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then + qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-* else cargo test --manifest-path libc-test/Cargo.toml --target $TARGET fi From 947d67573dc19427be2aec3d39b214787d13fe25 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 11:34:22 -0700 Subject: [PATCH 087/194] Fix cargo config --- ci/cargo-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/cargo-config b/ci/cargo-config index 5cf69a7ae1662..4a588ccd200e8 100644 --- a/ci/cargo-config +++ b/ci/cargo-config @@ -4,5 +4,5 @@ linker = "arm-linux-androideabi-gcc" [target.arm-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc-4.7" -[target.arm-linux-androideabi] +[target.mip-unknown-linux-gnu] linker = "mips-linux-gnu-gcc" From ac5ba005b4abf7fad195a4f1fe77f9ee22ba6d06 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 11:49:09 -0700 Subject: [PATCH 088/194] Attempt another package on mips --- ci/run-travis.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 751e186190b52..d349d3b54bfa4 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -32,6 +32,7 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ sudo tee -a /etc/apt/sources.list sudo apt-get update + sudo apt-get install emdebian-archive-keyring sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu export CC=mips-linux-gnu-gcc else From 86c7c4398d46b9a62006f09d7dbb740e9b1ebbd8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 12:58:03 -0700 Subject: [PATCH 089/194] Really install mips gcc --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index d349d3b54bfa4..1b72605365b17 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -33,7 +33,7 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then sudo tee -a /etc/apt/sources.list sudo apt-get update sudo apt-get install emdebian-archive-keyring - sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu + sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes export CC=mips-linux-gnu-gcc else # Download and install the relevant target locally, then run tests From 4a62f6111f7765544be3268d33916227aae87629 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 13:18:35 -0700 Subject: [PATCH 090/194] I can spell MIPS --- ci/cargo-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/cargo-config b/ci/cargo-config index 4a588ccd200e8..575bdacdbf1fe 100644 --- a/ci/cargo-config +++ b/ci/cargo-config @@ -4,5 +4,5 @@ linker = "arm-linux-androideabi-gcc" [target.arm-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc-4.7" -[target.mip-unknown-linux-gnu] +[target.mips-unknown-linux-gnu] linker = "mips-linux-gnu-gcc" From a4d78c4d0a5d58a16cccfaf78eb544e4464e1dd3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 13:52:51 -0700 Subject: [PATCH 091/194] Refactor with fewer intermediate artifacts --- ci/run-travis.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 1b72605365b17..ebff423c0a786 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -8,9 +8,7 @@ fi export HOST=$ARCH-$OS -# clang has better error messages and implements alignof more broadly -export CC=clang - +MAIN_TARGETS=https://static.rust-lang.org/dist/ EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 if [ "$TARGET" = "arm-linux-androideabi" ]; then @@ -26,7 +24,11 @@ elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user export CC=arm-linux-gnueabihf-gcc-4.7 elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then + # Download pre-built and custom MIPS libs and then also instsall the MIPS + # compiler according to this post: + # http://sathisharada.blogspot.com/2014_10_01_archive.html curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + echo 'deb http://ftp.de.debian.org/debian squeeze main' | \ sudo tee -a /etc/apt/sources.list echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ @@ -36,13 +38,15 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes export CC=mips-linux-gnu-gcc else - # Download and install the relevant target locally, then run tests - curl -sO https://static.rust-lang.org/dist/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz - tar xf rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz - rm -rf $HOME/rust/lib/rustlib/$HOST - mv rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST \ - $HOME/rust/lib/rustlib + # Download the rustlib folder from the relevant portion of main distribution's + # tarballs. + curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ + tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ + rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST TARGET=$HOST + + # clang has better error messages and implements alignof more broadly + export CC=clang fi mkdir .cargo From 2fe6de47c45a80e7a549554198002ef5968f450a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 14:07:49 -0700 Subject: [PATCH 092/194] Remove trailing slash --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index ebff423c0a786..20aec65091c19 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -8,7 +8,7 @@ fi export HOST=$ARCH-$OS -MAIN_TARGETS=https://static.rust-lang.org/dist/ +MAIN_TARGETS=https://static.rust-lang.org/dist EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 if [ "$TARGET" = "arm-linux-androideabi" ]; then From 213c629852ac5caefbcbd138007084930330895b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 14:41:36 -0700 Subject: [PATCH 093/194] Move Dockerfile to ci folder --- Dockerfile => ci/Dockerfile-android | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Dockerfile => ci/Dockerfile-android (100%) diff --git a/Dockerfile b/ci/Dockerfile-android similarity index 100% rename from Dockerfile rename to ci/Dockerfile-android From 412d4f931970bfdfa603c6ce09597cf595d7cd02 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 17:33:40 -0700 Subject: [PATCH 094/194] OK, don't actually run mips for now... --- ci/run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/run.sh b/ci/run.sh index 43f13b62e329b..11292a340fff0 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -13,7 +13,8 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/all-* elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then - qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-* + # FIXME: this segfaults on travis, passes locally? + #qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-* else cargo test --manifest-path libc-test/Cargo.toml --target $TARGET fi From 17da63d4ef0ed4e6722599abd7ff7f8d98c809a2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Sep 2015 17:52:07 -0700 Subject: [PATCH 095/194] I hate shell --- ci/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/run.sh b/ci/run.sh index 11292a340fff0..368037b26759e 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -15,6 +15,7 @@ elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then # FIXME: this segfaults on travis, passes locally? #qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-* + echo skip else cargo test --manifest-path libc-test/Cargo.toml --target $TARGET fi From e04155fa43f91ed73c4c141770f757976c758254 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 10:15:18 -0700 Subject: [PATCH 096/194] Get FreeBSD compiling --- src/freebsdlike.rs | 823 ----------------------------------- src/freebsdlike/dragonfly.rs | 2 + src/freebsdlike/freebsd.rs | 2 + src/freebsdlike/mod.rs | 577 ++++++++++++++++++++++++ src/freebsdlike/x86.rs | 64 +++ src/freebsdlike/x86_64.rs | 63 +++ 6 files changed, 708 insertions(+), 823 deletions(-) delete mode 100644 src/freebsdlike.rs create mode 100644 src/freebsdlike/dragonfly.rs create mode 100644 src/freebsdlike/freebsd.rs create mode 100644 src/freebsdlike/mod.rs create mode 100644 src/freebsdlike/x86.rs create mode 100644 src/freebsdlike/x86_64.rs diff --git a/src/freebsdlike.rs b/src/freebsdlike.rs deleted file mode 100644 index a5c228cdfd0a5..0000000000000 --- a/src/freebsdlike.rs +++ /dev/null @@ -1,823 +0,0 @@ - - #[cfg(target_os = "freebsd")] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, size_t, - time_t, suseconds_t, c_long}; - use types::os::arch::c99::{uintptr_t}; - - pub type pthread_t = uintptr_t; - pub type rlim_t = i64; - - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: size_t, - __unused1: size_t, - pub gl_offs: size_t, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, - - __unused3: *mut c_void, - - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u8; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - - - } - } - - #[cfg(target_arch = "x86")] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i32; - pub type c_ulong = u32; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u32; - pub type ptrdiff_t = i32; - pub type clock_t = i32; - pub type time_t = i32; - pub type suseconds_t = i32; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i32; - pub type uintptr_t = u32; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - pub type off_t = i64; - pub type dev_t = u32; - pub type ino_t = u32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = i32; - } - pub mod posix01 { - use types::common::c95::{c_void}; - use types::common::c99::{uint32_t, int32_t}; - use types::os::arch::c95::{c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = u32; - pub type blkcnt_t = i64; - pub type fflags_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: fflags_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - __unused: [u8; 8], - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - pub type pthread_attr_t = *mut c_void; - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - } - } - - #[cfg(target_arch = "x86_64")] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = i32; - pub type time_t = i64; - pub type suseconds_t = i64; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - pub type off_t = i64; - pub type dev_t = u32; - pub type ino_t = u32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u16; - pub type ssize_t = i64; - } - pub mod posix01 { - use types::common::c95::{c_void}; - use types::common::c99::{uint32_t, int32_t}; - use types::os::arch::c95::{c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t, ino_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = u16; - pub type blksize_t = u32; - pub type blkcnt_t = i64; - pub type fflags_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: fflags_t, - pub st_gen: uint32_t, - pub st_lspare: int32_t, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - pub type pthread_attr_t = *mut c_void; - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - } - } - } - #[cfg(any(target_os = "freebsd", - target_os = "dragonfly"))] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 2147483647; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 2; - pub const _IOLBF : c_int = 1; - pub const BUFSIZ : c_uint = 1024; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 1024; - pub const L_tmpnam : c_uint = 1024; - pub const TMP_MAX : c_uint = 308915776; - } - pub mod c99 { - } - pub mod posix88 { - use types::common::c95::c_void; - use types::os::arch::c95::c_int; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 512; - pub const O_EXCL : c_int = 2048; - pub const O_NOCTTY : c_int = 32768; - pub const O_TRUNC : c_int = 1024; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x1000; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_SYNC : c_int = 0x0000; - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_INVALIDATE : c_int = 0x0002; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EDEADLK : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - pub const EAGAIN : c_int = 35; - pub const EWOULDBLOCK : c_int = 35; - pub const EINPROGRESS : c_int = 36; - pub const EALREADY : c_int = 37; - pub const ENOTSOCK : c_int = 38; - pub const EDESTADDRREQ : c_int = 39; - pub const EMSGSIZE : c_int = 40; - pub const EPROTOTYPE : c_int = 41; - pub const ENOPROTOOPT : c_int = 42; - pub const EPROTONOSUPPORT : c_int = 43; - pub const ESOCKTNOSUPPORT : c_int = 44; - pub const EOPNOTSUPP : c_int = 45; - pub const EPFNOSUPPORT : c_int = 46; - pub const EAFNOSUPPORT : c_int = 47; - pub const EADDRINUSE : c_int = 48; - pub const EADDRNOTAVAIL : c_int = 49; - pub const ENETDOWN : c_int = 50; - pub const ENETUNREACH : c_int = 51; - pub const ENETRESET : c_int = 52; - pub const ECONNABORTED : c_int = 53; - pub const ECONNRESET : c_int = 54; - pub const ENOBUFS : c_int = 55; - pub const EISCONN : c_int = 56; - pub const ENOTCONN : c_int = 57; - pub const ESHUTDOWN : c_int = 58; - pub const ETOOMANYREFS : c_int = 59; - pub const ETIMEDOUT : c_int = 60; - pub const ECONNREFUSED : c_int = 61; - pub const ELOOP : c_int = 62; - pub const ENAMETOOLONG : c_int = 63; - pub const EHOSTDOWN : c_int = 64; - pub const EHOSTUNREACH : c_int = 65; - pub const ENOTEMPTY : c_int = 66; - pub const EPROCLIM : c_int = 67; - pub const EUSERS : c_int = 68; - pub const EDQUOT : c_int = 69; - pub const ESTALE : c_int = 70; - pub const EREMOTE : c_int = 71; - pub const EBADRPC : c_int = 72; - pub const ERPCMISMATCH : c_int = 73; - pub const EPROGUNAVAIL : c_int = 74; - pub const EPROGMISMATCH : c_int = 75; - pub const EPROCUNAVAIL : c_int = 76; - pub const ENOLCK : c_int = 77; - pub const ENOSYS : c_int = 78; - pub const EFTYPE : c_int = 79; - pub const EAUTH : c_int = 80; - pub const ENEEDAUTH : c_int = 81; - pub const EIDRM : c_int = 82; - pub const ENOMSG : c_int = 83; - pub const EOVERFLOW : c_int = 84; - pub const ECANCELED : c_int = 85; - pub const EILSEQ : c_int = 86; - pub const ENOATTR : c_int = 87; - pub const EDOOFUS : c_int = 88; - pub const EBADMSG : c_int = 89; - pub const EMULTIHOP : c_int = 90; - pub const ENOLINK : c_int = 91; - pub const EPROTO : c_int = 92; - pub const ENOMEDIUM : c_int = 93; - pub const EUNUSED94 : c_int = 94; - pub const EUNUSED95 : c_int = 95; - pub const EUNUSED96 : c_int = 96; - pub const EUNUSED97 : c_int = 97; - pub const EUNUSED98 : c_int = 98; - pub const EASYNC : c_int = 99; - pub const ELAST : c_int = 99; - } - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - - pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; - - pub const GLOB_APPEND : c_int = 0x0001; - pub const GLOB_DOOFFS : c_int = 0x0002; - pub const GLOB_ERR : c_int = 0x0004; - pub const GLOB_MARK : c_int = 0x0008; - pub const GLOB_NOCHECK : c_int = 0x0010; - pub const GLOB_NOSORT : c_int = 0x0020; - pub const GLOB_NOESCAPE : c_int = 0x2000; - - pub const GLOB_NOSPACE : c_int = -1; - pub const GLOB_ABORTED : c_int = -2; - pub const GLOB_NOMATCH : c_int = -3; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_IOV_MAX : c_int = 56; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 70; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 71; - pub const _SC_LOGIN_NAME_MAX : c_int = 73; - pub const _SC_MQ_PRIO_MAX : c_int = 75; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 82; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 83; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 85; - pub const _SC_THREAD_KEYS_MAX : c_int = 86; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 87; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 88; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 89; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 90; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 91; - pub const _SC_THREAD_STACK_MIN : c_int = 93; - pub const _SC_THREAD_THREADS_MAX : c_int = 94; - pub const _SC_THREADS : c_int = 96; - pub const _SC_TTY_NAME_MAX : c_int = 101; - pub const _SC_ATEXIT_MAX : c_int = 107; - pub const _SC_XOPEN_CRYPT : c_int = 108; - pub const _SC_XOPEN_ENH_I18N : c_int = 109; - pub const _SC_XOPEN_LEGACY : c_int = 110; - pub const _SC_XOPEN_REALTIME : c_int = 111; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 112; - pub const _SC_XOPEN_SHM : c_int = 113; - pub const _SC_XOPEN_UNIX : c_int = 115; - pub const _SC_XOPEN_VERSION : c_int = 116; - pub const _SC_XOPEN_XCU_VERSION : c_int = 117; - - pub const PTHREAD_CREATE_JOINABLE: c_int = 0; - pub const PTHREAD_CREATE_DETACHED: c_int = 1; - - #[cfg(target_arch = "arm")] - pub const PTHREAD_STACK_MIN: size_t = 4096; - - #[cfg(all(target_os = "freebsd", - any(target_arch = "mips", - target_arch = "mipsel", - target_arch = "x86", - target_arch = "x86_64")))] - pub const PTHREAD_STACK_MIN: size_t = 2048; - - #[cfg(target_os = "dragonfly")] - pub const PTHREAD_STACK_MIN: size_t = 1024; - - pub const CLOCK_REALTIME: c_int = 0; - pub const CLOCK_MONOTONIC: c_int = 4; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_RSS: c_int = 5; - pub const RLIMIT_MEMLOCK: c_int = 6; - pub const RLIMIT_NPROC: c_int = 7; - pub const RLIMIT_NOFILE: c_int = 8; - pub const RLIMIT_SBSIZE: c_int = 9; - pub const RLIMIT_VMEM: c_int = 10; - pub const RLIMIT_AS: c_int = RLIMIT_VMEM; - pub const RLIMIT_NPTS: c_int = 11; - pub const RLIMIT_SWAP: c_int = 12; - pub const RLIMIT_KQUEUES: c_int = 13; - - pub const RLIM_NLIMITS: rlim_t = 14; - pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - pub const RUSAGE_THREAD: c_int = 1; - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_FREE : c_int = 5; - pub const MADV_NOSYNC : c_int = 6; - pub const MADV_AUTOSYNC : c_int = 7; - pub const MADV_NOCORE : c_int = 8; - pub const MADV_CORE : c_int = 9; - pub const MADV_PROTECT : c_int = 10; - - pub const MINCORE_INCORE : c_int = 0x1; - pub const MINCORE_REFERENCED : c_int = 0x2; - pub const MINCORE_MODIFIED : c_int = 0x4; - pub const MINCORE_REFERENCED_OTHER : c_int = 0x8; - pub const MINCORE_MODIFIED_OTHER : c_int = 0x10; - pub const MINCORE_SUPER : c_int = 0x20; - - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 28; - pub const AF_UNIX: c_int = 1; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 12; - pub const IPV6_DROP_MEMBERSHIP: c_int = 13; - - pub const TCP_NODELAY: c_int = 1; - pub const TCP_KEEPIDLE: c_int = 256; - pub const SOL_SOCKET: c_int = 0xffff; - pub const SO_DEBUG: c_int = 0x01; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_REUSEPORT: c_int = 0x0200; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 0x8; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - pub mod extra { - use types::os::arch::c95::c_int; - - pub const O_SYNC : c_int = 128; - pub const O_NONBLOCK : c_int = 4; - pub const CTL_KERN: c_int = 1; - pub const KERN_PROC: c_int = 14; - #[cfg(target_os = "freebsd")] - pub const KERN_PROC_PATHNAME: c_int = 12; - #[cfg(target_os = "dragonfly")] - pub const KERN_PROC_PATHNAME: c_int = 9; - - pub const MAP_COPY : c_int = 0x0002; - pub const MAP_RENAME : c_int = 0x0020; - pub const MAP_NORESERVE : c_int = 0x0040; - pub const MAP_HASSEMAPHORE : c_int = 0x0200; - pub const MAP_STACK : c_int = 0x0400; - pub const MAP_NOSYNC : c_int = 0x0800; - pub const MAP_NOCORE : c_int = 0x020000; - - pub const IPPROTO_RAW : c_int = 255; - } - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 1; - pub const _SC_CHILD_MAX : c_int = 2; - pub const _SC_CLK_TCK : c_int = 3; - pub const _SC_NGROUPS_MAX : c_int = 4; - pub const _SC_OPEN_MAX : c_int = 5; - pub const _SC_JOB_CONTROL : c_int = 6; - pub const _SC_SAVED_IDS : c_int = 7; - pub const _SC_VERSION : c_int = 8; - pub const _SC_BC_BASE_MAX : c_int = 9; - pub const _SC_BC_DIM_MAX : c_int = 10; - pub const _SC_BC_SCALE_MAX : c_int = 11; - pub const _SC_BC_STRING_MAX : c_int = 12; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; - pub const _SC_EXPR_NEST_MAX : c_int = 14; - pub const _SC_LINE_MAX : c_int = 15; - pub const _SC_RE_DUP_MAX : c_int = 16; - pub const _SC_2_VERSION : c_int = 17; - pub const _SC_2_C_BIND : c_int = 18; - pub const _SC_2_C_DEV : c_int = 19; - pub const _SC_2_CHAR_TERM : c_int = 20; - pub const _SC_2_FORT_DEV : c_int = 21; - pub const _SC_2_FORT_RUN : c_int = 22; - pub const _SC_2_LOCALEDEF : c_int = 23; - pub const _SC_2_SW_DEV : c_int = 24; - pub const _SC_2_UPE : c_int = 25; - pub const _SC_STREAM_MAX : c_int = 26; - pub const _SC_TZNAME_MAX : c_int = 27; - pub const _SC_ASYNCHRONOUS_IO : c_int = 28; - pub const _SC_MAPPED_FILES : c_int = 29; - pub const _SC_MEMLOCK : c_int = 30; - pub const _SC_MEMLOCK_RANGE : c_int = 31; - pub const _SC_MEMORY_PROTECTION : c_int = 32; - pub const _SC_MESSAGE_PASSING : c_int = 33; - pub const _SC_PRIORITIZED_IO : c_int = 34; - pub const _SC_PRIORITY_SCHEDULING : c_int = 35; - pub const _SC_REALTIME_SIGNALS : c_int = 36; - pub const _SC_SEMAPHORES : c_int = 37; - pub const _SC_FSYNC : c_int = 38; - pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 39; - pub const _SC_SYNCHRONIZED_IO : c_int = 40; - pub const _SC_TIMERS : c_int = 41; - pub const _SC_AIO_LISTIO_MAX : c_int = 42; - pub const _SC_AIO_MAX : c_int = 43; - pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; - pub const _SC_DELAYTIMER_MAX : c_int = 45; - pub const _SC_MQ_OPEN_MAX : c_int = 46; - pub const _SC_PAGESIZE : c_int = 47; - pub const _SC_RTSIG_MAX : c_int = 48; - pub const _SC_SEM_NSEMS_MAX : c_int = 49; - pub const _SC_SEM_VALUE_MAX : c_int = 50; - pub const _SC_SIGQUEUE_MAX : c_int = 51; - pub const _SC_TIMER_MAX : c_int = 52; - } - } diff --git a/src/freebsdlike/dragonfly.rs b/src/freebsdlike/dragonfly.rs new file mode 100644 index 0000000000000..a677d1a521520 --- /dev/null +++ b/src/freebsdlike/dragonfly.rs @@ -0,0 +1,2 @@ +pub const PTHREAD_STACK_MIN: ::size_t = 1024; +pub const KERN_PROC_PATHNAME: ::c_int = 9; diff --git a/src/freebsdlike/freebsd.rs b/src/freebsdlike/freebsd.rs new file mode 100644 index 0000000000000..c4998379ba84e --- /dev/null +++ b/src/freebsdlike/freebsd.rs @@ -0,0 +1,2 @@ +pub const PTHREAD_STACK_MIN: ::size_t = 2048; +pub const KERN_PROC_PATHNAME: ::c_int = 12; diff --git a/src/freebsdlike/mod.rs b/src/freebsdlike/mod.rs new file mode 100644 index 0000000000000..8db9316c04bcf --- /dev/null +++ b/src/freebsdlike/mod.rs @@ -0,0 +1,577 @@ +pub type pthread_t = uintptr_t; +pub type rlim_t = i64; +pub type sighandler_t = size_t; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type in_port_t = u16; +pub type in_addr_t = u32; + +pub enum timezone {} + +s! { + pub struct glob_t { + pub gl_pathc: ::size_t, + __unused1: ::size_t, + pub gl_offs: ::size_t, + __unused2: ::c_int, + pub gl_pathv: *mut *mut ::c_char, + + __unused3: *mut ::c_void, + + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + __unused8: *mut ::c_void, + } + + pub struct timeval { + pub tv_sec: ::time_t, + pub tv_usec: ::suseconds_t, + } + + pub struct timespec { + pub tv_sec: ::time_t, + pub tv_nsec: ::c_long, + } + + pub struct rlimit { + pub rlim_cur: ::rlim_t, + pub rlim_max: ::rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: ::c_long, + pub ru_ixrss: ::c_long, + pub ru_idrss: ::c_long, + pub ru_isrss: ::c_long, + pub ru_minflt: ::c_long, + pub ru_majflt: ::c_long, + pub ru_nswap: ::c_long, + pub ru_inblock: ::c_long, + pub ru_oublock: ::c_long, + pub ru_msgsnd: ::c_long, + pub ru_msgrcv: ::c_long, + pub ru_nsignals: ::c_long, + pub ru_nvcsw: ::c_long, + pub ru_nivcsw: ::c_long + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + pub struct in6_addr { + pub s6_addr: [u16; 8], + __align: [u32; 0], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut ::c_void + } +} + +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; +pub const L_tmpnam: c_uint = 1024; +pub const TMP_MAX: c_uint = 308915776; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 512; +pub const O_EXCL: ::c_int = 2048; +pub const O_NOCTTY: ::c_int = 32768; +pub const O_TRUNC: ::c_int = 1024; +pub const S_IFIFO: mode_t = 4096; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFMT: mode_t = 61440; +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; +pub const S_IRWXU: mode_t = 448; +pub const S_IXUSR: mode_t = 64; +pub const S_IWUSR: mode_t = 128; +pub const S_IRUSR: mode_t = 256; +pub const S_IRWXG: mode_t = 56; +pub const S_IXGRP: mode_t = 8; +pub const S_IWGRP: mode_t = 16; +pub const S_IRGRP: mode_t = 32; +pub const S_IRWXO: mode_t = 7; +pub const S_IXOTH: mode_t = 1; +pub const S_IWOTH: mode_t = 2; +pub const S_IROTH: mode_t = 4; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x1000; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_SYNC: ::c_int = 0x0000; +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EDEADLK: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EAGAIN: ::c_int = 35; +pub const EWOULDBLOCK: ::c_int = 35; +pub const EINPROGRESS: ::c_int = 36; +pub const EALREADY: ::c_int = 37; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const EOPNOTSUPP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const ELOOP: ::c_int = 62; +pub const ENAMETOOLONG: ::c_int = 63; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const ENOTEMPTY: ::c_int = 66; +pub const EPROCLIM: ::c_int = 67; +pub const EUSERS: ::c_int = 68; +pub const EDQUOT: ::c_int = 69; +pub const ESTALE: ::c_int = 70; +pub const EREMOTE: ::c_int = 71; +pub const EBADRPC: ::c_int = 72; +pub const ERPCMISMATCH: ::c_int = 73; +pub const EPROGUNAVAIL: ::c_int = 74; +pub const EPROGMISMATCH: ::c_int = 75; +pub const EPROCUNAVAIL: ::c_int = 76; +pub const ENOLCK: ::c_int = 77; +pub const ENOSYS: ::c_int = 78; +pub const EFTYPE: ::c_int = 79; +pub const EAUTH: ::c_int = 80; +pub const ENEEDAUTH: ::c_int = 81; +pub const EIDRM: ::c_int = 82; +pub const ENOMSG: ::c_int = 83; +pub const EOVERFLOW: ::c_int = 84; +pub const ECANCELED: ::c_int = 85; +pub const EILSEQ: ::c_int = 86; +pub const ENOATTR: ::c_int = 87; +pub const EDOOFUS: ::c_int = 88; +pub const EBADMSG: ::c_int = 89; +pub const EMULTIHOP: ::c_int = 90; +pub const ENOLINK: ::c_int = 91; +pub const EPROTO: ::c_int = 92; +pub const ENOMEDIUM: ::c_int = 93; +pub const EUNUSED94: ::c_int = 94; +pub const EUNUSED95: ::c_int = 95; +pub const EUNUSED96: ::c_int = 96; +pub const EUNUSED97: ::c_int = 97; +pub const EUNUSED98: ::c_int = 98; +pub const EASYNC: ::c_int = 99; +pub const ELAST: ::c_int = 99; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +pub const SIGTRAP: ::c_int = 5; +pub const SIG_IGN: size_t = 1; + +pub const GLOB_APPEND : ::c_int = 0x0001; +pub const GLOB_DOOFFS : ::c_int = 0x0002; +pub const GLOB_ERR : ::c_int = 0x0004; +pub const GLOB_MARK : ::c_int = 0x0008; +pub const GLOB_NOCHECK : ::c_int = 0x0010; +pub const GLOB_NOSORT : ::c_int = 0x0020; +pub const GLOB_NOESCAPE: ::c_int = 0x2000; + +pub const GLOB_NOSPACE : ::c_int = -1; +pub const GLOB_ABORTED : ::c_int = -2; +pub const GLOB_NOMATCH : ::c_int = -3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const _SC_IOV_MAX: ::c_int = 56; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_MQ_PRIO_MAX: ::c_int = 75; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; +pub const _SC_THREAD_STACK_MIN: ::c_int = 93; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; +pub const _SC_THREADS: ::c_int = 96; +pub const _SC_TTY_NAME_MAX: ::c_int = 101; +pub const _SC_ATEXIT_MAX: ::c_int = 107; +pub const _SC_XOPEN_CRYPT: ::c_int = 108; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; +pub const _SC_XOPEN_LEGACY: ::c_int = 110; +pub const _SC_XOPEN_REALTIME: ::c_int = 111; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; +pub const _SC_XOPEN_SHM: ::c_int = 113; +pub const _SC_XOPEN_UNIX: ::c_int = 115; +pub const _SC_XOPEN_VERSION: ::c_int = 116; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 117; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const CLOCK_REALTIME: ::c_int = 0; +pub const CLOCK_MONOTONIC: ::c_int = 4; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_MEMLOCK: ::c_int = 6; +pub const RLIMIT_NPROC: ::c_int = 7; +pub const RLIMIT_NOFILE: ::c_int = 8; +pub const RLIMIT_SBSIZE: ::c_int = 9; +pub const RLIMIT_VMEM: ::c_int = 10; +pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; +pub const RLIMIT_NPTS: ::c_int = 11; +pub const RLIMIT_SWAP: ::c_int = 12; +pub const RLIMIT_KQUEUES: ::c_int = 13; + +pub const RLIM_NLIMITS: rlim_t = 14; +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + +pub const RUSAGE_SELF: ::c_int = 0; +pub const RUSAGE_CHILDREN: ::c_int = -1; +pub const RUSAGE_THREAD: ::c_int = 1; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 5; +pub const MADV_NOSYNC: ::c_int = 6; +pub const MADV_AUTOSYNC: ::c_int = 7; +pub const MADV_NOCORE: ::c_int = 8; +pub const MADV_CORE: ::c_int = 9; +pub const MADV_PROTECT: ::c_int = 10; + +pub const MINCORE_INCORE: ::c_int = 0x1; +pub const MINCORE_REFERENCED: ::c_int = 0x2; +pub const MINCORE_MODIFIED: ::c_int = 0x4; +pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; +pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; +pub const MINCORE_SUPER: ::c_int = 0x20; + +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 28; +pub const AF_UNIX: ::c_int = 1; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; +pub const IP_MULTICAST_TTL: ::c_int = 10; +pub const IP_MULTICAST_LOOP: ::c_int = 11; +pub const IP_TTL: ::c_int = 4; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_ADD_MEMBERSHIP: ::c_int = 12; +pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; + +pub const TCP_NODELAY: ::c_int = 1; +pub const TCP_KEEPIDLE: ::c_int = 256; +pub const SOL_SOCKET: ::c_int = 0xffff; +pub const SO_DEBUG: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; + +pub const IFF_LOOPBACK: ::c_int = 0x8; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const O_SYNC: ::c_int = 128; +pub const O_NONBLOCK: ::c_int = 4; +pub const CTL_KERN: ::c_int = 1; +pub const KERN_PROC: ::c_int = 14; + +pub const MAP_COPY: ::c_int = 0x0002; +pub const MAP_RENAME: ::c_int = 0x0020; +pub const MAP_NORESERVE: ::c_int = 0x0040; +pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; +pub const MAP_STACK: ::c_int = 0x0400; +pub const MAP_NOSYNC: ::c_int = 0x0800; +pub const MAP_NOCORE: ::c_int = 0x020000; + +pub const IPPROTO_RAW: ::c_int = 255; + +pub const _SC_ARG_MAX: ::c_int = 1; +pub const _SC_CHILD_MAX: ::c_int = 2; +pub const _SC_CLK_TCK: ::c_int = 3; +pub const _SC_NGROUPS_MAX: ::c_int = 4; +pub const _SC_OPEN_MAX: ::c_int = 5; +pub const _SC_JOB_CONTROL: ::c_int = 6; +pub const _SC_SAVED_IDS: ::c_int = 7; +pub const _SC_VERSION: ::c_int = 8; +pub const _SC_BC_BASE_MAX: ::c_int = 9; +pub const _SC_BC_DIM_MAX: ::c_int = 10; +pub const _SC_BC_SCALE_MAX: ::c_int = 11; +pub const _SC_BC_STRING_MAX: ::c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; +pub const _SC_EXPR_NEST_MAX: ::c_int = 14; +pub const _SC_LINE_MAX: ::c_int = 15; +pub const _SC_RE_DUP_MAX: ::c_int = 16; +pub const _SC_2_VERSION: ::c_int = 17; +pub const _SC_2_C_BIND: ::c_int = 18; +pub const _SC_2_C_DEV: ::c_int = 19; +pub const _SC_2_CHAR_TERM: ::c_int = 20; +pub const _SC_2_FORT_DEV: ::c_int = 21; +pub const _SC_2_FORT_RUN: ::c_int = 22; +pub const _SC_2_LOCALEDEF: ::c_int = 23; +pub const _SC_2_SW_DEV: ::c_int = 24; +pub const _SC_2_UPE: ::c_int = 25; +pub const _SC_STREAM_MAX: ::c_int = 26; +pub const _SC_TZNAME_MAX: ::c_int = 27; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; +pub const _SC_MAPPED_FILES: ::c_int = 29; +pub const _SC_MEMLOCK: ::c_int = 30; +pub const _SC_MEMLOCK_RANGE: ::c_int = 31; +pub const _SC_MEMORY_PROTECTION: ::c_int = 32; +pub const _SC_MESSAGE_PASSING: ::c_int = 33; +pub const _SC_PRIORITIZED_IO: ::c_int = 34; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; +pub const _SC_REALTIME_SIGNALS: ::c_int = 36; +pub const _SC_SEMAPHORES: ::c_int = 37; +pub const _SC_FSYNC: ::c_int = 38; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; +pub const _SC_TIMERS: ::c_int = 41; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; +pub const _SC_AIO_MAX: ::c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; +pub const _SC_DELAYTIMER_MAX: ::c_int = 45; +pub const _SC_MQ_OPEN_MAX: ::c_int = 46; +pub const _SC_PAGESIZE: ::c_int = 47; +pub const _SC_RTSIG_MAX: ::c_int = 48; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; +pub const _SC_SEM_VALUE_MAX: ::c_int = 50; +pub const _SC_SIGQUEUE_MAX: ::c_int = 51; +pub const _SC_TIMER_MAX: ::c_int = 52; + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // ... + } +} + +cfg_if! { + if #[cfg(target_os = "freebsd")] { + mod freebsd; + pub use self::freebsd::*; + } else if #[cfg(target_os = "dragonfly")] { + mod dragonfly; + pub use self::dragonfly::*; + } else { + // ... + } +} diff --git a/src/freebsdlike/x86.rs b/src/freebsdlike/x86.rs new file mode 100644 index 0000000000000..47ab9491bf6f2 --- /dev/null +++ b/src/freebsdlike/x86.rs @@ -0,0 +1,64 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u32; +pub type ptrdiff_t = i32; +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i32; +pub type uintptr_t = u32; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i64; +pub type dev_t = u32; +pub type ino_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type mode_t = u16; +pub type ssize_t = i32; +pub type nlink_t = u16; +pub type blksize_t = u32; +pub type blkcnt_t = i64; +pub type fflags_t = u32; +pub type pthread_attr_t = *mut c_void; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: ::uint32_t, + pub st_lspare: ::int32_t, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + __unused: ::[u8; 8], + } +} diff --git a/src/freebsdlike/x86_64.rs b/src/freebsdlike/x86_64.rs new file mode 100644 index 0000000000000..bacea737a13a9 --- /dev/null +++ b/src/freebsdlike/x86_64.rs @@ -0,0 +1,63 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u64; +pub type ptrdiff_t = i64; +pub type clock_t = i32; +pub type time_t = i64; +pub type suseconds_t = i64; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i64; +pub type uintptr_t = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i64; +pub type dev_t = u32; +pub type ino_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type mode_t = u16; +pub type ssize_t = i64; +pub type nlink_t = u16; +pub type blksize_t = u32; +pub type blkcnt_t = i64; +pub type fflags_t = u32; +pub type pthread_attr_t = *mut ::c_void; + +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: ::uint32_t, + pub st_lspare: ::int32_t, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + } +} From 50a42e20f4d958b1f2826f875bd7b929c36b0715 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 14:27:15 -0700 Subject: [PATCH 097/194] Major organization revamp Everything is a tree! --- src/lib.rs | 35 +- src/linuxlike/android.rs | 69 ---- src/linuxlike/b32/android.rs | 40 -- src/linuxlike/b32/mips.rs | 36 -- src/linuxlike/b32/mod.rs | 45 -- src/linuxlike/linux/mod.rs | 175 -------- src/unix/android.rs | 25 -- src/{ => unix/bsd}/apple/b32.rs | 0 src/{ => unix/bsd}/apple/b64.rs | 2 +- src/{ => unix/bsd}/apple/mod.rs | 84 +--- src/{ => unix/bsd}/freebsdlike/dragonfly.rs | 0 src/{ => unix/bsd}/freebsdlike/freebsd.rs | 0 src/{ => unix/bsd}/freebsdlike/mod.rs | 90 +--- src/{ => unix/bsd}/freebsdlike/x86.rs | 2 +- src/{ => unix/bsd}/freebsdlike/x86_64.rs | 0 src/unix/bsd/mod.rs | 69 ++++ .../bsd/openbsdlike/mod.rs} | 0 src/unix/mod.rs | 387 ++++++++++++------ src/unix/notbsd/android.rs | 162 ++++++++ src/{linuxlike => unix/notbsd}/linux/mips.rs | 65 +++ src/unix/notbsd/linux/mod.rs | 188 +++++++++ .../notbsd/linux/notmips/b32.rs} | 33 +- .../notbsd/linux/notmips}/b64/aarch64.rs | 0 .../notbsd/linux/notmips}/b64/mod.rs | 0 .../notbsd/linux/notmips}/b64/x86_64.rs | 0 .../notbsd/linux/notmips/mod.rs} | 12 + src/{linuxlike => unix/notbsd}/mod.rs | 102 +---- src/unix/other/bsdlike.rs | 22 - src/unix/other/mod.rs | 83 ---- src/unix/other/notbsd.rs | 14 - 30 files changed, 819 insertions(+), 921 deletions(-) delete mode 100644 src/linuxlike/android.rs delete mode 100644 src/linuxlike/b32/android.rs delete mode 100644 src/linuxlike/b32/mips.rs delete mode 100644 src/linuxlike/b32/mod.rs delete mode 100644 src/linuxlike/linux/mod.rs delete mode 100644 src/unix/android.rs rename src/{ => unix/bsd}/apple/b32.rs (100%) rename src/{ => unix/bsd}/apple/b64.rs (91%) rename src/{ => unix/bsd}/apple/mod.rs (91%) rename src/{ => unix/bsd}/freebsdlike/dragonfly.rs (100%) rename src/{ => unix/bsd}/freebsdlike/freebsd.rs (100%) rename src/{ => unix/bsd}/freebsdlike/mod.rs (88%) rename src/{ => unix/bsd}/freebsdlike/x86.rs (98%) rename src/{ => unix/bsd}/freebsdlike/x86_64.rs (100%) create mode 100644 src/unix/bsd/mod.rs rename src/{openbsdlike.rs => unix/bsd/openbsdlike/mod.rs} (100%) create mode 100644 src/unix/notbsd/android.rs rename src/{linuxlike => unix/notbsd}/linux/mips.rs (73%) create mode 100644 src/unix/notbsd/linux/mod.rs rename src/{linuxlike/b32/other.rs => unix/notbsd/linux/notmips/b32.rs} (52%) rename src/{linuxlike => unix/notbsd/linux/notmips}/b64/aarch64.rs (100%) rename src/{linuxlike => unix/notbsd/linux/notmips}/b64/mod.rs (100%) rename src/{linuxlike => unix/notbsd/linux/notmips}/b64/x86_64.rs (100%) rename src/{linuxlike/linux/other.rs => unix/notbsd/linux/notmips/mod.rs} (94%) rename src/{linuxlike => unix/notbsd}/mod.rs (83%) delete mode 100644 src/unix/other/bsdlike.rs delete mode 100644 src/unix/other/mod.rs delete mode 100644 src/unix/other/notbsd.rs diff --git a/src/lib.rs b/src/lib.rs index 8677ad911bc13..b3319475e19b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,31 +32,6 @@ pub enum fpos_t {} pub enum DIR {} pub enum dirent {} -cfg_if! { - if #[cfg(any(target_os = "macos", target_os = "ios"))] { - mod apple; - pub use apple::*; - } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd", - target_os = "dragonfly"))] { - mod openbsdlike; - pub use openbsdlike::*; - } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] { - mod freebsdlike; - pub use freebsdlike::*; - } else if #[cfg(any(target_os = "android", target_os = "linux"))] { - mod linuxlike; - pub use linuxlike::*; - } else if #[cfg(windows)] { - mod windows; - pub use windows::*; - } else { - // ... - } -} - -#[cfg(unix)] mod unix; -#[cfg(unix)] pub use unix::*; - extern { pub fn isalnum(c: c_int) -> c_int; pub fn isalpha(c: c_int) -> c_int; @@ -173,3 +148,13 @@ extern { pub fn rand() -> c_int; pub fn srand(seed: c_uint); } + +cfg_if! { + if #[cfg(windows)] { + mod windows; + pub use windows::*; + } else { + mod unix; + pub use unix::*; + } +} diff --git a/src/linuxlike/android.rs b/src/linuxlike/android.rs deleted file mode 100644 index e8b7caa3034f8..0000000000000 --- a/src/linuxlike/android.rs +++ /dev/null @@ -1,69 +0,0 @@ -//! Android-specific definitions for linux-like values - -pub const BUFSIZ: ::c_uint = 1024; -pub const FILENAME_MAX: ::c_uint = 1024; -pub const FOPEN_MAX: ::c_uint = 20; -pub const L_tmpnam: ::c_uint = 1024; -pub const TMP_MAX: ::c_uint = 308915776; -pub const _PC_NAME_MAX: ::c_int = 4; - -pub const _SC_ARG_MAX: ::c_int = 0; -pub const _SC_BC_BASE_MAX: ::c_int = 1; -pub const _SC_BC_DIM_MAX: ::c_int = 2; -pub const _SC_BC_SCALE_MAX: ::c_int = 3; -pub const _SC_BC_STRING_MAX: ::c_int = 4; -pub const _SC_CHILD_MAX: ::c_int = 5; -pub const _SC_CLK_TCK: ::c_int = 6; -pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7; -pub const _SC_EXPR_NEST_MAX: ::c_int = 8; -pub const _SC_LINE_MAX: ::c_int = 9; -pub const _SC_NGROUPS_MAX: ::c_int = 10; -pub const _SC_OPEN_MAX: ::c_int = 11; -pub const _SC_2_C_BIND: ::c_int = 13; -pub const _SC_2_C_DEV: ::c_int = 14; -pub const _SC_2_C_VERSION: ::c_int = 15; -pub const _SC_2_CHAR_TERM: ::c_int = 16; -pub const _SC_2_FORT_DEV: ::c_int = 17; -pub const _SC_2_FORT_RUN: ::c_int = 18; -pub const _SC_2_LOCALEDEF: ::c_int = 19; -pub const _SC_2_SW_DEV: ::c_int = 20; -pub const _SC_2_UPE: ::c_int = 21; -pub const _SC_2_VERSION: ::c_int = 22; -pub const _SC_JOB_CONTROL: ::c_int = 23; -pub const _SC_SAVED_IDS: ::c_int = 24; -pub const _SC_VERSION: ::c_int = 25; -pub const _SC_RE_DUP_MAX: ::c_int = 26; -pub const _SC_STREAM_MAX: ::c_int = 27; -pub const _SC_TZNAME_MAX: ::c_int = 28; -pub const _SC_XOPEN_CRYPT: ::c_int = 29; -pub const _SC_XOPEN_ENH_I18N: ::c_int = 30; -pub const _SC_XOPEN_SHM: ::c_int = 31; -pub const _SC_XOPEN_VERSION: ::c_int = 32; -pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33; -pub const _SC_XOPEN_REALTIME: ::c_int = 34; -pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35; -pub const _SC_XOPEN_LEGACY: ::c_int = 36; -pub const _SC_ATEXIT_MAX: ::c_int = 37; -pub const _SC_IOV_MAX: ::c_int = 38; -pub const _SC_PAGESIZE: ::c_int = 39; -pub const _SC_XOPEN_UNIX: ::c_int = 41; -pub const _SC_MQ_PRIO_MAX: ::c_int = 51; -pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71; -pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72; -pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74; -pub const _SC_THREAD_KEYS_MAX: ::c_int = 75; -pub const _SC_THREAD_STACK_MIN: ::c_int = 76; -pub const _SC_THREAD_THREADS_MAX: ::c_int = 77; -pub const _SC_TTY_NAME_MAX: ::c_int = 78; -pub const _SC_THREADS: ::c_int = 79; -pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80; -pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81; -pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82; -pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83; -pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; -pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; - -pub const PTHREAD_STACK_MIN: ::size_t = 8192; - -pub const O_SYNC: ::c_int = 0x1000; diff --git a/src/linuxlike/b32/android.rs b/src/linuxlike/b32/android.rs deleted file mode 100644 index 290b3a001abeb..0000000000000 --- a/src/linuxlike/b32/android.rs +++ /dev/null @@ -1,40 +0,0 @@ -//! Android specific definitions for 32-bit linux-like values - -pub type blkcnt_t = u32; -pub type blksize_t = u32; -pub type dev_t = u32; -pub type mode_t = u16; -pub type nlink_t = u16; - -s! { - pub struct stat { - pub st_dev: ::c_ulonglong, - __pad0: [::c_uchar; 4], - __st_ino: ::ino_t, - pub st_mode: ::c_uint, - pub st_nlink: ::c_uint, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::c_ulonglong, - __pad3: [::c_uchar; 4], - pub st_size: ::c_longlong, - pub st_blksize: blksize_t, - pub st_blocks: ::c_ulonglong, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_ulong, - pub st_ino: ::c_ulonglong, - } - - pub struct pthread_attr_t { - pub flags: ::uint32_t, - pub stack_base: *mut ::c_void, - pub stack_size: ::size_t, - pub guard_size: ::size_t, - pub sched_policy: ::int32_t, - pub sched_priority: ::int32_t, - } -} diff --git a/src/linuxlike/b32/mips.rs b/src/linuxlike/b32/mips.rs deleted file mode 100644 index b20504e99b43b..0000000000000 --- a/src/linuxlike/b32/mips.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! MIPS specific definitions for 32-bit linux-like values - -pub type blkcnt_t = i32; -pub type blksize_t = i32; -pub type dev_t = u64; -pub type mode_t = u32; -pub type nlink_t = u32; - -s! { - pub struct stat { - pub st_dev: ::c_ulong, - pub st_pad1: [::c_long; 3], - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::c_ulong, - pub st_pad2: [::c_long; 2], - pub st_size: ::off_t, - pub st_pad3: ::c_long, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, - pub st_pad5: [::c_long; 14], - } - - pub struct pthread_attr_t { - __size: [u32; 9] - } -} diff --git a/src/linuxlike/b32/mod.rs b/src/linuxlike/b32/mod.rs deleted file mode 100644 index 02f1c217f8272..0000000000000 --- a/src/linuxlike/b32/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! 32-bit specific definitions for linux-like values - -pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type size_t = u32; -pub type ptrdiff_t = i32; -pub type clock_t = i32; -pub type time_t = i32; -pub type suseconds_t = i32; -pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intptr_t = i32; -pub type uintptr_t = u32; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type off_t = i32; -pub type ino_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; -pub type ssize_t = i32; - -cfg_if! { - if #[cfg(target_os = "android")] { - mod android; - pub use self::android::*; - } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { - mod mips; - pub use self::mips::*; - } else { - mod other; - pub use self::other::*; - } -} diff --git a/src/linuxlike/linux/mod.rs b/src/linuxlike/linux/mod.rs deleted file mode 100644 index 7d508aeb0200b..0000000000000 --- a/src/linuxlike/linux/mod.rs +++ /dev/null @@ -1,175 +0,0 @@ -//! Linux-specific definitions for linux-like values - -s! { - pub struct glob_t { - pub gl_pathc: ::size_t, - pub gl_pathv: *mut *mut ::c_char, - pub gl_offs: ::size_t, - pub gl_flags: ::c_int, - - __unused1: *mut ::c_void, - __unused2: *mut ::c_void, - __unused3: *mut ::c_void, - __unused4: *mut ::c_void, - __unused5: *mut ::c_void, - } - - pub struct ifaddrs { - pub ifa_next: *mut ::ifaddrs, - pub ifa_name: *mut ::c_char, - pub ifa_flags: ::c_uint, - pub ifa_addr: *mut ::sockaddr, - pub ifa_netmask: *mut ::sockaddr, - pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union - pub ifa_data: *mut ::c_void - } -} - -pub const BUFSIZ: ::c_uint = 8192; -pub const FILENAME_MAX: ::c_uint = 4096; -pub const FOPEN_MAX: ::c_uint = 16; -pub const L_tmpnam: ::c_uint = 20; -pub const TMP_MAX: ::c_uint = 238328; -pub const _PC_NAME_MAX: ::c_int = 3; - -pub const _SC_ARG_MAX: ::c_int = 0; -pub const _SC_CHILD_MAX: ::c_int = 1; -pub const _SC_CLK_TCK: ::c_int = 2; -pub const _SC_NGROUPS_MAX: ::c_int = 3; -pub const _SC_OPEN_MAX: ::c_int = 4; -pub const _SC_STREAM_MAX: ::c_int = 5; -pub const _SC_TZNAME_MAX: ::c_int = 6; -pub const _SC_JOB_CONTROL: ::c_int = 7; -pub const _SC_SAVED_IDS: ::c_int = 8; -pub const _SC_REALTIME_SIGNALS: ::c_int = 9; -pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; -pub const _SC_TIMERS: ::c_int = 11; -pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; -pub const _SC_PRIORITIZED_IO: ::c_int = 13; -pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; -pub const _SC_FSYNC: ::c_int = 15; -pub const _SC_MAPPED_FILES: ::c_int = 16; -pub const _SC_MEMLOCK: ::c_int = 17; -pub const _SC_MEMLOCK_RANGE: ::c_int = 18; -pub const _SC_MEMORY_PROTECTION: ::c_int = 19; -pub const _SC_MESSAGE_PASSING: ::c_int = 20; -pub const _SC_SEMAPHORES: ::c_int = 21; -pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; -pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; -pub const _SC_AIO_MAX: ::c_int = 24; -pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; -pub const _SC_DELAYTIMER_MAX: ::c_int = 26; -pub const _SC_MQ_OPEN_MAX: ::c_int = 27; -pub const _SC_MQ_PRIO_MAX: ::c_int = 28; -pub const _SC_VERSION: ::c_int = 29; -pub const _SC_PAGESIZE: ::c_int = 30; -pub const _SC_RTSIG_MAX: ::c_int = 31; -pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; -pub const _SC_SEM_VALUE_MAX: ::c_int = 33; -pub const _SC_SIGQUEUE_MAX: ::c_int = 34; -pub const _SC_TIMER_MAX: ::c_int = 35; -pub const _SC_BC_BASE_MAX: ::c_int = 36; -pub const _SC_BC_DIM_MAX: ::c_int = 37; -pub const _SC_BC_SCALE_MAX: ::c_int = 38; -pub const _SC_BC_STRING_MAX: ::c_int = 39; -pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; -pub const _SC_EXPR_NEST_MAX: ::c_int = 42; -pub const _SC_LINE_MAX: ::c_int = 43; -pub const _SC_RE_DUP_MAX: ::c_int = 44; -pub const _SC_2_VERSION: ::c_int = 46; -pub const _SC_2_C_BIND: ::c_int = 47; -pub const _SC_2_C_DEV: ::c_int = 48; -pub const _SC_2_FORT_DEV: ::c_int = 49; -pub const _SC_2_FORT_RUN: ::c_int = 50; -pub const _SC_2_SW_DEV: ::c_int = 51; -pub const _SC_2_LOCALEDEF: ::c_int = 52; -pub const _SC_IOV_MAX: ::c_int = 60; -pub const _SC_THREADS: ::c_int = 67; -pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; -pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; -pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; -pub const _SC_TTY_NAME_MAX: ::c_int = 72; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; -pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; -pub const _SC_THREAD_STACK_MIN: ::c_int = 75; -pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; -pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; -pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; -pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; -pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; -pub const _SC_ATEXIT_MAX: ::c_int = 87; -pub const _SC_XOPEN_VERSION: ::c_int = 89; -pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; -pub const _SC_XOPEN_UNIX: ::c_int = 91; -pub const _SC_XOPEN_CRYPT: ::c_int = 92; -pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; -pub const _SC_XOPEN_SHM: ::c_int = 94; -pub const _SC_2_CHAR_TERM: ::c_int = 95; -pub const _SC_2_C_VERSION: ::c_int = 96; -pub const _SC_2_UPE: ::c_int = 97; -pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; -pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; -pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; -pub const _SC_XOPEN_LEGACY: ::c_int = 129; -pub const _SC_XOPEN_REALTIME: ::c_int = 130; -pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; - -pub const RLIM_SAVED_MAX: ::rlim_t = ::RLIM_INFINITY; -pub const RLIM_SAVED_CUR: ::rlim_t = ::RLIM_INFINITY; - -#[cfg(not(target_env = "musl"))] -pub const RUSAGE_THREAD: ::c_int = 1; - -pub const GLOB_ERR: ::c_int = 1 << 0; -pub const GLOB_MARK: ::c_int = 1 << 1; -pub const GLOB_NOSORT: ::c_int = 1 << 2; -pub const GLOB_DOOFFS: ::c_int = 1 << 3; -pub const GLOB_NOCHECK: ::c_int = 1 << 4; -pub const GLOB_APPEND: ::c_int = 1 << 5; -pub const GLOB_NOESCAPE: ::c_int = 1 << 6; - -pub const GLOB_NOSPACE: ::c_int = 1; -pub const GLOB_ABORTED: ::c_int = 2; -pub const GLOB_NOMATCH: ::c_int = 3; - -pub const POSIX_MADV_NORMAL: ::c_int = 0; -pub const POSIX_MADV_RANDOM: ::c_int = 1; -pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; -pub const POSIX_MADV_WILLNEED: ::c_int = 3; -pub const POSIX_MADV_DONTNEED: ::c_int = 4; - -pub const S_IEXEC: ::mode_t = 64; -pub const S_IWRITE: ::mode_t = 128; -pub const S_IREAD: ::mode_t = 256; - -pub const F_LOCK: ::c_int = 1; -pub const F_TEST: ::c_int = 3; -pub const F_TLOCK: ::c_int = 2; -pub const F_ULOCK: ::c_int = 0; - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub const MAP_32BIT: ::c_int = 0x0040; - -pub const TCP_MD5SIG: ::c_int = 14; - -cfg_if! { - if #[cfg(any(target_arch = "arm", target_arch = "x86", - target_arch = "x86_64"))] { - pub const PTHREAD_STACK_MIN: ::size_t = 16384; - } else { - pub const PTHREAD_STACK_MIN: ::size_t = 131072; - } -} - -cfg_if! { - if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { - mod mips; - pub use self::mips::*; - } else { - mod other; - pub use self::other::*; - } -} diff --git a/src/unix/android.rs b/src/unix/android.rs deleted file mode 100644 index 41e6971802f67..0000000000000 --- a/src/unix/android.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! Android versions of standard Unix functions - -extern { - pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; - pub fn putenv(string: *const ::c_char) -> ::c_int; - pub fn readlink(path: *const ::c_char, - buf: *mut ::c_char, - bufsz: ::size_t) - -> ::c_int; - pub fn msync(addr: *const ::c_void, len: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) - -> ::c_int; - pub fn sysconf(name: ::c_int) -> ::c_int; - pub fn usleep(secs: ::c_ulong) -> ::c_int; - pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_uint, addr: *const ::sockaddr, - addrlen: *mut ::socklen_t) -> ::ssize_t; - pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, - flags: ::c_uint) -> ::ssize_t; - pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_uint) -> ::ssize_t; -} diff --git a/src/apple/b32.rs b/src/unix/bsd/apple/b32.rs similarity index 100% rename from src/apple/b32.rs rename to src/unix/bsd/apple/b32.rs diff --git a/src/apple/b64.rs b/src/unix/bsd/apple/b64.rs similarity index 91% rename from src/apple/b64.rs rename to src/unix/bsd/apple/b64.rs index 65e1b9fcb34ef..1a79be30368eb 100644 --- a/src/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -9,7 +9,7 @@ pub type uintptr_t = u64; s! { pub struct pthread_attr_t { - __sig: ::c_long, + __sig: c_long, __opaque: [::c_char; 56] } } diff --git a/src/apple/mod.rs b/src/unix/bsd/apple/mod.rs similarity index 91% rename from src/apple/mod.rs rename to src/unix/bsd/apple/mod.rs index ba43d98866287..97e42786cd74c 100644 --- a/src/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -61,46 +61,6 @@ s! { __unused8: *mut ::c_void, } - pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - - pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, @@ -109,42 +69,6 @@ s! { __ss_pad2: [u8; 112], } - pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - - pub struct in_addr { - pub s_addr: in_addr_t, - } - - pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - - pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, @@ -156,12 +80,6 @@ s! { pub ai_next: *mut addrinfo, } - pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, @@ -685,7 +603,7 @@ pub const _SC_PASS_MAX: c_int = 131; extern { pub fn _NSGetExecutablePath(buf: *mut c_char, - bufsize: *mut ::uint32_t) -> c_int; + bufsize: *mut uint32_t) -> c_int; } cfg_if! { diff --git a/src/freebsdlike/dragonfly.rs b/src/unix/bsd/freebsdlike/dragonfly.rs similarity index 100% rename from src/freebsdlike/dragonfly.rs rename to src/unix/bsd/freebsdlike/dragonfly.rs diff --git a/src/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd.rs similarity index 100% rename from src/freebsdlike/freebsd.rs rename to src/unix/bsd/freebsdlike/freebsd.rs diff --git a/src/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs similarity index 88% rename from src/freebsdlike/mod.rs rename to src/unix/bsd/freebsdlike/mod.rs index 8db9316c04bcf..4c582c45ed1ca 100644 --- a/src/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -25,46 +25,6 @@ s! { __unused8: *mut ::c_void, } - pub struct timeval { - pub tv_sec: ::time_t, - pub tv_usec: ::suseconds_t, - } - - pub struct timespec { - pub tv_sec: ::time_t, - pub tv_nsec: ::c_long, - } - - pub struct rlimit { - pub rlim_cur: ::rlim_t, - pub rlim_max: ::rlim_t, - } - - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: ::c_long, - pub ru_ixrss: ::c_long, - pub ru_idrss: ::c_long, - pub ru_isrss: ::c_long, - pub ru_minflt: ::c_long, - pub ru_majflt: ::c_long, - pub ru_nswap: ::c_long, - pub ru_inblock: ::c_long, - pub ru_oublock: ::c_long, - pub ru_msgsnd: ::c_long, - pub ru_msgrcv: ::c_long, - pub ru_nsignals: ::c_long, - pub ru_nvcsw: ::c_long, - pub ru_nivcsw: ::c_long - } - - pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: sa_family_t, @@ -73,42 +33,6 @@ s! { __ss_pad2: [u8; 112], } - pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - - pub struct in_addr { - pub s_addr: in_addr_t, - } - - pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - - pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -116,23 +40,17 @@ s! { pub ai_protocol: ::c_int, pub ai_addrlen: socklen_t, pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, + pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } - pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_dstaddr: *mut ::sockaddr, pub ifa_data: *mut ::c_void } } diff --git a/src/freebsdlike/x86.rs b/src/unix/bsd/freebsdlike/x86.rs similarity index 98% rename from src/freebsdlike/x86.rs rename to src/unix/bsd/freebsdlike/x86.rs index 47ab9491bf6f2..5a80c0d42b038 100644 --- a/src/freebsdlike/x86.rs +++ b/src/unix/bsd/freebsdlike/x86.rs @@ -59,6 +59,6 @@ s! { pub st_lspare: ::int32_t, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, - __unused: ::[u8; 8], + __unused: [u8; 8], } } diff --git a/src/freebsdlike/x86_64.rs b/src/unix/bsd/freebsdlike/x86_64.rs similarity index 100% rename from src/freebsdlike/x86_64.rs rename to src/unix/bsd/freebsdlike/x86_64.rs diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs new file mode 100644 index 0000000000000..783298c184978 --- /dev/null +++ b/src/unix/bsd/mod.rs @@ -0,0 +1,69 @@ +s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104] + } +} + +extern { + pub fn shm_open(name: *const c_char, oflag: c_int, ...) -> c_int; + pub fn sysctl(name: *mut c_int, + namelen: c_uint, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *mut ::c_void, + newlen: size_t) + -> c_int; + pub fn mincore(addr: *const ::c_void, len: size_t, + vec: *mut c_char) -> c_int; + pub fn sysctlbyname(name: *const c_char, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *mut ::c_void, + newlen: size_t) + -> c_int; + pub fn sysctlnametomib(name: *const c_char, + mibp: *mut c_int, + sizep: *mut size_t) + -> c_int; +} + +cfg_if! { + if #[cfg(any(target_os = "macos", target_os = "ios"))] { + mod apple; + pub use self::apple::*; + } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd", + target_os = "dragonfly"))] { + mod openbsdlike; + pub use self::openbsdlike::*; + } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] { + mod freebsdlike; + pub use self::freebsdlike::*; + } else { + // ... + } +} diff --git a/src/openbsdlike.rs b/src/unix/bsd/openbsdlike/mod.rs similarity index 100% rename from src/openbsdlike.rs rename to src/unix/bsd/openbsdlike/mod.rs diff --git a/src/unix/mod.rs b/src/unix/mod.rs index ed98452400c75..524b9be9a2a7f 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -5,246 +5,373 @@ s! { pub struct utimbuf { - pub actime: ::time_t, - pub modtime: ::time_t, + pub actime: time_t, + pub modtime: time_t, + } + + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct in6_addr { + pub s6_addr: [u16; 8], + __align: [u32; 0], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, } } extern { - pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "connect$UNIX2003")] - pub fn connect(socket: ::c_int, address: *const ::sockaddr, - len: ::socklen_t) -> ::c_int; + pub fn connect(socket: c_int, address: *const sockaddr, + len: socklen_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "bind$UNIX2003")] - pub fn bind(socket: ::c_int, address: *const ::sockaddr, - address_len: ::socklen_t) -> ::c_int; + pub fn bind(socket: c_int, address: *const sockaddr, + address_len: socklen_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "listen$UNIX2003")] - pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; + pub fn listen(socket: c_int, backlog: c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "accept$UNIX2003")] - pub fn accept(socket: ::c_int, address: *mut ::sockaddr, - address_len: *mut ::socklen_t) -> ::c_int; + pub fn accept(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getpeername$UNIX2003")] - pub fn getpeername(socket: ::c_int, address: *mut ::sockaddr, - address_len: *mut ::socklen_t) -> ::c_int; + pub fn getpeername(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getsockname$UNIX2003")] - pub fn getsockname(socket: ::c_int, address: *mut ::sockaddr, - address_len: *mut ::socklen_t) -> ::c_int; - pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int, + pub fn getsockname(socket: c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> c_int; + pub fn setsockopt(socket: c_int, level: c_int, name: c_int, value: *const ::c_void, - option_len: ::socklen_t) -> ::c_int; + option_len: socklen_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003")] - pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t, - flags: ::c_int, addr: *const ::sockaddr, - addrlen: ::socklen_t) -> ::ssize_t; - pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; + pub fn sendto(socket: c_int, buf: *const ::c_void, len: size_t, + flags: c_int, addr: *const sockaddr, + addrlen: socklen_t) -> ssize_t; + pub fn shutdown(socket: c_int, how: c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "chmod$UNIX2003")] - pub fn chmod(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fchmod$UNIX2003")] - pub fn fchmod(fd: ::c_int, mode: ::mode_t) -> ::c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] - pub fn fstat(fildes: ::c_int, buf: *mut ::stat) -> ::c_int; + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; - pub fn mkdir(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] - pub fn stat(path: *const ::c_char, buf: *mut ::stat) -> ::c_int; + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "popen$UNIX2003")] - pub fn popen(command: *const ::c_char, - mode: *const ::c_char) -> *mut ::FILE; - pub fn pclose(stream: *mut ::FILE) -> ::c_int; + pub fn popen(command: *const c_char, + mode: *const c_char) -> *mut ::FILE; + pub fn pclose(stream: *mut ::FILE) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fdopen$UNIX2003")] - pub fn fdopen(fd: ::c_int, mode: *const ::c_char) -> *mut ::FILE; - pub fn fileno(stream: *mut ::FILE) -> ::c_int; + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut ::FILE; + pub fn fileno(stream: *mut ::FILE) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "open$UNIX2003")] - pub fn open(path: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "creat$UNIX2003")] - pub fn creat(path: *const ::c_char, mode: ::mode_t) -> ::c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fcntl$UNIX2003")] - pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "opendir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "opendir$INODE64$UNIX2003")] - pub fn opendir(dirname: *const ::c_char) -> *mut ::DIR; + pub fn opendir(dirname: *const c_char) -> *mut ::DIR; #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, - result: *mut *mut ::dirent) -> ::c_int; + result: *mut *mut ::dirent) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "closedir$UNIX2003")] - pub fn closedir(dirp: *mut ::DIR) -> ::c_int; + pub fn closedir(dirp: *mut ::DIR) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "rewinddir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "rewinddir$INODE64$UNIX2003")] pub fn rewinddir(dirp: *mut ::DIR); - pub fn access(path: *const ::c_char, amode: ::c_int) -> ::c_int; - pub fn alarm(seconds: ::c_uint) -> ::c_uint; - pub fn chdir(dir: *const ::c_char) -> ::c_int; - pub fn chown(path: *const ::c_char, uid: ::uid_t, - gid: ::gid_t) -> ::c_int; + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn alarm(seconds: c_uint) -> c_uint; + pub fn chdir(dir: *const c_char) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, + gid: gid_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "close$UNIX2003")] - pub fn close(fd: ::c_int) -> ::c_int; - pub fn dup(fd: ::c_int) -> ::c_int; - pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; - pub fn execv(prog: *const ::c_char, - argv: *const *const ::c_char) -> ::c_int; - pub fn execve(prog: *const ::c_char, argv: *const *const ::c_char, - envp: *const *const ::c_char) - -> ::c_int; - pub fn execvp(c: *const ::c_char, - argv: *const *const ::c_char) -> ::c_int; - pub fn fork() -> ::pid_t; - pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> ::c_long; - pub fn getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char; - pub fn getegid() -> ::gid_t; - pub fn geteuid() -> ::uid_t; - pub fn getgid() -> ::gid_t; - pub fn getgroups(ngroups_max: ::c_int, groups: *mut ::gid_t) - -> ::c_int; - pub fn getlogin() -> *mut ::c_char; + pub fn close(fd: c_int) -> c_int; + pub fn dup(fd: c_int) -> c_int; + pub fn dup2(src: c_int, dst: c_int) -> c_int; + pub fn execv(prog: *const c_char, + argv: *const *const c_char) -> c_int; + pub fn execve(prog: *const c_char, argv: *const *const c_char, + envp: *const *const c_char) + -> c_int; + pub fn execvp(c: *const c_char, + argv: *const *const c_char) -> c_int; + pub fn fork() -> pid_t; + pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) + -> c_int; + pub fn getlogin() -> *mut c_char; // GNU getopt(3) modifies its arguments despite the // char * const [] prototype; see the manpage. - pub fn getopt(argc: ::c_int, argv: *mut *mut ::c_char, - optstr: *const ::c_char) -> ::c_int; - pub fn getpgrp() -> ::pid_t; - pub fn getpid() -> ::pid_t; - pub fn getppid() -> ::pid_t; - pub fn getuid() -> ::uid_t; - pub fn isatty(fd: ::c_int) -> ::c_int; - pub fn link(src: *const ::c_char, dst: *const ::c_char) -> ::c_int; - pub fn lseek(fd: ::c_int, offset: ::off_t, whence: ::c_int) - -> ::off_t; - pub fn pathconf(path: *const ::c_char, name: ::c_int) -> ::c_long; + pub fn getopt(argc: c_int, argv: *mut *mut c_char, + optstr: *const c_char) -> c_int; + pub fn getpgrp() -> pid_t; + pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getuid() -> uid_t; + pub fn isatty(fd: c_int) -> c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) + -> off_t; + pub fn pathconf(path: *const c_char, name: c_int) -> c_long; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pause$UNIX2003")] - pub fn pause() -> ::c_int; - pub fn pipe(fds: *mut ::c_int) -> ::c_int; + pub fn pause() -> c_int; + pub fn pipe(fds: *mut c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "read$UNIX2003")] - pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) - -> ::ssize_t; - pub fn rmdir(path: *const ::c_char) -> ::c_int; - pub fn setgid(gid: ::gid_t) -> ::c_int; - pub fn setpgid(pid: ::pid_t, pgid: ::pid_t) -> ::c_int; - pub fn setsid() -> ::pid_t; - pub fn setuid(uid: ::uid_t) -> ::c_int; + pub fn read(fd: c_int, buf: *mut ::c_void, count: size_t) + -> ssize_t; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn setgid(gid: gid_t) -> c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; + pub fn setsid() -> pid_t; + pub fn setuid(uid: uid_t) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sleep$UNIX2003")] - pub fn sleep(secs: ::c_uint) -> ::c_uint; + pub fn sleep(secs: c_uint) -> c_uint; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "nanosleep$UNIX2003")] - pub fn nanosleep(rqtp: *const ::timespec, - rmtp: *mut ::timespec) -> ::c_int; - pub fn tcgetpgrp(fd: ::c_int) -> ::pid_t; - pub fn ttyname(fd: ::c_int) -> *mut ::c_char; - pub fn unlink(c: *const ::c_char) -> ::c_int; + pub fn nanosleep(rqtp: *const timespec, + rmtp: *mut timespec) -> c_int; + pub fn tcgetpgrp(fd: c_int) -> pid_t; + pub fn ttyname(fd: c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "wait$UNIX2003")] - pub fn wait(status: *mut ::c_int) -> ::pid_t; + pub fn wait(status: *mut c_int) -> pid_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "waitpid$UNIX2003")] - pub fn waitpid(pid: ::pid_t, status: *mut ::c_int, options: ::c_int) - -> ::pid_t; + pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) + -> pid_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "write$UNIX2003")] - pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) - -> ::ssize_t; + pub fn write(fd: c_int, buf: *const ::c_void, count: size_t) + -> ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pread$UNIX2003")] - pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, - offset: ::off_t) -> ::ssize_t; + pub fn pread(fd: c_int, buf: *mut ::c_void, count: size_t, + offset: off_t) -> ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pwrite$UNIX2003")] - pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, - offset: ::off_t) -> ::ssize_t; - pub fn utime(file: *const ::c_char, buf: *const ::utimbuf) -> ::c_int; + pub fn pwrite(fd: c_int, buf: *const ::c_void, count: size_t, + offset: off_t) -> ssize_t; + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "kill$UNIX2003")] - pub fn kill(pid: ::pid_t, sig: ::c_int) -> ::c_int; + pub fn kill(pid: pid_t, sig: c_int) -> c_int; - pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; - pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; - pub fn mlockall(flags: ::c_int) -> ::c_int; - pub fn munlockall() -> ::c_int; + pub fn mlock(addr: *const ::c_void, len: size_t) -> c_int; + pub fn munlock(addr: *const ::c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlockall() -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mmap$UNIX2003")] pub fn mmap(addr: *mut ::c_void, - len: ::size_t, - prot: ::c_int, - flags: ::c_int, - fd: ::c_int, - offset: ::off_t) + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t) -> *mut ::c_void; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "munmap$UNIX2003")] - pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; + pub fn munmap(addr: *mut ::c_void, len: size_t) -> c_int; - pub fn if_nametoindex(ifname: *const ::c_char) -> ::c_uint; + pub fn if_nametoindex(ifname: *const c_char) -> c_uint; #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] - pub fn lstat(path: *const ::c_char, buf: *mut ::stat) -> ::c_int; + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fsync$UNIX2003")] - pub fn fsync(fd: ::c_int) -> ::c_int; + pub fn fsync(fd: c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "setenv$UNIX2003")] - pub fn setenv(name: *const ::c_char, val: *const ::c_char, - overwrite: ::c_int) -> ::c_int; + pub fn setenv(name: *const c_char, val: *const c_char, + overwrite: c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "unsetenv$UNIX2003")] - pub fn unsetenv(name: *const ::c_char) -> ::c_int; + pub fn unsetenv(name: *const c_char) -> c_int; - pub fn symlink(path1: *const ::c_char, - path2: *const ::c_char) -> ::c_int; + pub fn symlink(path1: *const c_char, + path2: *const c_char) -> c_int; - pub fn ftruncate(fd: ::c_int, length: ::off_t) -> ::c_int; + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; - pub fn signal(signum: ::c_int, - handler: ::sighandler_t) -> ::sighandler_t; + pub fn signal(signum: c_int, + handler: sighandler_t) -> sighandler_t; - pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; - pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; - pub fn getrusage(resource: ::c_int, usage: *mut ::rusage) -> ::c_int; + pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; + pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; - pub fn getdtablesize() -> ::c_int; + pub fn getdtablesize() -> c_int; #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] - pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) - -> *mut ::c_char; + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) + -> *mut c_char; + + pub fn flock(fd: c_int, operation: c_int) -> c_int; +} - pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; +#[cfg(not(target_os = "android"))] +extern { + pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut ifaddrs); + pub fn glob(pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut glob_t); + pub fn globfree(pglob: *mut glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: size_t, advice: c_int) + -> c_int; + + pub fn shm_unlink(name: *const c_char) -> c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003")] + pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003")] + pub fn telldir(dirp: *mut ::DIR) -> c_long; + + pub fn getsid(pid: pid_t) -> pid_t; + pub fn madvise(addr: *mut ::c_void, len: size_t, advice: c_int) + -> c_int; + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "putenv$UNIX2003")] + pub fn putenv(string: *mut c_char) -> c_int; + pub fn readlink(path: *const c_char, + buf: *mut c_char, + bufsz: size_t) + -> ssize_t; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003")] + pub fn msync(addr: *mut ::c_void, len: size_t, flags: c_int) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "mprotect$UNIX2003")] + pub fn mprotect(addr: *mut ::c_void, len: size_t, prot: c_int) + -> c_int; + pub fn sysconf(name: c_int) -> c_long; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "usleep$UNIX2003")] + pub fn usleep(secs: c_uint) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003")] + pub fn recvfrom(socket: c_int, buf: *mut ::c_void, len: size_t, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "send$UNIX2003")] + pub fn send(socket: c_int, buf: *const ::c_void, len: size_t, + flags: c_int) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recv$UNIX2003")] + pub fn recv(socket: c_int, buf: *mut ::c_void, len: size_t, + flags: c_int) -> ssize_t; + pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; } cfg_if! { - if #[cfg(target_os = "android")] { - mod android; - pub use self::android::*; + if #[cfg(any(target_os = "linux", target_os = "android"))] { + mod notbsd; + pub use self::notbsd::*; + } else if #[cfg(any(target_os = "macos", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd", + target_os = "netbsd", + target_os = "bitrig"))] { + mod bsd; + pub use self::bsd::*; } else { - mod other; - pub use self::other::*; + // ... } } diff --git a/src/unix/notbsd/android.rs b/src/unix/notbsd/android.rs new file mode 100644 index 0000000000000..78c3f14c34f50 --- /dev/null +++ b/src/unix/notbsd/android.rs @@ -0,0 +1,162 @@ +//! Android-specific definitions for linux-like values + +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u32; +pub type ptrdiff_t = i32; +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i32; +pub type uintptr_t = u32; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i32; +pub type ino_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type ssize_t = i32; +pub type blkcnt_t = u32; +pub type blksize_t = u32; +pub type dev_t = u32; +pub type mode_t = u16; +pub type nlink_t = u16; + +s! { + pub struct stat { + pub st_dev: ::c_ulonglong, + __pad0: [::c_uchar; 4], + __st_ino: ::ino_t, + pub st_mode: ::c_uint, + pub st_nlink: ::c_uint, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulonglong, + __pad3: [::c_uchar; 4], + pub st_size: ::c_longlong, + pub st_blksize: blksize_t, + pub st_blocks: ::c_ulonglong, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_ulong, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_ulong, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_ulong, + pub st_ino: ::c_ulonglong, + } + + pub struct pthread_attr_t { + pub flags: ::uint32_t, + pub stack_base: *mut ::c_void, + pub stack_size: ::size_t, + pub guard_size: ::size_t, + pub sched_policy: ::int32_t, + pub sched_priority: ::int32_t, + } +} + +pub const BUFSIZ: ::c_uint = 1024; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const L_tmpnam: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 308915776; +pub const _PC_NAME_MAX: ::c_int = 4; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_BC_BASE_MAX: ::c_int = 1; +pub const _SC_BC_DIM_MAX: ::c_int = 2; +pub const _SC_BC_SCALE_MAX: ::c_int = 3; +pub const _SC_BC_STRING_MAX: ::c_int = 4; +pub const _SC_CHILD_MAX: ::c_int = 5; +pub const _SC_CLK_TCK: ::c_int = 6; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7; +pub const _SC_EXPR_NEST_MAX: ::c_int = 8; +pub const _SC_LINE_MAX: ::c_int = 9; +pub const _SC_NGROUPS_MAX: ::c_int = 10; +pub const _SC_OPEN_MAX: ::c_int = 11; +pub const _SC_2_C_BIND: ::c_int = 13; +pub const _SC_2_C_DEV: ::c_int = 14; +pub const _SC_2_C_VERSION: ::c_int = 15; +pub const _SC_2_CHAR_TERM: ::c_int = 16; +pub const _SC_2_FORT_DEV: ::c_int = 17; +pub const _SC_2_FORT_RUN: ::c_int = 18; +pub const _SC_2_LOCALEDEF: ::c_int = 19; +pub const _SC_2_SW_DEV: ::c_int = 20; +pub const _SC_2_UPE: ::c_int = 21; +pub const _SC_2_VERSION: ::c_int = 22; +pub const _SC_JOB_CONTROL: ::c_int = 23; +pub const _SC_SAVED_IDS: ::c_int = 24; +pub const _SC_VERSION: ::c_int = 25; +pub const _SC_RE_DUP_MAX: ::c_int = 26; +pub const _SC_STREAM_MAX: ::c_int = 27; +pub const _SC_TZNAME_MAX: ::c_int = 28; +pub const _SC_XOPEN_CRYPT: ::c_int = 29; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 30; +pub const _SC_XOPEN_SHM: ::c_int = 31; +pub const _SC_XOPEN_VERSION: ::c_int = 32; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33; +pub const _SC_XOPEN_REALTIME: ::c_int = 34; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35; +pub const _SC_XOPEN_LEGACY: ::c_int = 36; +pub const _SC_ATEXIT_MAX: ::c_int = 37; +pub const _SC_IOV_MAX: ::c_int = 38; +pub const _SC_PAGESIZE: ::c_int = 39; +pub const _SC_XOPEN_UNIX: ::c_int = 41; +pub const _SC_MQ_PRIO_MAX: ::c_int = 51; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 75; +pub const _SC_THREAD_STACK_MIN: ::c_int = 76; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 77; +pub const _SC_TTY_NAME_MAX: ::c_int = 78; +pub const _SC_THREADS: ::c_int = 79; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; + +pub const PTHREAD_STACK_MIN: ::size_t = 8192; + +pub const O_SYNC: ::c_int = 0x1000; + +extern { + pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + pub fn putenv(string: *const ::c_char) -> ::c_int; + pub fn readlink(path: *const ::c_char, + buf: *mut ::c_char, + bufsz: ::size_t) + -> ::c_int; + pub fn msync(addr: *const ::c_void, len: ::size_t, + flags: ::c_int) -> ::c_int; + pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + pub fn sysconf(name: ::c_int) -> ::c_int; + pub fn usleep(secs: ::c_ulong) -> ::c_int; + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_uint, addr: *const ::sockaddr, + addrlen: *mut ::socklen_t) -> ::ssize_t; + pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_uint) -> ::ssize_t; + pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_uint) -> ::ssize_t; +} diff --git a/src/linuxlike/linux/mips.rs b/src/unix/notbsd/linux/mips.rs similarity index 73% rename from src/linuxlike/linux/mips.rs rename to src/unix/notbsd/linux/mips.rs index 1889fe9c89364..83ee1da075cbd 100644 --- a/src/linuxlike/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -1,3 +1,68 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u32; +pub type ptrdiff_t = i32; +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i32; +pub type uintptr_t = u32; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i32; +pub type ino_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type ssize_t = i32; +pub type blkcnt_t = i32; +pub type blksize_t = i32; +pub type dev_t = u64; +pub type mode_t = u32; +pub type nlink_t = u32; + +s! { + pub struct stat { + pub st_dev: ::c_ulong, + pub st_pad1: [::c_long; 3], + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::c_ulong, + pub st_pad2: [::c_long; 2], + pub st_size: ::off_t, + pub st_pad3: ::c_long, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_pad5: [::c_long; 14], + } + + pub struct pthread_attr_t { + __size: [u32; 9] + } +} + pub const RLIMIT_NOFILE: ::c_int = 5; pub const RLIMIT_AS: ::c_int = 6; pub const RLIMIT_RSS: ::c_int = 7; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs new file mode 100644 index 0000000000000..049fd8e9e8ace --- /dev/null +++ b/src/unix/notbsd/linux/mod.rs @@ -0,0 +1,188 @@ +//! Linux-specific definitions for linux-like values + +s! { + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union + pub ifa_data: *mut ::c_void + } +} + +pub const BUFSIZ: c_uint = 8192; +pub const FILENAME_MAX: c_uint = 4096; +pub const FOPEN_MAX: c_uint = 16; +pub const L_tmpnam: c_uint = 20; +pub const TMP_MAX: c_uint = 238328; +pub const _PC_NAME_MAX: c_int = 3; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_C_VERSION: c_int = 96; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; + +pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; + +#[cfg(not(target_env = "musl"))] +pub const RUSAGE_THREAD: c_int = 1; + +pub const GLOB_ERR: c_int = 1 << 0; +pub const GLOB_MARK: c_int = 1 << 1; +pub const GLOB_NOSORT: c_int = 1 << 2; +pub const GLOB_DOOFFS: c_int = 1 << 3; +pub const GLOB_NOCHECK: c_int = 1 << 4; +pub const GLOB_APPEND: c_int = 1 << 5; +pub const GLOB_NOESCAPE: c_int = 1 << 6; + +pub const GLOB_NOSPACE: c_int = 1; +pub const GLOB_ABORTED: c_int = 2; +pub const GLOB_NOMATCH: c_int = 3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const S_IEXEC: mode_t = 64; +pub const S_IWRITE: mode_t = 128; +pub const S_IREAD: mode_t = 256; + +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub const MAP_32BIT: c_int = 0x0040; + +pub const TCP_MD5SIG: c_int = 14; + +extern { + pub fn shm_open(name: *const c_char, oflag: c_int, + mode: mode_t) -> c_int; + #[cfg(not(target_env = "musl"))] + pub fn sysctl(name: *mut c_int, + namelen: c_int, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *mut ::c_void, + newlen: size_t) + -> c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "arm", target_arch = "x86", + target_arch = "x86_64"))] { + pub const PTHREAD_STACK_MIN: size_t = 16384; + } else { + pub const PTHREAD_STACK_MIN: size_t = 131072; + } +} + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { + mod mips; + pub use self::mips::*; + } else { + mod notmips; + pub use self::notmips::*; + } +} diff --git a/src/linuxlike/b32/other.rs b/src/unix/notbsd/linux/notmips/b32.rs similarity index 52% rename from src/linuxlike/b32/other.rs rename to src/unix/notbsd/linux/notmips/b32.rs index 02bc4abacdacd..8eb4ef1f10d01 100644 --- a/src/linuxlike/b32/other.rs +++ b/src/unix/notbsd/linux/notmips/b32.rs @@ -1,6 +1,35 @@ -//! 32-bit specific definitions for linux-like values on platforms that aren't -//! MIPS or android +//! 32-bit specific definitions for linux-like values +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u32; +pub type ptrdiff_t = i32; +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i32; +pub type uintptr_t = u32; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i32; +pub type ino_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type ssize_t = i32; pub type blkcnt_t = i32; pub type blksize_t = i32; pub type dev_t = u64; diff --git a/src/linuxlike/b64/aarch64.rs b/src/unix/notbsd/linux/notmips/b64/aarch64.rs similarity index 100% rename from src/linuxlike/b64/aarch64.rs rename to src/unix/notbsd/linux/notmips/b64/aarch64.rs diff --git a/src/linuxlike/b64/mod.rs b/src/unix/notbsd/linux/notmips/b64/mod.rs similarity index 100% rename from src/linuxlike/b64/mod.rs rename to src/unix/notbsd/linux/notmips/b64/mod.rs diff --git a/src/linuxlike/b64/x86_64.rs b/src/unix/notbsd/linux/notmips/b64/x86_64.rs similarity index 100% rename from src/linuxlike/b64/x86_64.rs rename to src/unix/notbsd/linux/notmips/b64/x86_64.rs diff --git a/src/linuxlike/linux/other.rs b/src/unix/notbsd/linux/notmips/mod.rs similarity index 94% rename from src/linuxlike/linux/other.rs rename to src/unix/notbsd/linux/notmips/mod.rs index 9e4668a1a870e..2fabb483635f7 100644 --- a/src/linuxlike/linux/other.rs +++ b/src/unix/notbsd/linux/notmips/mod.rs @@ -145,3 +145,15 @@ pub const TCP_FASTOPEN: ::c_int = 23; pub const TCP_TIMESTAMP: ::c_int = 24; pub const SO_REUSEPORT: ::c_int = 15; + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { + mod b32; + pub use self::b32::*; + } else if #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] { + mod b64; + pub use self::b64::*; + } else { + // ... + } +} diff --git a/src/linuxlike/mod.rs b/src/unix/notbsd/mod.rs similarity index 83% rename from src/linuxlike/mod.rs rename to src/unix/notbsd/mod.rs index 6c3bd90827bef..8222c01a0c4c6 100644 --- a/src/linuxlike/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -1,7 +1,3 @@ -//! Linux-like values -//! -//! Currenly applies to the Linux and Android platforms - pub type in_addr_t = u32; pub type in_port_t = u16; pub type pthread_t = c_ulong; @@ -13,58 +9,38 @@ pub type socklen_t = u32; pub enum timezone {} s! { - pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [u8; 14], } - pub struct sockaddr_storage { - pub ss_family: sa_family_t, - __ss_align: isize, - #[cfg(target_pointer_width = "32")] - __ss_pad2: [u8; 128 - 2 * 4], - #[cfg(target_pointer_width = "64")] - __ss_pad2: [u8; 128 - 2 * 8], - } - pub struct sockaddr_in { pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, pub sin_zero: [u8; 8], } - pub struct in_addr { - pub s_addr: in_addr_t, - } - pub struct sockaddr_in6 { pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, + pub sin6_port: ::in_port_t, pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, + pub sin6_addr: ::in6_addr, pub sin6_scope_id: u32, } - pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108] } - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_align: isize, + #[cfg(target_pointer_width = "32")] + __ss_pad2: [u8; 128 - 2 * 4], + #[cfg(target_pointer_width = "64")] + __ss_pad2: [u8; 128 - 2 * 8], } pub struct addrinfo { @@ -75,50 +51,16 @@ s! { pub ai_addrlen: socklen_t, #[cfg(target_os = "linux")] - pub ai_addr: *mut sockaddr, + pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, #[cfg(any(target_os = "android", target_os = "nacl"))] - pub ai_addr: *mut sockaddr, + pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108] - } - - pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - pub struct sockaddr_ll { pub sll_family: c_ushort, pub sll_protocol: c_ushort, @@ -350,16 +292,8 @@ pub const LOCK_UN: ::c_int = 8; extern { pub fn fdatasync(fd: ::c_int) -> ::c_int; -} - -cfg_if! { - if #[cfg(target_pointer_width = "32")] { - mod b32; - pub use self::b32::*; - } else { - mod b64; - pub use self::b64::*; - } + pub fn mincore(addr: *mut ::c_void, len: size_t, + vec: *mut c_uchar) -> c_int; } cfg_if! { diff --git a/src/unix/other/bsdlike.rs b/src/unix/other/bsdlike.rs deleted file mode 100644 index 2928c2eb1b846..0000000000000 --- a/src/unix/other/bsdlike.rs +++ /dev/null @@ -1,22 +0,0 @@ -extern { - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_uint, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn mincore(addr: *const ::c_void, len: ::size_t, - vec: *mut ::c_char) -> ::c_int; - pub fn sysctlbyname(name: *const ::c_char, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn sysctlnametomib(name: *const ::c_char, - mibp: *mut ::c_int, - sizep: *mut ::size_t) - -> ::c_int; -} diff --git a/src/unix/other/mod.rs b/src/unix/other/mod.rs deleted file mode 100644 index 4f2d20ab0ab49..0000000000000 --- a/src/unix/other/mod.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! All Unix OS-es that are not android - -extern { - pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; - pub fn freeifaddrs(ifa: *mut ::ifaddrs); - pub fn glob(pattern: *const ::c_char, - flags: ::c_int, - errfunc: Option ::c_int>, - pglob: *mut ::glob_t); - pub fn globfree(pglob: *mut ::glob_t); - - pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - - pub fn shm_unlink(name: *const ::c_char) -> ::c_int; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "seekdir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "seekdir$INODE64$UNIX2003")] - pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); - - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "telldir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "telldir$INODE64$UNIX2003")] - pub fn telldir(dirp: *mut ::DIR) -> ::c_long; - - pub fn getsid(pid: ::pid_t) -> ::pid_t; - pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) - -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "putenv$UNIX2003")] - pub fn putenv(string: *mut ::c_char) -> ::c_int; - pub fn readlink(path: *const ::c_char, - buf: *mut ::c_char, - bufsz: ::size_t) - -> ::ssize_t; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "msync$UNIX2003")] - pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "mprotect$UNIX2003")] - pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) - -> ::c_int; - pub fn sysconf(name: ::c_int) -> ::c_long; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "usleep$UNIX2003")] - pub fn usleep(secs: ::c_uint) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recvfrom$UNIX2003")] - pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *mut ::sockaddr, - addrlen: *mut ::socklen_t) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "send$UNIX2003")] - pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, - flags: ::c_int) -> ::ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recv$UNIX2003")] - pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int) -> ::ssize_t; - pub fn mkfifo(path: *const ::c_char, mode: ::mode_t) -> ::c_int; -} - -cfg_if! { - if #[cfg(any(target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd"))] { - mod bsdlike; - pub use self::bsdlike::*; - } else { - mod notbsd; - pub use self::notbsd::*; - } -} diff --git a/src/unix/other/notbsd.rs b/src/unix/other/notbsd.rs deleted file mode 100644 index f42ea1fe24de1..0000000000000 --- a/src/unix/other/notbsd.rs +++ /dev/null @@ -1,14 +0,0 @@ -extern { - pub fn shm_open(name: *const ::c_char, oflag: ::c_int, - mode: ::mode_t) -> ::c_int; - #[cfg(not(target_env = "musl"))] - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn mincore(addr: *mut ::c_void, len: ::size_t, - vec: *mut ::c_uchar) -> ::c_int; -} From 27f7a6c1b27a9b3e899b9553d2eee72adea1795a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 14:32:14 -0700 Subject: [PATCH 098/194] Consolidate common linux defn's upwards --- src/unix/notbsd/linux/notmips/b32.rs | 19 +--------- src/unix/notbsd/linux/notmips/b64/aarch64.rs | 40 ++++++++++---------- src/unix/notbsd/linux/notmips/b64/mod.rs | 19 +--------- src/unix/notbsd/linux/notmips/b64/x86_64.rs | 2 +- src/unix/notbsd/linux/notmips/mod.rs | 18 +++++++++ 5 files changed, 41 insertions(+), 57 deletions(-) diff --git a/src/unix/notbsd/linux/notmips/b32.rs b/src/unix/notbsd/linux/notmips/b32.rs index 8eb4ef1f10d01..503ce5e770e3f 100644 --- a/src/unix/notbsd/linux/notmips/b32.rs +++ b/src/unix/notbsd/linux/notmips/b32.rs @@ -1,38 +1,21 @@ //! 32-bit specific definitions for linux-like values pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; pub type c_long = i32; pub type c_ulong = u32; -pub type c_float = f32; -pub type c_double = f64; pub type size_t = u32; pub type ptrdiff_t = i32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intptr_t = i32; pub type uintptr_t = u32; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type off_t = i32; pub type ino_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; +pub type off_t = i32; pub type ssize_t = i32; pub type blkcnt_t = i32; pub type blksize_t = i32; -pub type dev_t = u64; pub type mode_t = u32; pub type nlink_t = u32; diff --git a/src/unix/notbsd/linux/notmips/b64/aarch64.rs b/src/unix/notbsd/linux/notmips/b64/aarch64.rs index a22cd88bd3284..4bc5293de94af 100644 --- a/src/unix/notbsd/linux/notmips/b64/aarch64.rs +++ b/src/unix/notbsd/linux/notmips/b64/aarch64.rs @@ -1,31 +1,31 @@ //! AArch64-specific definitions for 64-bit linux-like values +pub type c_char = u8; pub type nlink_t = u32; pub type blksize_t = i32; -pub type c_char = u8; pub type wchar_t = u32; s! { pub struct stat { - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_mode: mode_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - __pad1: dev_t, - pub st_size: off_t, - pub st_blksize: blksize_t, - __pad2: c_int, - pub st_blocks: blkcnt_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - __unused: [c_int; 2], + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad1: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + __pad2: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_int; 2], } pub struct pthread_attr_t { diff --git a/src/unix/notbsd/linux/notmips/b64/mod.rs b/src/unix/notbsd/linux/notmips/b64/mod.rs index 3e6233fca4aba..582895b4fff9a 100644 --- a/src/unix/notbsd/linux/notmips/b64/mod.rs +++ b/src/unix/notbsd/linux/notmips/b64/mod.rs @@ -1,33 +1,16 @@ //! 64-bit specific definitions for linux-like values -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; pub type c_long = i64; pub type c_ulong = u64; -pub type c_float = f32; -pub type c_double = f64; pub type size_t = u64; pub type ptrdiff_t = i64; pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intptr_t = i64; pub type uintptr_t = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type off_t = i64; -pub type dev_t = u64; pub type ino_t = u64; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; +pub type off_t = i64; pub type mode_t = u32; pub type ssize_t = i64; pub type blkcnt_t = i64; diff --git a/src/unix/notbsd/linux/notmips/b64/x86_64.rs b/src/unix/notbsd/linux/notmips/b64/x86_64.rs index da85b5265efc2..22d0accb425ed 100644 --- a/src/unix/notbsd/linux/notmips/b64/x86_64.rs +++ b/src/unix/notbsd/linux/notmips/b64/x86_64.rs @@ -1,8 +1,8 @@ //! x86_64-specific definitions for 64-bit linux-like values +pub type c_char = i8; pub type nlink_t = u64; pub type blksize_t = i64; -pub type c_char = i8; pub type wchar_t = i32; s! { diff --git a/src/unix/notbsd/linux/notmips/mod.rs b/src/unix/notbsd/linux/notmips/mod.rs index 2fabb483635f7..0ddaa489ac29d 100644 --- a/src/unix/notbsd/linux/notmips/mod.rs +++ b/src/unix/notbsd/linux/notmips/mod.rs @@ -1,3 +1,21 @@ +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type dev_t = u64; +pub type gid_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type useconds_t = u32; + pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; From 6d3cfdb3e34f08baea6203bd23716f03059f1cd9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 14:53:01 -0700 Subject: [PATCH 099/194] Test signedness of integer types --- libc-test/build.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 04a34b1fcb707..e724a5fd9ffe2 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -318,7 +318,8 @@ fn main() { .flag("/wd4996"); // don't warn about deprecated functions } else { cfg.flag("-Wall").flag("-Wextra").flag("-Werror") - .flag("-Wno-unused-parameter"); + .flag("-Wno-unused-parameter") + .flag("-Wno-type-limits"); } drop(tg); @@ -337,6 +338,7 @@ impl<'a> TestGenerator<'a> { } let c = self.rust_ty_to_c_ty(ty); self.test_size_align(ty, &c); + self.test_sign(ty, &c); } fn test_struct(&mut self, ty: &str, s: &ast::StructDef) { @@ -410,6 +412,32 @@ impl<'a> TestGenerator<'a> { self.tests.push(format!("size_align_{}", rust)); } + fn test_sign(&mut self, rust: &str, c: &str) { + match c { + "float" | + "double" => return, + _ => {} + } + t!(writeln!(self.c, r#" + uint32_t __test_signed_{ty}(void) {{ + return ((({cty}) -1) < 0); + }} + "#, ty = rust, cty = c)); + t!(writeln!(self.rust, r#" + fn sign_{ty}() {{ + extern {{ + fn __test_signed_{ty}() -> u32; + }} + println!("verifying type {ty} sign"); + unsafe {{ + same(((!(0 as {ty})) < (0 as {ty})) as u32, + __test_signed_{ty}(), "{ty} signed"); + }} + }} + "#, ty = rust)); + self.tests.push(format!("sign_{}", rust)); + } + fn rust_ty_to_c_ty(&self, mut rust_ty: &str) -> String { let mut cty = self.rust2c(&rust_ty.replace("*mut ", "") .replace("*const ", "")); From 918f8e17f83a7eb58391525969bcb25362e8937f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 16:39:51 -0700 Subject: [PATCH 100/194] Move common linux defn's up --- src/unix/notbsd/linux/mips.rs | 17 ----------------- src/unix/notbsd/linux/mod.rs | 19 +++++++++++++++++++ src/unix/notbsd/linux/notmips/mod.rs | 17 ----------------- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 83ee1da075cbd..75125d4c2eb9e 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -1,36 +1,19 @@ pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; pub type c_long = i32; pub type c_ulong = u32; -pub type c_float = f32; -pub type c_double = f64; pub type size_t = u32; pub type ptrdiff_t = i32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intptr_t = i32; pub type uintptr_t = u32; -pub type intmax_t = i64; -pub type uintmax_t = u64; pub type off_t = i32; pub type ino_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; pub type ssize_t = i32; pub type blkcnt_t = i32; pub type blksize_t = i32; -pub type dev_t = u64; pub type mode_t = u32; pub type nlink_t = u32; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 049fd8e9e8ace..8d0328476310b 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -1,5 +1,24 @@ //! Linux-specific definitions for linux-like values +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type dev_t = u64; +pub type gid_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type useconds_t = u32; + s! { pub struct glob_t { pub gl_pathc: size_t, diff --git a/src/unix/notbsd/linux/notmips/mod.rs b/src/unix/notbsd/linux/notmips/mod.rs index 0ddaa489ac29d..3b3109c008bb1 100644 --- a/src/unix/notbsd/linux/notmips/mod.rs +++ b/src/unix/notbsd/linux/notmips/mod.rs @@ -1,20 +1,3 @@ -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type dev_t = u64; -pub type gid_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type useconds_t = u32; pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; From 9c99c16a2dd2d8dc8a0ad316b540f298b933d37e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 16:40:08 -0700 Subject: [PATCH 101/194] Fix signedness of c_char/c_wchar on ARM linux --- src/unix/notbsd/linux/notmips/b32/arm.rs | 2 ++ .../notbsd/linux/notmips/{b32.rs => b32/mod.rs} | 14 ++++++++++++-- src/unix/notbsd/linux/notmips/b32/x86.rs | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/unix/notbsd/linux/notmips/b32/arm.rs rename src/unix/notbsd/linux/notmips/{b32.rs => b32/mod.rs} (84%) create mode 100644 src/unix/notbsd/linux/notmips/b32/x86.rs diff --git a/src/unix/notbsd/linux/notmips/b32/arm.rs b/src/unix/notbsd/linux/notmips/b32/arm.rs new file mode 100644 index 0000000000000..1a92e3b4fa341 --- /dev/null +++ b/src/unix/notbsd/linux/notmips/b32/arm.rs @@ -0,0 +1,2 @@ +pub type c_char = u8; +pub type wchar_t = u32; diff --git a/src/unix/notbsd/linux/notmips/b32.rs b/src/unix/notbsd/linux/notmips/b32/mod.rs similarity index 84% rename from src/unix/notbsd/linux/notmips/b32.rs rename to src/unix/notbsd/linux/notmips/b32/mod.rs index 503ce5e770e3f..6928962cbacf3 100644 --- a/src/unix/notbsd/linux/notmips/b32.rs +++ b/src/unix/notbsd/linux/notmips/b32/mod.rs @@ -1,6 +1,5 @@ //! 32-bit specific definitions for linux-like values -pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; pub type size_t = u32; @@ -8,7 +7,6 @@ pub type ptrdiff_t = i32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; -pub type wchar_t = i32; pub type intptr_t = i32; pub type uintptr_t = u32; pub type ino_t = u32; @@ -47,3 +45,15 @@ s! { __size: [u32; 9] } } + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else { + // ... + } +} diff --git a/src/unix/notbsd/linux/notmips/b32/x86.rs b/src/unix/notbsd/linux/notmips/b32/x86.rs new file mode 100644 index 0000000000000..76ec3ce823e8f --- /dev/null +++ b/src/unix/notbsd/linux/notmips/b32/x86.rs @@ -0,0 +1,2 @@ +pub type c_char = i8; +pub type wchar_t = i32; From 526058705e4b840a5c45a615f238d815396f3822 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 16:49:37 -0700 Subject: [PATCH 102/194] More consolidation and fix all android types --- src/unix/mod.rs | 1 + src/unix/notbsd/android.rs | 23 +-- src/unix/notbsd/linux/mod.rs | 266 +++++++++++++++++------------------ src/unix/notbsd/mod.rs | 17 ++- 4 files changed, 147 insertions(+), 160 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 524b9be9a2a7f..631d86c4e0a8b 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -292,6 +292,7 @@ extern { pub fn flock(fd: c_int, operation: c_int) -> c_int; } +// TODO: get rid of this #[cfg(not(...))] #[cfg(not(target_os = "android"))] extern { pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; diff --git a/src/unix/notbsd/android.rs b/src/unix/notbsd/android.rs index 78c3f14c34f50..7d191a3ad3036 100644 --- a/src/unix/notbsd/android.rs +++ b/src/unix/notbsd/android.rs @@ -1,40 +1,27 @@ //! Android-specific definitions for linux-like values -pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; +pub type c_char = u8; pub type c_long = i32; pub type c_ulong = u32; -pub type c_float = f32; -pub type c_double = f64; pub type size_t = u32; pub type ptrdiff_t = i32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; -pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; +pub type wchar_t = u32; pub type intptr_t = i32; pub type uintptr_t = u32; -pub type intmax_t = i64; -pub type uintmax_t = u64; pub type off_t = i32; pub type ino_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; pub type ssize_t = i32; pub type blkcnt_t = u32; pub type blksize_t = u32; pub type dev_t = u32; pub type mode_t = u16; pub type nlink_t = u16; +pub type useconds_t = i32; +pub type socklen_t = i32; +pub type pthread_t = c_long; s! { pub struct stat { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 8d0328476310b..4f98565c34d5f 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -1,30 +1,16 @@ //! Linux-specific definitions for linux-like values -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; - -pub type dev_t = u64; -pub type gid_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; pub type useconds_t = u32; +pub type dev_t = u64; +pub type socklen_t = u32; +pub type pthread_t = c_ulong; s! { pub struct glob_t { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, - pub gl_flags: c_int, + pub gl_flags: ::c_int, __unused1: *mut ::c_void, __unused2: *mut ::c_void, @@ -36,7 +22,7 @@ s! { pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, + pub ifa_flags: ::c_uint, pub ifa_addr: *mut ::sockaddr, pub ifa_netmask: *mut ::sockaddr, pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union @@ -44,147 +30,147 @@ s! { } } -pub const BUFSIZ: c_uint = 8192; -pub const FILENAME_MAX: c_uint = 4096; -pub const FOPEN_MAX: c_uint = 16; -pub const L_tmpnam: c_uint = 20; -pub const TMP_MAX: c_uint = 238328; -pub const _PC_NAME_MAX: c_int = 3; - -pub const _SC_ARG_MAX: c_int = 0; -pub const _SC_CHILD_MAX: c_int = 1; -pub const _SC_CLK_TCK: c_int = 2; -pub const _SC_NGROUPS_MAX: c_int = 3; -pub const _SC_OPEN_MAX: c_int = 4; -pub const _SC_STREAM_MAX: c_int = 5; -pub const _SC_TZNAME_MAX: c_int = 6; -pub const _SC_JOB_CONTROL: c_int = 7; -pub const _SC_SAVED_IDS: c_int = 8; -pub const _SC_REALTIME_SIGNALS: c_int = 9; -pub const _SC_PRIORITY_SCHEDULING: c_int = 10; -pub const _SC_TIMERS: c_int = 11; -pub const _SC_ASYNCHRONOUS_IO: c_int = 12; -pub const _SC_PRIORITIZED_IO: c_int = 13; -pub const _SC_SYNCHRONIZED_IO: c_int = 14; -pub const _SC_FSYNC: c_int = 15; -pub const _SC_MAPPED_FILES: c_int = 16; -pub const _SC_MEMLOCK: c_int = 17; -pub const _SC_MEMLOCK_RANGE: c_int = 18; -pub const _SC_MEMORY_PROTECTION: c_int = 19; -pub const _SC_MESSAGE_PASSING: c_int = 20; -pub const _SC_SEMAPHORES: c_int = 21; -pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; -pub const _SC_AIO_LISTIO_MAX: c_int = 23; -pub const _SC_AIO_MAX: c_int = 24; -pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; -pub const _SC_DELAYTIMER_MAX: c_int = 26; -pub const _SC_MQ_OPEN_MAX: c_int = 27; -pub const _SC_MQ_PRIO_MAX: c_int = 28; -pub const _SC_VERSION: c_int = 29; -pub const _SC_PAGESIZE: c_int = 30; -pub const _SC_RTSIG_MAX: c_int = 31; -pub const _SC_SEM_NSEMS_MAX: c_int = 32; -pub const _SC_SEM_VALUE_MAX: c_int = 33; -pub const _SC_SIGQUEUE_MAX: c_int = 34; -pub const _SC_TIMER_MAX: c_int = 35; -pub const _SC_BC_BASE_MAX: c_int = 36; -pub const _SC_BC_DIM_MAX: c_int = 37; -pub const _SC_BC_SCALE_MAX: c_int = 38; -pub const _SC_BC_STRING_MAX: c_int = 39; -pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; -pub const _SC_EXPR_NEST_MAX: c_int = 42; -pub const _SC_LINE_MAX: c_int = 43; -pub const _SC_RE_DUP_MAX: c_int = 44; -pub const _SC_2_VERSION: c_int = 46; -pub const _SC_2_C_BIND: c_int = 47; -pub const _SC_2_C_DEV: c_int = 48; -pub const _SC_2_FORT_DEV: c_int = 49; -pub const _SC_2_FORT_RUN: c_int = 50; -pub const _SC_2_SW_DEV: c_int = 51; -pub const _SC_2_LOCALEDEF: c_int = 52; -pub const _SC_IOV_MAX: c_int = 60; -pub const _SC_THREADS: c_int = 67; -pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; -pub const _SC_LOGIN_NAME_MAX: c_int = 71; -pub const _SC_TTY_NAME_MAX: c_int = 72; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; -pub const _SC_THREAD_KEYS_MAX: c_int = 74; -pub const _SC_THREAD_STACK_MIN: c_int = 75; -pub const _SC_THREAD_THREADS_MAX: c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; -pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; -pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; -pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; -pub const _SC_NPROCESSORS_ONLN: c_int = 84; -pub const _SC_ATEXIT_MAX: c_int = 87; -pub const _SC_XOPEN_VERSION: c_int = 89; -pub const _SC_XOPEN_XCU_VERSION: c_int = 90; -pub const _SC_XOPEN_UNIX: c_int = 91; -pub const _SC_XOPEN_CRYPT: c_int = 92; -pub const _SC_XOPEN_ENH_I18N: c_int = 93; -pub const _SC_XOPEN_SHM: c_int = 94; -pub const _SC_2_CHAR_TERM: c_int = 95; -pub const _SC_2_C_VERSION: c_int = 96; -pub const _SC_2_UPE: c_int = 97; -pub const _SC_XBS5_ILP32_OFF32: c_int = 125; -pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; -pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; -pub const _SC_XOPEN_LEGACY: c_int = 129; -pub const _SC_XOPEN_REALTIME: c_int = 130; -pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const BUFSIZ: ::c_uint = 8192; +pub const FILENAME_MAX: ::c_uint = 4096; +pub const FOPEN_MAX: ::c_uint = 16; +pub const L_tmpnam: ::c_uint = 20; +pub const TMP_MAX: ::c_uint = 238328; +pub const _PC_NAME_MAX: ::c_int = 3; + +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_CHILD_MAX: ::c_int = 1; +pub const _SC_CLK_TCK: ::c_int = 2; +pub const _SC_NGROUPS_MAX: ::c_int = 3; +pub const _SC_OPEN_MAX: ::c_int = 4; +pub const _SC_STREAM_MAX: ::c_int = 5; +pub const _SC_TZNAME_MAX: ::c_int = 6; +pub const _SC_JOB_CONTROL: ::c_int = 7; +pub const _SC_SAVED_IDS: ::c_int = 8; +pub const _SC_REALTIME_SIGNALS: ::c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; +pub const _SC_TIMERS: ::c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; +pub const _SC_PRIORITIZED_IO: ::c_int = 13; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; +pub const _SC_FSYNC: ::c_int = 15; +pub const _SC_MAPPED_FILES: ::c_int = 16; +pub const _SC_MEMLOCK: ::c_int = 17; +pub const _SC_MEMLOCK_RANGE: ::c_int = 18; +pub const _SC_MEMORY_PROTECTION: ::c_int = 19; +pub const _SC_MESSAGE_PASSING: ::c_int = 20; +pub const _SC_SEMAPHORES: ::c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; +pub const _SC_AIO_MAX: ::c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; +pub const _SC_DELAYTIMER_MAX: ::c_int = 26; +pub const _SC_MQ_OPEN_MAX: ::c_int = 27; +pub const _SC_MQ_PRIO_MAX: ::c_int = 28; +pub const _SC_VERSION: ::c_int = 29; +pub const _SC_PAGESIZE: ::c_int = 30; +pub const _SC_RTSIG_MAX: ::c_int = 31; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; +pub const _SC_SEM_VALUE_MAX: ::c_int = 33; +pub const _SC_SIGQUEUE_MAX: ::c_int = 34; +pub const _SC_TIMER_MAX: ::c_int = 35; +pub const _SC_BC_BASE_MAX: ::c_int = 36; +pub const _SC_BC_DIM_MAX: ::c_int = 37; +pub const _SC_BC_SCALE_MAX: ::c_int = 38; +pub const _SC_BC_STRING_MAX: ::c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; +pub const _SC_EXPR_NEST_MAX: ::c_int = 42; +pub const _SC_LINE_MAX: ::c_int = 43; +pub const _SC_RE_DUP_MAX: ::c_int = 44; +pub const _SC_2_VERSION: ::c_int = 46; +pub const _SC_2_C_BIND: ::c_int = 47; +pub const _SC_2_C_DEV: ::c_int = 48; +pub const _SC_2_FORT_DEV: ::c_int = 49; +pub const _SC_2_FORT_RUN: ::c_int = 50; +pub const _SC_2_SW_DEV: ::c_int = 51; +pub const _SC_2_LOCALEDEF: ::c_int = 52; +pub const _SC_IOV_MAX: ::c_int = 60; +pub const _SC_THREADS: ::c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; +pub const _SC_TTY_NAME_MAX: ::c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; +pub const _SC_THREAD_STACK_MIN: ::c_int = 75; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; +pub const _SC_ATEXIT_MAX: ::c_int = 87; +pub const _SC_XOPEN_VERSION: ::c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; +pub const _SC_XOPEN_UNIX: ::c_int = 91; +pub const _SC_XOPEN_CRYPT: ::c_int = 92; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; +pub const _SC_XOPEN_SHM: ::c_int = 94; +pub const _SC_2_CHAR_TERM: ::c_int = 95; +pub const _SC_2_C_VERSION: ::c_int = 96; +pub const _SC_2_UPE: ::c_int = 97; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; +pub const _SC_XOPEN_LEGACY: ::c_int = 129; +pub const _SC_XOPEN_REALTIME: ::c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; #[cfg(not(target_env = "musl"))] -pub const RUSAGE_THREAD: c_int = 1; - -pub const GLOB_ERR: c_int = 1 << 0; -pub const GLOB_MARK: c_int = 1 << 1; -pub const GLOB_NOSORT: c_int = 1 << 2; -pub const GLOB_DOOFFS: c_int = 1 << 3; -pub const GLOB_NOCHECK: c_int = 1 << 4; -pub const GLOB_APPEND: c_int = 1 << 5; -pub const GLOB_NOESCAPE: c_int = 1 << 6; - -pub const GLOB_NOSPACE: c_int = 1; -pub const GLOB_ABORTED: c_int = 2; -pub const GLOB_NOMATCH: c_int = 3; - -pub const POSIX_MADV_NORMAL: c_int = 0; -pub const POSIX_MADV_RANDOM: c_int = 1; -pub const POSIX_MADV_SEQUENTIAL: c_int = 2; -pub const POSIX_MADV_WILLNEED: c_int = 3; -pub const POSIX_MADV_DONTNEED: c_int = 4; +pub const RUSAGE_THREAD: ::c_int = 1; + +pub const GLOB_ERR: ::c_int = 1 << 0; +pub const GLOB_MARK: ::c_int = 1 << 1; +pub const GLOB_NOSORT: ::c_int = 1 << 2; +pub const GLOB_DOOFFS: ::c_int = 1 << 3; +pub const GLOB_NOCHECK: ::c_int = 1 << 4; +pub const GLOB_APPEND: ::c_int = 1 << 5; +pub const GLOB_NOESCAPE: ::c_int = 1 << 6; + +pub const GLOB_NOSPACE: ::c_int = 1; +pub const GLOB_ABORTED: ::c_int = 2; +pub const GLOB_NOMATCH: ::c_int = 3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const S_IEXEC: mode_t = 64; pub const S_IWRITE: mode_t = 128; pub const S_IREAD: mode_t = 256; -pub const F_LOCK: c_int = 1; -pub const F_TEST: c_int = 3; -pub const F_TLOCK: c_int = 2; -pub const F_ULOCK: c_int = 0; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub const MAP_32BIT: c_int = 0x0040; +pub const MAP_32BIT: ::c_int = 0x0040; -pub const TCP_MD5SIG: c_int = 14; +pub const TCP_MD5SIG: ::c_int = 14; extern { - pub fn shm_open(name: *const c_char, oflag: c_int, - mode: mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: ::c_int, + mode: mode_t) -> ::c_int; #[cfg(not(target_env = "musl"))] - pub fn sysctl(name: *mut c_int, - namelen: c_int, + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_int, oldp: *mut ::c_void, oldlenp: *mut size_t, newp: *mut ::c_void, newlen: size_t) - -> c_int; + -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 8222c01a0c4c6..a45f16d5721bb 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -1,10 +1,23 @@ +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; pub type in_addr_t = u32; pub type in_port_t = u16; -pub type pthread_t = c_ulong; pub type rlim_t = c_ulong; pub type sa_family_t = u16; pub type sighandler_t = size_t; -pub type socklen_t = u32; pub enum timezone {} From 64768f5aebb9c64b160e45c8f43a05ceec28ccad Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 16:56:56 -0700 Subject: [PATCH 103/194] Fix compile on OSX --- src/unix/bsd/apple/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 97e42786cd74c..9edcaef7b32ac 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -76,7 +76,7 @@ s! { pub ai_protocol: c_int, pub ai_addrlen: socklen_t, pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, + pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } @@ -84,9 +84,9 @@ s! { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut c_char, pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_dstaddr: *mut ::sockaddr, pub ifa_data: *mut ::c_void } @@ -603,7 +603,7 @@ pub const _SC_PASS_MAX: c_int = 131; extern { pub fn _NSGetExecutablePath(buf: *mut c_char, - bufsize: *mut uint32_t) -> c_int; + bufsize: *mut ::uint32_t) -> c_int; } cfg_if! { From eef03da0f960fca4b2dd7c7c74381c4ee1893989 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 16:57:06 -0700 Subject: [PATCH 104/194] Don't test mach_timebase_info_t signedness It's just a struct --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index e724a5fd9ffe2..b0303e1513106 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -415,6 +415,7 @@ impl<'a> TestGenerator<'a> { fn test_sign(&mut self, rust: &str, c: &str) { match c { "float" | + "mach_timebase_info_data_t" | "double" => return, _ => {} } From 8293cede01fb1beb1fa4ca0bcba4fad9fc791f1f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 17:05:19 -0700 Subject: [PATCH 105/194] Get FreeBSD compiling --- libc-test/build.rs | 3 +++ src/unix/bsd/apple/mod.rs | 22 +++++++++++++++++-- src/unix/bsd/freebsdlike/mod.rs | 38 ++++++++++++++++++++++----------- src/unix/bsd/mod.rs | 14 ------------ src/unix/bsd/openbsdlike/mod.rs | 20 ++++++++++++++++- src/unix/mod.rs | 4 ---- src/unix/notbsd/mod.rs | 6 ++++-- 7 files changed, 71 insertions(+), 36 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index b0303e1513106..4fd85222a3a7f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -228,6 +228,8 @@ impl<'a> TestGenerator<'a> { ("windows", "windows", "gnu") } else if self.target.contains("android") { ("android", "unix", "") + } else if self.target.contains("unknown-freebsd") { + ("freebsd", "unix", "") } else { panic!("unknown os/family width: {}", self.target) }; @@ -417,6 +419,7 @@ impl<'a> TestGenerator<'a> { "float" | "mach_timebase_info_data_t" | "double" => return, + n if n.starts_with("pthread") => return, _ => {} } t!(writeln!(self.c, r#" diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 9edcaef7b32ac..71b24a6931e93 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -602,8 +602,26 @@ pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130; pub const _SC_PASS_MAX: c_int = 131; extern { - pub fn _NSGetExecutablePath(buf: *mut c_char, - bufsize: *mut ::uint32_t) -> c_int; + pub fn _NSGetExecutablePath(buf: *mut ::c_char, + bufsize: *mut ::uint32_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "mprotect$UNIX2003")] + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::c_int; + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn sysctlbyname(name: *const ::c_char, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4c582c45ed1ca..fc50c2201b91c 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -57,7 +57,7 @@ s! { pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; -pub const RAND_MAX: ::c_int = 2147483647; +pub const RAND_MAX: ::c_int = 0x7fff_fffd; pub const EOF: ::c_int = -1; pub const SEEK_SET: ::c_int = 0; pub const SEEK_CUR: ::c_int = 1; @@ -238,14 +238,7 @@ pub const EBADMSG: ::c_int = 89; pub const EMULTIHOP: ::c_int = 90; pub const ENOLINK: ::c_int = 91; pub const EPROTO: ::c_int = 92; -pub const ENOMEDIUM: ::c_int = 93; -pub const EUNUSED94: ::c_int = 94; -pub const EUNUSED95: ::c_int = 95; -pub const EUNUSED96: ::c_int = 96; -pub const EUNUSED97: ::c_int = 97; -pub const EUNUSED98: ::c_int = 98; -pub const EASYNC: ::c_int = 99; -pub const ELAST: ::c_int = 99; +pub const ELAST: ::c_int = 96; pub const F_DUPFD: ::c_int = 0; pub const F_GETFD: ::c_int = 1; @@ -323,9 +316,8 @@ pub const RLIMIT_VMEM: ::c_int = 10; pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; pub const RLIMIT_NPTS: ::c_int = 11; pub const RLIMIT_SWAP: ::c_int = 12; -pub const RLIMIT_KQUEUES: ::c_int = 13; -pub const RLIM_NLIMITS: rlim_t = 14; +pub const RLIM_NLIMITS: rlim_t = 13; pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; pub const RUSAGE_SELF: ::c_int = 0; @@ -366,8 +358,8 @@ pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; -pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; -pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_KEEPIDLE: ::c_int = 256; @@ -470,6 +462,26 @@ pub const _SC_SEM_VALUE_MAX: ::c_int = 50; pub const _SC_SIGQUEUE_MAX: ::c_int = 51; pub const _SC_TIMER_MAX: ::c_int = 52; +extern { + pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) + -> c_int; + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) + -> ::c_int; + pub fn sysctl(name: *const c_int, + namelen: c_uint, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *const ::c_void, + newlen: size_t) + -> c_int; + pub fn sysctlbyname(name: *const c_char, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *const ::c_void, + newlen: size_t) + -> c_int; +} + cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 783298c184978..cdfe504d41b6c 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -30,22 +30,8 @@ s! { } extern { - pub fn shm_open(name: *const c_char, oflag: c_int, ...) -> c_int; - pub fn sysctl(name: *mut c_int, - namelen: c_uint, - oldp: *mut ::c_void, - oldlenp: *mut size_t, - newp: *mut ::c_void, - newlen: size_t) - -> c_int; pub fn mincore(addr: *const ::c_void, len: size_t, vec: *mut c_char) -> c_int; - pub fn sysctlbyname(name: *const c_char, - oldp: *mut ::c_void, - oldlenp: *mut size_t, - newp: *mut ::c_void, - newlen: size_t) - -> c_int; pub fn sysctlnametomib(name: *const c_char, mibp: *mut c_int, sizep: *mut size_t) diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index d3c0f5f50d755..f003630199084 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -710,4 +710,22 @@ pub const _SC_TIMERS : c_int = 94; } } - +extern { + pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) + -> c_int; + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) + -> ::c_int; + pub fn sysctl(name: *mut c_int, + namelen: c_uint, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *mut ::c_void, + newlen: size_t) + -> c_int; + pub fn sysctlbyname(name: *const c_char, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *mut ::c_void, + newlen: size_t) + -> c_int; +} diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 631d86c4e0a8b..820b59df42061 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -336,10 +336,6 @@ extern { #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "msync$UNIX2003")] pub fn msync(addr: *mut ::c_void, len: size_t, flags: c_int) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "mprotect$UNIX2003")] - pub fn mprotect(addr: *mut ::c_void, len: size_t, prot: c_int) - -> c_int; pub fn sysconf(name: c_int) -> c_long; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "usleep$UNIX2003")] diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index a45f16d5721bb..8ae7964a2089a 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -305,8 +305,10 @@ pub const LOCK_UN: ::c_int = 8; extern { pub fn fdatasync(fd: ::c_int) -> ::c_int; - pub fn mincore(addr: *mut ::c_void, len: size_t, - vec: *mut c_uchar) -> c_int; + pub fn mincore(addr: *mut ::c_void, len: ::size_t, + vec: *mut ::c_uchar) -> ::c_int; + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; } cfg_if! { From 9d5b8b2c5a7903179fc8f558feaccf69822339b4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 17:14:23 -0700 Subject: [PATCH 106/194] Fix android build --- src/unix/notbsd/linux/mod.rs | 2 ++ src/unix/notbsd/mod.rs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 4f98565c34d5f..d17f3306a70cb 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -171,6 +171,8 @@ extern { newp: *mut ::c_void, newlen: size_t) -> ::c_int; + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 8ae7964a2089a..87fec5e17ff92 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -307,8 +307,6 @@ extern { pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; - pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) - -> ::c_int; } cfg_if! { From 2c57e36e1230e7a37d2f3ffbf2563d423245e199 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 17:30:53 -0700 Subject: [PATCH 107/194] Move linkage to specific modules --- Cargo.toml | 3 +++ src/linkage.rs | 38 -------------------------------------- src/unix/mod.rs | 14 ++++++++++++++ src/windows.rs | 6 ++++++ 4 files changed, 23 insertions(+), 38 deletions(-) delete mode 100644 src/linkage.rs diff --git a/Cargo.toml b/Cargo.toml index e6b56d4bc5c6b..76a29c6517434 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,6 @@ description = """ A library for types and bindings to native C functions often found in libc or other common platform libraries. """ + +[features] +default = [] diff --git a/src/linkage.rs b/src/linkage.rs deleted file mode 100644 index 721325c684d2e..0000000000000 --- a/src/linkage.rs +++ /dev/null @@ -1,38 +0,0 @@ - -// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them -// in when creating a test crate. -#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))] -#[link(name = "c")] -#[link(name = "m")] -extern {} - -// When compiling rust with musl, statically include libc.a in liblibc.rlib. -// A cargo build of the libc crate will therefore automatically pick up the -// libc.a symbols because liblibc is transitively linked to by the stdlib. -#[cfg(all(target_env = "musl", not(feature = "cargo-build"), not(test)))] -#[link(name = "c", kind = "static")] -extern {} - -#[cfg(all(windows, target_env = "msvc"))] -#[link(name = "kernel32")] -#[link(name = "shell32")] -#[link(name = "msvcrt")] -extern {} - -// libnacl provides functions that require a trip through the IRT to work. -// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip -// to the kernel. -#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] -#[link(name = "nacl", kind = "static")] -extern {} - -// pnaclmm provides a number of functions that the toolchain's Clang emits calls -// to when codegening atomic ops. All the functions within wrap various atomic -// operations. -// Yes, it could be linked by rustc explicitly, however by linking it here -// instead we save a bit of time where bins are involved (by not running the -// optimizations on the whole pnaclmm foreach binary built). -#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))] -#[link(name = "pnaclmm", kind = "static")] -extern {} - diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 820b59df42061..14c427fd3aab8 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -63,6 +63,20 @@ s! { } } +cfg_if! { + if #[cfg(feature = "default")] { + // cargo build, don't pull in anything extra as the libstd libc dep + // already pulls in all libs. + } else if #[cfg(target_env = "musl")] { + #[link(name = "c", kind = "static")] + extern {} + } else { + #[link(name = "c")] + #[link(name = "m")] + extern {} + } +} + extern { pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), diff --git a/src/windows.rs b/src/windows.rs index 159a311f8bafa..cade64df5228c 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -667,6 +667,12 @@ pub const IPPROTO_RAW: c_int = 255; pub const FIONBIO: c_long = -0x7FFB9982; +#[cfg(target_env = "msvc")] +#[link(name = "kernel32")] +#[link(name = "shell32")] +#[link(name = "msvcrt")] +extern {} + extern { #[link_name = "_chmod"] pub fn chmod(path: *const c_char, mode: c_int) -> c_int; From 7b28c271d6797f77718b78cdb5f5c425f2de254b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 20:56:16 -0700 Subject: [PATCH 108/194] Fix build on MSVC --- libc-test/build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4fd85222a3a7f..7c995d0487230 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -317,7 +317,8 @@ fn main() { cfg.flag("/W3").flag("/Wall").flag("/WX") .flag("/wd4820") // weird warning about adding padding? .flag("/wd4100") // don't warn about unused parameters - .flag("/wd4996"); // don't warn about deprecated functions + .flag("/wd4996") // don't warn about deprecated functions + .flag("/wd4296"); // don't warn about '<' being always false } else { cfg.flag("-Wall").flag("-Wextra").flag("-Werror") .flag("-Wno-unused-parameter") @@ -416,8 +417,9 @@ impl<'a> TestGenerator<'a> { fn test_sign(&mut self, rust: &str, c: &str) { match c { - "float" | + "LARGE_INTEGER" | "mach_timebase_info_data_t" | + "float" | "double" => return, n if n.starts_with("pthread") => return, _ => {} From 1846918fe2893f086a5d30ebf58bb17198681d1a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 20:57:42 -0700 Subject: [PATCH 109/194] Fix windows build --- libc-test/build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7c995d0487230..7bca1484b6be1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -422,6 +422,11 @@ impl<'a> TestGenerator<'a> { "float" | "double" => return, n if n.starts_with("pthread") => return, + + // windows-isms + n if n.starts_with("P") => return, + n if n.starts_with("H") => return, + n if n.starts_with("LP") => return, _ => {} } t!(writeln!(self.c, r#" From d11e9141b256b627a4679875369102506935f4e4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 15 Sep 2015 23:28:52 -0700 Subject: [PATCH 110/194] Switch to ctest crate Extracted tests! --- appveyor.yml | 2 +- ci/run.sh | 10 +- libc-test/Cargo.lock | 100 ------ libc-test/Cargo.toml | 12 +- libc-test/build.rs | 721 ++++++----------------------------------- libc-test/src/lib.rs | 0 libc-test/src/main.rs | 6 + libc-test/tests/all.rs | 73 ----- 8 files changed, 120 insertions(+), 804 deletions(-) delete mode 100644 libc-test/Cargo.lock delete mode 100644 libc-test/src/lib.rs create mode 100644 libc-test/src/main.rs delete mode 100644 libc-test/tests/all.rs diff --git a/appveyor.yml b/appveyor.yml index 7c01515f6c3d2..cdd5bf1abb74e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,4 +25,4 @@ build: false test_script: - cargo test - - cargo test --manifest-path libc-test/Cargo.toml + - cargo run --manifest-path libc-test/Cargo.toml diff --git a/ci/run.sh b/ci/run.sh index 368037b26759e..9604f1be11378 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -3,19 +3,19 @@ set -ex TARGET=$1 -cargo test --manifest-path libc-test/Cargo.toml --no-run --target $TARGET +cargo build --manifest-path libc-test/Cargo.toml --target $TARGET if [ "$TARGET" = "arm-linux-androideabi" ]; then emulator @test -no-window & adb wait-for-device - adb push /root/target/$TARGET/debug/all-* /data/test - adb shell /data/test + adb push /root/target/$TARGET/debug/libc-test /data/libc-test + adb shell /data/libc-test elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then - qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/all-* + qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/libc-test elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then # FIXME: this segfaults on travis, passes locally? #qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-* echo skip else - cargo test --manifest-path libc-test/Cargo.toml --target $TARGET + cargo run --manifest-path libc-test/Cargo.toml --target $TARGET fi diff --git a/libc-test/Cargo.lock b/libc-test/Cargo.lock deleted file mode 100644 index 1726c5370150b..0000000000000 --- a/libc-test/Cargo.lock +++ /dev/null @@ -1,100 +0,0 @@ -[root] -name = "libc-test" -version = "0.1.0" -dependencies = [ - "gcc 0.3.13 (git+https://github.com/alexcrichton/gcc-rs)", - "libc 0.1.10", - "syntex_syntax 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "advapi32-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bitflags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "gcc" -version = "0.3.13" -source = "git+https://github.com/alexcrichton/gcc-rs#e429c775dcbb03eb049bcb7f7215cf8d9ee3b837" -dependencies = [ - "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kernel32-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "libc" -version = "0.1.10" - -[[package]] -name = "libc" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc-serialize" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syntex_syntax" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "term" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index fee56fee20282..9ff476579f6e1 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -8,14 +8,4 @@ build = "build.rs" libc = { path = ".." } [build-dependencies] -syntex_syntax = "0.13.0" -gcc = { git = "https://github.com/alexcrichton/gcc-rs" } - -[lib] -name = "libc_test" -test = false -doctest = false - -[[test]] -name = "all" -harness = false +ctest = { git = "https://github.com/alexcrichton/ctest" } diff --git a/libc-test/build.rs b/libc-test/build.rs index 7bca1484b6be1..50ded54100b57 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1,161 +1,87 @@ -extern crate gcc; -extern crate syntex_syntax as syntax; +extern crate ctest; -use std::collections::HashSet; use std::env; -use std::fs::File; -use std::io::BufWriter; -use std::io::prelude::*; -use std::path::{Path, PathBuf}; -use syntax::abi::Abi; -use syntax::ast; -use syntax::attr::{self, ReprAttr}; -use syntax::diagnostic::SpanHandler; -use syntax::ext::base::SyntaxExtension; -use syntax::ext::expand; -use syntax::parse::token::{intern, InternedString}; -use syntax::parse::{self, ParseSess}; -use syntax::visit::{self, Visitor}; - -macro_rules! t { - ($e:expr) => (match $e { - Ok(e) => e, - Err(e) => panic!("{} failed with {}", stringify!($e), e), - }) -} - -struct TestGenerator<'a> { - target: String, - rust: Box, - c: Box, - sh: &'a SpanHandler, - structs: HashSet, - abi: Abi, - tests: Vec, -} - -struct StructFinder { - structs: HashSet, -} - -impl<'a> TestGenerator<'a> { - fn defines(&self) -> Vec<&'static str> { - let mut ret = Vec::new(); - - // Pull in extra goodies on linux - if self.target.contains("unknown-linux-gnu") { - ret.push("_GNU_SOURCE"); - } - - // MSVC doesn't have stdalign.h so get alignof ourselves - if self.target.contains("msvc") { - ret.push("alignof __alignof"); - } - - // android also doesn't have stdalign.h so get alignof ourselves - if self.target.contains("android") || self.target.contains("mips") { - ret.push("alignof __alignof__"); - } - - // Pull in extra goodies on mingw - if self.target.contains("windows") { - ret.push("_WIN32_WINNT 0x8000"); - } - return ret - } - - fn headers(&self) -> Vec<&'static str> { - let mut base = Vec::new(); - - base.extend([ - "errno.h", - "fcntl.h", - "limits.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "sys/stat.h", - "sys/types.h", - "time.h", - "wchar.h", - ].iter().cloned()); - - if self.target.contains("apple-darwin") { - base.push("mach-o/dyld.h"); - base.push("mach/mach_time.h"); - } - - if self.target.contains("unknown-linux") || - self.target.contains("android") { - base.push("linux/if_packet.h"); - base.push("net/ethernet.h"); +fn main() { + let target = env::var("TARGET").unwrap(); + let windows = target.contains("windows"); + let mingw = target.contains("windows-gnu"); + let mut cfg = ctest::TestGenerator::new(); + + // Pull in extra goodies on linux/mingw + if target.contains("unknown-linux-gnu") { + cfg.define("_GNU_SOURCE", None); + } else if target.contains("windows") { + cfg.define("_WIN32_WINNT", Some("0x8000")); + } + + cfg.header("errno.h") + .header("fcntl.h") + .header("limits.h") + .header("stddef.h") + .header("stdint.h") + .header("stdio.h") + .header("stdlib.h") + .header("sys/stat.h") + .header("sys/types.h") + .header("time.h") + .header("wchar.h"); + + if target.contains("apple-darwin") { + cfg.header("mach-o/dyld.h"); + cfg.header("mach/mach_time.h"); + } else if target.contains("unknown-linux") || + target.contains("android") { + cfg.header("linux/if_packet.h"); + cfg.header("net/ethernet.h"); + } + + if target.contains("windows") { + cfg.header("winsock2.h"); // must be before windows.h + + cfg.header("direct.h"); + cfg.header("io.h"); + cfg.header("sys/utime.h"); + cfg.header("windows.h"); + cfg.header("process.h"); + cfg.header("ws2ipdef.h"); + + if target.contains("gnu") { + cfg.header("ws2tcpip.h"); } - - if self.target.contains("windows") { - base.push("winsock2.h"); // must be before windows.h - - base.push("direct.h"); - base.push("io.h"); - base.push("sys/utime.h"); - base.push("windows.h"); - base.push("process.h"); - base.push("ws2ipdef.h"); - - if self.target.contains("gnu") { - base.push("stdalign.h"); - base.push("ws2tcpip.h"); - } + } else { + cfg.header("ctype.h"); + cfg.header("dirent.h"); + cfg.header("net/if.h"); + cfg.header("netdb.h"); + cfg.header("netinet/in.h"); + cfg.header("netinet/ip.h"); + cfg.header("netinet/tcp.h"); + cfg.header("pthread.h"); + cfg.header("signal.h"); + cfg.header("string.h"); + cfg.header("sys/file.h"); + cfg.header("sys/ioctl.h"); + cfg.header("sys/mman.h"); + cfg.header("sys/resource.h"); + cfg.header("sys/socket.h"); + cfg.header("sys/time.h"); + cfg.header("sys/un.h"); + cfg.header("sys/wait.h"); + cfg.header("unistd.h"); + cfg.header("utime.h"); + + if target.contains("android") { + cfg.header("arpa/inet.h"); } else { - base.push("ctype.h"); - base.push("dirent.h"); - base.push("net/if.h"); - base.push("netdb.h"); - base.push("netinet/in.h"); - base.push("netinet/ip.h"); - base.push("netinet/tcp.h"); - base.push("pthread.h"); - base.push("signal.h"); - base.push("string.h"); - base.push("sys/file.h"); - base.push("sys/ioctl.h"); - base.push("sys/mman.h"); - base.push("sys/resource.h"); - base.push("sys/socket.h"); - base.push("sys/time.h"); - base.push("sys/un.h"); - base.push("sys/wait.h"); - base.push("unistd.h"); - base.push("utime.h"); - - if self.target.contains("android") { - base.push("arpa/inet.h"); - } else { - base.push("glob.h"); - base.push("ifaddrs.h"); - if !self.target.contains("mips") { - base.push("stdalign.h"); - } - base.push("sys/sysctl.h"); - } + cfg.header("glob.h"); + cfg.header("ifaddrs.h"); + cfg.header("sys/sysctl.h"); } - - return base } - fn rust2c(&self, ty: &str) -> String { - let windows = self.target.contains("windows"); + cfg.type_name(move |ty, is_struct| { match ty { - t if t.starts_with("c_") => { - match &ty[2..].replace("long", " long")[..] { - s if s.starts_with("u") => format!("unsigned {}", &s[1..]), - "short" => format!("short"), - s if s.starts_with("s") => format!("signed {}", &s[1..]), - s => s.to_string(), - } - } - // Just pass all these through, no need for a "struct" prefix "glob_t" | "FILE" | @@ -166,7 +92,7 @@ impl<'a> TestGenerator<'a> { // Windows uppercase structs don't have `struct` in front, there's a // few special cases for windows, and then otherwise put `struct` in // front of everything. - t if self.structs.contains(t) => { + t if is_struct => { if windows && ty.chars().next().unwrap().is_uppercase() { t.to_string() } else if windows && t == "stat" { @@ -184,16 +110,17 @@ impl<'a> TestGenerator<'a> { t => t.to_string(), } - } + }); - fn rust2cfield(&self, struct_: &str, field: &str) -> String { + let target2 = target.clone(); + cfg.field_name(move |struct_, field| { match field { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_ == "stat" => { - if self.target.contains("apple-darwin") { + if target2.contains("apple-darwin") { s.replace("_nsec", "spec.tv_nsec") - } else if self.target.contains("android") { + } else if target2.contains("android") { s.to_string() } else { s.replace("e_nsec", ".tv_nsec") @@ -201,314 +128,49 @@ impl<'a> TestGenerator<'a> { } s => s.to_string(), } - } - - fn cfg_list(&self) -> Vec<(&'static str, Option<&'static str>)> { - let mut ret = Vec::new(); - let (arch, target_pointer_width) = if self.target.starts_with("x86_64") { - ("x86_64", "64") - } else if self.target.starts_with("i686") { - ("x86", "32") - } else if self.target.starts_with("arm") { - ("arm", "32") - } else if self.target.starts_with("mips") { - ("mips", "32") - } else { - panic!("unknown arch/pointer width: {}", self.target) - }; - let (os, family, env) = if self.target.contains("unknown-linux-gnu") { - ("linux", "unix", "gnu") - } else if self.target.contains("unknown-linux-musl") { - ("linux", "unix", "musl") - } else if self.target.contains("apple-darwin") { - ("macos", "unix", "") - } else if self.target.contains("windows-msvc") { - ("windows", "windows", "msvc") - } else if self.target.contains("windows-gnu") { - ("windows", "windows", "gnu") - } else if self.target.contains("android") { - ("android", "unix", "") - } else if self.target.contains("unknown-freebsd") { - ("freebsd", "unix", "") - } else { - panic!("unknown os/family width: {}", self.target) - }; - - ret.push((family, None)); - ret.push(("target_os", Some(os))); - ret.push(("target_family", Some(family))); - ret.push(("target_arch", Some(arch))); - // skip endianness - ret.push(("target_pointer_width", Some(target_pointer_width))); - ret.push(("target_env", Some(env))); - - return ret - } -} - -fn main() { - // Prep the test generator - let target = t!(env::var("TARGET")); - let out = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let rust_out = BufWriter::new(t!(File::create(out.join("all.rs")))); - let c_out = BufWriter::new(t!(File::create(out.join("all.c")))); - let sess = ParseSess::new(); - let mut tg = TestGenerator { - target: target, - rust: Box::new(rust_out), - c: Box::new(c_out), - sh: &sess.span_diagnostic, - structs: HashSet::new(), - abi: Abi::C, - tests: Vec::new(), - }; - - // Parse the libc crate - let src = Path::new("../src/lib.rs"); - let cfg = Vec::new(); - let krate = parse::parse_crate_from_file(src, cfg, &sess); + }); - // expand macros - let ecfg = expand::ExpansionConfig::default("libc".to_string()); - let exts = vec![ - (intern("macro_rules"), SyntaxExtension::MacroRulesTT), - ]; - let mut krate = expand::expand_crate(&sess, ecfg, Vec::new(), - exts, &mut Vec::new(), krate); - - // Strip the crate down to just what's configured for our target - for (k, v) in tg.cfg_list() { - let s = InternedString::new; - krate.config.push(match v { - Some(v) => attr::mk_name_value_item_str(s(k), s(v)), - None => attr::mk_word_item(s(k)), - }); - } - let mut gated_cfgs = Vec::new(); - let krate = syntax::config::strip_unconfigured_items(&sess.span_diagnostic, - krate, - &mut gated_cfgs); - - // Probe the crate to find all structs (used to convert type names to names - // in C). - let mut structs = StructFinder { - structs: HashSet::new(), - }; - visit::walk_crate(&mut structs, &krate); - tg.structs = structs.structs; - - // Prep the C file by emitting header stuff - for define in tg.defines() { - t!(writeln!(tg.c, "#define {}", define)); - } - for header in tg.headers() { - t!(writeln!(tg.c, "#include <{}>", header)); - } - - // Walk the crate, emitting test cases for everything found - visit::walk_crate(&mut tg, &krate); - tg.emit_run_all(); - - // Compile our C shim to be linked into tests - let mut cfg = gcc::Config::new(); - cfg.file(out.join("all.c")); - - if tg.target.contains("msvc") { - cfg.flag("/W3").flag("/Wall").flag("/WX") - .flag("/wd4820") // weird warning about adding padding? - .flag("/wd4100") // don't warn about unused parameters - .flag("/wd4996") // don't warn about deprecated functions - .flag("/wd4296"); // don't warn about '<' being always false - } else { - cfg.flag("-Wall").flag("-Wextra").flag("-Werror") - .flag("-Wno-unused-parameter") - .flag("-Wno-type-limits"); - } - - drop(tg); - cfg.compile("liball.a"); -} - -impl<'a> TestGenerator<'a> { - fn test_type(&mut self, ty: &str) { + let target2 = target.clone(); + cfg.skip_type(move |ty| { match ty { // sighandler_t is crazy across platforms - "sighandler_t" => return, + "sighandler_t" => true, // Not actually defined on android, but it's not hurting anyone - "in_port_t" if self.target.contains("android") => return, - _ => {} + "in_port_t" if target2.contains("android") => true, + _ => false } - let c = self.rust_ty_to_c_ty(ty); - self.test_size_align(ty, &c); - self.test_sign(ty, &c); - } + }); - fn test_struct(&mut self, ty: &str, s: &ast::StructDef) { - let cty = self.rust_ty_to_c_ty(ty); - self.test_size_align(ty, &cty); - - self.tests.push(format!("field_offset_size_{}", ty)); - t!(writeln!(self.rust, r#" - fn field_offset_size_{ty}() {{ - println!("verifying struct {ty}"); - "#, ty = ty)); - for field in s.fields.iter() { - let name = match field.node.kind { - ast::NamedField(name, ast::Public) => name, - ast::NamedField(_, ast::Inherited) => continue, - ast::UnnamedField(..) => panic!("no tuple structs in FFI"), - }; - - let cfield = self.rust2cfield(ty, &name.to_string()); - - t!(writeln!(self.c, r#" - uint64_t __test_offset_{ty}_{rust_field}(void) {{ - return offsetof({cty}, {c_field}); - }} - uint64_t __test_size_{ty}_{rust_field}(void) {{ - {cty}* foo = NULL; - return sizeof(foo->{c_field}); - }} - "#, ty = ty, cty = cty, rust_field = name, c_field = cfield)); - t!(writeln!(self.rust, r#" - extern {{ - fn __test_offset_{ty}_{field}() -> u64; - fn __test_size_{ty}_{field}() -> u64; - }} - unsafe {{ - let foo = 0 as *const {ty}; - same(offset_of!({ty}, {field}), - __test_offset_{ty}_{field}(), - "field offset {field} of {ty}"); - same(mem::size_of_val(&(*foo).{field}) as u64, - __test_size_{ty}_{field}(), - "field size {field} of {ty}"); - }} - "#, ty = ty, field = name)); - } - t!(writeln!(self.rust, r#" - }} - "#)); - } - - fn test_size_align(&mut self, rust: &str, c: &str) { - t!(writeln!(self.c, r#" - uint64_t __test_size_{ty}(void) {{ return sizeof({cty}); }} - uint64_t __test_align_{ty}(void) {{ return alignof({cty}); }} - "#, ty = rust, cty = c)); - t!(writeln!(self.rust, r#" - fn size_align_{ty}() {{ - extern {{ - fn __test_size_{ty}() -> u64; - fn __test_align_{ty}() -> u64; - }} - println!("verifying type {ty} align/size"); - unsafe {{ - same(mem::size_of::<{ty}>() as u64, - __test_size_{ty}(), "{ty} size"); - same(align::<{ty}>() as u64, - __test_align_{ty}(), "{ty} align"); - }} - }} - "#, ty = rust)); - self.tests.push(format!("size_align_{}", rust)); - } - - fn test_sign(&mut self, rust: &str, c: &str) { + cfg.skip_signededness(|c| { match c { "LARGE_INTEGER" | "mach_timebase_info_data_t" | "float" | - "double" => return, - n if n.starts_with("pthread") => return, + "double" => true, + n if n.starts_with("pthread") => true, // windows-isms - n if n.starts_with("P") => return, - n if n.starts_with("H") => return, - n if n.starts_with("LP") => return, - _ => {} + n if n.starts_with("P") => true, + n if n.starts_with("H") => true, + n if n.starts_with("LP") => true, + _ => false, } - t!(writeln!(self.c, r#" - uint32_t __test_signed_{ty}(void) {{ - return ((({cty}) -1) < 0); - }} - "#, ty = rust, cty = c)); - t!(writeln!(self.rust, r#" - fn sign_{ty}() {{ - extern {{ - fn __test_signed_{ty}() -> u32; - }} - println!("verifying type {ty} sign"); - unsafe {{ - same(((!(0 as {ty})) < (0 as {ty})) as u32, - __test_signed_{ty}(), "{ty} signed"); - }} - }} - "#, ty = rust)); - self.tests.push(format!("sign_{}", rust)); - } + }); - fn rust_ty_to_c_ty(&self, mut rust_ty: &str) -> String { - let mut cty = self.rust2c(&rust_ty.replace("*mut ", "") - .replace("*const ", "")); - while rust_ty.starts_with("*") { - if rust_ty.starts_with("*const") { - cty = format!("const {}*", cty); - rust_ty = &rust_ty[7..]; - } else { - cty = format!("{}*", cty); - rust_ty = &rust_ty[5..]; - } - } - return cty - } - - fn test_const(&mut self, name: &str, rust_ty: &str) { - let mingw = self.target.contains("windows-gnu"); - - // Apparently these don't exist in mingw headers? + // Apparently these don't exist in mingw headers? + cfg.skip_const(move |name| { match name { "MEM_RESET_UNDO" | "FILE_ATTRIBUTE_NO_SCRUB_DATA" | "FILE_ATTRIBUTE_INTEGRITY_STREAM" | - "ERROR_NOTHING_TO_TERMINATE" if mingw => return, - _ => {} + "ERROR_NOTHING_TO_TERMINATE" if mingw => true, + "SIG_IGN" => true, // sighandler_t weirdness + _ => false, } + }); - let cty = self.rust_ty_to_c_ty(rust_ty); - - // SIG_IGN has weird types on platforms, just worry about it as a size_t - let cast = if name == "SIG_IGN" {"(size_t)"} else {""}; - - t!(writeln!(self.c, r#" - int __test_const_{name}({cty} *outptr) {{ - *outptr = {cast}({name}); - return 1; - }} - "#, name = name, cast = cast, cty = cty)); - t!(writeln!(self.rust, r#" - fn const_{name}() {{ - extern {{ - fn __test_const_{name}(out: *mut {ty}) -> c_int; - }} - println!("verifying const {name} value"); - unsafe {{ - let mut o = mem::zeroed(); - if __test_const_{name}(&mut o) == 0 {{ - panic!("{name} not defined"); - }} else {{ - same({name}, o, "{name} value"); - }} - }} - }} - "#, ty = rust_ty, name = name)); - self.tests.push(format!("const_{}", name)); - } - - fn test_extern_fn(&mut self, name: &str, cname: &str, - args: &[String], ret: &str, - variadic: bool, abi: Abi) { + cfg.skip_fn(|name| { match name { // manually verified "execv" | @@ -519,179 +181,10 @@ impl<'a> TestGenerator<'a> { "getrlimit" | "setrlimit" | "signal" | - "getopt" => return, - _ => {} - } - let args = if args.len() == 0 && !variadic { - "void".to_string() - } else { - args.iter().map(|a| self.rust_ty_to_c_ty(a)).collect::>() - .connect(", ") + if variadic {", ..."} else {""} - }; - let cret = self.rust_ty_to_c_ty(ret); - let abi = match abi { - Abi::C => "", - Abi::Stdcall => "__stdcall ", - Abi::System if self.target.contains("i686-pc-windows") => { - "__stdcall " - } - Abi::System => "", - a => panic!("unknown ABI: {}", a), - }; - t!(writeln!(self.c, r#" - {ret} ({abi}*__test_fn_{name}(void))({args}) {{ - return {cname}; - }} - "#, name = name, cname = cname, args = args, ret = cret, abi = abi)); - t!(writeln!(self.rust, r#" - fn fn_{name}() {{ - extern {{ - fn __test_fn_{name}() -> size_t; - }} - println!("verifying function {name} pointer"); - unsafe {{ - same({name} as usize, - __test_fn_{name}() as usize, - "{name} function pointer"); - }} - }} - "#, name = name)); - self.tests.push(format!("fn_{}", name)); - } - - fn assert_no_generics(&self, _i: ast::Ident, generics: &ast::Generics) { - assert!(generics.lifetimes.len() == 0); - assert!(generics.ty_params.len() == 0); - assert!(generics.where_clause.predicates.len() == 0); - } - - fn ty2name(&self, ty: &ast::Ty) -> String { - match ty.node { - ast::TyPath(_, ref path) => { - path.segments.last().unwrap().identifier.to_string() - } - ast::TyPtr(ref t) => { - format!("*{} {}", match t.mutbl { - ast::MutImmutable => "const", - ast::MutMutable => "mut", - }, self.ty2name(&t.ty)) - } - ast::TyBareFn(ref t) => { - assert!(t.lifetimes.len() == 0); - let (ret, mut args, variadic) = self.decl2rust(&t.decl); - assert!(!variadic); - if args.len() == 0 { - args.push("void".to_string()); - } - format!("{}(*)({})", ret, args.connect(", ")) - } - _ => panic!("unknown ty {:?}", ty), - } - } - - fn decl2rust(&self, decl: &ast::FnDecl) -> (String, Vec, bool) { - let args = decl.inputs.iter().map(|arg| { - self.ty2name(&arg.ty) - }).collect::>(); - let ret = match decl.output { - ast::NoReturn(..) | - ast::DefaultReturn(..) => "void".to_string(), - ast::Return(ref t) => self.ty2name(t), - }; - (ret, args, decl.variadic) - } - - fn emit_run_all(&mut self) { - t!(writeln!(self.rust, " - fn run_all() {{ - ")); - for test in self.tests.iter() { - if test.starts_with("fn_") { - // FIXME: weird dllimport issues with windows? - t!(writeln!(self.rust, "if cfg!(not(windows)) {{ {}(); }}", - test)); - } else { - t!(writeln!(self.rust, "{}();", test)); - } - } - t!(writeln!(self.rust, " - }} - ")); - } -} - -impl<'a, 'v> Visitor<'v> for TestGenerator<'a> { - fn visit_item(&mut self, i: &'v ast::Item) { - let prev_abi = self.abi; - match i.node { - ast::ItemTy(_, ref generics) => { - self.assert_no_generics(i.ident, generics); - self.test_type(&i.ident.to_string()); - } - - ast::ItemStruct(ref s, ref generics) => { - self.assert_no_generics(i.ident, generics); - let is_c = i.attrs.iter().any(|a| { - attr::find_repr_attrs(self.sh, a).iter().any(|a| { - *a == ReprAttr::ReprExtern - }) - }); - if !is_c { - panic!("{} is not marked #[repr(C)]", i.ident); - } - self.test_struct(&i.ident.to_string(), s); - } - - ast::ItemConst(ref ty, _) => { - let ty = self.ty2name(ty); - self.test_const(&i.ident.to_string(), &ty); - } - - ast::ItemForeignMod(ref fm) => { - self.abi = fm.abi; - } - - _ => {} + "getopt" => true, + _ => false, } - visit::walk_item(self, i); - self.abi = prev_abi; - } + }); - fn visit_foreign_item(&mut self, i: &'v ast::ForeignItem) { - match i.node { - ast::ForeignItemFn(ref decl, ref generics) => { - self.assert_no_generics(i.ident, generics); - let (ret, args, variadic) = self.decl2rust(decl); - let cname = match attr::first_attr_value_str_by_name(&i.attrs, - "link_name") { - Some(ref i) if !i.to_string().contains("$") => { - i.to_string() - } - _ => i.ident.to_string(), - }; - let abi = self.abi; - self.test_extern_fn(&i.ident.to_string(), &cname, &args, &ret, - variadic, abi); - } - ast::ForeignItemStatic(_, _) => { - } - } - visit::walk_foreign_item(self, i) - } -} - -impl<'v> Visitor<'v> for StructFinder { - fn visit_item(&mut self, i: &'v ast::Item) { - match i.node { - ast::ItemStruct(..) => { - self.structs.insert(i.ident.to_string()); - } - ast::ItemEnum(..) => { - self.structs.insert(i.ident.to_string()); - } - - _ => {} - } - visit::walk_item(self, i) - } + cfg.generate("../src/lib.rs", "all.rs"); } diff --git a/libc-test/src/lib.rs b/libc-test/src/lib.rs deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/libc-test/src/main.rs b/libc-test/src/main.rs new file mode 100644 index 0000000000000..e4cb8fed88ff9 --- /dev/null +++ b/libc-test/src/main.rs @@ -0,0 +1,6 @@ +#![allow(bad_style)] +extern crate libc; + +use libc::*; + +include!(concat!(env!("OUT_DIR"), "/all.rs")); diff --git a/libc-test/tests/all.rs b/libc-test/tests/all.rs deleted file mode 100644 index a2f4daf70fe80..0000000000000 --- a/libc-test/tests/all.rs +++ /dev/null @@ -1,73 +0,0 @@ -#![allow(bad_style, unused_imports)] - -extern crate libc; -extern crate libc_test; - -use std::any::{Any, TypeId}; -use std::mem; - -use libc::*; - -trait Pretty { - fn pretty(&self) -> String; -} - -impl Pretty for *const T { - fn pretty(&self) -> String { format!("{:?}", self) } -} -impl Pretty for *mut T { - fn pretty(&self) -> String { format!("{:?}", self) } -} -macro_rules! p { - ($($i:ident)*) => ($( - impl Pretty for $i { - fn pretty(&self) -> String { format!("{} ({:#x})", self, self) } - } - )*) -} -p! { i8 i16 i32 i64 u8 u16 u32 u64 usize isize } - -static mut FAILED: bool = false; - -fn same(rust: T, c: T, attr: &str) { - if rust != c { - println!("bad {}: rust: {} != c {}", attr, rust.pretty(), c.pretty()); - unsafe { FAILED = true; } - } -} - -#[allow(deprecated)] -fn align() -> u64 { - // TODO: apparently these three types have less alignment in Rust on x86 - // than they do in C this difference should.. probably be reconciled. - // - // Perhaps #27195? - if cfg!(target_pointer_width = "32") { - if TypeId::of::() == TypeId::of::() || - TypeId::of::() == TypeId::of::() || - TypeId::of::() == TypeId::of::() { - return 8 - } - } - mem::min_align_of::() as u64 -} - -macro_rules! offset_of { - ($ty:ident, $field:ident) => ( - (&((*(0 as *const $ty)).$field)) as *const _ as u64 - ) -} - -include!(concat!(env!("OUT_DIR"), "/all.rs")); - -fn main() { - println!("RUNNING ALL TESTS"); - run_all(); - unsafe { - if FAILED { - panic!("some tests failed"); - } else { - println!("PASSED"); - } - } -} From e0f4d107fa9af897196088713102fbe6b433f0c2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 09:48:14 -0700 Subject: [PATCH 111/194] Skip the pointer check for functions on windows --- libc-test/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 50ded54100b57..0e5cd9f9fea73 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -186,5 +186,8 @@ fn main() { } }); + // Windows dllimport oddness? + cfg.skip_fn_ptrcheck(move |_| windows); + cfg.generate("../src/lib.rs", "all.rs"); } From f3b9748e4ce5d1a5d052cbdc75885c413363651f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 14:13:20 -0700 Subject: [PATCH 112/194] Start testing types of struct fields --- libc-test/build.rs | 5 +++++ src/unix/mod.rs | 2 +- src/unix/notbsd/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 0e5cd9f9fea73..233983d9644ee 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -189,5 +189,10 @@ fn main() { // Windows dllimport oddness? cfg.skip_fn_ptrcheck(move |_| windows); + cfg.skip_field_type(|struct_, field| { + // This is a weird union, don't check the type. + struct_ == "ifaddrs" && field == "ifa_ifu" + }); + cfg.generate("../src/lib.rs", "all.rs"); } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 14c427fd3aab8..cacecbc3adfc2 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -48,7 +48,7 @@ s! { } pub struct in6_addr { - pub s6_addr: [u16; 8], + pub s6_addr16: [u16; 8], __align: [u32; 0], } diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 87fec5e17ff92..8591420ce5b8e 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -24,7 +24,7 @@ pub enum timezone {} s! { pub struct sockaddr { pub sa_family: sa_family_t, - pub sa_data: [u8; 14], + pub sa_data: [::c_char; 14], } pub struct sockaddr_in { @@ -49,7 +49,7 @@ s! { pub struct sockaddr_storage { pub ss_family: sa_family_t, - __ss_align: isize, + __ss_align: ::size_t, #[cfg(target_pointer_width = "32")] __ss_pad2: [u8; 128 - 2 * 4], #[cfg(target_pointer_width = "64")] From 316c367d1b14957d25973969472f5fbcad281eb2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 14:32:59 -0700 Subject: [PATCH 113/194] Fix tests on OSX --- src/unix/bsd/mod.rs | 4 ++-- src/unix/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index cdfe504d41b6c..d55c78162df4c 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -2,7 +2,7 @@ s! { pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, - pub sa_data: [u8; 14], + pub sa_data: [::c_char; 14], } pub struct sockaddr_in { @@ -10,7 +10,7 @@ s! { pub sin_family: sa_family_t, pub sin_port: ::in_port_t, pub sin_addr: ::in_addr, - pub sin_zero: [u8; 8], + pub sin_zero: [::c_char; 8], } pub struct sockaddr_in6 { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index cacecbc3adfc2..19521054b8a39 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -48,7 +48,7 @@ s! { } pub struct in6_addr { - pub s6_addr16: [u16; 8], + pub s6_addr: [u8; 16], __align: [u32; 0], } From 094f44db7916730d13528a7694c4af2d62ce7c25 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 16:27:23 -0700 Subject: [PATCH 114/194] Fix android --- libc-test/build.rs | 8 ++++++-- src/unix/bsd/mod.rs | 5 +++++ src/unix/mod.rs | 5 ----- src/unix/notbsd/android.rs | 15 ++++++++++----- src/unix/notbsd/linux/mod.rs | 5 +++++ 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 233983d9644ee..d94be1a94e433 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -15,6 +15,12 @@ fn main() { cfg.define("_WIN32_WINNT", Some("0x8000")); } + // Android doesn't actually have in_port_t but it's much easier if we + // provide one for us to test against + if target.contains("android") { + cfg.define("in_port_t", Some("uint16_t")); + } + cfg.header("errno.h") .header("fcntl.h") .header("limits.h") @@ -136,8 +142,6 @@ fn main() { // sighandler_t is crazy across platforms "sighandler_t" => true, - // Not actually defined on android, but it's not hurting anyone - "in_port_t" if target2.contains("android") => true, _ => false } }); diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d55c78162df4c..df8c0d190f4f0 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -27,6 +27,11 @@ s! { pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } } extern { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 19521054b8a39..8c568c00adf87 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -56,11 +56,6 @@ s! { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } - - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } } cfg_if! { diff --git a/src/unix/notbsd/android.rs b/src/unix/notbsd/android.rs index 7d191a3ad3036..637f64676a6f7 100644 --- a/src/unix/notbsd/android.rs +++ b/src/unix/notbsd/android.rs @@ -30,18 +30,18 @@ s! { __st_ino: ::ino_t, pub st_mode: ::c_uint, pub st_nlink: ::c_uint, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, + pub st_uid: ::c_ulong, + pub st_gid: ::c_ulong, pub st_rdev: ::c_ulonglong, __pad3: [::c_uchar; 4], pub st_size: ::c_longlong, pub st_blksize: blksize_t, pub st_blocks: ::c_ulonglong, - pub st_atime: ::time_t, + pub st_atime: ::c_ulong, pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::time_t, + pub st_mtime: ::c_ulong, pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::time_t, + pub st_ctime: ::c_ulong, pub st_ctime_nsec: ::c_ulong, pub st_ino: ::c_ulonglong, } @@ -54,6 +54,11 @@ s! { pub sched_policy: ::int32_t, pub sched_priority: ::int32_t, } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: ::in6_addr, + pub ipv6mr_interface: ::c_int, + } } pub const BUFSIZ: ::c_uint = 1024; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index d17f3306a70cb..6c6a03974d3b2 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -28,6 +28,11 @@ s! { pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union pub ifa_data: *mut ::c_void } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } } pub const BUFSIZ: ::c_uint = 8192; From 848faedff8dc0ec3d543ebe3a26a48d528446fe9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 16:35:14 -0700 Subject: [PATCH 115/194] Now fix other platforms! --- src/unix/bsd/mod.rs | 4 ++-- src/unix/notbsd/linux/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index df8c0d190f4f0..ecb21b1c75f58 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -29,8 +29,8 @@ s! { } pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, + pub ipv6mr_multiaddr: ::in6_addr, + pub ipv6mr_interface: ::c_uint, } } diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 6c6a03974d3b2..4afac2d23196a 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -30,8 +30,8 @@ s! { } pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, + pub ipv6mr_multiaddr: ::in6_addr, + pub ipv6mr_interface: ::c_uint, } } From d809601a92292a0bb363feafee64c934ec3ecebb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 16:36:30 -0700 Subject: [PATCH 116/194] OK, different strategy for fixing --- src/unix/bsd/mod.rs | 5 ----- src/unix/mod.rs | 8 ++++++++ src/unix/notbsd/android.rs | 5 ----- src/unix/notbsd/linux/mod.rs | 5 ----- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index ecb21b1c75f58..d55c78162df4c 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -27,11 +27,6 @@ s! { pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } - - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: ::in6_addr, - pub ipv6mr_interface: ::c_uint, - } } extern { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8c568c00adf87..6ec4bf6d9ced0 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -56,6 +56,14 @@ s! { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + #[cfg(target_os = "android")] + pub ipv6mr_interface: c_uint, + #[cfg(not(target_os = "android"))] + pub ipv6mr_interface: c_int, + } } cfg_if! { diff --git a/src/unix/notbsd/android.rs b/src/unix/notbsd/android.rs index 637f64676a6f7..96fdc200322a9 100644 --- a/src/unix/notbsd/android.rs +++ b/src/unix/notbsd/android.rs @@ -54,11 +54,6 @@ s! { pub sched_policy: ::int32_t, pub sched_priority: ::int32_t, } - - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: ::in6_addr, - pub ipv6mr_interface: ::c_int, - } } pub const BUFSIZ: ::c_uint = 1024; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 4afac2d23196a..d17f3306a70cb 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -28,11 +28,6 @@ s! { pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union pub ifa_data: *mut ::c_void } - - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: ::in6_addr, - pub ipv6mr_interface: ::c_uint, - } } pub const BUFSIZ: ::c_uint = 8192; From 2482400b2701c39194506dc928a29e2e31f55223 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 17:34:54 -0700 Subject: [PATCH 117/194] Oops, backwards --- src/unix/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6ec4bf6d9ced0..a96361a7c0938 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -60,9 +60,9 @@ s! { pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] - pub ipv6mr_interface: c_uint, - #[cfg(not(target_os = "android"))] pub ipv6mr_interface: c_int, + #[cfg(not(target_os = "android"))] + pub ipv6mr_interface: c_uint, } } From b5da7c0f0163015cdaad9cf2eace27b929f750e7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 17:44:40 -0700 Subject: [PATCH 118/194] Fix unused variable warning --- libc-test/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d94be1a94e433..41c17598d03e6 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1,3 +1,5 @@ +#![deny(warnings)] + extern crate ctest; use std::env; @@ -136,7 +138,6 @@ fn main() { } }); - let target2 = target.clone(); cfg.skip_type(move |ty| { match ty { // sighandler_t is crazy across platforms From 2de0b8b914b6c9ec775d983a739df9325e5851c4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 18:43:20 -0700 Subject: [PATCH 119/194] Fix windows --- src/windows.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index cade64df5228c..91d0099689929 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -96,6 +96,15 @@ pub type LPFILETIME = *mut FILETIME; pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; +pub type UCHAR = c_uchar; +pub type ULONG = c_ulong; +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + pub type ULONG_PTR = u64; + } else { + pub type ULONG_PTR = c_ulong; + } +} s! { // note this is the struct called stat64 in Windows. Not stat, nor stati64. @@ -131,7 +140,7 @@ s! { pub struct sockaddr { pub sa_family: u16, - pub sa_data: [u8; 14], + pub sa_data: [CHAR; 14], } pub struct sockaddr_storage { @@ -145,23 +154,23 @@ s! { pub sin_family: u16, pub sin_port: u16, pub sin_addr: in_addr, - pub sin_zero: [u8; 8], + pub sin_zero: [CHAR; 8], } pub struct in_addr { - pub s_addr: u32, + pub s_addr: ULONG, } pub struct sockaddr_in6 { pub sin6_family: u16, pub sin6_port: u16, - pub sin6_flowinfo: u32, + pub sin6_flowinfo: ULONG, pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, + pub sin6_scope_id: ULONG, } pub struct in6_addr { - pub s6_addr: [u16; 8], + pub s6_addr: [UCHAR; 16], } pub struct ip_mreq { @@ -171,7 +180,7 @@ s! { pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, + pub ipv6mr_interface: ULONG, } pub struct addrinfo { @@ -244,8 +253,8 @@ s! { } pub struct OVERLAPPED { - pub Internal: *mut c_ulong, - pub InternalHigh: *mut c_ulong, + pub Internal: ULONG_PTR, + pub InternalHigh: ULONG_PTR, pub Offset: DWORD, pub OffsetHigh: DWORD, pub hEvent: HANDLE, @@ -265,7 +274,7 @@ s! { pub struct WSAPROTOCOLCHAIN { pub ChainLen: c_int, - pub ChainEntries: [DWORD; MAX_PROTOCOL_CHAIN as usize], + pub ChainEntries: [DWORD; 7], } pub struct WSAPROTOCOL_INFO { @@ -288,7 +297,7 @@ s! { pub iSecurityScheme: c_int, pub dwMessageSize: DWORD, pub dwProviderReserved: DWORD, - pub szProtocol: [u8; WSAPROTOCOL_LEN as usize + 1], + pub szProtocol: [CHAR; 256], } pub struct WIN32_FIND_DATAW { From 4f04e23beff6c18d263bc84a8f08bb06ad5f34bf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 22:54:38 -0700 Subject: [PATCH 120/194] Fix align of in6_addr on Windows --- src/windows.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/windows.rs b/src/windows.rs index 91d0099689929..0bbea30b0f1af 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -171,6 +171,7 @@ s! { pub struct in6_addr { pub s6_addr: [UCHAR; 16], + _align: [u16; 0], } pub struct ip_mreq { From 3abaff18ab244022a7ce3169551768934cb4c700 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 22:59:53 -0700 Subject: [PATCH 121/194] Another attempt to fix windows --- src/windows.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index 0bbea30b0f1af..0c38bef301a28 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -144,14 +144,20 @@ s! { } pub struct sockaddr_storage { - pub ss_family: u16, + #[cfg(target_env = "msvc")] + pub ss_family: c_ushort, + #[cfg(not(target_env = "msvc"))] + pub ss_family: c_short, __ss_pad1: [u8; 6], __ss_align: i64, __ss_pad2: [u8; 112], } pub struct sockaddr_in { - pub sin_family: u16, + #[cfg(target_env = "msvc")] + pub sin_family: c_ushort, + #[cfg(not(target_env = "msvc"))] + pub sin_family: c_short, pub sin_port: u16, pub sin_addr: in_addr, pub sin_zero: [CHAR; 8], @@ -162,7 +168,10 @@ s! { } pub struct sockaddr_in6 { - pub sin6_family: u16, + #[cfg(target_env = "msvc")] + pub sin6_family: c_ushort, + #[cfg(not(target_env = "msvc"))] + pub sin6_family: c_short, pub sin6_port: u16, pub sin6_flowinfo: ULONG, pub sin6_addr: in6_addr, @@ -181,7 +190,10 @@ s! { pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, + #[cfg(target_env = "msvc")] pub ipv6mr_interface: ULONG, + #[cfg(not(target_env = "msvc"))] + pub ipv6mr_interface: c_uint, } pub struct addrinfo { From e3b6f83c1845d19414a30c2ecb4460de2251f2d8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 23:31:09 -0700 Subject: [PATCH 122/194] Attempt to fix windows --- src/windows.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/windows.rs b/src/windows.rs index 0c38bef301a28..48dd0698a871e 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -59,6 +59,7 @@ pub type BOOLEAN = BYTE; pub type CCHAR = c_char; pub type CHAR = c_char; pub type DWORD = c_ulong; +pub type DWORD_PTR = ULONG_PTR; pub type DWORDLONG = c_ulonglong; pub type HANDLE = LPVOID; pub type HINSTANCE = HANDLE; @@ -247,7 +248,7 @@ s! { pub dwPageSize: DWORD, pub lpMinimumApplicationAddress: LPVOID, pub lpMaximumApplicationAddress: LPVOID, - pub dwActiveProcessorMask: uintptr_t, + pub dwActiveProcessorMask: DWORD_PTR, pub dwNumberOfProcessors: DWORD, pub dwProcessorType: DWORD, pub dwAllocationGranularity: DWORD, From 9f2b1010c41b7fc2765a204e10aad0b568db3e4d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 23:32:21 -0700 Subject: [PATCH 123/194] Hide variants of c_void from docs --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b3319475e19b9..ded1683d245d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,10 @@ #[repr(u8)] pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used + #[doc(hidden)] __variant1, + #[doc(hidden)] __variant2, } From 24abc4fb80c0fb4a7b14f2ce12bf92a51597435d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 23:54:56 -0700 Subject: [PATCH 124/194] Attempt to build docs on Travis --- .travis.yml | 3 ++ ci/dox.sh | 34 +++++++++++++++ ci/run-travis.sh | 4 +- src/dox.rs | 105 +++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 8 ++++ src/macros.rs | 4 +- src/unix/mod.rs | 4 +- 7 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 ci/dox.sh create mode 100644 src/dox.rs diff --git a/.travis.yml b/.travis.yml index e37ff6b203353..1fce2aec53585 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,9 @@ matrix: - os: linux env: TARGET=mips-unknown-linux-gnu rust: nightly-2015-09-08 + - os: linux + env: TARGET=DOX + rust: nightly addons: apt: packages: diff --git a/ci/dox.sh b/ci/dox.sh new file mode 100644 index 0000000000000..ec13b062fb555 --- /dev/null +++ b/ci/dox.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -e + +rm -rf target/doc +mkdir -p target/doc + +doc() { + local _target=$1 + echo documenting $_target + rustdoc -o target/doc/$_target --target $_target src/lib.rs --cfg dox +} + +doc x86_64-unknown-linux-gnu +doc i686-unknown-linux-gnu +doc x86_64-apple-darwin +doc i686-apple-darwin +doc x86_64-pc-windows-gnu +doc x86_64-pc-windows-msvc +doc i686-pc-windows-gnu +doc i686-pc-windows-msvc + +doc arm-unknown-linux-gnueabihf +doc mips-unknown-linux-gnu +doc arm-linux-androideabi +doc x86_64-unknown-linux-musl + +cp ci/landing-page.html target/doc/index.html + +if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "autotest" ]; then + pip install ghp-import --user $USER + $HOME/.local/bin/ghp-import -n target/doc + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +fi diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 20aec65091c19..bb45dca8eb8d2 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -11,7 +11,9 @@ export HOST=$ARCH-$OS MAIN_TARGETS=https://static.rust-lang.org/dist EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 -if [ "$TARGET" = "arm-linux-androideabi" ]; then +if [ "$TARGET" = "DOX" ]; then + exec sh ci/dox.sh +elif [ "$TARGET" = "arm-linux-androideabi" ]; then # Pull a pre-built docker image for testing android, then run tests entirely # within that image. docker pull alexcrichton/rust-libc-test diff --git a/src/dox.rs b/src/dox.rs new file mode 100644 index 0000000000000..92e3edacf8743 --- /dev/null +++ b/src/dox.rs @@ -0,0 +1,105 @@ +pub use self::imp::*; + +#[cfg(not(dox))] +mod imp { + pub use std::option::Option; + pub use std::clone::Clone; + pub use std::marker::Copy; +} + +#[cfg(dox)] +mod imp { + pub enum Option { + Some(T), + None, + } + + pub trait Clone { + fn clone(&self) -> Self; + } + + #[lang = "copy"] + pub trait Copy {} + + #[lang = "sized"] + pub trait Sized {} + + macro_rules! each_int { + ($mac:ident) => ( + $mac!(u8); + $mac!(u16); + $mac!(u32); + $mac!(u64); + $mac!(usize); + $mac!(i8); + $mac!(i16); + $mac!(i32); + $mac!(i64); + $mac!(isize); + ) + } + + #[lang = "shl"] + pub trait Shl { + type Output; + fn shl(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_shl { + ($($i:ident)*) => ($( + impl Shl<$i> for $i { + type Output = $i; + fn shl(self, rhs: $i) -> $i { self << rhs } + } + )*) + } + each_int!(impl_shl); + + #[lang = "mul"] + pub trait Mul { + type Output; + fn mul(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_mul { + ($($i:ident)*) => ($( + impl Mul for $i { + type Output = $i; + fn mul(self, rhs: $i) -> $i { self * rhs } + } + )*) + } + each_int!(impl_mul); + + #[lang = "sub"] + pub trait Sub { + type Output; + fn sub(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_sub { + ($($i:ident)*) => ($( + impl Sub for $i { + type Output = $i; + fn sub(self, rhs: $i) -> $i { self - rhs } + } + )*) + } + each_int!(impl_sub); + + #[lang = "bitor"] + pub trait Bitor { + type Output; + fn bitor(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_bitor { + ($($i:ident)*) => ($( + impl Bitor for $i { + type Output = $i; + fn bitor(self, rhs: $i) -> $i { self | rhs } + } + )*) + } + each_int!(impl_bitor); +} diff --git a/src/lib.rs b/src/lib.rs index ded1683d245d2..cf2ba526bd4b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,8 +9,16 @@ // except according to those terms. #![allow(bad_style, raw_pointer_derive)] +#![cfg_attr(dox, feature(no_core, lang_items))] +#![cfg_attr(dox, no_core)] +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] + +#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), + doc(html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-gnu"))] #[macro_use] mod macros; +mod dox; #[repr(u8)] pub enum c_void { diff --git a/src/macros.rs b/src/macros.rs index 0c58de5fd26e5..bb5d9eeadd182 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -40,8 +40,8 @@ macro_rules! s { #[repr(C)] pub struct $i { $($field)* } } - impl Copy for $i {} - impl Clone for $i { + impl ::dox::Copy for $i {} + impl ::dox::Clone for $i { fn clone(&self) -> $i { *self } } )*) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index a96361a7c0938..f05e6337cd5db 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -316,8 +316,8 @@ extern { pub fn freeifaddrs(ifa: *mut ifaddrs); pub fn glob(pattern: *const c_char, flags: c_int, - errfunc: Option c_int>, + errfunc: ::dox::Option c_int>, pglob: *mut glob_t); pub fn globfree(pglob: *mut glob_t); From 41afa80f053324be0ad0a5040e645e6b4b8f73eb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 23:56:01 -0700 Subject: [PATCH 125/194] Add upload tokens --- .travis.yml | 2 ++ ci/dox.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1fce2aec53585..18a7ccba74821 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ os: env: - ARCH=i686 - ARCH=x86_64 + global: + secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= matrix: include: - os: linux diff --git a/ci/dox.sh b/ci/dox.sh index ec13b062fb555..615aacdd2547d 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -30,5 +30,5 @@ cp ci/landing-page.html target/doc/index.html if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "autotest" ]; then pip install ghp-import --user $USER $HOME/.local/bin/ghp-import -n target/doc - git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages + git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages fi From d82bc6b1f8396597b5ae1d58a911554225c979f5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 23:59:04 -0700 Subject: [PATCH 126/194] Add a landing page --- ci/landing-page.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 ci/landing-page.html diff --git a/ci/landing-page.html b/ci/landing-page.html new file mode 100644 index 0000000000000..4effa19f4f75f --- /dev/null +++ b/ci/landing-page.html @@ -0,0 +1 @@ +hello! From 356d1f3d5a83cfe3f4cb9554dad829b7790cab74 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 23:59:33 -0700 Subject: [PATCH 127/194] Temp disable travis --- .travis.yml | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18a7ccba74821..7e2bc03e6c43d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,35 @@ language: rust sudo: required -rust: - - 1.0.0 - - beta - - nightly +# rust: +# - 1.0.0 +# - beta +# - nightly services: - docker script: - sh ci/run-travis.sh -os: - - linux - - osx +# os: +# - linux +# - osx env: - - ARCH=i686 - - ARCH=x86_64 + # - ARCH=i686 + # - ARCH=x86_64 global: secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= matrix: include: - - os: linux - env: TARGET=arm-linux-androideabi - rust: nightly-2015-09-08 - - os: linux - env: TARGET=x86_64-unknown-linux-musl - rust: nightly-2015-09-08 - - os: linux - env: TARGET=arm-unknown-linux-gnueabihf - rust: nightly-2015-09-08 - - os: linux - env: TARGET=mips-unknown-linux-gnu - rust: nightly-2015-09-08 + # - os: linux + # env: TARGET=arm-linux-androideabi + # rust: nightly-2015-09-08 + # - os: linux + # env: TARGET=x86_64-unknown-linux-musl + # rust: nightly-2015-09-08 + # - os: linux + # env: TARGET=arm-unknown-linux-gnueabihf + # rust: nightly-2015-09-08 + # - os: linux + # env: TARGET=mips-unknown-linux-gnu + # rust: nightly-2015-09-08 - os: linux env: TARGET=DOX rust: nightly From 3fffd1049e2460733f2623427c02259d9082d74b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 00:46:53 -0700 Subject: [PATCH 128/194] Try another config --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e2bc03e6c43d..e4c093b281ce8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,6 @@ script: env: # - ARCH=i686 # - ARCH=x86_64 - global: - secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= matrix: include: # - os: linux @@ -31,7 +29,9 @@ matrix: # env: TARGET=mips-unknown-linux-gnu # rust: nightly-2015-09-08 - os: linux - env: TARGET=DOX + env: + - TARGET=DOX + - secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= rust: nightly addons: apt: From 9eca4685de498f362156a2b683e0bc8ab1a5c0b6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 00:48:36 -0700 Subject: [PATCH 129/194] Another? --- .travis.yml | 34 ++++++++++++++++------------------ ci/run-travis.sh | 10 +++++++--- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index e4c093b281ce8..be99341adf2e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,24 @@ language: rust -sudo: required -# rust: +sudo: false +rust: # - 1.0.0 # - beta -# - nightly -services: - - docker + - nightly +# services: +# - docker script: - sh ci/run-travis.sh # os: # - linux # - osx env: - # - ARCH=i686 - # - ARCH=x86_64 -matrix: - include: + matrix: + # - ARCH=i686 + - ARCH=x86_64 + global: + secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= +# matrix: +# include: # - os: linux # env: TARGET=arm-linux-androideabi # rust: nightly-2015-09-08 @@ -28,15 +31,10 @@ matrix: # - os: linux # env: TARGET=mips-unknown-linux-gnu # rust: nightly-2015-09-08 - - os: linux - env: - - TARGET=DOX - - secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= - rust: nightly -addons: - apt: - packages: - - gcc-multilib +# addons: +# apt: +# packages: +# - gcc-multilib notifications: email: on_success: never diff --git a/ci/run-travis.sh b/ci/run-travis.sh index bb45dca8eb8d2..f760306a9eac2 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -11,9 +11,7 @@ export HOST=$ARCH-$OS MAIN_TARGETS=https://static.rust-lang.org/dist EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 -if [ "$TARGET" = "DOX" ]; then - exec sh ci/dox.sh -elif [ "$TARGET" = "arm-linux-androideabi" ]; then +if [ "$TARGET" = "arm-linux-androideabi" ]; then # Pull a pre-built docker image for testing android, then run tests entirely # within that image. docker pull alexcrichton/rust-libc-test @@ -54,3 +52,9 @@ fi mkdir .cargo cp ci/cargo-config .cargo/config sh ci/run.sh $TARGET + +if [ "$TARGET" = "x86_64-unknown-linux-gnu" ] && \ + [ "$TRAVIS_RUST_VERSION" = "nightly" ] && \ + [ "$TRAVIS_OS_NAME" = "linux" ]; then + sh ci/dox.sh +fi From 12240ada586b20faf5dcdac7a9e8dea5aa32d9ab Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 01:01:45 -0700 Subject: [PATCH 130/194] Go back to a real travis yml --- .travis.yml | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index be99341adf2e7..8466ee87811fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,40 +1,40 @@ language: rust -sudo: false +sudo: required rust: -# - 1.0.0 -# - beta + - 1.0.0 + - beta - nightly -# services: -# - docker +services: + - docker script: - sh ci/run-travis.sh -# os: -# - linux -# - osx +os: + - linux + - osx env: matrix: - # - ARCH=i686 + - ARCH=i686 - ARCH=x86_64 global: secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= -# matrix: -# include: - # - os: linux - # env: TARGET=arm-linux-androideabi - # rust: nightly-2015-09-08 - # - os: linux - # env: TARGET=x86_64-unknown-linux-musl - # rust: nightly-2015-09-08 - # - os: linux - # env: TARGET=arm-unknown-linux-gnueabihf - # rust: nightly-2015-09-08 - # - os: linux - # env: TARGET=mips-unknown-linux-gnu - # rust: nightly-2015-09-08 -# addons: -# apt: -# packages: -# - gcc-multilib +matrix: + include: + - os: linux + env: TARGET=arm-linux-androideabi + rust: nightly-2015-09-08 + - os: linux + env: TARGET=x86_64-unknown-linux-musl + rust: nightly-2015-09-08 + - os: linux + env: TARGET=arm-unknown-linux-gnueabihf + rust: nightly-2015-09-08 + - os: linux + env: TARGET=mips-unknown-linux-gnu + rust: nightly-2015-09-08 +addons: + apt: + packages: + - gcc-multilib notifications: email: on_success: never From 0de482ca8a125b6f9a653f80e1d57228d47170cd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 08:05:43 -0700 Subject: [PATCH 131/194] Ok... another key? --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8466ee87811fe..3f0cd55b1b412 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ os: - osx env: matrix: - - ARCH=i686 - ARCH=x86_64 + - ARCH=i686 global: - secure: Zh+dsvtjyhRKki3nA+x9FlUEszs6qswMSg1xnkihLbWjrNQhPRcfZXux2LoRbh4A7RtrlDU0Bzga9G7uuNlouALqeAqSbUVBmctjrOrWnKnhHmYQkYa8XBTR90rSn+37sLyinnGSFRIrOM5sc3dTZGlGmjNWwp+Kf8oj9T2SS7w= + secure: knGy4XLi5DVpZPcBaB8PiGA49NtZLcaWwLIPwSS68CwRJXOeeNPe/+xb7vWCWblJp3k7jK1HkJgHq+muWe1e+gUvXpmvASyuwpIBd4eQn55k4jfQlAVPCpxoIYANnv7bjfDMhuTEUDmvt9vI7BXDlLfi2VRrSrUd9obSwd3QU+ie5V88FTvPIe12zVmcvW8YVkKYsWRM4auIOU7CZSEW4nT+OE6RCpETE12u1qxUhsq03byCL7HQYGJs2S0RsqdyEZV+kAeJxA0ULNXlPs0FEagpqFbxfmZSSWzGp6K9juaRc03OBYiCcxrhYopuU1B1q4xMJk/2xWfPhoNJTU8yKW6fHstJz9Eb7MXH2y3UzDBAbDdwaNH4/aq0fN6O2U2lr7n09oF+pa9Gi5gyUYhKN19skaHMPF+Y7GCkqyCpR2oKTWTp+zSKycvgcsfl9zX2MvZG2NCgLPqRPaCEg/Psa2HvnM4/LgZw5ViDHJDVvNofzKx+2zzUlpsrkXaVDeRqUYVnO/LLiLl1cVT0QDHH1DHLXFY8G7CLfQYA64Np0LURartCmoamC86FavkSPTmnUL7i3RBMJnOUy2Uzf/SzbdRq3Sfp5tAV/miGzWaJFs81wuDKTWq5bnSGNVR18Wori6K8BboRYLmxMpSgQJ/8AnvnXETKwoP2lajJr1A4oPI= matrix: include: - os: linux From dab1ead5faeeba7b3c085cc3de22b38677150120 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 09:52:21 -0700 Subject: [PATCH 132/194] Auto-generate an index --- ci/dox.sh | 10 ++++++++-- ci/landing-page-footer.html | 7 +++++++ ci/landing-page-head.html | 4 ++++ ci/landing-page.html | 1 - 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 ci/landing-page-footer.html create mode 100644 ci/landing-page-head.html delete mode 100644 ci/landing-page.html diff --git a/ci/dox.sh b/ci/dox.sh index 615aacdd2547d..5450088cc60c5 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -5,10 +5,16 @@ set -e rm -rf target/doc mkdir -p target/doc +cp ci/landing-page-head.html target/doc/index.html + doc() { local _target=$1 echo documenting $_target - rustdoc -o target/doc/$_target --target $_target src/lib.rs --cfg dox + rustdoc -o target/doc/$_target --target $_target src/lib.rs --cfg dox \ + --crate-name libc + + echo "
  • $_target
  • " \ + >> target/doc/index.html } doc x86_64-unknown-linux-gnu @@ -25,7 +31,7 @@ doc mips-unknown-linux-gnu doc arm-linux-androideabi doc x86_64-unknown-linux-musl -cp ci/landing-page.html target/doc/index.html +cat ci/landing-page-footer.html >> target/doc/index.html if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "autotest" ]; then pip install ghp-import --user $USER diff --git a/ci/landing-page-footer.html b/ci/landing-page-footer.html new file mode 100644 index 0000000000000..fc69fa88eb5ce --- /dev/null +++ b/ci/landing-page-footer.html @@ -0,0 +1,7 @@ + + + + + + +
      diff --git a/ci/landing-page-head.html b/ci/landing-page-head.html new file mode 100644 index 0000000000000..de3c63c01f310 --- /dev/null +++ b/ci/landing-page-head.html @@ -0,0 +1,4 @@ +
    + + + diff --git a/ci/landing-page.html b/ci/landing-page.html deleted file mode 100644 index 4effa19f4f75f..0000000000000 --- a/ci/landing-page.html +++ /dev/null @@ -1 +0,0 @@ -hello! From 730a17fd1c7a96cf14452fc56a4a5b886d1a1933 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 10:05:36 -0700 Subject: [PATCH 133/194] Root urls for everyone! Also refator to only list all the triples once --- ci/dox.sh | 28 ++++++++-------------------- src/lib.rs | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/ci/dox.sh b/ci/dox.sh index 5450088cc60c5..a003dc389d06c 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -7,29 +7,17 @@ mkdir -p target/doc cp ci/landing-page-head.html target/doc/index.html -doc() { - local _target=$1 - echo documenting $_target - rustdoc -o target/doc/$_target --target $_target src/lib.rs --cfg dox \ +TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'` + +for target in $TARGETS; do + echo documenting $target + + rustdoc -o target/doc/$target --target $target src/lib.rs --cfg dox \ --crate-name libc - echo "
  • $_target
  • " \ + echo "
  • $target
  • " \ >> target/doc/index.html -} - -doc x86_64-unknown-linux-gnu -doc i686-unknown-linux-gnu -doc x86_64-apple-darwin -doc i686-apple-darwin -doc x86_64-pc-windows-gnu -doc x86_64-pc-windows-msvc -doc i686-pc-windows-gnu -doc i686-pc-windows-msvc - -doc arm-unknown-linux-gnueabihf -doc mips-unknown-linux-gnu -doc arm-linux-androideabi -doc x86_64-unknown-linux-musl +done cat ci/landing-page-footer.html >> target/doc/index.html diff --git a/src/lib.rs b/src/lib.rs index cf2ba526bd4b8..4ae6ac5a764ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,8 +14,42 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] -#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), - doc(html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-gnu"))] +#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc( + html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-gnu" +))] +#![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc( + html_root_url = "http://alexcrichton.com/libc/i686-unknown-linux-gnu" +))] +#![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc( + html_root_url = "http://alexcrichton.com/libc/arm-unknown-linux-gnueabihf" +))] +#![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc( + html_root_url = "http://alexcrichton.com/libc/mips-unknown-linux-gnu" +))] +#![cfg_attr(all(target_os = "linux", target_env = "musl"), doc( + html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-musl" +))] +#![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc( + html_root_url = "http://alexcrichton.com/libc/x86_64-apple-darwin" +))] +#![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc( + html_root_url = "http://alexcrichton.com/libc/i686-apple-darwin" +))] +#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc( + html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-gnu" +))] +#![cfg_attr(all(windows, target_arch = "i686", target_env = "gnu"), doc( + html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-gnu" +))] +#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc( + html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-msvc" +))] +#![cfg_attr(all(windows, target_arch = "i686", target_env = "msvc"), doc( + html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-msvc" +))] +#![cfg_attr(all(target_os = "android"), doc( + html_root_url = "http://alexcrichton.com/libc/arm-linux-androideabi" +))] #[macro_use] mod macros; mod dox; From 611e9a38e463a0842ec0457ae7a0cca67cf279c3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 10:06:19 -0700 Subject: [PATCH 134/194] i686 => x86 --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4ae6ac5a764ca..a7ecabda563f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,13 +38,13 @@ #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc( html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-gnu" ))] -#![cfg_attr(all(windows, target_arch = "i686", target_env = "gnu"), doc( +#![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc( html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-gnu" ))] #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc( html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-msvc" ))] -#![cfg_attr(all(windows, target_arch = "i686", target_env = "msvc"), doc( +#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc( html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-msvc" ))] #![cfg_attr(all(target_os = "android"), doc( From 95b18b7d0220903b70007689a203cbd89e1446a7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 10:06:58 -0700 Subject: [PATCH 135/194] Show some crate docs --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a7ecabda563f4..8ee87eabafb3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +//! Crate docs + #![allow(bad_style, raw_pointer_derive)] #![cfg_attr(dox, feature(no_core, lang_items))] #![cfg_attr(dox, no_core)] From e00e24a2be824a9cb13abfd94d41250a4661413a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 10:16:30 -0700 Subject: [PATCH 136/194] Add more badges --- README.md | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3a0cc20cf64fd..46b30bfd7f776 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,7 @@ libc A Rust library with native bindings to the types and functions commonly found on various systems, including libc. -[![Build Status](https://travis-ci.org/rust-lang/libc.svg?branch=master)](https://travis-ci.org/rust-lang/libc) +[![Build Status](https://travis-ci.org/alexcrichton/libc.svg?branch=master)](https://travis-ci.org/alexcrichton/libc) +[![Build status](https://ci.appveyor.com/api/projects/status/v0414slj8y8nga0p?svg=true)](https://ci.appveyor.com/project/alexcrichton/libc) -[Documentation](http://doc.rust-lang.org/libc) - -## Usage - -Add this to your `Cargo.toml`: - -```toml -[dependencies] - -libc = "0.1" -``` - -and this to your crate root: - -```rust -extern crate libc; -``` +[Documentation](http://alexcrichton.com/libc) From d5c493e388072c349672b2012c7abec67dff8c37 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 10:17:12 -0700 Subject: [PATCH 137/194] Remove .gitmodules --- .gitmodules | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29bb2d1d..0000000000000 From 242d3d33e274ea362f96c6348f96a88e3ce91940 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 11:57:15 -0700 Subject: [PATCH 138/194] Only test autotest for now --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3f0cd55b1b412..1a8f3945ed3a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,3 +38,6 @@ addons: notifications: email: on_success: never +branches: + only: + - autotest From cd9b33e32b91a7738e33c711d99b49b71f368b97 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 14:47:40 -0700 Subject: [PATCH 139/194] Import lots of the stdlib --- libc-test/build.rs | 55 +++++++---- libc-test/src/main.rs | 2 +- src/unix/bsd/apple/b32.rs | 4 + src/unix/bsd/apple/b64.rs | 4 + src/unix/bsd/apple/mod.rs | 67 ++++++++++++- src/unix/bsd/freebsdlike/dragonfly.rs | 4 + src/unix/bsd/freebsdlike/freebsd.rs | 4 + src/unix/bsd/freebsdlike/mod.rs | 33 ++++++- src/unix/bsd/mod.rs | 28 ++++++ src/unix/bsd/openbsdlike/mod.rs | 34 ++++++- src/unix/mod.rs | 99 ++++++++++++++++++-- src/unix/notbsd/android.rs | 83 ++++++++++++++++ src/unix/notbsd/linux/mips.rs | 37 ++++++++ src/unix/notbsd/linux/mod.rs | 57 +++++++++++ src/unix/notbsd/linux/notmips/b32/mod.rs | 7 ++ src/unix/notbsd/linux/notmips/b64/aarch64.rs | 2 + src/unix/notbsd/linux/notmips/b64/mod.rs | 8 ++ src/unix/notbsd/linux/notmips/b64/x86_64.rs | 2 + src/unix/notbsd/linux/notmips/mod.rs | 30 ++++++ src/unix/notbsd/mod.rs | 15 ++- 20 files changed, 543 insertions(+), 32 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 41c17598d03e6..3bc7782b3de37 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -8,6 +8,7 @@ fn main() { let target = env::var("TARGET").unwrap(); let windows = target.contains("windows"); let mingw = target.contains("windows-gnu"); + let linux = target.contains("unknown-linux"); let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw @@ -78,6 +79,8 @@ fn main() { cfg.header("sys/wait.h"); cfg.header("unistd.h"); cfg.header("utime.h"); + cfg.header("pwd.h"); + cfg.header("grp.h"); if target.contains("android") { cfg.header("arpa/inet.h"); @@ -86,16 +89,23 @@ fn main() { cfg.header("ifaddrs.h"); cfg.header("sys/sysctl.h"); } + + } + if target.contains("linux") { + cfg.header("sys/prctl.h"); } cfg.type_name(move |ty, is_struct| { match ty { // Just pass all these through, no need for a "struct" prefix - "glob_t" | "FILE" | - "DIR" | - "fpos_t" => ty.to_string(), - t if t.starts_with("pthread") => t.to_string(), + "DIR" => ty.to_string(), + + // Fixup a few types on windows that don't actually exist. + "time64_t" if windows => "__time64_t".to_string(), + "ssize_t" if windows => "SSIZE_T".to_string(), + + t if t.ends_with("_t") => t.to_string(), // Windows uppercase structs don't have `struct` in front, there's a // few special cases for windows, and then otherwise put `struct` in @@ -112,10 +122,6 @@ fn main() { } } - // Fixup a few types on windows that don't actually exist. - "time64_t" if windows => "__time64_t".to_string(), - "ssize_t" if windows => "SSIZE_T".to_string(), - t => t.to_string(), } }); @@ -163,30 +169,33 @@ fn main() { } }); - // Apparently these don't exist in mingw headers? cfg.skip_const(move |name| { match name { + // Apparently these don't exist in mingw headers? "MEM_RESET_UNDO" | "FILE_ATTRIBUTE_NO_SCRUB_DATA" | "FILE_ATTRIBUTE_INTEGRITY_STREAM" | "ERROR_NOTHING_TO_TERMINATE" if mingw => true, + "SIG_IGN" => true, // sighandler_t weirdness + _ => false, } }); - cfg.skip_fn(|name| { + cfg.skip_fn(move |name| { + // skip those that are manually verifiedmanually verified match name { - // manually verified - "execv" | + "execv" | // crazy stuff with const/mut "execve" | "execvp" | - "execvpe" | - "glob" | - "getrlimit" | - "setrlimit" | - "signal" | - "getopt" => true, + "execvpe" => true, + + "getrlimit" | // non-int in 1st arg + "setrlimit" | // non-int in 1st arg + "gettimeofday" | // typed 2nd arg on linux + "strerror_r" if linux => true, // actually xpg-something-or-other + _ => false, } }); @@ -196,7 +205,15 @@ fn main() { cfg.skip_field_type(|struct_, field| { // This is a weird union, don't check the type. - struct_ == "ifaddrs" && field == "ifa_ifu" + (struct_ == "ifaddrs" && field == "ifa_ifu") || + // sighandler_t type is super weird + (struct_ == "sigaction" && field == "sa_sigaction") + }); + + cfg.skip_field(|struct_, field| { + // this is actually a union on linux, so we can't represent it well and + // just insert some padding. + (struct_ == "siginfo_t" && field == "_pad") }); cfg.generate("../src/lib.rs", "all.rs"); diff --git a/libc-test/src/main.rs b/libc-test/src/main.rs index e4cb8fed88ff9..fff188d321171 100644 --- a/libc-test/src/main.rs +++ b/libc-test/src/main.rs @@ -1,4 +1,4 @@ -#![allow(bad_style)] +#![allow(bad_style, improper_ctypes)] extern crate libc; use libc::*; diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 62caa5fdd5d09..293822e721f33 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -7,6 +7,10 @@ pub type ptrdiff_t = i32; pub type intptr_t = i32; pub type uintptr_t = u32; +pub const __PTHREAD_MUTEX_SIZE__: usize = 40; +pub const __PTHREAD_COND_SIZE__: usize = 24; +pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; + s! { pub struct pthread_attr_t { __sig: c_long, diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index 1a79be30368eb..fb9f58ccd244e 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -7,6 +7,10 @@ pub type ptrdiff_t = i64; pub type intptr_t = i64; pub type uintptr_t = u64; +pub const __PTHREAD_MUTEX_SIZE__: usize = 56; +pub const __PTHREAD_COND_SIZE__: usize = 40; +pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; + s! { pub struct pthread_attr_t { __sig: c_long, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 71b24a6931e93..173788df3def2 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -41,6 +41,8 @@ pub type pthread_t = uintptr_t; pub type rlim_t = u64; pub type sighandler_t = size_t; pub type mach_timebase_info_data_t = mach_timebase_info; +pub type pthread_key_t = c_ulong; +pub type sigset_t = u32; pub enum timezone {} @@ -120,6 +122,41 @@ s! { pub st_qspare: [::int64_t; 2], } + + pub struct pthread_mutex_t { + __sig: libc::c_long, + __opaque: [u8; __PTHREAD_MUTEX_SIZE__], + } + pub struct pthread_mutexattr_t { + __sig: libc::c_long, + __opaque: [u8; 16], + } + + pub struct pthread_cond_t { + __sig: libc::c_long, + __opaque: [u8; __PTHREAD_COND_SIZE__], + } + + pub struct pthread_rwlock_t { + __sig: libc::c_long, + __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct siginfo_t { + pub _signo: ::c_int, + pub _errno: ::c_int, + pub _code: ::c_int, + pub _pid: ::pid_t, + pub _uid: ::uid_t, + pub _status: ::c_int, + pub si_addr: *mut ::c_void + } + + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + pub sa_flags: ::c_int, + } } pub const EXIT_FAILURE: c_int = 1; @@ -334,7 +371,6 @@ pub const F_SETFL: c_int = 4; pub const O_ACCMODE: c_int = 3; pub const SIGTRAP: c_int = 5; -pub const SIG_IGN: size_t = 1; pub const GLOB_APPEND : c_int = 0x0001; pub const GLOB_DOOFFS : c_int = 0x0002; @@ -601,9 +637,30 @@ pub const _SC_TRACE_SYS_MAX: c_int = 129; pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130; pub const _SC_PASS_MAX: c_int = 131; + +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const _PTHREAD_MUTEX_SIG_INIT: ::c_long = 0x32AAABA7; +pub const _PTHREAD_COND_SIG_INIT: ::c_long = 0x3CB0B1BB; +pub const _PTHREAD_RWLOCK_SIG_INIT: ::c_long = 0x2DA8B3B4; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __sig: _PTHREAD_MUTEX_SIG_INIT, + __opaque: [0; __PTHREAD_MUTEX_SIZE__], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __sig: _PTHREAD_COND_SIG_INIT, + __opaque: [0; __PTHREAD_COND_SIZE__], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __sig: _PTHREAD_RWLOCK_SIG_INIT, + __opaque: [0; __PTHREAD_RWLOCK_SIZE__], +}; + extern { pub fn _NSGetExecutablePath(buf: *mut ::c_char, bufsize: *mut ::uint32_t) -> ::c_int; + pub fn _NSGetArgc() -> *mut c_int; + pub fn _NSGetArgv() -> *mut *mut *mut c_char; + pub fn _NSGetEnviron() -> *mut *const *const c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) @@ -622,6 +679,14 @@ extern { newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; + pub fn _tlv_atexit(dtor: unsafe extern fn(*mut u8), + arg: *mut u8); + pub fn mach_absolute_time() -> u64; + pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; + pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; + pub fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut ::c_void; + pub fn pthread_get_stacksize_np(thread: pthread_t) -> ::size_t; + pub fn __error() -> *const ::c_int; } cfg_if! { diff --git a/src/unix/bsd/freebsdlike/dragonfly.rs b/src/unix/bsd/freebsdlike/dragonfly.rs index a677d1a521520..f158cda803c9f 100644 --- a/src/unix/bsd/freebsdlike/dragonfly.rs +++ b/src/unix/bsd/freebsdlike/dragonfly.rs @@ -1,2 +1,6 @@ pub const PTHREAD_STACK_MIN: ::size_t = 1024; pub const KERN_PROC_PATHNAME: ::c_int = 9; + +extern { + pub fn __dfly_error() -> *const ::c_int; +} diff --git a/src/unix/bsd/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd.rs index c4998379ba84e..808f6eac95638 100644 --- a/src/unix/bsd/freebsdlike/freebsd.rs +++ b/src/unix/bsd/freebsdlike/freebsd.rs @@ -1,2 +1,6 @@ pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const KERN_PROC_PATHNAME: ::c_int = 12; + +extern { + pub fn __error() -> *const ::c_int; +} diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index fc50c2201b91c..4ca588f941f00 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -5,6 +5,11 @@ pub type socklen_t = u32; pub type sa_family_t = u8; pub type in_port_t = u16; pub type in_addr_t = u32; +pub type pthread_mutex_t = *mut ::c_void; +pub type pthread_mutexattr_t = *mut ::c_void; +pub type pthread_cond_t = *mut ::c_void; +pub type pthread_rwlock_t = *mut ::c_void; +pub type pthread_key_t = ::c_int; pub enum timezone {} @@ -53,6 +58,26 @@ s! { pub ifa_dstaddr: *mut ::sockaddr, pub ifa_data: *mut ::c_void } + + pub struct sigset_t { + bits: [u32; 4], + } + + pub struct siginfo_t { + pub _signo: ::c_int, + pub _errno: ::c_int, + pub _code: ::c_int, + pub _pid: ::pid_t, + pub _uid: ::uid_t, + pub _status: ::c_int, + pub si_addr: *mut ::c_void + } + + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_flags: ::c_int, + pub sa_mask: sigset_t, + } } pub const EXIT_FAILURE: ::c_int = 1; @@ -247,7 +272,6 @@ pub const F_GETFL: ::c_int = 3; pub const F_SETFL: ::c_int = 4; pub const SIGTRAP: ::c_int = 5; -pub const SIG_IGN: size_t = 1; pub const GLOB_APPEND : ::c_int = 0x0001; pub const GLOB_DOOFFS : ::c_int = 0x0002; @@ -462,6 +486,11 @@ pub const _SC_SEM_VALUE_MAX: ::c_int = 50; pub const _SC_SIGQUEUE_MAX: ::c_int = 51; pub const _SC_TIMER_MAX: ::c_int = 52; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; + extern { pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) -> c_int; @@ -480,6 +509,8 @@ extern { newp: *const ::c_void, newlen: size_t) -> c_int; + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d55c78162df4c..5dd2fb7092561 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -27,8 +27,36 @@ s! { pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_change: ::time_t, + pub pw_class: *mut ::c_char, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + pub pw_expire: ::time_t, + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } } +pub const FIOCLEX: c_ulong = 0x20006601; + +pub const SA_ONSTACK: ::c_int = 0x0001; +pub const SA_SIGINFO: ::c_int = 0x0040; + +pub const SIGSTKSZ: ::size_t = 131072; +pub const SIGBUS: ::c_int = 10; +pub const SIG_SETMASK: ::c_int = 3; + extern { pub fn mincore(addr: *const ::c_void, len: size_t, vec: *mut c_char) -> c_int; diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index f003630199084..ef40db4458f83 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -1,3 +1,21 @@ + pub type sigset_t = libc::c_uint; +pub type pthread_key_t = ::c_int; + struct stack_t { + ss_sp: *mut libc::c_void, + ss_size: libc::size_t, + ss_flags: libc::c_int, + } + pub struct siginfo_t { + pub si_signo: libc::c_int, + pub si_code: libc::c_int, + pub si_errno: libc::c_int, + pub si_addr: *mut libc::c_void + } + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + pub sa_flags: libc::c_int, + } #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))] pub mod os { @@ -497,7 +515,6 @@ pub const F_DUPFD_CLOEXEC : c_int = 10; pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; pub const GLOB_APPEND : c_int = 0x0001; pub const GLOB_DOOFFS : c_int = 0x0002; @@ -710,6 +727,15 @@ pub const _SC_TIMERS : c_int = 94; } } + pub type pthread_mutex_t = *mut libc::c_void; + pub type pthread_mutexattr_t = *mut libc::c_void; + pub type pthread_cond_t = *mut libc::c_void; + pub type pthread_rwlock_t = *mut libc::c_void; + + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); + pub const PTHREAD_MUTEX_RECURSIVE: libc::c_int = 2; extern { pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) -> c_int; @@ -728,4 +754,10 @@ extern { newp: *mut ::c_void, newlen: size_t) -> c_int; + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn pthread_main_np() -> ::c_uint; + pub fn pthread_stackseg_np(thread: pthread_t, + sinfo: *mut stack_t) -> ::c_uint; + pub fn __errno() -> *const ::c_int; } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index f05e6337cd5db..2dabfd1544b30 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -66,9 +66,14 @@ s! { } } +pub const WNOHANG: c_int = 1; +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + cfg_if! { if #[cfg(feature = "default")] { - // cargo build, don't pull in anything extra as the libstd libc dep + // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. } else if #[cfg(target_env = "musl")] { #[link(name = "c", kind = "static")] @@ -193,9 +198,7 @@ extern { pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int; pub fn getlogin() -> *mut c_char; - // GNU getopt(3) modifies its arguments despite the - // char * const [] prototype; see the manpage. - pub fn getopt(argc: c_int, argv: *mut *mut c_char, + pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; pub fn getpgrp() -> pid_t; pub fn getpid() -> pid_t; @@ -303,8 +306,8 @@ extern { pub fn getdtablesize() -> c_int; #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] - pub fn realpath(pathname: *const c_char, resolved: *mut c_char) - -> *mut c_char; + pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) + -> *mut ::c_char; pub fn flock(fd: c_int, operation: c_int) -> c_int; } @@ -318,7 +321,7 @@ extern { flags: c_int, errfunc: ::dox::Option c_int>, - pglob: *mut glob_t); + pglob: *mut glob_t) -> c_int; pub fn globfree(pglob: *mut glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: size_t, advice: c_int) @@ -371,6 +374,88 @@ extern { pub fn recv(socket: c_int, buf: *mut ::c_void, len: size_t, flags: c_int) -> ssize_t; pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; + + pub fn pthread_self() -> ::pthread_t; + pub fn pthread_create(native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void) -> ::c_int; + pub fn pthread_join(native: ::pthread_t, + value: *mut *mut ::c_void) -> ::c_int; + pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, + stack_size: ::size_t) -> ::c_int; + pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, + state: ::c_int) -> ::c_int; + pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; + pub fn sched_yield() -> ::c_int; + pub fn pthread_key_create(key: *mut pthread_key_t, + dtor: Option) + -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) + -> c_int; + pub fn pthread_mutex_init(lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t) -> ::c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, + _type: ::c_int) -> ::c_int; + + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const ::timespec) -> ::c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, + oldset: *mut sigset_t) -> ::c_int; + + // #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] + pub fn strerror_r(errnum: c_int, buf: *mut c_char, + buflen: size_t) -> c_int; + + pub fn getsockopt(sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_void, + optlen: *mut ::socklen_t) -> ::c_int; + pub fn raise(signum: ::c_int) -> ::c_int; + pub fn sigaction(signum: ::c_int, + act: *const sigaction, + oldact: *mut sigaction) -> ::c_int; + pub fn sigaltstack(ss: *const sigaltstack, + oss: *mut sigaltstack) -> ::c_int; + pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; + + pub fn getpwuid_r(uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd) -> ::c_int; + + pub fn utimes(filename: *const ::c_char, + times: *const ::timeval) -> ::c_int; + pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; + pub fn setgroups(ngroups: ::size_t, + ptr: *const ::gid_t) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/android.rs b/src/unix/notbsd/android.rs index 96fdc200322a9..6f4833ce9f14f 100644 --- a/src/unix/notbsd/android.rs +++ b/src/unix/notbsd/android.rs @@ -22,6 +22,8 @@ pub type nlink_t = u16; pub type useconds_t = i32; pub type socklen_t = i32; pub type pthread_t = c_long; +pub type pthread_mutexattr_t = ::c_long; +pub type sigset_t = c_ulong; s! { pub struct stat { @@ -54,6 +56,63 @@ s! { pub sched_policy: ::int32_t, pub sched_priority: ::int32_t, } + + pub struct pthread_mutex_t { value: ::c_int } + + pub struct pthread_cond_t { value: ::c_int } + + pub struct pthread_rwlock_t { + lock: pthread_mutex_t, + cond: pthread_cond_t, + numLocks: ::c_int, + writerThreadId: ::c_int, + pendingReaders: ::c_int, + pendingWriters: ::c_int, + reserved: [*mut ::c_void; 4], + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [u64; 0], + } +} + +#[cfg(target_pointer_width = "32")] +s!{ + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_flags: libc::c_ulong, + _restorer: *mut libc::c_void, + pub sa_mask: sigset_t, + } +} + +#[cfg(target_pointer_width = "64")] +s!{ + pub struct sigaction { + pub sa_flags: libc::c_uint, + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut libc::c_void, + } } pub const BUFSIZ: ::c_uint = 1024; @@ -121,9 +180,33 @@ pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; pub const PTHREAD_STACK_MIN: ::size_t = 8192; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + value: 0, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + value: 0, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + lock: PTHREAD_MUTEX_INITIALIZER, + cond: PTHREAD_COND_INITIALIZER, + numLocks: 0, + writerThreadId: 0, + pendingReaders: 0, + pendingWriters: 0, + reserved: [0 as *mut _; 4], +}; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const O_SYNC: ::c_int = 0x1000; +pub const FIOCLEX: ::c_ulong = 0x5451; + +pub const SA_ONSTACK: ::c_ulong = 0x08000000; +pub const SA_SIGINFO: ::c_ulong = 0x00000004; + +pub const SIGBUS: ::c_int = 7; +pub const SIG_SETMASK: ::c_int = 2; + extern { pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 75125d4c2eb9e..8364e7bed4eee 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -44,6 +44,31 @@ s! { pub struct pthread_attr_t { __size: [u32; 9] } + + pub struct sigaction { + pub sa_flags: ::c_uint, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut ::c_void, + _resv: [::c_int; 1], + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct sigset_t { + __val: [::c_ulong; 32], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub _pad: [::c_int; 29], + } } pub const RLIMIT_NOFILE: ::c_int = 5; @@ -177,3 +202,15 @@ pub const SO_SNDLOWAT: ::c_int = 4099; pub const SO_RCVTIMEO: ::c_int = 4102; pub const SO_SNDTIMEO: ::c_int = 4101; pub const SO_ACCEPTCONN: ::c_int = 4105; + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; + +pub const FIOCLEX: ::c_ulong = 0x6601; + +pub const SA_ONSTACK: ::c_ulong = 0x08000000; +pub const SA_SIGINFO: ::c_ulong = 0x00000008; + +pub const SIGBUS: ::c_int = 10; + +pub const SIG_SETMASK: ::c_int = 3; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index d17f3306a70cb..e119bbd64eacc 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -28,6 +28,46 @@ s! { pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union pub ifa_data: *mut ::c_void } + + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } } pub const BUFSIZ: ::c_uint = 8192; @@ -160,6 +200,22 @@ pub const MAP_32BIT: ::c_int = 0x0040; pub const TCP_MD5SIG: ::c_int = 14; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __align: [], + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __align: [], + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __align: [], + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + extern { pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; @@ -173,6 +229,7 @@ extern { -> ::c_int; pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn __errno_location() -> *mut ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/linux/notmips/b32/mod.rs b/src/unix/notbsd/linux/notmips/b32/mod.rs index 6928962cbacf3..fcf75da464542 100644 --- a/src/unix/notbsd/linux/notmips/b32/mod.rs +++ b/src/unix/notbsd/linux/notmips/b32/mod.rs @@ -17,6 +17,9 @@ pub type blksize_t = i32; pub type mode_t = u32; pub type nlink_t = u32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; + s! { pub struct stat { pub st_dev: ::dev_t, @@ -44,6 +47,10 @@ s! { pub struct pthread_attr_t { __size: [u32; 9] } + + pub struct sigset_t { + __val: [::c_ulong; 32], + } } cfg_if! { diff --git a/src/unix/notbsd/linux/notmips/b64/aarch64.rs b/src/unix/notbsd/linux/notmips/b64/aarch64.rs index 4bc5293de94af..cf23b3fb93292 100644 --- a/src/unix/notbsd/linux/notmips/b64/aarch64.rs +++ b/src/unix/notbsd/linux/notmips/b64/aarch64.rs @@ -5,6 +5,8 @@ pub type nlink_t = u32; pub type blksize_t = i32; pub type wchar_t = u32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; + s! { pub struct stat { pub st_dev: ::dev_t, diff --git a/src/unix/notbsd/linux/notmips/b64/mod.rs b/src/unix/notbsd/linux/notmips/b64/mod.rs index 582895b4fff9a..8f55e09d601d7 100644 --- a/src/unix/notbsd/linux/notmips/b64/mod.rs +++ b/src/unix/notbsd/linux/notmips/b64/mod.rs @@ -15,6 +15,14 @@ pub type mode_t = u32; pub type ssize_t = i64; pub type blkcnt_t = i64; +s! { + pub struct sigset_t { + __val: [::c_ulong; 16], + } +} + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/unix/notbsd/linux/notmips/b64/x86_64.rs b/src/unix/notbsd/linux/notmips/b64/x86_64.rs index 22d0accb425ed..fec4a9224dee7 100644 --- a/src/unix/notbsd/linux/notmips/b64/x86_64.rs +++ b/src/unix/notbsd/linux/notmips/b64/x86_64.rs @@ -5,6 +5,8 @@ pub type nlink_t = u64; pub type blksize_t = i64; pub type wchar_t = i32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + s! { pub struct stat { pub st_dev: ::dev_t, diff --git a/src/unix/notbsd/linux/notmips/mod.rs b/src/unix/notbsd/linux/notmips/mod.rs index 3b3109c008bb1..d836971758925 100644 --- a/src/unix/notbsd/linux/notmips/mod.rs +++ b/src/unix/notbsd/linux/notmips/mod.rs @@ -1,3 +1,25 @@ +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + _restorer: *mut ::c_void, + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } +} pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; @@ -147,6 +169,14 @@ pub const TCP_TIMESTAMP: ::c_int = 24; pub const SO_REUSEPORT: ::c_int = 15; +pub const FIOCLEX: ::c_ulong = 0x5451; + +pub const SA_ONSTACK: ::c_ulong = 0x08000000; +pub const SA_SIGINFO: ::c_ulong = 0x00000004; + +pub const SIGBUS: ::c_int = 7; +pub const SIG_SETMASK: ::c_int = 2; + cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { mod b32; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 8591420ce5b8e..9cd3f454593f4 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -18,6 +18,7 @@ pub type in_port_t = u16; pub type rlim_t = c_ulong; pub type sa_family_t = u16; pub type sighandler_t = size_t; +pub type pthread_key_t = c_uint; pub enum timezone {} @@ -68,7 +69,7 @@ s! { pub ai_canonname: *mut c_char, - #[cfg(any(target_os = "android", target_os = "nacl"))] + #[cfg(target_os = "android")] pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, @@ -105,7 +106,6 @@ pub const F_SETFL: c_int = 4; pub const O_ACCMODE: c_int = 3; pub const SIGTRAP: c_int = 5; -pub const SIG_IGN: size_t = 1; pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 1; @@ -303,10 +303,21 @@ pub const LOCK_EX: ::c_int = 2; pub const LOCK_NB: ::c_int = 4; pub const LOCK_UN: ::c_int = 8; +pub const SIGSTKSZ: ::size_t = 8192; + extern { pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn prctl(option: ::c_int, ...) -> ::c_int; + pub fn pthread_getattr_np(native: ::pthread_t, + attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t) -> ::c_int; + pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t) -> ::c_int; } cfg_if! { From 1ff961010ba16ccbdd74f88cf23fb11e413f6910 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 15:09:02 -0700 Subject: [PATCH 140/194] Fix android --- libc-test/build.rs | 21 ++- src/lib.rs | 1 + src/unix/mod.rs | 156 ++++++++++-------- src/unix/notbsd/android/b32.rs | 8 + src/unix/notbsd/android/b64.rs | 8 + .../notbsd/{android.rs => android/mod.rs} | 35 ++-- 6 files changed, 129 insertions(+), 100 deletions(-) create mode 100644 src/unix/notbsd/android/b32.rs create mode 100644 src/unix/notbsd/android/b64.rs rename src/unix/notbsd/{android.rs => android/mod.rs} (93%) diff --git a/libc-test/build.rs b/libc-test/build.rs index 3bc7782b3de37..d7ee75b949ee7 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -9,18 +9,19 @@ fn main() { let windows = target.contains("windows"); let mingw = target.contains("windows-gnu"); let linux = target.contains("unknown-linux"); + let android = target.contains("android"); let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw if target.contains("unknown-linux-gnu") { cfg.define("_GNU_SOURCE", None); - } else if target.contains("windows") { + } else if windows { cfg.define("_WIN32_WINNT", Some("0x8000")); } // Android doesn't actually have in_port_t but it's much easier if we // provide one for us to test against - if target.contains("android") { + if android { cfg.define("in_port_t", Some("uint16_t")); } @@ -39,13 +40,12 @@ fn main() { if target.contains("apple-darwin") { cfg.header("mach-o/dyld.h"); cfg.header("mach/mach_time.h"); - } else if target.contains("unknown-linux") || - target.contains("android") { + } else if linux || android { cfg.header("linux/if_packet.h"); cfg.header("net/ethernet.h"); } - if target.contains("windows") { + if windows { cfg.header("winsock2.h"); // must be before windows.h cfg.header("direct.h"); @@ -67,6 +67,7 @@ fn main() { cfg.header("netinet/ip.h"); cfg.header("netinet/tcp.h"); cfg.header("pthread.h"); + cfg.header("dlfcn.h"); cfg.header("signal.h"); cfg.header("string.h"); cfg.header("sys/file.h"); @@ -81,13 +82,15 @@ fn main() { cfg.header("utime.h"); cfg.header("pwd.h"); cfg.header("grp.h"); + cfg.header("malloc.h"); - if target.contains("android") { + if android { cfg.header("arpa/inet.h"); } else { cfg.header("glob.h"); cfg.header("ifaddrs.h"); cfg.header("sys/sysctl.h"); + cfg.header("execinfo.h"); } } @@ -193,9 +196,13 @@ fn main() { "getrlimit" | // non-int in 1st arg "setrlimit" | // non-int in 1st arg - "gettimeofday" | // typed 2nd arg on linux "strerror_r" if linux => true, // actually xpg-something-or-other + // typed 2nd arg on linux and android + "gettimeofday" if linux || android => true, + + "dlerror" if android => true, // const-ness is added + _ => false, } }); diff --git a/src/lib.rs b/src/lib.rs index 8ee87eabafb3d..8d0211a156b6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -150,6 +150,7 @@ extern { base: c_int) -> c_ulong; pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; pub fn free(p: *mut c_void); pub fn exit(status: c_int) -> !; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 2dabfd1544b30..eee5289aa4233 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -297,8 +297,8 @@ extern { pub fn ftruncate(fd: c_int, length: off_t) -> c_int; - pub fn signal(signum: c_int, - handler: sighandler_t) -> sighandler_t; + #[cfg_attr(target_os = "android", link_name = "bsd_signal")] + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; @@ -310,70 +310,7 @@ extern { -> *mut ::c_char; pub fn flock(fd: c_int, operation: c_int) -> c_int; -} - -// TODO: get rid of this #[cfg(not(...))] -#[cfg(not(target_os = "android"))] -extern { - pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; - pub fn freeifaddrs(ifa: *mut ifaddrs); - pub fn glob(pattern: *const c_char, - flags: c_int, - errfunc: ::dox::Option c_int>, - pglob: *mut glob_t) -> c_int; - pub fn globfree(pglob: *mut glob_t); - - pub fn posix_madvise(addr: *mut ::c_void, len: size_t, advice: c_int) - -> c_int; - - pub fn shm_unlink(name: *const c_char) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "seekdir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "seekdir$INODE64$UNIX2003")] - pub fn seekdir(dirp: *mut ::DIR, loc: c_long); - - #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), - link_name = "telldir$INODE64")] - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "telldir$INODE64$UNIX2003")] - pub fn telldir(dirp: *mut ::DIR) -> c_long; - - pub fn getsid(pid: pid_t) -> pid_t; - pub fn madvise(addr: *mut ::c_void, len: size_t, advice: c_int) - -> c_int; - pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "putenv$UNIX2003")] - pub fn putenv(string: *mut c_char) -> c_int; - pub fn readlink(path: *const c_char, - buf: *mut c_char, - bufsz: size_t) - -> ssize_t; - - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "msync$UNIX2003")] - pub fn msync(addr: *mut ::c_void, len: size_t, flags: c_int) -> c_int; - pub fn sysconf(name: c_int) -> c_long; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "usleep$UNIX2003")] - pub fn usleep(secs: c_uint) -> c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recvfrom$UNIX2003")] - pub fn recvfrom(socket: c_int, buf: *mut ::c_void, len: size_t, - flags: c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "send$UNIX2003")] - pub fn send(socket: c_int, buf: *const ::c_void, len: size_t, - flags: c_int) -> ssize_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "recv$UNIX2003")] - pub fn recv(socket: c_int, buf: *mut ::c_void, len: size_t, - flags: c_int) -> ssize_t; - pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; @@ -443,19 +380,94 @@ extern { oldact: *mut sigaction) -> ::c_int; pub fn sigaltstack(ss: *const sigaltstack, oss: *mut sigaltstack) -> ::c_int; - pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; - - pub fn getpwuid_r(uid: ::uid_t, - pwd: *mut passwd, - buf: *mut ::c_char, - buflen: ::size_t, - result: *mut *mut passwd) -> ::c_int; pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; + pub fn dlopen(filename: *const ::c_char, + flag: ::c_int) -> *mut ::c_void; + pub fn dlerror() -> *mut ::c_char; + pub fn dlsym(handle: *mut ::c_void, + symbol: *const ::c_char) -> *mut ::c_void; + pub fn dlclose(handle: *mut ::c_void) -> ::c_int; +} + +// TODO: get rid of this #[cfg(not(...))] +#[cfg(not(target_os = "android"))] +extern { + pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut ifaddrs); + pub fn glob(pattern: *const c_char, + flags: c_int, + errfunc: ::dox::Option c_int>, + pglob: *mut glob_t) -> c_int; + pub fn globfree(pglob: *mut glob_t); + + pub fn posix_madvise(addr: *mut ::c_void, len: size_t, advice: c_int) + -> c_int; + + pub fn shm_unlink(name: *const c_char) -> c_int; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003")] + pub fn seekdir(dirp: *mut ::DIR, loc: c_long); + + #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64")] + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003")] + pub fn telldir(dirp: *mut ::DIR) -> c_long; + + pub fn getsid(pid: pid_t) -> pid_t; + pub fn madvise(addr: *mut ::c_void, len: size_t, advice: c_int) + -> c_int; + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "putenv$UNIX2003")] + pub fn putenv(string: *mut c_char) -> c_int; + pub fn readlink(path: *const c_char, + buf: *mut c_char, + bufsz: size_t) + -> ssize_t; + + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003")] + pub fn msync(addr: *mut ::c_void, len: size_t, flags: c_int) -> c_int; + pub fn sysconf(name: c_int) -> c_long; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "usleep$UNIX2003")] + pub fn usleep(secs: c_uint) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003")] + pub fn recvfrom(socket: c_int, buf: *mut ::c_void, len: size_t, + flags: c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "send$UNIX2003")] + pub fn send(socket: c_int, buf: *const ::c_void, len: size_t, + flags: c_int) -> ssize_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "recv$UNIX2003")] + pub fn recv(socket: c_int, buf: *mut ::c_void, len: size_t, + flags: c_int) -> ssize_t; + pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + + pub fn getpwuid_r(uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd) -> ::c_int; + pub fn backtrace(buf: *mut *mut ::c_void, + sz: ::c_int) -> ::c_int; + pub fn posix_memalign(memptr: *mut *mut ::c_void, + align: ::size_t, + size: ::size_t) -> ::c_int; + pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs new file mode 100644 index 0000000000000..2f3de7ba2a55f --- /dev/null +++ b/src/unix/notbsd/android/b32.rs @@ -0,0 +1,8 @@ +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_ulong, + pub sa_restorer: Option, + } +} diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64.rs new file mode 100644 index 0000000000000..45dd78c9cc13c --- /dev/null +++ b/src/unix/notbsd/android/b64.rs @@ -0,0 +1,8 @@ +s! { + pub struct sigaction { + pub sa_flags: ::c_uint, + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut ::c_void, + } +} diff --git a/src/unix/notbsd/android.rs b/src/unix/notbsd/android/mod.rs similarity index 93% rename from src/unix/notbsd/android.rs rename to src/unix/notbsd/android/mod.rs index 6f4833ce9f14f..78e9898e7c34a 100644 --- a/src/unix/notbsd/android.rs +++ b/src/unix/notbsd/android/mod.rs @@ -91,27 +91,6 @@ s! { pub si_errno: ::c_int, pub si_code: ::c_int, pub _pad: [::c_int; 29], - _align: [u64; 0], - } -} - -#[cfg(target_pointer_width = "32")] -s!{ - pub struct sigaction { - pub sa_sigaction: sighandler_t, - pub sa_flags: libc::c_ulong, - _restorer: *mut libc::c_void, - pub sa_mask: sigset_t, - } -} - -#[cfg(target_pointer_width = "64")] -s!{ - pub struct sigaction { - pub sa_flags: libc::c_uint, - pub sa_sigaction: sighandler_t, - pub sa_mask: sigset_t, - _restorer: *mut libc::c_void, } } @@ -230,3 +209,17 @@ extern { pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_uint) -> ::ssize_t; } + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod b32; + pub use self::b32::*; + } else if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + // ... + } +} + + From 684cfa46918d0c1a2591e7008e826d60d62c59b8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 15:18:18 -0700 Subject: [PATCH 141/194] Add aarch64 support/CI --- .travis.yml | 3 +++ ci/cargo-config | 3 +++ ci/run-travis.sh | 4 ++++ ci/run.sh | 2 ++ src/unix/notbsd/linux/mips.rs | 1 + src/unix/notbsd/linux/mod.rs | 3 +-- src/unix/notbsd/linux/notmips/b32/mod.rs | 1 + src/unix/notbsd/linux/notmips/b64/aarch64.rs | 1 + src/unix/notbsd/linux/notmips/b64/x86_64.rs | 1 + 9 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a8f3945ed3a0..bda94c10cbf6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,9 @@ matrix: - os: linux env: TARGET=mips-unknown-linux-gnu rust: nightly-2015-09-08 + - os: linux + env: TARGET=aarch64-unknown-linux-gnu + rust: nightly-2015-09-08 addons: apt: packages: diff --git a/ci/cargo-config b/ci/cargo-config index 575bdacdbf1fe..f8f6cc21da47c 100644 --- a/ci/cargo-config +++ b/ci/cargo-config @@ -6,3 +6,6 @@ linker = "arm-linux-gnueabihf-gcc-4.7" [target.mips-unknown-linux-gnu] linker = "mips-linux-gnu-gcc" + +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" diff --git a/ci/run-travis.sh b/ci/run-travis.sh index f760306a9eac2..e4fa0d55a6ce4 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -23,6 +23,10 @@ elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user export CC=arm-linux-gnueabihf-gcc-4.7 +elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + sudo apt-get install gcc-aarch64-linux-gnu qemu-user + export CC=aarch64-linux-gnu-gcc elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then # Download pre-built and custom MIPS libs and then also instsall the MIPS # compiler according to this post: diff --git a/ci/run.sh b/ci/run.sh index 9604f1be11378..16778a98728d8 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -16,6 +16,8 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then # FIXME: this segfaults on travis, passes locally? #qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-* echo skip +elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then + qemu-aarch64 -L /usr/aarch64-linux-gnu/ libc-test/target/$TARGET/debug/libc-test else cargo run --manifest-path libc-test/Cargo.toml --target $TARGET fi diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 8364e7bed4eee..35ee3a82c7b99 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -205,6 +205,7 @@ pub const SO_ACCEPTCONN: ::c_int = 4105; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const FIOCLEX: ::c_ulong = 0x6601; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index e119bbd64eacc..4eeda9d2216e3 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -50,7 +50,7 @@ s! { } pub struct pthread_mutexattr_t { - __align: [::c_int; 0], + __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } @@ -214,7 +214,6 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { }; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const __SIZEOF_PTHREAD_COND_T: usize = 48; -pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; extern { pub fn shm_open(name: *const c_char, oflag: ::c_int, diff --git a/src/unix/notbsd/linux/notmips/b32/mod.rs b/src/unix/notbsd/linux/notmips/b32/mod.rs index fcf75da464542..862969060dece 100644 --- a/src/unix/notbsd/linux/notmips/b32/mod.rs +++ b/src/unix/notbsd/linux/notmips/b32/mod.rs @@ -19,6 +19,7 @@ pub type nlink_t = u32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; s! { pub struct stat { diff --git a/src/unix/notbsd/linux/notmips/b64/aarch64.rs b/src/unix/notbsd/linux/notmips/b64/aarch64.rs index cf23b3fb93292..7452e7dc89e34 100644 --- a/src/unix/notbsd/linux/notmips/b64/aarch64.rs +++ b/src/unix/notbsd/linux/notmips/b64/aarch64.rs @@ -6,6 +6,7 @@ pub type blksize_t = i32; pub type wchar_t = u32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; s! { pub struct stat { diff --git a/src/unix/notbsd/linux/notmips/b64/x86_64.rs b/src/unix/notbsd/linux/notmips/b64/x86_64.rs index fec4a9224dee7..0068fe0654fbb 100644 --- a/src/unix/notbsd/linux/notmips/b64/x86_64.rs +++ b/src/unix/notbsd/linux/notmips/b64/x86_64.rs @@ -6,6 +6,7 @@ pub type blksize_t = i64; pub type wchar_t = i32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; s! { pub struct stat { From de9736da964082b442e7bce5cbb09dbae203e4f2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 15:47:44 -0700 Subject: [PATCH 142/194] Fix all tests on OSX --- libc-test/build.rs | 14 +++++++-- src/lib.rs | 1 - src/unix/bsd/apple/mod.rs | 43 ++++++++++++++-------------- src/unix/bsd/mod.rs | 4 ++- src/unix/mod.rs | 37 +++++++++++++++++++++--- src/unix/notbsd/android/mod.rs | 2 +- src/unix/notbsd/linux/mips.rs | 2 +- src/unix/notbsd/linux/notmips/mod.rs | 2 +- src/unix/notbsd/mod.rs | 3 ++ 9 files changed, 75 insertions(+), 33 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d7ee75b949ee7..b9838196713ef 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -10,6 +10,7 @@ fn main() { let mingw = target.contains("windows-gnu"); let linux = target.contains("unknown-linux"); let android = target.contains("android"); + let darwin = target.contains("apple-darwin"); let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw @@ -37,7 +38,7 @@ fn main() { .header("time.h") .header("wchar.h"); - if target.contains("apple-darwin") { + if darwin { cfg.header("mach-o/dyld.h"); cfg.header("mach/mach_time.h"); } else if linux || android { @@ -82,7 +83,6 @@ fn main() { cfg.header("utime.h"); cfg.header("pwd.h"); cfg.header("grp.h"); - cfg.header("malloc.h"); if android { cfg.header("arpa/inet.h"); @@ -93,6 +93,13 @@ fn main() { cfg.header("execinfo.h"); } + if darwin { + cfg.header("malloc/malloc.h"); + cfg.header("crt_externs.h"); + } else { + cfg.header("malloc.h"); + } + } if target.contains("linux") { cfg.header("sys/prctl.h"); @@ -108,6 +115,9 @@ fn main() { "time64_t" if windows => "__time64_t".to_string(), "ssize_t" if windows => "SSIZE_T".to_string(), + // OSX calls this something else + "sighandler_t" if darwin => "sig_t".to_string(), + t if t.ends_with("_t") => t.to_string(), // Windows uppercase structs don't have `struct` in front, there's a diff --git a/src/lib.rs b/src/lib.rs index 8d0211a156b6c..8ee87eabafb3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -150,7 +150,6 @@ extern { base: c_int) -> c_ulong; pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; - pub fn memalign(align: size_t, size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; pub fn free(p: *mut c_void); pub fn exit(status: c_int) -> !; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 173788df3def2..588f33ee528e6 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -124,32 +124,33 @@ s! { pub struct pthread_mutex_t { - __sig: libc::c_long, + __sig: ::c_long, __opaque: [u8; __PTHREAD_MUTEX_SIZE__], } pub struct pthread_mutexattr_t { - __sig: libc::c_long, - __opaque: [u8; 16], + __sig: ::c_long, + __opaque: [u8; 8], } pub struct pthread_cond_t { - __sig: libc::c_long, + __sig: ::c_long, __opaque: [u8; __PTHREAD_COND_SIZE__], } pub struct pthread_rwlock_t { - __sig: libc::c_long, + __sig: ::c_long, __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], } pub struct siginfo_t { - pub _signo: ::c_int, - pub _errno: ::c_int, - pub _code: ::c_int, - pub _pid: ::pid_t, - pub _uid: ::uid_t, - pub _status: ::c_int, - pub si_addr: *mut ::c_void + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub si_pid: ::pid_t, + pub si_uid: ::uid_t, + pub si_status: ::c_int, + pub si_addr: *mut ::c_void, + _pad: [usize; 9], } pub struct sigaction { @@ -639,19 +640,19 @@ pub const _SC_PASS_MAX: c_int = 131; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; -pub const _PTHREAD_MUTEX_SIG_INIT: ::c_long = 0x32AAABA7; -pub const _PTHREAD_COND_SIG_INIT: ::c_long = 0x3CB0B1BB; -pub const _PTHREAD_RWLOCK_SIG_INIT: ::c_long = 0x2DA8B3B4; +pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7; +pub const _PTHREAD_COND_SIG_init: ::c_long = 0x3CB0B1BB; +pub const _PTHREAD_RWLOCK_SIG_init: ::c_long = 0x2DA8B3B4; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __sig: _PTHREAD_MUTEX_SIG_INIT, + __sig: _PTHREAD_MUTEX_SIG_init, __opaque: [0; __PTHREAD_MUTEX_SIZE__], }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __sig: _PTHREAD_COND_SIG_INIT, + __sig: _PTHREAD_COND_SIG_init, __opaque: [0; __PTHREAD_COND_SIZE__], }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __sig: _PTHREAD_RWLOCK_SIG_INIT, + __sig: _PTHREAD_RWLOCK_SIG_init, __opaque: [0; __PTHREAD_RWLOCK_SIZE__], }; @@ -660,7 +661,7 @@ extern { bufsize: *mut ::uint32_t) -> ::c_int; pub fn _NSGetArgc() -> *mut c_int; pub fn _NSGetArgv() -> *mut *mut *mut c_char; - pub fn _NSGetEnviron() -> *mut *const *const c_char; + pub fn _NSGetEnviron() -> *mut *mut *mut c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) @@ -679,14 +680,12 @@ extern { newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; - pub fn _tlv_atexit(dtor: unsafe extern fn(*mut u8), - arg: *mut u8); pub fn mach_absolute_time() -> u64; pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; pub fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut ::c_void; pub fn pthread_get_stacksize_np(thread: pthread_t) -> ::size_t; - pub fn __error() -> *const ::c_int; + pub fn __error() -> *mut ::c_int; } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 5dd2fb7092561..92b2d8732d713 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -41,7 +41,7 @@ s! { pub pw_expire: ::time_t, } - pub struct sigaltstack { + pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_size: ::size_t, pub ss_flags: ::c_int, @@ -64,6 +64,8 @@ extern { mibp: *mut c_int, sizep: *mut size_t) -> c_int; + pub fn setgroups(ngroups: ::c_int, + ptr: *const ::gid_t) -> ::c_int; } cfg_if! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index eee5289aa4233..75c1855faaef3 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -198,6 +198,8 @@ extern { pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int; pub fn getlogin() -> *mut c_char; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "getopt$UNIX2003")] pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; pub fn getpgrp() -> pid_t; @@ -300,7 +302,11 @@ extern { #[cfg_attr(target_os = "android", link_name = "bsd_signal")] pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "getrlimit$UNIX2003")] pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "setrlimit$UNIX2003")] pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; @@ -319,6 +325,8 @@ extern { attr: *const ::pthread_attr_t, f: extern fn(*mut ::c_void) -> *mut ::c_void, value: *mut ::c_void) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_join$UNIX2003")] pub fn pthread_join(native: ::pthread_t, value: *mut *mut ::c_void) -> ::c_int; pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; @@ -344,24 +352,44 @@ extern { pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_mutexattr_destroy$UNIX2003")] pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int; pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: ::c_int) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_wait$UNIX2003")] pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_timedwait$UNIX2003")] pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t, abstime: *const ::timespec) -> ::c_int; pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_destroy$UNIX2003")] pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_rdlock$UNIX2003")] pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_tryrdlock$UNIX2003")] pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_wrlock$UNIX2003")] pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_trywrlock$UNIX2003")] pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_unlock$UNIX2003")] pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003")] pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int; @@ -378,14 +406,14 @@ extern { pub fn sigaction(signum: ::c_int, act: *const sigaction, oldact: *mut sigaction) -> ::c_int; - pub fn sigaltstack(ss: *const sigaltstack, - oss: *mut sigaltstack) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003")] + pub fn sigaltstack(ss: *const stack_t, + oss: *mut stack_t) -> ::c_int; pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; - pub fn setgroups(ngroups: ::size_t, - ptr: *const ::gid_t) -> ::c_int; pub fn dlopen(filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void; pub fn dlerror() -> *mut ::c_char; @@ -399,6 +427,7 @@ extern { extern { pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; pub fn freeifaddrs(ifa: *mut ifaddrs); + #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] pub fn glob(pattern: *const c_char, flags: c_int, errfunc: ::dox::Option ::c_int; + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + pub fn setgroups(ngroups: ::size_t, + ptr: *const ::gid_t) -> ::c_int; } cfg_if! { From b347b44771a1d2714539fdbef7672a801df0aafe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 15:48:30 -0700 Subject: [PATCH 143/194] Fix x86_64 linux --- src/unix/notbsd/linux/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 4eeda9d2216e3..cdf4194dc9b0e 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -50,6 +50,9 @@ s! { } pub struct pthread_mutexattr_t { + #[cfg(target_arch = "x86_64")] + __align: [::c_int; 0], + #[cfg(not(target_arch = "x86_64"))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } From 6de3816a0258de0d4e5144da9127ecb86317b80b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 16:53:43 -0700 Subject: [PATCH 144/194] Fix references to Option through dox --- src/unix/mod.rs | 2 +- src/unix/notbsd/android/b32.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 75c1855faaef3..8f1d1a07aa708 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -338,7 +338,7 @@ extern { pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; pub fn sched_yield() -> ::c_int; pub fn pthread_key_create(key: *mut pthread_key_t, - dtor: Option) + dtor: ::dox::Option) -> c_int; pub fn pthread_key_delete(key: pthread_key_t) -> c_int; pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs index 2f3de7ba2a55f..8ae2c2e38040d 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32.rs @@ -3,6 +3,6 @@ s! { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, pub sa_flags: ::c_ulong, - pub sa_restorer: Option, + pub sa_restorer: ::dox::Option, } } From 15b83c244fbdbf24d797cc0639792414251a6111 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 17:25:52 -0700 Subject: [PATCH 145/194] Use musl-gcc, fix musl headers --- ci/run-travis.sh | 2 ++ libc-test/build.rs | 23 ++++++++---- src/unix/bsd/mod.rs | 1 + src/unix/mod.rs | 7 ++-- src/unix/notbsd/android/mod.rs | 4 +++ src/unix/notbsd/linux/mod.rs | 52 +++++++++++++++++++--------- src/unix/notbsd/linux/notmips/mod.rs | 13 +++++-- src/unix/notbsd/mod.rs | 3 -- 8 files changed, 74 insertions(+), 31 deletions(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index e4fa0d55a6ce4..f5ddc9dc51f5c 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -19,6 +19,8 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then sh ci/run.sh $TARGET elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + sudo apt-get install musl-tools + export CC=musl-gcc elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user diff --git a/libc-test/build.rs b/libc-test/build.rs index b9838196713ef..0f607c24bd034 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -11,10 +11,11 @@ fn main() { let linux = target.contains("unknown-linux"); let android = target.contains("android"); let darwin = target.contains("apple-darwin"); + let musl = target.contains("musl"); let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw - if target.contains("unknown-linux-gnu") { + if target.contains("unknown-linux") { cfg.define("_GNU_SOURCE", None); } else if windows { cfg.define("_WIN32_WINNT", Some("0x8000")); @@ -42,7 +43,7 @@ fn main() { cfg.header("mach-o/dyld.h"); cfg.header("mach/mach_time.h"); } else if linux || android { - cfg.header("linux/if_packet.h"); + cfg.header("netpacket/packet.h"); cfg.header("net/ethernet.h"); } @@ -89,8 +90,11 @@ fn main() { } else { cfg.header("glob.h"); cfg.header("ifaddrs.h"); - cfg.header("sys/sysctl.h"); - cfg.header("execinfo.h"); + + if !musl { + cfg.header("execinfo.h"); + cfg.header("sys/sysctl.h"); + } } if darwin { @@ -192,6 +196,9 @@ fn main() { "SIG_IGN" => true, // sighandler_t weirdness + // types on musl are defined a little differently + n if musl && n.contains("PTHREAD") => true, + _ => false, } }); @@ -220,17 +227,19 @@ fn main() { // Windows dllimport oddness? cfg.skip_fn_ptrcheck(move |_| windows); - cfg.skip_field_type(|struct_, field| { + cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. (struct_ == "ifaddrs" && field == "ifa_ifu") || // sighandler_t type is super weird (struct_ == "sigaction" && field == "sa_sigaction") }); - cfg.skip_field(|struct_, field| { + cfg.skip_field(move |struct_, field| { // this is actually a union on linux, so we can't represent it well and // just insert some padding. - (struct_ == "siginfo_t" && field == "_pad") + (struct_ == "siginfo_t" && field == "_pad") || + // musl names this __dummy1 but it's still there + (musl && struct_ == "glob_t" && field == "gl_flags") }); cfg.generate("../src/lib.rs", "all.rs"); diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 92b2d8732d713..94c90e85a7ae8 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -66,6 +66,7 @@ extern { -> c_int; pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; } cfg_if! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8f1d1a07aa708..4e80d2cf7f958 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -40,7 +40,10 @@ s! { pub ru_msgrcv: c_long, pub ru_nsignals: c_long, pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long + pub ru_nivcsw: c_long, + + #[cfg(target_env = "musl")] + __reserved: [c_long; 16], } pub struct in_addr { @@ -455,7 +458,6 @@ extern { pub fn getsid(pid: pid_t) -> pid_t; pub fn madvise(addr: *mut ::c_void, len: size_t, advice: c_int) -> c_int; - pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "putenv$UNIX2003")] pub fn putenv(string: *mut c_char) -> c_int; @@ -491,6 +493,7 @@ extern { buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; + #[cfg(not(target_env = "musl"))] pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; pub fn posix_memalign(memptr: *mut *mut ::c_void, diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 13519e32561c3..0ed7098898af3 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -186,6 +186,10 @@ pub const SA_SIGINFO: ::c_ulong = 0x00000004; pub const SIGBUS: ::c_int = 7; pub const SIG_SETMASK: ::c_int = 2; +pub const O_ACCMODE: ::c_int = 3; + +pub const RUSAGE_CHILDREN: c_int = -1; + extern { pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index cdf4194dc9b0e..eaf7cb257ddb9 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -73,11 +73,8 @@ s! { } } -pub const BUFSIZ: ::c_uint = 8192; pub const FILENAME_MAX: ::c_uint = 4096; -pub const FOPEN_MAX: ::c_uint = 16; pub const L_tmpnam: ::c_uint = 20; -pub const TMP_MAX: ::c_uint = 238328; pub const _PC_NAME_MAX: ::c_int = 3; pub const _SC_ARG_MAX: ::c_int = 0; @@ -156,7 +153,6 @@ pub const _SC_XOPEN_CRYPT: ::c_int = 92; pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; pub const _SC_XOPEN_SHM: ::c_int = 94; pub const _SC_2_CHAR_TERM: ::c_int = 95; -pub const _SC_2_C_VERSION: ::c_int = 96; pub const _SC_2_UPE: ::c_int = 97; pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; @@ -168,9 +164,6 @@ pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; -#[cfg(not(target_env = "musl"))] -pub const RUSAGE_THREAD: ::c_int = 1; - pub const GLOB_ERR: ::c_int = 1 << 0; pub const GLOB_MARK: ::c_int = 1 << 1; pub const GLOB_NOSORT: ::c_int = 1 << 2; @@ -187,7 +180,6 @@ pub const POSIX_MADV_NORMAL: ::c_int = 0; pub const POSIX_MADV_RANDOM: ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; -pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const S_IEXEC: mode_t = 64; pub const S_IWRITE: mode_t = 128; @@ -221,17 +213,10 @@ pub const __SIZEOF_PTHREAD_COND_T: usize = 48; extern { pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; - #[cfg(not(target_env = "musl"))] - pub fn sysctl(name: *mut ::c_int, - namelen: ::c_int, - oldp: *mut ::c_void, - oldlenp: *mut size_t, - newp: *mut ::c_void, - newlen: size_t) - -> ::c_int; pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn __errno_location() -> *mut ::c_int; + } cfg_if! { @@ -243,6 +228,41 @@ cfg_if! { } } +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const BUFSIZ: ::c_uint = 1024; + pub const TMP_MAX: ::c_uint = 10000; + pub const FOPEN_MAX: ::c_uint = 1000; + pub const POSIX_MADV_DONTNEED: ::c_int = 0; + pub const O_ACCMODE: ::c_int = 0o10000003; + pub const RUSAGE_CHILDREN: ::c_int = 1; + + extern { + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; + } + } else { + pub const BUFSIZ: ::c_uint = 8192; + pub const TMP_MAX: ::c_uint = 238328; + pub const FOPEN_MAX: ::c_uint = 16; + pub const POSIX_MADV_DONTNEED: ::c_int = 4; + pub const _SC_2_C_VERSION: ::c_int = 96; + pub const RUSAGE_THREAD: ::c_int = 1; + pub const O_ACCMODE: ::c_int = 3; + pub const RUSAGE_CHILDREN: ::c_int = -1; + + extern { + pub fn sysctl(name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut size_t, + newp: *mut ::c_void, + newlen: size_t) + -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + } + } +} + cfg_if! { if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { mod mips; diff --git a/src/unix/notbsd/linux/notmips/mod.rs b/src/unix/notbsd/linux/notmips/mod.rs index 3b64ecb15e5a6..9a3ca318a96ba 100644 --- a/src/unix/notbsd/linux/notmips/mod.rs +++ b/src/unix/notbsd/linux/notmips/mod.rs @@ -26,8 +26,6 @@ pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_RTTIME: ::c_int = 15; -pub const RLIMIT_NLIMITS: ::c_int = 16; pub const RLIM_INFINITY: ::rlim_t = !0; pub const O_APPEND: ::c_int = 1024; @@ -156,7 +154,6 @@ pub const SO_RCVTIMEO: ::c_int = 20; pub const SO_SNDTIMEO: ::c_int = 21; pub const SO_ACCEPTCONN: ::c_int = 30; -pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; pub const TCP_THIN_DUPACK: ::c_int = 17; pub const TCP_USER_TIMEOUT: ::c_int = 18; @@ -177,6 +174,16 @@ pub const SA_SIGINFO: ::c_ulong = 0x00000004; pub const SIGBUS: ::c_int = 7; pub const SIG_SETMASK: ::c_int = 2; +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const RLIMIT_NLIMITS: ::c_int = 15; + } else { + pub const RLIMIT_NLIMITS: ::c_int = 16; + pub const RLIMIT_RTTIME: ::c_int = 15; + pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; + } +} + cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { mod b32; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index d6b7ad046e21b..ba6c767a4b54b 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -103,8 +103,6 @@ pub const F_SETFD: c_int = 2; pub const F_GETFL: c_int = 3; pub const F_SETFL: c_int = 4; -pub const O_ACCMODE: c_int = 3; - pub const SIGTRAP: c_int = 5; pub const PTHREAD_CREATE_JOINABLE: c_int = 0; @@ -125,7 +123,6 @@ pub const RLIMIT_NICE: c_int = 13; pub const RLIMIT_RTPRIO: c_int = 14; pub const RUSAGE_SELF: c_int = 0; -pub const RUSAGE_CHILDREN: c_int = -1; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; From 97a2c17c1727e5dffe07ed7e021317e93fb4e9e8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 17:28:45 -0700 Subject: [PATCH 146/194] Impl Copy/Clone for dummy Option --- src/dox.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dox.rs b/src/dox.rs index 92e3edacf8743..4c68157687d03 100644 --- a/src/dox.rs +++ b/src/dox.rs @@ -13,6 +13,10 @@ mod imp { Some(T), None, } + impl for Option {} + impl Clone for Option { + fn clone(&self) -> Option { loop {} } + } pub trait Clone { fn clone(&self) -> Self; From d13e1e4bdad79bd91adff3f9d82c2b9375f5f33c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 17:29:18 -0700 Subject: [PATCH 147/194] Add aarch64 url --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 8ee87eabafb3d..7997e11ca08f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,6 +28,9 @@ #![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc( html_root_url = "http://alexcrichton.com/libc/mips-unknown-linux-gnu" ))] +#![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc( + html_root_url = "http://alexcrichton.com/libc/aarch64-unknown-linux-gnu" +))] #![cfg_attr(all(target_os = "linux", target_env = "musl"), doc( html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-musl" ))] From d9962f4bd16cefb0e653835dfad5f0b5bee8a755 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 17:45:10 -0700 Subject: [PATCH 148/194] CI dox --- ci/Dockerfile-android | 4 ++++ ci/README.md | 45 +++++++++++++++++++++++++++++++++++++++++++ ci/cargo-config | 2 ++ ci/dox.sh | 11 ++++++++--- ci/msys2.ps1 | 2 ++ ci/run-travis.sh | 4 ++++ ci/run.sh | 3 +++ 7 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 ci/README.md diff --git a/ci/Dockerfile-android b/ci/Dockerfile-android index dc85a9cb0a7a0..5f0a31e9c2fb1 100644 --- a/ci/Dockerfile-android +++ b/ci/Dockerfile-android @@ -1,3 +1,7 @@ +# This is a Dockerfile for building the image that is used to build Android +# binaries and run tests within. This will install the NDK, SDK, and set up an +# emulator to run tests in. + FROM ubuntu:latest RUN mkdir /build diff --git a/ci/README.md b/ci/README.md new file mode 100644 index 0000000000000..c05e771da18fc --- /dev/null +++ b/ci/README.md @@ -0,0 +1,45 @@ +The goal of the libc crate is to have CI running everywhere to have the +strongest guarantees about the definitions that this library contains, and as a +result the CI is pretty complicated and also pretty large! Hopefully this can +serve as a guide through the sea of scripts in this directory and elsewhere in +this project. + +First up, let's talk about the files in this directory: + +* `Dockerfile-android`, `android-accept-licenses.sh` -- these two files are + used to build the Docker image that the android CI builder uses. The + `Dockerfile` just installs the Android SDK, NDK, a Rust nightly, Rust target + libraries for Android, and sets up an emulator to run tests in. You can build + a new image with this command (from the root of the project): + + docker build -t alexcrichton/rust-libc-test -f ci/Dockerfile-android . + + When building a new image contact @alexcrichton to push it to the docker hub + and have libc start using it. This hasn't needed to happen yet, so the process + may be a little involved. + + The script here, `android-accept-licenses.sh` is just a helper used to accept + the licenses of the SDK of Android while the docker image is being created. + +* `msys2.ps1` - a PowerShell script which is used to install MSYS2 on the + AppVeyor bots. As of this writing MSYS2 isn't installed by default, and this + script will install the right version/arch of msys2 in preparation of using + the contained C compiler to compile C shims. + +* `run-travis.sh` - a shell script run by all Travis builders, this is + responsible for setting up the rest of the environment such as installing new + packages, downloading Rust target libraries, etc. + +* `run.sh` - the actual script which runs tests for a particular architecture. + Called from the `run-travis.sh` script this will run all tests for the target + specified. + +* `cargo-config` - Cargo configuration of linkers to use copied into place by + the `run-travis.sh` script before builds are run. + +* `dox.sh` - script called from `run-travis.sh` on only the linux 64-bit nightly + Travis bots to build documentation for this crate. + +* `landing-page-*.html` - used by `dox.sh` to generate a landing page for all + architectures' documentation. + diff --git a/ci/cargo-config b/ci/cargo-config index f8f6cc21da47c..e738f18902dc0 100644 --- a/ci/cargo-config +++ b/ci/cargo-config @@ -1,3 +1,5 @@ +# Configuration of which linkers to call on Travis for various architectures + [target.arm-linux-androideabi] linker = "arm-linux-androideabi-gcc" diff --git a/ci/dox.sh b/ci/dox.sh index a003dc389d06c..6edcb159ddba6 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -1,14 +1,18 @@ #!/bin/sh +# Builds documentation for all target triples that we have a registered URL for +# in liblibc. This scrapes the list of triples to document from `src/lib.rs` +# which has a bunch of `html_root_url` directives we pick up. + set -e +TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'` + rm -rf target/doc mkdir -p target/doc cp ci/landing-page-head.html target/doc/index.html -TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'` - for target in $TARGETS; do echo documenting $target @@ -21,7 +25,8 @@ done cat ci/landing-page-footer.html >> target/doc/index.html -if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "autotest" ]; then +# If we're on travis, not a PR, and on the right branch, publish! +if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then pip install ghp-import --user $USER $HOME/.local/bin/ghp-import -n target/doc git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages diff --git a/ci/msys2.ps1 b/ci/msys2.ps1 index f57cc6b4e8555..071e8f4af0294 100644 --- a/ci/msys2.ps1 +++ b/ci/msys2.ps1 @@ -1,3 +1,5 @@ +# Installs MSYS2 on AppVeyor builders + If (!${env:MSYS2_ARCH}) { Exit 0 } diff --git a/ci/run-travis.sh b/ci/run-travis.sh index f5ddc9dc51f5c..db01aae2412b8 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -1,3 +1,7 @@ +# Entry point for all travis builds, this will set up the Travis environment by +# downloading any dependencies. It will then execute the `run.sh` script to +# build and execute all tests. + set -ex if [ "$TRAVIS_OS_NAME" = "linux" ]; then diff --git a/ci/run.sh b/ci/run.sh index 16778a98728d8..f9e0b51e02e64 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -1,5 +1,8 @@ #!/bin/sh +# Builds and runs tests for a particular target passed as an argument to this +# script. + set -ex TARGET=$1 From d86471cb4aa6ce08eb35823ec6b7e2c82658653a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 17:46:58 -0700 Subject: [PATCH 149/194] Only install gcc-multilib when necessary --- .travis.yml | 4 ---- ci/run-travis.sh | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bda94c10cbf6e..e34b284cd9582 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,6 @@ matrix: - os: linux env: TARGET=aarch64-unknown-linux-gnu rust: nightly-2015-09-08 -addons: - apt: - packages: - - gcc-multilib notifications: email: on_success: never diff --git a/ci/run-travis.sh b/ci/run-travis.sh index db01aae2412b8..5abf23f82836d 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -57,6 +57,10 @@ else # clang has better error messages and implements alignof more broadly export CC=clang + + if [ "$TARGET" = "i686-unknown-linux-gnu" ]; then + sudo apt-get install gcc-multilib + fi fi mkdir .cargo From 145ac09cf92144d2e92df87c213dca1fad0c3bfe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 17:52:13 -0700 Subject: [PATCH 150/194] Describe CI processes --- ci/README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ci/README.md b/ci/README.md index c05e771da18fc..6aebb43fdd023 100644 --- a/ci/README.md +++ b/ci/README.md @@ -4,6 +4,8 @@ result the CI is pretty complicated and also pretty large! Hopefully this can serve as a guide through the sea of scripts in this directory and elsewhere in this project. +# Files + First up, let's talk about the files in this directory: * `Dockerfile-android`, `android-accept-licenses.sh` -- these two files are @@ -43,3 +45,36 @@ First up, let's talk about the files in this directory: * `landing-page-*.html` - used by `dox.sh` to generate a landing page for all architectures' documentation. +# CI Systems + +Currently this repository leverages a combination of Travis CI and AppVeyor for +running tests. The triples tested are: + +* AppVeyor + * `{i686,x86_64}-pc-windows-{msvc,gnu}` +* Travis + * `{i686,x86_64,mips,aarch64}-unknown-linux-gnu` + * `x86_64-unknown-linux-musl` + * `arm-unknown-linux-gnueabihf` + * `arm-linux-androideabi` + * `{i686,x86_64}-apple-darwin` + +The Windows triples are all pretty standard, they just set up their environment +then run tests, no need for downloading any extra target libs (we just download +the right installer). The Intel Linux/OSX builds are similar in that we just +download the right target libs and run tests. Note that the Intel Linux/OSX +builds are run on stable/beta/nightly, but are the only ones that do so. + +The remaining architectures look like: + +* Android runs in a docker image with an emulator, the NDK, and the SDK already + set up (see `Dockerfile-android`). The entire build happens within the docker + image. +* The MIPS, ARM, and AArch64 builds all use QEMU to run the generated binary to + actually verify the tests pass. +* The MUSL build just has to download a MUSL compiler and target libraries and + then otherwise runs tests normally. + +Hopefully that's at least somewhat of an introduction to everything going on +here, and feel free to ping @alexcrichton with questions! + From 0262b07fa58a2b0ca79cbcfb0f9d2080a79924c9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 17:53:03 -0700 Subject: [PATCH 151/194] Fix impl syntax --- src/dox.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dox.rs b/src/dox.rs index 4c68157687d03..9432b882196a5 100644 --- a/src/dox.rs +++ b/src/dox.rs @@ -13,7 +13,7 @@ mod imp { Some(T), None, } - impl for Option {} + impl Copy for Option {} impl Clone for Option { fn clone(&self) -> Option { loop {} } } From b66b8a4424aa971c3bb9551f6b9130af736a3612 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 20:55:52 -0700 Subject: [PATCH 152/194] Run apt-get update before installing --- ci/run-travis.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 5abf23f82836d..b7d0206479a06 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -15,6 +15,11 @@ export HOST=$ARCH-$OS MAIN_TARGETS=https://static.rust-lang.org/dist EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 +install() { + sudo apt-get update + sudo apt-get install $@ +} + if [ "$TARGET" = "arm-linux-androideabi" ]; then # Pull a pre-built docker image for testing android, then run tests entirely # within that image. @@ -23,15 +28,15 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then sh ci/run.sh $TARGET elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - sudo apt-get install musl-tools + install musl-tools export CC=musl-gcc elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user + install gcc-4.7-arm-linux-gnueabihf qemu-user export CC=arm-linux-gnueabihf-gcc-4.7 elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - sudo apt-get install gcc-aarch64-linux-gnu qemu-user + install gcc-aarch64-linux-gnu qemu-user export CC=aarch64-linux-gnu-gcc elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then # Download pre-built and custom MIPS libs and then also instsall the MIPS @@ -43,9 +48,8 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then sudo tee -a /etc/apt/sources.list echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install emdebian-archive-keyring - sudo apt-get install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes + install emdebian-archive-keyring + install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes export CC=mips-linux-gnu-gcc else # Download the rustlib folder from the relevant portion of main distribution's @@ -59,7 +63,7 @@ else export CC=clang if [ "$TARGET" = "i686-unknown-linux-gnu" ]; then - sudo apt-get install gcc-multilib + install gcc-multilib fi fi From 038aedb642e7d058c2172d4a985fb2babf145f36 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Sep 2015 20:56:52 -0700 Subject: [PATCH 153/194] Fix android build --- src/unix/notbsd/android/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 0ed7098898af3..fe296bdfc5ebc 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -188,7 +188,7 @@ pub const SIG_SETMASK: ::c_int = 2; pub const O_ACCMODE: ::c_int = 3; -pub const RUSAGE_CHILDREN: c_int = -1; +pub const RUSAGE_CHILDREN: ::c_int = -1; extern { pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) From a1b948e34abeefa646826aeafd4fdd8a1c0b0934 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 11:54:32 -0700 Subject: [PATCH 154/194] Fix FreeBSD --- ci/Vagrantfile | 30 +++++++++++++++ ci/run-travis.sh | 23 ++++++++++++ libc-test/build.rs | 57 +++++++++++++++-------------- src/unix/bsd/apple/mod.rs | 11 +++++- src/unix/bsd/freebsdlike/freebsd.rs | 2 +- src/unix/bsd/freebsdlike/mod.rs | 25 +++++++++---- src/unix/bsd/mod.rs | 8 +--- src/unix/bsd/openbsdlike/mod.rs | 9 +++++ src/unix/mod.rs | 3 -- src/unix/notbsd/mod.rs | 3 ++ 10 files changed, 125 insertions(+), 46 deletions(-) create mode 100644 ci/Vagrantfile diff --git a/ci/Vagrantfile b/ci/Vagrantfile new file mode 100644 index 0000000000000..a55aa3ebea42d --- /dev/null +++ b/ci/Vagrantfile @@ -0,0 +1,30 @@ +# A vagrant configuration file for running tests on BSD-like machines +# +# Note that this was originally intended to later be used to run tests on +# Travis, but it didn't work out. Regardless this has stuck around! You can run +# tests in FreeBSD via: +# +# git clone https://github.com/alexcrichton/libc --branch autotest +# cd libc/ci +# vagrant up freebsd +# vagrant ssh freebsd +# ... +# cd /vagrant/libc-test +# cargo run +# +# And "that's it"! You look up instructions on Vagrant's website for how to +# install vagrant. + +Vagrant.configure(2) do |config| + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + config.vm.define :freebsd do |bsd| + bsd.vm.box = "arkadi/freebsd-10.1-amd64" + bsd.vm.provision :shell, inline: 'yes | sudo pkg install rust cargo' + bsd.vm.provider "virtualbox" do |vb| + vb.memory = "2048" + end + end + config.vm.synced_folder "..", "/vagrant" +end diff --git a/ci/run-travis.sh b/ci/run-travis.sh index b7d0206479a06..ede2e4855fd7d 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -20,6 +20,23 @@ install() { sudo apt-get install $@ } +# NOTE: this is not actually run on travis right now, this was added to in +# theory run FreeBSD vagrant images on Travis, but it ended up not working, so +# this may not be working when you read this. +install_vagrant() { + echo 'deb http://download.virtualbox.org/virtualbox/debian trusty contrib' | \ + sudo tee -a /etc/apt/sources.list + vbox=virtualbox-5.0_5.0.4-102546~Ubuntu~trusty_amd64.deb + curl https://www.virtualbox.org/download/oracle_vbox.asc | sudo apt-key add - + install virtualbox-5.0 linux-headers-3.16.0-31-generic nfs-kernel-server + + # After we've got virtualbox, install vagrant itself. Note that the version in + # the default ubuntu repos is too old to run the images we have, so install + # the one from the vagrant website's download link + curl -LO https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4_x86_64.deb + sudo dpkg -i vagrant_1.7.4_x86_64.deb +} + if [ "$TARGET" = "arm-linux-androideabi" ]; then # Pull a pre-built docker image for testing android, then run tests entirely # within that image. @@ -51,6 +68,12 @@ elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then install emdebian-archive-keyring install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes export CC=mips-linux-gnu-gcc +elif [ "$TARGET" = "x86_64-unknown-freebsd" ]; then + install_vagrant + cd ci + vagrant up freebsd + exec vagrant ssh freebsd -c \ + 'cd /vagrant && CARGO_TARGET_DIR=/tmp sh ci/run.sh x86_64-unknown-freebsd' else # Download the rustlib folder from the relevant portion of main distribution's # tarballs. diff --git a/libc-test/build.rs b/libc-test/build.rs index 0f607c24bd034..530d10b50cce6 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -12,6 +12,8 @@ fn main() { let android = target.contains("android"); let darwin = target.contains("apple-darwin"); let musl = target.contains("musl"); + let freebsd = target.contains("freebsd"); + let bsdlike = freebsd || darwin; let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw @@ -39,14 +41,6 @@ fn main() { .header("time.h") .header("wchar.h"); - if darwin { - cfg.header("mach-o/dyld.h"); - cfg.header("mach/mach_time.h"); - } else if linux || android { - cfg.header("netpacket/packet.h"); - cfg.header("net/ethernet.h"); - } - if windows { cfg.header("winsock2.h"); // must be before windows.h @@ -84,31 +78,38 @@ fn main() { cfg.header("utime.h"); cfg.header("pwd.h"); cfg.header("grp.h"); + } - if android { - cfg.header("arpa/inet.h"); - } else { - cfg.header("glob.h"); - cfg.header("ifaddrs.h"); - - if !musl { - cfg.header("execinfo.h"); - cfg.header("sys/sysctl.h"); - } - } - - if darwin { - cfg.header("malloc/malloc.h"); - cfg.header("crt_externs.h"); - } else { - cfg.header("malloc.h"); + if android { + cfg.header("arpa/inet.h"); + } else if !windows { + cfg.header("glob.h"); + cfg.header("ifaddrs.h"); + + if !musl { + cfg.header("execinfo.h"); + cfg.header("sys/sysctl.h"); } + } + if darwin { + cfg.header("mach-o/dyld.h"); + cfg.header("mach/mach_time.h"); + cfg.header("malloc/malloc.h"); + cfg.header("crt_externs.h"); } - if target.contains("linux") { + + if linux || android { + cfg.header("netpacket/packet.h"); + cfg.header("net/ethernet.h"); + cfg.header("malloc.h"); cfg.header("sys/prctl.h"); } + if freebsd { + cfg.header("pthread_np.h"); + } + cfg.type_name(move |ty, is_struct| { match ty { // Just pass all these through, no need for a "struct" prefix @@ -120,7 +121,7 @@ fn main() { "ssize_t" if windows => "SSIZE_T".to_string(), // OSX calls this something else - "sighandler_t" if darwin => "sig_t".to_string(), + "sighandler_t" if bsdlike => "sig_t".to_string(), t if t.ends_with("_t") => t.to_string(), @@ -216,7 +217,7 @@ fn main() { "strerror_r" if linux => true, // actually xpg-something-or-other // typed 2nd arg on linux and android - "gettimeofday" if linux || android => true, + "gettimeofday" if linux || android || freebsd => true, "dlerror" if android => true, // const-ness is added diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 588f33ee528e6..56f5ad432ee8e 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -158,6 +158,12 @@ s! { pub sa_mask: sigset_t, pub sa_flags: ::c_int, } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } } pub const EXIT_FAILURE: c_int = 1; @@ -638,7 +644,6 @@ pub const _SC_TRACE_SYS_MAX: c_int = 129; pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130; pub const _SC_PASS_MAX: c_int = 131; - pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7; pub const _PTHREAD_COND_SIG_init: ::c_long = 0x3CB0B1BB; @@ -656,6 +661,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __opaque: [0; __PTHREAD_RWLOCK_SIZE__], }; +pub const SIGSTKSZ: ::size_t = 131072; + extern { pub fn _NSGetExecutablePath(buf: *mut ::c_char, bufsize: *mut ::uint32_t) -> ::c_int; @@ -686,6 +693,8 @@ extern { pub fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut ::c_void; pub fn pthread_get_stacksize_np(thread: pthread_t) -> ::size_t; pub fn __error() -> *mut ::c_int; + pub fn backtrace(buf: *mut *mut ::c_void, + sz: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd.rs index 808f6eac95638..cfaba455a80f9 100644 --- a/src/unix/bsd/freebsdlike/freebsd.rs +++ b/src/unix/bsd/freebsdlike/freebsd.rs @@ -2,5 +2,5 @@ pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const KERN_PROC_PATHNAME: ::c_int = 12; extern { - pub fn __error() -> *const ::c_int; + pub fn __error() -> *mut ::c_int; } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4ca588f941f00..7fafaf91d148f 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -64,13 +64,14 @@ s! { } pub struct siginfo_t { - pub _signo: ::c_int, - pub _errno: ::c_int, - pub _code: ::c_int, - pub _pid: ::pid_t, - pub _uid: ::uid_t, - pub _status: ::c_int, - pub si_addr: *mut ::c_void + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub si_pid: ::pid_t, + pub si_uid: ::uid_t, + pub si_status: ::c_int, + pub si_addr: *mut ::c_void, + _pad: [c_int; 12], } pub struct sigaction { @@ -78,6 +79,12 @@ s! { pub sa_flags: ::c_int, pub sa_mask: sigset_t, } + + pub struct stack_t { + pub ss_sp: *mut ::c_char, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } } pub const EXIT_FAILURE: ::c_int = 1; @@ -491,6 +498,8 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const SIGSTKSZ: ::size_t = 34816; + extern { pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) -> c_int; @@ -511,6 +520,8 @@ extern { -> c_int; pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn backtrace(buf: *mut *mut ::c_void, + sz: ::size_t) -> ::size_t; } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 94c90e85a7ae8..56ae724674916 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -39,12 +39,9 @@ s! { pub pw_dir: *mut ::c_char, pub pw_shell: *mut ::c_char, pub pw_expire: ::time_t, - } - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_size: ::size_t, - pub ss_flags: ::c_int, + #[cfg(not(target_os = "macos"))] + pub pw_fields: ::c_int, } } @@ -53,7 +50,6 @@ pub const FIOCLEX: c_ulong = 0x20006601; pub const SA_ONSTACK: ::c_int = 0x0001; pub const SA_SIGINFO: ::c_int = 0x0040; -pub const SIGSTKSZ: ::size_t = 131072; pub const SIGBUS: ::c_int = 10; pub const SIG_SETMASK: ::c_int = 3; diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index ef40db4458f83..5c5d426dc29d6 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -17,6 +17,12 @@ pub type pthread_key_t = ::c_int; pub sa_flags: libc::c_int, } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))] pub mod os { pub mod common { @@ -736,6 +742,7 @@ pub type pthread_key_t = ::c_int; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); pub const PTHREAD_MUTEX_RECURSIVE: libc::c_int = 2; +pub const SIGSTKSZ: ::size_t = 131072; extern { pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) -> c_int; @@ -760,4 +767,6 @@ extern { pub fn pthread_stackseg_np(thread: pthread_t, sinfo: *mut stack_t) -> ::c_uint; pub fn __errno() -> *const ::c_int; + pub fn backtrace(buf: *mut *mut ::c_void, + sz: ::size_t) -> ::size_t; } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 4e80d2cf7f958..16c9a152858f5 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -493,9 +493,6 @@ extern { buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; - #[cfg(not(target_env = "musl"))] - pub fn backtrace(buf: *mut *mut ::c_void, - sz: ::c_int) -> ::c_int; pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index ba6c767a4b54b..23467aca2a860 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -318,6 +318,9 @@ extern { pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; + #[cfg(not(target_env = "musl"))] + pub fn backtrace(buf: *mut *mut ::c_void, + sz: ::c_int) -> ::c_int; } cfg_if! { From 1e1ff67a9bf19c9ef2e1db418a905470f3cfc361 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 15:00:36 -0700 Subject: [PATCH 155/194] Fix backtrace for android --- src/unix/notbsd/linux/mod.rs | 2 ++ src/unix/notbsd/mod.rs | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index eaf7cb257ddb9..59b591a027e05 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -259,6 +259,8 @@ cfg_if! { newlen: size_t) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; + pub fn backtrace(buf: *mut *mut ::c_void, + sz: ::c_int) -> ::c_int; } } } diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 23467aca2a860..ba6c767a4b54b 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -318,9 +318,6 @@ extern { pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; - #[cfg(not(target_env = "musl"))] - pub fn backtrace(buf: *mut *mut ::c_void, - sz: ::c_int) -> ::c_int; } cfg_if! { From c4a8d60974df815e9424a9be9459e7d1074a2f50 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 15:00:49 -0700 Subject: [PATCH 156/194] Consolidate mode_t upwards on linux --- src/unix/notbsd/linux/mips.rs | 1 - src/unix/notbsd/linux/mod.rs | 1 + src/unix/notbsd/linux/notmips/b32/mod.rs | 2 +- src/unix/notbsd/linux/notmips/b64/aarch64.rs | 2 +- src/unix/notbsd/linux/notmips/b64/mod.rs | 1 - src/unix/notbsd/linux/notmips/b64/x86_64.rs | 2 +- 6 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 349e3330910df..53cd2db13255a 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -14,7 +14,6 @@ pub type ino_t = u32; pub type ssize_t = i32; pub type blkcnt_t = i32; pub type blksize_t = i32; -pub type mode_t = u32; pub type nlink_t = u32; s! { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 59b591a027e05..d45cb4eb85ad4 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -4,6 +4,7 @@ pub type useconds_t = u32; pub type dev_t = u64; pub type socklen_t = u32; pub type pthread_t = c_ulong; +pub type mode_t = u32; s! { pub struct glob_t { diff --git a/src/unix/notbsd/linux/notmips/b32/mod.rs b/src/unix/notbsd/linux/notmips/b32/mod.rs index 862969060dece..b437d76d95ef0 100644 --- a/src/unix/notbsd/linux/notmips/b32/mod.rs +++ b/src/unix/notbsd/linux/notmips/b32/mod.rs @@ -13,8 +13,8 @@ pub type ino_t = u32; pub type off_t = i32; pub type ssize_t = i32; pub type blkcnt_t = i32; + pub type blksize_t = i32; -pub type mode_t = u32; pub type nlink_t = u32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; diff --git a/src/unix/notbsd/linux/notmips/b64/aarch64.rs b/src/unix/notbsd/linux/notmips/b64/aarch64.rs index 7452e7dc89e34..31e8b25f52841 100644 --- a/src/unix/notbsd/linux/notmips/b64/aarch64.rs +++ b/src/unix/notbsd/linux/notmips/b64/aarch64.rs @@ -1,9 +1,9 @@ //! AArch64-specific definitions for 64-bit linux-like values pub type c_char = u8; +pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = i32; -pub type wchar_t = u32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; diff --git a/src/unix/notbsd/linux/notmips/b64/mod.rs b/src/unix/notbsd/linux/notmips/b64/mod.rs index 8f55e09d601d7..1916dc43aac95 100644 --- a/src/unix/notbsd/linux/notmips/b64/mod.rs +++ b/src/unix/notbsd/linux/notmips/b64/mod.rs @@ -11,7 +11,6 @@ pub type intptr_t = i64; pub type uintptr_t = u64; pub type ino_t = u64; pub type off_t = i64; -pub type mode_t = u32; pub type ssize_t = i64; pub type blkcnt_t = i64; diff --git a/src/unix/notbsd/linux/notmips/b64/x86_64.rs b/src/unix/notbsd/linux/notmips/b64/x86_64.rs index 0068fe0654fbb..2d3320a20bc68 100644 --- a/src/unix/notbsd/linux/notmips/b64/x86_64.rs +++ b/src/unix/notbsd/linux/notmips/b64/x86_64.rs @@ -1,9 +1,9 @@ //! x86_64-specific definitions for 64-bit linux-like values pub type c_char = i8; +pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; -pub type wchar_t = i32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; From 83c81680dc6f623f54b4c74542902cbeb13efe45 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 15:01:06 -0700 Subject: [PATCH 157/194] Consolidate freebsd arch's upwards --- src/unix/bsd/freebsdlike/mod.rs | 29 +++++++++++++++++++++++++++++ src/unix/bsd/freebsdlike/x86.rs | 28 ---------------------------- src/unix/bsd/freebsdlike/x86_64.rs | 28 ---------------------------- 3 files changed, 29 insertions(+), 56 deletions(-) diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 7fafaf91d148f..11bf83022439d 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1,3 +1,32 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type clock_t = i32; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i64; +pub type dev_t = u32; +pub type ino_t = u32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type mode_t = u16; +pub type nlink_t = u16; +pub type blksize_t = u32; +pub type blkcnt_t = i64; +pub type fflags_t = u32; +pub type pthread_attr_t = *mut ::c_void; + pub type pthread_t = uintptr_t; pub type rlim_t = i64; pub type sighandler_t = size_t; diff --git a/src/unix/bsd/freebsdlike/x86.rs b/src/unix/bsd/freebsdlike/x86.rs index 5a80c0d42b038..3be08eee33cc8 100644 --- a/src/unix/bsd/freebsdlike/x86.rs +++ b/src/unix/bsd/freebsdlike/x86.rs @@ -1,40 +1,12 @@ -pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; pub type c_long = i32; pub type c_ulong = u32; -pub type c_float = f32; -pub type c_double = f64; pub type size_t = u32; pub type ptrdiff_t = i32; -pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; -pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intptr_t = i32; pub type uintptr_t = u32; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type off_t = i64; -pub type dev_t = u32; -pub type ino_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; -pub type mode_t = u16; pub type ssize_t = i32; -pub type nlink_t = u16; -pub type blksize_t = u32; -pub type blkcnt_t = i64; -pub type fflags_t = u32; -pub type pthread_attr_t = *mut c_void; s! { pub struct stat { diff --git a/src/unix/bsd/freebsdlike/x86_64.rs b/src/unix/bsd/freebsdlike/x86_64.rs index bacea737a13a9..c45374423b56a 100644 --- a/src/unix/bsd/freebsdlike/x86_64.rs +++ b/src/unix/bsd/freebsdlike/x86_64.rs @@ -1,40 +1,12 @@ -pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; pub type c_long = i64; pub type c_ulong = u64; -pub type c_float = f32; -pub type c_double = f64; pub type size_t = u64; pub type ptrdiff_t = i64; -pub type clock_t = i32; pub type time_t = i64; pub type suseconds_t = i64; -pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intptr_t = i64; pub type uintptr_t = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type off_t = i64; -pub type dev_t = u32; -pub type ino_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; -pub type mode_t = u16; pub type ssize_t = i64; -pub type nlink_t = u16; -pub type blksize_t = u32; -pub type blkcnt_t = i64; -pub type fflags_t = u32; -pub type pthread_attr_t = *mut ::c_void; s! { pub struct stat { From 78f5acadfa7410cc59a723328067631e7246409f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 15:01:16 -0700 Subject: [PATCH 158/194] Note triples in README --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 46b30bfd7f776..2b57d7ee7e6e5 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,17 @@ various systems, including libc. [![Build status](https://ci.appveyor.com/api/projects/status/v0414slj8y8nga0p?svg=true)](https://ci.appveyor.com/project/alexcrichton/libc) [Documentation](http://alexcrichton.com/libc) + +## Platform Support + +Tested: + * `{i686,x86_64}-pc-windows-{msvc,gnu}` + * `{i686,x86_64,mips,aarch64}-unknown-linux-gnu` + * `x86_64-unknown-linux-musl` + * `arm-unknown-linux-gnueabihf` + * `arm-linux-androideabi` + * `{i686,x86_64}-apple-darwin` + +Untested: + * `{i686,x86_64}-unknown-freebsd` + * `x86_64-unknown-{bitrig,dragonfly,openbsd,netbsd}` From 2eb32ef4552dba475779fc215cd6af93aa1aa007 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 15:09:10 -0700 Subject: [PATCH 159/194] Format openbsd --- src/unix/bsd/openbsdlike/bitrig.rs | 16 + src/unix/bsd/openbsdlike/mod.rs | 1258 +++++++++++---------------- src/unix/bsd/openbsdlike/openbsd.rs | 18 + 3 files changed, 564 insertions(+), 728 deletions(-) create mode 100644 src/unix/bsd/openbsdlike/bitrig.rs create mode 100644 src/unix/bsd/openbsdlike/openbsd.rs diff --git a/src/unix/bsd/openbsdlike/bitrig.rs b/src/unix/bsd/openbsdlike/bitrig.rs new file mode 100644 index 0000000000000..9039ff446cd36 --- /dev/null +++ b/src/unix/bsd/openbsdlike/bitrig.rs @@ -0,0 +1,16 @@ +s! { + pub struct glob_t { + pub gl_pathc: c_int, + pub gl_matchc: c_int, + pub gl_offs: c_int, + pub gl_flags: c_int, + pub gl_pathv: *mut *mut c_char, + __unused1: *mut c_void, + __unused2: *mut c_void, + __unused3: *mut c_void, + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + } +} diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 5c5d426dc29d6..1234c19b15bda 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -1,748 +1,540 @@ - pub type sigset_t = libc::c_uint; +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_float = f32; +pub type c_double = f64; +pub type size_t = u64; +pub type ptrdiff_t = i64; +pub type clock_t = i64; +pub type time_t = i64; +pub type suseconds_t = i64; +pub type wchar_t = i32; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intptr_t = i64; +pub type uintptr_t = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i64; +pub type dev_t = i32; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type mode_t = u32; +pub type ssize_t = c_long; + +pub type sighandler_t = size_t; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type in_port_t = u16; +pub type in_addr_t = u32; + +pub type nlink_t = uint32_t; +pub type blksize_t = uint32_t; +pub type ino_t = uint64_t; +pub type blkcnt_t = i64; +pub type fflags_t = u32; +pub type pthread_attr_t = *mut c_void; +pub type sigset_t = ::c_uint; pub type pthread_key_t = ::c_int; - struct stack_t { - ss_sp: *mut libc::c_void, - ss_size: libc::size_t, - ss_flags: libc::c_int, - } +pub type pthread_mutex_t = *mut ::c_void; +pub type pthread_mutexattr_t = *mut ::c_void; +pub type pthread_cond_t = *mut ::c_void; +pub type pthread_rwlock_t = *mut ::c_void; +pub type pthread_t = uintptr_t; +pub type rlim_t = u64; + + +pub enum timezone {} + +s! { + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + pub struct siginfo_t { - pub si_signo: libc::c_int, - pub si_code: libc::c_int, - pub si_errno: libc::c_int, - pub si_addr: *mut libc::c_void + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub si_addr: *mut ::c_void } + pub struct sigaction { pub sa_sigaction: sighandler_t, pub sa_mask: sigset_t, - pub sa_flags: libc::c_int, + pub sa_flags: ::c_int, } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_size: ::size_t, pub ss_flags: ::c_int, } - #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))] - pub mod os { - pub mod common { - pub mod posix01 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, size_t, - time_t, suseconds_t, c_long}; - use types::os::arch::c99::{uintptr_t}; - - pub type pthread_t = uintptr_t; - pub type rlim_t = u64; - - #[cfg(target_os = "bitrig")] - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: c_int, - pub gl_matchc: c_int, - pub gl_offs: c_int, - pub gl_flags: c_int, - pub gl_pathv: *mut *mut c_char, - __unused1: *mut c_void, - __unused2: *mut c_void, - __unused3: *mut c_void, - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - } - - #[cfg(any(target_os = "netbsd", target_os="openbsd"))] - #[repr(C)] - #[derive(Copy, Clone)] pub struct glob_t { - pub gl_pathc: c_int, - __unused1: c_int, - pub gl_offs: c_int, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, - - __unused3: *mut c_void, - - __unused4: *mut c_void, - __unused5: *mut c_void, - __unused6: *mut c_void, - __unused7: *mut c_void, - __unused8: *mut c_void, - __unused9: *mut c_void, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } - - #[repr(C)] - #[derive(Copy, Clone)] pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, - } - - pub enum timezone {} - - pub type sighandler_t = size_t; - - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - } - - pub mod bsd43 { - use types::os::common::posix01::timeval; - use types::os::arch::c95::c_long; - #[repr(C)] - #[derive(Copy, Clone)] - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long - } - } - - pub mod bsd44 { - use types::common::c95::{c_void}; - use types::os::arch::c95::{c_char, c_int, c_uint}; - - pub type socklen_t = u32; - pub type sa_family_t = u8; - pub type in_port_t = u16; - pub type in_addr_t = u32; - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [u8; 14], - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_pad2: i64, - __ss_pad3: [u8; 240], - } - impl Clone for sockaddr_storage { - fn clone(&self) -> sockaddr_storage { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, - pub sin_zero: [u8; 8], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in_addr { - pub s_addr: in_addr_t, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: in6_addr, - pub sin6_scope_id: u32, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct in6_addr { - pub s6_addr: [u16; 8], - __align: [u32; 0], - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_addr: *mut sockaddr, - pub ai_canonname: *mut c_char, - pub ai_next: *mut addrinfo, - } - #[repr(C)] - #[derive(Copy)] pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] - } - impl Clone for sockaddr_un { - fn clone(&self) -> sockaddr_un { *self } - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - } - } - - #[cfg(target_arch = "x86_64")] - pub mod arch { - pub mod c95 { - pub type c_char = i8; - pub type c_schar = i8; - pub type c_uchar = u8; - pub type c_short = i16; - pub type c_ushort = u16; - pub type c_int = i32; - pub type c_uint = u32; - pub type c_long = i64; - pub type c_ulong = u64; - pub type c_float = f32; - pub type c_double = f64; - pub type size_t = u64; - pub type ptrdiff_t = i64; - pub type clock_t = i64; - pub type time_t = i64; - pub type suseconds_t = i64; - pub type wchar_t = i32; - } - pub mod c99 { - pub type c_longlong = i64; - pub type c_ulonglong = u64; - pub type intptr_t = i64; - pub type uintptr_t = u64; - pub type intmax_t = i64; - pub type uintmax_t = u64; - } - pub mod posix88 { - use types::os::arch::c95::{c_long}; - pub type off_t = i64; - pub type dev_t = i32; - pub type pid_t = i32; - pub type uid_t = u32; - pub type gid_t = u32; - pub type useconds_t = u32; - pub type mode_t = u32; - pub type ssize_t = c_long; - } - pub mod posix01 { - use types::common::c95::{c_void}; - use types::common::c99::{uint32_t, uint64_t}; - use types::os::arch::c95::{c_long, time_t}; - use types::os::arch::posix88::{dev_t, gid_t}; - use types::os::arch::posix88::{mode_t, off_t}; - use types::os::arch::posix88::{uid_t}; - - pub type nlink_t = uint32_t; - pub type blksize_t = uint32_t; - pub type ino_t = uint64_t; - pub type blkcnt_t = i64; - pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t - - #[repr(C)] - #[derive(Copy, Clone)] pub struct stat { - pub st_mode: mode_t, - pub st_dev: dev_t, - pub st_ino: ino_t, - pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, - pub st_rdev: dev_t, - pub st_atime: time_t, - pub st_atime_nsec: c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, - pub st_blksize: blksize_t, - pub st_flags: fflags_t, - pub st_gen: uint32_t, - pub st_birthtime: time_t, - pub st_birthtime_nsec: c_long, - } - #[repr(C)] - #[derive(Copy, Clone)] pub struct utimbuf { - pub actime: time_t, - pub modtime: time_t, - } - - pub type pthread_attr_t = *mut c_void; - } - pub mod posix08 { - } - pub mod bsd44 { - } - pub mod extra { - } - } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: i64, + __ss_pad3: [u8; 240], + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, } - #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))] - pub mod os { - pub mod c95 { - use types::os::arch::c95::{c_int, c_uint}; - - pub const EXIT_FAILURE : c_int = 1; - pub const EXIT_SUCCESS : c_int = 0; - pub const RAND_MAX : c_int = 2147483647; - pub const EOF : c_int = -1; - pub const SEEK_SET : c_int = 0; - pub const SEEK_CUR : c_int = 1; - pub const SEEK_END : c_int = 2; - pub const _IOFBF : c_int = 0; - pub const _IONBF : c_int = 2; - pub const _IOLBF : c_int = 1; - pub const BUFSIZ : c_uint = 1024; - pub const FOPEN_MAX : c_uint = 20; - pub const FILENAME_MAX : c_uint = 1024; - pub const L_tmpnam : c_uint = 1024; - pub const TMP_MAX : c_uint = 308915776; - } - pub mod c99 { - } - pub mod posix88 { - use types::common::c95::c_void; - use types::os::arch::c95::c_int; - use types::os::arch::posix88::mode_t; - - pub const O_RDONLY : c_int = 0; - pub const O_WRONLY : c_int = 1; - pub const O_RDWR : c_int = 2; - pub const O_APPEND : c_int = 8; - pub const O_CREAT : c_int = 512; - pub const O_EXCL : c_int = 2048; - pub const O_NOCTTY : c_int = 32768; - pub const O_TRUNC : c_int = 1024; - pub const S_IFIFO : mode_t = 4096; - pub const S_IFCHR : mode_t = 8192; - pub const S_IFBLK : mode_t = 24576; - pub const S_IFDIR : mode_t = 16384; - pub const S_IFREG : mode_t = 32768; - pub const S_IFLNK : mode_t = 40960; - pub const S_IFSOCK : mode_t = 49152; - pub const S_IFMT : mode_t = 61440; - pub const S_IEXEC : mode_t = 64; - pub const S_IWRITE : mode_t = 128; - pub const S_IREAD : mode_t = 256; - pub const S_IRWXU : mode_t = 448; - pub const S_IXUSR : mode_t = 64; - pub const S_IWUSR : mode_t = 128; - pub const S_IRUSR : mode_t = 256; - pub const S_IRWXG : mode_t = 56; - pub const S_IXGRP : mode_t = 8; - pub const S_IWGRP : mode_t = 16; - pub const S_IRGRP : mode_t = 32; - pub const S_IRWXO : mode_t = 7; - pub const S_IXOTH : mode_t = 1; - pub const S_IWOTH : mode_t = 2; - pub const S_IROTH : mode_t = 4; - pub const F_OK : c_int = 0; - pub const R_OK : c_int = 4; - pub const W_OK : c_int = 2; - pub const X_OK : c_int = 1; - pub const STDIN_FILENO : c_int = 0; - pub const STDOUT_FILENO : c_int = 1; - pub const STDERR_FILENO : c_int = 2; - pub const F_LOCK : c_int = 1; - pub const F_TEST : c_int = 3; - pub const F_TLOCK : c_int = 2; - pub const F_ULOCK : c_int = 0; - pub const SIGHUP : c_int = 1; - pub const SIGINT : c_int = 2; - pub const SIGQUIT : c_int = 3; - pub const SIGILL : c_int = 4; - pub const SIGABRT : c_int = 6; - pub const SIGFPE : c_int = 8; - pub const SIGKILL : c_int = 9; - pub const SIGSEGV : c_int = 11; - pub const SIGPIPE : c_int = 13; - pub const SIGALRM : c_int = 14; - pub const SIGTERM : c_int = 15; - - pub const PROT_NONE : c_int = 0; - pub const PROT_READ : c_int = 1; - pub const PROT_WRITE : c_int = 2; - pub const PROT_EXEC : c_int = 4; - - pub const MAP_FILE : c_int = 0x0000; - pub const MAP_SHARED : c_int = 0x0001; - pub const MAP_PRIVATE : c_int = 0x0002; - pub const MAP_FIXED : c_int = 0x0010; - pub const MAP_ANON : c_int = 0x1000; - - pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; - - pub const MCL_CURRENT : c_int = 0x0001; - pub const MCL_FUTURE : c_int = 0x0002; - - pub const MS_ASYNC : c_int = 0x0001; - pub const MS_SYNC : c_int = 0x0002; - pub const MS_INVALIDATE : c_int = 0x0004; - - pub const EPERM : c_int = 1; - pub const ENOENT : c_int = 2; - pub const ESRCH : c_int = 3; - pub const EINTR : c_int = 4; - pub const EIO : c_int = 5; - pub const ENXIO : c_int = 6; - pub const E2BIG : c_int = 7; - pub const ENOEXEC : c_int = 8; - pub const EBADF : c_int = 9; - pub const ECHILD : c_int = 10; - pub const EDEADLK : c_int = 11; - pub const ENOMEM : c_int = 12; - pub const EACCES : c_int = 13; - pub const EFAULT : c_int = 14; - pub const ENOTBLK : c_int = 15; - pub const EBUSY : c_int = 16; - pub const EEXIST : c_int = 17; - pub const EXDEV : c_int = 18; - pub const ENODEV : c_int = 19; - pub const ENOTDIR : c_int = 20; - pub const EISDIR : c_int = 21; - pub const EINVAL : c_int = 22; - pub const ENFILE : c_int = 23; - pub const EMFILE : c_int = 24; - pub const ENOTTY : c_int = 25; - pub const ETXTBSY : c_int = 26; - pub const EFBIG : c_int = 27; - pub const ENOSPC : c_int = 28; - pub const ESPIPE : c_int = 29; - pub const EROFS : c_int = 30; - pub const EMLINK : c_int = 31; - pub const EPIPE : c_int = 32; - pub const EDOM : c_int = 33; - pub const ERANGE : c_int = 34; - pub const EAGAIN : c_int = 35; - pub const EWOULDBLOCK : c_int = 35; - pub const EINPROGRESS : c_int = 36; - pub const EALREADY : c_int = 37; - pub const ENOTSOCK : c_int = 38; - pub const EDESTADDRREQ : c_int = 39; - pub const EMSGSIZE : c_int = 40; - pub const EPROTOTYPE : c_int = 41; - pub const ENOPROTOOPT : c_int = 42; - pub const EPROTONOSUPPORT : c_int = 43; - pub const ESOCKTNOSUPPORT : c_int = 44; - pub const EOPNOTSUPP : c_int = 45; - pub const EPFNOSUPPORT : c_int = 46; - pub const EAFNOSUPPORT : c_int = 47; - pub const EADDRINUSE : c_int = 48; - pub const EADDRNOTAVAIL : c_int = 49; - pub const ENETDOWN : c_int = 50; - pub const ENETUNREACH : c_int = 51; - pub const ENETRESET : c_int = 52; - pub const ECONNABORTED : c_int = 53; - pub const ECONNRESET : c_int = 54; - pub const ENOBUFS : c_int = 55; - pub const EISCONN : c_int = 56; - pub const ENOTCONN : c_int = 57; - pub const ESHUTDOWN : c_int = 58; - pub const ETOOMANYREFS : c_int = 59; - pub const ETIMEDOUT : c_int = 60; - pub const ECONNREFUSED : c_int = 61; - pub const ELOOP : c_int = 62; - pub const ENAMETOOLONG : c_int = 63; - pub const EHOSTDOWN : c_int = 64; - pub const EHOSTUNREACH : c_int = 65; - pub const ENOTEMPTY : c_int = 66; - pub const EPROCLIM : c_int = 67; - pub const EUSERS : c_int = 68; - pub const EDQUOT : c_int = 69; - pub const ESTALE : c_int = 70; - pub const EREMOTE : c_int = 71; - pub const EBADRPC : c_int = 72; - pub const ERPCMISMATCH : c_int = 73; - pub const EPROGUNAVAIL : c_int = 74; - pub const EPROGMISMATCH : c_int = 75; - pub const EPROCUNAVAIL : c_int = 76; - pub const ENOLCK : c_int = 77; - pub const ENOSYS : c_int = 78; - pub const EFTYPE : c_int = 79; - pub const EAUTH : c_int = 80; - pub const ENEEDAUTH : c_int = 81; - pub const EIPSEC : c_int = 82; - pub const ENOATTR : c_int = 83; - pub const EILSEQ : c_int = 84; - pub const ENOMEDIUM : c_int = 85; - pub const EMEDIUMTYPE : c_int = 86; - pub const EOVERFLOW : c_int = 87; - pub const ECANCELED : c_int = 88; - pub const EIDRM : c_int = 89; - pub const ENOMSG : c_int = 90; - pub const ENOTSUP : c_int = 91; - pub const ELAST : c_int = 91; // must be equal to largest errno - } - pub mod posix01 { - use types::os::arch::c95::{c_int, size_t}; - use types::os::common::posix01::rlim_t; - - pub const F_DUPFD : c_int = 0; - pub const F_GETFD : c_int = 1; - pub const F_SETFD : c_int = 2; - pub const F_GETFL : c_int = 3; - pub const F_SETFL : c_int = 4; - pub const F_GETOWN : c_int = 5; - pub const F_SETOWN : c_int = 6; - pub const F_GETLK : c_int = 7; - pub const F_SETLK : c_int = 8; - pub const F_SETLKW : c_int = 9; - pub const F_DUPFD_CLOEXEC : c_int = 10; - - pub const SIGTRAP : c_int = 5; - - pub const GLOB_APPEND : c_int = 0x0001; - pub const GLOB_DOOFFS : c_int = 0x0002; - pub const GLOB_ERR : c_int = 0x0004; - pub const GLOB_MARK : c_int = 0x0008; - pub const GLOB_NOCHECK : c_int = 0x0010; - pub const GLOB_NOSORT : c_int = 0x0020; - pub const GLOB_NOESCAPE : c_int = 0x1000; - - pub const GLOB_NOSPACE : c_int = -1; - pub const GLOB_ABORTED : c_int = -2; - pub const GLOB_NOMATCH : c_int = -3; - pub const GLOB_NOSYS : c_int = -4; - - pub const POSIX_MADV_NORMAL : c_int = 0; - pub const POSIX_MADV_RANDOM : c_int = 1; - pub const POSIX_MADV_SEQUENTIAL : c_int = 2; - pub const POSIX_MADV_WILLNEED : c_int = 3; - pub const POSIX_MADV_DONTNEED : c_int = 4; - - pub const _SC_IOV_MAX : c_int = 51; - pub const _SC_GETGR_R_SIZE_MAX : c_int = 100; - pub const _SC_GETPW_R_SIZE_MAX : c_int = 101; - pub const _SC_LOGIN_NAME_MAX : c_int = 102; - pub const _SC_MQ_PRIO_MAX : c_int = 59; - pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; - pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; - pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80; - pub const _SC_THREAD_KEYS_MAX : c_int = 81; - pub const _SC_THREAD_PRIO_INHERIT : c_int = 82; - pub const _SC_THREAD_PRIO_PROTECT : c_int = 83; - pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84; - pub const _SC_THREAD_PROCESS_SHARED : c_int = 85; - pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103; - pub const _SC_THREAD_STACK_MIN : c_int = 89; - pub const _SC_THREAD_THREADS_MAX : c_int = 90; - pub const _SC_THREADS : c_int = 91; - pub const _SC_TTY_NAME_MAX : c_int = 107; - pub const _SC_ATEXIT_MAX : c_int = 46; - pub const _SC_XOPEN_CRYPT : c_int = 117; - pub const _SC_XOPEN_ENH_I18N : c_int = 118; - pub const _SC_XOPEN_LEGACY : c_int = 119; - pub const _SC_XOPEN_REALTIME : c_int = 120; - pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121; - pub const _SC_XOPEN_SHM : c_int = 30; - pub const _SC_XOPEN_UNIX : c_int = 123; - pub const _SC_XOPEN_VERSION : c_int = 125; - - pub const PTHREAD_CREATE_JOINABLE : c_int = 0; - pub const PTHREAD_CREATE_DETACHED : c_int = 1; - pub const PTHREAD_STACK_MIN : size_t = 2048; - - pub const CLOCK_REALTIME : c_int = 0; - pub const CLOCK_MONOTONIC : c_int = 3; - - pub const RLIMIT_CPU: c_int = 0; - pub const RLIMIT_FSIZE: c_int = 1; - pub const RLIMIT_DATA: c_int = 2; - pub const RLIMIT_STACK: c_int = 3; - pub const RLIMIT_CORE: c_int = 4; - pub const RLIMIT_RSS: c_int = 5; - pub const RLIMIT_MEMLOCK: c_int = 6; - pub const RLIMIT_NPROC: c_int = 7; - pub const RLIMIT_NOFILE: c_int = 8; - pub const RLIM_NLIMITS: c_int = 9; - - pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; - pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; - pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; - - pub const RUSAGE_SELF: c_int = 0; - pub const RUSAGE_CHILDREN: c_int = -1; - pub const RUSAGE_THREAD: c_int = 1; - } - pub mod posix08 { - } - pub mod bsd44 { - use types::os::arch::c95::c_int; - - pub const MADV_NORMAL : c_int = 0; - pub const MADV_RANDOM : c_int = 1; - pub const MADV_SEQUENTIAL : c_int = 2; - pub const MADV_WILLNEED : c_int = 3; - pub const MADV_DONTNEED : c_int = 4; - pub const MADV_FREE : c_int = 6; - - pub const AF_UNIX: c_int = 1; - pub const AF_INET: c_int = 2; - pub const AF_INET6: c_int = 24; - pub const SOCK_STREAM: c_int = 1; - pub const SOCK_DGRAM: c_int = 2; - pub const SOCK_RAW: c_int = 3; - pub const IPPROTO_TCP: c_int = 6; - pub const IPPROTO_IP: c_int = 0; - pub const IPPROTO_IPV6: c_int = 41; - pub const IP_MULTICAST_TTL: c_int = 10; - pub const IP_MULTICAST_LOOP: c_int = 11; - pub const IP_TTL: c_int = 4; - pub const IP_HDRINCL: c_int = 2; - pub const IP_ADD_MEMBERSHIP: c_int = 12; - pub const IP_DROP_MEMBERSHIP: c_int = 13; - pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist - pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist - - pub const TCP_NODELAY: c_int = 0x01; - pub const SOL_SOCKET: c_int = 0xffff; - pub const SO_DEBUG: c_int = 0x01; - pub const SO_ACCEPTCONN: c_int = 0x0002; - pub const SO_REUSEADDR: c_int = 0x0004; - pub const SO_KEEPALIVE: c_int = 0x0008; - pub const SO_DONTROUTE: c_int = 0x0010; - pub const SO_BROADCAST: c_int = 0x0020; - pub const SO_USELOOPBACK: c_int = 0x0040; - pub const SO_LINGER: c_int = 0x0080; - pub const SO_OOBINLINE: c_int = 0x0100; - pub const SO_REUSEPORT: c_int = 0x0200; - pub const SO_SNDBUF: c_int = 0x1001; - pub const SO_RCVBUF: c_int = 0x1002; - pub const SO_SNDLOWAT: c_int = 0x1003; - pub const SO_RCVLOWAT: c_int = 0x1004; - pub const SO_SNDTIMEO: c_int = 0x1005; - pub const SO_RCVTIMEO: c_int = 0x1006; - pub const SO_ERROR: c_int = 0x1007; - pub const SO_TYPE: c_int = 0x1008; - - pub const IFF_LOOPBACK: c_int = 0x8; - - pub const SHUT_RD: c_int = 0; - pub const SHUT_WR: c_int = 1; - pub const SHUT_RDWR: c_int = 2; - - pub const LOCK_SH: c_int = 1; - pub const LOCK_EX: c_int = 2; - pub const LOCK_NB: c_int = 4; - pub const LOCK_UN: c_int = 8; - } - pub mod extra { - use types::os::arch::c95::c_int; - - pub const O_DSYNC : c_int = 128; // same as SYNC - pub const O_SYNC : c_int = 128; - pub const O_NONBLOCK : c_int = 4; - pub const CTL_KERN : c_int = 1; - pub const KERN_PROC : c_int = 66; - - pub const MAP_COPY : c_int = 0x0002; - pub const MAP_RENAME : c_int = 0x0000; - pub const MAP_NORESERVE : c_int = 0x0000; - pub const MAP_NOEXTEND : c_int = 0x0000; - pub const MAP_HASSEMAPHORE : c_int = 0x0000; - - pub const IPPROTO_RAW : c_int = 255; - - pub const PATH_MAX: c_int = 1024; - } - pub mod sysconf { - use types::os::arch::c95::c_int; - - pub const _SC_ARG_MAX : c_int = 1; - pub const _SC_CHILD_MAX : c_int = 2; - pub const _SC_CLK_TCK : c_int = 3; - pub const _SC_NGROUPS_MAX : c_int = 4; - pub const _SC_OPEN_MAX : c_int = 5; - pub const _SC_JOB_CONTROL : c_int = 6; - pub const _SC_SAVED_IDS : c_int = 7; - pub const _SC_VERSION : c_int = 8; - pub const _SC_BC_BASE_MAX : c_int = 9; - pub const _SC_BC_DIM_MAX : c_int = 10; - pub const _SC_BC_SCALE_MAX : c_int = 11; - pub const _SC_BC_STRING_MAX : c_int = 12; - pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; - pub const _SC_EXPR_NEST_MAX : c_int = 14; - pub const _SC_LINE_MAX : c_int = 15; - pub const _SC_RE_DUP_MAX : c_int = 16; - pub const _SC_2_VERSION : c_int = 17; - pub const _SC_2_C_BIND : c_int = 18; - pub const _SC_2_C_DEV : c_int = 19; - pub const _SC_2_CHAR_TERM : c_int = 20; - pub const _SC_2_FORT_DEV : c_int = 21; - pub const _SC_2_FORT_RUN : c_int = 22; - pub const _SC_2_LOCALEDEF : c_int = 23; - pub const _SC_2_SW_DEV : c_int = 24; - pub const _SC_2_UPE : c_int = 25; - pub const _SC_STREAM_MAX : c_int = 26; - pub const _SC_TZNAME_MAX : c_int = 27; - pub const _SC_PAGESIZE : c_int = 28; - pub const _SC_FSYNC : c_int = 29; - pub const _SC_SEM_NSEMS_MAX : c_int = 31; - pub const _SC_SEM_VALUE_MAX : c_int = 32; - pub const _SC_AIO_LISTIO_MAX : c_int = 42; - pub const _SC_AIO_MAX : c_int = 43; - pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; - pub const _SC_ASYNCHRONOUS_IO : c_int = 45; - pub const _SC_DELAYTIMER_MAX : c_int = 50; - pub const _SC_MAPPED_FILES : c_int = 53; - pub const _SC_MEMLOCK : c_int = 54; - pub const _SC_MEMLOCK_RANGE : c_int = 55; - pub const _SC_MEMORY_PROTECTION : c_int = 56; - pub const _SC_MESSAGE_PASSING : c_int = 57; - pub const _SC_MQ_OPEN_MAX : c_int = 58; - pub const _SC_PRIORITIZED_IO : c_int = 60; - pub const _SC_PRIORITY_SCHEDULING : c_int = 61; - pub const _SC_REALTIME_SIGNALS : c_int = 64; - pub const _SC_RTSIG_MAX : c_int = 66; - pub const _SC_SEMAPHORES : c_int = 67; - pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68; - pub const _SC_SIGQUEUE_MAX : c_int = 70; - pub const _SC_SYNCHRONIZED_IO : c_int = 75; - pub const _SC_TIMER_MAX : c_int = 93; - pub const _SC_TIMERS : c_int = 94; - } + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut sockaddr, + pub ifa_netmask: *mut sockaddr, + pub ifa_dstaddr: *mut sockaddr, + pub ifa_data: *mut c_void } - pub type pthread_mutex_t = *mut libc::c_void; - pub type pthread_mutexattr_t = *mut libc::c_void; - pub type pthread_cond_t = *mut libc::c_void; - pub type pthread_rwlock_t = *mut libc::c_void; - - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); - pub const PTHREAD_MUTEX_RECURSIVE: libc::c_int = 2; + + pub struct stat { + pub st_mode: mode_t, + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: fflags_t, + pub st_gen: uint32_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + } +} + +pub const EXIT_FAILURE : c_int = 1; +pub const EXIT_SUCCESS : c_int = 0; +pub const RAND_MAX : c_int = 2147483647; +pub const EOF : c_int = -1; +pub const SEEK_SET : c_int = 0; +pub const SEEK_CUR : c_int = 1; +pub const SEEK_END : c_int = 2; +pub const _IOFBF : c_int = 0; +pub const _IONBF : c_int = 2; +pub const _IOLBF : c_int = 1; +pub const BUFSIZ : c_uint = 1024; +pub const FOPEN_MAX : c_uint = 20; +pub const FILENAME_MAX : c_uint = 1024; +pub const L_tmpnam : c_uint = 1024; +pub const TMP_MAX : c_uint = 308915776; +pub const O_RDONLY : c_int = 0; +pub const O_WRONLY : c_int = 1; +pub const O_RDWR : c_int = 2; +pub const O_APPEND : c_int = 8; +pub const O_CREAT : c_int = 512; +pub const O_EXCL : c_int = 2048; +pub const O_NOCTTY : c_int = 32768; +pub const O_TRUNC : c_int = 1024; +pub const S_IFIFO : mode_t = 4096; +pub const S_IFCHR : mode_t = 8192; +pub const S_IFBLK : mode_t = 24576; +pub const S_IFDIR : mode_t = 16384; +pub const S_IFREG : mode_t = 32768; +pub const S_IFLNK : mode_t = 40960; +pub const S_IFSOCK : mode_t = 49152; +pub const S_IFMT : mode_t = 61440; +pub const S_IEXEC : mode_t = 64; +pub const S_IWRITE : mode_t = 128; +pub const S_IREAD : mode_t = 256; +pub const S_IRWXU : mode_t = 448; +pub const S_IXUSR : mode_t = 64; +pub const S_IWUSR : mode_t = 128; +pub const S_IRUSR : mode_t = 256; +pub const S_IRWXG : mode_t = 56; +pub const S_IXGRP : mode_t = 8; +pub const S_IWGRP : mode_t = 16; +pub const S_IRGRP : mode_t = 32; +pub const S_IRWXO : mode_t = 7; +pub const S_IXOTH : mode_t = 1; +pub const S_IWOTH : mode_t = 2; +pub const S_IROTH : mode_t = 4; +pub const F_OK : c_int = 0; +pub const R_OK : c_int = 4; +pub const W_OK : c_int = 2; +pub const X_OK : c_int = 1; +pub const STDIN_FILENO : c_int = 0; +pub const STDOUT_FILENO : c_int = 1; +pub const STDERR_FILENO : c_int = 2; +pub const F_LOCK : c_int = 1; +pub const F_TEST : c_int = 3; +pub const F_TLOCK : c_int = 2; +pub const F_ULOCK : c_int = 0; +pub const SIGHUP : c_int = 1; +pub const SIGINT : c_int = 2; +pub const SIGQUIT : c_int = 3; +pub const SIGILL : c_int = 4; +pub const SIGABRT : c_int = 6; +pub const SIGFPE : c_int = 8; +pub const SIGKILL : c_int = 9; +pub const SIGSEGV : c_int = 11; +pub const SIGPIPE : c_int = 13; +pub const SIGALRM : c_int = 14; +pub const SIGTERM : c_int = 15; + +pub const PROT_NONE : c_int = 0; +pub const PROT_READ : c_int = 1; +pub const PROT_WRITE : c_int = 2; +pub const PROT_EXEC : c_int = 4; + +pub const MAP_FILE : c_int = 0x0000; +pub const MAP_SHARED : c_int = 0x0001; +pub const MAP_PRIVATE : c_int = 0x0002; +pub const MAP_FIXED : c_int = 0x0010; +pub const MAP_ANON : c_int = 0x1000; + +pub const MAP_FAILED : *mut c_void = !0 as *mut c_void; + +pub const MCL_CURRENT : c_int = 0x0001; +pub const MCL_FUTURE : c_int = 0x0002; + +pub const MS_ASYNC : c_int = 0x0001; +pub const MS_SYNC : c_int = 0x0002; +pub const MS_INVALIDATE : c_int = 0x0004; + +pub const EPERM : c_int = 1; +pub const ENOENT : c_int = 2; +pub const ESRCH : c_int = 3; +pub const EINTR : c_int = 4; +pub const EIO : c_int = 5; +pub const ENXIO : c_int = 6; +pub const E2BIG : c_int = 7; +pub const ENOEXEC : c_int = 8; +pub const EBADF : c_int = 9; +pub const ECHILD : c_int = 10; +pub const EDEADLK : c_int = 11; +pub const ENOMEM : c_int = 12; +pub const EACCES : c_int = 13; +pub const EFAULT : c_int = 14; +pub const ENOTBLK : c_int = 15; +pub const EBUSY : c_int = 16; +pub const EEXIST : c_int = 17; +pub const EXDEV : c_int = 18; +pub const ENODEV : c_int = 19; +pub const ENOTDIR : c_int = 20; +pub const EISDIR : c_int = 21; +pub const EINVAL : c_int = 22; +pub const ENFILE : c_int = 23; +pub const EMFILE : c_int = 24; +pub const ENOTTY : c_int = 25; +pub const ETXTBSY : c_int = 26; +pub const EFBIG : c_int = 27; +pub const ENOSPC : c_int = 28; +pub const ESPIPE : c_int = 29; +pub const EROFS : c_int = 30; +pub const EMLINK : c_int = 31; +pub const EPIPE : c_int = 32; +pub const EDOM : c_int = 33; +pub const ERANGE : c_int = 34; +pub const EAGAIN : c_int = 35; +pub const EWOULDBLOCK : c_int = 35; +pub const EINPROGRESS : c_int = 36; +pub const EALREADY : c_int = 37; +pub const ENOTSOCK : c_int = 38; +pub const EDESTADDRREQ : c_int = 39; +pub const EMSGSIZE : c_int = 40; +pub const EPROTOTYPE : c_int = 41; +pub const ENOPROTOOPT : c_int = 42; +pub const EPROTONOSUPPORT : c_int = 43; +pub const ESOCKTNOSUPPORT : c_int = 44; +pub const EOPNOTSUPP : c_int = 45; +pub const EPFNOSUPPORT : c_int = 46; +pub const EAFNOSUPPORT : c_int = 47; +pub const EADDRINUSE : c_int = 48; +pub const EADDRNOTAVAIL : c_int = 49; +pub const ENETDOWN : c_int = 50; +pub const ENETUNREACH : c_int = 51; +pub const ENETRESET : c_int = 52; +pub const ECONNABORTED : c_int = 53; +pub const ECONNRESET : c_int = 54; +pub const ENOBUFS : c_int = 55; +pub const EISCONN : c_int = 56; +pub const ENOTCONN : c_int = 57; +pub const ESHUTDOWN : c_int = 58; +pub const ETOOMANYREFS : c_int = 59; +pub const ETIMEDOUT : c_int = 60; +pub const ECONNREFUSED : c_int = 61; +pub const ELOOP : c_int = 62; +pub const ENAMETOOLONG : c_int = 63; +pub const EHOSTDOWN : c_int = 64; +pub const EHOSTUNREACH : c_int = 65; +pub const ENOTEMPTY : c_int = 66; +pub const EPROCLIM : c_int = 67; +pub const EUSERS : c_int = 68; +pub const EDQUOT : c_int = 69; +pub const ESTALE : c_int = 70; +pub const EREMOTE : c_int = 71; +pub const EBADRPC : c_int = 72; +pub const ERPCMISMATCH : c_int = 73; +pub const EPROGUNAVAIL : c_int = 74; +pub const EPROGMISMATCH : c_int = 75; +pub const EPROCUNAVAIL : c_int = 76; +pub const ENOLCK : c_int = 77; +pub const ENOSYS : c_int = 78; +pub const EFTYPE : c_int = 79; +pub const EAUTH : c_int = 80; +pub const ENEEDAUTH : c_int = 81; +pub const EIPSEC : c_int = 82; +pub const ENOATTR : c_int = 83; +pub const EILSEQ : c_int = 84; +pub const ENOMEDIUM : c_int = 85; +pub const EMEDIUMTYPE : c_int = 86; +pub const EOVERFLOW : c_int = 87; +pub const ECANCELED : c_int = 88; +pub const EIDRM : c_int = 89; +pub const ENOMSG : c_int = 90; +pub const ENOTSUP : c_int = 91; +pub const ELAST : c_int = 91; // must be equal to largest errno + +pub const F_DUPFD : c_int = 0; +pub const F_GETFD : c_int = 1; +pub const F_SETFD : c_int = 2; +pub const F_GETFL : c_int = 3; +pub const F_SETFL : c_int = 4; +pub const F_GETOWN : c_int = 5; +pub const F_SETOWN : c_int = 6; +pub const F_GETLK : c_int = 7; +pub const F_SETLK : c_int = 8; +pub const F_SETLKW : c_int = 9; +pub const F_DUPFD_CLOEXEC : c_int = 10; + +pub const SIGTRAP : c_int = 5; + +pub const GLOB_APPEND : c_int = 0x0001; +pub const GLOB_DOOFFS : c_int = 0x0002; +pub const GLOB_ERR : c_int = 0x0004; +pub const GLOB_MARK : c_int = 0x0008; +pub const GLOB_NOCHECK : c_int = 0x0010; +pub const GLOB_NOSORT : c_int = 0x0020; +pub const GLOB_NOESCAPE : c_int = 0x1000; + +pub const GLOB_NOSPACE : c_int = -1; +pub const GLOB_ABORTED : c_int = -2; +pub const GLOB_NOMATCH : c_int = -3; +pub const GLOB_NOSYS : c_int = -4; + +pub const POSIX_MADV_NORMAL : c_int = 0; +pub const POSIX_MADV_RANDOM : c_int = 1; +pub const POSIX_MADV_SEQUENTIAL : c_int = 2; +pub const POSIX_MADV_WILLNEED : c_int = 3; +pub const POSIX_MADV_DONTNEED : c_int = 4; + +pub const _SC_IOV_MAX : c_int = 51; +pub const _SC_GETGR_R_SIZE_MAX : c_int = 100; +pub const _SC_GETPW_R_SIZE_MAX : c_int = 101; +pub const _SC_LOGIN_NAME_MAX : c_int = 102; +pub const _SC_MQ_PRIO_MAX : c_int = 59; +pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80; +pub const _SC_THREAD_KEYS_MAX : c_int = 81; +pub const _SC_THREAD_PRIO_INHERIT : c_int = 82; +pub const _SC_THREAD_PRIO_PROTECT : c_int = 83; +pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84; +pub const _SC_THREAD_PROCESS_SHARED : c_int = 85; +pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103; +pub const _SC_THREAD_STACK_MIN : c_int = 89; +pub const _SC_THREAD_THREADS_MAX : c_int = 90; +pub const _SC_THREADS : c_int = 91; +pub const _SC_TTY_NAME_MAX : c_int = 107; +pub const _SC_ATEXIT_MAX : c_int = 46; +pub const _SC_XOPEN_CRYPT : c_int = 117; +pub const _SC_XOPEN_ENH_I18N : c_int = 118; +pub const _SC_XOPEN_LEGACY : c_int = 119; +pub const _SC_XOPEN_REALTIME : c_int = 120; +pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121; +pub const _SC_XOPEN_SHM : c_int = 30; +pub const _SC_XOPEN_UNIX : c_int = 123; +pub const _SC_XOPEN_VERSION : c_int = 125; + +pub const PTHREAD_CREATE_JOINABLE : c_int = 0; +pub const PTHREAD_CREATE_DETACHED : c_int = 1; +pub const PTHREAD_STACK_MIN : size_t = 2048; + +pub const CLOCK_REALTIME : c_int = 0; +pub const CLOCK_MONOTONIC : c_int = 3; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_MEMLOCK: c_int = 6; +pub const RLIMIT_NPROC: c_int = 7; +pub const RLIMIT_NOFILE: c_int = 8; +pub const RLIM_NLIMITS: c_int = 9; + +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; +pub const RUSAGE_THREAD: c_int = 1; + +pub const MADV_NORMAL : c_int = 0; +pub const MADV_RANDOM : c_int = 1; +pub const MADV_SEQUENTIAL : c_int = 2; +pub const MADV_WILLNEED : c_int = 3; +pub const MADV_DONTNEED : c_int = 4; +pub const MADV_FREE : c_int = 6; + +pub const AF_UNIX: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_INET6: c_int = 24; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_IPV6: c_int = 41; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_TTL: c_int = 4; +pub const IP_HDRINCL: c_int = 2; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IPV6_ADD_MEMBERSHIP: c_int = 12; // don't exist +pub const IPV6_DROP_MEMBERSHIP: c_int = 13; // don't exist + +pub const TCP_NODELAY: c_int = 0x01; +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_DEBUG: c_int = 0x01; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; + +pub const IFF_LOOPBACK: c_int = 0x8; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const O_DSYNC : c_int = 128; // same as SYNC +pub const O_SYNC : c_int = 128; +pub const O_NONBLOCK : c_int = 4; +pub const CTL_KERN : c_int = 1; +pub const KERN_PROC : c_int = 66; + +pub const MAP_COPY : c_int = 0x0002; +pub const MAP_RENAME : c_int = 0x0000; +pub const MAP_NORESERVE : c_int = 0x0000; +pub const MAP_NOEXTEND : c_int = 0x0000; +pub const MAP_HASSEMAPHORE : c_int = 0x0000; + +pub const IPPROTO_RAW : c_int = 255; + +pub const PATH_MAX: c_int = 1024; + +pub const _SC_ARG_MAX : c_int = 1; +pub const _SC_CHILD_MAX : c_int = 2; +pub const _SC_CLK_TCK : c_int = 3; +pub const _SC_NGROUPS_MAX : c_int = 4; +pub const _SC_OPEN_MAX : c_int = 5; +pub const _SC_JOB_CONTROL : c_int = 6; +pub const _SC_SAVED_IDS : c_int = 7; +pub const _SC_VERSION : c_int = 8; +pub const _SC_BC_BASE_MAX : c_int = 9; +pub const _SC_BC_DIM_MAX : c_int = 10; +pub const _SC_BC_SCALE_MAX : c_int = 11; +pub const _SC_BC_STRING_MAX : c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX : c_int = 13; +pub const _SC_EXPR_NEST_MAX : c_int = 14; +pub const _SC_LINE_MAX : c_int = 15; +pub const _SC_RE_DUP_MAX : c_int = 16; +pub const _SC_2_VERSION : c_int = 17; +pub const _SC_2_C_BIND : c_int = 18; +pub const _SC_2_C_DEV : c_int = 19; +pub const _SC_2_CHAR_TERM : c_int = 20; +pub const _SC_2_FORT_DEV : c_int = 21; +pub const _SC_2_FORT_RUN : c_int = 22; +pub const _SC_2_LOCALEDEF : c_int = 23; +pub const _SC_2_SW_DEV : c_int = 24; +pub const _SC_2_UPE : c_int = 25; +pub const _SC_STREAM_MAX : c_int = 26; +pub const _SC_TZNAME_MAX : c_int = 27; +pub const _SC_PAGESIZE : c_int = 28; +pub const _SC_FSYNC : c_int = 29; +pub const _SC_SEM_NSEMS_MAX : c_int = 31; +pub const _SC_SEM_VALUE_MAX : c_int = 32; +pub const _SC_AIO_LISTIO_MAX : c_int = 42; +pub const _SC_AIO_MAX : c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44; +pub const _SC_ASYNCHRONOUS_IO : c_int = 45; +pub const _SC_DELAYTIMER_MAX : c_int = 50; +pub const _SC_MAPPED_FILES : c_int = 53; +pub const _SC_MEMLOCK : c_int = 54; +pub const _SC_MEMLOCK_RANGE : c_int = 55; +pub const _SC_MEMORY_PROTECTION : c_int = 56; +pub const _SC_MESSAGE_PASSING : c_int = 57; +pub const _SC_MQ_OPEN_MAX : c_int = 58; +pub const _SC_PRIORITIZED_IO : c_int = 60; +pub const _SC_PRIORITY_SCHEDULING : c_int = 61; +pub const _SC_REALTIME_SIGNALS : c_int = 64; +pub const _SC_RTSIG_MAX : c_int = 66; +pub const _SC_SEMAPHORES : c_int = 67; +pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68; +pub const _SC_SIGQUEUE_MAX : c_int = 70; +pub const _SC_SYNCHRONIZED_IO : c_int = 75; +pub const _SC_TIMER_MAX : c_int = 93; +pub const _SC_TIMERS : c_int = 94; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const SIGSTKSZ: ::size_t = 131072; + extern { pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) -> c_int; @@ -770,3 +562,13 @@ extern { pub fn backtrace(buf: *mut *mut ::c_void, sz: ::size_t) -> ::size_t; } + +cfg_if! { + if #[cfg(target_os = "bitrig")] { + mod bitrig; + use self::bitrig::*; + } else { + mod openbsd; + use self::openbsd::*; + } +} diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs new file mode 100644 index 0000000000000..417c8a559fbf3 --- /dev/null +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -0,0 +1,18 @@ +s! { + pub struct glob_t { + pub gl_pathc: c_int, + __unused1: c_int, + pub gl_offs: c_int, + __unused2: c_int, + pub gl_pathv: *mut *mut c_char, + + __unused3: *mut c_void, + + __unused4: *mut c_void, + __unused5: *mut c_void, + __unused6: *mut c_void, + __unused7: *mut c_void, + __unused8: *mut c_void, + __unused9: *mut c_void, + } +} From a4e27ed77adbb6e65ea39c5640678cb873dc6e60 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 16:20:02 -0700 Subject: [PATCH 160/194] Upward movement for BSD --- src/unix/bsd/apple/mod.rs | 28 ------------- src/unix/bsd/freebsdlike/mod.rs | 69 +++++++++------------------------ src/unix/bsd/mod.rs | 27 +++++++++++++ src/unix/bsd/openbsdlike/mod.rs | 40 +++---------------- 4 files changed, 52 insertions(+), 112 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 56f5ad432ee8e..489afe0656e57 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2,44 +2,16 @@ //! //! This covers *-apple-* triples currently -pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; pub type clock_t = c_ulong; pub type time_t = c_long; pub type suseconds_t = i32; -pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; - -pub type off_t = i64; pub type dev_t = i32; pub type ino_t = u64; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; pub type mode_t = u16; pub type ssize_t = c_long; - pub type nlink_t = u16; pub type blksize_t = i32; -pub type blkcnt_t = i64; -pub type socklen_t = u32; -pub type sa_family_t = u8; -pub type in_port_t = u16; -pub type in_addr_t = u32; -pub type pthread_t = uintptr_t; pub type rlim_t = u64; -pub type sighandler_t = size_t; pub type mach_timebase_info_data_t = mach_timebase_info; pub type pthread_key_t = c_ulong; pub type sigset_t = u32; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 11bf83022439d..42b15090079e1 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1,39 +1,12 @@ -pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; pub type clock_t = i32; -pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type off_t = i64; pub type dev_t = u32; pub type ino_t = u32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; pub type mode_t = u16; pub type nlink_t = u16; pub type blksize_t = u32; -pub type blkcnt_t = i64; pub type fflags_t = u32; pub type pthread_attr_t = *mut ::c_void; - -pub type pthread_t = uintptr_t; pub type rlim_t = i64; -pub type sighandler_t = size_t; -pub type socklen_t = u32; -pub type sa_family_t = u8; -pub type in_port_t = u16; -pub type in_addr_t = u32; pub type pthread_mutex_t = *mut ::c_void; pub type pthread_mutexattr_t = *mut ::c_void; pub type pthread_cond_t = *mut ::c_void; @@ -61,7 +34,7 @@ s! { pub struct sockaddr_storage { pub ss_len: u8, - pub ss_family: sa_family_t, + pub ss_family: ::sa_family_t, __ss_pad1: [u8; 6], __ss_align: i64, __ss_pad2: [u8; 112], @@ -72,16 +45,16 @@ s! { pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, - pub ai_addrlen: socklen_t, - pub ai_canonname: *mut c_char, + pub ai_addrlen: ::socklen_t, + pub ai_canonname: *mut ::c_char, pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } pub struct ifaddrs { pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, + pub ifa_name: *mut ::c_char, + pub ifa_flags: ::c_uint, pub ifa_addr: *mut ::sockaddr, pub ifa_netmask: *mut ::sockaddr, pub ifa_dstaddr: *mut ::sockaddr, @@ -100,11 +73,11 @@ s! { pub si_uid: ::uid_t, pub si_status: ::c_int, pub si_addr: *mut ::c_void, - _pad: [c_int; 12], + _pad: [::c_int; 12], } pub struct sigaction { - pub sa_sigaction: sighandler_t, + pub sa_sigaction: ::sighandler_t, pub sa_flags: ::c_int, pub sa_mask: sigset_t, } @@ -126,11 +99,11 @@ pub const SEEK_END: ::c_int = 2; pub const _IOFBF: ::c_int = 0; pub const _IONBF: ::c_int = 2; pub const _IOLBF: ::c_int = 1; -pub const BUFSIZ: c_uint = 1024; -pub const FOPEN_MAX: c_uint = 20; -pub const FILENAME_MAX: c_uint = 1024; -pub const L_tmpnam: c_uint = 1024; -pub const TMP_MAX: c_uint = 308915776; +pub const BUFSIZ: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const L_tmpnam: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 308915776; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; @@ -527,30 +500,26 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; -pub const SIGSTKSZ: ::size_t = 34816; - extern { - pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) - -> c_int; + pub fn mprotect(addr: *const ::c_void, len: size_t, prot: ::c_int) + -> ::c_int; pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int; - pub fn sysctl(name: *const c_int, - namelen: c_uint, + pub fn sysctl(name: *const ::c_int, + namelen: ::c_uint, oldp: *mut ::c_void, oldlenp: *mut size_t, newp: *const ::c_void, newlen: size_t) - -> c_int; - pub fn sysctlbyname(name: *const c_char, + -> ::c_int; + pub fn sysctlbyname(name: *const ::c_char, oldp: *mut ::c_void, oldlenp: *mut size_t, newp: *const ::c_void, newlen: size_t) - -> c_int; + -> ::c_int; pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); - pub fn backtrace(buf: *mut *mut ::c_void, - sz: ::size_t) -> ::size_t; } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 56ae724674916..a7c30eabe7bc6 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -1,3 +1,30 @@ +pub type c_char = i8; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type wchar_t = i32; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type off_t = i64; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type useconds_t = u32; +pub type blkcnt_t = i64; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type in_port_t = u16; +pub type in_addr_t = u32; +pub type pthread_t = uintptr_t; +pub type sighandler_t = size_t; + s! { pub struct sockaddr { pub sa_len: u8, diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 1234c19b15bda..340857d8aa96d 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -1,45 +1,18 @@ -pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; pub type c_long = i64; pub type c_ulong = u64; -pub type c_float = f32; -pub type c_double = f64; pub type size_t = u64; pub type ptrdiff_t = i64; pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; -pub type wchar_t = i32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intptr_t = i64; pub type uintptr_t = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type off_t = i64; pub type dev_t = i32; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type useconds_t = u32; pub type mode_t = u32; pub type ssize_t = c_long; - -pub type sighandler_t = size_t; -pub type socklen_t = u32; -pub type sa_family_t = u8; -pub type in_port_t = u16; -pub type in_addr_t = u32; - pub type nlink_t = uint32_t; pub type blksize_t = uint32_t; pub type ino_t = uint64_t; -pub type blkcnt_t = i64; pub type fflags_t = u32; pub type pthread_attr_t = *mut c_void; pub type sigset_t = ::c_uint; @@ -48,19 +21,12 @@ pub type pthread_mutex_t = *mut ::c_void; pub type pthread_mutexattr_t = *mut ::c_void; pub type pthread_cond_t = *mut ::c_void; pub type pthread_rwlock_t = *mut ::c_void; -pub type pthread_t = uintptr_t; pub type rlim_t = u64; pub enum timezone {} s! { - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_size: ::size_t, - pub ss_flags: ::c_int, - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, @@ -131,6 +97,12 @@ s! { pub st_birthtime: time_t, pub st_birthtime_nsec: c_long, } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } } pub const EXIT_FAILURE : c_int = 1; From c674e37af501726f8449cd6390a3cb49e383880a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 16:22:00 -0700 Subject: [PATCH 161/194] Upward movement for Unix --- src/unix/bsd/mod.rs | 24 +++--------------------- src/unix/mod.rs | 19 +++++++++++++++++++ src/unix/notbsd/mod.rs | 18 ------------------ 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a7c30eabe7bc6..18ba01093ae71 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -1,29 +1,11 @@ pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type wchar_t = i32; -pub type intmax_t = i64; -pub type uintmax_t = u64; pub type off_t = i64; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; pub type useconds_t = u32; pub type blkcnt_t = i64; pub type socklen_t = u32; pub type sa_family_t = u8; -pub type in_port_t = u16; -pub type in_addr_t = u32; pub type pthread_t = uintptr_t; -pub type sighandler_t = size_t; s! { pub struct sockaddr { @@ -82,11 +64,11 @@ pub const SIG_SETMASK: ::c_int = 3; extern { pub fn mincore(addr: *const ::c_void, len: size_t, - vec: *mut c_char) -> c_int; + vec: *mut c_char) -> ::c_int; pub fn sysctlnametomib(name: *const c_char, - mibp: *mut c_int, + mibp: *mut ::c_int, sizep: *mut size_t) - -> c_int; + -> ::c_int; pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 16c9a152858f5..e8a16691a7a6a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -3,6 +3,25 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type sighandler_t = size_t; + s! { pub struct utimbuf { pub actime: time_t, diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index ba6c767a4b54b..e982ce6a0b602 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -1,23 +1,5 @@ -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; -pub type in_addr_t = u32; -pub type in_port_t = u16; pub type rlim_t = c_ulong; pub type sa_family_t = u16; -pub type sighandler_t = size_t; pub type pthread_key_t = c_uint; pub enum timezone {} From 6603ca0d7ea72abcd1aff1d34acae7c5dc1e79ae Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 16:23:25 -0700 Subject: [PATCH 162/194] AppVeyor only autotest branch --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index cdd5bf1abb74e..1412f909cd30b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,3 +26,7 @@ build: false test_script: - cargo test - cargo run --manifest-path libc-test/Cargo.toml + +branches: + only: + - autotest From 3715e831f86c326938cc63dfcb26d79361eb5fe4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 16:27:10 -0700 Subject: [PATCH 163/194] Move ifaddrs up a level on BSD --- src/unix/bsd/apple/mod.rs | 10 ---------- src/unix/bsd/freebsdlike/mod.rs | 10 ---------- src/unix/bsd/mod.rs | 10 ++++++++++ src/unix/bsd/openbsdlike/mod.rs | 10 ---------- 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 489afe0656e57..23184e1e4e94b 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -54,16 +54,6 @@ s! { pub ai_next: *mut addrinfo, } - pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut ::sockaddr, - pub ifa_netmask: *mut ::sockaddr, - pub ifa_dstaddr: *mut ::sockaddr, - pub ifa_data: *mut ::c_void - } - pub struct mach_timebase_info { pub numer: u32, pub denom: u32, diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 42b15090079e1..043eb64afa7b0 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -51,16 +51,6 @@ s! { pub ai_next: *mut addrinfo, } - pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut ::c_char, - pub ifa_flags: ::c_uint, - pub ifa_addr: *mut ::sockaddr, - pub ifa_netmask: *mut ::sockaddr, - pub ifa_dstaddr: *mut ::sockaddr, - pub ifa_data: *mut ::c_void - } - pub struct sigset_t { bits: [u32; 4], } diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 18ba01093ae71..216c68852caa8 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -52,6 +52,16 @@ s! { #[cfg(not(target_os = "macos"))] pub pw_fields: ::c_int, } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut ::c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_dstaddr: *mut ::sockaddr, + pub ifa_data: *mut ::c_void + } } pub const FIOCLEX: c_ulong = 0x20006601; diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 340857d8aa96d..239eff2c7edc1 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -65,16 +65,6 @@ s! { pub ai_next: *mut addrinfo, } - pub struct ifaddrs { - pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut c_char, - pub ifa_flags: c_uint, - pub ifa_addr: *mut sockaddr, - pub ifa_netmask: *mut sockaddr, - pub ifa_dstaddr: *mut sockaddr, - pub ifa_data: *mut c_void - } - pub struct stat { pub st_mode: mode_t, pub st_dev: dev_t, From 239f9cda7fb3a7f664febbf1850eed07f692fccc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 16:31:34 -0700 Subject: [PATCH 164/194] Fix resolution in notbsd/mod.rs --- src/unix/notbsd/mod.rs | 98 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index e982ce6a0b602..b0f74215526ba 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -1,6 +1,6 @@ pub type rlim_t = c_ulong; pub type sa_family_t = u16; -pub type pthread_key_t = c_uint; +pub type pthread_key_t = ::c_uint; pub enum timezone {} @@ -40,10 +40,10 @@ s! { } pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, pub ai_addrlen: socklen_t, #[cfg(target_os = "linux")] @@ -58,53 +58,53 @@ s! { } pub struct sockaddr_ll { - pub sll_family: c_ushort, - pub sll_protocol: c_ushort, - pub sll_ifindex: c_int, - pub sll_hatype: c_ushort, - pub sll_pkttype: c_uchar, - pub sll_halen: c_uchar, - pub sll_addr: [c_uchar; 8] + pub sll_family: ::c_ushort, + pub sll_protocol: ::c_ushort, + pub sll_ifindex: ::c_int, + pub sll_hatype: ::c_ushort, + pub sll_pkttype: ::c_uchar, + pub sll_halen: ::c_uchar, + pub sll_addr: [::c_uchar; 8] } } -pub const EXIT_FAILURE: c_int = 1; -pub const EXIT_SUCCESS: c_int = 0; -pub const RAND_MAX: c_int = 2147483647; -pub const EOF: c_int = -1; -pub const SEEK_SET: c_int = 0; -pub const SEEK_CUR: c_int = 1; -pub const SEEK_END: c_int = 2; -pub const _IOFBF: c_int = 0; -pub const _IONBF: c_int = 2; -pub const _IOLBF: c_int = 1; - -pub const F_DUPFD: c_int = 0; -pub const F_GETFD: c_int = 1; -pub const F_SETFD: c_int = 2; -pub const F_GETFL: c_int = 3; -pub const F_SETFL: c_int = 4; - -pub const SIGTRAP: c_int = 5; - -pub const PTHREAD_CREATE_JOINABLE: c_int = 0; -pub const PTHREAD_CREATE_DETACHED: c_int = 1; - -pub const CLOCK_REALTIME: c_int = 0; -pub const CLOCK_MONOTONIC: c_int = 1; - -pub const RLIMIT_CPU: c_int = 0; -pub const RLIMIT_FSIZE: c_int = 1; -pub const RLIMIT_DATA: c_int = 2; -pub const RLIMIT_STACK: c_int = 3; -pub const RLIMIT_CORE: c_int = 4; -pub const RLIMIT_LOCKS: c_int = 10; -pub const RLIMIT_SIGPENDING: c_int = 11; -pub const RLIMIT_MSGQUEUE: c_int = 12; -pub const RLIMIT_NICE: c_int = 13; -pub const RLIMIT_RTPRIO: c_int = 14; - -pub const RUSAGE_SELF: c_int = 0; +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +pub const SIGTRAP: ::c_int = 5; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; + +pub const CLOCK_REALTIME: ::c_int = 0; +pub const CLOCK_MONOTONIC: ::c_int = 1; + +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + +pub const RUSAGE_SELF: ::c_int = 0; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; From 70b1f23f27db39268545d9036fcdfd47041d5ffe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 16:32:03 -0700 Subject: [PATCH 165/194] Try running MIPS again --- ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run.sh b/ci/run.sh index f9e0b51e02e64..22146f28752b3 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -17,7 +17,7 @@ elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/libc-test elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then # FIXME: this segfaults on travis, passes locally? - #qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/all-* + qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/libc-test echo skip elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then qemu-aarch64 -L /usr/aarch64-linux-gnu/ libc-test/target/$TARGET/debug/libc-test From caeb3fa56c0dafcd4127466095e46d8af93d12bb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 16:51:54 -0700 Subject: [PATCH 166/194] Fix resolution on OSX --- src/unix/bsd/apple/mod.rs | 932 +++++++++++++++++++------------------- 1 file changed, 466 insertions(+), 466 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 23184e1e4e94b..7b5b04317a3a8 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -21,10 +21,10 @@ pub enum timezone {} s! { pub struct glob_t { pub gl_pathc: size_t, - __unused1: c_int, + __unused1: ::c_int, pub gl_offs: size_t, - __unused2: c_int, - pub gl_pathv: *mut *mut c_char, + __unused2: ::c_int, + pub gl_pathv: *mut *mut ::c_char, __unused3: *mut ::c_void, @@ -37,19 +37,19 @@ s! { pub struct sockaddr_storage { pub ss_len: u8, - pub ss_family: sa_family_t, + pub ss_family: ::sa_family_t, __ss_pad1: [u8; 6], __ss_align: i64, __ss_pad2: [u8; 112], } pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: socklen_t, - pub ai_canonname: *mut c_char, + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_canonname: *mut ::c_char, pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, } @@ -64,8 +64,8 @@ s! { pub st_mode: mode_t, pub st_nlink: nlink_t, pub st_ino: ino_t, - pub st_uid: uid_t, - pub st_gid: gid_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, pub st_rdev: dev_t, pub st_atime: time_t, pub st_atime_nsec: c_long, @@ -75,8 +75,8 @@ s! { pub st_ctime_nsec: c_long, pub st_birthtime: time_t, pub st_birthtime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: blkcnt_t, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, pub st_blksize: blksize_t, pub st_flags: ::uint32_t, pub st_gen: ::uint32_t, @@ -116,7 +116,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: sighandler_t, + pub sa_sigaction: ::sighandler_t, pub sa_mask: sigset_t, pub sa_flags: ::c_int, } @@ -128,31 +128,31 @@ s! { } } -pub const EXIT_FAILURE: c_int = 1; -pub const EXIT_SUCCESS: c_int = 0; -pub const RAND_MAX: c_int = 2147483647; -pub const EOF: c_int = -1; -pub const SEEK_SET: c_int = 0; -pub const SEEK_CUR: c_int = 1; -pub const SEEK_END: c_int = 2; -pub const _IOFBF: c_int = 0; -pub const _IONBF: c_int = 2; -pub const _IOLBF: c_int = 1; -pub const BUFSIZ: c_uint = 1024; -pub const FOPEN_MAX: c_uint = 20; -pub const FILENAME_MAX: c_uint = 1024; -pub const L_tmpnam: c_uint = 1024; -pub const TMP_MAX: c_uint = 308915776; -pub const _PC_NAME_MAX: c_int = 4; - -pub const O_RDONLY: c_int = 0; -pub const O_WRONLY: c_int = 1; -pub const O_RDWR: c_int = 2; -pub const O_APPEND: c_int = 8; -pub const O_CREAT: c_int = 512; -pub const O_EXCL: c_int = 2048; -pub const O_NOCTTY: c_int = 131072; -pub const O_TRUNC: c_int = 1024; +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 2147483647; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 2; +pub const _IOLBF: ::c_int = 1; +pub const BUFSIZ: ::c_uint = 1024; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 1024; +pub const L_tmpnam: ::c_uint = 1024; +pub const TMP_MAX: ::c_uint = 308915776; +pub const _PC_NAME_MAX: ::c_int = 4; + +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 512; +pub const O_EXCL: ::c_int = 2048; +pub const O_NOCTTY: ::c_int = 131072; +pub const O_TRUNC: ::c_int = 1024; pub const S_IFIFO: mode_t = 4096; pub const S_IFCHR: mode_t = 8192; pub const S_IFBLK: mode_t = 24576; @@ -176,435 +176,435 @@ pub const S_IRWXO: mode_t = 7; pub const S_IXOTH: mode_t = 1; pub const S_IWOTH: mode_t = 2; pub const S_IROTH: mode_t = 4; -pub const F_OK: c_int = 0; -pub const R_OK: c_int = 4; -pub const W_OK: c_int = 2; -pub const X_OK: c_int = 1; -pub const STDIN_FILENO: c_int = 0; -pub const STDOUT_FILENO: c_int = 1; -pub const STDERR_FILENO: c_int = 2; -pub const F_LOCK: c_int = 1; -pub const F_TEST: c_int = 3; -pub const F_TLOCK: c_int = 2; -pub const F_ULOCK: c_int = 0; -pub const SIGHUP: c_int = 1; -pub const SIGINT: c_int = 2; -pub const SIGQUIT: c_int = 3; -pub const SIGILL: c_int = 4; -pub const SIGABRT: c_int = 6; -pub const SIGFPE: c_int = 8; -pub const SIGKILL: c_int = 9; -pub const SIGSEGV: c_int = 11; -pub const SIGPIPE: c_int = 13; -pub const SIGALRM: c_int = 14; -pub const SIGTERM: c_int = 15; - -pub const PROT_NONE: c_int = 0; -pub const PROT_READ: c_int = 1; -pub const PROT_WRITE: c_int = 2; -pub const PROT_EXEC: c_int = 4; - -pub const MAP_FILE: c_int = 0x0000; -pub const MAP_SHARED: c_int = 0x0001; -pub const MAP_PRIVATE: c_int = 0x0002; -pub const MAP_FIXED: c_int = 0x0010; -pub const MAP_ANON: c_int = 0x1000; +pub const F_OK: ::c_int = 0; +pub const R_OK: ::c_int = 4; +pub const W_OK: ::c_int = 2; +pub const X_OK: ::c_int = 1; +pub const STDIN_FILENO: ::c_int = 0; +pub const STDOUT_FILENO: ::c_int = 1; +pub const STDERR_FILENO: ::c_int = 2; +pub const F_LOCK: ::c_int = 1; +pub const F_TEST: ::c_int = 3; +pub const F_TLOCK: ::c_int = 2; +pub const F_ULOCK: ::c_int = 0; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGSEGV: ::c_int = 11; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const PROT_NONE: ::c_int = 0; +pub const PROT_READ: ::c_int = 1; +pub const PROT_WRITE: ::c_int = 2; +pub const PROT_EXEC: ::c_int = 4; + +pub const MAP_FILE: ::c_int = 0x0000; +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_ANON: ::c_int = 0x1000; pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; -pub const MCL_CURRENT: c_int = 0x0001; -pub const MCL_FUTURE: c_int = 0x0002; - -pub const MS_ASYNC: c_int = 0x0001; -pub const MS_INVALIDATE: c_int = 0x0002; -pub const MS_SYNC: c_int = 0x0010; - -pub const MS_KILLPAGES: c_int = 0x0004; -pub const MS_DEACTIVATE: c_int = 0x0008; - -pub const EPERM: c_int = 1; -pub const ENOENT: c_int = 2; -pub const ESRCH: c_int = 3; -pub const EINTR: c_int = 4; -pub const EIO: c_int = 5; -pub const ENXIO: c_int = 6; -pub const E2BIG: c_int = 7; -pub const ENOEXEC: c_int = 8; -pub const EBADF: c_int = 9; -pub const ECHILD: c_int = 10; -pub const EDEADLK: c_int = 11; -pub const ENOMEM: c_int = 12; -pub const EACCES: c_int = 13; -pub const EFAULT: c_int = 14; -pub const ENOTBLK: c_int = 15; -pub const EBUSY: c_int = 16; -pub const EEXIST: c_int = 17; -pub const EXDEV: c_int = 18; -pub const ENODEV: c_int = 19; -pub const ENOTDIR: c_int = 20; -pub const EISDIR: c_int = 21; -pub const EINVAL: c_int = 22; -pub const ENFILE: c_int = 23; -pub const EMFILE: c_int = 24; -pub const ENOTTY: c_int = 25; -pub const ETXTBSY: c_int = 26; -pub const EFBIG: c_int = 27; -pub const ENOSPC: c_int = 28; -pub const ESPIPE: c_int = 29; -pub const EROFS: c_int = 30; -pub const EMLINK: c_int = 31; -pub const EPIPE: c_int = 32; -pub const EDOM: c_int = 33; -pub const ERANGE: c_int = 34; -pub const EAGAIN: c_int = 35; -pub const EWOULDBLOCK: c_int = EAGAIN; -pub const EINPROGRESS: c_int = 36; -pub const EALREADY: c_int = 37; -pub const ENOTSOCK: c_int = 38; -pub const EDESTADDRREQ: c_int = 39; -pub const EMSGSIZE: c_int = 40; -pub const EPROTOTYPE: c_int = 41; -pub const ENOPROTOOPT: c_int = 42; -pub const EPROTONOSUPPORT: c_int = 43; -pub const ESOCKTNOSUPPORT: c_int = 44; -pub const ENOTSUP: c_int = 45; -pub const EPFNOSUPPORT: c_int = 46; -pub const EAFNOSUPPORT: c_int = 47; -pub const EADDRINUSE: c_int = 48; -pub const EADDRNOTAVAIL: c_int = 49; -pub const ENETDOWN: c_int = 50; -pub const ENETUNREACH: c_int = 51; -pub const ENETRESET: c_int = 52; -pub const ECONNABORTED: c_int = 53; -pub const ECONNRESET: c_int = 54; -pub const ENOBUFS: c_int = 55; -pub const EISCONN: c_int = 56; -pub const ENOTCONN: c_int = 57; -pub const ESHUTDOWN: c_int = 58; -pub const ETOOMANYREFS: c_int = 59; -pub const ETIMEDOUT: c_int = 60; -pub const ECONNREFUSED: c_int = 61; -pub const ELOOP: c_int = 62; -pub const ENAMETOOLONG: c_int = 63; -pub const EHOSTDOWN: c_int = 64; -pub const EHOSTUNREACH: c_int = 65; -pub const ENOTEMPTY: c_int = 66; -pub const EPROCLIM: c_int = 67; -pub const EUSERS: c_int = 68; -pub const EDQUOT: c_int = 69; -pub const ESTALE: c_int = 70; -pub const EREMOTE: c_int = 71; -pub const EBADRPC: c_int = 72; -pub const ERPCMISMATCH: c_int = 73; -pub const EPROGUNAVAIL: c_int = 74; -pub const EPROGMISMATCH: c_int = 75; -pub const EPROCUNAVAIL: c_int = 76; -pub const ENOLCK: c_int = 77; -pub const ENOSYS: c_int = 78; -pub const EFTYPE: c_int = 79; -pub const EAUTH: c_int = 80; -pub const ENEEDAUTH: c_int = 81; -pub const EPWROFF: c_int = 82; -pub const EDEVERR: c_int = 83; -pub const EOVERFLOW: c_int = 84; -pub const EBADEXEC: c_int = 85; -pub const EBADARCH: c_int = 86; -pub const ESHLIBVERS: c_int = 87; -pub const EBADMACHO: c_int = 88; -pub const ECANCELED: c_int = 89; -pub const EIDRM: c_int = 90; -pub const ENOMSG: c_int = 91; -pub const EILSEQ: c_int = 92; -pub const ENOATTR: c_int = 93; -pub const EBADMSG: c_int = 94; -pub const EMULTIHOP: c_int = 95; -pub const ENODATA: c_int = 96; -pub const ENOLINK: c_int = 97; -pub const ENOSR: c_int = 98; -pub const ENOSTR: c_int = 99; -pub const EPROTO: c_int = 100; -pub const ETIME: c_int = 101; -pub const EOPNOTSUPP: c_int = 102; -pub const ENOPOLICY: c_int = 103; -pub const ENOTRECOVERABLE: c_int = 104; -pub const EOWNERDEAD: c_int = 105; -pub const EQFULL: c_int = 106; -pub const ELAST: c_int = 106; - -pub const F_DUPFD: c_int = 0; -pub const F_GETFD: c_int = 1; -pub const F_SETFD: c_int = 2; -pub const F_GETFL: c_int = 3; -pub const F_SETFL: c_int = 4; - -pub const O_ACCMODE: c_int = 3; - -pub const SIGTRAP: c_int = 5; - -pub const GLOB_APPEND : c_int = 0x0001; -pub const GLOB_DOOFFS : c_int = 0x0002; -pub const GLOB_ERR : c_int = 0x0004; -pub const GLOB_MARK : c_int = 0x0008; -pub const GLOB_NOCHECK : c_int = 0x0010; -pub const GLOB_NOSORT : c_int = 0x0020; -pub const GLOB_NOESCAPE: c_int = 0x2000; - -pub const GLOB_NOSPACE : c_int = -1; -pub const GLOB_ABORTED : c_int = -2; -pub const GLOB_NOMATCH : c_int = -3; - -pub const POSIX_MADV_NORMAL: c_int = 0; -pub const POSIX_MADV_RANDOM: c_int = 1; -pub const POSIX_MADV_SEQUENTIAL: c_int = 2; -pub const POSIX_MADV_WILLNEED: c_int = 3; -pub const POSIX_MADV_DONTNEED: c_int = 4; - -pub const _SC_IOV_MAX: c_int = 56; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 70; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 71; -pub const _SC_LOGIN_NAME_MAX: c_int = 73; -pub const _SC_MQ_PRIO_MAX: c_int = 75; -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 82; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 83; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 85; -pub const _SC_THREAD_KEYS_MAX: c_int = 86; -pub const _SC_THREAD_PRIO_INHERIT: c_int = 87; -pub const _SC_THREAD_PRIO_PROTECT: c_int = 88; -pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 89; -pub const _SC_THREAD_PROCESS_SHARED: c_int = 90; -pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 91; -pub const _SC_THREAD_STACK_MIN: c_int = 93; -pub const _SC_THREAD_THREADS_MAX: c_int = 94; -pub const _SC_THREADS: c_int = 96; -pub const _SC_TTY_NAME_MAX: c_int = 101; -pub const _SC_ATEXIT_MAX: c_int = 107; -pub const _SC_XOPEN_CRYPT: c_int = 108; -pub const _SC_XOPEN_ENH_I18N: c_int = 109; -pub const _SC_XOPEN_LEGACY: c_int = 110; -pub const _SC_XOPEN_REALTIME: c_int = 111; -pub const _SC_XOPEN_REALTIME_THREADS: c_int = 112; -pub const _SC_XOPEN_SHM: c_int = 113; -pub const _SC_XOPEN_UNIX: c_int = 115; -pub const _SC_XOPEN_VERSION: c_int = 116; -pub const _SC_XOPEN_XCU_VERSION: c_int = 121; - -pub const PTHREAD_CREATE_JOINABLE: c_int = 1; -pub const PTHREAD_CREATE_DETACHED: c_int = 2; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const MS_ASYNC: ::c_int = 0x0001; +pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MS_SYNC: ::c_int = 0x0010; + +pub const MS_KILLPAGES: ::c_int = 0x0004; +pub const MS_DEACTIVATE: ::c_int = 0x0008; + +pub const EPERM: ::c_int = 1; +pub const ENOENT: ::c_int = 2; +pub const ESRCH: ::c_int = 3; +pub const EINTR: ::c_int = 4; +pub const EIO: ::c_int = 5; +pub const ENXIO: ::c_int = 6; +pub const E2BIG: ::c_int = 7; +pub const ENOEXEC: ::c_int = 8; +pub const EBADF: ::c_int = 9; +pub const ECHILD: ::c_int = 10; +pub const EDEADLK: ::c_int = 11; +pub const ENOMEM: ::c_int = 12; +pub const EACCES: ::c_int = 13; +pub const EFAULT: ::c_int = 14; +pub const ENOTBLK: ::c_int = 15; +pub const EBUSY: ::c_int = 16; +pub const EEXIST: ::c_int = 17; +pub const EXDEV: ::c_int = 18; +pub const ENODEV: ::c_int = 19; +pub const ENOTDIR: ::c_int = 20; +pub const EISDIR: ::c_int = 21; +pub const EINVAL: ::c_int = 22; +pub const ENFILE: ::c_int = 23; +pub const EMFILE: ::c_int = 24; +pub const ENOTTY: ::c_int = 25; +pub const ETXTBSY: ::c_int = 26; +pub const EFBIG: ::c_int = 27; +pub const ENOSPC: ::c_int = 28; +pub const ESPIPE: ::c_int = 29; +pub const EROFS: ::c_int = 30; +pub const EMLINK: ::c_int = 31; +pub const EPIPE: ::c_int = 32; +pub const EDOM: ::c_int = 33; +pub const ERANGE: ::c_int = 34; +pub const EAGAIN: ::c_int = 35; +pub const EWOULDBLOCK: ::c_int = EAGAIN; +pub const EINPROGRESS: ::c_int = 36; +pub const EALREADY: ::c_int = 37; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const ENOTSUP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const ELOOP: ::c_int = 62; +pub const ENAMETOOLONG: ::c_int = 63; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const ENOTEMPTY: ::c_int = 66; +pub const EPROCLIM: ::c_int = 67; +pub const EUSERS: ::c_int = 68; +pub const EDQUOT: ::c_int = 69; +pub const ESTALE: ::c_int = 70; +pub const EREMOTE: ::c_int = 71; +pub const EBADRPC: ::c_int = 72; +pub const ERPCMISMATCH: ::c_int = 73; +pub const EPROGUNAVAIL: ::c_int = 74; +pub const EPROGMISMATCH: ::c_int = 75; +pub const EPROCUNAVAIL: ::c_int = 76; +pub const ENOLCK: ::c_int = 77; +pub const ENOSYS: ::c_int = 78; +pub const EFTYPE: ::c_int = 79; +pub const EAUTH: ::c_int = 80; +pub const ENEEDAUTH: ::c_int = 81; +pub const EPWROFF: ::c_int = 82; +pub const EDEVERR: ::c_int = 83; +pub const EOVERFLOW: ::c_int = 84; +pub const EBADEXEC: ::c_int = 85; +pub const EBADARCH: ::c_int = 86; +pub const ESHLIBVERS: ::c_int = 87; +pub const EBADMACHO: ::c_int = 88; +pub const ECANCELED: ::c_int = 89; +pub const EIDRM: ::c_int = 90; +pub const ENOMSG: ::c_int = 91; +pub const EILSEQ: ::c_int = 92; +pub const ENOATTR: ::c_int = 93; +pub const EBADMSG: ::c_int = 94; +pub const EMULTIHOP: ::c_int = 95; +pub const ENODATA: ::c_int = 96; +pub const ENOLINK: ::c_int = 97; +pub const ENOSR: ::c_int = 98; +pub const ENOSTR: ::c_int = 99; +pub const EPROTO: ::c_int = 100; +pub const ETIME: ::c_int = 101; +pub const EOPNOTSUPP: ::c_int = 102; +pub const ENOPOLICY: ::c_int = 103; +pub const ENOTRECOVERABLE: ::c_int = 104; +pub const EOWNERDEAD: ::c_int = 105; +pub const EQFULL: ::c_int = 106; +pub const ELAST: ::c_int = 106; + +pub const F_DUPFD: ::c_int = 0; +pub const F_GETFD: ::c_int = 1; +pub const F_SETFD: ::c_int = 2; +pub const F_GETFL: ::c_int = 3; +pub const F_SETFL: ::c_int = 4; + +pub const O_ACCMODE: ::c_int = 3; + +pub const SIGTRAP: ::c_int = 5; + +pub const GLOB_APPEND : ::c_int = 0x0001; +pub const GLOB_DOOFFS : ::c_int = 0x0002; +pub const GLOB_ERR : ::c_int = 0x0004; +pub const GLOB_MARK : ::c_int = 0x0008; +pub const GLOB_NOCHECK : ::c_int = 0x0010; +pub const GLOB_NOSORT : ::c_int = 0x0020; +pub const GLOB_NOESCAPE: ::c_int = 0x2000; + +pub const GLOB_NOSPACE : ::c_int = -1; +pub const GLOB_ABORTED : ::c_int = -2; +pub const GLOB_NOMATCH : ::c_int = -3; + +pub const POSIX_MADV_NORMAL: ::c_int = 0; +pub const POSIX_MADV_RANDOM: ::c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; + +pub const _SC_IOV_MAX: ::c_int = 56; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_MQ_PRIO_MAX: ::c_int = 75; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; +pub const _SC_THREAD_STACK_MIN: ::c_int = 93; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; +pub const _SC_THREADS: ::c_int = 96; +pub const _SC_TTY_NAME_MAX: ::c_int = 101; +pub const _SC_ATEXIT_MAX: ::c_int = 107; +pub const _SC_XOPEN_CRYPT: ::c_int = 108; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; +pub const _SC_XOPEN_LEGACY: ::c_int = 110; +pub const _SC_XOPEN_REALTIME: ::c_int = 111; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; +pub const _SC_XOPEN_SHM: ::c_int = 113; +pub const _SC_XOPEN_UNIX: ::c_int = 115; +pub const _SC_XOPEN_VERSION: ::c_int = 116; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 121; + +pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1; +pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; pub const PTHREAD_STACK_MIN: size_t = 8192; -pub const RLIMIT_CPU: c_int = 0; -pub const RLIMIT_FSIZE: c_int = 1; -pub const RLIMIT_DATA: c_int = 2; -pub const RLIMIT_STACK: c_int = 3; -pub const RLIMIT_CORE: c_int = 4; -pub const RLIMIT_AS: c_int = 5; -pub const RLIMIT_MEMLOCK: c_int = 6; -pub const RLIMIT_NPROC: c_int = 7; -pub const RLIMIT_NOFILE: c_int = 8; -pub const RLIM_NLIMITS: c_int = 9; -pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_AS: ::c_int = 5; +pub const RLIMIT_MEMLOCK: ::c_int = 6; +pub const RLIMIT_NPROC: ::c_int = 7; +pub const RLIMIT_NOFILE: ::c_int = 8; +pub const RLIM_NLIMITS: ::c_int = 9; +pub const _RLIMIT_POSIX_FLAG: ::c_int = 0x1000; pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; -pub const RUSAGE_SELF: c_int = 0; -pub const RUSAGE_CHILDREN: c_int = -1; - -pub const MADV_NORMAL: c_int = 0; -pub const MADV_RANDOM: c_int = 1; -pub const MADV_SEQUENTIAL: c_int = 2; -pub const MADV_WILLNEED: c_int = 3; -pub const MADV_DONTNEED: c_int = 4; -pub const MADV_FREE: c_int = 5; -pub const MADV_ZERO_WIRED_PAGES: c_int = 6; -pub const MADV_FREE_REUSABLE: c_int = 7; -pub const MADV_FREE_REUSE: c_int = 8; -pub const MADV_CAN_REUSE: c_int = 9; - -pub const MINCORE_INCORE: c_int = 0x1; -pub const MINCORE_REFERENCED: c_int = 0x2; -pub const MINCORE_MODIFIED: c_int = 0x4; -pub const MINCORE_REFERENCED_OTHER: c_int = 0x8; -pub const MINCORE_MODIFIED_OTHER: c_int = 0x10; - -pub const AF_UNIX: c_int = 1; -pub const AF_INET: c_int = 2; -pub const AF_INET6: c_int = 30; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; -pub const SOCK_RAW: c_int = 3; -pub const IPPROTO_TCP: c_int = 6; -pub const IPPROTO_IP: c_int = 0; -pub const IPPROTO_IPV6: c_int = 41; -pub const IP_MULTICAST_TTL: c_int = 10; -pub const IP_MULTICAST_LOOP: c_int = 11; -pub const IP_TTL: c_int = 4; -pub const IP_HDRINCL: c_int = 2; -pub const IP_ADD_MEMBERSHIP: c_int = 12; -pub const IP_DROP_MEMBERSHIP: c_int = 13; -pub const IPV6_JOIN_GROUP: c_int = 12; -pub const IPV6_LEAVE_GROUP: c_int = 13; - -pub const TCP_NODELAY: c_int = 0x01; -pub const TCP_KEEPALIVE: c_int = 0x10; -pub const SOL_SOCKET: c_int = 0xffff; - -pub const SO_DEBUG: c_int = 0x01; -pub const SO_ACCEPTCONN: c_int = 0x0002; -pub const SO_REUSEADDR: c_int = 0x0004; -pub const SO_KEEPALIVE: c_int = 0x0008; -pub const SO_DONTROUTE: c_int = 0x0010; -pub const SO_BROADCAST: c_int = 0x0020; -pub const SO_USELOOPBACK: c_int = 0x0040; -pub const SO_LINGER: c_int = 0x0080; -pub const SO_OOBINLINE: c_int = 0x0100; -pub const SO_REUSEPORT: c_int = 0x0200; -pub const SO_SNDBUF: c_int = 0x1001; -pub const SO_RCVBUF: c_int = 0x1002; -pub const SO_SNDLOWAT: c_int = 0x1003; -pub const SO_RCVLOWAT: c_int = 0x1004; -pub const SO_SNDTIMEO: c_int = 0x1005; -pub const SO_RCVTIMEO: c_int = 0x1006; -pub const SO_ERROR: c_int = 0x1007; -pub const SO_TYPE: c_int = 0x1008; - -pub const IFF_LOOPBACK: c_int = 0x8; - -pub const SHUT_RD: c_int = 0; -pub const SHUT_WR: c_int = 1; -pub const SHUT_RDWR: c_int = 2; - -pub const LOCK_SH: c_int = 1; -pub const LOCK_EX: c_int = 2; -pub const LOCK_NB: c_int = 4; -pub const LOCK_UN: c_int = 8; - -pub const O_DSYNC: c_int = 4194304; -pub const O_SYNC: c_int = 128; -pub const O_NONBLOCK: c_int = 4; -pub const F_GETPATH: c_int = 50; -pub const F_FULLFSYNC: c_int = 51; - -pub const MAP_COPY: c_int = 0x0002; -pub const MAP_RENAME: c_int = 0x0020; -pub const MAP_NORESERVE: c_int = 0x0040; -pub const MAP_NOEXTEND: c_int = 0x0100; -pub const MAP_HASSEMAPHORE: c_int = 0x0200; -pub const MAP_NOCACHE: c_int = 0x0400; -pub const MAP_JIT: c_int = 0x0800; - -pub const IPPROTO_RAW: c_int = 255; - -pub const SO_NREAD: c_int = 0x1020; -pub const SO_NKE: c_int = 0x1021; -pub const SO_NOSIGPIPE: c_int = 0x1022; -pub const SO_NOADDRERR: c_int = 0x1023; -pub const SO_NWRITE: c_int = 0x1024; -pub const SO_DONTTRUNC: c_int = 0x2000; -pub const SO_WANTMORE: c_int = 0x4000; -pub const SO_WANTOOBFLAG: c_int = 0x8000; - -pub const PATH_MAX: c_int = 1024; - -pub const _SC_ARG_MAX: c_int = 1; -pub const _SC_CHILD_MAX: c_int = 2; -pub const _SC_CLK_TCK: c_int = 3; -pub const _SC_NGROUPS_MAX: c_int = 4; -pub const _SC_OPEN_MAX: c_int = 5; -pub const _SC_JOB_CONTROL: c_int = 6; -pub const _SC_SAVED_IDS: c_int = 7; -pub const _SC_VERSION: c_int = 8; -pub const _SC_BC_BASE_MAX: c_int = 9; -pub const _SC_BC_DIM_MAX: c_int = 10; -pub const _SC_BC_SCALE_MAX: c_int = 11; -pub const _SC_BC_STRING_MAX: c_int = 12; -pub const _SC_COLL_WEIGHTS_MAX: c_int = 13; -pub const _SC_EXPR_NEST_MAX: c_int = 14; -pub const _SC_LINE_MAX: c_int = 15; -pub const _SC_RE_DUP_MAX: c_int = 16; -pub const _SC_2_VERSION: c_int = 17; -pub const _SC_2_C_BIND: c_int = 18; -pub const _SC_2_C_DEV: c_int = 19; -pub const _SC_2_CHAR_TERM: c_int = 20; -pub const _SC_2_FORT_DEV: c_int = 21; -pub const _SC_2_FORT_RUN: c_int = 22; -pub const _SC_2_LOCALEDEF: c_int = 23; -pub const _SC_2_SW_DEV: c_int = 24; -pub const _SC_2_UPE: c_int = 25; -pub const _SC_STREAM_MAX: c_int = 26; -pub const _SC_TZNAME_MAX: c_int = 27; -pub const _SC_ASYNCHRONOUS_IO: c_int = 28; -pub const _SC_PAGESIZE: c_int = 29; -pub const _SC_MEMLOCK: c_int = 30; -pub const _SC_MEMLOCK_RANGE: c_int = 31; -pub const _SC_MEMORY_PROTECTION: c_int = 32; -pub const _SC_MESSAGE_PASSING: c_int = 33; -pub const _SC_PRIORITIZED_IO: c_int = 34; -pub const _SC_PRIORITY_SCHEDULING: c_int = 35; -pub const _SC_REALTIME_SIGNALS: c_int = 36; -pub const _SC_SEMAPHORES: c_int = 37; -pub const _SC_FSYNC: c_int = 38; -pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 39; -pub const _SC_SYNCHRONIZED_IO: c_int = 40; -pub const _SC_TIMERS: c_int = 41; -pub const _SC_AIO_LISTIO_MAX: c_int = 42; -pub const _SC_AIO_MAX: c_int = 43; -pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44; -pub const _SC_DELAYTIMER_MAX: c_int = 45; -pub const _SC_MQ_OPEN_MAX: c_int = 46; -pub const _SC_MAPPED_FILES: c_int = 47; -pub const _SC_RTSIG_MAX: c_int = 48; -pub const _SC_SEM_NSEMS_MAX: c_int = 49; -pub const _SC_SEM_VALUE_MAX: c_int = 50; -pub const _SC_SIGQUEUE_MAX: c_int = 51; -pub const _SC_TIMER_MAX: c_int = 52; -pub const _SC_NPROCESSORS_CONF: c_int = 57; -pub const _SC_NPROCESSORS_ONLN: c_int = 58; -pub const _SC_2_PBS: c_int = 59; -pub const _SC_2_PBS_ACCOUNTING: c_int = 60; -pub const _SC_2_PBS_CHECKPOINT: c_int = 61; -pub const _SC_2_PBS_LOCATE: c_int = 62; -pub const _SC_2_PBS_MESSAGE: c_int = 63; -pub const _SC_2_PBS_TRACK: c_int = 64; -pub const _SC_ADVISORY_INFO: c_int = 65; -pub const _SC_BARRIERS: c_int = 66; -pub const _SC_CLOCK_SELECTION: c_int = 67; -pub const _SC_CPUTIME: c_int = 68; -pub const _SC_FILE_LOCKING: c_int = 69; -pub const _SC_HOST_NAME_MAX: c_int = 72; -pub const _SC_MONOTONIC_CLOCK: c_int = 74; -pub const _SC_READER_WRITER_LOCKS: c_int = 76; -pub const _SC_REGEXP: c_int = 77; -pub const _SC_SHELL: c_int = 78; -pub const _SC_SPAWN: c_int = 79; -pub const _SC_SPIN_LOCKS: c_int = 80; -pub const _SC_SPORADIC_SERVER: c_int = 81; -pub const _SC_THREAD_CPUTIME: c_int = 84; -pub const _SC_THREAD_SPORADIC_SERVER: c_int = 92; -pub const _SC_TIMEOUTS: c_int = 95; -pub const _SC_TRACE: c_int = 97; -pub const _SC_TRACE_EVENT_FILTER: c_int = 98; -pub const _SC_TRACE_INHERIT: c_int = 99; -pub const _SC_TRACE_LOG: c_int = 100; -pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 102; -pub const _SC_V6_ILP32_OFF32: c_int = 103; -pub const _SC_V6_ILP32_OFFBIG: c_int = 104; -pub const _SC_V6_LP64_OFF64: c_int = 105; -pub const _SC_V6_LPBIG_OFFBIG: c_int = 106; -pub const _SC_IPV6: c_int = 118; -pub const _SC_RAW_SOCKETS: c_int = 119; -pub const _SC_SYMLOOP_MAX: c_int = 120; -pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; -pub const _SC_XOPEN_STREAMS: c_int = 114; -pub const _SC_XBS5_ILP32_OFF32: c_int = 122; -pub const _SC_XBS5_ILP32_OFFBIG: c_int = 123; -pub const _SC_XBS5_LP64_OFF64: c_int = 124; -pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 125; -pub const _SC_SS_REPL_MAX: c_int = 126; -pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 127; -pub const _SC_TRACE_NAME_MAX: c_int = 128; -pub const _SC_TRACE_SYS_MAX: c_int = 129; -pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130; -pub const _SC_PASS_MAX: c_int = 131; +pub const RUSAGE_SELF: ::c_int = 0; +pub const RUSAGE_CHILDREN: ::c_int = -1; + +pub const MADV_NORMAL: ::c_int = 0; +pub const MADV_RANDOM: ::c_int = 1; +pub const MADV_SEQUENTIAL: ::c_int = 2; +pub const MADV_WILLNEED: ::c_int = 3; +pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 5; +pub const MADV_ZERO_WIRED_PAGES: ::c_int = 6; +pub const MADV_FREE_REUSABLE: ::c_int = 7; +pub const MADV_FREE_REUSE: ::c_int = 8; +pub const MADV_CAN_REUSE: ::c_int = 9; + +pub const MINCORE_INCORE: ::c_int = 0x1; +pub const MINCORE_REFERENCED: ::c_int = 0x2; +pub const MINCORE_MODIFIED: ::c_int = 0x4; +pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; +pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; + +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET: ::c_int = 2; +pub const AF_INET6: ::c_int = 30; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; +pub const IPPROTO_TCP: ::c_int = 6; +pub const IPPROTO_IP: ::c_int = 0; +pub const IPPROTO_IPV6: ::c_int = 41; +pub const IP_MULTICAST_TTL: ::c_int = 10; +pub const IP_MULTICAST_LOOP: ::c_int = 11; +pub const IP_TTL: ::c_int = 4; +pub const IP_HDRINCL: ::c_int = 2; +pub const IP_ADD_MEMBERSHIP: ::c_int = 12; +pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; + +pub const TCP_NODELAY: ::c_int = 0x01; +pub const TCP_KEEPALIVE: ::c_int = 0x10; +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_DEBUG: ::c_int = 0x01; +pub const SO_ACCEPTCONN: ::c_int = 0x0002; +pub const SO_REUSEADDR: ::c_int = 0x0004; +pub const SO_KEEPALIVE: ::c_int = 0x0008; +pub const SO_DONTROUTE: ::c_int = 0x0010; +pub const SO_BROADCAST: ::c_int = 0x0020; +pub const SO_USELOOPBACK: ::c_int = 0x0040; +pub const SO_LINGER: ::c_int = 0x0080; +pub const SO_OOBINLINE: ::c_int = 0x0100; +pub const SO_REUSEPORT: ::c_int = 0x0200; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDLOWAT: ::c_int = 0x1003; +pub const SO_RCVLOWAT: ::c_int = 0x1004; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_TYPE: ::c_int = 0x1008; + +pub const IFF_LOOPBACK: ::c_int = 0x8; + +pub const SHUT_RD: ::c_int = 0; +pub const SHUT_WR: ::c_int = 1; +pub const SHUT_RDWR: ::c_int = 2; + +pub const LOCK_SH: ::c_int = 1; +pub const LOCK_EX: ::c_int = 2; +pub const LOCK_NB: ::c_int = 4; +pub const LOCK_UN: ::c_int = 8; + +pub const O_DSYNC: ::c_int = 4194304; +pub const O_SYNC: ::c_int = 128; +pub const O_NONBLOCK: ::c_int = 4; +pub const F_GETPATH: ::c_int = 50; +pub const F_FULLFSYNC: ::c_int = 51; + +pub const MAP_COPY: ::c_int = 0x0002; +pub const MAP_RENAME: ::c_int = 0x0020; +pub const MAP_NORESERVE: ::c_int = 0x0040; +pub const MAP_NOEXTEND: ::c_int = 0x0100; +pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; +pub const MAP_NOCACHE: ::c_int = 0x0400; +pub const MAP_JIT: ::c_int = 0x0800; + +pub const IPPROTO_RAW: ::c_int = 255; + +pub const SO_NREAD: ::c_int = 0x1020; +pub const SO_NKE: ::c_int = 0x1021; +pub const SO_NOSIGPIPE: ::c_int = 0x1022; +pub const SO_NOADDRERR: ::c_int = 0x1023; +pub const SO_NWRITE: ::c_int = 0x1024; +pub const SO_DONTTRUNC: ::c_int = 0x2000; +pub const SO_WANTMORE: ::c_int = 0x4000; +pub const SO_WANTOOBFLAG: ::c_int = 0x8000; + +pub const PATH_MAX: ::c_int = 1024; + +pub const _SC_ARG_MAX: ::c_int = 1; +pub const _SC_CHILD_MAX: ::c_int = 2; +pub const _SC_CLK_TCK: ::c_int = 3; +pub const _SC_NGROUPS_MAX: ::c_int = 4; +pub const _SC_OPEN_MAX: ::c_int = 5; +pub const _SC_JOB_CONTROL: ::c_int = 6; +pub const _SC_SAVED_IDS: ::c_int = 7; +pub const _SC_VERSION: ::c_int = 8; +pub const _SC_BC_BASE_MAX: ::c_int = 9; +pub const _SC_BC_DIM_MAX: ::c_int = 10; +pub const _SC_BC_SCALE_MAX: ::c_int = 11; +pub const _SC_BC_STRING_MAX: ::c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; +pub const _SC_EXPR_NEST_MAX: ::c_int = 14; +pub const _SC_LINE_MAX: ::c_int = 15; +pub const _SC_RE_DUP_MAX: ::c_int = 16; +pub const _SC_2_VERSION: ::c_int = 17; +pub const _SC_2_C_BIND: ::c_int = 18; +pub const _SC_2_C_DEV: ::c_int = 19; +pub const _SC_2_CHAR_TERM: ::c_int = 20; +pub const _SC_2_FORT_DEV: ::c_int = 21; +pub const _SC_2_FORT_RUN: ::c_int = 22; +pub const _SC_2_LOCALEDEF: ::c_int = 23; +pub const _SC_2_SW_DEV: ::c_int = 24; +pub const _SC_2_UPE: ::c_int = 25; +pub const _SC_STREAM_MAX: ::c_int = 26; +pub const _SC_TZNAME_MAX: ::c_int = 27; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; +pub const _SC_PAGESIZE: ::c_int = 29; +pub const _SC_MEMLOCK: ::c_int = 30; +pub const _SC_MEMLOCK_RANGE: ::c_int = 31; +pub const _SC_MEMORY_PROTECTION: ::c_int = 32; +pub const _SC_MESSAGE_PASSING: ::c_int = 33; +pub const _SC_PRIORITIZED_IO: ::c_int = 34; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; +pub const _SC_REALTIME_SIGNALS: ::c_int = 36; +pub const _SC_SEMAPHORES: ::c_int = 37; +pub const _SC_FSYNC: ::c_int = 38; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; +pub const _SC_TIMERS: ::c_int = 41; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; +pub const _SC_AIO_MAX: ::c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; +pub const _SC_DELAYTIMER_MAX: ::c_int = 45; +pub const _SC_MQ_OPEN_MAX: ::c_int = 46; +pub const _SC_MAPPED_FILES: ::c_int = 47; +pub const _SC_RTSIG_MAX: ::c_int = 48; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; +pub const _SC_SEM_VALUE_MAX: ::c_int = 50; +pub const _SC_SIGQUEUE_MAX: ::c_int = 51; +pub const _SC_TIMER_MAX: ::c_int = 52; +pub const _SC_NPROCESSORS_CONF: ::c_int = 57; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 58; +pub const _SC_2_PBS: ::c_int = 59; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61; +pub const _SC_2_PBS_LOCATE: ::c_int = 62; +pub const _SC_2_PBS_MESSAGE: ::c_int = 63; +pub const _SC_2_PBS_TRACK: ::c_int = 64; +pub const _SC_ADVISORY_INFO: ::c_int = 65; +pub const _SC_BARRIERS: ::c_int = 66; +pub const _SC_CLOCK_SELECTION: ::c_int = 67; +pub const _SC_CPUTIME: ::c_int = 68; +pub const _SC_FILE_LOCKING: ::c_int = 69; +pub const _SC_HOST_NAME_MAX: ::c_int = 72; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 74; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 76; +pub const _SC_REGEXP: ::c_int = 77; +pub const _SC_SHELL: ::c_int = 78; +pub const _SC_SPAWN: ::c_int = 79; +pub const _SC_SPIN_LOCKS: ::c_int = 80; +pub const _SC_SPORADIC_SERVER: ::c_int = 81; +pub const _SC_THREAD_CPUTIME: ::c_int = 84; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92; +pub const _SC_TIMEOUTS: ::c_int = 95; +pub const _SC_TRACE: ::c_int = 97; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98; +pub const _SC_TRACE_INHERIT: ::c_int = 99; +pub const _SC_TRACE_LOG: ::c_int = 100; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102; +pub const _SC_V6_ILP32_OFF32: ::c_int = 103; +pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104; +pub const _SC_V6_LP64_OFF64: ::c_int = 105; +pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106; +pub const _SC_IPV6: ::c_int = 118; +pub const _SC_RAW_SOCKETS: ::c_int = 119; +pub const _SC_SYMLOOP_MAX: ::c_int = 120; +pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; +pub const _SC_XOPEN_STREAMS: ::c_int = 114; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 122; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 123; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 124; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 125; +pub const _SC_SS_REPL_MAX: ::c_int = 126; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 127; +pub const _SC_TRACE_NAME_MAX: ::c_int = 128; +pub const _SC_TRACE_SYS_MAX: ::c_int = 129; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 130; +pub const _SC_PASS_MAX: ::c_int = 131; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7; @@ -628,9 +628,9 @@ pub const SIGSTKSZ: ::size_t = 131072; extern { pub fn _NSGetExecutablePath(buf: *mut ::c_char, bufsize: *mut ::uint32_t) -> ::c_int; - pub fn _NSGetArgc() -> *mut c_int; - pub fn _NSGetArgv() -> *mut *mut *mut c_char; - pub fn _NSGetEnviron() -> *mut *mut *mut c_char; + pub fn _NSGetArgc() -> *mut ::c_int; + pub fn _NSGetArgv() -> *mut *mut *mut ::c_char; + pub fn _NSGetEnviron() -> *mut *mut *mut ::c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) @@ -652,8 +652,8 @@ extern { pub fn mach_absolute_time() -> u64; pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; - pub fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut ::c_void; - pub fn pthread_get_stacksize_np(thread: pthread_t) -> ::size_t; + pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void; + pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t; pub fn __error() -> *mut ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; From a7600612270d7d1c9b8555ccf56f4ed580106845 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 17:10:40 -0700 Subject: [PATCH 167/194] Add sample OpenBSD VM --- ci/Vagrantfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/Vagrantfile b/ci/Vagrantfile index a55aa3ebea42d..caa11a85d2eaf 100644 --- a/ci/Vagrantfile +++ b/ci/Vagrantfile @@ -19,6 +19,8 @@ Vagrant.configure(2) do |config| # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. + config.vm.synced_folder "..", "/vagrant" + config.vm.define :freebsd do |bsd| bsd.vm.box = "arkadi/freebsd-10.1-amd64" bsd.vm.provision :shell, inline: 'yes | sudo pkg install rust cargo' @@ -26,5 +28,11 @@ Vagrant.configure(2) do |config| vb.memory = "2048" end end - config.vm.synced_folder "..", "/vagrant" + + config.vm.define :openbsd do |bsd| + bsd.vm.box = "bodgit/openbsd-5.7-amd64" + bsd.vm.provider "virtualbox" do |vb| + vb.memory = "2048" + end + end end From babf390fcfa42e1cd8c1767d01337daf2b3eb7d3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 17:16:51 -0700 Subject: [PATCH 168/194] Add some IPv6 options --- src/unix/bsd/mod.rs | 3 +++ src/unix/notbsd/mod.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 216c68852caa8..3b8c4fb8f587a 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -72,6 +72,9 @@ pub const SA_SIGINFO: ::c_int = 0x0040; pub const SIGBUS: ::c_int = 10; pub const SIG_SETMASK: ::c_int = 3; +pub const IPV6_MULTICAST_LOOP: ::c_int = 11; +pub const IPV6_V6ONLY: ::c_int = 27; + extern { pub fn mincore(addr: *const ::c_void, len: size_t, vec: *mut c_char) -> ::c_int; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index b0f74215526ba..cd7547ccef92c 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -271,6 +271,9 @@ pub const TCP_INFO: ::c_int = 11; pub const TCP_QUICKACK: ::c_int = 12; pub const TCP_CONGESTION: ::c_int = 13; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_V6ONLY: ::c_int = 26; + pub const SO_DEBUG: ::c_int = 1; pub const SHUT_RD: ::c_int = 0; From 2536b35aa8801082e51c96f950c75963f0f6bfd8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 17:20:26 -0700 Subject: [PATCH 169/194] OK, apparently MIPS can run now? --- ci/run.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 22146f28752b3..04e49cacc3188 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -16,9 +16,7 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/libc-test elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then - # FIXME: this segfaults on travis, passes locally? qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/libc-test - echo skip elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then qemu-aarch64 -L /usr/aarch64-linux-gnu/ libc-test/target/$TARGET/debug/libc-test else From 22f3c5e1a74103777bde9fc244063451da3c3a78 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 17:30:58 -0700 Subject: [PATCH 170/194] Use a switch instead of if/else --- ci/run-travis.sh | 126 ++++++++++++++++++++++------------------------- ci/run.sh | 25 +++++++--- 2 files changed, 76 insertions(+), 75 deletions(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index ede2e4855fd7d..0bebd4245140a 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -20,75 +20,65 @@ install() { sudo apt-get install $@ } -# NOTE: this is not actually run on travis right now, this was added to in -# theory run FreeBSD vagrant images on Travis, but it ended up not working, so -# this may not be working when you read this. -install_vagrant() { - echo 'deb http://download.virtualbox.org/virtualbox/debian trusty contrib' | \ - sudo tee -a /etc/apt/sources.list - vbox=virtualbox-5.0_5.0.4-102546~Ubuntu~trusty_amd64.deb - curl https://www.virtualbox.org/download/oracle_vbox.asc | sudo apt-key add - - install virtualbox-5.0 linux-headers-3.16.0-31-generic nfs-kernel-server - - # After we've got virtualbox, install vagrant itself. Note that the version in - # the default ubuntu repos is too old to run the images we have, so install - # the one from the vagrant website's download link - curl -LO https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.4_x86_64.deb - sudo dpkg -i vagrant_1.7.4_x86_64.deb -} - -if [ "$TARGET" = "arm-linux-androideabi" ]; then +case "$TARGET" in # Pull a pre-built docker image for testing android, then run tests entirely - # within that image. - docker pull alexcrichton/rust-libc-test - exec docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test \ - sh ci/run.sh $TARGET -elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - install musl-tools - export CC=musl-gcc -elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - install gcc-4.7-arm-linux-gnueabihf qemu-user - export CC=arm-linux-gnueabihf-gcc-4.7 -elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - install gcc-aarch64-linux-gnu qemu-user - export CC=aarch64-linux-gnu-gcc -elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then - # Download pre-built and custom MIPS libs and then also instsall the MIPS - # compiler according to this post: - # http://sathisharada.blogspot.com/2014_10_01_archive.html - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - - echo 'deb http://ftp.de.debian.org/debian squeeze main' | \ - sudo tee -a /etc/apt/sources.list - echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ - sudo tee -a /etc/apt/sources.list - install emdebian-archive-keyring - install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes - export CC=mips-linux-gnu-gcc -elif [ "$TARGET" = "x86_64-unknown-freebsd" ]; then - install_vagrant - cd ci - vagrant up freebsd - exec vagrant ssh freebsd -c \ - 'cd /vagrant && CARGO_TARGET_DIR=/tmp sh ci/run.sh x86_64-unknown-freebsd' -else - # Download the rustlib folder from the relevant portion of main distribution's - # tarballs. - curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ - tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ - rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST - TARGET=$HOST - - # clang has better error messages and implements alignof more broadly - export CC=clang - - if [ "$TARGET" = "i686-unknown-linux-gnu" ]; then - install gcc-multilib - fi -fi + #d within that image. + arm-linux-androideabi) + docker pull alexcrichton/rust-libc-test + exec docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test \ + sh ci/run.sh $TARGET + ;; + + x86_64-unknown-linux-musl) + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + install musl-tools + export CC=musl-gcc + ;; + + arm-unknown-linux-gnueabihf) + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + install gcc-4.7-arm-linux-gnueabihf qemu-user + export CC=arm-linux-gnueabihf-gcc-4.7 + ;; + + aarch64-unknown-linux-gnu) + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + install gcc-aarch64-linux-gnu qemu-user + export CC=aarch64-linux-gnu-gcc + ;; + + mips-unknown-linux-gnu) + # Download pre-built and custom MIPS libs and then also instsall the MIPS + # compiler according to this post: + # http://sathisharada.blogspot.com/2014_10_01_archive.html + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + + echo 'deb http://ftp.de.debian.org/debian squeeze main' | \ + sudo tee -a /etc/apt/sources.list + echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ + sudo tee -a /etc/apt/sources.list + install emdebian-archive-keyring + install qemu-user gcc-4.4-mips-linux-gnu -y --force-yes + export CC=mips-linux-gnu-gcc + ;; + + *) + # Download the rustlib folder from the relevant portion of main distribution's + # tarballs. + curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ + tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ + rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST + TARGET=$HOST + + # clang has better error messages and implements alignof more broadly + export CC=clang + + if [ "$TARGET" = "i686-unknown-linux-gnu" ]; then + install gcc-multilib + fi + ;; + +esac mkdir .cargo cp ci/cargo-config .cargo/config diff --git a/ci/run.sh b/ci/run.sh index 04e49cacc3188..b0d4726f70391 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -8,17 +8,28 @@ set -ex TARGET=$1 cargo build --manifest-path libc-test/Cargo.toml --target $TARGET -if [ "$TARGET" = "arm-linux-androideabi" ]; then +case "$TARGET" in + arm-linux-androideabi) emulator @test -no-window & adb wait-for-device adb push /root/target/$TARGET/debug/libc-test /data/libc-test adb shell /data/libc-test -elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then + ;; + + arm-unknown-linux-gnueabihf) qemu-arm -L /usr/arm-linux-gnueabihf libc-test/target/$TARGET/debug/libc-test -elif [ "$TARGET" = "mips-unknown-linux-gnu" ]; then + ;; + + mips-unknown-linux-gnu) qemu-mips -L /usr/mips-linux-gnu libc-test/target/$TARGET/debug/libc-test -elif [ "$TARGET" = "aarch64-unknown-linux-gnu" ]; then - qemu-aarch64 -L /usr/aarch64-linux-gnu/ libc-test/target/$TARGET/debug/libc-test -else + ;; + + aarch64-unknown-linux-gnu) + qemu-aarch64 -L /usr/aarch64-linux-gnu/ \ + libc-test/target/$TARGET/debug/libc-test + ;; + + *) cargo run --manifest-path libc-test/Cargo.toml --target $TARGET -fi + ;; +esac From 32dc2279e039024e8b382aa661fb79e11278cd46 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 17:54:12 -0700 Subject: [PATCH 171/194] add a script to run everything locally --- ci/run-all.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ci/run-all.sh diff --git a/ci/run-all.sh b/ci/run-all.sh new file mode 100644 index 0000000000000..a66788fde677e --- /dev/null +++ b/ci/run-all.sh @@ -0,0 +1,45 @@ +# This is **not** meant to be run on CI, but rather locally instead. If you're +# on a Linux machine you'll be able to run most of these, but otherwise this'll +# just attempt to run as many platforms as possible! + +run() { + _target=$1 + _cc=$2 + if [ "$_cc" != "" ]; then + which $_cc > /dev/null + if [ $? -ne 0 ]; then + echo "$_cc not installed, skipping $_target" + return + fi + export CC=$_cc + fi + if [ ! -d .cargo ]; then + mkdir .cargo + cp ci/cargo-config .cargo/config + fi + sh ci/run.sh $_target +} + +OS=`uname` +if [ "$OS" = "Linux" ]; then + # For more info on where to get all these cross compilers see + # ci/run-travis.sh and what packages are needed on ubuntu + run x86_64-unknown-linux-gnu clang + run i686-unknown-linux-gnu clang + run x86_64-unknown-linux-musl musl-gcc + run mips-unknown-linux-gnu mips-linux-gnu-gcc + run aarch64-unknown-linux-gnu aarch64-linux-gnueabihf-gcc + run arm-unknown-linux-gnueabihf arm-linux-gnueabihf-gcc-4.7 + + # Prep for this by running `vagrant up freebsd` in the `ci` directory + (cd ci && vagrant ssh freebsd -c \ + "cd /vagrant && sh ci/run.sh x86_64-unknown-freebsd") + + # Make sure you've run `docker pull alexcrichton/rust-libc-test` to get + # this image ahead of time. + docker run -itv `pwd`:/clone alexcrichton/rust-libc-test \ + sh ci/run.sh arm-linux-androideabi +elif [ "$OS" = "Darwin" ]; then + cargo run --target x86_64-unknown-linux-gnu + cargo run --target i686-unknown-linux-gnu +fi From d3bbec41912d0b2afdd05567452591e511c57e5b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Sep 2015 18:51:25 -0700 Subject: [PATCH 172/194] Ignore .cargo --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a9d37c560c6ab..3d61e5b48f598 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target Cargo.lock +/.cargo From 9cb16341641db61a5e520172deac18a269e88d5a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Sep 2015 13:37:36 -0700 Subject: [PATCH 173/194] Move to master branch --- .travis.yml | 2 +- appveyor.yml | 2 +- ci/Vagrantfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e34b284cd9582..f58a60e4e1cf6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,4 +39,4 @@ notifications: on_success: never branches: only: - - autotest + - master diff --git a/appveyor.yml b/appveyor.yml index 1412f909cd30b..c2d28e4445e34 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,4 +29,4 @@ test_script: branches: only: - - autotest + - master diff --git a/ci/Vagrantfile b/ci/Vagrantfile index caa11a85d2eaf..70cfcf3284195 100644 --- a/ci/Vagrantfile +++ b/ci/Vagrantfile @@ -4,7 +4,7 @@ # Travis, but it didn't work out. Regardless this has stuck around! You can run # tests in FreeBSD via: # -# git clone https://github.com/alexcrichton/libc --branch autotest +# git clone https://github.com/alexcrichton/libc # cd libc/ci # vagrant up freebsd # vagrant ssh freebsd From c4d4c70a36f82186f259fb6816b0b87997633940 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Sep 2015 13:36:54 -0700 Subject: [PATCH 174/194] Slim down Windows bindings --- src/windows.rs | 774 +------------------------------------------------ 1 file changed, 3 insertions(+), 771 deletions(-) diff --git a/src/windows.rs b/src/windows.rs index 48dd0698a871e..e69d682d407a0 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -24,14 +24,12 @@ cfg_if! { pub type size_t = u32; pub type ssize_t = i32; pub type uintptr_t = u32; - pub type LONG_PTR = c_long; } else if #[cfg(target_arch = "x86_64")] { pub type intptr_t = i64; pub type ptrdiff_t = i64; pub type size_t = u64; pub type ssize_t = i64; pub type uintptr_t = u64; - pub type LONG_PTR = i64; } else { // unknown arch } @@ -53,60 +51,6 @@ pub type ino_t = u16; pub enum timezone {} pub type time64_t = i64; -pub type BOOL = c_int; -pub type BYTE = u8; -pub type BOOLEAN = BYTE; -pub type CCHAR = c_char; -pub type CHAR = c_char; -pub type DWORD = c_ulong; -pub type DWORD_PTR = ULONG_PTR; -pub type DWORDLONG = c_ulonglong; -pub type HANDLE = LPVOID; -pub type HINSTANCE = HANDLE; -pub type HMODULE = HINSTANCE; -pub type LONG = c_long; -pub type PLONG = *mut c_long; -pub type LARGE_INTEGER = c_longlong; -pub type PLARGE_INTEGER = *mut c_longlong; -pub type LPCWSTR = *const WCHAR; -pub type LPCSTR = *const CHAR; -pub type LPWSTR = *mut WCHAR; -pub type LPSTR = *mut CHAR; -pub type LPWCH = *mut WCHAR; -pub type LPCH = *mut CHAR; -pub type SOCKET = uintptr_t; -pub type LPSECURITY_ATTRIBUTES = *mut SECURITY_ATTRIBUTES; -pub type LPVOID = *mut ::c_void; -pub type LPCVOID = *const ::c_void; -pub type LPBYTE = *mut BYTE; -pub type LPWORD = *mut WORD; -pub type LPDWORD = *mut DWORD; -pub type LPHANDLE = *mut HANDLE; -pub type LRESULT = LONG_PTR; -pub type PBOOL = *mut BOOL; -pub type WCHAR = wchar_t; -pub type WORD = u16; -pub type SIZE_T = size_t; -pub type GROUP = c_uint; -pub type LPSTARTUPINFOW = *mut STARTUPINFOW; -pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION; -pub type LPSYSTEM_INFO = *mut SYSTEM_INFO; -pub type PMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION; -pub type LPOVERLAPPED = *mut OVERLAPPED; -pub type LPFILETIME = *mut FILETIME; -pub type LPWSAPROTOCOL_INFO = *mut WSAPROTOCOL_INFO; -pub type LPWIN32_FIND_DATAW = *mut WIN32_FIND_DATAW; -pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN; -pub type UCHAR = c_uchar; -pub type ULONG = c_ulong; -cfg_if! { - if #[cfg(target_arch = "x86_64")] { - pub type ULONG_PTR = u64; - } else { - pub type ULONG_PTR = c_ulong; - } -} - s! { // note this is the struct called stat64 in Windows. Not stat, nor stati64. pub struct stat { @@ -138,194 +82,6 @@ s! { pub tv_sec: time_t, pub tv_nsec: c_long, } - - pub struct sockaddr { - pub sa_family: u16, - pub sa_data: [CHAR; 14], - } - - pub struct sockaddr_storage { - #[cfg(target_env = "msvc")] - pub ss_family: c_ushort, - #[cfg(not(target_env = "msvc"))] - pub ss_family: c_short, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - - pub struct sockaddr_in { - #[cfg(target_env = "msvc")] - pub sin_family: c_ushort, - #[cfg(not(target_env = "msvc"))] - pub sin_family: c_short, - pub sin_port: u16, - pub sin_addr: in_addr, - pub sin_zero: [CHAR; 8], - } - - pub struct in_addr { - pub s_addr: ULONG, - } - - pub struct sockaddr_in6 { - #[cfg(target_env = "msvc")] - pub sin6_family: c_ushort, - #[cfg(not(target_env = "msvc"))] - pub sin6_family: c_short, - pub sin6_port: u16, - pub sin6_flowinfo: ULONG, - pub sin6_addr: in6_addr, - pub sin6_scope_id: ULONG, - } - - pub struct in6_addr { - pub s6_addr: [UCHAR; 16], - _align: [u16; 0], - } - - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - #[cfg(target_env = "msvc")] - pub ipv6mr_interface: ULONG, - #[cfg(not(target_env = "msvc"))] - pub ipv6mr_interface: c_uint, - } - - pub struct addrinfo { - pub ai_flags: c_int, - pub ai_family: c_int, - pub ai_socktype: c_int, - pub ai_protocol: c_int, - pub ai_addrlen: size_t, - pub ai_canonname: *mut c_char, - pub ai_addr: *mut sockaddr, - pub ai_next: *mut addrinfo, - } - - pub struct SECURITY_ATTRIBUTES { - pub nLength: DWORD, - pub lpSecurityDescriptor: LPVOID, - pub bInheritHandle: BOOL, - } - - pub struct STARTUPINFOW { - pub cb: DWORD, - pub lpReserved: LPWSTR, - pub lpDesktop: LPWSTR, - pub lpTitle: LPWSTR, - pub dwX: DWORD, - pub dwY: DWORD, - pub dwXSize: DWORD, - pub dwYSize: DWORD, - pub dwXCountChars: DWORD, - pub dwYCountChars: DWORD, - pub dwFillAttribute: DWORD, - pub dwFlags: DWORD, - pub wShowWindow: WORD, - pub cbReserved2: WORD, - pub lpReserved2: LPBYTE, - pub hStdInput: HANDLE, - pub hStdOutput: HANDLE, - pub hStdError: HANDLE, - } - - pub struct PROCESS_INFORMATION { - pub hProcess: HANDLE, - pub hThread: HANDLE, - pub dwProcessId: DWORD, - pub dwThreadId: DWORD, - } - - pub struct SYSTEM_INFO { - pub wProcessorArchitecture: WORD, - pub wReserved: WORD, - pub dwPageSize: DWORD, - pub lpMinimumApplicationAddress: LPVOID, - pub lpMaximumApplicationAddress: LPVOID, - pub dwActiveProcessorMask: DWORD_PTR, - pub dwNumberOfProcessors: DWORD, - pub dwProcessorType: DWORD, - pub dwAllocationGranularity: DWORD, - pub wProcessorLevel: WORD, - pub wProcessorRevision: WORD, - } - - pub struct MEMORY_BASIC_INFORMATION { - pub BaseAddress: LPVOID, - pub AllocationBase: LPVOID, - pub AllocationProtect: DWORD, - pub RegionSize: SIZE_T, - pub State: DWORD, - pub Protect: DWORD, - pub Type: DWORD, - } - - pub struct OVERLAPPED { - pub Internal: ULONG_PTR, - pub InternalHigh: ULONG_PTR, - pub Offset: DWORD, - pub OffsetHigh: DWORD, - pub hEvent: HANDLE, - } - - pub struct FILETIME { - pub dwLowDateTime: DWORD, - pub dwHighDateTime: DWORD, - } - - pub struct GUID { - pub Data1: DWORD, - pub Data2: WORD, - pub Data3: WORD, - pub Data4: [BYTE; 8], - } - - pub struct WSAPROTOCOLCHAIN { - pub ChainLen: c_int, - pub ChainEntries: [DWORD; 7], - } - - pub struct WSAPROTOCOL_INFO { - pub dwServiceFlags1: DWORD, - pub dwServiceFlags2: DWORD, - pub dwServiceFlags3: DWORD, - pub dwServiceFlags4: DWORD, - pub dwProviderFlags: DWORD, - pub ProviderId: GUID, - pub dwCatalogEntryId: DWORD, - pub ProtocolChain: WSAPROTOCOLCHAIN, - pub iVersion: c_int, - pub iAddressFamily: c_int, - pub iMaxSockAddr: c_int, - pub iMinSockAddr: c_int, - pub iSocketType: c_int, - pub iProtocol: c_int, - pub iProtocolMaxOffset: c_int, - pub iNetworkByteOrder: c_int, - pub iSecurityScheme: c_int, - pub dwMessageSize: DWORD, - pub dwProviderReserved: DWORD, - pub szProtocol: [CHAR; 256], - } - - pub struct WIN32_FIND_DATAW { - pub dwFileAttributes: DWORD, - pub ftCreationTime: FILETIME, - pub ftLastAccessTime: FILETIME, - pub ftLastWriteTime: FILETIME, - pub nFileSizeHigh: DWORD, - pub nFileSizeLow: DWORD, - pub dwReserved0: DWORD, - pub dwReserved1: DWORD, - pub cFileName: [wchar_t; 260], // #define MAX_PATH 260 - pub cAlternateFileName: [wchar_t; 14], - } } pub const EXIT_FAILURE: c_int = 1; @@ -342,59 +98,6 @@ pub const BUFSIZ: c_uint = 512; pub const FOPEN_MAX: c_uint = 20; pub const FILENAME_MAX: c_uint = 260; -pub const WSAEINTR: c_int = 10004; -pub const WSAEBADF: c_int = 10009; -pub const WSAEACCES: c_int = 10013; -pub const WSAEFAULT: c_int = 10014; -pub const WSAEINVAL: c_int = 10022; -pub const WSAEMFILE: c_int = 10024; -pub const WSAEWOULDBLOCK: c_int = 10035; -pub const WSAEINPROGRESS: c_int = 10036; -pub const WSAEALREADY: c_int = 10037; -pub const WSAENOTSOCK: c_int = 10038; -pub const WSAEDESTADDRREQ: c_int = 10039; -pub const WSAEMSGSIZE: c_int = 10040; -pub const WSAEPROTOTYPE: c_int = 10041; -pub const WSAENOPROTOOPT: c_int = 10042; -pub const WSAEPROTONOSUPPORT: c_int = 10043; -pub const WSAESOCKTNOSUPPORT: c_int = 10044; -pub const WSAEOPNOTSUPP: c_int = 10045; -pub const WSAEPFNOSUPPORT: c_int = 10046; -pub const WSAEAFNOSUPPORT: c_int = 10047; -pub const WSAEADDRINUSE: c_int = 10048; -pub const WSAEADDRNOTAVAIL: c_int = 10049; -pub const WSAENETDOWN: c_int = 10050; -pub const WSAENETUNREACH: c_int = 10051; -pub const WSAENETRESET: c_int = 10052; -pub const WSAECONNABORTED: c_int = 10053; -pub const WSAECONNRESET: c_int = 10054; -pub const WSAENOBUFS: c_int = 10055; -pub const WSAEISCONN: c_int = 10056; -pub const WSAENOTCONN: c_int = 10057; -pub const WSAESHUTDOWN: c_int = 10058; -pub const WSAETOOMANYREFS: c_int = 10059; -pub const WSAETIMEDOUT: c_int = 10060; -pub const WSAECONNREFUSED: c_int = 10061; -pub const WSAELOOP: c_int = 10062; -pub const WSAENAMETOOLONG: c_int = 10063; -pub const WSAEHOSTDOWN: c_int = 10064; -pub const WSAEHOSTUNREACH: c_int = 10065; -pub const WSAENOTEMPTY: c_int = 10066; -pub const WSAEPROCLIM: c_int = 10067; -pub const WSAEUSERS: c_int = 10068; -pub const WSAEDQUOT: c_int = 10069; -pub const WSAESTALE: c_int = 10070; -pub const WSAEREMOTE: c_int = 10071; -pub const WSASYSNOTREADY: c_int = 10091; -pub const WSAVERNOTSUPPORTED: c_int = 10092; -pub const WSANOTINITIALISED: c_int = 10093; -pub const WSAEDISCON: c_int = 10101; -pub const WSAENOMORE: c_int = 10102; -pub const WSAECANCELLED: c_int = 10103; -pub const WSAEINVALIDPROCTABLE: c_int = 10104; -pub const WSAEINVALIDPROVIDER: c_int = 10105; -pub const WSAEPROVIDERFAILEDINIT: c_int = 10106; - cfg_if! { if #[cfg(all(target_env = "gnu"))] { pub const L_tmpnam: c_uint = 14; @@ -411,6 +114,9 @@ pub const O_RDWR: c_int = 2; pub const O_APPEND: c_int = 8; pub const O_CREAT: c_int = 256; pub const O_EXCL: c_int = 1024; +pub const O_TEXT: c_int = 16384; +pub const O_BINARY: c_int = 32768; +pub const O_NOINHERIT: c_int = 128; pub const O_TRUNC: c_int = 512; pub const S_IFCHR: c_int = 8192; pub const S_IFDIR: c_int = 16384; @@ -420,279 +126,7 @@ pub const S_IEXEC: c_int = 64; pub const S_IWRITE: c_int = 128; pub const S_IREAD: c_int = 256; -pub const AF_INET: c_int = 2; -pub const AF_INET6: c_int = 23; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; -pub const SOCK_RAW: c_int = 3; -pub const IPPROTO_TCP: c_int = 6; -pub const IPPROTO_IP: c_int = 0; -pub const IPPROTO_IPV6: c_int = 41; -pub const IP_MULTICAST_TTL: c_int = 10; -pub const IP_MULTICAST_LOOP: c_int = 11; -pub const IP_ADD_MEMBERSHIP: c_int = 12; -pub const IP_DROP_MEMBERSHIP: c_int = 13; -pub const IPV6_ADD_MEMBERSHIP: c_int = 12; -pub const IPV6_DROP_MEMBERSHIP: c_int = 13; -pub const IP_TTL: c_int = 4; -pub const IP_HDRINCL: c_int = 2; - -pub const TCP_NODELAY: c_int = 0x0001; -pub const SOL_SOCKET: c_int = 0xffff; - -pub const SO_DEBUG: c_int = 0x0001; -pub const SO_ACCEPTCONN: c_int = 0x0002; -pub const SO_REUSEADDR: c_int = 0x0004; -pub const SO_KEEPALIVE: c_int = 0x0008; -pub const SO_DONTROUTE: c_int = 0x0010; -pub const SO_BROADCAST: c_int = 0x0020; -pub const SO_USELOOPBACK: c_int = 0x0040; -pub const SO_LINGER: c_int = 0x0080; -pub const SO_OOBINLINE: c_int = 0x0100; -pub const SO_SNDBUF: c_int = 0x1001; -pub const SO_RCVBUF: c_int = 0x1002; -pub const SO_SNDLOWAT: c_int = 0x1003; -pub const SO_RCVLOWAT: c_int = 0x1004; -pub const SO_SNDTIMEO: c_int = 0x1005; -pub const SO_RCVTIMEO: c_int = 0x1006; -pub const SO_ERROR: c_int = 0x1007; -pub const SO_TYPE: c_int = 0x1008; - -pub const IFF_LOOPBACK: c_int = 4; - -pub const SD_RECEIVE: c_int = 0; -pub const SD_SEND: c_int = 1; -pub const SD_BOTH: c_int = 2; - -pub const TRUE: BOOL = 1; -pub const FALSE: BOOL = 0; - -pub const O_TEXT: c_int = 16384; -pub const O_BINARY: c_int = 32768; -pub const O_NOINHERIT: c_int = 128; - -pub const ERROR_SUCCESS: c_int = 0; -pub const ERROR_INVALID_FUNCTION: c_int = 1; -pub const ERROR_FILE_NOT_FOUND: c_int = 2; -pub const ERROR_ACCESS_DENIED: c_int = 5; -pub const ERROR_INVALID_HANDLE: c_int = 6; -pub const ERROR_BROKEN_PIPE: c_int = 109; -pub const ERROR_DISK_FULL: c_int = 112; -pub const ERROR_CALL_NOT_IMPLEMENTED: c_int = 120; -pub const ERROR_INSUFFICIENT_BUFFER: c_int = 122; -pub const ERROR_INVALID_NAME: c_int = 123; -pub const ERROR_ALREADY_EXISTS: c_int = 183; -pub const ERROR_PIPE_BUSY: c_int = 231; -pub const ERROR_NO_DATA: c_int = 232; -pub const ERROR_INVALID_ADDRESS: c_int = 487; -pub const ERROR_PIPE_CONNECTED: c_int = 535; -pub const ERROR_NOTHING_TO_TERMINATE: c_int = 758; -pub const ERROR_OPERATION_ABORTED: c_int = 995; -pub const ERROR_IO_PENDING: c_int = 997; -pub const ERROR_FILE_INVALID: c_int = 1006; -pub const ERROR_NOT_FOUND: c_int = 1168; -pub const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE; - -pub const DELETE: DWORD = 0x00010000; -pub const READ_CONTROL: DWORD = 0x00020000; -pub const SYNCHRONIZE: DWORD = 0x00100000; -pub const WRITE_DAC: DWORD = 0x00040000; -pub const WRITE_OWNER: DWORD = 0x00080000; - -pub const PROCESS_CREATE_PROCESS: DWORD = 0x0080; -pub const PROCESS_CREATE_THREAD: DWORD = 0x0002; -pub const PROCESS_DUP_HANDLE: DWORD = 0x0040; -pub const PROCESS_QUERY_INFORMATION: DWORD = 0x0400; -pub const PROCESS_QUERY_LIMITED_INFORMATION: DWORD = 0x1000; -pub const PROCESS_SET_INFORMATION: DWORD = 0x0200; -pub const PROCESS_SET_QUOTA: DWORD = 0x0100; -pub const PROCESS_SUSPEND_RESUME: DWORD = 0x0800; -pub const PROCESS_TERMINATE: DWORD = 0x0001; -pub const PROCESS_VM_OPERATION: DWORD = 0x0008; -pub const PROCESS_VM_READ: DWORD = 0x0010; -pub const PROCESS_VM_WRITE: DWORD = 0x0020; - -pub const STARTF_FORCEONFEEDBACK: DWORD = 0x00000040; -pub const STARTF_FORCEOFFFEEDBACK: DWORD = 0x00000080; -pub const STARTF_PREVENTPINNING: DWORD = 0x00002000; -pub const STARTF_RUNFULLSCREEN: DWORD = 0x00000020; -pub const STARTF_TITLEISAPPID: DWORD = 0x00001000; -pub const STARTF_TITLEISLINKNAME: DWORD = 0x00000800; -pub const STARTF_USECOUNTCHARS: DWORD = 0x00000008; -pub const STARTF_USEFILLATTRIBUTE: DWORD = 0x00000010; -pub const STARTF_USEHOTKEY: DWORD = 0x00000200; -pub const STARTF_USEPOSITION: DWORD = 0x00000004; -pub const STARTF_USESHOWWINDOW: DWORD = 0x00000001; -pub const STARTF_USESIZE: DWORD = 0x00000002; -pub const STARTF_USESTDHANDLES: DWORD = 0x00000100; - -pub const WAIT_ABANDONED: DWORD = 0x00000080; -pub const WAIT_OBJECT_0: DWORD = 0x00000000; -pub const WAIT_TIMEOUT: DWORD = 0x00000102; -pub const WAIT_FAILED: DWORD = !0; - -pub const DUPLICATE_CLOSE_SOURCE: DWORD = 0x00000001; -pub const DUPLICATE_SAME_ACCESS: DWORD = 0x00000002; - -pub const INFINITE: DWORD = !0; -pub const STILL_ACTIVE: DWORD = 259; - -pub const MEM_COMMIT: DWORD = 0x00001000; -pub const MEM_RESERVE: DWORD = 0x00002000; -pub const MEM_DECOMMIT: DWORD = 0x00004000; -pub const MEM_RELEASE: DWORD = 0x00008000; -pub const MEM_RESET: DWORD = 0x00080000; -pub const MEM_RESET_UNDO: DWORD = 0x1000000; -pub const MEM_LARGE_PAGES: DWORD = 0x20000000; -pub const MEM_PHYSICAL: DWORD = 0x00400000; -pub const MEM_TOP_DOWN: DWORD = 0x00100000; -pub const MEM_WRITE_WATCH: DWORD = 0x00200000; - -pub const PAGE_EXECUTE: DWORD = 0x10; -pub const PAGE_EXECUTE_READ: DWORD = 0x20; -pub const PAGE_EXECUTE_READWRITE: DWORD = 0x40; -pub const PAGE_EXECUTE_WRITECOPY: DWORD = 0x80; -pub const PAGE_NOACCESS: DWORD = 0x01; -pub const PAGE_READONLY: DWORD = 0x02; -pub const PAGE_READWRITE: DWORD = 0x04; -pub const PAGE_WRITECOPY: DWORD = 0x08; -pub const PAGE_GUARD: DWORD = 0x100; -pub const PAGE_NOCACHE: DWORD = 0x200; -pub const PAGE_WRITECOMBINE: DWORD = 0x400; - -pub const SEC_COMMIT: DWORD = 0x8000000; -pub const SEC_IMAGE: DWORD = 0x1000000; -pub const SEC_IMAGE_NO_EXECUTE: DWORD = 0x11000000; -pub const SEC_LARGE_PAGES: DWORD = 0x80000000; -pub const SEC_NOCACHE: DWORD = 0x10000000; -pub const SEC_RESERVE: DWORD = 0x4000000; -pub const SEC_WRITECOMBINE: DWORD = 0x40000000; - -pub const FILE_MAP_ALL_ACCESS: DWORD = 0xf001f; -pub const FILE_MAP_READ: DWORD = 0x4; -pub const FILE_MAP_WRITE: DWORD = 0x2; -pub const FILE_MAP_COPY: DWORD = 0x1; -pub const FILE_MAP_EXECUTE: DWORD = 0x20; - -pub const PROCESSOR_ARCHITECTURE_INTEL: WORD = 0; -pub const PROCESSOR_ARCHITECTURE_ARM: WORD = 5; -pub const PROCESSOR_ARCHITECTURE_IA64: WORD = 6; -pub const PROCESSOR_ARCHITECTURE_AMD64: WORD = 9; -pub const PROCESSOR_ARCHITECTURE_UNKNOWN: WORD = 0xffff; - -pub const MOVEFILE_COPY_ALLOWED: DWORD = 2; -pub const MOVEFILE_CREATE_HARDLINK: DWORD = 16; -pub const MOVEFILE_DELAY_UNTIL_REBOOT: DWORD = 4; -pub const MOVEFILE_FAIL_IF_NOT_TRACKABLE: DWORD = 32; -pub const MOVEFILE_REPLACE_EXISTING: DWORD = 1; -pub const MOVEFILE_WRITE_THROUGH: DWORD = 8; - -pub const SYMBOLIC_LINK_FLAG_DIRECTORY: DWORD = 1; - -pub const FILE_SHARE_DELETE: DWORD = 0x4; -pub const FILE_SHARE_READ: DWORD = 0x1; -pub const FILE_SHARE_WRITE: DWORD = 0x2; - -pub const CREATE_ALWAYS: DWORD = 2; -pub const CREATE_NEW: DWORD = 1; -pub const OPEN_ALWAYS: DWORD = 4; -pub const OPEN_EXISTING: DWORD = 3; -pub const TRUNCATE_EXISTING: DWORD = 5; - -pub const FILE_APPEND_DATA: DWORD = 0x00000004; -pub const FILE_READ_DATA: DWORD = 0x00000001; -pub const FILE_WRITE_DATA: DWORD = 0x00000002; - -pub const FILE_ATTRIBUTE_ARCHIVE: DWORD = 0x20; -pub const FILE_ATTRIBUTE_COMPRESSED: DWORD = 0x800; -pub const FILE_ATTRIBUTE_DEVICE: DWORD = 0x40; -pub const FILE_ATTRIBUTE_DIRECTORY: DWORD = 0x10; -pub const FILE_ATTRIBUTE_ENCRYPTED: DWORD = 0x4000; -pub const FILE_ATTRIBUTE_HIDDEN: DWORD = 0x2; -pub const FILE_ATTRIBUTE_INTEGRITY_STREAM: DWORD = 0x8000; -pub const FILE_ATTRIBUTE_NORMAL: DWORD = 0x80; -pub const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: DWORD = 0x2000; -pub const FILE_ATTRIBUTE_NO_SCRUB_DATA: DWORD = 0x20000; -pub const FILE_ATTRIBUTE_OFFLINE: DWORD = 0x1000; -pub const FILE_ATTRIBUTE_READONLY: DWORD = 0x1; -pub const FILE_ATTRIBUTE_REPARSE_POINT: DWORD = 0x400; -pub const FILE_ATTRIBUTE_SPARSE_FILE: DWORD = 0x200; -pub const FILE_ATTRIBUTE_SYSTEM: DWORD = 0x4; -pub const FILE_ATTRIBUTE_TEMPORARY: DWORD = 0x100; -pub const FILE_ATTRIBUTE_VIRTUAL: DWORD = 0x10000; - -pub const FILE_FLAG_BACKUP_SEMANTICS: DWORD = 0x02000000; -pub const FILE_FLAG_DELETE_ON_CLOSE: DWORD = 0x04000000; -pub const FILE_FLAG_NO_BUFFERING: DWORD = 0x20000000; -pub const FILE_FLAG_OPEN_NO_RECALL: DWORD = 0x00100000; -pub const FILE_FLAG_OPEN_REPARSE_POINT: DWORD = 0x00200000; -pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000; -pub const FILE_FLAG_POSIX_SEMANTICS: DWORD = 0x1000000; -pub const FILE_FLAG_RANDOM_ACCESS: DWORD = 0x10000000; -pub const FILE_FLAG_SESSION_AWARE: DWORD = 0x00800000; -pub const FILE_FLAG_SEQUENTIAL_SCAN: DWORD = 0x08000000; -pub const FILE_FLAG_WRITE_THROUGH: DWORD = 0x80000000; -pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000; - -pub const FILE_NAME_NORMALIZED: DWORD = 0x0; -pub const FILE_NAME_OPENED: DWORD = 0x8; - -pub const VOLUME_NAME_DOS: DWORD = 0x0; -pub const VOLUME_NAME_GUID: DWORD = 0x1; -pub const VOLUME_NAME_NONE: DWORD = 0x4; -pub const VOLUME_NAME_NT: DWORD = 0x2; - -pub const GENERIC_READ: DWORD = 0x80000000; -pub const GENERIC_WRITE: DWORD = 0x40000000; -pub const GENERIC_EXECUTE: DWORD = 0x20000000; -pub const GENERIC_ALL: DWORD = 0x10000000; -pub const FILE_WRITE_ATTRIBUTES: DWORD = 0x00000100; -pub const FILE_READ_ATTRIBUTES: DWORD = 0x00000080; - -pub const STANDARD_RIGHTS_READ: DWORD = 0x20000; -pub const STANDARD_RIGHTS_WRITE: DWORD = 0x20000; -pub const FILE_WRITE_EA: DWORD = 0x00000010; -pub const FILE_READ_EA: DWORD = 0x00000008; -pub const FILE_GENERIC_READ: DWORD = - STANDARD_RIGHTS_READ | FILE_READ_DATA | - FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE; -pub const FILE_GENERIC_WRITE: DWORD = - STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | - FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | - SYNCHRONIZE; - -pub const FILE_BEGIN: DWORD = 0; -pub const FILE_CURRENT: DWORD = 1; -pub const FILE_END: DWORD = 2; - -pub const MAX_PROTOCOL_CHAIN: DWORD = 7; -pub const WSAPROTOCOL_LEN: DWORD = 255; -pub const INVALID_SOCKET: SOCKET = !0; - -pub const DETACHED_PROCESS: DWORD = 0x00000008; -pub const CREATE_NEW_PROCESS_GROUP: DWORD = 0x00000200; -pub const CREATE_UNICODE_ENVIRONMENT: DWORD = 0x00000400; - -pub const PIPE_ACCESS_DUPLEX: DWORD = 0x00000003; -pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001; -pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002; -pub const PIPE_TYPE_BYTE: DWORD = 0x00000000; -pub const PIPE_TYPE_MESSAGE: DWORD = 0x00000004; -pub const PIPE_READMODE_BYTE: DWORD = 0x00000000; -pub const PIPE_READMODE_MESSAGE: DWORD = 0x00000002; -pub const PIPE_WAIT: DWORD = 0x00000000; -pub const PIPE_NOWAIT: DWORD = 0x00000001; -pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; -pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; -pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; - -pub const IPPROTO_RAW: c_int = 255; - -pub const FIONBIO: c_long = -0x7FFB9982; - #[cfg(target_env = "msvc")] -#[link(name = "kernel32")] -#[link(name = "shell32")] #[link(name = "msvcrt")] extern {} @@ -772,205 +206,3 @@ extern { #[link_name = "_open_osfhandle"] pub fn open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int; } - -extern "system" { - pub fn GetEnvironmentVariableW(n: LPCWSTR, - v: LPWSTR, - nsize: DWORD) - -> DWORD; - pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR) - -> BOOL; - pub fn GetEnvironmentStringsW() -> LPWCH; - pub fn FreeEnvironmentStringsW(env_ptr: LPWCH) -> BOOL; - pub fn GetModuleFileNameW(hModule: HMODULE, - lpFilename: LPWSTR, - nSize: DWORD) - -> DWORD; - pub fn CreateDirectoryW(lpPathName: LPCWSTR, - lpSecurityAttributes: - LPSECURITY_ATTRIBUTES) - -> BOOL; - pub fn CopyFileW(lpExistingFileName: LPCWSTR, - lpNewFileName: LPCWSTR, - bFailIfExists: BOOL) - -> BOOL; - pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL; - pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL; - pub fn GetCurrentDirectoryW(nBufferLength: DWORD, - lpBuffer: LPWSTR) - -> DWORD; - pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL; - pub fn GetLastError() -> DWORD; - pub fn FindFirstFileW(fileName: LPCWSTR, findFileData: LPWIN32_FIND_DATAW) - -> HANDLE; - pub fn FindNextFileW(findFile: HANDLE, findFileData: LPWIN32_FIND_DATAW) - -> BOOL; - pub fn FindClose(findFile: HANDLE) -> BOOL; - pub fn DuplicateHandle(hSourceProcessHandle: HANDLE, - hSourceHandle: HANDLE, - hTargetProcessHandle: HANDLE, - lpTargetHandle: LPHANDLE, - dwDesiredAccess: DWORD, - bInheritHandle: BOOL, - dwOptions: DWORD) - -> BOOL; - pub fn CloseHandle(hObject: HANDLE) -> BOOL; - pub fn OpenProcess(dwDesiredAccess: DWORD, - bInheritHandle: BOOL, - dwProcessId: DWORD) - -> HANDLE; - pub fn GetCurrentProcess() -> HANDLE; - pub fn CreateProcessW(lpApplicationName: LPCWSTR, - lpCommandLine: LPWSTR, - lpProcessAttributes: - LPSECURITY_ATTRIBUTES, - lpThreadAttributes: - LPSECURITY_ATTRIBUTES, - bInheritHandles: BOOL, - dwCreationFlags: DWORD, - lpEnvironment: LPVOID, - lpCurrentDirectory: LPCWSTR, - lpStartupInfo: LPSTARTUPINFOW, - lpProcessInformation: - LPPROCESS_INFORMATION) - -> BOOL; - pub fn WaitForSingleObject(hHandle: HANDLE, - dwMilliseconds: DWORD) - -> DWORD; - pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) - -> BOOL; - pub fn GetExitCodeProcess(hProcess: HANDLE, - lpExitCode: LPDWORD) - -> BOOL; - pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO); - pub fn VirtualAlloc(lpAddress: LPVOID, - dwSize: SIZE_T, - flAllocationType: DWORD, - flProtect: DWORD) - -> LPVOID; - pub fn VirtualFree(lpAddress: LPVOID, - dwSize: SIZE_T, - dwFreeType: DWORD) - -> BOOL; - pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL; - pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T) - -> BOOL; - pub fn VirtualProtect(lpAddress: LPVOID, - dwSize: SIZE_T, - flNewProtect: DWORD, - lpflOldProtect: LPDWORD) - -> BOOL; - pub fn VirtualQuery(lpAddress: LPCVOID, - lpBuffer: PMEMORY_BASIC_INFORMATION, - dwLength: SIZE_T) - -> SIZE_T; - pub fn CreateFileMappingW(hFile: HANDLE, - lpAttributes: LPSECURITY_ATTRIBUTES, - flProtect: DWORD, - dwMaximumSizeHigh: DWORD, - dwMaximumSizeLow: DWORD, - lpName: LPCWSTR) - -> HANDLE; - pub fn MapViewOfFile(hFileMappingObject: HANDLE, - dwDesiredAccess: DWORD, - dwFileOffsetHigh: DWORD, - dwFileOffsetLow: DWORD, - dwNumberOfBytesToMap: SIZE_T) - -> LPVOID; - pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL; - pub fn MoveFileExW(lpExistingFileName: LPCWSTR, - lpNewFileName: LPCWSTR, - dwFlags: DWORD) -> BOOL; - pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR, - lpTargetFileName: LPCWSTR, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES) - -> BOOL; - pub fn FlushFileBuffers(hFile: HANDLE) -> BOOL; - pub fn CreateFileW(lpFileName: LPCWSTR, - dwDesiredAccess: DWORD, - dwShareMode: DWORD, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES, - dwCreationDisposition: DWORD, - dwFlagsAndAttributes: DWORD, - hTemplateFile: HANDLE) -> HANDLE; - pub fn ReadFile(hFile: HANDLE, - lpBuffer: LPVOID, - nNumberOfBytesToRead: DWORD, - lpNumberOfBytesRead: LPDWORD, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn WriteFile(hFile: HANDLE, - lpBuffer: LPCVOID, - nNumberOfBytesToWrite: DWORD, - lpNumberOfBytesWritten: LPDWORD, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn SetFilePointerEx(hFile: HANDLE, - liDistanceToMove: LARGE_INTEGER, - lpNewFilePointer: PLARGE_INTEGER, - dwMoveMethod: DWORD) -> BOOL; - pub fn SetEndOfFile(hFile: HANDLE) -> BOOL; - - pub fn GetSystemTimeAsFileTime(lpSystemTimeAsFileTime: LPFILETIME); - - pub fn QueryPerformanceFrequency(lpFrequency: *mut LARGE_INTEGER) -> BOOL; - pub fn QueryPerformanceCounter(lpPerformanceCount: *mut LARGE_INTEGER) - -> BOOL; - - pub fn GetCurrentProcessId() -> DWORD; - pub fn CreateNamedPipeW( - lpName: LPCWSTR, - dwOpenMode: DWORD, - dwPipeMode: DWORD, - nMaxInstances: DWORD, - nOutBufferSize: DWORD, - nInBufferSize: DWORD, - nDefaultTimeOut: DWORD, - lpSecurityAttributes: LPSECURITY_ATTRIBUTES - ) -> HANDLE; - pub fn ConnectNamedPipe(hNamedPipe: HANDLE, - lpOverlapped: LPOVERLAPPED) -> BOOL; - pub fn WaitNamedPipeW(lpNamedPipeName: LPCWSTR, - nTimeOut: DWORD) -> BOOL; - pub fn SetNamedPipeHandleState(hNamedPipe: HANDLE, - lpMode: LPDWORD, - lpMaxCollectionCount: LPDWORD, - lpCollectDataTimeout: LPDWORD) - -> BOOL; - pub fn CreateEventW(lpEventAttributes: LPSECURITY_ATTRIBUTES, - bManualReset: BOOL, - bInitialState: BOOL, - lpName: LPCWSTR) -> HANDLE; - pub fn GetOverlappedResult(hFile: HANDLE, - lpOverlapped: LPOVERLAPPED, - lpNumberOfBytesTransferred: LPDWORD, - bWait: BOOL) -> BOOL; - pub fn DisconnectNamedPipe(hNamedPipe: HANDLE) -> BOOL; - - pub fn ioctlsocket(s: SOCKET, cmd: c_long, argp: *mut c_ulong) -> c_int; - pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> SOCKET; - pub fn connect(socket: SOCKET, address: *const sockaddr, - len: c_int) -> c_int; - pub fn bind(socket: SOCKET, address: *const sockaddr, - address_len: c_int) -> c_int; - pub fn listen(socket: SOCKET, backlog: c_int) -> c_int; - pub fn accept(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> SOCKET; - pub fn getpeername(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> c_int; - pub fn getsockname(socket: SOCKET, address: *mut sockaddr, - address_len: *mut c_int) -> c_int; - pub fn setsockopt(socket: SOCKET, level: c_int, name: c_int, - value: *const c_char, - option_len: c_int) -> c_int; - pub fn closesocket(socket: SOCKET) -> c_int; - pub fn recv(socket: SOCKET, buf: *mut c_char, len: c_int, - flags: c_int) -> c_int; - pub fn send(socket: SOCKET, buf: *const c_char, len: c_int, - flags: c_int) -> c_int; - pub fn recvfrom(socket: SOCKET, buf: *mut c_char, len: c_int, - flags: c_int, addr: *mut sockaddr, - addrlen: *mut c_int) -> c_int; - pub fn sendto(socket: SOCKET, buf: *const c_char, len: c_int, - flags: c_int, addr: *const sockaddr, - addrlen: c_int) -> c_int; - pub fn shutdown(socket: SOCKET, how: c_int) -> c_int; -} From baef6116da5c705164c71f25b0614654afeac8a0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 19 Sep 2015 23:20:53 -0700 Subject: [PATCH 175/194] iOS support --- .travis.yml | 6 ++++++ README.md | 2 +- ci/README.md | 4 +++- ci/run-travis.sh | 4 ++++ ci/run.sh | 15 ++++++++++++++- libc-test/build.rs | 12 +++++++----- src/unix/bsd/apple/mod.rs | 5 ----- src/unix/bsd/mod.rs | 2 +- src/unix/mod.rs | 4 +++- 9 files changed, 39 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index f58a60e4e1cf6..837025fedd246 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,12 @@ matrix: - os: linux env: TARGET=aarch64-unknown-linux-gnu rust: nightly-2015-09-08 + - os: osx + env: TARGET=i386-apple-ios + rust: nightly-2015-09-08 + - os: osx + env: TARGET=x86_64-apple-ios + rust: nightly-2015-09-08 notifications: email: on_success: never diff --git a/README.md b/README.md index 2b57d7ee7e6e5..a1c8fdeb90a79 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Tested: * `x86_64-unknown-linux-musl` * `arm-unknown-linux-gnueabihf` * `arm-linux-androideabi` - * `{i686,x86_64}-apple-darwin` + * `{i686,x86_64}-apple-{darwin,ios}` Untested: * `{i686,x86_64}-unknown-freebsd` diff --git a/ci/README.md b/ci/README.md index 6aebb43fdd023..8e4729ed2e190 100644 --- a/ci/README.md +++ b/ci/README.md @@ -57,7 +57,7 @@ running tests. The triples tested are: * `x86_64-unknown-linux-musl` * `arm-unknown-linux-gnueabihf` * `arm-linux-androideabi` - * `{i686,x86_64}-apple-darwin` + * `{i686,x86_64}-apple-{darwin,ios}` The Windows triples are all pretty standard, they just set up their environment then run tests, no need for downloading any extra target libs (we just download @@ -74,6 +74,8 @@ The remaining architectures look like: actually verify the tests pass. * The MUSL build just has to download a MUSL compiler and target libraries and then otherwise runs tests normally. +* iOS builds need an extra linker flag currently, but beyond that they're built + as standard as everything else. Hopefully that's at least somewhat of an introduction to everything going on here, and feel free to ping @alexcrichton with questions! diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 0bebd4245140a..ee58b887392a8 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -47,6 +47,10 @@ case "$TARGET" in export CC=aarch64-linux-gnu-gcc ;; + *-apple-ios) + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + ;; + mips-unknown-linux-gnu) # Download pre-built and custom MIPS libs and then also instsall the MIPS # compiler according to this post: diff --git a/ci/run.sh b/ci/run.sh index b0d4726f70391..6a4b4b122a79c 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -6,7 +6,16 @@ set -ex TARGET=$1 -cargo build --manifest-path libc-test/Cargo.toml --target $TARGET +case "$TARGET" in + *-apple-ios) + cargo rustc --manifest-path libc-test/Cargo.toml --target $TARGET -- \ + -C link-args=-mios-simulator-version-min=7.0 + ;; + + *) + cargo build --manifest-path libc-test/Cargo.toml --target $TARGET + ;; +esac case "$TARGET" in arm-linux-androideabi) @@ -29,6 +38,10 @@ case "$TARGET" in libc-test/target/$TARGET/debug/libc-test ;; + *-apple-ios) + libc-test/target/$TARGET/debug/libc-test + ;; + *) cargo run --manifest-path libc-test/Cargo.toml --target $TARGET ;; diff --git a/libc-test/build.rs b/libc-test/build.rs index 530d10b50cce6..b4eb70c68514d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -10,10 +10,10 @@ fn main() { let mingw = target.contains("windows-gnu"); let linux = target.contains("unknown-linux"); let android = target.contains("android"); - let darwin = target.contains("apple-darwin"); + let apple = target.contains("apple"); let musl = target.contains("musl"); let freebsd = target.contains("freebsd"); - let bsdlike = freebsd || darwin; + let bsdlike = freebsd || apple; let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw @@ -92,11 +92,13 @@ fn main() { } } - if darwin { + if apple { cfg.header("mach-o/dyld.h"); cfg.header("mach/mach_time.h"); cfg.header("malloc/malloc.h"); - cfg.header("crt_externs.h"); + if target.starts_with("x86") { + cfg.header("crt_externs.h"); + } } if linux || android { @@ -150,7 +152,7 @@ fn main() { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_ == "stat" => { - if target2.contains("apple-darwin") { + if target2.contains("apple") { s.replace("_nsec", "spec.tv_nsec") } else if target2.contains("android") { s.to_string() diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 7b5b04317a3a8..a9697cedc63ff 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -626,11 +626,6 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { pub const SIGSTKSZ: ::size_t = 131072; extern { - pub fn _NSGetExecutablePath(buf: *mut ::c_char, - bufsize: *mut ::uint32_t) -> ::c_int; - pub fn _NSGetArgc() -> *mut ::c_int; - pub fn _NSGetArgv() -> *mut *mut *mut ::c_char; - pub fn _NSGetEnviron() -> *mut *mut *mut ::c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 3b8c4fb8f587a..c994d9c8509a3 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -49,7 +49,7 @@ s! { pub pw_shell: *mut ::c_char, pub pw_expire: ::time_t, - #[cfg(not(target_os = "macos"))] + #[cfg(not(any(target_os = "macos", target_os = "ios")))] pub pw_fields: ::c_int, } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e8a16691a7a6a..c7c7d4acffa46 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -333,7 +333,8 @@ extern { pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; pub fn getdtablesize() -> c_int; - #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] + #[cfg_attr(any(target_os = "macos", target_os = "ios"), + link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char; @@ -523,6 +524,7 @@ cfg_if! { mod notbsd; pub use self::notbsd::*; } else if #[cfg(any(target_os = "macos", + target_os = "ios", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", From 179104605391bdda15c0215c963c797504103d11 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Sep 2015 19:11:04 -0700 Subject: [PATCH 176/194] Use isize/usize --- src/lib.rs | 21 +- src/unix/bsd/apple/b32.rs | 4 - src/unix/bsd/apple/b64.rs | 4 - src/unix/bsd/apple/mod.rs | 1 - src/unix/bsd/freebsdlike/x86.rs | 5 - src/unix/bsd/freebsdlike/x86_64.rs | 5 - src/unix/bsd/openbsdlike/mod.rs | 5 - src/unix/mod.rs | 268 +++++++++++------------ src/unix/notbsd/android/mod.rs | 5 - src/unix/notbsd/linux/mips.rs | 5 - src/unix/notbsd/linux/mod.rs | 12 +- src/unix/notbsd/linux/notmips/b32/mod.rs | 5 - src/unix/notbsd/linux/notmips/b64/mod.rs | 5 - src/windows.rs | 174 ++++++--------- 14 files changed, 226 insertions(+), 293 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7997e11ca08f4..84d89adcf232c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ //! Crate docs -#![allow(bad_style, raw_pointer_derive)] +#![allow(bad_style, raw_pointer_derive, improper_ctypes)] #![cfg_attr(dox, feature(no_core, lang_items))] #![cfg_attr(dox, no_core)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -77,6 +77,25 @@ pub type uint16_t = u16; pub type uint32_t = u32; pub type uint64_t = u64; +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + pub enum FILE {} pub enum fpos_t {} pub enum DIR {} diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 293822e721f33..9a46ed05598ea 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -2,10 +2,6 @@ pub type c_long = i32; pub type c_ulong = u32; -pub type size_t = u32; -pub type ptrdiff_t = i32; -pub type intptr_t = i32; -pub type uintptr_t = u32; pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index fb9f58ccd244e..344582e35474f 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -2,10 +2,6 @@ pub type c_long = i64; pub type c_ulong = u64; -pub type size_t = u64; -pub type ptrdiff_t = i64; -pub type intptr_t = i64; -pub type uintptr_t = u64; pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index a9697cedc63ff..74435c43ebd58 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -8,7 +8,6 @@ pub type suseconds_t = i32; pub type dev_t = i32; pub type ino_t = u64; pub type mode_t = u16; -pub type ssize_t = c_long; pub type nlink_t = u16; pub type blksize_t = i32; pub type rlim_t = u64; diff --git a/src/unix/bsd/freebsdlike/x86.rs b/src/unix/bsd/freebsdlike/x86.rs index 3be08eee33cc8..8a5e5f9fb8d28 100644 --- a/src/unix/bsd/freebsdlike/x86.rs +++ b/src/unix/bsd/freebsdlike/x86.rs @@ -1,12 +1,7 @@ pub type c_long = i32; pub type c_ulong = u32; -pub type size_t = u32; -pub type ptrdiff_t = i32; pub type time_t = i32; pub type suseconds_t = i32; -pub type intptr_t = i32; -pub type uintptr_t = u32; -pub type ssize_t = i32; s! { pub struct stat { diff --git a/src/unix/bsd/freebsdlike/x86_64.rs b/src/unix/bsd/freebsdlike/x86_64.rs index c45374423b56a..a2da8452c4d34 100644 --- a/src/unix/bsd/freebsdlike/x86_64.rs +++ b/src/unix/bsd/freebsdlike/x86_64.rs @@ -1,12 +1,7 @@ pub type c_long = i64; pub type c_ulong = u64; -pub type size_t = u64; -pub type ptrdiff_t = i64; pub type time_t = i64; pub type suseconds_t = i64; -pub type intptr_t = i64; -pub type uintptr_t = u64; -pub type ssize_t = i64; s! { pub struct stat { diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 239eff2c7edc1..ecd1579e0c211 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -1,15 +1,10 @@ pub type c_long = i64; pub type c_ulong = u64; -pub type size_t = u64; -pub type ptrdiff_t = i64; pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; -pub type intptr_t = i64; -pub type uintptr_t = u64; pub type dev_t = i32; pub type mode_t = u32; -pub type ssize_t = c_long; pub type nlink_t = uint32_t; pub type blksize_t = uint32_t; pub type ino_t = uint64_t; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c7c7d4acffa46..c78058674d1b6 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -3,24 +3,12 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; pub type pid_t = i32; pub type uid_t = u32; pub type gid_t = u32; pub type in_addr_t = u32; pub type in_port_t = u16; -pub type sighandler_t = size_t; +pub type sighandler_t = ::size_t; s! { pub struct utimbuf { @@ -82,13 +70,13 @@ s! { pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] - pub ipv6mr_interface: c_int, + pub ipv6mr_interface: ::c_int, #[cfg(not(target_os = "android"))] - pub ipv6mr_interface: c_uint, + pub ipv6mr_interface: ::c_uint, } } -pub const WNOHANG: c_int = 1; +pub const WNOHANG: ::c_int = 1; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; @@ -108,74 +96,74 @@ cfg_if! { } extern { - pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; + pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "connect$UNIX2003")] - pub fn connect(socket: c_int, address: *const sockaddr, - len: socklen_t) -> c_int; + pub fn connect(socket: ::c_int, address: *const sockaddr, + len: socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "bind$UNIX2003")] - pub fn bind(socket: c_int, address: *const sockaddr, - address_len: socklen_t) -> c_int; + pub fn bind(socket: ::c_int, address: *const sockaddr, + address_len: socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "listen$UNIX2003")] - pub fn listen(socket: c_int, backlog: c_int) -> c_int; + pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "accept$UNIX2003")] - pub fn accept(socket: c_int, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; + pub fn accept(socket: ::c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getpeername$UNIX2003")] - pub fn getpeername(socket: c_int, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; + pub fn getpeername(socket: ::c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getsockname$UNIX2003")] - pub fn getsockname(socket: c_int, address: *mut sockaddr, - address_len: *mut socklen_t) -> c_int; - pub fn setsockopt(socket: c_int, level: c_int, name: c_int, + pub fn getsockname(socket: ::c_int, address: *mut sockaddr, + address_len: *mut socklen_t) -> ::c_int; + pub fn setsockopt(socket: ::c_int, level: ::c_int, name: ::c_int, value: *const ::c_void, - option_len: socklen_t) -> c_int; + option_len: socklen_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003")] - pub fn sendto(socket: c_int, buf: *const ::c_void, len: size_t, - flags: c_int, addr: *const sockaddr, - addrlen: socklen_t) -> ssize_t; - pub fn shutdown(socket: c_int, how: c_int) -> c_int; + pub fn sendto(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_int, addr: *const sockaddr, + addrlen: socklen_t) -> ::ssize_t; + pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "chmod$UNIX2003")] - pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn chmod(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fchmod$UNIX2003")] - pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + pub fn fchmod(fd: ::c_int, mode: mode_t) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] - pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; - pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; + pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] - pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "popen$UNIX2003")] pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; - pub fn pclose(stream: *mut ::FILE) -> c_int; + pub fn pclose(stream: *mut ::FILE) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fdopen$UNIX2003")] - pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut ::FILE; - pub fn fileno(stream: *mut ::FILE) -> c_int; + pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; + pub fn fileno(stream: *mut ::FILE) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "open$UNIX2003")] - pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "creat$UNIX2003")] - pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fcntl$UNIX2003")] - pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; + pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "opendir$INODE64")] @@ -184,161 +172,161 @@ extern { pub fn opendir(dirname: *const c_char) -> *mut ::DIR; #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, - result: *mut *mut ::dirent) -> c_int; + result: *mut *mut ::dirent) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "closedir$UNIX2003")] - pub fn closedir(dirp: *mut ::DIR) -> c_int; + pub fn closedir(dirp: *mut ::DIR) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "rewinddir$INODE64")] #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "rewinddir$INODE64$UNIX2003")] pub fn rewinddir(dirp: *mut ::DIR); - pub fn access(path: *const c_char, amode: c_int) -> c_int; - pub fn alarm(seconds: c_uint) -> c_uint; - pub fn chdir(dir: *const c_char) -> c_int; + pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; + pub fn alarm(seconds: ::c_uint) -> ::c_uint; + pub fn chdir(dir: *const c_char) -> ::c_int; pub fn chown(path: *const c_char, uid: uid_t, - gid: gid_t) -> c_int; + gid: gid_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "close$UNIX2003")] - pub fn close(fd: c_int) -> c_int; - pub fn dup(fd: c_int) -> c_int; - pub fn dup2(src: c_int, dst: c_int) -> c_int; + pub fn close(fd: ::c_int) -> ::c_int; + pub fn dup(fd: ::c_int) -> ::c_int; + pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; pub fn execv(prog: *const c_char, - argv: *const *const c_char) -> c_int; + argv: *const *const c_char) -> ::c_int; pub fn execve(prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char) - -> c_int; + -> ::c_int; pub fn execvp(c: *const c_char, - argv: *const *const c_char) -> c_int; + argv: *const *const c_char) -> ::c_int; pub fn fork() -> pid_t; - pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; - pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; pub fn getegid() -> gid_t; pub fn geteuid() -> uid_t; pub fn getgid() -> gid_t; - pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) - -> c_int; + pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) + -> ::c_int; pub fn getlogin() -> *mut c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getopt$UNIX2003")] - pub fn getopt(argc: c_int, argv: *const *mut c_char, - optstr: *const c_char) -> c_int; + pub fn getopt(argc: ::c_int, argv: *const *mut c_char, + optstr: *const c_char) -> ::c_int; pub fn getpgrp() -> pid_t; pub fn getpid() -> pid_t; pub fn getppid() -> pid_t; pub fn getuid() -> uid_t; - pub fn isatty(fd: c_int) -> c_int; - pub fn link(src: *const c_char, dst: *const c_char) -> c_int; - pub fn lseek(fd: c_int, offset: off_t, whence: c_int) + pub fn isatty(fd: ::c_int) -> ::c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; + pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; - pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pause$UNIX2003")] - pub fn pause() -> c_int; - pub fn pipe(fds: *mut c_int) -> c_int; + pub fn pause() -> ::c_int; + pub fn pipe(fds: *mut ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "read$UNIX2003")] - pub fn read(fd: c_int, buf: *mut ::c_void, count: size_t) - -> ssize_t; - pub fn rmdir(path: *const c_char) -> c_int; - pub fn setgid(gid: gid_t) -> c_int; - pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) + -> ::ssize_t; + pub fn rmdir(path: *const c_char) -> ::c_int; + pub fn setgid(gid: gid_t) -> ::c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; pub fn setsid() -> pid_t; - pub fn setuid(uid: uid_t) -> c_int; + pub fn setuid(uid: uid_t) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "sleep$UNIX2003")] - pub fn sleep(secs: c_uint) -> c_uint; + pub fn sleep(secs: ::c_uint) -> ::c_uint; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "nanosleep$UNIX2003")] pub fn nanosleep(rqtp: *const timespec, - rmtp: *mut timespec) -> c_int; - pub fn tcgetpgrp(fd: c_int) -> pid_t; - pub fn ttyname(fd: c_int) -> *mut c_char; - pub fn unlink(c: *const c_char) -> c_int; + rmtp: *mut timespec) -> ::c_int; + pub fn tcgetpgrp(fd: ::c_int) -> pid_t; + pub fn ttyname(fd: ::c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "wait$UNIX2003")] - pub fn wait(status: *mut c_int) -> pid_t; + pub fn wait(status: *mut ::c_int) -> pid_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "waitpid$UNIX2003")] - pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) + pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "write$UNIX2003")] - pub fn write(fd: c_int, buf: *const ::c_void, count: size_t) - -> ssize_t; + pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) + -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pread$UNIX2003")] - pub fn pread(fd: c_int, buf: *mut ::c_void, count: size_t, - offset: off_t) -> ssize_t; + pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, + offset: off_t) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "pwrite$UNIX2003")] - pub fn pwrite(fd: c_int, buf: *const ::c_void, count: size_t, - offset: off_t) -> ssize_t; - pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; + pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, + offset: off_t) -> ::ssize_t; + pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "kill$UNIX2003")] - pub fn kill(pid: pid_t, sig: c_int) -> c_int; + pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; - pub fn mlock(addr: *const ::c_void, len: size_t) -> c_int; - pub fn munlock(addr: *const ::c_void, len: size_t) -> c_int; - pub fn mlockall(flags: c_int) -> c_int; - pub fn munlockall() -> c_int; + pub fn mlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn munlock(addr: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn mlockall(flags: ::c_int) -> ::c_int; + pub fn munlockall() -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mmap$UNIX2003")] pub fn mmap(addr: *mut ::c_void, - len: size_t, - prot: c_int, - flags: c_int, - fd: c_int, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, offset: off_t) -> *mut ::c_void; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "munmap$UNIX2003")] - pub fn munmap(addr: *mut ::c_void, len: size_t) -> c_int; + pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; - pub fn if_nametoindex(ifname: *const c_char) -> c_uint; + pub fn if_nametoindex(ifname: *const c_char) -> ::c_uint; #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] - pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "fsync$UNIX2003")] - pub fn fsync(fd: c_int) -> c_int; + pub fn fsync(fd: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "setenv$UNIX2003")] pub fn setenv(name: *const c_char, val: *const c_char, - overwrite: c_int) -> c_int; + overwrite: ::c_int) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "unsetenv$UNIX2003")] - pub fn unsetenv(name: *const c_char) -> c_int; + pub fn unsetenv(name: *const c_char) -> ::c_int; pub fn symlink(path1: *const c_char, - path2: *const c_char) -> c_int; + path2: *const c_char) -> ::c_int; - pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; #[cfg_attr(target_os = "android", link_name = "bsd_signal")] - pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "getrlimit$UNIX2003")] - pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; + pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "setrlimit$UNIX2003")] - pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; - pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int; + pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; - pub fn getdtablesize() -> c_int; + pub fn getdtablesize() -> ::c_int; #[cfg_attr(any(target_os = "macos", target_os = "ios"), link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char; - pub fn flock(fd: c_int, operation: c_int) -> c_int; + pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; @@ -362,11 +350,11 @@ extern { pub fn sched_yield() -> ::c_int; pub fn pthread_key_create(key: *mut pthread_key_t, dtor: ::dox::Option) - -> c_int; - pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + -> ::c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) - -> c_int; + -> ::c_int; pub fn pthread_mutex_init(lock: *mut pthread_mutex_t, attr: *const pthread_mutexattr_t) -> ::c_int; pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; @@ -417,8 +405,8 @@ extern { oldset: *mut sigset_t) -> ::c_int; // #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] - pub fn strerror_r(errnum: c_int, buf: *mut c_char, - buflen: size_t) -> c_int; + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; pub fn getsockopt(sockfd: ::c_int, level: ::c_int, @@ -448,20 +436,20 @@ extern { // TODO: get rid of this #[cfg(not(...))] #[cfg(not(target_os = "android"))] extern { - pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int; + pub fn getifaddrs(ifap: *mut *mut ifaddrs) -> ::c_int; pub fn freeifaddrs(ifa: *mut ifaddrs); #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] pub fn glob(pattern: *const c_char, - flags: c_int, + flags: ::c_int, errfunc: ::dox::Option c_int>, - pglob: *mut glob_t) -> c_int; + errno: ::c_int) -> ::c_int>, + pglob: *mut glob_t) -> ::c_int; pub fn globfree(pglob: *mut glob_t); - pub fn posix_madvise(addr: *mut ::c_void, len: size_t, advice: c_int) - -> c_int; + pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; - pub fn shm_unlink(name: *const c_char) -> c_int; + pub fn shm_unlink(name: *const c_char) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), link_name = "seekdir$INODE64")] @@ -476,37 +464,37 @@ extern { pub fn telldir(dirp: *mut ::DIR) -> c_long; pub fn getsid(pid: pid_t) -> pid_t; - pub fn madvise(addr: *mut ::c_void, len: size_t, advice: c_int) - -> c_int; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) + -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "putenv$UNIX2003")] - pub fn putenv(string: *mut c_char) -> c_int; + pub fn putenv(string: *mut c_char) -> ::c_int; pub fn readlink(path: *const c_char, buf: *mut c_char, - bufsz: size_t) - -> ssize_t; + bufsz: ::size_t) + -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "msync$UNIX2003")] - pub fn msync(addr: *mut ::c_void, len: size_t, flags: c_int) -> c_int; - pub fn sysconf(name: c_int) -> c_long; + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; + pub fn sysconf(name: ::c_int) -> c_long; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "usleep$UNIX2003")] - pub fn usleep(secs: c_uint) -> c_int; + pub fn usleep(secs: ::c_uint) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recvfrom$UNIX2003")] - pub fn recvfrom(socket: c_int, buf: *mut ::c_void, len: size_t, - flags: c_int, addr: *mut sockaddr, - addrlen: *mut socklen_t) -> ssize_t; + pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int, addr: *mut sockaddr, + addrlen: *mut socklen_t) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "send$UNIX2003")] - pub fn send(socket: c_int, buf: *const ::c_void, len: size_t, - flags: c_int) -> ssize_t; + pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "recv$UNIX2003")] - pub fn recv(socket: c_int, buf: *mut ::c_void, len: size_t, - flags: c_int) -> ssize_t; - pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, + flags: ::c_int) -> ::ssize_t; + pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; pub fn getpwuid_r(uid: ::uid_t, pwd: *mut passwd, diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index fe296bdfc5ebc..3b3c9eb451c31 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -3,17 +3,12 @@ pub type c_char = u8; pub type c_long = i32; pub type c_ulong = u32; -pub type size_t = u32; -pub type ptrdiff_t = i32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = u32; -pub type intptr_t = i32; -pub type uintptr_t = u32; pub type off_t = i32; pub type ino_t = u32; -pub type ssize_t = i32; pub type blkcnt_t = u32; pub type blksize_t = u32; pub type dev_t = u32; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 53cd2db13255a..2f2eabec114f6 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -1,17 +1,12 @@ pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; -pub type size_t = u32; -pub type ptrdiff_t = i32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; pub type wchar_t = i32; -pub type intptr_t = i32; -pub type uintptr_t = u32; pub type off_t = i32; pub type ino_t = u32; -pub type ssize_t = i32; pub type blkcnt_t = i32; pub type blksize_t = i32; pub type nlink_t = u32; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index d45cb4eb85ad4..6606b41c9c6e0 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -8,9 +8,9 @@ pub type mode_t = u32; s! { pub struct glob_t { - pub gl_pathc: size_t, + pub gl_pathc: ::size_t, pub gl_pathv: *mut *mut c_char, - pub gl_offs: size_t, + pub gl_offs: ::size_t, pub gl_flags: ::c_int, __unused1: *mut ::c_void, @@ -223,9 +223,9 @@ extern { cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "x86", target_arch = "x86_64"))] { - pub const PTHREAD_STACK_MIN: size_t = 16384; + pub const PTHREAD_STACK_MIN: ::size_t = 16384; } else { - pub const PTHREAD_STACK_MIN: size_t = 131072; + pub const PTHREAD_STACK_MIN: ::size_t = 131072; } } @@ -255,9 +255,9 @@ cfg_if! { pub fn sysctl(name: *mut ::c_int, namelen: ::c_int, oldp: *mut ::c_void, - oldlenp: *mut size_t, + oldlenp: *mut ::size_t, newp: *mut ::c_void, - newlen: size_t) + newlen: ::size_t) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, diff --git a/src/unix/notbsd/linux/notmips/b32/mod.rs b/src/unix/notbsd/linux/notmips/b32/mod.rs index b437d76d95ef0..4e6024fa6d04f 100644 --- a/src/unix/notbsd/linux/notmips/b32/mod.rs +++ b/src/unix/notbsd/linux/notmips/b32/mod.rs @@ -2,16 +2,11 @@ pub type c_long = i32; pub type c_ulong = u32; -pub type size_t = u32; -pub type ptrdiff_t = i32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; -pub type intptr_t = i32; -pub type uintptr_t = u32; pub type ino_t = u32; pub type off_t = i32; -pub type ssize_t = i32; pub type blkcnt_t = i32; pub type blksize_t = i32; diff --git a/src/unix/notbsd/linux/notmips/b64/mod.rs b/src/unix/notbsd/linux/notmips/b64/mod.rs index 1916dc43aac95..ce3f3381c070f 100644 --- a/src/unix/notbsd/linux/notmips/b64/mod.rs +++ b/src/unix/notbsd/linux/notmips/b64/mod.rs @@ -2,16 +2,11 @@ pub type c_long = i64; pub type c_ulong = u64; -pub type size_t = u64; -pub type ptrdiff_t = i64; pub type clock_t = i64; pub type time_t = i64; pub type suseconds_t = i64; -pub type intptr_t = i64; -pub type uintptr_t = u64; pub type ino_t = u64; pub type off_t = i64; -pub type ssize_t = i64; pub type blkcnt_t = i64; s! { diff --git a/src/windows.rs b/src/windows.rs index e69d682d407a0..a4783cb0810a7 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,39 +1,9 @@ //! Windows CRT definitions pub type c_char = i8; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; pub type c_long = i32; pub type c_ulong = u32; -pub type c_float = f32; -pub type c_double = f64; pub type wchar_t = u16; -pub type c_longlong = i64; -pub type c_ulonglong = u64; -pub type intmax_t = i64; -pub type uintmax_t = u64; - -cfg_if! { - if #[cfg(target_arch = "x86")] { - pub type intptr_t = i32; - pub type ptrdiff_t = i32; - pub type size_t = u32; - pub type ssize_t = i32; - pub type uintptr_t = u32; - } else if #[cfg(target_arch = "x86_64")] { - pub type intptr_t = i64; - pub type ptrdiff_t = i64; - pub type size_t = u64; - pub type ssize_t = i64; - pub type uintptr_t = u64; - } else { - // unknown arch - } -} pub type clock_t = i32; @@ -57,9 +27,9 @@ s! { pub st_dev: dev_t, pub st_ino: ino_t, pub st_mode: u16, - pub st_nlink: c_short, - pub st_uid: c_short, - pub st_gid: c_short, + pub st_nlink: ::c_short, + pub st_uid: ::c_short, + pub st_gid: ::c_short, pub st_rdev: dev_t, pub st_size: i64, pub st_atime: time64_t, @@ -84,47 +54,47 @@ s! { } } -pub const EXIT_FAILURE: c_int = 1; -pub const EXIT_SUCCESS: c_int = 0; -pub const RAND_MAX: c_int = 32767; -pub const EOF: c_int = -1; -pub const SEEK_SET: c_int = 0; -pub const SEEK_CUR: c_int = 1; -pub const SEEK_END: c_int = 2; -pub const _IOFBF: c_int = 0; -pub const _IONBF: c_int = 4; -pub const _IOLBF: c_int = 64; -pub const BUFSIZ: c_uint = 512; -pub const FOPEN_MAX: c_uint = 20; -pub const FILENAME_MAX: c_uint = 260; +pub const EXIT_FAILURE: ::c_int = 1; +pub const EXIT_SUCCESS: ::c_int = 0; +pub const RAND_MAX: ::c_int = 32767; +pub const EOF: ::c_int = -1; +pub const SEEK_SET: ::c_int = 0; +pub const SEEK_CUR: ::c_int = 1; +pub const SEEK_END: ::c_int = 2; +pub const _IOFBF: ::c_int = 0; +pub const _IONBF: ::c_int = 4; +pub const _IOLBF: ::c_int = 64; +pub const BUFSIZ: ::c_uint = 512; +pub const FOPEN_MAX: ::c_uint = 20; +pub const FILENAME_MAX: ::c_uint = 260; cfg_if! { if #[cfg(all(target_env = "gnu"))] { - pub const L_tmpnam: c_uint = 14; - pub const TMP_MAX: c_uint = 0x7fff; + pub const L_tmpnam: ::c_uint = 14; + pub const TMP_MAX: ::c_uint = 0x7fff; } else { - pub const L_tmpnam: c_uint = 260; - pub const TMP_MAX: c_uint = 0x7fff_ffff; + pub const L_tmpnam: ::c_uint = 260; + pub const TMP_MAX: ::c_uint = 0x7fff_ffff; } } -pub const O_RDONLY: c_int = 0; -pub const O_WRONLY: c_int = 1; -pub const O_RDWR: c_int = 2; -pub const O_APPEND: c_int = 8; -pub const O_CREAT: c_int = 256; -pub const O_EXCL: c_int = 1024; -pub const O_TEXT: c_int = 16384; -pub const O_BINARY: c_int = 32768; -pub const O_NOINHERIT: c_int = 128; -pub const O_TRUNC: c_int = 512; -pub const S_IFCHR: c_int = 8192; -pub const S_IFDIR: c_int = 16384; -pub const S_IFREG: c_int = 32768; -pub const S_IFMT: c_int = 61440; -pub const S_IEXEC: c_int = 64; -pub const S_IWRITE: c_int = 128; -pub const S_IREAD: c_int = 256; +pub const O_RDONLY: ::c_int = 0; +pub const O_WRONLY: ::c_int = 1; +pub const O_RDWR: ::c_int = 2; +pub const O_APPEND: ::c_int = 8; +pub const O_CREAT: ::c_int = 256; +pub const O_EXCL: ::c_int = 1024; +pub const O_TEXT: ::c_int = 16384; +pub const O_BINARY: ::c_int = 32768; +pub const O_NOINHERIT: ::c_int = 128; +pub const O_TRUNC: ::c_int = 512; +pub const S_IFCHR: ::c_int = 8192; +pub const S_IFDIR: ::c_int = 16384; +pub const S_IFREG: ::c_int = 32768; +pub const S_IFMT: ::c_int = 61440; +pub const S_IEXEC: ::c_int = 64; +pub const S_IWRITE: ::c_int = 128; +pub const S_IREAD: ::c_int = 256; #[cfg(target_env = "msvc")] #[link(name = "msvcrt")] @@ -132,77 +102,77 @@ extern {} extern { #[link_name = "_chmod"] - pub fn chmod(path: *const c_char, mode: c_int) -> c_int; + pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int; #[link_name = "_wchmod"] - pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; + pub fn wchmod(path: *const wchar_t, mode: ::c_int) -> ::c_int; #[link_name = "_mkdir"] - pub fn mkdir(path: *const c_char) -> c_int; + pub fn mkdir(path: *const c_char) -> ::c_int; #[link_name = "_wrmdir"] - pub fn wrmdir(path: *const wchar_t) -> c_int; + pub fn wrmdir(path: *const wchar_t) -> ::c_int; #[link_name = "_fstat64"] - pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; #[link_name = "_stat64"] - pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; #[link_name = "_wstat64"] - pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; + pub fn wstat(path: *const wchar_t, buf: *mut stat) -> ::c_int; #[link_name = "_wutime64"] - pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; + pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> ::c_int; #[link_name = "_popen"] pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; #[link_name = "_pclose"] - pub fn pclose(stream: *mut ::FILE) -> c_int; + pub fn pclose(stream: *mut ::FILE) -> ::c_int; #[link_name = "_fdopen"] - pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut ::FILE; + pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; #[link_name = "_fileno"] - pub fn fileno(stream: *mut ::FILE) -> c_int; + pub fn fileno(stream: *mut ::FILE) -> ::c_int; #[link_name = "_open"] - pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; #[link_name = "_wopen"] - pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int; + pub fn wopen(path: *const wchar_t, oflag: ::c_int, ...) -> ::c_int; #[link_name = "_creat"] - pub fn creat(path: *const c_char, mode: c_int) -> c_int; + pub fn creat(path: *const c_char, mode: ::c_int) -> ::c_int; #[link_name = "_access"] - pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; #[link_name = "_chdir"] - pub fn chdir(dir: *const c_char) -> c_int; + pub fn chdir(dir: *const c_char) -> ::c_int; #[link_name = "_close"] - pub fn close(fd: c_int) -> c_int; + pub fn close(fd: ::c_int) -> ::c_int; #[link_name = "_dup"] - pub fn dup(fd: c_int) -> c_int; + pub fn dup(fd: ::c_int) -> ::c_int; #[link_name = "_dup2"] - pub fn dup2(src: c_int, dst: c_int) -> c_int; + pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; #[link_name = "_execv"] - pub fn execv(prog: *const c_char, argv: *const *const c_char) -> intptr_t; + pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::intptr_t; #[link_name = "_execve"] pub fn execve(prog: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) -> c_int; + envp: *const *const c_char) -> ::c_int; #[link_name = "_execvp"] - pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; #[link_name = "_execvpe"] pub fn execvpe(c: *const c_char, argv: *const *const c_char, - envp: *const *const c_char) -> c_int; + envp: *const *const c_char) -> ::c_int; #[link_name = "_getcwd"] - pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char; + pub fn getcwd(buf: *mut c_char, size: ::c_int) -> *mut c_char; #[link_name = "_getpid"] - pub fn getpid() -> c_int; + pub fn getpid() -> ::c_int; #[link_name = "_isatty"] - pub fn isatty(fd: c_int) -> c_int; + pub fn isatty(fd: ::c_int) -> ::c_int; #[link_name = "_lseek"] - pub fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long; + pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long; #[link_name = "_pipe"] - pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) -> c_int; + pub fn pipe(fds: *mut ::c_int, psize: ::c_uint, textmode: ::c_int) -> ::c_int; #[link_name = "_read"] - pub fn read(fd: c_int, buf: *mut ::c_void, count: c_uint) -> c_int; + pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::c_uint) -> ::c_int; #[link_name = "_rmdir"] - pub fn rmdir(path: *const c_char) -> c_int; + pub fn rmdir(path: *const c_char) -> ::c_int; #[link_name = "_unlink"] - pub fn unlink(c: *const c_char) -> c_int; + pub fn unlink(c: *const c_char) -> ::c_int; #[link_name = "_write"] - pub fn write(fd: c_int, buf: *const ::c_void, count: c_uint) -> c_int; + pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::c_uint) -> ::c_int; #[link_name = "_commit"] - pub fn commit(fd: c_int) -> c_int; + pub fn commit(fd: ::c_int) -> ::c_int; #[link_name = "_get_osfhandle"] - pub fn get_osfhandle(fd: c_int) -> intptr_t; + pub fn get_osfhandle(fd: ::c_int) -> ::intptr_t; #[link_name = "_open_osfhandle"] - pub fn open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int; + pub fn open_osfhandle(osfhandle: ::intptr_t, flags: ::c_int) -> ::c_int; } From 41e7a69e2a3904bfe4610088bac19ed61b141d25 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Sep 2015 19:22:09 -0700 Subject: [PATCH 177/194] Fix OSX --- src/unix/bsd/apple/mod.rs | 6 +++--- src/unix/bsd/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 74435c43ebd58..7aefcab271e45 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -19,9 +19,9 @@ pub enum timezone {} s! { pub struct glob_t { - pub gl_pathc: size_t, + pub gl_pathc: ::size_t, __unused1: ::c_int, - pub gl_offs: size_t, + pub gl_offs: ::size_t, __unused2: ::c_int, pub gl_pathv: *mut *mut ::c_char, @@ -389,7 +389,7 @@ pub const _SC_XOPEN_XCU_VERSION: ::c_int = 121; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1; pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; -pub const PTHREAD_STACK_MIN: size_t = 8192; +pub const PTHREAD_STACK_MIN: ::size_t = 8192; pub const RLIMIT_CPU: ::c_int = 0; pub const RLIMIT_FSIZE: ::c_int = 1; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index c994d9c8509a3..a1c854845170d 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -5,7 +5,7 @@ pub type useconds_t = u32; pub type blkcnt_t = i64; pub type socklen_t = u32; pub type sa_family_t = u8; -pub type pthread_t = uintptr_t; +pub type pthread_t = ::uintptr_t; s! { pub struct sockaddr { @@ -76,11 +76,11 @@ pub const IPV6_MULTICAST_LOOP: ::c_int = 11; pub const IPV6_V6ONLY: ::c_int = 27; extern { - pub fn mincore(addr: *const ::c_void, len: size_t, + pub fn mincore(addr: *const ::c_void, len: ::size_t, vec: *mut c_char) -> ::c_int; pub fn sysctlnametomib(name: *const c_char, mibp: *mut ::c_int, - sizep: *mut size_t) + sizep: *mut ::size_t) -> ::c_int; pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; From 67e3388d19631c010f66e161adbe62a7f3669130 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Sep 2015 21:09:40 -0700 Subject: [PATCH 178/194] Add FIONBIO --- src/unix/bsd/mod.rs | 1 + src/unix/notbsd/android/mod.rs | 2 ++ src/unix/notbsd/linux/mips.rs | 1 + src/unix/notbsd/linux/notmips/mod.rs | 1 + 4 files changed, 5 insertions(+) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a1c854845170d..8c8460ef2d4b1 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -65,6 +65,7 @@ s! { } pub const FIOCLEX: c_ulong = 0x20006601; +pub const FIONBIO: ::c_int = 0x8004667e; pub const SA_ONSTACK: ::c_int = 0x0001; pub const SA_SIGINFO: ::c_int = 0x0040; diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 3b3c9eb451c31..68f93b1f87c2d 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -96,6 +96,8 @@ pub const L_tmpnam: ::c_uint = 1024; pub const TMP_MAX: ::c_uint = 308915776; pub const _PC_NAME_MAX: ::c_int = 4; +pub const FIONBIO: ::c_int = 0x5421; + pub const _SC_ARG_MAX: ::c_int = 0; pub const _SC_BC_BASE_MAX: ::c_int = 1; pub const _SC_BC_DIM_MAX: ::c_int = 2; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 2f2eabec114f6..607e6a14c4e99 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -202,6 +202,7 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const FIOCLEX: ::c_ulong = 0x6601; +pub const FIONBIO: ::c_int = 0x667e; pub const SA_ONSTACK: ::c_ulong = 0x08000000; pub const SA_SIGINFO: ::c_ulong = 0x00000008; diff --git a/src/unix/notbsd/linux/notmips/mod.rs b/src/unix/notbsd/linux/notmips/mod.rs index 9a3ca318a96ba..f69b1ac7f069f 100644 --- a/src/unix/notbsd/linux/notmips/mod.rs +++ b/src/unix/notbsd/linux/notmips/mod.rs @@ -167,6 +167,7 @@ pub const TCP_TIMESTAMP: ::c_int = 24; pub const SO_REUSEPORT: ::c_int = 15; pub const FIOCLEX: ::c_ulong = 0x5451; +pub const FIONBIO: ::c_int = 0x5421; pub const SA_ONSTACK: ::c_ulong = 0x08000000; pub const SA_SIGINFO: ::c_ulong = 0x00000004; From ab0442cd1596c38333f9b123440eabb61ca1b1d1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Oct 2015 14:38:47 -0700 Subject: [PATCH 179/194] AppVeyor has MSYS2 installed by default now! --- appveyor.yml | 9 +-------- ci/msys2.ps1 | 22 ---------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 ci/msys2.ps1 diff --git a/appveyor.yml b/appveyor.yml index c2d28e4445e34..74811ed105eca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,23 +1,16 @@ environment: - global: - MSYS2_BASEVER: 20150512 matrix: - TARGET: x86_64-pc-windows-gnu - MSYS2_ARCH: x86_64 MSYS2_BITS: 64 - MSYSTEM: MINGW64 - TARGET: i686-pc-windows-gnu - MSYS2_ARCH: i686 MSYS2_BITS: 32 - MSYSTEM: MINGW32 - TARGET: x86_64-pc-windows-msvc - TARGET: i686-pc-windows-msvc install: - - ps: ci\msys2.ps1 - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - - if defined MSYS2_BITS set PATH=%PATH%;%CD%\msys2\mingw%MSYS2_BITS%\bin + - if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin - rustc -V - cargo -V diff --git a/ci/msys2.ps1 b/ci/msys2.ps1 deleted file mode 100644 index 071e8f4af0294..0000000000000 --- a/ci/msys2.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -# Installs MSYS2 on AppVeyor builders - -If (!${env:MSYS2_ARCH}) { - Exit 0 -} - -Start-FileDownload ` - ("http://kent.dl.sourceforge.net/project/msys2/Base/" + ` - $env:MSYS2_ARCH + "/msys2-base-" + $env:MSYS2_ARCH + "-" + ` - $env:MSYS2_BASEVER + ".tar.xz") ` - -FileName "msys2.tar.xz" - -7z x msys2.tar.xz -7z x msys2.tar > $nul -Move-Item ("msys" + $env:MSYS2_BITS) msys2 -.\msys2\usr\bin\bash.exe -lc "" -.\msys2\usr\bin\bash.exe -lc ` - ("for i in {1..3}; do " + ` - "pacman --noconfirm -Suy mingw-w64-"+ $env:MSYS2_ARCH + "-gcc " + ` - "&& break || sleep 15; " + ` - "done") -.\msys2\autorebase.bat From cc12d2b2d32f4cabc12f53953220932f6f353152 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 14 Oct 2015 15:58:08 -0700 Subject: [PATCH 180/194] Pass -y to apt-get --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index ee58b887392a8..bb40ba737b350 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -17,7 +17,7 @@ EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 install() { sudo apt-get update - sudo apt-get install $@ + sudo apt-get install -y $@ } case "$TARGET" in From a1da67dbaa5440eb3ed18de7379166ce6813ea1c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 21 Oct 2015 10:04:09 -0700 Subject: [PATCH 181/194] Try to fix nightly CI --- ci/run-travis.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index bb40ba737b350..dbea32837de5f 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -69,9 +69,13 @@ case "$TARGET" in *) # Download the rustlib folder from the relevant portion of main distribution's # tarballs. + pkg=rustc + if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then + pkg=rust-std + fi curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ - rust-$TRAVIS_RUST_VERSION-$HOST/rustc/lib/rustlib/$HOST + rust-$TRAVIS_RUST_VERSION-$HOST/$pkg/lib/rustlib/$HOST TARGET=$HOST # clang has better error messages and implements alignof more broadly From 573f2de6accd55cfde2d7f1cbab255d7f3466359 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 21 Oct 2015 10:23:08 -0700 Subject: [PATCH 182/194] Another attempt at fixing nightly --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index dbea32837de5f..5b9eeff987f03 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -71,7 +71,7 @@ case "$TARGET" in # tarballs. pkg=rustc if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then - pkg=rust-std + pkg=rust-std-$HOST fi curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ From 354693de77c376d2fc6e92f871f103d6a4a98ab8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 28 Oct 2015 14:11:53 -0700 Subject: [PATCH 183/194] Update CI --- ci/run-travis.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 5b9eeff987f03..71593170a160b 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -69,9 +69,9 @@ case "$TARGET" in *) # Download the rustlib folder from the relevant portion of main distribution's # tarballs. - pkg=rustc - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then - pkg=rust-std-$HOST + pkg=rust-std-$HOST + if [ "$TRAVIS_RUST_VERSION" == "1.0.0" ]; then + pkg=rustc fi curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ From b017b5e72f5be63567b0d0cacccb6efa7b4b5889 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 28 Oct 2015 14:46:38 -0700 Subject: [PATCH 184/194] Really fix ci... --- ci/run-travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 71593170a160b..09f2d79dabc8c 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -70,7 +70,7 @@ case "$TARGET" in # Download the rustlib folder from the relevant portion of main distribution's # tarballs. pkg=rust-std-$HOST - if [ "$TRAVIS_RUST_VERSION" == "1.0.0" ]; then + if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then pkg=rustc fi curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ From 657eeec3b6f608e8315079247bab5082d8c6b538 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 10:06:09 -0700 Subject: [PATCH 185/194] Run more extra targets on nightly --- .travis.yml | 10 +++++----- ci/run-travis.sh | 41 ++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 837025fedd246..cb303ac4d0d79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,19 +21,19 @@ matrix: include: - os: linux env: TARGET=arm-linux-androideabi - rust: nightly-2015-09-08 + rust: nightly - os: linux env: TARGET=x86_64-unknown-linux-musl - rust: nightly-2015-09-08 + rust: nightly - os: linux env: TARGET=arm-unknown-linux-gnueabihf - rust: nightly-2015-09-08 + rust: nightly - os: linux env: TARGET=mips-unknown-linux-gnu - rust: nightly-2015-09-08 + rust: nightly - os: linux env: TARGET=aarch64-unknown-linux-gnu - rust: nightly-2015-09-08 + rust: nightly - os: osx env: TARGET=i386-apple-ios rust: nightly-2015-09-08 diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 09f2d79dabc8c..f214babcfc474 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -11,6 +11,9 @@ else fi export HOST=$ARCH-$OS +if [ "$TARGET" = "" ]; then + TARGET=$HOST +fi MAIN_TARGETS=https://static.rust-lang.org/dist EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 @@ -20,6 +23,27 @@ install() { sudo apt-get install -y $@ } +case "$TARGET" in + *-apple-ios) + curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib + ;; + + *) + # Download the rustlib folder from the relevant portion of main distribution's + # tarballs. + dir=rust-std-$TARGET + pkg=rust-std + if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then + pkg=rust + dir=rustc + fi + curl -s $MAIN_TARGETS/$pkg-$TRAVIS_RUST_VERSION-$TARGET.tar.gz | \ + tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ + $pkg-$TRAVIS_RUST_VERSION-$TARGET/$dir/lib/rustlib/$TARGET + ;; + +esac + case "$TARGET" in # Pull a pre-built docker image for testing android, then run tests entirely #d within that image. @@ -30,33 +54,27 @@ case "$TARGET" in ;; x86_64-unknown-linux-musl) - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib install musl-tools export CC=musl-gcc ;; arm-unknown-linux-gnueabihf) - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib install gcc-4.7-arm-linux-gnueabihf qemu-user export CC=arm-linux-gnueabihf-gcc-4.7 ;; aarch64-unknown-linux-gnu) - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib install gcc-aarch64-linux-gnu qemu-user export CC=aarch64-linux-gnu-gcc ;; *-apple-ios) - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib ;; mips-unknown-linux-gnu) # Download pre-built and custom MIPS libs and then also instsall the MIPS # compiler according to this post: # http://sathisharada.blogspot.com/2014_10_01_archive.html - curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib - echo 'deb http://ftp.de.debian.org/debian squeeze main' | \ sudo tee -a /etc/apt/sources.list echo 'deb http://www.emdebian.org/debian/ squeeze main' | \ @@ -67,17 +85,6 @@ case "$TARGET" in ;; *) - # Download the rustlib folder from the relevant portion of main distribution's - # tarballs. - pkg=rust-std-$HOST - if [ "$TRAVIS_RUST_VERSION" = "1.0.0" ]; then - pkg=rustc - fi - curl -s $MAIN_TARGETS/rust-$TRAVIS_RUST_VERSION-$HOST.tar.gz | \ - tar xzf - -C $HOME/rust/lib/rustlib --strip-components=4 \ - rust-$TRAVIS_RUST_VERSION-$HOST/$pkg/lib/rustlib/$HOST - TARGET=$HOST - # clang has better error messages and implements alignof more broadly export CC=clang From 13418a50fc55ba3ed5b7bd6ee204ec8fda9f4b2f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 11:54:12 -0700 Subject: [PATCH 186/194] Improve the README and switch URLs --- README.md | 101 +++++++++++++++++++++++++++++++++++++++++++++-------- src/lib.rs | 26 +++++++------- 2 files changed, 100 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index a1c8fdeb90a79..88f62813630d5 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,94 @@ libc A Rust library with native bindings to the types and functions commonly found on various systems, including libc. -[![Build Status](https://travis-ci.org/alexcrichton/libc.svg?branch=master)](https://travis-ci.org/alexcrichton/libc) -[![Build status](https://ci.appveyor.com/api/projects/status/v0414slj8y8nga0p?svg=true)](https://ci.appveyor.com/project/alexcrichton/libc) +[![Build Status](https://travis-ci.org/rust-lang/libc.svg?branch=master)](https://travis-ci.org/rust-lang/libc) +[![Build status](https://ci.appveyor.com/api/projects/status/v0414slj8y8nga0p?svg=true)](https://ci.appveyor.com/project/rust-lang/libc) -[Documentation](http://alexcrichton.com/libc) +[Documentation][#Platforms-and-Documentation] -## Platform Support +## Usage + +First, add the following to your `Cargo.toml`: + +```toml +[dependencies] +libc = "1.0" +``` + +Next, add this to your crate root: + +```rust +extern crate libc; +``` + +## What is libc? + +The primary purpose of this crate is to provide all of the definitions necessary +to easily interoperate with C code (or "C-like" code) on each of the platforms +that Rust supports. This includes type definitions (e.g. `c_int`), constants +(e.g. `EINVAL`) as well as function headers (e.g. `malloc`). + +This crate does not strive to have any form of compatibility across platforms, +but rather it is simply a straight binding to the system libraries on the +platform in question. + +## Public API + +This crate exports all underlying platform types, functions, and constants under +the crate root, so all items are accessible as `libc::foo`. The types and values +of all the exported APIs match the platform that libc is compiled for. + +## Adding an API + +Want to use an API which currently isn't bound in `libc`? It's quite easy to add +one! + +The internal structure of this crate is designed to minimize the number of +`#[cfg]` attributes in order to easily be able to add new items which apply +to all platforms in the future. As a result, the crate is organized +hierarchically based on platform. Each module has a number of `#[cfg]`'d +children, but only one is ever actually compiled. Each module then reexports all +the contents of its children. + +This means that for each platform that libc supports, the path from a +leaf module to the root will contain all bindings for the platform in question. +Consequently, this indicates where an API should be added! Adding an API at a +particular level in the hierarchy means that it is supported on all the child +platforms of that level. For example, when adding a Unix API it should be added +to `src/unix/mod.rs`, but when adding a Linux-only API it should be added to +`src/unix/notbsd/linux/mod.rs`. + +If you're not 100% sure at what level of the hierarchy an API should be added +at, fear not! This crate has CI support which tests any binding against all +platforms supported, so you'll see failures if an API is added at the wrong +level or has different signatures across platforms. + +## Platforms and Documentation + +The following platforms are currently tested and have documentation available: Tested: - * `{i686,x86_64}-pc-windows-{msvc,gnu}` - * `{i686,x86_64,mips,aarch64}-unknown-linux-gnu` - * `x86_64-unknown-linux-musl` - * `arm-unknown-linux-gnueabihf` - * `arm-linux-androideabi` - * `{i686,x86_64}-apple-{darwin,ios}` - -Untested: - * `{i686,x86_64}-unknown-freebsd` - * `x86_64-unknown-{bitrig,dragonfly,openbsd,netbsd}` + * [`i686-pc-windows-msvc`](https://doc.rust-lang.org/libc/i686-pc-windows-msvc/libc) + * [`x86_64-pc-windows-msvc`](https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc/libc) + * [`i686-pc-windows-gnu`](https://doc.rust-lang.org/libc/i686-pc-windows-gnu/libc) + * [`x86_64-pc-windows-gnu`](https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu/libc) + * [`i686-apple-darwin`](https://doc.rust-lang.org/libc/i686-apple-darwin/libc) + * [`x86_64-apple-darwin`](https://doc.rust-lang.org/libc/x86_64-apple-darwin/libc) + * [`i686-apple-ios`](https://doc.rust-lang.org/libc/i686-apple-ios/libc) + * [`x86_64-apple-ios`](https://doc.rust-lang.org/libc/x86_64-apple-ios/libc) + * [`i686-unknown-linux-gnu`](https://doc.rust-lang.org/libc/i686-unknown-linux-gnu/libc) + * [`x86_64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc) + * [`x86_64-unknown-linux-musl`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl/libc) + * [`aarch64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu/libc) + * [`mips-unknown-linux-gnu`](https://doc.rust-lang.org/libc/mips-unknown-linux-gnu/libc) + * [`arm-unknown-linux-gnueabihf`](https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf/libc) + * [`arm-linux-androideabi`](https://doc.rust-lang.org/libc/arm-linux-androideabi/libc) + +The following may be supported, but are not guaranteed to always work: + + * `x86_64-unknown-freebsd` + * `i686-unknown-freebsd` + * `x86_64-unknown-bitrig` + * `x86_64-unknown-dragonfly` + * `x86_64-unknown-openbsd` + * `x86_64-unknown-netbsd` diff --git a/src/lib.rs b/src/lib.rs index 84d89adcf232c..67d7416ad0f9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,43 +17,43 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] #![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc( - html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-gnu" + html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc( - html_root_url = "http://alexcrichton.com/libc/i686-unknown-linux-gnu" + html_root_url = "https://doc.rust-lang.org/libc/i686-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc( - html_root_url = "http://alexcrichton.com/libc/arm-unknown-linux-gnueabihf" + html_root_url = "https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf" ))] #![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc( - html_root_url = "http://alexcrichton.com/libc/mips-unknown-linux-gnu" + html_root_url = "https://doc.rust-lang.org/libc/mips-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc( - html_root_url = "http://alexcrichton.com/libc/aarch64-unknown-linux-gnu" + html_root_url = "https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu" ))] #![cfg_attr(all(target_os = "linux", target_env = "musl"), doc( - html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-musl" + html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl" ))] #![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc( - html_root_url = "http://alexcrichton.com/libc/x86_64-apple-darwin" + html_root_url = "https://doc.rust-lang.org/libc/x86_64-apple-darwin" ))] #![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc( - html_root_url = "http://alexcrichton.com/libc/i686-apple-darwin" + html_root_url = "https://doc.rust-lang.org/libc/i686-apple-darwin" ))] #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc( - html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-gnu" + html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu" ))] #![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc( - html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-gnu" + html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-gnu" ))] #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc( - html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-msvc" + html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc" ))] #![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc( - html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-msvc" + html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-msvc" ))] #![cfg_attr(all(target_os = "android"), doc( - html_root_url = "http://alexcrichton.com/libc/arm-linux-androideabi" + html_root_url = "https://doc.rust-lang.org/libc/arm-linux-androideabi" ))] #[macro_use] mod macros; From b1fbefa73b3cc698029b05f8775f4a0041f9733c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 11:56:13 -0700 Subject: [PATCH 187/194] Add some notes for common platforms --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 88f62813630d5..4d82511277e4a 100644 --- a/README.md +++ b/README.md @@ -73,19 +73,25 @@ The following platforms are currently tested and have documentation available: Tested: * [`i686-pc-windows-msvc`](https://doc.rust-lang.org/libc/i686-pc-windows-msvc/libc) * [`x86_64-pc-windows-msvc`](https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc/libc) + (Windows) * [`i686-pc-windows-gnu`](https://doc.rust-lang.org/libc/i686-pc-windows-gnu/libc) * [`x86_64-pc-windows-gnu`](https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu/libc) * [`i686-apple-darwin`](https://doc.rust-lang.org/libc/i686-apple-darwin/libc) * [`x86_64-apple-darwin`](https://doc.rust-lang.org/libc/x86_64-apple-darwin/libc) + (OSX) * [`i686-apple-ios`](https://doc.rust-lang.org/libc/i686-apple-ios/libc) * [`x86_64-apple-ios`](https://doc.rust-lang.org/libc/x86_64-apple-ios/libc) + (iOS) * [`i686-unknown-linux-gnu`](https://doc.rust-lang.org/libc/i686-unknown-linux-gnu/libc) * [`x86_64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc) + (Linux) * [`x86_64-unknown-linux-musl`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl/libc) + (Linux MUSL) * [`aarch64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu/libc) * [`mips-unknown-linux-gnu`](https://doc.rust-lang.org/libc/mips-unknown-linux-gnu/libc) * [`arm-unknown-linux-gnueabihf`](https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf/libc) * [`arm-linux-androideabi`](https://doc.rust-lang.org/libc/arm-linux-androideabi/libc) + (Android) The following may be supported, but are not guaranteed to always work: From 524e1374025e8162cccaf840db9e134257f8771c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 11:57:29 -0700 Subject: [PATCH 188/194] Add numbered steps to add an API --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 4d82511277e4a..9530a3241d0f9 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,14 @@ at, fear not! This crate has CI support which tests any binding against all platforms supported, so you'll see failures if an API is added at the wrong level or has different signatures across platforms. +With that in mind, the steps for adding a new API are: + +1. Determine where in the module hierarchy your API should be added. +2. Add the API. +3. Send a PR to this repo. +4. Wait for CI to pass, fixing errors. +5. Wait for a merge! + ## Platforms and Documentation The following platforms are currently tested and have documentation available: From 5289b311fb1e5737751e1718ca0285bcc364949b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 11:57:58 -0700 Subject: [PATCH 189/194] Fix a link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9530a3241d0f9..4e67dd0c7dbf8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ various systems, including libc. [![Build Status](https://travis-ci.org/rust-lang/libc.svg?branch=master)](https://travis-ci.org/rust-lang/libc) [![Build status](https://ci.appveyor.com/api/projects/status/v0414slj8y8nga0p?svg=true)](https://ci.appveyor.com/project/rust-lang/libc) -[Documentation][#Platforms-and-Documentation] +[Documentation](#platforms-and-documentation) ## Usage From 1f7e2e821a0ada2fb5c69effb6a7e65e14b915d7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 12:02:05 -0700 Subject: [PATCH 190/194] Fix appveyor link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e67dd0c7dbf8..4e678f46a85dd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A Rust library with native bindings to the types and functions commonly found on various systems, including libc. [![Build Status](https://travis-ci.org/rust-lang/libc.svg?branch=master)](https://travis-ci.org/rust-lang/libc) -[![Build status](https://ci.appveyor.com/api/projects/status/v0414slj8y8nga0p?svg=true)](https://ci.appveyor.com/project/rust-lang/libc) +[![Build status](https://ci.appveyor.com/api/projects/status/v0414slj8y8nga0p?svg=true)](https://ci.appveyor.com/project/alexcrichton/libc) [Documentation](#platforms-and-documentation) From 26942d5e76d775f5a70478720241b63d9ada5a85 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 12:03:30 -0700 Subject: [PATCH 191/194] Don't ignore .cargo --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3d61e5b48f598..a9d37c560c6ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ target Cargo.lock -/.cargo From bbf73ded8da17434ebc447336a6c307fb7d1c1ba Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 12:28:25 -0700 Subject: [PATCH 192/194] Add a link to the RFC from the README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4e678f46a85dd..4d87a8b969861 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ This crate exports all underlying platform types, functions, and constants under the crate root, so all items are accessible as `libc::foo`. The types and values of all the exported APIs match the platform that libc is compiled for. +More detailed information about the design of this library can be found in its +[associated RFC][rfc]. + +[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md + ## Adding an API Want to use an API which currently isn't bound in `libc`? It's quite easy to add From d5c4e55f6554f909e662ef9d13caeaf62663a445 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 15:46:16 -0700 Subject: [PATCH 193/194] Explain weirdness of c_void and android missing fns --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 67d7416ad0f9e..797c5394f904d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,9 +59,12 @@ #[macro_use] mod macros; mod dox; +// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable +// more optimization opportunities around it recognizing things like +// malloc/free. #[repr(u8)] pub enum c_void { - // Two dummy variants so the #[repr] attribute can be used + // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] __variant1, #[doc(hidden)] @@ -208,7 +211,8 @@ extern { pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; } -// These are all inline functions on android +// These are all inline functions on android, so they end up just being entirely +// missing on that platform. #[cfg(not(target_os = "android"))] extern { pub fn abs(i: c_int) -> c_int; From 2995f5595cff15846bccf855d8864effac62c1bb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Oct 2015 16:34:55 -0700 Subject: [PATCH 194/194] Use the standard android slave docker image --- ci/Dockerfile-android | 68 ---------------------------------- ci/README.md | 22 ++--------- ci/android-accept-licenses.sh | 14 ------- ci/run-travis.sh | 20 ++++++++-- ci/run.sh | 4 +- src/unix/notbsd/android/mod.rs | 2 +- 6 files changed, 23 insertions(+), 107 deletions(-) delete mode 100644 ci/Dockerfile-android delete mode 100755 ci/android-accept-licenses.sh diff --git a/ci/Dockerfile-android b/ci/Dockerfile-android deleted file mode 100644 index 5f0a31e9c2fb1..0000000000000 --- a/ci/Dockerfile-android +++ /dev/null @@ -1,68 +0,0 @@ -# This is a Dockerfile for building the image that is used to build Android -# binaries and run tests within. This will install the NDK, SDK, and set up an -# emulator to run tests in. - -FROM ubuntu:latest - -RUN mkdir /build -WORKDIR /build - -# Setup PATH to allow running android tools. -ENV PATH=$PATH:/build/android-ndk/bin -ENV PATH=$PATH:/build/android-sdk-linux/tools -ENV PATH=$PATH:/build/android-sdk-linux/platform-tools - -# So it looks like the default sdk gives us a 32-bit executable, but then it -# whines about it. Not sure how to download a 64-bit executable in the sdk so -# just let the 32-bit thing run for now. -ENV ANDROID_EMULATOR_FORCE_32BIT=true - -# Install necessary packages: -RUN dpkg --add-architecture i386 -RUN apt-get -y update -RUN apt-get -y install expect curl libncurses5:i386 libstdc++6:i386 zlib1g:i386 \ - openjdk-6-jre gcc-multilib - -# Prep the Android NDK -# -# See https://github.com/servo/servo/wiki/Building-for-Android -RUN curl -O http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2 -RUN tar xf android-ndk-r9c-linux-x86_64.tar.bz2 -RUN bash android-ndk-r9c/build/tools/make-standalone-toolchain.sh \ - --platform=android-18 \ - --toolchain=arm-linux-androideabi-4.8 \ - --install-dir=/build/android-ndk \ - --ndk-dir=/build/android-ndk-r9c \ - --arch=arm -RUN rm -rf android-ndk-r9c-linux-x86_64.tar.bz2 -RUN rm -rf android-ndk-r9c - -# Prep the SDK and emulator -# -# Note that the update process requires that we accept a bunch of licenses, and -# we can't just pipe `yes` into it for some reason, so we take the same strategy -# located in https://github.com/appunite/docker by just wrapping it in a script -# which apparently magically accepts the licenses. -RUN curl -O http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz -RUN tar xf android-sdk_r24.3.4-linux.tgz -COPY ci/android-accept-licenses.sh /build/android-accept-licenses.sh -RUN ["./android-accept-licenses.sh", \ - "android - update sdk -a --no-ui --filter platform-tools,android-18,sys-img-armeabi-v7a-android-18"] -RUN echo "no" | android create avd \ - --name test \ - --target android-18 \ - --abi armeabi-v7a -RUN rm -rf android-sdk_r24.3.4-linux.tgz -RUN rm android-accept-licenses.sh - -# Install rustc + extra targets -RUN curl https://static.rust-lang.org/rustup.sh | \ - sh -s -- --spec=nightly-2015-09-08 -y -RUN curl https://people.mozilla.org/~acrichton/libc-test/2015-09-08/arm-linux-androideabi.tar.gz | \ - tar xzf - -C /usr/local/lib/rustlib -RUN mkdir /root/.cargo -COPY ci/cargo-config /root/.cargo/config -ENV CARGO_TARGET_DIR=/root/target - -RUN mkdir /clone -WORKDIR /clone diff --git a/ci/README.md b/ci/README.md index 8e4729ed2e190..5b4c681c25eca 100644 --- a/ci/README.md +++ b/ci/README.md @@ -8,21 +8,6 @@ this project. First up, let's talk about the files in this directory: -* `Dockerfile-android`, `android-accept-licenses.sh` -- these two files are - used to build the Docker image that the android CI builder uses. The - `Dockerfile` just installs the Android SDK, NDK, a Rust nightly, Rust target - libraries for Android, and sets up an emulator to run tests in. You can build - a new image with this command (from the root of the project): - - docker build -t alexcrichton/rust-libc-test -f ci/Dockerfile-android . - - When building a new image contact @alexcrichton to push it to the docker hub - and have libc start using it. This hasn't needed to happen yet, so the process - may be a little involved. - - The script here, `android-accept-licenses.sh` is just a helper used to accept - the licenses of the SDK of Android while the docker image is being created. - * `msys2.ps1` - a PowerShell script which is used to install MSYS2 on the AppVeyor bots. As of this writing MSYS2 isn't installed by default, and this script will install the right version/arch of msys2 in preparation of using @@ -67,9 +52,8 @@ builds are run on stable/beta/nightly, but are the only ones that do so. The remaining architectures look like: -* Android runs in a docker image with an emulator, the NDK, and the SDK already - set up (see `Dockerfile-android`). The entire build happens within the docker - image. +* Android runs in a [docker image][android-docker] with an emulator, the NDK, + and the SDK already set up. The entire build happens within the docker image. * The MIPS, ARM, and AArch64 builds all use QEMU to run the generated binary to actually verify the tests pass. * The MUSL build just has to download a MUSL compiler and target libraries and @@ -77,6 +61,8 @@ The remaining architectures look like: * iOS builds need an extra linker flag currently, but beyond that they're built as standard as everything else. +[android-docker]: https://github.com/rust-lang/rust-buildbot/blob/master/slaves/android/Dockerfile + Hopefully that's at least somewhat of an introduction to everything going on here, and feel free to ping @alexcrichton with questions! diff --git a/ci/android-accept-licenses.sh b/ci/android-accept-licenses.sh deleted file mode 100755 index 776adf6f42314..0000000000000 --- a/ci/android-accept-licenses.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/expect -f - -set timeout 1800 -set cmd [lindex $argv 0] -set licenses [lindex $argv 1] - -spawn {*}$cmd -expect { - "Do you accept the license '*'*" { - exp_send "y\r" - exp_continue - } - eof -} diff --git a/ci/run-travis.sh b/ci/run-travis.sh index f214babcfc474..975accb66464e 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -46,11 +46,23 @@ esac case "$TARGET" in # Pull a pre-built docker image for testing android, then run tests entirely - #d within that image. + # within that image. Note that this is using the same rustc installation that + # travis has (sharing it via `-v`) and otherwise the tests run entirely within + # the container. arm-linux-androideabi) - docker pull alexcrichton/rust-libc-test - exec docker run -v `pwd`:/clone -t alexcrichton/rust-libc-test \ - sh ci/run.sh $TARGET + script=" +cp -r /checkout/* . +mkdir .cargo +cp ci/cargo-config .cargo/config +sh ci/run.sh $TARGET +" + exec docker run \ + --entrypoint bash \ + -v $HOME/rust:/usr/local:ro \ + -v `pwd`:/checkout:ro \ + -e LD_LIBRARY_PATH=/usr/local/lib \ + -it alexcrichton/rust-slave-android:2015-10-21 \ + -c "$script" ;; x86_64-unknown-linux-musl) diff --git a/ci/run.sh b/ci/run.sh index 6a4b4b122a79c..6dd177bffacb2 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -19,9 +19,9 @@ esac case "$TARGET" in arm-linux-androideabi) - emulator @test -no-window & + emulator @arm-18 -no-window & adb wait-for-device - adb push /root/target/$TARGET/debug/libc-test /data/libc-test + adb push libc-test/target/$TARGET/debug/libc-test /data/libc-test adb shell /data/libc-test ;; diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 68f93b1f87c2d..e26bceac30c92 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -200,7 +200,7 @@ extern { flags: ::c_int) -> ::c_int; pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; - pub fn sysconf(name: ::c_int) -> ::c_int; + pub fn sysconf(name: ::c_int) -> ::c_long; pub fn usleep(secs: ::c_ulong) -> ::c_int; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_uint, addr: *const ::sockaddr,