Merge branch 'master' into master

This commit is contained in:
Kelvin Ly 2017-05-04 22:08:48 -04:00 committed by GitHub
commit 96a830648d
37 changed files with 470 additions and 120 deletions

View File

@ -56,6 +56,10 @@ matrix:
- os: linux
env: TARGET=i686-linux-android
rust: stable
# as of 2017/05/03 x86_64-linux-android are not on stable
- os: linux
env: TARGET=x86_64-linux-android
rust: beta
- os: linux
env: TARGET=x86_64-unknown-linux-musl
rust: stable

4
Cargo.lock generated
View File

@ -3,7 +3,7 @@ name = "libc-test"
version = "0.1.0"
dependencies = [
"ctest 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.21",
"libc 0.2.22",
]
[[package]]
@ -48,7 +48,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.21"
version = "0.2.22"
[[package]]
name = "log"

View File

@ -1,7 +1,7 @@
[package]
name = "libc"
version = "0.2.21"
version = "0.2.22"
authors = ["The Rust Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"

View File

@ -98,6 +98,25 @@ We have two automated tests running on [Travis](https://travis-ci.org/rust-lang/
2. Style checker
- `rustc ci/style.rs && ./style src`
### Releasing your change to crates.io
Now that you've done the amazing job of landing your new API or your new
platform in this crate, the next step is to get that sweet, sweet usage from
crates.io! The only next step is to bump the version of libc and then publish
it. If you'd like to get a release out ASAP you can follow these steps:
1. Update the version number in `Cargo.toml`, you'll just be bumping the patch
version number.
2. Run `cargo update` to regenerate the lockfile to encode your version bump in
the lock file. You may pull in some other updated dependencies, that's ok.
3. Send a PR to this repository. It should [look like this][example], but it'd
also be nice to fill out the description with a small rationale for the
release (any rationale is ok though!)
4. Once merged the release will be tagged and published by one of the libc crate
maintainers.
[example]: https://github.com/rust-lang/libc/pull/583
## Platforms and Documentation
The following platforms are currently tested and have documentation available:

View File

@ -7,7 +7,7 @@ environment:
- TARGET: x86_64-pc-windows-msvc
- TARGET: i686-pc-windows-msvc
install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init.exe -y --default-host %TARGET%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin

View File

@ -37,6 +37,10 @@ case "$1" in
abi=x86
;;
x86_64)
abi=x86_64
;;
*)
echo "invalid arch: $1"
exit 1

52
ci/android-sysimage.sh Normal file
View File

@ -0,0 +1,52 @@
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
set -ex
URL=https://dl.google.com/android/repository/sys-img/android
main() {
local arch=$1
local name=$2
local dest=/system
local td=$(mktemp -d)
apt-get install --no-install-recommends e2tools
pushd $td
curl -O $URL/$name
unzip -q $name
local system=$(find . -name system.img)
mkdir -p $dest/{bin,lib,lib64}
# Extract android linker and libraries to /system
# This allows android executables to be run directly (or with qemu)
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
e2cp -p $system:/bin/linker64 $dest/bin/
e2cp -p $system:/lib64/libdl.so $dest/lib64/
e2cp -p $system:/lib64/libc.so $dest/lib64/
e2cp -p $system:/lib64/libm.so $dest/lib64/
else
e2cp -p $system:/bin/linker $dest/bin/
e2cp -p $system:/lib/libdl.so $dest/lib/
e2cp -p $system:/lib/libc.so $dest/lib/
e2cp -p $system:/lib/libm.so $dest/lib/
fi
# clean up
apt-get purge --auto-remove -y e2tools
popd
rm -rf $td
}
main "${@}"

View File

@ -0,0 +1,26 @@
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gcc \
libc-dev \
python \
unzip
WORKDIR /android/
ENV ANDROID_ARCH=x86_64
COPY android-install-ndk.sh /android/
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
# We do not run x86_64-linux-android tests on an android emulator.
# See ci/android-sysimage.sh for informations about how tests are run.
COPY android-sysimage.sh /android/
RUN bash /android/android-sysimage.sh x86_64 x86_64-21_r04.zip
ENV PATH=$PATH:/rust/bin:/android/ndk-$ANDROID_ARCH/bin \
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \
CC_x86_64_linux_android=x86_64-linux-android-gcc \
CXX_x86_64_linux_android=x86_64-linux-android-g++ \
HOME=/tmp

