Skip to content

Instantly share code, notes, and snippets.

@pnkfelix
Created April 4, 2016 18:13
Show Gist options
  • Save pnkfelix/727d5533e16f40b5f55068fec4a8e17b to your computer and use it in GitHub Desktop.
Save pnkfelix/727d5533e16f40b5f55068fec4a8e17b to your computer and use it in GitHub Desktop.
% rustc --crate-type lib lib.narrow.rs -g -L dependency=/home/fklock/Dev/Rust/nix/target/debug -L dependency=/home/fklock/Dev/Rust\
/nix/target/debug/deps --extern libc=/home/fklock/Dev/Rust/nix/target/debug/deps/liblibc-00ad8a4a4c184a2d.rlib --extern cfg_if=/home/fklock/Dev/Rust/nix/target/debug/deps/l\
ibcfg_if-0a8d2242d60f8925.rlib --extern bitflags=/home/fklock/Dev/Rust/nix/target/debug/deps/libbitflags-b378ff20d60f43f8.rlib --cfg raw_pointer_derive_allowed
rustc: ../../../../../../src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::Function; Y = llvm::Value; t\
ypename llvm::cast_retty<X, Y*>::ret_type = llvm::Function*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Aborted (core dumped)
#![feature(fmt_internals, core_intrinsics, libstd_sys_internals)]
#![feature(prelude_import)]
#![no_std]
//! Rust friendly bindings to the various *nix system functions.
//!
//! Modules are structured according to the C header file that they would be
//! defined in.
#![crate_name = "nix"]
#![cfg(unix)]
#![allow(non_camel_case_types)]
// latest bitflags triggers a rustc bug with cross-crate macro expansions causing dead_code
// warnings even though the macro expands into something with allow(dead_code)
#![allow(dead_code)]
//#![deny(warnings)]
#![allow(unused_imports, unused_variables, unused_attributes, unused_features, unused_mut)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate cfg_if;
#[macro_use]
mod macros {
#[prelude_import]
use std::prelude::v1::*;
}
// In rust 1.8+ this should be `pub extern crate libc` but prior
// to https://github.com/rust-lang/rust/issues/26775 being resolved
// it is necessary to get a little creative.
pub mod libc {
#[prelude_import]
use std::prelude::v1::*;
extern crate libc;
pub use self::libc::*;
}
pub use libc::{c_int, c_void};
pub use errno::Errno;
pub mod errno {
use libc::c_int;
use std::{fmt, io, error};
use {Error, Result};
pub use self::consts::*;
pub use self::consts::Errno::*;
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))]
unsafe fn errno_location() -> *mut c_int { loop { } }
#[cfg(target_os = "bitrig")]
fn errno_location() -> *mut c_int { loop { } }
#[cfg(target_os = "dragonfly")]
unsafe fn errno_location() -> *mut c_int { loop { } }
#[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
unsafe fn errno_location() -> *mut c_int { loop { } }
#[cfg(any(target_os = "linux", target_os = "android"))]
unsafe fn errno_location() -> *mut c_int { loop { } }
/// Sets the platform-specific errno to no-error
unsafe fn clear() -> () { loop { } }
/// Returns the platform-specific value of errno
pub fn errno() -> i32 { loop { } }
impl Errno {
pub fn last() -> Self { loop { } }
pub fn desc(self) -> &'static str { loop { } }
pub fn from_i32(err: i32) -> Errno { loop { } }
pub unsafe fn clear() -> () { loop { } }
/// Returns `Ok(value)` if it does not contain the sentinel value. This
/// should not be used when `-1` is not the errno sentinel value.
pub fn result<S: ErrnoSentinel + PartialEq<S>>(value: S)
-> Result<S> {
loop { }
}
}
/// The sentinel value indicates that a function failed and more detailed
/// information about the error can be found in `errno`
pub trait ErrnoSentinel: Sized {
fn sentinel()
-> Self;
}
impl ErrnoSentinel for isize {
fn sentinel() -> Self { loop { } }
}
impl ErrnoSentinel for i32 {
fn sentinel() -> Self { loop { } }
}
impl ErrnoSentinel for i64 {
fn sentinel() -> Self { loop { } }
}
impl error::Error for Errno {
fn description(&self) -> &str { loop { } }
}
impl fmt::Display for Errno {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { loop { } }
}
impl From<Errno> for io::Error {
fn from(err: Errno) -> Self { loop { } }
}
fn last() -> Errno { loop { } }
fn desc(errno: Errno) -> &'static str { loop { } }
#[cfg(any(target_os = "linux", target_os = "android"))]
mod consts {
#[derive(Debug, Clone, PartialEq, Copy)]
pub enum Errno {
UnknownErrno = 0,
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EAGAIN = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EDEADLK = 35,
ENAMETOOLONG = 36,
ENOLCK = 37,
ENOSYS = 38,
ENOTEMPTY = 39,
ELOOP = 40,
ENOMSG = 42,
EIDRM = 43,
ECHRNG = 44,
EL2NSYNC = 45,
EL3HLT = 46,
EL3RST = 47,
ELNRNG = 48,
EUNATCH = 49,
ENOCSI = 50,
EL2HLT = 51,
EBADE = 52,
EBADR = 53,
EXFULL = 54,
ENOANO = 55,
EBADRQC = 56,
EBADSLT = 57,
EBFONT = 59,
ENOSTR = 60,
ENODATA = 61,
ETIME = 62,
ENOSR = 63,
ENONET = 64,
ENOPKG = 65,
EREMOTE = 66,
ENOLINK = 67,
EADV = 68,
ESRMNT = 69,
ECOMM = 70,
EPROTO = 71,
EMULTIHOP = 72,
EDOTDOT = 73,
EBADMSG = 74,
EOVERFLOW = 75,
ENOTUNIQ = 76,
EBADFD = 77,
EREMCHG = 78,
ELIBACC = 79,
ELIBBAD = 80,
ELIBSCN = 81,
ELIBMAX = 82,
ELIBEXEC = 83,
EILSEQ = 84,
ERESTART = 85,
ESTRPIPE = 86,
EUSERS = 87,
ENOTSOCK = 88,
EDESTADDRREQ = 89,
EMSGSIZE = 90,
EPROTOTYPE = 91,
ENOPROTOOPT = 92,
EPROTONOSUPPORT = 93,
ESOCKTNOSUPPORT = 94,
EOPNOTSUPP = 95,
EPFNOSUPPORT = 96,
EAFNOSUPPORT = 97,
EADDRINUSE = 98,
EADDRNOTAVAIL = 99,
ENETDOWN = 100,
ENETUNREACH = 101,
ENETRESET = 102,
ECONNABORTED = 103,
ECONNRESET = 104,
ENOBUFS = 105,
EISCONN = 106,
ENOTCONN = 107,
ESHUTDOWN = 108,
ETOOMANYREFS = 109,
ETIMEDOUT = 110,
ECONNREFUSED = 111,
EHOSTDOWN = 112,
EHOSTUNREACH = 113,
EALREADY = 114,
EINPROGRESS = 115,
ESTALE = 116,
EUCLEAN = 117,
ENOTNAM = 118,
ENAVAIL = 119,
EISNAM = 120,
EREMOTEIO = 121,
EDQUOT = 122,
ENOMEDIUM = 123,
EMEDIUMTYPE = 124,
ECANCELED = 125,
ENOKEY = 126,
EKEYEXPIRED = 127,
EKEYREVOKED = 128,
EKEYREJECTED = 129,
EOWNERDEAD = 130,
ENOTRECOVERABLE = 131,
#[cfg(not(target_os = "android"))]
ERFKILL = 132,
#[cfg(not(target_os = "android"))]
EHWPOISON = 133,
}
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
pub const EDEADLOCK: Errno = Errno::EDEADLK;
pub fn from_i32(e: i32) -> Errno { loop { } }
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod consts {
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum Errno {
UnknownErrno = 0,
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EDEADLK = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EAGAIN = 35,
EINPROGRESS = 36,
EALREADY = 37,
ENOTSOCK = 38,
EDESTADDRREQ = 39,
EMSGSIZE = 40,
EPROTOTYPE = 41,
ENOPROTOOPT = 42,
EPROTONOSUPPORT = 43,
ESOCKTNOSUPPORT = 44,
ENOTSUP = 45,
EPFNOSUPPORT = 46,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
EISCONN = 56,
ENOTCONN = 57,
ESHUTDOWN = 58,
ETOOMANYREFS = 59,
ETIMEDOUT = 60,
ECONNREFUSED = 61,
ELOOP = 62,
ENAMETOOLONG = 63,
EHOSTDOWN = 64,
EHOSTUNREACH = 65,
ENOTEMPTY = 66,
EPROCLIM = 67,
EUSERS = 68,
EDQUOT = 69,
ESTALE = 70,
EREMOTE = 71,
EBADRPC = 72,
ERPCMISMATCH = 73,
EPROGUNAVAIL = 74,
EPROGMISMATCH = 75,
EPROCUNAVAIL = 76,
ENOLCK = 77,
ENOSYS = 78,
EFTYPE = 79,
EAUTH = 80,
ENEEDAUTH = 81,
EPWROFF = 82,
EDEVERR = 83,
EOVERFLOW = 84,
EBADEXEC = 85,
EBADARCH = 86,
ESHLIBVERS = 87,
EBADMACHO = 88,
ECANCELED = 89,
EIDRM = 90,
ENOMSG = 91,
EILSEQ = 92,
ENOATTR = 93,
EBADMSG = 94,
EMULTIHOP = 95,
ENODATA = 96,
ENOLINK = 97,
ENOSR = 98,
ENOSTR = 99,
EPROTO = 100,
ETIME = 101,
EOPNOTSUPP = 102,
ENOPOLICY = 103,
ENOTRECOVERABLE = 104,
EOWNERDEAD = 105,
EQFULL = 106,
}
pub const ELAST: Errno = Errno::EQFULL;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
pub const EDEADLOCK: Errno = Errno::EDEADLK;
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
pub fn from_i32(e: i32) -> Errno { loop { } }
}
#[cfg(target_os = "freebsd")]
mod consts {
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum Errno {
UnknownErrno = 0,
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EDEADLK = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EAGAIN = 35,
EINPROGRESS = 36,
EALREADY = 37,
ENOTSOCK = 38,
EDESTADDRREQ = 39,
EMSGSIZE = 40,
EPROTOTYPE = 41,
ENOPROTOOPT = 42,
EPROTONOSUPPORT = 43,
ESOCKTNOSUPPORT = 44,
ENOTSUP = 45,
EPFNOSUPPORT = 46,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
EISCONN = 56,
ENOTCONN = 57,
ESHUTDOWN = 58,
ETOOMANYREFS = 59,
ETIMEDOUT = 60,
ECONNREFUSED = 61,
ELOOP = 62,
ENAMETOOLONG = 63,
EHOSTDOWN = 64,
EHOSTUNREACH = 65,
ENOTEMPTY = 66,
EPROCLIM = 67,
EUSERS = 68,
EDQUOT = 69,
ESTALE = 70,
EREMOTE = 71,
EBADRPC = 72,
ERPCMISMATCH = 73,
EPROGUNAVAIL = 74,
EPROGMISMATCH = 75,
EPROCUNAVAIL = 76,
ENOLCK = 77,
ENOSYS = 78,
EFTYPE = 79,
EAUTH = 80,
ENEEDAUTH = 81,
EIDRM = 82,
ENOMSG = 83,
EOVERFLOW = 84,
ECANCELED = 85,
EILSEQ = 86,
ENOATTR = 87,
EDOOFUS = 88,
EBADMSG = 89,
EMULTIHOP = 90,
ENOLINK = 91,
EPROTO = 92,
ENOTCAPABLE = 93,
ECAPMODE = 94,
ENOTRECOVERABLE = 95,
EOWNERDEAD = 96,
}
pub const ELAST: Errno = Errno::EOWNERDEAD;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
pub const EDEADLOCK: Errno = Errno::EDEADLK;
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
pub fn from_i32(e: i32) -> Errno { loop { } }
}
#[cfg(target_os = "dragonfly")]
mod consts {
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum Errno {
UnknownErrno = 0,
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EDEADLK = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EAGAIN = 35,
EINPROGRESS = 36,
EALREADY = 37,
ENOTSOCK = 38,
EDESTADDRREQ = 39,
EMSGSIZE = 40,
EPROTOTYPE = 41,
ENOPROTOOPT = 42,
EPROTONOSUPPORT = 43,
ESOCKTNOSUPPORT = 44,
ENOTSUP = 45,
EPFNOSUPPORT = 46,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
EISCONN = 56,
ENOTCONN = 57,
ESHUTDOWN = 58,
ETOOMANYREFS = 59,
ETIMEDOUT = 60,
ECONNREFUSED = 61,
ELOOP = 62,
ENAMETOOLONG = 63,
EHOSTDOWN = 64,
EHOSTUNREACH = 65,
ENOTEMPTY = 66,
EPROCLIM = 67,
EUSERS = 68,
EDQUOT = 69,
ESTALE = 70,
EREMOTE = 71,
EBADRPC = 72,
ERPCMISMATCH = 73,
EPROGUNAVAIL = 74,
EPROGMISMATCH = 75,
EPROCUNAVAIL = 76,
ENOLCK = 77,
ENOSYS = 78,
EFTYPE = 79,
EAUTH = 80,
ENEEDAUTH = 81,
EIDRM = 82,
ENOMSG = 83,
EOVERFLOW = 84,
ECANCELED = 85,
EILSEQ = 86,
ENOATTR = 87,
EDOOFUS = 88,
EBADMSG = 89,
EMULTIHOP = 90,
ENOLINK = 91,
EPROTO = 92,
ENOMEDIUM = 93,
EUNUSED94 = 94,
EUNUSED95 = 95,
EUNUSED96 = 96,
EUNUSED97 = 97,
EUNUSED98 = 98,
EASYNC = 99,
}
pub const ELAST: Errno = Errno::EASYNC;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
pub const EDEADLOCK: Errno = Errno::EDEADLK;
pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
pub fn from_i32(e: i32) -> Errno { loop { } }
}
#[cfg(target_os = "openbsd")]
mod consts {
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum Errno {
UnknownErrno = 0,
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EDEADLK = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EAGAIN = 35,
EINPROGRESS = 36,
EALREADY = 37,
ENOTSOCK = 38,
EDESTADDRREQ = 39,
EMSGSIZE = 40,
EPROTOTYPE = 41,
ENOPROTOOPT = 42,
EPROTONOSUPPORT = 43,
ESOCKTNOSUPPORT = 44,
EOPNOTSUPP = 45,
EPFNOSUPPORT = 46,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
EISCONN = 56,
ENOTCONN = 57,
ESHUTDOWN = 58,
ETOOMANYREFS = 59,
ETIMEDOUT = 60,
ECONNREFUSED = 61,
ELOOP = 62,
ENAMETOOLONG = 63,
EHOSTDOWN = 64,
EHOSTUNREACH = 65,
ENOTEMPTY = 66,
EPROCLIM = 67,
EUSERS = 68,
EDQUOT = 69,
ESTALE = 70,
EREMOTE = 71,
EBADRPC = 72,
ERPCMISMATCH = 73,
EPROGUNAVAIL = 74,
EPROGMISMATCH = 75,
EPROCUNAVAIL = 76,
ENOLCK = 77,
ENOSYS = 78,
EFTYPE = 79,
EAUTH = 80,
ENEEDAUTH = 81,
EIPSEC = 82,
ENOATTR = 83,
EILSEQ = 84,
ENOMEDIUM = 85,
EMEDIUMTYPE = 86,
EOVERFLOW = 87,
ECANCELED = 88,
EIDRM = 89,
ENOMSG = 90,
ENOTSUP = 91,
}
pub const ELAST: Errno = Errno::ENOTSUP;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
pub fn from_i32(e: i32) -> Errno { loop { } }
}
#[cfg(target_os = "netbsd")]
mod consts {
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum Errno {
UnknownErrno = 0,
EPERM = 1,
ENOENT = 2,
ESRCH = 3,
EINTR = 4,
EIO = 5,
ENXIO = 6,
E2BIG = 7,
ENOEXEC = 8,
EBADF = 9,
ECHILD = 10,
EDEADLK = 11,
ENOMEM = 12,
EACCES = 13,
EFAULT = 14,
ENOTBLK = 15,
EBUSY = 16,
EEXIST = 17,
EXDEV = 18,
ENODEV = 19,
ENOTDIR = 20,
EISDIR = 21,
EINVAL = 22,
ENFILE = 23,
EMFILE = 24,
ENOTTY = 25,
ETXTBSY = 26,
EFBIG = 27,
ENOSPC = 28,
ESPIPE = 29,
EROFS = 30,
EMLINK = 31,
EPIPE = 32,
EDOM = 33,
ERANGE = 34,
EAGAIN = 35,
EINPROGRESS = 36,
EALREADY = 37,
ENOTSOCK = 38,
EDESTADDRREQ = 39,
EMSGSIZE = 40,
EPROTOTYPE = 41,
ENOPROTOOPT = 42,
EPROTONOSUPPORT = 43,
ESOCKTNOSUPPORT = 44,
EOPNOTSUPP = 45,
EPFNOSUPPORT = 46,
EAFNOSUPPORT = 47,
EADDRINUSE = 48,
EADDRNOTAVAIL = 49,
ENETDOWN = 50,
ENETUNREACH = 51,
ENETRESET = 52,
ECONNABORTED = 53,
ECONNRESET = 54,
ENOBUFS = 55,
EISCONN = 56,
ENOTCONN = 57,
ESHUTDOWN = 58,
ETOOMANYREFS = 59,
ETIMEDOUT = 60,
ECONNREFUSED = 61,
ELOOP = 62,
ENAMETOOLONG = 63,
EHOSTDOWN = 64,
EHOSTUNREACH = 65,
ENOTEMPTY = 66,
EPROCLIM = 67,
EUSERS = 68,
EDQUOT = 69,
ESTALE = 70,
EREMOTE = 71,
EBADRPC = 72,
ERPCMISMATCH = 73,
EPROGUNAVAIL = 74,
EPROGMISMATCH = 75,
EPROCUNAVAIL = 76,
ENOLCK = 77,
ENOSYS = 78,
EFTYPE = 79,
EAUTH = 80,
ENEEDAUTH = 81,
EIDRM = 82,
ENOMSG = 83,
EOVERFLOW = 84,
EILSEQ = 85,
ENOTSUP = 86,
ECANCELED = 87,
EBADMSG = 88,
ENODATA = 89,
ENOSR = 90,
ENOSTR = 91,
ETIME = 92,
ENOATTR = 93,
EMULTIHOP = 94,
ENOLINK = 95,
EPROTO = 96,
}
pub const ELAST: Errno = Errno::ENOTSUP;
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
pub const EL2NSYNC: Errno = Errno::UnknownErrno;
pub fn from_i32(e: i32) -> Errno { loop { } }
}
#[cfg(test)]
mod test {
use super::*;
use nixtest::assert_const_eq;
use libc::c_int;
macro_rules! check_errno(( $ ( $ errno : ident ) , + ) => {
{
$ (
assert_const_eq (
stringify ! ( $ errno ) , $ errno as c_int )
; ) + } } ;);
#[test]
pub fn test_errno_values() { loop { } }
#[test]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn test_linux_errnos() { loop { } }
#[test]
#[cfg(target_os = "linux")]
pub fn test_linux_not_android_errnos() { loop { } }
#[test]
#[cfg(target_os = "freebsd")]
pub fn test_freebsd_errnos() { loop { } }
#[test]
#[cfg(target_os = "dragonfly")]
pub fn test_dragonfly_errnos() { loop { } }
#[test]
#[cfg(target_os = "openbsd")]
pub fn test_openbsd_errnos() { loop { } }
#[test]
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub fn test_darwin_errnos() { loop { } }
}
}
pub mod features {
pub use self::os::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use sys::utsname::uname;
static VERS_UNKNOWN: usize = 1;
static VERS_2_6_18: usize = 2;
static VERS_2_6_27: usize = 3;
static VERS_2_6_28: usize = 4;
static VERS_3: usize = 5;
fn parse_kernel_version() -> usize { loop { } }
fn kernel_version() -> usize { loop { } }
pub fn socket_atomic_cloexec() -> bool { loop { } }
#[test]
pub fn test_parsing_kernel_version() { loop { } }
}
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "ios",
target_os = "openbsd",
target_os = "netbsd"))]
mod os {
pub fn socket_atomic_cloexec() -> bool { loop { } }
}
}
pub mod fcntl { }
#[cfg(none)]
pub mod fcntl {
use {Errno, Result, NixPath};
use libc::{c_int, c_uint};
use sys::stat::Mode;
use std::os::unix::io::RawFd;
#[cfg(any(target_os = "linux", target_os = "android"))]
use sys::uio::IoVec;
#[cfg(any(target_os = "linux", target_os = "android"))]
use libc;
pub use self::consts::*;
pub use self::ffi::flock;
#[allow(dead_code)]
mod ffi {
pub use libc::{open, fcntl};
pub use self::os::*;
pub use libc::flock as libc_flock;
pub use libc::{LOCK_SH, LOCK_EX, LOCK_NB, LOCK_UN};
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use libc::{c_int, c_short, off_t, pid_t};
#[repr(C)]
#[derive(Clone, Copy, Default, Debug)]
pub struct flock {
pub l_type: c_short,
pub l_whence: c_short,
pub l_start: off_t,
pub l_len: off_t,
pub l_pid: pid_t,
pub l_sysid: c_int,
}
pub const F_DUPFD: c_int = 0;
pub const F_DUPFD_CLOEXEC: c_int = 1030;
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_SETLK: c_int = 6;
pub const F_SETLKW: c_int = 7;
pub const F_GETLK: c_int = 5;
pub const F_ADD_SEALS: c_int = 1033;
pub const F_GET_SEALS: c_int = 1034;
pub const F_SEAL_SEAL: c_int = 1;
pub const F_SEAL_SHRINK: c_int = 2;
pub const F_SEAL_GROW: c_int = 4;
pub const F_SEAL_WRITE: c_int = 8;
}
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "ios",
target_os = "openbsd",
target_os = "netbsd"))]
mod os {
use libc::{c_int, c_short, off_t, pid_t};
#[repr(C)]
#[derive(Clone, Copy, Default, Debug)]
pub struct flock {
pub l_start: off_t,
pub l_len: off_t,
pub l_pid: pid_t,
pub l_type: c_short,
pub l_whence: c_short,
pub l_sysid: c_int,
}
pub const F_DUPFD: c_int = 0;
#[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
pub const F_DUPFD_CLOEXEC: c_int = 67;
#[cfg(target_os = "dragonfly")]
pub const F_DUPFD_CLOEXEC: c_int = 17;
#[cfg(target_os = "netbsd")]
pub const F_DUPFD_CLOEXEC: c_int = 12;
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;
#[cfg(target_os = "netbsd")]
pub const F_GETOWN: c_int = 5;
#[cfg(target_os = "netbsd")]
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;
#[cfg(target_os = "netbsd")]
pub const F_CLOSEM: c_int = 10;
#[cfg(target_os = "netbsd")]
pub const F_MAXFD: c_int = 11;
#[cfg(target_os = "netbsd")]
pub const F_GETNOSIGPIPE: c_int = 13;
#[cfg(target_os = "netbsd")]
pub const F_SETNOSIGPIPE: c_int = 14;
}
}
pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag, mode: Mode)
-> Result<RawFd> {
loop { }
}
pub enum FcntlArg<'a> {
F_DUPFD(RawFd),
F_DUPFD_CLOEXEC(RawFd),
F_GETFD,
F_SETFD(FdFlag),
F_GETFL,
F_SETFL(OFlag),
F_SETLK(&'a flock),
F_SETLKW(&'a flock),
F_GETLK(&'a mut flock),
#[cfg(any(target_os = "linux", target_os = "android"))]
F_OFD_SETLK(&'a flock),
#[cfg(any(target_os = "linux", target_os = "android"))]
F_OFD_SETLKW(&'a flock),
#[cfg(any(target_os = "linux", target_os = "android"))]
F_OFD_GETLK(&'a mut flock),
#[cfg(target_os = "linux")]
F_ADD_SEALS(SealFlag),
#[cfg(target_os = "linux")]
F_GET_SEALS,
}
pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> { loop { } }
pub enum FlockArg {
LockShared,
LockExclusive,
Unlock,
LockSharedNonblock,
LockExclusiveNonblock,
UnlockNonblock,
}
pub fn flock(fd: RawFd, arg: FlockArg) -> Result<()> { loop { } }
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn splice(fd_in: RawFd, off_in: Option<&mut libc::loff_t>,
fd_out: RawFd, off_out: Option<&mut libc::loff_t>,
len: usize, flags: SpliceFFlags) -> Result<usize> {
loop { }
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn tee(fd_in: RawFd, fd_out: RawFd, len: usize, flags: SpliceFFlags)
-> Result<usize> {
loop { }
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn vmsplice(fd: RawFd, iov: &[IoVec<&[u8]>], flags: SpliceFFlags)
-> Result<usize> {
loop { }
}
#[cfg(any(target_os = "linux", target_os = "android"))]
mod consts {
use libc::{self, c_int, c_uint};
bitflags! (flags SpliceFFlags : c_uint {
const SPLICE_F_MOVE = libc:: SPLICE_F_MOVE , const
SPLICE_F_NONBLOCK = libc:: SPLICE_F_NONBLOCK , const
SPLICE_F_MORE = libc:: SPLICE_F_MORE , const SPLICE_F_GIFT
= libc:: SPLICE_F_GIFT , });
bitflags! (flags OFlag : c_int {
const O_ACCMODE = 0o00000003 , const O_RDONLY = 0o00000000
, const O_WRONLY = 0o00000001 , const O_RDWR = 0o00000002 ,
const O_CREAT = 0o00000100 , const O_EXCL = 0o00000200 ,
const O_NOCTTY = 0o00000400 , const O_TRUNC = 0o00001000 ,
const O_APPEND = 0o00002000 , const O_NONBLOCK = 0o00004000
, const O_DSYNC = 0o00010000 , const O_DIRECT = 0o00040000
, const O_LARGEFILE = 0o00100000 , const O_DIRECTORY =
0o00200000 , const O_NOFOLLOW = 0o00400000 , const
O_NOATIME = 0o01000000 , const O_CLOEXEC = 0o02000000 ,
const O_SYNC = 0o04000000 , const O_PATH = 0o10000000 ,
const O_TMPFILE = 0o20000000 , const O_NDELAY = O_NONBLOCK
. bits });
bitflags! (flags FdFlag : c_int { const FD_CLOEXEC = 1 });
bitflags! (flags SealFlag : c_int {
const F_SEAL_SEAL = 1 , const F_SEAL_SHRINK = 2 , const
F_SEAL_GROW = 4 , const F_SEAL_WRITE = 8 , });
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod consts {
use libc::c_int;
bitflags! (flags OFlag : c_int {
const O_ACCMODE = 0x0000003 , const O_RDONLY = 0x0000000 ,
const O_WRONLY = 0x0000001 , const O_RDWR = 0x0000002 ,
const O_CREAT = 0x0000200 , const O_EXCL = 0x0000800 ,
const O_NOCTTY = 0x0020000 , const O_TRUNC = 0x0000400 ,
const O_APPEND = 0x0000008 , const O_NONBLOCK = 0x0000004 ,
const O_DSYNC = 0x0400000 , const O_DIRECTORY = 0x0100000 ,
const O_NOFOLLOW = 0x0000100 , const O_CLOEXEC = 0x1000000
, const O_SYNC = 0x0000080 , const O_NDELAY = O_NONBLOCK .
bits , const O_FSYNC = O_SYNC . bits });
bitflags! (flags FdFlag : c_int { const FD_CLOEXEC = 1 });
}
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
mod consts {
use libc::c_int;
bitflags! (flags OFlag : c_int {
const O_ACCMODE = 0x0000003 , const O_RDONLY = 0x0000000 ,
const O_WRONLY = 0x0000001 , const O_RDWR = 0x0000002 ,
const O_CREAT = 0x0000200 , const O_EXCL = 0x0000800 ,
const O_NOCTTY = 0x0008000 , const O_TRUNC = 0x0000400 ,
const O_APPEND = 0x0000008 , const O_NONBLOCK = 0x0000004 ,
const O_DIRECTORY = 0x0020000 , const O_NOFOLLOW =
0x0000100 , const O_CLOEXEC = 0x0100000 , const O_SYNC =
0x0000080 , const O_NDELAY = O_NONBLOCK . bits , const
O_FSYNC = O_SYNC . bits , const O_SHLOCK = 0x0000080 ,
const O_EXLOCK = 0x0000020 , const O_DIRECT = 0x0010000 ,
const O_EXEC = 0x0040000 , const O_TTY_INIT = 0x0080000 });
bitflags! (flags FdFlag : c_int { const FD_CLOEXEC = 1 });
}
#[cfg(target_os = "netbsd")]
mod consts {
use libc::c_int;
bitflags! (flags OFlag : c_int {
const O_ACCMODE = 0x0000003 , const O_RDONLY = 0x0000000 ,
const O_WRONLY = 0x0000001 , const O_RDWR = 0x0000002 ,
const O_NONBLOCK = 0x0000004 , const O_APPEND = 0x0000008 ,
const O_SHLOCK = 0x0000010 , const O_EXLOCK = 0x0000020 ,
const O_ASYNC = 0x0000040 , const O_SYNC = 0x0000080 ,
const O_NOFOLLOW = 0x0000100 , const O_CREAT = 0x0000200 ,
const O_TRUNC = 0x0000400 , const O_EXCL = 0x0000800 ,
const O_NOCTTY = 0x0008000 , const O_DSYNC = 0x0010000 ,
const O_RSYNC = 0x0020000 , const O_ALT_IO = 0x0040000 ,
const O_DIRECT = 0x0080000 , const O_NOSIGPIPE = 0x0100000
, const O_DIRECTORY = 0x0200000 , const O_CLOEXEC =
0x0400000 , const O_SEARCH = 0x0800000 , const O_FSYNC =
O_SYNC . bits , const O_NDELAY = O_NONBLOCK . bits , });
bitflags! (flags FdFlag : c_int { const FD_CLOEXEC = 1 });
}
#[cfg(target_os = "dragonfly")]
mod consts {
use libc::c_int;
bitflags! (flags OFlag : c_int {
const O_ACCMODE = 0x0000003 , const O_RDONLY = 0x0000000 ,
const O_WRONLY = 0x0000001 , const O_RDWR = 0x0000002 ,
const O_CREAT = 0x0000200 , const O_EXCL = 0x0000800 ,
const O_NOCTTY = 0x0008000 , const O_TRUNC = 0x0000400 ,
const O_APPEND = 0x0000008 , const O_NONBLOCK = 0x0000004 ,
const O_DIRECTORY = 0x8000000 , const O_NOFOLLOW =
0x0000100 , const O_CLOEXEC = 0x0020000 , const O_SYNC =
0x0000080 , const O_NDELAY = O_NONBLOCK . bits , const
O_FSYNC = O_SYNC . bits , const O_SHLOCK = 0x0000010 ,
const O_EXLOCK = 0x0000020 , const O_DIRECT = 0x0010000 ,
});
bitflags! (flags FdFlag : c_int { const FD_CLOEXEC = 1 });
}
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod mount {
use libc::{c_ulong, c_int};
use {Errno, Result, NixPath};
bitflags! (flags MsFlags : c_ulong {
const MS_RDONLY = 1 << 0 , const MS_NOSUID = 1 << 1 , const
MS_NODEV = 1 << 2 , const MS_NOEXEC = 1 << 3 , const
MS_SYNCHRONOUS = 1 << 4 , const MS_REMOUNT = 1 << 5 , const
MS_MANDLOCK = 1 << 6 , const MS_DIRSYNC = 1 << 7 , const
MS_NOATIME = 1 << 10 , const MS_NODIRATIME = 1 << 11 , const
MS_BIND = 1 << 12 , const MS_MOVE = 1 << 13 , const MS_REC = 1
<< 14 , const MS_VERBOSE = 1 << 15 , const MS_SILENT = 1 << 15
, const MS_POSIXACL = 1 << 16 , const MS_UNBINDABLE = 1 << 17 ,
const MS_PRIVATE = 1 << 18 , const MS_SLAVE = 1 << 19 , const
MS_SHARED = 1 << 20 , const MS_RELATIME = 1 << 21 , const
MS_KERNMOUNT = 1 << 22 , const MS_I_VERSION = 1 << 23 , const
MS_STRICTATIME = 1 << 24 , const MS_NOSEC = 1 << 28 , const
MS_BORN = 1 << 29 , const MS_ACTIVE = 1 << 30 , const MS_NOUSER
= 1 << 31 , const MS_RMT_MASK = MS_RDONLY . bits |
MS_SYNCHRONOUS . bits | MS_MANDLOCK . bits | MS_I_VERSION .
bits , const MS_MGC_VAL = 0xC0ED0000 , const MS_MGC_MSK =
0xffff0000 });
bitflags! (flags MntFlags : c_int {
const MNT_FORCE = 1 << 0 , const MNT_DETACH = 1 << 1 , const
MNT_EXPIRE = 1 << 2 });
mod ffi {
use libc::{c_char, c_int, c_ulong, c_void};
extern "C" {
pub fn mount(source: *const c_char, target: *const c_char,
fstype: *const c_char, flags: c_ulong,
data: *const c_void) -> c_int;
pub fn umount(target: *const c_char) -> c_int;
pub fn umount2(target: *const c_char, flags: c_int) -> c_int;
}
}
pub fn mount<P1: ?Sized + NixPath, P2: ?Sized + NixPath, P3: ?Sized +
NixPath, P4: ?Sized +
NixPath>(source: Option<&P1>, target: &P2,
fstype: Option<&P3>, flags: MsFlags,
data: Option<&P4>) -> Result<()> {
loop { }
}
pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> { loop { } }
pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags)
-> Result<()> {
loop { }
}
}
#[cfg(any(target_os = "linux"))]
pub mod mqueue {
//! Posix Message Queue functions
//!
//! [Further reading and details on the C API](http://man7.org/linux/man-pages/man7/mq_overview.7.html)
use {Errno, Result};
use libc::{c_int, c_long, c_char, size_t, mode_t};
use std::ffi::CString;
use sys::stat::Mode;
use std::ptr;
pub use self::consts::*;
pub type MQd = c_int;
#[cfg(target_os = "linux")]
mod consts {
use libc::c_int;
bitflags! (flags MQ_OFlag : c_int {
const O_RDONLY = 0o00000000 , const O_WRONLY = 0o00000001 ,
const O_RDWR = 0o00000002 , const O_CREAT = 0o00000100 ,
const O_EXCL = 0o00000200 , const O_NONBLOCK = 0o00004000 ,
const O_CLOEXEC = 0o02000000 , });
bitflags! (flags FdFlag : c_int { const FD_CLOEXEC = 1 });
}
mod ffi {
use libc::{c_char, size_t, ssize_t, c_uint, c_int};
use super::MQd;
use super::MqAttr;
#[allow(improper_ctypes)]
extern "C" {
pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> MQd;
pub fn mq_close(mqd: MQd) -> c_int;
pub fn mq_unlink(name: *const c_char) -> c_int;
pub fn mq_receive(mqd: MQd, msg_ptr: *const c_char,
msg_len: size_t, msq_prio: *const c_uint)
-> ssize_t;
pub fn mq_send(mqd: MQd, msg_ptr: *const c_char, msg_len: size_t,
msq_prio: c_uint) -> c_int;
pub fn mq_getattr(mqd: MQd, attr: *mut MqAttr) -> c_int;
pub fn mq_setattr(mqd: MQd, newattr: *const MqAttr,
oldattr: *mut MqAttr) -> c_int;
}
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct MqAttr {
pub mq_flags: c_long,
pub mq_maxmsg: c_long,
pub mq_msgsize: c_long,
pub mq_curmsgs: c_long,
pad: [c_long; 4],
}
impl MqAttr {
pub fn new(mq_flags: c_long, mq_maxmsg: c_long, mq_msgsize: c_long,
mq_curmsgs: c_long) -> MqAttr {
loop { }
}
}
pub fn mq_open(name: &CString, oflag: MQ_OFlag, mode: Mode,
attr: Option<&MqAttr>) -> Result<MQd> {
loop { }
}
pub fn mq_unlink(name: &CString) -> Result<()> { loop { } }
pub fn mq_close(mqdes: MQd) -> Result<()> { loop { } }
pub fn mq_receive(mqdes: MQd, message: &mut [u8], msq_prio: u32)
-> Result<usize> {
loop { }
}
pub fn mq_send(mqdes: MQd, message: &[u8], msq_prio: u32) -> Result<()> {
loop { }
}
pub fn mq_getattr(mqd: MQd) -> Result<MqAttr> { loop { } }
/// Set the attributes of the message queue. Only O_NONBLOCK can be set, everything else will be ignored
/// Returns the old attributes
/// It is recommend to use the mq_set_nonblock() and mq_remove_nonblock() convenience functions as they are easier to use
///
/// [Further reading](http://man7.org/linux/man-pages/man3/mq_setattr.3.html)
pub fn mq_setattr(mqd: MQd, newattr: &MqAttr) -> Result<MqAttr> {
loop { }
}
/// Convenience function.
/// Sets the O_NONBLOCK attribute for a given message queue descriptor
/// Returns the old attributes
pub fn mq_set_nonblock(mqd: MQd) -> Result<(MqAttr)> { loop { } }
/// Convenience function.
/// Removes O_NONBLOCK attribute for a given message queue descriptor
/// Returns the old attributes
pub fn mq_remove_nonblock(mqd: MQd) -> Result<(MqAttr)> { loop { } }
}
#[cfg(any(target_os = "linux", target_os = "macos"))]
pub mod poll {
use libc::c_int;
use {Errno, Result};
pub use self::ffi::PollFd;
pub use self::ffi::consts::*;
mod ffi {
use libc::c_int;
pub use self::consts::*;
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct PollFd {
pub fd: c_int,
pub events: EventFlags,
pub revents: EventFlags,
}
#[cfg(target_os = "linux")]
pub mod consts {
use libc::{c_short, c_ulong};
bitflags! (flags EventFlags : c_short {
const POLLIN = 0x001 , const POLLPRI = 0x002 , const
POLLOUT = 0x004 , const POLLRDNORM = 0x040 , const
POLLWRNORM = 0x100 , const POLLRDBAND = 0x080 , const
POLLWRBAND = 0x200 , const POLLERR = 0x008 , const
POLLHUP = 0x010 , const POLLNVAL = 0x020 , });
pub type nfds_t = c_ulong;
}
#[cfg(target_os = "macos")]
pub mod consts {
use libc::{c_short, c_uint};
bitflags! (flags EventFlags : c_short {
const POLLIN = 0x0001 , const POLLPRI = 0x0002 , const
POLLOUT = 0x0004 , const POLLRDNORM = 0x0040 , const
POLLWRNORM = 0x0004 , const POLLRDBAND = 0x0080 , const
POLLWRBAND = 0x0100 , const POLLERR = 0x0008 , const
POLLHUP = 0x0010 , const POLLNVAL = 0x0020 , });
pub type nfds_t = c_uint;
}
#[allow(improper_ctypes)]
extern "C" {
pub fn poll(fds: *mut PollFd, nfds: nfds_t, timeout: c_int)
-> c_int;
}
}
pub fn poll(fds: &mut [PollFd], timeout: c_int) -> Result<c_int> {
loop { }
}
}
pub mod net {
pub mod if_ {
//! Network interface name resolution.
//!
//! Uses Linux and/or POSIX functions to resolve interface names like "eth0"
//! or "socan1" into device numbers.
use libc;
use libc::c_uint;
use {Result, Error, NixPath};
/// Resolve an interface into a interface number.
pub fn if_nametoindex<P: ?Sized + NixPath>(name: &P)
-> Result<c_uint> {
loop { }
}
}
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod sched {
use std::mem;
use std::os::unix::io::RawFd;
use libc::{self, c_int, c_void, c_ulong, pid_t};
use {Errno, Result};
bitflags! (flags CloneFlags : c_int {
const CLONE_VM = libc:: CLONE_VM , const CLONE_FS = libc::
CLONE_FS , const CLONE_FILES = libc:: CLONE_FILES , const
CLONE_SIGHAND = libc:: CLONE_SIGHAND , const CLONE_PTRACE =
libc:: CLONE_PTRACE , const CLONE_VFORK = libc:: CLONE_VFORK ,
const CLONE_PARENT = libc:: CLONE_PARENT , const CLONE_THREAD =
libc:: CLONE_THREAD , const CLONE_NEWNS = libc:: CLONE_NEWNS ,
const CLONE_SYSVSEM = libc:: CLONE_SYSVSEM , const CLONE_SETTLS
= libc:: CLONE_SETTLS , const CLONE_PARENT_SETTID = libc::
CLONE_PARENT_SETTID , const CLONE_CHILD_CLEARTID = libc::
CLONE_CHILD_CLEARTID , const CLONE_DETACHED = libc::
CLONE_DETACHED , const CLONE_UNTRACED = libc:: CLONE_UNTRACED ,
const CLONE_CHILD_SETTID = libc:: CLONE_CHILD_SETTID , const
CLONE_NEWUTS = libc:: CLONE_NEWUTS as c_int , const
CLONE_NEWIPC = libc:: CLONE_NEWIPC as c_int , const
CLONE_NEWUSER = libc:: CLONE_NEWUSER as c_int , const
CLONE_NEWPID = libc:: CLONE_NEWPID as c_int , const
CLONE_NEWNET = libc:: CLONE_NEWNET as c_int , const CLONE_IO =
libc:: CLONE_IO as c_int , });
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
mod cpuset_attribs {
use super::CpuMask;
pub const CPU_SETSIZE: usize = 1024;
pub const CPU_MASK_BITS: usize = 64;
#[inline]
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
#[inline]
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
}
#[cfg(all(target_arch = "x86", target_os = "linux"))]
mod cpuset_attribs {
use super::CpuMask;
pub const CPU_SETSIZE: usize = 1024;
pub const CPU_MASK_BITS: usize = 32;
#[inline]
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
#[inline]
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
}
#[cfg(all(target_arch = "aarch64",
any(target_os = "linux", target_os = "android")))]
mod cpuset_attribs {
use super::CpuMask;
pub const CPU_SETSIZE: usize = 1024;
pub const CPU_MASK_BITS: usize = 64;
#[inline]
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
#[inline]
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
}
#[cfg(all(any(target_arch = "arm", target_arch = "mips"),
target_os = "android"))]
mod cpuset_attribs {
use super::CpuMask;
pub const CPU_SETSIZE: usize = 32;
pub const CPU_MASK_BITS: usize = 32;
#[inline]
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
#[inline]
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
}
#[cfg(all(any(target_arch = "arm", target_arch = "mips"),
target_os = "linux"))]
mod cpuset_attribs {
use super::CpuMask;
pub const CPU_SETSIZE: usize = 1024;
pub const CPU_MASK_BITS: usize = 32;
#[inline]
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
#[inline]
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
loop { }
}
}
pub type CloneCb<'a> = ::std::boxed::Box<FnMut() -> isize+ 'a>;
pub type CpuMask = c_ulong;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CpuSet {
cpu_mask: [CpuMask; cpuset_attribs::CPU_SETSIZE /
cpuset_attribs::CPU_MASK_BITS],
}
impl CpuSet {
pub fn new() -> CpuSet { loop { } }
pub fn set(&mut self, field: usize) { loop { } }
pub fn unset(&mut self, field: usize) { loop { } }
}
mod ffi {
use libc::{c_void, c_int, pid_t, size_t};
use super::CpuSet;
pub type CloneCb =
extern "C" fn(data: *const super::CloneCb) -> c_int;
#[allow(improper_ctypes)]
extern "C" {
pub fn clone(cb: *const CloneCb, child_stack: *mut c_void,
flags: c_int, arg: *mut super::CloneCb, ...)
-> c_int;
pub fn unshare(flags: c_int) -> c_int;
pub fn setns(fd: c_int, nstype: c_int) -> c_int;
pub fn sched_setaffinity(__pid: pid_t, __cpusetsize: size_t,
__cpuset: *const CpuSet) -> c_int;
}
}
pub fn sched_setaffinity(pid: isize, cpuset: &CpuSet) -> Result<()> {
loop { }
}
pub fn clone(mut cb: CloneCb, stack: &mut [u8], flags: CloneFlags)
-> Result<pid_t> {
loop { }
}
pub fn unshare(flags: CloneFlags) -> Result<()> { loop { } }
pub fn setns(fd: RawFd, nstype: CloneFlags) -> Result<()> { loop { } }
}
pub mod sys {
#[prelude_import]
use std::prelude::v1::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod epoll {
use {Errno, Result};
use libc::c_int;
use std::os::unix::io::RawFd;
mod ffi {
use libc::{c_int};
use super::EpollEvent;
extern "C" {
pub fn epoll_create(size: c_int) -> c_int;
pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int,
event: *const EpollEvent) -> c_int;
pub fn epoll_wait(epfd: c_int, events: *mut EpollEvent,
max_events: c_int, timeout: c_int) -> c_int;
}
}
bitflags! (# [ repr ( C ) ] flags EpollEventKind : u32 {
const EPOLLIN = 0x001 , const EPOLLPRI = 0x002 , const
EPOLLOUT = 0x004 , const EPOLLRDNORM = 0x040 , const
EPOLLRDBAND = 0x080 , const EPOLLWRNORM = 0x100 , const
EPOLLWRBAND = 0x200 , const EPOLLMSG = 0x400 , const
EPOLLERR = 0x008 , const EPOLLHUP = 0x010 , const
EPOLLRDHUP = 0x2000 , const EPOLLEXCLUSIVE = 1 << 28 ,
const EPOLLWAKEUP = 1 << 29 , const EPOLLONESHOT = 1 << 30
, const EPOLLET = 1 << 31 });
#[derive(Clone, Copy)]
#[repr(C)]
pub enum EpollOp {
EpollCtlAdd = 1,
EpollCtlDel = 2,
EpollCtlMod = 3,
}
#[cfg(not(target_arch = "x86_64"))]
#[derive(Clone, Copy)]
#[repr(C)]
pub struct EpollEvent {
pub events: EpollEventKind,
pub data: u64,
}
#[cfg(target_arch = "x86_64")]
#[derive(Clone, Copy)]
#[repr(C, packed)]
pub struct EpollEvent {
pub events: EpollEventKind,
pub data: u64,
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[test]
fn test_epoll_event_size() { loop { } }
#[cfg(target_arch = "arm")]
#[test]
fn test_epoll_event_size() { loop { } }
#[inline]
pub fn epoll_create() -> Result<RawFd> { loop { } }
#[inline]
pub fn epoll_ctl(epfd: RawFd, op: EpollOp, fd: RawFd,
event: &EpollEvent) -> Result<()> {
loop { }
}
#[inline]
pub fn epoll_wait(epfd: RawFd, events: &mut [EpollEvent],
timeout_ms: isize) -> Result<usize> {
loop { }
}
}
#[cfg(target_os = "linux")]
pub mod memfd {
#[prelude_import]
use std::prelude::v1::*;
use libc;
use std::os::unix::io::RawFd;
use {Errno, Result};
use std::ffi::CStr;
pub struct MemFdCreateFlag {
bits: libc::c_uint,
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::hash::Hash for MemFdCreateFlag {
fn hash<__H: ::std::hash::Hasher>(&self, __arg_0: &mut __H)
-> () {
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } => {
::std::hash::Hash::hash(&(*__self_0_0), __arg_0);
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Ord for MemFdCreateFlag {
#[inline]
fn cmp(&self, __arg_0: &MemFdCreateFlag) -> ::std::cmp::Ordering {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
match ::std::cmp::Ord::cmp(&(*__self_0_0),
&(*__self_1_0)) {
::std::cmp::Ordering::Equal =>
::std::cmp::Ordering::Equal,
__cmp => __cmp,
},
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialOrd for MemFdCreateFlag {
#[inline]
fn partial_cmp(&self, __arg_0: &MemFdCreateFlag)
-> ::std::option::Option<::std::cmp::Ordering> {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
match ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0),
&(*__self_1_0))
{
::std::option::Option::Some(::std::cmp::Ordering::Equal)
=>
::std::option::Option::Some(::std::cmp::Ordering::Equal),
__cmp => __cmp,
},
},
}
}
#[inline]
fn lt(&self, __arg_0: &MemFdCreateFlag) -> bool {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && false,
},
}
}
#[inline]
fn le(&self, __arg_0: &MemFdCreateFlag) -> bool {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && true,
},
}
}
#[inline]
fn gt(&self, __arg_0: &MemFdCreateFlag) -> bool {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && false,
},
}
}
#[inline]
fn ge(&self, __arg_0: &MemFdCreateFlag) -> bool {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && true,
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::clone::Clone for MemFdCreateFlag {
#[inline]
fn clone(&self) -> MemFdCreateFlag {
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
MemFdCreateFlag{bits:
::std::clone::Clone::clone(&(*__self_0_0)),},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Eq for MemFdCreateFlag {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } => {
(*__self_0_0).assert_receiver_is_total_eq();
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialEq for MemFdCreateFlag {
#[inline]
fn eq(&self, __arg_0: &MemFdCreateFlag) -> bool {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
true && (*__self_0_0) == (*__self_1_0),
},
}
}
#[inline]
fn ne(&self, __arg_0: &MemFdCreateFlag) -> bool {
match *__arg_0 {
MemFdCreateFlag { bits: ref __self_1_0 } =>
match *self {
MemFdCreateFlag { bits: ref __self_0_0 } =>
false || (*__self_0_0) != (*__self_1_0),
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::marker::Copy for MemFdCreateFlag { }
pub const MFD_CLOEXEC: MemFdCreateFlag = MemFdCreateFlag{bits: 1,};
pub const MFD_ALLOW_SEALING: MemFdCreateFlag =
MemFdCreateFlag{bits: 2,};
impl ::bitflags::__core::fmt::Debug for MemFdCreateFlag {
fn fmt(&self, f: &mut ::bitflags::__core::fmt::Formatter)
-> ::bitflags::__core::fmt::Result { loop { } }
}
#[allow(dead_code)]
impl MemFdCreateFlag {
/// Returns an empty set of flags.
#[inline]
pub fn empty() -> MemFdCreateFlag { MemFdCreateFlag{bits: 0,} }
/// Returns the set containing all flags.
#[inline]
pub fn all() -> MemFdCreateFlag {
#[allow(dead_code)]
mod dummy {
#[prelude_import]
use std::prelude::v1::*;
const MFD_CLOEXEC: super::MemFdCreateFlag =
super::MemFdCreateFlag{bits: 0,};
const MFD_ALLOW_SEALING: super::MemFdCreateFlag =
super::MemFdCreateFlag{bits: 0,};
#[inline]
pub fn all() -> super::MemFdCreateFlag {
use super::*;
MemFdCreateFlag{bits:
MFD_CLOEXEC.bits |
MFD_ALLOW_SEALING.bits,}
}
}
dummy::all()
}
/// Returns the raw value of the flags currently stored.
#[inline]
pub fn bits(&self) -> libc::c_uint { self.bits }
/// Convert from underlying bit representation, unless that
/// representation contains bits that do not correspond to a flag.
#[inline]
pub fn from_bits(bits: libc::c_uint)
-> ::bitflags::__core::option::Option<MemFdCreateFlag> {
if (bits & !MemFdCreateFlag::all().bits()) != 0 {
::bitflags::__core::option::Option::None
} else {
::bitflags::__core::option::Option::Some(MemFdCreateFlag{bits:
bits,})
}
}
/// Convert from underlying bit representation, dropping any bits
/// that do not correspond to flags.
#[inline]
pub fn from_bits_truncate(bits: libc::c_uint) -> MemFdCreateFlag {
MemFdCreateFlag{bits: bits,} & MemFdCreateFlag::all()
}
/// Returns `true` if no flags are currently stored.
#[inline]
pub fn is_empty(&self) -> bool {
*self == MemFdCreateFlag::empty()
}
/// Returns `true` if all flags are currently set.
#[inline]
pub fn is_all(&self) -> bool { *self == MemFdCreateFlag::all() }
/// Returns `true` if there are flags common to both `self` and `other`.
#[inline]
pub fn intersects(&self, other: MemFdCreateFlag) -> bool {
!(*self & other).is_empty()
}
/// Returns `true` all of the flags in `other` are contained within `self`.
#[inline]
pub fn contains(&self, other: MemFdCreateFlag) -> bool {
(*self & other) == other
}
/// Inserts the specified flags in-place.
#[inline]
pub fn insert(&mut self, other: MemFdCreateFlag) {
self.bits |= other.bits;
}
/// Removes the specified flags in-place.
#[inline]
pub fn remove(&mut self, other: MemFdCreateFlag) {
self.bits &= !other.bits;
}
/// Toggles the specified flags in-place.
#[inline]
pub fn toggle(&mut self, other: MemFdCreateFlag) {
self.bits ^= other.bits;
}
}
impl ::bitflags::__core::ops::BitOr for MemFdCreateFlag {
type
Output
=
MemFdCreateFlag;
/// Returns the union of the two sets of flags.
#[inline]
fn bitor(self, other: MemFdCreateFlag) -> MemFdCreateFlag {
MemFdCreateFlag{bits: self.bits | other.bits,}
}
}
impl ::bitflags::__core::ops::BitXor for MemFdCreateFlag {
type
Output
=
MemFdCreateFlag;
/// Returns the left flags, but with all the right flags toggled.
#[inline]
fn bitxor(self, other: MemFdCreateFlag) -> MemFdCreateFlag {
MemFdCreateFlag{bits: self.bits ^ other.bits,}
}
}
impl ::bitflags::__core::ops::BitAnd for MemFdCreateFlag {
type
Output
=
MemFdCreateFlag;
/// Returns the intersection between the two sets of flags.
#[inline]
fn bitand(self, other: MemFdCreateFlag) -> MemFdCreateFlag {
MemFdCreateFlag{bits: self.bits & other.bits,}
}
}
impl ::bitflags::__core::ops::Sub for MemFdCreateFlag {
type
Output
=
MemFdCreateFlag;
/// Returns the set difference of the two sets of flags.
#[inline]
fn sub(self, other: MemFdCreateFlag) -> MemFdCreateFlag {
MemFdCreateFlag{bits: self.bits & !other.bits,}
}
}
impl ::bitflags::__core::ops::Not for MemFdCreateFlag {
type
Output
=
MemFdCreateFlag;
/// Returns the complement of this set of flags.
#[inline]
fn not(self) -> MemFdCreateFlag {
MemFdCreateFlag{bits: !self.bits,} & MemFdCreateFlag::all()
}
}
impl ::bitflags::__core::iter::FromIterator<MemFdCreateFlag> for
MemFdCreateFlag {
fn from_iter<T: ::bitflags::__core::iter::IntoIterator<Item =
MemFdCreateFlag>>(iterator: T) -> MemFdCreateFlag {
let mut result = Self::empty();
for item in iterator { result.insert(item) }
result
}
}
pub fn memfd_create(name: &CStr, flags: MemFdCreateFlag)
-> Result<RawFd> {
use sys::syscall::{syscall, MEMFD_CREATE};
let res =
unsafe { syscall(MEMFD_CREATE, name.as_ptr(), flags.bits()) };
Errno::result(res).map(|r| r as RawFd)
}
}
#[cfg(not(any(target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly")))]
pub mod ioctl {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[path = "platform/linux.rs"]
#[macro_use]
mod platform {
pub const NRBITS: u32 = 8;
pub const TYPEBITS: u32 = 8;
#[cfg(any(target_arch = "mips", target_arch = "powerpc"))]
mod consts {
pub const NONE: u8 = 1;
pub const READ: u8 = 2;
pub const WRITE: u8 = 4;
pub const SIZEBITS: u8 = 13;
pub const DIRBITS: u8 = 3;
}
#[cfg(not(any(target_arch = "powerpc",
target_arch = "mips",
target_arch = "x86",
target_arch = "arm",
target_arch = "x86_64",
target_arch = "aarch64")))]
use this_arch_not_supported;
#[cfg(any(target_arch = "x86",
target_arch = "arm",
target_arch = "x86_64",
target_arch = "aarch64"))]
mod consts {
pub const NONE: u8 = 0;
pub const READ: u8 = 2;
pub const WRITE: u8 = 1;
pub const SIZEBITS: u8 = 14;
pub const DIRBITS: u8 = 2;
}
pub use self::consts::*;
pub const NRSHIFT: u32 = 0;
pub const TYPESHIFT: u32 = NRSHIFT + (NRBITS as u32);
pub const SIZESHIFT: u32 = TYPESHIFT + (TYPEBITS as u32);
pub const DIRSHIFT: u32 = SIZESHIFT + (SIZEBITS as u32);
pub const NRMASK: u32 = (1 << NRBITS) - 1;
pub const TYPEMASK: u32 = (1 << TYPEBITS) - 1;
pub const SIZEMASK: u32 = (1 << SIZEBITS) - 1;
pub const DIRMASK: u32 = (1 << DIRBITS) - 1;
/// Encode an ioctl command.
#[macro_export]
macro_rules! ioc((
$ dir : expr , $ ty : expr , $ nr : expr , $ sz :
expr ) => (
(
( $ dir as u32 ) << $ crate:: sys:: ioctl::
DIRSHIFT ) | (
( $ ty as u32 ) << $ crate:: sys:: ioctl::
TYPESHIFT ) | (
( $ nr as u32 ) << $ crate:: sys:: ioctl::
NRSHIFT ) | (
( $ sz as u32 ) << $ crate:: sys:: ioctl::
SIZESHIFT ) ));
/// Encode an ioctl command that has no associated data.
#[macro_export]
macro_rules! io(( $ ty : expr , $ nr : expr ) => (
ioc ! (
$ crate:: sys:: ioctl:: NONE , $ ty , $ nr , 0 )
));
/// Encode an ioctl command that reads.
#[macro_export]
macro_rules! ior(( $ ty : expr , $ nr : expr , $ sz : expr ) => (
ioc ! (
$ crate:: sys:: ioctl:: READ , $ ty , $ nr , $ sz
) ));
/// Encode an ioctl command that writes.
#[macro_export]
macro_rules! iow(( $ ty : expr , $ nr : expr , $ sz : expr ) => (
ioc ! (
$ crate:: sys:: ioctl:: WRITE , $ ty , $ nr , $
sz ) ));
/// Encode an ioctl command that both reads and writes.
#[macro_export]
macro_rules! iorw(( $ ty : expr , $ nr : expr , $ sz : expr ) => (
ioc ! (
$ crate:: sys:: ioctl:: READ | $ crate:: sys::
ioctl:: WRITE , $ ty , $ nr , $ sz ) ));
/// Convert raw ioctl return value to a Nix result
#[macro_export]
macro_rules! convert_ioctl_res(( $ w : expr ) => (
{ $ crate:: Errno:: result ( $ w )
} ) ;);
/// Extracts the "direction" (read/write/none) from an encoded ioctl command.
#[inline(always)]
pub fn ioc_dir(nr: u32) -> u8 { loop { } }
/// Extracts the type from an encoded ioctl command.
#[inline(always)]
pub fn ioc_type(nr: u32) -> u32 { loop { } }
/// Extracts the ioctl number from an encoded ioctl command.
#[inline(always)]
pub fn ioc_nr(nr: u32) -> u32 { loop { } }
/// Extracts the size from an encoded ioctl command.
#[inline(always)]
pub fn ioc_size(nr: u32) -> u32 { loop { } }
pub const IN: u32 = (WRITE as u32) << DIRSHIFT;
pub const OUT: u32 = (READ as u32) << DIRSHIFT;
pub const INOUT: u32 = ((READ | WRITE) as u32) << DIRSHIFT;
pub const SIZE_MASK: u32 = SIZEMASK << SIZESHIFT;
}
#[cfg(target_os = "macos")]
#[path = "platform/macos.rs"]
#[macro_use]
mod platform { }
#[cfg(target_os = "ios")]
#[path = "platform/ios.rs"]
#[macro_use]
mod platform { }
#[cfg(target_os = "freebsd")]
#[path = "platform/freebsd.rs"]
#[macro_use]
mod platform { }
#[cfg(target_os = "netbsd")]
#[path = "platform/netbsd.rs"]
#[macro_use]
mod platform { }
#[cfg(target_os = "openbsd")]
#[path = "platform/openbsd.rs"]
#[macro_use]
mod platform { }
#[cfg(target_os = "dragonfly")]
#[path = "platform/dragonfly.rs"]
#[macro_use]
mod platform { }
pub use self::platform::*;
extern "C" {
#[doc(hidden)]
pub fn ioctl(fd: libc::c_int, req: libc::c_ulong, ...)
-> libc::c_int;
}
/// A hack to get the macros to work nicely.
#[doc(hidden)]
pub use libc;
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod sendfile {
#[prelude_import]
use std::prelude::v1::*;
use std::os::unix::io::RawFd;
use std::ptr;
use libc::{self, off_t};
use {Errno, Result};
pub fn sendfile(out_fd: RawFd, in_fd: RawFd,
offset: Option<&mut off_t>, count: usize)
-> Result<usize> {
let offset =
offset.map(|offset|
offset as *mut _).unwrap_or(ptr::null_mut());
let ret = unsafe { libc::sendfile(out_fd, in_fd, offset, count) };
Errno::result(ret).map(|r| r as usize)
}
}
pub mod signal {
use libc;
use {Errno, Result};
use std::mem;
use std::ptr;
pub use libc::{SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE,
SIGKILL, SIGSEGV, SIGPIPE, SIGALRM, SIGTERM, SIGTRAP,
SIGIOT, SIGBUS, SIGSYS, SIGURG, SIGSTOP, SIGTSTP,
SIGCONT, SIGCHLD, SIGTTIN, SIGTTOU, SIGIO, SIGXCPU,
SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGUSR1,
SIGUSR2};
pub const SIGEMT: libc::c_int = 7;
pub const NSIG: libc::c_int = 32;
bitflags! (flags SaFlags : libc:: c_int {
const SA_NOCLDSTOP = libc:: SA_NOCLDSTOP , const
SA_NOCLDWAIT = libc:: SA_NOCLDWAIT , const SA_NODEFER =
libc:: SA_NODEFER , const SA_ONSTACK = libc:: SA_ONSTACK ,
const SA_RESETHAND = libc:: SA_RESETHAND , const SA_RESTART
= libc:: SA_RESTART , const SA_SIGINFO = libc:: SA_SIGINFO
, });
bitflags! (flags SigFlags : libc:: c_int {
const SIG_BLOCK = libc:: SIG_BLOCK , const SIG_UNBLOCK =
libc:: SIG_UNBLOCK , const SIG_SETMASK = libc:: SIG_SETMASK
, });
#[derive(Clone, Copy)]
pub struct SigSet {
sigset: libc::sigset_t,
}
pub type SigNum = libc::c_int;
impl SigSet {
pub fn all() -> SigSet { loop { } }
pub fn empty() -> SigSet { loop { } }
pub fn add(&mut self, signum: SigNum) -> Result<()> { loop { } }
pub fn remove(&mut self, signum: SigNum) -> Result<()> {
loop { }
}
pub fn contains(&self, signum: SigNum) -> Result<bool> {
loop { }
}
/// Gets the currently blocked (masked) set of signals for the calling thread.
pub fn thread_get_mask() -> Result<SigSet> { loop { } }
/// Sets the set of signals as the signal mask for the calling thread.
pub fn thread_set_mask(&self) -> Result<()> { loop { } }
/// Adds the set of signals to the signal mask for the calling thread.
pub fn thread_block(&self) -> Result<()> { loop { } }
/// Removes the set of signals from the signal mask for the calling thread.
pub fn thread_unblock(&self) -> Result<()> { loop { } }
/// Sets the set of signals as the signal mask, and returns the old mask.
pub fn thread_swap_mask(&self, how: SigFlags) -> Result<SigSet> {
loop { }
}
/// Suspends execution of the calling thread until one of the signals in the
/// signal mask becomes pending, and returns the accepted signal.
pub fn wait(&self) -> Result<SigNum> { loop { } }
}
impl AsRef<libc::sigset_t> for SigSet {
fn as_ref(&self) -> &libc::sigset_t { loop { } }
}
#[allow(unknown_lints)]
#[cfg_attr(not(raw_pointer_derive_allowed),
allow(raw_pointer_derive))]
#[derive(Clone, Copy, PartialEq)]
pub enum SigHandler {
SigDfl,
SigIgn,
Handler(extern "C" fn(SigNum)),
SigAction(extern "C" fn(SigNum, *mut libc::siginfo_t,
*mut libc::c_void)),
}
pub struct SigAction {
sigaction: libc::sigaction,
}
impl SigAction {
/// This function will set or unset the flag `SA_SIGINFO` depending on the
/// type of the `handler` argument.
pub fn new(handler: SigHandler, flags: SaFlags, mask: SigSet)
-> SigAction {
loop { }
}
}
pub unsafe fn sigaction(signum: SigNum, sigaction: &SigAction)
-> Result<SigAction> {
loop { }
}
pub fn pthread_sigmask(how: SigFlags, set: Option<&SigSet>,
oldset: Option<&mut SigSet>) -> Result<()> {
loop { }
}
pub fn kill(pid: libc::pid_t, signum: SigNum) -> Result<()> {
loop { }
}
pub fn raise(signum: SigNum) -> Result<()> { loop { } }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_contains() { loop { } }
#[test]
fn test_thread_signal_block() { loop { } }
#[test]
fn test_thread_signal_swap() { loop { } }
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
#[test]
fn test_sigwait() { loop { } }
}
}
pub mod socket {
//! Socket interface functions
//!
//! [Further reading](http://man7.org/linux/man-pages/man7/socket.7.html)
use {Error, Errno, Result};
use features;
// use fcntl::{fcntl, FD_CLOEXEC, O_NONBLOCK};
// use fcntl::FcntlArg::{F_SETFD, F_SETFL};
use libc::{c_void, c_int, socklen_t, size_t, pid_t, uid_t, gid_t};
use std::{mem, ptr, slice};
use std::os::unix::io::RawFd;
use sys::uio::IoVec;
mod addr {
use super::{consts, sa_family_t};
use {Errno, Error, Result, NixPath};
use libc;
use std::{fmt, hash, mem, net, ptr};
use std::ffi::OsStr;
use std::path::Path;
use std::os::unix::ffi::OsStrExt;
#[cfg(any(target_os = "linux", target_os = "android"))]
use sys::socket::addr::netlink::NetlinkAddr;
#[repr(i32)]
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum AddressFamily {
Unix = consts::AF_UNIX,
Inet = consts::AF_INET,
Inet6 = consts::AF_INET6,
#[cfg(any(target_os = "linux", target_os = "android"))]
Netlink = consts::AF_NETLINK,
#[cfg(any(target_os = "linux", target_os = "android"))]
Packet = consts::AF_PACKET,
}
#[derive(Copy)]
pub enum InetAddr {
V4(libc::sockaddr_in),
V6(libc::sockaddr_in6),
}
impl InetAddr {
pub fn from_std(std: &net::SocketAddr) -> InetAddr {
loop { }
}
pub fn new(ip: IpAddr, port: u16) -> InetAddr { loop { } }
/// Gets the IP address associated with this socket address.
pub fn ip(&self) -> IpAddr { loop { } }
/// Gets the port number associated with this socket address
pub fn port(&self) -> u16 { loop { } }
pub fn to_std(&self) -> net::SocketAddr { loop { } }
// pub fn to_str(&self) -> String { loop { } }
}
impl PartialEq for InetAddr {
fn eq(&self, other: &InetAddr) -> bool { loop { } }
}
impl Eq for InetAddr { }
impl hash::Hash for InetAddr {
fn hash<H: hash::Hasher>(&self, s: &mut H) { loop { } }
}
impl Clone for InetAddr {
fn clone(&self) -> InetAddr { loop { } }
}
impl fmt::Display for InetAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
pub enum IpAddr { V4(Ipv4Addr), V6(Ipv6Addr), }
impl IpAddr {
/// Create a new IpAddr that contains an IPv4 address.
///
/// The result will represent the IP address a.b.c.d
pub fn new_v4(a: u8, b: u8, c: u8, d: u8) -> IpAddr {
loop { }
}
/// Create a new IpAddr that contains an IPv6 address.
///
/// The result will represent the IP address a:b:c:d:e:f
pub fn new_v6(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16,
g: u16, h: u16) -> IpAddr {
loop { }
}
}
impl fmt::Display for IpAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
#[derive(Copy)]
pub struct Ipv4Addr(pub libc::in_addr);
impl Ipv4Addr {
pub fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr {
loop { }
}
pub fn from_std(std: &net::Ipv4Addr) -> Ipv4Addr { loop { } }
pub fn any() -> Ipv4Addr { loop { } }
pub fn octets(&self) -> [u8; 4] { loop { } }
pub fn to_std(&self) -> net::Ipv4Addr { loop { } }
}
impl PartialEq for Ipv4Addr {
fn eq(&self, other: &Ipv4Addr) -> bool { loop { } }
}
impl Eq for Ipv4Addr { }
impl hash::Hash for Ipv4Addr {
fn hash<H: hash::Hasher>(&self, s: &mut H) { loop { } }
}
impl Clone for Ipv4Addr {
fn clone(&self) -> Ipv4Addr { loop { } }
}
impl fmt::Display for Ipv4Addr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
#[derive(Clone, Copy)]
pub struct Ipv6Addr(pub libc::in6_addr);
macro_rules! to_u8_array(( $ ( $ num : ident ) , * ) => {
[
$ (
( $ num >> 8 ) as u8 , ( $ num & 0xff )
as u8 , ) * ] });
macro_rules! to_u16_array((
$ slf : ident , $ (
$ first : expr , $ second : expr ) , * )
=> {
[
$ (
(
( $ slf . 0 . s6_addr [ $ first ] as u16
) << 8 ) + $ slf . 0 . s6_addr [
$ second ] as u16 , ) * ] });
impl Ipv6Addr {
pub fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16,
g: u16, h: u16) -> Ipv6Addr {
loop { }
}
pub fn from_std(std: &net::Ipv6Addr) -> Ipv6Addr { loop { } }
/// Return the eight 16-bit segments that make up this address
pub fn segments(&self) -> [u16; 8] { loop { } }
pub fn to_std(&self) -> net::Ipv6Addr { loop { } }
}
impl fmt::Display for Ipv6Addr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
/// A wrapper around sockaddr_un. We track the length of sun_path,
/// because it may not be null-terminated (unconnected and abstract
/// sockets). Note that the actual sockaddr length is greater by
/// size_of::<sa_family_t>().
#[derive(Copy)]
pub struct UnixAddr(pub libc::sockaddr_un, pub usize);
impl UnixAddr {
/// Create a new sockaddr_un representing a filesystem path.
pub fn new<P: ?Sized + NixPath>(path: &P)
-> Result<UnixAddr> {
loop { }
}
/// Create a new sockaddr_un representing an address in the
/// "abstract namespace". This is a Linux-specific extension,
/// primarily used to allow chrooted processes to communicate with
/// specific daemons.
pub fn new_abstract(path: &[u8]) -> Result<UnixAddr> {
loop { }
}
fn sun_path(&self) -> &[u8] { loop { } }
/// If this address represents a filesystem path, return that path.
pub fn path(&self) -> Option<&Path> { loop { } }
}
impl PartialEq for UnixAddr {
fn eq(&self, other: &UnixAddr) -> bool { loop { } }
}
impl Eq for UnixAddr { }
impl hash::Hash for UnixAddr {
fn hash<H: hash::Hasher>(&self, s: &mut H) { loop { } }
}
impl Clone for UnixAddr {
fn clone(&self) -> UnixAddr { loop { } }
}
impl fmt::Display for UnixAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
/// Represents a socket address
#[derive(Copy)]
pub enum SockAddr {
Inet(InetAddr),
Unix(UnixAddr),
#[cfg(any(target_os = "linux", target_os = "android"))]
Netlink(NetlinkAddr),
}
impl SockAddr {
pub fn new_inet(addr: InetAddr) -> SockAddr { loop { } }
pub fn new_unix<P: ?Sized + NixPath>(path: &P)
-> Result<SockAddr> {
loop { }
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn new_netlink(pid: u32, groups: u32) -> SockAddr {
loop { }
}
pub fn family(&self) -> AddressFamily { loop { } }
// pub fn to_str(&self) -> String { loop { } }
pub unsafe fn as_ffi_pair(&self)
-> (&libc::sockaddr, libc::socklen_t) {
loop { }
}
}
impl PartialEq for SockAddr {
fn eq(&self, other: &SockAddr) -> bool { loop { } }
}
impl Eq for SockAddr { }
impl hash::Hash for SockAddr {
fn hash<H: hash::Hasher>(&self, s: &mut H) { loop { } }
}
impl Clone for SockAddr {
fn clone(&self) -> SockAddr { loop { } }
}
impl fmt::Display for SockAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod netlink {
use sys::socket::addr::{AddressFamily};
use libc::{sa_family_t, sockaddr_nl};
use std::{fmt, mem};
use std::hash::{Hash, Hasher};
#[derive(Copy, Clone)]
pub struct NetlinkAddr(pub sockaddr_nl);
impl PartialEq for NetlinkAddr {
fn eq(&self, other: &Self) -> bool { loop { } }
}
impl Eq for NetlinkAddr { }
impl Hash for NetlinkAddr {
fn hash<H: Hasher>(&self, s: &mut H) { loop { } }
}
impl NetlinkAddr {
pub fn new(pid: u32, groups: u32) -> NetlinkAddr {
loop { }
}
pub fn pid(&self) -> u32 { loop { } }
pub fn groups(&self) -> u32 { loop { } }
}
impl fmt::Display for NetlinkAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
}
}
mod consts {
pub use self::os::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
use libc::{self, c_int, uint8_t};
pub const AF_UNIX: c_int = 1;
pub const AF_LOCAL: c_int = AF_UNIX;
pub const AF_INET: c_int = 2;
pub const AF_INET6: c_int = 10;
pub const AF_NETLINK: c_int = 16;
pub const AF_PACKET: c_int = 17;
pub const SOCK_STREAM: c_int = 1;
pub const SOCK_DGRAM: c_int = 2;
pub const SOCK_SEQPACKET: c_int = 5;
pub const SOCK_RAW: c_int = 3;
pub const SOCK_RDM: c_int = 4;
pub const SOL_IP: c_int = 0;
pub const SOL_SOCKET: c_int = 1;
pub const SOL_TCP: c_int = 6;
pub const SOL_UDP: c_int = 17;
pub const SOL_IPV6: c_int = 41;
pub const SOL_NETLINK: c_int = 270;
pub const IPPROTO_IP: c_int = SOL_IP;
pub const IPPROTO_IPV6: c_int = SOL_IPV6;
pub const IPPROTO_TCP: c_int = SOL_TCP;
pub const IPPROTO_UDP: c_int = SOL_UDP;
pub const SO_ACCEPTCONN: c_int = 30;
pub const SO_BINDTODEVICE: c_int = 25;
pub const SO_BROADCAST: c_int = 6;
pub const SO_BSDCOMPAT: c_int = 14;
pub const SO_DEBUG: c_int = 1;
pub const SO_DOMAIN: c_int = 39;
pub const SO_ERROR: c_int = 4;
pub const SO_DONTROUTE: c_int = 5;
pub const SO_KEEPALIVE: c_int = 9;
pub const SO_LINGER: c_int = 13;
pub const SO_MARK: c_int = 36;
pub const SO_OOBINLINE: c_int = 10;
pub const SO_PASSCRED: c_int = 16;
pub const SO_PEEK_OFF: c_int = 42;
pub const SO_PEERCRED: c_int = 17;
pub const SO_PRIORITY: c_int = 12;
pub const SO_PROTOCOL: c_int = 38;
pub const SO_RCVBUF: c_int = 8;
pub const SO_RCVBUFFORCE: c_int = 33;
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_REUSEADDR: c_int = 2;
pub const SO_REUSEPORT: c_int = 15;
pub const SO_RXQ_OVFL: c_int = 40;
pub const SO_SNDBUF: c_int = 7;
pub const SO_SNDBUFFORCE: c_int = 32;
pub const SO_TIMESTAMP: c_int = 29;
pub const SO_TYPE: c_int = 3;
pub const SO_BUSY_POLL: c_int = 46;
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 = libc::TCP_KEEPIDLE;
pub const IP_MULTICAST_IF: c_int = 32;
pub type IpMulticastTtl = uint8_t;
pub const IP_MULTICAST_TTL: c_int = 33;
pub const IP_MULTICAST_LOOP: c_int = 34;
pub const IP_ADD_MEMBERSHIP: c_int = 35;
pub const IP_DROP_MEMBERSHIP: c_int = 36;
pub const IPV6_ADD_MEMBERSHIP: c_int =
libc::IPV6_ADD_MEMBERSHIP;
pub const IPV6_DROP_MEMBERSHIP: c_int =
libc::IPV6_DROP_MEMBERSHIP;
pub type InAddrT = u32;
pub const INADDR_ANY: InAddrT = 0;
pub const INADDR_NONE: InAddrT = 4294967295;
pub const INADDR_BROADCAST: InAddrT = 4294967295;
bitflags! (flags MsgFlags : libc:: c_int {
const MSG_OOB = 0x0001 , const MSG_PEEK = 0x0002 ,
const MSG_CTRUNC = 0x0008 , const MSG_TRUNC =
0x0020 , const MSG_DONTWAIT = 0x0040 , const
MSG_EOR = 0x0080 , const MSG_ERRQUEUE = 0x2000 ,
});
pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;
pub const SCM_RIGHTS: c_int = 1;
}
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "ios",
target_os = "openbsd",
target_os = "netbsd"))]
mod os {
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd"))]
use libc::{self, c_int, uint8_t};
#[cfg(any(target_os = "openbsd", target_os = "netbsd"))]
use libc::{self, c_int, uint8_t};
pub const AF_UNIX: c_int = 1;
pub const AF_LOCAL: c_int = AF_UNIX;
pub const AF_INET: c_int = 2;
#[cfg(target_os = "netbsd")]
pub const AF_INET6: c_int = 24;
#[cfg(target_os = "openbsd")]
pub const AF_INET6: c_int = 26;
#[cfg(target_os = "freebsd")]
pub const AF_INET6: c_int = 28;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub const AF_INET6: c_int = 30;
pub const SOCK_STREAM: c_int = 1;
pub const SOCK_DGRAM: c_int = 2;
pub const SOCK_SEQPACKET: c_int = 5;
pub const SOCK_RAW: c_int = 3;
pub const SOCK_RDM: c_int = 4;
pub const SOL_SOCKET: c_int = 65535;
pub const IPPROTO_IP: c_int = 0;
pub const IPPROTO_IPV6: c_int = 41;
pub const IPPROTO_TCP: c_int = 6;
pub const IPPROTO_UDP: c_int = 17;
pub const SO_ACCEPTCONN: c_int = 2;
pub const SO_BROADCAST: c_int = 32;
pub const SO_DEBUG: c_int = 1;
#[cfg(not(target_os = "netbsd"))]
pub const SO_DONTTRUNC: c_int = 8192;
#[cfg(target_os = "netbsd")]
pub const SO_USELOOPBACK: c_int = 64;
pub const SO_ERROR: c_int = 4103;
pub const SO_DONTROUTE: c_int = 16;
pub const SO_KEEPALIVE: c_int = 8;
pub const SO_LABEL: c_int = 4112;
pub const SO_LINGER: c_int = 128;
pub const SO_NREAD: c_int = 4128;
pub const SO_NKE: c_int = 4129;
pub const SO_NOSIGPIPE: c_int = 4130;
pub const SO_NOADDRERR: c_int = 4131;
pub const SO_NOTIFYCONFLICT: c_int = 4134;
pub const SO_NP_EXTENSIONS: c_int = 4227;
pub const SO_NWRITE: c_int = 4132;
pub const SO_OOBINLINE: c_int = 256;
pub const SO_PEERLABEL: c_int = 4113;
pub const SO_RCVBUF: c_int = 4098;
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_RANDOMPORT: c_int = 4226;
pub const SO_RESTRICTIONS: c_int = 4225;
pub const SO_RESTRICT_DENYIN: c_int = 1;
pub const SO_RESTRICT_DENYOUT: c_int = 2;
pub const SO_REUSEADDR: c_int = 4;
pub const SO_REUSEPORT: c_int = 512;
pub const SO_REUSESHAREUID: c_int = 4133;
pub const SO_SNDBUF: c_int = 4097;
#[cfg(not(target_os = "netbsd"))]
pub const SO_TIMESTAMP: c_int = 1024;
#[cfg(not(target_os = "netbsd"))]
pub const SO_TIMESTAMP_MONOTONIC: c_int = 2048;
#[cfg(target_os = "netbsd")]
pub const SO_TIMESTAMP: c_int = 8192;
pub const SO_TYPE: c_int = 4104;
#[cfg(not(target_os = "netbsd"))]
pub const SO_WANTMORE: c_int = 16384;
pub const SO_WANTOOBFLAG: c_int = 32768;
#[allow(overflowing_literals)]
pub const SO_RESTRICT_DENYSET: c_int = 2147483648;
pub const TCP_NODELAY: c_int = 1;
pub const TCP_MAXSEG: c_int = 2;
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub const TCP_KEEPALIVE: c_int = libc::TCP_KEEPALIVE;
#[cfg(target_os = "freebsd")]
pub const TCP_KEEPIDLE: c_int = libc::TCP_KEEPIDLE;
#[cfg(target_os = "netbsd")]
pub const TCP_KEEPIDLE: c_int = 3;
pub const IP_MULTICAST_IF: c_int = 9;
pub type IpMulticastTtl = uint8_t;
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_JOIN_GROUP: c_int = libc::IPV6_JOIN_GROUP;
pub const IPV6_LEAVE_GROUP: c_int = libc::IPV6_LEAVE_GROUP;
pub type InAddrT = u32;
pub const INADDR_ANY: InAddrT = 0;
pub const INADDR_NONE: InAddrT = 4294967295;
pub const INADDR_BROADCAST: InAddrT = 4294967295;
bitflags! (flags MsgFlags : libc:: c_int {
const MSG_OOB = 0x01 , const MSG_PEEK = 0x02 ,
const MSG_EOR = 0x08 , const MSG_TRUNC = 0x10 ,
const MSG_CTRUNC = 0x20 , const MSG_DONTWAIT = 0x80
, });
pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;
pub const SCM_RIGHTS: c_int = 1;
}
#[cfg(target_os = "dragonfly")]
mod os {
use libc::{c_int, uint8_t};
pub const AF_UNIX: c_int = 1;
pub const AF_LOCAL: c_int = AF_UNIX;
pub const AF_INET: c_int = 2;
pub const AF_INET6: c_int = 28;
pub const SOCK_STREAM: c_int = 1;
pub const SOCK_DGRAM: c_int = 2;
pub const SOCK_SEQPACKET: c_int = 5;
pub const SOCK_RAW: c_int = 3;
pub const SOCK_RDM: c_int = 4;
pub const SOL_SOCKET: c_int = 65535;
pub const IPPROTO_IP: c_int = 0;
pub const IPPROTO_IPV6: c_int = 41;
pub const IPPROTO_TCP: c_int = 6;
pub const IPPROTO_UDP: c_int = 17;
pub const SO_ACCEPTCONN: c_int = 2;
pub const SO_BROADCAST: c_int = 32;
pub const SO_DEBUG: c_int = 1;
pub const SO_ERROR: c_int = 4103;
pub const SO_DONTROUTE: c_int = 16;
pub const SO_KEEPALIVE: c_int = 8;
pub const SO_LINGER: c_int = 128;
pub const SO_NOSIGPIPE: c_int = 2048;
pub const SO_OOBINLINE: c_int = 256;
pub const SO_RCVBUF: c_int = 4098;
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_REUSEADDR: c_int = 4;
pub const SO_REUSEPORT: c_int = 512;
pub const SO_SNDBUF: c_int = 4097;
pub const SO_TIMESTAMP: c_int = 1024;
pub const SO_TYPE: c_int = 4104;
pub const TCP_NODELAY: c_int = 1;
pub const TCP_MAXSEG: c_int = 2;
pub const TCP_KEEPIDLE: c_int = 256;
pub const IP_MULTICAST_IF: c_int = 9;
pub type IpMulticastTtl = uint8_t;
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_JOIN_GROUP: c_int = libc::IPV6_JOIN_GROUP;
pub const IPV6_LEAVE_GROUP: c_int = libc::IPV6_LEAVE_GROUP;
pub type InAddrT = u32;
pub const INADDR_ANY: InAddrT = 0;
pub const INADDR_NONE: InAddrT = 4294967295;
pub const INADDR_BROADCAST: InAddrT = 4294967295;
bitflags! (flags MsgFlags : libc:: c_int {
const MSG_OOB = 0x01 , const MSG_PEEK = 0x02 ,
const MSG_DONTWAIT = 0x80 , });
pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;
}
#[cfg(test)]
mod test {
use super::*;
use nixtest::{assert_const_eq, get_int_const, GetConst};
use libc::{c_char};
use std::fmt;
impl fmt::Display for MsgFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
impl GetConst for MsgFlags {
unsafe fn get_const(name: *const c_char) -> MsgFlags {
loop { }
}
}
macro_rules! check_const(( $ ( $ konst : ident ) , + ) => {
{
$ (
assert_const_eq (
stringify ! ( $ konst ) , $ konst ) ;
) + } } ;);
#[test]
pub fn test_const_values() { loop { } }
#[cfg(target_os = "linux")]
#[test]
pub fn test_linux_consts() { loop { } }
}
}
mod ffi {
#![allow(improper_ctypes)]
pub use libc::{socket, listen, bind, accept, connect, setsockopt,
sendto, recvfrom, getsockname, getpeername, recv,
send};
use libc::{c_int, c_void, socklen_t, size_t, ssize_t};
use sys::uio::IoVec;
#[cfg(target_os = "linux")]
pub type type_of_cmsg_len = size_t;
#[cfg(not(target_os = "linux"))]
pub type type_of_cmsg_len = socklen_t;
#[repr(C)]
pub struct msghdr<'a> {
pub msg_name: *const c_void,
pub msg_namelen: socklen_t,
pub msg_iov: *const IoVec<&'a [u8]>,
pub msg_iovlen: size_t,
pub msg_control: *const c_void,
pub msg_controllen: size_t,
pub msg_flags: c_int,
}
#[repr(C)]
pub struct cmsghdr {
pub cmsg_len: type_of_cmsg_len,
pub cmsg_level: c_int,
pub cmsg_type: c_int,
pub cmsg_data: [type_of_cmsg_len; 0],
}
extern "C" {
pub fn getsockopt(sockfd: c_int, level: c_int, optname: c_int,
optval: *mut c_void, optlen: *mut socklen_t)
-> c_int;
pub fn socketpair(domain: c_int, typ: c_int, protocol: c_int,
sv: *mut c_int) -> c_int;
pub fn sendmsg(sockfd: c_int, msg: *const msghdr,
flags: c_int) -> ssize_t;
pub fn recvmsg(sockfd: c_int, msg: *mut msghdr, flags: c_int)
-> ssize_t;
}
}
mod multicast {
use super::addr::{Ipv4Addr, Ipv6Addr};
use libc::{in_addr, in6_addr, c_uint};
use std::fmt;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct ip_mreq {
pub imr_multiaddr: in_addr,
pub imr_interface: in_addr,
}
impl fmt::Debug for ip_mreq {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
loop { }
}
}
impl ip_mreq {
pub fn new(group: Ipv4Addr, interface: Option<Ipv4Addr>)
-> ip_mreq {
loop { }
}
}
pub struct ipv6_mreq {
pub ipv6mr_multiaddr: in6_addr,
pub ipv6mr_interface: c_uint,
}
impl ipv6_mreq {
pub fn new(group: Ipv6Addr) -> ipv6_mreq { loop { } }
}
}
pub mod sockopt { }
pub use self::addr::{AddressFamily, SockAddr, InetAddr, UnixAddr,
IpAddr, Ipv4Addr, Ipv6Addr};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use sys::socket::addr::netlink::NetlinkAddr;
pub use libc::{in_addr, in6_addr, sockaddr, sockaddr_in, sockaddr_in6,
sockaddr_un, sa_family_t};
pub use self::multicast::{ip_mreq, ipv6_mreq};
pub use self::consts::*;
#[cfg(any(not(target_os = "linux"), not(target_arch = "x86")))]
pub use libc::sockaddr_storage;
#[cfg(all(target_os = "linux", target_arch = "x86"))]
pub struct sockaddr_storage {
pub ss_family: sa_family_t,
pub __ss_align: u32,
pub __ss_pad2: [u8; 120],
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[repr(i32)]
pub enum SockType {
Stream = consts::SOCK_STREAM,
Datagram = consts::SOCK_DGRAM,
SeqPacket = consts::SOCK_SEQPACKET,
Raw = consts::SOCK_RAW,
Rdm = consts::SOCK_RDM,
}
bitflags! (flags SockFlag : c_int {
const SOCK_NONBLOCK = 0o0004000 , const SOCK_CLOEXEC =
0o2000000 });
/// Copy the in-memory representation of src into the byte slice dst,
/// updating the slice to point to the remainder of dst only. Unsafe
/// because it exposes all bytes in src, which may be UB if some of them
/// are uninitialized (including padding).
unsafe fn copy_bytes<'a, 'b,
T: ?Sized>(src: &T, dst: &'a mut &'b mut [u8]) {
loop { }
}
use self::ffi::{cmsghdr, msghdr, type_of_cmsg_len};
/// A structure used to make room in a cmsghdr passed to recvmsg. The
/// size and alignment match that of a cmsghdr followed by a T, but the
/// fields are not accessible, as the actual types will change on a call
/// to recvmsg.
///
/// To make room for multiple messages, nest the type parameter with
/// tuples, e.g.
/// `let cmsg: CmsgSpace<([RawFd; 3], CmsgSpace<[RawFd; 2]>)> = CmsgSpace::new();`
pub struct CmsgSpace<T> {
_hdr: cmsghdr,
_data: T,
}
impl <T> CmsgSpace<T> {
/// Create a CmsgSpace<T>. The structure is used only for space, so
/// the fields are uninitialized.
pub fn new() -> Self { loop { } }
}
pub struct RecvMsg<'a> {
pub bytes: usize,
cmsg_buffer: &'a [u8],
pub address: Option<SockAddr>,
pub flags: MsgFlags,
}
impl <'a> RecvMsg<'a> {
/// Iterate over the valid control messages pointed to by this
/// msghdr.
pub fn cmsgs(&self) -> CmsgIterator { loop { } }
}
pub struct CmsgIterator<'a>(&'a [u8]);
impl <'a> Iterator for CmsgIterator<'a> {
type
Item
=
ControlMessage<'a>;
fn next(&mut self) -> Option<ControlMessage<'a>> { loop { } }
}
/// A type-safe wrapper around a single control message. More types may
/// be added to this enum; do not exhaustively pattern-match it.
/// [Further reading](http://man7.org/linux/man-pages/man3/cmsg.3.html)
pub enum ControlMessage<'a> {
/// A message of type SCM_RIGHTS, containing an array of file
/// descriptors passed between processes. See the description in the
/// "Ancillary messages" section of the
/// [unix(7) man page](http://man7.org/linux/man-pages/man7/unix.7.html).
ScmRights(&'a [RawFd]),
#[doc(hidden)]
Unknown(UnknownCmsg<'a>),
}
#[doc(hidden)]
pub struct UnknownCmsg<'a>(&'a cmsghdr, &'a [u8]);
fn cmsg_align(len: usize) -> usize { loop { } }
impl <'a> ControlMessage<'a> {
/// The value of CMSG_SPACE on this message.
fn space(&self) -> usize { loop { } }
/// The value of CMSG_LEN on this message.
fn len(&self) -> usize { loop { } }
unsafe fn encode_into<'b>(&self, buf: &mut &'b mut [u8]) {
loop { }
}
}
/// Send data in scatter-gather vectors to a socket, possibly accompanied
/// by ancillary data. Optionally direct the message at the given address,
/// as with sendto.
///
/// Allocates if cmsgs is nonempty.
pub fn sendmsg<'a>(fd: RawFd, iov: &[IoVec<&'a [u8]>],
cmsgs: &[ControlMessage<'a>], flags: MsgFlags,
addr: Option<&'a SockAddr>) -> Result<usize> {
loop { }
}
/// Receive message in scatter-gather vectors from a socket, and
/// optionally receive ancillary data into the provided buffer.
/// If no ancillary data is desired, use () as the type parameter.
pub fn recvmsg<'a,
T>(fd: RawFd, iov: &[IoVec<&mut [u8]>],
cmsg_buffer: Option<&'a mut CmsgSpace<T>>,
flags: MsgFlags) -> Result<RecvMsg<'a>> {
loop { }
}
/// Create an endpoint for communication
///
/// [Further reading](http://man7.org/linux/man-pages/man2/socket.2.html)
pub fn socket(domain: AddressFamily, ty: SockType, flags: SockFlag,
protocol: c_int) -> Result<RawFd> {
loop { }
}
/// Create a pair of connected sockets
///
/// [Further reading](http://man7.org/linux/man-pages/man2/socketpair.2.html)
pub fn socketpair(domain: AddressFamily, ty: SockType,
protocol: c_int, flags: SockFlag)
-> Result<(RawFd, RawFd)> {
loop { }
}
/// Listen for connections on a socket
///
/// [Further reading](http://man7.org/linux/man-pages/man2/listen.2.html)
pub fn listen(sockfd: RawFd, backlog: usize) -> Result<()> {
loop { }
}
/// Bind a name to a socket
///
/// [Further reading](http://man7.org/linux/man-pages/man2/bind.2.html)
pub fn bind(fd: RawFd, addr: &SockAddr) -> Result<()> { loop { } }
/// Accept a connection on a socket
///
/// [Further reading](http://man7.org/linux/man-pages/man2/accept.2.html)
pub fn accept(sockfd: RawFd) -> Result<RawFd> { loop { } }
/// Accept a connection on a socket
///
/// [Further reading](http://man7.org/linux/man-pages/man2/accept.2.html)
pub fn accept4(sockfd: RawFd, flags: SockFlag) -> Result<RawFd> {
loop { }
}
#[inline]
fn accept4_polyfill(sockfd: RawFd, flags: SockFlag) -> Result<RawFd> {
loop { }
}
/// Initiate a connection on a socket
///
/// [Further reading](http://man7.org/linux/man-pages/man2/connect.2.html)
pub fn connect(fd: RawFd, addr: &SockAddr) -> Result<()> { loop { } }
/// Receive data from a connection-oriented socket. Returns the number of
/// bytes read
///
/// [Further reading](http://man7.org/linux/man-pages/man2/recv.2.html)
pub fn recv(sockfd: RawFd, buf: &mut [u8], flags: MsgFlags)
-> Result<usize> {
loop { }
}
/// Receive data from a connectionless or connection-oriented socket. Returns
/// the number of bytes read and the socket address of the sender.
///
/// [Further reading](http://man7.org/linux/man-pages/man2/recvmsg.2.html)
pub fn recvfrom(sockfd: RawFd, buf: &mut [u8])
-> Result<(usize, SockAddr)> {
loop { }
}
pub fn sendto(fd: RawFd, buf: &[u8], addr: &SockAddr, flags: MsgFlags)
-> Result<usize> {
loop { }
}
/// Send data to a connection-oriented socket. Returns the number of bytes read
///
/// [Further reading](http://man7.org/linux/man-pages/man2/send.2.html)
pub fn send(fd: RawFd, buf: &[u8], flags: MsgFlags) -> Result<usize> {
loop { }
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct linger {
pub l_onoff: c_int,
pub l_linger: c_int,
}
#[repr(C)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct ucred {
pid: pid_t,
uid: uid_t,
gid: gid_t,
}
/// The protocol level at which to get / set socket options. Used as an
/// argument to `getsockopt` and `setsockopt`.
///
/// [Further reading](http://man7.org/linux/man-pages/man2/setsockopt.2.html)
#[repr(i32)]
pub enum SockLevel {
Socket = SOL_SOCKET,
Tcp = IPPROTO_TCP,
Ip = IPPROTO_IP,
Ipv6 = IPPROTO_IPV6,
Udp = IPPROTO_UDP,
#[cfg(any(target_os = "linux", target_os = "android"))]
Netlink = SOL_NETLINK,
}
/// Represents a socket option that can be accessed or set. Used as an argument
/// to `getsockopt`
pub trait GetSockOpt: Copy {
type
Val;
#[doc(hidden)]
fn get(&self, fd: RawFd)
-> Result<Self::Val>;
}
/// Represents a socket option that can be accessed or set. Used as an argument
/// to `setsockopt`
pub trait SetSockOpt: Copy {
type
Val;
#[doc(hidden)]
fn set(&self, fd: RawFd, val: &Self::Val)
-> Result<()>;
}
/// Get the current value for the requested socket option
///
/// [Further reading](http://man7.org/linux/man-pages/man2/getsockopt.2.html)
pub fn getsockopt<O: GetSockOpt>(fd: RawFd, opt: O)
-> Result<O::Val> {
loop { }
}
/// Sets the value for the requested socket option
///
/// [Further reading](http://man7.org/linux/man-pages/man2/setsockopt.2.html)
pub fn setsockopt<O: SetSockOpt>(fd: RawFd, opt: O, val: &O::Val)
-> Result<()> {
loop { }
}
/// Get the address of the peer connected to the socket `fd`.
///
/// [Further reading](http://man7.org/linux/man-pages/man2/getpeername.2.html)
pub fn getpeername(fd: RawFd) -> Result<SockAddr> { loop { } }
/// Get the current address to which the socket `fd` is bound.
///
/// [Further reading](http://man7.org/linux/man-pages/man2/getsockname.2.html)
pub fn getsockname(fd: RawFd) -> Result<SockAddr> { loop { } }
pub unsafe fn sockaddr_storage_to_addr(addr: &sockaddr_storage,
len: usize)
-> Result<SockAddr> {
loop { }
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Shutdown {
/// Further receptions will be disallowed.
Read,
/// Further transmissions will be disallowed.
Write,
/// Further receptions and transmissions will be disallowed.
Both,
}
/// Shut down part of a full-duplex connection.
///
/// [Further reading](http://man7.org/linux/man-pages/man2/shutdown.2.html)
pub fn shutdown(df: RawFd, how: Shutdown) -> Result<()> { loop { } }
#[test]
pub fn test_struct_sizes() { loop { } }
}
pub mod stat {
pub use libc::dev_t;
pub use libc::stat as FileStat;
use {Errno, Result, NixPath};
use libc::mode_t;
use std::mem;
use std::os::unix::io::RawFd;
mod ffi {
use libc::{c_char, c_int, mode_t, dev_t};
pub use libc::{stat, fstat, lstat};
extern "C" {
pub fn mknod(pathname: *const c_char, mode: mode_t,
dev: dev_t) -> c_int;
pub fn umask(mask: mode_t) -> mode_t;
}
}
bitflags! (flags SFlag : mode_t {
const S_IFREG = 0o100000 , const S_IFCHR = 0o020000 , const
S_IFBLK = 0o060000 , const S_IFIFO = 0o010000 , const
S_IFSOCK = 0o140000 });
bitflags! (flags Mode : mode_t {
const S_IRWXU = 0o0700 , const S_IRUSR = 0o0400 , const
S_IWUSR = 0o0200 , const S_IXUSR = 0o0100 , const S_IRWXG =
0o0070 , const S_IRGRP = 0o0040 , const S_IWGRP = 0o0020 ,
const S_IXGRP = 0o0010 , const S_IRWXO = 0o0007 , const
S_IROTH = 0o0004 , const S_IWOTH = 0o0002 , const S_IXOTH =
0o0001 , const S_ISUID = 0o4000 , const S_ISGID = 0o2000 ,
const S_ISVTX = 0o1000 , });
pub fn mknod<P: ?Sized +
NixPath>(path: &P, kind: SFlag, perm: Mode, dev: dev_t)
-> Result<()> {
loop { }
}
#[cfg(target_os = "linux")]
const MINORBITS: usize = 20;
#[cfg(target_os = "linux")]
pub fn mkdev(major: u64, minor: u64) -> dev_t { loop { } }
pub fn umask(mode: Mode) -> Mode { loop { } }
pub fn stat<P: ?Sized + NixPath>(path: &P) -> Result<FileStat> {
loop { }
}
pub fn lstat<P: ?Sized + NixPath>(path: &P) -> Result<FileStat> {
loop { }
}
pub fn fstat(fd: RawFd) -> Result<FileStat> { loop { } }
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod syscall {
//! Indirect system call
//!
#[prelude_import]
use std::prelude::v1::*;
use libc::c_int;
pub use self::arch::*;
#[cfg(target_arch = "x86_64")]
mod arch {
#[prelude_import]
use std::prelude::v1::*;
use libc::c_long;
pub type Syscall = c_long;
pub static SYSPIVOTROOT: Syscall = 155;
pub static MEMFD_CREATE: Syscall = 319;
}
extern "C" {
pub fn syscall(num: Syscall, ...) -> c_int;
}
}
#[cfg(not(target_os = "ios"))]
pub mod termios {
use {Errno, Result};
use libc::c_int;
use std::mem;
use std::os::unix::io::RawFd;
pub use self::ffi::consts::*;
pub use self::ffi::consts::SetArg::*;
pub use self::ffi::consts::FlushArg::*;
pub use self::ffi::consts::FlowArg::*;
mod ffi {
pub use self::consts::*;
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "openbsd",
target_os = "netbsd",
target_os = "linux"))]
mod non_android {
use super::consts::*;
use libc::c_int;
#[allow(improper_ctypes)]
extern "C" {
pub fn cfgetispeed(termios: *const Termios) -> speed_t;
pub fn cfgetospeed(termios: *const Termios) -> speed_t;
pub fn cfsetispeed(termios: *mut Termios, speed: speed_t)
-> c_int;
pub fn cfsetospeed(termios: *mut Termios, speed: speed_t)
-> c_int;
pub fn tcgetattr(fd: c_int, termios: *mut Termios)
-> c_int;
pub fn tcsetattr(fd: c_int, optional_actions: c_int,
termios: *const Termios) -> c_int;
pub fn tcdrain(fd: c_int) -> c_int;
pub fn tcflow(fd: c_int, action: c_int) -> c_int;
pub fn tcflush(fd: c_int, action: c_int) -> c_int;
pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int;
}
}
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "openbsd",
target_os = "netbsd",
target_os = "linux"))]
pub use self::non_android::*;
#[inline]
#[cfg(all(target_os = "android", not(target_arch = "mips")))]
mod android {
use libc;
use libc::c_int;
use super::consts::*;
const TCGETS: c_int = 21505;
const TCSBRK: c_int = 21513;
const TCXONC: c_int = 21514;
const TCFLSH: c_int = 21515;
const TCSBRKP: c_int = 21541;
pub unsafe fn cfgetispeed(termios: *const Termios)
-> speed_t {
loop { }
}
pub unsafe fn cfgetospeed(termios: *const Termios)
-> speed_t {
loop { }
}
pub unsafe fn cfsetispeed(termios: *mut Termios,
speed: speed_t) -> c_int {
loop { }
}
pub unsafe fn cfsetospeed(termios: *mut Termios,
speed: speed_t) -> c_int {
loop { }
}
pub unsafe fn tcgetattr(fd: c_int, termios: *mut Termios)
-> c_int {
loop { }
}
pub unsafe fn tcsetattr(fd: c_int, optional_actions: c_int,
termios: *const Termios) -> c_int {
loop { }
}
pub unsafe fn tcdrain(fd: c_int) -> c_int { loop { } }
pub unsafe fn tcflow(fd: c_int, action: c_int) -> c_int {
loop { }
}
pub unsafe fn tcflush(fd: c_int, action: c_int) -> c_int {
loop { }
}
pub unsafe fn tcsendbreak(fd: c_int, duration: c_int)
-> c_int {
loop { }
}
}
#[cfg(target_os = "android")]
pub use self::android::*;
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "openbsd",
target_os = "netbsd"))]
pub mod consts {
#[cfg(not(any(target_os = "dragonfly",
target_os = "netbsd")))]
use libc::{c_int, c_ulong, c_uchar};
#[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
use libc::{c_int, c_uint, c_uchar};
#[cfg(not(any(target_os = "dragonfly",
target_os = "netbsd")))]
pub type tcflag_t = c_ulong;
#[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
pub type tcflag_t = c_uint;
pub type cc_t = c_uchar;
#[cfg(not(any(target_os = "dragonfly",
target_os = "netbsd")))]
pub type speed_t = c_ulong;
#[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
pub type speed_t = c_uint;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Termios {
pub c_iflag: InputFlags,
pub c_oflag: OutputFlags,
pub c_cflag: ControlFlags,
pub c_lflag: LocalFlags,
pub c_cc: [cc_t; NCCS],
pub c_ispeed: speed_t,
pub c_ospeed: speed_t,
}
pub const VEOF: usize = 0;
pub const VEOL: usize = 1;
pub const VEOL2: usize = 2;
pub const VERASE: usize = 3;
pub const VWERASE: usize = 4;
pub const VKILL: usize = 5;
pub const VREPRINT: usize = 6;
pub const VINTR: usize = 8;
pub const VQUIT: usize = 9;
pub const VSUSP: usize = 10;
pub const VDSUSP: usize = 11;
pub const VSTART: usize = 12;
pub const VSTOP: usize = 13;
pub const VLNEXT: usize = 14;
pub const VDISCARD: usize = 15;
pub const VMIN: usize = 16;
pub const VTIME: usize = 17;
pub const VSTATUS: usize = 18;
pub const NCCS: usize = 20;
bitflags! (flags InputFlags : tcflag_t {
const IGNBRK = 0x00000001 , const BRKINT =
0x00000002 , const IGNPAR = 0x00000004 , const
PARMRK = 0x00000008 , const INPCK = 0x00000010 ,
const ISTRIP = 0x00000020 , const INLCR =
0x00000040 , const IGNCR = 0x00000080 , const ICRNL
= 0x00000100 , const IXON = 0x00000200 , const
IXOFF = 0x00000400 , const IXANY = 0x00000800 ,
const IMAXBEL = 0x00002000 , # [
cfg ( not ( target_os = "dragonfly" ) ) ] const
IUTF8 = 0x00004000 , });
bitflags! (flags OutputFlags : tcflag_t {
const OPOST = 0x00000001 , const ONLCR = 0x00000002
, const OXTABS = 0x00000004 , const ONOEOT =
0x00000008 , });
bitflags! (flags ControlFlags : tcflag_t {
const CIGNORE = 0x00000001 , const CSIZE =
0x00000300 , const CS5 = 0x00000000 , const CS6 =
0x00000100 , const CS7 = 0x00000200 , const CS8 =
0x00000300 , const CSTOPB = 0x00000400 , const
CREAD = 0x00000800 , const PARENB = 0x00001000 ,
const PARODD = 0x00002000 , const HUPCL =
0x00004000 , const CLOCAL = 0x00008000 , const
CCTS_OFLOW = 0x00010000 , const CRTSCTS =
0x00030000 , const CRTS_IFLOW = 0x00020000 , const
CDTR_IFLOW = 0x00040000 , const CDSR_OFLOW =
0x00080000 , const CCAR_OFLOW = 0x00100000 , const
MDMBUF = 0x00100000 , });
bitflags! (flags LocalFlags : tcflag_t {
const ECHOKE = 0x00000001 , const ECHOE =
0x00000002 , const ECHOK = 0x00000004 , const ECHO
= 0x00000008 , const ECHONL = 0x00000010 , const
ECHOPRT = 0x00000020 , const ECHOCTL = 0x00000040 ,
const ISIG = 0x00000080 , const ICANON = 0x00000100
, const ALTWERASE = 0x00000200 , const IEXTEN =
0x00000400 , const EXTPROC = 0x00000800 , const
TOSTOP = 0x00400000 , const FLUSHO = 0x00800000 ,
const NOKERNINFO = 0x02000000 , const PENDIN =
0x20000000 , const NOFLSH = 0x80000000 , });
pub const NL0: c_int = 0;
pub const NL1: c_int = 256;
pub const NL2: c_int = 512;
pub const NL3: c_int = 768;
pub const TAB0: c_int = 0;
pub const TAB1: c_int = 1024;
pub const TAB2: c_int = 2048;
pub const TAB3: c_int = 4;
pub const CR0: c_int = 0;
pub const CR1: c_int = 4096;
pub const CR2: c_int = 8192;
pub const CR3: c_int = 12288;
pub const FF0: c_int = 0;
pub const FF1: c_int = 16384;
pub const BS0: c_int = 0;
pub const BS1: c_int = 32768;
pub const VT0: c_int = 0;
pub const VT1: c_int = 65536;
#[derive(Clone, Copy)]
#[repr(C)]
pub enum SetArg {
TCSANOW = 0,
TCSADRAIN = 1,
TCSAFLUSH = 2,
TCSASOFT = 16,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub enum FlushArg {
TCIFLUSH = 1,
TCOFLUSH = 2,
TCIOFLUSH = 3,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub enum FlowArg {
TCOOFF = 1,
TCOON = 2,
TCIOFF = 3,
TCION = 4,
}
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod consts {
use libc::{c_int, c_uint, c_uchar};
pub type tcflag_t = c_uint;
pub type cc_t = c_uchar;
pub type speed_t = c_uint;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct Termios {
pub c_iflag: InputFlags,
pub c_oflag: OutputFlags,
pub c_cflag: ControlFlags,
pub c_lflag: LocalFlags,
pub c_line: cc_t,
pub c_cc: [cc_t; NCCS],
pub c_ispeed: speed_t,
pub c_ospeed: speed_t,
}
pub const VEOF: usize = 4;
pub const VEOL: usize = 11;
pub const VEOL2: usize = 16;
pub const VERASE: usize = 2;
pub const VWERASE: usize = 14;
pub const VKILL: usize = 3;
pub const VREPRINT: usize = 12;
pub const VINTR: usize = 0;
pub const VQUIT: usize = 1;
pub const VSUSP: usize = 10;
pub const VSTART: usize = 8;
pub const VSTOP: usize = 9;
pub const VLNEXT: usize = 15;
pub const VDISCARD: usize = 13;
pub const VMIN: usize = 6;
pub const VTIME: usize = 5;
pub const NCCS: usize = 32;
bitflags! (flags InputFlags : tcflag_t {
const IGNBRK = 0x00000001 , const BRKINT =
0x00000002 , const IGNPAR = 0x00000004 , const
PARMRK = 0x00000008 , const INPCK = 0x00000010 ,
const ISTRIP = 0x00000020 , const INLCR =
0x00000040 , const IGNCR = 0x00000080 , const ICRNL
= 0x00000100 , const IXON = 0x00000400 , const
IXOFF = 0x00001000 , const IXANY = 0x00000800 ,
const IMAXBEL = 0x00002000 , const IUTF8 =
0x00004000 , });
bitflags! (flags OutputFlags : tcflag_t {
const OPOST = 0x00000001 , const ONLCR = 0x00000004
, });
bitflags! (flags ControlFlags : tcflag_t {
const CSIZE = 0x00000030 , const CS5 = 0x00000000 ,
const CS6 = 0x00000010 , const CS7 = 0x00000020 ,
const CS8 = 0x00000030 , const CSTOPB = 0x00000040
, const CREAD = 0x00000080 , const PARENB =
0x00000100 , const PARODD = 0x00000200 , const
HUPCL = 0x00000400 , const CLOCAL = 0x00000800 ,
const CRTSCTS = 0x80000000 , # [
cfg ( target_os = "android" ) ] const CBAUD =
0o0010017 , });
bitflags! (flags LocalFlags : tcflag_t {
const ECHOKE = 0x00000800 , const ECHOE =
0x00000010 , const ECHOK = 0x00000020 , const ECHO
= 0x00000008 , const ECHONL = 0x00000040 , const
ECHOPRT = 0x00000400 , const ECHOCTL = 0x00000200 ,
const ISIG = 0x00000001 , const ICANON = 0x00000002
, const IEXTEN = 0x00008000 , const EXTPROC =
0x00010000 , const TOSTOP = 0x00000100 , const
FLUSHO = 0x00001000 , const PENDIN = 0x00004000 ,
const NOFLSH = 0x00000080 , });
pub const NL0: c_int = 0;
pub const NL1: c_int = 256;
pub const TAB0: c_int = 0;
pub const TAB1: c_int = 2048;
pub const TAB2: c_int = 4096;
pub const TAB3: c_int = 6144;
pub const CR0: c_int = 0;
pub const CR1: c_int = 512;
pub const CR2: c_int = 1024;
pub const CR3: c_int = 1536;
pub const FF0: c_int = 0;
pub const FF1: c_int = 32768;
pub const BS0: c_int = 0;
pub const BS1: c_int = 8192;
pub const VT0: c_int = 0;
pub const VT1: c_int = 16384;
#[derive(Clone, Copy)]
#[repr(C)]
pub enum SetArg { TCSANOW = 0, TCSADRAIN = 1, TCSAFLUSH = 2, }
#[derive(Clone, Copy)]
#[repr(C)]
pub enum FlushArg {
TCIFLUSH = 0,
TCOFLUSH = 1,
TCIOFLUSH = 2,
}
#[derive(Clone, Copy)]
#[repr(C)]
pub enum FlowArg {
TCOOFF = 0,
TCOON = 1,
TCIOFF = 2,
TCION = 3,
}
}
}
pub fn cfgetispeed(termios: &Termios) -> speed_t { loop { } }
pub fn cfgetospeed(termios: &Termios) -> speed_t { loop { } }
pub fn cfsetispeed(termios: &mut Termios, speed: speed_t)
-> Result<()> {
loop { }
}
pub fn cfsetospeed(termios: &mut Termios, speed: speed_t)
-> Result<()> {
loop { }
}
pub fn tcgetattr(fd: RawFd) -> Result<Termios> { loop { } }
pub fn tcsetattr(fd: RawFd, actions: SetArg, termios: &Termios)
-> Result<()> {
loop { }
}
pub fn tcdrain(fd: RawFd) -> Result<()> { loop { } }
pub fn tcflow(fd: RawFd, action: FlowArg) -> Result<()> { loop { } }
pub fn tcflush(fd: RawFd, action: FlushArg) -> Result<()> {
loop { }
}
pub fn tcsendbreak(fd: RawFd, action: c_int) -> Result<()> {
loop { }
}
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod utsname {
use std::mem;
use libc::{c_char};
use std::ffi::CStr;
use std::str::from_utf8_unchecked;
mod ffi {
use libc::c_int;
use super::UtsName;
extern "C" {
pub fn uname(buf: *mut UtsName) -> c_int;
}
}
const UTSNAME_LEN: usize = 65;
#[repr(C)]
#[derive(Copy)]
pub struct UtsName {
sysname: [c_char; UTSNAME_LEN],
nodename: [c_char; UTSNAME_LEN],
release: [c_char; UTSNAME_LEN],
version: [c_char; UTSNAME_LEN],
machine: [c_char; UTSNAME_LEN],
#[allow(dead_code)]
domainname: [c_char; UTSNAME_LEN],
}
impl Clone for UtsName {
fn clone(&self) -> UtsName { loop { } }
}
impl UtsName {
pub fn sysname<'a>(&'a self) -> &'a str { loop { } }
pub fn nodename<'a>(&'a self) -> &'a str { loop { } }
pub fn release<'a>(&'a self) -> &'a str { loop { } }
pub fn version<'a>(&'a self) -> &'a str { loop { } }
pub fn machine<'a>(&'a self) -> &'a str { loop { } }
}
pub fn uname() -> UtsName { loop { } }
#[inline]
fn to_str<'a>(s: *const *const c_char) -> &'a str { loop { } }
#[cfg(test)]
mod test {
use super::uname;
#[test]
pub fn test_uname() { loop { } }
}
}
pub mod wait {
use libc::{pid_t, c_int};
use {Errno, Result};
use sys::signal;
mod ffi {
use libc::{pid_t, c_int};
extern "C" {
pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int)
-> pid_t;
}
}
#[cfg(not(any(target_os = "linux", target_os = "android")))]
bitflags! (flags WaitPidFlag : c_int { const WNOHANG = 0x00000001 ,
});
#[cfg(any(target_os = "linux", target_os = "android"))]
bitflags! (flags WaitPidFlag : c_int {
const WNOHANG = 0x00000001 , const WUNTRACED = 0x00000002 ,
const WEXITED = 0x00000004 , const WCONTINUED = 0x00000008
, const WNOWAIT = 0x01000000 , const __WNOTHREAD =
0x20000000 , const __WALL = 0x40000000 , });
#[cfg(any(target_os = "linux", target_os = "android"))]
const WSTOPPED: WaitPidFlag = WUNTRACED;
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum WaitStatus {
Exited(pid_t, i8),
Signaled(pid_t, signal::SigNum, bool),
Stopped(pid_t, signal::SigNum),
Continued(pid_t),
StillAlive,
}
#[cfg(any(target_os = "linux", target_os = "android"))]
mod status {
use sys::signal;
pub fn exited(status: i32) -> bool { loop { } }
pub fn exit_status(status: i32) -> i8 { loop { } }
pub fn signaled(status: i32) -> bool { loop { } }
pub fn term_signal(status: i32) -> signal::SigNum { loop { } }
pub fn dumped_core(status: i32) -> bool { loop { } }
pub fn stopped(status: i32) -> bool { loop { } }
pub fn stop_signal(status: i32) -> signal::SigNum { loop { } }
pub fn continued(status: i32) -> bool { loop { } }
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod status {
use sys::signal;
const WCOREFLAG: i32 = 128;
const WSTOPPED: i32 = 127;
fn wstatus(status: i32) -> i32 { loop { } }
pub fn exit_status(status: i32) -> i8 { loop { } }
pub fn stop_signal(status: i32) -> signal::SigNum { loop { } }
pub fn continued(status: i32) -> bool { loop { } }
pub fn stopped(status: i32) -> bool { loop { } }
pub fn exited(status: i32) -> bool { loop { } }
pub fn signaled(status: i32) -> bool { loop { } }
pub fn term_signal(status: i32) -> signal::SigNum { loop { } }
pub fn dumped_core(status: i32) -> bool { loop { } }
}
#[cfg(any(target_os = "freebsd",
target_os = "openbsd",
target_os = "dragonfly",
target_os = "netbsd"))]
mod status {
use sys::signal;
const WCOREFLAG: i32 = 128;
const WSTOPPED: i32 = 127;
fn wstatus(status: i32) -> i32 { loop { } }
pub fn stopped(status: i32) -> bool { loop { } }
pub fn stop_signal(status: i32) -> signal::SigNum { loop { } }
pub fn signaled(status: i32) -> bool { loop { } }
pub fn term_signal(status: i32) -> signal::SigNum { loop { } }
pub fn exited(status: i32) -> bool { loop { } }
pub fn exit_status(status: i32) -> i8 { loop { } }
pub fn continued(status: i32) -> bool { loop { } }
pub fn dumped_core(status: i32) -> bool { loop { } }
}
fn decode(pid: pid_t, status: i32) -> WaitStatus { loop { } }
pub fn waitpid(pid: pid_t, options: Option<WaitPidFlag>)
-> Result<WaitStatus> {
loop { }
}
pub fn wait() -> Result<WaitStatus> { loop { } }
}
pub mod mman {
#[prelude_import]
use std::prelude::v1::*;
use {Errno, Error, Result, NixPath};
// use fcntl::OFlag;
use libc::{self, c_void, size_t, off_t, mode_t};
use sys::stat::Mode;
use std::os::unix::io::RawFd;
pub use self::consts::*;
pub struct ProtFlags {
bits: libc::c_int,
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::hash::Hash for ProtFlags {
fn hash<__H: ::std::hash::Hasher>(&self, __arg_0: &mut __H)
-> () {
match *self {
ProtFlags { bits: ref __self_0_0 } => {
::std::hash::Hash::hash(&(*__self_0_0), __arg_0);
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Ord for ProtFlags {
#[inline]
fn cmp(&self, __arg_0: &ProtFlags) -> ::std::cmp::Ordering {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
match ::std::cmp::Ord::cmp(&(*__self_0_0),
&(*__self_1_0)) {
::std::cmp::Ordering::Equal =>
::std::cmp::Ordering::Equal,
__cmp => __cmp,
},
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialOrd for ProtFlags {
#[inline]
fn partial_cmp(&self, __arg_0: &ProtFlags)
-> ::std::option::Option<::std::cmp::Ordering> {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
match ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0),
&(*__self_1_0))
{
::std::option::Option::Some(::std::cmp::Ordering::Equal)
=>
::std::option::Option::Some(::std::cmp::Ordering::Equal),
__cmp => __cmp,
},
},
}
}
#[inline]
fn lt(&self, __arg_0: &ProtFlags) -> bool {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && false,
},
}
}
#[inline]
fn le(&self, __arg_0: &ProtFlags) -> bool {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && true,
},
}
}
#[inline]
fn gt(&self, __arg_0: &ProtFlags) -> bool {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && false,
},
}
}
#[inline]
fn ge(&self, __arg_0: &ProtFlags) -> bool {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && true,
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::clone::Clone for ProtFlags {
#[inline]
fn clone(&self) -> ProtFlags {
match *self {
ProtFlags { bits: ref __self_0_0 } =>
ProtFlags{bits:
::std::clone::Clone::clone(&(*__self_0_0)),},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Eq for ProtFlags {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
match *self {
ProtFlags { bits: ref __self_0_0 } => {
(*__self_0_0).assert_receiver_is_total_eq();
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialEq for ProtFlags {
#[inline]
fn eq(&self, __arg_0: &ProtFlags) -> bool {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
true && (*__self_0_0) == (*__self_1_0),
},
}
}
#[inline]
fn ne(&self, __arg_0: &ProtFlags) -> bool {
match *__arg_0 {
ProtFlags { bits: ref __self_1_0 } =>
match *self {
ProtFlags { bits: ref __self_0_0 } =>
false || (*__self_0_0) != (*__self_1_0),
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::marker::Copy for ProtFlags { }
pub const PROT_NONE: ProtFlags = ProtFlags{bits: libc::PROT_NONE,};
pub const PROT_READ: ProtFlags = ProtFlags{bits: libc::PROT_READ,};
pub const PROT_WRITE: ProtFlags = ProtFlags{bits: libc::PROT_WRITE,};
pub const PROT_EXEC: ProtFlags = ProtFlags{bits: libc::PROT_EXEC,};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub const PROT_GROWSDOWN: ProtFlags =
ProtFlags{bits: libc::PROT_GROWSDOWN,};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub const PROT_GROWSUP: ProtFlags =
ProtFlags{bits: libc::PROT_GROWSUP,};
impl ::bitflags::__core::fmt::Debug for ProtFlags {
fn fmt(&self, f: &mut ::bitflags::__core::fmt::Formatter)
-> ::bitflags::__core::fmt::Result { loop { } }
}
#[allow(dead_code)]
impl ProtFlags {
/// Returns an empty set of flags.
#[inline]
pub fn empty() -> ProtFlags { ProtFlags{bits: 0,} }
/// Returns the set containing all flags.
#[inline]
pub fn all() -> ProtFlags {
#[allow(dead_code)]
mod dummy {
#[prelude_import]
use std::prelude::v1::*;
const PROT_NONE: super::ProtFlags =
super::ProtFlags{bits: 0,};
const PROT_READ: super::ProtFlags =
super::ProtFlags{bits: 0,};
const PROT_WRITE: super::ProtFlags =
super::ProtFlags{bits: 0,};
const PROT_EXEC: super::ProtFlags =
super::ProtFlags{bits: 0,};
const PROT_GROWSDOWN: super::ProtFlags =
super::ProtFlags{bits: 0,};
const PROT_GROWSUP: super::ProtFlags =
super::ProtFlags{bits: 0,};
#[inline]
pub fn all() -> super::ProtFlags {
use super::*;
ProtFlags{bits:
PROT_NONE.bits | PROT_READ.bits |
PROT_WRITE.bits | PROT_EXEC.bits |
PROT_GROWSDOWN.bits |
PROT_GROWSUP.bits,}
}
}
dummy::all()
}
/// Returns the raw value of the flags currently stored.
#[inline]
pub fn bits(&self) -> libc::c_int { self.bits }
/// Convert from underlying bit representation, unless that
/// representation contains bits that do not correspond to a flag.
#[inline]
pub fn from_bits(bits: libc::c_int)
-> ::bitflags::__core::option::Option<ProtFlags> {
if (bits & !ProtFlags::all().bits()) != 0 {
::bitflags::__core::option::Option::None
} else {
::bitflags::__core::option::Option::Some(ProtFlags{bits:
bits,})
}
}
/// Convert from underlying bit representation, dropping any bits
/// that do not correspond to flags.
#[inline]
pub fn from_bits_truncate(bits: libc::c_int) -> ProtFlags {
ProtFlags{bits: bits,} & ProtFlags::all()
}
/// Returns `true` if no flags are currently stored.
#[inline]
pub fn is_empty(&self) -> bool { *self == ProtFlags::empty() }
/// Returns `true` if all flags are currently set.
#[inline]
pub fn is_all(&self) -> bool { *self == ProtFlags::all() }
/// Returns `true` if there are flags common to both `self` and `other`.
#[inline]
pub fn intersects(&self, other: ProtFlags) -> bool {
!(*self & other).is_empty()
}
/// Returns `true` all of the flags in `other` are contained within `self`.
#[inline]
pub fn contains(&self, other: ProtFlags) -> bool {
(*self & other) == other
}
/// Inserts the specified flags in-place.
#[inline]
pub fn insert(&mut self, other: ProtFlags) {
self.bits |= other.bits;
}
/// Removes the specified flags in-place.
#[inline]
pub fn remove(&mut self, other: ProtFlags) {
self.bits &= !other.bits;
}
/// Toggles the specified flags in-place.
#[inline]
pub fn toggle(&mut self, other: ProtFlags) {
self.bits ^= other.bits;
}
}
impl ::bitflags::__core::ops::BitOr for ProtFlags {
type
Output
=
ProtFlags;
/// Returns the union of the two sets of flags.
#[inline]
fn bitor(self, other: ProtFlags) -> ProtFlags {
ProtFlags{bits: self.bits | other.bits,}
}
}
impl ::bitflags::__core::ops::BitXor for ProtFlags {
type
Output
=
ProtFlags;
/// Returns the left flags, but with all the right flags toggled.
#[inline]
fn bitxor(self, other: ProtFlags) -> ProtFlags {
ProtFlags{bits: self.bits ^ other.bits,}
}
}
impl ::bitflags::__core::ops::BitAnd for ProtFlags {
type
Output
=
ProtFlags;
/// Returns the intersection between the two sets of flags.
#[inline]
fn bitand(self, other: ProtFlags) -> ProtFlags {
ProtFlags{bits: self.bits & other.bits,}
}
}
impl ::bitflags::__core::ops::Sub for ProtFlags {
type
Output
=
ProtFlags;
/// Returns the set difference of the two sets of flags.
#[inline]
fn sub(self, other: ProtFlags) -> ProtFlags {
ProtFlags{bits: self.bits & !other.bits,}
}
}
impl ::bitflags::__core::ops::Not for ProtFlags {
type
Output
=
ProtFlags;
/// Returns the complement of this set of flags.
#[inline]
fn not(self) -> ProtFlags {
ProtFlags{bits: !self.bits,} & ProtFlags::all()
}
}
impl ::bitflags::__core::iter::FromIterator<ProtFlags> for ProtFlags {
fn from_iter<T: ::bitflags::__core::iter::IntoIterator<Item =
ProtFlags>>(iterator: T) -> ProtFlags {
let mut result = Self::empty();
for item in iterator { result.insert(item) }
result
}
}
#[cfg(any(target_os = "linux", target_os = "android"))]
mod consts {
#[prelude_import]
use std::prelude::v1::*;
use libc::{self, c_int};
pub struct MapFlags {
bits: c_int,
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::hash::Hash for MapFlags {
fn hash<__H: ::std::hash::Hasher>(&self, __arg_0: &mut __H)
-> () {
match *self {
MapFlags { bits: ref __self_0_0 } => {
::std::hash::Hash::hash(&(*__self_0_0), __arg_0);
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Ord for MapFlags {
#[inline]
fn cmp(&self, __arg_0: &MapFlags) -> ::std::cmp::Ordering {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
match ::std::cmp::Ord::cmp(&(*__self_0_0),
&(*__self_1_0)) {
::std::cmp::Ordering::Equal =>
::std::cmp::Ordering::Equal,
__cmp => __cmp,
},
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialOrd for MapFlags {
#[inline]
fn partial_cmp(&self, __arg_0: &MapFlags)
-> ::std::option::Option<::std::cmp::Ordering> {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
match ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0),
&(*__self_1_0))
{
::std::option::Option::Some(::std::cmp::Ordering::Equal)
=>
::std::option::Option::Some(::std::cmp::Ordering::Equal),
__cmp => __cmp,
},
},
}
}
#[inline]
fn lt(&self, __arg_0: &MapFlags) -> bool {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && false,
},
}
}
#[inline]
fn le(&self, __arg_0: &MapFlags) -> bool {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && true,
},
}
}
#[inline]
fn gt(&self, __arg_0: &MapFlags) -> bool {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && false,
},
}
}
#[inline]
fn ge(&self, __arg_0: &MapFlags) -> bool {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && true,
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::clone::Clone for MapFlags {
#[inline]
fn clone(&self) -> MapFlags {
match *self {
MapFlags { bits: ref __self_0_0 } =>
MapFlags{bits:
::std::clone::Clone::clone(&(*__self_0_0)),},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Eq for MapFlags {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
match *self {
MapFlags { bits: ref __self_0_0 } => {
(*__self_0_0).assert_receiver_is_total_eq();
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialEq for MapFlags {
#[inline]
fn eq(&self, __arg_0: &MapFlags) -> bool {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
true && (*__self_0_0) == (*__self_1_0),
},
}
}
#[inline]
fn ne(&self, __arg_0: &MapFlags) -> bool {
match *__arg_0 {
MapFlags { bits: ref __self_1_0 } =>
match *self {
MapFlags { bits: ref __self_0_0 } =>
false || (*__self_0_0) != (*__self_1_0),
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::marker::Copy for MapFlags { }
pub const MAP_FILE: MapFlags = MapFlags{bits: libc::MAP_FILE,};
pub const MAP_SHARED: MapFlags =
MapFlags{bits: libc::MAP_SHARED,};
pub const MAP_PRIVATE: MapFlags =
MapFlags{bits: libc::MAP_PRIVATE,};
pub const MAP_FIXED: MapFlags = MapFlags{bits: libc::MAP_FIXED,};
pub const MAP_ANON: MapFlags = MapFlags{bits: libc::MAP_ANON,};
pub const MAP_ANONYMOUS: MapFlags =
MapFlags{bits: libc::MAP_ANON,};
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub const MAP_32BIT: MapFlags = MapFlags{bits: libc::MAP_32BIT,};
pub const MAP_GROWSDOWN: MapFlags =
MapFlags{bits: libc::MAP_GROWSDOWN,};
pub const MAP_DENYWRITE: MapFlags =
MapFlags{bits: libc::MAP_DENYWRITE,};
pub const MAP_EXECUTABLE: MapFlags =
MapFlags{bits: libc::MAP_EXECUTABLE,};
pub const MAP_LOCKED: MapFlags =
MapFlags{bits: libc::MAP_LOCKED,};
pub const MAP_NORESERVE: MapFlags =
MapFlags{bits: libc::MAP_NORESERVE,};
pub const MAP_POPULATE: MapFlags =
MapFlags{bits: libc::MAP_POPULATE,};
pub const MAP_NONBLOCK: MapFlags =
MapFlags{bits: libc::MAP_NONBLOCK,};
pub const MAP_STACK: MapFlags = MapFlags{bits: libc::MAP_STACK,};
pub const MAP_HUGETLB: MapFlags =
MapFlags{bits: libc::MAP_HUGETLB,};
impl ::bitflags::__core::fmt::Debug for MapFlags {
fn fmt(&self, f: &mut ::bitflags::__core::fmt::Formatter)
-> ::bitflags::__core::fmt::Result {
#[allow(dead_code)]
#[allow(unused_assignments)]
mod dummy {
#[prelude_import]
use std::prelude::v1::*;
const MAP_FILE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_SHARED: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_PRIVATE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_FIXED: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_ANON: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_ANONYMOUS: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_32BIT: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_GROWSDOWN: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_DENYWRITE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_EXECUTABLE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_LOCKED: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_NORESERVE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_POPULATE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_NONBLOCK: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_STACK: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_HUGETLB: super::MapFlags =
super::MapFlags{bits: 0,};
#[inline]
pub fn fmt(self_: &super::MapFlags,
f: &mut ::bitflags::__core::fmt::Formatter)
-> ::bitflags::__core::fmt::Result { loop { } }
}
dummy::fmt(self, f)
}
}
#[allow(dead_code)]
impl MapFlags {
/// Returns an empty set of flags.
#[inline]
pub fn empty() -> MapFlags { MapFlags{bits: 0,} }
/// Returns the set containing all flags.
#[inline]
pub fn all() -> MapFlags {
#[allow(dead_code)]
mod dummy {
#[prelude_import]
use std::prelude::v1::*;
const MAP_FILE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_SHARED: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_PRIVATE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_FIXED: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_ANON: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_ANONYMOUS: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_32BIT: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_GROWSDOWN: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_DENYWRITE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_EXECUTABLE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_LOCKED: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_NORESERVE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_POPULATE: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_NONBLOCK: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_STACK: super::MapFlags =
super::MapFlags{bits: 0,};
const MAP_HUGETLB: super::MapFlags =
super::MapFlags{bits: 0,};
#[inline]
pub fn all() -> super::MapFlags {
use super::*;
MapFlags{bits:
MAP_FILE.bits | MAP_SHARED.bits |
MAP_PRIVATE.bits | MAP_FIXED.bits
| MAP_ANON.bits |
MAP_ANONYMOUS.bits |
MAP_32BIT.bits |
MAP_GROWSDOWN.bits |
MAP_DENYWRITE.bits |
MAP_EXECUTABLE.bits |
MAP_LOCKED.bits |
MAP_NORESERVE.bits |
MAP_POPULATE.bits |
MAP_NONBLOCK.bits |
MAP_STACK.bits |
MAP_HUGETLB.bits,}
}
}
dummy::all()
}
/// Returns the raw value of the flags currently stored.
#[inline]
pub fn bits(&self) -> c_int { self.bits }
/// Convert from underlying bit representation, unless that
/// representation contains bits that do not correspond to a flag.
#[inline]
pub fn from_bits(bits: c_int)
-> ::bitflags::__core::option::Option<MapFlags> {
if (bits & !MapFlags::all().bits()) != 0 {
::bitflags::__core::option::Option::None
} else {
::bitflags::__core::option::Option::Some(MapFlags{bits:
bits,})
}
}
/// Convert from underlying bit representation, dropping any bits
/// that do not correspond to flags.
#[inline]
pub fn from_bits_truncate(bits: c_int) -> MapFlags {
MapFlags{bits: bits,} & MapFlags::all()
}
/// Returns `true` if no flags are currently stored.
#[inline]
pub fn is_empty(&self) -> bool { *self == MapFlags::empty() }
/// Returns `true` if all flags are currently set.
#[inline]
pub fn is_all(&self) -> bool { *self == MapFlags::all() }
/// Returns `true` if there are flags common to both `self` and `other`.
#[inline]
pub fn intersects(&self, other: MapFlags) -> bool {
!(*self & other).is_empty()
}
/// Returns `true` all of the flags in `other` are contained within `self`.
#[inline]
pub fn contains(&self, other: MapFlags) -> bool {
(*self & other) == other
}
/// Inserts the specified flags in-place.
#[inline]
pub fn insert(&mut self, other: MapFlags) {
self.bits |= other.bits;
}
/// Removes the specified flags in-place.
#[inline]
pub fn remove(&mut self, other: MapFlags) {
self.bits &= !other.bits;
}
/// Toggles the specified flags in-place.
#[inline]
pub fn toggle(&mut self, other: MapFlags) {
self.bits ^= other.bits;
}
}
impl ::bitflags::__core::ops::BitOr for MapFlags {
type
Output
=
MapFlags;
/// Returns the union of the two sets of flags.
#[inline]
fn bitor(self, other: MapFlags) -> MapFlags {
MapFlags{bits: self.bits | other.bits,}
}
}
impl ::bitflags::__core::ops::BitXor for MapFlags {
type
Output
=
MapFlags;
/// Returns the left flags, but with all the right flags toggled.
#[inline]
fn bitxor(self, other: MapFlags) -> MapFlags {
MapFlags{bits: self.bits ^ other.bits,}
}
}
impl ::bitflags::__core::ops::BitAnd for MapFlags {
type
Output
=
MapFlags;
/// Returns the intersection between the two sets of flags.
#[inline]
fn bitand(self, other: MapFlags) -> MapFlags {
MapFlags{bits: self.bits & other.bits,}
}
}
impl ::bitflags::__core::ops::Sub for MapFlags {
type
Output
=
MapFlags;
/// Returns the set difference of the two sets of flags.
#[inline]
fn sub(self, other: MapFlags) -> MapFlags {
MapFlags{bits: self.bits & !other.bits,}
}
}
impl ::bitflags::__core::ops::Not for MapFlags {
type
Output
=
MapFlags;
/// Returns the complement of this set of flags.
#[inline]
fn not(self) -> MapFlags {
MapFlags{bits: !self.bits,} & MapFlags::all()
}
}
impl ::bitflags::__core::iter::FromIterator<MapFlags> for MapFlags
{
fn from_iter<T: ::bitflags::__core::iter::IntoIterator<Item =
MapFlags>>(iterator: T) -> MapFlags {
let mut result = Self::empty();
for item in iterator { result.insert(item) }
result
}
}
pub type MmapAdvise = c_int;
pub const MADV_NORMAL: MmapAdvise = 0;
pub const MADV_RANDOM: MmapAdvise = 1;
pub const MADV_SEQUENTIAL: MmapAdvise = 2;
pub const MADV_WILLNEED: MmapAdvise = 3;
pub const MADV_DONTNEED: MmapAdvise = 4;
pub const MADV_REMOVE: MmapAdvise = 9;
pub const MADV_DONTFORK: MmapAdvise = 10;
pub const MADV_DOFORK: MmapAdvise = 11;
pub const MADV_MERGEABLE: MmapAdvise = 12;
pub const MADV_UNMERGEABLE: MmapAdvise = 13;
pub const MADV_HUGEPAGE: MmapAdvise = 14;
pub const MADV_NOHUGEPAGE: MmapAdvise = 15;
pub const MADV_DONTDUMP: MmapAdvise = 16;
pub const MADV_DODUMP: MmapAdvise = 17;
pub const MADV_HWPOISON: MmapAdvise = 100;
pub struct MsFlags {
bits: c_int,
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::hash::Hash for MsFlags {
fn hash<__H: ::std::hash::Hasher>(&self, __arg_0: &mut __H)
-> () {
match *self {
MsFlags { bits: ref __self_0_0 } => {
::std::hash::Hash::hash(&(*__self_0_0), __arg_0);
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Ord for MsFlags {
#[inline]
fn cmp(&self, __arg_0: &MsFlags) -> ::std::cmp::Ordering {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
match ::std::cmp::Ord::cmp(&(*__self_0_0),
&(*__self_1_0)) {
::std::cmp::Ordering::Equal =>
::std::cmp::Ordering::Equal,
__cmp => __cmp,
},
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialOrd for MsFlags {
#[inline]
fn partial_cmp(&self, __arg_0: &MsFlags)
-> ::std::option::Option<::std::cmp::Ordering> {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
match ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0),
&(*__self_1_0))
{
::std::option::Option::Some(::std::cmp::Ordering::Equal)
=>
::std::option::Option::Some(::std::cmp::Ordering::Equal),
__cmp => __cmp,
},
},
}
}
#[inline]
fn lt(&self, __arg_0: &MsFlags) -> bool {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && false,
},
}
}
#[inline]
fn le(&self, __arg_0: &MsFlags) -> bool {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
(*__self_0_0) < (*__self_1_0) ||
!((*__self_1_0) < (*__self_0_0)) && true,
},
}
}
#[inline]
fn gt(&self, __arg_0: &MsFlags) -> bool {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && false,
},
}
}
#[inline]
fn ge(&self, __arg_0: &MsFlags) -> bool {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
(*__self_0_0) > (*__self_1_0) ||
!((*__self_1_0) > (*__self_0_0)) && true,
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::clone::Clone for MsFlags {
#[inline]
fn clone(&self) -> MsFlags {
match *self {
MsFlags { bits: ref __self_0_0 } =>
MsFlags{bits:
::std::clone::Clone::clone(&(*__self_0_0)),},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::Eq for MsFlags {
#[inline]
#[doc(hidden)]
fn assert_receiver_is_total_eq(&self) -> () {
match *self {
MsFlags { bits: ref __self_0_0 } => {
(*__self_0_0).assert_receiver_is_total_eq();
}
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::cmp::PartialEq for MsFlags {
#[inline]
fn eq(&self, __arg_0: &MsFlags) -> bool {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
true && (*__self_0_0) == (*__self_1_0),
},
}
}
#[inline]
fn ne(&self, __arg_0: &MsFlags) -> bool {
match *__arg_0 {
MsFlags { bits: ref __self_1_0 } =>
match *self {
MsFlags { bits: ref __self_0_0 } =>
false || (*__self_0_0) != (*__self_1_0),
},
}
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::std::marker::Copy for MsFlags { }
pub const MS_ASYNC: MsFlags = MsFlags{bits: libc::MS_ASYNC,};
pub const MS_INVALIDATE: MsFlags =
MsFlags{bits: libc::MS_INVALIDATE,};
pub const MS_SYNC: MsFlags = MsFlags{bits: libc::MS_SYNC,};
impl ::bitflags::__core::fmt::Debug for MsFlags {
fn fmt(&self, f: &mut ::bitflags::__core::fmt::Formatter)
-> ::bitflags::__core::fmt::Result { loop { } }
}
impl ::bitflags::__core::ops::BitOr for MsFlags {
type
Output
=
MsFlags;
/// Returns the union of the two sets of flags.
#[inline]
fn bitor(self, other: MsFlags) -> MsFlags {
MsFlags{bits: self.bits | other.bits,}
}
}
impl ::bitflags::__core::ops::BitXor for MsFlags {
type
Output
=
MsFlags;
/// Returns the left flags, but with all the right flags toggled.
#[inline]
fn bitxor(self, other: MsFlags) -> MsFlags {
MsFlags{bits: self.bits ^ other.bits,}
}
}
impl ::bitflags::__core::ops::BitAnd for MsFlags {
type
Output
=
MsFlags;
/// Returns the intersection between the two sets of flags.
#[inline]
fn bitand(self, other: MsFlags) -> MsFlags {
MsFlags{bits: self.bits & other.bits,}
}
}
impl ::bitflags::__core::ops::Sub for MsFlags {
type
Output
=
MsFlags;
/// Returns the set difference of the two sets of flags.
#[inline]
fn sub(self, other: MsFlags) -> MsFlags {
MsFlags{bits: self.bits & !other.bits,}
}
}
impl ::bitflags::__core::ops::Not for MsFlags {
type
Output
=
MsFlags;
/// Returns the complement of this set of flags.
#[inline]
fn not(self) -> MsFlags { loop { } }
}
impl ::bitflags::__core::iter::FromIterator<MsFlags> for MsFlags {
fn from_iter<T: ::bitflags::__core::iter::IntoIterator<Item =
MsFlags>>(iterator: T) -> MsFlags { loop { } }
}
pub const MAP_FAILED: isize = -1;
}
mod ffi {
#[prelude_import]
use std::prelude::v1::*;
use libc::{c_void, size_t, c_int, c_char, mode_t};
pub use libc::{mmap, munmap};
#[allow(improper_ctypes)]
extern "C" {
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;
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 madvise(addr: *const c_void, len: size_t,
advice: c_int) -> c_int;
pub fn msync(addr: *const c_void, len: size_t, flags: c_int)
-> c_int;
}
}
pub unsafe fn mlock(addr: *const c_void, length: size_t)
-> Result<()> {
Errno::result(ffi::mlock(addr, length)).map(drop)
}
pub fn munlock(addr: *const c_void, length: size_t) -> Result<()> {
Errno::result(unsafe { ffi::munlock(addr, length) }).map(drop)
}
/// Calls to mmap are inherently unsafe, so they must be made in an unsafe block. Typically
/// a higher-level abstraction will hide the unsafe interactions with the mmap'd region.
pub fn mmap(addr: *mut c_void, length: size_t, prot: ProtFlags,
flags: MapFlags, fd: RawFd, offset: off_t)
-> Result<*mut c_void> {
let ret =
unsafe {
ffi::mmap(addr, length, prot.bits(), flags.bits(), fd,
offset)
};
if (ret as isize) == MAP_FAILED {
Err(Error::Sys(Errno::last()))
} else { Ok(ret) }
}
pub fn munmap(addr: *mut c_void, len: size_t) -> Result<()> {
Errno::result(unsafe { ffi::munmap(addr, len) }).map(drop)
}
pub fn madvise(addr: *const c_void, length: size_t,
advise: MmapAdvise) -> Result<()> {
Errno::result(unsafe {
ffi::madvise(addr, length, advise)
}).map(drop)
}
pub fn msync(addr: *const c_void, length: size_t, flags: MsFlags)
-> Result<()> { loop { } }
pub fn shm_unlink<P: ?Sized + NixPath>(name: &P) -> Result<()> { loop { } }
}
pub mod uio {
#![allow(improper_ctypes)]
#[prelude_import]
use std::prelude::v1::*;
use {Errno, Result};
use libc::{self, c_int, c_void, size_t, off_t};
use std::marker::PhantomData;
use std::os::unix::io::RawFd;
pub fn writev(fd: RawFd, iov: &[IoVec<&[u8]>]) -> Result<usize> {
let res =
unsafe {
libc::writev(fd, iov.as_ptr() as *const libc::iovec,
iov.len() as c_int)
};
Errno::result(res).map(|r| r as usize)
}
pub fn readv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>])
-> Result<usize> {
let res =
unsafe {
libc::readv(fd, iov.as_ptr() as *const libc::iovec,
iov.len() as c_int)
};
Errno::result(res).map(|r| r as usize)
}
pub fn pwrite(fd: RawFd, buf: &[u8], offset: off_t) -> Result<usize> {
let res =
unsafe {
libc::pwrite(fd, buf.as_ptr() as *const c_void,
buf.len() as size_t, offset)
};
Errno::result(res).map(|r| r as usize)
}
pub fn pread(fd: RawFd, buf: &mut [u8], offset: off_t)
-> Result<usize> {
let res =
unsafe {
libc::pread(fd, buf.as_mut_ptr() as *mut c_void,
buf.len() as size_t, offset)
};
Errno::result(res).map(|r| r as usize)
}
#[repr(C)]
pub struct IoVec<T>(libc::iovec, PhantomData<T>);
impl <T> IoVec<T> {
#[inline]
pub fn as_slice<'a>(&'a self) -> &'a [u8] {
use std::slice;
unsafe {
slice::from_raw_parts(self.0.iov_base as *const u8,
self.0.iov_len as usize)
}
}
}
impl <'a> IoVec<&'a [u8]> {
pub fn from_slice(buf: &'a [u8]) -> IoVec<&'a [u8]> {
IoVec(libc::iovec{iov_base: buf.as_ptr() as *mut c_void,
iov_len: buf.len() as size_t,}, PhantomData)
}
}
impl <'a> IoVec<&'a mut [u8]> {
pub fn from_mut_slice(buf: &'a mut [u8]) -> IoVec<&'a mut [u8]> {
IoVec(libc::iovec{iov_base: buf.as_ptr() as *mut c_void,
iov_len: buf.len() as size_t,}, PhantomData)
}
}
}
pub mod time { }
#[cfg(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")))]
pub mod ptrace { }
pub mod select { }
#[cfg(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")))]
pub mod quota { }
#[cfg(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")))]
pub mod statfs { }
#[cfg(all(any(target_os = "linux", target_os = "macos"),
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm")))]
pub mod statvfs {
//! FFI for statvfs functions
//!
//! See the `vfs::Statvfs` struct for some rusty wrappers
#[prelude_import]
use std::prelude::v1::*;
use {Errno, Result, NixPath};
use std::os::unix::io::AsRawFd;
}
}
#[cfg(all(target_os = "linux",
any(target_arch = "x86", target_arch = "x86_64")))]
pub mod ucontext {
use libc;
use {Errno, Result};
use std::mem;
#[derive(Clone, Copy)]
pub struct UContext {
context: libc::ucontext_t,
}
impl UContext {
pub fn get() -> Result<UContext> { loop { } }
pub fn set(&self) -> Result<()> { loop { } }
}
}
pub mod unistd {
//! Standard symbolic constants and types
//!
#[prelude_import]
use std::prelude::v1::*;
use {Errno, Error, Result, NixPath};
// use fcntl::{fcntl, OFlag, O_NONBLOCK, O_CLOEXEC, FD_CLOEXEC};
// use fcntl::FcntlArg::{F_SETFD, F_SETFL};
use libc::{self, c_char, c_void, c_int, size_t, pid_t, off_t, uid_t,
gid_t};
use std::mem;
use std::ffi::CString;
use std::os::unix::io::RawFd;
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use self::linux::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
#[inline]
pub fn gettid() -> pid_t {
unsafe { libc::syscall(libc::SYS_gettid) as pid_t }
// unsafe { ::sys::syscall::syscall(libc::SYS_gettid) as pid_t }
}
#[cfg(any(target_os = "linux", target_os = "android"))]
mod linux {
}
}
use libc::c_char;
use std::{ptr, result};
use std::ffi::{CStr, OsStr};
use std::path::{Path, PathBuf};
use std::os::unix::ffi::OsStrExt;
use std::io;
use std::fmt;
use std::error;
use libc::PATH_MAX;
pub type Result<T> = result::Result<T, Error>;
pub enum Error { Sys(errno::Errno), InvalidPath, }
pub trait NixPath {
fn len(&self)
-> usize;
fn with_nix_path<T, F>(&self, f: F)
-> Result<T>
where
F: FnOnce(&CStr)
->
T;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment