diff --git a/.cirrus.yml b/.cirrus.yml index 656696c825752..7985cb854bbe3 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,19 +3,22 @@ task: env: HOME: /tmp # cargo cache needs it TARGET: x86_64-unknown-freebsd + # FIXME(freebsd): FreeBSD has a segfault when `RUST_BACKTRACE` is set + # https://github.com/rust-lang/rust/issues/132185 + RUST_BACKTRACE: "0" matrix: - name: nightly freebsd-13 i686 # Test i686 FreeBSD in 32-bit emulation on a 64-bit host. env: TARGET: i686-unknown-freebsd freebsd_instance: - image_family: freebsd-13-3 + image_family: freebsd-13-4 - name: nightly freebsd-13 x86_64 freebsd_instance: - image_family: freebsd-13-3 + image_family: freebsd-13-4 - name: nightly freebsd-14 x86_64 freebsd_instance: - image: freebsd-14-1-release-amd64-ufs + image: freebsd-14-2-release-amd64-ufs - name: nightly freebsd-15 x86_64 freebsd_instance: image_family: freebsd-15-0-snap diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d255ebff1cf69..964d72d1d4d99 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -136,7 +136,9 @@ jobs: - i686-unknown-linux-musl - loongarch64-unknown-linux-gnu - loongarch64-unknown-linux-musl - - powerpc-unknown-linux-gnu + # FIXME(ppc): SIGILL running tests, see + # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 + # - powerpc-unknown-linux-gnu - powerpc64-unknown-linux-gnu - powerpc64le-unknown-linux-gnu - riscv64gc-unknown-linux-gnu diff --git a/.gitignore b/.gitignore index bbbad4bc51532..f0ff2599d09b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ target Cargo.lock *~ -style diff --git a/CHANGELOG.md b/CHANGELOG.md index e1efe1f840044..4a41b3ffdef10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,43 @@ # Changelog ## [Unreleased] +## [0.2.170](https://github.com/rust-lang/libc/compare/0.2.169...0.2.170) - 2025-02-23 + +### Added + +- Android: Declare `setdomainname` and `getdomainname` +- FreeBSD: Add `evdev` structures +- FreeBSD: Add the new `st_filerev` field to `stat32` ([#4254](https://github.com/rust-lang/libc/pull/4254)) +- Linux: Add `SI_*`` and `TRAP_*`` signal codes +- Linux: Add experimental configuration to enable 64-bit time in kernel APIs, set by `RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64`. +- Linux: Add recent socket timestamping flags +- Linux: Added new CANFD_FDF flag for the flags field of canfd_frame +- Musl: add CLONE_NEWTIME +- Solarish: add the posix_spawn family of functions + +### Deprecated + +- Linux: deprecate kernel modules syscalls + +### Changed + +- Emscripten: Assume version is at least 3.1.42 + +### Fixed + +- BSD: Correct the definition of `WEXITSTATUS` +- Hurd: Fix CMSG_DATA on 64bit systems ([#4240](https://github.com/rust-lang/libc/pull/424)) +- NetBSD: fix `getmntinfo` ([#4265](https://github.com/rust-lang/libc/pull/4265) +- VxWorks: Fix the size of `time_t` + +### Other + +- Add labels to FIXMEs , , +- CI: Bump FreeBSD CI to 13.4 and 14.2 +- Copy definitions from core::ffi and centralize them +- Define c_char at top-level and remove per-target c_char definitions +- Port style.rs to syn and add tests for the style checker + ## [0.2.169](https://github.com/rust-lang/libc/compare/0.2.168...0.2.169) - 2024-12-18 ### Added diff --git a/Cargo.toml b/Cargo.toml index aa6926ee5f0bd..e3b20745500dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.169" +version = "0.2.170" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/README.md b/README.md index 901a776e24f20..c616d8b29f52b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ but this is not guaranteed. You can see the platform(target)-specific docs on [docs.rs], select a platform you want to see. -See [`ci/build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/build.sh) for +See [`ci/verify-build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.sh) for the platforms on which `libc` is guaranteed to build for each Rust toolchain. The test-matrix at [GitHub Actions] and [Cirrus CI] show the platforms in which `libc` tests are run. diff --git a/build.rs b/build.rs index 90fbc0d7c5fda..3439208f7e2ce 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,7 @@ use std::{env, str}; // need to know all the possible cfgs that this script will set. If you need to set another cfg // make sure to add it to this list as well. const ALLOWED_CFGS: &'static [&'static str] = &[ - "emscripten_new_stat_abi", + "emscripten_old_stat_abi", "espidf_time32", "freebsd10", "freebsd11", @@ -18,6 +18,8 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "libc_deny_warnings", "libc_thread_local", "libc_ctest", + // Corresponds to `__USE_TIME_BITS64` in UAPI + "linux_time_bits64", ]; // Extra values to allow for check-cfg. @@ -74,9 +76,15 @@ fn main() { } match emcc_version_code() { - Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"), - // Non-Emscripten or version < 3.1.42. - Some(_) | None => (), + Some(v) if (v < 30142) => set_cfg("emscripten_old_stat_abi"), + // Non-Emscripten or version >= 3.1.42. + _ => (), + } + + let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); + if linux_time_bits64 { + set_cfg("linux_time_bits64"); } // On CI: deny all warnings diff --git a/ci/emscripten.sh b/ci/emscripten.sh index 0a4112e7e205e..e2f41937ddfc0 100755 --- a/ci/emscripten.sh +++ b/ci/emscripten.sh @@ -3,7 +3,7 @@ set -eux # Note: keep in sync with: -# https://github.com/rust-lang/rust/blob/master/src/ci/docker/scripts/emscripten.sh +# https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-unknown-emscripten.md#requirements emsdk_version=3.1.68 git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable diff --git a/ci/run.sh b/ci/run.sh index 9754118f742b8..8889cda5a21e5 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -81,6 +81,7 @@ if [ -n "${QEMU:-}" ]; then fi cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}" +test_flags="--skip check_style" # Run tests in the `libc` crate case "$target" in @@ -101,17 +102,20 @@ if [ "$target" = "s390x-unknown-linux-gnu" ]; then passed=0 until [ $n -ge $N ]; do if [ "$passed" = "0" ]; then - if $cmd --no-default-features; then + # shellcheck disable=SC2086 + if $cmd --no-default-features -- $test_flags; then passed=$((passed+1)) continue fi elif [ "$passed" = "1" ]; then - if $cmd; then + # shellcheck disable=SC2086 + if $cmd -- $test_flags; then passed=$((passed+1)) continue fi elif [ "$passed" = "2" ]; then - if $cmd --features extra_traits; then + # shellcheck disable=SC2086 + if $cmd --features extra_traits -- $test_flags; then break fi fi @@ -119,7 +123,10 @@ if [ "$target" = "s390x-unknown-linux-gnu" ]; then sleep 1 done else - $cmd --no-default-features - $cmd - $cmd --features extra_traits + # shellcheck disable=SC2086 + $cmd --no-default-features -- $test_flags + # shellcheck disable=SC2086 + $cmd -- $test_flags + # shellcheck disable=SC2086 + $cmd --features extra_traits -- $test_flags fi diff --git a/ci/runtest-android.rs b/ci/runtest-android.rs index 92bce79b0d714..d422f9c2e8a7e 100644 --- a/ci/runtest-android.rs +++ b/ci/runtest-android.rs @@ -1,11 +1,11 @@ use std::env; -use std::process::Command; use std::path::{Path, PathBuf}; +use std::process::Command; fn main() { let args = env::args_os() .skip(1) - .filter(|arg| arg != "--quiet") + .filter(|arg| arg != "--quiet" && arg != "--skip" && arg != "check_style") .collect::>(); assert_eq!(args.len(), 1); let test = PathBuf::from(&args[0]); @@ -36,14 +36,16 @@ fn main() { let stdout = String::from_utf8_lossy(&output.stdout); let stderr = String::from_utf8_lossy(&output.stderr); - println!("status: {}\nstdout ---\n{}\nstderr ---\n{}", - output.status, - stdout, - stderr); + println!( + "status: {}\nstdout ---\n{}\nstderr ---\n{}", + output.status, stdout, stderr + ); - if !stderr.lines().any(|l| (l.starts_with("PASSED ") && l.contains(" tests")) || l.starts_with("test result: ok")) - && !stdout.lines().any(|l| (l.starts_with("PASSED ") && l.contains(" tests")) || l.starts_with("test result: ok")) - { + if !stderr.lines().any(|l| { + (l.starts_with("PASSED ") && l.contains(" tests")) || l.starts_with("test result: ok") + }) && !stdout.lines().any(|l| { + (l.starts_with("PASSED ") && l.contains(" tests")) || l.starts_with("test result: ok") + }) { panic!("failed to find successful test run"); }; } diff --git a/ci/style.rs b/ci/style.rs deleted file mode 100644 index cad08f2eecc88..0000000000000 --- a/ci/style.rs +++ /dev/null @@ -1,213 +0,0 @@ -//! Simple script to verify the coding style of this library -//! -//! ## How to run -//! -//! The first argument to this script is the directory to run on, so running -//! this script should be as simple as: -//! -//! ```notrust -//! rustc ci/style.rs -//! ./style src -//! ``` -//! -//! ## Guidelines -//! -//! The current style is: -//! -//! * Specific module layout: -//! 1. use directives -//! 2. typedefs -//! 3. structs -//! 4. constants -//! 5. f! { ... } functions -//! 6. extern functions -//! 7. modules + pub use -//! -//! Things not verified: -//! -//! * alignment -//! * leading colons on paths - -use std::io::prelude::*; -use std::path::Path; -use std::{env, fs}; - -macro_rules! t { - ($e:expr) => { - match $e { - Ok(e) => e, - Err(e) => panic!("{} failed with {}", stringify!($e), e), - } - }; -} - -fn main() { - let arg = env::args().skip(1).next().unwrap_or(".".to_string()); - - let mut errors = Errors { errs: false }; - walk(Path::new(&arg), &mut errors); - - if errors.errs { - panic!("found some lint errors"); - } else { - println!("good style!"); - } -} - -fn walk(path: &Path, err: &mut Errors) { - for entry in t!(path.read_dir()).map(|e| t!(e)) { - let path = entry.path(); - if t!(entry.file_type()).is_dir() { - walk(&path, err); - continue; - } - - let name = entry.file_name().into_string().unwrap(); - match &name[..] { - n if !n.ends_with(".rs") => continue, - - "lib.rs" | "macros.rs" => continue, - - _ => {} - } - - let mut contents = String::new(); - t!(t!(fs::File::open(&path)).read_to_string(&mut contents)); - - check_style(&contents, &path, err); - } -} - -struct Errors { - errs: bool, -} - -#[derive(Clone, Copy, PartialEq)] -enum State { - Start, - Imports, - Typedefs, - Structs, - Constants, - FunctionDefinitions, - Functions, - Modules, -} - -fn check_style(file: &str, path: &Path, err: &mut Errors) { - let mut state = State::Start; - - // FIXME: see below - // let mut s_macros = 0; - - let mut f_macros = 0; - let mut in_impl = false; - - for (i, line) in file.lines().enumerate() { - if line.contains("#[cfg(") - && line.contains(']') - && !line.contains(" if ") - && !(line.contains("target_endian") || line.contains("target_arch")) - { - if state != State::Structs { - err.error(path, i, "use cfg_if! and submodules instead of #[cfg]"); - } - } - if line.contains("#[derive(") && (line.contains("Copy") || line.contains("Clone")) { - err.error(path, i, "impl Copy and Clone manually"); - } - if line.contains("impl") { - in_impl = true; - } - if in_impl && line.starts_with('}') { - in_impl = false; - } - - let orig_line = line; - let line = line.trim_start(); - let is_pub = line.starts_with("pub "); - let line = if is_pub { &line[4..] } else { line }; - - let line_state = if line.starts_with("use ") { - if line.contains("c_void") || line.contains("c_char") { - continue; - } - if is_pub { - State::Modules - } else { - State::Imports - } - } else if line.starts_with("const ") { - State::Constants - } else if line.starts_with("type ") && !in_impl { - State::Typedefs - } else if line.starts_with("s! {") { - // FIXME: see below - // s_macros += 1; - State::Structs - } else if line.starts_with("s_no_extra_traits! {") { - // multiple macros of this type are allowed - State::Structs - } else if line.starts_with("s_paren! {") { - // multiple macros of this type are allowed - State::Structs - } else if line.starts_with("f! {") { - f_macros += 1; - State::FunctionDefinitions - } else if line.starts_with("extern ") && !orig_line.starts_with(" ") { - State::Functions - } else if line.starts_with("mod ") { - State::Modules - } else { - continue; - }; - - if state as usize > line_state as usize { - err.error( - path, - i, - &format!( - "{} found after {} when it belongs before", - line_state.desc(), - state.desc() - ), - ); - } - - if f_macros == 2 { - f_macros += 1; - err.error(path, i, "multiple f! macros in one module"); - } - - // FIXME(#4109): multiple should be allowed if at least one is `cfg(not) within `cfg_if`. - // For now just disable this and check by hand. - // if s_macros == 2 { - // s_macros += 1; - // err.error(path, i, "multiple s! macros in one module"); - // } - - state = line_state; - } -} - -impl State { - fn desc(&self) -> &str { - match *self { - State::Start => "start", - State::Imports => "import", - State::Typedefs => "typedef", - State::Structs => "struct", - State::Constants => "constant", - State::FunctionDefinitions => "function definition", - State::Functions => "extern function", - State::Modules => "module", - } - } -} - -impl Errors { - fn error(&mut self, path: &Path, line: usize, msg: &str) { - self.errs = true; - println!("{}:{}: {}", path.display(), line + 1, msg); - } -} diff --git a/ci/style.sh b/ci/style.sh index c758712012e16..da16bf4fe9baf 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -9,7 +9,7 @@ if [ -n "${CI:-}" ]; then check="--check" fi -rustc ci/style.rs && ./style src +cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture command -v rustfmt rustfmt -V diff --git a/ci/verify-build.sh b/ci/verify-build.sh index e61fc69188c59..ccdc223263641 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -72,6 +72,11 @@ test_target() { $cmd --features const-extern-fn $cmd --features extra_traits + if [ "$os" = "linux" ]; then + # Test with the equivalent of __USE_TIME_BITS64 + RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd + fi + # Test again without default features, i.e. without "std" $cmd --no-default-features $cmd --no-default-features --features extra_traits diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 007663f69c424..740b9ca18cac2 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -14,9 +14,15 @@ A test crate for the libc crate. [dependencies.libc] path = ".." -version = "0.2.169" +version = "0.2.170" default-features = false +[dev-dependencies] +syn = { version = "2.0.91", features = ["full", "visit"] } +proc-macro2 = { version = "1.0.92", features = ["span-locations"] } +glob = "0.3.2" +annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } + [build-dependencies] cc = "1.0.83" # FIXME: Use fork ctest until the maintainer gets back. @@ -88,3 +94,18 @@ harness = true name = "semver" path = "test/semver.rs" harness = false + +[[test]] +name = "primitive_types" +path = "test/primitive_types.rs" +harness = true + +[[test]] +name = "style" +path = "test/check_style.rs" +harness = true + +[[test]] +name = "style_tests" +path = "test/style_tests.rs" +harness = true diff --git a/libc-test/build.rs b/libc-test/build.rs index d35101d4cae39..7efacf7a41e63 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -268,7 +268,7 @@ fn test_apple(target: &str) { "os/clock.h", "os/lock.h", "os/signpost.h", - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. //"os/os_sync_wait_on_address.h", "poll.h", "pthread.h", @@ -338,15 +338,15 @@ fn test_apple(target: &str) { return true; } match ty { - // FIXME: actually a union + // FIXME(union): actually a union "sigval" => true, - // FIXME: The size is changed in recent macOSes. + // FIXME(macos): The size is changed in recent macOSes. "malloc_zone_t" => true, // it is a moving target, changing through versions // also contains bitfields members "tcp_connection_info" => true, - // FIXME: The size is changed in recent macOSes. + // FIXME(macos): The size is changed in recent macOSes. "malloc_introspection_t" => true, _ => false, @@ -358,15 +358,12 @@ fn test_apple(target: &str) { return true; } match ty { - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, - // FIXME: "'__uint128' undeclared" in C + // FIXME(macos): "'__uint128' undeclared" in C "__uint128" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, - _ => false, } }); @@ -380,13 +377,13 @@ fn test_apple(target: &str) { // These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, - // FIXME: the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). + // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). "SF_SETTABLE" => true, - // FIXME: XCode 13.1 doesn't have it. + // FIXME(macos): XCode 13.1 doesn't have it. "TIOCREMOTE" => true, - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. "OS_SYNC_WAKE_BY_ADDRESS_NONE" | "OS_SYNC_WAKE_BY_ADDRESS_SHARED" | "OS_SYNC_WAIT_ON_ADDRESS_NONE" @@ -405,19 +402,19 @@ fn test_apple(target: &str) { // close calls the close_nocancel system call "close" => true, - // FIXME: std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 + // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, - // FIXME: remove once the target in CI is updated + // FIXME(macos): remove once the target in CI is updated "pthread_jit_write_freeze_callbacks_np" => true, - // FIXME: ABI has been changed on recent macOSes. + // FIXME(macos): ABI has been changed on recent macOSes. "os_unfair_lock_assert_owner" | "os_unfair_lock_assert_not_owner" => true, - // FIXME: Once the SDK get updated to Ventura's level + // FIXME(macos): Once the SDK get updated to Ventura's level "freadlink" | "mknodat" | "mkfifoat" => true, - // FIXME: Requires the macOS 14.4 SDK. + // FIXME(macos): Requires the macOS 14.4 SDK. "os_sync_wake_by_address_any" | "os_sync_wake_by_address_all" | "os_sync_wake_by_address_flags_t" @@ -432,7 +429,7 @@ fn test_apple(target: &str) { cfg.skip_field(move |struct_, field| { match (struct_, field) { - // FIXME: the array size has been changed since macOS 10.15 ([8] -> [7]). + // FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]). ("statfs", "f_reserved") => true, ("__darwin_arm_neon_state64", "__v") => true, // MAXPATHLEN is too big for auto-derive traits on arrays. @@ -450,7 +447,7 @@ fn test_apple(target: &str) { cfg.skip_field_type(move |struct_, field| { match (struct_, field) { - // FIXME: actually a union + // FIXME(union): actually a union ("sigevent", "sigev_value") => true, _ => false, } @@ -484,7 +481,7 @@ fn test_apple(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", "espec.tv_nsec") } - // FIXME: sigaction actually contains a union with two variants: + // FIXME(macos): sigaction actually contains a union with two variants: // a sa_sigaction with type: (*)(int, struct __siginfo *, void *) // a sa_handler with type sig_t "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), @@ -493,7 +490,7 @@ fn test_apple(target: &str) { }); cfg.skip_roundtrip(move |s| match s { - // FIXME: this type has the wrong ABI + // FIXME(macos): this type has the wrong ABI "max_align_t" if i686 => true, // Can't return an array from a C function. "uuid_t" | "vol_capabilities_set_t" => true, @@ -600,7 +597,7 @@ fn test_openbsd(target: &str) { return true; } match ty { - // FIXME: actually a union + // FIXME(union): actually a union "sigval" => true, _ => false, @@ -647,11 +644,6 @@ fn test_openbsd(target: &str) { } }); - cfg.skip_type(move |ty| { - // `c_char_def` is always public but not always reexported. - ty == "c_char_def" - }); - cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix @@ -766,8 +758,6 @@ fn test_windows(target: &str) { "ssize_t" if !gnu => true, // FIXME: The size and alignment of this type are incorrect "time_t" if gnu && i686 => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, _ => false, }); @@ -925,6 +915,7 @@ fn test_solarish(target: &str) { "sched.h", "semaphore.h", "signal.h", + "spawn.h", "stddef.h", "stdint.h", "stdio.h", @@ -985,8 +976,6 @@ fn test_solarish(target: &str) { cfg.skip_type(move |ty| match ty { "sighandler_t" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, _ => false, }); @@ -1290,8 +1279,6 @@ fn test_netbsd(target: &str) { match ty { // FIXME: sighandler_t is crazy across platforms "sighandler_t" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, _ => false, } }); @@ -1511,8 +1498,6 @@ fn test_dragonflybsd(target: &str) { match ty { // sighandler_t is crazy across platforms "sighandler_t" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, _ => false, } }); @@ -1674,8 +1659,6 @@ fn test_wasi(target: &str) { } }); - cfg.skip_type(|ty| ty == "c_char_def"); - // These have a different and internal type in header files and are only // used here to generate a pointer to them in bindings so skip these tests. cfg.skip_static(|c| c.starts_with("_CLOCK_")); @@ -1924,9 +1907,6 @@ fn test_android(target: &str) { // FIXME: "'__uint128' undeclared" in C "__uint128" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, - _ => false, } }); @@ -2103,6 +2083,9 @@ fn test_android(target: &str) { | "PF_BLOCK_TS" | "PF_SUSPEND_TASK" => true, + // FIXME(android): Requires >= 6.12 kernel headers. + "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, + _ => false, } }); @@ -2161,6 +2144,9 @@ fn test_android(target: &str) { // Added in API level 26, but some tests use level 24. "endgrent" => true, + // Added in API level 26, but some tests use level 24. + "getdomainname" | "setdomainname" => true, + // FIXME: bad function pointers: "isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint" | "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower" @@ -2329,6 +2315,7 @@ fn test_freebsd(target: &str) { "sys/thr.h", "sys/time.h", [freebsd14 || freebsd15]:"sys/timerfd.h", + [freebsd13 || freebsd14 || freebsd15]:"dev/evdev/input.h", "sys/times.h", "sys/timex.h", "sys/types.h", @@ -2402,6 +2389,7 @@ fn test_freebsd(target: &str) { "type_" if struct_ == "rtprio" => "type".to_string(), "type_" if struct_ == "sockstat" => "type".to_string(), "type_" if struct_ == "devstat_match_table" => "type".to_string(), + "type_" if struct_ == "input_event" => "type".to_string(), s => s.to_string(), } }); @@ -2689,9 +2677,6 @@ fn test_freebsd(target: &str) { // `eventfd(2)` and things come with it are added in FreeBSD 13 "eventfd_t" if Some(13) > freebsd_ver => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, - _ => false, } }); @@ -3012,9 +2997,6 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/issues/5033 ty if ty.starts_with("epoll") => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, - // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 t => t.ends_with("64") || t.ends_with("64_t"), @@ -3089,6 +3071,9 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/pull/14883 "SIG_IGN" => true, + // Constants present in other linuxes but not emscripten + "SI_DETHREAD" | "TRAP_PERF" => true, + // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 n if n.starts_with("RLIM64") => true, @@ -3286,9 +3271,6 @@ fn test_neutrino(target: &str) { // Does not exist in Neutrino "locale_t" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, - _ => false, } }); @@ -3455,8 +3437,6 @@ fn test_vxworks(target: &str) { // FIXME cfg.skip_type(move |ty| match ty { "stat64" | "sighandler_t" | "off64_t" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, _ => false, }); @@ -3804,9 +3784,6 @@ fn test_linux(target: &str) { // FIXME: "'__uint128' undeclared" in C "__uint128" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, - t => { if musl { // LFS64 types have been removed in musl 1.2.4+ @@ -4036,7 +4013,7 @@ fn test_linux(target: &str) { } // FIXME: Requires >= 5.4 kernel headers if name == "PTP_CLOCK_GETCAPS2" - || name == "PTP_ENABLE_PPS2" + || name == "PTP_ENABLE_PPS2" || name == "PTP_EXTTS_REQUEST2" || name == "PTP_PEROUT_REQUEST2" || name == "PTP_PIN_GETFUNC2" @@ -4162,6 +4139,9 @@ fn test_linux(target: &str) { // FIXME: Not currently available in headers on ARM and musl. "NETLINK_GET_STRICT_CHK" if arm => true, + // Skip as this signal codes and trap reasons need newer headers + "SI_DETHREAD" | "TRAP_PERF" => true, + // kernel constants not available in uclibc 1.0.34 | "EXTPROC" | "IPPROTO_BEETPH" @@ -4361,6 +4341,12 @@ fn test_linux(target: &str) { // FIXME: Requires >= 6.11 kernel headers. "MAP_DROPPABLE" => true, + // FIXME(linux): Requires >= 6.2 kernel headers. + "SOF_TIMESTAMPING_OPT_ID_TCP" => true, + + // FIXME(linux): Requires >= 6.12 kernel headers. + "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, + _ => false, } }); @@ -4759,8 +4745,6 @@ fn test_linux_like_apis(target: &str) { }) .skip_type(move |ty| match ty { "Elf64_Phdr" | "Elf32_Phdr" => false, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, _ => true, }); cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_elf.rs"); @@ -4996,8 +4980,6 @@ fn test_haiku(target: &str) { "pthread_condattr_t" => true, "pthread_mutexattr_t" => true, "pthread_rwlockattr_t" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, _ => false, } }); diff --git a/libc-test/semver/TODO-linux.txt b/libc-test/semver/TODO-linux.txt index 8427cf1ea12c8..98568ab0e9745 100644 --- a/libc-test/semver/TODO-linux.txt +++ b/libc-test/semver/TODO-linux.txt @@ -54,7 +54,6 @@ SO_SELECT_ERR_QUEUE SO_SNDTIMEO_NEW SO_STYLE SO_TIMESTAMPING_NEW -SO_TIMESTAMPNS SO_TIMESTAMPNS_NEW SO_TIMESTAMP_NEW SO_TXTIME diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 06a28efaac820..a60cd024f2040 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -2385,9 +2385,12 @@ SOCK_RAW SOCK_RDM SOCK_SEQPACKET SOCK_STREAM +SOF_TIMESTAMPING_BIND_PHC SOF_TIMESTAMPING_OPT_CMSG SOF_TIMESTAMPING_OPT_ID +SOF_TIMESTAMPING_OPT_ID_TCP SOF_TIMESTAMPING_OPT_PKTINFO +SOF_TIMESTAMPING_OPT_RX_FILTER SOF_TIMESTAMPING_OPT_STATS SOF_TIMESTAMPING_OPT_TSONLY SOF_TIMESTAMPING_OPT_TX_SWHW @@ -3324,6 +3327,7 @@ getaddrinfo getchar getchar_unlocked getcwd +getdomainname getegid getenv geteuid @@ -3720,6 +3724,7 @@ sendmsg sendto servent setbuf +setdomainname setegid setenv seteuid diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 486d11e64a60a..a5a9f9befb9d9 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2026,6 +2026,8 @@ ifconf ifreq in6_pktinfo initgroups +input_absinfo +input_event ip_mreqn ipc_perm jail diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index 433a6a1816240..b39aba51d1b5f 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -14,8 +14,10 @@ POSIX_FADV_NORMAL POSIX_FADV_RANDOM POSIX_FADV_SEQUENTIAL POSIX_FADV_WILLNEED +POSIX_SPAWN_SETSID posix_fadvise posix_fallocate +posix_spawn_file_actions_addfchdir_np pthread_attr_get_np pthread_attr_getstackaddr pthread_attr_setstack diff --git a/libc-test/semver/linux-loongarch64.txt b/libc-test/semver/linux-loongarch64.txt index ebcd4bf93356f..1302cb68b2c8a 100644 --- a/libc-test/semver/linux-loongarch64.txt +++ b/libc-test/semver/linux-loongarch64.txt @@ -87,7 +87,6 @@ SO_SECURITY_AUTHENTICATION SO_SECURITY_ENCRYPTION_NETWORK SO_SECURITY_ENCRYPTION_TRANSPORT SO_SELECT_ERR_QUEUE -SO_TIMESTAMPNS SO_WIFI_STATUS SYS_accept SYS_msgctl diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 62b188dac8288..2223bb50059ee 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -5,6 +5,7 @@ AIO_ALLDONE AIO_CANCELED AIO_NOTCANCELED BOOT_TIME +CLONE_NEWTIME DEAD_PROCESS EMPTY Elf32_Chdr diff --git a/libc-test/semver/linux-powerpc64.txt b/libc-test/semver/linux-powerpc64.txt index 77718d9ce47f0..604add92838db 100644 --- a/libc-test/semver/linux-powerpc64.txt +++ b/libc-test/semver/linux-powerpc64.txt @@ -48,7 +48,6 @@ SO_SECURITY_AUTHENTICATION SO_SECURITY_ENCRYPTION_NETWORK SO_SECURITY_ENCRYPTION_TRANSPORT SO_SELECT_ERR_QUEUE -SO_TIMESTAMPNS SO_WIFI_STATUS SYS__llseek SYS__newselect diff --git a/libc-test/semver/linux-powerpc64le.txt b/libc-test/semver/linux-powerpc64le.txt index 99be508e6bd59..b4e5c4159a3d8 100644 --- a/libc-test/semver/linux-powerpc64le.txt +++ b/libc-test/semver/linux-powerpc64le.txt @@ -46,7 +46,6 @@ SO_SECURITY_AUTHENTICATION SO_SECURITY_ENCRYPTION_NETWORK SO_SECURITY_ENCRYPTION_TRANSPORT SO_SELECT_ERR_QUEUE -SO_TIMESTAMPNS SO_WIFI_STATUS SYS__llseek SYS__newselect diff --git a/libc-test/semver/linux-riscv64gc.txt b/libc-test/semver/linux-riscv64gc.txt index 13f5b85196790..09519e9dfbe7e 100644 --- a/libc-test/semver/linux-riscv64gc.txt +++ b/libc-test/semver/linux-riscv64gc.txt @@ -51,7 +51,6 @@ SO_SECURITY_AUTHENTICATION SO_SECURITY_ENCRYPTION_NETWORK SO_SECURITY_ENCRYPTION_TRANSPORT SO_SELECT_ERR_QUEUE -SO_TIMESTAMPNS SO_WIFI_STATUS SYS_accept SYS_fadvise64 diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 175e2811e9649..c91b5034608d2 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2879,7 +2879,17 @@ SIOCSMIIREG SIOCSRARP SIOCWANDEV SIOGIFINDEX +SI_ASYNCIO +SI_ASYNCNL +SI_DETHREAD +SI_KERNEL SI_LOAD_SHIFT +SI_MESGQ +SI_QUEUE +SI_SIGIO +SI_TIMER +SI_TKILL +SI_USER SND_CNT SND_MAX SOCK_CLOEXEC @@ -2888,9 +2898,12 @@ SOCK_NONBLOCK SOCK_PACKET SOCK_RAW SOCK_RDM +SOF_TIMESTAMPING_BIND_PHC SOF_TIMESTAMPING_OPT_CMSG SOF_TIMESTAMPING_OPT_ID +SOF_TIMESTAMPING_OPT_ID_TCP SOF_TIMESTAMPING_OPT_PKTINFO +SOF_TIMESTAMPING_OPT_RX_FILTER SOF_TIMESTAMPING_OPT_STATS SOF_TIMESTAMPING_OPT_TSONLY SOF_TIMESTAMPING_OPT_TX_SWHW @@ -2954,6 +2967,7 @@ SO_RXQ_OVFL SO_SNDBUFFORCE SO_TIMESTAMP SO_TIMESTAMPING +SO_TIMESTAMPNS SPLICE_F_GIFT SPLICE_F_MORE SPLICE_F_MOVE @@ -3359,6 +3373,12 @@ TP_STATUS_USER TP_STATUS_VLAN_TPID_VALID TP_STATUS_VLAN_VALID TP_STATUS_WRONG_FORMAT +TRAP_BRANCH +TRAP_BRKPT +TRAP_HWBKPT +TRAP_PERF +TRAP_TRACE +TRAP_UNK TUNATTACHFILTER TUNDETACHFILTER TUNGETFEATURES diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index f6bb5be4e5aca..f8380fd02936b 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -15,6 +15,16 @@ LIO_READ LIO_WAIT LIO_WRITE PIPE_BUF +POSIX_SPAWN_NOEXECERR_NP +POSIX_SPAWN_NOSIGCHLD_NP +POSIX_SPAWN_RESETIDS +POSIX_SPAWN_SETPGROUP +POSIX_SPAWN_SETSCHEDPARAM +POSIX_SPAWN_SETSCHEDULER +POSIX_SPAWN_SETSIGDEF +POSIX_SPAWN_SETSIGIGN_NP +POSIX_SPAWN_SETSIGMASK +POSIX_SPAWN_WAITPID_NP SIGEV_PORT SIGRTMAX SIGRTMIN @@ -34,5 +44,32 @@ bind in6_pktinfo in_pktinfo lio_listio +posix_spawn +posix_spawn_file_actions_addchdir +posix_spawn_file_actions_addchdir_np +posix_spawn_file_actions_addclose +posix_spawn_file_actions_addclosefrom_np +posix_spawn_file_actions_adddup2 +posix_spawn_file_actions_addfchdir +posix_spawn_file_actions_addopen +posix_spawn_file_actions_destroy +posix_spawn_file_actions_init +posix_spawnattr_destroy +posix_spawnattr_getflags +posix_spawnattr_getpgroup +posix_spawnattr_getschedparam +posix_spawnattr_getschedpolicy +posix_spawnattr_getsigdefault +posix_spawnattr_getsigignore_np +posix_spawnattr_getsigmask +posix_spawnattr_init +posix_spawnattr_setflags +posix_spawnattr_setpgroup +posix_spawnattr_setschedparam +posix_spawnattr_setschedpolicy +posix_spawnattr_setsigdefault +posix_spawnattr_setsigignore_np +posix_spawnattr_setsigmask +posix_spawnp recvmsg sendmsg diff --git a/libc-test/test/check_style.rs b/libc-test/test/check_style.rs new file mode 100644 index 0000000000000..ee5e134891104 --- /dev/null +++ b/libc-test/test/check_style.rs @@ -0,0 +1,50 @@ +//! Simple script to verify the coding style of this library. +//! +//! ## How to run +//! +//! The first argument to this script is the directory to run on, so running +//! this script should be as simple as: +//! +//! ```notrust +//! cargo test --test style +//! ``` + +pub mod style; + +use std::env; +use std::path::Path; + +use style::{Result, StyleChecker}; + +#[test] +fn check_style() { + let root_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../src"); + walk(&root_dir).unwrap(); + eprintln!("good style!"); +} + +fn walk(root_dir: &Path) -> Result<()> { + let mut style_checker = StyleChecker::new(); + + for entry in glob::glob(&format!( + "{}/**/*.rs", + root_dir.to_str().expect("dir should be valid UTF-8") + ))? { + let entry = entry?; + + let name = entry + .file_name() + .expect("file name should not end in ..") + .to_str() + .expect("file name should be valid UTF-8"); + if let "lib.rs" | "macros.rs" = &name[..] { + continue; + } + + let path = entry.as_path(); + style_checker.check_file(path)?; + style_checker.reset_state(); + } + + style_checker.finalize() +} diff --git a/libc-test/test/style/mod.rs b/libc-test/test/style/mod.rs new file mode 100644 index 0000000000000..cc953d32c3aed --- /dev/null +++ b/libc-test/test/style/mod.rs @@ -0,0 +1,490 @@ +//! Provides the [StyleChecker] visitor to verify the coding style of +//! this library. +//! +//! This is split out so that the implementation itself can be tested +//! separately, see test/check_style.rs for how it's used and +//! test/style_tests.rs for the implementation tests. +//! +//! ## Guidelines +//! +//! The current style is: +//! +//! * Specific module layout: +//! 1. use directives +//! 2. typedefs +//! 3. structs +//! 4. constants +//! 5. f! { ... } functions +//! 6. extern functions +//! 7. modules + pub use +//! * No manual deriving Copy/Clone +//! * Only one f! per module +//! * Multiple s! macros are allowed as long as there isn't a duplicate cfg, +//! whether as a standalone attribute (#[cfg]) or in a cfg_if! +//! * s! macros should not just have a positive cfg since they should +//! just go into the relevant file but combined cfgs with all(...) and +//! any(...) are allowed + +use std::collections::HashMap; +use std::fs; +use std::ops::Deref; +use std::path::{Path, PathBuf}; + +use annotate_snippets::{Level, Renderer, Snippet}; +use proc_macro2::Span; +use syn::parse::{Parse, ParseStream}; +use syn::spanned::Spanned; +use syn::visit::{self, Visit}; +use syn::Token; + +const ALLOWED_REPEATED_MACROS: &[&str] = &["s", "s_no_extra_traits", "s_paren"]; + +pub type Error = Box; +pub type Result = std::result::Result; + +#[derive(Default)] +pub struct StyleChecker { + /// The state the style checker is in, used to enforce the module layout. + state: State, + /// Span of the first item encountered in this state to use in help + /// diagnostic text. + state_span: Option, + /// The s! macro cfgs we have seen, whether through #[cfg] attributes + /// or within the branches of cfg_if! blocks so that we can check for duplicates. + seen_s_macro_cfgs: HashMap, + /// Span of the first f! macro seen, used to enforce only one f! macro + /// per module. + first_f_macro: Option, + /// The errors that the style checker has seen. + errors: Vec, + /// Path of the currently active file. + path: PathBuf, + /// Whether the style checker is currently in an `impl` block. + in_impl: bool, +} + +/// The part of the module layout we are currently checking. +#[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +enum State { + #[default] + Start, + Imports, + Typedefs, + Structs, + Constants, + FunctionDefinitions, + Functions, + Modules, +} + +/// Similar to [syn::ExprIf] except with [syn::Attribute] +/// as the condition instead of [syn::Expr]. +struct ExprCfgIf { + _cond: syn::Attribute, + /// A `cfg_if!` branch can only contain items. + then_branch: Vec, + else_branch: Option>, +} + +enum ExprCfgElse { + /// Final block with no condition `else { /* ... */ }`. + Block(Vec), + /// `else if { /* ... */ }` block. + If(ExprCfgIf), +} + +/// Describes an that occurred error when checking the file +/// at the given `path`. Besides the error message, it contains +/// additional span information so that we can print nice error messages. +#[derive(Debug)] +struct FileError { + path: PathBuf, + span: Span, + title: String, + msg: String, + help: Option, +} + +/// Help message with an optional span where the help should point to. +type HelpMsg = (Option, String); + +impl StyleChecker { + pub fn new() -> Self { + Self::default() + } + + /// Reads and parses the file at the given path and checks + /// for any style violations. + pub fn check_file(&mut self, path: &Path) -> Result<()> { + let contents = fs::read_to_string(path)?; + + self.path = PathBuf::from(path); + self.check_string(contents) + } + + pub fn check_string(&mut self, contents: String) -> Result<()> { + let file = syn::parse_file(&contents)?; + self.visit_file(&file); + Ok(()) + } + + /// Resets the state of the [StyleChecker]. + pub fn reset_state(&mut self) { + *self = Self { + errors: std::mem::take(&mut self.errors), + ..Self::default() + }; + } + + /// Collect all errors into a single error, reporting them if any. + pub fn finalize(self) -> Result<()> { + if self.errors.is_empty() { + return Ok(()); + } + + let renderer = Renderer::styled(); + for error in self.errors { + let source = fs::read_to_string(&error.path)?; + + let mut snippet = Snippet::source(&source) + .origin(error.path.to_str().expect("path to be UTF-8")) + .fold(true) + .annotation(Level::Error.span(error.span.byte_range()).label(&error.msg)); + if let Some((help_span, help_msg)) = &error.help { + if let Some(help_span) = help_span { + snippet = snippet + .annotation(Level::Help.span(help_span.byte_range()).label(help_msg)); + } + } + + let mut msg = Level::Error.title(&error.title).snippet(snippet); + if let Some((help_span, help_msg)) = &error.help { + if help_span.is_none() { + msg = msg.footer(Level::Help.title(help_msg)) + } + } + + eprintln!("{}", renderer.render(msg)); + } + + Err("some tests failed".into()) + } + + fn set_state(&mut self, new_state: State, span: Span) { + if self.state > new_state && !self.in_impl { + let help_span = self + .state_span + .expect("state_span should be set since we are on a second state"); + self.error( + "incorrect module layout".to_string(), + span, + format!( + "{} found after {} when it belongs before", + new_state.desc(), + self.state.desc() + ), + ( + Some(help_span), + format!( + "move the {} to before this {}", + new_state.desc(), + self.state.desc() + ), + ), + ); + } + + if self.state != new_state { + self.state = new_state; + self.state_span = Some(span); + } + } + + /// Visit the items inside the [ExprCfgIf], restoring the state after + /// each branch. + fn visit_expr_cfg_if(&mut self, expr_cfg_if: &ExprCfgIf) { + let initial_state = self.state; + + for item in &expr_cfg_if.then_branch { + self.visit_item(item); + } + self.state = initial_state; + + if let Some(else_branch) = &expr_cfg_if.else_branch { + match else_branch.deref() { + ExprCfgElse::Block(items) => { + for item in items { + self.visit_item(item); + } + } + ExprCfgElse::If(expr_cfg_if) => self.visit_expr_cfg_if(&expr_cfg_if), + } + } + self.state = initial_state; + } + + /// If we see a normal s! macro without any attributes we just need + /// to check if there are any duplicates. + fn handle_s_macro_no_attrs(&mut self, item_macro: &syn::ItemMacro) { + let span = item_macro.span(); + match self.seen_s_macro_cfgs.get("") { + Some(seen_span) => { + self.error( + "duplicate s! macro".to_string(), + span, + format!("other s! macro"), + (Some(*seen_span), "combine the two".to_string()), + ); + } + None => { + self.seen_s_macro_cfgs.insert(String::new(), span); + } + } + } + + /// If an s! macro has attributes we check for any duplicates as well + /// as if they are standalone positive cfgs that would be better + /// in a separate file. + fn handle_s_macro_with_attrs(&mut self, item_macro: &syn::ItemMacro) { + for attr in &item_macro.attrs { + let Ok(meta_list) = attr.meta.require_list() else { + continue; + }; + + if meta_list.path.is_ident("cfg") { + let span = meta_list.span(); + let meta_str = meta_list.tokens.to_string(); + + match self.seen_s_macro_cfgs.get(&meta_str) { + Some(seen_span) => { + self.error( + "duplicate #[cfg] for s! macro".to_string(), + span, + "duplicated #[cfg]".to_string(), + (Some(*seen_span), "combine the two".to_string()), + ); + } + None => { + self.seen_s_macro_cfgs.insert(meta_str.clone(), span); + } + } + + if !meta_str.starts_with("not") + && !meta_str.starts_with("any") + && !meta_str.starts_with("all") + { + self.error( + "positive #[cfg] for s! macro".to_string(), + span, + String::new(), + (None, "move it to the relevant file".to_string()), + ); + } + } + } + } + + fn push_error(&mut self, title: String, span: Span, msg: String, help: Option) { + self.errors.push(FileError { + path: self.path.clone(), + title, + span, + msg, + help, + }); + } + + fn error(&mut self, title: String, span: Span, msg: String, help: HelpMsg) { + self.push_error(title, span, msg, Some(help)); + } +} + +impl<'ast> Visit<'ast> for StyleChecker { + /// Visit all items; most just update our current state but some also + /// perform additional checks like for the s! macro. + fn visit_item_use(&mut self, item_use: &'ast syn::ItemUse) { + let span = item_use.span(); + let new_state = if matches!(item_use.vis, syn::Visibility::Public(_)) { + State::Modules + } else { + State::Imports + }; + self.set_state(new_state, span); + + visit::visit_item_use(self, item_use); + } + + fn visit_item_const(&mut self, item_const: &'ast syn::ItemConst) { + let span = item_const.span(); + self.set_state(State::Constants, span); + + visit::visit_item_const(self, item_const); + } + + fn visit_item_impl(&mut self, item_impl: &'ast syn::ItemImpl) { + self.in_impl = true; + visit::visit_item_impl(self, item_impl); + self.in_impl = false; + } + + fn visit_item_struct(&mut self, item_struct: &'ast syn::ItemStruct) { + let span = item_struct.span(); + self.set_state(State::Structs, span); + + visit::visit_item_struct(self, item_struct); + } + + fn visit_item_type(&mut self, item_type: &'ast syn::ItemType) { + let span = item_type.span(); + self.set_state(State::Typedefs, span); + + visit::visit_item_type(self, item_type); + } + + /// Checks s! macros for any duplicate cfgs and whether they are + /// just positive #[cfg(...)] attributes. We need [syn::ItemMacro] + /// instead of [syn::Macro] because it contains the attributes. + fn visit_item_macro(&mut self, item_macro: &'ast syn::ItemMacro) { + if item_macro.mac.path.is_ident("s") { + if item_macro.attrs.is_empty() { + self.handle_s_macro_no_attrs(item_macro); + } else { + self.handle_s_macro_with_attrs(item_macro); + } + } + + visit::visit_item_macro(self, item_macro); + } + + fn visit_macro(&mut self, mac: &'ast syn::Macro) { + let span = mac.span(); + if mac.path.is_ident("cfg_if") { + let expr_cfg_if: ExprCfgIf = mac + .parse_body() + .expect("cfg_if! should be parsed since it compiled"); + + self.visit_expr_cfg_if(&expr_cfg_if); + } else { + let new_state = + if mac.path.get_ident().is_some_and(|ident| { + ALLOWED_REPEATED_MACROS.contains(&ident.to_string().as_str()) + }) { + // multiple macros of this type are allowed + State::Structs + } else if mac.path.is_ident("f") { + match self.first_f_macro { + Some(f_macro_span) => { + self.error( + "multiple f! macros in one module".to_string(), + span, + "other f! macro".to_string(), + ( + Some(f_macro_span), + "combine it with this f! macro".to_string(), + ), + ); + } + None => { + self.first_f_macro = Some(span); + } + } + State::FunctionDefinitions + } else { + self.state + }; + self.set_state(new_state, span); + } + + visit::visit_macro(self, mac); + } + + fn visit_item_foreign_mod(&mut self, item_foreign_mod: &'ast syn::ItemForeignMod) { + let span = item_foreign_mod.span(); + self.set_state(State::Functions, span); + + visit::visit_item_foreign_mod(self, item_foreign_mod); + } + + fn visit_item_mod(&mut self, item_mod: &'ast syn::ItemMod) { + let span = item_mod.span(); + self.set_state(State::Modules, span); + + visit::visit_item_mod(self, item_mod); + } + + fn visit_meta_list(&mut self, meta_list: &'ast syn::MetaList) { + let span = meta_list.span(); + let meta_str = meta_list.tokens.to_string(); + if meta_list.path.is_ident("derive") + && (meta_str.contains("Copy") || meta_str.contains("Clone")) + { + self.error( + "impl Copy and Clone manually".to_string(), + span, + "found manual implementation of Copy and/or Clone".to_string(), + (None, "use one of the s! macros instead".to_string()), + ); + } + + visit::visit_meta_list(self, meta_list); + } +} + +impl Parse for ExprCfgIf { + fn parse(input: ParseStream) -> syn::Result { + input.parse::()?; + let cond = input + .call(syn::Attribute::parse_outer)? + .into_iter() + .next() + .expect("an attribute should be present since it compiled"); + + let content; + syn::braced!(content in input); + let mut then_branch = Vec::new(); + while !content.is_empty() { + let mut value = content.parse()?; + if let syn::Item::Macro(item_macro) = &mut value { + item_macro.attrs.push(cond.clone()); + } + then_branch.push(value); + } + + let mut else_branch = None; + if input.peek(Token![else]) { + input.parse::()?; + + if input.peek(Token![if]) { + else_branch = Some(Box::new(ExprCfgElse::If(input.parse()?))); + } else { + let content; + syn::braced!(content in input); + let mut items = Vec::new(); + while !content.is_empty() { + items.push(content.parse()?); + } + else_branch = Some(Box::new(ExprCfgElse::Block(items))); + } + } + Ok(Self { + _cond: cond, + then_branch, + else_branch, + }) + } +} + +impl State { + fn desc(&self) -> &str { + match *self { + State::Start => "start", + State::Imports => "import", + State::Typedefs => "typedef", + State::Structs => "struct", + State::Constants => "constant", + State::FunctionDefinitions => "function definition", + State::Functions => "extern function", + State::Modules => "module", + } + } +} diff --git a/libc-test/test/style_tests.rs b/libc-test/test/style_tests.rs new file mode 100644 index 0000000000000..be8fddbccf644 --- /dev/null +++ b/libc-test/test/style_tests.rs @@ -0,0 +1,260 @@ +//! Verifies the implementation of the style checker in [style]. + +use style::StyleChecker; + +pub mod style; + +#[test] +fn check_style_accept_correct_module_layout() { + let contents = r#" +use core::mem::size_of; +pub type foo_t = u32; +struct Foo {} +pub const FOO: u32 = 0x20000; +f! {} +extern "C" {} +mod foolib; +pub use self::foolib::*; +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + checker.finalize().unwrap(); +} + +#[test] +fn check_style_reject_incorrect_module_layout() { + let contents = r#" +use core::mem::size_of; +pub type foo_t = u32; +struct Foo {} +pub const FOO: u32 = 0x20000; +extern "C" {} +f! {} +mod foolib; +pub use self::foolib::*; +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_reject_incorrect_cfg_if_layout() { + let contents = r#" +cfg_if! { + if #[cfg(foo)] { + pub type foo_t = u32; + use core::mem::size_of; + } +} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_accept_cfg_if_branch_resets_state() { + let contents = r#" +cfg_if! { + if #[cfg(foo)] { + use core::mem::size_of; + pub type foo_t = u32; + } else { + use core::mem::align_of; + } +} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + checker.finalize().unwrap(); +} + +#[test] +fn check_style_reject_multiple_f_macros() { + let contents = r#" +f! {} +f! {} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_accept_cfg_ignore_target_endian_nested() { + let contents = r#" +pub struct Foo { + #[cfg(target_endian = "little")] + pub id: __u16, +} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + checker.finalize().unwrap(); +} + +#[test] +fn check_style_reject_manual_copy() { + let contents = r#" +#[derive(Copy)] +pub struct Foo {} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_reject_manual_clone() { + let contents = r#" +#[derive(Clone)] +pub struct Foo {} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_accept_multiple_s_macros_with_disjoint_cfg() { + let contents = r#" +// Main `s!` +s! {} + +// These are not supported on a single arch. It doesn't make sense to +// duplicate `foo` into every single file except one, so allow this here. +#[cfg(not(target_arch = "foo"))] +s! { pub struct foo { /* ... */ } } + +// Similar to the above, no problems here +#[cfg(not(target_os = "illumos"))] +s! { pub struct bar { /* ... */ } } +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + checker.finalize().unwrap(); +} + +#[test] +fn check_style_reject_duplicated_s_macro() { + let contents = r#" +s! {} +s! {} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_reject_duplicated_s_macro_cfg() { + let contents = r#" +#[cfg(not(target_arch = "foo"))] +s! {} + +#[cfg(not(target_arch = "foo"))] +s! {} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_reject_single_positive_s_macro_cfg() { + let contents = r#" +// A positive (no `not`) config: reject because this should go into +// the relevant file. +#[cfg(target_arch = "foo")] +s! { pub struct foo { /* ... */ } } +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_reject_single_positive_s_macro_cfg_target_os() { + let contents = r#" +// A positive (no `not`) config: reject because this should go into +// the relevant file. +#[cfg(target_os = "foo")] +s! { pub struct foo { /* ... */ } } +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} + +#[test] +fn check_style_accept_positive_s_macro_any() { + let contents = r#" +// It's nicer to accept this so that we don't have to duplicate the same struct 3 times. +#[cfg(any(target_arch = "foo", target_arch = "bar", target_arch = "baz"))] +s! { pub struct foo { /* ... */ } } +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + checker.finalize().unwrap(); +} + +#[test] +fn check_style_accept_positive_s_macro_all() { + let contents = r#" +#[cfg(all(target_arch = "foo", target_arch = "bar", target_arch = "baz"))] +s! { pub struct foo { /* ... */ } } +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + checker.finalize().unwrap(); +} + +#[test] +fn check_style_reject_duplicated_cfg_and_cfg_if() { + let contents = r#" +#[cfg(not(target_arch = "foo"))] +s! { pub struct foo { /* ... */ } } + +cfg_if! { + if #[cfg(not(target_arch = "foo"))] { + s!{ pub struct bar {} } + } +} +"# + .to_string(); + + let mut checker = StyleChecker::new(); + checker.check_string(contents).unwrap(); + assert!(checker.finalize().is_err()); +} diff --git a/src/fuchsia/aarch64.rs b/src/fuchsia/aarch64.rs index b822375100948..577f0d99cf24d 100644 --- a/src/fuchsia/aarch64.rs +++ b/src/fuchsia/aarch64.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = u8; pub type __u64 = c_ulonglong; pub type wchar_t = u32; pub type nlink_t = c_ulong; diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 8e56e3f62928d..d666c7e39de60 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -7,16 +7,6 @@ use crate::prelude::*; // PUB_TYPE -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -88,10 +78,7 @@ pub type fsblkcnt_t = c_ulonglong; pub type fsfilcnt_t = c_ulonglong; pub type rlim_t = c_ulonglong; -pub type c_long = i64; -pub type c_ulong = u64; - -// FIXME: why are these uninhabited types? that seems... wrong? +// FIXME(fuchsia): why are these uninhabited types? that seems... wrong? // Presumably these should be `()` or an `extern type` (when that stabilizes). #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} @@ -111,7 +98,7 @@ impl Clone for DIR { } #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos64_t {} // FIXME: fill this out with a struct +pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct impl Copy for fpos64_t {} impl Clone for fpos64_t { fn clone(&self) -> fpos64_t { @@ -144,7 +131,7 @@ s! { pub tv_nsec: c_long, } - // FIXME: the rlimit and rusage related functions and types don't exist + // FIXME(fuchsia): the rlimit and rusage related functions and types don't exist // within zircon. Are there reasons for keeping them around? pub struct rlimit { pub rlim_cur: rlim_t, @@ -478,7 +465,7 @@ s! { pub ifa_flags: c_uint, pub ifa_addr: *mut crate::sockaddr, pub ifa_netmask: *mut crate::sockaddr, - pub ifa_ifu: *mut crate::sockaddr, // FIXME This should be a union + pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union pub ifa_data: *mut c_void, } @@ -1097,7 +1084,7 @@ cfg_if! { .field("totalhigh", &self.totalhigh) .field("freehigh", &self.freehigh) .field("mem_unit", &self.mem_unit) - // FIXME: .field("__reserved", &self.__reserved) + // FIXME(debug): .field("__reserved", &self.__reserved) .finish() } } @@ -1135,7 +1122,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("sockaddr_un") .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -1163,7 +1150,7 @@ cfg_if! { f.debug_struct("sockaddr_storage") .field("ss_family", &self.ss_family) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) + // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) .finish() } } @@ -1207,11 +1194,11 @@ cfg_if! { impl fmt::Debug for utsname { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) + // FIXME(debug): .field("sysname", &self.sysname) + // FIXME(debug): .field("nodename", &self.nodename) + // FIXME(debug): .field("release", &self.release) + // FIXME(debug): .field("version", &self.version) + // FIXME(debug): .field("machine", &self.machine) .finish() } } @@ -1246,7 +1233,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1281,7 +1268,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1390,7 +1377,7 @@ cfg_if! { impl fmt::Debug for pthread_cond_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_cond_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -1409,7 +1396,7 @@ cfg_if! { impl fmt::Debug for pthread_mutex_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_mutex_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -1428,7 +1415,7 @@ cfg_if! { impl fmt::Debug for pthread_rwlock_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_rwlock_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -3562,7 +3549,7 @@ impl Clone for FILE { } } #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos_t {} // FIXME: fill this out with a struct +pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { fn clone(&self) -> fpos_t { diff --git a/src/fuchsia/riscv64.rs b/src/fuchsia/riscv64.rs index bed7a926030fe..c57d52aad1386 100644 --- a/src/fuchsia/riscv64.rs +++ b/src/fuchsia/riscv64.rs @@ -2,7 +2,6 @@ use crate::off_t; use crate::prelude::*; // From psABI Calling Convention for RV64 -pub type c_char = u8; pub type __u64 = c_ulonglong; pub type wchar_t = i32; diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index b82b86adcd41e..ffff3a78b5ed5 100644 --- a/src/fuchsia/x86_64.rs +++ b/src/fuchsia/x86_64.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = c_long; diff --git a/src/hermit.rs b/src/hermit.rs index 9363fed788304..65d0bf374d8cd 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -1,26 +1,12 @@ //! Hermit C type definitions -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; pub type intptr_t = isize; pub type uintptr_t = usize; -pub type c_float = f32; -pub type c_double = f64; - pub type size_t = usize; pub type ssize_t = isize; pub type ptrdiff_t = isize; diff --git a/src/lib.rs b/src/lib.rs index 569775095fa8c..50aed357a82ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ redundant_semicolons, unused_macros, unused_macro_rules, - // FIXME: temporarily allow dead_code to fix CI: + // FIXME(1.0): temporarily allow dead_code to fix CI: // - https://github.com/rust-lang/libc/issues/3740 // - https://github.com/rust-lang/rust/pull/126456 dead_code, @@ -41,144 +41,106 @@ cfg_if! { pub use core::ffi::c_void; -/// Type definitions that are coupled tighter to architecture than OS. -mod arch { - cfg_if! { - // This configuration comes from `rust-lang/rust` in `library/core/src/ffi/mod.rs`. - if #[cfg(all( - not(windows), - // FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it - not(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", - )), - any( - target_arch = "aarch64", - target_arch = "arm", - target_arch = "csky", - target_arch = "hexagon", - target_arch = "msp430", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "riscv64", - target_arch = "riscv32", - target_arch = "s390x", - target_arch = "xtensa", - ) - ))] { - // To be reexported as `c_char` - // FIXME(ctest): just name these `c_char` once `ctest` learns that these don't get - // exported. - pub type c_char_def = u8; - } else { - pub type c_char_def = i8; - } - } -} - cfg_if! { if #[cfg(windows)] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod windows; pub use crate::windows::*; prelude!(); } else if #[cfg(target_os = "fuchsia")] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod fuchsia; pub use crate::fuchsia::*; prelude!(); } else if #[cfg(target_os = "switch")] { - mod fixed_width_ints; - pub use fixed_width_ints::*; + mod primitives; + pub use primitives::*; mod switch; pub use switch::*; prelude!(); } else if #[cfg(target_os = "psp")] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use primitives::*; mod psp; pub use crate::psp::*; prelude!(); } else if #[cfg(target_os = "vxworks")] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod vxworks; pub use crate::vxworks::*; prelude!(); } else if #[cfg(target_os = "solid_asp3")] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod solid; pub use crate::solid::*; prelude!(); } else if #[cfg(unix)] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod unix; pub use crate::unix::*; prelude!(); } else if #[cfg(target_os = "hermit")] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod hermit; pub use crate::hermit::*; prelude!(); } else if #[cfg(target_os = "teeos")] { - mod fixed_width_ints; - pub use fixed_width_ints::*; + mod primitives; + pub use primitives::*; mod teeos; pub use teeos::*; prelude!(); } else if #[cfg(target_os = "trusty")] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod trusty; pub use crate::trusty::*; prelude!(); } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod sgx; pub use crate::sgx::*; prelude!(); } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod wasi; pub use crate::wasi::*; prelude!(); } else if #[cfg(target_os = "xous")] { - mod fixed_width_ints; - pub use crate::fixed_width_ints::*; + mod primitives; + pub use crate::primitives::*; mod xous; pub use crate::xous::*; diff --git a/src/macros.rs b/src/macros.rs index b4db0fd469da8..e7dbf5611970e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -243,7 +243,7 @@ cfg_if! { )*) => ($( #[inline] $(#[$attr])* - pub $($constness)* unsafe extern fn $i($($arg: $argty),*) -> $ret + pub $($constness)* unsafe extern "C" fn $i($($arg: $argty),*) -> $ret $body )*) } @@ -257,7 +257,7 @@ cfg_if! { )*) => ($( #[inline] $(#[$attr])* - pub $($constness)* extern fn $i($($arg: $argty),*) -> $ret + pub $($constness)* extern "C" fn $i($($arg: $argty),*) -> $ret $body )*) } @@ -285,7 +285,7 @@ cfg_if! { )*) => ($( #[inline] $(#[$attr])* - pub unsafe extern fn $i($($arg: $argty),*) -> $ret + pub unsafe extern "C" fn $i($($arg: $argty),*) -> $ret $body )*) } @@ -299,7 +299,7 @@ cfg_if! { )*) => ($( #[inline] $(#[$attr])* - pub extern fn $i($($arg: $argty),*) -> $ret + pub extern "C" fn $i($($arg: $argty),*) -> $ret $body )*) } diff --git a/src/fixed_width_ints.rs b/src/primitives.rs similarity index 70% rename from src/fixed_width_ints.rs rename to src/primitives.rs index d2385fd385d10..668d3340d2abb 100644 --- a/src/fixed_width_ints.rs +++ b/src/primitives.rs @@ -1,6 +1,75 @@ -//! This module contains type aliases for C's fixed-width integer types . +//! This module contains type aliases for C's platform-specific types +//! and fixed-width integer types. //! -//! These aliases are deprecated: use the Rust types instead. +//! The platform-specific types definitions were taken from rust-lang/rust in +//! library/core/src/ffi/primitives.rs +//! +//! The fixed-width integer aliases are deprecated: use the Rust types instead. + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; + +pub type c_longlong = i64; +pub type c_ulonglong = u64; + +pub type c_float = f32; +pub type c_double = f64; + +cfg_if! { + if #[cfg(all( + not(windows), + // FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it + not(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )), + not(target_os = "vita"), + any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "csky", + target_arch = "hexagon", + target_arch = "msp430", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "riscv32", + target_arch = "riscv64", + target_arch = "s390x", + target_arch = "xtensa", + ) + ))] { + pub type c_char = u8; + } else { + // On every other target, c_char is signed. + pub type c_char = i8; + } +} + +cfg_if! { + if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] { + pub type c_int = i16; + pub type c_uint = u16; + } else { + pub type c_int = i32; + pub type c_uint = u32; + } +} + +cfg_if! { + if #[cfg(all(target_pointer_width = "64", not(windows)))] { + pub type c_long = i64; + pub type c_ulong = u64; + } else { + // The minimal size of `long` in the C standard is 32 bits + pub type c_long = i32; + pub type c_ulong = u32; + } +} #[deprecated(since = "0.2.55", note = "Use i8 instead.")] pub type int8_t = i8; diff --git a/src/psp.rs b/src/psp.rs index e1bf285967ede..73d4ae0173ece 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -6,16 +6,6 @@ use crate::prelude::*; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -25,10 +15,6 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; - pub type SceKernelVTimerHandler = unsafe extern "C" fn( uid: SceUid, arg1: *mut SceKernelSysClock, diff --git a/src/sgx.rs b/src/sgx.rs index e37ccd79c3a55..9cf9c6d3b41b8 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -1,15 +1,7 @@ //! SGX C types definition -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; +use crate::prelude::*; + pub type intmax_t = i64; pub type uintmax_t = u64; @@ -19,9 +11,5 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; -pub type c_char = i8; -pub type c_long = i64; -pub type c_ulong = u64; - pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; diff --git a/src/solid/aarch64.rs b/src/solid/aarch64.rs index 4032488b6c0d5..376783c8234ba 100644 --- a/src/solid/aarch64.rs +++ b/src/solid/aarch64.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i64; -pub type c_ulong = u64; diff --git a/src/solid/arm.rs b/src/solid/arm.rs index 55240068aa08e..376783c8234ba 100644 --- a/src/solid/arm.rs +++ b/src/solid/arm.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 19c9b6aed344b..965c5bb1aa522 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -4,16 +4,6 @@ use crate::prelude::*; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; diff --git a/src/switch.rs b/src/switch.rs index 4a8b16e15f568..d965ff7005fb2 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -1,15 +1,5 @@ //! Switch C type definitions -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -20,9 +10,6 @@ pub type uintptr_t = usize; pub type ssize_t = isize; pub type off_t = i64; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index 40bc0c0549a08..9929e70e61e63 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -7,28 +7,8 @@ use crate::prelude::*; -pub type c_schar = i8; - -pub type c_uchar = u8; - -pub type c_short = i16; - -pub type c_ushort = u16; - -pub type c_int = i32; - -pub type c_uint = u32; - pub type c_bool = i32; -pub type c_float = f32; - -pub type c_double = f64; - -pub type c_longlong = i64; - -pub type c_ulonglong = u64; - pub type intmax_t = i64; pub type uintmax_t = u64; @@ -45,18 +25,8 @@ pub type ssize_t = isize; pub type pid_t = c_int; -// aarch64 specific -pub type c_char = u8; - pub type wchar_t = u32; -pub type c_long = i64; - -pub type c_ulong = u64; - -#[repr(align(16))] -pub struct _CLongDouble(pub u128); - // long double in C means A float point value, which has 128bit length. // but some bit maybe not used, so the real length of long double could be 80(x86) or 128(power pc/IEEE) // this is different from f128(not stable and not included default) in Rust, so we use u128 for FFI(Rust to C). @@ -91,6 +61,9 @@ pub type wctype_t = c_ulong; pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int; +#[repr(align(16))] +pub struct _CLongDouble(pub u128); + #[repr(align(8))] #[repr(C)] pub struct pthread_cond_t { diff --git a/src/trusty.rs b/src/trusty.rs index 676a456d892fe..7441aade0631e 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -1,30 +1,9 @@ -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; pub type size_t = usize; pub type ssize_t = isize; pub type off_t = i64; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; - -cfg_if! { - if #[cfg(target_pointer_width = "32")] { - pub type c_long = i32; - pub type c_ulong = u32; - } else if #[cfg(target_pointer_width = "64")] { - pub type c_long = i64; - pub type c_ulong = u64; - } -} - -pub type c_longlong = i64; -pub type c_ulonglong = u64; - pub type c_uint8_t = u8; pub type c_uint16_t = u16; pub type c_uint32_t = u32; @@ -38,9 +17,6 @@ pub type c_int64_t = i64; pub type intptr_t = isize; pub type uintptr_t = usize; -pub type c_float = f32; -pub type c_double = f64; - pub type time_t = c_long; pub type clockid_t = c_int; diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 6e98709dc5462..647836b6f6719 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; pub type blkcnt_t = c_long; diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 921774611e299..fcb9e6edfafa7 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -1,9 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; - s! { pub struct sigset_t { pub ss_set: [c_ulong; 4], diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 70f8de79af7b6..4fec58f76be47 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -2,8 +2,6 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; pub type boolean_t = c_int; s! { diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index b09bcb9dad332..98dccd3d49ddd 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -2,9 +2,6 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; - s! { pub struct timeval32 { pub tv_sec: i32, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 943d9e400ecc0..fe8bad4209f37 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5,7 +5,6 @@ use crate::prelude::*; use crate::{cmsghdr, off_t}; -pub type c_char = i8; pub type wchar_t = i32; pub type clock_t = c_ulong; pub type time_t = c_long; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index a97ead4757b1a..cfaa93f76d88e 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -2,7 +2,6 @@ use crate::prelude::*; use crate::{cmsghdr, off_t}; pub type dev_t = u32; -pub type c_char = i8; pub type wchar_t = i32; pub type clock_t = u64; pub type ino_t = u64; @@ -11,8 +10,6 @@ pub type nlink_t = u32; pub type blksize_t = i64; pub type clockid_t = c_ulong; -pub type c_long = i64; -pub type c_ulong = u64; pub type time_t = i64; pub type suseconds_t = i64; @@ -865,6 +862,8 @@ cfg_if! { self.mc_fpregs.hash(state); } } + // FIXME(msrv): suggested method was added in 1.85 + #[allow(unpredictable_function_pointer_comparisons)] impl PartialEq for ucontext_t { fn eq(&self, other: &ucontext_t) -> bool { self.uc_sigmask == other.uc_sigmask diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 81d3eb351cdb6..ae93648ebd94f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; pub type clock_t = i32; pub type wchar_t = u32; pub type time_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 07492c9333d75..e29c9cef3981e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; -pub type c_long = i32; -pub type c_ulong = u32; pub type clock_t = u32; pub type wchar_t = u32; pub type time_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 4a454619ef06c..9c81a8410db04 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -266,7 +266,8 @@ s! { pub st_blksize: crate::blksize_t, pub st_flags: crate::fflags_t, pub st_gen: u64, - pub st_spare: [u64; 10], + pub st_filerev: u64, + pub st_spare: [u64; 9], } } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index ae4e366afdd48..23bbb1e1c47fe 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -290,6 +290,22 @@ s! { pub sem_flg: c_short, } + pub struct input_event { + pub time: crate::timeval, + pub type_: crate::u_short, + pub code: crate::u_short, + pub value: i32, + } + + pub struct input_absinfo { + pub value: i32, + pub minimum: i32, + pub maximum: i32, + pub fuzz: i32, + pub flat: i32, + pub resolution: i32, + } + pub struct msqid_ds { pub msg_perm: crate::ipc_perm, __unused1: *mut c_void, diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index 0bd678c9821b6..9fde25d37b62f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; -pub type c_long = i32; -pub type c_ulong = u32; pub type clock_t = u32; pub type wchar_t = i32; pub type time_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index e1548a2fa4a09..e7df7f7737997 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; pub type clock_t = u32; pub type wchar_t = i32; pub type time_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index e425411436d2b..449a29f7d3df4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; pub type clock_t = i32; pub type wchar_t = c_int; pub type time_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 5af53cd76f665..b196eafe06ab8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_char = i8; -pub type c_long = i32; -pub type c_ulong = u32; pub type clock_t = c_ulong; pub type wchar_t = i32; pub type time_t = i32; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fca9a126f81c1..fde274bb15a69 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_char = i8; -pub type c_long = i64; -pub type c_ulong = u64; pub type clock_t = i32; pub type wchar_t = i32; pub type time_t = i64; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d8e52f5f74245..445957537eb76 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -639,7 +639,7 @@ safe_f! { } pub {const} fn WEXITSTATUS(status: c_int) -> c_int { - status >> 8 + (status >> 8) & 0x00ff } pub {const} fn WCOREDUMP(status: c_int) -> bool { diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index 2391801fe458b..b511fc8457752 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = u8; pub type greg_t = u64; pub type __cpu_simple_lock_nv_t = c_uchar; diff --git a/src/unix/bsd/netbsdlike/netbsd/arm.rs b/src/unix/bsd/netbsdlike/netbsd/arm.rs index 1f54c8135bf47..b252862dfe650 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = u8; pub type __cpu_simple_lock_nv_t = c_int; pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/mips.rs b/src/unix/bsd/netbsdlike/netbsd/mips.rs index 7129c0f54eb6f..eabfe1bbcc1e8 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mips.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = i8; pub type __cpu_simple_lock_nv_t = c_int; pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 8e3507fc743a8..fe2b667a523fc 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2849,7 +2849,7 @@ extern "C" { ntargets: size_t, hint: *const c_void, ) -> c_int; - + #[link_name = "__getmntinfo13"] pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int; } diff --git a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs index a086396ed610a..fc4cc3898e12a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = u8; pub type __cpu_simple_lock_nv_t = c_int; pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 68cd264aadb78..550c3bd7bb4ea 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -2,9 +2,6 @@ use PT_FIRSTMACH; use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = u8; pub type __greg_t = u64; pub type __cpu_simple_lock_nv_t = c_int; pub type __gregset = [__greg_t; _NGREG]; diff --git a/src/unix/bsd/netbsdlike/netbsd/sparc64.rs b/src/unix/bsd/netbsdlike/netbsd/sparc64.rs index d564f58a3e688..91622f7eea3fa 100644 --- a/src/unix/bsd/netbsdlike/netbsd/sparc64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/sparc64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = i8; pub type __cpu_simple_lock_nv_t = c_uchar; // should be pub(crate), but that requires Rust 1.18.0 diff --git a/src/unix/bsd/netbsdlike/netbsd/x86.rs b/src/unix/bsd/netbsdlike/netbsd/x86.rs index 3c55792defcbd..92e160d9bca0c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = i8; pub type __cpu_simple_lock_nv_t = c_uchar; pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index f968e36d67aa2..5d31c0661e9c6 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = i8; pub type c___greg_t = u64; pub type __cpu_simple_lock_nv_t = c_uchar; diff --git a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs index bf704757c59d6..2c4b1df26ce83 100644 --- a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = u8; pub type ucontext_t = sigcontext; s! { diff --git a/src/unix/bsd/netbsdlike/openbsd/arm.rs b/src/unix/bsd/netbsdlike/openbsd/arm.rs index 1e66ed247a2eb..ae91cde0a1739 100644 --- a/src/unix/bsd/netbsdlike/openbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -1,9 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = u8; - pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/mips64.rs b/src/unix/bsd/netbsdlike/openbsd/mips64.rs index 15803ced09a08..162ceda265df9 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mips64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mips64.rs @@ -1,7 +1,3 @@ -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = i8; - #[doc(hidden)] pub const _ALIGNBYTES: usize = 7; diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs index 1e66ed247a2eb..ae91cde0a1739 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -1,9 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = u8; - pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs index cb808719fb8ea..1c3d8df3b7956 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -1,9 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = u8; - pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs index 6a39f3494dd14..a0865406b80f3 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = u8; pub type ucontext_t = sigcontext; s! { diff --git a/src/unix/bsd/netbsdlike/openbsd/sparc64.rs b/src/unix/bsd/netbsdlike/openbsd/sparc64.rs index 070fc9385f6c9..88481f4f014e8 100644 --- a/src/unix/bsd/netbsdlike/openbsd/sparc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/sparc64.rs @@ -1,7 +1,3 @@ -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = i8; - #[doc(hidden)] pub const _ALIGNBYTES: usize = 0xf; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86.rs b/src/unix/bsd/netbsdlike/openbsd/x86.rs index 4b495d0c16de8..d2cf7832edd7f 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -1,9 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = i8; - pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs index 4380c1d118922..db9114e27cb60 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = i8; pub type ucontext_t = sigcontext; s! { diff --git a/src/unix/haiku/b32.rs b/src/unix/haiku/b32.rs index c1135c834ef8b..1aa27e615ca4e 100644 --- a/src/unix/haiku/b32.rs +++ b/src/unix/haiku/b32.rs @@ -1,5 +1,3 @@ -pub type c_long = i32; -pub type c_ulong = u32; pub type time_t = i32; pub type Elf_Addr = crate::Elf32_Addr; diff --git a/src/unix/haiku/b64.rs b/src/unix/haiku/b64.rs index 96617042cf2ab..3355241fdb797 100644 --- a/src/unix/haiku/b64.rs +++ b/src/unix/haiku/b64.rs @@ -1,5 +1,3 @@ -pub type c_ulong = u64; -pub type c_long = i64; pub type time_t = i64; pub type Elf_Addr = crate::Elf64_Addr; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 78477a10bfc51..10ee719b9c18f 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -6,7 +6,6 @@ pub type pthread_key_t = c_int; pub type nfds_t = c_ulong; pub type tcflag_t = c_uint; pub type speed_t = c_uchar; -pub type c_char = i8; pub type clock_t = i32; pub type clockid_t = i32; pub type suseconds_t = i32; diff --git a/src/unix/hurd/b32.rs b/src/unix/hurd/b32.rs index 5223d549dd025..e706789006dba 100644 --- a/src/unix/hurd/b32.rs +++ b/src/unix/hurd/b32.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; - pub type __int64_t = c_longlong; pub type __uint64_t = c_ulonglong; diff --git a/src/unix/hurd/b64.rs b/src/unix/hurd/b64.rs index 1954c27f88563..a44428c575adf 100644 --- a/src/unix/hurd/b64.rs +++ b/src/unix/hurd/b64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; - pub type __int64_t = c_long; pub type __uint64_t = c_ulong; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 1a04a725ada56..0c5f001202844 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -4,8 +4,6 @@ use crate::c_schar; use crate::prelude::*; // types -pub type c_char = i8; - pub type __s16_type = c_short; pub type __u16_type = c_ushort; pub type __s32_type = c_int; @@ -228,7 +226,7 @@ pub type nl_item = c_int; pub type iconv_t = *mut c_void; #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos64_t {} // FIXME: fill this out with a struct +pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct impl Copy for fpos64_t {} impl Clone for fpos64_t { fn clone(&self) -> fpos64_t { @@ -816,7 +814,7 @@ s! { pub ifa_flags: c_uint, pub ifa_addr: *mut crate::sockaddr, pub ifa_netmask: *mut crate::sockaddr, - pub ifa_ifu: *mut crate::sockaddr, // FIXME This should be a union + pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union pub ifa_data: *mut c_void, } @@ -1094,7 +1092,7 @@ cfg_if! { .field("ut_line", &self.ut_line) .field("ut_id", &self.ut_id) .field("ut_user", &self.ut_user) - // FIXME: .field("ut_host", &self.ut_host) + // FIXME(debug): .field("ut_host", &self.ut_host) .field("ut_exit", &self.ut_exit) .field("ut_session", &self.ut_session) .field("ut_tv", &self.ut_tv) @@ -3451,7 +3449,7 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - cmsg.offset(1) as *mut c_uchar + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::()) as isize) } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index 0bf4087fde751..a6170adc14d3f 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = u32; pub type greg_t = i32; pub type mcontext_t = sigcontext; diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index 3e3485757ce98..42be94d425c72 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -3,8 +3,6 @@ use crate::prelude::*; // The following definitions are correct for arm and i686, // but may be wrong for mips -pub type c_long = i32; -pub type c_ulong = u32; pub type mode_t = u16; pub type off64_t = c_longlong; pub type sigset_t = c_ulong; diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index 9f80d8a71f449..2acbe7712eb77 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = i32; pub type greg_t = i32; @@ -269,9 +268,11 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -282,11 +283,11 @@ pub const SYS_personality: c_long = 136; pub const SYS_afs_syscall: c_long = 137; pub const SYS_setfsuid: c_long = 138; pub const SYS_setfsgid: c_long = 139; -// FIXME: SYS__llseek is in the NDK sources but for some reason is +// FIXME(android): SYS__llseek is in the NDK sources but for some reason is // not available in the tests // pub const SYS__llseek: c_long = 140; pub const SYS_getdents: c_long = 141; -// FIXME: SYS__newselect is in the NDK sources but for some reason is +// FIXME(android): SYS__newselect is in the NDK sources but for some reason is // not available in the tests // pub const SYS__newselect: c_long = 142; pub const SYS_flock: c_long = 143; @@ -295,7 +296,7 @@ pub const SYS_readv: c_long = 145; pub const SYS_writev: c_long = 146; pub const SYS_getsid: c_long = 147; pub const SYS_fdatasync: c_long = 148; -// FIXME: SYS__llseek is in the NDK sources but for some reason is +// FIXME(android): SYS__llseek is in the NDK sources but for some reason is // not available in the tests // pub const SYS__sysctl: c_long = 149; pub const SYS_mlock: c_long = 150; @@ -315,6 +316,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; pub const SYS_vm86: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 167; pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 39d8bc07c4dd5..b678eb8da6aa4 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -1,7 +1,6 @@ use crate::off64_t; use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = u32; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index ffa79ead870e8..cc407e113f67a 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -3,8 +3,6 @@ use crate::prelude::*; // The following definitions are correct for aarch64 and x86_64, // but may be wrong for mips64 -pub type c_long = i64; -pub type c_ulong = u64; pub type mode_t = u32; pub type off64_t = i64; pub type socklen_t = u32; @@ -161,7 +159,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_mutex_t") .field("value", &self.value) - // FIXME: .field("__reserved", &self.__reserved) + // FIXME(debug): .field("__reserved", &self.__reserved) .finish() } } @@ -190,7 +188,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_cond_t") .field("value", &self.value) - // FIXME: .field("__reserved", &self.__reserved) + // FIXME(debug): .field("__reserved", &self.__reserved) .finish() } } @@ -227,7 +225,7 @@ cfg_if! { .field("pendingReaders", &self.pendingReaders) .field("pendingWriters", &self.pendingWriters) .field("attr", &self.attr) - // FIXME: .field("__reserved", &self.__reserved) + // FIXME(debug): .field("__reserved", &self.__reserved) .finish() } } diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index d35c408955109..c4dc98e010aed 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -1,7 +1,6 @@ use crate::off64_t; use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = u32; pub type greg_t = i64; pub type __u64 = c_ulonglong; diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index 4da5cd4995679..ce2d70999856a 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -1,7 +1,6 @@ use crate::off64_t; use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = i32; pub type greg_t = i64; pub type __u64 = c_ulonglong; @@ -354,7 +353,7 @@ cfg_if! { .field("mxcsr", &self.mxcsr) .field("mxcr_mask", &self.mxcr_mask) .field("st_space", &self.st_space) - // FIXME: .field("xmm_space", &self.xmm_space) + // FIXME(debug): .field("xmm_space", &self.xmm_space) // Ignore padding field .finish() } @@ -546,7 +545,7 @@ pub const SYS_munlockall: c_long = 152; pub const SYS_vhangup: c_long = 153; pub const SYS_modify_ldt: c_long = 154; pub const SYS_pivot_root: c_long = 155; -// FIXME: SYS__sysctl is in the NDK sources but for some reason is +// FIXME(android): SYS__sysctl is in the NDK sources but for some reason is // not available in the tests // pub const SYS__sysctl: c_long = 156; pub const SYS_prctl: c_long = 157; @@ -566,10 +565,13 @@ pub const SYS_sethostname: c_long = 170; pub const SYS_setdomainname: c_long = 171; pub const SYS_iopl: c_long = 172; pub const SYS_ioperm: c_long = 173; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 174; pub const SYS_init_module: c_long = 175; pub const SYS_delete_module: c_long = 176; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 177; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 178; pub const SYS_quotactl: c_long = 179; pub const SYS_nfsservctl: c_long = 180; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index f408969175d34..5debbe8fb967d 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -699,7 +699,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -737,7 +737,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -809,7 +809,7 @@ cfg_if! { f.debug_struct("lastlog") .field("ll_time", &self.ll_time) .field("ll_line", &self.ll_line) - // FIXME: .field("ll_host", &self.ll_host) + // FIXME(debug): .field("ll_host", &self.ll_host) .finish() } } @@ -860,7 +860,7 @@ cfg_if! { .field("ut_line", &self.ut_line) .field("ut_id", &self.ut_id) .field("ut_user", &self.ut_user) - // FIXME: .field("ut_host", &self.ut_host) + // FIXME(debug): .field("ut_host", &self.ut_host) .field("ut_exit", &self.ut_exit) .field("ut_session", &self.ut_session) .field("ut_tv", &self.ut_tv) @@ -2942,6 +2942,9 @@ pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11; pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12; pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13; pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14; +pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15; +pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16; +pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17; #[deprecated( since = "0.2.55", @@ -3568,6 +3571,10 @@ pub const AT_RSEQ_ALIGN: c_ulong = 28; pub const AT_EXECFN: c_ulong = 31; pub const AT_MINSIGSTKSZ: c_ulong = 51; +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here. diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 866a20cd00722..f22843e54073f 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = i32; pub type useconds_t = u32; pub type dev_t = u32; @@ -28,8 +27,6 @@ pub type blksize_t = c_long; pub type fsblkcnt_t = u32; pub type fsfilcnt_t = u32; pub type rlim_t = u64; -pub type c_long = i32; -pub type c_ulong = u32; pub type nlink_t = u32; pub type ino64_t = crate::ino_t; @@ -45,7 +42,7 @@ pub type statvfs64 = crate::statvfs; pub type dirent64 = crate::dirent; #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos64_t {} // FIXME: fill this out with a struct +pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct impl Copy for fpos64_t {} impl Clone for fpos64_t { fn clone(&self) -> fpos64_t { @@ -228,16 +225,16 @@ s! { } pub struct stat { pub st_dev: crate::dev_t, - #[cfg(not(emscripten_new_stat_abi))] + #[cfg(emscripten_old_stat_abi)] __st_dev_padding: c_int, - #[cfg(not(emscripten_new_stat_abi))] + #[cfg(emscripten_old_stat_abi)] __st_ino_truncated: c_long, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - #[cfg(not(emscripten_new_stat_abi))] + #[cfg(emscripten_old_stat_abi)] __st_rdev_padding: c_int, pub st_size: off_t, pub st_blksize: crate::blksize_t, @@ -413,7 +410,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -466,7 +463,7 @@ cfg_if! { .field("totalhigh", &self.totalhigh) .field("freehigh", &self.freehigh) .field("mem_unit", &self.mem_unit) - // FIXME: .field("__reserved", &self.__reserved) + // FIXME(debug): .field("__reserved", &self.__reserved) .finish() } } @@ -526,7 +523,7 @@ cfg_if! { impl fmt::Debug for pthread_cond_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_cond_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -1575,8 +1572,6 @@ extern "C" { pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; - pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; - pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; pub fn sendmmsg( sockfd: c_int, msgvec: *mut crate::mmsghdr, diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 10953fe789df3..098c83c3b885b 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -40,10 +40,8 @@ pub const SO_PASSCRED: c_int = 16; pub const SO_PEERCRED: c_int = 17; pub const SO_RCVLOWAT: c_int = 18; pub const SO_SNDLOWAT: c_int = 19; -pub const SO_RCVTIMEO: c_int = 20; -pub const SO_SNDTIMEO: c_int = 21; -// pub const SO_RCVTIMEO_OLD: c_int = 20; -// pub const SO_SNDTIMEO_OLD: c_int = 21; +const SO_RCVTIMEO_OLD: c_int = 20; +const SO_SNDTIMEO_OLD: c_int = 21; pub const SO_SECURITY_AUTHENTICATION: c_int = 22; pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23; pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24; @@ -52,18 +50,46 @@ pub const SO_ATTACH_FILTER: c_int = 26; pub const SO_DETACH_FILTER: c_int = 27; pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; pub const SO_PEERNAME: c_int = 28; -pub const SO_TIMESTAMP: c_int = 29; -// pub const SO_TIMESTAMP_OLD: c_int = 29; +const SO_TIMESTAMP_OLD: c_int = 29; +const SO_TIMESTAMPNS_OLD: c_int = 35; +const SO_TIMESTAMPING_OLD: c_int = 37; + +cfg_if! { + if #[cfg(all( + linux_time_bits64, + any(target_arch = "arm", target_arch = "x86"), + not(any(target_env = "musl", target_env = "ohos")) + ))] { + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; + } else if #[cfg(all( + linux_time_bits64, + any(target_arch = "arm", target_arch = "x86"), + any(target_env = "musl", target_env = "ohos") + ))] { + pub const SO_TIMESTAMP: c_int = 63; + pub const SO_TIMESTAMPNS: c_int = 64; + pub const SO_TIMESTAMPING: c_int = 65; + pub const SO_RCVTIMEO: c_int = 66; + pub const SO_SNDTIMEO: c_int = 67; + } else { + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; + } +} + pub const SO_ACCEPTCONN: c_int = 30; pub const SO_PEERSEC: c_int = 31; pub const SO_SNDBUFFORCE: c_int = 32; pub const SO_RCVBUFFORCE: c_int = 33; pub const SO_PASSSEC: c_int = 34; -pub const SO_TIMESTAMPNS: c_int = 35; -// pub const SO_TIMESTAMPNS_OLD: c_int = 35; pub const SO_MARK: c_int = 36; -pub const SO_TIMESTAMPING: c_int = 37; -// pub const SO_TIMESTAMPING_OLD: c_int = 37; pub const SO_PROTOCOL: c_int = 38; pub const SO_DOMAIN: c_int = 39; pub const SO_RXQ_OVFL: c_int = 40; @@ -99,6 +125,7 @@ cfg_if! { any( target_arch = "x86", target_arch = "x86_64", + target_arch = "arm", target_arch = "aarch64", target_arch = "csky", target_arch = "loongarch64" diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 950ad5f118dfb..612f8c73ffc3c 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -36,10 +36,17 @@ pub const SO_RCVLOWAT: c_int = 0x1004; // NOTE: These definitions are now being renamed with _OLD postfix, // but CI haven't support them yet. // Some related consts could be found in b32.rs and b64.rs -pub const SO_SNDTIMEO: c_int = 0x1005; -pub const SO_RCVTIMEO: c_int = 0x1006; -// pub const SO_SNDTIMEO_OLD: c_int = 0x1005; -// pub const SO_RCVTIMEO_OLD: c_int = 0x1006; +const SO_SNDTIMEO_OLD: c_int = 0x1005; +const SO_RCVTIMEO_OLD: c_int = 0x1006; +cfg_if! { + if #[cfg(linux_time_bits64)] { + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; + } else { + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; + } +} pub const SO_ACCEPTCONN: c_int = 0x1009; pub const SO_PROTOCOL: c_int = 0x1028; pub const SO_DOMAIN: c_int = 0x1029; @@ -91,17 +98,25 @@ pub const SO_BINDTOIFINDEX: c_int = 62; // NOTE: These definitions are now being renamed with _OLD postfix, // but CI haven't support them yet. // Some related consts could be found in b32.rs and b64.rs -pub const SO_TIMESTAMP: c_int = 29; -pub const SO_TIMESTAMPNS: c_int = 35; -pub const SO_TIMESTAMPING: c_int = 37; -// pub const SO_TIMESTAMP_OLD: c_int = 29; -// pub const SO_TIMESTAMPNS_OLD: c_int = 35; -// pub const SO_TIMESTAMPING_OLD: c_int = 37; -// pub const SO_TIMESTAMP_NEW: c_int = 63; -// pub const SO_TIMESTAMPNS_NEW: c_int = 64; -// pub const SO_TIMESTAMPING_NEW: c_int = 65; -// pub const SO_RCVTIMEO_NEW: c_int = 66; -// pub const SO_SNDTIMEO_NEW: c_int = 67; +const SO_TIMESTAMP_OLD: c_int = 29; +const SO_RCVTIMEO_NEW: c_int = 66; +const SO_SNDTIMEO_NEW: c_int = 67; +const SO_TIMESTAMPNS_OLD: c_int = 35; +const SO_TIMESTAMPING_OLD: c_int = 37; +const SO_TIMESTAMP_NEW: c_int = 63; +const SO_TIMESTAMPNS_NEW: c_int = 64; +const SO_TIMESTAMPING_NEW: c_int = 65; +cfg_if! { + if #[cfg(linux_time_bits64)] { + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; + } else { + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; + } +} // pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; // pub const SO_PREFER_BUSY_POLL: c_int = 69; // pub const SO_BUSY_POLL_BUDGET: c_int = 70; @@ -349,10 +364,17 @@ cfg_if! { } cfg_if! { - if #[cfg( + if #[cfg(all( any(target_arch = "mips", target_arch = "mips32r6"), - any(target_env = "gnu", target_env = "uclibc") - )] { + any(target_env = "uclibc", target_env = "gnu"), + linux_time_bits64 + ))] { + pub const RLIM_INFINITY: crate::rlim_t = !0; + } else if #[cfg(all( + any(target_arch = "mips", target_arch = "mips32r6"), + any(target_env = "uclibc", target_env = "gnu"), + not(linux_time_bits64) + ))] { pub const RLIM_INFINITY: crate::rlim_t = 0x7fffffff; } } diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index de39df0d8323a..50d1ef17bb887 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -24,8 +24,15 @@ pub const SO_REUSEPORT: c_int = 15; // powerpc only differs in these pub const SO_RCVLOWAT: c_int = 16; pub const SO_SNDLOWAT: c_int = 17; -pub const SO_RCVTIMEO: c_int = 18; -pub const SO_SNDTIMEO: c_int = 19; +cfg_if! { + if #[cfg(linux_time_bits64)] { + pub const SO_SNDTIMEO: c_int = 67; + pub const SO_RCVTIMEO: c_int = 66; + } else { + pub const SO_SNDTIMEO: c_int = 19; + pub const SO_RCVTIMEO: c_int = 18; + } +} // pub const SO_RCVTIMEO_OLD: c_int = 18; // pub const SO_SNDTIMEO_OLD: c_int = 19; pub const SO_PASSCRED: c_int = 20; @@ -39,18 +46,26 @@ pub const SO_ATTACH_FILTER: c_int = 26; pub const SO_DETACH_FILTER: c_int = 27; pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; pub const SO_PEERNAME: c_int = 28; -pub const SO_TIMESTAMP: c_int = 29; -// pub const SO_TIMESTAMP_OLD: c_int = 29; +cfg_if! { + if #[cfg(linux_time_bits64)] { + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; + } else { + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; + } +} +const SO_TIMESTAMP_OLD: c_int = 29; +const SO_TIMESTAMPNS_OLD: c_int = 35; +const SO_TIMESTAMPING_OLD: c_int = 37; pub const SO_ACCEPTCONN: c_int = 30; pub const SO_PEERSEC: c_int = 31; pub const SO_SNDBUFFORCE: c_int = 32; pub const SO_RCVBUFFORCE: c_int = 33; pub const SO_PASSSEC: c_int = 34; -pub const SO_TIMESTAMPNS: c_int = 35; -// pub const SO_TIMESTAMPNS_OLD: c_int = 35; pub const SO_MARK: c_int = 36; -pub const SO_TIMESTAMPING: c_int = 37; -// pub const SO_TIMESTAMPING_OLD: c_int = 37; pub const SO_PROTOCOL: c_int = 38; pub const SO_DOMAIN: c_int = 39; pub const SO_RXQ_OVFL: c_int = 40; @@ -79,11 +94,11 @@ pub const SO_ZEROCOPY: c_int = 60; pub const SO_TXTIME: c_int = 61; pub const SCM_TXTIME: c_int = SO_TXTIME; pub const SO_BINDTOIFINDEX: c_int = 62; -// pub const SO_TIMESTAMP_NEW: c_int = 63; -// pub const SO_TIMESTAMPNS_NEW: c_int = 64; -// pub const SO_TIMESTAMPING_NEW: c_int = 65; -// pub const SO_RCVTIMEO_NEW: c_int = 66; -// pub const SO_SNDTIMEO_NEW: c_int = 67; +const SO_TIMESTAMP_NEW: c_int = 63; +const SO_TIMESTAMPNS_NEW: c_int = 64; +const SO_TIMESTAMPING_NEW: c_int = 65; +const SO_RCVTIMEO_NEW: c_int = 66; +const SO_SNDTIMEO_NEW: c_int = 67; // pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; // pub const SO_PREFER_BUSY_POLL: c_int = 69; // pub const SO_BUSY_POLL_BUDGET: c_int = 70; diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index f3869723996cb..9462f627d63e7 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; pub type wchar_t = u32; s! { diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index eb6f70d8fed07..96cc52c55854e 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; pub type wchar_t = u32; s! { diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index 3d252c6253035..d8b047ab446ab 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = i8; pub type wchar_t = i32; s! { @@ -549,9 +548,11 @@ pub const SYS_cacheflush: c_long = 123; pub const SYS_adjtimex_time32: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -588,6 +589,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid16: c_long = 164; pub const SYS_getresuid16: c_long = 165; pub const SYS_getpagesize: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 167; pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 73da7739dabf5..b15df99e50ec6 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = i8; pub type wchar_t = i32; s! { @@ -290,9 +289,11 @@ pub const SYS_modify_ldt: c_long = 4000 + 123; pub const SYS_adjtimex: c_long = 4000 + 124; pub const SYS_mprotect: c_long = 4000 + 125; pub const SYS_sigprocmask: c_long = 4000 + 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 4000 + 127; pub const SYS_init_module: c_long = 4000 + 128; pub const SYS_delete_module: c_long = 4000 + 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 4000 + 130; pub const SYS_quotactl: c_long = 4000 + 131; pub const SYS_getpgid: c_long = 4000 + 132; @@ -349,6 +350,7 @@ pub const SYS_socket: c_long = 4000 + 183; pub const SYS_socketpair: c_long = 4000 + 184; pub const SYS_setresuid: c_long = 4000 + 185; pub const SYS_getresuid: c_long = 4000 + 186; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 4000 + 187; pub const SYS_poll: c_long = 4000 + 188; pub const SYS_nfsservctl: c_long = 4000 + 189; diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index adb36cc169fef..2cdd1320bf3e3 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -3,8 +3,6 @@ use crate::prelude::*; use crate::pthread_mutex_t; -pub type c_long = i32; -pub type c_ulong = u32; pub type clock_t = i32; pub type shmatt_t = c_ulong; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 75ec2385a1230..d15012c4ec68c 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; pub type wchar_t = i32; s! { @@ -556,9 +555,11 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -595,6 +596,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 166; pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 43547cc7ad868..91b17847e10ae 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; pub type wchar_t = c_int; s! { diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index cfe62018f5fdd..de00e9915826a 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = i8; pub type wchar_t = i32; s! { @@ -618,6 +617,7 @@ pub const SYS_flistxattr: c_long = 180; pub const SYS_removexattr: c_long = 181; pub const SYS_lremovexattr: c_long = 182; pub const SYS_sigpending: c_long = 183; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 184; pub const SYS_setpgid: c_long = 185; pub const SYS_fremovexattr: c_long = 186; @@ -655,8 +655,10 @@ pub const SYS_clone: c_long = 217; pub const SYS_ioprio_get: c_long = 218; pub const SYS_adjtimex: c_long = 219; pub const SYS_sigprocmask: c_long = 220; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 221; pub const SYS_delete_module: c_long = 222; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 223; pub const SYS_getpgid: c_long = 224; pub const SYS_bdflush: c_long = 225; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index d626236dda792..bb2e3ccbf8925 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = i8; pub type wchar_t = i32; pub type greg_t = i32; @@ -772,9 +771,11 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -812,6 +813,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; pub const SYS_vm86: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 167; pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs index cec3b7ee28b5a..f808ff31f8cca 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs @@ -1,8 +1,6 @@ +use crate::prelude::*; use crate::pthread_mutex_t; -pub type c_long = i32; -pub type c_ulong = u32; - pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs index 4b09e476d370c..960e5127806b3 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs @@ -1,8 +1,6 @@ +use crate::prelude::*; use crate::pthread_mutex_t; -pub type c_long = i64; -pub type c_ulong = u64; - pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 27ba5263c5361..0e990f6006378 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = i32; @@ -602,7 +601,7 @@ pub const HWCAP_SSBS: c_ulong = 1 << 28; pub const HWCAP_SB: c_ulong = 1 << 29; pub const HWCAP_PACA: c_ulong = 1 << 30; pub const HWCAP_PACG: c_ulong = 1 << 31; -// FIXME: enable these again once linux-api-headers are up to date enough on CI. +// FIXME(linux): enable these again once linux-api-headers are up to date enough on CI. // See discussion in https://github.com/rust-lang/libc/pull/1638 //pub const HWCAP2_DCPODP: c_ulong = 1 << 0; //pub const HWCAP2_SVE2: c_ulong = 1 << 1; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index 8c05659dc09a7..6162565da17ca 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::{off64_t, off_t, pthread_mutex_t}; -pub type c_char = i8; -pub type c_long = i64; -pub type c_ulong = u64; pub type wchar_t = i32; pub type blksize_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 2d85df1385a10..375ea40cb6a1d 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -2,9 +2,6 @@ use crate::prelude::*; use crate::{off64_t, off_t, pthread_mutex_t}; pub type blksize_t = i64; -pub type c_char = i8; -pub type c_long = i64; -pub type c_ulong = u64; pub type nlink_t = u64; pub type suseconds_t = i64; pub type wchar_t = i32; @@ -412,10 +409,13 @@ pub const SYS_swapoff: c_long = 5000 + 163; pub const SYS_reboot: c_long = 5000 + 164; pub const SYS_sethostname: c_long = 5000 + 165; pub const SYS_setdomainname: c_long = 5000 + 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 5000 + 167; pub const SYS_init_module: c_long = 5000 + 168; pub const SYS_delete_module: c_long = 5000 + 169; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 5000 + 170; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 5000 + 171; pub const SYS_quotactl: c_long = 5000 + 172; pub const SYS_nfsservctl: c_long = 5000 + 173; diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 86d047dbf3878..e537dbcd0a86a 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t, pthread_mutex_t}; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = u8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; @@ -699,9 +696,11 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -738,6 +737,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 166; pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index db8deafe896be..578057ce58ed2 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; pub type wchar_t = c_int; pub type nlink_t = c_uint; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 95dacc9f91cbd..c08e12108b918 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -4,9 +4,6 @@ use crate::prelude::*; use crate::{off64_t, off_t, pthread_mutex_t}; pub type blksize_t = i64; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; pub type nlink_t = u64; pub type suseconds_t = i64; pub type wchar_t = i32; @@ -213,7 +210,7 @@ s! { } s_no_extra_traits! { - // FIXME: This is actually a union. + // FIXME(union): This is actually a union. pub struct fpreg_t { pub d: c_double, // f: c_float, @@ -680,9 +677,11 @@ pub const SYS_uname: c_long = 122; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -713,6 +712,7 @@ pub const SYS_sched_get_priority_min: c_long = 160; pub const SYS_sched_rr_get_interval: c_long = 161; pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 167; pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 5626cd3e46933..f77606e10cbf5 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t, pthread_mutex_t}; -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = i8; pub type wchar_t = i32; pub type nlink_t = u32; pub type blksize_t = i64; @@ -711,6 +708,7 @@ pub const SYS_flistxattr: c_long = 180; pub const SYS_removexattr: c_long = 181; pub const SYS_lremovexattr: c_long = 182; pub const SYS_sigpending: c_long = 183; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 184; pub const SYS_setpgid: c_long = 185; pub const SYS_fremovexattr: c_long = 186; @@ -748,8 +746,10 @@ pub const SYS_clone: c_long = 217; pub const SYS_ioprio_get: c_long = 218; pub const SYS_adjtimex: c_long = 219; pub const SYS_sigprocmask: c_long = 220; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 221; pub const SYS_delete_module: c_long = 222; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 223; pub const SYS_getpgid: c_long = 224; pub const SYS_bdflush: c_long = 225; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 0d9971252391b..291d78393fe9d 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = i8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; @@ -309,7 +308,7 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: crate::sigset_t, __private: [u8; 512], - // FIXME: the shadow stack field requires glibc >= 2.28. + // FIXME(linux): the shadow stack field requires glibc >= 2.28. // Re-add once we drop compatibility with glibc versions older than // 2.28. // @@ -358,7 +357,7 @@ cfg_if! { .field("mxcsr", &self.mxcsr) .field("mxcr_mask", &self.mxcr_mask) .field("st_space", &self.st_space) - // FIXME: .field("xmm_space", &self.xmm_space) + // FIXME(debug): .field("xmm_space", &self.xmm_space) // Ignore padding field .finish() } @@ -664,7 +663,7 @@ pub const PR_SPEC_FORCE_DISABLE: c_uint = 1 << 3; pub const PR_SPEC_DISABLE_NOEXEC: c_uint = 1 << 4; pub const PR_SPEC_STORE_BYPASS: c_int = 0; pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1; -// FIXME: perharps for later +// FIXME(linux): perharps for later //pub const PR_SPEC_L1D_FLUSH: c_int = 2; pub const MCL_CURRENT: c_int = 0x0001; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs index 5e7d6e5da5523..27b96a60aabd8 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::pthread_mutex_t; -pub type c_long = i64; -pub type c_ulong = u64; - s! { pub struct statvfs { pub f_bsize: c_ulong, @@ -244,10 +241,13 @@ pub const SYS_sethostname: c_long = 170; pub const SYS_setdomainname: c_long = 171; pub const SYS_iopl: c_long = 172; pub const SYS_ioperm: c_long = 173; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 174; pub const SYS_init_module: c_long = 175; pub const SYS_delete_module: c_long = 176; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 177; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 178; pub const SYS_quotactl: c_long = 179; pub const SYS_nfsservctl: c_long = 180; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs index eafb5246c9edc..1a1cd34be035f 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs @@ -1,9 +1,6 @@ use crate::prelude::*; use crate::pthread_mutex_t; -pub type c_long = i32; -pub type c_ulong = u32; - s! { pub struct statvfs { pub f_bsize: c_ulong, diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 75ac2e088f7d9..48648e2b05a99 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -661,7 +661,7 @@ cfg_if! { .field("ut_line", &self.ut_line) .field("ut_id", &self.ut_id) .field("ut_user", &self.ut_user) - // FIXME: .field("ut_host", &self.ut_host) + // FIXME(debug): .field("ut_host", &self.ut_host) .field("ut_exit", &self.ut_exit) .field("ut_session", &self.ut_session) .field("ut_tv", &self.ut_tv) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7321d37a684c5..63049fe1c5547 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -76,7 +76,7 @@ pub type sctp_assoc_t = __s32; pub type eventfd_t = u64; missing! { #[cfg_attr(feature = "extra_traits", derive(Debug))] - pub enum fpos64_t {} // FIXME: fill this out with a struct + pub enum fpos64_t {} // FIXME(linux): fill this out with a struct } e! { @@ -327,7 +327,21 @@ s! { } pub struct input_event { + // FIXME(1.0): Change to the commented variant, see https://github.com/rust-lang/libc/pull/4148#discussion_r1857511742 + #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] pub time: crate::timeval, + // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] + // pub input_event_sec: time_t, + // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] + // pub input_event_usec: suseconds_t, + // #[cfg(target_arch = "sparc64")] + // _pad1: c_int, + #[cfg(all(target_pointer_width = "32", linux_time_bits64))] + pub input_event_sec: c_ulong, + + #[cfg(all(target_pointer_width = "32", linux_time_bits64))] + pub input_event_usec: c_ulong, + pub type_: __u16, pub code: __u16, pub value: __s32, @@ -1751,7 +1765,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1789,7 +1803,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1815,7 +1829,7 @@ cfg_if! { impl fmt::Debug for pthread_cond_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_cond_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -1837,7 +1851,7 @@ cfg_if! { impl fmt::Debug for pthread_mutex_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_mutex_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -1859,7 +1873,7 @@ cfg_if! { impl fmt::Debug for pthread_rwlock_t { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_rwlock_t") - // FIXME: .field("size", &self.size) + // FIXME(debug): .field("size", &self.size) .finish() } } @@ -2162,18 +2176,6 @@ cfg_if! { } } -cfg_if! { - if #[cfg(all( - any(target_env = "gnu", target_env = "musl", target_env = "ohos"), - any(target_arch = "x86_64", target_arch = "x86") - ))] { - extern "C" { - pub fn iopl(level: c_int) -> c_int; - pub fn ioperm(from: c_ulong, num: c_ulong, turn_on: c_int) -> c_int; - } - } -} - cfg_if! { if #[cfg(any( target_env = "gnu", @@ -4542,6 +4544,9 @@ pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11; pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12; pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13; pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14; +pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15; +pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16; +pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17; pub const SOF_TXTIME_DEADLINE_MODE: u32 = 1 << 0; pub const SOF_TXTIME_REPORT_ERRORS: u32 = 1 << 1; @@ -5256,6 +5261,7 @@ pub const CANFD_MAX_DLEN: usize = 64; pub const CANFD_BRS: c_int = 0x01; pub const CANFD_ESI: c_int = 0x02; +pub const CANFD_FDF: c_int = 0x04; pub const CANXL_MIN_DLC: c_int = 0; pub const CANXL_MAX_DLC: c_int = 2047; @@ -5724,6 +5730,10 @@ pub const EPIOCGPARAMS: Ioctl = 0x80088a02; const _IOC_NRBITS: u32 = 8; const _IOC_TYPEBITS: u32 = 8; +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + // https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code cfg_if! { if #[cfg(any( @@ -6002,6 +6012,18 @@ safe_f! { } } +cfg_if! { + if #[cfg(all( + any(target_env = "gnu", target_env = "musl", target_env = "ohos"), + any(target_arch = "x86_64", target_arch = "x86") + ))] { + extern "C" { + pub fn iopl(level: c_int) -> c_int; + pub fn ioperm(from: c_ulong, num: c_ulong, turn_on: c_int) -> c_int; + } + } +} + cfg_if! { if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] { extern "C" { @@ -6341,8 +6363,6 @@ extern "C" { pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; - pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; - pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; pub fn vhangup() -> c_int; pub fn sync(); pub fn syncfs(fd: c_int) -> c_int; diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 3116837322b60..5829b0270d69c 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = u32; s! { diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 9becabd146f8d..f58eccca4edb3 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = u32; pub type stat64 = crate::stat; @@ -234,7 +233,7 @@ pub const SIGVTALRM: c_int = 26; pub const SIGWINCH: c_int = 28; pub const SIGXCPU: c_int = 24; pub const SIGXFSZ: c_int = 25; -pub const SIG_SETMASK: c_int = 2; // FIXME check these +pub const SIG_SETMASK: c_int = 2; // FIXME(musl) check these pub const SIG_BLOCK: c_int = 0x000000; pub const SIG_UNBLOCK: c_int = 0x01; pub const SOCK_DGRAM: c_int = 2; @@ -287,7 +286,7 @@ pub const SYS_clock_settime: c_int = 112; pub const SYS_clone: c_int = 220; pub const SYS_close: c_int = 57; pub const SYS_connect: c_int = 203; -pub const SYS_copy_file_range: c_int = -1; // FIXME +pub const SYS_copy_file_range: c_int = -1; // FIXME(musl) pub const SYS_creat: c_int = 1064; pub const SYS_delete_module: c_int = 106; pub const SYS_dup2: c_int = 1041; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index aacdc44579496..c9aa5b136dcba 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = c_int; s! { @@ -503,9 +502,11 @@ pub const SYS_modify_ldt: c_long = 4000 + 123; pub const SYS_adjtimex: c_long = 4000 + 124; pub const SYS_mprotect: c_long = 4000 + 125; pub const SYS_sigprocmask: c_long = 4000 + 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 4000 + 127; pub const SYS_init_module: c_long = 4000 + 128; pub const SYS_delete_module: c_long = 4000 + 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 4000 + 130; pub const SYS_quotactl: c_long = 4000 + 131; pub const SYS_getpgid: c_long = 4000 + 132; @@ -561,6 +562,7 @@ pub const SYS_socket: c_long = 4000 + 183; pub const SYS_socketpair: c_long = 4000 + 184; pub const SYS_setresuid: c_long = 4000 + 185; pub const SYS_getresuid: c_long = 4000 + 186; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 4000 + 187; pub const SYS_poll: c_long = 4000 + 188; pub const SYS_nfsservctl: c_long = 4000 + 189; diff --git a/src/unix/linux_like/linux/musl/b32/mod.rs b/src/unix/linux_like/linux/musl/b32/mod.rs index 4a62ef1906ffb..00b3d7705090f 100644 --- a/src/unix/linux_like/linux/musl/b32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mod.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; pub type nlink_t = u32; pub type blksize_t = c_long; pub type __u64 = c_ulonglong; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 29e797959123d..dbd10802e6656 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = i32; s! { @@ -469,9 +468,11 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -508,6 +509,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 166; pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index ff5839c64bc42..291dc7ec644d0 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; pub type wchar_t = c_int; s! { diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 476bacdb6b88d..52fe908802f32 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = i32; s! { @@ -611,9 +610,11 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -651,6 +652,7 @@ pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; pub const SYS_vm86: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 167; pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index c660ec5c3453f..e84b9f563c668 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = u8; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; pub type wchar_t = u32; diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index 1be59ada9aad5..36f05e10e6ea4 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = i8; pub type wchar_t = c_int; pub type nlink_t = c_uint; diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 09191a5f8275c..33afe4e46c0d2 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = i32; pub type __u64 = c_ulong; pub type __s64 = c_long; @@ -241,10 +240,13 @@ pub const SYS_swapoff: c_long = 5000 + 163; pub const SYS_reboot: c_long = 5000 + 164; pub const SYS_sethostname: c_long = 5000 + 165; pub const SYS_setdomainname: c_long = 5000 + 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 5000 + 167; pub const SYS_init_module: c_long = 5000 + 168; pub const SYS_delete_module: c_long = 5000 + 169; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 5000 + 170; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 5000 + 171; pub const SYS_quotactl: c_long = 5000 + 172; pub const SYS_nfsservctl: c_long = 5000 + 173; diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index 50d862f570426..b6e7de6591809 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; pub type regoff_t = c_long; s! { diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 3753293c8e0cf..fb9653bc881a0 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = i32; pub type __u64 = c_ulong; pub type __s64 = c_long; @@ -352,9 +351,11 @@ pub const SYS_modify_ldt: c_long = 123; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -391,6 +392,7 @@ pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; pub const SYS_setresuid: c_long = 164; pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 166; pub const SYS_poll: c_long = 167; pub const SYS_nfsservctl: c_long = 168; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index ec0ba4c1f926f..2b9b394d51d17 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -pub type c_char = u8; pub type wchar_t = c_int; pub type nlink_t = c_uint; diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 22a6cec4185f0..b992a2c4361e4 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -2,7 +2,6 @@ use crate::off_t; use crate::prelude::*; pub type blksize_t = i64; -pub type c_char = u8; pub type nlink_t = u64; pub type wchar_t = i32; pub type greg_t = u64; @@ -64,7 +63,7 @@ s! { } s_no_extra_traits! { - // FIXME: This is actually a union. + // FIXME(union): This is actually a union. pub struct fpreg_t { pub d: c_double, // f: c_float, @@ -434,9 +433,11 @@ pub const SYS_uname: c_long = 122; pub const SYS_adjtimex: c_long = 124; pub const SYS_mprotect: c_long = 125; pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 127; pub const SYS_init_module: c_long = 128; pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 130; pub const SYS_quotactl: c_long = 131; pub const SYS_getpgid: c_long = 132; @@ -468,6 +469,7 @@ pub const SYS_sched_get_priority_min: c_long = 160; pub const SYS_sched_rr_get_interval: c_long = 161; pub const SYS_nanosleep: c_long = 162; pub const SYS_mremap: c_long = 163; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 167; pub const SYS_poll: c_long = 168; pub const SYS_nfsservctl: c_long = 169; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index 6399f33209ac2..b44b54de65953 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -1,7 +1,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = c_long; @@ -206,7 +205,7 @@ cfg_if! { .field("mxcsr", &self.mxcsr) .field("mxcr_mask", &self.mxcr_mask) .field("st_space", &self.st_space) - // FIXME: .field("xmm_space", &self.xmm_space) + // FIXME(debug): .field("xmm_space", &self.xmm_space) // Ignore padding field .finish() } @@ -446,10 +445,13 @@ pub const SYS_sethostname: c_long = 170; pub const SYS_setdomainname: c_long = 171; pub const SYS_iopl: c_long = 172; pub const SYS_ioperm: c_long = 173; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 174; pub const SYS_init_module: c_long = 175; pub const SYS_delete_module: c_long = 176; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 177; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 178; pub const SYS_quotactl: c_long = 179; pub const SYS_nfsservctl: c_long = 180; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 4d31996d9c96e..81ee07483e7b4 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -516,7 +516,7 @@ s_no_extra_traits! { pub __reserved: [c_char; 256], } - // FIXME: musl added paddings and adjusted + // FIXME(musl): musl added paddings and adjusted // layout in 1.2.0 but our CI is still 1.1.24. // So, I'm leaving some fields as cfg for now. // ref. https://github.com/bminor/musl/commit/ @@ -608,7 +608,7 @@ cfg_if! { .field("totalhigh", &self.totalhigh) .field("freehigh", &self.freehigh) .field("mem_unit", &self.mem_unit) - // FIXME: .field("__reserved", &self.__reserved) + // FIXME(debug): .field("__reserved", &self.__reserved) .finish() } } @@ -665,7 +665,7 @@ cfg_if! { .field("ut_line", &self.ut_line) .field("ut_id", &self.ut_id) .field("ut_user", &self.ut_user) - //FIXME: .field("ut_host", &self.ut_host) + //FIXME(debug): .field("ut_host", &self.ut_host) .field("ut_exit", &self.ut_exit) .field("ut_session", &self.ut_session) //.field("__ut_pad2", &self.__ut_pad2) @@ -995,6 +995,8 @@ pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; pub const _CS_V6_ENV: c_int = 1148; pub const _CS_V7_ENV: c_int = 1149; +pub const CLONE_NEWTIME: c_int = 0x80; + cfg_if! { if #[cfg(target_arch = "s390x")] { pub const POSIX_FADV_DONTNEED: c_int = 6; diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index da3203f98a3de..000d9e33a734a 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -1,10 +1,7 @@ use crate::off64_t; use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = c_uint; -pub type c_long = i32; -pub type c_ulong = u32; pub type time_t = c_long; pub type clock_t = c_long; @@ -896,7 +893,7 @@ pub const SYS_pwritev2: c_long = 393; pub const SYS_pkey_mprotect: c_long = 394; pub const SYS_pkey_alloc: c_long = 395; pub const SYS_pkey_free: c_long = 396; -// FIXME: should be a `c_long` too, but a bug slipped in. +// FIXME(linux): should be a `c_long` too, but a bug slipped in. pub const SYS_statx: c_int = 397; pub const SYS_pidfd_send_signal: c_long = 424; pub const SYS_io_uring_setup: c_long = 425; diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index 6118928312b91..783b879cbf8dd 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -1,9 +1,6 @@ use crate::off64_t; use crate::prelude::*; -pub type c_char = i8; -pub type c_long = i32; -pub type c_ulong = u32; pub type clock_t = i32; pub type time_t = i32; pub type suseconds_t = i32; @@ -399,9 +396,11 @@ pub const SYS_modify_ldt: c_long = 4000 + 123; pub const SYS_adjtimex: c_long = 4000 + 124; pub const SYS_mprotect: c_long = 4000 + 125; pub const SYS_sigprocmask: c_long = 4000 + 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_create_module: c_long = 4000 + 127; pub const SYS_init_module: c_long = 4000 + 128; pub const SYS_delete_module: c_long = 4000 + 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_get_kernel_syms: c_long = 4000 + 130; pub const SYS_quotactl: c_long = 4000 + 131; pub const SYS_getpgid: c_long = 4000 + 132; @@ -458,6 +457,7 @@ pub const SYS_socket: c_long = 4000 + 183; pub const SYS_socketpair: c_long = 4000 + 184; pub const SYS_setresuid: c_long = 4000 + 185; pub const SYS_getresuid: c_long = 4000 + 186; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] pub const SYS_query_module: c_long = 4000 + 187; pub const SYS_poll: c_long = 4000 + 188; pub const SYS_nfsservctl: c_long = 4000 + 189; diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index 86ee7bdff472b..2e60f0d03fff9 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; pub type blkcnt_t = i64; pub type blksize_t = i64; -pub type c_char = i8; -pub type c_long = i64; -pub type c_ulong = u64; pub type fsblkcnt_t = c_ulong; pub type fsfilcnt_t = c_ulong; pub type ino_t = u64; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs index 7e1499a1fd8bd..b108e77c7cd32 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -28,7 +28,6 @@ s! { } } -#[cfg(target_os = "l4re")] #[allow(missing_debug_implementations)] pub struct pthread_attr_t { pub __detachstate: c_int, diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 709b0d152444a..684eef20473db 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -6,9 +6,6 @@ use crate::prelude::*; pub type blkcnt_t = i64; pub type blksize_t = i64; pub type clock_t = i64; -pub type c_char = i8; -pub type c_long = i64; -pub type c_ulong = u64; pub type fsblkcnt_t = c_ulong; pub type fsfilcnt_t = c_ulong; pub type fsword_t = c_long; @@ -155,14 +152,14 @@ s! { } pub struct stack_t { - // FIXME + // FIXME(ulibc) pub ss_sp: *mut c_void, pub ss_flags: c_int, pub ss_size: size_t, } pub struct statfs { - // FIXME + // FIXME(ulibc) pub f_type: fsword_t, pub f_bsize: fsword_t, pub f_blocks: crate::fsblkcnt_t, @@ -208,7 +205,7 @@ s! { } pub struct msghdr { - // FIXME + // FIXME(ulibc) pub msg_name: *mut c_void, pub msg_namelen: crate::socklen_t, pub msg_iov: *mut crate::iovec, @@ -219,7 +216,7 @@ s! { } pub struct termios { - // FIXME + // FIXME(ulibc) pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, pub c_cflag: crate::tcflag_t, @@ -229,12 +226,12 @@ s! { } pub struct sigset_t { - // FIXME + // FIXME(ulibc) __val: [c_ulong; 16], } pub struct sysinfo { - // FIXME + // FIXME(ulibc) pub uptime: c_long, pub loads: [c_ulong; 3], pub totalram: c_ulong, @@ -252,7 +249,7 @@ s! { } pub struct glob_t { - // FIXME + // FIXME(ulibc) pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, @@ -265,7 +262,7 @@ s! { } pub struct cpu_set_t { - // FIXME + // FIXME(ulibc) #[cfg(target_pointer_width = "32")] bits: [u32; 32], #[cfg(target_pointer_width = "64")] @@ -273,7 +270,7 @@ s! { } pub struct fsid_t { - // FIXME + // FIXME(ulibc) __val: [c_int; 2], } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index ff8b63a9abaef..c7ff2aea96e79 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -161,7 +161,7 @@ s! { pub ifa_flags: c_uint, pub ifa_addr: *mut crate::sockaddr, pub ifa_netmask: *mut crate::sockaddr, - pub ifa_ifu: *mut crate::sockaddr, // FIXME This should be a union + pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union pub ifa_data: *mut c_void, } @@ -342,7 +342,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("sockaddr_un") .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -371,7 +371,7 @@ cfg_if! { f.debug_struct("sockaddr_storage") .field("ss_family", &self.ss_family) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) + // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) .finish() } } @@ -422,12 +422,12 @@ cfg_if! { impl fmt::Debug for utsname { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) - // FIXME: .field("domainname", &self.domainname) + // FIXME(debug): .field("sysname", &self.sysname) + // FIXME(debug): .field("nodename", &self.nodename) + // FIXME(debug): .field("release", &self.release) + // FIXME(debug): .field("version", &self.version) + // FIXME(debug): .field("machine", &self.machine) + // FIXME(debug): .field("domainname", &self.domainname) .finish() } } @@ -1289,6 +1289,17 @@ pub const PIPE_BUF: usize = 4096; pub const SI_LOAD_SHIFT: c_uint = 16; +// si_code values +pub const SI_USER: c_int = 0; +pub const SI_KERNEL: c_int = 0x80; +pub const SI_QUEUE: c_int = -1; +pub const SI_TIMER: c_int = -2; +pub const SI_MESGQ: c_int = -3; +pub const SI_ASYNCIO: c_int = -4; +pub const SI_SIGIO: c_int = -5; +pub const SI_TKILL: c_int = -6; +pub const SI_ASYNCNL: c_int = -60; + // si_code values for SIGBUS signal pub const BUS_ADRALN: c_int = 1; pub const BUS_ADRERR: c_int = 2; @@ -1297,6 +1308,13 @@ pub const BUS_OBJERR: c_int = 3; pub const BUS_MCEERR_AR: c_int = 4; pub const BUS_MCEERR_AO: c_int = 5; +// si_code values for SIGTRAP +pub const TRAP_BRKPT: c_int = 1; +pub const TRAP_TRACE: c_int = 2; +pub const TRAP_BRANCH: c_int = 3; +pub const TRAP_HWBKPT: c_int = 4; +pub const TRAP_UNK: c_int = 5; + // si_code values for SIGCHLD signal pub const CLD_EXITED: c_int = 1; pub const CLD_KILLED: c_int = 2; @@ -1875,6 +1893,9 @@ extern "C" { pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + + pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; + pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; } // LFS64 extensions diff --git a/src/unix/mod.rs b/src/unix/mod.rs index a14dafdf06d9e..1e70238d19824 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -5,16 +5,6 @@ use crate::prelude::*; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -66,6 +56,7 @@ s! { pub modtime: time_t, } + // FIXME(time): Needs updates at least for glibc _TIME_BITS=64 pub struct timeval { pub tv_sec: time_t, pub tv_usec: suseconds_t, @@ -537,7 +528,7 @@ missing! { #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} #[cfg_attr(feature = "extra_traits", derive(Debug))] - pub enum fpos_t {} // FIXME: fill this out with a struct + pub enum fpos_t {} // FIXME(unix): fill this out with a struct } extern "C" { @@ -1329,11 +1320,11 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + // FIXME(time): for `time_t` pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + // FIXME(time): for `time_t` pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), @@ -1349,19 +1340,19 @@ extern "C" { pub fn time(time: *mut time_t) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + // FIXME(time): for `time_t` pub fn gmtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + // FIXME(time): for `time_t` pub fn localtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + // FIXME(time): for `time_t` pub fn difftime(time1: time_t, time0: time_t) -> c_double; #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` + // FIXME(time): for `time_t` pub fn timegm(tm: *mut crate::tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] @@ -1619,7 +1610,7 @@ cfg_if! { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "readdir_r@FBSD_1.0" )] - #[allow(non_autolinks)] // FIXME: `<>` breaks line length limit. + #[allow(non_autolinks)] // FIXME(docs): `<>` breaks line length limit. /// The 64-bit libc on Solaris and illumos only has readdir_r. If a /// 32-bit Solaris or illumos target is ever created, it should use /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos: diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index 0aa1de7dcc828..e4640580e2478 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -1,12 +1,8 @@ use crate::prelude::*; pub type clock_t = c_long; -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i64; -pub type c_ulong = u64; - s! { pub struct sockaddr { pub sa_len: u8, diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index a32e37ede596a..aea4ed764b03c 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -1,12 +1,8 @@ use crate::prelude::*; pub type clock_t = c_long; -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i32; -pub type c_ulong = u32; - s! { pub struct sockaddr { pub sa_family: crate::sa_family_t, diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 1ac5113c917b5..57a033fcaf263 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -1,12 +1,8 @@ use crate::prelude::*; pub type clock_t = c_ulong; -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i32; -pub type c_ulong = u32; - s! { pub struct cmsghdr { pub cmsg_len: crate::socklen_t, diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index 8c662f2a4517a..e98a4c53ccfff 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -3,10 +3,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = u8; -pub type c_long = i32; -pub type c_ulong = u32; - pub type wchar_t = c_uint; pub type u_register_t = c_uint; diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs index 6a9c42bdb7228..c4d4a2ed07c5e 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -1,12 +1,8 @@ use crate::prelude::*; pub type clock_t = c_ulong; -pub type c_char = u8; pub type wchar_t = c_int; -pub type c_long = i32; -pub type c_ulong = u32; - pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; // the newlib shipped with devkitPPC does not support the following components: diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 1a8c89319fa2d..822b61989d479 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -3,12 +3,8 @@ use crate::prelude::*; pub type clock_t = c_long; -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i32; -pub type c_ulong = u32; - pub type sigset_t = c_ulong; s! { diff --git a/src/unix/nto/aarch64.rs b/src/unix/nto/aarch64.rs index d0987f28be6b2..559ab6e49a45d 100644 --- a/src/unix/nto/aarch64.rs +++ b/src/unix/nto/aarch64.rs @@ -1,9 +1,6 @@ use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i64; -pub type c_ulong = u64; pub type time_t = i64; s! { diff --git a/src/unix/nto/x86_64.rs b/src/unix/nto/x86_64.rs index 425f479949466..521b5d4ab7879 100644 --- a/src/unix/nto/x86_64.rs +++ b/src/unix/nto/x86_64.rs @@ -1,9 +1,6 @@ use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = u32; -pub type c_long = i64; -pub type c_ulong = u64; pub type time_t = i64; s! { diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index ed3e1ed8bfa34..f77b104493670 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -1,4 +1,3 @@ -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; use crate::{in6_addr, in_addr_t, timespec, DIR}; @@ -6,8 +5,6 @@ pub type nlink_t = u16; pub type ino_t = u16; pub type blkcnt_t = u64; pub type blksize_t = i16; -pub type c_long = isize; -pub type c_ulong = usize; pub type cc_t = u8; pub type clock_t = i64; pub type dev_t = i32; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index c557509224437..c453f83efce60 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1,22 +1,7 @@ -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; pub type wchar_t = i32; -cfg_if! { - if #[cfg(target_pointer_width = "32")] { - pub type c_long = i32; - pub type c_ulong = u32; - } -} - -cfg_if! { - if #[cfg(target_pointer_width = "64")] { - pub type c_long = i64; - pub type c_ulong = u64; - } -} - pub type blkcnt_t = c_ulong; pub type blksize_t = c_long; pub type clock_t = c_long; @@ -349,7 +334,7 @@ pub const F_LOCK: c_int = 1; pub const F_TLOCK: c_int = 2; pub const F_TEST: c_int = 3; -// FIXME: relibc { +// FIXME(redox): relibc { pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; // } @@ -505,7 +490,7 @@ pub const F_GETFD: c_int = 1; pub const F_SETFD: c_int = 2; pub const F_GETFL: c_int = 3; pub const F_SETFL: c_int = 4; -// FIXME: relibc { +// FIXME(redox): relibc { pub const F_DUPFD_CLOEXEC: c_int = crate::F_DUPFD; // } pub const FD_CLOEXEC: c_int = 0x0100_0000; @@ -527,7 +512,7 @@ pub const O_DIRECTORY: c_int = 0x1000_0000; pub const O_PATH: c_int = 0x2000_0000; pub const O_SYMLINK: c_int = 0x4000_0000; // Negative to allow it to be used as int -// FIXME: Fix negative values missing from includes +// FIXME(redox): Fix negative values missing from includes pub const O_NOFOLLOW: c_int = -0x8000_0000; // locale.h @@ -568,7 +553,7 @@ pub const NI_NAMEREQD: c_int = 0x0008; pub const NI_DGRAM: c_int = 0x0010; // netinet/in.h -// FIXME: relibc { +// FIXME(redox): relibc { pub const IP_TTL: c_int = 2; pub const IPV6_UNICAST_HOPS: c_int = 16; pub const IPV6_MULTICAST_IF: c_int = 17; @@ -593,7 +578,7 @@ pub const IPPROTO_MAX: c_int = 255; // netinet/tcp.h pub const TCP_NODELAY: c_int = 1; -// FIXME: relibc { +// FIXME(redox): relibc { pub const TCP_KEEPIDLE: c_int = 1; // } @@ -724,7 +709,7 @@ pub const EXIT_SUCCESS: c_int = 0; pub const EXIT_FAILURE: c_int = 1; // sys/ioctl.h -// FIXME: relibc { +// FIXME(redox): relibc { pub const FIONREAD: c_ulong = 0x541B; pub const FIONBIO: c_ulong = 0x5421; pub const FIOCLEX: c_ulong = 0x5451; @@ -1284,7 +1269,7 @@ cfg_if! { .field("d_off", &self.d_off) .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1316,7 +1301,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("sockaddr_un") .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -1347,7 +1332,7 @@ cfg_if! { f.debug_struct("sockaddr_storage") .field("ss_family", &self.ss_family) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_padding", &self.__ss_padding) + // FIXME(debug): .field("__ss_padding", &self.__ss_padding) .finish() } } @@ -1399,12 +1384,12 @@ cfg_if! { impl fmt::Debug for utsname { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) - // FIXME: .field("domainname", &self.domainname) + // FIXME(debug): .field("sysname", &self.sysname) + // FIXME(debug): .field("nodename", &self.nodename) + // FIXME(debug): .field("release", &self.release) + // FIXME(debug): .field("version", &self.version) + // FIXME(debug): .field("machine", &self.machine) + // FIXME(debug): .field("domainname", &self.domainname) .finish() } } diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index a1adae00dcc12..caa3f27b3cb35 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -205,6 +205,8 @@ pub const POSIX_FADV_WILLNEED: c_int = 3; pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const POSIX_SPAWN_SETSID: c_short = 0x40; + pub const SIGINFO: c_int = 41; pub const O_DIRECT: c_int = 0x2000000; @@ -335,6 +337,11 @@ extern "C" { pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; pub fn getpagesizes2(pagesize: *mut size_t, nelem: c_int) -> c_int; + pub fn posix_spawn_file_actions_addfchdir_np( + file_actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int; pub fn syncfs(fd: c_int) -> c_int; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 0f398ca448263..3a335357d6b6b 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1,10 +1,7 @@ use core::mem::size_of; -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; pub type caddr_t = *mut c_char; pub type clockid_t = c_int; @@ -57,6 +54,9 @@ pub type lgrp_lat_between_t = c_uint; pub type lgrp_mem_size_flag_t = c_uint; pub type lgrp_view_t = c_uint; +pub type posix_spawnattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_void; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl Copy for timezone {} @@ -1544,6 +1544,17 @@ pub const POSIX_MADV_SEQUENTIAL: c_int = 2; pub const POSIX_MADV_WILLNEED: c_int = 3; pub const POSIX_MADV_DONTNEED: c_int = 4; +pub const POSIX_SPAWN_RESETIDS: c_short = 0x1; +pub const POSIX_SPAWN_SETPGROUP: c_short = 0x2; +pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x4; +pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x8; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 0x10; +pub const POSIX_SPAWN_SETSCHEDULER: c_short = 0x20; +pub const POSIX_SPAWN_SETSIGIGN_NP: c_short = 0x800; +pub const POSIX_SPAWN_NOSIGCHLD_NP: c_short = 0x1000; +pub const POSIX_SPAWN_WAITPID_NP: c_short = 0x2000; +pub const POSIX_SPAWN_NOEXECERR_NP: c_short = 0x4000; + pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 0x40; pub const PTHREAD_PROCESS_SHARED: c_int = 1; @@ -2689,6 +2700,106 @@ extern "C" { pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(file_actions: *mut posix_spawn_file_actions_t) + -> c_int; + pub fn posix_spawn_file_actions_addopen( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + path: *const c_char, + oflag: c_int, + mode: crate::mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + newfildes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addclosefrom_np( + file_actions: *mut posix_spawn_file_actions_t, + lowfiledes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir( + file_actions: *mut posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir_np( + file_actions: *mut posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir( + file_actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + _pgroup: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, policy: c_int) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + _policy: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + sigdefault: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + sigdefault: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigignore_np( + attr: *mut posix_spawnattr_t, + sigignore: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigignore_np( + attr: *const posix_spawnattr_t, + sigignore: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + sigmask: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + sigmask: *mut sigset_t, + ) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index d080e6ce8d7f6..d0304082dac8b 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -189,6 +189,8 @@ pub const PRIV_TPD_UNSAFE: c_uint = 0x0800; pub const PRIV_PROC_TPD_RESET: c_uint = 0x1000; pub const PRIV_TPD_KILLABLE: c_uint = 0x2000; +pub const POSIX_SPAWN_SETSID: c_short = 0x400; + pub const PRIV_USER: c_uint = PRIV_DEBUG | PRIV_PROC_SENSITIVE | NET_MAC_AWARE diff --git a/src/vxworks/aarch64.rs b/src/vxworks/aarch64.rs index 4032488b6c0d5..376783c8234ba 100644 --- a/src/vxworks/aarch64.rs +++ b/src/vxworks/aarch64.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i64; -pub type c_ulong = u64; diff --git a/src/vxworks/arm.rs b/src/vxworks/arm.rs index 55240068aa08e..376783c8234ba 100644 --- a/src/vxworks/arm.rs +++ b/src/vxworks/arm.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index b8faf16e9aa13..073b5d07ce6fa 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -14,16 +14,6 @@ impl Clone for DIR { } } -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -44,7 +34,7 @@ pub type ino_t = c_ulong; pub type rlim_t = c_ulong; pub type suseconds_t = c_long; -pub type time_t = c_long; +pub type time_t = c_longlong; pub type errno_t = c_int; @@ -562,7 +552,7 @@ pub const EAI_SERVICE: c_int = 9; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; -// FIXME: This is not defined in vxWorks, but we have to define it here +// FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; @@ -725,7 +715,7 @@ pub const S_taskLib_TASK_HOOK_TABLE_FULL: c_int = taskErrorBase + 0x0066; pub const S_taskLib_TASK_HOOK_NOT_FOUND: c_int = taskErrorBase + 0x0067; pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x0068; -// FIXME: could also be useful for TASK_DESC type +// FIXME(vxworks): could also be useful for TASK_DESC type pub const VX_TASK_NAME_LENGTH: c_int = 31; // semLibCommon.h @@ -1066,7 +1056,7 @@ impl Clone for FILE { } } #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos_t {} // FIXME: fill this out with a struct +pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { fn clone(&self) -> fpos_t { diff --git a/src/vxworks/powerpc.rs b/src/vxworks/powerpc.rs index 55240068aa08e..376783c8234ba 100644 --- a/src/vxworks/powerpc.rs +++ b/src/vxworks/powerpc.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/vxworks/powerpc64.rs b/src/vxworks/powerpc64.rs index 4032488b6c0d5..376783c8234ba 100644 --- a/src/vxworks/powerpc64.rs +++ b/src/vxworks/powerpc64.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = u32; -pub type c_long = i64; -pub type c_ulong = u64; diff --git a/src/vxworks/riscv32.rs b/src/vxworks/riscv32.rs index 40a8e338e83a2..f562626f7fb2b 100644 --- a/src/vxworks/riscv32.rs +++ b/src/vxworks/riscv32.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = i32; -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/vxworks/riscv64.rs b/src/vxworks/riscv64.rs index ccd68b0c64f82..f562626f7fb2b 100644 --- a/src/vxworks/riscv64.rs +++ b/src/vxworks/riscv64.rs @@ -1,4 +1 @@ -pub type c_char = u8; pub type wchar_t = i32; -pub type c_long = i64; -pub type c_ulong = u64; diff --git a/src/vxworks/x86.rs b/src/vxworks/x86.rs index e617bb83c6ce3..f562626f7fb2b 100644 --- a/src/vxworks/x86.rs +++ b/src/vxworks/x86.rs @@ -1,4 +1 @@ -pub type c_char = i8; pub type wchar_t = i32; -pub type c_long = i32; -pub type c_ulong = u32; diff --git a/src/vxworks/x86_64.rs b/src/vxworks/x86_64.rs index 5e95ea2567ddf..f562626f7fb2b 100644 --- a/src/vxworks/x86_64.rs +++ b/src/vxworks/x86_64.rs @@ -1,4 +1 @@ -pub type c_char = i8; pub type wchar_t = i32; -pub type c_long = i64; -pub type c_ulong = u64; diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 5919d43b857b8..035ff8958ab20 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -7,17 +7,6 @@ use core::iter::Iterator; use crate::prelude::*; -pub type c_char = i8; -pub type c_uchar = u8; -pub type c_schar = i8; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; pub type size_t = usize; @@ -29,8 +18,6 @@ pub type off_t = i64; pub type pid_t = i32; pub type clock_t = c_longlong; pub type time_t = c_longlong; -pub type c_double = f64; -pub type c_float = f32; pub type ino_t = u64; pub type sigset_t = c_uchar; pub type suseconds_t = c_longlong; @@ -45,6 +32,7 @@ pub type nfds_t = c_ulong; pub type wchar_t = i32; pub type nl_item = c_int; pub type __wasi_rights_t = u64; +pub type locale_t = *mut __locale_struct; s_no_extra_traits! { #[repr(align(16))] @@ -64,8 +52,6 @@ pub enum DIR {} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum __locale_struct {} -pub type locale_t = *mut __locale_struct; - s_paren! { // in wasi-libc clockid_t is const struct __clockid* (where __clockid is an opaque struct), // but that's an implementation detail that we don't want to have to deal with diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 927f01f409785..06cab0e5037a3 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -2,16 +2,6 @@ use crate::prelude::*; -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -22,9 +12,6 @@ pub type uintptr_t = usize; pub type ssize_t = isize; pub type sighandler_t = usize; -pub type c_char = i8; -pub type c_long = i32; -pub type c_ulong = u32; pub type wchar_t = u16; pub type clock_t = i32; @@ -273,7 +260,7 @@ impl Clone for FILE { } } #[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos_t {} // FIXME: fill this out with a struct +pub enum fpos_t {} // FIXME(windows): fill this out with a struct impl Copy for fpos_t {} impl Clone for fpos_t { fn clone(&self) -> fpos_t { diff --git a/src/xous.rs b/src/xous.rs index 4073349306fb9..35350a723c8e9 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -1,15 +1,5 @@ //! Xous C type definitions -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; -pub type c_int = i32; -pub type c_uint = u32; -pub type c_float = f32; -pub type c_double = f64; -pub type c_longlong = i64; -pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -20,9 +10,6 @@ pub type uintptr_t = usize; pub type ssize_t = isize; pub type off_t = i64; -pub type c_char = u8; -pub type c_long = i64; -pub type c_ulong = u64; pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; diff --git a/triagebot.toml b/triagebot.toml index 7a103b8fb72a6..d4ad3459c1fc8 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -177,3 +177,7 @@ cc = ["@semarie"] [mentions."src/unix/solarish"] message = "Some changes occurred in solarish module" cc = ["@jclulow", "@pfmooney"] + +[mentions."src/unix/linux_like/android"] +message = "Some changes occurred in the Android module" +cc = ["@maurer"]