From 44b90221d709e5f0bac876829073cdc30bb8e5a5 Mon Sep 17 00:00:00 2001 From: Nick Carter Date: Wed, 16 Oct 2019 17:04:46 +0100 Subject: [PATCH 01/61] Add struct ip_mreqn: ip multicast req with intf id The ip_mreqn struct has an additional interface id parameter. This allows programming IPv4 multicast groups using the interface id alongside the src IPv4 address. Linux has supported the ip_mreqn struct since Linux 2.2 ref: man ip.7 [Adding to linux x86_64 only as adding to linux_like/mod.rs caused failures in the sparc64 and mips64 C regression tests] --- src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index d1a229438096..74e2688c8ce5 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -261,6 +261,12 @@ s! { pub c_ispeed: ::speed_t, pub c_ospeed: ::speed_t, } + + pub struct ip_mreqn { + pub imr_multiaddr: ::in_addr, + pub imr_address: ::in_addr, + pub imr_ifindex: ::c_int, + } } s_no_extra_traits! { From 284184d140afd58f093bbe0d23cd50a620b43e4b Mon Sep 17 00:00:00 2001 From: Alex Touchet Date: Thu, 17 Oct 2019 20:03:51 -0700 Subject: [PATCH 02/61] Readme updates --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5371916acfec..ed313ae617d0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Azure Status]][Azure] [![Cirrus-CI Status]][Cirrus-CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] +[![Azure Status]][Azure] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] libc - Raw FFI bindings to platforms' system libraries ==== @@ -47,9 +47,9 @@ newer Rust features are only available on newer Rust toolchains: | `union` | 1.19.0 | | `const mem::size_of` | 1.24.0 | | `repr(align)` | 1.25.0 | -| `extra_traits` | 1.25.0 | +| `extra_traits` | 1.25.0 | | `core::ffi::c_void` | 1.30.0 | -| `repr(packed(N))` | 1.33.0 | +| `repr(packed(N))` | 1.33.0 | ## Platform support @@ -58,7 +58,7 @@ newer Rust features are only available on newer Rust toolchains: See [`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/ci/build.sh) for the platforms on which `libc` is guaranteed to build for each Rust -toolchain. The test-matrix at [Azure] and [Cirrus-CI] show the +toolchain. The test-matrix at [Azure] and [Cirrus CI] show the platforms in which `libc` tests are run.
@@ -67,10 +67,10 @@ platforms in which `libc` tests are run. This project is licensed under either of -* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) +* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([LICENSE-APACHE](LICENSE-APACHE)) -* [MIT License](http://opensource.org/licenses/MIT) +* [MIT License](https://opensource.org/licenses/MIT) ([LICENSE-MIT](LICENSE-MIT)) at your option. @@ -85,7 +85,7 @@ instructions] for more information. Contributions in any form (issues, pull requests, etc.) to this project must adhere to Rust's [Code of Conduct]. -[Code of Conduct]: https://www.rust-lang.org/en-US/conduct.html +[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be @@ -93,8 +93,8 @@ dual licensed as above, without any additional terms or conditions. [Azure Status]: https://dev.azure.com/rust-lang2/libc/_apis/build/status/rust-lang.libc?branchName=master [Azure]: https://dev.azure.com/rust-lang2/libc/_build/latest?definitionId=1&branchName=master -[Cirrus-CI]: https://cirrus-ci.com/github/rust-lang/libc -[Cirrus-CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg +[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc +[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg [crates.io]: https://crates.io/crates/libc [Latest Version]: https://img.shields.io/crates/v/libc.svg [Documentation]: https://docs.rs/libc/badge.svg From 5df4b8d01c457335356e9b01bf8835903ea45dde Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 22 Oct 2019 13:20:54 +0200 Subject: [PATCH 03/61] ci: switch mirrors to use our CDN We recently added a CDN in front of our CI mirrors as it's faster and cheaper for us. This switches libc's CI to use it instead of accessing the underlying bucket directly. --- ci/docker/mips-unknown-linux-musl/Dockerfile | 2 +- ci/docker/mipsel-unknown-linux-musl/Dockerfile | 2 +- ci/run.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/docker/mips-unknown-linux-musl/Dockerfile b/ci/docker/mips-unknown-linux-musl/Dockerfile index 50da684ae7b0..f1a1076cb5a1 100644 --- a/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -8,7 +8,7 @@ RUN mkdir /toolchain # Note that this originally came from: # https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 -RUN curl --retry 5 -L https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ +RUN curl --retry 5 -L https://ci-mirrors.rust-lang.org/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ tar xjf - -C /toolchain --strip-components=1 ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ diff --git a/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/ci/docker/mipsel-unknown-linux-musl/Dockerfile index 91c00c250cab..1221eb230d5f 100644 --- a/ci/docker/mipsel-unknown-linux-musl/Dockerfile +++ b/ci/docker/mipsel-unknown-linux-musl/Dockerfile @@ -8,7 +8,7 @@ RUN mkdir /toolchain # Note that this originally came from: # https://downloads.openwrt.org/snapshots/trunk/malta/generic/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 -RUN curl --retry 5 -L https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ +RUN curl --retry 5 -L https://ci-mirrors.rust-lang.org/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ tar xjf - -C /toolchain --strip-components=2 ENV PATH=$PATH:/rust/bin:/toolchain/bin \ diff --git a/ci/run.sh b/ci/run.sh index e863085d9a15..b435122c252c 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -5,7 +5,7 @@ set -ex -MIRRORS_URL="https://rust-lang-ci-mirrors.s3-us-west-1.amazonaws.com/libc" +MIRRORS_URL="https://ci-mirrors.rust-lang.org/libc" TARGET="${1}" From 785a60c4d221611b832df6c1a0357543f0e45b77 Mon Sep 17 00:00:00 2001 From: mikehoyle Date: Wed, 23 Oct 2019 14:18:27 -0700 Subject: [PATCH 04/61] Add a few functions & POSIX error codes to Windows API --- src/windows/mod.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/windows/mod.rs b/src/windows/mod.rs index ba80e0ca0f6c..9dafb43ac9f9 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -183,6 +183,49 @@ pub const ENOTEMPTY: ::c_int = 41; pub const EILSEQ: ::c_int = 42; pub const STRUNCATE: ::c_int = 80; +// POSIX Supplement (from errno.h) +pub const EADDRINUSE: ::c_int = 100; +pub const EADDRNOTAVAIL: ::c_int = 101; +pub const EAFNOSUPPORT: ::c_int = 102; +pub const EALREADY: ::c_int = 103; +pub const EBADMSG: ::c_int = 104; +pub const ECANCELED: ::c_int = 105; +pub const ECONNABORTED: ::c_int = 106; +pub const ECONNREFUSED: ::c_int = 107; +pub const ECONNRESET: ::c_int = 108; +pub const EDESTADDRREQ: ::c_int = 109; +pub const EHOSTUNREACH: ::c_int = 110; +pub const EIDRM: ::c_int = 111; +pub const EINPROGRESS: ::c_int = 112; +pub const EISCONN: ::c_int = 113; +pub const ELOOP: ::c_int = 114; +pub const EMSGSIZE: ::c_int = 115; +pub const ENETDOWN: ::c_int = 116; +pub const ENETRESET: ::c_int = 117; +pub const ENETUNREACH: ::c_int = 118; +pub const ENOBUFS: ::c_int = 119; +pub const ENODATA: ::c_int = 120; +pub const ENOLINK: ::c_int = 121; +pub const ENOMSG: ::c_int = 122; +pub const ENOPROTOOPT: ::c_int = 123; +pub const ENOSR: ::c_int = 124; +pub const ENOSTR: ::c_int = 125; +pub const ENOTCONN: ::c_int = 126; +pub const ENOTRECOVERABLE: ::c_int = 127; +pub const ENOTSOCK: ::c_int = 128; +pub const ENOTSUP: ::c_int = 129; +pub const EOPNOTSUPP: ::c_int = 130; +pub const EOTHER: ::c_int = 131; +pub const EOVERFLOW: ::c_int = 132; +pub const EOWNERDEAD: ::c_int = 133; +pub const EPROTO: ::c_int = 134; +pub const EPROTONOSUPPORT: ::c_int = 135; +pub const EPROTOTYPE: ::c_int = 136; +pub const ETIME: ::c_int = 137; +pub const ETIMEDOUT: ::c_int = 138; +pub const ETXTBSY: ::c_int = 139; +pub const EWOULDBLOCK: ::c_int = 140; + // signal codes pub const SIGINT: ::c_int = 2; pub const SIGILL: ::c_int = 4; @@ -335,6 +378,8 @@ extern "C" { n: size_t, ) -> ::size_t; + pub fn time(destTime: *mut time_t) -> time_t; + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; pub fn memcpy( @@ -425,6 +470,9 @@ extern "C" { pub fn isatty(fd: ::c_int) -> ::c_int; #[link_name = "_lseek"] pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long; + #[link_name = "_lseeki64"] + pub fn lseek64(fd: ::c_int, offset: c_longlong, origin: ::c_int) + -> c_longlong; #[link_name = "_pipe"] pub fn pipe( fds: *mut ::c_int, From 3ecdafbde86fc01cd3f37c9327497ed0da8ab743 Mon Sep 17 00:00:00 2001 From: mikehoyle Date: Thu, 24 Oct 2019 13:59:53 -0700 Subject: [PATCH 05/61] Updating for formatting _time64, and gnu test failures --- src/windows/mod.rs | 12 +++++++----- src/windows/msvc.rs | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 9dafb43ac9f9..a83babaed661 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -215,7 +215,6 @@ pub const ENOTRECOVERABLE: ::c_int = 127; pub const ENOTSOCK: ::c_int = 128; pub const ENOTSUP: ::c_int = 129; pub const EOPNOTSUPP: ::c_int = 130; -pub const EOTHER: ::c_int = 131; pub const EOVERFLOW: ::c_int = 132; pub const EOWNERDEAD: ::c_int = 133; pub const EPROTO: ::c_int = 134; @@ -378,8 +377,6 @@ extern "C" { n: size_t, ) -> ::size_t; - pub fn time(destTime: *mut time_t) -> time_t; - pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; pub fn memcpy( @@ -403,6 +400,8 @@ extern "C" { pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; pub fn raise(signum: c_int) -> c_int; + #[link_name = "_time64"] + pub fn time(destTime: *mut time_t) -> time_t; #[link_name = "_chmod"] pub fn chmod(path: *const c_char, mode: ::c_int) -> ::c_int; #[link_name = "_wchmod"] @@ -471,8 +470,11 @@ extern "C" { #[link_name = "_lseek"] pub fn lseek(fd: ::c_int, offset: c_long, origin: ::c_int) -> c_long; #[link_name = "_lseeki64"] - pub fn lseek64(fd: ::c_int, offset: c_longlong, origin: ::c_int) - -> c_longlong; + pub fn lseek64( + fd: ::c_int, + offset: c_longlong, + origin: ::c_int, + ) -> c_longlong; #[link_name = "_pipe"] pub fn pipe( fds: *mut ::c_int, diff --git a/src/windows/msvc.rs b/src/windows/msvc.rs index 27333ae2ecd9..8f20deb5dfb5 100644 --- a/src/windows/msvc.rs +++ b/src/windows/msvc.rs @@ -1,6 +1,10 @@ pub const L_tmpnam: ::c_uint = 260; pub const TMP_MAX: ::c_uint = 0x7fff_ffff; +// POSIX Supplement (from errno.h) +// This particular error code is only currently available in msvc toolchain +pub const EOTHER: ::c_int = 131; + extern "C" { #[link_name = "_stricmp"] pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; From f66774e673c9bf721f88e3d6b7d865d027eff0d2 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Fri, 25 Oct 2019 16:02:57 +0100 Subject: [PATCH 06/61] Add two missing pthread calls to the OpenBSD support. --- src/unix/bsd/netbsdlike/openbsd/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index f70fddf59ceb..5fa5dfbabeed 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1431,6 +1431,15 @@ extern "C" { len: ::size_t, prot: ::c_int, ) -> ::c_int; + pub fn pthread_attr_getguardsize( + attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_attr_getstack( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t, + ) -> ::c_int; pub fn pthread_main_np() -> ::c_int; pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn pthread_stackseg_np( From 5dfc2c82854eede618f35c4511e941506f0e76d0 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 30 Sep 2019 16:02:01 -0400 Subject: [PATCH 07/61] Add support for declaring 'const fn' Add a new feature to enable this, since `const extern fn` support is unstable --- Cargo.toml | 1 + README.md | 3 ++ src/lib.rs | 1 + src/macros.rs | 98 ++++++++++++++++++++++++++++++++++---- src/unix/linux_like/mod.rs | 8 ++-- 5 files changed, 99 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e48a34cdfe9a..a0658132492b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ std = [] align = [] rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] extra_traits = [] +const-extern-fn = [] # use_std is deprecated, use `std` instead use_std = [ 'std' ] diff --git a/README.md b/README.md index 5371916acfec..dc1d6d05de02 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ libc = "0.2" * `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. +* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s. + This features requires a nightly rustc + * **deprecated**: `use_std` is deprecated, and is equivalent to `std`. ## Rust version support diff --git a/src/lib.rs b/src/lib.rs index 3255303e5a9b..40625ac98dc6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,7 @@ #![no_std] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr(target_os = "redox", feature(static_nobundle))] +#![cfg_attr(feature = "const-extern-fn", feature(const_extern_fn))] #[macro_use] mod macros; diff --git a/src/macros.rs b/src/macros.rs index 14a28046640c..da3927063327 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -121,16 +121,96 @@ macro_rules! s_no_extra_traits { ); } -#[allow(unused_macros)] -macro_rules! f { - ($(pub fn $i:ident($($arg:ident: $argty:ty),*) -> $ret:ty { - $($body:stmt);* - })*) => ($( - #[inline] - pub unsafe extern fn $i($($arg: $argty),*) -> $ret { - $($body);* +// This is a pretty horrible hack to allow us to conditionally mark +// some functions as 'const', without requiring users of this macro +// to care about the "const-extern-fn" feature. +// +// When 'const-extern-fn' is enabled, we emit the captured 'const' keyword +// in the expanded function. +// +// When 'const-extern-fn' is disabled, we always emit a plain 'pub unsafe extern fn'. +// Note that the expression matched by the macro is exactly the same - this allows +// users of this macro to work whether or not 'const-extern-fn' is enabled +// +// Unfortunately, we need to duplicate most of this macro between the 'cfg_if' blocks. +// This is because 'const unsafe extern fn' won't even parse on older compilers, +// so we need to avoid emitting it at all of 'const-extern-fn'. +// +// Specifically, moving the 'cfg_if' into the macro body will *not* work. +// Doing so would cause the '#[cfg(feature = "const-extern-fn")]' to be emiited +// into user code. The 'cfg' gate will not stop Rust from trying to parse the +// 'pub const unsafe extern fn', so users would get a compiler error even when +// the 'const-extern-fn' feature is disabled +// +// Note that users of this macro need to place 'const' in a weird position +// (after the closing ')' for the arguments, but before the return type). +// This was the only way I could satisfy the following two requirements: +// 1. Avoid ambuguity errors from 'macro_rules!' (which happen when writing '$foo:ident fn' +// 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same +// 'f!' block +cfg_if! { + if #[cfg(feature = "const-extern-fn")] { + #[allow(unused_macros)] + macro_rules! f { + ($(pub $({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + pub $($constness)* unsafe extern fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) } - )*) + + #[allow(unused_macros)] + macro_rules! const_fn { + ($($({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + $($constness)* fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) + } + + } else { + #[allow(unused_macros)] + macro_rules! f { + ($(pub $({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + pub unsafe extern fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) + } + + #[allow(unused_macros)] + macro_rules! const_fn { + ($($({$constness:ident})* fn $i:ident( + $($arg:ident: $argty:ty),* + ) -> $ret:ty { + $($body:stmt);* + })*) => ($( + #[inline] + fn $i($($arg: $argty),* + ) -> $ret { + $($body);* + } + )*) + } + } } #[allow(unused_macros)] diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1568e4f8369f..a6ec553eeeb8 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1165,8 +1165,10 @@ pub const ARPHRD_IEEE802154: u16 = 804; pub const ARPHRD_VOID: u16 = 0xFFFF; pub const ARPHRD_NONE: u16 = 0xFFFE; -fn CMSG_ALIGN(len: usize) -> usize { - len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) +const_fn! { + {const} fn CMSG_ALIGN(len: usize) -> usize { + len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) + } } f! { @@ -1182,7 +1184,7 @@ f! { cmsg.offset(1) as *mut ::c_uchar } - pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + pub {const} fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::())) as ::c_uint } From fcd94cc6030afbfe99b7bec510dfa04549fbecff Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Mon, 28 Oct 2019 09:32:35 +0100 Subject: [PATCH 08/61] nfnetfilter & nfnetfilter_log constants --- src/unix/linux_like/linux/mod.rs | 75 ++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 04d19ea08a68..8bd9cc536856 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1664,6 +1664,81 @@ pub const NLMSG_DONE: ::c_int = 0x3; pub const NLMSG_OVERRUN: ::c_int = 0x4; pub const NLMSG_MIN_TYPE: ::c_int = 0x10; +// linux/netfilter/nfnetlink.h +pub const NFNLGRP_NONE: ::c_int = 0; +pub const NFNLGRP_CONNTRACK_NEW: ::c_int = 1; +pub const NFNLGRP_CONNTRACK_UPDATE: ::c_int = 2; +pub const NFNLGRP_CONNTRACK_DESTROY: ::c_int = 3; +pub const NFNLGRP_CONNTRACK_EXP_NEW: ::c_int = 4; +pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5; +pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6; +pub const NFNLGRP_NFTABLES: ::c_int = 7; +pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8; +pub const NFNLGRP_NFTRACE: ::c_int = 9; + +pub const NFNETLINK_V0: ::c_int = 0; + +pub const NFNL_SUBSYS_NONE: ::c_int = 0; +pub const NFNL_SUBSYS_CTNETLINK: ::c_int = 1; +pub const NFNL_SUBSYS_CTNETLINK_EXP: ::c_int = 2; +pub const NFNL_SUBSYS_QUEUE: ::c_int = 3; +pub const NFNL_SUBSYS_ULOG: ::c_int = 4; +pub const NFNL_SUBSYS_OSF: ::c_int = 5; +pub const NFNL_SUBSYS_IPSET: ::c_int = 6; +pub const NFNL_SUBSYS_ACCT: ::c_int = 7; +pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: ::c_int = 8; +pub const NFNL_SUBSYS_CTHELPER: ::c_int = 9; +pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10; +pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11; +pub const NFNL_SUBSYS_COUNT: ::c_int = 12; + +// linux/netfilter/nfnetlink_log.h +pub const NFULNL_MSG_PACKET: ::c_int = 0; +pub const NFULNL_MSG_CONFIG: ::c_int = 1; + +pub const NFULA_UNSPEC: ::c_int = 0; +pub const NFULA_PACKET_HDR: ::c_int = 1; +pub const NFULA_MARK: ::c_int = 2; +pub const NFULA_TIMESTAMP: ::c_int = 3; +pub const NFULA_IFINDEX_INDEV: ::c_int = 4; +pub const NFULA_IFINDEX_OUTDEV: ::c_int = 5; +pub const NFULA_IFINDEX_PHYSINDEV: ::c_int = 6; +pub const NFULA_IFINDEX_PHYSOUTDEV: ::c_int = 7; +pub const NFULA_HWADDR: ::c_int = 8; +pub const NFULA_PAYLOAD: ::c_int = 9; +pub const NFULA_PREFIX: ::c_int = 10; +pub const NFULA_UID: ::c_int = 11; +pub const NFULA_SEQ: ::c_int = 12; +pub const NFULA_SEQ_GLOBAL: ::c_int = 13; +pub const NFULA_GID: ::c_int = 14; +pub const NFULA_HWTYPE: ::c_int = 15; +pub const NFULA_HWHEADER: ::c_int = 16; +pub const NFULA_HWLEN: ::c_int = 17; +pub const NFULA_CT: ::c_int = 18; +pub const NFULA_CT_INFO: ::c_int = 19; + +pub const NFULNL_CFG_CMD_NONE: ::c_int = 0; +pub const NFULNL_CFG_CMD_BIND: ::c_int = 1; +pub const NFULNL_CFG_CMD_UNBIND: ::c_int = 2; +pub const NFULNL_CFG_CMD_PF_BIND: ::c_int = 3; +pub const NFULNL_CFG_CMD_PF_UNBIND: ::c_int = 4; + +pub const NFULA_CFG_UNSPEC: ::c_int = 0; +pub const NFULA_CFG_CMD: ::c_int = 1; +pub const NFULA_CFG_MODE: ::c_int = 2; +pub const NFULA_CFG_NLBUFSIZ: ::c_int = 3; +pub const NFULA_CFG_TIMEOUT: ::c_int = 4; +pub const NFULA_CFG_QTHRESH: ::c_int = 5; +pub const NFULA_CFG_FLAGS: ::c_int = 6; + +pub const NFULNL_COPY_NONE: ::c_int = 0x00; +pub const NFULNL_COPY_META: ::c_int = 0x01; +pub const NFULNL_COPY_PACKET: ::c_int = 0x02; + +pub const NFULNL_CFG_F_SEQ: ::c_int = 0x0001; +pub const NFULNL_CFG_F_SEQ_GLOBAL: ::c_int = 0x0002; +pub const NFULNL_CFG_F_CONNTRACK: ::c_int = 0x0004; + pub const GENL_NAMSIZ: ::c_int = 16; pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE; From 2216488714c3aa40198178e2dc5a057279aa8d83 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Mon, 28 Oct 2019 09:58:03 +0100 Subject: [PATCH 09/61] nfnetlink & nfnetlink_log constants First batch for #1562 --- libc-test/build.rs | 4 ++ src/unix/linux_like/android/mod.rs | 81 ++++++++++++++++++++++++++++++ src/unix/linux_like/linux/mod.rs | 6 +++ 3 files changed, 91 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index b2512b85d6a9..a42fec5f3cbe 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1253,6 +1253,8 @@ fn test_android(target: &str) { "linux/memfd.h", "linux/module.h", "linux/net_tstamp.h", + "linux/netfilter/nfnetlink.h", + "linux/netfilter/nfnetlink_log.h", "linux/netfilter/nf_tables.h", "linux/netfilter_ipv4.h", "linux/netfilter_ipv6.h", @@ -2196,6 +2198,8 @@ fn test_linux(target: &str) { "linux/memfd.h", "linux/module.h", "linux/net_tstamp.h", + "linux/netfilter/nfnetlink.h", + "linux/netfilter/nfnetlink_log.h", "linux/netfilter/nf_tables.h", "linux/netfilter_ipv4.h", "linux/netfilter_ipv6.h", diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 4c4a29669b73..fc515dc870a2 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1309,6 +1309,87 @@ pub const NLMSG_DONE: ::c_int = 0x3; pub const NLMSG_OVERRUN: ::c_int = 0x4; pub const NLMSG_MIN_TYPE: ::c_int = 0x10; +// linux/netfilter/nfnetlink.h +pub const NFNLGRP_NONE: ::c_int = 0; +pub const NFNLGRP_CONNTRACK_NEW: ::c_int = 1; +pub const NFNLGRP_CONNTRACK_UPDATE: ::c_int = 2; +pub const NFNLGRP_CONNTRACK_DESTROY: ::c_int = 3; +pub const NFNLGRP_CONNTRACK_EXP_NEW: ::c_int = 4; +pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5; +pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6; +pub const NFNLGRP_NFTABLES: ::c_int = 7; +pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8; +pub const NFNLGRP_NFTRACE: ::c_int = 9; + +pub const NFNETLINK_V0: ::c_int = 0; + +pub const NFNL_SUBSYS_NONE: ::c_int = 0; +pub const NFNL_SUBSYS_CTNETLINK: ::c_int = 1; +pub const NFNL_SUBSYS_CTNETLINK_EXP: ::c_int = 2; +pub const NFNL_SUBSYS_QUEUE: ::c_int = 3; +pub const NFNL_SUBSYS_ULOG: ::c_int = 4; +pub const NFNL_SUBSYS_OSF: ::c_int = 5; +pub const NFNL_SUBSYS_IPSET: ::c_int = 6; +pub const NFNL_SUBSYS_ACCT: ::c_int = 7; +pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: ::c_int = 8; +pub const NFNL_SUBSYS_CTHELPER: ::c_int = 9; +pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10; +pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11; +pub const NFNL_SUBSYS_COUNT: ::c_int = 12; + +pub const NFNL_BATCH_UNSPEC: ::c_int = 0; +pub const NFNL_BATCH_GENID: ::c_int = 1; + +pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE; +pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1; + +// linux/netfilter/nfnetlink_log.h +pub const NFULNL_MSG_PACKET: ::c_int = 0; +pub const NFULNL_MSG_CONFIG: ::c_int = 1; + +pub const NFULA_UNSPEC: ::c_int = 0; +pub const NFULA_PACKET_HDR: ::c_int = 1; +pub const NFULA_MARK: ::c_int = 2; +pub const NFULA_TIMESTAMP: ::c_int = 3; +pub const NFULA_IFINDEX_INDEV: ::c_int = 4; +pub const NFULA_IFINDEX_OUTDEV: ::c_int = 5; +pub const NFULA_IFINDEX_PHYSINDEV: ::c_int = 6; +pub const NFULA_IFINDEX_PHYSOUTDEV: ::c_int = 7; +pub const NFULA_HWADDR: ::c_int = 8; +pub const NFULA_PAYLOAD: ::c_int = 9; +pub const NFULA_PREFIX: ::c_int = 10; +pub const NFULA_UID: ::c_int = 11; +pub const NFULA_SEQ: ::c_int = 12; +pub const NFULA_SEQ_GLOBAL: ::c_int = 13; +pub const NFULA_GID: ::c_int = 14; +pub const NFULA_HWTYPE: ::c_int = 15; +pub const NFULA_HWHEADER: ::c_int = 16; +pub const NFULA_HWLEN: ::c_int = 17; +pub const NFULA_CT: ::c_int = 18; +pub const NFULA_CT_INFO: ::c_int = 19; + +pub const NFULNL_CFG_CMD_NONE: ::c_int = 0; +pub const NFULNL_CFG_CMD_BIND: ::c_int = 1; +pub const NFULNL_CFG_CMD_UNBIND: ::c_int = 2; +pub const NFULNL_CFG_CMD_PF_BIND: ::c_int = 3; +pub const NFULNL_CFG_CMD_PF_UNBIND: ::c_int = 4; + +pub const NFULA_CFG_UNSPEC: ::c_int = 0; +pub const NFULA_CFG_CMD: ::c_int = 1; +pub const NFULA_CFG_MODE: ::c_int = 2; +pub const NFULA_CFG_NLBUFSIZ: ::c_int = 3; +pub const NFULA_CFG_TIMEOUT: ::c_int = 4; +pub const NFULA_CFG_QTHRESH: ::c_int = 5; +pub const NFULA_CFG_FLAGS: ::c_int = 6; + +pub const NFULNL_COPY_NONE: ::c_int = 0x00; +pub const NFULNL_COPY_META: ::c_int = 0x01; +pub const NFULNL_COPY_PACKET: ::c_int = 0x02; + +pub const NFULNL_CFG_F_SEQ: ::c_int = 0x0001; +pub const NFULNL_CFG_F_SEQ_GLOBAL: ::c_int = 0x0002; +pub const NFULNL_CFG_F_CONNTRACK: ::c_int = 0x0004; + pub const GENL_NAMSIZ: ::c_int = 16; pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 8bd9cc536856..144d7beee63c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1692,6 +1692,12 @@ pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10; pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11; pub const NFNL_SUBSYS_COUNT: ::c_int = 12; +pub const NFNL_BATCH_UNSPEC: ::c_int = 0; +pub const NFNL_BATCH_GENID: ::c_int = 1; + +pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE; +pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1; + // linux/netfilter/nfnetlink_log.h pub const NFULNL_MSG_PACKET: ::c_int = 0; pub const NFULNL_MSG_CONFIG: ::c_int = 1; From add284a294bacf80f6f39988aa9b3c13a4140908 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 28 Oct 2019 20:12:47 -0400 Subject: [PATCH 10/61] Test 'const-extern-fn' on nightly --- ci/build.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ci/build.sh b/ci/build.sh index a970b0e9c970..cde46cb451b8 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -67,6 +67,13 @@ test_target() { cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --no-default-features --target "${TARGET}" \ --features extra_traits + # Test the 'const-extern-fn' feature on nightly + if [ "${RUST}" = "nightly" ]; then + cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --no-default-features --target "${TARGET}" \ + --features const-extern-fn + fi + + # Also test that it builds with `extra_traits` and default features: if [ "$NO_STD" != "1" ]; then cargo "+${RUST}" "${BUILD_CMD}" -vv $opt --target "${TARGET}" \ From 457d65439610ae70b38e05ac83dde1419670727a Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 28 Oct 2019 20:14:12 -0400 Subject: [PATCH 11/61] Fix feature name Co-Authored-By: gnzlbg --- src/lib.rs | 2 +- src/macros.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 40625ac98dc6..0b1496af1d6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,7 @@ #![no_std] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr(target_os = "redox", feature(static_nobundle))] -#![cfg_attr(feature = "const-extern-fn", feature(const_extern_fn))] +#![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))] #[macro_use] mod macros; diff --git a/src/macros.rs b/src/macros.rs index da3927063327..f14bbf552213 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -149,7 +149,7 @@ macro_rules! s_no_extra_traits { // 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same // 'f!' block cfg_if! { - if #[cfg(feature = "const-extern-fn")] { + if #[cfg(libc_const_extern_fn)] { #[allow(unused_macros)] macro_rules! f { ($(pub $({$constness:ident})* fn $i:ident( From b0ba2de7676af63ba4c13d7184b3f630735e7e7b Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 28 Oct 2019 21:09:30 -0400 Subject: [PATCH 12/61] Add Linux test --- build.rs | 5 +++++ tests/const_fn.rs | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 tests/const_fn.rs diff --git a/build.rs b/build.rs index d5bcb5253a4c..fb1aae9be42e 100644 --- a/build.rs +++ b/build.rs @@ -7,6 +7,7 @@ fn main() { rustc_minor_version().expect("Failed to get rustc version"); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); + let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); if env::var("CARGO_FEATURE_USE_STD").is_ok() { @@ -72,6 +73,10 @@ fn main() { if rustc_dep_of_std { println!("cargo:rustc-cfg=libc_thread_local"); } + + if const_extern_fn_cargo_feature { + println!("cargo:rustc-cfg=libc_const_extern_fn"); + } } fn rustc_minor_version() -> Option { diff --git a/tests/const_fn.rs b/tests/const_fn.rs new file mode 100644 index 000000000000..4c413c90e8fa --- /dev/null +++ b/tests/const_fn.rs @@ -0,0 +1,5 @@ +#![cfg(libc_const_extern_fn)] // If this does not hold, the file is empty + +#[cfg(target_os = "linux")] +const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) }; +//^ if CMSG_SPACE is not const, this will fail to compile From 476b6759762514c353b8f3d6375d86d747084340 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 29 Oct 2019 08:25:59 -0400 Subject: [PATCH 13/61] Panic if const-extern-fn is not used on nightly --- build.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index fb1aae9be42e..dddc029e221a 100644 --- a/build.rs +++ b/build.rs @@ -3,8 +3,8 @@ use std::process::Command; use std::str; fn main() { - let rustc_minor_ver = - rustc_minor_version().expect("Failed to get rustc version"); + let (rustc_minor_ver, is_nightly) = + rustc_minor_nightly().expect("Failed to get rustc version"); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); @@ -75,11 +75,14 @@ fn main() { } if const_extern_fn_cargo_feature { + if !is_nightly || rustc_minor_ver < 40 { + panic!("const-extern-fn requires a nightly compiler >= 1.40") + } println!("cargo:rustc-cfg=libc_const_extern_fn"); } } -fn rustc_minor_version() -> Option { +fn rustc_minor_nightly() -> Option<(u32, bool)> { macro_rules! otry { ($e:expr) => { match $e { @@ -98,7 +101,12 @@ fn rustc_minor_version() -> Option { return None; } - otry!(pieces.next()).parse().ok() + let minor = pieces.next(); + let nightly_raw = otry!(otry!(pieces.next()).split('-').nth(1)); + let nightly = nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly"); + let minor = otry!(otry!(minor).parse().ok()); + + Some((minor, nightly)) } fn which_freebsd() -> Option { From ca2d53e281fa287dfa4f6bfe8768b20c9705c44f Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 29 Oct 2019 09:51:44 -0400 Subject: [PATCH 14/61] Run 'cargo fmt' --- build.rs | 6 ++++-- tests/const_fn.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index dddc029e221a..420e15965121 100644 --- a/build.rs +++ b/build.rs @@ -7,7 +7,8 @@ fn main() { rustc_minor_nightly().expect("Failed to get rustc version"); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); - let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); + let const_extern_fn_cargo_feature = + env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); if env::var("CARGO_FEATURE_USE_STD").is_ok() { @@ -103,7 +104,8 @@ fn rustc_minor_nightly() -> Option<(u32, bool)> { let minor = pieces.next(); let nightly_raw = otry!(otry!(pieces.next()).split('-').nth(1)); - let nightly = nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly"); + let nightly = + nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly"); let minor = otry!(otry!(minor).parse().ok()); Some((minor, nightly)) diff --git a/tests/const_fn.rs b/tests/const_fn.rs index 4c413c90e8fa..0e7e1864b9f8 100644 --- a/tests/const_fn.rs +++ b/tests/const_fn.rs @@ -1,5 +1,5 @@ #![cfg(libc_const_extern_fn)] // If this does not hold, the file is empty #[cfg(target_os = "linux")] -const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) }; +const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) }; //^ if CMSG_SPACE is not const, this will fail to compile From e8106bd4de072a8578a36686c8e892b7f00d38f2 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Thu, 31 Oct 2019 05:04:04 -0300 Subject: [PATCH 15/61] Implement utmpx.h itens --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 158 ++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index efd0405912b6..c1e64ee20eb9 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -281,9 +281,36 @@ s! { pub msg_hdr: ::msghdr, pub msg_len: ::c_uint, } + + pub struct __exit_status { + pub e_termination: u16, + pub e_exit: u16, + } } s_no_extra_traits! { + + pub struct utmpx { + pub ut_name: [::c_char; _UTX_USERSIZE], + pub ut_id: [::c_char; _UTX_IDSIZE], + pub ut_line: [::c_char; _UTX_LINESIZE], + pub ut_host: [::c_char; _UTX_HOSTSIZE], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: ::pid_t, + pub ut_exit: __exit_status, + pub ut_ss: sockaddr_storage, + pub ut_tv: ::timeval, + pub ut_pad: [u8; _UTX_PADSIZE], + } + + pub struct lastlogx { + pub ll_tv: ::timeval, + pub ll_line: [::c_char; _UTX_LINESIZE], + pub ll_host: [::c_char; _UTX_HOSTSIZE], + pub ll_ss: sockaddr_storage, + } + pub struct in_pktinfo { pub ipi_addr: ::in_addr, pub ipi_ifindex: ::c_uint, @@ -377,6 +404,93 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_name == other.ut_name + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_ss == other.ut_ss + && self.ut_pad == other.ut_pad + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_name", &self.ut_name) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + .field("ut_host", &self.ut_host) + .field("ut_session", &self.ut_session) + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_exit", &self.ut_exit) + .field("ut_ss", &self.ut_ss) + .field("ut_tv", &self.ut_tv) + .field("ut_pad", &self.ut_pad) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_name.hash(state); + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_ss.hash(state); + self.ut_pad.hash(state); + } + } + + impl PartialEq for lastlogx { + fn eq(&self, other: &lastlogx) -> bool { + self.ll_tv == other.ll_tv + && self.ll_line == other.ll_line + && self.ll_host == other.ll_host + && self.ll_ss == other.ll_ss + } + } + + impl Eq for lastlogx {} + + impl ::fmt::Debug for lastlogx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("lastlogx") + .field("ll_tv", &self.ll_tv) + .field("ll_line", &self.ll_line) + .field("ll_host", &self.ll_host) + .field("ll_ss", &self.ll_ss) + .finish() + } + } + + impl ::hash::Hash for lastlogx { + fn hash(&self, state: &mut H) { + self.ll_tv.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + self.ll_ss.hash(state); + } + } + impl PartialEq for in_pktinfo { fn eq(&self, other: &in_pktinfo) -> bool { self.ipi_addr == other.ipi_addr @@ -1378,6 +1492,28 @@ pub const ONLRET: ::tcflag_t = 0x40; pub const CDTRCTS: ::tcflag_t = 0x00020000; pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS; +// pub const _PATH_UTMPX: &[::c_char; 14] = b"/var/run/utmpx"; +// pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx"; +// pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx"; +// pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update"; +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_PADSIZE: usize = 40; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; +pub const EMPTY: u16 = 0; +pub const RUN_LVL: u16 = 1; +pub const BOOT_TIME: u16 = 2; +pub const OLD_TIME: u16 = 3; +pub const NEW_TIME: u16 = 4; +pub const INIT_PROCESS: u16 = 5; +pub const LOGIN_PROCESS: u16 = 6; +pub const USER_PROCESS: u16 = 7; +pub const DEAD_PROCESS: u16 = 8; +pub const ACCOUNTING: u16 = 9; +pub const SIGNATURE: u16 = 10; +pub const DOWN_TIME: u16 = 11; + pub const SOCK_CLOEXEC: ::c_int = 0x10000000; pub const SOCK_NONBLOCK: ::c_int = 0x20000000; @@ -1738,6 +1874,28 @@ extern "C" { buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int; + + pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int; + pub fn getlastlogx( + fname: *const ::c_char, + uid: ::uid_t, + ll: *mut lastlogx, + ) -> *mut lastlogx; + pub fn updlastlogx( + fname: *const ::c_char, + uid: ::uid_t, + ll: *mut lastlogx, + ) -> ::c_int; + pub fn utmpxname(file: *const ::c_char) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + // TODO: uncomment after utmp implementation + // pub fn getutmp(ux: *const utmpx, u: *mut utmp); + // pub fn getutmpx(u: *const utmp, ux: *mut utmpx); } cfg_if! { From 919ba61a0239dc85aa2620c7a4e4a894181b5400 Mon Sep 17 00:00:00 2001 From: patrick felt Date: Thu, 31 Oct 2019 11:32:29 -0600 Subject: [PATCH 16/61] - add ssm struct and setsockopt constants Signed-off-by: patrick felt --- src/unix/linux_like/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1568e4f8369f..1107538d642c 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -24,6 +24,12 @@ s! { pub imr_interface: in_addr, } + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + pub imr_sourceaddr: in_addr, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], @@ -810,6 +816,8 @@ pub const IP_RECVTOS: ::c_int = 13; pub const IP_RECVERR: ::c_int = 11; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 39; +pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 40; pub const IP_TRANSPARENT: ::c_int = 19; pub const IPV6_UNICAST_HOPS: ::c_int = 16; pub const IPV6_MULTICAST_IF: ::c_int = 17; From 98fd3188e7d46db84d321475344f2f82d958b0c7 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Fri, 1 Nov 2019 08:05:13 -0300 Subject: [PATCH 17/61] Implement utmpx to solaris/illumos --- src/unix/solarish/mod.rs | 107 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 49a18367e7e6..cfa92690daf2 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -348,6 +348,11 @@ s! { pub d_descriptor: ::c_int, pub d_id: ::door_id_t } + + pub struct exit_status { + e_termination: ::c_short, + e_exit: ::c_short, + } } s_no_extra_traits! { @@ -357,6 +362,20 @@ s_no_extra_traits! { pub u64: u64, } + pub struct utmpx { + pub ut_user: [::c_char; _UTX_USERSIZE], + pub ut_id: [::c_char; _UTX_IDSIZE], + pub ut_line: [::c_char; _UTX_LINESIZE], + pub ut_pid: ::pid_t, + pub ut_type: ::c_short, + pub ut_exit: exit_status, + pub ut_tv: ::timeval, + pub ut_session: ::c_int, + pub ut_pad: [::c_int; _UTX_PADSIZE], + pub ut_syslen: ::c_short, + pub ut_host: [::c_char; _UTX_HOSTSIZE], + } + pub struct sockaddr_un { pub sun_family: sa_family_t, pub sun_path: [c_char; 108] @@ -434,6 +453,62 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_user == other.ut_user + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_syslen == other.ut_syslen + && self.ut_pad == other.ut_pad + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_user", &self.ut_user) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + .field("ut_pid", &self.ut_pid) + .field("ut_type", &self.ut_type) + .field("ut_exit", &self.ut_exit) + .field("ut_tv", &self.ut_tv) + .field("ut_session", &self.ut_session) + .field("ut_pad", &self.ut_pad) + .field("ut_syslen", &self.ut_syslen) + .field("ut_host", &self.ut_host) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_user.hash(state); + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_syslen.hash(state); + self.ut_pad.hash(state); + } + } + impl PartialEq for epoll_event { fn eq(&self, other: &epoll_event) -> bool { self.events == other.events @@ -1615,6 +1690,23 @@ pub const PORT_SOURCE_FILE: ::c_int = 7; pub const PORT_SOURCE_POSTWAIT: ::c_int = 8; pub const PORT_SOURCE_SIGNAL: ::c_int = 9; +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_PADSIZE: usize = 5; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 257; +pub const EMPTY: ::c_short = 0; +pub const RUN_LVL: ::c_short = 1; +pub const BOOT_TIME: ::c_short = 2; +pub const OLD_TIME: ::c_short = 3; +pub const NEW_TIME: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const USER_PROCESS: ::c_short = 7; +pub const DEAD_PROCESS: ::c_short = 8; +pub const ACCOUNTING: ::c_short = 9; +pub const DOWN_TIME: ::c_short = 10; + const _TIOC: ::c_int = ('T' as i32) << 8; const tIOC: ::c_int = ('t' as i32) << 8; pub const TCGETA: ::c_int = (_TIOC | 1); @@ -2296,6 +2388,21 @@ extern "C" { attributes: door_attr_t, ) -> ::c_int; pub fn fattach(fildes: ::c_int, path: *const ::c_char) -> ::c_int; + + pub fn makeutx(ux: *const utmpx) -> *mut utmpx; + pub fn modutx(ux: *const utmpx) -> *mut utmpx; + pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int; + pub fn utmpxname(file: *const ::c_char) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + // TODO: uncomment after utmp implementation + // pub fn getutmp(ux: *const utmpx, u: *mut utmp); + // pub fn getutmpx(u: *const utmp, ux: *mut utmpx); + // pub fn updwtmp(file: *const ::c_char, u: *mut utmp); } mod compat; From 8aa66cf6d6650513e41b5355f25022f09f0b71af Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Sun, 3 Nov 2019 20:17:15 -0800 Subject: [PATCH 18/61] adds IPV6_ consts for linux --- libc-test/build.rs | 26 ++++++++++++++++++++++++++ src/unix/linux_like/android/mod.rs | 28 +++++++++++++++++++++++++++- src/unix/linux_like/linux/mod.rs | 28 +++++++++++++++++++++++++++- 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index b2512b85d6a9..894b8714b183 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2325,6 +2325,32 @@ fn test_linux(target: &str) { | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" | "IPV6_FLOWINFO_PRIORITY" + + | "IPV6_ADDRFORM" + | "IPV6_2292PKTINFO" + | "IPV6_2292HOPOPTS" + | "IPV6_2292DSTOPTS" + | "IPV6_2292RTHDR" + | "IPV6_2292PKTOPTIONS" + | "IPV6_CHECKSUM" + | "IPV6_2292HOPLIMIT" + | "IPV6_NEXTHOP" + | "IPV6_UNICAST_HOPS" + | "IPV6_MULTICAST_IF" + | "IPV6_MULTICAST_HOPS" + | "IPV6_MULTICAST_LOOP" + | "IPV6_ADD_MEMBERSHIP" + | "IPV6_DROP_MEMBERSHIP" + | "IPV6_ROUTER_ALERT" + | "IPV6_MTU_DISCOVER" + | "IPV6_MTU" + | "IPV6_RECVERR" + | "IPV6_V6ONLY" + | "IPV6_JOIN_ANYCAST" + | "IPV6_LEAVE_ANYCAST" + | "IPV6_MULTICAST_ALL" + | "IPV6_ROUTER_ALERT_ISOLATE" + // The F_ fnctl constants are tested in the `linux_fnctl.rs` tests: | "F_CANCELLK" | "F_ADD_SEALS" diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 4c4a29669b73..f584782e4f73 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1403,11 +1403,37 @@ pub const IP_ORIGDSTADDR: ::c_int = 20; pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR; pub const IPV6_ORIGDSTADDR: ::c_int = 74; pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR; -pub const IPV6_FLOWINFO: ::c_int = 11; pub const IPV6_FLOWLABEL_MGR: ::c_int = 32; pub const IPV6_FLOWINFO_SEND: ::c_int = 33; pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; + +pub const IPV6_ADDRFORM: ::c_int = 1; +pub const IPV6_2292PKTINFO: ::c_int = 2; +pub const IPV6_2292HOPOPTS: ::c_int = 3; +pub const IPV6_2292DSTOPTS: ::c_int = 4; +pub const IPV6_2292RTHDR: ::c_int = 5; +pub const IPV6_2292PKTOPTIONS: ::c_int = 6; +pub const IPV6_CHECKSUM: ::c_int = 7; +pub const IPV6_2292HOPLIMIT: ::c_int = 8; +pub const IPV6_NEXTHOP: ::c_int = 9; +pub const IPV6_FLOWINFO: ::c_int = 11; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_ROUTER_ALERT: ::c_int = 22; +pub const IPV6_MTU_DISCOVER: ::c_int = 23; +pub const IPV6_MTU: ::c_int = 24; +pub const IPV6_RECVERR: ::c_int = 25; +pub const IPV6_V6ONLY: ::c_int = 26; +pub const IPV6_JOIN_ANYCAST: ::c_int = 27; +pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; +pub const IPV6_MULTICAST_ALL: ::c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; + pub const IUTF8: ::tcflag_t = 0x00004000; pub const CMSPAR: ::tcflag_t = 0o10000000000; pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 04d19ea08a68..31e310934121 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1530,11 +1530,37 @@ pub const IP_ORIGDSTADDR: ::c_int = 20; pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR; pub const IPV6_ORIGDSTADDR: ::c_int = 74; pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR; -pub const IPV6_FLOWINFO: ::c_int = 11; pub const IPV6_FLOWLABEL_MGR: ::c_int = 32; pub const IPV6_FLOWINFO_SEND: ::c_int = 33; pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; + +pub const IPV6_ADDRFORM: ::c_int = 1; +pub const IPV6_2292PKTINFO: ::c_int = 2; +pub const IPV6_2292HOPOPTS: ::c_int = 3; +pub const IPV6_2292DSTOPTS: ::c_int = 4; +pub const IPV6_2292RTHDR: ::c_int = 5; +pub const IPV6_2292PKTOPTIONS: ::c_int = 6; +pub const IPV6_CHECKSUM: ::c_int = 7; +pub const IPV6_2292HOPLIMIT: ::c_int = 8; +pub const IPV6_NEXTHOP: ::c_int = 9; +pub const IPV6_FLOWINFO: ::c_int = 11; +pub const IPV6_UNICAST_HOPS: ::c_int = 16; +pub const IPV6_MULTICAST_IF: ::c_int = 17; +pub const IPV6_MULTICAST_HOPS: ::c_int = 18; +pub const IPV6_MULTICAST_LOOP: ::c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_ROUTER_ALERT: ::c_int = 22; +pub const IPV6_MTU_DISCOVER: ::c_int = 23; +pub const IPV6_MTU: ::c_int = 24; +pub const IPV6_RECVERR: ::c_int = 25; +pub const IPV6_V6ONLY: ::c_int = 26; +pub const IPV6_JOIN_ANYCAST: ::c_int = 27; +pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; +pub const IPV6_MULTICAST_ALL: ::c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; + pub const IUTF8: ::tcflag_t = 0x00004000; pub const CMSPAR: ::tcflag_t = 0o10000000000; From d4521cd53f28a5f3a24b49bc3a1eb9d394366129 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Mon, 4 Nov 2019 06:25:53 -0800 Subject: [PATCH 19/61] fixup tests for IPV6_ --- libc-test/build.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 894b8714b183..00f3bf70dff5 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2325,7 +2325,6 @@ fn test_linux(target: &str) { | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" | "IPV6_FLOWINFO_PRIORITY" - | "IPV6_ADDRFORM" | "IPV6_2292PKTINFO" | "IPV6_2292HOPOPTS" @@ -2618,7 +2617,31 @@ fn test_linux_like_apis(target: &str) { | "IPV6_FLOWLABEL_MGR" | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" => false, + | "IPV6_FLOWINFO_PRIORITY" + | "IPV6_ADDRFORM" + | "IPV6_2292PKTINFO" + | "IPV6_2292HOPOPTS" + | "IPV6_2292DSTOPTS" + | "IPV6_2292RTHDR" + | "IPV6_2292PKTOPTIONS" + | "IPV6_CHECKSUM" + | "IPV6_2292HOPLIMIT" + | "IPV6_NEXTHOP" + | "IPV6_UNICAST_HOPS" + | "IPV6_MULTICAST_IF" + | "IPV6_MULTICAST_HOPS" + | "IPV6_MULTICAST_LOOP" + | "IPV6_ADD_MEMBERSHIP" + | "IPV6_DROP_MEMBERSHIP" + | "IPV6_ROUTER_ALERT" + | "IPV6_MTU_DISCOVER" + | "IPV6_MTU" + | "IPV6_RECVERR" + | "IPV6_V6ONLY" + | "IPV6_JOIN_ANYCAST" + | "IPV6_LEAVE_ANYCAST" + | "IPV6_MULTICAST_ALL" + | "IPV6_ROUTER_ALERT_ISOLATE" => false, _ => true, }) .type_name(move |ty, is_struct, is_union| match ty { From d5cdb38ebb2f8d096a4c2914f736a1e02f087174 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 5 Nov 2019 17:41:34 +0000 Subject: [PATCH 20/61] IPV6 consts are shared between android and linux Signed-off-by: Arthur Gautier --- libc-test/build.rs | 3 +-- src/unix/linux_like/android/mod.rs | 26 -------------------------- src/unix/linux_like/linux/mod.rs | 26 -------------------------- src/unix/linux_like/mod.rs | 18 ++++++++++++++++++ 4 files changed, 19 insertions(+), 54 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 00f3bf70dff5..21dd7e443533 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2640,8 +2640,7 @@ fn test_linux_like_apis(target: &str) { | "IPV6_V6ONLY" | "IPV6_JOIN_ANYCAST" | "IPV6_LEAVE_ANYCAST" - | "IPV6_MULTICAST_ALL" - | "IPV6_ROUTER_ALERT_ISOLATE" => false, + | "IPV6_MULTICAST_ALL" => false, _ => true, }) .type_name(move |ty, is_struct, is_union| match ty { diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index f584782e4f73..d34046846447 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1408,32 +1408,6 @@ pub const IPV6_FLOWINFO_SEND: ::c_int = 33; pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; -pub const IPV6_ADDRFORM: ::c_int = 1; -pub const IPV6_2292PKTINFO: ::c_int = 2; -pub const IPV6_2292HOPOPTS: ::c_int = 3; -pub const IPV6_2292DSTOPTS: ::c_int = 4; -pub const IPV6_2292RTHDR: ::c_int = 5; -pub const IPV6_2292PKTOPTIONS: ::c_int = 6; -pub const IPV6_CHECKSUM: ::c_int = 7; -pub const IPV6_2292HOPLIMIT: ::c_int = 8; -pub const IPV6_NEXTHOP: ::c_int = 9; -pub const IPV6_FLOWINFO: ::c_int = 11; -pub const IPV6_UNICAST_HOPS: ::c_int = 16; -pub const IPV6_MULTICAST_IF: ::c_int = 17; -pub const IPV6_MULTICAST_HOPS: ::c_int = 18; -pub const IPV6_MULTICAST_LOOP: ::c_int = 19; -pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; -pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; -pub const IPV6_ROUTER_ALERT: ::c_int = 22; -pub const IPV6_MTU_DISCOVER: ::c_int = 23; -pub const IPV6_MTU: ::c_int = 24; -pub const IPV6_RECVERR: ::c_int = 25; -pub const IPV6_V6ONLY: ::c_int = 26; -pub const IPV6_JOIN_ANYCAST: ::c_int = 27; -pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; -pub const IPV6_MULTICAST_ALL: ::c_int = 29; -pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; - pub const IUTF8: ::tcflag_t = 0x00004000; pub const CMSPAR: ::tcflag_t = 0o10000000000; pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 31e310934121..e7473d417a74 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1535,32 +1535,6 @@ pub const IPV6_FLOWINFO_SEND: ::c_int = 33; pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff; pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000; -pub const IPV6_ADDRFORM: ::c_int = 1; -pub const IPV6_2292PKTINFO: ::c_int = 2; -pub const IPV6_2292HOPOPTS: ::c_int = 3; -pub const IPV6_2292DSTOPTS: ::c_int = 4; -pub const IPV6_2292RTHDR: ::c_int = 5; -pub const IPV6_2292PKTOPTIONS: ::c_int = 6; -pub const IPV6_CHECKSUM: ::c_int = 7; -pub const IPV6_2292HOPLIMIT: ::c_int = 8; -pub const IPV6_NEXTHOP: ::c_int = 9; -pub const IPV6_FLOWINFO: ::c_int = 11; -pub const IPV6_UNICAST_HOPS: ::c_int = 16; -pub const IPV6_MULTICAST_IF: ::c_int = 17; -pub const IPV6_MULTICAST_HOPS: ::c_int = 18; -pub const IPV6_MULTICAST_LOOP: ::c_int = 19; -pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; -pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; -pub const IPV6_ROUTER_ALERT: ::c_int = 22; -pub const IPV6_MTU_DISCOVER: ::c_int = 23; -pub const IPV6_MTU: ::c_int = 24; -pub const IPV6_RECVERR: ::c_int = 25; -pub const IPV6_V6ONLY: ::c_int = 26; -pub const IPV6_JOIN_ANYCAST: ::c_int = 27; -pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; -pub const IPV6_MULTICAST_ALL: ::c_int = 29; -pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; - pub const IUTF8: ::tcflag_t = 0x00004000; pub const CMSPAR: ::tcflag_t = 0o10000000000; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1568e4f8369f..2b8107da17a2 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -811,13 +811,31 @@ pub const IP_RECVERR: ::c_int = 11; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; pub const IP_TRANSPARENT: ::c_int = 19; +pub const IPV6_ADDRFORM: ::c_int = 1; +pub const IPV6_2292PKTINFO: ::c_int = 2; +pub const IPV6_2292HOPOPTS: ::c_int = 3; +pub const IPV6_2292DSTOPTS: ::c_int = 4; +pub const IPV6_2292RTHDR: ::c_int = 5; +pub const IPV6_2292PKTOPTIONS: ::c_int = 6; +pub const IPV6_CHECKSUM: ::c_int = 7; +pub const IPV6_2292HOPLIMIT: ::c_int = 8; +pub const IPV6_NEXTHOP: ::c_int = 9; +pub const IPV6_FLOWINFO: ::c_int = 11; pub const IPV6_UNICAST_HOPS: ::c_int = 16; pub const IPV6_MULTICAST_IF: ::c_int = 17; pub const IPV6_MULTICAST_HOPS: ::c_int = 18; pub const IPV6_MULTICAST_LOOP: ::c_int = 19; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; +pub const IPV6_ROUTER_ALERT: ::c_int = 22; +pub const IPV6_MTU_DISCOVER: ::c_int = 23; +pub const IPV6_MTU: ::c_int = 24; +pub const IPV6_RECVERR: ::c_int = 25; pub const IPV6_V6ONLY: ::c_int = 26; +pub const IPV6_JOIN_ANYCAST: ::c_int = 27; +pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; +pub const IPV6_MULTICAST_ALL: ::c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; pub const IPV6_RECVPKTINFO: ::c_int = 49; pub const IPV6_PKTINFO: ::c_int = 50; pub const IPV6_RECVTCLASS: ::c_int = 66; From 5e9c38f1f8230209518409da2bf289df933dc109 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 5 Nov 2019 19:12:39 +0000 Subject: [PATCH 21/61] no need for new tests Signed-off-by: Arthur Gautier --- libc-test/build.rs | 50 +--------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 21dd7e443533..b2512b85d6a9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2325,31 +2325,6 @@ fn test_linux(target: &str) { | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" | "IPV6_FLOWINFO_PRIORITY" - | "IPV6_ADDRFORM" - | "IPV6_2292PKTINFO" - | "IPV6_2292HOPOPTS" - | "IPV6_2292DSTOPTS" - | "IPV6_2292RTHDR" - | "IPV6_2292PKTOPTIONS" - | "IPV6_CHECKSUM" - | "IPV6_2292HOPLIMIT" - | "IPV6_NEXTHOP" - | "IPV6_UNICAST_HOPS" - | "IPV6_MULTICAST_IF" - | "IPV6_MULTICAST_HOPS" - | "IPV6_MULTICAST_LOOP" - | "IPV6_ADD_MEMBERSHIP" - | "IPV6_DROP_MEMBERSHIP" - | "IPV6_ROUTER_ALERT" - | "IPV6_MTU_DISCOVER" - | "IPV6_MTU" - | "IPV6_RECVERR" - | "IPV6_V6ONLY" - | "IPV6_JOIN_ANYCAST" - | "IPV6_LEAVE_ANYCAST" - | "IPV6_MULTICAST_ALL" - | "IPV6_ROUTER_ALERT_ISOLATE" - // The F_ fnctl constants are tested in the `linux_fnctl.rs` tests: | "F_CANCELLK" | "F_ADD_SEALS" @@ -2617,30 +2592,7 @@ fn test_linux_like_apis(target: &str) { | "IPV6_FLOWLABEL_MGR" | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" - | "IPV6_ADDRFORM" - | "IPV6_2292PKTINFO" - | "IPV6_2292HOPOPTS" - | "IPV6_2292DSTOPTS" - | "IPV6_2292RTHDR" - | "IPV6_2292PKTOPTIONS" - | "IPV6_CHECKSUM" - | "IPV6_2292HOPLIMIT" - | "IPV6_NEXTHOP" - | "IPV6_UNICAST_HOPS" - | "IPV6_MULTICAST_IF" - | "IPV6_MULTICAST_HOPS" - | "IPV6_MULTICAST_LOOP" - | "IPV6_ADD_MEMBERSHIP" - | "IPV6_DROP_MEMBERSHIP" - | "IPV6_ROUTER_ALERT" - | "IPV6_MTU_DISCOVER" - | "IPV6_MTU" - | "IPV6_RECVERR" - | "IPV6_V6ONLY" - | "IPV6_JOIN_ANYCAST" - | "IPV6_LEAVE_ANYCAST" - | "IPV6_MULTICAST_ALL" => false, + | "IPV6_FLOWINFO_PRIORITY" => false, _ => true, }) .type_name(move |ty, is_struct, is_union| match ty { From f3064f37845c7d3da8d99678851e2f5243b09bc2 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 5 Nov 2019 20:08:18 +0000 Subject: [PATCH 22/61] IPV6_ROUTER_ALERT_ISOLATE looks too recent for test env Signed-off-by: Arthur Gautier --- src/unix/linux_like/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 2b8107da17a2..b5c029e79696 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -835,7 +835,6 @@ pub const IPV6_V6ONLY: ::c_int = 26; pub const IPV6_JOIN_ANYCAST: ::c_int = 27; pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; pub const IPV6_MULTICAST_ALL: ::c_int = 29; -pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; pub const IPV6_RECVPKTINFO: ::c_int = 49; pub const IPV6_PKTINFO: ::c_int = 50; pub const IPV6_RECVTCLASS: ::c_int = 66; From 44b7a20329ef9cc6b7d33b64d88de45b67acc520 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 5 Nov 2019 21:29:44 +0000 Subject: [PATCH 23/61] IPV6_MULTICAST_ALL is too recent for aarch64 test env Signed-off-by: Arthur Gautier --- src/unix/linux_like/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index b5c029e79696..1fca7c419ce6 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -834,7 +834,6 @@ pub const IPV6_RECVERR: ::c_int = 25; pub const IPV6_V6ONLY: ::c_int = 26; pub const IPV6_JOIN_ANYCAST: ::c_int = 27; pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; -pub const IPV6_MULTICAST_ALL: ::c_int = 29; pub const IPV6_RECVPKTINFO: ::c_int = 49; pub const IPV6_PKTINFO: ::c_int = 50; pub const IPV6_RECVTCLASS: ::c_int = 66; From 6ff2e8f12dcfa75c3ce24c275cb2f2426f1ae259 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 5 Nov 2019 21:32:27 +0000 Subject: [PATCH 24/61] IPV6_FLOWINFO does not work with asmjs Signed-off-by: Arthur Gautier --- src/unix/linux_like/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1fca7c419ce6..545c05304b2a 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -820,7 +820,6 @@ pub const IPV6_2292PKTOPTIONS: ::c_int = 6; pub const IPV6_CHECKSUM: ::c_int = 7; pub const IPV6_2292HOPLIMIT: ::c_int = 8; pub const IPV6_NEXTHOP: ::c_int = 9; -pub const IPV6_FLOWINFO: ::c_int = 11; pub const IPV6_UNICAST_HOPS: ::c_int = 16; pub const IPV6_MULTICAST_IF: ::c_int = 17; pub const IPV6_MULTICAST_HOPS: ::c_int = 18; From 53ce57eae741ac0db7c315ea0b4353f18d3067fa Mon Sep 17 00:00:00 2001 From: Petr Sumbera Date: Wed, 6 Nov 2019 10:42:51 +0100 Subject: [PATCH 25/61] Add support for shared memory operations for solaris/illumos This is needed because Firefox now uses slice-deque rust crate. --- src/unix/solarish/mod.rs | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 49a18367e7e6..578a5270f7da 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -34,6 +34,7 @@ pub type nl_item = ::c_int; pub type mqd_t = *mut ::c_void; pub type id_t = ::c_int; pub type idtype_t = ::c_uint; +pub type shmatt_t = ::c_ulong; pub type door_attr_t = ::c_uint; pub type door_id_t = ::c_ulonglong; @@ -57,6 +58,16 @@ s! { pub imr_interface: in_addr, } + pub struct ipc_perm { + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + pub seq: ::c_uint, + pub key: ::key_t, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], @@ -206,6 +217,24 @@ s! { pub ai_next: *mut addrinfo, } + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: ::size_t, + pub shm_flags: ::uintptr_t, + pub shm_lkcnt: ::c_ushort, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_cnattch: ::c_ulong, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_amp: *mut ::c_void, + pub shm_gransize: u64, + pub shm_allocated: u64, + pub shm_pad4: [i64; 1], + } + pub struct sigset_t { bits: [u32; 4], } @@ -1352,6 +1381,16 @@ pub const IFF_VIRTUAL: ::c_longlong = 0x2000000000; // Cannot send/receive pkts pub const IFF_DUPLICATE: ::c_longlong = 0x4000000000; // Local address in use pub const IFF_IPMP: ::c_longlong = 0x8000000000; // IPMP IP interface +// sys/ipc.h: +pub const IPC_ALLOC: ::c_int = 0x8000; +pub const IPC_CREAT: ::c_int = 0x200; +pub const IPC_EXCL: ::c_int = 0x400; +pub const IPC_NOWAIT: ::c_int = 0x800; +pub const IPC_PRIVATE: key_t = 0; +pub const IPC_RMID: ::c_int = 10; +pub const IPC_SET: ::c_int = 11; +pub const IPC_SEAT: ::c_int = 12; + pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; @@ -2011,6 +2050,16 @@ extern "C" { advice: ::c_int, ) -> ::c_int; + pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, + shmflg: ::c_int) -> *mut ::c_void; + + pub fn shmctl(shmid: ::c_int, cmd: ::c_int, + buf: *mut ::shmid_ds) -> ::c_int; + + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + + pub fn shmget(key: key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn shm_open( name: *const ::c_char, oflag: ::c_int, From a7c0dcf5dac9efac0a25f4b253b12109b4980f04 Mon Sep 17 00:00:00 2001 From: Petr Sumbera Date: Wed, 6 Nov 2019 11:25:58 +0100 Subject: [PATCH 26/61] Add missing MAP_ANONYMOUS for Solaris --- src/unix/solarish/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 578a5270f7da..d0611d9eba7a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1010,6 +1010,7 @@ pub const MAP_PRIVATE: ::c_int = 0x0002; pub const MAP_FIXED: ::c_int = 0x0010; pub const MAP_NORESERVE: ::c_int = 0x40; pub const MAP_ANON: ::c_int = 0x0100; +pub const MAP_ANONYMOUS: ::c_int = 0x0100; pub const MAP_RENAME: ::c_int = 0x20; pub const MAP_ALIGN: ::c_int = 0x200; pub const MAP_TEXT: ::c_int = 0x400; From 487b454d9f8c73b6a611d85d1e7d6820fece9938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Thu, 7 Nov 2019 08:25:22 +0100 Subject: [PATCH 27/61] add shm support for NetBSD and OpenBSD initial work from @landryb for OpenBSD, various fixes and NetBSD support from me. Fixes #1585 --- libc-test/build.rs | 2 ++ src/unix/bsd/netbsdlike/mod.rs | 35 ++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 13 ++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 15 +++++++++++ 4 files changed, 65 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index b2512b85d6a9..4ca79d72c1dc 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -322,6 +322,7 @@ fn test_openbsd(target: &str) { "ufs/ufs/quota.h", "pthread_np.h", "sys/syscall.h", + "sys/shm.h", } cfg.skip_struct(move |ty| { @@ -818,6 +819,7 @@ fn test_netbsd(target: &str) { "netinet/dccp.h", "sys/event.h", "sys/quota.h", + "sys/shm.h", } cfg.type_name(move |ty, is_struct, is_union| { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 5ce68e2c17fa..970cb233a191 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -10,6 +10,7 @@ pub type nl_item = c_long; pub type clockid_t = ::c_int; pub type id_t = u32; pub type sem_t = *mut sem; +pub type key_t = c_long; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} @@ -63,6 +64,16 @@ s! { pub l_type: ::c_short, pub l_whence: ::c_short, } + + pub struct ipc_perm { + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mode: ::mode_t, + pub seq: ::c_ushort, + pub key: ::key_t, + } } pub const D_T_FMT: ::nl_item = 0; @@ -199,9 +210,20 @@ pub const MAP_SHARED: ::c_int = 0x0001; pub const MAP_PRIVATE: ::c_int = 0x0002; pub const MAP_FIXED: ::c_int = 0x0010; pub const MAP_ANON: ::c_int = 0x1000; +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; +pub const IPC_CREAT: ::c_int = 0o001000; +pub const IPC_EXCL: ::c_int = 0o002000; +pub const IPC_NOWAIT: ::c_int = 0o004000; + +pub const IPC_PRIVATE: ::key_t = 0; + +pub const IPC_RMID: ::c_int = 0; +pub const IPC_SET: ::c_int = 1; +pub const IPC_STAT: ::c_int = 2; + pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -715,6 +737,19 @@ extern "C" { pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn uname(buf: *mut ::utsname) -> ::c_int; + + pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index efd0405912b6..a5a2fc61d507 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -9,6 +9,7 @@ pub type mqd_t = ::c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; pub type vm_size_t = ::uintptr_t; pub type lwpid_t = ::c_uint; +pub type shmatt_t = ::c_uint; impl siginfo_t { pub unsafe fn si_value(&self) -> ::sigval { @@ -281,6 +282,18 @@ s! { pub msg_hdr: ::msghdr, pub msg_len: ::c_uint, } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + _shm_internal: *mut ::c_void, + } } s_no_extra_traits! { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index f70fddf59ceb..0f9dd04f23fb 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -306,6 +306,21 @@ s! { pub ar_pln: u8, pub ar_op: u16, } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::c_int, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::c_short, + pub shm_atime: ::time_t, + __shm_atimensec: c_long, + pub shm_dtime: ::time_t, + __shm_dtimensec: c_long, + pub shm_ctime: ::time_t, + __shm_ctimensec: c_long, + pub shm_internal: *mut ::c_void, + } } impl siginfo_t { From 0910f3b2fcdf7745494e561cfbd679c724b60964 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 13 Nov 2019 11:11:26 +0100 Subject: [PATCH 28/61] Disable broken targets --- ci/azure.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ci/azure.yml b/ci/azure.yml index 97f13c9da357..da25a268db62 100644 --- a/ci/azure.yml +++ b/ci/azure.yml @@ -46,8 +46,10 @@ jobs: TARGET: arm-unknown-linux-gnueabihf arm-unknown-linux-musleabihf: TARGET: arm-unknown-linux-musleabihf - asmjs-unknown-emscripten: - TARGET: asmjs-unknown-emscripten + # Disabled because currently broken, see: + # https://github.com/rust-lang/libc/issues/1591 + # asmjs-unknown-emscripten: + # TARGET: asmjs-unknown-emscripten i686-linux-android: TARGET: i686-linux-android i686-unknown-linux-musl: @@ -74,8 +76,10 @@ jobs: # TARGET: wasm32-wasi sparc64-unknown-linux-gnu: TARGET: sparc64-unknown-linux-gnu - wasm32-unknown-emscripten: - TARGET: wasm32-unknown-emscripten + # Disabled because currently broken, see: + # https://github.com/rust-lang/libc/issues/1591 + # wasm32-unknown-emscripten: + # TARGET: wasm32-unknown-emscripten x86_64-linux-android: TARGET: x86_64-linux-android x86_64-unknown-linux-gnux32: @@ -122,10 +126,12 @@ jobs: ARCH: x86_64 x86_64-pc-windows-msvc: TARGET: x86_64-pc-windows-msvc - i686-pc-windows-gnu: - TARGET: i686-pc-windows-gnu - ARCH_BITS: 32 - ARCH: i686 + # Disabled because broken: + # https://github.com/rust-lang/libc/issues/1592 + #i686-pc-windows-gnu: + # TARGET: i686-pc-windows-gnu + # ARCH_BITS: 32 + # ARCH: i686 i686-pc-windows-msvc: TARGET: i686-pc-windows-msvc From e6a7fb663779c14f553428a432a419c194af1a93 Mon Sep 17 00:00:00 2001 From: Mike Zeller Date: Thu, 14 Nov 2019 20:46:05 +0000 Subject: [PATCH 29/61] Add illumos 3socket flags --- src/unix/solarish/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 49a18367e7e6..d7aebc1ed51d 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1803,6 +1803,11 @@ pub const VLNEXT: usize = 15; pub const VSTATUS: usize = 16; pub const VERASE2: usize = 17; +// 3SOCKET flags +pub const SOCK_CLOEXEC: ::c_int = 0x080000; +pub const SOCK_NONBLOCK: ::c_int = 0x100000; +pub const SOCK_NDELAY: ::c_int = 0x200000; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; From 60a2167702a6780d6e63d571f6861a2af38889dc Mon Sep 17 00:00:00 2001 From: Brandon Cheng Date: Sun, 6 Oct 2019 13:19:49 -0400 Subject: [PATCH 30/61] Add extended IFLA_ consts Only Netlink interface link attributes up IFLA_STATS are currently available. This commit adds IFLA_COST to IFLA_PROTO_DOWN. See https://github.com/torvalds/linux/blob/54ecb8f7/include/uapi/linux/if_link.h#L106 --- src/unix/linux_like/linux/mod.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 04d19ea08a68..053f16efa46e 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1127,6 +1127,38 @@ pub const IFLA_MTU: ::c_ushort = 4; pub const IFLA_LINK: ::c_ushort = 5; pub const IFLA_QDISC: ::c_ushort = 6; pub const IFLA_STATS: ::c_ushort = 7; +pub const IFLA_COST: ::c_ushort = 8; +pub const IFLA_PRIORITY: ::c_ushort = 9; +pub const IFLA_MASTER: ::c_ushort = 10; +pub const IFLA_WIRELESS: ::c_ushort = 11; +pub const IFLA_PROTINFO: ::c_ushort = 12; +pub const IFLA_TXQLEN: ::c_ushort = 13; +pub const IFLA_MAP: ::c_ushort = 14; +pub const IFLA_WEIGHT: ::c_ushort = 15; +pub const IFLA_OPERSTATE: ::c_ushort = 16; +pub const IFLA_LINKMODE: ::c_ushort = 17; +pub const IFLA_LINKINFO: ::c_ushort = 18; +pub const IFLA_NET_NS_PID: ::c_ushort = 19; +pub const IFLA_IFALIAS: ::c_ushort = 20; +pub const IFLA_NUM_VF: ::c_ushort = 21; +pub const IFLA_VFINFO_LIST: ::c_ushort = 22; +pub const IFLA_STATS64: ::c_ushort = 23; +pub const IFLA_VF_PORTS: ::c_ushort = 24; +pub const IFLA_PORT_SELF: ::c_ushort = 25; +pub const IFLA_AF_SPEC: ::c_ushort = 26; +pub const IFLA_GROUP: ::c_ushort = 27; +pub const IFLA_NET_NS_FD: ::c_ushort = 28; +pub const IFLA_EXT_MASK: ::c_ushort = 29; +pub const IFLA_PROMISCUITY: ::c_ushort = 30; +pub const IFLA_NUM_TX_QUEUES: ::c_ushort = 31; +pub const IFLA_NUM_RX_QUEUES: ::c_ushort = 32; +pub const IFLA_CARRIER: ::c_ushort = 33; +pub const IFLA_PHYS_PORT_ID: ::c_ushort = 34; +pub const IFLA_CARRIER_CHANGES: ::c_ushort = 35; +pub const IFLA_PHYS_SWITCH_ID: ::c_ushort = 36; +pub const IFLA_LINK_NETNSID: ::c_ushort = 37; +pub const IFLA_PHYS_PORT_NAME: ::c_ushort = 38; +pub const IFLA_PROTO_DOWN: ::c_ushort = 39; pub const IFLA_INFO_UNSPEC: ::c_ushort = 0; pub const IFLA_INFO_KIND: ::c_ushort = 1; From 1f7352ca3dc3dd4717d24267ec56cca85def0a40 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Tue, 29 Oct 2019 00:56:52 +0000 Subject: [PATCH 31/61] Deprecate vfork --- src/unix/linux_like/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1568e4f8369f..f673408edb4c 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1458,6 +1458,10 @@ extern "C" { pub fn acct(filename: *const ::c_char) -> ::c_int; pub fn brk(addr: *mut ::c_void) -> ::c_int; pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; + #[deprecated( + since = "0.2.66", + note = "causes memory corruption, see rust-lang/libc#1596" + )] pub fn vfork() -> ::pid_t; pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; From e7936addfb5fb06abc030595bd1388d347c728a4 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Sun, 17 Nov 2019 21:16:54 +0100 Subject: [PATCH 32/61] fixup! nfnetlink & nfnetlink_log constants --- src/unix/linux_like/android/mod.rs | 4 ---- src/unix/linux_like/linux/mod.rs | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index fc515dc870a2..09a934cca7d6 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1319,7 +1319,6 @@ pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5; pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6; pub const NFNLGRP_NFTABLES: ::c_int = 7; pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8; -pub const NFNLGRP_NFTRACE: ::c_int = 9; pub const NFNETLINK_V0: ::c_int = 0; @@ -1337,9 +1336,6 @@ pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10; pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11; pub const NFNL_SUBSYS_COUNT: ::c_int = 12; -pub const NFNL_BATCH_UNSPEC: ::c_int = 0; -pub const NFNL_BATCH_GENID: ::c_int = 1; - pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE; pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 144d7beee63c..3488c5bb186f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1674,7 +1674,6 @@ pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5; pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6; pub const NFNLGRP_NFTABLES: ::c_int = 7; pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8; -pub const NFNLGRP_NFTRACE: ::c_int = 9; pub const NFNETLINK_V0: ::c_int = 0; @@ -1692,9 +1691,6 @@ pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10; pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11; pub const NFNL_SUBSYS_COUNT: ::c_int = 12; -pub const NFNL_BATCH_UNSPEC: ::c_int = 0; -pub const NFNL_BATCH_GENID: ::c_int = 1; - pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE; pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1; From 9f1cbfa88a149a9e0142e536289c71954bac7a38 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Tue, 19 Nov 2019 00:28:16 -0300 Subject: [PATCH 33/61] Run rustfmt --- src/unix/solarish/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index cfa92690daf2..9df92b778874 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2399,10 +2399,10 @@ extern "C" { pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn setutxent(); pub fn endutxent(); - // TODO: uncomment after utmp implementation - // pub fn getutmp(ux: *const utmpx, u: *mut utmp); - // pub fn getutmpx(u: *const utmp, ux: *mut utmpx); - // pub fn updwtmp(file: *const ::c_char, u: *mut utmp); +// TODO: uncomment after utmp implementation +// pub fn getutmp(ux: *const utmpx, u: *mut utmp); +// pub fn getutmpx(u: *const utmp, ux: *mut utmpx); +// pub fn updwtmp(file: *const ::c_char, u: *mut utmp); } mod compat; From b14e947de37335b49cc12e4b51faf30cf455743b Mon Sep 17 00:00:00 2001 From: oxalica Date: Sun, 10 Nov 2019 20:08:22 +0800 Subject: [PATCH 34/61] Upgrade to musl 1.1.24 in CI --- ci/docker/mips-unknown-linux-musl/Dockerfile | 25 ++++++++++------ .../mipsel-unknown-linux-musl/Dockerfile | 27 ++++++++++------- ci/install-musl.sh | 2 +- ci/sysinfo_guard.patch | 10 +++++++ libc-test/build.rs | 29 ++++++++++--------- 5 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 ci/sysinfo_guard.patch diff --git a/ci/docker/mips-unknown-linux-musl/Dockerfile b/ci/docker/mips-unknown-linux-musl/Dockerfile index f1a1076cb5a1..a1ec7ff94650 100644 --- a/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -2,16 +2,23 @@ FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ - bzip2 + xz-utils patch RUN mkdir /toolchain -# Note that this originally came from: -# https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 -RUN curl --retry 5 -L https://ci-mirrors.rust-lang.org/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ - tar xjf - -C /toolchain --strip-components=1 +# Linux kernel version: 4.14.151 +# See build_dir/target-mips_24kc_musl/linux-ar71xx_generic/linux-4.14.151 +# Musl version: 1.1.24 +# See staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/info.mk +RUN curl --retry 5 -L https://downloads.openwrt.org/releases/19.07.0-rc1/targets/ar71xx/generic/openwrt-sdk-19.07.0-rc1-ar71xx-generic_gcc-7.4.0_musl.Linux-x86_64.tar.xz | \ + tar xJf - -C /toolchain --strip-components=1 -ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ - CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ - CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc \ - CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15" +# See https://lkml.org/lkml/2014/3/14/269 +COPY sysinfo_guard.patch /toolchain +RUN patch /toolchain/staging_dir/toolchain-mips_24kc_gcc-7.4.0_musl/include/linux/kernel.h ++#endif + + /* + * 'kernel.h' contains some often-used function prototypes etc diff --git a/libc-test/build.rs b/libc-test/build.rs index 4ca79d72c1dc..e943b9960c3a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2061,7 +2061,6 @@ fn test_linux(target: &str) { let i686 = target.contains("i686"); let mips = target.contains("mips"); let mips32 = mips && !target.contains("64"); - let mips32_musl = mips32 && musl; let mips64 = mips && target.contains("64"); let ppc64 = target.contains("powerpc64"); let s390x = target.contains("s390x"); @@ -2069,6 +2068,7 @@ fn test_linux(target: &str) { let x32 = target.contains("x32"); let x86_32 = target.contains("i686"); let x86_64 = target.contains("x86_64"); + let aarch64_musl = target.contains("aarch64") && musl; let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); @@ -2132,8 +2132,7 @@ fn test_linux(target: &str) { "sys/prctl.h", "sys/ptrace.h", "sys/quota.h", - // FIXME: the mips-musl CI build jobs use ancient musl 1.0.15: - [!mips32_musl]: "sys/random.h", + "sys/random.h", "sys/reboot.h", "sys/resource.h", "sys/sem.h", @@ -2187,8 +2186,7 @@ fn test_linux(target: &str) { "linux/fs.h", "linux/futex.h", "linux/genetlink.h", - // FIXME: musl version 1.0.15 used by mips build jobs is ancient - [!mips32_musl]: "linux/if.h", + "linux/if.h", "linux/if_addr.h", "linux/if_alg.h", "linux/if_ether.h", @@ -2303,9 +2301,6 @@ fn test_linux(target: &str) { // structs. "termios2" => true, - // FIXME: musl version using by mips build jobs 1.0.15 is ancient: - "ifmap" | "ifreq" | "ifconf" if mips32_musl => true, - // FIXME: remove once Ubuntu 20.04 LTS is released, somewhere in 2020. // ucontext_t added a new field as of glibc 2.28; our struct definition is // conservative and omits the field, but that means the size doesn't match for newer @@ -2349,7 +2344,7 @@ fn test_linux(target: &str) { // Require Linux kernel 5.1: "F_SEAL_FUTURE_WRITE" => true, - // The musl version 1.0.22 used in CI does not + // The musl version 1.1.24 used in CI does not // contain these glibc constants yet: | "RLIMIT_RTTIME" // should be in `resource.h` | "TCP_COOKIE_TRANSACTIONS" // should be in the `netinet/tcp.h` header @@ -2371,10 +2366,6 @@ fn test_linux(target: &str) { // - these constants are used by the glibc implementation. n if musl && n.contains("__SIZEOF_PTHREAD") => true, - // FIXME: musl version 1.0.15 used by mips build jobs is ancient - t if mips32_musl && t.starts_with("IFF") => true, - "MFD_HUGETLB" | "AF_XDP" | "PF_XDP" if mips32_musl => true, - _ => false, } }); @@ -2458,7 +2449,17 @@ fn test_linux(target: &str) { field == "_pad2" || field == "ssi_syscall" || field == "ssi_call_addr" || - field == "ssi_arch")) + field == "ssi_arch")) || + // FIXME: After musl 1.1.24, it have only one field `sched_priority`, + // while other fields become reserved. + (struct_ == "sched_param" && [ + "sched_ss_low_priority", + "sched_ss_repl_period", + "sched_ss_init_budget", + "sched_ss_max_repl", + ].contains(&field) && musl) || + // FIXME: After musl 1.1.24, the type becomes `int` instead of `unsigned short`. + (struct_ == "ipc_perm" && field == "__seq" && aarch64_musl) }); cfg.skip_roundtrip(move |s| match s { From 863e106543128dfaf6812e5554eb6089851f8ec2 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Tue, 19 Nov 2019 03:22:08 -0300 Subject: [PATCH 35/61] Run rustfmt --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index b03cfdd9fbd3..2f48aac5511f 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1907,9 +1907,9 @@ extern "C" { pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn setutxent(); pub fn endutxent(); - // TODO: uncomment after utmp implementation - // pub fn getutmp(ux: *const utmpx, u: *mut utmp); - // pub fn getutmpx(u: *const utmp, ux: *mut utmpx); +// TODO: uncomment after utmp implementation +// pub fn getutmp(ux: *const utmpx, u: *mut utmp); +// pub fn getutmpx(u: *const utmp, ux: *mut utmpx); } cfg_if! { From 7022df3dbf22ead59a0fa315aed2a72e82dedebc Mon Sep 17 00:00:00 2001 From: Yang Keao Date: Tue, 19 Nov 2019 15:29:31 +0800 Subject: [PATCH 36/61] add pthread_getname_np for mac os Signed-off-by: Yang Keao --- src/unix/bsd/apple/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index fa3ba81b0bd9..aa3cc1ca1c73 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3237,6 +3237,11 @@ extern "C" { #[allow(deprecated)] pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; + pub fn pthread_getname_np( + thread: ::pthread_t, + name: *mut ::c_char, + len: ::size_t, + ) -> ::c_int; pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void; pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t; pub fn pthread_condattr_setpshared( From 40f9253fc995620f038572a90941b82c290f138d Mon Sep 17 00:00:00 2001 From: GrayJack Date: Tue, 19 Nov 2019 06:10:36 -0300 Subject: [PATCH 37/61] Fix style error that `cargo fmt` didn't got --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 2f48aac5511f..000ce4431006 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -283,7 +283,6 @@ s! { pub msg_len: ::c_uint, } - pub struct __exit_status { pub e_termination: u16, pub e_exit: u16, From 5d3c5b9d40ff6bcb125ab4334f201c00cad178c1 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Wed, 20 Nov 2019 12:38:29 -0300 Subject: [PATCH 38/61] Fix the PartialEq utmpx impl --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 000ce4431006..69c1efbbcd1a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -428,7 +428,11 @@ cfg_if! { && self.ut_session == other.ut_session && self.ut_tv == other.ut_tv && self.ut_ss == other.ut_ss - && self.ut_pad == other.ut_pad + && self + .ut_pad + .iter() + .zip(other.ut_pad.iter()) + .all(|(a,b)| a == b) && self .ut_host .iter() From f10ee11f7043cb38fff02d9085b26009f2fc66aa Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 20 Nov 2019 13:08:27 -0500 Subject: [PATCH 39/61] Fix build.rs failing with a rustc built from a tarball Fixes #1601 --- build.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 420e15965121..f447c0ef9cd4 100644 --- a/build.rs +++ b/build.rs @@ -103,9 +103,16 @@ fn rustc_minor_nightly() -> Option<(u32, bool)> { } let minor = pieces.next(); - let nightly_raw = otry!(otry!(pieces.next()).split('-').nth(1)); - let nightly = - nightly_raw.starts_with("dev") || nightly_raw.starts_with("nightly"); + + // If `rustc` was built from a tarball, its version string + // will have neither a git hash nor a commit date + // (e.g. "rustc 1.39.0"). Treat this case as non-nightly, + // since a nightly build should either come from CI + // or a git checkout + let nightly_raw = otry!(pieces.next()).split('-').nth(1); + let nightly = nightly_raw + .map(|raw| raw.starts_with("dev") || raw.starts_with("nightly")) + .unwrap_or(false); let minor = otry!(otry!(minor).parse().ok()); Some((minor, nightly)) From c70634e4866f668a77260997c8bd7716b8905cdd Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Fri, 18 Oct 2019 15:46:38 +0300 Subject: [PATCH 40/61] Add flock64 to linux_like platforms --- src/unix/linux_like/android/mod.rs | 10 ++++++++++ src/unix/linux_like/emscripten/mod.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b32/powerpc.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b64/mips64/mod.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b64/s390x.rs | 8 ++++++++ src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs | 9 +++++++++ src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 8 ++++++++ src/unix/linux_like/linux/musl/mod.rs | 2 ++ 12 files changed, 93 insertions(+) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 4c4a29669b73..356fec29c8db 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -22,6 +22,8 @@ pub type ino_t = ::c_ulong; pub type __CPU_BITTYPE = ::c_ulong; pub type idtype_t = ::c_int; pub type loff_t = ::c_longlong; +pub type __kernel_loff_t = ::c_longlong; +pub type __kernel_pid_t = ::c_int; s! { pub struct stack_t { @@ -78,6 +80,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::__kernel_loff_t, + pub l_len: ::__kernel_loff_t, + pub l_pid: ::__kernel_pid_t, + } + pub struct cpu_set_t { #[cfg(target_pointer_width = "64")] __bits: [__CPU_BITTYPE; 16], diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index d062b98f41c4..3fc47bb5ebab 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -223,6 +223,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct pthread_attr_t { __size: [u32; 11] } diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index f74b41e31567..0a5fc8567b57 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -33,6 +33,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 92e52333cad1..7644428014f1 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -33,6 +33,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct ipc_perm { __key: ::key_t, pub uid: ::uid_t, diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 05e876067dd8..f5f7cac4c5ac 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -34,6 +34,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct _libc_fpreg { pub significand: [u16; 4], pub exponent: u16, diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index b980a11b1911..13d9aaf05a6c 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -45,6 +45,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 5b3da3cb2dc9..2b77aa4b3db5 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -57,6 +57,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct stat64 { pub st_dev: ::c_ulong, st_pad1: [::c_long; 2], diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index bd9089543afd..22507d72f326 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -45,6 +45,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index ac3170416024..403e4578d99b 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -44,6 +44,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 93b1fa534917..651ada376eec 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -60,6 +60,15 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + __reserved: ::c_short, + } + pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index d1a229438096..124f0926df3a 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -42,6 +42,14 @@ s! { pub l_pid: ::pid_t, } + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 7f10a0b39fb0..2c5d375a1aa5 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -13,6 +13,8 @@ pub type fsblkcnt_t = ::c_ulonglong; pub type fsfilcnt_t = ::c_ulonglong; pub type rlim_t = ::c_ulonglong; +pub type flock64 = flock; + impl siginfo_t { pub unsafe fn si_addr(&self) -> *mut ::c_void { #[repr(C)] From 66529ed3759cfd2994148b117984cddb15ddb4a6 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Wed, 20 Nov 2019 14:54:57 +0200 Subject: [PATCH 41/61] Add a rule for flock64 in libc-test build script --- libc-test/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index b2512b85d6a9..977d444a4639 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2230,6 +2230,9 @@ fn test_linux(target: &str) { t if t.ends_with("_t") => t.to_string(), + // This is either a struct or a typedef to a struct + "flock64" if musl => format!("struct {}", ty), + // put `struct` in front of all structs:. t if is_struct => format!("struct {}", t), From 2cb9eec1310474e06cbbee8bd38c2ac97951bc26 Mon Sep 17 00:00:00 2001 From: patrick felt Date: Thu, 21 Nov 2019 17:02:26 -0700 Subject: [PATCH 42/61] - skip the roundtrip c check due to alignment Signed-off-by: patrick felt --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index b2512b85d6a9..bdecc66fe2df 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2471,6 +2471,7 @@ fn test_linux(target: &str) { true } "ipv6_mreq" + | "ip_mreq_source" | "sockaddr_in6" | "sockaddr_ll" | "in_pktinfo" From 54283f9e984e0f8736c69e7df9b2bcbb387e8e10 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Thu, 21 Nov 2019 21:18:19 -0300 Subject: [PATCH 43/61] Implement utmp for solarish targets --- src/unix/solarish/mod.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 0ad132e840ad..c8cca192d94a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -353,6 +353,16 @@ s! { e_termination: ::c_short, e_exit: ::c_short, } + + pub struct utmp { + pub ut_user: [::c_char; 8], + pub ut_id: [::c_char; 4], + pub ut_line: [::c_char; 12], + pub ut_pid: ::c_short, + pub ut_type: ::c_short, + pub ut_exit: exit_status, + pub ut_time: ::time_t, + } } s_no_extra_traits! { @@ -1690,6 +1700,7 @@ pub const PORT_SOURCE_FILE: ::c_int = 7; pub const PORT_SOURCE_POSTWAIT: ::c_int = 8; pub const PORT_SOURCE_SIGNAL: ::c_int = 9; +pub const NONROOT_USR: ::c_short = 2; pub const _UTX_USERSIZE: usize = 32; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_PADSIZE: usize = 5; @@ -2404,10 +2415,18 @@ extern "C" { pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn setutxent(); pub fn endutxent(); -// TODO: uncomment after utmp implementation -// pub fn getutmp(ux: *const utmpx, u: *mut utmp); -// pub fn getutmpx(u: *const utmp, ux: *mut utmpx); -// pub fn updwtmp(file: *const ::c_char, u: *mut utmp); + + pub fn endutent(); + pub fn getutent() -> *mut utmp; + pub fn getutid(u: *const utmp) -> *mut utmp; + pub fn getutline(u: *const utmp) -> *mut utmp; + pub fn pututline(u: *const utmp) -> *mut utmp; + pub fn setutent(); + pub fn utmpname(file: *const ::c_char) -> ::c_int; + + pub fn getutmp(ux: *const utmpx, u: *mut utmp); + pub fn getutmpx(u: *const utmp, ux: *mut utmpx); + pub fn updwtmp(file: *const ::c_char, u: *mut utmp); } mod compat; From ea00e8b9118c314d1b83d6268e8d3efdb9cdbc51 Mon Sep 17 00:00:00 2001 From: oxalica Date: Thu, 31 Oct 2019 21:01:11 +0800 Subject: [PATCH 44/61] Provide SYS_statx for more arch --- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 1 + src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 1 + src/unix/linux_like/linux/gnu/b64/mips64/mod.rs | 1 + src/unix/linux_like/linux/gnu/b64/s390x.rs | 1 + src/unix/linux_like/linux/musl/b32/arm/mod.rs | 1 + src/unix/linux_like/linux/musl/b32/hexagon.rs | 1 + src/unix/linux_like/linux/musl/b32/mips/mod.rs | 4 ++++ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 1 + src/unix/linux_like/linux/musl/b64/aarch64/mod.rs | 1 + src/unix/linux_like/linux/musl/b64/mips64.rs | 1 + src/unix/linux_like/linux/musl/b64/powerpc64.rs | 1 + src/unix/linux_like/linux/musl/b64/x86_64/mod.rs | 1 + 12 files changed, 15 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 23b0160bffa0..4a3b600aaf6b 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -526,6 +526,7 @@ pub const SYS_pwritev2: ::c_long = 4000 + 362; pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; pub const SYS_pkey_alloc: ::c_long = 4000 + 364; pub const SYS_pkey_free: ::c_long = 4000 + 365; +pub const SYS_statx: ::c_long = 4000 + 366; pub const O_DIRECT: ::c_int = 0x8000; pub const O_DIRECTORY: ::c_int = 0x10000; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index b980a11b1911..1a0e2f9904bf 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -924,6 +924,7 @@ pub const SYS_pwritev2: ::c_long = 287; pub const SYS_pkey_mprotect: ::c_long = 288; pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; #[link(name = "util")] extern "C" { diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 5b3da3cb2dc9..c895f1da6d76 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -568,6 +568,7 @@ pub const SYS_pwritev2: ::c_long = 5000 + 322; pub const SYS_pkey_mprotect: ::c_long = 5000 + 323; pub const SYS_pkey_alloc: ::c_long = 5000 + 324; pub const SYS_pkey_free: ::c_long = 5000 + 325; +pub const SYS_statx: ::c_long = 5000 + 326; pub const SFD_CLOEXEC: ::c_int = 0x080000; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index ac3170416024..25d226158457 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -993,6 +993,7 @@ pub const SYS_chown: ::c_long = 212; pub const SYS_setfsuid: ::c_long = 215; pub const SYS_setfsgid: ::c_long = 216; pub const SYS_newfstatat: ::c_long = 293; +pub const SYS_statx: ::c_long = 379; #[link(name = "util")] extern "C" { diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index fd1e259fc3b5..ff2368873472 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -827,6 +827,7 @@ pub const SYS_pwritev2: ::c_long = 393; pub const SYS_pkey_mprotect: ::c_long = 394; pub const SYS_pkey_alloc: ::c_long = 395; pub const SYS_pkey_free: ::c_long = 396; +pub const SYS_statx: ::c_long = 397; extern "C" { pub fn getrandom( diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 0e6cc148fab3..23406955727b 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -710,6 +710,7 @@ pub const SYS_wait4: ::c_int = 260; pub const SYS_waitid: ::c_int = 95; pub const SYS_write: ::c_int = 64; pub const SYS_writev: ::c_int = 66; +pub const SYS_statx: ::c_int = 291; pub const TCFLSH: ::c_int = 21515; pub const TCGETA: ::c_int = 21509; pub const TCGETS: ::c_int = 21505; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 7fdd121a7ac4..be11341683f1 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -836,6 +836,10 @@ pub const SYS_mlock2: ::c_long = 4000 + 359; pub const SYS_copy_file_range: ::c_long = 4000 + 360; pub const SYS_preadv2: ::c_long = 4000 + 361; pub const SYS_pwritev2: ::c_long = 4000 + 362; +pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; +pub const SYS_pkey_alloc: ::c_long = 4000 + 364; +pub const SYS_pkey_free: ::c_long = 4000 + 365; +pub const SYS_statx: ::c_long = 4000 + 366; cfg_if! { if #[cfg(libc_align)] { diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index fb5569200c2d..78309045fa2e 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -916,6 +916,7 @@ pub const SYS_preadv2: ::c_long = 378; pub const SYS_pwritev2: ::c_long = 379; // FIXME syscalls 380-382 have been added in musl 1.16 // See discussion https://github.com/rust-lang/libc/pull/699 +pub const SYS_statx: ::c_long = 383; // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 8c286d83ccd2..876ff3c8d746 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -506,6 +506,7 @@ pub const SYS_pwritev2: ::c_long = 287; pub const SYS_pkey_mprotect: ::c_long = 288; pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const TIOCINQ: ::c_int = ::FIONREAD; diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index bbdc0105fbf9..2c410509fa76 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -424,6 +424,7 @@ pub const SYS_pwritev2: ::c_long = 5000 + 322; pub const SYS_pkey_mprotect: ::c_long = 5000 + 323; pub const SYS_pkey_alloc: ::c_long = 5000 + 324; pub const SYS_pkey_free: ::c_long = 5000 + 325; +pub const SYS_statx: ::c_long = 5000 + 326; pub const O_DIRECT: ::c_int = 0x8000; pub const O_DIRECTORY: ::c_int = 0x10000; diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 5c068feae8cb..d27d703ad9c4 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -596,6 +596,7 @@ pub const SYS_copy_file_range: ::c_long = 379; pub const SYS_preadv2: ::c_long = 380; pub const SYS_pwritev2: ::c_long = 381; pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; pub const FIOCLEX: ::c_int = 0x20006601; pub const FIONCLEX: ::c_int = 0x20006602; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index 84f615e2fa2e..e82d584314c9 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -578,6 +578,7 @@ pub const SYS_preadv2: ::c_long = 327; pub const SYS_pwritev2: ::c_long = 328; // FIXME syscalls 329-331 have been added in musl 1.16 // See discussion https://github.com/rust-lang/libc/pull/699 +pub const SYS_statx: ::c_long = 332; // offsets in user_regs_structs, from sys/reg.h pub const R15: ::c_int = 0; From d211ebff7685c7ade4eb5feeca6633cfe1270949 Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 22 Nov 2019 13:55:52 +0800 Subject: [PATCH 45/61] Bring back SYS_pkey_* for musl --- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 5 +++-- src/unix/linux_like/linux/musl/b64/x86_64/mod.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 78309045fa2e..fcd8ae4117b0 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -914,8 +914,9 @@ pub const SYS_mlock2: ::c_long = 376; pub const SYS_copy_file_range: ::c_long = 377; pub const SYS_preadv2: ::c_long = 378; pub const SYS_pwritev2: ::c_long = 379; -// FIXME syscalls 380-382 have been added in musl 1.16 -// See discussion https://github.com/rust-lang/libc/pull/699 +pub const SYS_pkey_mprotect: ::c_long = 380; +pub const SYS_pkey_alloc: ::c_long = 381; +pub const SYS_pkey_free: ::c_long = 382; pub const SYS_statx: ::c_long = 383; // offsets in user_regs_structs, from sys/reg.h diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index e82d584314c9..ff9300c85f39 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -576,8 +576,9 @@ pub const SYS_mlock2: ::c_long = 325; pub const SYS_copy_file_range: ::c_long = 326; pub const SYS_preadv2: ::c_long = 327; pub const SYS_pwritev2: ::c_long = 328; -// FIXME syscalls 329-331 have been added in musl 1.16 -// See discussion https://github.com/rust-lang/libc/pull/699 +pub const SYS_pkey_mprotect: ::c_long = 329; +pub const SYS_pkey_alloc: ::c_long = 330; +pub const SYS_pkey_free: ::c_long = 331; pub const SYS_statx: ::c_long = 332; // offsets in user_regs_structs, from sys/reg.h From 3c1b0eee2e7ffa8b700dd2ecbbdf0a7de33d0ee5 Mon Sep 17 00:00:00 2001 From: Petr Sumbera Date: Fri, 22 Nov 2019 09:28:47 +0100 Subject: [PATCH 46/61] distinguish between solaris and illumos for shmid_ds --- src/unix/solarish/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index d0611d9eba7a..b8a39536b9c4 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -220,6 +220,9 @@ s! { pub struct shmid_ds { pub shm_perm: ipc_perm, pub shm_segsz: ::size_t, + #[cfg(target_os = "illumos")] + pub shm_amp: *mut ::c_void, + #[cfg(target_os = "solaris")] pub shm_flags: ::uintptr_t, pub shm_lkcnt: ::c_ushort, pub shm_lpid: ::pid_t, @@ -229,9 +232,15 @@ s! { pub shm_atime: ::time_t, pub shm_dtime: ::time_t, pub shm_ctime: ::time_t, + #[cfg(target_os = "illumos")] + pub shm_pad4: [i64; 4], + #[cfg(target_os = "solaris")] pub shm_amp: *mut ::c_void, + #[cfg(target_os = "solaris")] pub shm_gransize: u64, + #[cfg(target_os = "solaris")] pub shm_allocated: u64, + #[cfg(target_os = "solaris")] pub shm_pad4: [i64; 1], } From 0eb1462e14e96105fa249f69cd54da6a4590f541 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Fri, 22 Nov 2019 18:12:15 +0000 Subject: [PATCH 47/61] Revert "IPV6_FLOWINFO does not work with asmjs" This reverts commit 6ff2e8f12dcfa75c3ce24c275cb2f2426f1ae259. --- src/unix/linux_like/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 545c05304b2a..1fca7c419ce6 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -820,6 +820,7 @@ pub const IPV6_2292PKTOPTIONS: ::c_int = 6; pub const IPV6_CHECKSUM: ::c_int = 7; pub const IPV6_2292HOPLIMIT: ::c_int = 8; pub const IPV6_NEXTHOP: ::c_int = 9; +pub const IPV6_FLOWINFO: ::c_int = 11; pub const IPV6_UNICAST_HOPS: ::c_int = 16; pub const IPV6_MULTICAST_IF: ::c_int = 17; pub const IPV6_MULTICAST_HOPS: ::c_int = 18; From 490e073525fa2e34a662b79dec946eaeed51c84d Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Mon, 25 Nov 2019 11:33:21 +0200 Subject: [PATCH 48/61] Fix wording in the build script flock64 rule Co-Authored-By: gnzlbg --- libc-test/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 977d444a4639..ea5494801db6 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2230,7 +2230,7 @@ fn test_linux(target: &str) { t if t.ends_with("_t") => t.to_string(), - // This is either a struct or a typedef to a struct + // In MUSL `flock64` is a typedef to `flock`. "flock64" if musl => format!("struct {}", ty), // put `struct` in front of all structs:. From 412dd4e1b0112c5aa605ef33bc18215fb56edf67 Mon Sep 17 00:00:00 2001 From: Petr Sumbera Date: Mon, 25 Nov 2019 15:17:42 +0100 Subject: [PATCH 49/61] Fixes fmt issues. --- src/unix/solarish/mod.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index b8a39536b9c4..956a664b20f3 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2060,11 +2060,17 @@ extern "C" { advice: ::c_int, ) -> ::c_int; - pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, - shmflg: ::c_int) -> *mut ::c_void; - - pub fn shmctl(shmid: ::c_int, cmd: ::c_int, - buf: *mut ::shmid_ds) -> ::c_int; + pub fn shmat( + shmid: ::c_int, + shmaddr: *const ::c_void, + shmflg: ::c_int, + ) -> *mut ::c_void; + + pub fn shmctl( + shmid: ::c_int, + cmd: ::c_int, + buf: *mut ::shmid_ds, + ) -> ::c_int; pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; From 034574cc52ba12cf7b11a6a76488da587d8deb63 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Mon, 25 Nov 2019 17:44:01 +0100 Subject: [PATCH 50/61] Add initial support for sparc-unknown-linux-gnu --- src/unix/linux_like/linux/align.rs | 4 + src/unix/linux_like/linux/gnu/b32/mod.rs | 3 + .../linux_like/linux/gnu/b32/sparc/align.rs | 7 + .../linux_like/linux/gnu/b32/sparc/mod.rs | 978 ++++++++++++++++++ src/unix/linux_like/linux/gnu/mod.rs | 10 +- src/unix/linux_like/linux/no_align.rs | 4 + 6 files changed, 1004 insertions(+), 2 deletions(-) create mode 100644 src/unix/linux_like/linux/gnu/b32/sparc/align.rs create mode 100644 src/unix/linux_like/linux/gnu/b32/sparc/mod.rs diff --git a/src/unix/linux_like/linux/align.rs b/src/unix/linux_like/linux/align.rs index 440a8415fbec..6000b416e0d4 100644 --- a/src/unix/linux_like/linux/align.rs +++ b/src/unix/linux_like/linux/align.rs @@ -62,6 +62,7 @@ macro_rules! expand_align { target_arch = "arm", target_arch = "hexagon", target_arch = "powerpc", + target_arch = "sparc", target_arch = "x86_64", target_arch = "x86")), repr(align(4)))] @@ -70,6 +71,7 @@ macro_rules! expand_align { target_arch = "arm", target_arch = "hexagon", target_arch = "powerpc", + target_arch = "sparc", target_arch = "x86_64", target_arch = "x86"))), repr(align(8)))] @@ -83,6 +85,7 @@ macro_rules! expand_align { target_arch = "arm", target_arch = "hexagon", target_arch = "powerpc", + target_arch = "sparc", target_arch = "x86_64", target_arch = "x86")), repr(align(4)))] @@ -91,6 +94,7 @@ macro_rules! expand_align { target_arch = "arm", target_arch = "hexagon", target_arch = "powerpc", + target_arch = "sparc", target_arch = "x86_64", target_arch = "x86"))), repr(align(8)))] diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 6f39c208c31d..cc6b6367fe67 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -262,6 +262,9 @@ cfg_if! { } else if #[cfg(target_arch = "powerpc")] { mod powerpc; pub use self::powerpc::*; + } else if #[cfg(target_arch = "sparc")] { + mod sparc; + pub use self::sparc::*; } else { // Unknown target_arch } diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/align.rs b/src/unix/linux_like/linux/gnu/b32/sparc/align.rs new file mode 100644 index 000000000000..98fda883cd37 --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b32/sparc/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 3] + } +} diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs new file mode 100644 index 000000000000..f670b3422bff --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -0,0 +1,978 @@ +//! SPARC-specific definitions for 32-bit linux-like values + +pub type c_char = u8; +pub type wchar_t = i32; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + f_spare: [::__fsword_t; 5], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + _pad: [::c_int; 29], + _align: [usize; 0], + } + + 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 struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + __reserved: ::c_short, + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_ushort, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_long; 2], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_ushort, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __reserved: [::c_long; 2], + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + __pad1: ::c_ushort, + pub mode: ::c_ushort, + __pad2: ::c_ushort, + pub __seq: ::c_ushort, + __unused1: ::c_ulonglong, + __unused2: ::c_ulonglong, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + __pad1: ::c_uint, + pub shm_atime: ::time_t, + __pad2: ::c_uint, + pub shm_dtime: ::time_t, + __pad3: ::c_uint, + pub shm_ctime: ::time_t, + pub shm_segsz: ::size_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __reserved1: ::c_ulong, + __reserved2: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + __pad1: ::c_uint, + pub msg_stime: ::time_t, + __pad2: ::c_uint, + pub msg_rtime: ::time_t, + __pad3: ::c_uint, + pub msg_ctime: ::time_t, + __msg_cbytes: ::c_ushort, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved1: ::c_ulong, + __glibc_reserved2: ::c_ulong, + } + + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; + +pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; +pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; + +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 7; + +pub const O_APPEND: ::c_int = 0x8; +pub const O_CREAT: ::c_int = 0x200; +pub const O_EXCL: ::c_int = 0x800; +pub const O_NOCTTY: ::c_int = 0x8000; +pub const O_NONBLOCK: ::c_int = 0x4000; +pub const O_SYNC: ::c_int = 0x802000; +pub const O_RSYNC: ::c_int = 0x802000; +pub const O_DSYNC: ::c_int = 0x2000; +pub const O_FSYNC: ::c_int = 0x802000; +pub const O_NOATIME: ::c_int = 0x200000; +pub const O_PATH: ::c_int = 0x1000000; +pub const O_TMPFILE: ::c_int = 0x2000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_GROWSDOWN: ::c_int = 0x0200; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; + +pub const EDEADLK: ::c_int = 78; +pub const ENAMETOOLONG: ::c_int = 63; +pub const ENOLCK: ::c_int = 79; +pub const ENOSYS: ::c_int = 90; +pub const ENOTEMPTY: ::c_int = 66; +pub const ELOOP: ::c_int = 62; +pub const ENOMSG: ::c_int = 75; +pub const EIDRM: ::c_int = 77; +pub const ECHRNG: ::c_int = 94; +pub const EL2NSYNC: ::c_int = 95; +pub const EL3HLT: ::c_int = 96; +pub const EL3RST: ::c_int = 97; +pub const ELNRNG: ::c_int = 98; +pub const EUNATCH: ::c_int = 99; +pub const ENOCSI: ::c_int = 100; +pub const EL2HLT: ::c_int = 101; +pub const EBADE: ::c_int = 102; +pub const EBADR: ::c_int = 103; +pub const EXFULL: ::c_int = 104; +pub const ENOANO: ::c_int = 105; +pub const EBADRQC: ::c_int = 106; +pub const EBADSLT: ::c_int = 107; +pub const EMULTIHOP: ::c_int = 87; +pub const EOVERFLOW: ::c_int = 92; +pub const ENOTUNIQ: ::c_int = 115; +pub const EBADFD: ::c_int = 93; +pub const EBADMSG: ::c_int = 76; +pub const EREMCHG: ::c_int = 89; +pub const ELIBACC: ::c_int = 114; +pub const ELIBBAD: ::c_int = 112; +pub const ELIBSCN: ::c_int = 124; +pub const ELIBMAX: ::c_int = 123; +pub const ELIBEXEC: ::c_int = 110; +pub const EILSEQ: ::c_int = 122; +pub const ERESTART: ::c_int = 116; +pub const ESTRPIPE: ::c_int = 91; +pub const EUSERS: ::c_int = 68; +pub const ENOTSOCK: ::c_int = 38; +pub const EDESTADDRREQ: ::c_int = 39; +pub const EMSGSIZE: ::c_int = 40; +pub const EPROTOTYPE: ::c_int = 41; +pub const ENOPROTOOPT: ::c_int = 42; +pub const EPROTONOSUPPORT: ::c_int = 43; +pub const ESOCKTNOSUPPORT: ::c_int = 44; +pub const EOPNOTSUPP: ::c_int = 45; +pub const EPFNOSUPPORT: ::c_int = 46; +pub const EAFNOSUPPORT: ::c_int = 47; +pub const EADDRINUSE: ::c_int = 48; +pub const EADDRNOTAVAIL: ::c_int = 49; +pub const ENETDOWN: ::c_int = 50; +pub const ENETUNREACH: ::c_int = 51; +pub const ENETRESET: ::c_int = 52; +pub const ECONNABORTED: ::c_int = 53; +pub const ECONNRESET: ::c_int = 54; +pub const ENOBUFS: ::c_int = 55; +pub const EISCONN: ::c_int = 56; +pub const ENOTCONN: ::c_int = 57; +pub const ESHUTDOWN: ::c_int = 58; +pub const ETOOMANYREFS: ::c_int = 59; +pub const ETIMEDOUT: ::c_int = 60; +pub const ECONNREFUSED: ::c_int = 61; +pub const EHOSTDOWN: ::c_int = 64; +pub const EHOSTUNREACH: ::c_int = 65; +pub const EALREADY: ::c_int = 37; +pub const EINPROGRESS: ::c_int = 36; +pub const ESTALE: ::c_int = 70; +pub const EDQUOT: ::c_int = 69; +pub const ENOMEDIUM: ::c_int = 125; +pub const EMEDIUMTYPE: ::c_int = 126; +pub const ECANCELED: ::c_int = 127; +pub const ENOKEY: ::c_int = 128; +pub const EKEYEXPIRED: ::c_int = 129; +pub const EKEYREVOKED: ::c_int = 130; +pub const EKEYREJECTED: ::c_int = 131; +pub const EOWNERDEAD: ::c_int = 132; +pub const ENOTRECOVERABLE: ::c_int = 133; +pub const EHWPOISON: ::c_int = 135; +pub const ERFKILL: ::c_int = 134; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const SO_PASSCRED: ::c_int = 2; +pub const SO_REUSEADDR: ::c_int = 4; +pub const SO_BINDTODEVICE: ::c_int = 0x000d; +pub const SO_TIMESTAMP: ::c_int = 0x001d; +pub const SO_MARK: ::c_int = 0x0022; +pub const SO_RXQ_OVFL: ::c_int = 0x0024; +pub const SO_PEEK_OFF: ::c_int = 0x0026; +pub const SO_BUSY_POLL: ::c_int = 0x0030; +pub const SO_TYPE: ::c_int = 0x1008; +pub const SO_ERROR: ::c_int = 0x1007; +pub const SO_DONTROUTE: ::c_int = 16; +pub const SO_BROADCAST: ::c_int = 32; +pub const SO_SNDBUF: ::c_int = 0x1001; +pub const SO_RCVBUF: ::c_int = 0x1002; +pub const SO_SNDBUFFORCE: ::c_int = 0x100a; +pub const SO_RCVBUFFORCE: ::c_int = 0x100b; +pub const SO_DOMAIN: ::c_int = 0x1029; +pub const SO_KEEPALIVE: ::c_int = 8; +pub const SO_OOBINLINE: ::c_int = 0x100; +pub const SO_LINGER: ::c_int = 128; +pub const SO_REUSEPORT: ::c_int = 0x200; +pub const SO_ACCEPTCONN: ::c_int = 0x8000; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const SA_ONSTACK: ::c_int = 1; +pub const SA_SIGINFO: ::c_int = 0x200; +pub const SA_NOCLDWAIT: ::c_int = 0x100; + +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 20; +pub const SIGBUS: ::c_int = 10; +pub const SIGUSR1: ::c_int = 30; +pub const SIGUSR2: ::c_int = 31; +pub const SIGCONT: ::c_int = 19; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGURG: ::c_int = 16; +pub const SIGIO: ::c_int = 23; +pub const SIGSYS: ::c_int = 12; +pub const SIGPOLL: ::c_int = 23; +pub const SIGPWR: ::c_int = 29; +pub const SIG_SETMASK: ::c_int = 4; +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; + +pub const POLLWRNORM: ::c_short = 4; +pub const POLLWRBAND: ::c_short = 0x100; + +pub const O_ASYNC: ::c_int = 0x40; +pub const O_NDELAY: ::c_int = 0x4004; + +pub const PTRACE_DETACH: ::c_uint = 11; + +pub const EFD_NONBLOCK: ::c_int = 0x4000; + +pub const F_GETLK: ::c_int = 7; +pub const F_GETOWN: ::c_int = 5; +pub const F_SETOWN: ::c_int = 6; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; + +pub const F_RDLCK: ::c_int = 1; +pub const F_WRLCK: ::c_int = 2; +pub const F_UNLCK: ::c_int = 3; + +pub const SFD_NONBLOCK: ::c_int = 0x4000; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const TIOCLINUX: ::c_ulong = 0x541C; +pub const TIOCGSERIAL: ::c_ulong = 0x541E; +pub const TIOCEXCL: ::c_ulong = 0x2000740d; +pub const TIOCNXCL: ::c_ulong = 0x2000740e; +pub const TIOCSCTTY: ::c_ulong = 0x20007484; +pub const TIOCSTI: ::c_ulong = 0x80017472; +pub const TIOCMGET: ::c_ulong = 0x4004746a; +pub const TIOCMBIS: ::c_ulong = 0x8004746c; +pub const TIOCMBIC: ::c_ulong = 0x8004746b; +pub const TIOCMSET: ::c_ulong = 0x8004746d; +pub const TIOCCONS: ::c_ulong = 0x20007424; + +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const SFD_CLOEXEC: ::c_int = 0x400000; + +pub const NCCS: usize = 17; +pub const O_TRUNC: ::c_int = 0x400; + +pub const O_CLOEXEC: ::c_int = 0x400000; + +pub const EBFONT: ::c_int = 109; +pub const ENOSTR: ::c_int = 72; +pub const ENODATA: ::c_int = 111; +pub const ETIME: ::c_int = 73; +pub const ENOSR: ::c_int = 74; +pub const ENONET: ::c_int = 80; +pub const ENOPKG: ::c_int = 113; +pub const EREMOTE: ::c_int = 71; +pub const ENOLINK: ::c_int = 82; +pub const EADV: ::c_int = 83; +pub const ESRMNT: ::c_int = 84; +pub const ECOMM: ::c_int = 85; +pub const EPROTO: ::c_int = 86; +pub const EDOTDOT: ::c_int = 88; + +pub const SA_NODEFER: ::c_int = 0x20; +pub const SA_RESETHAND: ::c_int = 0x4; +pub const SA_RESTART: ::c_int = 0x2; +pub const SA_NOCLDSTOP: ::c_int = 0x00000008; + +pub const EPOLL_CLOEXEC: ::c_int = 0x400000; + +pub const EFD_CLOEXEC: ::c_int = 0x400000; + +pub const O_DIRECTORY: ::c_int = 0o200000; +pub const O_NOFOLLOW: ::c_int = 0o400000; +pub const O_LARGEFILE: ::c_int = 0x40000; +pub const O_DIRECT: ::c_int = 0x100000; + +pub const MAP_LOCKED: ::c_int = 0x0100; +pub const MAP_NORESERVE: ::c_int = 0x00040; + +pub const EDEADLOCK: ::c_int = 108; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; + +pub const SO_PEERCRED: ::c_int = 0x40; +pub const SO_RCVLOWAT: ::c_int = 0x800; +pub const SO_SNDLOWAT: ::c_int = 0x1000; +pub const SO_RCVTIMEO: ::c_int = 0x2000; +pub const SO_SNDTIMEO: ::c_int = 0x4000; + +pub const FIOCLEX: ::c_ulong = 0x20006601; +pub const FIONCLEX: ::c_ulong = 0x20006602; +pub const FIONBIO: ::c_ulong = 0x8004667e; + +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: ::tcflag_t = 0x800; +pub const TAB2: ::tcflag_t = 0x1000; +pub const TAB3: ::tcflag_t = 0x1800; +pub const CR1: ::tcflag_t = 0x200; +pub const CR2: ::tcflag_t = 0x400; +pub const CR3: ::tcflag_t = 0x600; +pub const FF1: ::tcflag_t = 0x8000; +pub const BS1: ::tcflag_t = 0x2000; +pub const VT1: ::tcflag_t = 0x4000; +pub const VWERASE: usize = 0xe; +pub const VREPRINT: usize = 0xc; +pub const VSUSP: usize = 0xa; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VDISCARD: usize = 0xd; +pub const VTIME: usize = 0x5; +pub const IXON: ::tcflag_t = 0x400; +pub const IXOFF: ::tcflag_t = 0x1000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x30; +pub const CS6: ::tcflag_t = 0x10; +pub const CS7: ::tcflag_t = 0x20; +pub const CS8: ::tcflag_t = 0x30; +pub const CSTOPB: ::tcflag_t = 0x40; +pub const CREAD: ::tcflag_t = 0x80; +pub const PARENB: ::tcflag_t = 0x100; +pub const PARODD: ::tcflag_t = 0x200; +pub const HUPCL: ::tcflag_t = 0x400; +pub const CLOCAL: ::tcflag_t = 0x800; +pub const ECHOKE: ::tcflag_t = 0x800; +pub const ECHOE: ::tcflag_t = 0x10; +pub const ECHOK: ::tcflag_t = 0x20; +pub const ECHONL: ::tcflag_t = 0x40; +pub const ECHOPRT: ::tcflag_t = 0x400; +pub const ECHOCTL: ::tcflag_t = 0x200; +pub const ISIG: ::tcflag_t = 0x1; +pub const ICANON: ::tcflag_t = 0x2; +pub const PENDIN: ::tcflag_t = 0x4000; +pub const NOFLSH: ::tcflag_t = 0x80; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0x00001000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const BOTHER: ::speed_t = 0x1000; +pub const B57600: ::speed_t = 0x1001; +pub const B115200: ::speed_t = 0x1002; +pub const B230400: ::speed_t = 0x1003; +pub const B460800: ::speed_t = 0x1004; +pub const B76800: ::speed_t = 0x1005; +pub const B153600: ::speed_t = 0x1006; +pub const B307200: ::speed_t = 0x1007; +pub const B614400: ::speed_t = 0x1008; +pub const B921600: ::speed_t = 0x1009; +pub const B500000: ::speed_t = 0x100a; +pub const B576000: ::speed_t = 0x100b; +pub const B1000000: ::speed_t = 0x100c; +pub const B1152000: ::speed_t = 0x100d; +pub const B1500000: ::speed_t = 0x100e; +pub const B2000000: ::speed_t = 0x100f; + +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: ::tcflag_t = 0x8000; +pub const TOSTOP: ::tcflag_t = 0x100; +pub const FLUSHO: ::tcflag_t = 0x1000; +pub const EXTPROC: ::tcflag_t = 0x10000; +pub const TCGETS: ::c_ulong = 0x40245408; +pub const TCSETS: ::c_ulong = 0x80245409; +pub const TCSETSW: ::c_ulong = 0x8024540a; +pub const TCSETSF: ::c_ulong = 0x8024540b; +pub const TCGETA: ::c_ulong = 0x40125401; +pub const TCSETA: ::c_ulong = 0x80125402; +pub const TCSETAW: ::c_ulong = 0x80125403; +pub const TCSETAF: ::c_ulong = 0x80125404; +pub const TCSBRK: ::c_ulong = 0x20005405; +pub const TCXONC: ::c_ulong = 0x20005406; +pub const TCFLSH: ::c_ulong = 0x20005407; +pub const TIOCINQ: ::c_ulong = 0x4004667f; +pub const TIOCGPGRP: ::c_ulong = 0x40047483; +pub const TIOCSPGRP: ::c_ulong = 0x80047482; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const FIONREAD: ::c_ulong = 0x4004667f; + +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_wait4: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execv: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_chown: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_lchown: ::c_long = 16; +pub const SYS_brk: ::c_long = 17; +pub const SYS_perfctr: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_capget: ::c_long = 21; +pub const SYS_capset: ::c_long = 22; +pub const SYS_setuid: ::c_long = 23; +pub const SYS_getuid: ::c_long = 24; +pub const SYS_vmsplice: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_sigaltstack: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime: ::c_long = 30; +pub const SYS_lchown32: ::c_long = 31; +pub const SYS_fchown32: ::c_long = 32; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_chown32: ::c_long = 35; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_stat: ::c_long = 38; +pub const SYS_sendfile: ::c_long = 39; +pub const SYS_lstat: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_getuid32: ::c_long = 44; +pub const SYS_umount2: ::c_long = 45; +pub const SYS_setgid: ::c_long = 46; +pub const SYS_getgid: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid: ::c_long = 49; +pub const SYS_getegid: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_getgid32: ::c_long = 53; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_reboot: ::c_long = 55; +pub const SYS_mmap2: ::c_long = 56; +pub const SYS_symlink: ::c_long = 57; +pub const SYS_readlink: ::c_long = 58; +pub const SYS_execve: ::c_long = 59; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_fstat: ::c_long = 62; +pub const SYS_fstat64: ::c_long = 63; +pub const SYS_getpagesize: ::c_long = 64; +pub const SYS_msync: ::c_long = 65; +pub const SYS_vfork: ::c_long = 66; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_geteuid32: ::c_long = 69; +pub const SYS_getegid32: ::c_long = 70; +pub const SYS_mmap: ::c_long = 71; +pub const SYS_setreuid32: ::c_long = 72; +pub const SYS_munmap: ::c_long = 73; +pub const SYS_mprotect: ::c_long = 74; +pub const SYS_madvise: ::c_long = 75; +pub const SYS_vhangup: ::c_long = 76; +pub const SYS_truncate64: ::c_long = 77; +pub const SYS_mincore: ::c_long = 78; +pub const SYS_getgroups: ::c_long = 79; +pub const SYS_setgroups: ::c_long = 80; +pub const SYS_getpgrp: ::c_long = 81; +pub const SYS_setgroups32: ::c_long = 82; +pub const SYS_setitimer: ::c_long = 83; +pub const SYS_ftruncate64: ::c_long = 84; +pub const SYS_swapon: ::c_long = 85; +pub const SYS_getitimer: ::c_long = 86; +pub const SYS_setuid32: ::c_long = 87; +pub const SYS_sethostname: ::c_long = 88; +pub const SYS_setgid32: ::c_long = 89; +pub const SYS_dup2: ::c_long = 90; +pub const SYS_setfsuid32: ::c_long = 91; +pub const SYS_fcntl: ::c_long = 92; +pub const SYS_select: ::c_long = 93; +pub const SYS_setfsgid32: ::c_long = 94; +pub const SYS_fsync: ::c_long = 95; +pub const SYS_setpriority: ::c_long = 96; +pub const SYS_socket: ::c_long = 97; +pub const SYS_connect: ::c_long = 98; +pub const SYS_accept: ::c_long = 99; +pub const SYS_getpriority: ::c_long = 100; +pub const SYS_rt_sigreturn: ::c_long = 101; +pub const SYS_rt_sigaction: ::c_long = 102; +pub const SYS_rt_sigprocmask: ::c_long = 103; +pub const SYS_rt_sigpending: ::c_long = 104; +pub const SYS_rt_sigtimedwait: ::c_long = 105; +pub const SYS_rt_sigqueueinfo: ::c_long = 106; +pub const SYS_rt_sigsuspend: ::c_long = 107; +pub const SYS_setresuid32: ::c_long = 108; +pub const SYS_getresuid32: ::c_long = 109; +pub const SYS_setresgid32: ::c_long = 110; +pub const SYS_getresgid32: ::c_long = 111; +pub const SYS_setregid32: ::c_long = 112; +pub const SYS_recvmsg: ::c_long = 113; +pub const SYS_sendmsg: ::c_long = 114; +pub const SYS_getgroups32: ::c_long = 115; +pub const SYS_gettimeofday: ::c_long = 116; +pub const SYS_getrusage: ::c_long = 117; +pub const SYS_getsockopt: ::c_long = 118; +pub const SYS_getcwd: ::c_long = 119; +pub const SYS_readv: ::c_long = 120; +pub const SYS_writev: ::c_long = 121; +pub const SYS_settimeofday: ::c_long = 122; +pub const SYS_fchown: ::c_long = 123; +pub const SYS_fchmod: ::c_long = 124; +pub const SYS_recvfrom: ::c_long = 125; +pub const SYS_setreuid: ::c_long = 126; +pub const SYS_setregid: ::c_long = 127; +pub const SYS_rename: ::c_long = 128; +pub const SYS_truncate: ::c_long = 129; +pub const SYS_ftruncate: ::c_long = 130; +pub const SYS_flock: ::c_long = 131; +pub const SYS_lstat64: ::c_long = 132; +pub const SYS_sendto: ::c_long = 133; +pub const SYS_shutdown: ::c_long = 134; +pub const SYS_socketpair: ::c_long = 135; +pub const SYS_mkdir: ::c_long = 136; +pub const SYS_rmdir: ::c_long = 137; +pub const SYS_utimes: ::c_long = 138; +pub const SYS_stat64: ::c_long = 139; +pub const SYS_sendfile64: ::c_long = 140; +pub const SYS_getpeername: ::c_long = 141; +pub const SYS_futex: ::c_long = 142; +pub const SYS_gettid: ::c_long = 143; +pub const SYS_getrlimit: ::c_long = 144; +pub const SYS_setrlimit: ::c_long = 145; +pub const SYS_pivot_root: ::c_long = 146; +pub const SYS_prctl: ::c_long = 147; +pub const SYS_pciconfig_read: ::c_long = 148; +pub const SYS_pciconfig_write: ::c_long = 149; +pub const SYS_getsockname: ::c_long = 150; +pub const SYS_inotify_init: ::c_long = 151; +pub const SYS_inotify_add_watch: ::c_long = 152; +pub const SYS_poll: ::c_long = 153; +pub const SYS_getdents64: ::c_long = 154; +pub const SYS_fcntl64: ::c_long = 155; +pub const SYS_inotify_rm_watch: ::c_long = 156; +pub const SYS_statfs: ::c_long = 157; +pub const SYS_fstatfs: ::c_long = 158; +pub const SYS_umount: ::c_long = 159; +pub const SYS_sched_set_affinity: ::c_long = 160; +pub const SYS_sched_get_affinity: ::c_long = 161; +pub const SYS_getdomainname: ::c_long = 162; +pub const SYS_setdomainname: ::c_long = 163; +pub const SYS_quotactl: ::c_long = 165; +pub const SYS_set_tid_address: ::c_long = 166; +pub const SYS_mount: ::c_long = 167; +pub const SYS_ustat: ::c_long = 168; +pub const SYS_setxattr: ::c_long = 169; +pub const SYS_lsetxattr: ::c_long = 170; +pub const SYS_fsetxattr: ::c_long = 171; +pub const SYS_getxattr: ::c_long = 172; +pub const SYS_lgetxattr: ::c_long = 173; +pub const SYS_getdents: ::c_long = 174; +pub const SYS_setsid: ::c_long = 175; +pub const SYS_fchdir: ::c_long = 176; +pub const SYS_fgetxattr: ::c_long = 177; +pub const SYS_listxattr: ::c_long = 178; +pub const SYS_llistxattr: ::c_long = 179; +pub const SYS_flistxattr: ::c_long = 180; +pub const SYS_removexattr: ::c_long = 181; +pub const SYS_lremovexattr: ::c_long = 182; +pub const SYS_sigpending: ::c_long = 183; +pub const SYS_query_module: ::c_long = 184; +pub const SYS_setpgid: ::c_long = 185; +pub const SYS_fremovexattr: ::c_long = 186; +pub const SYS_tkill: ::c_long = 187; +pub const SYS_exit_group: ::c_long = 188; +pub const SYS_uname: ::c_long = 189; +pub const SYS_init_module: ::c_long = 190; +pub const SYS_personality: ::c_long = 191; +pub const SYS_remap_file_pages: ::c_long = 192; +pub const SYS_epoll_create: ::c_long = 193; +pub const SYS_epoll_ctl: ::c_long = 194; +pub const SYS_epoll_wait: ::c_long = 195; +pub const SYS_ioprio_set: ::c_long = 196; +pub const SYS_getppid: ::c_long = 197; +pub const SYS_sigaction: ::c_long = 198; +pub const SYS_sgetmask: ::c_long = 199; +pub const SYS_ssetmask: ::c_long = 200; +pub const SYS_sigsuspend: ::c_long = 201; +pub const SYS_oldlstat: ::c_long = 202; +pub const SYS_uselib: ::c_long = 203; +pub const SYS_readdir: ::c_long = 204; +pub const SYS_readahead: ::c_long = 205; +pub const SYS_socketcall: ::c_long = 206; +pub const SYS_syslog: ::c_long = 207; +pub const SYS_lookup_dcookie: ::c_long = 208; +pub const SYS_fadvise64: ::c_long = 209; +pub const SYS_fadvise64_64: ::c_long = 210; +pub const SYS_tgkill: ::c_long = 211; +pub const SYS_waitpid: ::c_long = 212; +pub const SYS_swapoff: ::c_long = 213; +pub const SYS_sysinfo: ::c_long = 214; +pub const SYS_ipc: ::c_long = 215; +pub const SYS_sigreturn: ::c_long = 216; +pub const SYS_clone: ::c_long = 217; +pub const SYS_ioprio_get: ::c_long = 218; +pub const SYS_adjtimex: ::c_long = 219; +pub const SYS_sigprocmask: ::c_long = 220; +pub const SYS_create_module: ::c_long = 221; +pub const SYS_delete_module: ::c_long = 222; +pub const SYS_get_kernel_syms: ::c_long = 223; +pub const SYS_getpgid: ::c_long = 224; +pub const SYS_bdflush: ::c_long = 225; +pub const SYS_sysfs: ::c_long = 226; +pub const SYS_afs_syscall: ::c_long = 227; +pub const SYS_setfsuid: ::c_long = 228; +pub const SYS_setfsgid: ::c_long = 229; +pub const SYS__newselect: ::c_long = 230; +pub const SYS_time: ::c_long = 231; +pub const SYS_splice: ::c_long = 232; +pub const SYS_stime: ::c_long = 233; +pub const SYS_statfs64: ::c_long = 234; +pub const SYS_fstatfs64: ::c_long = 235; +pub const SYS__llseek: ::c_long = 236; +pub const SYS_mlock: ::c_long = 237; +pub const SYS_munlock: ::c_long = 238; +pub const SYS_mlockall: ::c_long = 239; +pub const SYS_munlockall: ::c_long = 240; +pub const SYS_sched_setparam: ::c_long = 241; +pub const SYS_sched_getparam: ::c_long = 242; +pub const SYS_sched_setscheduler: ::c_long = 243; +pub const SYS_sched_getscheduler: ::c_long = 244; +pub const SYS_sched_yield: ::c_long = 245; +pub const SYS_sched_get_priority_max: ::c_long = 246; +pub const SYS_sched_get_priority_min: ::c_long = 247; +pub const SYS_sched_rr_get_interval: ::c_long = 248; +pub const SYS_nanosleep: ::c_long = 249; +pub const SYS_mremap: ::c_long = 250; +pub const SYS__sysctl: ::c_long = 251; +pub const SYS_getsid: ::c_long = 252; +pub const SYS_fdatasync: ::c_long = 253; +pub const SYS_nfsservctl: ::c_long = 254; +pub const SYS_sync_file_range: ::c_long = 255; +pub const SYS_clock_settime: ::c_long = 256; +pub const SYS_clock_gettime: ::c_long = 257; +pub const SYS_clock_getres: ::c_long = 258; +pub const SYS_clock_nanosleep: ::c_long = 259; +pub const SYS_sched_getaffinity: ::c_long = 260; +pub const SYS_sched_setaffinity: ::c_long = 261; +pub const SYS_timer_settime: ::c_long = 262; +pub const SYS_timer_gettime: ::c_long = 263; +pub const SYS_timer_getoverrun: ::c_long = 264; +pub const SYS_timer_delete: ::c_long = 265; +pub const SYS_timer_create: ::c_long = 266; +pub const SYS_io_setup: ::c_long = 268; +pub const SYS_io_destroy: ::c_long = 269; +pub const SYS_io_submit: ::c_long = 270; +pub const SYS_io_cancel: ::c_long = 271; +pub const SYS_io_getevents: ::c_long = 272; +pub const SYS_mq_open: ::c_long = 273; +pub const SYS_mq_unlink: ::c_long = 274; +pub const SYS_mq_timedsend: ::c_long = 275; +pub const SYS_mq_timedreceive: ::c_long = 276; +pub const SYS_mq_notify: ::c_long = 277; +pub const SYS_mq_getsetattr: ::c_long = 278; +pub const SYS_waitid: ::c_long = 279; +pub const SYS_tee: ::c_long = 280; +pub const SYS_add_key: ::c_long = 281; +pub const SYS_request_key: ::c_long = 282; +pub const SYS_keyctl: ::c_long = 283; +pub const SYS_openat: ::c_long = 284; +pub const SYS_mkdirat: ::c_long = 285; +pub const SYS_mknodat: ::c_long = 286; +pub const SYS_fchownat: ::c_long = 287; +pub const SYS_futimesat: ::c_long = 288; +pub const SYS_fstatat64: ::c_long = 289; +pub const SYS_unlinkat: ::c_long = 290; +pub const SYS_renameat: ::c_long = 291; +pub const SYS_linkat: ::c_long = 292; +pub const SYS_symlinkat: ::c_long = 293; +pub const SYS_readlinkat: ::c_long = 294; +pub const SYS_fchmodat: ::c_long = 295; +pub const SYS_faccessat: ::c_long = 296; +pub const SYS_pselect6: ::c_long = 297; +pub const SYS_ppoll: ::c_long = 298; +pub const SYS_unshare: ::c_long = 299; +pub const SYS_set_robust_list: ::c_long = 300; +pub const SYS_get_robust_list: ::c_long = 301; +pub const SYS_migrate_pages: ::c_long = 302; +pub const SYS_mbind: ::c_long = 303; +pub const SYS_get_mempolicy: ::c_long = 304; +pub const SYS_set_mempolicy: ::c_long = 305; +pub const SYS_kexec_load: ::c_long = 306; +pub const SYS_move_pages: ::c_long = 307; +pub const SYS_getcpu: ::c_long = 308; +pub const SYS_epoll_pwait: ::c_long = 309; +pub const SYS_utimensat: ::c_long = 310; +pub const SYS_signalfd: ::c_long = 311; +pub const SYS_timerfd_create: ::c_long = 312; +pub const SYS_eventfd: ::c_long = 313; +pub const SYS_fallocate: ::c_long = 314; +pub const SYS_timerfd_settime: ::c_long = 315; +pub const SYS_timerfd_gettime: ::c_long = 316; +pub const SYS_signalfd4: ::c_long = 317; +pub const SYS_eventfd2: ::c_long = 318; +pub const SYS_epoll_create1: ::c_long = 319; +pub const SYS_dup3: ::c_long = 320; +pub const SYS_pipe2: ::c_long = 321; +pub const SYS_inotify_init1: ::c_long = 322; +pub const SYS_accept4: ::c_long = 323; +pub const SYS_preadv: ::c_long = 324; +pub const SYS_pwritev: ::c_long = 325; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 326; +pub const SYS_perf_event_open: ::c_long = 327; +pub const SYS_recvmmsg: ::c_long = 328; +pub const SYS_fanotify_init: ::c_long = 329; +pub const SYS_fanotify_mark: ::c_long = 330; +pub const SYS_prlimit64: ::c_long = 331; +pub const SYS_name_to_handle_at: ::c_long = 332; +pub const SYS_open_by_handle_at: ::c_long = 333; +pub const SYS_clock_adjtime: ::c_long = 334; +pub const SYS_syncfs: ::c_long = 335; +pub const SYS_sendmmsg: ::c_long = 336; +pub const SYS_setns: ::c_long = 337; +pub const SYS_process_vm_readv: ::c_long = 338; +pub const SYS_process_vm_writev: ::c_long = 339; +pub const SYS_kern_features: ::c_long = 340; +pub const SYS_kcmp: ::c_long = 341; +pub const SYS_finit_module: ::c_long = 342; +pub const SYS_sched_setattr: ::c_long = 343; +pub const SYS_sched_getattr: ::c_long = 344; +pub const SYS_renameat2: ::c_long = 345; +pub const SYS_seccomp: ::c_long = 346; +pub const SYS_getrandom: ::c_long = 347; +pub const SYS_memfd_create: ::c_long = 348; +pub const SYS_bpf: ::c_long = 349; +pub const SYS_execveat: ::c_long = 350; +pub const SYS_membarrier: ::c_long = 351; +pub const SYS_userfaultfd: ::c_long = 352; +pub const SYS_bind: ::c_long = 353; +pub const SYS_listen: ::c_long = 354; +pub const SYS_setsockopt: ::c_long = 355; +pub const SYS_mlock2: ::c_long = 356; +pub const SYS_copy_file_range: ::c_long = 357; +pub const SYS_preadv2: ::c_long = 358; +pub const SYS_pwritev2: ::c_long = 359; +pub const SYS_statx: ::c_long = 360; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut ::c_int, + namelen: ::c_int, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t, + ) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 6473a041ee6a..60401ffdff7a 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -98,11 +98,13 @@ s! { pub c_line: ::cc_t, pub c_cc: [::cc_t; ::NCCS], #[cfg(not(any( + target_arch = "sparc", target_arch = "sparc64", target_arch = "mips", target_arch = "mips64")))] pub c_ispeed: ::speed_t, #[cfg(not(any( + target_arch = "sparc", target_arch = "sparc64", target_arch = "mips", target_arch = "mips64")))] @@ -864,7 +866,10 @@ cfg_if! { target_arch = "s390x" ))] { pub const PTHREAD_STACK_MIN: ::size_t = 16384; - } else if #[cfg(target_arch = "sparc64")] { + } else if #[cfg(any( + target_arch = "sparc", + target_arch = "sparc64" + ))] { pub const PTHREAD_STACK_MIN: ::size_t = 0x6000; } else { pub const PTHREAD_STACK_MIN: ::size_t = 131072; @@ -1023,7 +1028,8 @@ cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", - target_arch = "powerpc"))] { + target_arch = "powerpc", + target_arch = "sparc"))] { mod b32; pub use self::b32::*; } else if #[cfg(any(target_arch = "x86_64", diff --git a/src/unix/linux_like/linux/no_align.rs b/src/unix/linux_like/linux/no_align.rs index 016712a93226..13c2b71c9839 100644 --- a/src/unix/linux_like/linux/no_align.rs +++ b/src/unix/linux_like/linux/no_align.rs @@ -48,12 +48,14 @@ macro_rules! expand_align { #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", + target_arch = "sparc", all(target_arch = "x86_64", target_pointer_width = "32")))] __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", + target_arch = "sparc", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_longlong; 0], @@ -64,12 +66,14 @@ macro_rules! expand_align { #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", + target_arch = "sparc", all(target_arch = "x86_64", target_pointer_width = "32")))] __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", + target_arch = "sparc", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_longlong; 0], From ca3eb035f621f2df8d1de95514270178f687faeb Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Wed, 27 Nov 2019 05:12:42 +0000 Subject: [PATCH 51/61] expose futimens() for illumos systems --- src/unix/solarish/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index c8cca192d94a..e84067876455 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2157,6 +2157,10 @@ extern "C" { path: *const ::c_char, times: *const ::timeval, ) -> ::c_int; + pub fn futimens( + dirfd: ::c_int, + times: *const ::timespec, + ) -> ::c_int; pub fn utimensat( dirfd: ::c_int, path: *const ::c_char, From 112b7f9cb6ec923ff6e835e64ca149f6c3daddb1 Mon Sep 17 00:00:00 2001 From: msizanoen1 Date: Sat, 23 Nov 2019 14:02:48 +0700 Subject: [PATCH 52/61] Support for RISC-V 64-bit GNU/Linux --- ci/build.sh | 1 + src/unix/linux_like/linux/gnu/b64/mod.rs | 3 + .../linux_like/linux/gnu/b64/riscv64/mod.rs | 861 ++++++++++++++++++ src/unix/linux_like/linux/gnu/mod.rs | 3 +- 4 files changed, 867 insertions(+), 1 deletion(-) create mode 100644 src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs diff --git a/ci/build.sh b/ci/build.sh index cde46cb451b8..aad00859e890 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -220,6 +220,7 @@ nvptx64-nvidia-cuda \ powerpc-unknown-linux-gnuspe \ powerpc-unknown-netbsd \ powerpc64-unknown-freebsd \ +riscv64gc-unknown-linux-gnu \ riscv32imac-unknown-none-elf \ riscv32imc-unknown-none-elf \ sparc64-unknown-netbsd \ diff --git a/src/unix/linux_like/linux/gnu/b64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mod.rs index c91da0d98d1c..40ce8441a966 100644 --- a/src/unix/linux_like/linux/gnu/b64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -78,6 +78,9 @@ cfg_if! { } else if #[cfg(any(target_arch = "x86_64"))] { mod x86_64; pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "riscv64"))] { + mod riscv64; + pub use self::riscv64::*; } else { // Unknown target_arch } diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs new file mode 100644 index 000000000000..c45c5b230bed --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -0,0 +1,861 @@ +//! RISC-V-specific definitions for 64-bit linux-like values + +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = ::c_int; +pub type time_t = ::c_long; + +pub type dev_t = ::c_ulong; +pub type uid_t = ::c_uint; +pub type gid_t = ::c_uint; +pub type ino_t = ::c_ulong; +pub type ino64_t = ::c_ulong; +pub type mode_t = ::c_uint; +pub type nlink_t = ::c_uint; +pub type off_t = ::c_long; +pub type off64_t = ::c_long; +pub type pid_t = ::c_int; +pub type blksize_t = ::c_int; +pub type blkcnt_t = ::c_long; +pub type fsblkcnt_t = ::c_ulong; +pub type fsblkcnt64_t = ::c_ulong; +pub type fsfilcnt_t = ::c_ulong; +pub type fsfilcnt64_t = ::c_ulong; +pub type suseconds_t = i64; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct pthread_attr_t { + __size: [::c_ulong; 7], + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: ::c_long, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad1: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub __pad2: ::c_int, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: ::c_long, + pub __unused: [::c_int; 2usize], + } + + pub struct stat64 { + pub st_dev: dev_t, + pub st_ino: ino64_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub __pad1: dev_t, + pub st_size: off64_t, + pub st_blksize: blksize_t, + pub __pad2: ::c_int, + pub st_blocks: blkcnt_t, + pub st_atime: time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: ::c_long, + pub __unused: [::c_int; 2], + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statfs64 { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: fsblkcnt64_t, + pub f_bfree: fsblkcnt64_t, + pub f_bavail: fsblkcnt64_t, + pub f_files: fsfilcnt64_t, + pub f_ffree: fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, + pub f_favail: fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: fsblkcnt64_t, + pub f_bfree: fsblkcnt64_t, + pub f_bavail: fsblkcnt64_t, + pub f_files: fsfilcnt64_t, + pub f_ffree: fsfilcnt64_t, + pub f_favail: fsfilcnt64_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t, + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct sigset_t { + pub __val: [::c_ulong; 16], + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: uid_t, + pub gid: gid_t, + pub cuid: uid_t, + pub cgid: gid_t, + pub mode: ::c_ushort, + pub __pad1: ::c_ushort, + pub __seq: ::c_ushort, + pub __pad2: ::c_ushort, + pub __unused1: ::c_ulong, + pub __unused2: ::c_ulong, + } + + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: time_t, + pub shm_dtime: time_t, + pub shm_ctime: time_t, + pub shm_cpid: pid_t, + pub shm_lpid: pid_t, + pub shm_nattch: ::shmatt_t, + pub __unused5: ::c_ulong, + pub __unused6: ::c_ulong, + } + + 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 const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; +pub const VEOF: usize = 4; +pub const TIOCGSOFTCAR: ::c_ulong = 21529; +pub const TIOCSSOFTCAR: ::c_ulong = 21530; +pub const TIOCGRS485: ::c_int = 21550; +pub const TIOCSRS485: ::c_int = 21551; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 1052672; +pub const O_NOATIME: ::c_int = 262144; +pub const O_PATH: ::c_int = 2097152; +pub const O_TMPFILE: ::c_int = 4259840; +pub const MAP_GROWSDOWN: ::c_int = 256; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; +pub const SOL_SOCKET: ::c_int = 1; +pub const SO_REUSEADDR: ::c_int = 2; +pub const SO_TYPE: ::c_int = 3; +pub const SO_ERROR: ::c_int = 4; +pub const SO_DONTROUTE: ::c_int = 5; +pub const SO_BROADCAST: ::c_int = 6; +pub const SO_SNDBUF: ::c_int = 7; +pub const SO_RCVBUF: ::c_int = 8; +pub const SO_SNDBUFFORCE: ::c_int = 32; +pub const SO_RCVBUFFORCE: ::c_int = 33; +pub const SO_KEEPALIVE: ::c_int = 9; +pub const SO_OOBINLINE: ::c_int = 10; +pub const SO_NO_CHECK: ::c_int = 11; +pub const SO_PRIORITY: ::c_int = 12; +pub const SO_LINGER: ::c_int = 13; +pub const SO_BSDCOMPAT: ::c_int = 14; +pub const SO_REUSEPORT: ::c_int = 15; +pub const SO_PASSCRED: ::c_int = 16; +pub const SO_PEERCRED: ::c_int = 17; +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_SECURITY_AUTHENTICATION: ::c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; +pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = 26; +pub const SO_PEERNAME: ::c_int = 28; +pub const SO_TIMESTAMP: ::c_int = 29; +pub const SO_ACCEPTCONN: ::c_int = 30; +pub const SO_PEERSEC: ::c_int = 31; +pub const SO_PASSSEC: ::c_int = 34; +pub const SO_TIMESTAMPNS: ::c_int = 35; +pub const SCM_TIMESTAMPNS: ::c_int = 35; +pub const SO_MARK: ::c_int = 36; +pub const SO_PROTOCOL: ::c_int = 38; +pub const SO_DOMAIN: ::c_int = 39; +pub const SO_RXQ_OVFL: ::c_int = 40; +pub const SO_WIFI_STATUS: ::c_int = 41; +pub const SCM_WIFI_STATUS: ::c_int = 41; +pub const SO_PEEK_OFF: ::c_int = 42; +pub const SO_NOFCS: ::c_int = 43; +pub const SO_LOCK_FILTER: ::c_int = 44; +pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; +pub const SO_BUSY_POLL: ::c_int = 46; +pub const SO_MAX_PACING_RATE: ::c_int = 47; +pub const SO_BPF_EXTENSIONS: ::c_int = 48; +pub const SO_INCOMING_CPU: ::c_int = 49; +pub const SO_ATTACH_BPF: ::c_int = 50; +pub const SO_DETACH_BPF: ::c_int = 27; +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; +pub const SA_ONSTACK: ::c_int = 134217728; +pub const SA_SIGINFO: ::c_int = 4; +pub const SA_NOCLDWAIT: ::c_int = 2; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0; +pub const SIG_UNBLOCK: ::c_int = 1; +pub const POLLWRNORM: ::c_short = 256; +pub const POLLWRBAND: ::c_short = 512; +pub const O_ASYNC: ::c_int = 8192; +pub const O_NDELAY: ::c_int = 2048; +pub const PTRACE_DETACH: ::c_uint = 17; +pub const EFD_NONBLOCK: ::c_int = 2048; +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_RDLCK: ::c_int = 0; +pub const F_WRLCK: ::c_int = 1; +pub const F_UNLCK: ::c_int = 2; +pub const SFD_NONBLOCK: ::c_int = 2048; +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; +pub const TIOCLINUX: ::c_ulong = 21532; +pub const TIOCGSERIAL: ::c_ulong = 21534; +pub const TIOCEXCL: ::c_ulong = 21516; +pub const TIOCNXCL: ::c_ulong = 21517; +pub const TIOCSCTTY: ::c_ulong = 21518; +pub const TIOCSTI: ::c_ulong = 21522; +pub const TIOCMGET: ::c_ulong = 21525; +pub const TIOCMBIS: ::c_ulong = 21526; +pub const TIOCMBIC: ::c_ulong = 21527; +pub const TIOCMSET: ::c_ulong = 21528; +pub const TIOCCONS: ::c_ulong = 21533; +pub const TIOCM_ST: ::c_int = 8; +pub const TIOCM_SR: ::c_int = 16; +pub const TIOCM_CTS: ::c_int = 32; +pub const TIOCM_CAR: ::c_int = 64; +pub const TIOCM_RNG: ::c_int = 128; +pub const TIOCM_DSR: ::c_int = 256; +pub const SFD_CLOEXEC: ::c_int = 524288; +pub const NCCS: usize = 32; +pub const O_TRUNC: ::c_int = 512; +pub const O_CLOEXEC: ::c_int = 524288; +pub const EBFONT: ::c_int = 59; +pub const ENOSTR: ::c_int = 60; +pub const ENODATA: ::c_int = 61; +pub const ETIME: ::c_int = 62; +pub const ENOSR: ::c_int = 63; +pub const ENONET: ::c_int = 64; +pub const ENOPKG: ::c_int = 65; +pub const EREMOTE: ::c_int = 66; +pub const ENOLINK: ::c_int = 67; +pub const EADV: ::c_int = 68; +pub const ESRMNT: ::c_int = 69; +pub const ECOMM: ::c_int = 70; +pub const EPROTO: ::c_int = 71; +pub const EDOTDOT: ::c_int = 73; +pub const SA_NODEFER: ::c_int = 1073741824; +pub const SA_RESETHAND: ::c_int = -2147483648; +pub const SA_RESTART: ::c_int = 268435456; +pub const SA_NOCLDSTOP: ::c_int = 1; +pub const EPOLL_CLOEXEC: ::c_int = 524288; +pub const EFD_CLOEXEC: ::c_int = 524288; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const O_DIRECT: ::c_int = 16384; +pub const O_DIRECTORY: ::c_int = 65536; +pub const O_NOFOLLOW: ::c_int = 131072; +pub const MAP_HUGETLB: ::c_int = 262144; +pub const MAP_LOCKED: ::c_int = 8192; +pub const MAP_NORESERVE: ::c_int = 16384; +pub const MAP_ANON: ::c_int = 32; +pub const MAP_ANONYMOUS: ::c_int = 32; +pub const MAP_DENYWRITE: ::c_int = 2048; +pub const MAP_EXECUTABLE: ::c_int = 4096; +pub const MAP_POPULATE: ::c_int = 32768; +pub const MAP_NONBLOCK: ::c_int = 65536; +pub const MAP_STACK: ::c_int = 131072; +pub const EDEADLOCK: ::c_int = 35; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const FIOCLEX: ::c_ulong = 21585; +pub const FIONCLEX: ::c_ulong = 21584; +pub const FIONBIO: ::c_ulong = 21537; +pub const MCL_CURRENT: ::c_int = 1; +pub const MCL_FUTURE: ::c_int = 2; +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 4111; +pub const TAB1: ::tcflag_t = 2048; +pub const TAB2: ::tcflag_t = 4096; +pub const TAB3: ::tcflag_t = 6144; +pub const CR1: ::tcflag_t = 512; +pub const CR2: ::tcflag_t = 1024; +pub const CR3: ::tcflag_t = 1536; +pub const FF1: ::tcflag_t = 32768; +pub const BS1: ::tcflag_t = 8192; +pub const VT1: ::tcflag_t = 16384; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 1024; +pub const IXOFF: ::tcflag_t = 4096; +pub const ONLCR: ::tcflag_t = 4; +pub const CSIZE: ::tcflag_t = 48; +pub const CS6: ::tcflag_t = 16; +pub const CS7: ::tcflag_t = 32; +pub const CS8: ::tcflag_t = 48; +pub const CSTOPB: ::tcflag_t = 64; +pub const CREAD: ::tcflag_t = 128; +pub const PARENB: ::tcflag_t = 256; +pub const PARODD: ::tcflag_t = 512; +pub const HUPCL: ::tcflag_t = 1024; +pub const CLOCAL: ::tcflag_t = 2048; +pub const ECHOKE: ::tcflag_t = 2048; +pub const ECHOE: ::tcflag_t = 16; +pub const ECHOK: ::tcflag_t = 32; +pub const ECHONL: ::tcflag_t = 64; +pub const ECHOPRT: ::tcflag_t = 1024; +pub const ECHOCTL: ::tcflag_t = 512; +pub const ISIG: ::tcflag_t = 1; +pub const ICANON: ::tcflag_t = 2; +pub const PENDIN: ::tcflag_t = 16384; +pub const NOFLSH: ::tcflag_t = 128; +pub const CIBAUD: ::tcflag_t = 269418496; +pub const CBAUDEX: ::tcflag_t = 4096; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 2; +pub const NLDLY: ::tcflag_t = 256; +pub const CRDLY: ::tcflag_t = 1536; +pub const TABDLY: ::tcflag_t = 6144; +pub const BSDLY: ::tcflag_t = 8192; +pub const FFDLY: ::tcflag_t = 32768; +pub const VTDLY: ::tcflag_t = 16384; +pub const XTABS: ::tcflag_t = 6144; +pub const B0: ::speed_t = 0; +pub const B50: ::speed_t = 1; +pub const B75: ::speed_t = 2; +pub const B110: ::speed_t = 3; +pub const B134: ::speed_t = 4; +pub const B150: ::speed_t = 5; +pub const B200: ::speed_t = 6; +pub const B300: ::speed_t = 7; +pub const B600: ::speed_t = 8; +pub const B1200: ::speed_t = 9; +pub const B1800: ::speed_t = 10; +pub const B2400: ::speed_t = 11; +pub const B4800: ::speed_t = 12; +pub const B9600: ::speed_t = 13; +pub const B19200: ::speed_t = 14; +pub const B38400: ::speed_t = 15; +pub const EXTA: ::speed_t = 14; +pub const EXTB: ::speed_t = 15; +pub const B57600: ::speed_t = 4097; +pub const B115200: ::speed_t = 4098; +pub const B230400: ::speed_t = 4099; +pub const B460800: ::speed_t = 4100; +pub const B500000: ::speed_t = 4101; +pub const B576000: ::speed_t = 4102; +pub const B921600: ::speed_t = 4103; +pub const B1000000: ::speed_t = 4104; +pub const B1152000: ::speed_t = 4105; +pub const B1500000: ::speed_t = 4106; +pub const B2000000: ::speed_t = 4107; +pub const B2500000: ::speed_t = 4108; +pub const B3000000: ::speed_t = 4109; +pub const B3500000: ::speed_t = 4110; +pub const B4000000: ::speed_t = 4111; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 32768; +pub const TOSTOP: ::tcflag_t = 256; +pub const FLUSHO: ::tcflag_t = 4096; +pub const EXTPROC: ::tcflag_t = 65536; +pub const TCGETS: ::c_ulong = 21505; +pub const TCSETS: ::c_ulong = 21506; +pub const TCSETSW: ::c_ulong = 21507; +pub const TCSETSF: ::c_ulong = 21508; +pub const TCGETA: ::c_ulong = 21509; +pub const TCSETA: ::c_ulong = 21510; +pub const TCSETAW: ::c_ulong = 21511; +pub const TCSETAF: ::c_ulong = 21512; +pub const TCSBRK: ::c_ulong = 21513; +pub const TCXONC: ::c_ulong = 21514; +pub const TCFLSH: ::c_ulong = 21515; +pub const TIOCINQ: ::c_ulong = 21531; +pub const TIOCGPGRP: ::c_ulong = 21519; +pub const TIOCSPGRP: ::c_ulong = 21520; +pub const TIOCOUTQ: ::c_ulong = 21521; +pub const TIOCGWINSZ: ::c_ulong = 21523; +pub const TIOCSWINSZ: ::c_ulong = 21524; +pub const FIONREAD: ::c_ulong = 21531; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const SYS_read: ::c_long = 63; +pub const SYS_write: ::c_long = 64; +pub const SYS_close: ::c_long = 57; +pub const SYS_fstat: ::c_long = 80; +pub const SYS_lseek: ::c_long = 62; +pub const SYS_mmap: ::c_long = 222; +pub const SYS_mprotect: ::c_long = 226; +pub const SYS_munmap: ::c_long = 215; +pub const SYS_brk: ::c_long = 214; +pub const SYS_rt_sigaction: ::c_long = 134; +pub const SYS_rt_sigprocmask: ::c_long = 135; +pub const SYS_rt_sigreturn: ::c_long = 139; +pub const SYS_ioctl: ::c_long = 29; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_readv: ::c_long = 65; +pub const SYS_writev: ::c_long = 66; +pub const SYS_sched_yield: ::c_long = 124; +pub const SYS_mremap: ::c_long = 216; +pub const SYS_msync: ::c_long = 227; +pub const SYS_mincore: ::c_long = 232; +pub const SYS_madvise: ::c_long = 233; +pub const SYS_shmget: ::c_long = 194; +pub const SYS_shmat: ::c_long = 196; +pub const SYS_shmctl: ::c_long = 195; +pub const SYS_dup: ::c_long = 23; +pub const SYS_nanosleep: ::c_long = 101; +pub const SYS_getitimer: ::c_long = 102; +pub const SYS_setitimer: ::c_long = 103; +pub const SYS_getpid: ::c_long = 172; +pub const SYS_sendfile: ::c_long = 71; +pub const SYS_socket: ::c_long = 198; +pub const SYS_connect: ::c_long = 203; +pub const SYS_accept: ::c_long = 202; +pub const SYS_sendto: ::c_long = 206; +pub const SYS_recvfrom: ::c_long = 207; +pub const SYS_sendmsg: ::c_long = 211; +pub const SYS_recvmsg: ::c_long = 212; +pub const SYS_shutdown: ::c_long = 210; +pub const SYS_bind: ::c_long = 200; +pub const SYS_listen: ::c_long = 201; +pub const SYS_getsockname: ::c_long = 204; +pub const SYS_getpeername: ::c_long = 205; +pub const SYS_socketpair: ::c_long = 199; +pub const SYS_setsockopt: ::c_long = 208; +pub const SYS_getsockopt: ::c_long = 209; +pub const SYS_clone: ::c_long = 220; +pub const SYS_execve: ::c_long = 221; +pub const SYS_exit: ::c_long = 93; +pub const SYS_wait4: ::c_long = 260; +pub const SYS_kill: ::c_long = 129; +pub const SYS_uname: ::c_long = 160; +pub const SYS_semget: ::c_long = 190; +pub const SYS_semop: ::c_long = 193; +pub const SYS_semctl: ::c_long = 191; +pub const SYS_shmdt: ::c_long = 197; +pub const SYS_msgget: ::c_long = 186; +pub const SYS_msgsnd: ::c_long = 189; +pub const SYS_msgrcv: ::c_long = 188; +pub const SYS_msgctl: ::c_long = 187; +pub const SYS_fcntl: ::c_long = 25; +pub const SYS_flock: ::c_long = 32; +pub const SYS_fsync: ::c_long = 82; +pub const SYS_fdatasync: ::c_long = 83; +pub const SYS_truncate: ::c_long = 45; +pub const SYS_ftruncate: ::c_long = 46; +pub const SYS_getcwd: ::c_long = 17; +pub const SYS_chdir: ::c_long = 49; +pub const SYS_fchdir: ::c_long = 50; +pub const SYS_fchmod: ::c_long = 52; +pub const SYS_fchown: ::c_long = 55; +pub const SYS_umask: ::c_long = 166; +pub const SYS_gettimeofday: ::c_long = 169; +pub const SYS_getrlimit: ::c_long = 163; +pub const SYS_getrusage: ::c_long = 165; +pub const SYS_sysinfo: ::c_long = 179; +pub const SYS_times: ::c_long = 153; +pub const SYS_ptrace: ::c_long = 117; +pub const SYS_getuid: ::c_long = 174; +pub const SYS_syslog: ::c_long = 116; +pub const SYS_getgid: ::c_long = 176; +pub const SYS_setuid: ::c_long = 146; +pub const SYS_setgid: ::c_long = 144; +pub const SYS_geteuid: ::c_long = 175; +pub const SYS_getegid: ::c_long = 177; +pub const SYS_setpgid: ::c_long = 154; +pub const SYS_getppid: ::c_long = 173; +pub const SYS_setsid: ::c_long = 157; +pub const SYS_setreuid: ::c_long = 145; +pub const SYS_setregid: ::c_long = 143; +pub const SYS_getgroups: ::c_long = 158; +pub const SYS_setgroups: ::c_long = 159; +pub const SYS_setresuid: ::c_long = 147; +pub const SYS_getresuid: ::c_long = 148; +pub const SYS_setresgid: ::c_long = 149; +pub const SYS_getresgid: ::c_long = 150; +pub const SYS_getpgid: ::c_long = 155; +pub const SYS_setfsuid: ::c_long = 151; +pub const SYS_setfsgid: ::c_long = 152; +pub const SYS_getsid: ::c_long = 156; +pub const SYS_capget: ::c_long = 90; +pub const SYS_capset: ::c_long = 91; +pub const SYS_rt_sigpending: ::c_long = 136; +pub const SYS_rt_sigtimedwait: ::c_long = 137; +pub const SYS_rt_sigqueueinfo: ::c_long = 138; +pub const SYS_rt_sigsuspend: ::c_long = 133; +pub const SYS_sigaltstack: ::c_long = 132; +pub const SYS_personality: ::c_long = 92; +pub const SYS_statfs: ::c_long = 43; +pub const SYS_fstatfs: ::c_long = 44; +pub const SYS_getpriority: ::c_long = 141; +pub const SYS_setpriority: ::c_long = 140; +pub const SYS_sched_setparam: ::c_long = 118; +pub const SYS_sched_getparam: ::c_long = 121; +pub const SYS_sched_setscheduler: ::c_long = 119; +pub const SYS_sched_getscheduler: ::c_long = 120; +pub const SYS_sched_get_priority_max: ::c_long = 125; +pub const SYS_sched_get_priority_min: ::c_long = 126; +pub const SYS_sched_rr_get_interval: ::c_long = 127; +pub const SYS_mlock: ::c_long = 228; +pub const SYS_munlock: ::c_long = 229; +pub const SYS_mlockall: ::c_long = 230; +pub const SYS_munlockall: ::c_long = 231; +pub const SYS_vhangup: ::c_long = 58; +pub const SYS_pivot_root: ::c_long = 41; +pub const SYS_prctl: ::c_long = 167; +pub const SYS_adjtimex: ::c_long = 171; +pub const SYS_setrlimit: ::c_long = 164; +pub const SYS_chroot: ::c_long = 51; +pub const SYS_sync: ::c_long = 81; +pub const SYS_acct: ::c_long = 89; +pub const SYS_settimeofday: ::c_long = 170; +pub const SYS_mount: ::c_long = 40; +pub const SYS_umount2: ::c_long = 39; +pub const SYS_swapon: ::c_long = 224; +pub const SYS_swapoff: ::c_long = 225; +pub const SYS_reboot: ::c_long = 142; +pub const SYS_sethostname: ::c_long = 161; +pub const SYS_setdomainname: ::c_long = 162; +pub const SYS_init_module: ::c_long = 105; +pub const SYS_delete_module: ::c_long = 106; +pub const SYS_quotactl: ::c_long = 60; +pub const SYS_nfsservctl: ::c_long = 42; +pub const SYS_gettid: ::c_long = 178; +pub const SYS_readahead: ::c_long = 213; +pub const SYS_setxattr: ::c_long = 5; +pub const SYS_lsetxattr: ::c_long = 6; +pub const SYS_fsetxattr: ::c_long = 7; +pub const SYS_getxattr: ::c_long = 8; +pub const SYS_lgetxattr: ::c_long = 9; +pub const SYS_fgetxattr: ::c_long = 10; +pub const SYS_listxattr: ::c_long = 11; +pub const SYS_llistxattr: ::c_long = 12; +pub const SYS_flistxattr: ::c_long = 13; +pub const SYS_removexattr: ::c_long = 14; +pub const SYS_lremovexattr: ::c_long = 15; +pub const SYS_fremovexattr: ::c_long = 16; +pub const SYS_tkill: ::c_long = 130; +pub const SYS_futex: ::c_long = 98; +pub const SYS_sched_setaffinity: ::c_long = 122; +pub const SYS_sched_getaffinity: ::c_long = 123; +pub const SYS_io_setup: ::c_long = 0; +pub const SYS_io_destroy: ::c_long = 1; +pub const SYS_io_getevents: ::c_long = 4; +pub const SYS_io_submit: ::c_long = 2; +pub const SYS_io_cancel: ::c_long = 3; +pub const SYS_lookup_dcookie: ::c_long = 18; +pub const SYS_remap_file_pages: ::c_long = 234; +pub const SYS_getdents64: ::c_long = 61; +pub const SYS_set_tid_address: ::c_long = 96; +pub const SYS_restart_syscall: ::c_long = 128; +pub const SYS_semtimedop: ::c_long = 192; +pub const SYS_fadvise64: ::c_long = 223; +pub const SYS_timer_create: ::c_long = 107; +pub const SYS_timer_settime: ::c_long = 110; +pub const SYS_timer_gettime: ::c_long = 108; +pub const SYS_timer_getoverrun: ::c_long = 109; +pub const SYS_timer_delete: ::c_long = 111; +pub const SYS_clock_settime: ::c_long = 112; +pub const SYS_clock_gettime: ::c_long = 113; +pub const SYS_clock_getres: ::c_long = 114; +pub const SYS_clock_nanosleep: ::c_long = 115; +pub const SYS_exit_group: ::c_long = 94; +pub const SYS_epoll_ctl: ::c_long = 21; +pub const SYS_tgkill: ::c_long = 131; +pub const SYS_mbind: ::c_long = 235; +pub const SYS_set_mempolicy: ::c_long = 237; +pub const SYS_get_mempolicy: ::c_long = 236; +pub const SYS_mq_open: ::c_long = 180; +pub const SYS_mq_unlink: ::c_long = 181; +pub const SYS_mq_timedsend: ::c_long = 182; +pub const SYS_mq_timedreceive: ::c_long = 183; +pub const SYS_mq_notify: ::c_long = 184; +pub const SYS_mq_getsetattr: ::c_long = 185; +pub const SYS_kexec_load: ::c_long = 104; +pub const SYS_waitid: ::c_long = 95; +pub const SYS_add_key: ::c_long = 217; +pub const SYS_request_key: ::c_long = 218; +pub const SYS_keyctl: ::c_long = 219; +pub const SYS_ioprio_set: ::c_long = 30; +pub const SYS_ioprio_get: ::c_long = 31; +pub const SYS_inotify_add_watch: ::c_long = 27; +pub const SYS_inotify_rm_watch: ::c_long = 28; +pub const SYS_migrate_pages: ::c_long = 238; +pub const SYS_openat: ::c_long = 56; +pub const SYS_mkdirat: ::c_long = 34; +pub const SYS_mknodat: ::c_long = 33; +pub const SYS_fchownat: ::c_long = 54; +pub const SYS_newfstatat: ::c_long = 79; +pub const SYS_unlinkat: ::c_long = 35; +pub const SYS_linkat: ::c_long = 37; +pub const SYS_symlinkat: ::c_long = 36; +pub const SYS_readlinkat: ::c_long = 78; +pub const SYS_fchmodat: ::c_long = 53; +pub const SYS_faccessat: ::c_long = 48; +pub const SYS_pselect6: ::c_long = 72; +pub const SYS_ppoll: ::c_long = 73; +pub const SYS_unshare: ::c_long = 97; +pub const SYS_set_robust_list: ::c_long = 99; +pub const SYS_get_robust_list: ::c_long = 100; +pub const SYS_splice: ::c_long = 76; +pub const SYS_tee: ::c_long = 77; +pub const SYS_sync_file_range: ::c_long = 84; +pub const SYS_vmsplice: ::c_long = 75; +pub const SYS_move_pages: ::c_long = 239; +pub const SYS_utimensat: ::c_long = 88; +pub const SYS_epoll_pwait: ::c_long = 22; +pub const SYS_timerfd_create: ::c_long = 85; +pub const SYS_fallocate: ::c_long = 47; +pub const SYS_timerfd_settime: ::c_long = 86; +pub const SYS_timerfd_gettime: ::c_long = 87; +pub const SYS_accept4: ::c_long = 242; +pub const SYS_signalfd4: ::c_long = 74; +pub const SYS_eventfd2: ::c_long = 19; +pub const SYS_epoll_create1: ::c_long = 20; +pub const SYS_dup3: ::c_long = 24; +pub const SYS_pipe2: ::c_long = 59; +pub const SYS_inotify_init1: ::c_long = 26; +pub const SYS_preadv: ::c_long = 69; +pub const SYS_pwritev: ::c_long = 70; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; +pub const SYS_perf_event_open: ::c_long = 241; +pub const SYS_recvmmsg: ::c_long = 243; +pub const SYS_fanotify_init: ::c_long = 262; +pub const SYS_fanotify_mark: ::c_long = 263; +pub const SYS_prlimit64: ::c_long = 261; +pub const SYS_name_to_handle_at: ::c_long = 264; +pub const SYS_open_by_handle_at: ::c_long = 265; +pub const SYS_clock_adjtime: ::c_long = 266; +pub const SYS_syncfs: ::c_long = 267; +pub const SYS_sendmmsg: ::c_long = 269; +pub const SYS_setns: ::c_long = 268; +pub const SYS_getcpu: ::c_long = 168; +pub const SYS_process_vm_readv: ::c_long = 270; +pub const SYS_process_vm_writev: ::c_long = 271; +pub const SYS_kcmp: ::c_long = 272; +pub const SYS_finit_module: ::c_long = 273; +pub const SYS_sched_setattr: ::c_long = 274; +pub const SYS_sched_getattr: ::c_long = 275; +pub const SYS_renameat2: ::c_long = 276; +pub const SYS_seccomp: ::c_long = 277; +pub const SYS_getrandom: ::c_long = 278; +pub const SYS_memfd_create: ::c_long = 279; +pub const SYS_bpf: ::c_long = 280; +pub const SYS_execveat: ::c_long = 281; +pub const SYS_userfaultfd: ::c_long = 282; +pub const SYS_membarrier: ::c_long = 283; +pub const SYS_mlock2: ::c_long = 284; +pub const SYS_copy_file_range: ::c_long = 285; +pub const SYS_preadv2: ::c_long = 286; +pub const SYS_pwritev2: ::c_long = 287; +pub const SYS_pkey_mprotect: ::c_long = 288; +pub const SYS_pkey_alloc: ::c_long = 289; +pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 6473a041ee6a..c0cfd1f866d6 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1031,7 +1031,8 @@ cfg_if! { target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] { + target_arch = "sparc64", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } else { From 033a775459e4ba3aa6b9fc0fbacb2aa56b1218b2 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Wed, 27 Nov 2019 13:29:15 -0300 Subject: [PATCH 53/61] Fix the lastlogx PartialEq impl --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 69c1efbbcd1a..91ecd62a6b49 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -481,8 +481,12 @@ cfg_if! { fn eq(&self, other: &lastlogx) -> bool { self.ll_tv == other.ll_tv && self.ll_line == other.ll_line - && self.ll_host == other.ll_host && self.ll_ss == other.ll_ss + && self + .ll_host + .iter() + .zip(other.ll_host.iter()) + .all(|(a,b)| a == b) } } From 6fffc1685cd0191808ec722be47ec057e9cfe472 Mon Sep 17 00:00:00 2001 From: GrayJack Date: Wed, 27 Nov 2019 13:35:58 -0300 Subject: [PATCH 54/61] Comment fields that are array with size above 32 in Debug impl utmpx lastlogx --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 91ecd62a6b49..1cdc1c6752ad 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -449,14 +449,14 @@ cfg_if! { .field("ut_name", &self.ut_name) .field("ut_id", &self.ut_id) .field("ut_line", &self.ut_line) - .field("ut_host", &self.ut_host) + // FIXME .field("ut_host", &self.ut_host) .field("ut_session", &self.ut_session) .field("ut_type", &self.ut_type) .field("ut_pid", &self.ut_pid) .field("ut_exit", &self.ut_exit) .field("ut_ss", &self.ut_ss) .field("ut_tv", &self.ut_tv) - .field("ut_pad", &self.ut_pad) + // FIXME .field("ut_pad", &self.ut_pad) .finish() } } @@ -497,7 +497,7 @@ cfg_if! { f.debug_struct("lastlogx") .field("ll_tv", &self.ll_tv) .field("ll_line", &self.ll_line) - .field("ll_host", &self.ll_host) + // FIXME.field("ll_host", &self.ll_host) .field("ll_ss", &self.ll_ss) .finish() } From 7335d1e4cda84ce60901da65934ae00bef47c56a Mon Sep 17 00:00:00 2001 From: Alex Povar <1074182+zvirja@users.noreply.github.com> Date: Tue, 26 Nov 2019 22:52:32 +0100 Subject: [PATCH 55/61] Add ucred type to uclibc for all archs --- src/unix/uclibc/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index c479f40016e8..b4fe03688038 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -288,6 +288,12 @@ s! { pub msgtql: ::c_int, pub msgseg: ::c_ushort, } + + pub struct ucred { + pub pid: ::pid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + } } s_no_extra_traits! { From 223e7d340a21cd104d157438a630d0b9ccafa194 Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Wed, 27 Nov 2019 22:13:28 +0000 Subject: [PATCH 56/61] expose futimens() for illumos systems (fix style) --- src/unix/solarish/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index e84067876455..9f0372b20fb7 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2157,10 +2157,7 @@ extern "C" { path: *const ::c_char, times: *const ::timeval, ) -> ::c_int; - pub fn futimens( - dirfd: ::c_int, - times: *const ::timespec, - ) -> ::c_int; + pub fn futimens(dirfd: ::c_int, times: *const ::timespec) -> ::c_int; pub fn utimensat( dirfd: ::c_int, path: *const ::c_char, From f8513121537a30c31045e8c4bae4f76285823f46 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 28 Nov 2019 10:37:32 +0700 Subject: [PATCH 57/61] use *const pointer for NetBSD's pthread_setname_np --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index a5a2fc61d507..9b3c398503a0 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1680,7 +1680,7 @@ extern "C" { pub fn pthread_setname_np( t: ::pthread_t, name: *const ::c_char, - arg: *mut ::c_void, + arg: *const ::c_void, ) -> ::c_int; pub fn pthread_attr_get_np( thread: ::pthread_t, From bf419bbb8c206bfe66866b54fe7872bd51bfe5ac Mon Sep 17 00:00:00 2001 From: msizanoen1 Date: Wed, 27 Nov 2019 18:39:15 +0700 Subject: [PATCH 58/61] Force update nightly compiler on Linux --- ci/azure-install-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/azure-install-rust.yml b/ci/azure-install-rust.yml index e78fe32faf6d..31b07149bd4d 100644 --- a/ci/azure-install-rust.yml +++ b/ci/azure-install-rust.yml @@ -8,7 +8,7 @@ steps: if command -v rustup; then # Uncomment when rustup on Azure is updated #rustup set profile minimal - rustup update $toolchain + rustup update --force $toolchain rustup default $toolchain else curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $toolchain --profile=minimal From a06978b7c09e9988ca6bc8ec72bab96ac98b974a Mon Sep 17 00:00:00 2001 From: msizanoen1 Date: Thu, 28 Nov 2019 13:02:17 +0700 Subject: [PATCH 59/61] Fix breakage due to https://github.com/rust-lang/cargo/pull/7560 and rust-lang/rust#66748 --- ci/build.sh | 2 +- ci/dox.sh | 2 +- ci/semver.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index aad00859e890..082f0dc68339 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -15,7 +15,7 @@ RUST=${TOOLCHAIN} echo "Testing Rust ${RUST} on ${OS}" if [ "${TOOLCHAIN}" = "nightly" ] ; then - cargo +nightly install cargo-xbuild -Z install-upgrade + cargo +nightly install cargo-xbuild rustup component add rust-src fi diff --git a/ci/dox.sh b/ci/dox.sh index 0c89a2e17b1e..271b54b4fab7 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -19,7 +19,7 @@ if ! rustc --version | grep -E "nightly" ; then fi rustup component add rust-src -cargo +nightly install cargo-xbuild -Z install-upgrade +cargo +nightly install cargo-xbuild # List all targets that do currently build successfully: # shellcheck disable=SC1003 diff --git a/ci/semver.sh b/ci/semver.sh index 3412501a7215..7e6ea663c8ac 100644 --- a/ci/semver.sh +++ b/ci/semver.sh @@ -13,7 +13,7 @@ if ! rustc --version | grep -E "nightly" ; then exit 1 fi -cargo +nightly install semverver -Z install-upgrade +cargo +nightly install semverver TARGETS= case "${OS}" in From 42289eb64f63fff85a08dffcfb30b1e6b167d20a Mon Sep 17 00:00:00 2001 From: GrayJack Date: Thu, 28 Nov 2019 20:47:50 -0300 Subject: [PATCH 60/61] Implement utmp for NetBSD --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 1cdc1c6752ad..ef9fe0480998 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -299,6 +299,19 @@ s! { pub shm_ctime: ::time_t, _shm_internal: *mut ::c_void, } + + pub struct utmp { + pub ut_line: [::c_char; UT_LINESIZE], + pub ut_name: [::c_char; UT_NAMESIZE], + pub ut_host: [::c_char; UT_HOSTSIZE], + pub ut_time: ::time_t + } + + pub struct lastlog { + pub ll_line: [::c_char; UT_LINESIZE], + pub ll_host: [::c_char; UT_HOSTSIZE], + pub ll_time: ::time_t + } } s_no_extra_traits! { @@ -1517,6 +1530,9 @@ pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS; // pub const _PATH_WTMPX: &[::c_char; 14] = b"/var/log/wtmpx"; // pub const _PATH_LASTLOGX: &[::c_char; 17] = b"/var/log/lastlogx"; // pub const _PATH_UTMP_UPDATE: &[::c_char; 24] = b"/usr/libexec/utmp_update"; +pub const UT_NAMESIZE: usize = 8; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; pub const _UTX_USERSIZE: usize = 32; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_PADSIZE: usize = 40; @@ -1914,9 +1930,14 @@ extern "C" { pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn setutxent(); pub fn endutxent(); -// TODO: uncomment after utmp implementation -// pub fn getutmp(ux: *const utmpx, u: *mut utmp); -// pub fn getutmpx(u: *const utmp, ux: *mut utmpx); + + pub fn getutmp(ux: *const utmpx, u: *mut utmp); + pub fn getutmpx(u: *const utmp, ux: *mut utmpx); + + pub fn utpname(file: *const ::c_char) -> ::c_int; + pub fn setutent(); + pub fn endutent(); + pub fn getutent() -> *mut utmp; } cfg_if! { From 4f11029a68040c90acf771976b019c1ef273a8cd Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Fri, 29 Nov 2019 13:21:20 +0100 Subject: [PATCH 61/61] Bump patch version to 0.2.66 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 70f49e15e810..c701f41f2a0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.65" +version = "0.2.66" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md"