From a72002acbceb97d8d298ffe87357644bf22aa5ad Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 23 Dec 2024 10:43:39 +0000 Subject: [PATCH 01/45] Allow `unpredictable_function_pointer_comparisons` in another place Nightly must have just recently updated how this gets checked, we are getting new errors in CI. Allow the lint in another place. (backport ) (cherry picked from commit 1de1c0afc15d033923fbd8e0037cf2dfc2b6baf7) --- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index a97ead4757b1a..db83835f12c94 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -865,6 +865,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 From 8448147a26b338a9e92afa82bedbdbcc3655daa7 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 18 Dec 2024 10:39:37 +0900 Subject: [PATCH 02/45] Define c_char at top-level and remove per-target c_char definitions (backport ) (cherry picked from commit 0a02b941cf105dc4d4c5b5bd1ddc7bb546ad89c9) --- libc-test/build.rs | 36 +---------- src/fuchsia/aarch64.rs | 1 - src/fuchsia/riscv64.rs | 1 - src/fuchsia/x86_64.rs | 1 - src/hermit.rs | 1 - src/lib.rs | 64 +++++++++---------- src/sgx.rs | 1 - src/solid/aarch64.rs | 1 - src/solid/arm.rs | 1 - src/switch.rs | 1 - src/teeos/mod.rs | 3 - src/trusty.rs | 1 - src/unix/aix/mod.rs | 1 - src/unix/bsd/apple/mod.rs | 1 - src/unix/bsd/freebsdlike/dragonfly/mod.rs | 1 - src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 1 - src/unix/bsd/freebsdlike/freebsd/arm.rs | 1 - src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 1 - src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 1 - src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 1 - src/unix/bsd/freebsdlike/freebsd/x86.rs | 1 - .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 1 - src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 1 - src/unix/bsd/netbsdlike/netbsd/arm.rs | 1 - src/unix/bsd/netbsdlike/netbsd/mips.rs | 1 - src/unix/bsd/netbsdlike/netbsd/powerpc.rs | 1 - src/unix/bsd/netbsdlike/netbsd/riscv64.rs | 1 - src/unix/bsd/netbsdlike/netbsd/sparc64.rs | 1 - src/unix/bsd/netbsdlike/netbsd/x86.rs | 1 - src/unix/bsd/netbsdlike/netbsd/x86_64.rs | 1 - src/unix/bsd/netbsdlike/openbsd/aarch64.rs | 1 - src/unix/bsd/netbsdlike/openbsd/arm.rs | 1 - src/unix/bsd/netbsdlike/openbsd/mips64.rs | 1 - src/unix/bsd/netbsdlike/openbsd/powerpc.rs | 1 - src/unix/bsd/netbsdlike/openbsd/powerpc64.rs | 1 - src/unix/bsd/netbsdlike/openbsd/riscv64.rs | 1 - src/unix/bsd/netbsdlike/openbsd/sparc64.rs | 1 - src/unix/bsd/netbsdlike/openbsd/x86.rs | 1 - src/unix/bsd/netbsdlike/openbsd/x86_64.rs | 1 - src/unix/haiku/mod.rs | 1 - src/unix/hurd/mod.rs | 2 - src/unix/linux_like/android/b32/arm.rs | 1 - src/unix/linux_like/android/b32/x86/mod.rs | 1 - .../linux_like/android/b64/aarch64/mod.rs | 1 - .../linux_like/android/b64/riscv64/mod.rs | 1 - src/unix/linux_like/android/b64/x86_64/mod.rs | 1 - src/unix/linux_like/emscripten/mod.rs | 1 - src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 1 - src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 1 - src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 1 - src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 1 - src/unix/linux_like/linux/gnu/b32/powerpc.rs | 1 - .../linux_like/linux/gnu/b32/riscv32/mod.rs | 1 - .../linux_like/linux/gnu/b32/sparc/mod.rs | 1 - src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 1 - .../linux_like/linux/gnu/b64/aarch64/mod.rs | 1 - .../linux/gnu/b64/loongarch64/mod.rs | 1 - .../linux_like/linux/gnu/b64/mips64/mod.rs | 1 - .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 1 - .../linux_like/linux/gnu/b64/riscv64/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/s390x.rs | 1 - .../linux_like/linux/gnu/b64/sparc64/mod.rs | 1 - .../linux_like/linux/gnu/b64/x86_64/mod.rs | 1 - src/unix/linux_like/linux/musl/b32/arm/mod.rs | 1 - src/unix/linux_like/linux/musl/b32/hexagon.rs | 1 - .../linux_like/linux/musl/b32/mips/mod.rs | 1 - src/unix/linux_like/linux/musl/b32/powerpc.rs | 1 - .../linux_like/linux/musl/b32/riscv32/mod.rs | 1 - src/unix/linux_like/linux/musl/b32/x86/mod.rs | 1 - .../linux_like/linux/musl/b64/aarch64/mod.rs | 1 - .../linux/musl/b64/loongarch64/mod.rs | 1 - src/unix/linux_like/linux/musl/b64/mips64.rs | 1 - .../linux_like/linux/musl/b64/powerpc64.rs | 1 - .../linux_like/linux/musl/b64/riscv64/mod.rs | 1 - src/unix/linux_like/linux/musl/b64/s390x.rs | 1 - .../linux_like/linux/musl/b64/x86_64/mod.rs | 1 - src/unix/linux_like/linux/uclibc/arm/mod.rs | 1 - .../linux/uclibc/mips/mips32/mod.rs | 1 - .../linux/uclibc/mips/mips64/mod.rs | 1 - .../linux_like/linux/uclibc/x86_64/mod.rs | 1 - src/unix/newlib/aarch64/mod.rs | 1 - src/unix/newlib/arm/mod.rs | 1 - src/unix/newlib/espidf/mod.rs | 1 - src/unix/newlib/horizon/mod.rs | 1 - src/unix/newlib/powerpc/mod.rs | 1 - src/unix/newlib/vita/mod.rs | 1 - src/unix/nto/aarch64.rs | 1 - src/unix/nto/x86_64.rs | 1 - src/unix/nuttx/mod.rs | 1 - src/unix/redox/mod.rs | 1 - src/unix/solarish/mod.rs | 1 - src/vxworks/aarch64.rs | 1 - src/vxworks/arm.rs | 1 - src/vxworks/powerpc.rs | 1 - src/vxworks/powerpc64.rs | 1 - src/vxworks/riscv32.rs | 1 - src/vxworks/riscv64.rs | 1 - src/vxworks/x86.rs | 1 - src/vxworks/x86_64.rs | 1 - src/wasi/mod.rs | 1 - src/windows/mod.rs | 1 - src/xous.rs | 1 - 102 files changed, 30 insertions(+), 173 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d35101d4cae39..a82ae56e2e81e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -364,9 +364,6 @@ fn test_apple(target: &str) { // FIXME: "'__uint128' undeclared" in C "__uint128" => true, - // `c_char_def` is always public but not always reexported. - "c_char_def" => true, - _ => false, } }); @@ -766,8 +763,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, }); @@ -985,8 +980,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 +1283,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 +1502,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 +1663,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 +1911,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, } }); @@ -2689,9 +2673,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 +2993,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"), @@ -3286,9 +3264,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 +3430,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 +3777,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 +4006,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" @@ -4759,8 +4729,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 +4964,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/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/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..03947bc01ade5 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -1,6 +1,5 @@ //! Hermit C type definitions -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; pub type c_schar = i8; diff --git a/src/lib.rs b/src/lib.rs index 569775095fa8c..c1cdc7f1bc4eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,41 +41,35 @@ 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! { + // 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", + ) + ))] { + pub type c_char = u8; + } else { + pub type c_char = i8; } } diff --git a/src/sgx.rs b/src/sgx.rs index e37ccd79c3a55..65eded63ad460 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -19,7 +19,6 @@ 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; diff --git a/src/solid/aarch64.rs b/src/solid/aarch64.rs index 4032488b6c0d5..630c7db54b55b 100644 --- a/src/solid/aarch64.rs +++ b/src/solid/aarch64.rs @@ -1,4 +1,3 @@ -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..01fc7262f03e2 100644 --- a/src/solid/arm.rs +++ b/src/solid/arm.rs @@ -1,4 +1,3 @@ -pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i32; pub type c_ulong = u32; diff --git a/src/switch.rs b/src/switch.rs index 4a8b16e15f568..1875ea81ad1ec 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -20,7 +20,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; diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index 40bc0c0549a08..b055d2aca8c7e 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -45,9 +45,6 @@ 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; diff --git a/src/trusty.rs b/src/trusty.rs index 676a456d892fe..db908d5c6d47a 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -1,4 +1,3 @@ -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; pub type size_t = usize; pub type ssize_t = isize; 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/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 db83835f12c94..2897ad377f14d 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; diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 81d3eb351cdb6..0201008e485fb 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -1,6 +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; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 07492c9333d75..1624e655a0f4c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -1,6 +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; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index 0bd678c9821b6..6c8c973d570d1 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -1,6 +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; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index e1548a2fa4a09..a812568b38e7d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -1,6 +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; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index e425411436d2b..212413cbe22af 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -1,6 +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; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 5af53cd76f665..c5a922b455642 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -1,6 +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; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fca9a126f81c1..199ea643fdab4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -1,6 +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; diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index 2391801fe458b..dbac03d2fb2ac 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -3,7 +3,6 @@ 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..698eba93b31a5 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -3,7 +3,6 @@ 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..028deb0cfbf76 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mips.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -3,7 +3,6 @@ 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/powerpc.rs b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs index a086396ed610a..20eba6849a3ee 100644 --- a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -3,7 +3,6 @@ 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..0437b994ca276 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -4,7 +4,6 @@ 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..3cfe535e7edfa 100644 --- a/src/unix/bsd/netbsdlike/netbsd/sparc64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/sparc64.rs @@ -2,7 +2,6 @@ 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..04741f2dc1f4e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -2,7 +2,6 @@ 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..52f3da771a157 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -3,7 +3,6 @@ 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..4cd0b32549835 100644 --- a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -2,7 +2,6 @@ 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..7fd17cf65a55f 100644 --- a/src/unix/bsd/netbsdlike/openbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -2,7 +2,6 @@ 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; diff --git a/src/unix/bsd/netbsdlike/openbsd/mips64.rs b/src/unix/bsd/netbsdlike/openbsd/mips64.rs index 15803ced09a08..17ebae2889f17 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mips64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mips64.rs @@ -1,6 +1,5 @@ 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..7fd17cf65a55f 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -2,7 +2,6 @@ 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; diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs index cb808719fb8ea..1a3b452091ce0 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -2,7 +2,6 @@ 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; diff --git a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs index 6a39f3494dd14..d37e9a67e6888 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -2,7 +2,6 @@ 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..f8e165a7de299 100644 --- a/src/unix/bsd/netbsdlike/openbsd/sparc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/sparc64.rs @@ -1,6 +1,5 @@ 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..cac4ea7f8e94c 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -2,7 +2,6 @@ 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; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs index 4380c1d118922..683046836320d 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -3,7 +3,6 @@ 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/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/mod.rs b/src/unix/hurd/mod.rs index 1a04a725ada56..3a9253fc31f51 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; 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/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index 9f80d8a71f449..a5560e051660a 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; 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/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..ad878462c8c1a 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; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 866a20cd00722..c51935ee99f96 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; 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..2de54f047bbb4 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! { 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..9fd8f819379e5 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! { diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 75ec2385a1230..025ae37002e35 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! { 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..fcd3c52bcee37 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! { 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..84fb3ae31e6c9 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; 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..a4df172b8f5f7 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; 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..e8f045ba5f83b 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -1,7 +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; 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..e1aef3759ddd5 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -2,7 +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; 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..8d79845eb401b 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -5,7 +5,6 @@ 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; 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..3dd9369457353 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -3,7 +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; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 95dacc9f91cbd..d5ab89a86fc3c 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -4,7 +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; 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..b9f9485de1e37 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -5,7 +5,6 @@ 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; 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..a0dbb99ed76d9 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; 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..61174fbd408da 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; 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..56418ededd38e 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! { diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 29e797959123d..de2c5d5e3f724 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! { 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..5b947f38d99f2 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! { 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..0ce7e932a2db4 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; diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 3753293c8e0cf..f85e2748b1848 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; 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..25f49fc15534d 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; 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..b8f659b72392d 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; diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index da3203f98a3de..cbeedb51630f4 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -1,7 +1,6 @@ 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; 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..049b987fcd98a 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -1,7 +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; 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..d0a0f345546b6 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -3,7 +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; 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..8a363d558257f 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -6,7 +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; diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index 0aa1de7dcc828..f0ab09443da22 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; pub type clock_t = c_long; -pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i64; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index a32e37ede596a..ae89440f237db 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; pub type clock_t = c_long; -pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i32; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 1ac5113c917b5..0bb8e3ae9c766 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -1,7 +1,6 @@ use crate::prelude::*; pub type clock_t = c_ulong; -pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i32; diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index 8c662f2a4517a..05a1b284e295d 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -3,7 +3,6 @@ use crate::off_t; use crate::prelude::*; -pub type c_char = u8; pub type c_long = i32; pub type c_ulong = u32; diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs index 6a9c42bdb7228..b53c832a71aed 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -1,7 +1,6 @@ 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; diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 1a8c89319fa2d..1f531cb4d35ff 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; pub type clock_t = c_long; -pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i32; diff --git a/src/unix/nto/aarch64.rs b/src/unix/nto/aarch64.rs index d0987f28be6b2..acc36bbf75363 100644 --- a/src/unix/nto/aarch64.rs +++ b/src/unix/nto/aarch64.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -pub type c_char = u8; pub type wchar_t = u32; pub type c_long = i64; pub type c_ulong = u64; diff --git a/src/unix/nto/x86_64.rs b/src/unix/nto/x86_64.rs index 425f479949466..6cd24e187c443 100644 --- a/src/unix/nto/x86_64.rs +++ b/src/unix/nto/x86_64.rs @@ -1,6 +1,5 @@ use crate::prelude::*; -pub type c_char = i8; pub type wchar_t = u32; pub type c_long = i64; pub type c_ulong = u64; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index ed3e1ed8bfa34..bf6efdd7ae362 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}; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index c557509224437..7b918494c72c8 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1,4 +1,3 @@ -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; pub type wchar_t = i32; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 0f398ca448263..9def117803e52 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1,6 +1,5 @@ use core::mem::size_of; -pub use crate::arch::c_char_def as c_char; use crate::prelude::*; pub type c_long = i64; diff --git a/src/vxworks/aarch64.rs b/src/vxworks/aarch64.rs index 4032488b6c0d5..630c7db54b55b 100644 --- a/src/vxworks/aarch64.rs +++ b/src/vxworks/aarch64.rs @@ -1,4 +1,3 @@ -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..01fc7262f03e2 100644 --- a/src/vxworks/arm.rs +++ b/src/vxworks/arm.rs @@ -1,4 +1,3 @@ -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/powerpc.rs b/src/vxworks/powerpc.rs index 55240068aa08e..01fc7262f03e2 100644 --- a/src/vxworks/powerpc.rs +++ b/src/vxworks/powerpc.rs @@ -1,4 +1,3 @@ -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..630c7db54b55b 100644 --- a/src/vxworks/powerpc64.rs +++ b/src/vxworks/powerpc64.rs @@ -1,4 +1,3 @@ -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..741e312afce17 100644 --- a/src/vxworks/riscv32.rs +++ b/src/vxworks/riscv32.rs @@ -1,4 +1,3 @@ -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..7bacd5c5abec4 100644 --- a/src/vxworks/riscv64.rs +++ b/src/vxworks/riscv64.rs @@ -1,4 +1,3 @@ -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..741e312afce17 100644 --- a/src/vxworks/x86.rs +++ b/src/vxworks/x86.rs @@ -1,4 +1,3 @@ -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..7bacd5c5abec4 100644 --- a/src/vxworks/x86_64.rs +++ b/src/vxworks/x86_64.rs @@ -1,4 +1,3 @@ -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..909b33a20ac77 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -7,7 +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; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 927f01f409785..6e343db53f022 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -22,7 +22,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; diff --git a/src/xous.rs b/src/xous.rs index 4073349306fb9..468865c8d4131 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -20,7 +20,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; From 315dd4cee0614a90757f8770fa58f8a83be1e42e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 19 Dec 2024 08:20:27 +0000 Subject: [PATCH 03/45] Remove the `c_char_def` workaround for OpenBSD The exception was added after the PR with 0a02b941cf ("Define c_char at top-level...") was posted. Remove this skip since the same commit makes it no longer relevant. (backport ) (cherry picked from commit 2bb023e81743c5319226b749179c7d5aeff4cfa3) --- libc-test/build.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index a82ae56e2e81e..d023c466a3915 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -644,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 From 37ac889cbe63771e921ddb33b0c708e551c6c077 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 19 Dec 2024 09:01:31 +0000 Subject: [PATCH 04/45] Remove `c_char` from the PSP module ef8c0f31b1 ("Define c_char at top-level...") removes the need for per-OS definitions of `c_char`. Remove the definition of `c_char` from PEP, which as not covered in the backport (as this module does not exist on `main`). Suggested-by: Taiki Endo --- src/psp.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/psp.rs b/src/psp.rs index e1bf285967ede..ed9d4f4d5b415 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -25,7 +25,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; From 6f676aa063c5ac045a383743008c7829deb4f8af Mon Sep 17 00:00:00 2001 From: fpagliughi Date: Fri, 27 Dec 2024 14:05:38 -0500 Subject: [PATCH 05/45] Added new CANFD_FDF flag for the flags field of canfd_frame. (backport ) (cherry picked from commit 1012c5182c905715ad8afca24970aca31a175046) --- src/unix/linux_like/linux/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7321d37a684c5..bf9888537f5f9 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -5256,6 +5256,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; From df4528bb23e3e9ebe4f2d435f5499bc62153afb6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 3 Jan 2025 20:31:21 +0000 Subject: [PATCH 06/45] Add a triagebot ping for changes to Android (backport ) (cherry picked from commit 17ebba3f95bd673ff1e63c80035576329118b98d) --- triagebot.toml | 4 ++++ 1 file changed, 4 insertions(+) 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"] From 09e24d3ae26c3d939cea119c149eccdf6547a11b Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 18 Dec 2024 09:33:55 -0800 Subject: [PATCH 07/45] Declare `setdomainname` and `getdomainname` on Android. Android [supports] `setdomainname` and `getdomainname` in API level 26. [supports] https://github.com/aosp-google/bionic/blob/28f9101d76b709febe25977f98530d77580387d1/libc/include/unistd.h#L236 (backport ) (cherry picked from commit 7e1b5b840bac1df400aa85e2f51daad3aacfd052) --- libc-test/build.rs | 3 +++ libc-test/semver/android.txt | 2 ++ src/unix/linux_like/android/mod.rs | 3 +++ 3 files changed, 8 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index d023c466a3915..5c5fd96df21c0 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2140,6 +2140,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" diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 06a28efaac820..f8c136dd70e10 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3324,6 +3324,7 @@ getaddrinfo getchar getchar_unlocked getcwd +getdomainname getegid getenv geteuid @@ -3720,6 +3721,7 @@ sendmsg sendto servent setbuf +setdomainname setegid setenv seteuid diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index f408969175d34..f50547a2c3961 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -4126,6 +4126,9 @@ extern "C" { newpath: *const c_char, flags: c_uint, ) -> 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; } cfg_if! { From 91d0a1d96b37d5cdac251959418d03d8249de937 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 2 Jan 2025 16:47:30 -0800 Subject: [PATCH 08/45] Move `setdomainname` and `getdomainname` into linux_like. (backport ) (cherry picked from commit b0d8e18801b0b8ed77cdf39fa0b58f8c0c9cef94) --- src/unix/linux_like/android/mod.rs | 3 --- src/unix/linux_like/emscripten/mod.rs | 2 -- src/unix/linux_like/linux/mod.rs | 2 -- src/unix/linux_like/mod.rs | 3 +++ 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index f50547a2c3961..f408969175d34 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -4126,9 +4126,6 @@ extern "C" { newpath: *const c_char, flags: c_uint, ) -> 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; } cfg_if! { diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index c51935ee99f96..598983fb47c59 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1574,8 +1574,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/mod.rs b/src/unix/linux_like/linux/mod.rs index bf9888537f5f9..d7d54cb510bd8 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -6342,8 +6342,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/mod.rs b/src/unix/linux_like/mod.rs index ff8b63a9abaef..2df104eaccab8 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1875,6 +1875,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 From 4f1c07bcc68486a8b92b09b738d267e57e217f83 Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Sun, 5 Jan 2025 19:50:42 +0000 Subject: [PATCH 09/45] Chore: add labels to each FIXME (backport ) (cherry picked from commit 6b8535b3703e8ccc3d044095de38fa222c5a083f) --- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b64/s390x.rs | 2 +- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 6 +++--- src/unix/linux_like/linux/gnu/mod.rs | 2 +- src/unix/linux_like/linux/mod.rs | 12 ++++++------ src/unix/linux_like/linux/musl/b32/hexagon.rs | 4 ++-- src/unix/linux_like/linux/musl/b64/s390x.rs | 2 +- .../linux_like/linux/musl/b64/x86_64/mod.rs | 2 +- src/unix/linux_like/linux/musl/mod.rs | 6 +++--- src/unix/linux_like/linux/uclibc/arm/mod.rs | 2 +- src/unix/linux_like/linux/uclibc/x86_64/mod.rs | 18 +++++++++--------- src/windows/mod.rs | 2 +- 12 files changed, 30 insertions(+), 30 deletions(-) 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 a4df172b8f5f7..0e990f6006378 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -601,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/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index d5ab89a86fc3c..386d464295091 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -212,7 +212,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, 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 a0dbb99ed76d9..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 @@ -308,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. // @@ -357,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() } @@ -663,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/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 d7d54cb510bd8..0439493375949 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! { @@ -1751,7 +1751,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 +1789,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 +1815,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 +1837,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 +1859,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() } } diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 61174fbd408da..f58eccca4edb3 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -233,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; @@ -286,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/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 25f49fc15534d..cb3ec41be7f93 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -63,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, 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 b8f659b72392d..ac62582d08b61 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 @@ -205,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() } diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 4d31996d9c96e..7105461a9f93d 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) diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index cbeedb51630f4..c237b7e160bbf 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -895,7 +895,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/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 8a363d558257f..016b6580c5754 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -154,14 +154,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, @@ -207,7 +207,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, @@ -218,7 +218,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, @@ -228,12 +228,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, @@ -251,7 +251,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, @@ -264,7 +264,7 @@ s! { } pub struct cpu_set_t { - // FIXME + // FIXME(ulibc) #[cfg(target_pointer_width = "32")] bits: [u32; 32], #[cfg(target_pointer_width = "64")] @@ -272,7 +272,7 @@ s! { } pub struct fsid_t { - // FIXME + // FIXME(ulibc) __val: [c_int; 2], } diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 6e343db53f022..632c33f461493 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -272,7 +272,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 { From 49178977b749aa28f2e2fb9f65aba69059a78f81 Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:43:15 +0000 Subject: [PATCH 10/45] chore: add labels to FIXMEs (backport ) (cherry picked from commit 174a37cf6aecc87b8fab65152f10396b8101b878) --- src/unix/hurd/mod.rs | 6 ++-- src/unix/linux_like/android/b32/x86/mod.rs | 6 ++-- src/unix/linux_like/android/b64/mod.rs | 6 ++-- src/unix/linux_like/android/b64/x86_64/mod.rs | 4 +-- src/unix/linux_like/android/mod.rs | 8 ++--- src/unix/linux_like/emscripten/mod.rs | 8 ++--- src/unix/linux_like/mod.rs | 18 +++++------ src/unix/mod.rs | 16 +++++----- src/unix/redox/mod.rs | 30 +++++++++---------- 9 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 3a9253fc31f51..bb5339d0a48bd 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -226,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 { @@ -814,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, } @@ -1092,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) diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index a5560e051660a..caa4802d8a399 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -281,11 +281,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; @@ -294,7 +294,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; diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index ffa79ead870e8..0da702b45d18e 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -161,7 +161,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 +190,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 +227,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/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index ad878462c8c1a..d9f9fa50e0459 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -353,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() } @@ -545,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; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index f408969175d34..b12120bb564d4 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) diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 598983fb47c59..94b3776606a41 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -44,7 +44,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 { @@ -412,7 +412,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() } } @@ -465,7 +465,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() } } @@ -525,7 +525,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() } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 2df104eaccab8..5b6325e8ca822 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() } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index a14dafdf06d9e..8a0aa3266759b 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -537,7 +537,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 +1329,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 +1349,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 +1619,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/redox/mod.rs b/src/unix/redox/mod.rs index 7b918494c72c8..2f13157fff64a 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -348,7 +348,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; // } @@ -504,7 +504,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; @@ -526,7 +526,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 @@ -567,7 +567,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; @@ -592,7 +592,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; // } @@ -723,7 +723,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; @@ -1283,7 +1283,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() } } @@ -1315,7 +1315,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() } } @@ -1346,7 +1346,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() } } @@ -1398,12 +1398,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() } } From ab5bbaeff994aff92d5f1ea1df8dfb74f439f140 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 5 Jan 2025 20:05:24 +0000 Subject: [PATCH 11/45] linux/android proposal to deprecate kernel modules syscalls. they were functional up 2.6. [create_module](https://man7.org/linux/man-pages/man2/create_module.2.html) [query_module](https://man7.org/linux/man-pages/man2/query_module.2.html) [get_kernel_syms](https://man7.org/linux/man-pages/man2/get_kernel_syms.2.html) (backport ) (cherry picked from commit e84fc948d7f1f7f1a5f6c9631379f5febc2e37e3) --- src/unix/linux_like/android/b32/x86/mod.rs | 3 +++ src/unix/linux_like/android/b64/x86_64/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b32/powerpc.rs | 3 +++ src/unix/linux_like/linux/gnu/b32/sparc/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b64/mips64/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b64/s390x.rs | 3 +++ src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs | 3 +++ src/unix/linux_like/linux/musl/b32/mips/mod.rs | 3 +++ src/unix/linux_like/linux/musl/b32/powerpc.rs | 3 +++ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 3 +++ src/unix/linux_like/linux/musl/b64/mips64.rs | 3 +++ src/unix/linux_like/linux/musl/b64/powerpc64.rs | 3 +++ src/unix/linux_like/linux/musl/b64/s390x.rs | 3 +++ src/unix/linux_like/linux/musl/b64/x86_64/mod.rs | 3 +++ src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs | 3 +++ 20 files changed, 60 insertions(+) diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index caa4802d8a399..2acbe7712eb77 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -268,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; @@ -314,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/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index d9f9fa50e0459..ce2d70999856a 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -565,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/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index 2de54f047bbb4..d8b047ab446ab 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -548,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; @@ -587,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 9fd8f819379e5..b15df99e50ec6 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -289,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; @@ -348,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/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 025ae37002e35..d15012c4ec68c 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -555,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; @@ -594,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/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index fcd3c52bcee37..de00e9915826a 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -617,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; @@ -654,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 84fb3ae31e6c9..bb2e3ccbf8925 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -771,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; @@ -811,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/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index e1aef3759ddd5..1d13bdb945d6e 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -411,10 +411,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 8d79845eb401b..3eda86440d40c 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -698,9 +698,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; @@ -737,6 +739,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/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 386d464295091..7a48de58c967b 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -679,9 +679,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; @@ -712,6 +714,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 b9f9485de1e37..829686ff16ee5 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -710,6 +710,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; @@ -747,8 +748,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/not_x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs index 5e7d6e5da5523..eb9563e53e2c0 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 @@ -244,10 +244,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/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 56418ededd38e..c9aa5b136dcba 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -502,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; @@ -560,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/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index de2c5d5e3f724..dbd10802e6656 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -468,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; @@ -507,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/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 5b947f38d99f2..52fe908802f32 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -610,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; @@ -650,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/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 0ce7e932a2db4..33afe4e46c0d2 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -240,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/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index f85e2748b1848..fb9653bc881a0 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -351,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; @@ -390,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/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index cb3ec41be7f93..b992a2c4361e4 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -433,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; @@ -467,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 ac62582d08b61..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 @@ -445,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/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index 049b987fcd98a..a78daea80b62c 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -398,9 +398,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; @@ -457,6 +459,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; From fea6f1389840fe1597de72f036198653d06be57c Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Fri, 3 Jan 2025 13:25:58 +0800 Subject: [PATCH 12/45] add CLONE_NEWTIME to Linux/musl (backport ) (cherry picked from commit d05754dd39fc1854ca999918c7c6ba3184434227) (cherry picked from commit e5a8390276ba1ddecc3ec244a4c22e5d67979a79) [ squashed two commits for the backport - Trevor ] --- libc-test/semver/linux-musl.txt | 1 + src/unix/linux_like/linux/musl/mod.rs | 2 ++ 2 files changed, 3 insertions(+) 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/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 7105461a9f93d..81ee07483e7b4 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -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; From ba11cc0d4532e72356c3596ed28d38fb01b125b7 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Jan 2025 07:03:08 +0000 Subject: [PATCH 13/45] Fix the `missing_abi` lint Recent versions of Rust require the ABI always be specified for `extern` functions, whereas it historically defaulted to `extern "C"`. Fix a few cases where this lint now gets raised by specifying `extern "C"`. (backport ) (cherry picked from commit c9a71dc2d31b73c00091a4082c1e989cee79f792) --- src/macros.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 )*) } From 70eb0a04ecf2c22b3c03617985070ee2c91fad30 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 5 Feb 2025 07:57:14 +0000 Subject: [PATCH 14/45] Disable `RUST_BACKTRACE` for FreeBSD CI Having this environment variable set causes a segfault [1]. Just disable backtraces for now. [1]: https://github.com/rust-lang/rust/issues/132185 (backport ) (cherry picked from commit 8d8a199f29aadddf89e42c689f0d7a8ef3711c20) --- .cirrus.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index 656696c825752..7968772921d40 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,6 +3,9 @@ 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. From e04c86e3148295fa706236ef6b5fd76b41ac8d2a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 5 Feb 2025 08:09:26 +0000 Subject: [PATCH 15/45] FreeBSD: Add the new `st_filerev` field to `stat32` for FreeBSD 15 This field appears to have been added recently [1]. [1]: https://github.com/freebsd/freebsd-src/commit/b4663a8d111767206bb3ebcfec5b95a6b88bc720 (backport ) (cherry picked from commit f691a1a52fd6df5c6a58b526ff568d4a17049212) --- src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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], } } From 7cbbfedb9a0ca60252308c2dfa97510077d34606 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 5 Feb 2025 10:09:46 +0000 Subject: [PATCH 16/45] Temporarily disable `powerpc-unknown-linux-gnu` tests As mentioned in [1], this test has started to fail for unclear reasons. Disable this until it can be investigated further. [1]: https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 (backport ) (cherry picked from commit eb7045bd7e9744a980389fdbf95cc50880e67796) --- .github/workflows/ci.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From 42cd7e1a634960b02d290abb1978f5391a142ea0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 12 Feb 2025 19:34:17 +0000 Subject: [PATCH 17/45] Bump FreeBSD CI to 13.4 and 14.2 13.3 is marked EOL and 14.1 is marked legacy. Update these runners to the latest version. This should resolve some current CI failures. (backport ) (cherry picked from commit 40a6c7f95f61c3b9b97acf34740b8036e6f392f8) --- .cirrus.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 7968772921d40..7985cb854bbe3 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -12,13 +12,13 @@ task: 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 From 7f86bf8d863622032b83e1514b9ffaa7b3497fcc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 12 Jan 2025 16:44:26 +0100 Subject: [PATCH 18/45] hurd: Fix CMSG_DATA on 64bit systems This was fixed upstream glibc in https://sourceware.org/git/?p=glibc.git;a=patch;h=cf13f740a91b5bbf6bb60a30b45c2a3933ff1259 (backport ) (cherry picked from commit 3659a6d7de022d90fa20bbb67c10d4624d65a685) --- src/unix/hurd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index bb5339d0a48bd..0c5f001202844 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3449,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 { From 8e728d7474f3448dfb69d9fae3ae914d75512f6c Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:40:08 +0000 Subject: [PATCH 19/45] chore: add labels for FIXMEs in repo (backport ) (cherry picked from commit 6c6674e2954c1189926f3c8112372263f8e6b730) --- libc-test/build.rs | 38 +++++++++++++++++++------------------- src/fuchsia/mod.rs | 36 ++++++++++++++++++------------------ src/lib.rs | 2 +- src/vxworks/mod.rs | 6 +++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 5c5fd96df21c0..c5c7becebe718 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,10 +358,10 @@ 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, _ => false, @@ -377,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" @@ -402,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" @@ -429,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. @@ -447,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, } @@ -481,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(), @@ -490,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, @@ -597,7 +597,7 @@ fn test_openbsd(target: &str) { return true; } match ty { - // FIXME: actually a union + // FIXME(union): actually a union "sigval" => true, _ => false, diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 8e56e3f62928d..f0559db9bee55 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -91,7 +91,7 @@ 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 +111,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 +144,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 +478,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 +1097,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 +1135,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 +1163,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 +1207,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 +1246,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 +1281,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 +1390,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 +1409,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 +1428,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 +3562,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/lib.rs b/src/lib.rs index c1cdc7f1bc4eb..060c4c1b39cdd 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, diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index b8faf16e9aa13..e7ec43ab5e430 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -562,7 +562,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 +725,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 +1066,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 { From 608f947befc9a1194c0bcf03dca378abe4ab746c Mon Sep 17 00:00:00 2001 From: xd009642 Date: Thu, 6 Feb 2025 16:13:48 +0900 Subject: [PATCH 20/45] Adds in SI and TRAP signal codes Impacts linux and android adding in (when applicable): * SI_ASYNCIO * SI_ASYNCNL * SI_DETHREAD * SI_KERNEL * SI_MESGQ * SI_QUEUE * SI_SIGIO * SI_TIMER * SI_TKILL * SI_USER And also: * TRAP_BRANCH * TRAP_BRKPT * TRAP_HWBKPT * TRAP_PERF * TRAP_TRACE * TRAP_UNK (backport ) (cherry picked from commit a34697a1fde98a4898d88217144d2e68cecce57c) --- libc-test/build.rs | 6 ++++++ libc-test/semver/linux.txt | 16 ++++++++++++++++ src/unix/linux_like/android/mod.rs | 4 ++++ src/unix/linux_like/linux/mod.rs | 4 ++++ src/unix/linux_like/mod.rs | 18 ++++++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c5c7becebe718..447462569a55b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3065,6 +3065,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, @@ -4130,6 +4133,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" diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 175e2811e9649..d2193b870516f 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 @@ -3359,6 +3369,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/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index b12120bb564d4..0e1b05aa5cf72 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3568,6 +3568,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/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 0439493375949..88d39c6316a40 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -5725,6 +5725,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( diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 5b6325e8ca822..c7ff2aea96e79 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -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; From e7a9c4a7bb28339f57ac519f8449394d79a0910a Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 14 Jan 2025 10:40:10 +0100 Subject: [PATCH 21/45] emscripten: Assume version is at least 3.1.42 This revises commit 63b0d673eaf2a177ff208c5c50999738bdd1bf0d to assume that Emscripten 3.1.42 or later is being used whenever `emcc` is not available. Since Emscripten 3.1.42 was released on June 23, 2023, the majority of users are expected to have upgraded to a more recent version. Resolves: https://github.com/rust-lang/rust/issues/131467. (backport ) (cherry picked from commit b511f66635f8d8060c5b4ed0eb605ac8973005c5) --- build.rs | 8 ++++---- src/unix/linux_like/emscripten/mod.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index 90fbc0d7c5fda..5f401f9f1072e 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", @@ -74,9 +74,9 @@ 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. + _ => (), } // On CI: deny all warnings diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 94b3776606a41..c1c5108c17eb4 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -227,16 +227,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, From 5e6b350a0daa450e1e6b580f8f59169879bc722d Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Mon, 27 Jan 2025 10:25:23 +0100 Subject: [PATCH 22/45] emscripten: Fix broken link (backport ) (cherry picked from commit 99515f2058400fbd07156f3b5907b9285c5b5f7a) --- ci/emscripten.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 81c931f950d48e72da8cbdd75e2bae6f7b9f9bb9 Mon Sep 17 00:00:00 2001 From: Mohamed Attia Date: Thu, 13 Feb 2025 23:58:08 +0100 Subject: [PATCH 23/45] Fix reference to build file with guaranteed build platforms. (backport ) (cherry picked from commit 728a5e2ba3ae519347145d206e8aff2de5c8751a) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From e943c9823fa5012a42b2dfd6510dbaa982492256 Mon Sep 17 00:00:00 2001 From: Rain Date: Tue, 11 Feb 2025 23:22:09 +0000 Subject: [PATCH 24/45] [solarish/illumos] add the posix_spawn family of functions Add definitions from `spawn.h` as present [in illumos-gate (blame view)][spawn-h]. I added definitions more than 15 years old to `solarish/mod.rs`, and others to `solarish/illumos.rs`. There are a lot of definitions here -- it's easiest to look at them in the blame view linked above. But here are the corresponding man pages: For solarish: * [`posix_spawn`, `posix_spawnp`](https://illumos.org/man/3C/posix_spawn) * [`posix_spawn_file_actions_{init,destroy}`](https://illumos.org/man/3C/posix_spawn_file_actions_init) * [`posix_spawn_file_actions_{addopen,addclose}`](https://illumos.org/man/3C/posix_spawn_file_actions_addopen) * [`posix_spawn_file_actions_adddup2`](https://illumos.org/man/3C/posix_spawn_file_actions_adddup2) * [`posix_spawn_file_actions_addclosefrom_np`](https://illumos.org/man/3C/posix_spawn_file_actions_addclosefrom_np) * [`posix_spawnattr_{init,destroy}`](https://illumos.org/man/3C/posix_spawnattr_init) * [`posix_spawnattr_{setflags,getflags}`](https://illumos.org/man/3C/posix_spawnattr_setflags) * [`posix_spawnattr_{setpgroup,getpgroup}`](https://illumos.org/man/3C/posix_spawnattr_setpgroup) * [`posix_spawnattr_{setschedparam,getschedparam}`](https://illumos.org/man/3C/posix_spawnattr_setschedparam) * [`posix_spawnattr_{setschedpolicy,getschedpolicy}`](https://illumos.org/man/3C/posix_spawnattr_setschedpolicy) * [`posix_spawnattr_{setsigdefault,getsigdefault}`](https://illumos.org/man/3C/posix_spawnattr_setsigdefault) * [`posix_spawnattr_{setsigignore,getsigignore}_np`](https://illumos.org/man/3C/posix_spawnattr_setsigignore_np) * [`posix_spawnattr_{setsigmask,getsigmask}`](https://illumos.org/man/3C/posix_spawnattr_setsigmask) Newer functions added independently to Solaris and illumos: * [`posix_spawn_file_actions_{addchdir,addchdir_np,addfchdir}` on Solaris](https://docs.oracle.com/cd/E88353_01/html/E37843/posix-spawn-file-actions-addchdir-np-3c.html) * The illumos-only functions are quite recent so the man pages haven't been uploaded to illumos.org yet. But [here's the one for `addchdir` and `addfchdir`](https://github.com/illumos/illumos-gate/blob/7633a05bff8c639f2df722d1fba7b889b2763d3d/usr/src/man/man3c/posix_spawn_file_actions_addchdir.3c). Note that the `_np` functions are not documented in the manual, but they are available for compatibility. The one function I skipped over was [`posix_spawn_pipe_np`](https://illumos.org/man/3C/posix_spawn_pipe_np) -- it seemed a bit niche and I wasn't quite sure how to model `boolean_t`. [spawn-h]: https://github.com/illumos/illumos-gate/blame/7633a05bff8c639f2df722d1fba7b889b2763d3d/usr/src/head/spawn.h#L1 (backport ) (cherry picked from commit 162e3064659bbcfa857e606f47cbe90874cb6001) --- libc-test/build.rs | 1 + libc-test/semver/illumos.txt | 2 + libc-test/semver/solarish.txt | 37 +++++++++++ src/unix/solarish/illumos.rs | 7 +++ src/unix/solarish/mod.rs | 114 ++++++++++++++++++++++++++++++++++ src/unix/solarish/solaris.rs | 2 + 6 files changed, 163 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 447462569a55b..eb41e2eaa7ac8 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -915,6 +915,7 @@ fn test_solarish(target: &str) { "sched.h", "semaphore.h", "signal.h", + "spawn.h", "stddef.h", "stdint.h", "stdio.h", 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/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/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 9def117803e52..25913377e4a17 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -56,6 +56,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 {} @@ -1543,6 +1546,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; @@ -2688,6 +2702,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 From 5553e180f295460a9aa6284fbef7b5321742be7b Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Fri, 14 Feb 2025 11:34:50 +0100 Subject: [PATCH 25/45] NetBSD: fix getmntinfo for NetBSD (backport ) (cherry picked from commit e1e9d97c1340e037469fb2dc3ae1d3a309b1c9c7) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 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; } From 50fb36c599043b0c0f3c11b3fabf0ba35618894c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 18 Feb 2025 07:55:15 +0000 Subject: [PATCH 26/45] Re-add the test for `primitive_types` This was added in d4da6c866a ("Move testing of primitive types from std"), with cherry pick 69ce8953a4. However, I accidentally reverted this part of the patch in 65c90726e2 ("added wireless struct and constants to Linux"), the cherry pick for 1ee94df243. Add this back here. --- libc-test/Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 007663f69c424..725d2f3247593 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -88,3 +88,8 @@ harness = true name = "semver" path = "test/semver.rs" harness = false + +[[test]] +name = "primitive_types" +path = "test/primitive_types.rs" +harness = true From 48bd1a0f0b2b77f5db1ff4fa3b898e5f1d957823 Mon Sep 17 00:00:00 2001 From: Ryan Mehri Date: Fri, 10 Jan 2025 19:01:24 -0800 Subject: [PATCH 27/45] port style.rs to syn and add tests for the style checker (backport ) (cherry picked from commit 56e82108afa1e54a4bb1996251d3d79016a092e0) --- .gitignore | 1 - libc-test/Cargo.toml | 16 ++ libc-test/test/check_style.rs | 50 ++++ libc-test/test/style/mod.rs | 490 ++++++++++++++++++++++++++++++++++ libc-test/test/style_tests.rs | 260 ++++++++++++++++++ 5 files changed, 816 insertions(+), 1 deletion(-) create mode 100644 libc-test/test/check_style.rs create mode 100644 libc-test/test/style/mod.rs create mode 100644 libc-test/test/style_tests.rs 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/libc-test/Cargo.toml b/libc-test/Cargo.toml index 725d2f3247593..f0f4c22346753 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -17,6 +17,12 @@ path = ".." version = "0.2.169" 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. @@ -93,3 +99,13 @@ harness = false 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/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()); +} From 80dcbb0916d5638f633b6707d95d6ed6666e71c0 Mon Sep 17 00:00:00 2001 From: Ryan Mehri Date: Fri, 10 Jan 2025 19:02:21 -0800 Subject: [PATCH 28/45] update style script and ci to run new style checker (backport ) (cherry picked from commit bd1b83864184b0587d666bb1b3f1b563a487bde2) --- ci/run.sh | 19 ++-- ci/runtest-android.rs | 20 ++-- ci/style.rs | 213 ------------------------------------------ ci/style.sh | 2 +- 4 files changed, 25 insertions(+), 229 deletions(-) delete mode 100644 ci/style.rs 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 From b2823f33ca599096eee3189269783df038b8d71d Mon Sep 17 00:00:00 2001 From: Ryan Mehri Date: Fri, 10 Jan 2025 19:02:42 -0800 Subject: [PATCH 29/45] fix some lints that were detected by the new style checker (backport ) (cherry picked from commit 94c2b1424af9b69e7dd15b4f3de0f5af3427433d) --- src/teeos/mod.rs | 6 ++--- src/unix/linux_like/linux/mod.rs | 24 +++++++++---------- .../linux_like/linux/uclibc/x86_64/l4re.rs | 1 - src/wasi/mod.rs | 3 +-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index b055d2aca8c7e..1ec2706cfdf76 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -51,9 +51,6 @@ 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). @@ -88,6 +85,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/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 88d39c6316a40..c2fa6392fa500 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2162,18 +2162,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", @@ -6007,6 +5995,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" { 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/wasi/mod.rs b/src/wasi/mod.rs index 909b33a20ac77..f2b774ea51549 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -44,6 +44,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))] @@ -63,8 +64,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 From e2f9290974aa042a281628a83125f958f379fb0c Mon Sep 17 00:00:00 2001 From: Aphek Date: Tue, 4 Feb 2025 20:44:28 -0300 Subject: [PATCH 30/45] Copy definitions from core::ffi and centralize them (backport ) (cherry picked from commit 95446f458e472511d65e560224c1b85570e50944) [ include the necessary changes for psp, which isn't part of the original commit since the target is not present on main - Trevor ] --- src/fuchsia/mod.rs | 13 --- src/hermit.rs | 13 --- src/lib.rs | 84 ++++++------------- src/{fixed_width_ints.rs => primitives.rs} | 65 +++++++++++++- src/psp.rs | 13 --- src/sgx.rs | 13 --- src/solid/aarch64.rs | 2 - src/solid/arm.rs | 2 - src/solid/mod.rs | 10 --- src/switch.rs | 12 --- src/teeos/mod.rs | 24 ------ src/trusty.rs | 23 ----- src/unix/aix/powerpc64.rs | 3 - src/unix/bsd/apple/b32/mod.rs | 2 - src/unix/bsd/apple/b64/mod.rs | 3 - src/unix/bsd/freebsdlike/dragonfly/mod.rs | 2 - src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 2 - src/unix/bsd/freebsdlike/freebsd/arm.rs | 2 - src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 2 - src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 2 - src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 2 - src/unix/bsd/freebsdlike/freebsd/x86.rs | 2 - .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 2 - src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 2 - src/unix/bsd/netbsdlike/netbsd/arm.rs | 2 - src/unix/bsd/netbsdlike/netbsd/mips.rs | 2 - src/unix/bsd/netbsdlike/netbsd/powerpc.rs | 2 - src/unix/bsd/netbsdlike/netbsd/riscv64.rs | 2 - src/unix/bsd/netbsdlike/netbsd/sparc64.rs | 2 - src/unix/bsd/netbsdlike/netbsd/x86.rs | 2 - src/unix/bsd/netbsdlike/netbsd/x86_64.rs | 2 - src/unix/bsd/netbsdlike/openbsd/aarch64.rs | 2 - src/unix/bsd/netbsdlike/openbsd/arm.rs | 3 - src/unix/bsd/netbsdlike/openbsd/mips64.rs | 3 - src/unix/bsd/netbsdlike/openbsd/powerpc.rs | 3 - src/unix/bsd/netbsdlike/openbsd/powerpc64.rs | 3 - src/unix/bsd/netbsdlike/openbsd/riscv64.rs | 2 - src/unix/bsd/netbsdlike/openbsd/sparc64.rs | 3 - src/unix/bsd/netbsdlike/openbsd/x86.rs | 3 - src/unix/bsd/netbsdlike/openbsd/x86_64.rs | 2 - src/unix/haiku/b32.rs | 2 - src/unix/haiku/b64.rs | 2 - src/unix/hurd/b32.rs | 3 - src/unix/hurd/b64.rs | 3 - src/unix/linux_like/android/b32/mod.rs | 2 - src/unix/linux_like/android/b64/mod.rs | 2 - src/unix/linux_like/emscripten/mod.rs | 2 - src/unix/linux_like/linux/gnu/b32/mod.rs | 2 - .../linux_like/linux/gnu/b64/aarch64/ilp32.rs | 3 - .../linux_like/linux/gnu/b64/aarch64/lp64.rs | 3 - .../linux/gnu/b64/loongarch64/mod.rs | 2 - .../linux_like/linux/gnu/b64/mips64/mod.rs | 2 - .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 2 - .../linux_like/linux/gnu/b64/riscv64/mod.rs | 2 - src/unix/linux_like/linux/gnu/b64/s390x.rs | 2 - .../linux_like/linux/gnu/b64/sparc64/mod.rs | 2 - .../linux/gnu/b64/x86_64/not_x32.rs | 3 - .../linux_like/linux/gnu/b64/x86_64/x32.rs | 3 - src/unix/linux_like/linux/musl/b32/mod.rs | 2 - src/unix/linux_like/linux/musl/b64/mod.rs | 2 - src/unix/linux_like/linux/uclibc/arm/mod.rs | 2 - .../linux/uclibc/mips/mips32/mod.rs | 2 - .../linux/uclibc/mips/mips64/mod.rs | 2 - .../linux_like/linux/uclibc/x86_64/mod.rs | 2 - src/unix/mod.rs | 10 --- src/unix/newlib/aarch64/mod.rs | 3 - src/unix/newlib/arm/mod.rs | 3 - src/unix/newlib/espidf/mod.rs | 3 - src/unix/newlib/horizon/mod.rs | 3 - src/unix/newlib/powerpc/mod.rs | 3 - src/unix/newlib/vita/mod.rs | 3 - src/unix/nto/aarch64.rs | 2 - src/unix/nto/x86_64.rs | 2 - src/unix/nuttx/mod.rs | 2 - src/unix/redox/mod.rs | 14 ---- src/unix/solarish/mod.rs | 2 - src/vxworks/aarch64.rs | 2 - src/vxworks/arm.rs | 2 - src/vxworks/mod.rs | 10 --- src/vxworks/powerpc.rs | 2 - src/vxworks/powerpc64.rs | 2 - src/vxworks/riscv32.rs | 2 - src/vxworks/riscv64.rs | 2 - src/vxworks/x86.rs | 2 - src/vxworks/x86_64.rs | 2 - src/wasi/mod.rs | 12 --- src/windows/mod.rs | 12 --- src/xous.rs | 12 --- 88 files changed, 89 insertions(+), 415 deletions(-) rename src/{fixed_width_ints.rs => primitives.rs} (73%) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index f0559db9bee55..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,9 +78,6 @@ 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(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))] diff --git a/src/hermit.rs b/src/hermit.rs index 03947bc01ade5..65d0bf374d8cd 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -2,24 +2,11 @@ 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 060c4c1b39cdd..50aed357a82ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,138 +41,106 @@ cfg_if! { pub use core::ffi::c_void; -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", - ) - ))] { - pub type c_char = u8; - } else { - pub type c_char = 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/fixed_width_ints.rs b/src/primitives.rs similarity index 73% rename from src/fixed_width_ints.rs rename to src/primitives.rs index d2385fd385d10..30d9b98ff1bc0 100644 --- a/src/fixed_width_ints.rs +++ b/src/primitives.rs @@ -1,6 +1,67 @@ -//! 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), + not(target_vendor = "apple"), + 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 ed9d4f4d5b415..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,9 +15,6 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; -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 65eded63ad460..0caee5568e9e1 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -1,15 +1,5 @@ //! 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; pub type intmax_t = i64; pub type uintmax_t = u64; @@ -19,8 +9,5 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; -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 630c7db54b55b..376783c8234ba 100644 --- a/src/solid/aarch64.rs +++ b/src/solid/aarch64.rs @@ -1,3 +1 @@ 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 01fc7262f03e2..376783c8234ba 100644 --- a/src/solid/arm.rs +++ b/src/solid/arm.rs @@ -1,3 +1 @@ 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 1875ea81ad1ec..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,8 +10,6 @@ pub type uintptr_t = usize; pub type ssize_t = isize; pub type off_t = i64; -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 1ec2706cfdf76..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; @@ -47,10 +27,6 @@ pub type pid_t = c_int; pub type wchar_t = u32; -pub type c_long = i64; - -pub type c_ulong = u64; - // 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). diff --git a/src/trusty.rs b/src/trusty.rs index db908d5c6d47a..7441aade0631e 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -4,26 +4,6 @@ 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; @@ -37,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/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/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 2897ad377f14d..cfaa93f76d88e 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -10,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; diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 0201008e485fb..ae93648ebd94f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -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 1624e655a0f4c..e29c9cef3981e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -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/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index 6c8c973d570d1..9fde25d37b62f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -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 a812568b38e7d..e7df7f7737997 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -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 212413cbe22af..449a29f7d3df4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -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 c5a922b455642..b196eafe06ab8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -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 199ea643fdab4..fde274bb15a69 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -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/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index dbac03d2fb2ac..b511fc8457752 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -1,8 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i64; -pub type c_ulong = u64; 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 698eba93b31a5..b252862dfe650 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -1,8 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i32; -pub type c_ulong = u32; 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 028deb0cfbf76..eabfe1bbcc1e8 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mips.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -1,8 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i32; -pub type c_ulong = u32; 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/powerpc.rs b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs index 20eba6849a3ee..fc4cc3898e12a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -1,8 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i32; -pub type c_ulong = u32; 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 0437b994ca276..550c3bd7bb4ea 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -2,8 +2,6 @@ use PT_FIRSTMACH; use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; 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 3cfe535e7edfa..91622f7eea3fa 100644 --- a/src/unix/bsd/netbsdlike/netbsd/sparc64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/sparc64.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; 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 04741f2dc1f4e..92e160d9bca0c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; 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 52f3da771a157..5d31c0661e9c6 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -1,8 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i64; -pub type c_ulong = u64; 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 4cd0b32549835..2c4b1df26ce83 100644 --- a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; 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 7fd17cf65a55f..ae91cde0a1739 100644 --- a/src/unix/bsd/netbsdlike/openbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; - 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 17ebae2889f17..162ceda265df9 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mips64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mips64.rs @@ -1,6 +1,3 @@ -pub type c_long = i64; -pub type c_ulong = u64; - #[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 7fd17cf65a55f..ae91cde0a1739 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; - 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 1a3b452091ce0..1c3d8df3b7956 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; - 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 d37e9a67e6888..a0865406b80f3 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -pub type c_long = i64; -pub type c_ulong = u64; 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 f8e165a7de299..88481f4f014e8 100644 --- a/src/unix/bsd/netbsdlike/openbsd/sparc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/sparc64.rs @@ -1,6 +1,3 @@ -pub type c_long = i64; -pub type c_ulong = u64; - #[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 cac4ea7f8e94c..d2cf7832edd7f 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub type c_long = i32; -pub type c_ulong = u32; - 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 683046836320d..db9114e27cb60 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -1,8 +1,6 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; -pub type c_long = i64; -pub type c_ulong = u64; 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/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/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/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 0da702b45d18e..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; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index c1c5108c17eb4..f22843e54073f 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -27,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; 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/b64/aarch64/ilp32.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs index cec3b7ee28b5a..37e751e8db7da 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,5 @@ 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..80c22d40eeedc 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,5 @@ 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/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index e8f045ba5f83b..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,8 +1,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 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 1d13bdb945d6e..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,8 +2,6 @@ use crate::prelude::*; use crate::{off64_t, off_t, pthread_mutex_t}; pub type blksize_t = i64; -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; 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 3eda86440d40c..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,8 +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 wchar_t = i32; pub type nlink_t = u64; pub type blksize_t = i64; 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 3dd9369457353..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,8 +3,6 @@ use crate::prelude::*; use crate::{off64_t, off_t}; -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 7a48de58c967b..c08e12108b918 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -4,8 +4,6 @@ use crate::prelude::*; use crate::{off64_t, off_t, pthread_mutex_t}; pub type blksize_t = i64; -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; 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 829686ff16ee5..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,8 +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 wchar_t = i32; pub type nlink_t = u32; pub type blksize_t = i64; 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 eb9563e53e2c0..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, 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/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/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/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index c237b7e160bbf..000d9e33a734a 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -2,8 +2,6 @@ use crate::off64_t; use crate::prelude::*; 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; 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 a78daea80b62c..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,8 +1,6 @@ use crate::off64_t; use crate::prelude::*; -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; 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 d0a0f345546b6..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,8 +3,6 @@ use crate::prelude::*; pub type blkcnt_t = i64; pub type blksize_t = i64; -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/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 016b6580c5754..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,8 +6,6 @@ use crate::prelude::*; pub type blkcnt_t = i64; pub type blksize_t = i64; pub type clock_t = i64; -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; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8a0aa3266759b..65c426c181aef 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; diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index f0ab09443da22..e4640580e2478 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; pub type clock_t = c_long; 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 ae89440f237db..aea4ed764b03c 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; pub type clock_t = c_long; 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 0bb8e3ae9c766..57a033fcaf263 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; pub type clock_t = c_ulong; 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 05a1b284e295d..e98a4c53ccfff 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -3,9 +3,6 @@ use crate::off_t; use crate::prelude::*; -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 b53c832a71aed..c4d4a2ed07c5e 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -3,9 +3,6 @@ use crate::prelude::*; pub type clock_t = c_ulong; 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 1f531cb4d35ff..822b61989d479 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -5,9 +5,6 @@ pub type clock_t = c_long; 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 acc36bbf75363..559ab6e49a45d 100644 --- a/src/unix/nto/aarch64.rs +++ b/src/unix/nto/aarch64.rs @@ -1,8 +1,6 @@ use crate::prelude::*; 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 6cd24e187c443..521b5d4ab7879 100644 --- a/src/unix/nto/x86_64.rs +++ b/src/unix/nto/x86_64.rs @@ -1,8 +1,6 @@ use crate::prelude::*; 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 bf6efdd7ae362..f77b104493670 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -5,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 2f13157fff64a..c453f83efce60 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -2,20 +2,6 @@ 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; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 25913377e4a17..3a335357d6b6b 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2,8 +2,6 @@ use core::mem::size_of; 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; diff --git a/src/vxworks/aarch64.rs b/src/vxworks/aarch64.rs index 630c7db54b55b..376783c8234ba 100644 --- a/src/vxworks/aarch64.rs +++ b/src/vxworks/aarch64.rs @@ -1,3 +1 @@ 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 01fc7262f03e2..376783c8234ba 100644 --- a/src/vxworks/arm.rs +++ b/src/vxworks/arm.rs @@ -1,3 +1 @@ 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 e7ec43ab5e430..2b910616d794c 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; diff --git a/src/vxworks/powerpc.rs b/src/vxworks/powerpc.rs index 01fc7262f03e2..376783c8234ba 100644 --- a/src/vxworks/powerpc.rs +++ b/src/vxworks/powerpc.rs @@ -1,3 +1 @@ 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 630c7db54b55b..376783c8234ba 100644 --- a/src/vxworks/powerpc64.rs +++ b/src/vxworks/powerpc64.rs @@ -1,3 +1 @@ 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 741e312afce17..f562626f7fb2b 100644 --- a/src/vxworks/riscv32.rs +++ b/src/vxworks/riscv32.rs @@ -1,3 +1 @@ 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 7bacd5c5abec4..f562626f7fb2b 100644 --- a/src/vxworks/riscv64.rs +++ b/src/vxworks/riscv64.rs @@ -1,3 +1 @@ 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 741e312afce17..f562626f7fb2b 100644 --- a/src/vxworks/x86.rs +++ b/src/vxworks/x86.rs @@ -1,3 +1 @@ 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 7bacd5c5abec4..f562626f7fb2b 100644 --- a/src/vxworks/x86_64.rs +++ b/src/vxworks/x86_64.rs @@ -1,3 +1 @@ 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 f2b774ea51549..035ff8958ab20 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -7,16 +7,6 @@ use core::iter::Iterator; use crate::prelude::*; -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; @@ -28,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; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 632c33f461493..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,8 +12,6 @@ pub type uintptr_t = usize; pub type ssize_t = isize; pub type sighandler_t = usize; -pub type c_long = i32; -pub type c_ulong = u32; pub type wchar_t = u16; pub type clock_t = i32; diff --git a/src/xous.rs b/src/xous.rs index 468865c8d4131..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,8 +10,6 @@ pub type uintptr_t = usize; pub type ssize_t = isize; pub type off_t = i64; -pub type c_long = i64; -pub type c_ulong = u64; pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; From 9385f3ac7e0fa99300fa6ff17ccc732001b637c6 Mon Sep 17 00:00:00 2001 From: Aphek Date: Thu, 6 Feb 2025 00:40:07 -0300 Subject: [PATCH 31/45] Add missing preludes (backport ) (cherry picked from commit b54607f8eb8c2f7b1351d2374bc38300472761a1) --- src/sgx.rs | 2 ++ src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs | 1 + src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/src/sgx.rs b/src/sgx.rs index 0caee5568e9e1..9cf9c6d3b41b8 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -1,5 +1,7 @@ //! SGX C types definition +use crate::prelude::*; + pub type intmax_t = i64; pub type uintmax_t = u64; 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 37e751e8db7da..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,3 +1,4 @@ +use crate::prelude::*; use crate::pthread_mutex_t; pub const __SIZEOF_PTHREAD_CONDATTR_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 80c22d40eeedc..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,3 +1,4 @@ +use crate::prelude::*; use crate::pthread_mutex_t; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; From 3e2fb1752b364147baf0532d00e71f5e29514b03 Mon Sep 17 00:00:00 2001 From: Aphek Date: Tue, 4 Feb 2025 23:42:33 -0300 Subject: [PATCH 32/45] fix: Revert vita's c_char to i8 (backport ) (cherry picked from commit e5a669b526efd0db5809eb56b6dee3736d7a5c58) --- src/primitives.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/primitives.rs b/src/primitives.rs index 30d9b98ff1bc0..ed71e843057b1 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -21,6 +21,7 @@ cfg_if! { if #[cfg(all( not(windows), not(target_vendor = "apple"), + not(target_os = "vita"), any( target_arch = "aarch64", target_arch = "arm", From 11079fd0eb651261c330ac0c72860dc3b146fc62 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Wed, 20 Nov 2024 11:07:01 +0100 Subject: [PATCH 33/45] build.rs: Add linux_time_bits64 to ALLOWED_CFGS linux_time_bits64 will be used to match __USE_TIME_BITS64 in the uapi headers. The environment variable RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64 can be used by callers to enable the linux_time_bits64 config. (backport ) (cherry picked from commit 5453fe66f14aabb329ad508e99b114bcff51b0f0) --- build.rs | 7 +++++++ ci/verify-build.sh | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/build.rs b/build.rs index 5f401f9f1072e..2487f89e71563 100644 --- a/build.rs +++ b/build.rs @@ -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. @@ -43,6 +45,7 @@ fn main() { let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; + let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 11. @@ -79,6 +82,10 @@ fn main() { _ => (), } + if linux_time_bits64 { + set_cfg("linux_time_bits64"); + } + // On CI: deny all warnings if libc_ci { set_cfg("libc_deny_warnings"); 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 From 4134091ef8b27aa58c3371a5a78adfb6b7c89615 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 20 Mar 2023 14:21:04 +0100 Subject: [PATCH 34/45] linux: Set SO_TIMESTAMP* and SO_RCVTIMEO and SO_SNDTIMEO The actual values may be different on 32bit archs with and without __USE_TIME_BITS64 (backport ) (cherry picked from commit 616d546afb8c73de575450230c5da69ba91f7c3b) --- libc-test/semver/TODO-linux.txt | 1 - libc-test/semver/linux-loongarch64.txt | 1 - libc-test/semver/linux-powerpc64.txt | 1 - libc-test/semver/linux-powerpc64le.txt | 1 - libc-test/semver/linux-riscv64gc.txt | 1 - libc-test/semver/linux.txt | 1 + src/unix/linux_like/linux/arch/generic/mod.rs | 35 +++++++++++----- src/unix/linux_like/linux/arch/mips/mod.rs | 40 ++++++++++++------- src/unix/linux_like/linux/arch/powerpc/mod.rs | 31 ++++++++++---- 9 files changed, 74 insertions(+), 38 deletions(-) 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/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-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 d2193b870516f..3ec327aec6337 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2964,6 +2964,7 @@ SO_RXQ_OVFL SO_SNDBUFFORCE SO_TIMESTAMP SO_TIMESTAMPING +SO_TIMESTAMPNS SPLICE_F_GIFT SPLICE_F_MORE SPLICE_F_MOVE diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 10953fe789df3..ea38a20d67e40 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,35 @@ 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") + ))] { + 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 { + 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; diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 950ad5f118dfb..2fcadc8004ea7 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,20 @@ 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_TIMESTAMPNS_OLD: c_int = 35; +const SO_TIMESTAMPING_OLD: c_int = 37; +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; diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index de39df0d8323a..2e8d3e3675393 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; From 83d3f04b0393058a0de692965dea8fcb0c760e57 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Wed, 20 Nov 2024 11:11:35 +0100 Subject: [PATCH 35/45] linux: Set RLIM_INFINITY for 32bit mips with __USE_TIME_BITS64 (backport ) (cherry picked from commit 125b4f715756b3f641a7178534fb9e2374ac1d90) --- src/unix/linux_like/linux/arch/mips/mod.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 2fcadc8004ea7..70364b3108cd4 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -359,10 +359,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; } } From 17553b760d19867dc67647b3ee377f294fb3ac3a Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 17 Mar 2023 15:21:05 +0100 Subject: [PATCH 36/45] linux: Update struct input_event for __USE_TIME_BITS64 (backport ) (cherry picked from commit 7413e22f250030596f75c294cff976af2d3dfed5) --- src/unix/linux_like/linux/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index c2fa6392fa500..71311c1ed6681 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -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, From 72e58545718a7423154bd18f07a536d40b05bdc9 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Tue, 26 Nov 2024 17:28:26 +0100 Subject: [PATCH 37/45] unix: Add FIXME(time) for struct timeval struct timeval has to be updated at least for glibc with _TIME_BITS=64. (backport ) (cherry picked from commit c20130256eaa9e650beeffc1dc0b8ab0215aae2f) --- src/unix/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 65c426c181aef..1e70238d19824 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -56,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, From c5b746547116aef22ef4c01ccf2e626c36f0cee7 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 27 Jan 2025 09:53:12 +0100 Subject: [PATCH 38/45] Rerun build if RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64 changes Collect the linux_time_bits64 in one place. (backport ) (cherry picked from commit 9a861ed61c696761c18037ad6255176409bf43fe) --- build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 2487f89e71563..3439208f7e2ce 100644 --- a/build.rs +++ b/build.rs @@ -45,7 +45,6 @@ fn main() { let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; - let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 11. @@ -82,6 +81,8 @@ fn main() { _ => (), } + 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"); } From 8b0ab163062c7495f1fba755c9a782e58e94fc57 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 16 Dec 2024 09:21:06 +0100 Subject: [PATCH 39/45] Add forgotten SO_*_NEW values to powerpc, mips and arm The _NEW defines are not available in musl and ohos. (backport ) (cherry picked from commit b0e68783fa8f4b91b6a1fa03fe7d4b1ebb8ed015) --- src/unix/linux_like/linux/arch/generic/mod.rs | 14 +++++++++++++- src/unix/linux_like/linux/arch/mips/mod.rs | 5 +++++ src/unix/linux_like/linux/arch/powerpc/mod.rs | 10 +++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index ea38a20d67e40..098c83c3b885b 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -57,13 +57,24 @@ const SO_TIMESTAMPING_OLD: c_int = 37; cfg_if! { if #[cfg(all( linux_time_bits64, - any(target_arch = "arm", target_arch = "x86") + 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; @@ -114,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 70364b3108cd4..612f8c73ffc3c 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -99,8 +99,13 @@ pub const SO_BINDTOIFINDEX: c_int = 62; // but CI haven't support them yet. // Some related consts could be found in b32.rs and b64.rs 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; diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index 2e8d3e3675393..50d1ef17bb887 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -94,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; From b668252303c6a79c465aabc9a002bc0b4a79df6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=96=D1=83=D0=BD=D1=91=D0=B2=D0=B0=20=D0=9C=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=9C=D0=B8=D1=85=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=BD=D0=B0?= Date: Fri, 21 Jun 2024 18:21:30 +0300 Subject: [PATCH 40/45] Add structures for freebsd (backport ) (cherry picked from commit 187468d37a3e9d785d915bfe7b82f81c3c6dc3f1) --- libc-test/build.rs | 2 ++ libc-test/semver/freebsd.txt | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index eb41e2eaa7ac8..4aa1fa8bd8338 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2312,6 +2312,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", @@ -2385,6 +2386,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(), } }); 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/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, From 116b82e5aec3a42415d4586fbe01d4dcde5240dd Mon Sep 17 00:00:00 2001 From: Kartik Agarwala Date: Thu, 30 Jan 2025 13:52:59 +0530 Subject: [PATCH 41/45] Fix size of time_t in vxworks (backport ) (cherry picked from commit eec39f5d73774977fe237958e44490e0ec86fcdc) --- src/vxworks/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 2b910616d794c..073b5d07ce6fa 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -34,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; From 7a7fe4683185d030bd16630b58387b82786f5597 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 19 Dec 2024 09:03:23 +0100 Subject: [PATCH 42/45] Apply modulo 256 to BSD WEXITSTATUS wait(2p)[^1] says > WEXITSTATUS(status) > If WIFEXITED(status) is true, evaluates to the low-order 8 bits > of the argument passed to _exit(2) or exit(3) by the child. meaning WEXITSTATUS(status) is an 8-bit value. We accidentally return too many bits. For example WEXITSTATUS(-1) returns -1 instead of 255. Fix it, matching the C library and our other WEXITSTATUS implementations. [^1] https://manpage.me/index.cgi?apropos=0&q=wait&sektion=2&manpath=FreeBSD+12-CURRENT+and+Ports&arch=default&format=html Originally reported at https://github.com/fish-shell/fish-shell/issues/10919 (backport ) (cherry picked from commit f9cde2f7241fca7fe5c5d9564c8d361847f42f9e) --- src/unix/bsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From a0021d2cb1c5cb3ed33969afacb4b9b9760989f9 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Tue, 18 Feb 2025 14:23:52 +0000 Subject: [PATCH 43/45] Add recent socket timestamping flags for Linux and Android Linux defines 3 more flags for socket option SO_TIMESTAMPING: - SOF_TIMESTAMPING_BIND_PHC introduced in Linux 5.14 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d463126e23f112629edb01594141ca437a92a108 - SOF_TIMESTAMPING_OPT_ID_TCP introduced in Linux 6.2 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b534dc46c8ae0165b1b2509be24dbea4fa9c4011 - SOF_TIMESTAMPING_OPT_RX_FILTER introduced in Linux 6.12 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=be8e9eb3750639aa5cffb3f764ca080caed41bd0 These flags are defined in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/net_tstamp.h?h=v6.13 Android C library (bionic) picked this flags up: https://android.googlesource.com/platform//bionic/+/9cdc362a2f7463670a766400defcd332a9edfe19/libc/kernel/uapi/linux/net_tstamp.h Update Linux and Android files accordingly. (backport ) (cherry picked from commit d1d92db586e16f8ed1cc5e9ece79783b8b19b4ac) --- libc-test/build.rs | 9 +++++++++ libc-test/semver/android.txt | 3 +++ libc-test/semver/linux.txt | 3 +++ src/unix/linux_like/android/mod.rs | 3 +++ src/unix/linux_like/linux/mod.rs | 3 +++ 5 files changed, 21 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4aa1fa8bd8338..7efacf7a41e63 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2083,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, } }); @@ -4338,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, } }); diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index f8c136dd70e10..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 diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 3ec327aec6337..c91b5034608d2 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2898,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 diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 0e1b05aa5cf72..5debbe8fb967d 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -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", diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 71311c1ed6681..63049fe1c5547 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4544,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; From 42a30adc36ecceaf231589c4b1a1347c66d14222 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 22 Feb 2025 22:24:32 +0000 Subject: [PATCH 44/45] Switch back to matching `target_os` rather than `target_vendor` `ctest` is very particular about this and the current configuration, though working most of the time, seems to cause occasional CI errors that can't easily be explained or mitigated. Switch back to matching all Apple `target_os` options until `ctest` is fixed. (backport ) (cherry picked from commit a986f81dbc23bf669fdecd81a74b6ae3999cb8c8) --- src/primitives.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/primitives.rs b/src/primitives.rs index ed71e843057b1..668d3340d2abb 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -20,7 +20,14 @@ pub type c_double = f64; cfg_if! { if #[cfg(all( not(windows), - not(target_vendor = "apple"), + // 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", From 61d269893fc88f8e576d98432aa0aa639e64dbaf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 23 Feb 2025 00:11:57 +0000 Subject: [PATCH 45/45] chore: release v0.2.170 Co-authored-by: Trevor Gross --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- libc-test/Cargo.toml | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) 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/libc-test/Cargo.toml b/libc-test/Cargo.toml index f0f4c22346753..740b9ca18cac2 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -14,7 +14,7 @@ A test crate for the libc crate. [dependencies.libc] path = ".." -version = "0.2.169" +version = "0.2.170" default-features = false [dev-dependencies]