View File

@ -8,10 +8,14 @@ run() {
# use -f so we can use ci/ as build context
docker build -t libc -f ci/docker/$1/Dockerfile ci/
mkdir -p target
if [ -w /dev/kvm ]; then
kvm="--volume /dev/kvm:/dev/kvm"
fi
docker run \
--user `id -u`:`id -g` \
--rm \
--volume $HOME/.cargo:/cargo \
$kvm \
--env CARGO_HOME=/cargo \
--volume `rustc --print sysroot`:/rust:ro \
--volume `pwd`:/checkout:ro \
@ -19,8 +23,6 @@ run() {
--env CARGO_TARGET_DIR=/checkout/target \
--workdir /checkout \
--privileged \
--interactive \
--tty \
libc \
ci/run.sh $1
}

View File

@ -105,13 +105,20 @@ case "$TARGET" in
esac
case "$TARGET" in
# Android emulator for x86_64 does not work on travis (missing hardware
# acceleration). Tests are run on case *). See ci/android-sysimage.sh for
# informations about how tests are run.
arm-linux-androideabi | aarch64-linux-android | i686-linux-android)
# set SHELL so android can detect a 64bits system, see
# http://stackoverflow.com/a/41789144
# https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791
export SHELL=/bin/dash
arch=$(echo $TARGET | cut -d- -f1)
emulator @$arch -no-window -no-accel &
accel="-no-accel"
if emulator -accel-check; then
accel=""
fi
emulator @$arch -no-window $accel &
adb wait-for-device
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test
adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out

View File

