summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/bors.yml17
-rw-r--r--Cargo.toml6
-rw-r--r--build.rs105
-rw-r--r--libc-test/Cargo.toml12
-rw-r--r--libc-test/build.rs19
-rw-r--r--libc-test/semver/android.txt10
-rw-r--r--libc-test/semver/linux-musl.txt1
-rw-r--r--libc-test/semver/linux.txt10
-rw-r--r--src/unix/linux_like/android/mod.rs12
-rw-r--r--src/unix/linux_like/linux/align.rs11
-rw-r--r--src/unix/linux_like/linux/arch/generic/mod.rs4
-rw-r--r--src/unix/linux_like/linux/gnu/mod.rs8
-rw-r--r--src/unix/linux_like/linux/mod.rs167
-rw-r--r--src/unix/linux_like/linux/musl/mod.rs27
-rw-r--r--src/unix/linux_like/linux/no_align.rs12
-rw-r--r--src/unix/linux_like/mod.rs30
-rw-r--r--src/unix/mod.rs25
-rw-r--r--src/wasi.rs5
18 files changed, 337 insertions, 144 deletions
diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml
index 49a06de686..e4e342a1b3 100644
--- a/.github/workflows/bors.yml
+++ b/.github/workflows/bors.yml
@@ -317,6 +317,23 @@ jobs:
run: LIBC_CI=1 TOOLCHAIN=${{ matrix.toolchain }} WIN_TARGET=${{ matrix.target }} sh ./ci/build.sh
shell: bash
+ check_cfg:
+ permissions:
+ actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
+ contents: read # to fetch code (actions/checkout)
+
+ name: "Check #[cfg]s"
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
+ with:
+ github_token: "${{ secrets.GITHUB_TOKEN }}"
+ - uses: actions/checkout@v3
+ - name: Setup Rust toolchain
+ run: TOOLCHAIN=nightly sh ./ci/install-rust.sh
+ - name: Build with check-cfg
+ run: LIBC_CI=1 LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg=features,names,values,output
+
docs:
permissions:
actions: write # to cancel workflows (rust-lang/simpleinfra/github-actions/cancel-outdated-builds)
diff --git a/Cargo.toml b/Cargo.toml
index 15c2b9bf53..3721096743 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,13 +1,13 @@
[package]
name = "libc"
-version = "0.2.139"
+version = "0.2.140"
authors = ["The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/rust-lang/libc"
homepage = "https://github.com/rust-lang/libc"
documentation = "https://docs.rs/libc/"
-keywords = ["libc", "ffi", "bindings", "operating", "system" ]
+keywords = ["libc", "ffi", "bindings", "operating", "system"]
categories = ["external-ffi-bindings", "no-std", "os"]
build = "build.rs"
exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"]
@@ -29,7 +29,7 @@ rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
extra_traits = []
const-extern-fn = []
# use_std is deprecated, use `std` instead
-use_std = [ 'std' ]
+use_std = ['std']
[workspace]
members = ["libc-test"]
diff --git a/build.rs b/build.rs
index e97be1a6ab..e60672a761 100644
--- a/build.rs
+++ b/build.rs
@@ -2,6 +2,40 @@ use std::env;
use std::process::Command;
use std::str;
+// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
+// need to know all the possible cfgs that this script will set. If you need to set another cfg
+// make sure to add it to this list as well.
+const ALLOWED_CFGS: &'static [&'static str] = &[
+ "freebsd10",
+ "freebsd11",
+ "freebsd12",
+ "freebsd13",
+ "freebsd14",
+ "libc_align",
+ "libc_cfg_target_vendor",
+ "libc_const_extern_fn",
+ "libc_const_extern_fn_unstable",
+ "libc_const_size_of",
+ "libc_core_cvoid",
+ "libc_deny_warnings",
+ "libc_int128",
+ "libc_long_array",
+ "libc_non_exhaustive",
+ "libc_packedN",
+ "libc_priv_mod_use",
+ "libc_ptr_addr_of",
+ "libc_thread_local",
+ "libc_underscore_const_names",
+ "libc_union",
+];
+
+// Extra values to allow for check-cfg.
+const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
+ ("target_os", &["switch", "aix", "ohos"]),
+ ("target_env", &["illumos", "wasi", "aix", "ohos"]),
+ ("target_arch", &["loongarch64"]),
+];
+
fn main() {
// Avoid unnecessary re-building.
println!("cargo:rerun-if-changed=build.rs");
@@ -11,6 +45,7 @@ fn main() {
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();
+ let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok();
if env::var("CARGO_FEATURE_USE_STD").is_ok() {
println!(
@@ -25,94 +60,107 @@ fn main() {
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
// running tests to ensure that the ABI is correct.
match which_freebsd() {
- Some(10) if libc_ci || rustc_dep_of_std => {
- println!("cargo:rustc-cfg=freebsd10")
- }
- Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
- Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
- Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"),
- Some(14) if libc_ci => println!("cargo:rustc-cfg=freebsd14"),
- Some(_) | None => println!("cargo:rustc-cfg=freebsd11"),
+ Some(10) if libc_ci || rustc_dep_of_std => set_cfg("freebsd10"),
+ Some(11) if libc_ci => set_cfg("freebsd11"),
+ Some(12) if libc_ci => set_cfg("freebsd12"),
+ Some(13) if libc_ci => set_cfg("freebsd13"),
+ Some(14) if libc_ci => set_cfg("freebsd14"),
+ Some(_) | None => set_cfg("freebsd11"),
}
// On CI: deny all warnings
if libc_ci {
- println!("cargo:rustc-cfg=libc_deny_warnings");
+ set_cfg("libc_deny_warnings");
}
// Rust >= 1.15 supports private module use:
if rustc_minor_ver >= 15 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_priv_mod_use");
+ set_cfg("libc_priv_mod_use");
}
// Rust >= 1.19 supports unions:
if rustc_minor_ver >= 19 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_union");
+ set_cfg("libc_union");
}
// Rust >= 1.24 supports const mem::size_of:
if rustc_minor_ver >= 24 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_const_size_of");
+ set_cfg("libc_const_size_of");
}
// Rust >= 1.25 supports repr(align):
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
- println!("cargo:rustc-cfg=libc_align");
+ set_cfg("libc_align");
}
// Rust >= 1.26 supports i128 and u128:
if rustc_minor_ver >= 26 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_int128");
+ set_cfg("libc_int128");
}
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
// Otherwise, it defines an incompatible type to retaining
// backwards-compatibility.
if rustc_minor_ver >= 30 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_core_cvoid");
+ set_cfg("libc_core_cvoid");
}
// Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor).
if rustc_minor_ver >= 33 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_packedN");
- println!("cargo:rustc-cfg=libc_cfg_target_vendor");
+ set_cfg("libc_packedN");
+ set_cfg("libc_cfg_target_vendor");
}
// Rust >= 1.40 supports #[non_exhaustive].
if rustc_minor_ver >= 40 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_non_exhaustive");
+ set_cfg("libc_non_exhaustive");
}
// Rust >= 1.47 supports long array:
if rustc_minor_ver >= 47 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_long_array");
+ set_cfg("libc_long_array");
}
if rustc_minor_ver >= 51 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_ptr_addr_of");
+ set_cfg("libc_ptr_addr_of");
}
// Rust >= 1.37.0 allows underscores as anonymous constant names.
if rustc_minor_ver >= 37 || rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_underscore_const_names");
+ set_cfg("libc_underscore_const_names");
}
// #[thread_local] is currently unstable
if rustc_dep_of_std {
- println!("cargo:rustc-cfg=libc_thread_local");
+ set_cfg("libc_thread_local");
}
// Rust >= 1.62.0 allows to use `const_extern_fn` for "Rust" and "C".
if rustc_minor_ver >= 62 {
- println!("cargo:rustc-cfg=libc_const_extern_fn");
+ set_cfg("libc_const_extern_fn");
} else {
// Rust < 1.62.0 requires a crate feature and feature gate.
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_unstable");
- println!("cargo:rustc-cfg=libc_const_extern_fn");
+ set_cfg("libc_const_extern_fn_unstable");
+ set_cfg("libc_const_extern_fn");
+ }
+ }
+
+ // check-cfg is a nightly cargo/rustc feature to warn when unknown cfgs are used across the
+ // codebase. libc can configure it if the appropriate environment variable is passed. Since
+ // rust-lang/rust enforces it, this is useful when using a custom libc fork there.
+ //
+ // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg
+ if libc_check_cfg {
+ for cfg in ALLOWED_CFGS {
+ println!("cargo:rustc-check-cfg=values({})", cfg);
+ }
+ for &(name, values) in CHECK_CFG_EXTRA {
+ let values = values.join("\",\"");
+ println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
}
}
}
@@ -181,3 +229,10 @@ fn which_freebsd() -> Option<i32> {
_ => None,
}
}
+
+fn set_cfg(cfg: &str) {
+ if !ALLOWED_CFGS.contains(&cfg) {
+ panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg);
+ }
+ println!("cargo:rustc-cfg={}", cfg);
+}
diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml
index e291270b05..8cd125934a 100644
--- a/libc-test/Cargo.toml
+++ b/libc-test/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "libc-test"
-version = "0.2.139"
+version = "0.2.140"
authors = ["The Rust Project Developers"]
license = "MIT OR Apache-2.0"
build = "build.rs"
@@ -12,7 +12,7 @@ A test crate for the libc crate.
[dependencies.libc]
path = ".."
-version = "0.2.139"
+version = "0.2.140"
default-features = false
[build-dependencies]
@@ -21,10 +21,10 @@ cc = "1.0.61"
ctest2 = "0.4.3"
[features]
-default = [ "std" ]
-std = [ "libc/std" ]
-align = [ "libc/align" ]
-extra_traits = [ "libc/extra_traits" ]
+default = ["std"]
+std = ["libc/std"]
+align = ["libc/align"]
+extra_traits = ["libc/extra_traits"]
[[test]]
name = "main"
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 73c1c8fdb4..80b73e911b 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1632,6 +1632,7 @@ fn test_android(target: &str) {
"linux/rtnetlink.h",
"linux/if_tun.h",
"linux/magic.h",
+ "linux/membarrier.h",
"linux/memfd.h",
"linux/mempolicy.h",
"linux/module.h",
@@ -1783,6 +1784,9 @@ fn test_android(target: &str) {
// GRND_INSECURE was added in platform-tools-30.0.0
"GRND_INSECURE" => true,
+ // kernel 5.10 minimum required
+ "MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ" | "MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ" => true,
+
_ => false,
}
});
@@ -2271,6 +2275,10 @@ fn test_freebsd(target: &str) {
// Added in FreeBSD 14
"IFCAP_NV" if Some(14) > freebsd_ver => true,
+ // Removed in https://reviews.freebsd.org/D38574 and https://reviews.freebsd.org/D38822
+ // We maybe should deprecate them once a stable release ships them.
+ "IP_BINDMULTI" | "IP_RSS_LISTEN_BUCKET" => true,
+
_ => false,
}
});
@@ -3073,7 +3081,7 @@ fn test_linux(target: &str) {
// target_env
let gnu = target.contains("gnu");
- let musl = target.contains("musl");
+ let musl = target.contains("musl") || target.contains("ohos");
let uclibc = target.contains("uclibc");
match (gnu, musl, uclibc) {
@@ -3245,6 +3253,7 @@ fn test_linux(target: &str) {
"linux/keyctl.h",
"linux/magic.h",
"linux/memfd.h",
+ "linux/membarrier.h",
"linux/mempolicy.h",
"linux/mman.h",
"linux/module.h",
@@ -3480,6 +3489,12 @@ fn test_linux(target: &str) {
{
return true;
}
+ // FIXME: Requires >= 5.10 kernel headers
+ if name.starts_with("MEMBARRIER_CMD_REGISTER")
+ || name.starts_with("MEMBARRIER_CMD_PRIVATE")
+ {
+ return true;
+ }
}
match name {
// These constants are not available if gnu headers have been included
@@ -3931,7 +3946,7 @@ fn test_linux(target: &str) {
// are included (e.g. because including both sets of headers clashes)
fn test_linux_like_apis(target: &str) {
let gnu = target.contains("gnu");
- let musl = target.contains("musl");
+ let musl = target.contains("musl") || target.contains("ohos");
let linux = target.contains("linux");
let emscripten = target.contains("emscripten");
let android = target.contains("android");
diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt
index 3bee01ca18..d0017b846c 100644
--- a/libc-test/semver/android.txt
+++ b/libc-test/semver/android.txt
@@ -1164,6 +1164,16 @@ MCAST_MSFILTER
MCAST_UNBLOCK_SOURCE
MCL_CURRENT
MCL_FUTURE
+MEMBARRIER_CMD_GLOBAL
+MEMBARRIER_CMD_GLOBAL_EXPEDITED
+MEMBARRIER_CMD_QUERY
+MEMBARRIER_CMD_PRIVATE_EXPEDITED
+MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
+MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ
+MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED
+MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED
+MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE
+MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ
MFD_ALLOW_SEALING
MFD_CLOEXEC
MFD_HUGETLB
diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt
index 9fbb9032c3..09c461350f 100644
--- a/libc-test/semver/linux-musl.txt
+++ b/libc-test/semver/linux-musl.txt
@@ -33,6 +33,7 @@ aio_suspend
aio_write
aiocb
clock_adjtime
+copy_file_range
ctermid
explicit_bzero
futimes
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index 1b17b62d96..cdb0079144 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -1317,6 +1317,16 @@ MCAST_MSFILTER
MCAST_UNBLOCK_SOURCE
MCL_CURRENT
MCL_FUTURE
+MEMBARRIER_CMD_GLOBAL
+MEMBARRIER_CMD_GLOBAL_EXPEDITED
+MEMBARRIER_CMD_QUERY
+MEMBARRIER_CMD_PRIVATE_EXPEDITED
+MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
+MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ
+MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED
+MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED
+MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE
+MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ
MFD_ALLOW_SEALING
MFD_CLOEXEC
MFD_HUGETLB
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 2bc748ac4c..ca2938ac22 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -2732,6 +2732,18 @@ pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000;
pub const CLONE_PIDFD: ::c_int = 0x1000;
+// linux/membarrier.h
+pub const MEMBARRIER_CMD_QUERY: ::c_int = 0;
+pub const MEMBARRIER_CMD_GLOBAL: ::c_int = 1 << 0;
+pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: ::c_int = 1 << 1;
+pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: ::c_int = 1 << 2;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: ::c_int = 1 << 3;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: ::c_int = 1 << 4;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 5;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 6;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 7;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 8;
+
// linux/mempolicy.h
pub const MPOL_DEFAULT: ::c_int = 0;
pub const MPOL_PREFERRED: ::c_int = 1;
diff --git a/src/unix/linux_like/linux/align.rs b/src/unix/linux_like/linux/align.rs
index 60afbb200c..cd4bbc7213 100644
--- a/src/unix/linux_like/linux/align.rs
+++ b/src/unix/linux_like/linux/align.rs
@@ -28,9 +28,10 @@ macro_rules! expand_align {
size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
}
- #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"),
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos", target_pointer_width = "32"),
repr(align(4)))]
#[cfg_attr(all(not(target_env = "musl"),
+ not(target_env = "ohos"),
target_pointer_width = "64"),
repr(align(8)))]
pub struct pthread_rwlockattr_t {
@@ -63,16 +64,16 @@ macro_rules! expand_align {
}
s_no_extra_traits! {
- #[cfg_attr(all(target_env = "musl",
+ #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"),
target_pointer_width = "32"),
repr(align(4)))]
- #[cfg_attr(all(target_env = "musl",
+ #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"),
target_pointer_width = "64"),
repr(align(8)))]
- #[cfg_attr(all(not(target_env = "musl"),
+ #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")),
target_arch = "x86"),
repr(align(4)))]
- #[cfg_attr(all(not(target_env = "musl"),
+ #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")),
not(target_arch = "x86")),
repr(align(8)))]
pub struct pthread_cond_t {
diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs
index 40bc30a4f3..cffe748de9 100644
--- a/src/unix/linux_like/linux/arch/generic/mod.rs
+++ b/src/unix/linux_like/linux/arch/generic/mod.rs
@@ -95,7 +95,7 @@ cfg_if! {
if #[cfg(all(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64"),
- not(target_env = "musl")))] {
+ not(any(target_env = "musl", target_env = "ohos"))))] {
pub const SO_TIMESTAMP_NEW: ::c_int = 63;
pub const SO_TIMESTAMPNS_NEW: ::c_int = 64;
pub const SO_TIMESTAMPING_NEW: ::c_int = 65;
@@ -252,7 +252,7 @@ cfg_if! {
pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15;
pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS;
- } else if #[cfg(target_env = "musl")] {
+ } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
pub const RLIMIT_CPU: ::c_int = 0;
pub const RLIMIT_FSIZE: ::c_int = 1;
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index 1ee1ec70d0..0d2eb32eb4 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -1191,14 +1191,6 @@ extern "C" {
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
- pub fn copy_file_range(
- fd_in: ::c_int,
- off_in: *mut ::off64_t,
- fd_out: ::c_int,
- off_out: *mut ::off64_t,
- len: ::size_t,
- flags: ::c_uint,
- ) -> ::ssize_t;
pub fn fanotify_mark(
fd: ::c_int,
flags: ::c_uint,
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index b2246300fd..1d272d601d 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -471,9 +471,9 @@ s! {
__pgrp: ::pid_t,
__sd: ::sigset_t,
__ss: ::sigset_t,
- #[cfg(target_env = "musl")]
+ #[cfg(any(target_env = "musl", target_env = "ohos"))]
__prio: ::c_int,
- #[cfg(not(target_env = "musl"))]
+ #[cfg(not(any(target_env = "musl", target_env = "ohos")))]
__sp: ::sched_param,
__policy: ::c_int,
__pad: [::c_int; 16],
@@ -1225,7 +1225,7 @@ cfg_if! {
}
cfg_if! {
- if #[cfg(any(target_env = "gnu", target_env = "musl"))] {
+ if #[cfg(any(target_env = "gnu", target_env = "musl", target_env = "ohos"))] {
pub const ABDAY_1: ::nl_item = 0x20000;
pub const ABDAY_2: ::nl_item = 0x20001;
pub const ABDAY_3: ::nl_item = 0x20002;
@@ -1849,6 +1849,18 @@ pub const MPOL_F_NUMA_BALANCING: ::c_int = 1 << 13;
pub const MPOL_F_RELATIVE_NODES: ::c_int = 1 << 14;
pub const MPOL_F_STATIC_NODES: ::c_int = 1 << 15;
+// linux/membarrier.h
+pub const MEMBARRIER_CMD_QUERY: ::c_int = 0;
+pub const MEMBARRIER_CMD_GLOBAL: ::c_int = 1 << 0;
+pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: ::c_int = 1 << 1;
+pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: ::c_int = 1 << 2;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: ::c_int = 1 << 3;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: ::c_int = 1 << 4;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 5;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 6;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 7;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 8;
+
align_const! {
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
size: [0; __SIZEOF_PTHREAD_MUTEX_T],
@@ -3979,7 +3991,7 @@ safe_f! {
}
cfg_if! {
- if #[cfg(not(target_env = "uclibc"))] {
+ if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] {
extern "C" {
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
@@ -3998,6 +4010,13 @@ cfg_if! {
nitems: ::c_int,
sevp: *mut ::sigevent,
) -> ::c_int;
+ }
+ }
+}
+
+cfg_if! {
+ if #[cfg(not(target_env = "uclibc"))] {
+ extern "C" {
pub fn pwritev(
fd: ::c_int,
iov: *const ::iovec,
@@ -4047,8 +4066,79 @@ cfg_if! {
}
}
+// These functions are not available on OpenHarmony
+cfg_if! {
+ if #[cfg(not(target_env = "ohos"))] {
+ extern "C" {
+ // Only `getspnam_r` is implemented for musl, out of all of the reenterant
+ // functions from `shadow.h`.
+ // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
+ pub fn getspnam_r(
+ name: *const ::c_char,
+ spbuf: *mut spwd,
+ buf: *mut ::c_char,
+ buflen: ::size_t,
+ spbufp: *mut *mut spwd,
+ ) -> ::c_int;
+
+ pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int;
+ pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
+
+ pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
+ pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
+ pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
+ pub fn mq_receive(
+ mqd: ::mqd_t,
+ msg_ptr: *mut ::c_char,
+ msg_len: ::size_t,
+ msg_prio: *mut ::c_uint,
+ ) -> ::ssize_t;
+ pub fn mq_timedreceive(
+ mqd: ::mqd_t,
+ msg_ptr: *mut ::c_char,
+ msg_len: ::size_t,
+ msg_prio: *mut ::c_uint,
+ abs_timeout: *const ::timespec,
+ ) -> ::ssize_t;
+ pub fn mq_send(
+ mqd: ::mqd_t,
+ msg_ptr: *const ::c_char,
+ msg_len: ::size_t,
+ msg_prio: ::c_uint,
+ ) -> ::c_int;
+ pub fn mq_timedsend(
+ mqd: ::mqd_t,
+ msg_ptr: *const ::c_char,
+ msg_len: ::size_t,
+ msg_prio: ::c_uint,
+ abs_timeout: *const ::timespec,
+ ) -> ::c_int;
+ pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
+ pub fn mq_setattr(
+ mqd: ::mqd_t,
+ newattr: *const ::mq_attr,
+ oldattr: *mut ::mq_attr
+ ) -> ::c_int;
+
+ pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int;
+ pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
+ pub fn pthread_mutexattr_getrobust(
+ attr: *const pthread_mutexattr_t,
+ robustness: *mut ::c_int,
+ ) -> ::c_int;
+ pub fn pthread_mutexattr_setrobust(
+ attr: *mut pthread_mutexattr_t,
+ robustness: ::c_int,
+ ) -> ::c_int;
+ }
+ }
+}
+
extern "C" {
- #[cfg_attr(not(target_env = "musl"), link_name = "__xpg_strerror_r")]
+ #[cfg_attr(
+ not(any(target_env = "musl", target_env = "ohos")),
+ link_name = "__xpg_strerror_r"
+ )]
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
pub fn abs(i: ::c_int) -> ::c_int;
@@ -4079,18 +4169,6 @@ extern "C" {
pub fn getspent() -> *mut spwd;
pub fn getspnam(name: *const ::c_char) -> *mut spwd;
- // Only `getspnam_r` is implemented for musl, out of all of the reenterant
- // functions from `shadow.h`.
- // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
- pub fn getspnam_r(
- name: *const ::c_char,
- spbuf: *mut spwd,
- buf: *mut ::c_char,
- buflen: ::size_t,
- spbufp: *mut *mut spwd,
- ) -> ::c_int;
-
- pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int;
// System V IPC
pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int;
@@ -4196,37 +4274,6 @@ extern "C" {
id: ::c_int,
data: *mut ::c_char,
) -> ::c_int;
- pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t;
- pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
- pub fn mq_unlink(name: *const ::c_char) -> ::c_int;
- pub fn mq_receive(
- mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msg_prio: *mut ::c_uint,
- ) -> ::ssize_t;
- pub fn mq_timedreceive(
- mqd: ::mqd_t,
- msg_ptr: *mut ::c_char,
- msg_len: ::size_t,
- msg_prio: *mut ::c_uint,
- abs_timeout: *const ::timespec,
- ) -> ::ssize_t;
- pub fn mq_send(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_prio: ::c_uint,
- ) -> ::c_int;
- pub fn mq_timedsend(
- mqd: ::mqd_t,
- msg_ptr: *const ::c_char,
- msg_len: ::size_t,
- msg_prio: ::c_uint,
- abs_timeout: *const ::timespec,
- ) -> ::c_int;
- pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
- pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int;
pub fn epoll_pwait(
epfd: ::c_int,
events: *mut ::epoll_event,
@@ -4293,8 +4340,6 @@ extern "C" {
pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
- pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-
pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
@@ -4398,7 +4443,7 @@ extern "C" {
attr: *mut pthread_mutexattr_t,
protocol: ::c_int,
) -> ::c_int;
- pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int;
+
pub fn pthread_mutex_timedlock(
lock: *mut pthread_mutex_t,
abstime: *const ::timespec,
@@ -4496,7 +4541,6 @@ extern "C" {
pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int;
pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
- pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
@@ -4531,14 +4575,6 @@ extern "C" {
attr: *const pthread_mutexattr_t,
pshared: *mut ::c_int,
) -> ::c_int;
- pub fn pthread_mutexattr_getrobust(
- attr: *const pthread_mutexattr_t,
- robustness: *mut ::c_int,
- ) -> ::c_int;
- pub fn pthread_mutexattr_setrobust(
- attr: *mut pthread_mutexattr_t,
- robustness: ::c_int,
- ) -> ::c_int;
pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
pub fn faccessat(
dirfd: ::c_int,
@@ -4723,13 +4759,22 @@ extern "C" {
longopts: *const option,
longindex: *mut ::c_int,
) -> ::c_int;
+
+ pub fn copy_file_range(
+ fd_in: ::c_int,
+ off_in: *mut ::off64_t,
+ fd_out: ::c_int,
+ off_out: *mut ::off64_t,
+ len: ::size_t,
+ flags: ::c_uint,
+ ) -> ::ssize_t;
}
cfg_if! {
if #[cfg(target_env = "uclibc")] {
mod uclibc;
pub use self::uclibc::*;
- } else if #[cfg(target_env = "musl")] {
+ } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
mod musl;
pub use self::musl::*;
} else if #[cfg(target_env = "gnu")] {
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index 454ab53eb1..37a8ca2aff 100644
--- a/src/unix/linux_like/linux/musl/mod.rs
+++ b/src/unix/linux_like/linux/musl/mod.rs
@@ -287,12 +287,14 @@ s_no_extra_traits! {
// FIXME: musl added paddings and adjusted
// layout in 1.2.0 but our CI is still 1.1.24.
- // So, I'm leaving some fields as comments for now.
+ // So, I'm leaving some fields as cfg for now.
// ref. https://github.com/bminor/musl/commit/
// 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392
+ //
+ // OpenHarmony uses the musl 1.2 layout.
pub struct utmpx {
pub ut_type: ::c_short,
- //__ut_pad1: ::c_short,
+ __ut_pad1: ::c_short,
pub ut_pid: ::pid_t,
pub ut_line: [::c_char; 32],
pub ut_id: [::c_char; 4],
@@ -300,15 +302,22 @@ s_no_extra_traits! {
pub ut_host: [::c_char; 256],
pub ut_exit: __exit_status,
- //#[cfg(target_endian = "little")]
+ #[cfg(target_env = "musl")]
pub ut_session: ::c_long,
- //#[cfg(target_endian = "little")]
- //__ut_pad2: ::c_long,
- //#[cfg(not(target_endian = "little"))]
- //__ut_pad2: ::c_int,
- //#[cfg(not(target_endian = "little"))]
- //pub ut_session: ::c_int,
+ #[cfg(target_env = "ohos")]
+ #[cfg(target_endian = "little")]
+ pub ut_session: ::c_int,
+ #[cfg(target_env = "ohos")]
+ #[cfg(target_endian = "little")]
+ __ut_pad2: ::c_int,
+
+ #[cfg(target_env = "ohos")]
+ #[cfg(not(target_endian = "little"))]
+ __ut_pad2: ::c_int,
+ #[cfg(target_env = "ohos")]
+ #[cfg(not(target_endian = "little"))]
+ pub ut_session: ::c_int,
pub ut_tv: ::timeval,
pub ut_addr_v6: [::c_uint; 4],
diff --git a/src/unix/linux_like/linux/no_align.rs b/src/unix/linux_like/linux/no_align.rs
index 351340ed24..6f5f2f7c01 100644
--- a/src/unix/linux_like/linux/no_align.rs
+++ b/src/unix/linux_like/linux/no_align.rs
@@ -11,7 +11,7 @@ macro_rules! expand_align {
target_arch = "riscv32",
target_arch = "loongarch64",
all(target_arch = "aarch64",
- target_env = "musl")))]
+ any(target_env = "musl", target_env = "ohos"))))]
__align: [::c_int; 0],
#[cfg(not(any(target_arch = "x86_64",
target_arch = "powerpc64",
@@ -22,15 +22,15 @@ macro_rules! expand_align {
target_arch = "riscv32",
target_arch = "loongarch64",
all(target_arch = "aarch64",
- target_env = "musl"))))]
+ any(target_env = "musl", target_env = "ohos")))))]
__align: [::c_long; 0],
size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
}
pub struct pthread_rwlockattr_t {
- #[cfg(target_env = "musl")]
+ #[cfg(any(target_env = "musl", target_env = "ohos"))]
__align: [::c_int; 0],
- #[cfg(not(target_env = "musl"))]
+ #[cfg(not(any(target_env = "musl", target_env = "ohos")))]
__align: [::c_long; 0],
size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
}
@@ -59,9 +59,9 @@ macro_rules! expand_align {
s_no_extra_traits! {
pub struct pthread_cond_t {
- #[cfg(target_env = "musl")]
+ #[cfg(any(target_env = "musl", target_env = "ohos"))]
__align: [*const ::c_void; 0],
- #[cfg(not(target_env = "musl"))]
+ #[cfg(not(any(target_env = "musl", target_env = "ohos")))]
__align: [::c_longlong; 0],
size: [u8; ::__SIZEOF_PTHREAD_COND_T],
}
diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs
index 20d0006bd4..db57745967 100644
--- a/src/unix/linux_like/mod.rs
+++ b/src/unix/linux_like/mod.rs
@@ -108,13 +108,13 @@ s! {
pub struct sched_param {
pub sched_priority: ::c_int,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
+ #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_low_priority: ::c_int,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
+ #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_repl_period: ::timespec,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
+ #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_init_budget: ::timespec,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
+ #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_max_repl: ::c_int,
}
@@ -557,7 +557,21 @@ pub const XATTR_CREATE: ::c_int = 0x1;
pub const XATTR_REPLACE: ::c_int = 0x2;
cfg_if! {
- if #[cfg(not(target_env = "uclibc"))] {
+ if #[cfg(target_env = "ohos")] {
+ pub const LC_CTYPE: ::c_int = 0;
+ pub const LC_NUMERIC: ::c_int = 1;
+ pub const LC_TIME: ::c_int = 2;
+ pub const LC_COLLATE: ::c_int = 3;
+ pub const LC_MONETARY: ::c_int = 4;
+ pub const LC_MESSAGES: ::c_int = 5;
+ pub const LC_PAPER: ::c_int = 6;
+ pub const LC_NAME: ::c_int = 7;
+ pub const LC_ADDRESS: ::c_int = 8;
+ pub const LC_TELEPHONE: ::c_int = 9;
+ pub const LC_MEASUREMENT: ::c_int = 10;
+ pub const LC_IDENTIFICATION: ::c_int = 11;
+ pub const LC_ALL: ::c_int = 12;
+ } else if #[cfg(not(target_env = "uclibc"))] {
pub const LC_CTYPE: ::c_int = 0;
pub const LC_NUMERIC: ::c_int = 1;
pub const LC_TIME: ::c_int = 2;
@@ -973,7 +987,11 @@ pub const TCP_QUICKACK: ::c_int = 12;
pub const TCP_CONGESTION: ::c_int = 13;
pub const TCP_MD5SIG: ::c_int = 14;
cfg_if! {
- if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "musl")))] {
+ if #[cfg(all(target_os = "linux", any(
+ target_env = "gnu",
+ target_env = "musl",
+ target_env = "ohos"
+ )))] {
// WARN: deprecated
pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
}
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 49c2d5717a..b005970b9d 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -130,7 +130,7 @@ s! {
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad14: u32,
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
+ #[cfg(any(target_env = "musl", target_env = "ohos", target_os = "emscripten"))]
__reserved: [c_long; 16],
}
@@ -351,7 +351,7 @@ cfg_if! {
#[link(name = "dl", cfg(not(target_feature = "crt-static")))]
#[link(name = "c", cfg(not(target_feature = "crt-static")))]
extern {}
- } else if #[cfg(target_env = "musl")] {
+ } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
#[cfg_attr(feature = "rustc-dep-of-std",
link(name = "c", kind = "static", modifiers = "-bundle",
cfg(target_feature = "crt-static")))]
@@ -1217,7 +1217,10 @@ extern "C" {
pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
#[cfg_attr(
any(
- all(target_os = "linux", not(target_env = "musl")),
+ all(
+ target_os = "linux",
+ not(any(target_env = "musl", target_env = "ohos"))
+ ),
target_os = "freebsd",
target_os = "dragonfly",
target_os = "haiku"
@@ -1236,11 +1239,11 @@ extern "C" {
pub fn res_init() -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
#[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
#[cfg_attr(
@@ -1248,27 +1251,27 @@ extern "C" {
link_name = "mktime$UNIX2003"
)]
#[cfg_attr(target_os = "netbsd", link_name = "__mktime50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn mktime(tm: *mut tm) -> time_t;
#[cfg_attr(target_os = "netbsd", link_name = "__time50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn time(time: *mut time_t) -> time_t;
#[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn gmtime(time_p: *const time_t) -> *mut tm;
#[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn localtime(time_p: *const time_t) -> *mut tm;
#[cfg_attr(target_os = "netbsd", link_name = "__difftime50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn difftime(time1: time_t, time0: time_t) -> ::c_double;
#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
- #[cfg_attr(target_env = "musl", allow(deprecated))]
+ #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))]
// FIXME: for `time_t`
pub fn timegm(tm: *mut ::tm) -> time_t;
diff --git a/src/wasi.rs b/src/wasi.rs
index abfebd6439..1a855e0e0f 100644
--- a/src/wasi.rs
+++ b/src/wasi.rs
@@ -246,12 +246,15 @@ pub const S_IFREG: mode_t = 32768;
pub const S_IFLNK: mode_t = 40960;
pub const S_IFSOCK: mode_t = 49152;
pub const S_IFMT: mode_t = 57344;
+pub const S_IRWXO: mode_t = 0x7;
pub const S_IXOTH: mode_t = 0x1;
pub const S_IWOTH: mode_t = 0x2;
pub const S_IROTH: mode_t = 0x4;
+pub const S_IRWXG: mode_t = 0x38;
pub const S_IXGRP: mode_t = 0x8;
pub const S_IWGRP: mode_t = 0x10;
pub const S_IRGRP: mode_t = 0x20;
+pub const S_IRWXU: mode_t = 0x1c0;
pub const S_IXUSR: mode_t = 0x40;
pub const S_IWUSR: mode_t = 0x80;
pub const S_IRUSR: mode_t = 0x100;
@@ -822,4 +825,6 @@ extern "C" {
pub fn arc4random() -> u32;
pub fn arc4random_buf(a: *mut c_void, b: size_t);
pub fn arc4random_uniform(a: u32) -> u32;
+
+ pub fn __errno_location() -> *mut ::c_int;
}