From 43dd31edad79a3b6ca14104d435936687b5af420 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 26 Jun 2025 07:21:20 -0500 Subject: [PATCH 01/93] ci: Run `cargo-semver-checks` This should eventually be able to replace the `.txt` files. --- .github/workflows/ci.yaml | 6 +++++- ci/verify-build.sh | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 86467f799f0f2..a18f93f51a426 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,10 +67,14 @@ jobs: run: | set -eux [ "${{ matrix.toolchain }}" = "1.63.0" ] && echo 'RUSTFLAGS=' >> "$GITHUB_ENV" || true - + - name: Setup Rust toolchain run: ./ci/install-rust.sh + - name: Install semver-checks + uses: taiki-e/install-action@cargo-semver-checks + if: matrix.toolchain == 'stable' + # FIXME(ci): These `du` statements are temporary for debugging cache - name: Target size before restoring cache run: du -sh target | sort -k 2 || true diff --git a/ci/verify-build.sh b/ci/verify-build.sh index 7def289221491..0cd8f89dd3005 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -11,6 +11,7 @@ set -eux rust="$TOOLCHAIN" filter="${FILTER:-}" +host_target=$(rustc -vV | awk '/^host/ { print $2 }') case "$(uname -s)" in Linux*) os=linux ;; @@ -25,6 +26,7 @@ esac echo "Testing Rust $rust on $os" if [ "$TOOLCHAIN" = "nightly" ] ; then + # For build-std rustup component add rust-src fi @@ -108,6 +110,13 @@ test_target() { $cmd --no-default-features done fi + + # FIXME(semver): can't pass `--target` to `cargo-semver-checks` + if [ "$rust" = "stable" ] && [ "$target" = "$host_target" ]; then + # Run semver checks on the stable channel + cargo semver-checks --only-explicit-features \ + --features std,extra_traits + fi } freebsd_versions="\ From fff24ebca34b3a45e19c21bdd39ebe2caa8405de Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 26 Jun 2025 07:34:14 -0500 Subject: [PATCH 02/93] ci: Don't test an unused feature `const-extern-fn` no longer does anything so we don't need to test for it. --- ci/verify-build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/verify-build.sh b/ci/verify-build.sh index 0cd8f89dd3005..a44ef0a181fc8 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -71,7 +71,6 @@ test_target() { # Test with expected combinations of features $cmd - $cmd --features const-extern-fn $cmd --features extra_traits if [ "$os" = "linux" ]; then From 2957e7c19c805a79e2a4472d916db5066f8054ea Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Wed, 2 Jul 2025 06:27:24 +0200 Subject: [PATCH 03/93] semver: powerpc64le: Move glibc-only symbols into separate file These aren't defined on musl. Split them up like done e.g. in loongarch64. Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 27bf19c14b1338400145be51f0471832ed965a0a) --- libc-test/semver/linux-gnu-powerpc64le.txt | 14 ++++++++++++++ libc-test/semver/linux-powerpc64le.txt | 17 ----------------- 2 files changed, 14 insertions(+), 17 deletions(-) create mode 100644 libc-test/semver/linux-gnu-powerpc64le.txt diff --git a/libc-test/semver/linux-gnu-powerpc64le.txt b/libc-test/semver/linux-gnu-powerpc64le.txt new file mode 100644 index 0000000000000..148688c5ff20d --- /dev/null +++ b/libc-test/semver/linux-gnu-powerpc64le.txt @@ -0,0 +1,14 @@ +KEYCTL_CAPABILITIES +KEYCTL_CAPS0_BIG_KEY +KEYCTL_CAPS0_CAPABILITIES +KEYCTL_CAPS0_DIFFIE_HELLMAN +KEYCTL_CAPS0_INVALIDATE +KEYCTL_CAPS0_MOVE +KEYCTL_CAPS0_PERSISTENT_KEYRINGS +KEYCTL_CAPS0_PUBLIC_KEY +KEYCTL_CAPS0_RESTRICT_KEYRING +KEYCTL_CAPS1_NS_KEYRING_NAME +KEYCTL_CAPS1_NS_KEY_TAG +KEYCTL_MOVE +max_align_t +sysctl diff --git a/libc-test/semver/linux-powerpc64le.txt b/libc-test/semver/linux-powerpc64le.txt index b4e5c4159a3d8..f6564fd2ae586 100644 --- a/libc-test/semver/linux-powerpc64le.txt +++ b/libc-test/semver/linux-powerpc64le.txt @@ -2,27 +2,12 @@ B2500000 B3000000 B3500000 B4000000 -KEYCTL_CAPABILITIES -KEYCTL_CAPS0_BIG_KEY -KEYCTL_CAPS0_CAPABILITIES -KEYCTL_CAPS0_DIFFIE_HELLMAN -KEYCTL_CAPS0_INVALIDATE -KEYCTL_CAPS0_MOVE -KEYCTL_CAPS0_PERSISTENT_KEYRINGS -KEYCTL_CAPS0_PUBLIC_KEY -KEYCTL_CAPS0_RESTRICT_KEYRING -KEYCTL_CAPS1_NS_KEYRING_NAME -KEYCTL_CAPS1_NS_KEY_TAG -KEYCTL_MOVE MADV_SOFT_OFFLINE MAP_SYNC NFT_MSG_DELOBJ NFT_MSG_GETOBJ NFT_MSG_GETOBJ_RESET NFT_MSG_NEWOBJ -PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP SCM_TIMESTAMPNS SCM_WIFI_STATUS SIGSTKFLT @@ -159,5 +144,3 @@ TIOCGRS485 TIOCSBRK TIOCSRS485 flock64 -max_align_t -sysctl From 31c595a2351fa6aad3a4889eabd061f4da3ad1e1 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Wed, 2 Jul 2025 06:32:09 +0200 Subject: [PATCH 04/93] semver: powerpc64(le): Rename powerpc64le files to powerpc64 CARGO_CFG_TARGET_ARCH is powerpc64 on both powerpc64 and powerpc64le. This would cause the powerpc64le semver files to be unused. Replace the powerpc64 files with the powerpc64le ones, they are compatible with each other and only differ in endianess. Linux, musl and glibc share the same code for both endian targets. See the cargo documentation: https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 2881ee5fe892162df655cee7800f2f790f186348) --- ...owerpc64le.txt => linux-gnu-powerpc64.txt} | 0 libc-test/semver/linux-powerpc64.txt | 19 --- libc-test/semver/linux-powerpc64le.txt | 146 ------------------ 3 files changed, 165 deletions(-) rename libc-test/semver/{linux-gnu-powerpc64le.txt => linux-gnu-powerpc64.txt} (100%) delete mode 100644 libc-test/semver/linux-powerpc64le.txt diff --git a/libc-test/semver/linux-gnu-powerpc64le.txt b/libc-test/semver/linux-gnu-powerpc64.txt similarity index 100% rename from libc-test/semver/linux-gnu-powerpc64le.txt rename to libc-test/semver/linux-gnu-powerpc64.txt diff --git a/libc-test/semver/linux-powerpc64.txt b/libc-test/semver/linux-powerpc64.txt index 604add92838db..f6564fd2ae586 100644 --- a/libc-test/semver/linux-powerpc64.txt +++ b/libc-test/semver/linux-powerpc64.txt @@ -2,29 +2,12 @@ B2500000 B3000000 B3500000 B4000000 -Elf32_Rela -Elf64_Rela -KEYCTL_CAPABILITIES -KEYCTL_CAPS0_BIG_KEY -KEYCTL_CAPS0_CAPABILITIES -KEYCTL_CAPS0_DIFFIE_HELLMAN -KEYCTL_CAPS0_INVALIDATE -KEYCTL_CAPS0_MOVE -KEYCTL_CAPS0_PERSISTENT_KEYRINGS -KEYCTL_CAPS0_PUBLIC_KEY -KEYCTL_CAPS0_RESTRICT_KEYRING -KEYCTL_CAPS1_NS_KEYRING_NAME -KEYCTL_CAPS1_NS_KEY_TAG -KEYCTL_MOVE MADV_SOFT_OFFLINE MAP_SYNC NFT_MSG_DELOBJ NFT_MSG_GETOBJ NFT_MSG_GETOBJ_RESET NFT_MSG_NEWOBJ -PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP SCM_TIMESTAMPNS SCM_WIFI_STATUS SIGSTKFLT @@ -161,5 +144,3 @@ TIOCGRS485 TIOCSBRK TIOCSRS485 flock64 -max_align_t -sysctl diff --git a/libc-test/semver/linux-powerpc64le.txt b/libc-test/semver/linux-powerpc64le.txt deleted file mode 100644 index f6564fd2ae586..0000000000000 --- a/libc-test/semver/linux-powerpc64le.txt +++ /dev/null @@ -1,146 +0,0 @@ -B2500000 -B3000000 -B3500000 -B4000000 -MADV_SOFT_OFFLINE -MAP_SYNC -NFT_MSG_DELOBJ -NFT_MSG_GETOBJ -NFT_MSG_GETOBJ_RESET -NFT_MSG_NEWOBJ -SCM_TIMESTAMPNS -SCM_WIFI_STATUS -SIGSTKFLT -SIGUNUSED -SO_ATTACH_BPF -SO_ATTACH_FILTER -SO_BPF_EXTENSIONS -SO_BSDCOMPAT -SO_DETACH_BPF -SO_DETACH_FILTER -SO_GET_FILTER -SO_INCOMING_CPU -SO_LOCK_FILTER -SO_MAX_PACING_RATE -SO_NOFCS -SO_NO_CHECK -SO_PEERNAME -SO_PRIORITY -SO_PROTOCOL -SO_SECURITY_AUTHENTICATION -SO_SECURITY_ENCRYPTION_NETWORK -SO_SECURITY_ENCRYPTION_TRANSPORT -SO_SELECT_ERR_QUEUE -SO_WIFI_STATUS -SYS__llseek -SYS__newselect -SYS__sysctl -SYS_accept -SYS_access -SYS_afs_syscall -SYS_alarm -SYS_bdflush -SYS_break -SYS_chmod -SYS_chown -SYS_creat -SYS_create_module -SYS_dup2 -SYS_epoll_create -SYS_epoll_wait -SYS_eventfd -SYS_fork -SYS_fstat -SYS_fstatfs64 -SYS_ftime -SYS_futimesat -SYS_get_kernel_syms -SYS_getdents -SYS_getpgrp -SYS_getpmsg -SYS_gtty -SYS_idle -SYS_inotify_init -SYS_ioperm -SYS_iopl -SYS_ipc -SYS_kexec_file_load -SYS_lchown -SYS_link -SYS_lock -SYS_lstat -SYS_mkdir -SYS_mknod -SYS_modify_ldt -SYS_mpx -SYS_multiplexer -SYS_newfstatat -SYS_nice -SYS_oldfstat -SYS_oldlstat -SYS_oldolduname -SYS_oldstat -SYS_olduname -SYS_open -SYS_pause -SYS_pciconfig_iobase -SYS_pciconfig_read -SYS_pciconfig_write -SYS_pipe -SYS_poll -SYS_prof -SYS_profil -SYS_putpmsg -SYS_query_module -SYS_readdir -SYS_readlink -SYS_recv -SYS_rename -SYS_renameat -SYS_rmdir -SYS_rtas -SYS_select -SYS_send -SYS_sendfile -SYS_setrlimit -SYS_sgetmask -SYS_sigaction -SYS_signal -SYS_signalfd -SYS_sigpending -SYS_sigprocmask -SYS_sigreturn -SYS_sigsuspend -SYS_socketcall -SYS_spu_create -SYS_spu_run -SYS_ssetmask -SYS_stat -SYS_statfs64 -SYS_stime -SYS_stty -SYS_subpage_prot -SYS_swapcontext -SYS_switch_endian -SYS_symlink -SYS_sync_file_range2 -SYS_sys_debug_setcontext -SYS_sysfs -SYS_time -SYS_tuxcall -SYS_ugetrlimit -SYS_ulimit -SYS_umount -SYS_unlink -SYS_uselib -SYS_ustat -SYS_utime -SYS_utimes -SYS_vfork -SYS_vm86 -SYS_waitpid -TIOCCBRK -TIOCGRS485 -TIOCSBRK -TIOCSRS485 -flock64 From 76d4a8e2bcc25ae179b2425638b9e7e5c73303ed Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Wed, 2 Jul 2025 06:59:19 +0200 Subject: [PATCH 05/93] musl: Fix definition of NCCS on powerpc(64) These overwrite the value with their own. https://git.musl-libc.org/cgit/musl/tree/arch/powerpc/bits/termios.h#n2 https://git.musl-libc.org/cgit/musl/tree/arch/powerpc64/bits/termios.h#n2 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit f8e5a84d445b82ffbdd47a8b01a5fcbae63127c5) --- src/unix/linux_like/linux/musl/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index e2afbd860a1ce..bb4bc0bf2e37a 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -599,7 +599,10 @@ pub const ACCOUNTING: c_short = 9; pub const SFD_CLOEXEC: c_int = 0x080000; +#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] pub const NCCS: usize = 32; +#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] +pub const NCCS: usize = 19; pub const O_TRUNC: c_int = 512; pub const O_NOATIME: c_int = 0o1000000; From f162c05300f4f3d5b4209a79aa5f033f6e8b97d0 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Thu, 3 Jul 2025 03:45:08 +0200 Subject: [PATCH 06/93] musl: powerpc64: Fix definition of MAP_LOCKED and MAP_NORESERVE powerpc and powerpc64 have different definitions for these in musl. The powerpc values were correct, but powerpc64 ones were not. This was changed in musl 1.1.17. See https://git.musl-libc.org/cgit/musl/commit/?id=c10bc61508dc52b8315084e628f36a6c3c2dabb1 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 5c0742b970287f9086a0f3f2407c0b9528dbfdd8) --- src/unix/linux_like/linux/musl/b64/powerpc64.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 4f3c081fb633c..186f410363867 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -175,8 +175,8 @@ pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; pub const MAP_EXECUTABLE: c_int = 0x01000; -pub const MAP_LOCKED: c_int = 0x02000; -pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_LOCKED: c_int = 0x80; +pub const MAP_NORESERVE: c_int = 0x40; pub const MAP_POPULATE: c_int = 0x08000; pub const MAP_NONBLOCK: c_int = 0x010000; pub const MAP_STACK: c_int = 0x020000; From d0c1e3a67b1a92530c7ab364c2a26acd0df2786c Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Thu, 3 Jul 2025 03:55:27 +0200 Subject: [PATCH 07/93] musl: powerpc64: Fix definition of EDEADLK musl defines EDEADLK to be 35 on powerpc64 and EDEADLOCK to be 58. This has always been the case since the introduction of powerpc64 support in musl. See: https://git.musl-libc.org/cgit/musl/tree/arch/powerpc64/bits/errno.h#n35 https://git.musl-libc.org/cgit/musl/tree/arch/powerpc64/bits/errno.h#n58 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 3e28d999cd06953e6f6a7231c8a0864c61511ce9) --- src/unix/linux_like/linux/musl/b64/powerpc64.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 186f410363867..680230d8adb4f 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -639,8 +639,8 @@ pub const SYS_process_mrelease: c_long = 448; pub const SYS_futex_waitv: c_long = 449; pub const SYS_set_mempolicy_home_node: c_long = 450; -pub const EDEADLK: c_int = 58; -pub const EDEADLOCK: c_int = EDEADLK; +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = 58; pub const EXTPROC: crate::tcflag_t = 0x10000000; pub const VEOL: usize = 6; From d0cc330ca93e83a466883285d42897b0f47a206a Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Thu, 3 Jul 2025 04:10:36 +0200 Subject: [PATCH 08/93] musl: powerpc(64): Decommonize termios definitions PowerPC targets use their own, separate definitions of termios that change the order of the c_line and c_cc fields. See: https://git.musl-libc.org/cgit/musl/tree/arch/powerpc/bits/termios.h#n3 https://git.musl-libc.org/cgit/musl/tree/arch/powerpc64/bits/termios.h#n3 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 0dfd754b4f83fa99ed8ecc7b617e272b785495b8) --- src/unix/linux_like/linux/musl/b32/powerpc.rs | 11 +++++++++++ src/unix/linux_like/linux/musl/b64/powerpc64.rs | 11 +++++++++++ src/unix/linux_like/linux/musl/mod.rs | 2 ++ 3 files changed, 24 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 460b2d8fcf0ee..a07dfda17794e 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -4,6 +4,17 @@ use crate::prelude::*; pub type wchar_t = i32; s! { + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_line: crate::cc_t, + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 680230d8adb4f..462dad9117b74 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -8,6 +8,17 @@ pub type nlink_t = u64; pub type blksize_t = c_long; s! { + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_line: crate::cc_t, + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index bb4bc0bf2e37a..5241d0a7ad2dd 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -212,6 +212,8 @@ s! { __f_reserved: [c_int; 6], } + // PowerPC implementations are special, see the subfolders + #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, From 185a637ced4fe921b25ef99183735d9642fd21b1 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Thu, 3 Jul 2025 04:28:42 +0200 Subject: [PATCH 09/93] musl: powerpc64: Decommonize definition of shmid_ds powerpc64 is the only 64-bit target that doesn't use the generic definition for these in musl. See https://git.musl-libc.org/cgit/musl/tree/arch/powerpc64/bits/shm.h#n3 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 1ac2a19cbf07c7d3426c63ef00d183c5c7031d50) --- src/unix/linux_like/linux/musl/b64/mod.rs | 2 ++ src/unix/linux_like/linux/musl/b64/powerpc64.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index 6b6761ba03ac4..3fb059812b4ff 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -17,6 +17,8 @@ s! { __val: [c_ulong; 16], } + // PowerPC implementation is special, see the subfolder. + #[cfg(not(target_arch = "powerpc64"))] pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 462dad9117b74..dc03a71caedac 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -61,6 +61,18 @@ s! { __reserved: [c_long; 3], } + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __unused: [c_ulong; 2], + } + pub struct ipc_perm { #[cfg(musl_v1_2_3)] pub __key: crate::key_t, From e1a5df2411fd3f29e635ce74056bebf399f8683d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 3 Jul 2025 00:48:37 -0500 Subject: [PATCH 10/93] triagebot: Add autolabels for PowerPC (backport ) (cherry picked from commit 9ccce075b94a638328282a95c96595fa2ee1c020) --- triagebot.toml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index 6aa18772a750e..18c7fd79f8157 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -87,6 +87,24 @@ trigger_files = ["src/unix/linux_like/linux/musl"] [autolabel."O-newlib"] trigger_files = ["src/unix/newlib"] +[autolabel."O-powerpc"] +trigger_files = [ + "src/unix/aix/powerpc64.rs", + "src/unix/bsd/freebsdlike/freebsd/powerpc.rs", + "src/unix/bsd/freebsdlike/freebsd/powerpc64.rs", + "src/unix/bsd/netbsdlike/netbsd/powerpc.rs", + "src/unix/bsd/netbsdlike/openbsd/powerpc.rs", + "src/unix/bsd/netbsdlike/openbsd/powerpc64.rs", + "src/unix/linux_like/linux/arch/powerpc/", + "src/unix/linux_like/linux/gnu/b32/powerpc.rs", + "src/unix/linux_like/linux/gnu/b64/powerpc64/", + "src/unix/linux_like/linux/musl/b32/powerpc.rs", + "src/unix/linux_like/linux/musl/b64/powerpc64.rs", + "src/unix/newlib/powerpc/", + "src/vxworks/powerpc.rs", + "src/vxworks/powerpc64.rs", +] + [autolabel."O-redox"] trigger_files = ["src/unix/redox"] From c4afd2444b8dc6006e61a125e98f5fb9151bc737 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Wed, 2 Jul 2025 07:03:04 +0200 Subject: [PATCH 11/93] musl: Clarify reason for CPU_SETSIZE value This value was set to 1024 for all targets in the following commit: https://git.musl-libc.org/cgit/musl/commit/?id=bc695a5ac1d7929e5c1ad5297eb47e146cccd157 Since loongarch64 requires musl 1.2.5, the expected value there is different than the other targets, which still target an earlier musl. Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 046bed55e764420e99a2585964f5bb3df0bfd81b) --- src/unix/linux_like/linux/musl/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 5241d0a7ad2dd..d5383e5dae9b5 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -675,6 +675,7 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +// FIXME(musl): Value is 1024 for all architectures since 1.2.4 #[cfg(not(target_arch = "loongarch64"))] pub const CPU_SETSIZE: c_int = 128; #[cfg(target_arch = "loongarch64")] From 81ea0503f707282c75a4f8b4f6049933c15ee6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 2 Jul 2025 16:19:49 +0000 Subject: [PATCH 12/93] linux-musl-s390x: Remove bogus definition of RTLD_DEEPBIND musl-libc does not define RTLD_DEEPBIND on any architecture. Fixes: 88de3880f ("add definitions for s390x musl targets") (backport ) (cherry picked from commit 6faa6d3f98520607f382fd26dbbcd6bf3cfcc85d) --- src/unix/linux_like/linux/musl/b64/s390x.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 0f1062860d1ca..879ffb3a31d37 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -98,7 +98,6 @@ cfg_if! { } pub const VEOF: usize = 4; -pub const RTLD_DEEPBIND: c_int = 0x8; pub const EUCLEAN: c_int = 117; pub const ENOTNAM: c_int = 118; From a447c3b6f45b12ffc43caad52d564a50c2d6812e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 2 Jul 2025 16:25:50 +0000 Subject: [PATCH 13/93] linux-musl-s390x: Remove bogus definition of O_FSYNC musl-libc does not define O_FSYNC on any architecture, since commit v1.1.15-15-gc1f4ed15 (committed 2016-08-30): https://git.musl-libc.org/cgit/musl/commit/?id=c1f4ed150137d793c9d07356305a89e8785e7e02 Fixes: 88de3880f ("add definitions for s390x musl targets") (backport ) (cherry picked from commit a5b89d33fd9913b3fefa389e6824abc5f63763a2) --- src/unix/linux_like/linux/musl/b64/s390x.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 879ffb3a31d37..c312505a7d77f 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -133,7 +133,6 @@ pub const O_NOCTTY: c_int = 256; pub const O_SYNC: c_int = 1052672; pub const O_RSYNC: c_int = 1052672; pub const O_DSYNC: c_int = 4096; -pub const O_FSYNC: c_int = 0x101000; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; pub const O_NOFOLLOW: c_int = 0x20000; From 1a494b58ab62b0b80153077bb13d759779f5dae7 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 3 Jul 2025 09:15:37 -0400 Subject: [PATCH 14/93] Add function getpeereid. (backport ) (cherry picked from commit 336e3f1956c9a3a73455e2710c387a8dc493801a) --- libc-test/build.rs | 3 +++ libc-test/semver/aix.txt | 1 + src/unix/aix/mod.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c6282de1a3a5c..93e05b49a8897 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5729,6 +5729,9 @@ fn test_aix(target: &str) { // https://github.com/gnzlbg/ctest/issues/68. "lio_listio" => true, + // The function is only available under macro _KERNEL in 'proto_uipc.h'. + "getpeereid" => true, + _ => false, } }); diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index 3b6417ba3e718..8a030153c9fd4 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -1989,6 +1989,7 @@ getmntent getnameinfo getopt getpagesize +getpeereid getpeername getpgid getpgrp diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 3f8145d6b3b42..fdb3b9233cc86 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2949,6 +2949,7 @@ extern "C" { flags: c_int, ) -> c_int; pub fn getpagesize() -> c_int; + pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn getpwent() -> *mut crate::passwd; #[link_name = "_posix_getpwnam_r"] From 4c961104c047417cd293635879382a36a611d084 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Fri, 4 Jul 2025 05:57:10 +0200 Subject: [PATCH 15/93] musl: mips64: Use special MIPS definition of statfs 64-bit MIPS has the same special definition as 32-bit MIPS in musl. See https://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/statfs.h Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 4ea56f7d094f67d08c5a38e607952211b7eea24c) --- src/unix/linux_like/linux/musl/b64/mips64.rs | 30 ++++++++++++++++++++ src/unix/linux_like/linux/musl/mod.rs | 4 +-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 5cef57239fda9..cd80935324c6c 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -76,6 +76,36 @@ s! { __unused1: c_ulong, __unused2: c_ulong, } + + pub struct statfs { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } + + pub struct statfs64 { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } } pub const SIGSTKSZ: size_t = 8192; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index d5383e5dae9b5..8f43d1912fabf 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -382,7 +382,7 @@ s! { } // MIPS implementation is special (see mips arch folders) - #[cfg(not(target_arch = "mips"))] + #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] pub struct statfs { pub f_type: c_ulong, pub f_bsize: c_ulong, @@ -399,7 +399,7 @@ s! { } // MIPS implementation is special (see mips arch folders) - #[cfg(not(target_arch = "mips"))] + #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] pub struct statfs64 { pub f_type: c_ulong, pub f_bsize: c_ulong, From d2669062df7c57639c0094a31d85bde8c3ebc564 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Fri, 4 Jul 2025 07:46:30 +0200 Subject: [PATCH 16/93] musl: mips64: Swap order of si_errno and si_code in siginfo_t All MIPS targets, 32-bit and 64-bit, swap these around. See: https://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/signal.h#n103 https://git.musl-libc.org/cgit/musl/tree/include/signal.h#n100 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 76072a6a0ee57ba8f174217ad754976e637b1412) --- src/unix/linux_like/linux/musl/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 8f43d1912fabf..c2bba245a98db 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -157,10 +157,10 @@ s! { // FIXME(union): C implementation uses unions pub struct siginfo_t { pub si_signo: c_int, - #[cfg(not(target_arch = "mips"))] + #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] pub si_errno: c_int, pub si_code: c_int, - #[cfg(target_arch = "mips")] + #[cfg(any(target_arch = "mips", target_arch = "mips64"))] pub si_errno: c_int, #[doc(hidden)] #[deprecated( From b6012d187630103c1b47f0ead0949bfb0aae6a60 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Fri, 4 Jul 2025 07:40:42 +0200 Subject: [PATCH 17/93] linux_like: mips64: Fix SI_TIMER, SI_MESGQ and SI_ASYNCIO definitions mips64 uses the same definitions for these as the 32-bit targets. See e.g.: https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/siginfo.h#L21 https://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/signal.h#n96 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit dff820c26946aac4ae6d248b21e04d5fab57279f) --- src/unix/linux_like/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index a2969e854fdc9..42f4efe42aebb 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1269,7 +1269,11 @@ pub const SI_USER: c_int = 0; pub const SI_KERNEL: c_int = 0x80; pub const SI_QUEUE: c_int = -1; cfg_if! { - if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] { + if #[cfg(not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64" + )))] { pub const SI_TIMER: c_int = -2; pub const SI_MESGQ: c_int = -3; pub const SI_ASYNCIO: c_int = -4; From e4ac9344cbd148c0bc44d90c47624f361a7fbef3 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Fri, 4 Jul 2025 07:34:21 +0200 Subject: [PATCH 18/93] musl: mips64: Use special MIPS definition of stack_t stack_t is sigaltstack, which in musl has a special definition for MIPS that switches around ss_size and ss_flags. The 32-bit definition was already correct. See: https://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/signal.h#n67 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 3d3392b46e22770d22ff2c207bcccf2080f77975) --- src/unix/linux_like/linux/musl/b64/mips64.rs | 6 ++++++ src/unix/linux_like/linux/musl/b64/mod.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index cd80935324c6c..59667d3efeb7d 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -56,6 +56,12 @@ s! { __pad5: [c_int; 14], } + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + pub struct ipc_perm { #[cfg(musl_v1_2_3)] pub __key: crate::key_t, diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index 3fb059812b4ff..1bfd812ab2a34 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type regoff_t = c_long; s! { + // MIPS implementation is special, see the subfolder. + #[cfg(not(target_arch = "mips64"))] pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, From 9ff5e7f8970532607b5511d9dc4d5b84ca30f259 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 22:59:41 +0000 Subject: [PATCH 19/93] ci: Update RUSTFLAGS to attempt to resolve cache issues Our cache does not seem to be working. rust-cache takes RUSTFLAGS into account, so it is possible that there is a problem due to it getting set dynamically. This is more than likely not the cause, but it is worth a try and is cleaner anyway. (backport ) (cherry picked from commit be84d13ccfa684c3d7e7857df5e003331feaf229) --- .github/workflows/ci.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a18f93f51a426..6678e42b6adb3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -62,12 +62,6 @@ jobs: TOOLCHAIN: ${{ matrix.toolchain }} steps: - uses: actions/checkout@v4 - # Remove `-Dwarnings` at the MSRV since lints may be different or buffier - - name: Update RUSTFLAGS - run: | - set -eux - [ "${{ matrix.toolchain }}" = "1.63.0" ] && echo 'RUSTFLAGS=' >> "$GITHUB_ENV" || true - - name: Setup Rust toolchain run: ./ci/install-rust.sh @@ -85,7 +79,11 @@ jobs: run: du -sh target | sort -k 2 || true - name: Execute build.sh - run: ./ci/verify-build.sh + run: | + set -eux + # Remove `-Dwarnings` at the MSRV since lints may be different + [ "${{ matrix.toolchain }}" = "1.63.0" ] && export RUSTFLAGS="" + ./ci/verify-build.sh - name: Target size after job completion run: du -sh target | sort -k 2 From c3e3681c6775184f359875b7517530244bcfb241 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 23:21:35 +0000 Subject: [PATCH 20/93] ci: Only build `core` with `-Zbuild-std` We don't need alloc or std, so save some CI time by only building `core`. (backport ) (cherry picked from commit d96fb205fa12fe827cdc87599e322ca3fcbdb530) --- ci/run.sh | 2 +- ci/verify-build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index c58ae1caa1739..1d4b5f5079d96 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -51,7 +51,7 @@ if [ -n "${QEMU:-}" ]; then cargo build \ --manifest-path libc-test/Cargo.toml \ --target "$target" \ - --test main ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"} + --test main ${LIBC_CI_ZBUILD_STD+"-Zbuild-std=core"} rm "${CARGO_TARGET_DIR}/${target}"/debug/main-*.d cp "${CARGO_TARGET_DIR}/${target}"/debug/main-* "${tmpdir}"/mount/libc-test # shellcheck disable=SC2016 diff --git a/ci/verify-build.sh b/ci/verify-build.sh index a44ef0a181fc8..f19ed9d774a08 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -48,7 +48,7 @@ test_target() { if [ "${no_dist}" != "0" ]; then # If we can't download a `core`, we need to build it - cmd="$cmd -Zbuild-std=core,alloc" + cmd="$cmd -Zbuild-std=core" # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" From 20d39903369c06bb4a306eb5b8443662260b51dd Mon Sep 17 00:00:00 2001 From: mbyx Date: Tue, 15 Jul 2025 12:09:28 +0500 Subject: [PATCH 21/93] libc-test: fix lint error (backport ) (cherry picked from commit 2e5e02ca9ca27ebeb7f8cde2e8fdb195375e1a32) --- libc-test/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 93e05b49a8897..c5818dbe1b120 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3580,7 +3580,7 @@ fn test_neutrino(target: &str) { ) }); - cfg.skip_static(move |name| (name == "__dso_handle")); + cfg.skip_static(move |name| name == "__dso_handle"); cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); } From a56dcac2a3102426c18304ca6ea7cf8bd4b41743 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 16 Jul 2025 01:53:26 -0400 Subject: [PATCH 22/93] build: Fix incorrect `target_os` -> `target_arch` check This was introduced in 2a68f7f9f6 ("Add musl_v1_2_3 feature"). Fixes: https://github.com/rust-lang/libc/issues/4526 (backport ) (cherry picked from commit 4c52a681543d58fb8de37322f8b4bb86fbbd5fc4) --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 5e1e62c5188ef..070354f1e756a 100644 --- a/build.rs +++ b/build.rs @@ -95,7 +95,7 @@ fn main() { let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); // loongarch64 and ohos have already updated - if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" { + if musl_v1_2_3 || target_arch == "loongarch64" || target_env == "ohos" { // FIXME(musl): enable time64 api as well set_cfg("musl_v1_2_3"); } From b54ba610255829f06c78dea2e17e41594ce026a7 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Mon, 16 Jun 2025 19:03:46 -0700 Subject: [PATCH 23/93] hurd: Fix `clippy::unused_unit` warnings. (backport ) (cherry picked from commit afd569fb62dddeaf5f1068b87b0039d7b1412a34) --- src/unix/hurd/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 843e7f4c3915d..1844b6ab36d2e 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3473,14 +3473,12 @@ f! { let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { From dd93259846ad9360ec0dfac1d2c1e96a79aaf844 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Mon, 16 Jun 2025 19:08:17 -0700 Subject: [PATCH 24/93] hurd: Fix `clippy::redundant_static_lifetimes` warnings. (backport ) (cherry picked from commit 82d508f564eae5caafcbbc54ed77a0e218b16868) --- src/unix/hurd/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 1844b6ab36d2e..7f21e226a39e0 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -1594,12 +1594,12 @@ pub const SEM_VALUE_MAX: c_int = 2147483647; pub const MAXNAMLEN: usize = 255; // netdb.h -pub const _PATH_HEQUIV: &'static [u8; 17usize] = b"/etc/hosts.equiv\0"; -pub const _PATH_HOSTS: &'static [u8; 11usize] = b"/etc/hosts\0"; -pub const _PATH_NETWORKS: &'static [u8; 14usize] = b"/etc/networks\0"; -pub const _PATH_NSSWITCH_CONF: &'static [u8; 19usize] = b"/etc/nsswitch.conf\0"; -pub const _PATH_PROTOCOLS: &'static [u8; 15usize] = b"/etc/protocols\0"; -pub const _PATH_SERVICES: &'static [u8; 14usize] = b"/etc/services\0"; +pub const _PATH_HEQUIV: &[u8; 17usize] = b"/etc/hosts.equiv\0"; +pub const _PATH_HOSTS: &[u8; 11usize] = b"/etc/hosts\0"; +pub const _PATH_NETWORKS: &[u8; 14usize] = b"/etc/networks\0"; +pub const _PATH_NSSWITCH_CONF: &[u8; 19usize] = b"/etc/nsswitch.conf\0"; +pub const _PATH_PROTOCOLS: &[u8; 15usize] = b"/etc/protocols\0"; +pub const _PATH_SERVICES: &[u8; 14usize] = b"/etc/services\0"; pub const HOST_NOT_FOUND: c_int = 1; pub const TRY_AGAIN: c_int = 2; pub const NO_RECOVERY: c_int = 3; From 464dbb867be3bb8eb8367dc8244f2006416de577 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Mon, 16 Jun 2025 19:13:59 -0700 Subject: [PATCH 25/93] hurd: Fix `clippy::precedence` warnings. (backport ) (cherry picked from commit c5ddc704ef36fac2c12c69fe762af9b0506e2d8f) --- 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 7f21e226a39e0..6ce5d854682cb 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3416,7 +3416,7 @@ const _UTSNAME_LENGTH: usize = 1024; const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::() - 1 & !(mem::size_of::() - 1) + (len + mem::size_of::() - 1) & !(mem::size_of::() - 1) } } From f0e2ab1b2f33e6b532f107268c40ec6820b37f9e Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Mon, 16 Jun 2025 19:16:19 -0700 Subject: [PATCH 26/93] hurd: Fix `clippy::ptr_as_ptr` warnings. (backport ) (cherry picked from commit 483e331281ec08de555759b433c5a7bccacf91b5) --- src/unix/hurd/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 6ce5d854682cb..96dd443b3196d 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3424,7 +3424,7 @@ const_fn! { f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize >= mem::size_of::() { - (*mhdr).msg_control as *mut cmsghdr + (*mhdr).msg_control.cast::() } else { core::ptr::null_mut::() } @@ -3453,7 +3453,7 @@ f! { { core::ptr::null_mut::() } else { - next as *mut cmsghdr + next.cast::() } } From e5ec1abb54a35a2f36d2bee3b44f99af41931877 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 16 Jun 2025 08:42:00 +0000 Subject: [PATCH 27/93] Add the `enum` keyword to the `c_enum` macro Our `style.sh` script can't handle these easily, and it seems like `ctest` may struggle with this macro. Add the `enum` keyword so the expanded code is valid Rust. (backport ) (cherry picked from commit 19e04c8be3a62e36fef995fb6f6e40de06891d53) --- ci/style.sh | 2 +- src/macros.rs | 10 +++++----- src/unix/linux_like/linux/mod.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ci/style.sh b/ci/style.sh index 97a9bc47bc132..0d4a4f953dda1 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -26,7 +26,7 @@ while IFS= read -r file; do # Turn all braced macro `foo! { /* ... */ }` invocations into # `fn foo_fmt_tmp() { /* ... */ }`. - perl -pi -e 's/(?!macro_rules|c_enum)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file" + perl -pi -e 's/(?!macro_rules)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file" # Replace `if #[cfg(...)]` within `cfg_if` with `if cfg_tmp!([...])` which # `rustfmt` will format. We put brackets within the parens so it is easy to diff --git a/src/macros.rs b/src/macros.rs index a0fb7ff12c0f8..aac47561d2fbd 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -223,7 +223,7 @@ macro_rules! e { macro_rules! c_enum { ( $(#[repr($repr:ty)])? - $ty_name:ident { + enum $ty_name:ident { $($variant:ident $(= $value:literal)?,)+ } ) => { @@ -411,7 +411,7 @@ mod tests { fn c_enumbasic() { // By default, variants get sequential values. c_enum! { - e { + enum e { VAR0, VAR1, VAR2, @@ -428,7 +428,7 @@ mod tests { // By default, variants get sequential values. c_enum! { #[repr(u16)] - e { + enum e { VAR0, } } @@ -440,7 +440,7 @@ mod tests { fn c_enumset_value() { // Setting an explicit value resets the count. c_enum! { - e { + enum e { VAR2 = 2, VAR3, VAR4, @@ -457,7 +457,7 @@ mod tests { // C enums always take one more than the previous value, unless set to a specific // value. Duplicates are allowed. c_enum! { - e { + enum e { VAR0, VAR2_0 = 2, VAR3_0, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 992df6cffd92e..15518ce596ca3 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -95,7 +95,7 @@ e! { } c_enum! { - pid_type { + enum pid_type { PIDTYPE_PID, PIDTYPE_TGID, PIDTYPE_PGID, @@ -4559,14 +4559,14 @@ pub const RTNLGRP_STATS: c_uint = 0x24; // linux/cn_proc.h c_enum! { - proc_cn_mcast_op { + enum proc_cn_mcast_op { PROC_CN_MCAST_LISTEN = 1, PROC_CN_MCAST_IGNORE = 2, } } c_enum! { - proc_cn_event { + enum proc_cn_event { PROC_EVENT_NONE = 0x00000000, PROC_EVENT_FORK = 0x00000001, PROC_EVENT_EXEC = 0x00000002, From 639df92ab9836991769cf7bf00b73d770e7d11ed Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Tue, 24 Jun 2025 17:07:02 -0700 Subject: [PATCH 28/93] Add CLONE_CLEAR_SIGHAND and CLONE_INTO_CGROUP for Android (backport ) (cherry picked from commit cbcd3445cb146b18cd96aa86764e3e8864d6411c) --- libc-test/semver/android.txt | 2 ++ src/unix/linux_like/android/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 881ed4378f7ce..a52cc25077a95 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -238,9 +238,11 @@ CLOCK_TAI CLOCK_THREAD_CPUTIME_ID CLONE_CHILD_CLEARTID CLONE_CHILD_SETTID +CLONE_CLEAR_SIGHAND CLONE_DETACHED CLONE_FILES CLONE_FS +CLONE_INTO_CGROUP CLONE_IO CLONE_NEWCGROUP CLONE_NEWIPC diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 3dee96e2123a0..8d20394790f57 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -2896,6 +2896,8 @@ pub const SCHED_DEADLINE: c_int = 6; pub const SCHED_RESET_ON_FORK: c_int = 0x40000000; pub const CLONE_PIDFD: c_int = 0x1000; +pub const CLONE_CLEAR_SIGHAND: c_ulonglong = 0x100000000; +pub const CLONE_INTO_CGROUP: c_ulonglong = 0x200000000; // linux/membarrier.h pub const MEMBARRIER_CMD_QUERY: c_int = 0; From 0b79744fe1696a0018506b4d407c3e19dee0ec72 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 10 Jun 2025 10:33:59 +0300 Subject: [PATCH 29/93] libc-test/build.rs: add netinet/in_pcb.h to the list of FreeBSD headers (backport ) (cherry picked from commit 84430578c5c87f77d037c4324b2531705c86f254) --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c5818dbe1b120..2676ccb7402da 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2502,6 +2502,8 @@ fn test_freebsd(target: &str) { "sys/sem.h", "sys/shm.h", "sys/socket.h", + "sys/socketvar.h", + "netinet/in_pcb.h", // must be after sys/socketvar.h "sys/stat.h", "sys/statvfs.h", "sys/sysctl.h", From f24bd9104e83f27dbce0cad239b072326fff3eec Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 22 May 2025 14:22:35 +0300 Subject: [PATCH 30/93] FreeBSD: add xinpgen and related types definitions (backport ) (cherry picked from commit 7d2a69501b61dae6b2c27aff6c629ca507a7911a) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index de41a7c6d3ed6..1022cc7606953 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -11,6 +11,9 @@ pub type fixpt_t = __fixpt_t; pub type __lwpid_t = i32; pub type lwpid_t = __lwpid_t; pub type blksize_t = i32; +pub type ksize_t = u64; +pub type inp_gen_t = u64; +pub type so_gen_t = u64; pub type clockid_t = c_int; pub type sem_t = _sem; pub type timer_t = *mut __c_anonymous__timer; @@ -1701,6 +1704,16 @@ s_no_extra_traits! { pub uc_flags: c_int, __spare__: [c_int; 4], } + + #[repr(align(8))] + pub struct xinpgen { + pub xig_len: ksize_t, + pub xig_count: u32, + _xig_spare32: u32, + pub xig_gen: inp_gen_t, + pub xig_sogen: so_gen_t, + _xig_spare64: [u64; 4], + } } cfg_if! { From aa40d691c7853842a20b7fe4bdf34346de16d802 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 21 May 2025 08:03:07 +0300 Subject: [PATCH 31/93] FreeBSD: add in_conninfo definition (backport ) (cherry picked from commit 34e3b14f4b2a259917753b7c5185b94183fa781c) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 1022cc7606953..281cf39ef1c83 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1714,6 +1714,31 @@ s_no_extra_traits! { pub xig_sogen: so_gen_t, _xig_spare64: [u64; 4], } + + pub struct in_addr_4in6 { + _ia46_pad32: [u32; 3], + pub ia46_addr4: crate::in_addr, + } + + pub union in_dependaddr { + pub id46_addr: crate::in_addr_4in6, + pub id6_addr: crate::in6_addr, + } + + pub struct in_endpoints { + pub ie_fport: u16, + pub ie_lport: u16, + pub ie_dependfaddr: crate::in_dependaddr, + pub ie_dependladdr: crate::in_dependaddr, + pub ie6_zoneid: u32, + } + + pub struct in_conninfo { + pub inc_flags: u8, + pub inc_len: u8, + pub inc_fibnum: u16, + pub inc_ie: crate::in_endpoints, + } } cfg_if! { @@ -4631,6 +4656,10 @@ pub const RB_POWERCYCLE: c_int = 0x400000; pub const RB_PROBE: c_int = 0x10000000; pub const RB_MULTIPLE: c_int = 0x20000000; +// netinet/in_pcb.h +pub const INC_ISIPV6: c_uchar = 0x01; +pub const INC_IPV6MINMTU: c_uchar = 0x02; + // sys/time.h pub const CLOCK_BOOTTIME: crate::clockid_t = crate::CLOCK_UPTIME; pub const CLOCK_REALTIME_COARSE: crate::clockid_t = crate::CLOCK_REALTIME_FAST; From f424fb2dd6c70422a74bef7cf1b8800bc0bfdeb8 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 21 May 2025 08:03:29 +0300 Subject: [PATCH 32/93] FreeBSD: add xktls_session definition (backport ) (cherry picked from commit 9220aacb5bddebc356cff62ac7d9ca045f6f0f62) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 281cf39ef1c83..9016ca0a99703 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1739,6 +1739,38 @@ s_no_extra_traits! { pub inc_fibnum: u16, pub inc_ie: crate::in_endpoints, } + + pub struct xktls_session_onedir { + pub gennum: u64, + _rsrv1: [u64; 8], + _rsrv2: [u32; 8], + pub iv: [u8; 32], + pub cipher_algorithm: i32, + pub auth_algorithm: i32, + pub cipher_key_len: u16, + pub iv_len: u16, + pub auth_key_len: u16, + pub max_frame_len: u16, + pub tls_vmajor: u8, + pub tls_vminor: u8, + pub tls_hlen: u8, + pub tls_tlen: u8, + pub tls_bs: u8, + pub flags: u8, + pub drv_st_len: u16, + pub ifnet: [u8; 16], + } + + pub struct xktls_session { + pub tsz: u32, + pub fsz: u32, + pub inp_gencnt: u64, + pub so_pcb: kvaddr_t, + pub coninf: crate::in_conninfo, + pub rx_vlan_id: c_ushort, + pub rcv: crate::xktls_session_onedir, + pub snd: crate::xktls_session_onedir, + } } cfg_if! { From 1eed8a2da705012e9cc8fcf7f5719a9131b52f1d Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 10 Jun 2025 10:55:55 +0300 Subject: [PATCH 33/93] FreeBSD: skip checking of xktls_session* structs on FreeBSD 14.x and older (backport ) (cherry picked from commit db4dba7aac10f7ad14029bc1da5bc1152c284995) --- libc-test/build.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 2676ccb7402da..92e0c60612a4c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2920,6 +2920,10 @@ fn test_freebsd(target: &str) { // `splice` introduced in FreeBSD 14.2 "splice" if Some(14) > freebsd_ver => true, + // Those are introduced in FreeBSD 15. + "xktls_session_onedir" | "xktls_session" + if Some(15) > freebsd_ver => true, + _ => false, } }); From af882646dd86a1cc8e68aec43b7dc63b5fba2995 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Fri, 27 Jun 2025 14:31:17 -0400 Subject: [PATCH 34/93] Use unique errno values. (backport ) (cherry picked from commit fa6a2995bb341cd87a47a0e27aa96986e844d4c5) --- libc-test/build.rs | 5 +++++ libc-test/semver/aix.txt | 2 -- src/unix/aix/mod.rs | 6 ++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 92e0c60612a4c..8bf08ab78e54a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5648,6 +5648,11 @@ fn test_aix(target: &str) { // Skip 'sighandler_t' assignments. "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, + // _ALL_SOURCE defines these errno values as aliases of other errno + // values, but POSIX requires each errno to be unique. Skip these + // values because non-unique values are being used which will + // fail the test when _ALL_SOURCE is defined. + "EWOULDBLOCK" | "ENOTEMPTY" => true, _ => false, }); diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index 8a030153c9fd4..38553abf3f80d 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -253,13 +253,11 @@ ECHOKE ECHONL ECHOPRT ECHRNG -ECLONEME ECONNABORTED ECONNREFUSED ECONNRESET ECORRUPT EDEADLK -EDESTADDREQ EDESTADDRREQ EDIST EDOM diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index fdb3b9233cc86..985a44c41f5ed 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1264,12 +1264,11 @@ pub const ENOLCK: c_int = 49; pub const ENOCONNECT: c_int = 50; pub const ESTALE: c_int = 52; pub const EDIST: c_int = 53; -pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EWOULDBLOCK: c_int = 54; pub const EINPROGRESS: c_int = 55; pub const EALREADY: c_int = 56; pub const ENOTSOCK: c_int = 57; pub const EDESTADDRREQ: c_int = 58; -pub const EDESTADDREQ: c_int = EDESTADDRREQ; pub const EMSGSIZE: c_int = 59; pub const EPROTOTYPE: c_int = 60; pub const ENOPROTOOPT: c_int = 61; @@ -1298,7 +1297,7 @@ pub const EPROCLIM: c_int = 83; pub const EUSERS: c_int = 84; pub const ELOOP: c_int = 85; pub const ENAMETOOLONG: c_int = 86; -pub const ENOTEMPTY: c_int = EEXIST; +pub const ENOTEMPTY: c_int = 87; pub const EDQUOT: c_int = 88; pub const ECORRUPT: c_int = 89; pub const ESYSERROR: c_int = 90; @@ -1321,7 +1320,6 @@ pub const EBADMSG: c_int = 120; pub const EPROTO: c_int = 121; pub const ENODATA: c_int = 122; pub const ENOSTR: c_int = 123; -pub const ECLONEME: c_int = ERESTART; pub const ENOTSUP: c_int = 124; pub const EMULTIHOP: c_int = 125; pub const ENOLINK: c_int = 126; From a23abdd59742bde0b304123e2a80fd22d268766e Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Wed, 2 Jul 2025 03:49:03 +0200 Subject: [PATCH 35/93] musl: mips64: Fix type of nlink_t musl defines nlink_t to be an unsigned 32-bit integer on mips64, therefore changing the size of stat64 from 216 bytes to 208. The current definition in the libc crate does not match this and therefore defines stat64 wrong on mips64 musl, which results in bogus readings of fields following st_nlink. See https://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/alltypes.h.in#n22 for the musl definition of nlink_t. Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 02eff0f2968af897e3856b7a86952b96ba60d034) --- src/unix/linux_like/linux/musl/b64/mips64.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 59667d3efeb7d..57a460bd1c8f4 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -4,7 +4,7 @@ use crate::prelude::*; pub type wchar_t = i32; pub type __u64 = c_ulong; pub type __s64 = c_long; -pub type nlink_t = u64; +pub type nlink_t = c_uint; pub type blksize_t = i64; s! { From 5e8ca2cf096c448e7141d717950cae8c0ce0a821 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Wed, 2 Jul 2025 05:44:45 +0200 Subject: [PATCH 36/93] musl: Decommonize definition of fanotify_event_metadata musl has its own definition of the fanotify_event_metadata struct and doesn't use the one from the Linux kernel. The difference here is that musl's mask field has the type unsigned long long, while the kernel uses __u64. This currently causes libc-test to fail to compile on musl targets. Linux: https://github.com/torvalds/linux/blob/master/include/uapi/linux/fanotify.h#L143 musl: https://git.musl-libc.org/cgit/musl/tree/include/sys/fanotify.h#n15 Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 7559ba1619ec05c6619cc31f775eda45504065d2) --- src/unix/linux_like/linux/mod.rs | 1 + src/unix/linux_like/linux/musl/mod.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 15518ce596ca3..09456604215d3 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1220,6 +1220,7 @@ s! { size: [u8; crate::__SIZEOF_PTHREAD_BARRIERATTR_T], } + #[cfg(not(target_env = "musl"))] #[repr(align(8))] pub struct fanotify_event_metadata { pub event_len: __u32, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index c2bba245a98db..8d4a5ce90b93d 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -142,6 +142,17 @@ s! { __dummy4: [c_char; 16], } + #[repr(align(8))] + pub struct fanotify_event_metadata { + pub event_len: c_uint, + pub vers: c_uchar, + pub reserved: c_uchar, + pub metadata_len: c_ushort, + pub mask: c_ulonglong, + pub fd: c_int, + pub pid: c_int, + } + // FIXME(1.0): This should not implement `PartialEq` #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { From 36aa38bda88633f256949f5405c5646cc8f72ea3 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Wed, 2 Jul 2025 05:59:51 +0200 Subject: [PATCH 37/93] linux: gnu/musl: MAP_32BIT is only defined on x86 The Linux kernel only defines MAP_32BIT in the asm/mman.h header on x86. Remove the erraneous definitions for any other architectures on Linux targets. See https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/mman.h#L5 This makes libc-test somewhat compile on powerpc64le musl. Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 9332d56877d358f4efee70ecaa807396ef00aed0) --- libc-test/build.rs | 5 +++++ src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 1 - src/unix/linux_like/linux/musl/b64/powerpc64.rs | 2 ++ src/unix/linux_like/linux/musl/b64/wasm32/mod.rs | 1 - 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8bf08ab78e54a..3b8585d6739a9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4379,6 +4379,11 @@ fn test_linux(target: &str) { if old_musl && name == "RLIM_NLIMITS" { return true; } + // FIXME: Does not exist on non-x86 architectures, slated for removal + // in libc in 1.0 + if ppc64 && name == "MAP_32BIT" { + return true; + } } match name { // These constants are not available if gnu headers have been included 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 fe4b05f4e2a10..71b3dd316394c 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -191,7 +191,6 @@ pub const O_NDELAY: c_int = 0x800; pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_LOCKED: c_int = 0x02000; pub const MAP_NORESERVE: c_int = 0x04000; -pub const MAP_32BIT: c_int = 0x0040; pub const MAP_ANON: c_int = 0x0020; pub const MAP_ANONYMOUS: c_int = 0x0020; pub const MAP_DENYWRITE: c_int = 0x0800; diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index dc03a71caedac..a313aac21df09 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -95,6 +95,8 @@ s! { } pub const MADV_SOFT_OFFLINE: c_int = 101; +#[deprecated(since = "0.2.175", note = "Linux does not define MAP_32BIT on any architectures \ + other than x86 and x86_64, this constant will be removed in the future")] pub const MAP_32BIT: c_int = 0x0040; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x20000; diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs index 3f7a6098297f5..29750e79e17e6 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -441,7 +441,6 @@ pub const SYS_set_mempolicy_home_node: c_long = 450; pub const SYS_fadvise: c_long = SYS_fadvise64; pub const MADV_SOFT_OFFLINE: c_int = 101; -pub const MAP_32BIT: c_int = 0x0040; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; From 1ab0d740427cee51e7260c9d97ca48936821d6f0 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 26 Jun 2025 05:47:42 +0300 Subject: [PATCH 38/93] FreeBSD amd64: add mc_tlsbase member to mcontext_t (backport ) (cherry picked from commit 64bfc7d69794dbdf8509f1c0b5fcb1625f266646) --- src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index 40e1d72e2041e..4ee20901436cf 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -137,7 +137,8 @@ s_no_extra_traits! { pub mc_gsbase: register_t, pub mc_xfpustate: register_t, pub mc_xfpustate_len: register_t, - pub mc_spare: [c_long; 4], + pub mc_tlsbase: register_t, + pub mc_spare: [c_long; 3], } } From c96513542bb3770c7c771f4cbad699fbf4e3d418 Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Fri, 6 Jun 2025 15:01:48 -0700 Subject: [PATCH 39/93] Add SECBIT_ constants from securebits.h See: https://github.com/torvalds/linux/blob/master/include/uapi/linux/securebits.h (backport ) (cherry picked from commit f811577fed5214f9d8805c79e31b6d27840a0b4c) --- libc-test/build.rs | 1 + libc-test/semver/linux.txt | 11 ++++++++++ src/unix/linux_like/linux/mod.rs | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 3b8585d6739a9..58f489e5f65d3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3953,6 +3953,7 @@ fn test_linux(target: &str) { "linux/sched.h", "linux/sctp.h", "linux/seccomp.h", + "linux/securebits.h", "linux/sock_diag.h", "linux/sockios.h", "linux/tls.h", diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 533adc6ebbcae..5ab4aef3d8a35 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2776,6 +2776,14 @@ SCTP_STATUS SCTP_STREAM_RESET_INCOMING SCTP_STREAM_RESET_OUTGOING SCTP_UNORDERED +SECBIT_KEEP_CAPS +SECBIT_KEEP_CAPS_LOCKED +SECBIT_NOROOT +SECBIT_NOROOT_LOCKED +SECBIT_NO_CAP_AMBIENT_RAISE +SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED +SECBIT_NO_SETUID_FIXUP +SECBIT_NO_SETUID_FIXUP_LOCKED SECCOMP_ADDFD_FLAG_SEND SECCOMP_ADDFD_FLAG_SETFD SECCOMP_FILTER_FLAG_LOG @@ -2804,6 +2812,9 @@ SECCOMP_RET_USER_NOTIF SECCOMP_SET_MODE_FILTER SECCOMP_SET_MODE_STRICT SECCOMP_USER_NOTIF_FLAG_CONTINUE +SECUREBITS_DEFAULT +SECURE_ALL_BITS +SECURE_ALL_LOCKS SEEK_DATA SEEK_HOLE SELFMAG diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 09456604215d3..bf973f3b65af6 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4848,6 +4848,41 @@ pub const IN_ONLYDIR: u32 = 0x0100_0000; pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; +// uapi/linux/securebits.h +const SECURE_NOROOT: c_int = 0; +const SECURE_NOROOT_LOCKED: c_int = 1; + +pub const SECBIT_NOROOT: c_int = issecure_mask(SECURE_NOROOT); +pub const SECBIT_NOROOT_LOCKED: c_int = issecure_mask(SECURE_NOROOT_LOCKED); + +const SECURE_NO_SETUID_FIXUP: c_int = 2; +const SECURE_NO_SETUID_FIXUP_LOCKED: c_int = 3; + +pub const SECBIT_NO_SETUID_FIXUP: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP); +pub const SECBIT_NO_SETUID_FIXUP_LOCKED: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED); + +const SECURE_KEEP_CAPS: c_int = 4; +const SECURE_KEEP_CAPS_LOCKED: c_int = 5; + +pub const SECBIT_KEEP_CAPS: c_int = issecure_mask(SECURE_KEEP_CAPS); +pub const SECBIT_KEEP_CAPS_LOCKED: c_int = issecure_mask(SECURE_KEEP_CAPS_LOCKED); + +const SECURE_NO_CAP_AMBIENT_RAISE: c_int = 6; +const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = 7; + +pub const SECBIT_NO_CAP_AMBIENT_RAISE: c_int = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); +pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = + issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED); + +pub const SECUREBITS_DEFAULT: c_int = 0x00000000; +pub const SECURE_ALL_BITS: c_int = + SECBIT_NOROOT | SECBIT_NO_SETUID_FIXUP | SECBIT_KEEP_CAPS | SECBIT_NO_CAP_AMBIENT_RAISE; +pub const SECURE_ALL_LOCKS: c_int = SECURE_ALL_BITS << 1; + +const fn issecure_mask(x: c_int) -> c_int { + 1 << x +} + // linux/keyctl.h pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; From 318319c99ab751ee2d9375f47570c47663d3ff8f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 15:53:26 +0000 Subject: [PATCH 40/93] Add `core::mem::{size_of, align_of}` to the prelude Since 1.80 these, along with their `_val` versions, are in the default `core` prelude so they don't need to be imported. 1.80 exceeds our MSRV so we can't use it from there, but we can add it to our prelude for now. (backport ) (cherry picked from commit 26a5ea66ea54e4f099972a9e9b1b5200465978dd) --- src/fuchsia/mod.rs | 28 ++++---- src/macros.rs | 2 + src/primitives.rs | 16 ++--- src/teeos/mod.rs | 8 +-- src/unix/aix/mod.rs | 16 ++--- src/unix/bsd/apple/mod.rs | 46 ++++++------- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 12 ++-- src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/arm.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 23 ++++--- 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/freebsdlike/mod.rs | 2 +- src/unix/bsd/mod.rs | 8 +-- 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/mod.rs | 11 ++-- src/unix/bsd/netbsdlike/netbsd/powerpc.rs | 2 +- src/unix/bsd/netbsdlike/netbsd/riscv64.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 | 2 +- src/unix/bsd/netbsdlike/openbsd/mod.rs | 11 ++-- src/unix/bsd/netbsdlike/openbsd/powerpc.rs | 2 +- src/unix/bsd/netbsdlike/openbsd/powerpc64.rs | 2 +- src/unix/bsd/netbsdlike/openbsd/riscv64.rs | 2 +- src/unix/bsd/netbsdlike/openbsd/x86.rs | 2 +- src/unix/bsd/netbsdlike/openbsd/x86_64.rs | 2 +- src/unix/cygwin/mod.rs | 30 ++++----- src/unix/haiku/mod.rs | 18 ++--- src/unix/haiku/native.rs | 65 +++++-------------- src/unix/hurd/mod.rs | 30 ++++----- src/unix/linux_like/android/mod.rs | 12 ++-- src/unix/linux_like/emscripten/mod.rs | 8 +-- src/unix/linux_like/linux/mod.rs | 12 ++-- .../linux_like/linux/musl/b64/powerpc64.rs | 7 +- src/unix/linux_like/mod.rs | 20 +++--- src/unix/newlib/mod.rs | 6 +- src/unix/nto/mod.rs | 28 ++++---- src/unix/redox/mod.rs | 14 ++-- src/unix/solarish/mod.rs | 10 ++- src/vxworks/mod.rs | 11 ++-- 47 files changed, 226 insertions(+), 270 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 22f9c6faf755b..a019ebb1f04cf 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3250,20 +3250,20 @@ cfg_if! { f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } @@ -3281,21 +3281,21 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } @@ -3309,9 +3309,9 @@ f! { } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { - if ((*cmsg).cmsg_len as size_t) < mem::size_of::() { + if ((*cmsg).cmsg_len as size_t) < size_of::() { core::ptr::null_mut::() - } else if __CMSG_NEXT(cmsg).add(mem::size_of::()) >= __MHDR_END(mhdr) { + } else if __CMSG_NEXT(cmsg).add(size_of::()) >= __MHDR_END(mhdr) { core::ptr::null_mut::() } else { __CMSG_NEXT(cmsg).cast() @@ -3319,7 +3319,7 @@ f! { } pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as size_t >= mem::size_of::() { + if (*mhdr).msg_controllen as size_t >= size_of::() { (*mhdr).msg_control.cast() } else { core::ptr::null_mut::() @@ -3327,15 +3327,15 @@ f! { } pub {const} fn CMSG_ALIGN(len: size_t) -> size_t { - (len + mem::size_of::() - 1) & !(mem::size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } pub {const} fn CMSG_SPACE(len: c_uint) -> c_uint { - (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(mem::size_of::())) as c_uint + (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(size_of::())) as c_uint } pub {const} fn CMSG_LEN(len: c_uint) -> c_uint { - (CMSG_ALIGN(mem::size_of::()) + len as size_t) as c_uint + (CMSG_ALIGN(size_of::()) + len as size_t) as c_uint } } @@ -3403,8 +3403,8 @@ safe_f! { } fn __CMSG_LEN(cmsg: *const cmsghdr) -> ssize_t { - ((unsafe { (*cmsg).cmsg_len as size_t } + mem::size_of::() - 1) - & !(mem::size_of::() - 1)) as ssize_t + ((unsafe { (*cmsg).cmsg_len as size_t } + size_of::() - 1) & !(size_of::() - 1)) + as ssize_t } fn __CMSG_NEXT(cmsg: *const cmsghdr) -> *mut c_uchar { diff --git a/src/macros.rs b/src/macros.rs index aac47561d2fbd..5f2a08d5de32d 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -77,6 +77,8 @@ macro_rules! prelude { pub(crate) use ::core::option::Option; #[allow(unused_imports)] pub(crate) use ::core::{fmt, hash, iter, mem}; + #[allow(unused_imports)] + pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; // Commonly used types defined in this crate #[allow(unused_imports)] diff --git a/src/primitives.rs b/src/primitives.rs index 668d3340d2abb..307a5dafaa9cb 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -151,16 +151,16 @@ cfg_if! { // // catch the fact that llvm and gcc disagree on how x64 __int128 // // is actually *passed* on the stack (clang underaligns it for // // the same reason that rustc *never* properly aligns it). - // static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128); + // static_assert_eq!(size_of::<__int128>(), _SIZE_128); + // static_assert_eq!(align_of::<__int128>(), _ALIGN_128); - // static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128); + // static_assert_eq!(size_of::<__uint128>(), _SIZE_128); + // static_assert_eq!(align_of::<__uint128>(), _ALIGN_128); - // static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128); + // static_assert_eq!(size_of::<__int128_t>(), _SIZE_128); + // static_assert_eq!(align_of::<__int128_t>(), _ALIGN_128); - // static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); - // static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); + // static_assert_eq!(size_of::<__uint128_t>(), _SIZE_128); + // static_assert_eq!(align_of::<__uint128_t>(), _ALIGN_128); } } diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index 9929e70e61e63..fd9c0b168aba4 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -99,7 +99,7 @@ pub struct pthread_attr_t { #[repr(C)] pub struct cpu_set_t { - bits: [c_ulong; 128 / core::mem::size_of::()], + bits: [c_ulong; 128 / size_of::()], } #[repr(C)] @@ -137,7 +137,7 @@ pub struct mbstate_t { #[repr(C)] pub struct sem_t { - pub __val: [c_int; 4 * core::mem::size_of::() / core::mem::size_of::()], + pub __val: [c_int; 4 * size_of::() / size_of::()], } #[repr(C)] @@ -1342,7 +1342,7 @@ pub fn errno() -> c_int { pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = core::mem::size_of_val(&cpuset.bits[0]); + let size_of_mask = size_of_val(&cpuset.bits[0]); for i in cpuset.bits[..(size / size_of_mask)].iter() { s += i.count_ones(); @@ -1351,5 +1351,5 @@ pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(core::mem::size_of::(), cpuset) + CPU_COUNT_S(size_of::(), cpuset) } diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 985a44c41f5ed..13feca788cb3d 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2434,7 +2434,7 @@ pub const ACCOUNTING: c_short = 9; f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::() { + if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { core::ptr::null_mut::() @@ -2445,7 +2445,7 @@ f! { if cmsg.is_null() { CMSG_FIRSTHDR(mhdr) } else { - if (cmsg as usize + (*cmsg).cmsg_len as usize + mem::size_of::()) + if (cmsg as usize + (*cmsg).cmsg_len as usize + size_of::()) > ((*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize) { core::ptr::null_mut::() @@ -2457,15 +2457,15 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(mem::size_of::() as isize) + (cmsg as *mut c_uchar).offset(size_of::() as isize) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - mem::size_of::() as c_uint + length + size_of::() as c_uint + length } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - mem::size_of::() as c_uint + length + size_of::() as c_uint + length } pub fn FD_ZERO(set: *mut fd_set) -> () { @@ -2475,21 +2475,21 @@ f! { } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of::() * 8; + let bits = size_of::() * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of::() * 8; + let bits = size_of::() * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of::() * 8; + let bits = size_of::() * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 14b35e200ec39..0535336e34511 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4642,7 +4642,7 @@ pub const PROC_PIDVNODEPATHINFO: c_int = 9; pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; pub const PROC_PIDLISTFDS: c_int = 1; -pub const PROC_PIDLISTFD_SIZE: c_int = mem::size_of::() as c_int; +pub const PROC_PIDLISTFD_SIZE: c_int = size_of::() as c_int; pub const PROX_FDTYPE_ATALK: c_int = 0; pub const PROX_FDTYPE_VNODE: c_int = 1; pub const PROX_FDTYPE_SOCKET: c_int = 2; @@ -5129,48 +5129,42 @@ pub const VMADDR_CID_HOST: c_uint = 2; pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; const fn __DARWIN_ALIGN32(p: usize) -> usize { - const __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; + const __DARWIN_ALIGNBYTES32: usize = size_of::() - 1; (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32 } pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) - as mach_msg_type_number_t; + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) - as mach_msg_type_number_t; + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) - as mach_msg_type_number_t; + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) - as mach_msg_type_number_t; + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = - (mem::size_of::() / mem::size_of::()) - as mach_msg_type_number_t; + (size_of::() / size_of::()) as mach_msg_type_number_t; pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = - (mem::size_of::() / mem::size_of::()) as u32; + (size_of::() / size_of::()) as u32; pub const MACH_TASK_BASIC_INFO_COUNT: u32 = - (mem::size_of::() / mem::size_of::()) as u32; -pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = (mem::size_of::() - / mem::size_of::()) - as mach_msg_type_number_t; + (size_of::() / size_of::()) as u32; +pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) as mach_msg_type_number_t; // bsd/net/if_mib.h /// Non-interface-specific @@ -5209,7 +5203,7 @@ f! { let cmsg_len = (*cmsg).cmsg_len as usize; let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; - if next + __DARWIN_ALIGN32(mem::size_of::()) > max { + if next + __DARWIN_ALIGN32(size_of::()) > max { core::ptr::null_mut() } else { next as *mut cmsghdr @@ -5217,15 +5211,15 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).add(__DARWIN_ALIGN32(mem::size_of::())) + (cmsg as *mut c_uchar).add(__DARWIN_ALIGN32(size_of::())) } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (__DARWIN_ALIGN32(mem::size_of::()) + __DARWIN_ALIGN32(length as usize)) as c_uint + (__DARWIN_ALIGN32(size_of::()) + __DARWIN_ALIGN32(length as usize)) as c_uint } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - (__DARWIN_ALIGN32(mem::size_of::()) + length as usize) as c_uint + (__DARWIN_ALIGN32(size_of::()) + length as usize) as c_uint } pub {const} fn VM_MAKE_TAG(id: u8) -> u32 { diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 8ecb3336277dd..bf2c06383d92e 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -949,7 +949,7 @@ pub const CPUCTL_MSRSBIT: c_int = 0xc0106305; pub const CPUCTL_MSRCBIT: c_int = 0xc0106306; pub const CPUCTL_CPUID_COUNT: c_int = 0xc0106307; -pub const CPU_SETSIZE: size_t = mem::size_of::() * 8; +pub const CPU_SETSIZE: size_t = size_of::() * 8; pub const EVFILT_READ: i16 = -1; pub const EVFILT_WRITE: i16 = -2; @@ -1421,23 +1421,23 @@ pub const RTAX_MAX: c_int = 11; const_fn! { {const} fn _CMSG_ALIGN(n: usize) -> usize { - (n + (mem::size_of::() - 1)) & !(mem::size_of::() - 1) + (n + (size_of::() - 1)) & !(size_of::() - 1) } } f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - (_CMSG_ALIGN(mem::size_of::()) + length as usize) as c_uint + (_CMSG_ALIGN(size_of::()) + length as usize) as c_uint } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize) - + _CMSG_ALIGN(mem::size_of::()); + + _CMSG_ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next <= max { (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr @@ -1447,7 +1447,7 @@ f! { } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_CMSG_ALIGN(mem::size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint + (_CMSG_ALIGN(size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 7f5693dcf5d5c..e74c26bb46e2c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -33,7 +33,7 @@ s_no_extra_traits! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; cfg_if! { if #[cfg(feature = "extra_traits")] { diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 27eeafe200f53..c17e12913d8f8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -43,7 +43,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 9016ca0a99703..1ab5623ae5b47 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4726,19 +4726,18 @@ const_fn! { f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).add(_ALIGN(mem::size_of::())) + (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _ALIGN(mem::size_of::()) as c_uint + length + _ALIGN(size_of::()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); } - let next = - cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::()); + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { core::ptr::null_mut::() @@ -4748,7 +4747,7 @@ f! { } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_ALIGN(mem::size_of::()) + _ALIGN(length as usize)) as c_uint + (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint } pub fn MALLOCX_ALIGN(lg: c_uint) -> c_int { @@ -4765,7 +4764,7 @@ f! { pub fn SOCKCREDSIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::() + mem::size_of::() * ngrps + size_of::() + size_of::() * ngrps } pub fn uname(buf: *mut crate::utsname) -> c_int { @@ -4785,27 +4784,27 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * mem::size_of::(); + let bitset_bits = 8 * size_of::(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] |= 1 << offset; } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) -> () { - let bitset_bits = 8 * mem::size_of::(); + let bitset_bits = 8 * size_of::(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] &= !(1 << offset); } pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { - let bitset_bits = 8 * mem::size_of::(); + let bitset_bits = 8 * size_of::(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); 0 != cpuset.__bits[idx] & (1 << offset) } pub fn CPU_COUNT(cpuset: &cpuset_t) -> c_int { let mut s: u32 = 0; - let cpuset_size = mem::size_of::(); - let bitset_size = mem::size_of::(); + let cpuset_size = size_of::(); + let bitset_size = size_of::(); for i in cpuset.__bits[..(cpuset_size / bitset_size)].iter() { s += i.count_ones(); @@ -4815,7 +4814,7 @@ f! { pub fn SOCKCRED2SIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::() + mem::size_of::() * ngrps + size_of::() + size_of::() * ngrps } pub fn PROT_MAX(x: c_int) -> c_int { diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index a6d9ed6d7f4da..e4275b10ba508 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -53,7 +53,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 87b425ad9b096..b5a81311ecc60 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -53,7 +53,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index bc065cfa58fae..5ae5d34a74660 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -107,7 +107,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index b739719340438..5becde55db43e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -124,7 +124,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index 4ee20901436cf..27addc6361d1e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -317,7 +317,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 644e035e2c67a..6d32a1dc95a48 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -427,7 +427,7 @@ cfg_if! { } // Non-public helper constant -const SIZEOF_LONG: usize = mem::size_of::(); +const SIZEOF_LONG: usize = size_of::(); #[deprecated( since = "0.2.64", diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index f2f17f4681a56..cb83ccdc7efc0 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -573,7 +573,7 @@ pub const RTAX_BRD: c_int = 7; f! { pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::() { + if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control.cast::() } else { core::ptr::null_mut() @@ -581,20 +581,20 @@ f! { } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index b511fc8457752..e0206af04f8f1 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -65,7 +65,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/arm.rs b/src/unix/bsd/netbsdlike/netbsd/arm.rs index b252862dfe650..9ff44bd40826a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -3,7 +3,7 @@ use crate::PT_FIRSTMACH; pub type __cpu_simple_lock_nv_t = c_int; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; diff --git a/src/unix/bsd/netbsdlike/netbsd/mips.rs b/src/unix/bsd/netbsdlike/netbsd/mips.rs index eabfe1bbcc1e8..1b24b4f6e3159 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mips.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -3,7 +3,7 @@ use crate::PT_FIRSTMACH; pub type __cpu_simple_lock_nv_t = c_int; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 7bcb55ac25d9e..1367276762d61 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2285,19 +2285,18 @@ const_fn! { f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).add(_ALIGN(mem::size_of::())) + (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _ALIGN(mem::size_of::()) as c_uint + length + _ALIGN(size_of::()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); } - let next = - cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::()); + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { core::ptr::null_mut::() @@ -2307,7 +2306,7 @@ f! { } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_ALIGN(mem::size_of::()) + _ALIGN(length as usize)) as c_uint + (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint } // dirfd() is a macro on netbsd to access @@ -2319,7 +2318,7 @@ f! { pub fn SOCKCREDSIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::() + mem::size_of::() * ngrps + size_of::() + size_of::() * ngrps } pub fn PROT_MPROTECT(x: c_int) -> c_int { diff --git a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs index fc4cc3898e12a..f8f2d56c0d374 100644 --- a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -3,7 +3,7 @@ use crate::PT_FIRSTMACH; pub type __cpu_simple_lock_nv_t = c_int; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_STEP: c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 550c3bd7bb4ea..47240cb2818c0 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -22,7 +22,7 @@ s_no_extra_traits! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86.rs b/src/unix/bsd/netbsdlike/netbsd/x86.rs index 92e160d9bca0c..95f55768973ca 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -2,4 +2,4 @@ use crate::prelude::*; pub type __cpu_simple_lock_nv_t = c_uchar; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index 5d31c0661e9c6..77daa4b1e9eb2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -20,7 +20,7 @@ s! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_STEP: c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs index 2c4b1df26ce83..e0d347fb5e6b8 100644 --- a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -15,6 +15,6 @@ s! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/arm.rs b/src/unix/bsd/netbsdlike/openbsd/arm.rs index ae91cde0a1739..8b3f72139d86e 100644 --- a/src/unix/bsd/netbsdlike/openbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index d0bb4badac271..3a7aeadf4656d 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1633,7 +1633,7 @@ pub const NTFS_MFLAG_ALLNAMES: c_int = 0x2; pub const TMPFS_ARGS_VERSION: c_int = 1; const SI_MAXSZ: size_t = 128; -const SI_PAD: size_t = (SI_MAXSZ / mem::size_of::()) - 3; +const SI_PAD: size_t = (SI_MAXSZ / size_of::()) - 3; pub const MAP_STACK: c_int = 0x4000; pub const MAP_CONCEAL: c_int = 0x8000; @@ -1859,19 +1859,18 @@ const_fn! { f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).offset(_ALIGN(size_of::()) as isize) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _ALIGN(mem::size_of::()) as c_uint + length + _ALIGN(size_of::()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); } - let next = - cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::()); + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { core::ptr::null_mut::() @@ -1881,7 +1880,7 @@ f! { } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_ALIGN(mem::size_of::()) + _ALIGN(length as usize)) as c_uint + (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint } } diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs index ae91cde0a1739..8b3f72139d86e 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = 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 1c3d8df3b7956..5ebe85741454e 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = 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 a0865406b80f3..3545763d12c54 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -20,6 +20,6 @@ s! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86.rs b/src/unix/bsd/netbsdlike/openbsd/x86.rs index d2cf7832edd7f..97dc58327d222 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = 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 33a19f969ac97..984570c387013 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -98,7 +98,7 @@ cfg_if! { } } -pub(crate) const _ALIGNBYTES: usize = mem::size_of::() - 1; +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index b03c882027037..2353f68dbc153 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -272,7 +272,7 @@ s! { } pub struct fd_set { - fds_bits: [fd_mask; FD_SETSIZE / core::mem::size_of::() / 8], + fds_bits: [fd_mask; FD_SETSIZE / size_of::() / 8], } pub struct _uc_fpxreg { @@ -1774,19 +1774,19 @@ pub const FALLOC_FL_KEEP_SIZE: c_int = 0x1000; f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = core::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = core::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = core::mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); } @@ -1798,13 +1798,13 @@ f! { pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = cpu_set_t { bits: [0; 16] }; - let size_in_bits = 8 * core::mem::size_of_val(&_dummy.bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = core::mem::size_of_val(&cpuset.bits[0]); + let size_of_mask = size_of_val(&cpuset.bits[0]); for i in cpuset.bits[..(size / size_of_mask)].iter() { s += i.count_ones(); } @@ -1817,7 +1817,7 @@ f! { } } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * core::mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); if cpu < size_in_bits { let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; @@ -1825,7 +1825,7 @@ f! { } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * core::mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); if cpu < size_in_bits { let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); @@ -1833,7 +1833,7 @@ f! { } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * core::mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); if cpu < size_in_bits { let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) @@ -1843,7 +1843,7 @@ f! { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(::core::mem::size_of::(), cpuset) + CPU_COUNT_S(size_of::(), cpuset) } pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { @@ -1851,15 +1851,15 @@ f! { } pub fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(::core::mem::size_of::()) as c_uint + length + CMSG_ALIGN(size_of::()) as c_uint + length } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::core::mem::size_of::())) as c_uint + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= core::mem::size_of::() { + if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control.cast() } else { core::ptr::null_mut() @@ -1869,7 +1869,7 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; - if next as usize + CMSG_ALIGN(::core::mem::size_of::()) as usize > max { + if next as usize + CMSG_ALIGN(size_of::()) as usize > max { core::ptr::null_mut() } else { next @@ -1931,7 +1931,7 @@ safe_f! { const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { - len + core::mem::size_of::() - 1 & !(::core::mem::size_of::() - 1) + len + size_of::() - 1 & !(size_of::() - 1) } } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 9d04266c794da..790591fc0b9f7 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1505,13 +1505,13 @@ pub const POSIX_SPAWN_SETSID: c_int = 0x40; const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::() - 1 & !(mem::size_of::() - 1) + len + size_of::() - 1 & !(size_of::() - 1) } } f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::() { + if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { core::ptr::null_mut::() @@ -1519,15 +1519,15 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::())) as c_uint + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::()) as c_uint + length + CMSG_ALIGN(size_of::()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { @@ -1536,7 +1536,7 @@ f! { } let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize) - + CMSG_ALIGN(mem::size_of::()); + + CMSG_ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { core::ptr::null_mut::() @@ -1547,20 +1547,20 @@ f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 446c2fa0433e9..082e85b326ead 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -1298,17 +1298,12 @@ extern "C" { // The following functions are defined as macros in C/C++ #[inline] pub unsafe fn get_cpu_info(firstCPU: u32, cpuCount: u32, info: *mut cpu_info) -> status_t { - _get_cpu_info_etc( - firstCPU, - cpuCount, - info, - core::mem::size_of::() as size_t, - ) + _get_cpu_info_etc(firstCPU, cpuCount, info, size_of::() as size_t) } #[inline] pub unsafe fn get_area_info(id: area_id, info: *mut area_info) -> status_t { - _get_area_info(id, info, core::mem::size_of::() as usize) + _get_area_info(id, info, size_of::() as usize) } #[inline] @@ -1317,17 +1312,12 @@ pub unsafe fn get_next_area_info( cookie: *mut isize, info: *mut area_info, ) -> status_t { - _get_next_area_info( - team, - cookie, - info, - core::mem::size_of::() as usize, - ) + _get_next_area_info(team, cookie, info, size_of::() as usize) } #[inline] pub unsafe fn get_port_info(port: port_id, buf: *mut port_info) -> status_t { - _get_port_info(port, buf, core::mem::size_of::() as size_t) + _get_port_info(port, buf, size_of::() as size_t) } #[inline] @@ -1336,12 +1326,7 @@ pub unsafe fn get_next_port_info( cookie: *mut i32, portInfo: *mut port_info, ) -> status_t { - _get_next_port_info( - port, - cookie, - portInfo, - core::mem::size_of::() as size_t, - ) + _get_next_port_info(port, cookie, portInfo, size_of::() as size_t) } #[inline] @@ -1354,7 +1339,7 @@ pub unsafe fn get_port_message_info_etc( _get_port_message_info_etc( port, info, - core::mem::size_of::() as size_t, + size_of::() as size_t, flags, timeout, ) @@ -1362,42 +1347,32 @@ pub unsafe fn get_port_message_info_etc( #[inline] pub unsafe fn get_sem_info(id: sem_id, info: *mut sem_info) -> status_t { - _get_sem_info(id, info, core::mem::size_of::() as size_t) + _get_sem_info(id, info, size_of::() as size_t) } #[inline] pub unsafe fn get_next_sem_info(team: team_id, cookie: *mut i32, info: *mut sem_info) -> status_t { - _get_next_sem_info( - team, - cookie, - info, - core::mem::size_of::() as size_t, - ) + _get_next_sem_info(team, cookie, info, size_of::() as size_t) } #[inline] pub unsafe fn get_team_info(team: team_id, info: *mut team_info) -> status_t { - _get_team_info(team, info, core::mem::size_of::() as size_t) + _get_team_info(team, info, size_of::() as size_t) } #[inline] pub unsafe fn get_next_team_info(cookie: *mut i32, info: *mut team_info) -> status_t { - _get_next_team_info(cookie, info, core::mem::size_of::() as size_t) + _get_next_team_info(cookie, info, size_of::() as size_t) } #[inline] pub unsafe fn get_team_usage_info(team: team_id, who: i32, info: *mut team_usage_info) -> status_t { - _get_team_usage_info( - team, - who, - info, - core::mem::size_of::() as size_t, - ) + _get_team_usage_info(team, who, info, size_of::() as size_t) } #[inline] pub unsafe fn get_thread_info(id: thread_id, info: *mut thread_info) -> status_t { - _get_thread_info(id, info, core::mem::size_of::() as size_t) + _get_thread_info(id, info, size_of::() as size_t) } #[inline] @@ -1406,18 +1381,13 @@ pub unsafe fn get_next_thread_info( cookie: *mut i32, info: *mut thread_info, ) -> status_t { - _get_next_thread_info( - team, - cookie, - info, - core::mem::size_of::() as size_t, - ) + _get_next_thread_info(team, cookie, info, size_of::() as size_t) } // kernel/image.h #[inline] pub unsafe fn get_image_info(image: image_id, info: *mut image_info) -> status_t { - _get_image_info(image, info, core::mem::size_of::() as size_t) + _get_image_info(image, info, size_of::() as size_t) } #[inline] @@ -1426,10 +1396,5 @@ pub unsafe fn get_next_image_info( cookie: *mut i32, info: *mut image_info, ) -> status_t { - _get_next_image_info( - team, - cookie, - info, - core::mem::size_of::() as size_t, - ) + _get_next_image_info(team, cookie, info, size_of::() as size_t) } diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 96dd443b3196d..1f7276eb36f1c 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3416,14 +3416,14 @@ const _UTSNAME_LENGTH: usize = 1024; const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { - (len + mem::size_of::() - 1) & !(mem::size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } } // functions f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::() { + if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control.cast::() } else { core::ptr::null_mut::() @@ -3431,19 +3431,19 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::())) as c_uint + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::()) as c_uint + length + CMSG_ALIGN(size_of::()) as c_uint + length } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { - if ((*cmsg).cmsg_len as usize) < mem::size_of::() { + if ((*cmsg).cmsg_len as usize) < size_of::() { return core::ptr::null_mut::(); } let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; @@ -3459,7 +3459,7 @@ f! { pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = mem::zeroed(); - let size_in_bits = 8 * mem::size_of_val(&_dummy.bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } @@ -3470,26 +3470,26 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = mem::size_of_val(&cpuset.bits[0]); + let size_of_mask = size_of_val(&cpuset.bits[0]); for i in cpuset.bits[..(size / size_of_mask)].iter() { s += i.count_ones(); } @@ -3497,7 +3497,7 @@ f! { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(mem::size_of::(), cpuset) + CPU_COUNT_S(size_of::(), cpuset) } pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { @@ -3514,20 +3514,20 @@ f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 8d20394790f57..7201b09982eb7 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3402,7 +3402,7 @@ f! { pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = mem::zeroed(); - let size_in_bits = 8 * mem::size_of_val(&_dummy.__bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.__bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } @@ -3413,28 +3413,28 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] |= 1 << offset; () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] &= !(1 << offset); () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.__bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.__bits[idx] & (1 << offset)) } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = mem::size_of_val(&cpuset.__bits[0]); + let size_of_mask = size_of_val(&cpuset.__bits[0]); for i in cpuset.__bits[..(size / size_of_mask)].iter() { s += i.count_ones(); } @@ -3442,7 +3442,7 @@ f! { } pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { - CPU_COUNT_S(mem::size_of::(), cpuset) + CPU_COUNT_S(size_of::(), cpuset) } pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 57d00d1879930..1d00f3d404ea1 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1365,7 +1365,7 @@ pub const SOMAXCONN: c_int = 128; f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { - if ((*cmsg).cmsg_len as usize) < mem::size_of::() { + if ((*cmsg).cmsg_len as usize) < size_of::() { return core::ptr::null_mut::(); } let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; @@ -1384,21 +1384,21 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index bf973f3b65af6..e4874760155b1 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1,7 +1,5 @@ //! Linux-specific definitions for linux-like values -use core::mem::size_of; - use crate::prelude::*; use crate::{sock_filter, _IO, _IOR, _IOW, _IOWR}; @@ -5960,7 +5958,7 @@ f! { pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { let _dummy: cpu_set_t = mem::zeroed(); - let size_in_bits = 8 * mem::size_of_val(&_dummy.bits[0]); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); ((count as size_t + size_in_bits - 1) / 8) as size_t } @@ -5971,26 +5969,26 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.bits[idx] & (1 << offset)) } pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; - let size_of_mask = mem::size_of_val(&cpuset.bits[0]); + let size_of_mask = size_of_val(&cpuset.bits[0]); for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index a313aac21df09..bbcd382211dfd 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -95,8 +95,11 @@ s! { } pub const MADV_SOFT_OFFLINE: c_int = 101; -#[deprecated(since = "0.2.175", note = "Linux does not define MAP_32BIT on any architectures \ - other than x86 and x86_64, this constant will be removed in the future")] +#[deprecated( + since = "0.2.175", + note = "Linux does not define MAP_32BIT on any architectures \ + other than x86 and x86_64, this constant will be removed in the future" +)] pub const MAP_32BIT: c_int = 0x0040; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x20000; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 42f4efe42aebb..4e0d6124d880a 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1765,17 +1765,17 @@ cfg_if! { /// Build an ioctl number for an read-only ioctl. pub const fn _IOR(ty: u32, nr: u32) -> Ioctl { - _IOC(_IOC_READ, ty, nr, mem::size_of::()) + _IOC(_IOC_READ, ty, nr, size_of::()) } /// Build an ioctl number for an write-only ioctl. pub const fn _IOW(ty: u32, nr: u32) -> Ioctl { - _IOC(_IOC_WRITE, ty, nr, mem::size_of::()) + _IOC(_IOC_WRITE, ty, nr, size_of::()) } /// Build an ioctl number for a read-write ioctl. pub const fn _IOWR(ty: u32, nr: u32) -> Ioctl { - _IOC(_IOC_READ | _IOC_WRITE, ty, nr, mem::size_of::()) + _IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::()) } extern "C" { @@ -1787,13 +1787,13 @@ cfg_if! { const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { - (len + mem::size_of::() - 1) & !(mem::size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } } f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::() { + if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control.cast::() } else { core::ptr::null_mut::() @@ -1805,29 +1805,29 @@ f! { } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::())) as c_uint + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::()) as c_uint + length + CMSG_ALIGN(size_of::()) as c_uint + length } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index d49bdb3e9e18c..0193083f4e63b 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -837,20 +837,20 @@ pub const PRIO_USER: c_int = 2; f! { pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 7270beacacb5a..c5ebdde3868f3 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2310,7 +2310,7 @@ pub const BIOCSHDRCMPLT: c_int = -2147204491; pub const BIOCSRTIMEOUT: c_int = -2146418067; pub const BIOCVERSION: c_int = 1074020977; -pub const BPF_ALIGNMENT: usize = mem::size_of::(); +pub const BPF_ALIGNMENT: usize = size_of::(); pub const CHAR_BIT: usize = 8; pub const CODESET: crate::nl_item = 1; pub const CRNCYSTR: crate::nl_item = 55; @@ -2481,7 +2481,7 @@ pub const SIGEV_NONE: c_int = 0; pub const SIGEV_SIGNAL: c_int = 129; pub const SIGEV_THREAD: c_int = 135; pub const SO_USELOOPBACK: c_int = 0x0040; -pub const _SS_ALIGNSIZE: usize = mem::size_of::(); +pub const _SS_ALIGNSIZE: usize = size_of::(); pub const _SS_MAXSIZE: usize = 128; pub const _SS_PAD1SIZE: usize = _SS_ALIGNSIZE - 2; pub const _SS_PAD2SIZE: usize = _SS_MAXSIZE - 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE; @@ -2609,7 +2609,7 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { const_fn! { {const} fn _CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::() - 1 & !(mem::size_of::() - 1) + len + size_of::() - 1 & !(size_of::() - 1) } {const} fn _ALIGN(p: usize, b: usize) -> usize { @@ -2619,7 +2619,7 @@ const_fn! { f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= mem::size_of::() { + if (*mhdr).msg_controllen as usize >= size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { core::ptr::null_mut::() @@ -2628,7 +2628,7 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let msg = _CMSG_ALIGN((*cmsg).cmsg_len as usize); - let next = cmsg as usize + msg + _CMSG_ALIGN(mem::size_of::()); + let next = cmsg as usize + msg + _CMSG_ALIGN(size_of::()); if next > (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize { core::ptr::null_mut::() } else { @@ -2637,33 +2637,33 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _CMSG_ALIGN(mem::size_of::()) as c_uint + length + _CMSG_ALIGN(size_of::()) as c_uint + length } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (_CMSG_ALIGN(mem::size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint + (_CMSG_ALIGN(size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } @@ -2682,7 +2682,7 @@ f! { } pub fn _DEXTRA_VALID(_x: *const crate::dirent_extra, _d: *const dirent) -> bool { - let sz = _x as usize - _d as usize + mem::size_of::(); + let sz = _x as usize - _d as usize + size_of::(); let rsz = (*_d).d_reclen as usize; if sz > rsz || sz + (*_x).d_datalen as usize > rsz { @@ -2694,14 +2694,14 @@ f! { pub fn _DEXTRA_NEXT(_x: *const crate::dirent_extra) -> *mut crate::dirent_extra { _ALIGN( - _x as usize + mem::size_of::() + (*_x).d_datalen as usize, + _x as usize + size_of::() + (*_x).d_datalen as usize, 8, ) as *mut crate::dirent_extra } pub fn SOCKCREDSIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; - mem::size_of::() + mem::size_of::() * ngrps + size_of::() + size_of::() * ngrps } } diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 9a79d0e280f0c..7420fba229912 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -67,7 +67,7 @@ s_no_extra_traits! { pub struct sockaddr_storage { pub ss_family: crate::sa_family_t, - __ss_padding: [u8; 128 - mem::size_of::() - mem::size_of::()], + __ss_padding: [u8; 128 - size_of::() - size_of::()], __ss_align: c_ulong, } } @@ -1020,32 +1020,32 @@ pub const PRIO_USER: c_int = 2; f! { //sys/socket.h pub {const} fn CMSG_ALIGN(len: size_t) -> size_t { - (len + mem::size_of::() - 1) & !(mem::size_of::() - 1) + (len + size_of::() - 1) & !(size_of::() - 1) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - (CMSG_ALIGN(mem::size_of::()) + length as usize) as c_uint + (CMSG_ALIGN(size_of::()) + length as usize) as c_uint } pub {const} fn CMSG_SPACE(len: c_uint) -> c_uint { - (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(mem::size_of::())) as c_uint + (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(size_of::())) as c_uint } // wait.h pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] &= !(1 << (fd % size)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; - let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let size = size_of_val(&(*set).fds_bits[0]) * 8; (*set).fds_bits[fd / size] |= 1 << (fd % size); return; } diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index addfbe054b85f..48f13cdc59ae4 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1,5 +1,3 @@ -use core::mem::size_of; - use crate::prelude::*; pub type caddr_t = *mut c_char; @@ -2408,7 +2406,7 @@ f! { } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - _CMSG_DATA_ALIGN(mem::size_of::()) as c_uint + length + _CMSG_DATA_ALIGN(size_of::()) as c_uint + length } pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { @@ -2438,20 +2436,20 @@ f! { } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); return; } pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { - let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; + let bits = size_of_val(&(*set).fds_bits[0]) * 8; let fd = fd as usize; (*set).fds_bits[fd / bits] |= 1 << (fd % bits); return; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index deef310db8e0f..f28e5ee7229ba 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1,6 +1,5 @@ //! Interface to VxWorks C library -use core::mem::size_of; use core::ptr::null_mut; use crate::prelude::*; @@ -1074,13 +1073,13 @@ impl Clone for fpos_t { f! { pub {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::() - 1 & !(mem::size_of::() - 1) + len + size_of::() - 1 & !(size_of::() - 1) } pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { let next = cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize) - + CMSG_ALIGN(mem::size_of::()); + + CMSG_ALIGN(size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next <= max { (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr @@ -1098,15 +1097,15 @@ f! { } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(CMSG_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(mem::size_of::())) as c_uint + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(mem::size_of::()) as c_uint + length + CMSG_ALIGN(size_of::()) as c_uint + length } } From cea95cbcf6f29f1f9f4b3c112b86cf7dbb09c397 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 16:58:24 +0000 Subject: [PATCH 41/93] Add `--check` to `cargo fmt` run in CI `cargo fmt` was being called twice without `--check`, so style was only enforced on files that got checked individually. Remove the redundant call and add `--check` here. (backport ) (cherry picked from commit 1187328757859648aca72c9bff8bb2ad73412f75) --- ci/style.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ci/style.sh b/ci/style.sh index 0d4a4f953dda1..9b7c1ed26b05e 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -9,9 +9,6 @@ cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture command -v rustfmt rustfmt -V -# Run once to cover everything that isn't in `src/` -cargo fmt - # Save a list of all source files tmpfile="file-list~" # trailing tilde for gitignore find src -name '*.rs' > "$tmpfile" @@ -61,7 +58,7 @@ rm "$tmpfile" # Run once from workspace root to get everything that wasn't handled as an # individual file. -cargo fmt +cargo fmt "$check" # Ensure that `sort` output is not locale-dependent export LC_ALL=C From f6e013c5787cec6876082f7cdcde90a816c0feb6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 17:02:48 +0000 Subject: [PATCH 42/93] Format files that were previously not being checked in CI (backport ) (cherry picked from commit 5b14b8922104ace02276fddb759c84aa394142f5) --- libc-test/build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 58f489e5f65d3..022931047ac3c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2921,8 +2921,7 @@ fn test_freebsd(target: &str) { "splice" if Some(14) > freebsd_ver => true, // Those are introduced in FreeBSD 15. - "xktls_session_onedir" | "xktls_session" - if Some(15) > freebsd_ver => true, + "xktls_session_onedir" | "xktls_session" if Some(15) > freebsd_ver => true, _ => false, } From 310a79bf02ce35de56918eef8c943da75ed2a467 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 21:25:48 +0000 Subject: [PATCH 43/93] Fix style.sh unset variable when run locally (backport ) (cherry picked from commit ae97728280855bd20b59fbbf82d17d9f44a04896) --- ci/style.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/style.sh b/ci/style.sh index 9b7c1ed26b05e..4e425f8806000 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -58,7 +58,7 @@ rm "$tmpfile" # Run once from workspace root to get everything that wasn't handled as an # individual file. -cargo fmt "$check" +cargo fmt ${check:+"$check"} # Ensure that `sort` output is not locale-dependent export LC_ALL=C From 46673b8380754f49778a667cb1561a9da2bd16c4 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 14 Jun 2025 14:39:58 -0600 Subject: [PATCH 44/93] Fix CI on FreeBSD 15 A recent change has replaced an unused preprocessor symbol: P_UNUSED3 https://github.com/freebsd/freebsd-src/commit/33be1632047c05dbfcc139476e05f49c3a86d560 Another recent change has changed the size of a spare field: mc_spare https://github.com/freebsd/freebsd-src/commit/eea3e4dd9703a252509d75814049aa8da5007ebb (backport ) (cherry picked from commit 46b90a84f10929ae4b16dec2a07328f94b8bc2f5) --- libc-test/build.rs | 4 +++- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 022931047ac3c..f620e0659c0eb 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2641,7 +2641,7 @@ fn test_freebsd(target: &str) { "TDF_CANSWAP" | "TDF_SWAPINREQ" => true, // Unaccessible in FreeBSD 15 - "TDI_SWAPPED" | "P_SWAPPINGOUT" | "P_SWAPPINGIN" => true, + "TDI_SWAPPED" | "P_SWAPPINGOUT" | "P_SWAPPINGIN" | "P_UNUSED3" => true, // Removed in FreeBSD 14 (git a6b55ee6be1) "IFF_KNOWSEPOCH" => true, @@ -3062,6 +3062,8 @@ fn test_freebsd(target: &str) { // `tcp_snd_wscale` and `tcp_rcv_wscale` are bitfields ("tcp_info", "tcp_snd_wscale") => true, ("tcp_info", "tcp_rcv_wscale") => true, + // mc_spare can change in size between OS releases. It's a spare field, after all. + ("__mcontext", "mc_spare") => true, _ => false, } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 1ab5623ae5b47..3466e3b38d8cb 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4217,7 +4217,9 @@ pub const TDI_IWAIT: c_int = 0x0010; pub const P_ADVLOCK: c_int = 0x00000001; pub const P_CONTROLT: c_int = 0x00000002; pub const P_KPROC: c_int = 0x00000004; +#[deprecated(since = "1.0", note = "Replaced in FreeBSD 15 by P_IDLEPROC")] pub const P_UNUSED3: c_int = 0x00000008; +pub const P_IDLEPROC: c_int = 0x00000008; pub const P_PPWAIT: c_int = 0x00000010; pub const P_PROFIL: c_int = 0x00000020; pub const P_STOPPROF: c_int = 0x00000040; From d1ac77eede20ecf9b052de5cf9d2d8735c23909d Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Thu, 3 Jul 2025 04:45:07 +0200 Subject: [PATCH 45/93] ci/docs: Build and check powerpc64le-unknown-linux-musl Now that all of the issues with powerpc64 + musl are resolved, let's make sure it won't regress in the future and also build the documentation for it. Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 28ea7a98cac428db6a90db2aa8cde409e06e65f5) --- .github/workflows/ci.yaml | 4 ++++ Cargo.toml | 1 + .../powerpc64le-unknown-linux-musl/Dockerfile | 15 +++++++++++++++ ci/install-musl.sh | 7 +++++++ ci/verify-build.sh | 3 +++ 5 files changed, 30 insertions(+) create mode 100644 ci/docker/powerpc64le-unknown-linux-musl/Dockerfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6678e42b6adb3..789d1f40b5cd5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -187,6 +187,7 @@ jobs: - loongarch64-unknown-linux-musl - powerpc64-unknown-linux-gnu - powerpc64le-unknown-linux-gnu + - powerpc64le-unknown-linux-musl - riscv64gc-unknown-linux-gnu - s390x-unknown-linux-gnu - wasm32-unknown-emscripten @@ -221,6 +222,9 @@ jobs: - target: loongarch64-unknown-linux-musl env: RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: powerpc64le-unknown-linux-musl + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu diff --git a/Cargo.toml b/Cargo.toml index 9ac66aaeabc01..8e043b7b47f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,6 +77,7 @@ targets = [ "powerpc64-unknown-linux-gnu", "powerpc64-wrs-vxworks", "powerpc64le-unknown-linux-gnu", + "powerpc64le-unknown-linux-musl", "riscv32gc-unknown-linux-gnu", "riscv32i-unknown-none-elf", "riscv32imac-unknown-none-elf", diff --git a/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile new file mode 100644 index 0000000000000..b25f284eddf7a --- /dev/null +++ b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:24.10 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc make libc6-dev git curl ca-certificates \ + gcc-powerpc64le-linux-gnu qemu-user xz-utils patch rsync + +COPY install-musl.sh / +RUN /install-musl.sh powerpc64le + +# FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? +ENV PATH=$PATH:/musl-powerpc64/bin:/rust/bin \ + CC_powerpc64le_unknown_linux_musl=musl-gcc \ + RUSTFLAGS='-Clink-args=-lgcc -L /musl-powerpc64/lib' \ + CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \ + CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_MUSL_RUNNER="qemu-ppc64le -L /musl-powerpc64" diff --git a/ci/install-musl.sh b/ci/install-musl.sh index d3752a900ba6d..ca8368a7074df 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -68,6 +68,13 @@ case ${1} in ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes make install -j4 ;; + powerpc64*) + musl_arch=powerpc64 + kernel_arch=powerpc + CC="${1}-linux-gnu-gcc" CFLAGS="-mlong-double-64" \ + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + make install -j4 + ;; *) echo "Unknown target arch: \"${1}\"" exit 1 diff --git a/ci/verify-build.sh b/ci/verify-build.sh index f19ed9d774a08..85dff451e3863 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -161,11 +161,14 @@ x86_64-unknown-linux-musl \ x86_64-unknown-netbsd \ " +# FIXME(powerpc64le): powerpc64le-unknown-linux-musl is tier 2 since 1.85 and +# can be moved to rust_linux_targets once MSRV is increased rust_nightly_linux_targets="\ aarch64-unknown-fuchsia \ armv5te-unknown-linux-gnueabi \ armv5te-unknown-linux-musleabi \ i686-pc-windows-gnu \ +powerpc64le-unknown-linux-musl \ riscv64gc-unknown-linux-gnu \ x86_64-fortanix-unknown-sgx \ x86_64-pc-solaris \ From 0956e2a96c3c82393f72f4559ae47764b3746792 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 17:10:24 +0000 Subject: [PATCH 46/93] Add a lockfile and upgrade dependencies `ctest` is horribly inconsistent across targets for unclear reasons. It seems unlikely, but one possibility is that different versions of dependencies are getting used on different platforms. Attempt to mitigate this by adding a lockfile and upgrading all `Cargo.toml` dependencies to the latest version. (backport ) (cherry picked from commit fb3281c92be593ff5fdf6b663f21f408789b864e) --- .gitignore | 1 - Cargo.lock | 421 +++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- libc-test/Cargo.toml | 8 +- 4 files changed, 426 insertions(+), 6 deletions(-) create mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index f0ff2599d09b5..7aef3038432cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ target -Cargo.lock *~ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000000..76360464c7c7e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,421 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "annotate-snippets" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710e8eae58854cdc1790fcb56cca04d712a17be849eeb81da2a724bf4bae2bc4" +dependencies = [ + "anstyle", + "unicode-width", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "cc" +version = "1.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + +[[package]] +name = "ctest" +version = "0.1.0" + +[[package]] +name = "ctest-next" +version = "0.1.0" + +[[package]] +name = "ctest2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cf53ed2a9e25d98cd444fd6e73eae7de0a26a8cb9e3f998170c6901a1afa0e5" +dependencies = [ + "cc", + "garando_syntax", + "rustc_version", +] + +[[package]] +name = "dirs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +dependencies = [ + "cfg-if 0.1.10", + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_users", + "winapi", +] + +[[package]] +name = "garando_errors" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18495ec4aced5922809efe4d2862918ff0e8d75e122bde57bba9bae45965256a" +dependencies = [ + "garando_pos", + "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", + "term", + "unicode-xid", +] + +[[package]] +name = "garando_pos" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9386fc75dca486daefbbf5a8d2ea6f379237f95c9b982776159cd66f220aaf" +dependencies = [ + "serde", +] + +[[package]] +name = "garando_syntax" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8a383861d12fc78c251bbcb1ec252dd8338714ce02ab0cc393cfd02f40d32b" +dependencies = [ + "bitflags 1.3.2", + "garando_errors", + "garando_pos", + "log", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if 1.0.1", + "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "libc" +version = "0.2.174" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "libc-test" +version = "0.1.0" +dependencies = [ + "annotate-snippets", + "cc", + "cfg-if 1.0.1", + "ctest2", + "glob", + "libc 0.2.174", + "proc-macro2", + "regex", + "syn", +] + +[[package]] +name = "libredox" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" +dependencies = [ + "bitflags 2.9.1", + "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustc-std-workspace-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "term" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" +dependencies = [ + "dirs", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-width" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 8e043b7b47f61..eb60f04af2f85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -129,7 +129,7 @@ targets = [ cargo-args = ["-Zbuild-std=core"] [dependencies] -rustc-std-workspace-core = { version = "1.0.0", optional = true } +rustc-std-workspace-core = { version = "1.0.1", optional = true } [features] default = ["std"] diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 6379029be07a9..4d9331798a375 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -9,17 +9,17 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" [dependencies] -cfg-if = "1.0.0" +cfg-if = "1.0.1" libc = { path = "..", version = "0.2.171", default-features = false } [dev-dependencies] -syn = { version = "2.0.91", features = ["full", "visit"] } -proc-macro2 = { version = "1.0.92", features = ["span-locations"] } +syn = { version = "2.0.104", features = ["full", "visit"] } +proc-macro2 = { version = "1.0.95", features = ["span-locations"] } glob = "0.3.2" annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } [build-dependencies] -cc = "1.0.83" +cc = "1.2.29" # FIXME: Use fork ctest until the maintainer gets back. ctest2 = "0.4.3" regex = "1.11.1" From 33cc3133cf203532e8b311422745a4e800001e55 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 22:41:20 +0000 Subject: [PATCH 47/93] cleanup: Remove `allow(missing_debug_implementations)` Since the macros now create a `Debug` implementation for all types, there isn't any need to allow this lint anywhere. (backport ) (cherry picked from commit da7a725ce4cd2925494d0987716a365098e53948) --- src/unix/bsd/apple/b32/mod.rs | 1 - src/unix/bsd/apple/b64/aarch64/mod.rs | 1 - src/unix/bsd/apple/b64/x86_64/mod.rs | 1 - src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 1 - src/unix/cygwin/mod.rs | 1 - src/unix/linux_like/android/b32/x86/mod.rs | 1 - src/unix/linux_like/android/b64/aarch64/mod.rs | 1 - src/unix/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 | 2 -- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 2 -- 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/riscv32/mod.rs | 5 ----- src/unix/linux_like/linux/gnu/b32/sparc/mod.rs | 1 - src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/mips64/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs | 5 ----- src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 1 - src/unix/linux_like/linux/mod.rs | 11 ----------- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 2 -- src/unix/linux_like/linux/musl/b32/mips/mod.rs | 1 - src/unix/linux_like/linux/musl/b32/riscv32/mod.rs | 1 - src/unix/linux_like/linux/musl/b32/x86/mod.rs | 1 - src/unix/linux_like/linux/musl/b64/aarch64/mod.rs | 1 - src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs | 1 - src/unix/linux_like/linux/musl/b64/riscv64/mod.rs | 5 ----- src/unix/linux_like/linux/musl/b64/x86_64/mod.rs | 1 - src/unix/linux_like/linux/uclibc/x86_64/l4re.rs | 2 +- src/unix/linux_like/linux/uclibc/x86_64/mod.rs | 1 - src/unix/solarish/solaris.rs | 3 --- src/wasi/mod.rs | 1 - src/windows/gnu/mod.rs | 2 -- 38 files changed, 1 insertion(+), 66 deletions(-) diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index bdc986da168a8..bd6762558f508 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -60,7 +60,6 @@ s_no_extra_traits! { __opaque: [c_char; crate::__PTHREAD_ONCE_SIZE__], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index e300b76ae8228..a13013c09b03b 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -47,7 +47,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct max_align_t { priv_: f64, } diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index cfb1b8a8a5976..5365becf66c3e 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -172,7 +172,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index 27addc6361d1e..fa85f11ce2812 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -92,7 +92,6 @@ s_no_extra_traits! { pub a_un: __c_anonymous_elf64_auxv_union, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 2353f68dbc153..fde2c18936e71 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -453,7 +453,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index edbfd38552cb5..ca46c3c462246 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -51,7 +51,6 @@ s_no_extra_traits! { __fpregs_mem: _libc_fpstate, } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f64; 2], diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index b678eb8da6aa4..3c6131089ee89 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -85,7 +85,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 8], diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index c4dc98e010aed..ca8c727164ad7 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -55,7 +55,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 8], 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 3288f05e076aa..0fddeb7bc267f 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -112,7 +112,6 @@ s_no_extra_traits! { uc_sigmask64: crate::sigset64_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 1d00f3d404ea1..7a43670536e4f 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -315,7 +315,6 @@ s! { pub ha: [c_uchar; crate::MAX_ADDR_LEN], } - #[allow(missing_debug_implementations)] #[repr(align(4))] pub struct pthread_mutex_t { size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T], @@ -382,7 +381,6 @@ s_no_extra_traits! { size: [u8; crate::__SIZEOF_PTHREAD_COND_T], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], 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 3f81de3545de6..900851ab5f42c 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -232,13 +232,11 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [i64; 2], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct ucontext_t { pub uc_flags: c_ulong, 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 b8f73e2d5414a..95881894a4b94 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -168,7 +168,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [i64; 2], 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 71b3dd316394c..d614fddeca9d9 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -161,7 +161,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(2))] pub struct max_align_t { priv_: [i8; 20], 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 507672f8a974c..db0505a2473de 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -252,7 +252,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f32; 4], 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 d9599ddb582fc..b04ee50462745 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -197,7 +197,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub __uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -206,7 +205,6 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct mcontext_t { pub __gregs: [c_ulong; 32], @@ -219,19 +217,16 @@ s_no_extra_traits! { pub __q: __riscv_mc_q_ext_state, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_f_ext_state { pub __f: [c_uint; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_d_ext_state { pub __f: [c_ulonglong; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct __riscv_mc_q_ext_state { pub __f: [c_ulonglong; 64], 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 cfe2101b4af77..f9d6a95ed036e 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -198,7 +198,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [i64; 3], diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index da6af94375e4f..5f0dfe90adf81 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -287,7 +287,6 @@ s_no_extra_traits! { __ssp: [c_ulong; 4], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 6], 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 b310af8e4e531..28b4e40fde543 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -242,7 +242,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 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 c67177c7067f9..8f15ce4d1529a 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -237,7 +237,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], 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 8bd9542a62f1e..56f30cd08a482 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -187,7 +187,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], 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 5073a8af7a41e..047efe55b1a38 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -194,7 +194,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [i64; 4], 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 6da6eeccca486..bfbc8ee5cf683 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -247,7 +247,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub __uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -256,7 +255,6 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct mcontext_t { pub __gregs: [c_ulong; 32], @@ -269,19 +267,16 @@ s_no_extra_traits! { pub __q: __riscv_mc_q_ext_state, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_f_ext_state { pub __f: [c_uint; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_d_ext_state { pub __f: [c_ulonglong; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct __riscv_mc_q_ext_state { pub __f: [c_ulonglong; 64], 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 cdbd9b43b28c7..c4203dc0b2da4 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -197,7 +197,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [i64; 4], 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 ea8aeda42d63d..f4555ee420230 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 @@ -317,7 +317,6 @@ s_no_extra_traits! { // __ssp: [c_ulonglong; 4], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index e4874760155b1..0146d50b4e39d 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1574,18 +1574,15 @@ s_no_extra_traits! { pub sched_period: crate::__u64, } - #[allow(missing_debug_implementations)] pub union tpacket_req_u { pub req: crate::tpacket_req, pub req3: crate::tpacket_req3, } - #[allow(missing_debug_implementations)] pub union tpacket_bd_header_u { pub bh1: crate::tpacket_hdr_v1, } - #[allow(missing_debug_implementations)] pub struct tpacket_block_desc { pub version: __u32, pub offset_to_priv: __u32, @@ -1746,7 +1743,6 @@ s_no_extra_traits! { } // linux/net_tstamp.h - #[allow(missing_debug_implementations)] pub struct sock_txtime { pub clockid: crate::clockid_t, pub flags: __u32, @@ -1754,7 +1750,6 @@ s_no_extra_traits! { // linux/can.h #[repr(align(8))] - #[allow(missing_debug_implementations)] pub struct can_frame { pub can_id: canid_t, // FIXME(1.0): this field was renamed to `len` in Linux 5.11 @@ -1766,7 +1761,6 @@ s_no_extra_traits! { } #[repr(align(8))] - #[allow(missing_debug_implementations)] pub struct canfd_frame { pub can_id: canid_t, pub len: u8, @@ -1777,7 +1771,6 @@ s_no_extra_traits! { } #[repr(align(8))] - #[allow(missing_debug_implementations)] pub struct canxl_frame { pub prio: canid_t, pub flags: u8, @@ -1787,13 +1780,11 @@ s_no_extra_traits! { pub data: [u8; CANXL_MAX_DLEN], } - #[allow(missing_debug_implementations)] pub union __c_anonymous_sockaddr_can_can_addr { pub tp: __c_anonymous_sockaddr_can_tp, pub j1939: __c_anonymous_sockaddr_can_j1939, } - #[allow(missing_debug_implementations)] pub struct sockaddr_can { pub can_family: crate::sa_family_t, pub can_ifindex: c_int, @@ -1848,7 +1839,6 @@ s_no_extra_traits! { pub rsv: [c_uint; 4], } - #[allow(missing_debug_implementations)] pub struct ptp_perout_request { pub anonymous_1: __c_anonymous_ptp_perout_request_1, pub period: ptp_clock_time, @@ -1858,7 +1848,6 @@ s_no_extra_traits! { } // linux/if_xdp.h - #[allow(missing_debug_implementations)] pub struct xsk_tx_metadata { pub flags: crate::__u64, pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union, 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 b9be033a2c2c4..a04f05ea50db8 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -133,7 +133,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -143,7 +142,6 @@ s_no_extra_traits! { pub uc_regspace: [c_ulonglong; 64], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: (i64, i64), 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 3f2b73decbec6..4f29b27ad0a14 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -147,7 +147,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f32; 4], 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 9b76105969343..0e2f53edcad4c 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -102,7 +102,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: (i64, f64), 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 583e0a51eacb0..ae8b7d761dd6f 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -138,7 +138,6 @@ s_no_extra_traits! { __private: [u8; 112], } - #[allow(missing_debug_implementations)] #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], 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 243247edafc46..67151a8d37116 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -129,7 +129,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f32; 8], 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 17724b528415e..e014fbf48c0da 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -114,7 +114,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], 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 cf851c4660113..8389af961cf58 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -86,7 +86,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct ucontext_t { pub __uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -95,7 +94,6 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct mcontext_t { pub __gregs: [c_ulong; 32], @@ -108,19 +106,16 @@ s_no_extra_traits! { pub __q: __riscv_mc_q_ext_state, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_f_ext_state { pub __f: [c_uint; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] pub struct __riscv_mc_d_ext_state { pub __f: [c_ulonglong; 32], pub __fcsr: c_uint, } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct __riscv_mc_q_ext_state { pub __f: [c_ulonglong; 64], 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 17a9f6ce47475..ce8319f015e97 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 @@ -171,7 +171,6 @@ s_no_extra_traits! { __private: [u8; 512], } - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], 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 b108e77c7cd32..380077711d797 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,7 @@ s! { } } -#[allow(missing_debug_implementations)] +#[cfg_attr(feature = "extra_traits", derive(Debug))] pub struct pthread_attr_t { pub __detachstate: c_int, pub __schedpolicy: c_int, diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index fbc87be74125d..1a2e4bcc1a897 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -293,7 +293,6 @@ s! { } s_no_extra_traits! { - #[allow(missing_debug_implementations)] pub struct dirent { pub d_ino: crate::ino64_t, pub d_off: off64_t, diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 097ff1c9cd6bd..58b097a16269b 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -59,7 +59,6 @@ s! { s_no_extra_traits! { #[repr(packed)] - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub struct door_desc_t__d_data__d_desc { pub d_descriptor: c_int, pub d_id: crate::door_id_t, @@ -70,13 +69,11 @@ s_no_extra_traits! { d_resv: [c_int; 5], /* Check out /usr/include/sys/door.h */ } - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub struct door_desc_t { pub d_attributes: door_attr_t, pub d_data: door_desc_t__d_data, } - #[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))] pub struct door_arg_t { pub data_ptr: *const c_char, pub data_size: size_t, diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 61061918c05fc..4abb2bc1f99e2 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -36,7 +36,6 @@ pub type locale_t = *mut __locale_struct; s_no_extra_traits! { #[repr(align(16))] - #[allow(missing_debug_implementations)] pub struct max_align_t { priv_: [f64; 4], } diff --git a/src/windows/gnu/mod.rs b/src/windows/gnu/mod.rs index a263dfa736bba..aee2c1efed108 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -3,7 +3,6 @@ use crate::prelude::*; cfg_if! { if #[cfg(target_pointer_width = "64")] { s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], @@ -11,7 +10,6 @@ cfg_if! { } } else if #[cfg(target_pointer_width = "32")] { s_no_extra_traits! { - #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [i64; 6], From 8f00e3913bba80303725981f28162b28e4dcc98d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 5 May 2025 02:28:26 +0000 Subject: [PATCH 48/93] Begin source reorganization with `linux/can.h` This is a small module so it is easy to adapt to the future directory structure. Sources: * https://github.com/torvalds/linux/blob/92a09c47464d040866cf2b4cd052bc60555185fb/include/uapi/linux/can.h * https://github.com/torvalds/linux/blob/92a09c47464d040866cf2b4cd052bc60555185fb/include/uapi/linux/can/j1939.h * https://github.com/torvalds/linux/blob/92a09c47464d040866cf2b4cd052bc60555185fb/include/uapi/linux/can/raw.h (backport ) (cherry picked from commit 3356f1217d8dd5a17b4cf3d0e78fe341e98944df) --- src/lib.rs | 4 + src/new/linux_uapi/linux/can.rs | 137 +++++++++++++++++++ src/new/linux_uapi/linux/can/j1939.rs | 60 +++++++++ src/new/linux_uapi/linux/can/raw.rs | 15 +++ src/new/linux_uapi/linux/mod.rs | 4 + src/new/linux_uapi/mod.rs | 4 + src/new/mod.rs | 12 ++ src/unix/linux_like/linux/mod.rs | 185 -------------------------- triagebot.toml | 5 +- 9 files changed, 240 insertions(+), 186 deletions(-) create mode 100644 src/new/linux_uapi/linux/can.rs create mode 100644 src/new/linux_uapi/linux/can/j1939.rs create mode 100644 src/new/linux_uapi/linux/can/raw.rs create mode 100644 src/new/linux_uapi/linux/mod.rs create mode 100644 src/new/linux_uapi/mod.rs create mode 100644 src/new/mod.rs diff --git a/src/lib.rs b/src/lib.rs index a96ffc6ffe8ed..fb901944b22bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,7 @@ #[macro_use] mod macros; +mod new; cfg_if! { if #[cfg(feature = "rustc-dep-of-std")] { @@ -34,6 +35,9 @@ cfg_if! { pub use core::ffi::c_void; +#[allow(unused_imports)] // needed while the module is empty on some platforms +pub use new::*; + cfg_if! { if #[cfg(windows)] { mod primitives; diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs new file mode 100644 index 0000000000000..8fb4b9d6dc972 --- /dev/null +++ b/src/new/linux_uapi/linux/can.rs @@ -0,0 +1,137 @@ +//! Header: `uapi/linux/can.h` + +// FIXME(ctest): we shouldn't have to specify the path but garando doesn't find modules otherwise +#[path = "can/j1939.rs"] +pub(crate) mod j1939; +#[path = "can/raw.rs"] +pub(crate) mod raw; + +pub use j1939::*; +pub use raw::*; + +use crate::prelude::*; + +pub const CAN_EFF_FLAG: canid_t = 0x80000000; +pub const CAN_RTR_FLAG: canid_t = 0x40000000; +pub const CAN_ERR_FLAG: canid_t = 0x20000000; + +pub const CAN_SFF_MASK: canid_t = 0x000007FF; +pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF; +pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF; +pub const CANXL_PRIO_MASK: crate::canid_t = CAN_SFF_MASK; + +pub type canid_t = u32; + +pub const CAN_SFF_ID_BITS: c_int = 11; +pub const CAN_EFF_ID_BITS: c_int = 29; +pub const CANXL_PRIO_BITS: c_int = CAN_SFF_ID_BITS; + +pub type can_err_mask_t = u32; + +pub const CAN_MAX_DLC: c_int = 8; +pub const CAN_MAX_DLEN: usize = 8; + +pub const CANFD_MAX_DLC: c_int = 15; +pub const CANFD_MAX_DLEN: usize = 64; + +pub const CANXL_MIN_DLC: c_int = 0; +pub const CANXL_MAX_DLC: c_int = 2047; +pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; +pub const CANXL_MIN_DLEN: usize = 1; +pub const CANXL_MAX_DLEN: usize = 2048; + +s! { + #[repr(align(8))] + pub struct can_frame { + pub can_id: canid_t, + // FIXME(1.0): this field was renamed to `len` in Linux 5.11 + pub can_dlc: u8, + __pad: u8, + __res0: u8, + pub len8_dlc: u8, + pub data: [u8; CAN_MAX_DLEN], + } +} + +pub const CANFD_BRS: c_int = 0x01; +pub const CANFD_ESI: c_int = 0x02; +pub const CANFD_FDF: c_int = 0x04; + +s! { + #[repr(align(8))] + pub struct canfd_frame { + pub can_id: canid_t, + pub len: u8, + pub flags: u8, + __res0: u8, + __res1: u8, + pub data: [u8; CANFD_MAX_DLEN], + } +} + +pub const CANXL_XLF: c_int = 0x80; +pub const CANXL_SEC: c_int = 0x01; + +s! { + #[repr(align(8))] + pub struct canxl_frame { + pub prio: canid_t, + pub flags: u8, + pub sdt: u8, + pub len: u16, + pub af: u32, + pub data: [u8; CANXL_MAX_DLEN], + } +} + +pub const CAN_MTU: usize = size_of::(); +pub const CANFD_MTU: usize = size_of::(); +pub const CANXL_MTU: usize = size_of::(); +// FIXME(offset_of): use `core::mem::offset_of!` once that is available +// https://github.com/rust-lang/rfcs/pull/3308 +// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); +pub const CANXL_HDR_SIZE: usize = 12; +pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; +pub const CANXL_MAX_MTU: usize = CANXL_MTU; + +pub const CAN_RAW: c_int = 1; +pub const CAN_BCM: c_int = 2; +pub const CAN_TP16: c_int = 3; +pub const CAN_TP20: c_int = 4; +pub const CAN_MCNET: c_int = 5; +pub const CAN_ISOTP: c_int = 6; +pub const CAN_J1939: c_int = 7; +pub const CAN_NPROTO: c_int = 8; + +pub const SOL_CAN_BASE: c_int = 100; + +s_no_extra_traits! { + pub struct sockaddr_can { + pub can_family: crate::sa_family_t, + pub can_ifindex: c_int, + pub can_addr: __c_anonymous_sockaddr_can_can_addr, + } + + pub union __c_anonymous_sockaddr_can_can_addr { + pub tp: __c_anonymous_sockaddr_can_tp, + pub j1939: __c_anonymous_sockaddr_can_j1939, + } + + pub struct __c_anonymous_sockaddr_can_tp { + pub rx_id: canid_t, + pub tx_id: canid_t, + } + + pub struct __c_anonymous_sockaddr_can_j1939 { + pub name: u64, + pub pgn: u32, + pub addr: u8, + } + + pub struct can_filter { + pub can_id: canid_t, + pub can_mask: canid_t, + } +} + +pub const CAN_INV_FILTER: canid_t = 0x20000000; diff --git a/src/new/linux_uapi/linux/can/j1939.rs b/src/new/linux_uapi/linux/can/j1939.rs new file mode 100644 index 0000000000000..fdf425ce6c0c1 --- /dev/null +++ b/src/new/linux_uapi/linux/can/j1939.rs @@ -0,0 +1,60 @@ +//! `linux/can/j1939.h` + +pub use crate::linux::can::*; + +pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd; +pub const J1939_IDLE_ADDR: c_uchar = 0xfe; +pub const J1939_NO_ADDR: c_uchar = 0xff; +pub const J1939_NO_NAME: c_ulong = 0; +pub const J1939_PGN_REQUEST: c_uint = 0x0ea00; +pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00; +pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8; +pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00; +pub const J1939_PGN_MAX: c_uint = 0x3ffff; +pub const J1939_NO_PGN: c_uint = 0x40000; + +pub type pgn_t = u32; +pub type priority_t = u8; +pub type name_t = u64; + +pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939; + +// FIXME(cleanup): these could use c_enum if it can accept anonymous enums. + +pub const SO_J1939_FILTER: c_int = 1; +pub const SO_J1939_PROMISC: c_int = 2; +pub const SO_J1939_SEND_PRIO: c_int = 3; +pub const SO_J1939_ERRQUEUE: c_int = 4; + +pub const SCM_J1939_DEST_ADDR: c_int = 1; +pub const SCM_J1939_DEST_NAME: c_int = 2; +pub const SCM_J1939_PRIO: c_int = 3; +pub const SCM_J1939_ERRQUEUE: c_int = 4; + +pub const J1939_NLA_PAD: c_int = 0; +pub const J1939_NLA_BYTES_ACKED: c_int = 1; +pub const J1939_NLA_TOTAL_SIZE: c_int = 2; +pub const J1939_NLA_PGN: c_int = 3; +pub const J1939_NLA_SRC_NAME: c_int = 4; +pub const J1939_NLA_DEST_NAME: c_int = 5; +pub const J1939_NLA_SRC_ADDR: c_int = 6; +pub const J1939_NLA_DEST_ADDR: c_int = 7; + +pub const J1939_EE_INFO_NONE: c_int = 0; +pub const J1939_EE_INFO_TX_ABORT: c_int = 1; +pub const J1939_EE_INFO_RX_RTS: c_int = 2; +pub const J1939_EE_INFO_RX_DPO: c_int = 3; +pub const J1939_EE_INFO_RX_ABORT: c_int = 4; + +s! { + pub struct j1939_filter { + pub name: name_t, + pub name_mask: name_t, + pub pgn: pgn_t, + pub pgn_mask: pgn_t, + pub addr: u8, + pub addr_mask: u8, + } +} + +pub const J1939_FILTER_MAX: c_int = 512; diff --git a/src/new/linux_uapi/linux/can/raw.rs b/src/new/linux_uapi/linux/can/raw.rs new file mode 100644 index 0000000000000..1f92a13edbba6 --- /dev/null +++ b/src/new/linux_uapi/linux/can/raw.rs @@ -0,0 +1,15 @@ +//! `linux/can/raw.h` + +pub use crate::linux::can::*; + +pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW; +pub const CAN_RAW_FILTER_MAX: c_int = 512; + +// FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type. +pub const CAN_RAW_FILTER: c_int = 1; +pub const CAN_RAW_ERR_FILTER: c_int = 2; +pub const CAN_RAW_LOOPBACK: c_int = 3; +pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4; +pub const CAN_RAW_FD_FRAMES: c_int = 5; +pub const CAN_RAW_JOIN_FILTERS: c_int = 6; +pub const CAN_RAW_XL_FRAMES: c_int = 7; diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs new file mode 100644 index 0000000000000..4a9c04d6396b1 --- /dev/null +++ b/src/new/linux_uapi/linux/mod.rs @@ -0,0 +1,4 @@ +//! The `linux` directory within `include/uapi` in the Linux source tree. + +pub(crate) mod can; +pub use can::*; diff --git a/src/new/linux_uapi/mod.rs b/src/new/linux_uapi/mod.rs new file mode 100644 index 0000000000000..e0d4e094c435f --- /dev/null +++ b/src/new/linux_uapi/mod.rs @@ -0,0 +1,4 @@ +//! This directory maps to `include/uapi` in the Linux source tree. + +pub(crate) mod linux; +pub use linux::*; diff --git a/src/new/mod.rs b/src/new/mod.rs new file mode 100644 index 0000000000000..4006f5c82288d --- /dev/null +++ b/src/new/mod.rs @@ -0,0 +1,12 @@ +//! This module contains the future directory structure. If possible, new definitions should +//! get added here. +//! +//! Eventually everything should be moved over, and we will move this directory to the top +//! level in `src`. + +cfg_if! { + if #[cfg(target_os = "linux")] { + mod linux_uapi; + pub use linux_uapi::*; + } +} diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 0146d50b4e39d..dee6ed53e74fc 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -58,15 +58,6 @@ cfg_if! { } } -// linux/can.h -pub type canid_t = u32; - -// linux/can/j1939.h -pub type can_err_mask_t = u32; -pub type pgn_t = u32; -pub type priority_t = u8; -pub type name_t = u64; - pub type iconv_t = *mut c_void; // linux/sctp.h @@ -730,33 +721,6 @@ s! { pub ee_data: u32, } - // linux/can.h - pub struct __c_anonymous_sockaddr_can_tp { - pub rx_id: canid_t, - pub tx_id: canid_t, - } - - pub struct __c_anonymous_sockaddr_can_j1939 { - pub name: u64, - pub pgn: u32, - pub addr: u8, - } - - pub struct can_filter { - pub can_id: canid_t, - pub can_mask: canid_t, - } - - // linux/can/j1939.h - pub struct j1939_filter { - pub name: name_t, - pub name_mask: name_t, - pub pgn: pgn_t, - pub pgn_mask: pgn_t, - pub addr: u8, - pub addr_mask: u8, - } - // linux/seccomp.h pub struct seccomp_data { pub nr: c_int, @@ -1748,49 +1712,6 @@ s_no_extra_traits! { pub flags: __u32, } - // linux/can.h - #[repr(align(8))] - pub struct can_frame { - pub can_id: canid_t, - // FIXME(1.0): this field was renamed to `len` in Linux 5.11 - pub can_dlc: u8, - __pad: u8, - __res0: u8, - pub len8_dlc: u8, - pub data: [u8; CAN_MAX_DLEN], - } - - #[repr(align(8))] - pub struct canfd_frame { - pub can_id: canid_t, - pub len: u8, - pub flags: u8, - __res0: u8, - __res1: u8, - pub data: [u8; CANFD_MAX_DLEN], - } - - #[repr(align(8))] - pub struct canxl_frame { - pub prio: canid_t, - pub flags: u8, - pub sdt: u8, - pub len: u16, - pub af: u32, - pub data: [u8; CANXL_MAX_DLEN], - } - - pub union __c_anonymous_sockaddr_can_can_addr { - pub tp: __c_anonymous_sockaddr_can_tp, - pub j1939: __c_anonymous_sockaddr_can_j1939, - } - - pub struct sockaddr_can { - pub can_family: crate::sa_family_t, - pub can_ifindex: c_int, - pub can_addr: __c_anonymous_sockaddr_can_can_addr, - } - // linux/wireless.h pub union iwreq_data { pub name: [c_char; crate::IFNAMSIZ], @@ -5401,112 +5322,6 @@ pub const EDOM: c_int = 33; pub const ERANGE: c_int = 34; pub const EWOULDBLOCK: c_int = EAGAIN; -// linux/can.h -pub const CAN_EFF_FLAG: canid_t = 0x80000000; -pub const CAN_RTR_FLAG: canid_t = 0x40000000; -pub const CAN_ERR_FLAG: canid_t = 0x20000000; -pub const CAN_SFF_MASK: canid_t = 0x000007FF; -pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF; -pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF; -pub const CANXL_PRIO_MASK: crate::canid_t = CAN_SFF_MASK; - -pub const CAN_SFF_ID_BITS: c_int = 11; -pub const CAN_EFF_ID_BITS: c_int = 29; -pub const CANXL_PRIO_BITS: c_int = CAN_SFF_ID_BITS; - -pub const CAN_MAX_DLC: c_int = 8; -pub const CAN_MAX_DLEN: usize = 8; -pub const CANFD_MAX_DLC: c_int = 15; -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; -pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; -pub const CANXL_MIN_DLEN: usize = 1; -pub const CANXL_MAX_DLEN: usize = 2048; - -pub const CANXL_XLF: c_int = 0x80; -pub const CANXL_SEC: c_int = 0x01; - -pub const CAN_MTU: usize = size_of::(); -pub const CANFD_MTU: usize = size_of::(); -pub const CANXL_MTU: usize = size_of::(); -// FIXME(offset_of): use `core::mem::offset_of!` once that is available -// https://github.com/rust-lang/rfcs/pull/3308 -// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); -pub const CANXL_HDR_SIZE: usize = 12; -pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; -pub const CANXL_MAX_MTU: usize = CANXL_MTU; - -pub const CAN_RAW: c_int = 1; -pub const CAN_BCM: c_int = 2; -pub const CAN_TP16: c_int = 3; -pub const CAN_TP20: c_int = 4; -pub const CAN_MCNET: c_int = 5; -pub const CAN_ISOTP: c_int = 6; -pub const CAN_J1939: c_int = 7; -pub const CAN_NPROTO: c_int = 8; - -pub const SOL_CAN_BASE: c_int = 100; - -pub const CAN_INV_FILTER: canid_t = 0x20000000; -pub const CAN_RAW_FILTER_MAX: c_int = 512; - -// linux/can/raw.h -pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW; -pub const CAN_RAW_FILTER: c_int = 1; -pub const CAN_RAW_ERR_FILTER: c_int = 2; -pub const CAN_RAW_LOOPBACK: c_int = 3; -pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4; -pub const CAN_RAW_FD_FRAMES: c_int = 5; -pub const CAN_RAW_JOIN_FILTERS: c_int = 6; -pub const CAN_RAW_XL_FRAMES: c_int = 7; - -// linux/can/j1939.h -pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939; - -pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd; -pub const J1939_IDLE_ADDR: c_uchar = 0xfe; -pub const J1939_NO_ADDR: c_uchar = 0xff; -pub const J1939_NO_NAME: c_ulong = 0; -pub const J1939_PGN_REQUEST: c_uint = 0x0ea00; -pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00; -pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8; -pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00; -pub const J1939_PGN_MAX: c_uint = 0x3ffff; -pub const J1939_NO_PGN: c_uint = 0x40000; - -pub const SO_J1939_FILTER: c_int = 1; -pub const SO_J1939_PROMISC: c_int = 2; -pub const SO_J1939_SEND_PRIO: c_int = 3; -pub const SO_J1939_ERRQUEUE: c_int = 4; - -pub const SCM_J1939_DEST_ADDR: c_int = 1; -pub const SCM_J1939_DEST_NAME: c_int = 2; -pub const SCM_J1939_PRIO: c_int = 3; -pub const SCM_J1939_ERRQUEUE: c_int = 4; - -pub const J1939_NLA_PAD: c_int = 0; -pub const J1939_NLA_BYTES_ACKED: c_int = 1; -pub const J1939_NLA_TOTAL_SIZE: c_int = 2; -pub const J1939_NLA_PGN: c_int = 3; -pub const J1939_NLA_SRC_NAME: c_int = 4; -pub const J1939_NLA_DEST_NAME: c_int = 5; -pub const J1939_NLA_SRC_ADDR: c_int = 6; -pub const J1939_NLA_DEST_ADDR: c_int = 7; - -pub const J1939_EE_INFO_NONE: c_int = 0; -pub const J1939_EE_INFO_TX_ABORT: c_int = 1; -pub const J1939_EE_INFO_RX_RTS: c_int = 2; -pub const J1939_EE_INFO_RX_DPO: c_int = 3; -pub const J1939_EE_INFO_RX_ABORT: c_int = 4; - -pub const J1939_FILTER_MAX: c_int = 512; - // linux/sctp.h pub const SCTP_FUTURE_ASSOC: c_int = 0; pub const SCTP_CURRENT_ASSOC: c_int = 1; diff --git a/triagebot.toml b/triagebot.toml index 18c7fd79f8157..54d848f8f9cd3 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -61,7 +61,10 @@ trigger_files = [ trigger_files = ["src/unix/solarish/illumos.rs"] [autolabel."O-linux"] -trigger_files = ["src/unix/linux_like/linux"] +trigger_files = [ + "src/unix/linux_like/linux", + "src/reorg/linux_uapi", +] [autolabel."O-linux-like"] trigger_files = ["src/unix/linux_like/mod.rs"] From 5a7955ed6a7c1294f89b8b961522a82407d6d1e1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Jul 2025 15:26:01 +0000 Subject: [PATCH 49/93] ci: Skip the `new` module with style check (backport ) (cherry picked from commit d08c3940bf94b3efcaf476b27797bf7ac03b82b6) --- libc-test/test/check_style.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libc-test/test/check_style.rs b/libc-test/test/check_style.rs index ee5e134891104..24f793e4feb86 100644 --- a/libc-test/test/check_style.rs +++ b/libc-test/test/check_style.rs @@ -16,21 +16,32 @@ use std::path::Path; use style::{Result, StyleChecker}; +/// Relative to `src/`. +const SKIP_PREFIXES: &[&str] = &[ + // Don't run the style checker on the reorganized portion of the crate while we figure + // out what style we want. + "new/", +]; + #[test] fn check_style() { - let root_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../src"); - walk(&root_dir).unwrap(); + let src_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../src"); + walk(&src_root).unwrap(); eprintln!("good style!"); } -fn walk(root_dir: &Path) -> Result<()> { +fn walk(src_root: &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") + src_root.to_str().expect("dir should be valid UTF-8") ))? { let entry = entry?; + let relpath = entry.strip_prefix(src_root).expect("known path"); + if SKIP_PREFIXES.iter().any(|pfx| relpath.starts_with(pfx)) { + continue; + } let name = entry .file_name() From b2287047d8efd809918f3cbb107530bbf4bfe487 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 8 Jul 2025 00:05:06 -0500 Subject: [PATCH 50/93] Source reorganization of Android `socket.h` Create a bionic module and move some things over from `linux_like`. Source: https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/include/sys/socket.h;drc=dc6e2fb4857f05bfee435cfd4f3859e74c746811 (backport ) (cherry picked from commit bce7db1b5d3ba2f10e1caa17e6401ebf8016cf32) --- src/new/bionic/mod.rs | 2 ++ src/new/bionic/sys/mod.rs | 2 ++ src/new/bionic/sys/socket.rs | 51 ++++++++++++++++++++++++++++++ src/new/mod.rs | 3 ++ src/unix/linux_like/android/mod.rs | 44 +------------------------- src/unix/linux_like/mod.rs | 14 ++++---- 6 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 src/new/bionic/mod.rs create mode 100644 src/new/bionic/sys/mod.rs create mode 100644 src/new/bionic/sys/socket.rs diff --git a/src/new/bionic/mod.rs b/src/new/bionic/mod.rs new file mode 100644 index 0000000000000..644a4ab96d90f --- /dev/null +++ b/src/new/bionic/mod.rs @@ -0,0 +1,2 @@ +mod sys; +pub use sys::*; diff --git a/src/new/bionic/sys/mod.rs b/src/new/bionic/sys/mod.rs new file mode 100644 index 0000000000000..fd96d0821ac88 --- /dev/null +++ b/src/new/bionic/sys/mod.rs @@ -0,0 +1,2 @@ +mod socket; +pub use socket::*; diff --git a/src/new/bionic/sys/socket.rs b/src/new/bionic/sys/socket.rs new file mode 100644 index 0000000000000..49af36fe93356 --- /dev/null +++ b/src/new/bionic/sys/socket.rs @@ -0,0 +1,51 @@ +//! Header: `bionic/libc/include/sys/socket.h` + +use crate::prelude::*; + +s! { + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct ucred { + pub pid: crate::pid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } +} + +extern "C" { + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sendmmsg( + sockfd: c_int, + msgvec: *const crate::mmsghdr, + vlen: c_uint, + flags: c_int, + ) -> c_int; + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; +} diff --git a/src/new/mod.rs b/src/new/mod.rs index 4006f5c82288d..0a2a55b0f469b 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -8,5 +8,8 @@ cfg_if! { if #[cfg(target_os = "linux")] { mod linux_uapi; pub use linux_uapi::*; + } else if #[cfg(target_os = "android")] { + mod bionic; + pub use bionic::*; } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 7201b09982eb7..100008ce5d8e9 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1,6 +1,7 @@ //! Android-specific definitions for linux-like values use crate::prelude::*; +use crate::{cmsghdr, msghdr}; cfg_if! { if #[cfg(doc)] { @@ -74,22 +75,6 @@ s! { __val: [c_int; 2], } - pub struct msghdr { - pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, - pub msg_iov: *mut crate::iovec, - pub msg_iovlen: size_t, - pub msg_control: *mut c_void, - pub msg_controllen: size_t, - pub msg_flags: c_int, - } - - pub struct cmsghdr { - pub cmsg_len: size_t, - pub cmsg_level: c_int, - pub cmsg_type: c_int, - } - pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, @@ -203,12 +188,6 @@ s! { pub it_value: crate::timespec, } - pub struct ucred { - pub pid: crate::pid_t, - pub uid: crate::uid_t, - pub gid: crate::gid_t, - } - pub struct genlmsghdr { pub cmd: u8, pub version: u8, @@ -3501,14 +3480,6 @@ extern "C" { pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn recvfrom( - socket: c_int, - buf: *mut c_void, - len: size_t, - flags: c_int, - addr: *mut crate::sockaddr, - addrlen: *mut crate::socklen_t, - ) -> ssize_t; pub fn getnameinfo( sa: *const crate::sockaddr, salen: crate::socklen_t, @@ -3821,19 +3792,6 @@ extern "C" { ) -> c_int; pub fn __errno() -> *mut c_int; pub fn inotify_rm_watch(fd: c_int, wd: u32) -> c_int; - pub fn sendmmsg( - sockfd: c_int, - msgvec: *const crate::mmsghdr, - vlen: c_uint, - flags: c_int, - ) -> c_int; - pub fn recvmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_int, - timeout: *const crate::timespec, - ) -> c_int; pub fn inotify_init() -> c_int; pub fn inotify_init1(flags: c_int) -> c_int; pub fn inotify_add_watch(fd: c_int, path: *const c_char, mask: u32) -> c_int; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 4e0d6124d880a..98a093db2e742 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1792,24 +1792,24 @@ const_fn! { } f! { - pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { - if (*mhdr).msg_controllen as usize >= size_of::() { - (*mhdr).msg_control.cast::() + pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut crate::cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control.cast::() } else { - core::ptr::null_mut::() + core::ptr::null_mut::() } } - pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + pub fn CMSG_DATA(cmsg: *const crate::cmsghdr) -> *mut c_uchar { cmsg.offset(1) as *mut c_uchar } pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { - (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { - CMSG_ALIGN(size_of::()) as c_uint + length + CMSG_ALIGN(size_of::()) as c_uint + length } pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { From 0108917a289af803a8349d74491f859f895c8065 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Wed, 23 Jul 2025 11:31:01 -0400 Subject: [PATCH 51/93] Add 'const' to signatures to be consistent with other platforms. (backport ) (cherry picked from commit 6af1254bc96e0dbd7a1c713179d3d8277b611a90) --- libc-test/build.rs | 9 +++++++++ src/unix/aix/mod.rs | 18 +++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f620e0659c0eb..6724ab2c7719d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5750,6 +5750,15 @@ fn test_aix(target: &str) { // The function is only available under macro _KERNEL in 'proto_uipc.h'. "getpeereid" => true, + // The AIX signatures for these non-POSIX functions differ from + // those on platforms like Linux: some arguments are not marked + // with the 'const' qualifier, even though they are not modified. + // To be consistent with other platforms, 'const' is added to the + // Rust declarations. However, this causes a mismatch with the AIX + // header signatures. Skipping. + "setdomainname" | "settimeofday" | "statfs" | "statfs64" | "statx" | "swapoff" + | "swapon" | "utmpname" | "setgroups" => true, + _ => false, } }); diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 13feca788cb3d..2d3f40c2a10b8 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -3250,15 +3250,15 @@ extern "C" { #[link_name = "nsendmsg"] pub fn sendmsg(sockfd: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; pub fn setcontext(ucp: *const ucontext_t) -> c_int; - pub fn setdomainname(name: *mut c_char, len: c_int) -> c_int; - pub fn setgroups(ngroups: c_int, ptr: *mut crate::gid_t) -> c_int; + pub fn setdomainname(name: *const c_char, len: c_int) -> c_int; + pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int; pub fn setgrent(); pub fn setmntent(filename: *const c_char, ty: *const c_char) -> *mut crate::FILE; pub fn setpriority(which: c_int, who: id_t, priority: c_int) -> c_int; pub fn setpwent(); pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; - pub fn settimeofday(tv: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; pub fn setitimer( which: c_int, new_value: *const crate::itimerval, @@ -3285,10 +3285,10 @@ extern "C" { pub fn srand48(seed: c_long); pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn stat64at(dirfd: c_int, path: *const c_char, buf: *mut stat64, flags: c_int) -> c_int; - pub fn statfs(path: *mut c_char, buf: *mut statfs) -> c_int; - pub fn statfs64(path: *mut c_char, buf: *mut statfs64) -> c_int; + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; - pub fn statx(path: *mut c_char, buf: *mut stat, length: c_int, command: c_int) -> c_int; + pub fn statx(path: *const c_char, buf: *mut stat, length: c_int, command: c_int) -> c_int; pub fn strcasecmp_l( string1: *const c_char, string2: *const c_char, @@ -3310,8 +3310,8 @@ extern "C" { pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; pub fn strsep(string: *mut *mut c_char, delim: *const c_char) -> *mut c_char; pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; - pub fn swapoff(puath: *mut c_char) -> c_int; - pub fn swapon(path: *mut c_char) -> c_int; + pub fn swapoff(path: *const c_char) -> c_int; + pub fn swapon(path: *const c_char) -> c_int; pub fn sync(); pub fn telldir(dirp: *mut crate::DIR) -> c_long; pub fn timer_create( @@ -3332,7 +3332,7 @@ extern "C" { pub fn uname(buf: *mut crate::utsname) -> c_int; pub fn updwtmp(file: *const c_char, u: *const utmp); pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; - pub fn utmpname(file: *mut c_char) -> c_int; + pub fn utmpname(file: *const c_char) -> c_int; pub fn utimensat( dirfd: c_int, path: *const c_char, From 906fcef8075ca53212716289f114e2fc8691a1c1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 21:48:34 -0500 Subject: [PATCH 52/93] ci: Remove handling for the `QEMU` environment variable The last uses of this were removed in 201d5394658f ("Remove OpenBSD CI") and e88e6b99de10 ("Move FreeBSD testing from Travis/QEMU to Cirrus-CI"), so this is no longer needed. Clean up the CI script. (backport ) (cherry picked from commit 423ee014c89e237d086c327413da939da050b4d0) --- ci/run.sh | 73 +------------------------------------------------------ 1 file changed, 1 insertion(+), 72 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 1d4b5f5079d96..3583e198ecea1 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -5,87 +5,16 @@ set -eux -mirrors_url="https://ci-mirrors.rust-lang.org/libc" - target="$1" export RUST_BACKTRACE="${RUST_BACKTRACE:-1}" -# If we're going to run tests inside of a qemu image, then we don't need any of -# the scripts below. Instead, download the image, prepare a filesystem which has -# the current state of this repository, and then run the image. -# -# It's assume that all images, when run with two disks, will run the `run.sh` -# script from the second which we place inside. -if [ -n "${QEMU:-}" ]; then - tmpdir=/tmp/qemu-img-creation - mkdir -p "${tmpdir}" - - if [ -z "${QEMU#*.gz}" ]; then - # image is .gz : download and uncompress it - base_file="${QEMU%.gz}" - pipe_cmd="gunzip -d" - elif [ -z "${QEMU#*.xz}" ]; then - # image is .xz : download and uncompress it - base_file="${QEMU%.xz}" - pipe_cmd="unxz" - else - # plain qcow2 image: just download it - base_file="$QEMU" - pipe_cmd="cat" # nop to forward the result - fi - - qemufile="$(echo "$base_file" | sed 's/\//__/g')" - if [ ! -f "${tmpdir}/${qemufile}" ]; then - curl --retry 5 "${mirrors_url}/${QEMU}" | $pipe_cmd > "${tmpdir}/${qemufile}" - fi - - # Create a mount a fresh new filesystem image that we'll later pass to QEMU. - # This will have a `run.sh` script will which use the artifacts inside to run - # on the host. - rm -f "${tmpdir}/libc-test.img" - mkdir "${tmpdir}/mount" - - # Do the standard rigamarole of cross-compiling an executable and then the - # script to run just executes the binary. - cargo build \ - --manifest-path libc-test/Cargo.toml \ - --target "$target" \ - --test main ${LIBC_CI_ZBUILD_STD+"-Zbuild-std=core"} - rm "${CARGO_TARGET_DIR}/${target}"/debug/main-*.d - cp "${CARGO_TARGET_DIR}/${target}"/debug/main-* "${tmpdir}"/mount/libc-test - # shellcheck disable=SC2016 - echo 'exec $1/libc-test' > "${tmpdir}/mount/run.sh" - - du -sh "${tmpdir}/mount" - genext2fs \ - --root "${tmpdir}/mount" \ - --size-in-blocks 100000 \ - "${tmpdir}/libc-test.img" - - # Pass -snapshot to prevent tampering with the disk images, this helps when - # running this script in development. The two drives are then passed next, - # first is the OS and second is the one we just made. Next the network is - # configured to work (I'm not entirely sure how), and then finally we turn off - # graphics and redirect the serial console output to out.log. - qemu-system-x86_64 \ - -m 1024 \ - -snapshot \ - -drive if=virtio,file="${tmpdir}/${qemufile}" \ - -drive if=virtio,file="${tmpdir}/libc-test.img" \ - -net nic,model=virtio \ - -net user \ - -nographic \ - -vga none 2>&1 | tee "${CARGO_TARGET_DIR}/out.log" - exec grep -E "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log" -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 - # Only run `libc-test` + # Only run `libc-test` # FIXME(android): unit tests fail to start on Android *android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; *s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; From baf9c04f98f9d9c76dfbe14d916b587225dd2da2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 21:56:30 -0500 Subject: [PATCH 53/93] ci: Upgrade wasm dependencies to the latest version (backport ) (cherry picked from commit 7013c988dbe2d1b1a7c9709138f6d2f957d7683f) --- ci/wasi.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ci/wasi.sh b/ci/wasi.sh index e7896233ad7f3..4928681b0a270 100755 --- a/ci/wasi.sh +++ b/ci/wasi.sh @@ -11,12 +11,8 @@ apt-get install -y --no-install-recommends \ # Wasmtime is used to execute tests and wasi-sdk is used to compile tests. # Download appropriate versions here and configure various flags below. -# -# At the time of this writing wasmtime 24.0.0 is the latest release and -# wasi-sdk-24 is the latest release, that these numbers match is just -# coincidence. -wasmtime=24.0.0 -wasi_sdk=24 +wasmtime=35.0.0 +wasi_sdk=25 curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | tar xJf - From 7217b2b23929ca78e1bf2f081b9a499c42f1f6c5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 22:41:43 -0500 Subject: [PATCH 54/93] ci: Format shell scripts Set up `shfmt` configuration and apply it to our shell scripts with the following: fd -e sh -x shfmt -w (backport ) (cherry picked from commit 0d1d6fdb4e4bb25a36e7cf9a85aedf91642bb17c) --- .editorconfig | 7 ++++++ ci/android-install-sdk.sh | 48 +++++++++++++++++++-------------------- ci/install-musl.sh | 17 +++++++------- ci/install-rust.sh | 10 ++++---- ci/run-docker.sh | 2 +- ci/run.sh | 8 +++---- ci/style.sh | 4 ++-- ci/verify-build.sh | 14 ++++++------ 8 files changed, 58 insertions(+), 52 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000000..155c9905f91e1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +[*.sh] +# See https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd#examples +indent_style = space +indent_size = 4 + +switch_case_indent = true +space_redirects = true diff --git a/ci/android-install-sdk.sh b/ci/android-install-sdk.sh index 331e061357648..43e1153dcd331 100755 --- a/ci/android-install-sdk.sh +++ b/ci/android-install-sdk.sh @@ -15,27 +15,27 @@ wget -q --tries=20 "https://dl.google.com/android/repository/commandlinetools-li unzip -q -d sdk/cmdline-tools "commandlinetools-linux-${sdk}_latest.zip" case "$1" in - arm | armv7) - api=24 - image="system-images;android-${api};default;armeabi-v7a" - ;; - aarch64) - api=24 - image="system-images;android-${api};google_apis;arm64-v8a" - ;; - i686) - api=28 - image="system-images;android-${api};default;x86" - ;; - x86_64) - api=28 - image="system-images;android-${api};default;x86_64" - ;; - *) - echo "invalid arch: $1" - exit 1 - ;; -esac; + arm | armv7) + api=24 + image="system-images;android-${api};default;armeabi-v7a" + ;; + aarch64) + api=24 + image="system-images;android-${api};google_apis;arm64-v8a" + ;; + i686) + api=28 + image="system-images;android-${api};default;x86" + ;; + x86_64) + api=28 + image="system-images;android-${api};default;x86_64" + ;; + *) + echo "invalid arch: $1" + exit 1 + ;; +esac # Try to fix warning about missing file. # See https://askubuntu.com/a/1078784 @@ -53,9 +53,9 @@ echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg # which produces an insane amount of output. yes | ./sdk/cmdline-tools/tools/bin/sdkmanager --licenses --no_https | grep -v = || true yes | ./sdk/cmdline-tools/tools/bin/sdkmanager --no_https \ - "platform-tools" \ - "platforms;android-${api}" \ - "${image}" | grep -v = || true + "platform-tools" \ + "platforms;android-${api}" \ + "${image}" | grep -v = || true # The newer emulator versions (31.3.12 or higher) fail to a valid AVD and the test gets stuck. # Until we figure out why, we use the older version (31.3.11). diff --git a/ci/install-musl.sh b/ci/install-musl.sh index ca8368a7074df..f5516553707d2 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -25,14 +25,14 @@ case ${1} in musl_arch=aarch64 kernel_arch=arm64 CC=aarch64-linux-gnu-gcc \ - ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes make install -j4 ;; arm) musl_arch=arm kernel_arch=arm CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm -mfpu=vfp" \ - ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes make install -j4 ;; i686) @@ -43,7 +43,7 @@ case ${1} in # Specifically pass -m32 in CFLAGS and override CC when running # ./configure, since otherwise the script will fail to find a compiler. CC=gcc CFLAGS="-m32" \ - ./configure --prefix="/musl-${musl_arch}" --disable-shared --target=i686 + ./configure --prefix="/musl-${musl_arch}" --disable-shared --target=i686 # unset CROSS_COMPILE when running make; otherwise the makefile will # call the non-existent binary 'i686-ar'. make CROSS_COMPILE= install -j4 @@ -58,21 +58,21 @@ case ${1} in musl_arch=s390x kernel_arch=s390 CC=s390x-linux-gnu-gcc \ - ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes make install -j4 ;; loongarch64) musl_arch=loongarch64 kernel_arch=loongarch CC=loongarch64-linux-gnu-gcc-14 \ - ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes make install -j4 ;; powerpc64*) musl_arch=powerpc64 kernel_arch=powerpc CC="${1}-linux-gnu-gcc" CFLAGS="-mlong-double-64" \ - ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes make install -j4 ;; *) @@ -81,7 +81,6 @@ case ${1} in ;; esac - # shellcheck disable=SC2103 cd .. rm -rf "$musl" @@ -123,8 +122,8 @@ EOF base=$(basename "$url") curl --retry 5 -L "$url" > "$base" case $base in - linux-*) kernel=$base;; - patch-*) patch=$base;; + linux-*) kernel=$base ;; + patch-*) patch=$base ;; esac # Check if file is known grep -o "$base" alpine-sha512sums diff --git a/ci/install-rust.sh b/ci/install-rust.sh index 6e7b1930c59a2..69e8ba97a5d3d 100755 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -9,9 +9,9 @@ toolchain="${TOOLCHAIN:-nightly}" os="${OS:-}" case "$(uname -s)" in - Linux*) os=linux ;; - Darwin*) os=macos ;; - MINGW*) os=windows ;; + Linux*) os=linux ;; + Darwin*) os=macos ;; + MINGW*) os=windows ;; *) echo "Unknown system $(uname -s)" exit 1 @@ -51,7 +51,7 @@ if [ "$os" = "windows" ]; then if [ -n "${ARCH_BITS:-}" ]; then echo "Fix MinGW" - for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do + for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a; do cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib" done fi @@ -71,6 +71,6 @@ until [ $n -ge $N ]; do break fi - n=$((n+1)) + n=$((n + 1)) sleep 1 done diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 9411d39e5f670..db10c3b061ba8 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -21,7 +21,7 @@ echo "${HOME}" pwd # Avoid "no space left on device" failure if running in CI -if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ] ; then +if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ]; then docker system prune -af docker system df fi diff --git a/ci/run.sh b/ci/run.sh index 3583e198ecea1..7b4525143d05a 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -19,7 +19,7 @@ case "$target" in *android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; *s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; # For all other platforms, test everything in the workspace - *) cmd="$cmd --workspace" + *) cmd="$cmd --workspace" ;; esac if [ "$target" = "s390x-unknown-linux-gnu" ]; then @@ -32,13 +32,13 @@ if [ "$target" = "s390x-unknown-linux-gnu" ]; then if [ "$passed" = "0" ]; then # shellcheck disable=SC2086 if $cmd --no-default-features -- $test_flags; then - passed=$((passed+1)) + passed=$((passed + 1)) continue fi elif [ "$passed" = "1" ]; then # shellcheck disable=SC2086 if $cmd -- $test_flags; then - passed=$((passed+1)) + passed=$((passed + 1)) continue fi elif [ "$passed" = "2" ]; then @@ -47,7 +47,7 @@ if [ "$target" = "s390x-unknown-linux-gnu" ]; then break fi fi - n=$((n+1)) + n=$((n + 1)) sleep 1 done else diff --git a/ci/style.sh b/ci/style.sh index 4e425f8806000..72465f71c760a 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -65,7 +65,7 @@ export LC_ALL=C for file in libc-test/semver/*.txt; do case "$file" in - *TODO*) continue ;; + *TODO*) continue ;; esac if ! sort -C "$file"; then @@ -82,7 +82,7 @@ for file in libc-test/semver/*.txt; do fi done -if shellcheck --version ; then +if shellcheck --version; then find . -name '*.sh' -print0 | xargs -0 shellcheck else echo "shellcheck not found" diff --git a/ci/verify-build.sh b/ci/verify-build.sh index 85dff451e3863..e833de2e04c5b 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -14,9 +14,9 @@ filter="${FILTER:-}" host_target=$(rustc -vV | awk '/^host/ { print $2 }') case "$(uname -s)" in - Linux*) os=linux ;; - Darwin*) os=macos ;; - MINGW*) os=windows ;; + Linux*) os=linux ;; + Darwin*) os=macos ;; + MINGW*) os=windows ;; *) echo "Unknown system $(uname -s)" exit 1 @@ -25,7 +25,7 @@ esac echo "Testing Rust $rust on $os" -if [ "$TOOLCHAIN" = "nightly" ] ; then +if [ "$TOOLCHAIN" = "nightly" ]; then # For build-std rustup component add rust-src fi @@ -61,10 +61,10 @@ test_target() { N=5 n=0 until [ $n -ge $N ]; do - if rustup target add "$target" --toolchain "$rust" ; then + if rustup target add "$target" --toolchain "$rust"; then break fi - n=$((n+1)) + n=$((n + 1)) sleep 1 done fi @@ -77,7 +77,7 @@ test_target() { # Test with the equivalent of __USE_TIME_BITS64 RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd case "$target" in - arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*) + arm*-gnu* | i*86*-gnu | powerpc-*-gnu* | mips*-gnu | sparc-*-gnu | thumb-*gnu*) # Test with the equivalent of _FILE_OFFSET_BITS=64 RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd # Test with the equivalent of _TIME_BITS=64 From 9fa71a8666dee7788a513c6ca5e25ca63182e4f7 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Thu, 10 Jul 2025 14:30:59 +0000 Subject: [PATCH 55/93] linux: Add EXEC_RESTRICT_FILE and EXEC_DENY_INTERACTIVE securebits These were added in 6.14 with the following commit: https://github.com/torvalds/linux/commit/a0623b2a1d595341971c189b90a6b06f42cd209d Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 1a1efaf8d6873a4d00f0a3329adbf4bc7703b0ee) --- libc-test/build.rs | 10 ++++++++++ libc-test/semver/linux.txt | 5 +++++ src/unix/linux_like/linux/mod.rs | 24 ++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 6724ab2c7719d..2a690d8e2d273 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4735,6 +4735,16 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.6 kernel headers. "PROC_EVENT_NONZERO_EXIT" => true, + // FIXME(linux): Requires >= 6.14 kernel headers. + "SECBIT_EXEC_DENY_INTERACTIVE" + | "SECBIT_EXEC_DENY_INTERACTIVE_LOCKED" + | "SECBIT_EXEC_RESTRICT_FILE" + | "SECBIT_EXEC_RESTRICT_FILE_LOCKED" + | "SECURE_ALL_UNPRIVILEGED" => true, + + // FIXME(linux): Value changed in 6.14 + "SECURE_ALL_BITS" | "SECURE_ALL_LOCKS" => true, + _ => false, } }); diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 5ab4aef3d8a35..47a029dfc6b8f 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2776,6 +2776,10 @@ SCTP_STATUS SCTP_STREAM_RESET_INCOMING SCTP_STREAM_RESET_OUTGOING SCTP_UNORDERED +SECBIT_EXEC_DENY_INTERACTIVE +SECBIT_EXEC_DENY_INTERACTIVE_LOCKED +SECBIT_EXEC_RESTRICT_FILE +SECBIT_EXEC_RESTRICT_FILE_LOCKED SECBIT_KEEP_CAPS SECBIT_KEEP_CAPS_LOCKED SECBIT_NOROOT @@ -2815,6 +2819,7 @@ SECCOMP_USER_NOTIF_FLAG_CONTINUE SECUREBITS_DEFAULT SECURE_ALL_BITS SECURE_ALL_LOCKS +SECURE_ALL_UNPRIVILEGED SEEK_DATA SEEK_HOLE SELFMAG diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index dee6ed53e74fc..7fd24d480c53a 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4782,11 +4782,31 @@ pub const SECBIT_NO_CAP_AMBIENT_RAISE: c_int = issecure_mask(SECURE_NO_CAP_AMBIE pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED); +const SECURE_EXEC_RESTRICT_FILE: c_int = 8; +const SECURE_EXEC_RESTRICT_FILE_LOCKED: c_int = 9; + +pub const SECBIT_EXEC_RESTRICT_FILE: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE); +pub const SECBIT_EXEC_RESTRICT_FILE_LOCKED: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE_LOCKED); + +const SECURE_EXEC_DENY_INTERACTIVE: c_int = 10; +const SECURE_EXEC_DENY_INTERACTIVE_LOCKED: c_int = 11; + +pub const SECBIT_EXEC_DENY_INTERACTIVE: c_int = issecure_mask(SECURE_EXEC_DENY_INTERACTIVE); +pub const SECBIT_EXEC_DENY_INTERACTIVE_LOCKED: c_int = + issecure_mask(SECURE_EXEC_DENY_INTERACTIVE_LOCKED); + pub const SECUREBITS_DEFAULT: c_int = 0x00000000; -pub const SECURE_ALL_BITS: c_int = - SECBIT_NOROOT | SECBIT_NO_SETUID_FIXUP | SECBIT_KEEP_CAPS | SECBIT_NO_CAP_AMBIENT_RAISE; +pub const SECURE_ALL_BITS: c_int = SECBIT_NOROOT + | SECBIT_NO_SETUID_FIXUP + | SECBIT_KEEP_CAPS + | SECBIT_NO_CAP_AMBIENT_RAISE + | SECBIT_EXEC_RESTRICT_FILE + | SECBIT_EXEC_DENY_INTERACTIVE; pub const SECURE_ALL_LOCKS: c_int = SECURE_ALL_BITS << 1; +pub const SECURE_ALL_UNPRIVILEGED: c_int = + issecure_mask(SECURE_EXEC_RESTRICT_FILE) | issecure_mask(SECURE_EXEC_DENY_INTERACTIVE); + const fn issecure_mask(x: c_int) -> c_int { 1 << x } From 14c8f0944aaf61c9467419a685c4d4d1b3fb3cfb Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 23:32:54 -0500 Subject: [PATCH 56/93] test: Start using automatic test detection Move the `cmsg` test from `libc-test/test/` to `libc-test/tests/`, which is autodetected. (backport ) (cherry picked from commit b0de59a36ea4d7c6c80fd061daff43c90e58475d) --- libc-test/Cargo.toml | 5 ----- {libc-test/test => libc-tests/tests}/cmsg.rs | 5 ++--- 2 files changed, 2 insertions(+), 8 deletions(-) rename {libc-test/test => libc-tests/tests}/cmsg.rs (95%) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 4d9331798a375..5be5863f4d5af 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -65,11 +65,6 @@ name = "linux-termios" path = "test/linux_termios.rs" harness = false -[[test]] -name = "cmsg" -path = "test/cmsg.rs" -harness = true - [[test]] name = "makedev" path = "test/makedev.rs" diff --git a/libc-test/test/cmsg.rs b/libc-tests/tests/cmsg.rs similarity index 95% rename from libc-test/test/cmsg.rs rename to libc-tests/tests/cmsg.rs index 763819019b771..bba658c498aa9 100644 --- a/libc-test/test/cmsg.rs +++ b/libc-tests/tests/cmsg.rs @@ -55,7 +55,6 @@ mod t { #[cfg(not(target_arch = "sparc64"))] #[test] fn test_cmsg_nxthdr() { - use std::ptr; // Helps to align the buffer on the stack. #[repr(align(8))] struct Align8(T); @@ -65,7 +64,7 @@ mod t { let mut mhdr: msghdr = unsafe { mem::zeroed() }; for start_ofs in 0..64 { let pcmsghdr = buffer.0.as_mut_ptr().cast::(); - mhdr.msg_control = pcmsghdr as *mut c_void; + mhdr.msg_control = pcmsghdr.cast::(); mhdr.msg_controllen = (160 - start_ofs) as _; for cmsg_len in 0..64 { // Address must be a multiple of 0x4 for testing on AIX. @@ -80,7 +79,7 @@ mod t { let next = cmsg_nxthdr(&mhdr, pcmsghdr); assert_eq!(libc_next, next); - if libc_next != ptr::null_mut() { + if !libc_next.is_null() { (*libc_next).cmsg_len = next_cmsg_len; let libc_next = libc::CMSG_NXTHDR(&mhdr, pcmsghdr); let next = cmsg_nxthdr(&mhdr, pcmsghdr); From 50faaa22a1a6aea6377ae5c614e5fbfa72c594fe Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 21:59:36 -0500 Subject: [PATCH 57/93] ci: Upgrade to the macos-15 runner image (backport ) (cherry picked from commit 96c990ecd0ee68f8f6764365bc64dc09cf96f691) --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 789d1f40b5cd5..e9c1306af438b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: name: Clippy on ${{ matrix.os }} strategy: matrix: - os: [ubuntu-24.04, macos-14, windows-2022] + os: [ubuntu-24.04, macos-15, windows-2022] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: @@ -52,7 +52,7 @@ jobs: strategy: matrix: toolchain: [stable, nightly, 1.63.0] - os: [ubuntu-24.04, macos-14, windows-2022] + os: [ubuntu-24.04, macos-15, windows-2022] include: - toolchain: beta os: ubuntu-24.04 @@ -111,7 +111,7 @@ jobs: docker: true os: ubuntu-24.04 - target: aarch64-apple-darwin - os: macos-14 + os: macos-15 - target: x86_64-pc-windows-gnu os: windows-2022 env: From 3ceeee10a6f730c5ba20e04fca951142c95c451c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 24 Jul 2025 00:31:29 -0500 Subject: [PATCH 58/93] test: Correct the directory for `tests` b0de59a36ea4 ("test: Start using automatic test detection") moved `cmsg` to `libc-tests` rather than `libc-test`. Fix this here. (backport ) (cherry picked from commit b93598fc771b948e86bab17623e2fd9d1d844769) --- {libc-tests => libc-test}/tests/cmsg.rs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {libc-tests => libc-test}/tests/cmsg.rs (100%) diff --git a/libc-tests/tests/cmsg.rs b/libc-test/tests/cmsg.rs similarity index 100% rename from libc-tests/tests/cmsg.rs rename to libc-test/tests/cmsg.rs From 04777c194f303c743a85f5b08613cf3e83aa3365 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 24 Jul 2025 00:35:43 -0500 Subject: [PATCH 59/93] test: Move more tests to `libc-test/tests` Use autodetection for more tests that don't need a harness. (backport ) (cherry picked from commit 196f0abd8fee3dcd8926ce847ebbf82081f61d3b) --- libc-test/Cargo.toml | 20 -------------------- libc-test/{test => tests}/errqueue.rs | 0 libc-test/{test => tests}/makedev.rs | 0 libc-test/{test => tests}/primitive_types.rs | 0 libc-test/{test => tests}/sigrt.rs | 0 5 files changed, 20 deletions(-) rename libc-test/{test => tests}/errqueue.rs (100%) rename libc-test/{test => tests}/makedev.rs (100%) rename libc-test/{test => tests}/primitive_types.rs (100%) rename libc-test/{test => tests}/sigrt.rs (100%) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 5be5863f4d5af..6c9d8c82ab07f 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -65,31 +65,11 @@ name = "linux-termios" path = "test/linux_termios.rs" harness = false -[[test]] -name = "makedev" -path = "test/makedev.rs" -harness = true - -[[test]] -name = "errqueue" -path = "test/errqueue.rs" -harness = true - -[[test]] -name = "sigrt" -path = "test/sigrt.rs" -harness = true - [[test]] name = "semver" path = "test/semver.rs" harness = false -[[test]] -name = "primitive_types" -path = "test/primitive_types.rs" -harness = true - [[test]] name = "style" path = "test/check_style.rs" diff --git a/libc-test/test/errqueue.rs b/libc-test/tests/errqueue.rs similarity index 100% rename from libc-test/test/errqueue.rs rename to libc-test/tests/errqueue.rs diff --git a/libc-test/test/makedev.rs b/libc-test/tests/makedev.rs similarity index 100% rename from libc-test/test/makedev.rs rename to libc-test/tests/makedev.rs diff --git a/libc-test/test/primitive_types.rs b/libc-test/tests/primitive_types.rs similarity index 100% rename from libc-test/test/primitive_types.rs rename to libc-test/tests/primitive_types.rs diff --git a/libc-test/test/sigrt.rs b/libc-test/tests/sigrt.rs similarity index 100% rename from libc-test/test/sigrt.rs rename to libc-test/tests/sigrt.rs From 8cdff917549a683e51a97625a1adead1ce846c32 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 24 Jul 2025 09:15:11 -0400 Subject: [PATCH 60/93] Retore `struct winsize`. (backport ) (cherry picked from commit e8bb082966a51e71a6bca208096ee26fad80c746) --- libc-test/semver/aix.txt | 1 + src/unix/mod.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index 38553abf3f80d..1f3324e213f54 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -2601,6 +2601,7 @@ waitpid wchar_t wcslen wcstombs +winsize wmemchr write writev diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 96209e7e72cd7..941f2faa99217 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -160,7 +160,6 @@ s! { pub revents: c_short, } - #[cfg(not(target_os = "aix"))] pub struct winsize { pub ws_row: c_ushort, pub ws_col: c_ushort, From 916f6b4c259f3e132deec5f960361ea3984303a2 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 24 Jul 2025 08:31:53 -0400 Subject: [PATCH 61/93] Fix the type of the 'f_fsid' field in 'struct statvfs'. (backport ) (cherry picked from commit d98eb8fcdc99e1dc66288050b64e8cc09964d9a3) --- libc-test/build.rs | 3 +++ src/unix/aix/powerpc64.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 2a690d8e2d273..243d809cabf64 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5700,6 +5700,9 @@ fn test_aix(target: &str) { ("__context64", "fpr") => true, ("__tm_context_t", "fpr") => true, + // The _ALL_SOURCE type of 'f_fsid' differs from POSIX's on AIX. + ("statvfs", "f_fsid") => true, + _ => false, } }); diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index f379e2df71898..b2b7ea88f6e4e 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -29,7 +29,7 @@ s! { pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, - pub f_fsid: crate::fsid_t, + pub f_fsid: c_ulong, pub f_basetype: [c_char; 16], pub f_flag: c_ulong, pub f_namemax: c_ulong, From 0801043211874d65644cc1d28322e9f05744b588 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Fri, 25 Jul 2025 15:59:19 -0400 Subject: [PATCH 62/93] Fix the type of constants for use as the 'int request' argument to 'ioctl()'. (backport ) (cherry picked from commit 3c84eb65e46f39eed403a76a5da3b2e526cff0af) --- libc-test/build.rs | 16 ++++ src/unix/aix/mod.rs | 180 ++++++++++++++++++++++---------------------- 2 files changed, 106 insertions(+), 90 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 243d809cabf64..7ea00da688a19 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5670,6 +5670,22 @@ fn test_aix(target: &str) { // values because non-unique values are being used which will // fail the test when _ALL_SOURCE is defined. "EWOULDBLOCK" | "ENOTEMPTY" => true, + + // FIXME(ctest): These constants are intended for use as the 'int request' argument + // to 'ioctl()'. However, the AIX headers do not explicitly define their types. If a + // value has the sign bit set, it gets sign-extended to a 64-bit value in the 64-bit + // mode, which fails the comparison with the Rust definitions, where the type is + //`c_int`. + "BIOCSETF" | "BIOCSBLEN" | "BIOCSRTIMEOUT" | "BIOCIMMEDIATE" | "BIOCSETIF" | "FIONBIO" + | "FIOASYNC" | "FIOSETOWN" | "TIOCSETD" | "TIOCMODS" | "TIOCSETP" | "TIOCSETN" + | "TIOCFLUSH" | "TIOCSETC" | "SIOCADDMULTI" | "SIOCADDRT" | "SIOCDARP" | "SIOCDELMULTI" + | "SIOCGIFADDR" | "SIOCGIFBRDADDR" | "SIOCGIFCONF" | "SIOCGIFDSTADDR" | "SIOCGIFFLAGS" + | "SIOCGIFHWADDR" | "SIOCGIFMETRIC" | "SIOCGIFMTU" | "SIOCGIFNETMASK" | "SIOCSARP" + | "SIOCSIFADDR" | "SIOCSIFBRDADDR" | "SIOCSIFDSTADDR" | "SIOCSIFFLAGS" + | "SIOCSIFMETRIC" | "SIOCSIFMTU" | "SIOCSIFNETMASK" | "TIOCUCNTL" | "TIOCCONS" + | "TIOCPKT" | "TIOCSWINSZ" | "TIOCLBIS" | "TIOCLBIC" | "TIOCLSET" | "TIOCSLTC" + | "TIOCSPGRP" | "TIOCSTI" | "TIOCMSET" | "TIOCMBIS" | "TIOCMBIC" | "TIOCREMOTE" => true, + _ => false, }); diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 2d3f40c2a10b8..1ee8c53b5505b 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -825,20 +825,20 @@ pub const DLT_PPP: c_int = 0x17; pub const DLT_FDDI: c_int = 0xf; pub const DLT_ATM: c_int = 0x25; pub const DLT_IPOIB: c_int = 0xc7; -pub const BIOCSETF: c_long = -2146418073; -pub const BIOCGRTIMEOUT: c_long = 1074807406; -pub const BIOCGBLEN: c_long = 1074020966; -pub const BIOCSBLEN: c_long = -1073462682; -pub const BIOCFLUSH: c_long = 536887912; -pub const BIOCPROMISC: c_long = 536887913; -pub const BIOCGDLT: c_long = 1074020970; -pub const BIOCSRTIMEOUT: c_long = -2146418067; -pub const BIOCGSTATS: c_long = 1074283119; -pub const BIOCIMMEDIATE: c_long = -2147204496; -pub const BIOCVERSION: c_long = 1074020977; -pub const BIOCSDEVNO: c_long = 536887922; -pub const BIOCGETIF: c_long = 1075855979; -pub const BIOCSETIF: c_long = -2145369492; +pub const BIOCSETF: c_int = 0x80104267; +pub const BIOCGRTIMEOUT: c_int = 0x4010426e; +pub const BIOCGBLEN: c_int = 0x40044266; +pub const BIOCSBLEN: c_int = 0xc0044266; +pub const BIOCFLUSH: c_int = 0x20004268; +pub const BIOCPROMISC: c_int = 0x20004269; +pub const BIOCGDLT: c_int = 0x4004426a; +pub const BIOCSRTIMEOUT: c_int = 0x8010426d; +pub const BIOCGSTATS: c_int = 0x4008426f; +pub const BIOCIMMEDIATE: c_int = 0x80044270; +pub const BIOCVERSION: c_int = 0x40044271; +pub const BIOCSDEVNO: c_int = 0x20004272; +pub const BIOCGETIF: c_int = 0x4020426b; +pub const BIOCSETIF: c_int = 0x8020426c; pub const BPF_ABS: c_int = 32; pub const BPF_ADD: c_int = 0; pub const BPF_ALIGNMENT: c_ulong = 4; @@ -1362,22 +1362,22 @@ pub const Q_SETQUOTA: c_int = 0x400; // sys/ioctl.h pub const IOCPARM_MASK: c_int = 0x7f; -pub const IOC_VOID: c_long = 536870912; -pub const IOC_OUT: c_long = 1073741824; -pub const IOC_IN: c_long = -2147483648; -pub const IOC_INOUT: c_long = IOC_IN | IOC_OUT; -pub const FIOCLEX: c_long = 536897025; -pub const FIONCLEX: c_long = 536897026; -pub const FIONREAD: c_long = 1074030207; -pub const FIONBIO: c_long = -2147195266; -pub const FIOASYNC: c_long = -2147195267; -pub const FIOSETOWN: c_long = -2147195268; -pub const FIOGETOWN: c_long = 1074030203; -pub const TIOCGETD: c_long = 1074033664; -pub const TIOCSETD: c_long = -2147191807; -pub const TIOCHPCL: c_long = 536900610; -pub const TIOCMODG: c_long = 1074033667; -pub const TIOCMODS: c_long = -2147191804; +pub const IOC_VOID: c_int = 0x20000000; +pub const IOC_OUT: c_int = 0x40000000; +pub const IOC_IN: c_int = 0x40000000 << 1; +pub const IOC_INOUT: c_int = IOC_IN | IOC_OUT; +pub const FIOCLEX: c_int = 0x20006601; +pub const FIONCLEX: c_int = 0x20006602; +pub const FIONREAD: c_int = 0x4004667f; +pub const FIONBIO: c_int = 0x8004667e; +pub const FIOASYNC: c_int = 0x8004667d; +pub const FIOSETOWN: c_int = 0x8004667c; +pub const FIOGETOWN: c_int = 0x4004667b; +pub const TIOCGETD: c_int = 0x40047400; +pub const TIOCSETD: c_int = 0x80047401; +pub const TIOCHPCL: c_int = 0x20007402; +pub const TIOCMODG: c_int = 0x40047403; +pub const TIOCMODS: c_int = 0x80047404; pub const TIOCM_LE: c_int = 0x1; pub const TIOCM_DTR: c_int = 0x2; pub const TIOCM_RTS: c_int = 0x4; @@ -1389,46 +1389,46 @@ pub const TIOCM_CD: c_int = 0x40; pub const TIOCM_RNG: c_int = 0x80; pub const TIOCM_RI: c_int = 0x80; pub const TIOCM_DSR: c_int = 0x100; -pub const TIOCGETP: c_long = 1074164744; -pub const TIOCSETP: c_long = -2147060727; -pub const TIOCSETN: c_long = -2147060726; -pub const TIOCEXCL: c_long = 536900621; -pub const TIOCNXCL: c_long = 536900622; -pub const TIOCFLUSH: c_long = -2147191792; -pub const TIOCSETC: c_long = -2147060719; -pub const TIOCGETC: c_long = 1074164754; +pub const TIOCGETP: c_int = 0x40067408; +pub const TIOCSETP: c_int = 0x80067409; +pub const TIOCSETN: c_int = 0x8006740a; +pub const TIOCEXCL: c_int = 0x2000740d; +pub const TIOCNXCL: c_int = 0x2000740e; +pub const TIOCFLUSH: c_int = 0x80047410; +pub const TIOCSETC: c_int = 0x80067411; +pub const TIOCGETC: c_int = 0x40067412; pub const TANDEM: c_int = 0x1; pub const CBREAK: c_int = 0x2; pub const LCASE: c_int = 0x4; pub const MDMBUF: c_int = 0x800000; pub const XTABS: c_int = 0xc00; -pub const SIOCADDMULTI: c_long = -2145359567; -pub const SIOCADDRT: c_long = -2143784438; -pub const SIOCDARP: c_long = -2142476000; -pub const SIOCDELMULTI: c_long = -2145359566; -pub const SIOCDELRT: c_long = -2143784437; -pub const SIOCDIFADDR: c_long = -2144835303; -pub const SIOCGARP: c_long = -1068734170; -pub const SIOCGIFADDR: c_long = -1071093471; -pub const SIOCGIFBRDADDR: c_long = -1071093469; -pub const SIOCGIFCONF: c_long = -1072666299; -pub const SIOCGIFDSTADDR: c_long = -1071093470; -pub const SIOCGIFFLAGS: c_long = -1071093487; -pub const SIOCGIFHWADDR: c_long = -1068209771; -pub const SIOCGIFMETRIC: c_long = -1071093481; -pub const SIOCGIFMTU: c_long = -1071093418; -pub const SIOCGIFNETMASK: c_long = -1071093467; -pub const SIOCSARP: c_long = -2142476002; -pub const SIOCSIFADDR: c_long = -2144835316; -pub const SIOCSIFBRDADDR: c_long = -2144835309; -pub const SIOCSIFDSTADDR: c_long = -2144835314; -pub const SIOCSIFFLAGS: c_long = -2144835312; -pub const SIOCSIFMETRIC: c_long = -2144835304; -pub const SIOCSIFMTU: c_long = -2144835240; -pub const SIOCSIFNETMASK: c_long = -2144835306; -pub const TIOCUCNTL: c_long = -2147191706; -pub const TIOCCONS: c_long = -2147191710; -pub const TIOCPKT: c_long = -2147191696; +pub const SIOCADDMULTI: c_int = 0x80206931; +pub const SIOCADDRT: c_int = 0x8038720a; +pub const SIOCDARP: c_int = 0x804c6920; +pub const SIOCDELMULTI: c_int = 0x80206932; +pub const SIOCDELRT: c_int = 0x8038720b; +pub const SIOCDIFADDR: c_int = 0x80286919; +pub const SIOCGARP: c_int = 0xc04c6926; +pub const SIOCGIFADDR: c_int = 0xc0286921; +pub const SIOCGIFBRDADDR: c_int = 0xc0286923; +pub const SIOCGIFCONF: c_int = 0xc0106945; +pub const SIOCGIFDSTADDR: c_int = 0xc0286922; +pub const SIOCGIFFLAGS: c_int = 0xc0286911; +pub const SIOCGIFHWADDR: c_int = 0xc0546995; +pub const SIOCGIFMETRIC: c_int = 0xc0286917; +pub const SIOCGIFMTU: c_int = 0xc0286956; +pub const SIOCGIFNETMASK: c_int = 0xc0286925; +pub const SIOCSARP: c_int = 0x804c691e; +pub const SIOCSIFADDR: c_int = 0x8028690c; +pub const SIOCSIFBRDADDR: c_int = 0x80286913; +pub const SIOCSIFDSTADDR: c_int = 0x8028690e; +pub const SIOCSIFFLAGS: c_int = 0x80286910; +pub const SIOCSIFMETRIC: c_int = 0x80286918; +pub const SIOCSIFMTU: c_int = 0x80286958; +pub const SIOCSIFNETMASK: c_int = 0x80286916; +pub const TIOCUCNTL: c_int = 0x80047466; +pub const TIOCCONS: c_int = 0x80047462; +pub const TIOCPKT: c_int = 0x80047470; pub const TIOCPKT_DATA: c_int = 0; pub const TIOCPKT_FLUSHREAD: c_int = 1; pub const TIOCPKT_FLUSHWRITE: c_int = 2; @@ -2092,31 +2092,31 @@ pub const TCOON: c_int = 1; pub const TCIOFF: c_int = 2; pub const TCION: c_int = 3; pub const TIOC: c_int = 0x5400; -pub const TIOCGWINSZ: c_long = 1074295912; -pub const TIOCSWINSZ: c_long = -2146929561; -pub const TIOCLBIS: c_long = -2147191681; -pub const TIOCLBIC: c_long = -2147191682; -pub const TIOCLSET: c_long = -2147191683; -pub const TIOCLGET: c_long = 1074033788; -pub const TIOCSBRK: c_long = 536900731; -pub const TIOCCBRK: c_long = 536900730; -pub const TIOCSDTR: c_long = 536900729; -pub const TIOCCDTR: c_long = 536900728; -pub const TIOCSLTC: c_long = -2147060619; -pub const TIOCGLTC: c_long = 1074164852; -pub const TIOCOUTQ: c_long = 1074033779; -pub const TIOCNOTTY: c_long = 536900721; -pub const TIOCSTOP: c_long = 536900719; -pub const TIOCSTART: c_long = 536900718; -pub const TIOCGPGRP: c_long = 1074033783; -pub const TIOCSPGRP: c_long = -2147191690; -pub const TIOCGSID: c_long = 1074033736; -pub const TIOCSTI: c_long = -2147388302; -pub const TIOCMSET: c_long = -2147191699; -pub const TIOCMBIS: c_long = -2147191700; -pub const TIOCMBIC: c_long = -2147191701; -pub const TIOCMGET: c_long = 1074033770; -pub const TIOCREMOTE: c_long = -2147191703; +pub const TIOCGWINSZ: c_int = 0x40087468; +pub const TIOCSWINSZ: c_int = 0x80087467; +pub const TIOCLBIS: c_int = 0x8004747f; +pub const TIOCLBIC: c_int = 0x8004747e; +pub const TIOCLSET: c_int = 0x8004747d; +pub const TIOCLGET: c_int = 0x4004747c; +pub const TIOCSBRK: c_int = 0x2000747b; +pub const TIOCCBRK: c_int = 0x2000747a; +pub const TIOCSDTR: c_int = 0x20007479; +pub const TIOCCDTR: c_int = 0x20007478; +pub const TIOCSLTC: c_int = 0x80067475; +pub const TIOCGLTC: c_int = 0x40067474; +pub const TIOCOUTQ: c_int = 0x40047473; +pub const TIOCNOTTY: c_int = 0x20007471; +pub const TIOCSTOP: c_int = 0x2000746f; +pub const TIOCSTART: c_int = 0x2000746e; +pub const TIOCGPGRP: c_int = 0x40047477; +pub const TIOCSPGRP: c_int = 0x80047476; +pub const TIOCGSID: c_int = 0x40047448; +pub const TIOCSTI: c_int = 0x80017472; +pub const TIOCMSET: c_int = 0x8004746d; +pub const TIOCMBIS: c_int = 0x8004746c; +pub const TIOCMBIC: c_int = 0x8004746b; +pub const TIOCMGET: c_int = 0x4004746a; +pub const TIOCREMOTE: c_int = 0x80047469; // sys/user.h pub const MAXCOMLEN: c_int = 32; From 8d561ff741eaa3a7ce843d1aa5625e130cffedc7 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 29 Jul 2025 03:01:57 -0500 Subject: [PATCH 63/93] linux: Fix `s_no_extra_traits`->`s!` in `can` Fixes an accidental semver regression for trait impls introduced in 151d902258ef ("Begin source reorganization with `linux/can.h`", cherry-pick 3356f1217d8d). --- src/new/linux_uapi/linux/can.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 8fb4b9d6dc972..8e48b4a869bb8 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -116,7 +116,9 @@ s_no_extra_traits! { pub tp: __c_anonymous_sockaddr_can_tp, pub j1939: __c_anonymous_sockaddr_can_j1939, } +} +s! { pub struct __c_anonymous_sockaddr_can_tp { pub rx_id: canid_t, pub tx_id: canid_t, From 63011f63a89ee80fdd8145e37e0222e76277220e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 9 Aug 2025 21:06:42 -0500 Subject: [PATCH 64/93] ci: Update Debian s390x links Debian recently had a release, so we need to update our links. (backport ) (cherry picked from commit 46337d0b155a849ba81f7a978810fc0fbd26eb19) --- ci/linux-s390x.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/linux-s390x.sh b/ci/linux-s390x.sh index ddba4c48c0d82..e365cb3abbc8f 100755 --- a/ci/linux-s390x.sh +++ b/ci/linux-s390x.sh @@ -6,8 +6,8 @@ mkdir -m 777 /qemu cd /qemu curl --retry 5 -LO https://github.com/qemu/qemu/raw/HEAD/pc-bios/s390-ccw.img -curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20241227/images/generic/kernel.debian -curl --retry 5 -LO http://ftp.debian.org/debian/dists/testing/main/installer-s390x/20241227/images/generic/initrd.debian +curl --retry 5 -LO https://ftp.debian.org/debian/dists/testing/main/installer-s390x/20250803/images/generic/kernel.debian +curl --retry 5 -LO https://ftp.debian.org/debian/dists/testing/main/installer-s390x/20250803/images/generic/initrd.debian mv kernel.debian kernel mv initrd.debian initrd.gz From 203ff7f960f6c970d6a01b0f1ae5cb7ff1415cd9 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 11 May 2025 22:56:04 +0100 Subject: [PATCH 65/93] Adding strftime* for illumos/solaris. [ref](https://smartos.org/man/3C/strftime) [ref](https://docs.oracle.com/cd/E88353_01/html/E37843/strftime-3c.html) Fixes: #4449 (backport ) (cherry picked from commit f4964b534a01893f2eb7f2f880ddea6277555a19) --- libc-test/semver/solarish.txt | 2 ++ src/unix/solarish/mod.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index b02baab0efac2..cee5977fc35ee 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -75,3 +75,5 @@ posix_spawnattr_setsigmask posix_spawnp recvmsg sendmsg +strftime +strftime_l diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 48f13cdc59ae4..fc89d1d6d2a62 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -3130,6 +3130,21 @@ extern "C" { pub fn arc4random_uniform(upper_bound: u32) -> u32; pub fn secure_getenv(name: *const c_char) -> *mut c_char; + + #[cfg_attr(target_os = "solaris", link_name = "__strftime_xpg7")] + pub fn strftime( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + ) -> size_t; + pub fn strftime_l( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + loc: crate::locale_t, + ) -> size_t; } #[link(name = "sendfile")] From 26d8317dfa0bb5e7ac46fd80fd05546fe2955f7e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 26 Jul 2025 01:29:53 -0500 Subject: [PATCH 66/93] Enable the `rust_2024_compatibility` lint Enable this lint with the expectation that we will eventually be upgrading editions. There are some exceptions needed, and `unsafe_op_in_unsafe_fn` will take a while to go through. (backport ) (cherry picked from commit 2fe8b17c7582e91ed935a8bc6add5b575e087e06) --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index fb901944b22bd..703a985b7acb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,15 @@ unused_macros, unused_macro_rules, )] +// Prepare for a future upgrade +#![warn(rust_2024_compatibility)] +// Things missing for 2024 that are blocked on MSRV or breakage +#![allow( + missing_unsafe_on_extern, + edition_2024_expr_fragment_specifier, + // Allowed globally, the warning is enabled in individual modules as we work through them + unsafe_op_in_unsafe_fn +)] #![cfg_attr(libc_deny_warnings, deny(warnings))] // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] From a28e51f2a5a00a912cf94ccaf2cad28ec92fdca7 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Sun, 29 Jun 2025 09:29:04 -0400 Subject: [PATCH 67/93] add prctl constants on android Add all constants from bionic's `prctl.h` header https://android.googlesource.com/platform/bionic/+/7ac54f5c391bf3aeb9fec84a158939421fd8f505/libc/kernel/uapi/linux/prctl.h (backport ) (cherry picked from commit eb505fb30cd201e146e2aa16b2b843c111a1d033) --- libc-test/semver/android.txt | 156 ++++++++++++++++++++++++++ src/unix/linux_like/android/mod.rs | 173 +++++++++++++++++++++++++++-- 2 files changed, 317 insertions(+), 12 deletions(-) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index a52cc25077a95..80066883c7db0 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -1947,17 +1947,171 @@ PROT_GROWSUP PROT_NONE PROT_READ PROT_WRITE +PR_CAPBSET_DROP +PR_CAPBSET_READ +PR_CAP_AMBIENT +PR_CAP_AMBIENT_CLEAR_ALL +PR_CAP_AMBIENT_IS_SET +PR_CAP_AMBIENT_LOWER +PR_CAP_AMBIENT_RAISE +PR_ENDIAN_BIG +PR_ENDIAN_LITTLE +PR_ENDIAN_PPC_LITTLE +PR_FPEMU_NOPRINT +PR_FPEMU_SIGFPE +PR_FP_EXC_ASYNC +PR_FP_EXC_DISABLED +PR_FP_EXC_DIV +PR_FP_EXC_INV +PR_FP_EXC_NONRECOV +PR_FP_EXC_OVF +PR_FP_EXC_PRECISE +PR_FP_EXC_RES +PR_FP_EXC_SW_ENABLE +PR_FP_EXC_UND +PR_FP_MODE_FR +PR_FP_MODE_FRE +PR_GET_AUXV +PR_GET_CHILD_SUBREAPER +PR_GET_DUMPABLE +PR_GET_ENDIAN +PR_GET_FPEMU +PR_GET_FPEXC +PR_GET_FP_MODE +PR_GET_IO_FLUSHER +PR_GET_KEEPCAPS +PR_GET_MDWE +PR_GET_MEMORY_MERGE PR_GET_NAME PR_GET_NO_NEW_PRIVS +PR_GET_PDEATHSIG PR_GET_SECCOMP +PR_GET_SECUREBITS +PR_GET_SPECULATION_CTRL +PR_GET_TAGGED_ADDR_CTRL +PR_GET_THP_DISABLE +PR_GET_TID_ADDRESS +PR_GET_TIMERSLACK PR_GET_TIMING +PR_GET_TSC +PR_GET_UNALIGN +PR_MCE_KILL +PR_MCE_KILL_CLEAR +PR_MCE_KILL_DEFAULT +PR_MCE_KILL_EARLY +PR_MCE_KILL_GET +PR_MCE_KILL_LATE +PR_MCE_KILL_SET +PR_MDWE_NO_INHERIT +PR_MDWE_REFUSE_EXEC_GAIN +PR_MPX_DISABLE_MANAGEMENT +PR_MPX_ENABLE_MANAGEMENT +PR_MTE_TAG_MASK +PR_MTE_TAG_SHIFT +PR_MTE_TCF_ASYNC +PR_MTE_TCF_MASK +PR_MTE_TCF_NONE +PR_MTE_TCF_SHIFT +PR_MTE_TCF_SYNC +PR_PAC_APDAKEY +PR_PAC_APDBKEY +PR_PAC_APGAKEY +PR_PAC_APIAKEY +PR_PAC_APIBKEY +PR_PAC_GET_ENABLED_KEYS +PR_PAC_RESET_KEYS +PR_PAC_SET_ENABLED_KEYS +PR_RISCV_V_GET_CONTROL +PR_RISCV_V_SET_CONTROL +PR_RISCV_V_VSTATE_CTRL_CUR_MASK +PR_RISCV_V_VSTATE_CTRL_DEFAULT +PR_RISCV_V_VSTATE_CTRL_INHERIT +PR_RISCV_V_VSTATE_CTRL_MASK +PR_RISCV_V_VSTATE_CTRL_NEXT_MASK +PR_RISCV_V_VSTATE_CTRL_OFF +PR_RISCV_V_VSTATE_CTRL_ON +PR_SCHED_CORE +PR_SCHED_CORE_CREATE +PR_SCHED_CORE_GET +PR_SCHED_CORE_MAX +PR_SCHED_CORE_SCOPE_PROCESS_GROUP +PR_SCHED_CORE_SCOPE_THREAD +PR_SCHED_CORE_SCOPE_THREAD_GROUP +PR_SCHED_CORE_SHARE_FROM +PR_SCHED_CORE_SHARE_TO +PR_SET_CHILD_SUBREAPER +PR_SET_DUMPABLE +PR_SET_ENDIAN +PR_SET_FPEMU +PR_SET_FPEXC +PR_SET_FP_MODE +PR_SET_IO_FLUSHER +PR_SET_KEEPCAPS +PR_SET_MDWE +PR_SET_MEMORY_MERGE +PR_SET_MM +PR_SET_MM_ARG_END +PR_SET_MM_ARG_START +PR_SET_MM_AUXV +PR_SET_MM_BRK +PR_SET_MM_END_CODE +PR_SET_MM_END_DATA +PR_SET_MM_ENV_END +PR_SET_MM_ENV_START +PR_SET_MM_EXE_FILE +PR_SET_MM_MAP +PR_SET_MM_MAP_SIZE +PR_SET_MM_START_BRK +PR_SET_MM_START_CODE +PR_SET_MM_START_DATA +PR_SET_MM_START_STACK PR_SET_NAME PR_SET_NO_NEW_PRIVS +PR_SET_PDEATHSIG +PR_SET_PTRACER +PR_SET_PTRACER_ANY PR_SET_SECCOMP +PR_SET_SECUREBITS +PR_SET_SPECULATION_CTRL +PR_SET_SYSCALL_USER_DISPATCH +PR_SET_TAGGED_ADDR_CTRL +PR_SET_THP_DISABLE +PR_SET_TIMERSLACK +PR_SET_TIMING +PR_SET_TSC +PR_SET_UNALIGN PR_SET_VMA PR_SET_VMA_ANON_NAME +PR_SME_GET_VL +PR_SME_SET_VL +PR_SME_SET_VL_ONEXEC +PR_SME_VL_INHERIT +PR_SME_VL_LEN_MASK +PR_SPEC_DISABLE +PR_SPEC_DISABLE_NOEXEC +PR_SPEC_ENABLE +PR_SPEC_FORCE_DISABLE +PR_SPEC_INDIRECT_BRANCH +PR_SPEC_L1D_FLUSH +PR_SPEC_NOT_AFFECTED +PR_SPEC_PRCTL +PR_SPEC_STORE_BYPASS +PR_SVE_GET_VL +PR_SVE_SET_VL +PR_SVE_SET_VL_ONEXEC +PR_SVE_VL_INHERIT +PR_SVE_VL_LEN_MASK +PR_SYS_DISPATCH_OFF +PR_SYS_DISPATCH_ON +PR_TAGGED_ADDR_ENABLE +PR_TASK_PERF_EVENTS_DISABLE +PR_TASK_PERF_EVENTS_ENABLE PR_TIMING_STATISTICAL PR_TIMING_TIMESTAMP +PR_TSC_ENABLE +PR_TSC_SIGSEGV +PR_UNALIGN_NOPRINT +PR_UNALIGN_SIGBUS PTHREAD_BARRIER_SERIAL_THREAD PTHREAD_COND_INITIALIZER PTHREAD_CREATE_DETACHED @@ -2516,6 +2670,8 @@ SW_CNT SW_MAX SYN_CNT SYN_MAX +SYSCALL_DISPATCH_FILTER_ALLOW +SYSCALL_DISPATCH_FILTER_BLOCK SYS_accept4 SYS_acct SYS_add_key diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 100008ce5d8e9..ac76616b68cfb 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -2912,29 +2912,178 @@ pub const PF_VSOCK: c_int = AF_VSOCK; pub const SOMAXCONN: c_int = 128; -// sys/prctl.h -pub const PR_SET_PDEATHSIG: c_int = 1; -pub const PR_GET_PDEATHSIG: c_int = 2; -pub const PR_GET_SECUREBITS: c_int = 27; -pub const PR_SET_SECUREBITS: c_int = 28; - // sys/system_properties.h pub const PROP_VALUE_MAX: c_int = 92; pub const PROP_NAME_MAX: c_int = 32; // sys/prctl.h -pub const PR_SET_VMA: c_int = 0x53564d41; -pub const PR_SET_VMA_ANON_NAME: c_int = 0; -pub const PR_SET_NO_NEW_PRIVS: c_int = 38; -pub const PR_GET_NO_NEW_PRIVS: c_int = 39; -pub const PR_GET_SECCOMP: c_int = 21; -pub const PR_SET_SECCOMP: c_int = 22; +pub const PR_SET_PDEATHSIG: c_int = 1; +pub const PR_GET_PDEATHSIG: c_int = 2; +pub const PR_GET_DUMPABLE: c_int = 3; +pub const PR_SET_DUMPABLE: c_int = 4; +pub const PR_GET_UNALIGN: c_int = 5; +pub const PR_SET_UNALIGN: c_int = 6; +pub const PR_UNALIGN_NOPRINT: c_int = 1; +pub const PR_UNALIGN_SIGBUS: c_int = 2; +pub const PR_GET_KEEPCAPS: c_int = 7; +pub const PR_SET_KEEPCAPS: c_int = 8; +pub const PR_GET_FPEMU: c_int = 9; +pub const PR_SET_FPEMU: c_int = 10; +pub const PR_FPEMU_NOPRINT: c_int = 1; +pub const PR_FPEMU_SIGFPE: c_int = 2; +pub const PR_GET_FPEXC: c_int = 11; +pub const PR_SET_FPEXC: c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: c_int = 0x80; +pub const PR_FP_EXC_DIV: c_int = 0x010000; +pub const PR_FP_EXC_OVF: c_int = 0x020000; +pub const PR_FP_EXC_UND: c_int = 0x040000; +pub const PR_FP_EXC_RES: c_int = 0x080000; +pub const PR_FP_EXC_INV: c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: c_int = 0; +pub const PR_FP_EXC_NONRECOV: c_int = 1; +pub const PR_FP_EXC_ASYNC: c_int = 2; +pub const PR_FP_EXC_PRECISE: c_int = 3; pub const PR_GET_TIMING: c_int = 13; pub const PR_SET_TIMING: c_int = 14; pub const PR_TIMING_STATISTICAL: c_int = 0; pub const PR_TIMING_TIMESTAMP: c_int = 1; pub const PR_SET_NAME: c_int = 15; pub const PR_GET_NAME: c_int = 16; +pub const PR_GET_ENDIAN: c_int = 19; +pub const PR_SET_ENDIAN: c_int = 20; +pub const PR_ENDIAN_BIG: c_int = 0; +pub const PR_ENDIAN_LITTLE: c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: c_int = 2; +pub const PR_GET_SECCOMP: c_int = 21; +pub const PR_SET_SECCOMP: c_int = 22; +pub const PR_CAPBSET_READ: c_int = 23; +pub const PR_CAPBSET_DROP: c_int = 24; +pub const PR_GET_TSC: c_int = 25; +pub const PR_SET_TSC: c_int = 26; +pub const PR_TSC_ENABLE: c_int = 1; +pub const PR_TSC_SIGSEGV: c_int = 2; +pub const PR_GET_SECUREBITS: c_int = 27; +pub const PR_SET_SECUREBITS: c_int = 28; +pub const PR_SET_TIMERSLACK: c_int = 29; +pub const PR_GET_TIMERSLACK: c_int = 30; +pub const PR_TASK_PERF_EVENTS_DISABLE: c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: c_int = 32; +pub const PR_MCE_KILL: c_int = 33; +pub const PR_MCE_KILL_CLEAR: c_int = 0; +pub const PR_MCE_KILL_SET: c_int = 1; +pub const PR_MCE_KILL_LATE: c_int = 0; +pub const PR_MCE_KILL_EARLY: c_int = 1; +pub const PR_MCE_KILL_DEFAULT: c_int = 2; +pub const PR_MCE_KILL_GET: c_int = 34; +pub const PR_SET_MM: c_int = 35; +pub const PR_SET_MM_START_CODE: c_int = 1; +pub const PR_SET_MM_END_CODE: c_int = 2; +pub const PR_SET_MM_START_DATA: c_int = 3; +pub const PR_SET_MM_END_DATA: c_int = 4; +pub const PR_SET_MM_START_STACK: c_int = 5; +pub const PR_SET_MM_START_BRK: c_int = 6; +pub const PR_SET_MM_BRK: c_int = 7; +pub const PR_SET_MM_ARG_START: c_int = 8; +pub const PR_SET_MM_ARG_END: c_int = 9; +pub const PR_SET_MM_ENV_START: c_int = 10; +pub const PR_SET_MM_ENV_END: c_int = 11; +pub const PR_SET_MM_AUXV: c_int = 12; +pub const PR_SET_MM_EXE_FILE: c_int = 13; +pub const PR_SET_MM_MAP: c_int = 14; +pub const PR_SET_MM_MAP_SIZE: c_int = 15; +pub const PR_SET_PTRACER: c_int = 0x59616d61; +pub const PR_SET_PTRACER_ANY: c_ulong = 0xffffffffffffffff; +pub const PR_SET_CHILD_SUBREAPER: c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: c_int = 37; +pub const PR_SET_NO_NEW_PRIVS: c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: c_int = 39; +pub const PR_GET_TID_ADDRESS: c_int = 40; +pub const PR_SET_THP_DISABLE: c_int = 41; +pub const PR_GET_THP_DISABLE: c_int = 42; +pub const PR_MPX_ENABLE_MANAGEMENT: c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: c_int = 44; +pub const PR_SET_FP_MODE: c_int = 45; +pub const PR_GET_FP_MODE: c_int = 46; +pub const PR_FP_MODE_FR: c_int = 1 << 0; +pub const PR_FP_MODE_FRE: c_int = 1 << 1; +pub const PR_CAP_AMBIENT: c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: c_int = 4; +pub const PR_SVE_SET_VL: c_int = 50; +pub const PR_SVE_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SVE_GET_VL: c_int = 51; +pub const PR_SVE_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SVE_VL_INHERIT: c_int = 1 << 17; +pub const PR_GET_SPECULATION_CTRL: c_int = 52; +pub const PR_SET_SPECULATION_CTRL: c_int = 53; +pub const PR_SPEC_STORE_BYPASS: c_int = 0; +pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1; +pub const PR_SPEC_L1D_FLUSH: c_int = 2; +pub const PR_SPEC_NOT_AFFECTED: c_int = 0; +pub const PR_SPEC_PRCTL: c_ulong = 1 << 0; +pub const PR_SPEC_ENABLE: c_ulong = 1 << 1; +pub const PR_SPEC_DISABLE: c_ulong = 1 << 2; +pub const PR_SPEC_FORCE_DISABLE: c_ulong = 1 << 3; +pub const PR_SPEC_DISABLE_NOEXEC: c_ulong = 1 << 4; +pub const PR_PAC_RESET_KEYS: c_int = 54; +pub const PR_PAC_APIAKEY: c_ulong = 1 << 0; +pub const PR_PAC_APIBKEY: c_ulong = 1 << 1; +pub const PR_PAC_APDAKEY: c_ulong = 1 << 2; +pub const PR_PAC_APDBKEY: c_ulong = 1 << 3; +pub const PR_PAC_APGAKEY: c_ulong = 1 << 4; +pub const PR_SET_TAGGED_ADDR_CTRL: c_int = 55; +pub const PR_GET_TAGGED_ADDR_CTRL: c_int = 56; +pub const PR_TAGGED_ADDR_ENABLE: c_ulong = 1 << 0; +pub const PR_MTE_TCF_NONE: c_ulong = 0; +pub const PR_MTE_TCF_SYNC: c_ulong = 1 << 1; +pub const PR_MTE_TCF_ASYNC: c_ulong = 1 << 2; +pub const PR_MTE_TCF_MASK: c_ulong = PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC; +pub const PR_MTE_TAG_SHIFT: c_ulong = 3; +pub const PR_MTE_TAG_MASK: c_ulong = 0xffff << PR_MTE_TAG_SHIFT; +pub const PR_MTE_TCF_SHIFT: c_ulong = 1; +pub const PR_SET_IO_FLUSHER: c_int = 57; +pub const PR_GET_IO_FLUSHER: c_int = 58; +pub const PR_SET_SYSCALL_USER_DISPATCH: c_int = 59; +pub const PR_SYS_DISPATCH_OFF: c_int = 0; +pub const PR_SYS_DISPATCH_ON: c_int = 1; +pub const SYSCALL_DISPATCH_FILTER_ALLOW: c_int = 0; +pub const SYSCALL_DISPATCH_FILTER_BLOCK: c_int = 1; +pub const PR_PAC_SET_ENABLED_KEYS: c_int = 60; +pub const PR_PAC_GET_ENABLED_KEYS: c_int = 61; +pub const PR_SCHED_CORE: c_int = 62; +pub const PR_SCHED_CORE_GET: c_int = 0; +pub const PR_SCHED_CORE_CREATE: c_int = 1; +pub const PR_SCHED_CORE_SHARE_TO: c_int = 2; +pub const PR_SCHED_CORE_SHARE_FROM: c_int = 3; +pub const PR_SCHED_CORE_MAX: c_int = 4; +pub const PR_SCHED_CORE_SCOPE_THREAD: c_int = 0; +pub const PR_SCHED_CORE_SCOPE_THREAD_GROUP: c_int = 1; +pub const PR_SCHED_CORE_SCOPE_PROCESS_GROUP: c_int = 2; +pub const PR_SME_SET_VL: c_int = 63; +pub const PR_SME_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SME_GET_VL: c_int = 64; +pub const PR_SME_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SME_VL_INHERIT: c_int = 1 << 17; +pub const PR_SET_MDWE: c_int = 65; +pub const PR_MDWE_REFUSE_EXEC_GAIN: c_ulong = 1 << 0; +pub const PR_MDWE_NO_INHERIT: c_ulong = 1 << 1; +pub const PR_GET_MDWE: c_int = 66; +pub const PR_SET_VMA: c_int = 0x53564d41; +pub const PR_SET_VMA_ANON_NAME: c_int = 0; +pub const PR_GET_AUXV: c_int = 0x41555856; +pub const PR_SET_MEMORY_MERGE: c_int = 67; +pub const PR_GET_MEMORY_MERGE: c_int = 68; +pub const PR_RISCV_V_SET_CONTROL: c_int = 69; +pub const PR_RISCV_V_GET_CONTROL: c_int = 70; +pub const PR_RISCV_V_VSTATE_CTRL_DEFAULT: c_int = 0; +pub const PR_RISCV_V_VSTATE_CTRL_OFF: c_int = 1; +pub const PR_RISCV_V_VSTATE_CTRL_ON: c_int = 2; +pub const PR_RISCV_V_VSTATE_CTRL_INHERIT: c_int = 1 << 4; +pub const PR_RISCV_V_VSTATE_CTRL_CUR_MASK: c_int = 0x3; +pub const PR_RISCV_V_VSTATE_CTRL_NEXT_MASK: c_int = 0xc; +pub const PR_RISCV_V_VSTATE_CTRL_MASK: c_int = 0x1f; // linux/if_addr.h pub const IFA_UNSPEC: c_ushort = 0; From 65bd617c30a74619291ada8b77227562afd65395 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 28 Jul 2025 11:12:02 +0000 Subject: [PATCH 68/93] l4re: Move `pthread_attr_t` into `s!` Resolve the `improper_ctypes` warning on l4re-uclibc that we are getting in CI. The current version was added in e412497d3e0d ("Move L4Re-specific code into separate module.") and doesn't seem to have been intentional. (backport ) (cherry picked from commit 95c140034157f4c0aafc7b5130ed026390ffd098) --- .../linux_like/linux/uclibc/x86_64/l4re.rs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) 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 380077711d797..536c716ca4868 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -26,22 +26,21 @@ s! { /// Bitmap of CPUs. map: l4_umword_t, } -} -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub struct pthread_attr_t { - pub __detachstate: c_int, - pub __schedpolicy: c_int, - pub __schedparam: super::__sched_param, - pub __inheritsched: c_int, - pub __scope: c_int, - pub __guardsize: size_t, - pub __stackaddr_set: c_int, - pub __stackaddr: *mut c_void, // better don't use it - pub __stacksize: size_t, - // L4Re specifics - pub affinity: l4_sched_cpu_set_t, - pub create_flags: c_uint, + pub struct pthread_attr_t { + pub __detachstate: c_int, + pub __schedpolicy: c_int, + pub __schedparam: super::__sched_param, + pub __inheritsched: c_int, + pub __scope: c_int, + pub __guardsize: size_t, + pub __stackaddr_set: c_int, + pub __stackaddr: *mut c_void, // better don't use it + pub __stacksize: size_t, + // L4Re specifics + pub affinity: l4_sched_cpu_set_t, + pub create_flags: c_uint, + } } // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but From 54d5823082d1fd52649ce20b26e229b6dcce2f2e Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 10 Aug 2025 20:42:23 -0500 Subject: [PATCH 69/93] Update the `c_enum` macro to take multiple values Partial cherry pick of a541bf4f6dc5 ("libc: remove uses of enum as per #4419"). Co-authored-by: mbyx --- src/macros.rs | 30 ++++++++++++++++++++++-------- src/unix/linux_like/linux/mod.rs | 8 +++----- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 5f2a08d5de32d..d0a55fa2fca29 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -223,10 +223,24 @@ macro_rules! e { /// /// See for more. macro_rules! c_enum { - ( + ($( + $(#[repr($repr:ty)])? + pub enum $ty_name:ident { + $($variant:ident $(= $value:expr)?,)+ + } + )+) => { + $(c_enum!(@expand; + $(#[repr($repr)])? + pub enum $ty_name { + $($variant $(= $value)?,)+ + } + );)+ + }; + + (@expand; $(#[repr($repr:ty)])? - enum $ty_name:ident { - $($variant:ident $(= $value:literal)?,)+ + pub enum $ty_name:ident { + $($variant:ident $(= $value:expr)?,)+ } ) => { pub type $ty_name = c_enum!(@ty $($repr)?); @@ -237,7 +251,7 @@ macro_rules! c_enum { (@one; $_ty_name:ident; $_idx:expr;) => {}; ( @one; $ty_name:ident; $default_val:expr; - $variant:ident $(= $value:literal)?, + $variant:ident $(= $value:expr)?, $($tail:tt)* ) => { pub const $variant: $ty_name = { @@ -413,7 +427,7 @@ mod tests { fn c_enumbasic() { // By default, variants get sequential values. c_enum! { - enum e { + pub enum e { VAR0, VAR1, VAR2, @@ -430,7 +444,7 @@ mod tests { // By default, variants get sequential values. c_enum! { #[repr(u16)] - enum e { + pub enum e { VAR0, } } @@ -442,7 +456,7 @@ mod tests { fn c_enumset_value() { // Setting an explicit value resets the count. c_enum! { - enum e { + pub enum e { VAR2 = 2, VAR3, VAR4, @@ -459,7 +473,7 @@ mod tests { // C enums always take one more than the previous value, unless set to a specific // value. Duplicates are allowed. c_enum! { - enum e { + pub enum e { VAR0, VAR2_0 = 2, VAR3_0, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7fd24d480c53a..182889574eadd 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -84,7 +84,7 @@ e! { } c_enum! { - enum pid_type { + pub enum pid_type { PIDTYPE_PID, PIDTYPE_TGID, PIDTYPE_PGID, @@ -4468,14 +4468,12 @@ pub const RTNLGRP_STATS: c_uint = 0x24; // linux/cn_proc.h c_enum! { - enum proc_cn_mcast_op { + pub enum proc_cn_mcast_op { PROC_CN_MCAST_LISTEN = 1, PROC_CN_MCAST_IGNORE = 2, } -} -c_enum! { - enum proc_cn_event { + pub enum proc_cn_event { PROC_EVENT_NONE = 0x00000000, PROC_EVENT_FORK = 0x00000001, PROC_EVENT_EXEC = 0x00000002, From f0a2c3e97baefd170b6ead3ab9db3dfc22538bdf Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 10 Aug 2025 20:42:23 -0500 Subject: [PATCH 70/93] haiku: Switch from `e!` to `c_enum!` The enums used on Haiku are currently broken: they have no `repr` attribute so Rust is treating them as a `u8` when they need to be `c_int`. This is flagged by `improper_ctypes`, which only shows up now that this lint got removed. Since this is broken anyway, we may as well just switch to `c_enum!`. This is a user-visible breaking change, but allowed as the target is tier 3. Partially cherry picked from commit a541bf4f6dc5 ("libc: remove uses of enum as per #4419"). Co-authored-by: mbyx --- src/unix/haiku/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 082e85b326ead..f3eaf623a59a5 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -46,7 +46,7 @@ pub type thread_func = extern "C" fn(*mut c_void) -> status_t; // kernel/image.h pub type image_id = i32; -e! { +c_enum! { // kernel/OS.h pub enum thread_state { B_THREAD_RUNNING = 1, From eaab4fc3f05dc646a953d4fd5ba46dfa1f8bd6f6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 10 Aug 2025 21:47:19 -0500 Subject: [PATCH 71/93] psp: Correct char -> c_char --- src/psp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/psp.rs b/src/psp.rs index 131ef3180332b..823567127c401 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -3271,18 +3271,18 @@ extern "C" { pub fn sceRtcGetWin32FileTime(date: *mut ScePspDateTime, time: *mut u64) -> i32; pub fn sceRtcParseDateTime(dest_tick: *mut u64, date_string: *const u8) -> i32; pub fn sceRtcFormatRFC3339( - psz_date_time: *mut char, + psz_date_time: *mut c_char, p_utc: *const u64, time_zone_minutes: i32, ) -> i32; - pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32; + pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; pub fn sceRtcParseRFC3339(p_utc: *mut u64, psz_date_time: *const u8) -> i32; pub fn sceRtcFormatRFC2822( - psz_date_time: *mut char, + psz_date_time: *mut c_char, p_utc: *const u64, time_zone_minutes: i32, ) -> i32; - pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32; + pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; pub fn sceIoOpen(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; pub fn sceIoOpenAsync(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; From 40b9f1c0b6ae36c8fa4cb5bc56ccfb7b51d5a3bb Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 26 Jul 2025 01:27:28 -0500 Subject: [PATCH 72/93] Don't allow `improper_ctypes` Most of what this crate does is interact with C, so the lint should be useful. It can be disabled on a case-by-case basis as needed. There are a few fixes needed for enums, which will be going away anyway (rust-lang/libc#4419). Additionally, switch the `bad_style` lint to the newer name `nonstandard_style`. (backport ) (cherry picked from commit 38bb46e21cfbf5fa0f5c879be7b98079de75c9e6) --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 703a985b7acb6..5989c64da6287 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,9 +4,8 @@ #![allow( renamed_and_removed_lints, // Keep this order. unknown_lints, // Keep this order. - bad_style, + nonstandard_style, overflowing_literals, - improper_ctypes, unused_macros, unused_macro_rules, )] From d287f62aba0d8f9c44bce9080c489dbc5abebb75 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 24 Jul 2025 15:41:01 -0400 Subject: [PATCH 73/93] Add 'struct ld_info' and friends. (backport ) (cherry picked from commit 925eb0c94f5ceab848c666bc1bac4b34044a5c7b) --- libc-test/build.rs | 17 +++++++++ libc-test/semver/aix.txt | 6 ++++ src/unix/aix/powerpc64.rs | 75 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7ea00da688a19..ce3a3fda4e1f6 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5702,6 +5702,18 @@ fn test_aix(target: &str) { // allow type 'double' to be used in signal contexts. "fpreg_t" => true, + // This type is defined for a union used within `struct ld_info`. + // The AIX header does not declare a separate standalone union + // type for it. + "__ld_info_file" => true, + + // This is a simplified version of the AIX union `_simple_lock`. + "_kernel_simple_lock" => true, + + // These structures are guarded by the `_KERNEL` macro in the AIX + // header. + "fileops_t" | "file" => true, + _ => false, } }); @@ -5719,6 +5731,11 @@ fn test_aix(target: &str) { // The _ALL_SOURCE type of 'f_fsid' differs from POSIX's on AIX. ("statvfs", "f_fsid") => true, + // The type of `_file` is `__ld_info_file`, which is defined + // specifically for the union inside `struct ld_info`. The AIX + // header does not define a separate standalone union type for it. + ("ld_info", "_file") => true, + _ => false, } }); diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index 1f3324e213f54..73163c854f30d 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -1791,12 +1791,14 @@ _W_STOPPED _W_STRC __context64 __extctx_t +__ld_info_file __pollfd_ext_u __tm_context_t __vmx_context_t __vmxreg_t __vsx_context_t _exit +_kernel_simple_lock abort accept access @@ -1915,7 +1917,9 @@ fgetpos fgetpos64 fgetpwent fgets +file fileno +fileops_t flock flock64 fnmatch @@ -2079,6 +2083,7 @@ kill lchown lcong48 lconv +ld_info lfind linger link @@ -2090,6 +2095,7 @@ locale_t localeconv localtime localtime_r +lock_data_instrumented lpar_get_info lpar_set_resources lrand48 diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index b2b7ea88f6e4e..1a8ebb1cc7f6b 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -1,6 +1,12 @@ use crate::off_t; use crate::prelude::*; +// Define lock_data_instrumented as an empty enum +missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum lock_data_instrumented {} +} + s! { pub struct sigset_t { pub ss_set: [c_ulong; 4], @@ -256,6 +262,74 @@ s_no_extra_traits! { pub __pad: [c_int; 3], } + pub union _kernel_simple_lock { + pub _slock: c_long, + pub _slockp: *mut lock_data_instrumented, + } + + pub struct fileops_t { + pub fo_rw: Option< + extern "C" fn( + file: *mut file, + rw: crate::uio_rw, + io: *mut c_void, + ext: c_long, + secattr: *mut c_void, + ) -> c_int, + >, + pub fo_ioctl: Option< + extern "C" fn( + file: *mut file, + a: c_long, + b: crate::caddr_t, + c: c_long, + d: c_long, + ) -> c_int, + >, + pub fo_select: Option< + extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int, + >, + pub fo_close: Option c_int>, + pub fo_fstat: Option c_int>, + } + + pub struct file { + pub f_flag: c_long, + pub f_count: c_int, + pub f_options: c_short, + pub f_type: c_short, + // Should be pointer to 'vnode' + pub f_data: *mut c_void, + pub f_offset: c_longlong, + pub f_dir_off: c_long, + // Should be pointer to 'cred' + pub f_cred: *mut c_void, + pub f_lock: _kernel_simple_lock, + pub f_offset_lock: _kernel_simple_lock, + pub f_vinfo: crate::caddr_t, + pub f_ops: *mut fileops_t, + pub f_parentp: crate::caddr_t, + pub f_fnamep: crate::caddr_t, + pub f_fdata: [c_char; 160], + } + + pub union __ld_info_file { + pub _ldinfo_fd: c_int, + pub _ldinfo_fp: *mut file, + pub _core_offset: c_long, + } + + pub struct ld_info { + pub ldinfo_next: c_uint, + pub ldinfo_flags: c_uint, + pub _file: __ld_info_file, + pub ldinfo_textorg: *mut c_void, + pub ldinfo_textsize: c_ulong, + pub ldinfo_dataorg: *mut c_void, + pub ldinfo_datasize: c_ulong, + pub ldinfo_filename: [c_char; 2], + } + pub union __pollfd_ext_u { pub addr: *mut c_void, pub data32: u32, @@ -327,6 +401,7 @@ cfg_if! { self.__si_flags.hash(state); } } + impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { From eed2be9367633d953e624a9118c9a437c05fb489 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Mon, 28 Jul 2025 11:53:03 -0400 Subject: [PATCH 74/93] Remove duplicate constant definitions FIND and ENTER. (backport ) (cherry picked from commit bdc4b7df37ec8bbac325ddd6cdba712a0abe3bcd) --- src/unix/aix/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 1ee8c53b5505b..9a4eac63dea63 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1159,10 +1159,6 @@ pub const NFSMNT_ACDIRMAX: c_int = 0x0800; // rpcsvc/rstat.h pub const CPUSTATES: c_int = 4; -// search.h -pub const FIND: c_int = 0; -pub const ENTER: c_int = 1; - // semaphore.h pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t; From aadbcf5307bca6e6476672234629d2ec2dbdb545 Mon Sep 17 00:00:00 2001 From: qinghon Date: Sun, 25 May 2025 00:44:44 +0800 Subject: [PATCH 75/93] netbsd/openbsd: Export ioctl request generator macros (backport ) (cherry picked from commit e7cf1cc51c715d495cfd41fa3a1e7b10eb9f6f57) --- libc-test/semver/netbsd.txt | 16 +++++++++++++++ libc-test/semver/openbsd.txt | 14 +++++++++++++ src/unix/bsd/netbsdlike/mod.rs | 28 ++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 23 +++++++++++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 17 ++++++++++++++++ 5 files changed, 98 insertions(+) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 57e1cf5c4bd1b..677e37ea0a155 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -426,6 +426,17 @@ IFF_SIMPLEX IFF_UP IMAXBEL INIT_PROCESS +IOCBASECMD +IOCGROUP +IOCGROUP_SHIFT +IOCPARM_LEN +IOCPARM_MASK +IOCPARM_SHIFT +IOC_DIRMASK +IOC_IN +IOC_INOUT +IOC_OUT +IOC_VOID IOV_MAX IPC_CREAT IPC_EXCL @@ -1116,9 +1127,14 @@ XATTR_CREATE XATTR_REPLACE YESEXPR YESSTR +_IO +_IOC _IOFBF _IOLBF _IONBF +_IOR +_IOW +_IOWR _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_FILESIZEBITS diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index a340a83a92712..c63c347723834 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -267,6 +267,15 @@ IFF_SIMPLEX IFF_STATICARP IFF_UP IMAXBEL +IOCBASECMD +IOCGROUP +IOCPARM_LEN +IOCPARM_MASK +IOC_DIRMASK +IOC_IN +IOC_INOUT +IOC_OUT +IOC_VOID IOV_MAX IPC_CREAT IPC_EXCL @@ -912,9 +921,14 @@ WSTOPPED WTRAPPED YESEXPR YESSTR +_IO +_IOC _IOFBF _IOLBF _IONBF +_IOR +_IOW +_IOWR _MAX_PAGE_SHIFT _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 682b8b7e9fe74..b9c35fe7f41f3 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -440,6 +440,34 @@ pub const MNT_NODEV: c_int = 0x00000010; pub const MNT_LOCAL: c_int = 0x00001000; pub const MNT_QUOTA: c_int = 0x00002000; +// sys/ioccom.h in NetBSD and OpenBSD +pub const IOCPARM_MASK: u32 = 0x1fff; + +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + +pub const fn _IO(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_VOID, g, n, 0) +} + +/// Build an ioctl number for an read-only ioctl. +pub const fn _IOR(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_OUT, g, n, mem::size_of::() as c_ulong) +} + +/// Build an ioctl number for an write-only ioctl. +pub const fn _IOW(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_IN, g, n, mem::size_of::() as c_ulong) +} + +/// Build an ioctl number for a read-write ioctl. +pub const fn _IOWR(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_INOUT, g, n, mem::size_of::() as c_ulong) +} + pub const AF_UNSPEC: c_int = 0; pub const AF_LOCAL: c_int = 1; pub const AF_UNIX: c_int = AF_LOCAL; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 1367276762d61..507905f532d3b 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1712,6 +1712,29 @@ pub const MNT_WAIT: c_int = 1; pub const MNT_NOWAIT: c_int = 2; pub const MNT_LAZY: c_int = 3; +// sys/ioccom.h +pub const IOCPARM_SHIFT: u32 = 16; +pub const IOCGROUP_SHIFT: u32 = 8; + +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> IOCPARM_SHIFT) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << IOCPARM_SHIFT)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> IOCGROUP_SHIFT) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) + | (((len) & crate::IOCPARM_MASK as c_ulong) << IOCPARM_SHIFT) + | ((group) << IOCGROUP_SHIFT) + | (num) +} + // pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 3a7aeadf4656d..5ee6bc0ca04f3 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1738,6 +1738,23 @@ pub const PF_R: u32 = 0x4; pub const PF_MASKOS: u32 = 0x0ff00000; pub const PF_MASKPROC: u32 = 0xf0000000; +// sys/ioccom.h +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> 16) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << 16)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> 8) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) | (((len) & crate::IOCPARM_MASK as c_ulong) << 16) | ((group) << 8) | (num) +} + // sys/mount.h pub const MNT_NOPERM: c_int = 0x00000020; pub const MNT_WXALLOWED: c_int = 0x00000800; From d23c71ee979e1a32aaf97a9a7c5f38ff0a59c3b1 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Tue, 29 Jul 2025 12:08:16 -0400 Subject: [PATCH 76/93] Fix the types of 'struct stat'/'stat stat64' fields 'st_*tim'. (backport ) (cherry picked from commit cf82fdf3f22ccfa98ba120efc50d5f39ab2d52ff) --- libc-test/build.rs | 10 ++++++++++ src/unix/aix/mod.rs | 6 +++--- src/unix/aix/powerpc64.rs | 6 +++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index ce3a3fda4e1f6..fb9367d2ff958 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5736,6 +5736,16 @@ fn test_aix(target: &str) { // header does not define a separate standalone union type for it. ("ld_info", "_file") => true, + // On AIX, when _ALL_SOURCE is defined, the types of the following fields + // differ from those used when _XOPEN_SOURCE is defined. The former uses + // 'struct st_timespec', while the latter uses 'struct timespec'. + ("stat", "st_atim") => true, + ("stat", "st_mtim") => true, + ("stat", "st_ctim") => true, + ("stat64", "st_atim") => true, + ("stat64", "st_mtim") => true, + ("stat64", "st_ctim") => true, + _ => false, } }); diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 9a4eac63dea63..a4e975ad8030e 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -463,9 +463,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: dev_t, pub st_ssize: c_int, - pub st_atim: st_timespec, - pub st_mtim: st_timespec, - pub st_ctim: st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, pub st_vfstype: c_int, diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 1a8ebb1cc7f6b..856fd0d127d70 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -69,9 +69,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_ssize: c_int, - pub st_atim: crate::st_timespec, - pub st_mtim: crate::st_timespec, - pub st_ctim: crate::st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_vfstype: c_int, From 60a8cfd564f83164d45b9533ff7a0d7371878f2a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 29 Jul 2025 05:53:53 -0500 Subject: [PATCH 77/93] NetBSD: mark an enum `#[repr(C)]` Resolve an instance of `improper_ctypes`. --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 507905f532d3b..b6b3639c37916 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -39,6 +39,7 @@ pub type Elf64_Xword = u64; pub type iconv_t = *mut c_void; e! { + #[repr(C)] pub enum fae_action { FAE_OPEN, FAE_DUP2, From 7085e0f243a91e0fa5f4640f35f4393c9bc338fe Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Fri, 1 Aug 2025 21:39:50 +0200 Subject: [PATCH 78/93] NetBSD: add ptsname_r support (backport ) (cherry picked from commit e634372f7ebe918abccfa9b0de25f6dda2399f66) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index b6b3639c37916..8179de20797e5 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2497,6 +2497,8 @@ extern "C" { winp: *mut crate::winsize, ) -> crate::pid_t; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + #[link_name = "__lutimes50"] pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; #[link_name = "__gettimeofday50"] From f6355882054c91d0ed7827f35ea3d2c8b2dcfe76 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Wed, 6 Aug 2025 15:21:45 +0200 Subject: [PATCH 79/93] Export UDP socket option consts on Android (backport ) (cherry picked from commit a43bdc34b235b4992289a0903ec24d86121af4c0) --- libc-test/semver/android.txt | 6 ++++++ src/unix/linux_like/android/mod.rs | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 80066883c7db0..96c77cb43c5ef 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3096,6 +3096,12 @@ TUN_F_USO4 TUN_F_USO6 TUN_PKT_STRIP TUN_TX_TIMESTAMP +UDP_CORK +UDP_ENCAP +UDP_GRO +UDP_NO_CHECK6_RX +UDP_NO_CHECK6_TX +UDP_SEGMENT UINPUT_MAX_NAME_SIZE UINPUT_VERSION UIO_MAXIOV diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index ac76616b68cfb..df901a36635a8 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1323,6 +1323,15 @@ pub const SOL_ATALK: c_int = 258; pub const SOL_NETROM: c_int = 259; pub const SOL_ROSE: c_int = 260; +/* UDP socket options */ +// include/uapi/linux/udp.h +pub const UDP_CORK: c_int = 1; +pub const UDP_ENCAP: c_int = 100; +pub const UDP_NO_CHECK6_TX: c_int = 101; +pub const UDP_NO_CHECK6_RX: c_int = 102; +pub const UDP_SEGMENT: c_int = 103; +pub const UDP_GRO: c_int = 104; + /* DCCP socket options */ pub const DCCP_SOCKOPT_PACKET_SIZE: c_int = 1; pub const DCCP_SOCKOPT_SERVICE: c_int = 2; From 4fa238b0c252d87f8b1badc3016add6923c3f644 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 2 Aug 2025 12:49:42 -0700 Subject: [PATCH 80/93] riscv32: Define plain syscalls as their time64 variants RISCV32 is "time64-only" from the beginning on the kernel side. Based on musl change [1] [1] https://git.musl-libc.org/cgit/musl/commit/?id=4bbd7baea7c8538b3fb8e30f7b022a1eee071450 (backport ) (cherry picked from commit 458c5a0fb8668ec2f19f4a8ce023934809c58e52) --- .../linux_like/linux/musl/b32/riscv32/mod.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 0e2f53edcad4c..ea4b51f006f0f 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -633,3 +633,23 @@ pub const SYS_faccessat2: c_long = 439; pub const SYS_process_madvise: c_long = 440; pub const SYS_epoll_pwait2: c_long = 441; pub const SYS_mount_setattr: c_long = 442; + +// Plain syscalls aliased to their time64 variants +pub const SYS_clock_gettime: c_long = SYS_clock_gettime64; +pub const SYS_clock_settime: c_long = SYS_clock_settime64; +pub const SYS_clock_adjtime: c_long = SYS_clock_adjtime64; +pub const SYS_clock_getres: c_long = SYS_clock_getres_time64; +pub const SYS_clock_nanosleep: c_long = SYS_clock_nanosleep_time64; +pub const SYS_timer_gettime: c_long = SYS_timer_gettime64; +pub const SYS_timer_settime: c_long = SYS_timer_settime64; +pub const SYS_timerfd_gettime: c_long = SYS_timerfd_gettime64; +pub const SYS_timerfd_settime: c_long = SYS_timerfd_settime64; +pub const SYS_utimensat: c_long = SYS_utimensat_time64; +pub const SYS_pselect6: c_long = SYS_pselect6_time64; +pub const SYS_ppoll: c_long = SYS_ppoll_time64; +pub const SYS_recvmmsg: c_long = SYS_recvmmsg_time64; +pub const SYS_mq_timedsend: c_long = SYS_mq_timedsend_time64; +pub const SYS_mq_timedreceive: c_long = SYS_mq_timedreceive_time64; +pub const SYS_rt_sigtimedwait: c_long = SYS_rt_sigtimedwait_time64; +pub const SYS_futex: c_long = SYS_futex_time64; +pub const SYS_sched_rr_get_interval: c_long = SYS_sched_rr_get_interval_time64; From d431cd27a62f3c1679a19aeaec49428a52d08635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Oct 2024 09:05:59 +0200 Subject: [PATCH 81/93] Enable statx on musl-libc Version 1.2.5 of musl-libc added support for the statx system call[1]. [1]: https://musl.libc.org/releases.html (backport ) (cherry picked from commit ef3c046a1a839d3eef28d69de6b397e83ce9b94a) --- src/unix/linux_like/mod.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 98a093db2e742..b044caf109ee1 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -234,7 +234,11 @@ cfg_if! { } cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { s! { pub struct statx { pub stx_mask: crate::__u32, @@ -1663,7 +1667,11 @@ cfg_if! { } cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; pub const AT_STATX_SYNC_AS_STAT: c_int = 0x0000; pub const AT_STATX_FORCE_SYNC: c_int = 0x2000; @@ -2181,7 +2189,11 @@ cfg_if! { // The statx syscall, available on some libcs. cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { extern "C" { pub fn statx( dirfd: c_int, From d3c354e1e2767eae5a226fcc7e631ee4ec1f53a3 Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Mon, 23 Dec 2024 10:16:15 +0000 Subject: [PATCH 82/93] Haiku: move BSD API to a separate file Haiku implements various parts of the (non-POSIX) BSD API. This moves it to a separate file, for easier future maintenance. No functional change intended; the changes are synchronized with R1Beta5 (backport ) (cherry picked from commit f1091a7e87f04c0f7f78ef4b0dee15a0b1d71618) --- src/unix/haiku/bsd.rs | 81 +++++++++++++++++++++++++++++++++++++++ src/unix/haiku/mod.rs | 83 +++++++++++++--------------------------- src/unix/haiku/native.rs | 14 +------ 3 files changed, 109 insertions(+), 69 deletions(-) create mode 100644 src/unix/haiku/bsd.rs diff --git a/src/unix/haiku/bsd.rs b/src/unix/haiku/bsd.rs new file mode 100644 index 0000000000000..f093911d0c9c8 --- /dev/null +++ b/src/unix/haiku/bsd.rs @@ -0,0 +1,81 @@ +//! This file contains the BSD APIs available in Haiku. It corresponds to the +//! header files in `headers/compatibility/bsd`. +//! +//! Note that Haiku's BSD compatibility is a combination of system APIs and +//! utility libraries. There should only be system APIs in `libc`. When you are +//! trying to determine whether something should be included in this file, the +//! best indicator is whether it also exists in the BSD-specific definitions in +//! this libc crate. + +use crate::prelude::*; + +// stringlist.h (utility library) +// Note: this is kept because it was previously introduced +pub type StringList = _stringlist; + +s! { + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub struct _stringlist { + pub sl_str: *mut *mut c_char, + pub sl_max: size_t, + pub sl_cur: size_t, + } + + // sys/link_elf.h + pub struct dl_phdr_info { + pub dlpi_addr: crate::Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const crate::Elf_Phdr, + pub dlpi_phnum: crate::Elf_Half, + } +} + +#[link(name = "bsd")] +extern "C" { + // stdlib.h + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn getprogname() -> *const c_char; + pub fn setprogname(progname: *const c_char); + pub fn arc4random() -> u32; + pub fn arc4random_uniform(upper_bound: u32) -> u32; + pub fn arc4random_buf(buf: *mut c_void, n: size_t); + + // pty.h + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn login_tty(_fd: c_int) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + + // string.h + pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; + pub fn explicit_bzero(buf: *mut c_void, len: size_t); + + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub fn sl_init() -> *mut StringList; + pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; + pub fn sl_free(sl: *mut StringList, i: c_int); + pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; + + // sys/link_elf.h + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + // sys/time.h + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; +} diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 790591fc0b9f7..71eb890d30452 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1,5 +1,29 @@ use crate::prelude::*; +// This module contains bindings to the native Haiku API. The Haiku API +// originates from BeOS, and it was the original way to perform low level +// system and IO operations. The POSIX API was in that era was like a +// compatibility layer. In current Haiku development, both the POSIX API and +// the Haiku API are considered to be co-equal status. However, they are not +// integrated like they are on other UNIX platforms, which means that for many +// low level concepts there are two versions, like processes (POSIX) and +// teams (Haiku), or pthreads and native threads. +// +// Both the POSIX API and the Haiku API live in libroot.so, the library that is +// linked to any binary by default. Additionally, Haiku supports several +// non-POSIX APIs from BSD and GNU, which live in libbsd.so and libgnu.so. These +// modules are also supported. +// +// The module is comprised of the following files: +// - `mod.rs` (this file) implements the C11 and POSIX API found in +// `headers/posix` +// - `b32.rs`, `b64.rs` and `x86_64.rs` contain platform-specific definitions +// of the C11 and POSIX APIs +// - `native.rs` defines the native Haiku API that is implemented in +// `libroot.so` and that are found in `headers/os`. +// - `bsd.rs` defines the BSD customizations available on Haiku found in +// `headers/compatibility/bsd` + pub type rlim_t = crate::uintptr_t; pub type sa_family_t = u8; pub type pthread_key_t = c_int; @@ -56,8 +80,6 @@ pub type ACTION = c_int; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -pub type StringList = _stringlist; - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl Copy for timezone {} @@ -440,19 +462,6 @@ s! { pub flag: *mut c_int, pub val: c_int, } - - pub struct _stringlist { - pub sl_str: *mut *mut c_char, - pub sl_max: size_t, - pub sl_cur: size_t, - } - - pub struct dl_phdr_info { - pub dlpi_addr: crate::Elf_Addr, - pub dlpi_name: *const c_char, - pub dlpi_phdr: *const crate::Elf_Phdr, - pub dlpi_phnum: crate::Elf_Half, - } } s_no_extra_traits! { @@ -1772,7 +1781,6 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; - 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 bind( @@ -2032,46 +2040,6 @@ extern "C" { pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; } -#[link(name = "bsd")] -extern "C" { - pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; - pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; - pub fn forkpty( - amaster: *mut c_int, - name: *mut c_char, - termp: *mut termios, - winp: *mut crate::winsize, - ) -> crate::pid_t; - pub fn openpty( - amaster: *mut c_int, - aslave: *mut c_int, - name: *mut c_char, - termp: *mut termios, - winp: *mut crate::winsize, - ) -> c_int; - pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; - pub fn explicit_bzero(buf: *mut c_void, len: size_t); - pub fn login_tty(_fd: c_int) -> c_int; - - pub fn sl_init() -> *mut StringList; - pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; - pub fn sl_free(sl: *mut StringList, i: c_int); - pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; - - pub fn getprogname() -> *const c_char; - pub fn setprogname(progname: *const c_char); - pub fn dl_iterate_phdr( - callback: Option< - unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, - >, - data: *mut c_void, - ) -> c_int; - - pub fn arc4random() -> u32; - pub fn arc4random_uniform(upper_bound: u32) -> u32; - pub fn arc4random_buf(buf: *mut c_void, n: size_t); -} - #[link(name = "gnu")] extern "C" { pub fn memmem( @@ -2115,5 +2083,8 @@ cfg_if! { } } +mod bsd; +pub use self::bsd::*; + mod native; pub use self::native::*; diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index f3eaf623a59a5..13a203f92ff56 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -1,19 +1,7 @@ use crate::off_t; use crate::prelude::*; -// This module contains bindings to the native Haiku API. The Haiku API -// originates from BeOS, and it was the original way to perform low level -// system and IO operations. The POSIX API was in that era was like a -// compatibility layer. In current Haiku development, both the POSIX API and -// the Haiku API are considered to be co-equal status. However, they are not -// integrated like they are on other UNIX platforms, which means that for many -// low level concepts there are two versions, like processes (POSIX) and -// teams (Haiku), or pthreads and native threads. -// -// Both the POSIX API and the Haiku API live in libroot.so, the library that is -// linked to any binary by default. -// -// This file follows the Haiku API for Haiku R1 beta 2. It is organized by the +// This file follows the Haiku API for Haiku R1 beta 5. It is organized by the // C/C++ header files in which the concepts can be found, while adhering to the // style guide for this crate. From 802771851aeea8255a82335e38a66ff9e5d167c5 Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Wed, 25 Dec 2024 16:54:36 +0000 Subject: [PATCH 83/93] Haiku: add additional functionality in libbsd.so This includes: * sys/event.h: `kevent()`, `kqueue()`, data structure and constants * sys/iocomm.h: constants that are also defined for other platforms * stdlib.h: `mkstemps()` and `strtonum()` * sys/uov.h: `preadv()` and `pwritev()` * sys/wait.h: `wait4()` (backport ) (cherry picked from commit 7fd1b1a7b956bb345506a380874e6dfc523f93ba) --- src/unix/haiku/bsd.rs | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/unix/haiku/bsd.rs b/src/unix/haiku/bsd.rs index f093911d0c9c8..1e3881e2c67ff 100644 --- a/src/unix/haiku/bsd.rs +++ b/src/unix/haiku/bsd.rs @@ -22,6 +22,17 @@ s! { pub sl_cur: size_t, } + // sys/event.h + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + // sys/link_elf.h pub struct dl_phdr_info { pub dlpi_addr: crate::Elf_Addr, @@ -31,6 +42,25 @@ s! { } } +// sys/event.h +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_PROC: i16 = -5; +pub const EV_ADD: u16 = 0x0001; +pub const EV_DELETE: u16 = 0x0002; +pub const EV_ONESHOT: u16 = 0x0010; +pub const EV_CLEAR: u16 = 0x0020; +pub const EV_EOF: u16 = 0x8000; +pub const EV_ERROR: u16 = 0x4000; +pub const NOTE_EXIT: u32 = 0x80000000; + +// sys/ioccom.h +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + #[link(name = "bsd")] extern "C" { // stdlib.h @@ -40,6 +70,13 @@ extern "C" { pub fn arc4random() -> u32; pub fn arc4random_uniform(upper_bound: u32) -> u32; pub fn arc4random_buf(buf: *mut c_void, n: size_t); + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn strtonum( + nptr: *const c_char, + minval: c_longlong, + maxval: c_longlong, + errstr: *mut *const c_char, + ) -> c_longlong; // pty.h pub fn openpty( @@ -68,6 +105,17 @@ extern "C" { pub fn sl_free(sl: *mut StringList, i: c_int); pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; + // sys/event.h + pub fn kqueue() -> c_int; + pub fn kevent( + kq: c_int, + changelist: *const kevent, + nchanges: c_int, + eventlist: *mut kevent, + nevents: c_int, + timeout: *const crate::timespec, + ) -> c_int; + // sys/link_elf.h pub fn dl_iterate_phdr( callback: Option< @@ -78,4 +126,26 @@ extern "C" { // sys/time.h pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + // sys/uov.h + pub fn preadv( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + pub fn pwritev( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + + // sys/wait.h + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; } From 7cdcaa62396816db2177cb663a4bf57f79603a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Jul 2025 16:02:37 +0200 Subject: [PATCH 84/93] freebsd: Fix type of struct xktls_session_onedir, field ifnet For the upstream definition, see: https://github.com/freebsd/freebsd-src/commit/c9e9a0fe5b0f88561f55fb2f6f5354fbbd96dd5d (backport ) (cherry picked from commit 985d95bb29c2156adcebf881266fd2f1a8708c6e) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3466e3b38d8cb..e2ee8e21f0c6f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1758,7 +1758,7 @@ s_no_extra_traits! { pub tls_bs: u8, pub flags: u8, pub drv_st_len: u16, - pub ifnet: [u8; 16], + pub ifnet: [c_char; 16], } pub struct xktls_session { From 4cc1bf43310e6a31636e4c4eb31e78e702938f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Thu, 24 Jul 2025 17:38:51 +0200 Subject: [PATCH 85/93] freebsd: Document avoidance of reserved name `gen` (backport ) (cherry picked from commit 99e33735dbc69837d5f4d1ea91a4ed353695985e) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index e2ee8e21f0c6f..f60eb1a3e9cbe 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1741,6 +1741,8 @@ s_no_extra_traits! { } pub struct xktls_session_onedir { + // Note: this field is called `gen` in upstream FreeBSD, but `gen` is + // reserved keyword in Rust since the 2024 Edition, hence `gennum`. pub gennum: u64, _rsrv1: [u64; 8], _rsrv2: [u32; 8], From adfe283365cff1c6a05cddeca8afeaa667d1c637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Thu, 24 Jul 2025 17:50:17 +0200 Subject: [PATCH 86/93] libc-test: Account for xktls_session_onedir::gen (freebsd) (backport ) (cherry picked from commit 56a04abb0c9f0cd84c7234451456eda4f796ae26) --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index fb9367d2ff958..1304d3bf14202 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2585,6 +2585,8 @@ fn test_freebsd(target: &str) { "type_" if struct_ == "sockstat" => "type".to_string(), "type_" if struct_ == "devstat_match_table" => "type".to_string(), "type_" if struct_ == "input_event" => "type".to_string(), + // Field is named `gennum` in Rust because `gen` is a keyword + "gennum" if struct_ == "xktls_session_onedir" => "gen".to_string(), s => s.to_string(), } }); From 2816bc2f66c1c62ec5a616fb499a2b27bbba4a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Jul 2025 16:04:28 +0200 Subject: [PATCH 87/93] libc-test: include sys/ktls.h on freebsd is necessary in order to find the xktls_* structs. See also: https://github.com/freebsd/freebsd-src/commit/c9e9a0fe5b0f88561f55fb2f6f5354fbbd96dd5d (backport ) (cherry picked from commit 4147a8b2689dfd281b3ca148c755e452936143f4) --- libc-test/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 1304d3bf14202..af273130833df 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2503,7 +2503,8 @@ fn test_freebsd(target: &str) { "sys/shm.h", "sys/socket.h", "sys/socketvar.h", - "netinet/in_pcb.h", // must be after sys/socketvar.h + [freebsd15]:"sys/ktls.h", + "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h "sys/stat.h", "sys/statvfs.h", "sys/sysctl.h", From 9606a2918b1f370119af8022d61b0ff03175beb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Jul 2025 16:29:16 +0200 Subject: [PATCH 88/93] freebsd15: Add ki_uerrmsg to struct kinfo_proc Upstream commit: https://github.com/freebsd/freebsd-src/commit/7212b37345936899e979c63d0b054e114576faa0 (backport ) (cherry picked from commit e2404b45f790d0b0e7fccc252c496b2d2b852aef) --- src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 6a02d7b35c186..97912bdebcdb2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -226,6 +226,8 @@ s! { // This is normally "struct pwddesc". /// Pointer to process paths info. pub ki_pd: *mut c_void, + /// Address of the ext err msg place + pub ki_uerrmsg: *mut c_void, pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], /// PS_* flags. @@ -445,7 +447,7 @@ pub const KF_TYPE_EVENTFD: c_int = 13; /// max length of devicename pub const SPECNAMELEN: c_int = 255; -pub const KI_NSPARE_PTR: usize = 5; +pub const KI_NSPARE_PTR: usize = 4; /// domainset policies pub const DOMAINSET_POLICY_INVALID: c_int = 0; From e9b021b7cd3d3f045ce8ec743d344e56b14f7244 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 16 Dec 2024 09:33:31 +0000 Subject: [PATCH 89/93] freebsd adding further TCP stack related constants. ref: https://github.com/freebsd/freebsd-src/commit/e570d231f48957dcf0757b7b716330f3bd64e362#diff-c354fa9fe15a3e5c90079f38792a8e5458d76677437a53ee7537a62fbc72e100R255 (backport ) (cherry picked from commit 0442ebb48baf9cd1d599a889f29eb44b68a461d6) --- libc-test/semver/freebsd.txt | 20 ++++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index d0b64323282c1..e8f385fe78982 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1507,15 +1507,35 @@ TAB3 TABDLY TCP_BBR_ALGORITHM TCP_BBR_DRAIN_PG +TCP_BBR_EXTRA_STATE +TCP_BBR_FLOOR_MIN_TSO +TCP_BBR_HDWR_PACE TCP_BBR_IWINTSO TCP_BBR_MAX_RTO TCP_BBR_MIN_RTO +TCP_BBR_MIN_TOPACEOUT +TCP_BBR_PACE_CROSS +TCP_BBR_PACE_DEL_TAR TCP_BBR_PACE_OH +TCP_BBR_PACE_PER_SEC +TCP_BBR_PACE_SEG_MAX +TCP_BBR_PACE_SEG_MIN +TCP_BBR_POLICER_DETECT +TCP_BBR_PROBE_RTT_GAIN TCP_BBR_PROBE_RTT_INT +TCP_BBR_PROBE_RTT_LEN +TCP_BBR_RACK_INIT_RATE +TCP_BBR_RACK_RTT_USE +TCP_BBR_RETRAN_WTSO +TCP_BBR_SEND_IWND_IN_TSO TCP_BBR_STARTUP_LOSS_EXIT TCP_BBR_STARTUP_PG +TCP_BBR_TMR_PACE_OH TCP_BBR_TSLIMITS +TCP_BBR_TSTMP_RAISES TCP_BBR_USEDEL_RATE +TCP_BBR_USE_RACK_RR +TCP_BBR_UTTER_MAX_TSO TCP_CCALGOOPT TCP_CONGESTION TCP_DELACK diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index f60eb1a3e9cbe..f64d079fd04c5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3638,6 +3638,26 @@ pub const TCP_BBR_USEDEL_RATE: c_int = 1079; pub const TCP_BBR_MIN_RTO: c_int = 1080; pub const TCP_BBR_MAX_RTO: c_int = 1081; pub const TCP_BBR_ALGORITHM: c_int = 1083; +pub const TCP_BBR_PACE_PER_SEC: c_int = 1086; +pub const TCP_BBR_PACE_DEL_TAR: c_int = 1087; +pub const TCP_BBR_PACE_SEG_MAX: c_int = 1088; +pub const TCP_BBR_PACE_SEG_MIN: c_int = 1089; +pub const TCP_BBR_PACE_CROSS: c_int = 1090; +pub const TCP_BBR_TMR_PACE_OH: c_int = 1096; +pub const TCP_BBR_RACK_RTT_USE: c_int = 1098; +pub const TCP_BBR_RETRAN_WTSO: c_int = 1099; +pub const TCP_BBR_PROBE_RTT_GAIN: c_int = 1101; +pub const TCP_BBR_PROBE_RTT_LEN: c_int = 1102; +pub const TCP_BBR_SEND_IWND_IN_TSO: c_int = 1103; +pub const TCP_BBR_USE_RACK_RR: c_int = 1104; +pub const TCP_BBR_HDWR_PACE: c_int = 1105; +pub const TCP_BBR_UTTER_MAX_TSO: c_int = 1106; +pub const TCP_BBR_EXTRA_STATE: c_int = 1107; +pub const TCP_BBR_FLOOR_MIN_TSO: c_int = 1108; +pub const TCP_BBR_MIN_TOPACEOUT: c_int = 1109; +pub const TCP_BBR_TSTMP_RAISES: c_int = 1110; +pub const TCP_BBR_POLICER_DETECT: c_int = 1111; +pub const TCP_BBR_RACK_INIT_RATE: c_int = 1112; pub const IP_BINDANY: c_int = 24; pub const IP_BINDMULTI: c_int = 25; From 172527344a1d92b2ca7f88fe2b1bbde4b02de58b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 9 Aug 2025 19:28:27 -0500 Subject: [PATCH 90/93] Rename the ctest file from `main` to `ctest` Make it more obvious what this test is about. (backport ) (cherry picked from commit fef089cce47331eac7f087dc968917fa9a578965) --- ci/create-artifacts.py | 4 ++-- libc-test/Cargo.toml | 4 ++-- libc-test/build.rs | 34 ++++++++++++++-------------- libc-test/test/{main.rs => ctest.rs} | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) rename libc-test/test/{main.rs => ctest.rs} (53%) diff --git a/ci/create-artifacts.py b/ci/create-artifacts.py index 23710c9cf602a..2854daa563154 100755 --- a/ci/create-artifacts.py +++ b/ci/create-artifacts.py @@ -14,9 +14,9 @@ def main(): - # Find the most recently touched file named "main.c" in the target + # Find the most recently touched file named "ctest_output.c" in the target # directory. This will be libc-tests's `OUT_DIR` - marker_files = [Path(p) for p in glob("target/**/main.c", recursive=True)] + marker_files = [Path(p) for p in glob("target/**/ctest_output.c", recursive=True)] marker_files.sort(key=lambda path: path.stat().st_mtime) build_dir = marker_files[0].parent print(f"Located build directory '{build_dir}'") diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 6c9d8c82ab07f..32d98257e335e 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -31,8 +31,8 @@ align = ["libc/align"] extra_traits = ["libc/extra_traits"] [[test]] -name = "main" -path = "test/main.rs" +name = "ctest" +path = "test/ctest.rs" harness = false [[test]] diff --git a/libc-test/build.rs b/libc-test/build.rs index af273130833df..8cb82e8a8d833 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -504,7 +504,7 @@ fn test_apple(target: &str) { "uuid_t" | "vol_capabilities_set_t" => true, _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_openbsd(target: &str) { @@ -694,7 +694,7 @@ fn test_openbsd(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_cygwin(target: &str) { @@ -866,7 +866,7 @@ fn test_cygwin(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_windows(target: &str) { @@ -995,7 +995,7 @@ fn test_windows(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_redox(target: &str) { @@ -1045,7 +1045,7 @@ fn test_redox(target: &str) { "wchar.h", } - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_solarish(target: &str) { @@ -1335,7 +1335,7 @@ fn test_solarish(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_netbsd(target: &str) { @@ -1551,7 +1551,7 @@ fn test_netbsd(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_dragonflybsd(target: &str) { @@ -1776,7 +1776,7 @@ fn test_dragonflybsd(target: &str) { (struct_ == "sigevent" && field == "sigev_notify_thread_id") }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_wasi(target: &str) { @@ -1883,7 +1883,7 @@ fn test_wasi(target: &str) { // doesn't support sizeof. cfg.skip_field(|s, field| s == "dirent" && field == "d_name"); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_android(target: &str) { @@ -2390,7 +2390,7 @@ fn test_android(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); test_linux_like_apis(target); } @@ -3079,7 +3079,7 @@ fn test_freebsd(target: &str) { }); } - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_emscripten(target: &str) { @@ -3319,7 +3319,7 @@ fn test_emscripten(target: &str) { ].contains(&field)) }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_neutrino(target: &str) { @@ -3592,7 +3592,7 @@ fn test_neutrino(target: &str) { cfg.skip_static(move |name| name == "__dso_handle"); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_vxworks(target: &str) { @@ -3698,7 +3698,7 @@ fn test_vxworks(target: &str) { _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { @@ -5019,7 +5019,7 @@ fn test_linux(target: &str) { _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); test_linux_like_apis(target); } @@ -5537,7 +5537,7 @@ fn test_haiku(target: &str) { s => s.to_string(), } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_aix(target: &str) { @@ -5834,5 +5834,5 @@ fn test_aix(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } diff --git a/libc-test/test/main.rs b/libc-test/test/ctest.rs similarity index 53% rename from libc-test/test/main.rs rename to libc-test/test/ctest.rs index c3fdcb56e54df..0b48c4af2975e 100644 --- a/libc-test/test/main.rs +++ b/libc-test/test/ctest.rs @@ -2,4 +2,4 @@ use libc::*; -include!(concat!(env!("OUT_DIR"), "/main.rs")); +include!(concat!(env!("OUT_DIR"), "/ctest_output.rs")); From 94a7f32972a352fe348edbd49b06995542f3c5f5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 9 Aug 2025 21:11:26 -0500 Subject: [PATCH 91/93] cleanup: Format a file that was missed Also start validating formatting in CI for files in `ci/`. (backport ) (cherry picked from commit c0071cc9f9385da6352e40824cfd77334e85f72d) --- ci/ios/deploy_and_run_on_ios_simulator.rs | 100 +++++++++++++--------- ci/style.sh | 2 +- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/ci/ios/deploy_and_run_on_ios_simulator.rs b/ci/ios/deploy_and_run_on_ios_simulator.rs index 7e0b80268ffbc..0398a9d3f888d 100644 --- a/ci/ios/deploy_and_run_on_ios_simulator.rs +++ b/ci/ios/deploy_and_run_on_ios_simulator.rs @@ -6,18 +6,19 @@ // (https://github.com/snipsco/dinghy): cargo dinghy install, then cargo dinghy // test. -use std::env; use std::fs::{self, File}; use std::io::Write; use std::path::Path; -use std::process; use std::process::Command; +use std::{env, process}; macro_rules! t { - ($e:expr) => (match $e { - Ok(e) => e, - Err(e) => panic!("{} failed with: {e}", stringify!($e)), - }) + ($e:expr) => { + match $e { + Ok(e) => e, + Err(e) => panic!("{} failed with: {e}", stringify!($e)), + } + }; } // Step one: Wrap as an app @@ -25,11 +26,15 @@ fn package_as_simulator_app(crate_name: &str, test_binary_path: &Path) { println!("Packaging simulator app"); drop(fs::remove_dir_all("ios_simulator_app")); t!(fs::create_dir("ios_simulator_app")); - t!(fs::copy(test_binary_path, - Path::new("ios_simulator_app").join(crate_name))); + t!(fs::copy( + test_binary_path, + Path::new("ios_simulator_app").join(crate_name) + )); let mut f = t!(File::create("ios_simulator_app/Info.plist")); - t!(f.write_all(format!(r#" + t!(f.write_all( + format!( + r#" com.rust.unittests - "#, crate_name).as_bytes())); + "#, + crate_name + ) + .as_bytes() + )); } // Step two: Start the iOS simulator @@ -57,8 +66,10 @@ fn start_simulator() { for line in stdout.lines() { if line.contains("rust_ios") { if found_rust_sim { - panic!("Duplicate rust_ios simulators found. Please \ - double-check xcrun simctl list."); + panic!( + "Duplicate rust_ios simulators found. Please \ + double-check xcrun simctl list." + ); } simulator_exists = true; simulator_booted = line.contains("(Booted)"); @@ -69,62 +80,67 @@ fn start_simulator() { if simulator_exists == false { println!("Creating iOS simulator"); Command::new("xcrun") - .arg("simctl") - .arg("create") - .arg("rust_ios") - .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE") - .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2") - .check_status(); + .arg("simctl") + .arg("create") + .arg("rust_ios") + .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE") + .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2") + .check_status(); } else if simulator_booted == true { println!("Shutting down already-booted simulator"); Command::new("xcrun") - .arg("simctl") - .arg("shutdown") - .arg("rust_ios") - .check_status(); + .arg("simctl") + .arg("shutdown") + .arg("rust_ios") + .check_status(); } println!("Starting iOS simulator"); // We can't uninstall the app (if present) as that will hang if the // simulator isn't completely booted; just erase the simulator instead. - Command::new("xcrun").arg("simctl").arg("erase").arg("rust_ios").check_status(); - Command::new("xcrun").arg("simctl").arg("boot").arg("rust_ios").check_status(); + Command::new("xcrun") + .arg("simctl") + .arg("erase") + .arg("rust_ios") + .check_status(); + Command::new("xcrun") + .arg("simctl") + .arg("boot") + .arg("rust_ios") + .check_status(); } // Step three: Install the app fn install_app_to_simulator() { println!("Installing app to simulator"); Command::new("xcrun") - .arg("simctl") - .arg("install") - .arg("booted") - .arg("ios_simulator_app/") - .check_status(); + .arg("simctl") + .arg("install") + .arg("booted") + .arg("ios_simulator_app/") + .check_status(); } // Step four: Run the app fn run_app_on_simulator() { println!("Running app"); let output = t!(Command::new("xcrun") - .arg("simctl") - .arg("launch") - .arg("--console") - .arg("booted") - .arg("com.rust.unittests") - .output()); + .arg("simctl") + .arg("launch") + .arg("--console") + .arg("booted") + .arg("com.rust.unittests") + .output()); println!("status: {}", output.status); println!("stdout --\n{}\n", String::from_utf8_lossy(&output.stdout)); println!("stderr --\n{}\n", String::from_utf8_lossy(&output.stderr)); let stdout = String::from_utf8_lossy(&output.stdout); - let passed = stdout.lines() - .find(|l| - (l.contains("PASSED") && - l.contains("tests")) || - l.contains("test result: ok") - ) - .unwrap_or(false); + let passed = stdout + .lines() + .find(|l| (l.contains("PASSED") && l.contains("tests")) || l.contains("test result: ok")) + .unwrap_or(false); println!("Shutting down simulator"); Command::new("xcrun") diff --git a/ci/style.sh b/ci/style.sh index 72465f71c760a..2d3e874e38998 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -11,7 +11,7 @@ rustfmt -V # Save a list of all source files tmpfile="file-list~" # trailing tilde for gitignore -find src -name '*.rs' > "$tmpfile" +find src ci -name '*.rs' > "$tmpfile" # Before formatting, replace all macro identifiers with a function signature. # This allows `rustfmt` to format it. From 4d04aee906450fed27305de30c23f518166f919f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 11 Aug 2025 00:34:42 -0500 Subject: [PATCH 92/93] chore: release libc 0.2.175 --- CHANGELOG.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa193e550288a..7c57f86a2d6ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,66 @@ # Changelog +## [0.2.175](https://github.com/rust-lang/libc/compare/0.2.174...0.2.175) - 2025-08-10 + +### Added + +- AIX: Add `getpeereid` ([#4524](https://github.com/rust-lang/libc/pull/4524)) +- AIX: Add `struct ld_info` and friends ([#4578](https://github.com/rust-lang/libc/pull/4578)) +- AIX: Retore `struct winsize` ([#4577](https://github.com/rust-lang/libc/pull/4577)) +- Android: Add UDP socket option constants ([#4619](https://github.com/rust-lang/libc/pull/4619)) +- Android: Add `CLONE_CLEAR_SIGHAND` and `CLONE_INTO_CGROUP` ([#4502](https://github.com/rust-lang/libc/pull/4502)) +- Android: Add more `prctl` constants ([#4531](https://github.com/rust-lang/libc/pull/4531)) +- FreeBSD Add further TCP stack-related constants ([#4196](https://github.com/rust-lang/libc/pull/4196)) +- FreeBSD x86-64: Add `mcontext_t.mc_tlsbase ` ([#4503](https://github.com/rust-lang/libc/pull/4503)) +- FreeBSD15: Add `kinfo_proc.ki_uerrmsg` ([#4552](https://github.com/rust-lang/libc/pull/4552)) +- FreeBSD: Add `in_conninfo` ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- FreeBSD: Add `xinpgen` and related types ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- FreeBSD: Add `xktls_session` ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- Haiku: Add functionality from `libbsd` ([#4221](https://github.com/rust-lang/libc/pull/4221)) +- Linux: Add `SECBIT_*` ([#4480](https://github.com/rust-lang/libc/pull/4480)) +- NetBSD, OpenBSD: Export `ioctl` request generator macros ([#4460](https://github.com/rust-lang/libc/pull/4460)) +- NetBSD: Add `ptsname_r` ([#4608](https://github.com/rust-lang/libc/pull/4608)) +- RISCV32: Add time-related syscalls ([#4612](https://github.com/rust-lang/libc/pull/4612)) +- Solarish: Add `strftime*` ([#4453](https://github.com/rust-lang/libc/pull/4453)) +- linux: Add `EXEC_RESTRICT_*` and `EXEC_DENY_*` ([#4545](https://github.com/rust-lang/libc/pull/4545)) + +### Changed + +- AIX: Add `const` to signatures to be consistent with other platforms ([#4563](https://github.com/rust-lang/libc/pull/4563)) + +### Fixed + +- AIX: Fix the type of `struct statvfs.f_fsid` ([#4576](https://github.com/rust-lang/libc/pull/4576)) +- AIX: Fix the type of constants for the `ioctl` `request` argument ([#4582](https://github.com/rust-lang/libc/pull/4582)) +- AIX: Fix the types of `stat{,64}.st_*tim` ([#4597](https://github.com/rust-lang/libc/pull/4597)) +- AIX: Use unique `errno` values ([#4507](https://github.com/rust-lang/libc/pull/4507)) +- Build: Fix an incorrect `target_os` -> `target_arch` check ([#4550](https://github.com/rust-lang/libc/pull/4550)) +- FreeBSD: Fix the type of `xktls_session_onedir.ifnet` ([#4552](https://github.com/rust-lang/libc/pull/4552)) +- Mips64 musl: Fix the type of `nlink_t` ([#4509](https://github.com/rust-lang/libc/pull/4509)) +- Mips64 musl: Use a special MIPS definition of `stack_t` ([#4528](https://github.com/rust-lang/libc/pull/4528)) +- Mips64: Fix `SI_TIMER`, `SI_MESGQ` and `SI_ASYNCIO` definitions ([#4529](https://github.com/rust-lang/libc/pull/4529)) +- Musl Mips64: Swap the order of `si_errno` and `si_code` in `siginfo_t` ([#4530](https://github.com/rust-lang/libc/pull/4530)) +- Musl Mips64: Use a special MIPS definition of `statfs` ([#4527](https://github.com/rust-lang/libc/pull/4527)) +- Musl: Fix the definition of `fanotify_event_metadata` ([#4510](https://github.com/rust-lang/libc/pull/4510)) +- NetBSD: Correct `enum fae_action` to be `#[repr(C)]` ([#60a8cfd5](https://github.com/rust-lang/libc/commit/60a8cfd564f83164d45b9533ff7a0d7371878f2a)) +- PSP: Correct `char` -> `c_char` ([eaab4fc3](https://github.com/rust-lang/libc/commit/eaab4fc3f05dc646a953d4fd5ba46dfa1f8bd6f6)) +- PowerPC musl: Fix `termios` definitions ([#4518](https://github.com/rust-lang/libc/pull/4518)) +- PowerPC musl: Fix the definition of `EDEADLK` ([#4517](https://github.com/rust-lang/libc/pull/4517)) +- PowerPC musl: Fix the definition of `NCCS` ([#4513](https://github.com/rust-lang/libc/pull/4513)) +- PowerPC musl: Fix the definitions of `MAP_LOCKED` and `MAP_NORESERVE` ([#4516](https://github.com/rust-lang/libc/pull/4516)) +- PowerPC64 musl: Fix the definition of `shmid_ds` ([#4519](https://github.com/rust-lang/libc/pull/4519)) + +### Deprecated + +- Linux: `MAP_32BIT` is only defined on x86 on non-x86 architectures ([#4511](https://github.com/rust-lang/libc/pull/4511)) + +### Removed + +- AIX: Remove duplicate constant definitions `FIND` and `ENTER` ([#4588](https://github.com/rust-lang/libc/pull/4588)) +- s390x musl: Remove `O_FSYNC` ([#4515](https://github.com/rust-lang/libc/pull/4515)) +- s390x musl: Remove `RTLD_DEEPBIND` ([#4515](https://github.com/rust-lang/libc/pull/4515)) + + ## [0.2.174](https://github.com/rust-lang/libc/compare/0.2.173...0.2.174) - 2025-06-17 ### Added diff --git a/Cargo.toml b/Cargo.toml index eb60f04af2f85..afeb07bc7c993 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.174" +version = "0.2.175" keywords = ["libc", "ffi", "bindings", "operating", "system"] categories = ["external-ffi-bindings", "no-std", "os"] exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] From 84e26e6b166a6634d679fbf44e957102846b8a03 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 11 Aug 2025 01:51:12 -0500 Subject: [PATCH 93/93] Update the lockfile The release CI job didn't like that the `libc` dependency wasn't up to date. --- Cargo.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76360464c7c7e..f53314d8d3ba2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,9 +41,9 @@ checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "cc" -version = "1.2.29" +version = "1.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362" +checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" dependencies = [ "shlex", ] @@ -95,7 +95,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ - "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.174", "redox_users", "winapi", ] @@ -107,7 +107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18495ec4aced5922809efe4d2862918ff0e8d75e122bde57bba9bae45965256a" dependencies = [ "garando_pos", - "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.174", "serde", "term", "unicode-xid", @@ -144,7 +144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if 1.0.1", - "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.174", "wasi", ] @@ -163,15 +163,15 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "libc" version = "0.2.174" -dependencies = [ - "rustc-std-workspace-core", -] +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "libc" -version = "0.2.174" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +version = "0.2.175" +dependencies = [ + "rustc-std-workspace-core", +] [[package]] name = "libc-test" @@ -182,7 +182,7 @@ dependencies = [ "cfg-if 1.0.1", "ctest2", "glob", - "libc 0.2.174", + "libc 0.2.175", "proc-macro2", "regex", "syn", @@ -190,12 +190,12 @@ dependencies = [ [[package]] name = "libredox" -version = "0.1.4" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" +checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" dependencies = [ "bitflags 2.9.1", - "libc 0.2.174 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.174", ] [[package]] @@ -212,9 +212,9 @@ checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "beef09f85ae72cea1ef96ba6870c51e6382ebfa4f0e85b643459331f3daa5be0" dependencies = [ "unicode-ident", ] @@ -317,9 +317,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "itoa", "memchr",