@ -78,6 +78,7 @@ fn main() {
cfg.header("netinet/in.h");
cfg.header("netinet/ip.h");
cfg.header("netinet/tcp.h");
cfg.header("resolv.h");
cfg.header("pthread.h");
cfg.header("dlfcn.h");
cfg.header("signal.h");
@ -107,8 +108,8 @@ fn main() {
}
if android {
if !aarch64 {
// time64_t is not define for aarch64
if !aarch64 && !x86_64 {
// time64_t is not define for aarch64 and x86_64
// If included it will generate the error 'Your time_t is already 64-bit'
cfg.header("time64.h");
}
@ -419,6 +420,11 @@ fn main() {
"prlimit" | "prlimit64" | // non-int in 2nd arg
"strerror_r" if linux => true, // actually xpg-something-or-other
// int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that
// they match the interface defined by Linux verbatim, but they conflict with other
// send*/recv* syscalls
"sendmmsg" | "recvmmsg" if musl => true,
// typed 2nd arg on linux and android
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
@ -483,6 +489,7 @@ fn main() {
// it's in a header file?
"endpwent" if android => true,
// These are either unimplemented or optionally built into uClibc
// or "sysinfo", where it's defined but the structs in linux/sysinfo.h and sys/sysinfo.h
// clash so it can't be tested
@ -492,6 +499,16 @@ fn main() {
"backtrace" |
"sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" |
"nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true,
// Apparently res_init exists on Android, but isn't defined in a header:
// https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html
"res_init" if android => true,
// On macOS and iOS, res_init is available, but requires linking with libresolv:
// http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
// See discussion for skipping here:
// https://github.com/rust-lang/libc/pull/585#discussion_r114561460
"res_init" if apple => true,
_ => false,
}

View File

@ -505,6 +505,9 @@ pub const P_PID: idtype_t = 0;
pub const P_PGID: idtype_t = 2;
pub const P_ALL: idtype_t = 7;
pub const B460800: ::speed_t = 460800;
pub const B921600: ::speed_t = 921600;
extern {
pub fn __error() -> *mut ::c_int;

View File

@ -869,13 +869,13 @@ pub const B57600: speed_t = 57600;
pub const B76800: speed_t = 76800;
pub const B115200: speed_t = 115200;
pub const B230400: speed_t = 230400;
pub const B460800: speed_t = 460800;
pub const B921600: speed_t = 921600;
pub const EXTA: speed_t = 19200;
pub const EXTB: speed_t = 38400;
pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t;
pub const CRTSCTS: ::tcflag_t = 0x00030000;
f! {
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0x13

View File

@ -275,7 +275,9 @@ pub const WNOHANG: ::c_int = 0x00000001;
pub const WUNTRACED: ::c_int = 0x00000002;
pub const RTLD_NOW: ::c_int = 0x2;
pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void;
pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void;
pub const LOG_CRON: ::c_int = 9 << 3;
pub const LOG_AUTHPRIV: ::c_int = 10 << 3;

View File

@ -641,6 +641,9 @@ pub const P_ALL: idtype_t = 0;
pub const P_PID: idtype_t = 1;
pub const P_PGID: idtype_t = 4;
pub const B460800: ::speed_t = 460800;
pub const B921600: ::speed_t = 921600;
extern {
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;

View File

@ -576,6 +576,9 @@ extern {
link_name = "pthread_join$UNIX2003")]
pub fn pthread_join(native: ::pthread_t,
value: *mut *mut ::c_void) -> ::c_int;
pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
parent: Option<unsafe extern fn()>,
child: Option<unsafe extern fn()>) -> ::c_int;
pub fn pthread_exit(value: *mut ::c_void);
pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
@ -691,6 +694,14 @@ extern {
res: *mut *mut addrinfo) -> ::c_int;
pub fn freeaddrinfo(res: *mut addrinfo);
pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
#[cfg_attr(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "freebsd",
target_os = "dragonfly"),
link_name = "__res_init")]
#[cfg_attr(any(target_os = "macos", target_os = "ios"),
link_name = "res_9_init")]
pub fn res_init() -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
@ -777,6 +788,12 @@ extern {
#[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")]
pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")]
pub fn sigprocmask(how: ::c_int,
set: *const sigset_t,
oldset: *mut sigset_t)
-> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
pub fn timegm(tm: *mut ::tm) -> time_t;

View File

@ -1,3 +1,6 @@
// The following definitions are correct for arm and i686,
// but may be wrong for mips
pub type c_long = i32;
pub type c_ulong = u32;
pub type mode_t = u16;

View File

@ -0,0 +1,56 @@
pub type c_char = u8;
pub type wchar_t = u32;
s! {
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::c_uint,
pub st_nlink: ::c_uint,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
__pad1: ::c_ulong,
pub st_size: ::off64_t,
pub st_blksize: ::c_int,
__pad2: ::c_int,
pub st_blocks: ::c_long,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_ulong,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_ulong,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_ulong,
__unused4: ::c_uint,
__unused5: ::c_uint,
}
pub struct stat64 {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::c_uint,
pub st_nlink: ::c_uint,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
__pad1: ::c_ulong,
pub st_size: ::off64_t,
pub st_blksize: ::c_int,
__pad2: ::c_int,
pub st_blocks: ::c_long,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_ulong,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_ulong,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_ulong,
__unused4: ::c_uint,
__unused5: ::c_uint,
}
}
pub const O_DIRECT: ::c_int = 0x10000;
pub const O_DIRECTORY: ::c_int = 0x4000;
pub const O_NOFOLLOW: ::c_int = 0x8000;
pub const SYS_gettid: ::c_long = 178;

View File

@ -1,12 +1,11 @@
// The following definitions are correct for aarch64 and may be wrong for x86_64
// The following definitions are correct for aarch64 and x86_64,
// but may be wrong for mips64
pub type c_char = u8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type mode_t = u32;
pub type off64_t = i64;
pub type socklen_t = u32;
pub type wchar_t = u32;
s! {
pub struct sigset_t {
@ -17,7 +16,7 @@ s! {
pub sa_flags: ::c_uint,
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
_restorer: *mut ::c_void,
pub sa_restorer: ::dox::Option<extern fn()>,
}
pub struct rlimit64 {
@ -25,52 +24,6 @@ s! {
pub rlim_max: ::c_ulonglong,
}
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::c_uint,
pub st_nlink: ::c_uint,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
__pad1: ::c_ulong,
pub st_size: ::off64_t,
pub st_blksize: ::c_int,
__pad2: ::c_int,
pub st_blocks: ::c_long,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_ulong,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_ulong,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_ulong,
__unused4: ::c_uint,
__unused5: ::c_uint,
}
pub struct stat64 {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::c_uint,
pub st_nlink: ::c_uint,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
__pad1: ::c_ulong,
pub st_size: ::off64_t,
pub st_blksize: ::c_int,
__pad2: ::c_int,
pub st_blocks: ::c_long,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_ulong,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_ulong,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_ulong,
__unused4: ::c_uint,
__unused5: ::c_uint,
}
pub struct pthread_attr_t {
pub flags: ::uint32_t,
pub stack_base: *mut ::c_void,
@ -143,15 +96,10 @@ s! {
}
}
pub const O_DIRECT: ::c_int = 0x10000;
pub const O_DIRECTORY: ::c_int = 0x4000;
pub const O_NOFOLLOW: ::c_int = 0x8000;
pub const RTLD_GLOBAL: ::c_int = 0x00100;
pub const RTLD_NOW: ::c_int = 2;
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
pub const SYS_gettid: ::c_long = 178;
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
value: 0,
__reserved: [0; 36],
@ -200,3 +148,15 @@ extern {
// the return type should be ::ssize_t, but it is c_int!
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::c_int;
}
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
} else if #[cfg(target_arch = "aarch64")] {
mod aarch64;
pub use self::aarch64::*;
} else {
// Unknown target_arch
}
}

