From 72ffd545a33dec6d1e20ccdcd141f23a613d87fb Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 29 Jan 2025 20:07:14 +0100 Subject: [PATCH] [#604] Use the libc crate --- Cargo.Bazel.lock | 38 +- Cargo.lock | 5 +- Cargo.toml | 1 + iceoryx2-bb/posix/Cargo.toml | 8 + iceoryx2-pal/posix/Cargo.toml | 9 + iceoryx2-pal/posix/build.rs | 16 +- iceoryx2-pal/posix/src/freebsd/constants.rs | 6 - iceoryx2-pal/posix/src/freebsd/fcntl.rs | 2 +- iceoryx2-pal/posix/src/freebsd/pthread.rs | 16 +- iceoryx2-pal/posix/src/freebsd/stat.rs | 2 +- iceoryx2-pal/posix/src/freebsd/types.rs | 11 +- iceoryx2-pal/posix/src/lib.rs | 25 +- iceoryx2-pal/posix/src/libc/constants.rs | 581 ++++++++++---------- iceoryx2-pal/posix/src/libc/dirent.rs | 12 +- iceoryx2-pal/posix/src/libc/errno.rs | 14 +- iceoryx2-pal/posix/src/libc/fcntl.rs | 16 +- iceoryx2-pal/posix/src/libc/inet.rs | 8 +- iceoryx2-pal/posix/src/libc/mman.rs | 18 +- iceoryx2-pal/posix/src/libc/mod.rs | 44 +- iceoryx2-pal/posix/src/libc/pthread.rs | 131 ++--- iceoryx2-pal/posix/src/libc/pwd.rs | 8 +- iceoryx2-pal/posix/src/libc/resource.rs | 4 +- iceoryx2-pal/posix/src/libc/sched.rs | 14 +- iceoryx2-pal/posix/src/libc/select.rs | 37 +- iceoryx2-pal/posix/src/libc/semaphore.rs | 20 +- iceoryx2-pal/posix/src/libc/signal.rs | 27 +- iceoryx2-pal/posix/src/libc/socket.rs | 26 +- iceoryx2-pal/posix/src/libc/stat.rs | 6 +- iceoryx2-pal/posix/src/libc/stdio.rs | 2 +- iceoryx2-pal/posix/src/libc/stdlib.rs | 8 +- iceoryx2-pal/posix/src/libc/string.rs | 6 +- iceoryx2-pal/posix/src/libc/time.rs | 6 +- iceoryx2-pal/posix/src/libc/types.rs | 109 ++-- iceoryx2-pal/posix/src/libc/unistd.rs | 38 +- iceoryx2-pal/posix/src/linux/constants.rs | 7 - iceoryx2-pal/posix/src/linux/fcntl.rs | 2 +- iceoryx2-pal/posix/src/linux/pthread.rs | 22 +- iceoryx2-pal/posix/src/linux/stat.rs | 2 +- iceoryx2-pal/posix/src/linux/types.rs | 11 +- iceoryx2-pal/posix/src/macos/constants.rs | 2 - iceoryx2-pal/posix/src/macos/fcntl.rs | 2 +- iceoryx2-pal/posix/src/macos/stat.rs | 2 +- iceoryx2-pal/posix/src/macos/types.rs | 8 +- iceoryx2-pal/posix/src/windows/constants.rs | 4 +- iceoryx2-pal/posix/src/windows/types.rs | 6 - iceoryx2/Cargo.toml | 6 + 46 files changed, 677 insertions(+), 671 deletions(-) diff --git a/Cargo.Bazel.lock b/Cargo.Bazel.lock index de60b4461..8245992ee 100644 --- a/Cargo.Bazel.lock +++ b/Cargo.Bazel.lock @@ -1,5 +1,5 @@ { - "checksum": "904dcb8a11d275446a0883d509f57dc79d98a328977a4d37fb7915476bec2922", + "checksum": "8a4cb983bd3e3b39bbdffe7693e509356851eec3e62381640c88afa0dc207023", "crates": { "addr2line 0.24.2": { "name": "addr2line", @@ -491,7 +491,7 @@ "target": "addr2line" }, { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" }, { @@ -1371,7 +1371,7 @@ "target": "glob" }, { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" }, { @@ -1715,7 +1715,7 @@ "deps": { "common": [ { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" }, { @@ -1967,19 +1967,19 @@ "selects": { "cfg(target_os = \"hermit\")": [ { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" } ], "cfg(target_os = \"wasi\")": [ { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" } ], "cfg(unix)": [ { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" } ], @@ -2156,7 +2156,7 @@ ], "cfg(unix)": [ { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" } ] @@ -3268,6 +3268,10 @@ { "id": "lazy_static 1.5.0", "target": "lazy_static" + }, + { + "id": "libc 0.2.169", + "target": "libc" } ], "selects": { @@ -3525,13 +3529,13 @@ }, "license": "MIT/Apache-2.0" }, - "libc 0.2.159": { + "libc 0.2.169": { "name": "libc", - "version": "0.2.159", + "version": "0.2.169", "repository": { "Http": { - "url": "https://static.crates.io/crates/libc/0.2.159/download", - "sha256": "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" + "url": "https://static.crates.io/crates/libc/0.2.169/download", + "sha256": "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" } }, "targets": [ @@ -3621,14 +3625,14 @@ "deps": { "common": [ { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "build_script_build" } ], "selects": {} }, - "edition": "2015", - "version": "0.2.159" + "edition": "2021", + "version": "0.2.169" }, "build_script_attrs": { "data_glob": [ @@ -4801,7 +4805,7 @@ "alias": "libc_errno" }, { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" } ], @@ -5623,7 +5627,7 @@ "selects": { "cfg(unix)": [ { - "id": "libc 0.2.159", + "id": "libc 0.2.169", "target": "libc" } ], diff --git a/Cargo.lock b/Cargo.lock index f44287229..fe018c63c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -742,6 +742,7 @@ dependencies = [ "iceoryx2-pal-concurrency-sync", "iceoryx2-pal-configuration", "lazy_static", + "libc", "windows-sys 0.48.0", ] @@ -790,9 +791,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libloading" diff --git a/Cargo.toml b/Cargo.toml index 1a9535e9f..156b1d895 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,6 +85,7 @@ colored = { version = "2.1" } generic-tests = { version = "0.1.2" } human-panic = { version = "1.2.3" } lazy_static = { version = "1.4.0" } +libc = { version = "0.2.169" } log = { version = "0.4.21" } once_cell = { version = "1.19.0" } ouroboros = { version = "0.18.4" } diff --git a/iceoryx2-bb/posix/Cargo.toml b/iceoryx2-bb/posix/Cargo.toml index 28aced46d..2db21f02b 100644 --- a/iceoryx2-bb/posix/Cargo.toml +++ b/iceoryx2-bb/posix/Cargo.toml @@ -10,6 +10,14 @@ repository = { workspace = true } rust-version = { workspace = true } version = { workspace = true } +[features] +# Use https://crates.io/crates/libc for the platform abstraction. This simplifies +# cross-compilation since bindgen is not required anymore. Unfortunately, the libc crate +# does not offer all the functionality iceoryx2 requires on all of the supported +# platforms. Therefore, only a subset of the supported platforms will work with this +# feature flag. +libc_platform = ["iceoryx2-pal-posix/libc_platform"] + [dependencies] iceoryx2-bb-container = { workspace = true } iceoryx2-bb-system-types = { workspace = true } diff --git a/iceoryx2-pal/posix/Cargo.toml b/iceoryx2-pal/posix/Cargo.toml index 128bbeaaf..a4de73eee 100644 --- a/iceoryx2-pal/posix/Cargo.toml +++ b/iceoryx2-pal/posix/Cargo.toml @@ -10,6 +10,14 @@ repository = { workspace = true } rust-version = { workspace = true } version = { workspace = true } +[features] +# Use https://crates.io/crates/libc for the platform abstraction. This simplifies +# cross-compilation since bindgen is not required anymore. Unfortunately, the libc crate +# does not offer all the functionality iceoryx2 requires on all of the supported +# platforms. Therefore, only a subset of the supported platforms will work with this +# feature flag. +libc_platform = [] + [build-dependencies] cc = { workspace = true } bindgen = { workspace = true } @@ -18,6 +26,7 @@ bindgen = { workspace = true } iceoryx2-pal-concurrency-sync = { workspace = true } iceoryx2-pal-configuration = { workspace = true } lazy_static = { workspace = true } +libc = { workspace = true } [target.'cfg(windows)'.dependencies] windows-sys = { workspace = true } diff --git a/iceoryx2-pal/posix/build.rs b/iceoryx2-pal/posix/build.rs index a1922737e..c84a31251 100644 --- a/iceoryx2-pal/posix/build.rs +++ b/iceoryx2-pal/posix/build.rs @@ -10,14 +10,18 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -extern crate bindgen; -extern crate cc; - -use bindgen::*; -use std::env; -use std::path::PathBuf; +#[cfg(feature = "libc_platform")] +fn main() {} +#[cfg(not(feature = "libc_platform"))] fn main() { + extern crate bindgen; + extern crate cc; + + use bindgen::*; + use std::env; + use std::path::PathBuf; + #[cfg(any(target_os = "linux", target_os = "freebsd"))] println!("cargo:rustc-link-lib=pthread"); diff --git a/iceoryx2-pal/posix/src/freebsd/constants.rs b/iceoryx2-pal/posix/src/freebsd/constants.rs index 936f4cd72..383cda2fe 100644 --- a/iceoryx2-pal/posix/src/freebsd/constants.rs +++ b/iceoryx2-pal/posix/src/freebsd/constants.rs @@ -59,10 +59,6 @@ pub const SO_PASSCRED: int = crate::internal::LOCAL_PEERCRED as _; pub const SO_PEERCRED: int = crate::internal::LOCAL_PEERCRED as _; pub const SCM_CREDENTIALS: int = crate::internal::SCM_CREDS as _; -pub const PTHREAD_PREFER_READER_NP: int = 0; -pub const PTHREAD_PREFER_WRITER_NP: int = 1; -pub const PTHREAD_PREFER_WRITER_NONRECURSIVE_NP: int = 2; - pub const PTHREAD_MUTEX_STALLED: int = crate::internal::PTHREAD_MUTEX_STALLED as _; pub const PTHREAD_MUTEX_ROBUST: int = crate::internal::PTHREAD_MUTEX_ROBUST as _; pub const PTHREAD_MUTEX_NORMAL: int = crate::internal::pthread_mutextype_PTHREAD_MUTEX_NORMAL as _; @@ -103,8 +99,6 @@ pub const PTHREAD_PROCESS_SHARED: int = crate::internal::PTHREAD_PROCESS_SHARED pub const PTHREAD_PRIO_NONE: int = crate::internal::PTHREAD_PRIO_NONE as _; pub const PTHREAD_PRIO_INHERIT: int = crate::internal::PTHREAD_PRIO_INHERIT as _; pub const PTHREAD_PRIO_PROTECT: int = crate::internal::PTHREAD_PRIO_PROTECT as _; -pub const PTHREAD_SCOPE_SYSTEM: int = crate::internal::PTHREAD_SCOPE_SYSTEM as _; -pub const PTHREAD_SCOPE_PROCESS: int = crate::internal::PTHREAD_SCOPE_PROCESS as _; pub const RLIMIT_CPU: __rlim_t = 0; pub const RLIMIT_FSIZE: __rlim_t = 1; diff --git a/iceoryx2-pal/posix/src/freebsd/fcntl.rs b/iceoryx2-pal/posix/src/freebsd/fcntl.rs index 47efa6042..47837c92e 100644 --- a/iceoryx2-pal/posix/src/freebsd/fcntl.rs +++ b/iceoryx2-pal/posix/src/freebsd/fcntl.rs @@ -21,7 +21,7 @@ pub unsafe fn open_with_mode(pathname: *const c_char, flags: int, mode: mode_t) } pub unsafe fn fstat(fd: int, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); + let mut os_specific_buffer = native_stat_t::new(); match crate::internal::fstat(fd, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); diff --git a/iceoryx2-pal/posix/src/freebsd/pthread.rs b/iceoryx2-pal/posix/src/freebsd/pthread.rs index 80672772d..3406d3624 100644 --- a/iceoryx2-pal/posix/src/freebsd/pthread.rs +++ b/iceoryx2-pal/posix/src/freebsd/pthread.rs @@ -86,7 +86,9 @@ pub unsafe fn pthread_attr_setaffinity_np( cpusetsize: size_t, cpuset: *const cpu_set_t, ) -> int { - internal::pthread_attr_setaffinity_np(attr, cpusetsize, cpuset) + let cpuset = core::mem::transmute::(*cpuset); + + internal::pthread_attr_setaffinity_np(attr, cpusetsize, &cpuset) } pub unsafe fn pthread_create( @@ -123,7 +125,9 @@ pub unsafe fn pthread_setaffinity_np( cpusetsize: size_t, cpuset: *const cpu_set_t, ) -> int { - internal::pthread_setaffinity_np(thread, cpusetsize, cpuset) + let cpuset = core::mem::transmute::(*cpuset); + + internal::pthread_setaffinity_np(thread, cpusetsize, &cpuset) } pub unsafe fn pthread_getaffinity_np( @@ -131,7 +135,13 @@ pub unsafe fn pthread_getaffinity_np( cpusetsize: size_t, cpuset: *mut cpu_set_t, ) -> int { - internal::pthread_getaffinity_np(thread, cpusetsize, cpuset) + let mut native_cpuset = native_cpu_set_t::new(); + + let ret_val = internal::pthread_getaffinity_np(thread, cpusetsize, &mut native_cpuset); + + *cpuset = core::mem::transmute::(native_cpuset); + + ret_val } pub unsafe fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> int { diff --git a/iceoryx2-pal/posix/src/freebsd/stat.rs b/iceoryx2-pal/posix/src/freebsd/stat.rs index 0adcf7415..3cb45cea0 100644 --- a/iceoryx2-pal/posix/src/freebsd/stat.rs +++ b/iceoryx2-pal/posix/src/freebsd/stat.rs @@ -17,7 +17,7 @@ use crate::posix::types::*; use crate::posix::Struct; pub unsafe fn stat(path: *const c_char, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); + let mut os_specific_buffer = crate::native_stat_t::new(); match crate::internal::stat(path, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); diff --git a/iceoryx2-pal/posix/src/freebsd/types.rs b/iceoryx2-pal/posix/src/freebsd/types.rs index 67ffdf1db..c09e2201e 100644 --- a/iceoryx2-pal/posix/src/freebsd/types.rs +++ b/iceoryx2-pal/posix/src/freebsd/types.rs @@ -61,6 +61,9 @@ pub type uint = crate::internal::uint; pub type ushort = crate::internal::ushort; pub type void = core::ffi::c_void; +pub(crate) type native_cpu_set_t = crate::internal::cpu_set_t; +impl Struct for native_cpu_set_t {} + pub type sigset_t = crate::internal::sigset_t; impl Struct for sigset_t {} @@ -100,6 +103,9 @@ impl Struct for rlimit {} pub type sched_param = crate::internal::sched_param; impl Struct for sched_param {} +pub(crate) type native_stat_t = libc::stat; +impl Struct for native_stat_t {} + #[repr(C)] pub struct stat_t { pub st_dev: dev_t, @@ -116,8 +122,8 @@ pub struct stat_t { pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, } -impl From for stat_t { - fn from(value: crate::internal::stat) -> Self { +impl From for stat_t { + fn from(value: native_stat_t) -> Self { stat_t { st_dev: value.st_dev, st_ino: value.st_ino, @@ -136,7 +142,6 @@ impl From for stat_t { } } impl Struct for stat_t {} -impl Struct for crate::internal::stat {} pub type timespec = crate::internal::timespec; impl Struct for timespec {} diff --git a/iceoryx2-pal/posix/src/lib.rs b/iceoryx2-pal/posix/src/lib.rs index daf81069f..cf05ae0cc 100644 --- a/iceoryx2-pal/posix/src/lib.rs +++ b/iceoryx2-pal/posix/src/lib.rs @@ -15,6 +15,7 @@ #![warn(clippy::std_instead_of_alloc)] #![warn(clippy::std_instead_of_core)] +#[cfg(not(feature = "libc_platform"))] pub(crate) mod internal { #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] @@ -32,13 +33,16 @@ pub(crate) mod internal { pub const ESUCCES: u32 = 0; } -#[cfg(target_os = "freebsd")] +#[cfg(feature = "libc_platform")] +mod libc; + +#[cfg(all(target_os = "freebsd", not(feature = "libc_platform")))] mod freebsd; -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(feature = "libc_platform")))] mod linux; -#[cfg(target_os = "macos")] +#[cfg(all(target_os = "macos", not(feature = "libc_platform")))] mod macos; -#[cfg(target_os = "windows")] +#[cfg(all(target_os = "windows", not(feature = "libc_platform")))] mod windows; #[cfg(not(target_os = "windows"))] @@ -49,13 +53,16 @@ use scandir::*; pub mod posix { #![allow(dead_code)] - #[cfg(target_os = "freebsd")] + #[cfg(feature = "libc_platform")] + pub use crate::libc::*; + + #[cfg(all(target_os = "freebsd", not(feature = "libc_platform")))] pub use crate::freebsd::*; - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", not(feature = "libc_platform")))] pub use crate::linux::*; - #[cfg(target_os = "macos")] + #[cfg(all(target_os = "macos", not(feature = "libc_platform")))] pub use crate::macos::*; - #[cfg(target_os = "windows")] + #[cfg(all(target_os = "windows", not(feature = "libc_platform")))] pub use crate::windows::*; pub trait Struct: Sized { @@ -116,7 +123,7 @@ pub mod posix { } } -#[cfg(target_os = "windows")] +#[cfg(all(target_os = "windows", not(feature = "libc_platform")))] pub(crate) mod win_internal { #![allow(dead_code)] use std::os::windows::prelude::OsStrExt; diff --git a/iceoryx2-pal/posix/src/libc/constants.rs b/iceoryx2-pal/posix/src/libc/constants.rs index 26f8a9d98..4e859579a 100644 --- a/iceoryx2-pal/posix/src/libc/constants.rs +++ b/iceoryx2-pal/posix/src/libc/constants.rs @@ -15,97 +15,88 @@ use crate::posix::types::*; -pub const CPU_SETSIZE: usize = crate::internal::__CPU_SETSIZE as _; -pub const FD_SETSIZE: usize = crate::internal::FD_SETSIZE as _; +pub const CPU_SETSIZE: usize = libc::CPU_SETSIZE as _; +pub const FD_SETSIZE: usize = libc::FD_SETSIZE as _; pub const NULL_TERMINATOR: c_char = 0; -pub const O_RDONLY: int = crate::internal::O_RDONLY as _; -pub const O_WRONLY: int = crate::internal::O_WRONLY as _; -pub const O_RDWR: int = crate::internal::O_RDWR as _; +pub const O_RDONLY: int = libc::O_RDONLY as _; +pub const O_WRONLY: int = libc::O_WRONLY as _; +pub const O_RDWR: int = libc::O_RDWR as _; -pub const O_CREAT: int = crate::internal::O_CREAT as _; -pub const O_EXCL: int = crate::internal::O_EXCL as _; -pub const O_NOCTTY: int = crate::internal::O_NOCTTY as _; -pub const O_APPEND: int = crate::internal::O_APPEND as _; -pub const O_NONBLOCK: int = crate::internal::O_NONBLOCK as _; -pub const O_DIRECTORY: int = crate::internal::O_DIRECTORY as _; +pub const O_CREAT: int = libc::O_CREAT as _; +pub const O_EXCL: int = libc::O_EXCL as _; +pub const O_NOCTTY: int = libc::O_NOCTTY as _; +pub const O_APPEND: int = libc::O_APPEND as _; +pub const O_NONBLOCK: int = libc::O_NONBLOCK as _; +pub const O_DIRECTORY: int = libc::O_DIRECTORY as _; -pub const F_RDLCK: int = crate::internal::F_RDLCK as _; -pub const F_WRLCK: int = crate::internal::F_WRLCK as _; -pub const F_UNLCK: int = crate::internal::F_UNLCK as _; -pub const F_GETFD: int = crate::internal::F_GETFD as _; -pub const F_GETFL: int = crate::internal::F_GETFL as _; -pub const F_SETFL: int = crate::internal::F_SETFL as _; -pub const F_GETLK: int = crate::internal::F_GETLK as _; -pub const F_SETLK: int = crate::internal::F_SETLK as _; -pub const F_SETLKW: int = crate::internal::F_SETLKW as _; +pub const F_RDLCK: int = libc::F_RDLCK as _; +pub const F_WRLCK: int = libc::F_WRLCK as _; +pub const F_UNLCK: int = libc::F_UNLCK as _; +pub const F_GETFD: int = libc::F_GETFD as _; +pub const F_GETFL: int = libc::F_GETFL as _; +pub const F_SETFL: int = libc::F_SETFL as _; +pub const F_GETLK: int = libc::F_GETLK as _; +pub const F_SETLK: int = libc::F_SETLK as _; +pub const F_SETLKW: int = libc::F_SETLKW as _; -pub const PROT_NONE: int = crate::internal::PROT_NONE as _; -pub const PROT_READ: int = crate::internal::PROT_READ as _; -pub const PROT_WRITE: int = crate::internal::PROT_WRITE as _; -pub const PROT_EXEC: int = crate::internal::PROT_EXEC as _; -pub const MCL_CURRENT: int = crate::internal::MCL_CURRENT as _; -pub const MCL_FUTURE: int = crate::internal::MCL_FUTURE as _; -pub const MAP_SHARED: int = crate::internal::MAP_SHARED as _; +pub const PROT_NONE: int = libc::PROT_NONE as _; +pub const PROT_READ: int = libc::PROT_READ as _; +pub const PROT_WRITE: int = libc::PROT_WRITE as _; +pub const PROT_EXEC: int = libc::PROT_EXEC as _; +pub const MCL_CURRENT: int = libc::MCL_CURRENT as _; +pub const MCL_FUTURE: int = libc::MCL_FUTURE as _; +pub const MAP_SHARED: int = libc::MAP_SHARED as _; pub const MAP_FAILED: *mut void = u64::MAX as *mut void; -pub const PTHREAD_BARRIER_SERIAL_THREAD: int = crate::internal::PTHREAD_BARRIER_SERIAL_THREAD as _; -pub const PTHREAD_EXPLICIT_SCHED: int = crate::internal::PTHREAD_EXPLICIT_SCHED as _; -pub const PTHREAD_INHERIT_SCHED: int = crate::internal::PTHREAD_INHERIT_SCHED as _; +pub const PTHREAD_BARRIER_SERIAL_THREAD: int = libc::PTHREAD_BARRIER_SERIAL_THREAD as _; +pub const PTHREAD_EXPLICIT_SCHED: int = libc::PTHREAD_EXPLICIT_SCHED as _; +pub const PTHREAD_INHERIT_SCHED: int = libc::PTHREAD_INHERIT_SCHED as _; pub const MAX_SIGNAL_VALUE: usize = 32; -pub const SO_PASSCRED: int = crate::internal::SO_PASSCRED as _; -pub const SO_PEERCRED: int = crate::internal::SO_PEERCRED as _; +pub const SO_PASSCRED: int = libc::SO_PASSCRED as _; +pub const SO_PEERCRED: int = libc::SO_PEERCRED as _; pub const SCM_CREDENTIALS: int = 0x02; -pub const PTHREAD_PREFER_READER_NP: int = crate::internal::PTHREAD_RWLOCK_PREFER_READER_NP as _; -pub const PTHREAD_PREFER_WRITER_NP: int = crate::internal::PTHREAD_RWLOCK_PREFER_WRITER_NP as _; -pub const PTHREAD_PREFER_WRITER_NONRECURSIVE_NP: int = - crate::internal::PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP as _; +pub const PTHREAD_MUTEX_NORMAL: int = libc::PTHREAD_MUTEX_NORMAL as _; +pub const PTHREAD_MUTEX_RECURSIVE: int = libc::PTHREAD_MUTEX_RECURSIVE as _; +pub const PTHREAD_MUTEX_ERRORCHECK: int = libc::PTHREAD_MUTEX_ERRORCHECK as _; +pub const PTHREAD_MUTEX_STALLED: int = libc::PTHREAD_MUTEX_STALLED as _; +pub const PTHREAD_MUTEX_ROBUST: int = libc::PTHREAD_MUTEX_ROBUST as _; -pub const PTHREAD_MUTEX_NORMAL: int = crate::internal::PTHREAD_MUTEX_NORMAL as _; -pub const PTHREAD_MUTEX_RECURSIVE: int = crate::internal::PTHREAD_MUTEX_RECURSIVE as _; -pub const PTHREAD_MUTEX_ERRORCHECK: int = crate::internal::PTHREAD_MUTEX_ERRORCHECK as _; -pub const PTHREAD_MUTEX_STALLED: int = crate::internal::PTHREAD_MUTEX_STALLED as _; -pub const PTHREAD_MUTEX_ROBUST: int = crate::internal::PTHREAD_MUTEX_ROBUST as _; +pub const _SC_UIO_MAXIOV: int = libc::_SC_UIO_MAXIOV as _; +pub const _SC_IOV_MAX: int = libc::_SC_IOV_MAX as _; +pub const _SC_AVPHYS_PAGES: int = libc::_SC_AVPHYS_PAGES as _; +pub const _SC_PASS_MAX: int = libc::_SC_PASS_MAX as _; +pub const _SC_XOPEN_XPG2: int = libc::_SC_XOPEN_XPG2 as _; +pub const _SC_XOPEN_XPG3: int = libc::_SC_XOPEN_XPG3 as _; +pub const _SC_XOPEN_XPG4: int = libc::_SC_XOPEN_XPG4 as _; +pub const _SC_NZERO: int = libc::_SC_NZERO as _; +pub const _SC_XBS5_ILP32_OFF32: int = libc::_SC_XBS5_ILP32_OFF32 as _; +pub const _SC_XBS5_ILP32_OFFBIG: int = libc::_SC_XBS5_ILP32_OFFBIG as _; +pub const _SC_XBS5_LP64_OFF64: int = libc::_SC_XBS5_LP64_OFF64 as _; +pub const _SC_XBS5_LPBIG_OFFBIG: int = libc::_SC_XBS5_LPBIG_OFFBIG as _; +pub const _SC_STREAMS: int = libc::_SC_STREAMS as _; +pub const _SC_V7_ILP32_OFF32: int = libc::_SC_V7_ILP32_OFF32 as _; +pub const _SC_V7_ILP32_OFFBIG: int = libc::_SC_V7_ILP32_OFFBIG as _; +pub const _SC_V7_LP64_OFF64: int = libc::_SC_V7_LP64_OFF64 as _; +pub const _SC_V7_LPBIG_OFFBIG: int = libc::_SC_V7_LPBIG_OFFBIG as _; +pub const _SC_SS_REPL_MAX: int = libc::_SC_SS_REPL_MAX as _; +pub const _SC_TRACE_EVENT_NAME_MAX: int = libc::_SC_TRACE_EVENT_NAME_MAX as _; +pub const _SC_TRACE_NAME_MAX: int = libc::_SC_TRACE_NAME_MAX as _; +pub const _SC_TRACE_SYS_MAX: int = libc::_SC_TRACE_SYS_MAX as _; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: int = libc::_SC_THREAD_ROBUST_PRIO_INHERIT as _; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: int = libc::_SC_THREAD_ROBUST_PRIO_PROTECT as _; +pub const _PC_SOCK_MAXBUF: int = libc::_PC_SOCK_MAXBUF as _; +pub const _PC_2_SYMLINKS: int = libc::_PC_2_SYMLINKS as _; +pub const _SC_TRACE_USER_EVENT_MAX: int = libc::_SC_TRACE_USER_EVENT_MAX as _; -pub const _SC_UIO_MAXIOV: int = crate::internal::_SC_UIO_MAXIOV as _; -pub const _SC_IOV_MAX: int = crate::internal::_SC_IOV_MAX as _; -pub const _SC_AVPHYS_PAGES: int = crate::internal::_SC_AVPHYS_PAGES as _; -pub const _SC_PASS_MAX: int = crate::internal::_SC_PASS_MAX as _; -pub const _SC_XOPEN_XPG2: int = crate::internal::_SC_XOPEN_XPG2 as _; -pub const _SC_XOPEN_XPG3: int = crate::internal::_SC_XOPEN_XPG3 as _; -pub const _SC_XOPEN_XPG4: int = crate::internal::_SC_XOPEN_XPG4 as _; -pub const _SC_NZERO: int = crate::internal::_SC_NZERO as _; -pub const _SC_XBS5_ILP32_OFF32: int = crate::internal::_SC_XBS5_ILP32_OFF32 as _; -pub const _SC_XBS5_ILP32_OFFBIG: int = crate::internal::_SC_XBS5_ILP32_OFFBIG as _; -pub const _SC_XBS5_LP64_OFF64: int = crate::internal::_SC_XBS5_LP64_OFF64 as _; -pub const _SC_XBS5_LPBIG_OFFBIG: int = crate::internal::_SC_XBS5_LPBIG_OFFBIG as _; -pub const _SC_STREAMS: int = crate::internal::_SC_STREAMS as _; -pub const _SC_V7_ILP32_OFF32: int = crate::internal::_SC_V7_ILP32_OFF32 as _; -pub const _SC_V7_ILP32_OFFBIG: int = crate::internal::_SC_V7_ILP32_OFFBIG as _; -pub const _SC_V7_LP64_OFF64: int = crate::internal::_SC_V7_LP64_OFF64 as _; -pub const _SC_V7_LPBIG_OFFBIG: int = crate::internal::_SC_V7_LPBIG_OFFBIG as _; -pub const _SC_SS_REPL_MAX: int = crate::internal::_SC_SS_REPL_MAX as _; -pub const _SC_TRACE_EVENT_NAME_MAX: int = crate::internal::_SC_TRACE_EVENT_NAME_MAX as _; -pub const _SC_TRACE_NAME_MAX: int = crate::internal::_SC_TRACE_NAME_MAX as _; -pub const _SC_TRACE_SYS_MAX: int = crate::internal::_SC_TRACE_SYS_MAX as _; -pub const _SC_THREAD_ROBUST_PRIO_INHERIT: int = - crate::internal::_SC_THREAD_ROBUST_PRIO_INHERIT as _; -pub const _SC_THREAD_ROBUST_PRIO_PROTECT: int = - crate::internal::_SC_THREAD_ROBUST_PRIO_PROTECT as _; -pub const _PC_SOCK_MAXBUF: int = crate::internal::_PC_SOCK_MAXBUF as _; -pub const _PC_2_SYMLINKS: int = crate::internal::_PC_2_SYMLINKS as _; -pub const _SC_TRACE_USER_EVENT_MAX: int = crate::internal::_SC_TRACE_USER_EVENT_MAX as _; - -pub const PTHREAD_PROCESS_PRIVATE: int = crate::internal::PTHREAD_PROCESS_PRIVATE as _; -pub const PTHREAD_PROCESS_SHARED: int = crate::internal::PTHREAD_PROCESS_SHARED as _; -pub const PTHREAD_PRIO_NONE: int = crate::internal::PTHREAD_PRIO_NONE as _; -pub const PTHREAD_PRIO_INHERIT: int = crate::internal::PTHREAD_PRIO_INHERIT as _; -pub const PTHREAD_PRIO_PROTECT: int = crate::internal::PTHREAD_PRIO_PROTECT as _; -pub const PTHREAD_SCOPE_SYSTEM: int = crate::internal::PTHREAD_SCOPE_SYSTEM as _; -pub const PTHREAD_SCOPE_PROCESS: int = crate::internal::PTHREAD_SCOPE_PROCESS as _; +pub const PTHREAD_PROCESS_PRIVATE: int = libc::PTHREAD_PROCESS_PRIVATE as _; +pub const PTHREAD_PROCESS_SHARED: int = libc::PTHREAD_PROCESS_SHARED as _; +pub const PTHREAD_PRIO_NONE: int = libc::PTHREAD_PRIO_NONE as _; +pub const PTHREAD_PRIO_INHERIT: int = libc::PTHREAD_PRIO_INHERIT as _; +pub const PTHREAD_PRIO_PROTECT: int = libc::PTHREAD_PRIO_PROTECT as _; pub const RLIMIT_CPU: __rlim_t = 0; pub const RLIMIT_FSIZE: __rlim_t = 1; @@ -126,244 +117,236 @@ pub const RLIMIT_RTTIME: __rlim_t = 15; pub const RLIMIT_NLIMITS: __rlim_t = 16; pub const RLIMIT_INFINITY: __rlim_t = __rlim_t::MAX; -pub const SCHED_OTHER: int = crate::internal::SCHED_OTHER as _; -pub const SCHED_FIFO: int = crate::internal::SCHED_FIFO as _; -pub const SCHED_RR: int = crate::internal::SCHED_RR as _; +pub const SCHED_OTHER: int = libc::SCHED_OTHER as _; +pub const SCHED_FIFO: int = libc::SCHED_FIFO as _; +pub const SCHED_RR: int = libc::SCHED_RR as _; -pub const SEEK_SET: int = crate::internal::SEEK_SET as _; -pub const SEEK_CUR: int = crate::internal::SEEK_CUR as _; -pub const SEEK_END: int = crate::internal::SEEK_END as _; +pub const SEEK_SET: int = libc::SEEK_SET as _; +pub const SEEK_CUR: int = libc::SEEK_CUR as _; +pub const SEEK_END: int = libc::SEEK_END as _; pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; -pub const SIGABRT: int = crate::internal::SIGABRT as _; -pub const SIGALRM: int = crate::internal::SIGALRM as _; -pub const SIGBUS: int = crate::internal::SIGBUS as _; -pub const SIGCHLD: int = crate::internal::SIGCHLD as _; -pub const SIGCONT: int = crate::internal::SIGCONT as _; -pub const SIGFPE: int = crate::internal::SIGFPE as _; -pub const SIGHUP: int = crate::internal::SIGHUP as _; -pub const SIGILL: int = crate::internal::SIGILL as _; -pub const SIGINT: int = crate::internal::SIGINT as _; -pub const SIGKILL: int = crate::internal::SIGKILL as _; -pub const SIGPIPE: int = crate::internal::SIGPIPE as _; -pub const SIGQUIT: int = crate::internal::SIGQUIT as _; -pub const SIGSEGV: int = crate::internal::SIGSEGV as _; -pub const SIGSTOP: int = crate::internal::SIGSTOP as _; -pub const SIGTERM: int = crate::internal::SIGTERM as _; -pub const SIGTSTP: int = crate::internal::SIGTSTP as _; -pub const SIGTTIN: int = crate::internal::SIGTTIN as _; -pub const SIGTTOU: int = crate::internal::SIGTTOU as _; -pub const SIGUSR1: int = crate::internal::SIGUSR1 as _; -pub const SIGUSR2: int = crate::internal::SIGUSR2 as _; -pub const SIGPROF: int = crate::internal::SIGPROF as _; -pub const SIGSYS: int = crate::internal::SIGSYS as _; -pub const SIGTRAP: int = crate::internal::SIGTRAP as _; -pub const SIGURG: int = crate::internal::SIGURG as _; -pub const SIGVTALRM: int = crate::internal::SIGVTALRM as _; -pub const SIGXCPU: int = crate::internal::SIGXCPU as _; -pub const SIGXFSZ: int = crate::internal::SIGXFSZ as _; +pub const SIGABRT: int = libc::SIGABRT as _; +pub const SIGALRM: int = libc::SIGALRM as _; +pub const SIGBUS: int = libc::SIGBUS as _; +pub const SIGCHLD: int = libc::SIGCHLD as _; +pub const SIGCONT: int = libc::SIGCONT as _; +pub const SIGFPE: int = libc::SIGFPE as _; +pub const SIGHUP: int = libc::SIGHUP as _; +pub const SIGILL: int = libc::SIGILL as _; +pub const SIGINT: int = libc::SIGINT as _; +pub const SIGKILL: int = libc::SIGKILL as _; +pub const SIGPIPE: int = libc::SIGPIPE as _; +pub const SIGQUIT: int = libc::SIGQUIT as _; +pub const SIGSEGV: int = libc::SIGSEGV as _; +pub const SIGSTOP: int = libc::SIGSTOP as _; +pub const SIGTERM: int = libc::SIGTERM as _; +pub const SIGTSTP: int = libc::SIGTSTP as _; +pub const SIGTTIN: int = libc::SIGTTIN as _; +pub const SIGTTOU: int = libc::SIGTTOU as _; +pub const SIGUSR1: int = libc::SIGUSR1 as _; +pub const SIGUSR2: int = libc::SIGUSR2 as _; +pub const SIGPROF: int = libc::SIGPROF as _; +pub const SIGSYS: int = libc::SIGSYS as _; +pub const SIGTRAP: int = libc::SIGTRAP as _; +pub const SIGURG: int = libc::SIGURG as _; +pub const SIGVTALRM: int = libc::SIGVTALRM as _; +pub const SIGXCPU: int = libc::SIGXCPU as _; +pub const SIGXFSZ: int = libc::SIGXFSZ as _; pub const SIG_ERR: sighandler_t = sighandler_t::MAX; pub const SIG_DFL: int = 0; pub const SIG_IGN: int = 1; -pub const SA_RESTART: int = crate::internal::SA_RESTART as _; +pub const SA_RESTART: int = libc::SA_RESTART as _; -pub const AF_LOCAL: sa_family_t = crate::internal::AF_UNIX as _; -pub const AF_UNIX: sa_family_t = crate::internal::AF_UNIX as _; -pub const AF_INET: sa_family_t = crate::internal::AF_INET as _; -pub const PF_INET: sa_family_t = crate::internal::PF_INET as _; -pub const PF_LOCAL: sa_family_t = crate::internal::AF_UNIX as _; -pub const PF_UNIX: sa_family_t = crate::internal::AF_UNIX as _; +pub const AF_LOCAL: sa_family_t = libc::AF_UNIX as _; +pub const AF_UNIX: sa_family_t = libc::AF_UNIX as _; +pub const AF_INET: sa_family_t = libc::AF_INET as _; +pub const PF_INET: sa_family_t = libc::PF_INET as _; +pub const PF_LOCAL: sa_family_t = libc::AF_UNIX as _; +pub const PF_UNIX: sa_family_t = libc::AF_UNIX as _; pub const INADDR_ANY: in_addr_t = 0; -pub const SO_SNDBUF: int = crate::internal::SO_SNDBUF as _; -pub const SO_RCVBUF: int = crate::internal::SO_RCVBUF as _; -#[cfg(target_pointer_width = "32")] -pub const SO_RCVTIMEO: int = crate::internal::SO_RCVTIMEO_OLD as _; -#[cfg(target_pointer_width = "64")] -pub const SO_RCVTIMEO: int = crate::internal::SO_RCVTIMEO as _; -#[cfg(target_pointer_width = "32")] -pub const SO_SNDTIMEO: int = crate::internal::SO_SNDTIMEO_OLD as _; -#[cfg(target_pointer_width = "64")] -pub const SO_SNDTIMEO: int = crate::internal::SO_SNDTIMEO as _; -pub const SOCK_STREAM: int = crate::internal::__socket_type_SOCK_STREAM as _; -pub const SOCK_DGRAM: int = crate::internal::__socket_type_SOCK_DGRAM as _; -pub const IPPROTO_UDP: int = crate::internal::IPPROTO_UDP as _; +pub const SO_SNDBUF: int = libc::SO_SNDBUF as _; +pub const SO_RCVBUF: int = libc::SO_RCVBUF as _; +pub const SO_RCVTIMEO: int = libc::SO_RCVTIMEO as _; +pub const SO_SNDTIMEO: int = libc::SO_SNDTIMEO as _; +pub const SOCK_STREAM: int = libc::SOCK_STREAM as _; +pub const SOCK_DGRAM: int = libc::SOCK_DGRAM as _; +pub const IPPROTO_UDP: int = libc::IPPROTO_UDP as _; pub const SOCK_NONBLOCK: int = O_NONBLOCK; -pub const MSG_PEEK: int = crate::internal::MSG_PEEK as _; +pub const MSG_PEEK: int = libc::MSG_PEEK as _; pub const SCM_MAX_FD: u32 = 253; -pub const SCM_RIGHTS: int = crate::internal::SCM_RIGHTS as _; -pub const SOL_SOCKET: int = crate::internal::SOL_SOCKET as _; +pub const SCM_RIGHTS: int = libc::SCM_RIGHTS as _; +pub const SOL_SOCKET: int = libc::SOL_SOCKET as _; pub const SUN_PATH_LEN: usize = 108; pub const SA_DATA_LEN: usize = 14; -pub const S_IFMT: mode_t = crate::internal::S_IFMT as _; -pub const S_IFSOCK: mode_t = crate::internal::S_IFSOCK as _; -pub const S_IFLNK: mode_t = crate::internal::S_IFLNK as _; -pub const S_IFREG: mode_t = crate::internal::S_IFREG as _; -pub const S_IFBLK: mode_t = crate::internal::S_IFBLK as _; -pub const S_IFDIR: mode_t = crate::internal::S_IFDIR as _; -pub const S_IFCHR: mode_t = crate::internal::S_IFCHR as _; -pub const S_IFIFO: mode_t = crate::internal::S_IFIFO as _; -pub const S_IRWXU: mode_t = crate::internal::S_IRWXU as _; -pub const S_IXUSR: mode_t = crate::internal::S_IXUSR as _; -pub const S_IWUSR: mode_t = crate::internal::S_IWUSR as _; -pub const S_IRUSR: mode_t = crate::internal::S_IRUSR as _; -pub const S_IRWXG: mode_t = crate::internal::S_IRWXG as _; -pub const S_IXGRP: mode_t = crate::internal::S_IXGRP as _; -pub const S_IWGRP: mode_t = crate::internal::S_IWGRP as _; -pub const S_IRGRP: mode_t = crate::internal::S_IRGRP as _; -pub const S_IRWXO: mode_t = crate::internal::S_IRWXO as _; -pub const S_IXOTH: mode_t = crate::internal::S_IXOTH as _; -pub const S_IWOTH: mode_t = crate::internal::S_IWOTH as _; -pub const S_IROTH: mode_t = crate::internal::S_IROTH as _; -pub const S_ISUID: mode_t = crate::internal::S_ISUID as _; -pub const S_ISGID: mode_t = crate::internal::S_ISGID as _; -pub const S_ISVTX: mode_t = crate::internal::S_ISVTX as _; +pub const S_IFMT: mode_t = libc::S_IFMT as _; +pub const S_IFSOCK: mode_t = libc::S_IFSOCK as _; +pub const S_IFLNK: mode_t = libc::S_IFLNK as _; +pub const S_IFREG: mode_t = libc::S_IFREG as _; +pub const S_IFBLK: mode_t = libc::S_IFBLK as _; +pub const S_IFDIR: mode_t = libc::S_IFDIR as _; +pub const S_IFCHR: mode_t = libc::S_IFCHR as _; +pub const S_IFIFO: mode_t = libc::S_IFIFO as _; +pub const S_IRWXU: mode_t = libc::S_IRWXU as _; +pub const S_IXUSR: mode_t = libc::S_IXUSR as _; +pub const S_IWUSR: mode_t = libc::S_IWUSR as _; +pub const S_IRUSR: mode_t = libc::S_IRUSR as _; +pub const S_IRWXG: mode_t = libc::S_IRWXG as _; +pub const S_IXGRP: mode_t = libc::S_IXGRP as _; +pub const S_IWGRP: mode_t = libc::S_IWGRP as _; +pub const S_IRGRP: mode_t = libc::S_IRGRP as _; +pub const S_IRWXO: mode_t = libc::S_IRWXO as _; +pub const S_IXOTH: mode_t = libc::S_IXOTH as _; +pub const S_IWOTH: mode_t = libc::S_IWOTH as _; +pub const S_IROTH: mode_t = libc::S_IROTH as _; +pub const S_ISUID: mode_t = libc::S_ISUID as _; +pub const S_ISGID: mode_t = libc::S_ISGID as _; +pub const S_ISVTX: mode_t = libc::S_ISVTX as _; -pub const CLOCK_REALTIME: clockid_t = crate::internal::CLOCK_REALTIME as _; -pub const CLOCK_MONOTONIC: clockid_t = crate::internal::CLOCK_MONOTONIC as _; +pub const CLOCK_REALTIME: clockid_t = libc::CLOCK_REALTIME as _; +pub const CLOCK_MONOTONIC: clockid_t = libc::CLOCK_MONOTONIC as _; pub const CLOCK_TIMER_ABSTIME: int = 1; -pub const F_OK: int = crate::internal::F_OK as _; -pub const R_OK: int = crate::internal::R_OK as _; -pub const W_OK: int = crate::internal::W_OK as _; -pub const X_OK: int = crate::internal::X_OK as _; +pub const F_OK: int = libc::F_OK as _; +pub const R_OK: int = libc::R_OK as _; +pub const W_OK: int = libc::W_OK as _; +pub const X_OK: int = libc::X_OK as _; -pub const _SC_ARG_MAX: int = crate::internal::_SC_ARG_MAX as _; -pub const _SC_CHILD_MAX: int = crate::internal::_SC_CHILD_MAX as _; -pub const _SC_CLK_TCK: int = crate::internal::_SC_CLK_TCK as _; -pub const _SC_NGROUPS_MAX: int = crate::internal::NGROUPS_MAX as _; -pub const _SC_OPEN_MAX: int = crate::internal::_SC_OPEN_MAX as _; -pub const _SC_STREAM_MAX: int = crate::internal::_SC_STREAM_MAX as _; -pub const _SC_TZNAME_MAX: int = crate::internal::_SC_TZNAME_MAX as _; -pub const _SC_JOB_CONTROL: int = crate::internal::_SC_JOB_CONTROL as _; -pub const _SC_SAVED_IDS: int = crate::internal::_SC_SAVED_IDS as _; -pub const _SC_REALTIME_SIGNALS: int = crate::internal::_SC_REALTIME_SIGNALS as _; -pub const _SC_PRIORITY_SCHEDULING: int = crate::internal::_SC_PRIORITY_SCHEDULING as _; -pub const _SC_TIMERS: int = crate::internal::_SC_TIMERS as _; -pub const _SC_ASYNCHRONOUS_IO: int = crate::internal::_SC_ASYNCHRONOUS_IO as _; -pub const _SC_PRIORITIZED_IO: int = crate::internal::_SC_PRIORITIZED_IO as _; -pub const _SC_SYNCHRONIZED_IO: int = crate::internal::_SC_SYNCHRONIZED_IO as _; -pub const _SC_FSYNC: int = crate::internal::_SC_FSYNC as _; -pub const _SC_MAPPED_FILES: int = crate::internal::_SC_MAPPED_FILES as _; -pub const _SC_MEMLOCK: int = crate::internal::_SC_MEMLOCK as _; -pub const _SC_MEMLOCK_RANGE: int = crate::internal::_SC_MEMLOCK_RANGE as _; -pub const _SC_MEMORY_PROTECTION: int = crate::internal::_SC_MEMORY_PROTECTION as _; -pub const _SC_MESSAGE_PASSING: int = crate::internal::_SC_MESSAGE_PASSING as _; -pub const _SC_SEMAPHORES: int = crate::internal::_SC_SEMAPHORES as _; -pub const _SC_SHARED_MEMORY_OBJECTS: int = crate::internal::_SC_SHARED_MEMORY_OBJECTS as _; -pub const _SC_AIO_LISTIO_MAX: int = crate::internal::_SC_AIO_LISTIO_MAX as _; -pub const _SC_AIO_MAX: int = crate::internal::_SC_AIO_MAX as _; -pub const _SC_AIO_PRIO_DELTA_MAX: int = crate::internal::_SC_AIO_PRIO_DELTA_MAX as _; -pub const _SC_DELAYTIMER_MAX: int = crate::internal::_SC_DELAYTIMER_MAX as _; -pub const _SC_MQ_OPEN_MAX: int = crate::internal::_SC_MQ_OPEN_MAX as _; -pub const _SC_MQ_PRIO_MAX: int = crate::internal::MQ_PRIO_MAX as _; -pub const _SC_VERSION: int = crate::internal::_SC_VERSION as _; -pub const _SC_PAGESIZE: int = crate::internal::_SC_PAGESIZE as _; -pub const _SC_RTSIG_MAX: int = crate::internal::_SC_RTSIG_MAX as _; -pub const _SC_SEM_NSEMS_MAX: int = crate::internal::_SC_SEM_NSEMS_MAX as _; -pub const _SC_SEM_VALUE_MAX: int = crate::internal::_SC_SEM_VALUE_MAX as _; -pub const _SC_SIGQUEUE_MAX: int = crate::internal::_SC_SIGQUEUE_MAX as _; -pub const _SC_TIMER_MAX: int = crate::internal::_SC_TIMER_MAX as _; -pub const _SC_BC_BASE_MAX: int = crate::internal::_SC_BC_BASE_MAX as _; -pub const _SC_BC_DIM_MAX: int = crate::internal::_SC_BC_DIM_MAX as _; -pub const _SC_BC_SCALE_MAX: int = crate::internal::_SC_BC_SCALE_MAX as _; -pub const _SC_BC_STRING_MAX: int = crate::internal::_SC_BC_STRING_MAX as _; -pub const _SC_COLL_WEIGHTS_MAX: int = crate::internal::_SC_COLL_WEIGHTS_MAX as _; -pub const _SC_EXPR_NEST_MAX: int = crate::internal::_SC_EXPR_NEST_MAX as _; -pub const _SC_LINE_MAX: int = crate::internal::_SC_LINE_MAX as _; -pub const _SC_RE_DUP_MAX: int = crate::internal::_SC_RE_DUP_MAX as _; -pub const _SC_2_VERSION: int = crate::internal::_SC_2_VERSION as _; -pub const _SC_2_C_BIND: int = crate::internal::_SC_2_C_BIND as _; -pub const _SC_2_C_DEV: int = crate::internal::_SC_2_C_DEV as _; -pub const _SC_2_FORT_DEV: int = crate::internal::_SC_2_FORT_DEV as _; -pub const _SC_2_FORT_RUN: int = crate::internal::_SC_2_FORT_RUN as _; -pub const _SC_2_SW_DEV: int = crate::internal::_SC_2_SW_DEV as _; -pub const _SC_2_LOCALEDEF: int = crate::internal::_SC_2_LOCALEDEF as _; -pub const _SC_THREADS: int = crate::internal::_SC_THREADS as _; -pub const _SC_THREAD_SAFE_FUNCTIONS: int = crate::internal::_SC_THREAD_SAFE_FUNCTIONS as _; -pub const _SC_GETGR_R_SIZE_MAX: int = crate::internal::_SC_GETGR_R_SIZE_MAX as _; -pub const _SC_GETPW_R_SIZE_MAX: int = crate::internal::_SC_GETPW_R_SIZE_MAX as _; -pub const _SC_LOGIN_NAME_MAX: int = crate::internal::_SC_LOGIN_NAME_MAX as _; -pub const _SC_TTY_NAME_MAX: int = crate::internal::_SC_TTY_NAME_MAX as _; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: int = - crate::internal::_SC_THREAD_DESTRUCTOR_ITERATIONS as _; -pub const _SC_THREAD_KEYS_MAX: int = crate::internal::_SC_THREAD_KEYS_MAX as _; -pub const _SC_THREAD_STACK_MIN: int = crate::internal::_SC_THREAD_STACK_MIN as _; -pub const _SC_THREAD_THREADS_MAX: int = crate::internal::_SC_THREAD_THREADS_MAX as _; -pub const _SC_THREAD_ATTR_STACKADDR: int = crate::internal::_SC_THREAD_ATTR_STACKADDR as _; -pub const _SC_THREAD_ATTR_STACKSIZE: int = crate::internal::_SC_THREAD_ATTR_STACKSIZE as _; -pub const _SC_THREAD_PRIORITY_SCHEDULING: int = - crate::internal::_SC_THREAD_PRIORITY_SCHEDULING as _; -pub const _SC_THREAD_PRIO_INHERIT: int = crate::internal::_SC_THREAD_PRIO_INHERIT as _; -pub const _SC_THREAD_PRIO_PROTECT: int = crate::internal::_SC_THREAD_PRIO_PROTECT as _; -pub const _SC_THREAD_PROCESS_SHARED: int = crate::internal::_SC_THREAD_PROCESS_SHARED as _; -pub const _SC_NPROCESSORS_CONF: int = crate::internal::_SC_NPROCESSORS_CONF as _; -pub const _SC_NPROCESSORS_ONLN: int = crate::internal::_SC_NPROCESSORS_ONLN as _; -pub const _SC_PHYS_PAGES: int = crate::internal::_SC_PHYS_PAGES as _; -pub const _SC_ATEXIT_MAX: int = crate::internal::_SC_ATEXIT_MAX as _; -pub const _SC_XOPEN_VERSION: int = crate::internal::_SC_XOPEN_VERSION as _; -pub const _SC_XOPEN_XCU_VERSION: int = crate::internal::_SC_XOPEN_XCU_VERSION as _; -pub const _SC_XOPEN_UNIX: int = crate::internal::_SC_XOPEN_UNIX as _; -pub const _SC_XOPEN_CRYPT: int = crate::internal::_SC_XOPEN_CRYPT as _; -pub const _SC_XOPEN_ENH_I18N: int = crate::internal::_SC_XOPEN_ENH_I18N as _; -pub const _SC_XOPEN_SHM: int = crate::internal::_SC_XOPEN_SHM as _; -pub const _SC_2_CHAR_TERM: int = crate::internal::_SC_2_CHAR_TERM as _; -pub const _SC_2_UPE: int = crate::internal::_SC_2_UPE as _; -pub const _SC_XOPEN_LEGACY: int = crate::internal::_SC_XOPEN_LEGACY as _; -pub const _SC_XOPEN_REALTIME: int = crate::internal::_SC_XOPEN_REALTIME as _; -pub const _SC_XOPEN_REALTIME_THREADS: int = crate::internal::_SC_XOPEN_REALTIME_THREADS as _; -pub const _SC_ADVISORY_INFO: int = crate::internal::_SC_ADVISORY_INFO as _; -pub const _SC_BARRIERS: int = crate::internal::_SC_BARRIERS as _; -pub const _SC_CLOCK_SELECTION: int = crate::internal::_SC_CLOCK_SELECTION as _; -pub const _SC_CPUTIME: int = crate::internal::_SC_CPUTIME as _; -pub const _SC_THREAD_CPUTIME: int = crate::internal::_SC_THREAD_CPUTIME as _; -pub const _SC_MONOTONIC_CLOCK: int = crate::internal::_SC_MONOTONIC_CLOCK as _; -pub const _SC_READER_WRITER_LOCKS: int = crate::internal::_SC_READER_WRITER_LOCKS as _; -pub const _SC_SPIN_LOCKS: int = crate::internal::_SC_SPIN_LOCKS as _; -pub const _SC_REGEXP: int = crate::internal::_SC_REGEXP as _; -pub const _SC_SHELL: int = crate::internal::_SC_SHELL as _; -pub const _SC_SPAWN: int = crate::internal::_SC_SPAWN as _; -pub const _SC_SPORADIC_SERVER: int = crate::internal::_SC_SPORADIC_SERVER as _; -pub const _SC_THREAD_SPORADIC_SERVER: int = crate::internal::_SC_THREAD_SPORADIC_SERVER as _; -pub const _SC_TIMEOUTS: int = crate::internal::_SC_TIMEOUTS as _; -pub const _SC_TYPED_MEMORY_OBJECTS: int = crate::internal::_SC_TYPED_MEMORY_OBJECTS as _; -pub const _SC_2_PBS: int = crate::internal::_SC_2_PBS as _; -pub const _SC_2_PBS_ACCOUNTING: int = crate::internal::_SC_2_PBS_ACCOUNTING as _; -pub const _SC_2_PBS_LOCATE: int = crate::internal::_SC_2_PBS_LOCATE as _; -pub const _SC_2_PBS_MESSAGE: int = crate::internal::_SC_2_PBS_MESSAGE as _; -pub const _SC_2_PBS_TRACK: int = crate::internal::_SC_2_PBS_TRACK as _; -pub const _SC_SYMLOOP_MAX: int = crate::internal::_SC_SYMLOOP_MAX as _; -pub const _SC_2_PBS_CHECKPOINT: int = crate::internal::_SC_2_PBS_CHECKPOINT as _; -pub const _SC_V6_ILP32_OFF32: int = crate::internal::_SC_V6_ILP32_OFF32 as _; -pub const _SC_V6_ILP32_OFFBIG: int = crate::internal::_SC_V6_ILP32_OFFBIG as _; -pub const _SC_V6_LP64_OFF64: int = crate::internal::_SC_V6_LP64_OFF64 as _; -pub const _SC_V6_LPBIG_OFFBIG: int = crate::internal::_SC_V6_LPBIG_OFFBIG as _; -pub const _SC_HOST_NAME_MAX: int = crate::internal::_SC_HOST_NAME_MAX as _; -pub const _SC_TRACE: int = crate::internal::_SC_TRACE as _; -pub const _SC_TRACE_EVENT_FILTER: int = crate::internal::_SC_TRACE_EVENT_FILTER as _; -pub const _SC_TRACE_INHERIT: int = crate::internal::_SC_TRACE_INHERIT as _; -pub const _SC_TRACE_LOG: int = crate::internal::_SC_TRACE_LOG as _; -pub const _SC_IPV6: int = crate::internal::_SC_IPV6 as _; -pub const _SC_RAW_SOCKETS: int = crate::internal::_SC_RAW_SOCKETS as _; -pub const _SC_XOPEN_STREAMS: int = crate::internal::_SC_XOPEN_STREAMS as _; +pub const _SC_ARG_MAX: int = libc::_SC_ARG_MAX as _; +pub const _SC_CHILD_MAX: int = libc::_SC_CHILD_MAX as _; +pub const _SC_CLK_TCK: int = libc::_SC_CLK_TCK as _; +pub const _SC_NGROUPS_MAX: int = libc::_SC_NGROUPS_MAX as _; +pub const _SC_OPEN_MAX: int = libc::_SC_OPEN_MAX as _; +pub const _SC_STREAM_MAX: int = libc::_SC_STREAM_MAX as _; +pub const _SC_TZNAME_MAX: int = libc::_SC_TZNAME_MAX as _; +pub const _SC_JOB_CONTROL: int = libc::_SC_JOB_CONTROL as _; +pub const _SC_SAVED_IDS: int = libc::_SC_SAVED_IDS as _; +pub const _SC_REALTIME_SIGNALS: int = libc::_SC_REALTIME_SIGNALS as _; +pub const _SC_PRIORITY_SCHEDULING: int = libc::_SC_PRIORITY_SCHEDULING as _; +pub const _SC_TIMERS: int = libc::_SC_TIMERS as _; +pub const _SC_ASYNCHRONOUS_IO: int = libc::_SC_ASYNCHRONOUS_IO as _; +pub const _SC_PRIORITIZED_IO: int = libc::_SC_PRIORITIZED_IO as _; +pub const _SC_SYNCHRONIZED_IO: int = libc::_SC_SYNCHRONIZED_IO as _; +pub const _SC_FSYNC: int = libc::_SC_FSYNC as _; +pub const _SC_MAPPED_FILES: int = libc::_SC_MAPPED_FILES as _; +pub const _SC_MEMLOCK: int = libc::_SC_MEMLOCK as _; +pub const _SC_MEMLOCK_RANGE: int = libc::_SC_MEMLOCK_RANGE as _; +pub const _SC_MEMORY_PROTECTION: int = libc::_SC_MEMORY_PROTECTION as _; +pub const _SC_MESSAGE_PASSING: int = libc::_SC_MESSAGE_PASSING as _; +pub const _SC_SEMAPHORES: int = libc::_SC_SEMAPHORES as _; +pub const _SC_SHARED_MEMORY_OBJECTS: int = libc::_SC_SHARED_MEMORY_OBJECTS as _; +pub const _SC_AIO_LISTIO_MAX: int = libc::_SC_AIO_LISTIO_MAX as _; +pub const _SC_AIO_MAX: int = libc::_SC_AIO_MAX as _; +pub const _SC_AIO_PRIO_DELTA_MAX: int = libc::_SC_AIO_PRIO_DELTA_MAX as _; +pub const _SC_DELAYTIMER_MAX: int = libc::_SC_DELAYTIMER_MAX as _; +pub const _SC_MQ_OPEN_MAX: int = libc::_SC_MQ_OPEN_MAX as _; +pub const _SC_MQ_PRIO_MAX: int = libc::_SC_MQ_PRIO_MAX as _; +pub const _SC_VERSION: int = libc::_SC_VERSION as _; +pub const _SC_PAGESIZE: int = libc::_SC_PAGESIZE as _; +pub const _SC_RTSIG_MAX: int = libc::_SC_RTSIG_MAX as _; +pub const _SC_SEM_NSEMS_MAX: int = libc::_SC_SEM_NSEMS_MAX as _; +pub const _SC_SEM_VALUE_MAX: int = libc::_SC_SEM_VALUE_MAX as _; +pub const _SC_SIGQUEUE_MAX: int = libc::_SC_SIGQUEUE_MAX as _; +pub const _SC_TIMER_MAX: int = libc::_SC_TIMER_MAX as _; +pub const _SC_BC_BASE_MAX: int = libc::_SC_BC_BASE_MAX as _; +pub const _SC_BC_DIM_MAX: int = libc::_SC_BC_DIM_MAX as _; +pub const _SC_BC_SCALE_MAX: int = libc::_SC_BC_SCALE_MAX as _; +pub const _SC_BC_STRING_MAX: int = libc::_SC_BC_STRING_MAX as _; +pub const _SC_COLL_WEIGHTS_MAX: int = libc::_SC_COLL_WEIGHTS_MAX as _; +pub const _SC_EXPR_NEST_MAX: int = libc::_SC_EXPR_NEST_MAX as _; +pub const _SC_LINE_MAX: int = libc::_SC_LINE_MAX as _; +pub const _SC_RE_DUP_MAX: int = libc::_SC_RE_DUP_MAX as _; +pub const _SC_2_VERSION: int = libc::_SC_2_VERSION as _; +pub const _SC_2_C_BIND: int = libc::_SC_2_C_BIND as _; +pub const _SC_2_C_DEV: int = libc::_SC_2_C_DEV as _; +pub const _SC_2_FORT_DEV: int = libc::_SC_2_FORT_DEV as _; +pub const _SC_2_FORT_RUN: int = libc::_SC_2_FORT_RUN as _; +pub const _SC_2_SW_DEV: int = libc::_SC_2_SW_DEV as _; +pub const _SC_2_LOCALEDEF: int = libc::_SC_2_LOCALEDEF as _; +pub const _SC_THREADS: int = libc::_SC_THREADS as _; +pub const _SC_THREAD_SAFE_FUNCTIONS: int = libc::_SC_THREAD_SAFE_FUNCTIONS as _; +pub const _SC_GETGR_R_SIZE_MAX: int = libc::_SC_GETGR_R_SIZE_MAX as _; +pub const _SC_GETPW_R_SIZE_MAX: int = libc::_SC_GETPW_R_SIZE_MAX as _; +pub const _SC_LOGIN_NAME_MAX: int = libc::_SC_LOGIN_NAME_MAX as _; +pub const _SC_TTY_NAME_MAX: int = libc::_SC_TTY_NAME_MAX as _; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: int = libc::_SC_THREAD_DESTRUCTOR_ITERATIONS as _; +pub const _SC_THREAD_KEYS_MAX: int = libc::_SC_THREAD_KEYS_MAX as _; +pub const _SC_THREAD_STACK_MIN: int = libc::_SC_THREAD_STACK_MIN as _; +pub const _SC_THREAD_THREADS_MAX: int = libc::_SC_THREAD_THREADS_MAX as _; +pub const _SC_THREAD_ATTR_STACKADDR: int = libc::_SC_THREAD_ATTR_STACKADDR as _; +pub const _SC_THREAD_ATTR_STACKSIZE: int = libc::_SC_THREAD_ATTR_STACKSIZE as _; +pub const _SC_THREAD_PRIORITY_SCHEDULING: int = libc::_SC_THREAD_PRIORITY_SCHEDULING as _; +pub const _SC_THREAD_PRIO_INHERIT: int = libc::_SC_THREAD_PRIO_INHERIT as _; +pub const _SC_THREAD_PRIO_PROTECT: int = libc::_SC_THREAD_PRIO_PROTECT as _; +pub const _SC_THREAD_PROCESS_SHARED: int = libc::_SC_THREAD_PROCESS_SHARED as _; +pub const _SC_NPROCESSORS_CONF: int = libc::_SC_NPROCESSORS_CONF as _; +pub const _SC_NPROCESSORS_ONLN: int = libc::_SC_NPROCESSORS_ONLN as _; +pub const _SC_PHYS_PAGES: int = libc::_SC_PHYS_PAGES as _; +pub const _SC_ATEXIT_MAX: int = libc::_SC_ATEXIT_MAX as _; +pub const _SC_XOPEN_VERSION: int = libc::_SC_XOPEN_VERSION as _; +pub const _SC_XOPEN_XCU_VERSION: int = libc::_SC_XOPEN_XCU_VERSION as _; +pub const _SC_XOPEN_UNIX: int = libc::_SC_XOPEN_UNIX as _; +pub const _SC_XOPEN_CRYPT: int = libc::_SC_XOPEN_CRYPT as _; +pub const _SC_XOPEN_ENH_I18N: int = libc::_SC_XOPEN_ENH_I18N as _; +pub const _SC_XOPEN_SHM: int = libc::_SC_XOPEN_SHM as _; +pub const _SC_2_CHAR_TERM: int = libc::_SC_2_CHAR_TERM as _; +pub const _SC_2_UPE: int = libc::_SC_2_UPE as _; +pub const _SC_XOPEN_LEGACY: int = libc::_SC_XOPEN_LEGACY as _; +pub const _SC_XOPEN_REALTIME: int = libc::_SC_XOPEN_REALTIME as _; +pub const _SC_XOPEN_REALTIME_THREADS: int = libc::_SC_XOPEN_REALTIME_THREADS as _; +pub const _SC_ADVISORY_INFO: int = libc::_SC_ADVISORY_INFO as _; +pub const _SC_BARRIERS: int = libc::_SC_BARRIERS as _; +pub const _SC_CLOCK_SELECTION: int = libc::_SC_CLOCK_SELECTION as _; +pub const _SC_CPUTIME: int = libc::_SC_CPUTIME as _; +pub const _SC_THREAD_CPUTIME: int = libc::_SC_THREAD_CPUTIME as _; +pub const _SC_MONOTONIC_CLOCK: int = libc::_SC_MONOTONIC_CLOCK as _; +pub const _SC_READER_WRITER_LOCKS: int = libc::_SC_READER_WRITER_LOCKS as _; +pub const _SC_SPIN_LOCKS: int = libc::_SC_SPIN_LOCKS as _; +pub const _SC_REGEXP: int = libc::_SC_REGEXP as _; +pub const _SC_SHELL: int = libc::_SC_SHELL as _; +pub const _SC_SPAWN: int = libc::_SC_SPAWN as _; +pub const _SC_SPORADIC_SERVER: int = libc::_SC_SPORADIC_SERVER as _; +pub const _SC_THREAD_SPORADIC_SERVER: int = libc::_SC_THREAD_SPORADIC_SERVER as _; +pub const _SC_TIMEOUTS: int = libc::_SC_TIMEOUTS as _; +pub const _SC_TYPED_MEMORY_OBJECTS: int = libc::_SC_TYPED_MEMORY_OBJECTS as _; +pub const _SC_2_PBS: int = libc::_SC_2_PBS as _; +pub const _SC_2_PBS_ACCOUNTING: int = libc::_SC_2_PBS_ACCOUNTING as _; +pub const _SC_2_PBS_LOCATE: int = libc::_SC_2_PBS_LOCATE as _; +pub const _SC_2_PBS_MESSAGE: int = libc::_SC_2_PBS_MESSAGE as _; +pub const _SC_2_PBS_TRACK: int = libc::_SC_2_PBS_TRACK as _; +pub const _SC_SYMLOOP_MAX: int = libc::_SC_SYMLOOP_MAX as _; +pub const _SC_2_PBS_CHECKPOINT: int = libc::_SC_2_PBS_CHECKPOINT as _; +pub const _SC_V6_ILP32_OFF32: int = libc::_SC_V6_ILP32_OFF32 as _; +pub const _SC_V6_ILP32_OFFBIG: int = libc::_SC_V6_ILP32_OFFBIG as _; +pub const _SC_V6_LP64_OFF64: int = libc::_SC_V6_LP64_OFF64 as _; +pub const _SC_V6_LPBIG_OFFBIG: int = libc::_SC_V6_LPBIG_OFFBIG as _; +pub const _SC_HOST_NAME_MAX: int = libc::_SC_HOST_NAME_MAX as _; +pub const _SC_TRACE: int = libc::_SC_TRACE as _; +pub const _SC_TRACE_EVENT_FILTER: int = libc::_SC_TRACE_EVENT_FILTER as _; +pub const _SC_TRACE_INHERIT: int = libc::_SC_TRACE_INHERIT as _; +pub const _SC_TRACE_LOG: int = libc::_SC_TRACE_LOG as _; +pub const _SC_IPV6: int = libc::_SC_IPV6 as _; +pub const _SC_RAW_SOCKETS: int = libc::_SC_RAW_SOCKETS as _; +pub const _SC_XOPEN_STREAMS: int = libc::_SC_XOPEN_STREAMS as _; -pub const _PC_LINK_MAX: int = crate::internal::_PC_LINK_MAX as _; -pub const _PC_MAX_CANON: int = crate::internal::_PC_MAX_CANON as _; -pub const _PC_MAX_INPUT: int = crate::internal::_PC_MAX_INPUT as _; -pub const _PC_NAME_MAX: int = crate::internal::_PC_NAME_MAX as _; -pub const _PC_PATH_MAX: int = crate::internal::_PC_PATH_MAX as _; -pub const _PC_PIPE_BUF: int = crate::internal::_PC_PIPE_BUF as _; -pub const _PC_CHOWN_RESTRICTED: int = crate::internal::_PC_CHOWN_RESTRICTED as _; -pub const _PC_NO_TRUNC: int = crate::internal::_PC_NO_TRUNC as _; -pub const _PC_VDISABLE: int = crate::internal::_PC_VDISABLE as _; -pub const _PC_SYNC_IO: int = crate::internal::_PC_SYNC_IO as _; -pub const _PC_ASYNC_IO: int = crate::internal::_PC_ASYNC_IO as _; -pub const _PC_PRIO_IO: int = crate::internal::_PC_PRIO_IO as _; -pub const _PC_FILESIZEBITS: int = crate::internal::_PC_FILESIZEBITS as _; -pub const _PC_REC_INCR_XFER_SIZE: int = crate::internal::_PC_REC_INCR_XFER_SIZE as _; -pub const _PC_REC_MAX_XFER_SIZE: int = crate::internal::_PC_REC_MAX_XFER_SIZE as _; -pub const _PC_REC_MIN_XFER_SIZE: int = crate::internal::_PC_REC_MIN_XFER_SIZE as _; -pub const _PC_REC_XFER_ALIGN: int = crate::internal::_PC_REC_XFER_ALIGN as _; -pub const _PC_ALLOC_SIZE_MIN: int = crate::internal::_PC_ALLOC_SIZE_MIN as _; -pub const _PC_SYMLINK_MAX: int = crate::internal::_PC_SYMLINK_MAX as _; +pub const _PC_LINK_MAX: int = libc::_PC_LINK_MAX as _; +pub const _PC_MAX_CANON: int = libc::_PC_MAX_CANON as _; +pub const _PC_MAX_INPUT: int = libc::_PC_MAX_INPUT as _; +pub const _PC_NAME_MAX: int = libc::_PC_NAME_MAX as _; +pub const _PC_PATH_MAX: int = libc::_PC_PATH_MAX as _; +pub const _PC_PIPE_BUF: int = libc::_PC_PIPE_BUF as _; +pub const _PC_CHOWN_RESTRICTED: int = libc::_PC_CHOWN_RESTRICTED as _; +pub const _PC_NO_TRUNC: int = libc::_PC_NO_TRUNC as _; +pub const _PC_VDISABLE: int = libc::_PC_VDISABLE as _; +pub const _PC_SYNC_IO: int = libc::_PC_SYNC_IO as _; +pub const _PC_ASYNC_IO: int = libc::_PC_ASYNC_IO as _; +pub const _PC_PRIO_IO: int = libc::_PC_PRIO_IO as _; +pub const _PC_FILESIZEBITS: int = libc::_PC_FILESIZEBITS as _; +pub const _PC_REC_INCR_XFER_SIZE: int = libc::_PC_REC_INCR_XFER_SIZE as _; +pub const _PC_REC_MAX_XFER_SIZE: int = libc::_PC_REC_MAX_XFER_SIZE as _; +pub const _PC_REC_MIN_XFER_SIZE: int = libc::_PC_REC_MIN_XFER_SIZE as _; +pub const _PC_REC_XFER_ALIGN: int = libc::_PC_REC_XFER_ALIGN as _; +pub const _PC_ALLOC_SIZE_MIN: int = libc::_PC_ALLOC_SIZE_MIN as _; +pub const _PC_SYMLINK_MAX: int = libc::_PC_SYMLINK_MAX as _; diff --git a/iceoryx2-pal/posix/src/libc/dirent.rs b/iceoryx2-pal/posix/src/libc/dirent.rs index 188bdc4a7..ce7ec8d70 100644 --- a/iceoryx2-pal/posix/src/libc/dirent.rs +++ b/iceoryx2-pal/posix/src/libc/dirent.rs @@ -20,25 +20,25 @@ pub unsafe fn scandir(path: *const c_char, namelist: *mut *mut *mut dirent) -> i } pub unsafe fn mkdir(pathname: *const c_char, mode: mode_t) -> int { - crate::internal::mkdir(pathname, mode) + libc::mkdir(pathname, mode) } pub unsafe fn opendir(dirname: *const c_char) -> *mut DIR { - crate::internal::opendir(dirname) + libc::opendir(dirname) } pub unsafe fn closedir(dirp: *mut DIR) -> int { - crate::internal::closedir(dirp) + libc::closedir(dirp) } pub unsafe fn dirfd(dirp: *mut DIR) -> int { - crate::internal::dirfd(dirp) + libc::dirfd(dirp) } pub unsafe fn readdir(dirp: *mut DIR) -> *const dirent { - crate::internal::readdir(dirp) + libc::readdir(dirp) } pub unsafe fn readdir_r(dirp: *mut DIR, entry: *mut dirent, result: *mut *mut dirent) -> int { - crate::internal::readdir_r(dirp, entry, result) + libc::readdir_r(dirp, entry, result) } diff --git a/iceoryx2-pal/posix/src/libc/errno.rs b/iceoryx2-pal/posix/src/libc/errno.rs index 542708215..9981ade84 100644 --- a/iceoryx2-pal/posix/src/libc/errno.rs +++ b/iceoryx2-pal/posix/src/libc/errno.rs @@ -21,7 +21,7 @@ macro_rules! ErrnoEnumGenerator { #[repr(i32)] pub enum Errno { $($entry = $value),*, - $($map_entry = crate::internal::$map_entry as _),*, + $($map_entry = libc::$map_entry as _),*, NOTIMPLEMENTED = i32::MAX } @@ -30,9 +30,9 @@ macro_rules! ErrnoEnumGenerator { impl Into for u32 { #[deny(clippy::from_over_into)] fn into(self) -> Errno { - match self { + match self as i32 { $($value => Errno::$entry),*, - $($crate::internal::$map_entry => Errno::$map_entry),*, + $(libc::$map_entry => Errno::$map_entry),*, _ => Errno::NOTIMPLEMENTED } } @@ -198,15 +198,15 @@ ErrnoEnumGenerator!( impl Errno { pub fn get() -> Errno { - unsafe { *crate::internal::__errno_location() }.into() + unsafe { *libc::__errno_location() }.into() } pub fn set(value: Errno) { - unsafe { *crate::internal::__errno_location() = value as i32 }; + unsafe { *libc::__errno_location() = value as i32 }; } pub fn reset() { - unsafe { *crate::internal::__errno_location() = 0 }; + unsafe { *libc::__errno_location() = 0 }; } } @@ -229,5 +229,5 @@ pub unsafe fn strerror_r(errnum: int, buf: *mut c_char, buflen: size_t) -> int { } pub unsafe fn strerror(errnum: int) -> *const c_char { - crate::internal::strerror(errnum) + libc::strerror(errnum) } diff --git a/iceoryx2-pal/posix/src/libc/fcntl.rs b/iceoryx2-pal/posix/src/libc/fcntl.rs index 9e8cdc298..db4d56d8b 100644 --- a/iceoryx2-pal/posix/src/libc/fcntl.rs +++ b/iceoryx2-pal/posix/src/libc/fcntl.rs @@ -17,12 +17,12 @@ use crate::posix::types::*; use crate::posix::Struct; pub unsafe fn open_with_mode(pathname: *const c_char, flags: int, mode: mode_t) -> int { - crate::internal::open(pathname, flags, mode) + libc::open(pathname, flags, mode) } pub unsafe fn fstat(fd: int, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); - match crate::internal::fstat(fd, &mut os_specific_buffer) { + let mut os_specific_buffer = native_stat_t::new(); + match libc::fstat(fd, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); 0 @@ -32,21 +32,21 @@ pub unsafe fn fstat(fd: int, buf: *mut stat_t) -> int { } pub unsafe fn fcntl_int(fd: int, cmd: int, arg: int) -> int { - crate::internal::fcntl(fd, cmd, arg) + libc::fcntl(fd, cmd, arg) } pub unsafe fn fcntl(fd: int, cmd: int, arg: *mut flock) -> int { - crate::internal::fcntl(fd, cmd, arg) + libc::fcntl(fd, cmd, arg) } pub unsafe fn fcntl2(fd: int, cmd: int) -> int { - crate::internal::fcntl(fd, cmd) + libc::fcntl(fd, cmd) } pub unsafe fn fchmod(fd: int, mode: mode_t) -> int { - crate::internal::fchmod(fd, mode) + libc::fchmod(fd, mode) } pub unsafe fn open(pathname: *const c_char, flags: int) -> int { - crate::internal::open(pathname, flags) + libc::open(pathname, flags) } diff --git a/iceoryx2-pal/posix/src/libc/inet.rs b/iceoryx2-pal/posix/src/libc/inet.rs index abb6c94f5..cce44c2c4 100644 --- a/iceoryx2-pal/posix/src/libc/inet.rs +++ b/iceoryx2-pal/posix/src/libc/inet.rs @@ -14,17 +14,17 @@ #![allow(clippy::missing_safety_doc)] pub unsafe fn htonl(hostlong: u32) -> u32 { - crate::internal::htonl(hostlong) + libc::htonl(hostlong) } pub unsafe fn htons(hostshort: u16) -> u16 { - crate::internal::htons(hostshort) + libc::htons(hostshort) } pub unsafe fn ntohl(netlong: u32) -> u32 { - crate::internal::ntohl(netlong) + libc::ntohl(netlong) } pub unsafe fn ntohs(netshort: u16) -> u16 { - crate::internal::ntohs(netshort) + libc::ntohs(netshort) } diff --git a/iceoryx2-pal/posix/src/libc/mman.rs b/iceoryx2-pal/posix/src/libc/mman.rs index 3fb43938b..6fd81d9aa 100644 --- a/iceoryx2-pal/posix/src/libc/mman.rs +++ b/iceoryx2-pal/posix/src/libc/mman.rs @@ -16,27 +16,27 @@ use crate::posix::{closedir, opendir, readdir, types::*}; pub unsafe fn mlock(addr: *const void, len: size_t) -> int { - crate::internal::mlock(addr, len) + libc::mlock(addr, len) } pub unsafe fn munlock(addr: *const void, len: size_t) -> int { - crate::internal::munlock(addr, len) + libc::munlock(addr, len) } pub unsafe fn mlockall(flags: int) -> int { - crate::internal::mlockall(flags) + libc::mlockall(flags) } pub unsafe fn munlockall() -> int { - crate::internal::munlockall() + libc::munlockall() } pub unsafe fn shm_open(name: *const c_char, oflag: int, mode: mode_t) -> int { - crate::internal::shm_open(name, oflag, mode) + libc::shm_open(name, oflag, mode) } pub unsafe fn shm_unlink(name: *const c_char) -> int { - crate::internal::shm_unlink(name) + libc::shm_unlink(name) } pub unsafe fn shm_list() -> Vec<[i8; 256]> { @@ -84,13 +84,13 @@ pub unsafe fn mmap( fd: int, off: off_t, ) -> *mut void { - crate::internal::mmap(addr, len, prot, flags, fd, off) + libc::mmap(addr, len, prot, flags, fd, off) } pub unsafe fn munmap(addr: *mut void, len: size_t) -> int { - crate::internal::munmap(addr, len) + libc::munmap(addr, len) } pub unsafe fn mprotect(addr: *mut void, len: size_t, prot: int) -> int { - crate::internal::mprotect(addr, len, prot) + libc::mprotect(addr, len, prot) } diff --git a/iceoryx2-pal/posix/src/libc/mod.rs b/iceoryx2-pal/posix/src/libc/mod.rs index a3adf2d9a..a7f592ea9 100644 --- a/iceoryx2-pal/posix/src/libc/mod.rs +++ b/iceoryx2-pal/posix/src/libc/mod.rs @@ -33,25 +33,25 @@ pub mod time; pub mod types; pub mod unistd; -pub use crate::linux::constants::*; -pub use crate::linux::dirent::*; -pub use crate::linux::errno::*; -pub use crate::linux::fcntl::*; -pub use crate::linux::inet::*; -pub use crate::linux::mman::*; -pub use crate::linux::pthread::*; -pub use crate::linux::pwd::*; -pub use crate::linux::resource::*; -pub use crate::linux::sched::*; -pub use crate::linux::select::*; -pub use crate::linux::semaphore::*; -pub use crate::linux::signal::*; -pub use crate::linux::socket::*; -pub use crate::linux::stat::*; -pub use crate::linux::stdio::*; -pub use crate::linux::stdlib::*; -pub use crate::linux::string::*; -pub use crate::linux::support::*; -pub use crate::linux::time::*; -pub use crate::linux::types::*; -pub use crate::linux::unistd::*; +pub use crate::libc::constants::*; +pub use crate::libc::dirent::*; +pub use crate::libc::errno::*; +pub use crate::libc::fcntl::*; +pub use crate::libc::inet::*; +pub use crate::libc::mman::*; +pub use crate::libc::pthread::*; +pub use crate::libc::pwd::*; +pub use crate::libc::resource::*; +pub use crate::libc::sched::*; +pub use crate::libc::select::*; +pub use crate::libc::semaphore::*; +pub use crate::libc::signal::*; +pub use crate::libc::socket::*; +pub use crate::libc::stat::*; +pub use crate::libc::stdio::*; +pub use crate::libc::stdlib::*; +pub use crate::libc::string::*; +pub use crate::libc::support::*; +pub use crate::libc::time::*; +pub use crate::libc::types::*; +pub use crate::libc::unistd::*; diff --git a/iceoryx2-pal/posix/src/libc/pthread.rs b/iceoryx2-pal/posix/src/libc/pthread.rs index 44b9ac6a0..f816a9f42 100644 --- a/iceoryx2-pal/posix/src/libc/pthread.rs +++ b/iceoryx2-pal/posix/src/libc/pthread.rs @@ -16,11 +16,11 @@ use crate::posix::*; pub unsafe fn pthread_rwlockattr_setkind_np(attr: *mut pthread_rwlockattr_t, pref: int) -> int { - crate::internal::pthread_rwlockattr_setkind_np(attr, pref) + libc::pthread_rwlockattr_setkind_np(attr, pref) } pub unsafe fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> int { - crate::internal::pthread_barrier_wait(barrier) + libc::pthread_barrier_wait(barrier) } pub unsafe fn pthread_barrier_init( @@ -28,57 +28,57 @@ pub unsafe fn pthread_barrier_init( attr: *const pthread_barrierattr_t, count: uint, ) -> int { - crate::internal::pthread_barrier_init(barrier, attr, count) + libc::pthread_barrier_init(barrier, attr, count) } pub unsafe fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> int { - crate::internal::pthread_barrier_destroy(barrier) + libc::pthread_barrier_destroy(barrier) } pub unsafe fn pthread_barrierattr_destroy(attr: *mut pthread_barrierattr_t) -> int { - crate::internal::pthread_barrierattr_destroy(attr) + libc::pthread_barrierattr_destroy(attr) } pub unsafe fn pthread_barrierattr_init(attr: *mut pthread_barrierattr_t) -> int { - crate::internal::pthread_barrierattr_init(attr) + libc::pthread_barrierattr_init(attr) } pub unsafe fn pthread_barrierattr_setpshared( attr: *mut pthread_barrierattr_t, pshared: int, ) -> int { - crate::internal::pthread_barrierattr_setpshared(attr, pshared) + libc::pthread_barrierattr_setpshared(attr, pshared) } pub unsafe fn pthread_attr_init(attr: *mut pthread_attr_t) -> int { - crate::internal::pthread_attr_init(attr) + libc::pthread_attr_init(attr) } pub unsafe fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> int { - crate::internal::pthread_attr_destroy(attr) + libc::pthread_attr_destroy(attr) } pub unsafe fn pthread_attr_setguardsize(attr: *mut pthread_attr_t, guardsize: size_t) -> int { - crate::internal::pthread_attr_setguardsize(attr, guardsize) + libc::pthread_attr_setguardsize(attr, guardsize) } pub unsafe fn pthread_attr_setinheritsched(attr: *mut pthread_attr_t, inheritsched: int) -> int { - crate::internal::pthread_attr_setinheritsched(attr, inheritsched) + libc::pthread_attr_setinheritsched(attr, inheritsched) } pub unsafe fn pthread_attr_setschedpolicy(attr: *mut pthread_attr_t, policy: int) -> int { - crate::internal::pthread_attr_setschedpolicy(attr, policy) + libc::pthread_attr_setschedpolicy(attr, policy) } pub unsafe fn pthread_attr_setschedparam( attr: *mut pthread_attr_t, param: *const sched_param, ) -> int { - crate::internal::pthread_attr_setschedparam(attr, param) + libc::pthread_attr_setschedparam(attr, param) } pub unsafe fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stacksize: size_t) -> int { - crate::internal::pthread_attr_setstacksize(attr, stacksize) + libc::pthread_attr_setstacksize(attr, stacksize) } pub unsafe fn pthread_attr_setaffinity_np( @@ -86,36 +86,38 @@ pub unsafe fn pthread_attr_setaffinity_np( cpusetsize: size_t, cpuset: *const cpu_set_t, ) -> int { - internal::pthread_attr_setaffinity_np(attr, cpusetsize, cpuset) + let cpuset = core::mem::transmute::(*cpuset); + + libc::pthread_attr_setaffinity_np(attr, cpusetsize, &cpuset) } pub unsafe fn pthread_create( thread: *mut pthread_t, attr: *const pthread_attr_t, - start_routine: unsafe extern "C" fn(*mut void) -> *mut void, + start_routine: extern "C" fn(*mut void) -> *mut void, arg: *mut void, ) -> int { - crate::internal::pthread_create(thread, attr, Some(start_routine), arg) + libc::pthread_create(thread, attr, start_routine, arg) } pub unsafe fn pthread_join(thread: pthread_t, retval: *mut *mut void) -> int { - crate::internal::pthread_join(thread, retval) + libc::pthread_join(thread, retval) } pub unsafe fn pthread_self() -> pthread_t { - crate::internal::pthread_self() + libc::pthread_self() } pub unsafe fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> int { - internal::pthread_setname_np(thread, name) + libc::pthread_setname_np(thread, name) } pub unsafe fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size_t) -> int { - internal::pthread_getname_np(thread, name, len) + libc::pthread_getname_np(thread, name, len) } pub unsafe fn pthread_kill(thread: pthread_t, sig: int) -> int { - internal::pthread_kill(thread, sig) + libc::pthread_kill(thread, sig) } pub unsafe fn pthread_setaffinity_np( @@ -123,7 +125,9 @@ pub unsafe fn pthread_setaffinity_np( cpusetsize: size_t, cpuset: *const cpu_set_t, ) -> int { - internal::pthread_setaffinity_np(thread, cpusetsize, cpuset) + let cpuset = core::mem::transmute::(*cpuset); + + libc::pthread_setaffinity_np(thread, cpusetsize, &cpuset) } pub unsafe fn pthread_getaffinity_np( @@ -131,133 +135,112 @@ pub unsafe fn pthread_getaffinity_np( cpusetsize: size_t, cpuset: *mut cpu_set_t, ) -> int { - internal::pthread_getaffinity_np(thread, cpusetsize, cpuset) + let mut native_cpuset = native_cpu_set_t::new(); + + let ret_val = libc::pthread_getaffinity_np(thread, cpusetsize, &mut native_cpuset); + + *cpuset = core::mem::transmute::(native_cpuset); + + ret_val } pub unsafe fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> int { - crate::internal::pthread_rwlockattr_init(attr) + libc::pthread_rwlockattr_init(attr) } pub unsafe fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> int { - crate::internal::pthread_rwlockattr_destroy(attr) + libc::pthread_rwlockattr_destroy(attr) } pub unsafe fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, pshared: int) -> int { - crate::internal::pthread_rwlockattr_setpshared(attr, pshared) + libc::pthread_rwlockattr_setpshared(attr, pshared) } pub unsafe fn pthread_rwlock_init( lock: *mut pthread_rwlock_t, attr: *const pthread_rwlockattr_t, ) -> int { - crate::internal::pthread_rwlock_init(lock, attr) + libc::pthread_rwlock_init(lock, attr) } pub unsafe fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> int { - crate::internal::pthread_rwlock_destroy(lock) + libc::pthread_rwlock_destroy(lock) } pub unsafe fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> int { - crate::internal::pthread_rwlock_rdlock(lock) + libc::pthread_rwlock_rdlock(lock) } pub unsafe fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> int { - crate::internal::pthread_rwlock_tryrdlock(lock) + libc::pthread_rwlock_tryrdlock(lock) } pub unsafe fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> int { - crate::internal::pthread_rwlock_unlock(lock) + libc::pthread_rwlock_unlock(lock) } pub unsafe fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> int { - crate::internal::pthread_rwlock_wrlock(lock) + libc::pthread_rwlock_wrlock(lock) } pub unsafe fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> int { - crate::internal::pthread_rwlock_trywrlock(lock) + libc::pthread_rwlock_trywrlock(lock) } pub unsafe fn pthread_mutex_init( mtx: *mut pthread_mutex_t, attr: *const pthread_mutexattr_t, ) -> int { - crate::internal::pthread_mutex_init(mtx, attr) + libc::pthread_mutex_init(mtx, attr) } pub unsafe fn pthread_mutex_destroy(mtx: *mut pthread_mutex_t) -> int { - crate::internal::pthread_mutex_destroy(mtx) + libc::pthread_mutex_destroy(mtx) } pub unsafe fn pthread_mutex_lock(mtx: *mut pthread_mutex_t) -> int { - crate::internal::pthread_mutex_lock(mtx) + libc::pthread_mutex_lock(mtx) } pub unsafe fn pthread_mutex_timedlock( mtx: *mut pthread_mutex_t, abs_timeout: *const timespec, ) -> int { - crate::internal::pthread_mutex_timedlock(mtx, abs_timeout) + libc::pthread_mutex_timedlock(mtx, abs_timeout) } pub unsafe fn pthread_mutex_trylock(mtx: *mut pthread_mutex_t) -> int { - crate::internal::pthread_mutex_trylock(mtx) + libc::pthread_mutex_trylock(mtx) } pub unsafe fn pthread_mutex_unlock(mtx: *mut pthread_mutex_t) -> int { - crate::internal::pthread_mutex_unlock(mtx) + libc::pthread_mutex_unlock(mtx) } pub unsafe fn pthread_mutex_consistent(mtx: *mut pthread_mutex_t) -> int { - crate::internal::pthread_mutex_consistent(mtx) + libc::pthread_mutex_consistent(mtx) } pub unsafe fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> int { - crate::internal::pthread_mutexattr_init(attr) + libc::pthread_mutexattr_init(attr) } pub unsafe fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> int { - crate::internal::pthread_mutexattr_destroy(attr) + libc::pthread_mutexattr_destroy(attr) } pub unsafe fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: int) -> int { - crate::internal::pthread_mutexattr_setprotocol(attr, protocol) + libc::pthread_mutexattr_setprotocol(attr, protocol) } pub unsafe fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: int) -> int { - crate::internal::pthread_mutexattr_setpshared(attr, pshared) + libc::pthread_mutexattr_setpshared(attr, pshared) } pub unsafe fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robustness: int) -> int { - crate::internal::pthread_mutexattr_setrobust(attr, robustness) + libc::pthread_mutexattr_setrobust(attr, robustness) } pub unsafe fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, mtype: int) -> int { - crate::internal::pthread_mutexattr_settype(attr, mtype) -} - -mod internal { - use super::*; - - #[cfg_attr(target_os = "linux", link(name = "pthread"))] - extern "C" { - pub(super) fn pthread_attr_setaffinity_np( - attr: *mut pthread_attr_t, - cpusetsize: size_t, - cpuset: *const cpu_set_t, - ) -> int; - - pub(super) fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> int; - pub(super) fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size_t) -> int; - pub(super) fn pthread_kill(thread: pthread_t, sig: int) -> int; - pub(super) fn pthread_setaffinity_np( - thread: pthread_t, - cpusetsize: size_t, - cpuset: *const cpu_set_t, - ) -> int; - pub(super) fn pthread_getaffinity_np( - thread: pthread_t, - cpusetsize: size_t, - cpuset: *mut cpu_set_t, - ) -> int; - } + libc::pthread_mutexattr_settype(attr, mtype) } diff --git a/iceoryx2-pal/posix/src/libc/pwd.rs b/iceoryx2-pal/posix/src/libc/pwd.rs index e8b36d9da..0d4ac1d30 100644 --- a/iceoryx2-pal/posix/src/libc/pwd.rs +++ b/iceoryx2-pal/posix/src/libc/pwd.rs @@ -21,7 +21,7 @@ pub unsafe fn getpwnam_r( buflen: size_t, result: *mut *mut passwd, ) -> int { - crate::internal::getpwnam_r(name, pwd, buf, buflen, result) + libc::getpwnam_r(name, pwd, buf, buflen, result) } pub unsafe fn getpwuid_r( @@ -31,7 +31,7 @@ pub unsafe fn getpwuid_r( buflen: size_t, result: *mut *mut passwd, ) -> int { - crate::internal::getpwuid_r(uid, pwd, buf, buflen, result) + libc::getpwuid_r(uid, pwd, buf, buflen, result) } pub unsafe fn getgrnam_r( @@ -41,7 +41,7 @@ pub unsafe fn getgrnam_r( buflen: size_t, result: *mut *mut group, ) -> int { - crate::internal::getgrnam_r(name, grp, buf, buflen, result) + libc::getgrnam_r(name, grp, buf, buflen, result) } pub unsafe fn getgrgid_r( @@ -51,5 +51,5 @@ pub unsafe fn getgrgid_r( buflen: size_t, result: *mut *mut group, ) -> int { - crate::internal::getgrgid_r(gid, grp, buf, buflen, result) + libc::getgrgid_r(gid, grp, buf, buflen, result) } diff --git a/iceoryx2-pal/posix/src/libc/resource.rs b/iceoryx2-pal/posix/src/libc/resource.rs index 398e4e214..574ec5e94 100644 --- a/iceoryx2-pal/posix/src/libc/resource.rs +++ b/iceoryx2-pal/posix/src/libc/resource.rs @@ -16,9 +16,9 @@ use crate::posix::types::*; pub unsafe fn getrlimit(resource: int, rlim: *mut rlimit) -> int { - crate::internal::getrlimit(resource, rlim) + libc::getrlimit(resource as _, rlim) } pub unsafe fn setrlimit(resource: int, rlim: *const rlimit) -> int { - crate::internal::setrlimit(resource, rlim) + libc::setrlimit(resource as _, rlim) } diff --git a/iceoryx2-pal/posix/src/libc/sched.rs b/iceoryx2-pal/posix/src/libc/sched.rs index bad7abac1..442bece91 100644 --- a/iceoryx2-pal/posix/src/libc/sched.rs +++ b/iceoryx2-pal/posix/src/libc/sched.rs @@ -16,29 +16,29 @@ use crate::posix::types::*; pub unsafe fn sched_get_priority_max(policy: int) -> int { - crate::internal::sched_get_priority_max(policy) + libc::sched_get_priority_max(policy) } pub unsafe fn sched_get_priority_min(policy: int) -> int { - crate::internal::sched_get_priority_min(policy) + libc::sched_get_priority_min(policy) } pub unsafe fn sched_yield() -> int { - crate::internal::sched_yield() + libc::sched_yield() } pub unsafe fn sched_getparam(pid: pid_t, param: *mut sched_param) -> int { - crate::internal::sched_getparam(pid, param) + libc::sched_getparam(pid, param) } pub unsafe fn sched_getscheduler(pid: pid_t) -> int { - crate::internal::sched_getscheduler(pid) + libc::sched_getscheduler(pid) } pub unsafe fn sched_setparam(pid: pid_t, param: *const sched_param) -> int { - crate::internal::sched_setparam(pid, param) + libc::sched_setparam(pid, param) } pub unsafe fn sched_setscheduler(pid: pid_t, policy: int, param: *const sched_param) -> int { - crate::internal::sched_setscheduler(pid, policy, param) + libc::sched_setscheduler(pid, policy, param) } diff --git a/iceoryx2-pal/posix/src/libc/select.rs b/iceoryx2-pal/posix/src/libc/select.rs index ef2a68370..d60ac7410 100644 --- a/iceoryx2-pal/posix/src/libc/select.rs +++ b/iceoryx2-pal/posix/src/libc/select.rs @@ -22,58 +22,41 @@ pub unsafe fn select( errorfds: *mut fd_set, timeout: *mut timeval, ) -> int { - crate::internal::select(nfds, readfds, writefds, errorfds, timeout) + libc::select(nfds, readfds, writefds, errorfds, timeout) } pub unsafe fn CMSG_SPACE(length: size_t) -> size_t { - internal::iceoryx2_cmsg_space(length) + libc::CMSG_SPACE(length as _) as _ } pub unsafe fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - internal::iceoryx2_cmsg_firsthdr(mhdr) + libc::CMSG_FIRSTHDR(mhdr) } pub unsafe fn CMSG_NXTHDR(header: *const msghdr, sub_header: *const cmsghdr) -> *mut cmsghdr { - internal::iceoryx2_cmsg_nxthdr(header as *mut msghdr, sub_header as *mut cmsghdr) + libc::CMSG_NXTHDR(header as *mut msghdr, sub_header as *mut cmsghdr) } pub unsafe fn CMSG_LEN(length: size_t) -> size_t { - internal::iceoryx2_cmsg_len(length) + libc::CMSG_LEN(length as _) as _ } pub unsafe fn CMSG_DATA(cmsg: *mut cmsghdr) -> *mut uchar { - internal::iceoryx2_cmsg_data(cmsg) + libc::CMSG_DATA(cmsg) } pub unsafe fn FD_CLR(fd: int, set: *mut fd_set) { - internal::iceoryx2_fd_clr(fd, set) + libc::FD_CLR(fd, set) } pub unsafe fn FD_ISSET(fd: int, set: *const fd_set) -> bool { - internal::iceoryx2_fd_isset(fd, set) != 0 + libc::FD_ISSET(fd, set) } pub unsafe fn FD_SET(fd: int, set: *mut fd_set) { - internal::iceoryx2_fd_set(fd, set) + libc::FD_SET(fd, set) } pub unsafe fn FD_ZERO(set: *mut fd_set) { - internal::iceoryx2_fd_zero(set) -} - -mod internal { - use super::*; - - #[cfg_attr(target_os = "linux", link(name = "c"))] - extern "C" { - pub(super) fn iceoryx2_cmsg_space(len: size_t) -> size_t; - pub(super) fn iceoryx2_cmsg_firsthdr(hdr: *const msghdr) -> *mut cmsghdr; - pub(super) fn iceoryx2_cmsg_nxthdr(hdr: *mut msghdr, sub: *mut cmsghdr) -> *mut cmsghdr; - pub(super) fn iceoryx2_cmsg_len(len: size_t) -> size_t; - pub(super) fn iceoryx2_cmsg_data(cmsg: *mut cmsghdr) -> *mut uchar; - pub(super) fn iceoryx2_fd_clr(fd: int, set: *mut fd_set); - pub(super) fn iceoryx2_fd_isset(fd: int, set: *const fd_set) -> int; - pub(super) fn iceoryx2_fd_set(fd: int, set: *mut fd_set); - pub(super) fn iceoryx2_fd_zero(set: *mut fd_set); - } + libc::FD_ZERO(set) } diff --git a/iceoryx2-pal/posix/src/libc/semaphore.rs b/iceoryx2-pal/posix/src/libc/semaphore.rs index c1f13398c..37ae909b8 100644 --- a/iceoryx2-pal/posix/src/libc/semaphore.rs +++ b/iceoryx2-pal/posix/src/libc/semaphore.rs @@ -16,41 +16,41 @@ use crate::posix::types::*; pub unsafe fn sem_create(name: *const c_char, oflag: int, mode: mode_t, value: uint) -> *mut sem_t { - crate::internal::sem_open(name, oflag, mode, value) + libc::sem_open(name, oflag, mode, value) } pub unsafe fn sem_post(sem: *mut sem_t) -> int { - crate::internal::sem_post(sem) + libc::sem_post(sem) } pub unsafe fn sem_wait(sem: *mut sem_t) -> int { - crate::internal::sem_wait(sem) + libc::sem_wait(sem) } pub unsafe fn sem_trywait(sem: *mut sem_t) -> int { - crate::internal::sem_trywait(sem) + libc::sem_trywait(sem) } pub unsafe fn sem_timedwait(sem: *mut sem_t, abs_timeout: *const timespec) -> int { - crate::internal::sem_timedwait(sem, abs_timeout) + libc::sem_timedwait(sem, abs_timeout) } pub unsafe fn sem_unlink(name: *const c_char) -> int { - crate::internal::sem_unlink(name) + libc::sem_unlink(name) } pub unsafe fn sem_open(name: *const c_char, oflag: int) -> *mut sem_t { - crate::internal::sem_open(name, oflag) + libc::sem_open(name, oflag) } pub unsafe fn sem_destroy(sem: *mut sem_t) -> int { - crate::internal::sem_destroy(sem) + libc::sem_destroy(sem) } pub unsafe fn sem_init(sem: *mut sem_t, pshared: int, value: uint) -> int { - crate::internal::sem_init(sem, pshared, value) + libc::sem_init(sem, pshared, value) } pub unsafe fn sem_close(sem: *mut sem_t) -> int { - crate::internal::sem_close(sem) + libc::sem_close(sem) } diff --git a/iceoryx2-pal/posix/src/libc/signal.rs b/iceoryx2-pal/posix/src/libc/signal.rs index 9ecec93ec..a92c25918 100644 --- a/iceoryx2-pal/posix/src/libc/signal.rs +++ b/iceoryx2-pal/posix/src/libc/signal.rs @@ -17,18 +17,13 @@ use crate::posix::{sighandler_t, Struct}; #[derive(Copy, Clone)] #[repr(transparent)] -pub struct sigaction_t(crate::internal::sigaction); +pub struct sigaction_t(libc::sigaction); impl Struct for sigaction_t {} impl sigaction_t { pub fn set_handler(&mut self, handler: sighandler_t) { - unsafe { - self.0.__sigaction_handler.sa_handler = core::mem::transmute::< - usize, - core::option::Option, - >(handler); - } + self.0.sa_sigaction = handler; } pub fn flags(&self) -> int { @@ -42,22 +37,28 @@ impl sigaction_t { impl core::fmt::Debug for sigaction_t { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let sa_handler = unsafe { + #[cfg(target_pointer_width = "32")] + type sa_mask_underlying = [u32; 32]; + #[cfg(target_pointer_width = "64")] + type sa_mask_underlying = [u64; 16]; + + let sa_mask = unsafe { #[allow(clippy::missing_transmute_annotations)] - core::mem::transmute::<_, usize>(self.0.__sigaction_handler) + core::mem::transmute::<_, sa_mask_underlying>(self.0.sa_mask) }; + f.debug_struct("sigaction_t") - .field("__sigaction_handler", &sa_handler) - .field("sa_mask", &self.0.sa_mask) + .field("sa_sigaction", &self.0.sa_sigaction) + .field("sa_mask", &sa_mask) .field("sa_flags", &self.0.sa_flags) .finish() } } pub unsafe fn sigaction(sig: int, act: &sigaction_t, oact: &mut sigaction_t) -> int { - crate::internal::sigaction(sig, &act.0, &mut oact.0) + libc::sigaction(sig, &act.0, &mut oact.0) } pub unsafe fn kill(pid: pid_t, sig: int) -> int { - crate::internal::kill(pid, sig) + libc::kill(pid, sig) } diff --git a/iceoryx2-pal/posix/src/libc/socket.rs b/iceoryx2-pal/posix/src/libc/socket.rs index b5d79813e..c3b52116d 100644 --- a/iceoryx2-pal/posix/src/libc/socket.rs +++ b/iceoryx2-pal/posix/src/libc/socket.rs @@ -21,7 +21,7 @@ pub unsafe fn socketpair( protocol: int, socket_vector: *mut int, // actually it shall be [int; 2] ) -> int { - crate::internal::socketpair(domain, socket_type, protocol, socket_vector) + libc::socketpair(domain, socket_type, protocol, socket_vector) } pub unsafe fn setsockopt( @@ -31,11 +31,11 @@ pub unsafe fn setsockopt( option_value: *const void, option_len: socklen_t, ) -> int { - crate::internal::setsockopt(socket, level, option_name, option_value, option_len) + libc::setsockopt(socket, level, option_name, option_value, option_len) } pub unsafe fn getsockname(socket: int, address: *mut sockaddr, address_len: *mut socklen_t) -> int { - crate::internal::getsockname(socket, address, address_len) + libc::getsockname(socket, address, address_len) } pub unsafe fn getsockopt( @@ -45,23 +45,23 @@ pub unsafe fn getsockopt( option_value: *mut void, option_len: *mut socklen_t, ) -> int { - crate::internal::getsockopt(socket, level, option_name, option_value, option_len) + libc::getsockopt(socket, level, option_name, option_value, option_len) } pub unsafe fn bind(socket: int, address: *const sockaddr, address_len: socklen_t) -> int { - crate::internal::bind(socket, address, address_len) + libc::bind(socket, address, address_len) } pub unsafe fn connect(socket: int, address: *const sockaddr, address_len: socklen_t) -> int { - crate::internal::connect(socket, address, address_len) + libc::connect(socket, address, address_len) } pub unsafe fn socket(domain: int, socket_type: int, protocol: int) -> int { - crate::internal::socket(domain, socket_type, protocol) + libc::socket(domain, socket_type, protocol) } pub unsafe fn sendmsg(socket: int, message: *const msghdr, flags: int) -> ssize_t { - crate::internal::sendmsg(socket, message, flags) + libc::sendmsg(socket, message, flags) } pub unsafe fn sendto( @@ -72,15 +72,15 @@ pub unsafe fn sendto( dest_addr: *const sockaddr, dest_len: socklen_t, ) -> ssize_t { - crate::internal::sendto(socket, message, length, flags, dest_addr, dest_len) + libc::sendto(socket, message, length, flags, dest_addr, dest_len) } pub unsafe fn send(socket: int, message: *const void, length: size_t, flags: int) -> ssize_t { - crate::internal::send(socket, message, length, flags) + libc::send(socket, message, length, flags) } pub unsafe fn recvmsg(socket: int, message: *mut msghdr, flags: int) -> ssize_t { - crate::internal::recvmsg(socket, message, flags) + libc::recvmsg(socket, message, flags) } pub unsafe fn recvfrom( @@ -91,9 +91,9 @@ pub unsafe fn recvfrom( address: *mut sockaddr, address_len: *mut socklen_t, ) -> ssize_t { - crate::internal::recvfrom(socket, buffer, length, flags, address, address_len) + libc::recvfrom(socket, buffer, length, flags, address, address_len) } pub unsafe fn recv(socket: int, buffer: *mut void, length: size_t, flags: int) -> ssize_t { - crate::internal::recv(socket, buffer, length, flags) + libc::recv(socket, buffer, length, flags) } diff --git a/iceoryx2-pal/posix/src/libc/stat.rs b/iceoryx2-pal/posix/src/libc/stat.rs index 0adcf7415..cddacbb86 100644 --- a/iceoryx2-pal/posix/src/libc/stat.rs +++ b/iceoryx2-pal/posix/src/libc/stat.rs @@ -17,8 +17,8 @@ use crate::posix::types::*; use crate::posix::Struct; pub unsafe fn stat(path: *const c_char, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); - match crate::internal::stat(path, &mut os_specific_buffer) { + let mut os_specific_buffer = native_stat_t::new(); + match libc::stat(path, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); 0 @@ -28,5 +28,5 @@ pub unsafe fn stat(path: *const c_char, buf: *mut stat_t) -> int { } pub unsafe fn umask(mask: mode_t) -> mode_t { - crate::internal::umask(mask) + libc::umask(mask) } diff --git a/iceoryx2-pal/posix/src/libc/stdio.rs b/iceoryx2-pal/posix/src/libc/stdio.rs index e5f9ac36c..162ce2770 100644 --- a/iceoryx2-pal/posix/src/libc/stdio.rs +++ b/iceoryx2-pal/posix/src/libc/stdio.rs @@ -16,5 +16,5 @@ use crate::posix::types::*; pub unsafe fn remove(pathname: *const c_char) -> int { - crate::internal::remove(pathname) + libc::remove(pathname) } diff --git a/iceoryx2-pal/posix/src/libc/stdlib.rs b/iceoryx2-pal/posix/src/libc/stdlib.rs index 273c1ccdd..872a894b5 100644 --- a/iceoryx2-pal/posix/src/libc/stdlib.rs +++ b/iceoryx2-pal/posix/src/libc/stdlib.rs @@ -16,17 +16,17 @@ use crate::posix::types::*; pub unsafe fn malloc(size: size_t) -> *mut void { - crate::internal::malloc(size as _) + libc::malloc(size as _) } pub unsafe fn calloc(nmemb: size_t, size: size_t) -> *mut void { - crate::internal::calloc(nmemb as _, size as _) + libc::calloc(nmemb as _, size as _) } pub unsafe fn realloc(ptr: *mut void, size: size_t) -> *mut void { - crate::internal::realloc(ptr, size as _) + libc::realloc(ptr, size as _) } pub unsafe fn free(ptr: *mut void) { - crate::internal::free(ptr) + libc::free(ptr) } diff --git a/iceoryx2-pal/posix/src/libc/string.rs b/iceoryx2-pal/posix/src/libc/string.rs index 4dc235bea..dd62fccbe 100644 --- a/iceoryx2-pal/posix/src/libc/string.rs +++ b/iceoryx2-pal/posix/src/libc/string.rs @@ -16,13 +16,13 @@ use crate::posix::types::*; pub unsafe fn memset(s: *mut void, c: int, n: size_t) -> *mut void { - crate::internal::memset(s, c, n as _) + libc::memset(s, c, n as _) } pub unsafe fn memcpy(dest: *mut void, src: *const void, n: size_t) -> *mut void { - crate::internal::memcpy(dest, src, n as _) + libc::memcpy(dest, src, n as _) } pub unsafe fn strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char { - crate::internal::strncpy(dest, src, n as _) + libc::strncpy(dest, src, n as _) } diff --git a/iceoryx2-pal/posix/src/libc/time.rs b/iceoryx2-pal/posix/src/libc/time.rs index 0efc1267b..907ddbccc 100644 --- a/iceoryx2-pal/posix/src/libc/time.rs +++ b/iceoryx2-pal/posix/src/libc/time.rs @@ -16,11 +16,11 @@ use crate::posix::types::*; pub unsafe fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> int { - crate::internal::clock_gettime(clock_id, tp) + libc::clock_gettime(clock_id, tp) } pub unsafe fn clock_settime(clock_id: clockid_t, tp: *const timespec) -> int { - crate::internal::clock_settime(clock_id, tp) + libc::clock_settime(clock_id, tp) } pub unsafe fn clock_nanosleep( @@ -29,5 +29,5 @@ pub unsafe fn clock_nanosleep( rqtp: *const timespec, rmtp: *mut timespec, ) -> int { - crate::internal::clock_nanosleep(clock_id, flags, rqtp, rmtp) + libc::clock_nanosleep(clock_id, flags, rqtp, rmtp) } diff --git a/iceoryx2-pal/posix/src/libc/types.rs b/iceoryx2-pal/posix/src/libc/types.rs index c63e19641..05bb83dc6 100644 --- a/iceoryx2-pal/posix/src/libc/types.rs +++ b/iceoryx2-pal/posix/src/libc/types.rs @@ -15,7 +15,7 @@ use crate::posix::{SockAddrIn, Struct}; -pub type ulong = crate::internal::ulong; +pub type ulong = libc::c_ulong; #[repr(C)] pub struct ucred { @@ -26,78 +26,84 @@ pub struct ucred { impl Struct for ucred {} -pub type DIR = crate::internal::DIR; +pub type DIR = libc::DIR; -pub type blkcnt_t = crate::internal::blkcnt_t; -pub type blksize_t = crate::internal::blksize_t; +pub type blkcnt_t = libc::blkcnt_t; +pub type blksize_t = libc::blksize_t; pub type c_char = core::ffi::c_char; -pub type clockid_t = crate::internal::clockid_t; -pub type dev_t = crate::internal::dev_t; -pub type gid_t = crate::internal::gid_t; -pub type ino_t = crate::internal::ino_t; +pub type clockid_t = libc::clockid_t; +pub type dev_t = libc::dev_t; +pub type gid_t = libc::gid_t; +pub type ino_t = libc::ino_t; pub type int = core::ffi::c_int; pub type in_port_t = u16; pub type in_addr_t = u32; pub type long = core::ffi::c_long; -pub type mode_t = crate::internal::mode_t; -pub type nlink_t = crate::internal::nlink_t; -pub type off_t = crate::internal::off_t; -pub type pid_t = crate::internal::pid_t; -pub type rlim_t = crate::internal::rlim_t; -pub type __rlim_t = crate::internal::__rlim_t; -pub type sa_family_t = crate::internal::sa_family_t; +pub type mode_t = libc::mode_t; +pub type nlink_t = libc::nlink_t; +pub type off_t = libc::off_t; +pub type pid_t = libc::pid_t; +pub type rlim_t = libc::rlim_t; +pub type __rlim_t = libc::rlim_t; +pub type sa_family_t = libc::sa_family_t; pub type short = core::ffi::c_short; pub type sighandler_t = size_t; pub type size_t = usize; -pub type socklen_t = crate::internal::socklen_t; +pub type socklen_t = libc::socklen_t; pub type ssize_t = isize; -pub type suseconds_t = crate::internal::suseconds_t; -pub type time_t = crate::internal::time_t; +pub type suseconds_t = libc::suseconds_t; +pub type time_t = libc::time_t; pub type uchar = core::ffi::c_uchar; -pub type uid_t = crate::internal::uid_t; -pub type uint = crate::internal::uint; -pub type ushort = crate::internal::ushort; +pub type uid_t = libc::uid_t; +pub type uint = libc::c_uint; +pub type ushort = libc::c_ushort; pub type void = core::ffi::c_void; -pub type sigset_t = crate::internal::sigset_t; +pub(crate) type native_cpu_set_t = libc::cpu_set_t; +impl Struct for native_cpu_set_t {} + +pub type sigset_t = libc::sigset_t; impl Struct for sigset_t {} -pub type pthread_barrier_t = crate::internal::pthread_barrier_t; +pub type pthread_barrier_t = libc::pthread_barrier_t; impl Struct for pthread_barrier_t {} -pub type pthread_barrierattr_t = crate::internal::pthread_barrierattr_t; +pub type pthread_barrierattr_t = libc::pthread_barrierattr_t; impl Struct for pthread_barrierattr_t {} -pub type pthread_attr_t = crate::internal::pthread_attr_t; +pub type pthread_attr_t = libc::pthread_attr_t; impl Struct for pthread_attr_t {} -pub type pthread_t = crate::internal::pthread_t; +pub type pthread_t = libc::pthread_t; impl Struct for pthread_t {} -pub type pthread_rwlockattr_t = crate::internal::pthread_rwlockattr_t; +pub type pthread_rwlockattr_t = libc::pthread_rwlockattr_t; impl Struct for pthread_rwlockattr_t {} -pub type pthread_rwlock_t = crate::internal::pthread_rwlock_t; +pub type pthread_rwlock_t = libc::pthread_rwlock_t; impl Struct for pthread_rwlock_t {} -pub type pthread_mutex_t = crate::internal::pthread_mutex_t; +pub type pthread_mutex_t = libc::pthread_mutex_t; impl Struct for pthread_mutex_t {} -pub type pthread_mutexattr_t = crate::internal::pthread_mutexattr_t; +pub type pthread_mutexattr_t = libc::pthread_mutexattr_t; impl Struct for pthread_mutexattr_t {} -pub type sem_t = crate::internal::sem_t; +pub type sem_t = libc::sem_t; impl Struct for sem_t {} -pub type flock = crate::internal::flock; +pub type flock = libc::flock; impl Struct for flock {} -pub type rlimit = crate::internal::rlimit; +pub type rlimit = libc::rlimit; impl Struct for rlimit {} -pub type sched_param = crate::internal::sched_param; +pub type sched_param = libc::sched_param; impl Struct for sched_param {} +pub(crate) type native_stat_t = libc::stat; +impl Struct for native_stat_t {} + #[repr(C)] pub struct stat_t { pub st_dev: dev_t, @@ -114,8 +120,8 @@ pub struct stat_t { pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, } -impl From for stat_t { - fn from(value: crate::internal::stat) -> Self { +impl From for stat_t { + fn from(value: native_stat_t) -> Self { stat_t { st_dev: value.st_dev, st_ino: value.st_ino, @@ -125,45 +131,44 @@ impl From for stat_t { st_gid: value.st_gid, st_rdev: value.st_rdev, st_size: value.st_size, - st_atime: value.st_atim.tv_sec, - st_mtime: value.st_mtim.tv_sec, - st_ctime: value.st_ctim.tv_sec, + st_atime: value.st_atime, + st_mtime: value.st_mtime, + st_ctime: value.st_ctime, st_blksize: value.st_blksize, st_blocks: value.st_blocks, } } } impl Struct for stat_t {} -impl Struct for crate::internal::stat {} -pub type timespec = crate::internal::timespec; +pub type timespec = libc::timespec; impl Struct for timespec {} -pub type timeval = crate::internal::timeval; +pub type timeval = libc::timeval; impl Struct for timeval {} -pub type fd_set = crate::internal::fd_set; +pub type fd_set = libc::fd_set; impl Struct for fd_set {} -pub type dirent = crate::internal::dirent; +pub type dirent = libc::dirent; impl Struct for dirent {} -pub type msghdr = crate::internal::msghdr; +pub type msghdr = libc::msghdr; impl Struct for msghdr {} -pub type cmsghdr = crate::internal::cmsghdr; +pub type cmsghdr = libc::cmsghdr; impl Struct for cmsghdr {} -pub type iovec = crate::internal::iovec; +pub type iovec = libc::iovec; impl Struct for iovec {} -pub type sockaddr = crate::internal::sockaddr; +pub type sockaddr = libc::sockaddr; impl Struct for sockaddr {} -pub type sockaddr_un = crate::internal::sockaddr_un; +pub type sockaddr_un = libc::sockaddr_un; impl Struct for sockaddr_un {} -pub type sockaddr_in = crate::internal::sockaddr_in; +pub type sockaddr_in = libc::sockaddr_in; impl Struct for sockaddr_in {} impl SockAddrIn for sockaddr_in { @@ -176,8 +181,8 @@ impl SockAddrIn for sockaddr_in { } } -pub type passwd = crate::internal::passwd; +pub type passwd = libc::passwd; impl Struct for passwd {} -pub type group = crate::internal::group; +pub type group = libc::group; impl Struct for group {} diff --git a/iceoryx2-pal/posix/src/libc/unistd.rs b/iceoryx2-pal/posix/src/libc/unistd.rs index 22d124bda..99fa8cfec 100644 --- a/iceoryx2-pal/posix/src/libc/unistd.rs +++ b/iceoryx2-pal/posix/src/libc/unistd.rs @@ -16,78 +16,78 @@ use crate::posix::types::*; pub unsafe fn proc_pidpath(pid: pid_t, buffer: *mut c_char, buffer_len: size_t) -> isize { - let path = if pid == crate::internal::getpid() { + let path = if pid == libc::getpid() { "/proc/self/exe\0".to_owned() } else { "/proc/".to_owned() + &pid.to_string() + "/exe\0" }; - crate::internal::readlink(path.as_bytes().as_ptr().cast(), buffer.cast(), buffer_len) + libc::readlink(path.as_bytes().as_ptr().cast(), buffer.cast(), buffer_len) } pub unsafe fn sysconf(name: int) -> long { - crate::internal::sysconf(name) + libc::sysconf(name) } pub unsafe fn pathconf(path: *const c_char, name: int) -> long { - crate::internal::pathconf(path, name) + libc::pathconf(path, name) } pub unsafe fn getpid() -> pid_t { - crate::internal::getpid() + libc::getpid() } pub unsafe fn getppid() -> pid_t { - crate::internal::getppid() + libc::getppid() } pub unsafe fn dup(fildes: int) -> int { - crate::internal::dup(fildes) + libc::dup(fildes) } pub unsafe fn close(fd: int) -> int { - crate::internal::close(fd) + libc::close(fd) } pub unsafe fn read(fd: int, buf: *mut void, count: size_t) -> ssize_t { - crate::internal::read(fd, buf, count) + libc::read(fd, buf, count) } pub unsafe fn write(fd: int, buf: *const void, count: size_t) -> ssize_t { - crate::internal::write(fd, buf, count) + libc::write(fd, buf, count) } pub unsafe fn access(pathname: *const c_char, mode: int) -> int { - crate::internal::access(pathname, mode) + libc::access(pathname, mode) } pub unsafe fn unlink(pathname: *const c_char) -> int { - crate::internal::unlink(pathname) + libc::unlink(pathname) } pub unsafe fn lseek(fd: int, offset: off_t, whence: int) -> off_t { - crate::internal::lseek(fd, offset, whence) + libc::lseek(fd, offset, whence) } pub unsafe fn getuid() -> uid_t { - crate::internal::getuid() + libc::getuid() } pub unsafe fn getgid() -> gid_t { - crate::internal::getgid() + libc::getgid() } pub unsafe fn rmdir(pathname: *const c_char) -> int { - crate::internal::rmdir(pathname) + libc::rmdir(pathname) } pub unsafe fn ftruncate(fd: int, length: off_t) -> int { - crate::internal::ftruncate(fd, length) + libc::ftruncate(fd, length) } pub unsafe fn fchown(fd: int, owner: uid_t, group: gid_t) -> int { - crate::internal::fchown(fd, owner, group) + libc::fchown(fd, owner, group) } pub unsafe fn fsync(fd: int) -> int { - crate::internal::fsync(fd) + libc::fsync(fd) } diff --git a/iceoryx2-pal/posix/src/linux/constants.rs b/iceoryx2-pal/posix/src/linux/constants.rs index 26f8a9d98..5462c9179 100644 --- a/iceoryx2-pal/posix/src/linux/constants.rs +++ b/iceoryx2-pal/posix/src/linux/constants.rs @@ -59,11 +59,6 @@ pub const SO_PASSCRED: int = crate::internal::SO_PASSCRED as _; pub const SO_PEERCRED: int = crate::internal::SO_PEERCRED as _; pub const SCM_CREDENTIALS: int = 0x02; -pub const PTHREAD_PREFER_READER_NP: int = crate::internal::PTHREAD_RWLOCK_PREFER_READER_NP as _; -pub const PTHREAD_PREFER_WRITER_NP: int = crate::internal::PTHREAD_RWLOCK_PREFER_WRITER_NP as _; -pub const PTHREAD_PREFER_WRITER_NONRECURSIVE_NP: int = - crate::internal::PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP as _; - pub const PTHREAD_MUTEX_NORMAL: int = crate::internal::PTHREAD_MUTEX_NORMAL as _; pub const PTHREAD_MUTEX_RECURSIVE: int = crate::internal::PTHREAD_MUTEX_RECURSIVE as _; pub const PTHREAD_MUTEX_ERRORCHECK: int = crate::internal::PTHREAD_MUTEX_ERRORCHECK as _; @@ -104,8 +99,6 @@ pub const PTHREAD_PROCESS_SHARED: int = crate::internal::PTHREAD_PROCESS_SHARED pub const PTHREAD_PRIO_NONE: int = crate::internal::PTHREAD_PRIO_NONE as _; pub const PTHREAD_PRIO_INHERIT: int = crate::internal::PTHREAD_PRIO_INHERIT as _; pub const PTHREAD_PRIO_PROTECT: int = crate::internal::PTHREAD_PRIO_PROTECT as _; -pub const PTHREAD_SCOPE_SYSTEM: int = crate::internal::PTHREAD_SCOPE_SYSTEM as _; -pub const PTHREAD_SCOPE_PROCESS: int = crate::internal::PTHREAD_SCOPE_PROCESS as _; pub const RLIMIT_CPU: __rlim_t = 0; pub const RLIMIT_FSIZE: __rlim_t = 1; diff --git a/iceoryx2-pal/posix/src/linux/fcntl.rs b/iceoryx2-pal/posix/src/linux/fcntl.rs index 9e8cdc298..e79a9d202 100644 --- a/iceoryx2-pal/posix/src/linux/fcntl.rs +++ b/iceoryx2-pal/posix/src/linux/fcntl.rs @@ -21,7 +21,7 @@ pub unsafe fn open_with_mode(pathname: *const c_char, flags: int, mode: mode_t) } pub unsafe fn fstat(fd: int, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); + let mut os_specific_buffer = native_stat_t::new(); match crate::internal::fstat(fd, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); diff --git a/iceoryx2-pal/posix/src/linux/pthread.rs b/iceoryx2-pal/posix/src/linux/pthread.rs index 44b9ac6a0..7292639f7 100644 --- a/iceoryx2-pal/posix/src/linux/pthread.rs +++ b/iceoryx2-pal/posix/src/linux/pthread.rs @@ -86,7 +86,9 @@ pub unsafe fn pthread_attr_setaffinity_np( cpusetsize: size_t, cpuset: *const cpu_set_t, ) -> int { - internal::pthread_attr_setaffinity_np(attr, cpusetsize, cpuset) + let cpuset = core::mem::transmute::(*cpuset); + + internal::pthread_attr_setaffinity_np(attr, cpusetsize, &cpuset) } pub unsafe fn pthread_create( @@ -123,7 +125,9 @@ pub unsafe fn pthread_setaffinity_np( cpusetsize: size_t, cpuset: *const cpu_set_t, ) -> int { - internal::pthread_setaffinity_np(thread, cpusetsize, cpuset) + let cpuset = core::mem::transmute::(*cpuset); + + internal::pthread_setaffinity_np(thread, cpusetsize, &cpuset) } pub unsafe fn pthread_getaffinity_np( @@ -131,7 +135,13 @@ pub unsafe fn pthread_getaffinity_np( cpusetsize: size_t, cpuset: *mut cpu_set_t, ) -> int { - internal::pthread_getaffinity_np(thread, cpusetsize, cpuset) + let mut native_cpuset = native_cpu_set_t::new(); + + let ret_val = internal::pthread_getaffinity_np(thread, cpusetsize, &mut native_cpuset); + + *cpuset = core::mem::transmute::(native_cpuset); + + ret_val } pub unsafe fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> int { @@ -243,7 +253,7 @@ mod internal { pub(super) fn pthread_attr_setaffinity_np( attr: *mut pthread_attr_t, cpusetsize: size_t, - cpuset: *const cpu_set_t, + cpuset: *const native_cpu_set_t, ) -> int; pub(super) fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> int; @@ -252,12 +262,12 @@ mod internal { pub(super) fn pthread_setaffinity_np( thread: pthread_t, cpusetsize: size_t, - cpuset: *const cpu_set_t, + cpuset: *const native_cpu_set_t, ) -> int; pub(super) fn pthread_getaffinity_np( thread: pthread_t, cpusetsize: size_t, - cpuset: *mut cpu_set_t, + cpuset: *mut native_cpu_set_t, ) -> int; } } diff --git a/iceoryx2-pal/posix/src/linux/stat.rs b/iceoryx2-pal/posix/src/linux/stat.rs index 0adcf7415..20e9e3804 100644 --- a/iceoryx2-pal/posix/src/linux/stat.rs +++ b/iceoryx2-pal/posix/src/linux/stat.rs @@ -17,7 +17,7 @@ use crate::posix::types::*; use crate::posix::Struct; pub unsafe fn stat(path: *const c_char, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); + let mut os_specific_buffer = native_stat_t::new(); match crate::internal::stat(path, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); diff --git a/iceoryx2-pal/posix/src/linux/types.rs b/iceoryx2-pal/posix/src/linux/types.rs index c63e19641..898afe772 100644 --- a/iceoryx2-pal/posix/src/linux/types.rs +++ b/iceoryx2-pal/posix/src/linux/types.rs @@ -59,6 +59,9 @@ pub type uint = crate::internal::uint; pub type ushort = crate::internal::ushort; pub type void = core::ffi::c_void; +pub(crate) type native_cpu_set_t = crate::internal::cpu_set_t; +impl Struct for native_cpu_set_t {} + pub type sigset_t = crate::internal::sigset_t; impl Struct for sigset_t {} @@ -98,6 +101,9 @@ impl Struct for rlimit {} pub type sched_param = crate::internal::sched_param; impl Struct for sched_param {} +pub(crate) type native_stat_t = crate::internal::stat; +impl Struct for native_stat_t {} + #[repr(C)] pub struct stat_t { pub st_dev: dev_t, @@ -114,8 +120,8 @@ pub struct stat_t { pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, } -impl From for stat_t { - fn from(value: crate::internal::stat) -> Self { +impl From for stat_t { + fn from(value: native_stat_t) -> Self { stat_t { st_dev: value.st_dev, st_ino: value.st_ino, @@ -134,7 +140,6 @@ impl From for stat_t { } } impl Struct for stat_t {} -impl Struct for crate::internal::stat {} pub type timespec = crate::internal::timespec; impl Struct for timespec {} diff --git a/iceoryx2-pal/posix/src/macos/constants.rs b/iceoryx2-pal/posix/src/macos/constants.rs index d61a4a1f4..116e1c6ea 100644 --- a/iceoryx2-pal/posix/src/macos/constants.rs +++ b/iceoryx2-pal/posix/src/macos/constants.rs @@ -103,8 +103,6 @@ pub const PTHREAD_PROCESS_SHARED: int = crate::internal::PTHREAD_PROCESS_SHARED pub const PTHREAD_PRIO_NONE: int = crate::internal::PTHREAD_PRIO_NONE as _; pub const PTHREAD_PRIO_INHERIT: int = crate::internal::PTHREAD_PRIO_INHERIT as _; pub const PTHREAD_PRIO_PROTECT: int = crate::internal::PTHREAD_PRIO_PROTECT as _; -pub const PTHREAD_SCOPE_SYSTEM: int = crate::internal::PTHREAD_SCOPE_SYSTEM as _; -pub const PTHREAD_SCOPE_PROCESS: int = crate::internal::PTHREAD_SCOPE_PROCESS as _; pub const RLIMIT_CPU: __rlim_t = 0; pub const RLIMIT_FSIZE: __rlim_t = 1; diff --git a/iceoryx2-pal/posix/src/macos/fcntl.rs b/iceoryx2-pal/posix/src/macos/fcntl.rs index 23391d564..0ed029244 100644 --- a/iceoryx2-pal/posix/src/macos/fcntl.rs +++ b/iceoryx2-pal/posix/src/macos/fcntl.rs @@ -23,7 +23,7 @@ pub unsafe fn open_with_mode(pathname: *const c_char, flags: int, mode: mode_t) } pub unsafe fn fstat(fd: int, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); + let mut os_specific_buffer = native_stat_t::new(); match crate::internal::fstat(fd, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); diff --git a/iceoryx2-pal/posix/src/macos/stat.rs b/iceoryx2-pal/posix/src/macos/stat.rs index 0adcf7415..20e9e3804 100644 --- a/iceoryx2-pal/posix/src/macos/stat.rs +++ b/iceoryx2-pal/posix/src/macos/stat.rs @@ -17,7 +17,7 @@ use crate::posix::types::*; use crate::posix::Struct; pub unsafe fn stat(path: *const c_char, buf: *mut stat_t) -> int { - let mut os_specific_buffer = crate::internal::stat::new(); + let mut os_specific_buffer = native_stat_t::new(); match crate::internal::stat(path, &mut os_specific_buffer) { 0 => { *buf = os_specific_buffer.into(); diff --git a/iceoryx2-pal/posix/src/macos/types.rs b/iceoryx2-pal/posix/src/macos/types.rs index 9bd77a87a..273bbab6b 100644 --- a/iceoryx2-pal/posix/src/macos/types.rs +++ b/iceoryx2-pal/posix/src/macos/types.rs @@ -177,6 +177,9 @@ impl Struct for rlimit {} pub type sched_param = crate::internal::sched_param; impl Struct for sched_param {} +pub(crate) type native_stat_t = crate::internal::stat; +impl Struct for native_stat_t {} + #[repr(C)] pub struct stat_t { pub st_dev: dev_t, @@ -193,8 +196,8 @@ pub struct stat_t { pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, } -impl From for stat_t { - fn from(value: crate::internal::stat) -> Self { +impl From for stat_t { + fn from(value: native_stat_t) -> Self { stat_t { st_dev: value.st_dev, st_ino: value.st_ino, @@ -213,7 +216,6 @@ impl From for stat_t { } } impl Struct for stat_t {} -impl Struct for crate::internal::stat {} pub type timespec = crate::internal::timespec; impl Struct for timespec {} diff --git a/iceoryx2-pal/posix/src/windows/constants.rs b/iceoryx2-pal/posix/src/windows/constants.rs index 6dc65717c..6a950b1f5 100644 --- a/iceoryx2-pal/posix/src/windows/constants.rs +++ b/iceoryx2-pal/posix/src/windows/constants.rs @@ -60,11 +60,11 @@ pub const PTHREAD_PROCESS_SHARED: int = 64; pub const PTHREAD_PRIO_NONE: int = 128; pub const PTHREAD_PRIO_INHERIT: int = 256; pub const PTHREAD_PRIO_PROTECT: int = 512; -pub const PTHREAD_SCOPE_SYSTEM: int = 1024; -pub const PTHREAD_SCOPE_PROCESS: int = 2048; + pub const PTHREAD_PREFER_READER_NP: int = 4096; pub const PTHREAD_PREFER_WRITER_NP: int = 8192; pub const PTHREAD_PREFER_WRITER_NONRECURSIVE_NP: int = 16384; + pub const PTHREAD_BARRIER_SERIAL_THREAD: int = 32768; pub const PTHREAD_EXPLICIT_SCHED: int = 65536; pub const PTHREAD_INHERIT_SCHED: int = 131072; diff --git a/iceoryx2-pal/posix/src/windows/types.rs b/iceoryx2-pal/posix/src/windows/types.rs index afbe23a2c..22c79742c 100644 --- a/iceoryx2-pal/posix/src/windows/types.rs +++ b/iceoryx2-pal/posix/src/windows/types.rs @@ -213,13 +213,7 @@ pub struct stat_t { pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, } -impl From for stat_t { - fn from(value: crate::internal::stat) -> Self { - stat_t::new() - } -} impl Struct for stat_t {} -impl Struct for crate::internal::stat {} pub type timespec = crate::internal::timespec; impl Struct for timespec {} diff --git a/iceoryx2/Cargo.toml b/iceoryx2/Cargo.toml index 128f48590..cca64fcbc 100644 --- a/iceoryx2/Cargo.toml +++ b/iceoryx2/Cargo.toml @@ -20,6 +20,12 @@ logger_tracing = ["iceoryx2-bb-log/logger_tracing"] # This shall not be used in production and is meant to be enabled in a docker environment # with inconsistent user configuration. dev_permissions = ["iceoryx2-cal/dev_permissions"] +# Use https://crates.io/crates/libc for the platform abstraction. This simplifies +# cross-compilation since bindgen is not required anymore. Unfortunately, the libc crate +# does not offer all the functionality iceoryx2 requires on all of the supported +# platforms. Therefore, only a subset of the supported platforms will work with this +# feature flag. +libc_platform = ["iceoryx2-bb-posix/libc_platform"] [dependencies] iceoryx2-bb-container = { workspace = true }