View File

@ -0,0 +1,50 @@
pub type c_char = i8;
pub type wchar_t = i32;
s! {
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::c_ulong,
pub st_mode: ::c_uint,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
pub st_size: ::off64_t,
pub st_blksize: ::c_long,
pub st_blocks: ::c_long,
pub st_atime: ::c_ulong,
pub st_atime_nsec: ::c_ulong,
pub st_mtime: ::c_ulong,
pub st_mtime_nsec: ::c_ulong,
pub st_ctime: ::c_ulong,
pub st_ctime_nsec: ::c_ulong,
__unused: [::c_long; 3],
}
pub struct stat64 {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::c_ulong,
pub st_mode: ::c_uint,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
pub st_size: ::off64_t,
pub st_blksize: ::c_long,
pub st_blocks: ::c_long,
pub st_atime: ::c_ulong,
pub st_atime_nsec: ::c_ulong,
pub st_mtime: ::c_ulong,
pub st_mtime_nsec: ::c_ulong,
pub st_ctime: ::c_ulong,
pub st_ctime_nsec: ::c_ulong,
__unused: [::c_long; 3],
}
}
pub const O_DIRECT: ::c_int = 0x4000;
pub const O_DIRECTORY: ::c_int = 0x10000;
pub const O_NOFOLLOW: ::c_int = 0x20000;
pub const SYS_gettid: ::c_long = 186;

View File

@ -464,7 +464,6 @@ pub const TCSBRKP: ::c_int = 0x5425;
pub const TCSANOW: ::c_int = 0;
pub const TCSADRAIN: ::c_int = 0x1;
pub const TCSAFLUSH: ::c_int = 0x2;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const VEOF: usize = 4;
pub const VEOL: usize = 11;
pub const VEOL2: usize = 16;
@ -585,6 +584,7 @@ pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::c_int = 0x00000800;
pub const TAB2: ::c_int = 0x00001000;
@ -753,6 +753,17 @@ f! {
pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
set1.__bits == set2.__bits
}
pub fn major(dev: ::dev_t) -> ::c_int {
((dev >> 8) & 0xfff) as ::c_int
}
pub fn minor(dev: ::dev_t) -> ::c_int {
((dev & 0xff) | ((dev >> 12) & 0xfff00)) as ::c_int
}
pub fn makedev(ma: ::c_int, mi: ::c_int) -> ::dev_t {
let ma = ma as ::dev_t;
let mi = mi as ::dev_t;
((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12)
}
}
extern {

View File

@ -86,7 +86,7 @@ s! {
pub sa_flags: ::c_int,
pub sa_sigaction: ::sighandler_t,
pub sa_mask: sigset_t,
_restorer: *mut ::c_void,
pub sa_restorer: ::dox::Option<extern fn()>,
_resv: [::c_int; 1],
}

View File

@ -85,7 +85,7 @@ s! {
pub sa_flags: ::c_int,
pub sa_sigaction: ::sighandler_t,
pub sa_mask: sigset_t,
_restorer: *mut ::c_void,
pub sa_restorer: ::dox::Option<extern fn()>,
}
pub struct stack_t {

View File

@ -322,7 +322,7 @@ pub const VMIN: usize = 4;
pub const IEXTEN: ::tcflag_t = 0x00000100;
pub const TOSTOP: ::tcflag_t = 0x00008000;
pub const FLUSHO: ::tcflag_t = 0x00002000;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const EXTPROC: ::tcflag_t = 0o200000;
pub const TCSANOW: ::c_int = 0x540e;
pub const TCSADRAIN: ::c_int = 0x540f;
pub const TCSAFLUSH: ::c_int = 0x5410;
@ -420,6 +420,7 @@ pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::c_int = 0x00000800;
pub const TAB2: ::c_int = 0x00001000;

View File

@ -220,6 +220,11 @@ s! {
pub msgtql: ::c_int,
pub msgseg: ::c_ushort,
}
pub struct mmsghdr {
pub msg_hdr: ::msghdr,
pub msg_len: ::c_uint,
}
}
pub const ABDAY_1: ::nl_item = 0x20000;
@ -722,6 +727,31 @@ f! {
pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
set1.bits == set2.bits
}
pub fn major(dev: ::dev_t) -> ::c_uint {
let mut major = 0;
major |= (dev & 0x00000000000fff00) >> 8;
major |= (dev & 0xfffff00000000000) >> 32;
major as ::c_uint
}
pub fn minor(dev: ::dev_t) -> ::c_uint {
let mut minor = 0;
minor |= (dev & 0xfffff00000000000) >> 0;
minor |= (dev & 0x00000ffffff00000) >> 12;
minor as ::c_uint
}
pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
let major = major as ::dev_t;
let minor = minor as ::dev_t;
let mut dev = 0;
dev |= (major & 0x00000fff) << 8;
dev |= (major & 0xfffff000) << 32;
dev |= (minor & 0x000000ff) << 0;
dev |= (minor & 0xffffff00) << 12;
dev
}
}
extern {
@ -958,6 +988,13 @@ extern {
-> ::ssize_t;
}
extern {
pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
flags: ::c_int) -> ::c_int;
pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
}
cfg_if! {
if #[cfg(any(target_env = "musl",
target_os = "fuchsia",

View File

@ -35,7 +35,7 @@ s! {
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
pub sa_flags: ::c_int,
_restorer: *mut ::c_void,
pub sa_restorer: ::dox::Option<extern fn()>,
}
pub struct ipc_perm {
@ -239,6 +239,7 @@ pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::c_int = 0x00000800;
pub const TAB2: ::c_int = 0x00001000;

View File

@ -100,6 +100,7 @@ pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::c_int = 0x00000800;
pub const TAB2: ::c_int = 0x00001000;

View File

@ -103,6 +103,7 @@ pub const MCL_CURRENT: ::c_int = 0x2000;
pub const MCL_FUTURE: ::c_int = 0x4000;
pub const SIGSTKSZ: ::size_t = 0x4000;
pub const MINSIGSTKSZ: ::size_t = 4096;
pub const CBAUD: ::tcflag_t = 0xff;
pub const TAB1: ::c_int = 0x400;
pub const TAB2: ::c_int = 0x800;

View File

@ -141,6 +141,7 @@ pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::c_int = 0x00000800;
pub const TAB2: ::c_int = 0x00001000;

View File

@ -344,6 +344,7 @@ pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const SIGSTKSZ: ::size_t = 16384;
pub const MINSIGSTKSZ: ::size_t = 5120;
pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::c_int = 0x00000800;
pub const TAB2: ::c_int = 0x00001000;

View File

@ -342,6 +342,7 @@ pub const MCL_CURRENT: ::c_int = 0x2000;
pub const MCL_FUTURE: ::c_int = 0x4000;
pub const SIGSTKSZ: ::size_t = 0x4000;
pub const MINSIGSTKSZ: ::size_t = 4096;
pub const CBAUD: ::tcflag_t = 0xff;
pub const TAB1: ::c_int = 0x400;
pub const TAB2: ::c_int = 0x800;

View File

@ -301,6 +301,7 @@ pub const MCL_CURRENT: ::c_int = 0x2000;
pub const MCL_FUTURE: ::c_int = 0x4000;
pub const SIGSTKSZ: ::size_t = 16384;
pub const MINSIGSTKSZ: ::size_t = 4096;
pub const CBAUD: ::tcflag_t = 0x0000100f;
pub const TAB1: ::c_int = 0x800;
pub const TAB2: ::c_int = 0x1000;

View File

@ -402,6 +402,7 @@ pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const CBAUD: ::tcflag_t = 0o0010017;
pub const TAB1: ::c_int = 0x00000800;
pub const TAB2: ::c_int = 0x00001000;

View File

@ -70,7 +70,7 @@ s! {
#[cfg(target_arch = "sparc64")]
__reserved0: ::c_int,
pub sa_flags: ::c_int,
_restorer: *mut ::c_void,
pub sa_restorer: ::dox::Option<extern fn()>,
}
pub struct stack_t {
@ -314,7 +314,6 @@ pub const TMPFS_MAGIC: ::c_long = 0x01021994;
pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
pub const VEOF: usize = 4;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const CPU_SETSIZE: ::c_int = 0x400;

View File

@ -86,7 +86,7 @@ s! {
pub sa_sigaction: ::sighandler_t,
__glibc_reserved0: ::c_int,
pub sa_flags: ::c_int,
_restorer: *mut ::c_void,
pub sa_restorer: ::dox::Option<extern fn()>,
pub sa_mask: sigset_t,
}
@ -339,6 +339,7 @@ pub const SA_ONSTACK: ::c_int = 0x08000000;
pub const SA_SIGINFO: ::c_int = 4;
pub const SIGBUS: ::c_int = 7;
pub const SIGSTKSZ: ::size_t = 0x2000;
pub const MINSIGSTKSZ: ::size_t = 2048;
pub const SIG_SETMASK: ::c_int = 2;
pub const SOCK_DGRAM: ::c_int = 2;
pub const SOCK_STREAM: ::c_int = 1;
@ -576,7 +577,6 @@ pub const VMIN: usize = 6;
pub const IEXTEN: ::tcflag_t = 0x00008000;
pub const TOSTOP: ::tcflag_t = 0x00000100;
pub const FLUSHO: ::tcflag_t = 0x00001000;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const CPU_SETSIZE: ::c_int = 0x400;

View File

@ -675,6 +675,7 @@ pub const IGNCR: ::tcflag_t = 0x00000080;
pub const ICRNL: ::tcflag_t = 0x00000100;
pub const IXANY: ::tcflag_t = 0x00000800;
pub const IMAXBEL: ::tcflag_t = 0x00002000;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const OPOST: ::tcflag_t = 0x1;
pub const CS5: ::tcflag_t = 0x00000000;
pub const CRTSCTS: ::tcflag_t = 0x80000000;

View File

@ -3,36 +3,36 @@ use dox::{mem, Option};
pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type clockid_t = ::c_int;
pub type blkcnt_t = i64;
pub type clock_t = i64;
pub type daddr_t = i64;
pub type dev_t = u64;
pub type fsblkcnt_t = u64;
pub type fsfilcnt_t = u64;
pub type ino_t = i64;
pub type key_t = i32;
pub type major_t = u32;
pub type minor_t = u32;
pub type mode_t = u32;
pub type nlink_t = u32;
pub type rlim_t = u64;
pub type speed_t = u32;
pub type tcflag_t = u32;
pub type time_t = i64;
pub type wchar_t = i32;
pub type clockid_t = ::c_int;
pub type blkcnt_t = ::c_long;
pub type clock_t = ::c_long;
pub type daddr_t = ::c_long;
pub type dev_t = ::c_ulong;
pub type fsblkcnt_t = ::c_ulong;
pub type fsfilcnt_t = ::c_ulong;
pub type ino_t = ::c_ulong;
pub type key_t = ::c_int;
pub type major_t = ::c_uint;
pub type minor_t = ::c_uint;
pub type mode_t = ::c_uint;
pub type nlink_t = ::c_uint;
pub type rlim_t = ::c_ulong;
pub type speed_t = ::c_uint;
pub type tcflag_t = ::c_uint;
pub type time_t = ::c_long;
pub type wchar_t = ::c_int;
pub type nfds_t = ::c_ulong;
pub type suseconds_t = ::c_long;
pub type off_t = i64;
pub type off_t = ::c_long;
pub type useconds_t = ::c_uint;
pub type socklen_t = u32;
pub type socklen_t = ::c_uint;
pub type sa_family_t = u16;
pub type pthread_t = ::c_uint;
pub type pthread_key_t = ::c_uint;
pub type blksize_t = u32;
pub type fflags_t = u32;
pub type blksize_t = ::c_int;
pub type fflags_t = ::c_int;
pub type nl_item = ::c_int;
pub type id_t = ::c_int;
pub type idtype_t = ::c_uint;
@ -340,6 +340,14 @@ s! {
pub if_index: ::c_uint,
pub if_name: *mut ::c_char,
}
pub struct port_event {
pub portev_events: ::c_int,
pub portev_source: ::c_ushort,
pub portev_pad: ::c_ushort,
pub portev_object: ::uintptr_t,
pub portev_user: ::uintptr_t,
}
}
pub const LC_CTYPE: ::c_int = 0;
@ -617,7 +625,7 @@ pub const E2BIG: ::c_int = 7;
pub const ENOEXEC: ::c_int = 8;
pub const EBADF: ::c_int = 9;
pub const ECHILD: ::c_int = 10;
pub const EDEADLK: ::c_int = 45;
pub const EAGAIN: ::c_int = 11;
pub const ENOMEM: ::c_int = 12;
pub const EACCES: ::c_int = 13;
pub const EFAULT: ::c_int = 14;
@ -641,11 +649,65 @@ pub const EMLINK: ::c_int = 31;
pub const EPIPE: ::c_int = 32;
pub const EDOM: ::c_int = 33;
pub const ERANGE: ::c_int = 34;
pub const ENOMSG: ::c_int = 35;
pub const EIDRM: ::c_int = 36;
pub const ECHRNG: ::c_int = 37;
pub const EL2NSYNC: ::c_int = 38;
pub const EL3HLT: ::c_int = 39;
pub const EL3RST: ::c_int = 40;
pub const ELNRNG: ::c_int = 41;
pub const EUNATCH: ::c_int = 42;
pub const ENOCSI: ::c_int = 43;
pub const EL2HLT: ::c_int = 44;
pub const EDEADLK: ::c_int = 45;
pub const ENOLCK: ::c_int = 46;
pub const ECANCELED: ::c_int = 47;
pub const ENOTSUP: ::c_int = 48;
pub const EAGAIN: ::c_int = 11;
pub const EWOULDBLOCK: ::c_int = 11;
pub const EINPROGRESS: ::c_int = 150;
pub const EALREADY: ::c_int = 149;
pub const EDQUOT: ::c_int = 49;
pub const EBADE: ::c_int = 50;
pub const EBADR: ::c_int = 51;
pub const EXFULL: ::c_int = 52;
pub const ENOANO: ::c_int = 53;
pub const EBADRQC: ::c_int = 54;
pub const EBADSLT: ::c_int = 55;
pub const EDEADLOCK: ::c_int = 56;
pub const EBFONT: ::c_int = 57;
pub const EOWNERDEAD: ::c_int = 58;
pub const ENOTRECOVERABLE: ::c_int = 59;
pub const ENOSTR: ::c_int = 60;
pub const ENODATA: ::c_int = 61;
pub const ETIME: ::c_int = 62;
pub const ENOSR: ::c_int = 63;
pub const ENONET: ::c_int = 64;
pub const ENOPKG: ::c_int = 65;
pub const EREMOTE: ::c_int = 66;
pub const ENOLINK: ::c_int = 67;
pub const EADV: ::c_int = 68;
pub const ESRMNT: ::c_int = 69;
pub const ECOMM: ::c_int = 70;
pub const EPROTO: ::c_int = 71;
pub const ELOCKUNMAPPED: ::c_int = 72;
pub const ENOTACTIVE: ::c_int = 73;
pub const EMULTIHOP: ::c_int = 74;
pub const EADI: ::c_int = 75;
pub const EBADMSG: ::c_int = 77;
pub const ENAMETOOLONG: ::c_int = 78;
pub const EOVERFLOW: ::c_int = 79;
pub const ENOTUNIQ: ::c_int = 80;
pub const EBADFD: ::c_int = 81;
pub const EREMCHG: ::c_int = 82;
pub const ELIBACC: ::c_int = 83;
pub const ELIBBAD: ::c_int = 84;
pub const ELIBSCN: ::c_int = 85;
pub const ELIBMAX: ::c_int = 86;
pub const ELIBEXEC: ::c_int = 87;
pub const EILSEQ: ::c_int = 88;
pub const ENOSYS: ::c_int = 89;
pub const ELOOP: ::c_int = 90;
pub const ERESTART: ::c_int = 91;
pub const ESTRPIPE: ::c_int = 92;
pub const ENOTEMPTY: ::c_int = 93;
pub const EUSERS: ::c_int = 94;
pub const ENOTSOCK: ::c_int = 95;
pub const EDESTADDRREQ: ::c_int = 96;
pub const EMSGSIZE: ::c_int = 97;
@ -670,26 +732,11 @@ pub const ESHUTDOWN: ::c_int = 143;
pub const ETOOMANYREFS: ::c_int = 144;
pub const ETIMEDOUT: ::c_int = 145;
pub const ECONNREFUSED: ::c_int = 146;
pub const ELOOP: ::c_int = 90;
pub const ENAMETOOLONG: ::c_int = 78;
pub const EHOSTDOWN: ::c_int = 147;
pub const EHOSTUNREACH: ::c_int = 148;
pub const ENOTEMPTY: ::c_int = 93;
pub const EUSERS: ::c_int = 94;
pub const EDQUOT: ::c_int = 49;
pub const ESTALE: ::c_int = 151;
pub const EREMOTE: ::c_int = 66;
pub const ENOLCK: ::c_int = 46;
pub const ENOSYS: ::c_int = 89;
pub const EIDRM: ::c_int = 36;
pub const ENOMSG: ::c_int = 35;
pub const EOVERFLOW: ::c_int = 79;
pub const ECANCELED: ::c_int = 47;
pub const EILSEQ: ::c_int = 88;
pub const EBADMSG: ::c_int = 77;
pub const EMULTIHOP: ::c_int = 74;
pub const ENOLINK: ::c_int = 67;
pub const EPROTO: ::c_int = 71;
pub const EWOULDBLOCK: ::c_int = EAGAIN;
pub const EALREADY: ::c_int = 149;
pub const EINPROGRESS: ::c_int = 150;
pub const EAI_SYSTEM: ::c_int = 11;
@ -965,6 +1012,16 @@ pub const RTLD_NODELETE: ::c_int = 0x1000;
pub const RTLD_FIRST: ::c_int = 0x2000;
pub const RTLD_CONFGEN: ::c_int = 0x10000;
pub const PORT_SOURCE_AIO: ::c_int = 1;
pub const PORT_SOURCE_TIMER: ::c_int = 2;
pub const PORT_SOURCE_USER: ::c_int = 3;
pub const PORT_SOURCE_FD: ::c_int = 4;
pub const PORT_SOURCE_ALERT: ::c_int = 5;
pub const PORT_SOURCE_MQ: ::c_int = 6;
pub const PORT_SOURCE_FILE: ::c_int = 7;
pub const PORT_SOURCE_POSTWAIT: ::c_int = 8;
pub const PORT_SOURCE_SIGNAL: ::c_int = 9;
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
@ -1123,4 +1180,15 @@ extern {
flags: ::c_int) -> ::ssize_t;
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;
pub fn port_create() -> ::c_int;
pub fn port_associate(port: ::c_int, source: ::c_int, object: ::uintptr_t,
events: ::c_int, user: ::uintptr_t) -> ::c_int;
pub fn port_dissociate(port: ::c_int, source: ::c_int, object: ::uintptr_t)
-> ::c_int;
pub fn port_get(port: ::c_int, pe: *mut port_event,
timeout: *const ::timespec) -> ::c_int;
pub fn port_getn(port: ::c_int, pe_list: *mut port_event, max: ::c_uint,
nget: *mut ::c_uint, timeout: *const ::timespec)
-> ::c_int;
}