From 0987973a5a11972082c04f9d1318ab4c317efa00 Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:14:45 +0100 Subject: [PATCH 01/23] move AF_XDP structs and constants to linux/mod.rs (backport ) (cherry picked from commit 7eaea55a4571530a4ca1cc5431c95cdc9b05d38a) --- libc-test/semver/linux-gnu.txt | 24 ----- libc-test/semver/linux-musl.txt | 24 ----- libc-test/semver/linux.txt | 24 +++++ src/unix/linux_like/linux/gnu/mod.rs | 111 ----------------------- src/unix/linux_like/linux/mod.rs | 121 ++++++++++++++++++++++++-- src/unix/linux_like/linux/musl/mod.rs | 112 ------------------------ 6 files changed, 140 insertions(+), 276 deletions(-) diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 2aed5d7628eae..9001de4c4ff3a 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -405,7 +405,6 @@ SOL_PPPOL2TP SOL_RAW SOL_RDS SOL_RXRPC -SOL_XDP STATX_ALL STATX_ATIME STATX_ATTR_APPEND @@ -472,31 +471,8 @@ UDF_SUPER_MAGIC UNAME26 USBDEVICE_SUPER_MAGIC USER_PROCESS -XDP_COPY -XDP_MMAP_OFFSETS -XDP_OPTIONS -XDP_OPTIONS_ZEROCOPY -XDP_PGOFF_RX_RING -XDP_PGOFF_TX_RING -XDP_PKT_CONTD -XDP_RING_NEED_WAKEUP -XDP_RX_RING -XDP_SHARED_UMEM -XDP_STATISTICS -XDP_TX_RING -XDP_UMEM_COMPLETION_RING -XDP_UMEM_FILL_RING -XDP_UMEM_PGOFF_COMPLETION_RING -XDP_UMEM_PGOFF_FILL_RING -XDP_UMEM_REG -XDP_UMEM_UNALIGNED_CHUNK_FLAG -XDP_USE_NEED_WAKEUP -XDP_USE_SG -XDP_ZEROCOPY XENFS_SUPER_MAGIC XFS_SUPER_MAGIC -XSK_UNALIGNED_BUF_ADDR_MASK -XSK_UNALIGNED_BUF_OFFSET_SHIFT _CS_GNU_LIBC_VERSION _CS_GNU_LIBPTHREAD_VERSION _CS_V6_ENV diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 2223bb50059ee..d8e4918facb16 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -36,31 +36,7 @@ RWF_DSYNC RWF_HIPRI RWF_NOWAIT RWF_SYNC -SOL_XDP USER_PROCESS -XDP_COPY -XDP_MMAP_OFFSETS -XDP_OPTIONS -XDP_OPTIONS_ZEROCOPY -XDP_PGOFF_RX_RING -XDP_PGOFF_TX_RING -XDP_PKT_CONTD -XDP_RING_NEED_WAKEUP -XDP_RX_RING -XDP_SHARED_UMEM -XDP_STATISTICS -XDP_TX_RING -XDP_UMEM_COMPLETION_RING -XDP_UMEM_FILL_RING -XDP_UMEM_PGOFF_COMPLETION_RING -XDP_UMEM_PGOFF_FILL_RING -XDP_UMEM_REG -XDP_UMEM_UNALIGNED_CHUNK_FLAG -XDP_USE_NEED_WAKEUP -XDP_USE_SG -XDP_ZEROCOPY -XSK_UNALIGNED_BUF_ADDR_MASK -XSK_UNALIGNED_BUF_OFFSET_SHIFT _CS_V6_ENV _CS_V7_ENV adjtimex diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index c91b5034608d2..af5ded298cb80 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2939,6 +2939,7 @@ SOL_TIPC SOL_TLS SOL_UDP SOL_X25 +SOL_XDP SOMAXCONN SO_BINDTODEVICE SO_BUSY_POLL @@ -3455,11 +3456,34 @@ W_EXITCODE W_STOPCODE XATTR_CREATE XATTR_REPLACE +XDP_COPY +XDP_MMAP_OFFSETS +XDP_OPTIONS +XDP_OPTIONS_ZEROCOPY +XDP_PGOFF_RX_RING +XDP_PGOFF_TX_RING +XDP_PKT_CONTD +XDP_RING_NEED_WAKEUP +XDP_RX_RING +XDP_SHARED_UMEM +XDP_STATISTICS XDP_TXMD_FLAGS_CHECKSUM XDP_TXMD_FLAGS_TIMESTAMP XDP_TX_METADATA +XDP_TX_RING +XDP_UMEM_COMPLETION_RING +XDP_UMEM_FILL_RING +XDP_UMEM_PGOFF_COMPLETION_RING +XDP_UMEM_PGOFF_FILL_RING +XDP_UMEM_REG XDP_UMEM_TX_METADATA_LEN XDP_UMEM_TX_SW_CSUM +XDP_UMEM_UNALIGNED_CHUNK_FLAG +XDP_USE_NEED_WAKEUP +XDP_USE_SG +XDP_ZEROCOPY +XSK_UNALIGNED_BUF_ADDR_MASK +XSK_UNALIGNED_BUF_OFFSET_SHIFT XTABS YESEXPR YESSTR diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 48648e2b05a99..6d3ffd45885aa 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -328,84 +328,6 @@ s! { pub u: __c_anonymous_ptrace_syscall_info_data, } - // linux/if_xdp.h - - pub struct sockaddr_xdp { - pub sxdp_family: crate::__u16, - pub sxdp_flags: crate::__u16, - pub sxdp_ifindex: crate::__u32, - pub sxdp_queue_id: crate::__u32, - pub sxdp_shared_umem_fd: crate::__u32, - } - - pub struct xdp_ring_offset { - pub producer: crate::__u64, - pub consumer: crate::__u64, - pub desc: crate::__u64, - pub flags: crate::__u64, - } - - pub struct xdp_mmap_offsets { - pub rx: xdp_ring_offset, - pub tx: xdp_ring_offset, - pub fr: xdp_ring_offset, - pub cr: xdp_ring_offset, - } - - pub struct xdp_ring_offset_v1 { - pub producer: crate::__u64, - pub consumer: crate::__u64, - pub desc: crate::__u64, - } - - pub struct xdp_mmap_offsets_v1 { - pub rx: xdp_ring_offset_v1, - pub tx: xdp_ring_offset_v1, - pub fr: xdp_ring_offset_v1, - pub cr: xdp_ring_offset_v1, - } - - pub struct xdp_umem_reg { - pub addr: crate::__u64, - pub len: crate::__u64, - pub chunk_size: crate::__u32, - pub headroom: crate::__u32, - pub flags: crate::__u32, - pub tx_metadata_len: crate::__u32, - } - - pub struct xdp_umem_reg_v1 { - pub addr: crate::__u64, - pub len: crate::__u64, - pub chunk_size: crate::__u32, - pub headroom: crate::__u32, - } - - pub struct xdp_statistics { - pub rx_dropped: crate::__u64, - pub rx_invalid_descs: crate::__u64, - pub tx_invalid_descs: crate::__u64, - pub rx_ring_full: crate::__u64, - pub rx_fill_ring_empty_descs: crate::__u64, - pub tx_ring_empty_descs: crate::__u64, - } - - pub struct xdp_statistics_v1 { - pub rx_dropped: crate::__u64, - pub rx_invalid_descs: crate::__u64, - pub tx_invalid_descs: crate::__u64, - } - - pub struct xdp_options { - pub flags: crate::__u32, - } - - pub struct xdp_desc { - pub addr: crate::__u64, - pub len: crate::__u32, - pub options: crate::__u32, - } - pub struct iocb { pub aio_data: crate::__u64, #[cfg(target_endian = "little")] @@ -809,7 +731,6 @@ pub const SOL_RDS: c_int = 276; pub const SOL_IUCV: c_int = 277; pub const SOL_CAIF: c_int = 278; pub const SOL_NFC: c_int = 280; -pub const SOL_XDP: c_int = 283; pub const MSG_TRYHARD: c_int = 4; @@ -1042,38 +963,6 @@ pub const GENL_UNS_ADMIN_PERM: c_int = 0x10; pub const GENL_ID_VFS_DQUOT: c_int = crate::NLMSG_MIN_TYPE + 1; pub const GENL_ID_PMCRAID: c_int = crate::NLMSG_MIN_TYPE + 2; -// linux/if_xdp.h -pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0; -pub const XDP_COPY: crate::__u16 = 1 << 1; -pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2; -pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3; -pub const XDP_USE_SG: crate::__u16 = 1 << 4; - -pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0; - -pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0; - -pub const XDP_MMAP_OFFSETS: c_int = 1; -pub const XDP_RX_RING: c_int = 2; -pub const XDP_TX_RING: c_int = 3; -pub const XDP_UMEM_REG: c_int = 4; -pub const XDP_UMEM_FILL_RING: c_int = 5; -pub const XDP_UMEM_COMPLETION_RING: c_int = 6; -pub const XDP_STATISTICS: c_int = 7; -pub const XDP_OPTIONS: c_int = 8; - -pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0; - -pub const XDP_PGOFF_RX_RING: off_t = 0; -pub const XDP_PGOFF_TX_RING: off_t = 0x80000000; -pub const XDP_UMEM_PGOFF_FILL_RING: c_ulonglong = 0x100000000; -pub const XDP_UMEM_PGOFF_COMPLETION_RING: c_ulonglong = 0x180000000; - -pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48; -pub const XSK_UNALIGNED_BUF_ADDR_MASK: c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; - -pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; - pub const ELFOSABI_ARM_AEABI: u8 = 64; // linux/sched.h diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 63049fe1c5547..fffeeaeb49d6f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1225,6 +1225,83 @@ s! { } // linux/if_xdp.h + + pub struct sockaddr_xdp { + pub sxdp_family: crate::__u16, + pub sxdp_flags: crate::__u16, + pub sxdp_ifindex: crate::__u32, + pub sxdp_queue_id: crate::__u32, + pub sxdp_shared_umem_fd: crate::__u32, + } + + pub struct xdp_ring_offset { + pub producer: crate::__u64, + pub consumer: crate::__u64, + pub desc: crate::__u64, + pub flags: crate::__u64, + } + + pub struct xdp_mmap_offsets { + pub rx: xdp_ring_offset, + pub tx: xdp_ring_offset, + pub fr: xdp_ring_offset, + pub cr: xdp_ring_offset, + } + + pub struct xdp_ring_offset_v1 { + pub producer: crate::__u64, + pub consumer: crate::__u64, + pub desc: crate::__u64, + } + + pub struct xdp_mmap_offsets_v1 { + pub rx: xdp_ring_offset_v1, + pub tx: xdp_ring_offset_v1, + pub fr: xdp_ring_offset_v1, + pub cr: xdp_ring_offset_v1, + } + + pub struct xdp_umem_reg { + pub addr: crate::__u64, + pub len: crate::__u64, + pub chunk_size: crate::__u32, + pub headroom: crate::__u32, + pub flags: crate::__u32, + pub tx_metadata_len: crate::__u32, + } + + pub struct xdp_umem_reg_v1 { + pub addr: crate::__u64, + pub len: crate::__u64, + pub chunk_size: crate::__u32, + pub headroom: crate::__u32, + } + + pub struct xdp_statistics { + pub rx_dropped: crate::__u64, + pub rx_invalid_descs: crate::__u64, + pub tx_invalid_descs: crate::__u64, + pub rx_ring_full: crate::__u64, + pub rx_fill_ring_empty_descs: crate::__u64, + pub tx_ring_empty_descs: crate::__u64, + } + + pub struct xdp_statistics_v1 { + pub rx_dropped: crate::__u64, + pub rx_invalid_descs: crate::__u64, + pub tx_invalid_descs: crate::__u64, + } + + pub struct xdp_options { + pub flags: crate::__u32, + } + + pub struct xdp_desc { + pub addr: crate::__u64, + pub len: crate::__u32, + pub options: crate::__u32, + } + pub struct xsk_tx_metadata_completion { pub tx_timestamp: crate::__u64, } @@ -5671,13 +5748,47 @@ pub const SCHED_FLAG_UTIL_CLAMP_MIN: c_int = 0x20; pub const SCHED_FLAG_UTIL_CLAMP_MAX: c_int = 0x40; // linux/if_xdp.h -pub const XDP_UMEM_TX_SW_CSUM: __u32 = 1 << 1; -pub const XDP_UMEM_TX_METADATA_LEN: __u32 = 1 << 2; +pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0; +pub const XDP_COPY: crate::__u16 = 1 << 1; +pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2; +pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3; +pub const XDP_USE_SG: crate::__u16 = 1 << 4; + +pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0; + +pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0; + +pub const XDP_MMAP_OFFSETS: c_int = 1; +pub const XDP_RX_RING: c_int = 2; +pub const XDP_TX_RING: c_int = 3; +pub const XDP_UMEM_REG: c_int = 4; +pub const XDP_UMEM_FILL_RING: c_int = 5; +pub const XDP_UMEM_COMPLETION_RING: c_int = 6; +pub const XDP_STATISTICS: c_int = 7; +pub const XDP_OPTIONS: c_int = 8; + +pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0; + +pub const XDP_PGOFF_RX_RING: crate::off_t = 0; +pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000; +pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000; +pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000; + +pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48; +pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = + (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; + +pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; + +pub const XDP_UMEM_TX_SW_CSUM: crate::__u32 = 1 << 1; +pub const XDP_UMEM_TX_METADATA_LEN: crate::__u32 = 1 << 2; + +pub const XDP_TXMD_FLAGS_TIMESTAMP: crate::__u32 = 1 << 0; +pub const XDP_TXMD_FLAGS_CHECKSUM: crate::__u32 = 1 << 1; -pub const XDP_TXMD_FLAGS_TIMESTAMP: __u32 = 1 << 0; -pub const XDP_TXMD_FLAGS_CHECKSUM: __u32 = 1 << 1; +pub const XDP_TX_METADATA: crate::__u32 = 1 << 1; -pub const XDP_TX_METADATA: __u32 = 1 << 1; +pub const SOL_XDP: c_int = 283; // linux/mount.h pub const MOUNT_ATTR_RDONLY: crate::__u64 = 0x00000001; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 81ee07483e7b4..7463f064ada4e 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -314,84 +314,6 @@ s! { pub esterror: c_long, } - // linux/if_xdp.h - - pub struct sockaddr_xdp { - pub sxdp_family: crate::__u16, - pub sxdp_flags: crate::__u16, - pub sxdp_ifindex: crate::__u32, - pub sxdp_queue_id: crate::__u32, - pub sxdp_shared_umem_fd: crate::__u32, - } - - pub struct xdp_ring_offset { - pub producer: crate::__u64, - pub consumer: crate::__u64, - pub desc: crate::__u64, - pub flags: crate::__u64, - } - - pub struct xdp_mmap_offsets { - pub rx: xdp_ring_offset, - pub tx: xdp_ring_offset, - pub fr: xdp_ring_offset, - pub cr: xdp_ring_offset, - } - - pub struct xdp_ring_offset_v1 { - pub producer: crate::__u64, - pub consumer: crate::__u64, - pub desc: crate::__u64, - } - - pub struct xdp_mmap_offsets_v1 { - pub rx: xdp_ring_offset_v1, - pub tx: xdp_ring_offset_v1, - pub fr: xdp_ring_offset_v1, - pub cr: xdp_ring_offset_v1, - } - - pub struct xdp_umem_reg { - pub addr: crate::__u64, - pub len: crate::__u64, - pub chunk_size: crate::__u32, - pub headroom: crate::__u32, - pub flags: crate::__u32, - pub tx_metadata_len: crate::__u32, - } - - pub struct xdp_umem_reg_v1 { - pub addr: crate::__u64, - pub len: crate::__u64, - pub chunk_size: crate::__u32, - pub headroom: crate::__u32, - } - - pub struct xdp_statistics { - pub rx_dropped: crate::__u64, - pub rx_invalid_descs: crate::__u64, - pub tx_invalid_descs: crate::__u64, - pub rx_ring_full: crate::__u64, - pub rx_fill_ring_empty_descs: crate::__u64, - pub tx_ring_empty_descs: crate::__u64, - } - - pub struct xdp_statistics_v1 { - pub rx_dropped: crate::__u64, - pub rx_invalid_descs: crate::__u64, - pub tx_invalid_descs: crate::__u64, - } - - pub struct xdp_options { - pub flags: crate::__u32, - } - - pub struct xdp_desc { - pub addr: crate::__u64, - pub len: crate::__u32, - pub options: crate::__u32, - } - // netinet/tcp.h pub struct tcp_info { @@ -958,40 +880,6 @@ pub const TIME_ERROR: c_int = 5; pub const TIME_BAD: c_int = TIME_ERROR; pub const MAXTC: c_long = 6; -pub const SOL_XDP: c_int = 283; - -// linux/if_xdp.h -pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0; -pub const XDP_COPY: crate::__u16 = 1 << 1; -pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2; -pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3; -pub const XDP_USE_SG: crate::__u16 = 1 << 4; - -pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0; - -pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0; - -pub const XDP_MMAP_OFFSETS: c_int = 1; -pub const XDP_RX_RING: c_int = 2; -pub const XDP_TX_RING: c_int = 3; -pub const XDP_UMEM_REG: c_int = 4; -pub const XDP_UMEM_FILL_RING: c_int = 5; -pub const XDP_UMEM_COMPLETION_RING: c_int = 6; -pub const XDP_STATISTICS: c_int = 7; -pub const XDP_OPTIONS: c_int = 8; - -pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0; - -pub const XDP_PGOFF_RX_RING: off_t = 0; -pub const XDP_PGOFF_TX_RING: off_t = 0x80000000; -pub const XDP_UMEM_PGOFF_FILL_RING: c_ulonglong = 0x100000000; -pub const XDP_UMEM_PGOFF_COMPLETION_RING: c_ulonglong = 0x180000000; - -pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48; -pub const XSK_UNALIGNED_BUF_ADDR_MASK: c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; - -pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; - pub const _CS_V6_ENV: c_int = 1148; pub const _CS_V7_ENV: c_int = 1149; From df2251448d96cf21d0638a0ef24d00cb7c703024 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 26 Dec 2024 16:11:39 +0800 Subject: [PATCH 02/23] feat: add pw_passwd field to passwd struct in NuttX Signed-off-by: Huang Qi (backport ) (cherry picked from commit ec9ea2242ff6fa06126084b35f6a55140728e05b) --- src/unix/nuttx/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index f77b104493670..5ce6d89a938c5 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -52,6 +52,7 @@ s! { pub struct passwd { pub pw_name: *const c_char, + pub pw_passwd: *const c_char, pub pw_uid: u32, pub pw_gid: u32, pub pw_gecos: *const c_char, @@ -245,6 +246,7 @@ s! { // for example, struct passwd, https://pubs.opengroup.org/onlinepubs/009695399/basedefs/pwd.h.html, // POSIX only defines following fields in struct passwd: // char *pw_name User's login name. +// char *pw_passwd Encrypted password. // uid_t pw_uid Numerical user ID. // gid_t pw_gid Numerical group ID. // char *pw_dir Initial working directory. From 80adb61619ae716d4bd9ed6394b3e54d549a3c9d Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Thu, 26 Dec 2024 16:11:53 +0800 Subject: [PATCH 03/23] fix: update tm_zone and d_name fields to use c_char type in NuttX Signed-off-by: Huang Qi (backport ) (cherry picked from commit cb668df8ba18319a91716c12f76bbc5e287ae861) --- src/unix/nuttx/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 5ce6d89a938c5..58b8b71cfd70d 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -127,7 +127,7 @@ s! { pub tm_yday: i32, pub tm_isdst: i32, pub tm_gmtoff: isize, - pub tm_zone: *const i8, + pub tm_zone: *const c_char, __reserved: [usize; __DEFAULT_RESERVED_SIZE__], } @@ -164,7 +164,7 @@ s! { pub struct dirent { pub d_type: u8, - pub d_name: [i8; __NAME_MAX__ + 1], + pub d_name: [c_char; __NAME_MAX__ + 1], } pub struct fd_set { From 89d2bbf7b37e89b777a0c362c6b9afc9e22fb5c9 Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Mon, 6 Jan 2025 21:55:57 +0000 Subject: [PATCH 04/23] chore: add labels to FIXMEs (backport ) (cherry picked from commit d1d9c2b0ef78fc78e8d41e230490a5c50b0c88d0) --- libc-test/build.rs | 98 +++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7efacf7a41e63..fbb91bdead989 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2662,8 +2662,8 @@ fn test_freebsd(target: &str) { // These constants may change or disappear in future OS releases, and they probably // have no legitimate use in applications anyway. - "CAP_UNUSED0_44" | "CAP_UNUSED0_57" | "CAP_UNUSED1_22" | "CAP_UNUSED1_57" | - "CAP_ALL0" | "CAP_ALL1" => true, + "CAP_UNUSED0_44" | "CAP_UNUSED0_57" | "CAP_UNUSED1_22" | "CAP_UNUSED1_57" + | "CAP_ALL0" | "CAP_ALL1" => true, _ => false, } @@ -3036,11 +3036,11 @@ fn test_emscripten(target: &str) { cfg.skip_const(move |name| { match name { - // FIXME: deprecated - SIGNUNUSED was removed in glibc 2.26 + // FIXME(deprecated): deprecated - SIGNUNUSED was removed in glibc 2.26 // users should use SIGSYS instead "SIGUNUSED" => true, - // FIXME: emscripten uses different constants to constructs these + // FIXME(emscripten): emscripten uses different constants to constructs these n if n.contains("__SIZEOF_PTHREAD") => true, // No epoll support @@ -3097,7 +3097,7 @@ fn test_emscripten(target: &str) { (struct_ == "siginfo_t" && field == "_pad") || // musl names this __dummy1 but it's still there (struct_ == "glob_t" && field == "gl_flags") || - // FIXME: After musl 1.1.24, it have only one field `sched_priority`, + // FIXME(emscripten): After musl 1.1.24, it have only one field `sched_priority`, // while other fields become reserved. (struct_ == "sched_param" && [ "sched_ss_low_priority", @@ -3264,7 +3264,7 @@ fn test_neutrino(target: &str) { cfg.skip_type(move |ty| { match ty { - // FIXME: `sighandler_t` type is incorrect, see: + // FIXME(sighandler): `sighandler_t` type is incorrect, see: // https://github.com/rust-lang/libc/issues/1359 "sighandler_t" => true, @@ -3282,7 +3282,7 @@ fn test_neutrino(target: &str) { match ty { "Elf64_Phdr" | "Elf32_Phdr" => true, - // FIXME: This is actually a union, not a struct + // FIXME(union): This is actually a union, not a struct "sigval" => true, // union @@ -3316,7 +3316,7 @@ fn test_neutrino(target: &str) { // wrong signature of callback ptr "__cxa_atexit" => true, - // FIXME: Our API is unsound. The Rust API allows aliasing + // FIXME(ctest): Our API is unsound. The Rust API allows aliasing // pointers, but the C API requires pointers not to alias. // We should probably be at least using `&`/`&mut` here, see: // https://github.com/gnzlbg/ctest/issues/68 @@ -3426,7 +3426,7 @@ fn test_vxworks(target: &str) { "pathLib.h", "mqueue.h", } - // FIXME + // FIXME(vxworks) cfg.skip_const(move |name| match name { // sighandler_t weirdness "SIG_DFL" | "SIG_ERR" | "SIG_IGN" @@ -3434,7 +3434,7 @@ fn test_vxworks(target: &str) { | "RTLD_DEFAULT" => true, _ => false, }); - // FIXME + // FIXME(vxworks) cfg.skip_type(move |ty| match ty { "stat64" | "sighandler_t" | "off64_t" => true, _ => false, @@ -3457,7 +3457,7 @@ fn test_vxworks(target: &str) { t => t.to_string(), }); - // FIXME + // FIXME(vxworks) cfg.skip_fn(move |name| match name { // sigval "sigqueue" | "_sigqueue" @@ -3670,7 +3670,7 @@ fn test_linux(target: &str) { "linux/netfilter_ipv6/ip6_tables.h", "linux/netlink.h", "linux/openat2.h", - // FIXME: some items require Linux >= 5.6: + // FIXME(linux): some items require Linux >= 5.6: "linux/ptp_clock.h", "linux/ptrace.h", "linux/quota.h", @@ -3733,7 +3733,7 @@ fn test_linux(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", ".tv_nsec") } - // FIXME: epoll_event.data is actually a union in C, but in Rust + // FIXME(linux): epoll_event.data is actually a union in C, but in Rust // it is only a u64 because we only expose one field // http://man7.org/linux/man-pages/man2/epoll_wait.2.html "u64" if struct_ == "epoll_event" => "data.u64".to_string(), @@ -3753,7 +3753,7 @@ fn test_linux(target: &str) { }); cfg.skip_type(move |ty| { - // FIXME: very recent additions to musl, not yet released. + // FIXME(musl): very recent additions to musl, not yet released. // also apparently some glibc versions if ty == "Elf32_Relr" || ty == "Elf64_Relr" { return true; @@ -3762,7 +3762,7 @@ fn test_linux(target: &str) { return true; } match ty { - // FIXME: `sighandler_t` type is incorrect, see: + // FIXME(sighandler): `sighandler_t` type is incorrect, see: // https://github.com/rust-lang/libc/issues/1359 "sighandler_t" => true, @@ -3800,7 +3800,7 @@ fn test_linux(target: &str) { return true; } - // FIXME: CI has old headers + // FIXME(linux): CI has old headers if ty == "ptp_sys_offset_extended" { return true; } @@ -3810,7 +3810,7 @@ fn test_linux(target: &str) { return true; } - // FIXME: sparc64 CI has old headers + // FIXME(linux): sparc64 CI has old headers if sparc64 && (ty == "uinput_ff_erase" || ty == "uinput_abs_setup") { return true; } @@ -3833,7 +3833,7 @@ fn test_linux(target: &str) { return true; } - // FIXME: musl doesn't compile with `struct fanout_args` for unknown reasons. + // FIXME(musl): musl doesn't compile with `struct fanout_args` for unknown reasons. if musl && ty == "fanout_args" { return true; } @@ -3851,7 +3851,7 @@ fn test_linux(target: &str) { // which is absent in glibc, has to be defined. "__timeval" => true, - // FIXME: This is actually a union, not a struct + // FIXME(union): This is actually a union, not a struct "sigval" => true, // This type is tested in the `linux_termios.rs` file since there @@ -3859,13 +3859,13 @@ fn test_linux(target: &str) { // structs. "termios2" => true, - // FIXME: remove once we set minimum supported glibc version. + // FIXME(linux): remove once we set minimum supported glibc version. // ucontext_t added a new field as of glibc 2.28; our struct definition is // conservative and omits the field, but that means the size doesn't match for newer // glibcs (see https://github.com/rust-lang/libc/issues/1410) "ucontext_t" if gnu => true, - // FIXME: Somehow we cannot include headers correctly in glibc 2.30. + // FIXME(linux): Somehow we cannot include headers correctly in glibc 2.30. // So let's ignore for now and re-visit later. // Probably related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91085 "statx" => true, @@ -3885,14 +3885,14 @@ fn test_linux(target: &str) { "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, - // FIXME: requires >= 6.1 kernel headers + // FIXME(linux): requires >= 6.1 kernel headers "canxl_frame" => true, - // FIXME: The size of `iv` has been changed since Linux v6.0 + // FIXME(linux): The size of `iv` has been changed since Linux v6.0 // https://github.com/torvalds/linux/commit/94dfc73e7cf4a31da66b8843f0b9283ddd6b8381 "af_alg_iv" => true, - // FIXME: Requires >= 5.1 kernel headers. + // FIXME(linux): Requires >= 5.1 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. "tls12_crypto_info_aes_gcm_256" if (aarch64 || arm || i686 || s390x || x86_64) && musl => @@ -3900,7 +3900,7 @@ fn test_linux(target: &str) { true } - // FIXME: Requires >= 5.11 kernel headers. + // FIXME(linux): Requires >= 5.11 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. "tls12_crypto_info_chacha20_poly1305" if (aarch64 || arm || i686 || s390x || x86_64) && musl => @@ -3908,26 +3908,26 @@ fn test_linux(target: &str) { true } - // FIXME: Requires >= 5.3 kernel headers. + // FIXME(linux): Requires >= 5.3 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. "xdp_options" if musl => true, - // FIXME: Requires >= 5.4 kernel headers. + // FIXME(linux): Requires >= 5.4 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. "xdp_ring_offset" | "xdp_mmap_offsets" if musl => true, - // FIXME: Requires >= 6.8 kernel headers. + // FIXME(linux): Requires >= 6.8 kernel headers. // A field was added in 6.8. // https://github.com/torvalds/linux/commit/341ac980eab90ac1f6c22ee9f9da83ed9604d899 // The previous version of the struct was removed in 6.11 due to a bug. // https://github.com/torvalds/linux/commit/32654bbd6313b4cfc82297e6634fa9725c3c900f "xdp_umem_reg" => true, - // FIXME: Requires >= 5.9 kernel headers. + // FIXME(linux): Requires >= 5.9 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. "xdp_statistics" if musl => true, - // FIXME: Requires >= 6.8 kernel headers. + // FIXME(linux): Requires >= 6.8 kernel headers. "xsk_tx_metadata" | "__c_anonymous_xsk_tx_metadata_union" | "xsk_tx_metadata_request" @@ -3951,7 +3951,7 @@ fn test_linux(target: &str) { // kernel so we can drop this and test the type once this new version is used in CI. "sched_attr" => true, - // FIXME: Requires >= 6.9 kernel headers. + // FIXME(linux): Requires >= 6.9 kernel headers. "epoll_params" => true, _ => false, @@ -3996,7 +3996,7 @@ fn test_linux(target: &str) { } } if musl { - // FIXME: Requires >= 5.0 kernel headers + // FIXME(linux): Requires >= 5.0 kernel headers if name == "SECCOMP_GET_NOTIF_SIZES" || name == "SECCOMP_FILTER_FLAG_NEW_LISTENER" || name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH" @@ -4007,11 +4007,11 @@ fn test_linux(target: &str) { { return true; } - // FIXME: Requires >= 4.20 kernel headers + // FIXME(linux): Requires >= 4.20 kernel headers if name == "PTP_SYS_OFFSET_EXTENDED" { return true; } - // FIXME: Requires >= 5.4 kernel headers + // FIXME(linux): Requires >= 5.4 kernel headers if name == "PTP_CLOCK_GETCAPS2" || name == "PTP_ENABLE_PPS2" || name == "PTP_EXTTS_REQUEST2" @@ -4024,7 +4024,7 @@ fn test_linux(target: &str) { { return true; } - // FIXME: Requires >= 5.4.1 kernel headers + // FIXME(linux): Requires >= 5.4.1 kernel headers if name.starts_with("J1939") || name.starts_with("RTEXT_FILTER_") || name.starts_with("SO_J1939") @@ -4032,7 +4032,7 @@ fn test_linux(target: &str) { { return true; } - // FIXME: Requires >= 5.10 kernel headers + // FIXME(linux): Requires >= 5.10 kernel headers if name.starts_with("MEMBARRIER_CMD_REGISTER") || name.starts_with("MEMBARRIER_CMD_PRIVATE") { @@ -4073,15 +4073,15 @@ fn test_linux(target: &str) { // because including `linux/if_arp.h` causes some conflicts: "ARPHRD_CAN" => true, - // FIXME: deprecated: not available in any header + // FIXME(deprecated): deprecated: not available in any header // See: https://github.com/rust-lang/libc/issues/1356 "ENOATTR" => true, - // FIXME: SIGUNUSED was removed in glibc 2.26 + // FIXME(deprecated): SIGUNUSED was removed in glibc 2.26 // Users should use SIGSYS instead. "SIGUNUSED" => true, - // FIXME: conflicts with glibc headers and is tested in + // FIXME(linux): conflicts with glibc headers and is tested in // `linux_termios.rs` below: | "BOTHER" | "IBSHIFT" @@ -4090,11 +4090,11 @@ fn test_linux(target: &str) { | "TCSETSW2" | "TCSETSF2" => true, - // FIXME: on musl the pthread types are defined a little differently + // FIXME(musl): on musl the pthread types are defined a little differently // - these constants are used by the glibc implementation. n if musl && n.contains("__SIZEOF_PTHREAD") => true, - // FIXME: It was extended to 4096 since glibc 2.31 (Linux 5.4). + // FIXME(linux): It was extended to 4096 since glibc 2.31 (Linux 5.4). // We should do so after a while. "SOMAXCONN" if gnu => true, @@ -4106,37 +4106,37 @@ fn test_linux(target: &str) { | "IPPROTO_ETHERNET" | "IPPROTO_MPTCP" => true, - // FIXME: Not yet implemented on sparc64 + // FIXME(linux): Not yet implemented on sparc64 "SYS_clone3" if sparc64 => true, - // FIXME: Not defined on ARM, gnueabihf, musl, PowerPC, riscv64, s390x, and sparc64. + // FIXME(linux): Not defined on ARM, gnueabihf, musl, PowerPC, riscv64, s390x, and sparc64. "SYS_memfd_secret" if arm | gnueabihf | musl | ppc | riscv64 | s390x | sparc64 => true, - // FIXME: Added in Linux 5.16 + // FIXME(linux): Added in Linux 5.16 // https://github.com/torvalds/linux/commit/039c0ec9bb77446d7ada7f55f90af9299b28ca49 "SYS_futex_waitv" => true, - // FIXME: Added in Linux 5.17 + // FIXME(linux): Added in Linux 5.17 // https://github.com/torvalds/linux/commit/c6018b4b254971863bd0ad36bb5e7d0fa0f0ddb0 "SYS_set_mempolicy_home_node" => true, - // FIXME: Added in Linux 5.18 + // FIXME(linux): Added in Linux 5.18 // https://github.com/torvalds/linux/commit/8b5413647262dda8d8d0e07e14ea1de9ac7cf0b2 "NFQA_PRIORITY" => true, - // FIXME: requires more recent kernel headers on CI + // FIXME(linux): requires more recent kernel headers on CI | "UINPUT_VERSION" | "SW_MAX" | "SW_CNT" if ppc64 || riscv64 => true, - // FIXME: requires more recent kernel headers on CI + // FIXME(linux): requires more recent kernel headers on CI | "MFD_EXEC" | "MFD_NOEXEC_SEAL" | "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" if sparc64 => true, - // FIXME: Not currently available in headers on ARM and musl. + // FIXME(linux): Not currently available in headers on ARM and musl. "NETLINK_GET_STRICT_CHK" if arm => true, // Skip as this signal codes and trap reasons need newer headers From 8a77755a432895e20a1a765f98a8c49dfc7f8230 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Fri, 24 Jan 2025 21:32:07 +0800 Subject: [PATCH 05/23] Remove pthread_set_name_np from NuttX Removed `pthread_set_name_np` function from the NuttX bindings as it does not exist in the NuttX API, this change aligns the code with the actual NuttX implementation Signed-off-by: Huang Qi (backport ) (cherry picked from commit f4ab0b11a443e5592d348256337a6b621ea5dd09) --- src/unix/nuttx/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 58b8b71cfd70d..8446eafaf19e6 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -556,7 +556,6 @@ extern "C" { pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32; pub fn futimens(fd: i32, times: *const timespec) -> i32; pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> i32; - pub fn pthread_set_name_np(thread: pthread_t, name: *const c_char) -> i32; pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> i32; pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: usize) -> i32; pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize; From 9ee1fc9839a47ac196e21eb5eef98bb42896c5a0 Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Fri, 7 Feb 2025 00:49:19 +0000 Subject: [PATCH 06/23] chore: add labels to FIXMEs (backport ) (cherry picked from commit 67d2ead291e2a1c3c1a3c53a6a90070925fec8cf) --- libc-test/build.rs | 72 +++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index fbb91bdead989..27195892b9a0a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4196,26 +4196,26 @@ fn test_linux(target: &str) { | "CANXL_XLF" => true, - // FIXME: Parts of netfilter/nfnetlink*.h require more recent kernel headers: + // FIXME(linux): Parts of netfilter/nfnetlink*.h require more recent kernel headers: | "RTNLGRP_MCTP_IFADDR" // linux v5.17+ | "RTNLGRP_TUNNEL" // linux v5.18+ | "RTNLGRP_STATS" // linux v5.18+ => true, - // FIXME: The below is no longer const in glibc 2.34: + // FIXME(linux): The below is no longer const in glibc 2.34: // https://github.com/bminor/glibc/commit/5d98a7dae955bafa6740c26eaba9c86060ae0344 | "PTHREAD_STACK_MIN" | "SIGSTKSZ" | "MINSIGSTKSZ" if gnu => true, - // FIXME: Linux >= 5.16: + // FIXME(linux): Linux >= 5.16: // https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96 "NF_NETDEV_EGRESS" if sparc64 => true, // value changed "NF_NETDEV_NUMHOOKS" if sparc64 => true, - // FIXME: requires Linux >= v5.8 + // FIXME(linux): requires Linux >= v5.8 "IF_LINK_MODE_TESTING" if sparc64 => true, // DIFF(main): fixed in 1.0 with e9abac9ac2 @@ -4227,7 +4227,7 @@ fn test_linux(target: &str) { // kernel 6.2 minimum "TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true, - // FIXME: Requires more recent kernel headers + // FIXME(linux): Requires more recent kernel headers | "IFLA_PARENT_DEV_NAME" // linux v5.13+ | "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+ | "IFLA_GRO_MAX_SIZE" // linux v5.16+ @@ -4240,10 +4240,10 @@ fn test_linux(target: &str) { // kernel 6.5 minimum "MOVE_MOUNT_BENEATH" => true, - // FIXME: Requires linux 6.1 + // FIXME(linux): Requires linux 6.1 "ALG_SET_KEY_BY_KEY_SERIAL" | "ALG_SET_DRBG_ENTROPY" => true, - // FIXME: Requires more recent kernel headers + // FIXME(linux): Requires more recent kernel headers | "FAN_FS_ERROR" // linux v5.16+ | "FAN_RENAME" // linux v5.17+ | "FAN_REPORT_TARGET_FID" // linux v5.17+ @@ -4271,10 +4271,10 @@ fn test_linux(target: &str) { | "FAN_EPIDFD" if musl => true, - // FIXME: Requires linux 6.5 + // FIXME(linux): Requires linux 6.5 "NFT_MSG_MAX" => true, - // FIXME: Requires >= 6.6 kernel headers. + // FIXME(linux): Requires >= 6.6 kernel headers. "XDP_USE_SG" | "XDP_PKT_CONTD" => @@ -4282,7 +4282,7 @@ fn test_linux(target: &str) { true } - // FIXME: Requires >= 6.8 kernel headers. + // FIXME(linux): Requires >= 6.8 kernel headers. "XDP_UMEM_TX_SW_CSUM" | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" @@ -4292,20 +4292,20 @@ fn test_linux(target: &str) { true } - // FIXME: Requires >= 6.11 kernel headers. + // FIXME(linux): Requires >= 6.11 kernel headers. "XDP_UMEM_TX_METADATA_LEN" => { true } - // FIXME: Requires >= 6.6 kernel headers. + // FIXME(linux): Requires >= 6.6 kernel headers. "SYS_fchmodat2" => true, - // FIXME: Requires >= 6.10 kernel headers. + // FIXME(linux): Requires >= 6.10 kernel headers. "SYS_mseal" => true, - // FIXME: seems to not be available all the time (from : + // FIXME(linux): seems to not be available all the time (from : "PF_VCPU" | "PF_IDLE" | "PF_EXITING" @@ -4334,11 +4334,11 @@ fn test_linux(target: &str) { | "PF_BLOCK_TS" | "PF_SUSPEND_TASK" => true, - // FIXME: Requires >= 6.9 kernel headers. + // FIXME(linux): Requires >= 6.9 kernel headers. "EPIOCSPARAMS" | "EPIOCGPARAMS" => true, - // FIXME: Requires >= 6.11 kernel headers. + // FIXME(linux): Requires >= 6.11 kernel headers. "MAP_DROPPABLE" => true, // FIXME(linux): Requires >= 6.2 kernel headers. @@ -4375,7 +4375,7 @@ fn test_linux(target: &str) { // test the XSI version below. "strerror_r" => true, - // FIXME: Our API is unsound. The Rust API allows aliasing + // FIXME(linux): Our API is unsound. The Rust API allows aliasing // pointers, but the C API requires pointers not to alias. // We should probably be at least using `&`/`&mut` here, see: // https://github.com/gnzlbg/ctest/issues/68 @@ -4386,10 +4386,10 @@ fn test_linux(target: &str) { // Needs glibc 2.35 or later. "posix_spawn_file_actions_addtcsetpgrp_np" if gnu && sparc64 => true, - // FIXME: Deprecated since glibc 2.30. Remove fn once upstream does. + // FIXME(linux): Deprecated since glibc 2.30. Remove fn once upstream does. "sysctl" if gnu => true, - // FIXME: It now takes c_void instead of timezone since glibc 2.31. + // FIXME(linux): It now takes c_void instead of timezone since glibc 2.31. "gettimeofday" if gnu => true, // These are all implemented as static inline functions in uclibc, so @@ -4417,7 +4417,7 @@ fn test_linux(target: &str) { // assume it's a int instead. "getnameinfo" if uclibc => true, - // FIXME: This needs musl 1.2.2 or later. + // FIXME(musl): This needs musl 1.2.2 or later. "gettid" if musl => true, // Needs glibc 2.33 or later. @@ -4453,7 +4453,7 @@ fn test_linux(target: &str) { "posix_basename" if gnu => true, "gnu_basename" if gnu => true, - // FIXME: function pointers changed since Ubuntu 23.10 + // FIXME(linux): function pointers changed since Ubuntu 23.10 "strtol" | "strtoll" | "strtoul" | "strtoull" | "fscanf" | "scanf" | "sscanf" => true, // Added in musl 1.2.5 @@ -4515,7 +4515,7 @@ fn test_linux(target: &str) { field == "ssi_syscall" || field == "ssi_call_addr" || field == "ssi_arch")) || - // FIXME: After musl 1.1.24, it have only one field `sched_priority`, + // FIXME(musl): After musl 1.1.24, it have only one field `sched_priority`, // while other fields become reserved. (struct_ == "sched_param" && [ "sched_ss_low_priority", @@ -4523,11 +4523,11 @@ fn test_linux(target: &str) { "sched_ss_init_budget", "sched_ss_max_repl", ].contains(&field) && musl) || - // FIXME: After musl 1.1.24, the type becomes `int` instead of `unsigned short`. + // FIXME(musl): After musl 1.1.24, the type becomes `int` instead of `unsigned short`. (struct_ == "ipc_perm" && field == "__seq" && aarch64_musl) || // glibc uses unnamed fields here and Rust doesn't support that yet (struct_ == "timex" && field.starts_with("__unused")) || - // FIXME: It now takes mode_t since glibc 2.31 on some targets. + // FIXME(linux): It now takes mode_t since glibc 2.31 on some targets. (struct_ == "ipc_perm" && field == "mode" && ((x86_64 || i686 || arm || riscv64) && gnu || x86_64_gnux32) ) || @@ -4574,9 +4574,9 @@ fn test_linux(target: &str) { }); cfg.skip_roundtrip(move |s| match s { - // FIXME: + // FIXME(1.0): "mcontext_t" if s390x => true, - // FIXME: This is actually a union. + // FIXME(union): This is actually a union. "fpreg_t" if s390x => true, // The test doesn't work on some env: @@ -4610,7 +4610,7 @@ fn test_linux(target: &str) { "fanotify_event_info_fid" => true, "cmsghdr" => true, - // FIXME: the call ABI of max_align_t is incorrect on these platforms: + // FIXME(linux): the call ABI of max_align_t is incorrect on these platforms: "max_align_t" if i686 || ppc64 => true, _ => false, @@ -4941,13 +4941,13 @@ fn test_haiku(target: &str) { return true; } match ty { - // FIXME: actually a union + // FIXME(union): actually a union "sigval" => true, - // FIXME: locale_t does not exist on Haiku + // FIXME(haiku): locale_t does not exist on Haiku "locale_t" => true, - // FIXME: rusage has a different layout on Haiku + // FIXME(haiku): rusage has a different layout on Haiku "rusage" => true, - // FIXME?: complains that rust aligns on 4 byte boundary, but + // FIXME(haiku): complains that rust aligns on 4 byte boundary, but // Haiku does not align it at all. "in6_addr" => true, // The d_name attribute is an array of 1 on Haiku, with the @@ -4972,7 +4972,7 @@ fn test_haiku(target: &str) { cfg.skip_type(move |ty| { match ty { - // FIXME: locale_t does not exist on Haiku + // FIXME(haiku): locale_t does not exist on Haiku "locale_t" => true, // These cause errors, to be reviewed in the future "sighandler_t" => true, @@ -4987,7 +4987,7 @@ fn test_haiku(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 + // FIXME(haiku): https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" | "execvpe" => true, // FIXME: does not exist on haiku "open_wmemstream" => true, @@ -5013,7 +5013,7 @@ fn test_haiku(target: &str) { cfg.skip_const(move |name| { match name { - // FIXME: these constants do not exist on Haiku + // FIXME(haiku): these constants do not exist on Haiku "DT_UNKNOWN" | "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" => true, "USRQUOTA" | "GRPQUOTA" => true, @@ -5039,7 +5039,7 @@ fn test_haiku(target: &str) { cfg.skip_field(move |struct_, field| { match (struct_, field) { - // FIXME: the stat struct actually has timespec members, whereas + // FIXME(time): the stat struct actually has timespec members, whereas // the current representation has these unpacked. ("stat", "st_atime") => true, ("stat", "st_atime_nsec") => true, @@ -5069,7 +5069,7 @@ fn test_haiku(target: &str) { }); cfg.skip_roundtrip(move |s| match s { - // FIXME: for some reason the roundtrip check fails for cpu_info + // FIXME(1.0): for some reason the roundtrip check fails for cpu_info "cpu_info" => true, _ => false, }); From 0149964361364aec583fae0559e50ddd0409b376 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 14 Feb 2025 19:51:48 +0000 Subject: [PATCH 07/23] linux: deprecate obsolete packet filter interfaces. sockaddr_ll/AF_PACKET are in place since Linux 2.2 (backport ) (cherry picked from commit eb78ad0090fb2d2195bd4564368468334d399dea) --- src/unix/linux_like/android/mod.rs | 1 + src/unix/linux_like/linux/gnu/mod.rs | 1 + src/unix/linux_like/linux/mod.rs | 1 + src/unix/linux_like/linux/musl/mod.rs | 1 + src/unix/linux_like/linux/uclibc/mod.rs | 1 + 5 files changed, 5 insertions(+) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 5debbe8fb967d..2ba535d635961 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1474,6 +1474,7 @@ pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; pub const SOCK_SEQPACKET: c_int = 5; pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub const SOCK_PACKET: c_int = 10; pub const IPPROTO_MAX: c_int = 256; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 6d3ffd45885aa..0272166e76e14 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -763,6 +763,7 @@ pub const ENOTSUP: c_int = EOPNOTSUPP; pub const SOCK_SEQPACKET: c_int = 5; pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub const SOCK_PACKET: c_int = 10; pub const AF_IB: c_int = 27; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index fffeeaeb49d6f..d9936fdb4f7e7 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -186,6 +186,7 @@ s! { pub mr_address: [c_uchar; 8], } + #[deprecated(since = "0.2.70", note = "sockaddr_ll type must be used instead")] pub struct sockaddr_pkt { pub spkt_family: c_ushort, pub spkt_device: [c_uchar; 14], diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 7463f064ada4e..b474a6f3e4dfe 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -716,6 +716,7 @@ pub const MAP_ANONYMOUS: c_int = MAP_ANON; pub const SOCK_SEQPACKET: c_int = 5; pub const SOCK_DCCP: c_int = 6; pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub const SOCK_PACKET: c_int = 10; pub const SOMAXCONN: c_int = 128; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 7495f07878119..272f3c4e223b2 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -382,6 +382,7 @@ pub const RUSAGE_THREAD: c_int = 1; pub const SHM_EXEC: c_int = 0o100000; pub const SIGPOLL: c_int = SIGIO; pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub const SOCK_PACKET: c_int = 10; pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; pub const UDP_GRO: c_int = 104; From 7d17f1641b9bde14286be5d5041efc356c9c5869 Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Mon, 6 Jan 2025 00:49:46 +0000 Subject: [PATCH 08/23] chore: add labels to FIXMEs (backport ) (cherry picked from commit 5096e10057a48869119b4f267f78366b425c53fa) --- libc-test/build.rs | 98 +++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 27195892b9a0a..994e359d49f79 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -724,7 +724,7 @@ fn test_windows(target: &str) { // Just pass all these through, no need for a "struct" prefix "FILE" | "DIR" | "Dl_info" => ty.to_string(), - // FIXME: these don't exist: + // FIXME(windows): these don't exist: "time64_t" => "__time64_t".to_string(), "ssize_t" => "SSIZE_T".to_string(), @@ -756,7 +756,7 @@ fn test_windows(target: &str) { cfg.skip_type(move |name| match name { "SSIZE_T" if !gnu => true, "ssize_t" if !gnu => true, - // FIXME: The size and alignment of this type are incorrect + // FIXME(windows): The size and alignment of this type are incorrect "time_t" if gnu && i686 => true, _ => false, }); @@ -766,7 +766,7 @@ fn test_windows(target: &str) { return true; } match ty { - // FIXME: The size and alignment of this struct are incorrect + // FIXME(windows): The size and alignment of this struct are incorrect "timespec" if gnu && i686 => true, _ => false, } @@ -774,12 +774,12 @@ fn test_windows(target: &str) { cfg.skip_const(move |name| { match name { - // FIXME: API error: + // FIXME(windows): API error: // SIG_ERR type is "void (*)(int)", not "int" "SIG_ERR" | // Similar for SIG_DFL/IGN/GET/SGE/ACK "SIG_DFL" | "SIG_IGN" | "SIG_GET" | "SIG_SGE" | "SIG_ACK" => true, - // FIXME: newer windows-gnu environment on CI? + // FIXME(windows): newer windows-gnu environment on CI? "_O_OBTAIN_DIR" if gnu => true, _ => false, } @@ -789,7 +789,7 @@ fn test_windows(target: &str) { "CONTEXT" if field == "Fp" => true, _ => false, }); - // FIXME: All functions point to the wrong addresses? + // FIXME(windows): All functions point to the wrong addresses? cfg.skip_fn_ptrcheck(|_| true); cfg.skip_signededness(move |c| { @@ -1093,7 +1093,7 @@ fn test_solarish(target: &str) { // are still ABI compatible. We can wait for the next major release // to be compliant with the new API. // - // FIXME: unskip these for next major release + // FIXME(solarish): unskip these for next major release "setpriority" | "personality" => true, // signal is defined in terms of sighandler_t, so ignore @@ -1131,7 +1131,7 @@ fn test_solarish(target: &str) { // excluded from the tests. "getifaddrs" if is_illumos => true, - // FIXME: Our API is unsound. The Rust API allows aliasing + // FIXME(ctest): Our API is unsound. The Rust API allows aliasing // pointers, but the C API requires pointers not to alias. // We should probably be at least using `&`/`&mut` here, see: // https://github.com/gnzlbg/ctest/issues/68 @@ -1277,7 +1277,7 @@ fn test_netbsd(target: &str) { return true; } match ty { - // FIXME: sighandler_t is crazy across platforms + // FIXME(netbsd): sighandler_t is crazy across platforms "sighandler_t" => true, _ => false, } @@ -1321,7 +1321,7 @@ fn test_netbsd(target: &str) { cfg.skip_fn(move |name| { match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 + // FIXME(netbsd): https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, // FIXME: netbsd 10 minimum "getentropy" | "getrandom" => true, @@ -1462,7 +1462,7 @@ fn test_dragonflybsd(target: &str) { | "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(), - // FIXME: OSX calls this something else + // FIXME(dragonflybsd): OSX calls this something else "sighandler_t" => "sig_t".to_string(), t if is_union => format!("union {}", t), @@ -1507,7 +1507,7 @@ fn test_dragonflybsd(target: &str) { return true; } match ty { - // FIXME: These are tested as part of the linux_fcntl tests since + // FIXME(dragonflybsd): These are tested as part of the linux_fcntl tests since // there are header conflicts when including them with all the other // structs. "termios2" => true, @@ -1874,7 +1874,7 @@ fn test_android(target: &str) { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => s.to_string(), - // FIXME: appears that `epoll_event.data` is an union + // FIXME(union): appears that `epoll_event.data` is an union "u64" if struct_ == "epoll_event" => "data.u64".to_string(), // The following structs have a field called `type` in C, // but `type` is a Rust keyword, so these fields are translated @@ -1893,7 +1893,7 @@ fn test_android(target: &str) { cfg.skip_type(move |ty| { match ty { - // FIXME: `sighandler_t` type is incorrect, see: + // FIXME(android): `sighandler_t` type is incorrect, see: // https://github.com/rust-lang/libc/issues/1359 "sighandler_t" => true, @@ -1904,7 +1904,7 @@ fn test_android(target: &str) { "posix_spawn_file_actions_t" => true, "posix_spawnattr_t" => true, - // FIXME: "'__uint128' undeclared" in C + // FIXME(android): "'__uint128' undeclared" in C "__uint128" => true, _ => false, @@ -1927,12 +1927,12 @@ fn test_android(target: &str) { // These are tested in the `linux_elf.rs` file. "Elf64_Phdr" | "Elf32_Phdr" => true, - // FIXME: The type of `iv` has been changed. + // FIXME(android): The type of `iv` has been changed. "af_alg_iv" => true, - // FIXME: The size of struct has been changed: + // FIXME(android): The size of struct has been changed: "inotify_event" => true, - // FIXME: The field has been changed: + // FIXME(android): The field has been changed: "sockaddr_vm" => true, _ => false, @@ -1959,13 +1959,13 @@ fn test_android(target: &str) { // The `ARPHRD_CAN` is tested in the `linux_if_arp.rs` tests: "ARPHRD_CAN" => true, - // FIXME: deprecated: not available in any header + // FIXME(deprecated): deprecated: not available in any header // See: https://github.com/rust-lang/libc/issues/1356 "ENOATTR" => true, - // FIXME: still necessary? + // FIXME(android): still necessary? "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: deprecated - removed in glibc 2.26 + // FIXME(deprecated): deprecated - removed in glibc 2.26 "SIGUNUSED" => true, // Needs a newer Android SDK for the definition @@ -1974,7 +1974,7 @@ fn test_android(target: &str) { // Requires Linux kernel 5.6 "VMADDR_CID_LOCAL" => true, - // FIXME: conflicts with standard C headers and is tested in + // FIXME(android): conflicts with standard C headers and is tested in // `linux_termios.rs` below: "BOTHER" => true, "IBSHIFT" => true, @@ -2004,7 +2004,7 @@ fn test_android(target: &str) { // kernel 6.2 minimum "TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true, - // FIXME: NDK r22 minimum required + // FIXME(android): NDK r22 minimum required | "FDB_NOTIFY_BIT" | "FDB_NOTIFY_INACTIVE_BIT" | "IFLA_ALT_IFNAME" @@ -2017,16 +2017,16 @@ fn test_android(target: &str) { | "NFEA_DONT_REFRESH" | "NFEA_UNSPEC" => true, - // FIXME: NDK r23 minimum required + // FIXME(android): NDK r23 minimum required | "IFLA_PARENT_DEV_BUS_NAME" | "IFLA_PARENT_DEV_NAME" => true, - // FIXME: NDK r25 minimum required + // FIXME(android): NDK r25 minimum required | "IFLA_GRO_MAX_SIZE" | "NDA_FLAGS_EXT" | "NTF_EXT_MANAGED" => true, - // FIXME: NDK above r25 required + // FIXME(android): NDK above r25 required | "IFLA_ALLMULTI" | "IFLA_DEVLINK_PORT" | "IFLA_GRO_IPV4_MAX_SIZE" @@ -2040,7 +2040,7 @@ fn test_android(target: &str) { | "NTF_EXT_LOCKED" | "ALG_SET_DRBG_ENTROPY" => true, - // FIXME: Something has been changed on r26b: + // FIXME(android): Something has been changed on r26b: | "IPPROTO_MAX" | "NFNL_SUBSYS_COUNT" | "NF_NETDEV_NUMHOOKS" @@ -2048,10 +2048,10 @@ fn test_android(target: &str) { | "SW_MAX" | "SW_CNT" => true, - // FIXME: aarch64 env cannot find it: + // FIXME(android): aarch64 env cannot find it: | "PTRACE_GETREGS" | "PTRACE_SETREGS" if aarch64 => true, - // FIXME: The value has been changed on r26b: + // FIXME(android): The value has been changed on r26b: | "SYS_syscalls" if aarch64 => true, // From ``. @@ -2093,7 +2093,7 @@ fn test_android(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 + // FIXME(android): https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, // There are two versions of the sterror_r function, see @@ -2147,7 +2147,7 @@ fn test_android(target: &str) { // Added in API level 26, but some tests use level 24. "getdomainname" | "setdomainname" => true, - // FIXME: bad function pointers: + // FIXME(android): bad function pointers: "isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint" | "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower" | "toupper" => true, @@ -2163,12 +2163,12 @@ fn test_android(target: &str) { (struct_ == "sigevent" && field == "sigev_value") || // this one is an anonymous union (struct_ == "ff_effect" && field == "u") || - // FIXME: `sa_sigaction` has type `sighandler_t` but that type is + // FIXME(android): `sa_sigaction` has type `sighandler_t` but that type is // incorrect, see: https://github.com/rust-lang/libc/issues/1359 (struct_ == "sigaction" && field == "sa_sigaction") || // signalfd had SIGSYS fields added in Android 4.19, but CI does not have that version yet. (struct_ == "signalfd_siginfo" && field == "ssi_call_addr") || - // FIXME: Seems the type has been changed on NDK r26b + // FIXME(android): Seems the type has been changed on NDK r26b (struct_ == "flock64" && (field == "l_start" || field == "l_len")) }); @@ -2360,7 +2360,7 @@ fn test_freebsd(target: &str) { | "devstat_match_flags" | "devstat_priority" => ty.to_string(), - // FIXME: https://github.com/rust-lang/libc/issues/1273 + // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 "sighandler_t" => "sig_t".to_string(), t if is_union => format!("union {}", t), @@ -2423,12 +2423,12 @@ fn test_freebsd(target: &str) { true } - // FIXME: These are deprecated - remove in a couple of releases. + // FIXME(deprecated): These are deprecated - remove in a couple of releases. // These constants were removed in FreeBSD 11 (svn r273250) but will // still be accepted and ignored at runtime. "MAP_RENAME" | "MAP_NORESERVE" => true, - // FIXME: These are deprecated - remove in a couple of releases. + // FIXME(deprecated): These are deprecated - remove in a couple of releases. // These constants were removed in FreeBSD 11 (svn r262489), // and they've never had any legitimate use outside of the // base system anyway. @@ -2454,7 +2454,7 @@ fn test_freebsd(target: &str) { // Removed in FreeBSD 14 (git 7ff9ae90f0b) "IFF_NOGROUP" => true, - // FIXME: These are deprecated - remove in a couple of releases. + // FIXME(deprecated): These are deprecated - remove in a couple of releases. // These symbols are not stable across OS-versions. They were // changed for FreeBSD 14 in git revisions b62848b0c3f and // 2cf7870864e. @@ -2568,7 +2568,7 @@ fn test_freebsd(target: &str) { } // Added in FreeBSD 14. - "F_KINFO" => true, // FIXME: depends how frequent freebsd 14 is updated on CI, this addition went this week only. + "F_KINFO" => true, // FIXME(freebsd): depends how frequent freebsd 14 is updated on CI, this addition went this week only. "SHM_RENAME_NOREPLACE" | "SHM_RENAME_EXCHANGE" | "SHM_LARGEPAGE_ALLOC_DEFAULT" @@ -2624,11 +2624,11 @@ fn test_freebsd(target: &str) { // Added in FreeBSD 14 "IFCAP_NV" if Some(14) > freebsd_ver => true, - // FIXME: Removed in https://reviews.freebsd.org/D38574 and https://reviews.freebsd.org/D38822 + // FIXME(freebsd): Removed in https://reviews.freebsd.org/D38574 and https://reviews.freebsd.org/D38822 // We maybe should deprecate them once a stable release ships them. "IP_BINDMULTI" | "IP_RSS_LISTEN_BUCKET" => true, - // FIXME: Removed in https://reviews.freebsd.org/D39127. + // FIXME(freebsd): Removed in https://reviews.freebsd.org/D39127. "KERN_VNODE" => true, // Added in FreeBSD 14 @@ -2651,10 +2651,10 @@ fn test_freebsd(target: &str) { true } - // FIXME: Removed in FreeBSD 15: + // FIXME(freebsd): Removed in FreeBSD 15: "LOCAL_CONNWAIT" if freebsd_ver >= Some(15) => true, - // FIXME: The values has been changed in FreeBSD 15: + // FIXME(freebsd): The values has been changed in FreeBSD 15: "CLOCK_BOOTTIME" if Some(15) <= freebsd_ver => true, // Added in FreeBSD 14.0 @@ -2713,7 +2713,7 @@ fn test_freebsd(target: &str) { | "sctp_send_failed_event" | "sctp_stream_reset_event" => true, - // FIXME: Changed in FreeBSD 15 + // FIXME(freebsd): Changed in FreeBSD 15 "tcp_info" | "sockstat" if Some(15) >= freebsd_ver => true, _ => false, @@ -2732,7 +2732,7 @@ fn test_freebsd(target: &str) { // Therefore the function pointer comparison does not make sense for it. "uname" => true, - // FIXME: Our API is unsound. The Rust API allows aliasing + // FIXME(ctest): Our API is unsound. The Rust API allows aliasing // pointers, but the C API requires pointers not to alias. // We should probably be at least using `&`/`&mut` here, see: // https://github.com/gnzlbg/ctest/issues/68 @@ -2795,7 +2795,7 @@ fn test_freebsd(target: &str) { cfg.skip_field(move |struct_, field| { match (struct_, field) { - // FIXME: `sa_sigaction` has type `sighandler_t` but that type is + // FIXME(freebsd): `sa_sigaction` has type `sighandler_t` but that type is // incorrect, see: https://github.com/rust-lang/libc/issues/1359 ("sigaction", "sa_sigaction") => true, @@ -2826,7 +2826,7 @@ fn test_freebsd(target: &str) { // anonymous struct ("devstat", "dev_links") => true, - // FIXME: structs too complicated to bind for now... + // FIXME(freebsd): structs too complicated to bind for now... ("kinfo_proc", "ki_paddr") => true, ("kinfo_proc", "ki_addr") => true, ("kinfo_proc", "ki_tracep") => true, @@ -2874,7 +2874,7 @@ fn test_emscripten(target: &str) { assert!(target.contains("emscripten")); let mut cfg = ctest_cfg(); - cfg.define("_GNU_SOURCE", None); // FIXME: ?? + cfg.define("_GNU_SOURCE", None); // FIXME(emscripten): ?? headers! { cfg: "ctype.h", @@ -2990,7 +2990,7 @@ fn test_emscripten(target: &str) { cfg.skip_type(move |ty| { match ty { // sighandler_t is crazy across platforms - // FIXME: is this necessary? + // FIXME(emscripten): is this necessary? "sighandler_t" => true, // No epoll support @@ -3008,7 +3008,7 @@ fn test_emscripten(target: &str) { // This is actually a union, not a struct "sigval" => true, - // FIXME: Investigate why the test fails. + // FIXME(emscripten): Investigate why the test fails. // Skip for now to unblock CI. "pthread_condattr_t" => true, "pthread_mutexattr_t" => true, From 5d9a22f51d19b2e343ad43a11e83aa011c8f032f Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 17 Feb 2025 14:33:34 +0100 Subject: [PATCH 09/23] gnu b32: Copy struct stat to mips and use it Just a simple copy, no cfg conditionals have been removed. This makes it easier to review this commit. (backport ) (cherry picked from commit 66532982296edaf223b111d7b2859ec0bea806da) --- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 48 +++++++++ src/unix/linux_like/linux/gnu/b32/mod.rs | 100 ++++++++++-------- 2 files changed, 101 insertions(+), 47 deletions(-) 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 b15df99e50ec6..729d6429c3428 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -4,6 +4,54 @@ use crate::{off64_t, off_t}; pub type wchar_t = i32; s! { + pub struct stat { + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_dev: crate::dev_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_dev: c_ulong, + + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __pad1: c_short, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad1: [c_long; 3], + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_rdev: crate::dev_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_rdev: c_ulong, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __pad2: c_short, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad2: [c_long; 2], + pub st_size: off_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad3: c_long, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_blksize: crate::blksize_t, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __unused4: c_long, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __unused5: c_long, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_blksize: crate::blksize_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_blocks: crate::blkcnt_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad5: [c_long; 14], + } + pub struct stat64 { pub st_dev: c_ulong, st_pad1: [c_long; 3], diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 2cdd1320bf3e3..9ff08c293e2c1 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -40,55 +40,61 @@ cfg_if! { } } -s! { - pub struct stat { - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_dev: crate::dev_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_dev: c_ulong, - - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __pad1: c_short, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad1: [c_long; 3], - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_rdev: crate::dev_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_rdev: c_ulong, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __pad2: c_short, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad2: [c_long; 2], - pub st_size: off_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad3: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_blksize: crate::blksize_t, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __unused4: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __unused5: c_long, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_blksize: crate::blksize_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_blocks: crate::blkcnt_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad5: [c_long; 14], +cfg_if! { + if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] { + s! { + pub struct stat { + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_dev: crate::dev_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_dev: c_ulong, + + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __pad1: c_short, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad1: [c_long; 3], + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_rdev: crate::dev_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_rdev: c_ulong, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __pad2: c_short, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad2: [c_long; 2], + pub st_size: off_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad3: c_long, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_blksize: crate::blksize_t, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __unused4: c_long, + #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] + __unused5: c_long, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_blksize: crate::blksize_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + pub st_blocks: crate::blkcnt_t, + #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] + st_pad5: [c_long; 14], + } + } } +} +s! { pub struct statvfs { pub f_bsize: c_ulong, pub f_frsize: c_ulong, From d67c99451930925c5fbb9aad622a903cae78bc06 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 17 Feb 2025 14:36:48 +0100 Subject: [PATCH 10/23] gnu b32: Remove mips cfg conditionals in struct stat Now that mips has its own copy of struct stat, remove all the cfg conditionals used to handle the difference between mips and everything else. Future support for _FILE_OFFSET_BITS=64 and _TIME_BITS=64 will be much easier when the mips differences does not have to be handled in the same conditionals. (backport ) (cherry picked from commit a092eed1ade740da43817037ff5675b237a8606b) --- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 24 ------------------- src/unix/linux_like/linux/gnu/b32/mod.rs | 24 ------------------- 2 files changed, 48 deletions(-) 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 729d6429c3428..249ed09a0dadd 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -5,50 +5,26 @@ pub type wchar_t = i32; s! { pub struct stat { - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_dev: crate::dev_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] pub st_dev: c_ulong, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __pad1: c_short, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] st_pad1: [c_long; 3], pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_rdev: crate::dev_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] pub st_rdev: c_ulong, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __pad2: c_short, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] st_pad2: [c_long; 2], pub st_size: off_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] st_pad3: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_blksize: crate::blksize_t, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __unused4: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] - __unused5: c_long, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] pub st_blksize: crate::blksize_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] pub st_blocks: crate::blkcnt_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] st_pad5: [c_long; 14], } diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 9ff08c293e2c1..134bfb05b7470 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -44,34 +44,18 @@ cfg_if! { if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] { s! { pub struct stat { - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] pub st_dev: crate::dev_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_dev: c_ulong, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] __pad1: c_short, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad1: [c_long; 3], pub st_ino: crate::ino_t, pub st_mode: crate::mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] pub st_rdev: crate::dev_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_rdev: c_ulong, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] __pad2: c_short, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad2: [c_long; 2], pub st_size: off_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad3: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] pub st_blksize: crate::blksize_t, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -79,16 +63,8 @@ cfg_if! { pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] __unused4: c_long, - #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] __unused5: c_long, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_blksize: crate::blksize_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - pub st_blocks: crate::blkcnt_t, - #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] - st_pad5: [c_long; 14], } } } From 25245d2958554ad8350b58ed823d97e81064ed82 Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Wed, 8 Jan 2025 02:05:41 +0000 Subject: [PATCH 11/23] chore: add labels to FIXMEs (backport ) (cherry picked from commit ccf7b41dd47aa6ab07bf14561b1e9f37e2e900ea) --- src/fuchsia/x86_64.rs | 2 +- src/unix/bsd/apple/b32/mod.rs | 4 +-- src/unix/bsd/apple/b64/aarch64/mod.rs | 2 +- src/unix/bsd/apple/b64/mod.rs | 2 +- src/unix/bsd/apple/b64/x86_64/mod.rs | 2 +- src/unix/bsd/apple/mod.rs | 30 +++++++++---------- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 8 ++--- src/unix/bsd/freebsdlike/freebsd/mod.rs | 14 ++++----- .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 2 +- src/unix/bsd/freebsdlike/mod.rs | 2 +- src/unix/bsd/netbsdlike/netbsd/mod.rs | 21 ++++++------- 11 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index ffff3a78b5ed5..a184539e28277 100644 --- a/src/fuchsia/x86_64.rs +++ b/src/fuchsia/x86_64.rs @@ -102,7 +102,7 @@ cfg_if! { .field("uc_stack", &self.uc_stack) .field("uc_mcontext", &self.uc_mcontext) .field("uc_sigmask", &self.uc_sigmask) - // FIXME: .field("__private", &self.__private) + // FIXME(debug): .field("__private", &self.__private) .finish() } } diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 4fec58f76be47..3753ffb085907 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -45,7 +45,7 @@ s! { } pub struct malloc_zone_t { - __private: [crate::uintptr_t; 18], // FIXME: keeping private for now + __private: [crate::uintptr_t; 18], // FIXME(macos): keeping private for now } } @@ -84,7 +84,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_attr_t") .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) + // FIXME(debug): .field("__opaque", &self.__opaque) .finish() } } diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index 60b9d4bb4ce40..e300b76ae8228 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -5,7 +5,7 @@ pub type mcontext_t = *mut __darwin_mcontext64; s! { pub struct malloc_zone_t { - __private: [crate::uintptr_t; 18], // FIXME: needs arm64 auth pointers support + __private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support } pub struct ucontext_t { diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 98dccd3d49ddd..2bd682313428e 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -77,7 +77,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_attr_t") .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) + // FIXME(debug): .field("__opaque", &self.__opaque) .finish() } } diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index ea738497e98de..aa5ab85c0268b 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -106,7 +106,7 @@ s! { } pub struct malloc_introspection_t { - _private: [crate::uintptr_t; 16], // FIXME: keeping private for now + _private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now } pub struct malloc_zone_t { diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index fe8bad4209f37..2f89f70dcb477 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -371,7 +371,7 @@ s! { } pub struct sigaction { - // FIXME: this field is actually a union + // FIXME(union): this field is actually a union pub sa_sigaction: crate::sighandler_t, pub sa_mask: sigset_t, pub sa_flags: c_int, @@ -1342,9 +1342,9 @@ s_no_extra_traits! { pub shm_lpid: crate::pid_t, pub shm_cpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - pub shm_atime: crate::time_t, // FIXME: 64-bit wrong align => wrong offset - pub shm_dtime: crate::time_t, // FIXME: 64-bit wrong align => wrong offset - pub shm_ctime: crate::time_t, // FIXME: 64-bit wrong align => wrong offset + pub shm_atime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset + pub shm_dtime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset + pub shm_ctime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset // FIXME: 64-bit wrong align => wrong offset: pub shm_internal: *mut c_void, } @@ -1955,7 +1955,7 @@ cfg_if! { .field("pth_curpri", &self.pth_curpri) .field("pth_priority", &self.pth_priority) .field("pth_maxpriority", &self.pth_maxpriority) - // FIXME: .field("pth_name", &self.pth_name) + // FIXME(debug): .field("pth_name", &self.pth_name) .finish() } } @@ -2021,8 +2021,8 @@ cfg_if! { .field("f_fssubtype", &self.f_fssubtype) .field("f_fstypename", &self.f_fstypename) .field("f_type", &self.f_type) - // FIXME: .field("f_mntonname", &self.f_mntonname) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) + // FIXME(debug): .field("f_mntonname", &self.f_mntonname) + // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) .field("f_reserved", &self.f_reserved) .finish() } @@ -2072,7 +2072,7 @@ cfg_if! { .field("d_reclen", &self.d_reclen) .field("d_namlen", &self.d_namlen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -2101,7 +2101,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_rwlock_t") .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) + // FIXME(debug): .field("__opaque", &self.__opaque) .finish() } } @@ -2129,7 +2129,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_mutex_t") .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) + // FIXME(debug): .field("__opaque", &self.__opaque) .finish() } } @@ -2158,7 +2158,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("pthread_cond_t") .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) + // FIXME(debug): .field("__opaque", &self.__opaque) .finish() } } @@ -2197,7 +2197,7 @@ cfg_if! { .field("ss_family", &self.ss_family) .field("__ss_pad1", &self.__ss_pad1) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) + // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) .finish() } } @@ -2237,13 +2237,13 @@ cfg_if! { impl fmt::Debug for utmpx { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utmpx") - // FIXME: .field("ut_user", &self.ut_user) + // FIXME(debug): .field("ut_user", &self.ut_user) .field("ut_id", &self.ut_id) .field("ut_line", &self.ut_line) .field("ut_pid", &self.ut_pid) .field("ut_type", &self.ut_type) .field("ut_tv", &self.ut_tv) - // FIXME: .field("ut_host", &self.ut_host) + // FIXME(debug): .field("ut_host", &self.ut_host) .field("ut_pad", &self.ut_pad) .finish() } @@ -2485,7 +2485,7 @@ cfg_if! { .field("pth_curpri", &self.pth_curpri) .field("pth_priority", &self.pth_priority) .field("pth_maxpriority", &self.pth_maxpriority) - // FIXME: .field("pth_name", &self.pth_name) + // FIXME(debug): .field("pth_name", &self.pth_name) .finish() } } diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index cfaa93f76d88e..c7621809ba439 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -560,7 +560,7 @@ cfg_if! { .field("ut_name", &self.ut_name) .field("ut_id", &self.ut_id) .field("ut_line", &self.ut_line) - // FIXME: .field("ut_host", &self.ut_host) + // FIXME(debug): .field("ut_host", &self.ut_host) .field("ut_unused", &self.ut_unused) .field("ut_session", &self.ut_session) .field("ut_type", &self.ut_type) @@ -639,7 +639,7 @@ cfg_if! { .field("d_type", &self.d_type) // Ignore __unused1 // Ignore __unused2 - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -701,10 +701,10 @@ cfg_if! { .field("f_flags", &self.f_flags) .field("f_syncwrites", &self.f_syncwrites) .field("f_asyncwrites", &self.f_asyncwrites) - // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME(debug): .field("f_mntonname", &self.f_mntonname) .field("f_syncreads", &self.f_syncreads) .field("f_asyncreads", &self.f_asyncreads) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) + // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) .finish() } } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 23bbb1e1c47fe..824ff1ac674c6 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1639,7 +1639,7 @@ s_no_extra_traits! { pub kf_flags: c_int, _kf_pad0: c_int, pub kf_offset: i64, - _priv: [u8; 304], // FIXME: this is really a giant union + _priv: [u8; 304], // FIXME(freebsd): this is really a giant union pub kf_status: u16, _kf_pad1: u16, _kf_ispare0: c_int, @@ -1690,8 +1690,8 @@ cfg_if! { .field("ut_pid", &self.ut_pid) .field("ut_user", &self.ut_user) .field("ut_line", &self.ut_line) - // FIXME: .field("ut_host", &self.ut_host) - // FIXME: .field("__ut_spare", &self.__ut_spare) + // FIXME(debug): .field("ut_host", &self.ut_host) + // FIXME(debug): .field("__ut_spare", &self.__ut_spare) .finish() } } @@ -1778,7 +1778,7 @@ cfg_if! { .field("sdl_nlen", &self.sdl_nlen) .field("sdl_alen", &self.sdl_alen) .field("sdl_slen", &self.sdl_slen) - // FIXME: .field("sdl_data", &self.sdl_data) + // FIXME(debug): .field("sdl_data", &self.sdl_data) .finish() } } @@ -2286,7 +2286,7 @@ cfg_if! { f.debug_struct("sctp_gen_error_cause") .field("code", &{ self.code }) .field("length", &{ self.length }) - // FIXME: .field("info", &{self.info}) + // FIXME(debug): .field("info", &{self.info}) .finish() } } @@ -2358,7 +2358,7 @@ cfg_if! { f.debug_struct("sctp_error_missing_param") .field("cause", &{ self.cause }) .field("num_missing_params", &{ self.num_missing_params }) - // FIXME: .field("tpe", &{self.tpe}) + // FIXME(debug): .field("tpe", &{self.tpe}) .finish() } } @@ -5689,7 +5689,7 @@ extern "C" { pub fn pidfile_close(path: *mut crate::pidfh) -> c_int; pub fn pidfile_remove(path: *mut crate::pidfh) -> c_int; pub fn pidfile_fileno(path: *const crate::pidfh) -> c_int; - // FIXME: pidfile_signal in due time (both manpage present and updated image snapshot) + // FIXME(freebsd): pidfile_signal in due time (both manpage present and updated image snapshot) } #[link(name = "procstat")] diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fde274bb15a69..065847043225c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -344,7 +344,7 @@ cfg_if! { .field("mc_len", &self.mc_len) .field("mc_fpformat", &self.mc_fpformat) .field("mc_ownedfp", &self.mc_ownedfp) - // FIXME: .field("mc_fpstate", &self.mc_fpstate) + // FIXME(debug): .field("mc_fpstate", &self.mc_fpstate) .field("mc_fsbase", &self.mc_fsbase) .field("mc_gsbase", &self.mc_gsbase) .field("mc_xfpustate", &self.mc_xfpustate) diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 3c62e7d5e8271..2d74756d9957d 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -418,7 +418,7 @@ cfg_if! { .field("ss_family", &self.ss_family) .field("__ss_pad1", &self.__ss_pad1) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) + // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) .finish() } } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index fe2b667a523fc..3cd4d7ae13953 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -10,7 +10,7 @@ pub type fsfilcnt_t = u64; pub type idtype_t = c_int; pub type mqd_t = c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; -pub type vm_size_t = crate::uintptr_t; // FIXME: deprecated since long time +pub type vm_size_t = crate::uintptr_t; // FIXME(deprecated): deprecated since long time pub type lwpid_t = c_uint; pub type shmatt_t = c_uint; pub type cpuid_t = c_ulong; @@ -297,7 +297,8 @@ s! { pub flags: u32, pub fflags: u32, pub data: i64, - pub udata: intptr_t, /* FIXME: NetBSD 10.0 will finally have same layout as other BSD */ + // FIXME(netbsd): NetBSD 10.0 will finally have same layout as other BSD + pub udata: intptr_t, } pub struct dqblk { @@ -799,7 +800,7 @@ s_no_extra_traits! { pub ut_session: u16, pub ut_type: u16, pub ut_pid: crate::pid_t, - pub ut_exit: __exit_status, // FIXME: when anonymous struct are supported + pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported pub ut_ss: sockaddr_storage, pub ut_tv: crate::timeval, pub ut_pad: [u8; _UTX_PADSIZE], @@ -945,14 +946,14 @@ cfg_if! { .field("ut_name", &self.ut_name) .field("ut_id", &self.ut_id) .field("ut_line", &self.ut_line) - // FIXME .field("ut_host", &self.ut_host) + // FIXME(debug) .field("ut_host", &self.ut_host) .field("ut_session", &self.ut_session) .field("ut_type", &self.ut_type) .field("ut_pid", &self.ut_pid) .field("ut_exit", &self.ut_exit) .field("ut_ss", &self.ut_ss) .field("ut_tv", &self.ut_tv) - // FIXME .field("ut_pad", &self.ut_pad) + // FIXME(debug) .field("ut_pad", &self.ut_pad) .finish() } } @@ -993,7 +994,7 @@ cfg_if! { f.debug_struct("lastlogx") .field("ll_tv", &self.ll_tv) .field("ll_line", &self.ll_line) - // FIXME.field("ll_host", &self.ll_host) + // FIXME(debug).field("ll_host", &self.ll_host) .field("ll_ss", &self.ll_ss) .finish() } @@ -1159,7 +1160,7 @@ cfg_if! { .field("d_reclen", &self.d_reclen) .field("d_namlen", &self.d_namlen) .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -1235,8 +1236,8 @@ cfg_if! { .field("f_owner", &self.f_owner) .field("f_spare", &self.f_spare) .field("f_fstypename", &self.f_fstypename) - // FIXME: .field("f_mntonname", &self.f_mntonname) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) + // FIXME(debug): .field("f_mntonname", &self.f_mntonname) + // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) .finish() } } @@ -1290,7 +1291,7 @@ cfg_if! { .field("ss_family", &self.ss_family) .field("__ss_pad1", &self.__ss_pad1) .field("__ss_pad2", &self.__ss_pad2) - // FIXME: .field("__ss_pad3", &self.__ss_pad3) + // FIXME(debug): .field("__ss_pad3", &self.__ss_pad3) .finish() } } From 24430c76a2764e1cb767600bbdb519c525272a6a Mon Sep 17 00:00:00 2001 From: Ivan Gankevich Date: Wed, 18 Dec 2024 07:33:32 +0100 Subject: [PATCH 12/23] Make all `major`, `minor`, `makedev` into `const fn`. (backport ) (cherry picked from commit 37c3333c07105cf29245941ecbbd5733ad0ddd22) --- libc-test/src/makedev.c | 16 +++-- libc-test/test/makedev.rs | 58 ++++++++++++++++++- src/fuchsia/mod.rs | 28 ++++----- src/unix/aix/mod.rs | 38 ++++++------ src/unix/bsd/apple/mod.rs | 24 ++++---- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 16 ++--- .../bsd/freebsdlike/freebsd/freebsd11/mod.rs | 6 +- .../bsd/freebsdlike/freebsd/freebsd12/mod.rs | 6 +- .../bsd/freebsdlike/freebsd/freebsd13/mod.rs | 6 +- .../bsd/freebsdlike/freebsd/freebsd14/mod.rs | 6 +- .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 6 +- src/unix/bsd/netbsdlike/netbsd/mod.rs | 22 +++---- src/unix/bsd/netbsdlike/openbsd/mod.rs | 25 ++++---- src/unix/hurd/mod.rs | 16 ++--- src/unix/linux_like/android/mod.rs | 14 +++-- src/unix/linux_like/emscripten/mod.rs | 38 ++++++------ src/unix/linux_like/linux/mod.rs | 28 ++++----- src/unix/nto/mod.rs | 16 ++--- 18 files changed, 210 insertions(+), 159 deletions(-) diff --git a/libc-test/src/makedev.c b/libc-test/src/makedev.c index 7f99d60728bb4..62752c72ab97f 100644 --- a/libc-test/src/makedev.c +++ b/libc-test/src/makedev.c @@ -3,11 +3,19 @@ #include #endif -// Since makedev is a macro instead of a function, it isn't available to FFI. -// libc must reimplement it, which is error-prone. This file provides FFI -// access to the actual macro so it can be tested against the Rust -// reimplementation. +// Since makedev, major, minor are macros instead of functions, they aren't +// available to FFI. libc must reimplement them, which is error-prone. This +// file provides FFI access to the actual macros so they can be tested against +// the Rust reimplementation. dev_t makedev_ffi(unsigned major, unsigned minor) { return makedev(major, minor); } + +unsigned int major_ffi(dev_t dev) { + return major(dev); +} + +unsigned int minor_ffi(dev_t dev) { + return minor(dev); +} diff --git a/libc-test/test/makedev.rs b/libc-test/test/makedev.rs index cb00975b9a41f..44297a2163aa2 100644 --- a/libc-test/test/makedev.rs +++ b/libc-test/test/makedev.rs @@ -1,6 +1,50 @@ -//! Compare libc's makdev function against the actual C macros, for various +//! Compare libc's makedev, major, minor functions against the actual C macros, for various //! inputs. +#[cfg(any(target_os = "solaris", target_os = "illumos"))] +mod ret { + pub type MajorRetType = libc::major_t; + pub type MinorRetType = libc::minor_t; +} + +#[cfg(any( + target_os = "linux", + target_os = "l4re", + target_os = "emscripten", + target_os = "fuchsia", + target_os = "aix", + target_os = "nto", + target_os = "hurd", + target_os = "openbsd", +))] +mod ret { + pub type MajorRetType = libc::c_uint; + pub type MinorRetType = libc::c_uint; +} + +#[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "netbsd", + target_os = "freebsd", +))] +mod ret { + pub type MajorRetType = libc::c_int; + pub type MinorRetType = libc::c_int; +} + +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" +))] +mod ret { + pub type MajorRetType = i32; + pub type MinorRetType = i32; +} + #[cfg(any( target_os = "android", target_os = "dragonfly", @@ -14,13 +58,21 @@ mod t { use libc::{self, c_uint, dev_t}; + use super::ret::*; + extern "C" { pub fn makedev_ffi(major: c_uint, minor: c_uint) -> dev_t; + pub fn major_ffi(dev: dev_t) -> c_uint; + pub fn minor_ffi(dev: dev_t) -> c_uint; } fn compare(major: c_uint, minor: c_uint) { - let expected = unsafe { makedev_ffi(major, minor) }; - assert_eq!(libc::makedev(major, minor), expected); + let dev = unsafe { makedev_ffi(major, minor) }; + assert_eq!(libc::makedev(major, minor), dev); + let major = unsafe { major_ffi(dev) }; + assert_eq!(libc::major(dev), major as MajorRetType); + let minor = unsafe { minor_ffi(dev) }; + assert_eq!(libc::minor(dev), minor as MinorRetType); } // Every OS should be able to handle 8 bit major and minor numbers diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index d666c7e39de60..9e8f55471a1ac 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3423,20 +3423,6 @@ f! { set1.bits == set2.bits } - pub fn major(dev: crate::dev_t) -> c_uint { - let mut major = 0; - major |= (dev & 0x00000000000fff00) >> 8; - major |= (dev & 0xfffff00000000000) >> 32; - major as c_uint - } - - pub fn minor(dev: crate::dev_t) -> c_uint { - let mut minor = 0; - minor |= (dev & 0x00000000000000ff) >> 0; - minor |= (dev & 0x00000ffffff00000) >> 12; - minor as c_uint - } - pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { cmsg.offset(1) as *mut c_uchar } @@ -3519,6 +3505,20 @@ safe_f! { dev |= (minor & 0xffffff00) << 12; dev } + + pub {const} fn major(dev: crate::dev_t) -> c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as c_uint + } + + pub {const} fn minor(dev: crate::dev_t) -> c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as c_uint + } } fn __CMSG_LEN(cmsg: *const cmsghdr) -> ssize_t { diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 647836b6f6719..d158ab86c8a9b 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2546,25 +2546,6 @@ f! { let fd = fd as usize; return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; } - - pub fn major(dev: crate::dev_t) -> c_uint { - let x = dev >> 16; - x as c_uint - } - - pub fn minor(dev: crate::dev_t) -> c_uint { - let y = dev & 0xFFFF; - y as c_uint - } - - pub fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { - let major = major as crate::dev_t; - let minor = minor as crate::dev_t; - let mut dev = 0; - dev |= major << 16; - dev |= minor; - dev - } } safe_f! { @@ -2612,6 +2593,25 @@ safe_f! { pub {const} fn WCOREDUMP(_status: c_int) -> bool { false } + + pub {const} fn major(dev: crate::dev_t) -> c_uint { + let x = dev >> 16; + x as c_uint + } + + pub {const} fn minor(dev: crate::dev_t) -> c_uint { + let y = dev & 0xFFFF; + y as c_uint + } + + pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= major << 16; + dev |= minor; + dev + } } #[link(name = "thread")] diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 2f89f70dcb477..9103522d95053 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5715,18 +5715,6 @@ f! { pub {const} fn VM_MAKE_TAG(id: u8) -> u32 { (id as u32) << 24u32 } - - pub fn major(dev: dev_t) -> i32 { - (dev >> 24) & 0xff - } - - pub fn minor(dev: dev_t) -> i32 { - dev & 0xffffff - } - - pub fn makedev(major: i32, minor: i32) -> dev_t { - (major << 24) | minor - } } safe_f! { @@ -5749,6 +5737,18 @@ safe_f! { pub {const} fn WIFSTOPPED(status: c_int) -> bool { _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13 } + + pub {const} fn makedev(major: i32, minor: i32) -> dev_t { + (major << 24) | minor + } + + pub {const} fn major(dev: dev_t) -> i32 { + (dev >> 24) & 0xff + } + + pub {const} fn minor(dev: dev_t) -> i32 { + dev & 0xffffff + } } extern "C" { diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index c7621809ba439..a8c253bb976ac 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1590,14 +1590,6 @@ f! { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); 0 != cpuset.ary[idx] & (1 << offset) } - - pub fn major(dev: crate::dev_t) -> c_int { - ((dev >> 8) & 0xff) as c_int - } - - pub fn minor(dev: crate::dev_t) -> c_int { - (dev & 0xffff00ff) as c_int - } } safe_f! { @@ -1613,6 +1605,14 @@ safe_f! { dev |= minor; dev } + + pub {const} fn major(dev: crate::dev_t) -> c_int { + ((dev >> 8) & 0xff) as c_int + } + + pub {const} fn minor(dev: crate::dev_t) -> c_int { + (dev & 0xffff00ff) as c_int + } } extern "C" { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 6a484e4a0b229..87ddbcc4376c8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -441,14 +441,12 @@ safe_f! { let minor = minor as crate::dev_t; (major << 8) | minor } -} -f! { - pub fn major(dev: crate::dev_t) -> c_int { + pub {const} fn major(dev: crate::dev_t) -> c_int { ((dev >> 8) & 0xff) as c_int } - pub fn minor(dev: crate::dev_t) -> c_int { + pub {const} fn minor(dev: crate::dev_t) -> c_int { (dev & 0xffff00ff) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index d419433efeb9b..6c2f586195dc5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -496,14 +496,12 @@ safe_f! { dev |= ((minor & 0xffff00ff) as dev_t) << 0; dev } -} -f! { - pub fn major(dev: crate::dev_t) -> c_int { + pub {const} fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub fn minor(dev: crate::dev_t) -> c_int { + pub {const} fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index c5944a69988e8..cf507e66b38c0 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -518,14 +518,12 @@ safe_f! { dev |= ((minor & 0xffff00ff) as dev_t) << 0; dev } -} -f! { - pub fn major(dev: crate::dev_t) -> c_int { + pub {const} fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub fn minor(dev: crate::dev_t) -> c_int { + pub {const} fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 34dd48f486f4a..0a05ca9fad3e8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -518,14 +518,12 @@ safe_f! { dev |= ((minor & 0xffff00ff) as dev_t) << 0; dev } -} -f! { - pub fn major(dev: crate::dev_t) -> c_int { + pub {const} fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub fn minor(dev: crate::dev_t) -> c_int { + pub {const} fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 9c81a8410db04..2fe39a3acea2c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -519,14 +519,12 @@ safe_f! { dev |= ((minor & 0xffff00ff) as dev_t) << 0; dev } -} -f! { - pub fn major(dev: crate::dev_t) -> c_int { + pub {const} fn major(dev: crate::dev_t) -> c_int { (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int } - pub fn minor(dev: crate::dev_t) -> c_int { + pub {const} fn minor(dev: crate::dev_t) -> c_int { (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int } } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 3cd4d7ae13953..8ede2b603d100 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2461,17 +2461,6 @@ f! { pub fn PROT_MPROTECT_EXTRACT(x: c_int) -> c_int { (x >> 3) & 0x7 } - - pub fn major(dev: crate::dev_t) -> c_int { - (((dev as u32) & 0x000fff00) >> 8) as c_int - } - - pub fn minor(dev: crate::dev_t) -> c_int { - let mut res = 0; - res |= ((dev as u32) & 0xfff00000) >> 12; - res |= (dev as u32) & 0x000000ff; - res as c_int - } } safe_f! { @@ -2500,6 +2489,17 @@ safe_f! { dev |= minor & 0xff; dev } + + pub {const} fn major(dev: crate::dev_t) -> c_int { + (((dev as u32) & 0x000fff00) >> 8) as c_int + } + + pub {const} fn minor(dev: crate::dev_t) -> c_int { + let mut res = 0; + res |= ((dev as u32) & 0xfff00000) >> 12; + res |= (dev as u32) & 0x000000ff; + res as c_int + } } extern "C" { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index f86919264c0ad..62955757e8e21 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1966,19 +1966,6 @@ f! { pub {const} fn CMSG_SPACE(length: c_uint) -> c_uint { (_ALIGN(mem::size_of::()) + _ALIGN(length as usize)) as c_uint } - - pub fn major(dev: crate::dev_t) -> c_uint { - ((dev as c_uint) >> 8) & 0xff - } - - pub fn minor(dev: crate::dev_t) -> c_uint { - let dev = dev as c_uint; - let mut res = 0; - res |= (dev) & 0xff; - res |= ((dev) & 0xffff0000) >> 8; - - res - } } safe_f! { @@ -2007,6 +1994,18 @@ safe_f! { dev |= (minor & 0xffff00) << 8; dev } + + pub {const} fn major(dev: crate::dev_t) -> c_uint { + ((dev as c_uint) >> 8) & 0xff + } + + pub {const} fn minor(dev: crate::dev_t) -> c_uint { + let dev = dev as c_uint; + let mut res = 0; + res |= (dev) & 0xff; + res |= ((dev) & 0xffff0000) >> 8; + res + } } extern "C" { diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 0c5f001202844..8703f4d37a66d 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3524,14 +3524,6 @@ f! { set1.bits == set2.bits } - pub fn major(dev: crate::dev_t) -> c_uint { - ((dev >> 8) & 0xff) as c_uint - } - - pub fn minor(dev: crate::dev_t) -> c_uint { - (dev & 0xffff00ff) as c_uint - } - pub fn IPTOS_TOS(tos: u8) -> u8 { tos & IPTOS_TOS_MASK } @@ -4566,6 +4558,14 @@ safe_f! { dev } + pub {const} fn major(dev: crate::dev_t) -> c_uint { + ((dev >> 8) & 0xff) as c_uint + } + + pub {const} fn minor(dev: crate::dev_t) -> c_uint { + (dev & 0xffff00ff) as c_uint + } + pub fn SIGRTMAX() -> c_int { unsafe { __libc_current_sigrtmax() } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 2ba535d635961..af76f0307f8a0 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3647,12 +3647,6 @@ f! { set1.__bits == set2.__bits } - pub fn major(dev: crate::dev_t) -> c_int { - ((dev >> 8) & 0xfff) as c_int - } - pub fn minor(dev: crate::dev_t) -> c_int { - ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as c_int - } pub fn NLA_ALIGN(len: c_int) -> c_int { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); } @@ -3668,6 +3662,14 @@ safe_f! { let mi = mi as crate::dev_t; ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12) } + + pub {const} fn major(dev: crate::dev_t) -> c_int { + ((dev >> 8) & 0xfff) as c_int + } + + pub {const} fn minor(dev: crate::dev_t) -> c_int { + ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as c_int + } } extern "C" { diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index f22843e54073f..09de6f7d1e191 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1452,41 +1452,41 @@ f! { pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { set1.bits == set2.bits } +} + +safe_f! { + pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= (major & 0xfffff000) << 31 << 1; + dev |= (major & 0x00000fff) << 8; + dev |= (minor & 0xffffff00) << 12; + dev |= minor & 0x000000ff; + dev + } - pub fn major(dev: crate::dev_t) -> c_uint { + pub {const} fn major(dev: crate::dev_t) -> c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ // main/system/lib/libc/musl/include/sys/sysmacros.h let mut major = 0; - major |= (dev & 0x00000fff) >> 8; - major |= (dev & 0xfffff000) >> 31 >> 1; + major |= (dev >> 31 >> 1) & 0xfffff000; + major |= (dev >> 8) & 0x00000fff; major as c_uint } - pub fn minor(dev: crate::dev_t) -> c_uint { + pub {const} fn minor(dev: crate::dev_t) -> c_uint { // see // https://github.com/emscripten-core/emscripten/blob/ // main/system/lib/libc/musl/include/sys/sysmacros.h let mut minor = 0; - minor |= (dev & 0x000000ff) >> 0; - minor |= (dev & 0xffffff00) >> 12; + minor |= (dev >> 12) & 0xffffff00; + minor |= dev & 0x000000ff; minor as c_uint } } -safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { - let major = major as crate::dev_t; - let minor = minor as crate::dev_t; - let mut dev = 0; - dev |= (major & 0x00000fff) << 8; - dev |= (major & 0xfffff000) << 31 << 1; - dev |= (minor & 0x000000ff) << 0; - dev |= (minor & 0xffffff00) << 12; - dev - } -} - extern "C" { pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index d9936fdb4f7e7..c3c084ed05d99 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -6006,20 +6006,6 @@ f! { () } - pub fn major(dev: crate::dev_t) -> c_uint { - let mut major = 0; - major |= (dev & 0x00000000000fff00) >> 8; - major |= (dev & 0xfffff00000000000) >> 32; - major as c_uint - } - - pub fn minor(dev: crate::dev_t) -> c_uint { - let mut minor = 0; - minor |= (dev & 0x00000000000000ff) >> 0; - minor |= (dev & 0x00000ffffff00000) >> 12; - minor as c_uint - } - pub fn IPTOS_TOS(tos: u8) -> u8 { tos & IPTOS_TOS_MASK } @@ -6111,6 +6097,20 @@ safe_f! { dev } + pub {const} fn major(dev: crate::dev_t) -> c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as c_uint + } + + pub {const} fn minor(dev: crate::dev_t) -> c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as c_uint + } + pub {const} fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool { policy == SCTP_PR_SCTP_TTL } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index ad4b390d61c07..b6850da000d34 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2804,14 +2804,6 @@ f! { let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; mem::size_of::() + mem::size_of::() * ngrps } - - pub fn major(dev: crate::dev_t) -> c_uint { - ((dev as c_uint) >> 10) & 0x3f - } - - pub fn minor(dev: crate::dev_t) -> c_uint { - (dev as c_uint) & 0x3ff - } } safe_f! { @@ -2854,6 +2846,14 @@ safe_f! { pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { ((major << 10) | (minor)) as crate::dev_t } + + pub {const} fn major(dev: crate::dev_t) -> c_uint { + ((dev as c_uint) >> 10) & 0x3f + } + + pub {const} fn minor(dev: crate::dev_t) -> c_uint { + (dev as c_uint) & 0x3ff + } } // Network related functions are provided by libsocket and regex From 903dc2321db03df0f635d6950bfe881458e13564 Mon Sep 17 00:00:00 2001 From: lvllvl <24905907+lvllvl@users.noreply.github.com> Date: Mon, 24 Feb 2025 00:29:41 +0000 Subject: [PATCH 13/23] chore: add labels to each FIXME (backport ) (cherry picked from commit 861246a7e1ae9d9ad6b8d356ebb47ab5ad1b43df) --- src/unix/bsd/mod.rs | 12 +++---- src/unix/bsd/netbsdlike/openbsd/mod.rs | 20 ++++++------ src/unix/bsd/netbsdlike/openbsd/x86_64.rs | 4 +-- src/unix/haiku/mod.rs | 10 +++--- src/unix/haiku/x86_64.rs | 10 +++--- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 2 +- src/unix/linux_like/linux/musl/b32/hexagon.rs | 2 +- src/unix/nto/mod.rs | 14 ++++---- src/unix/solarish/mod.rs | 32 +++++++++---------- 9 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 445957537eb76..bddb68c8b400a 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -185,7 +185,7 @@ cfg_if! { f.debug_struct("sockaddr_un") .field("sun_len", &self.sun_len) .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -232,11 +232,11 @@ cfg_if! { impl fmt::Debug for utsname { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) + // FIXME(debug): .field("sysname", &self.sysname) + // FIXME(debug): .field("nodename", &self.nodename) + // FIXME(debug): .field("release", &self.release) + // FIXME(debug): .field("version", &self.version) + // FIXME(debug): .field("machine", &self.machine) .finish() } } diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 62955757e8e21..ff3a99fcc7db2 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -781,7 +781,7 @@ cfg_if! { .field("d_reclen", &self.d_reclen) .field("d_type", &self.d_type) .field("d_namlen", &self.d_namlen) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -874,8 +874,8 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("lastlog") .field("ll_time", &self.ll_time) - // FIXME: .field("ll_line", &self.ll_line) - // FIXME: .field("ll_host", &self.ll_host) + // FIXME(debug): .field("ll_line", &self.ll_line) + // FIXME(debug): .field("ll_host", &self.ll_host) .finish() } } @@ -914,9 +914,9 @@ cfg_if! { impl fmt::Debug for utmp { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utmp") - // FIXME: .field("ut_line", &self.ut_line) - // FIXME: .field("ut_name", &self.ut_name) - // FIXME: .field("ut_host", &self.ut_host) + // FIXME(debug): .field("ut_line", &self.ut_line) + // FIXME(debug): .field("ut_name", &self.ut_name) + // FIXME(debug): .field("ut_host", &self.ut_host) .field("ut_time", &self.ut_time) .finish() } @@ -1049,10 +1049,10 @@ cfg_if! { .field("f_namemax", &self.f_namemax) .field("f_owner", &self.f_owner) .field("f_ctime", &self.f_ctime) - // FIXME: .field("f_fstypename", &self.f_fstypename) - // FIXME: .field("f_mntonname", &self.f_mntonname) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) - // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) + // FIXME(debug): .field("f_fstypename", &self.f_fstypename) + // FIXME(debug): .field("f_mntonname", &self.f_mntonname) + // FIXME(debug): .field("f_mntfromname", &self.f_mntfromname) + // FIXME(debug): .field("f_mntfromspec", &self.f_mntfromspec) .field("mount_info", &self.mount_info) .finish() } diff --git a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs index db9114e27cb60..9003f3588c1b6 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -92,8 +92,8 @@ cfg_if! { .field("fx_rdp", &{ self.fx_rdp }) .field("fx_mxcsr", &{ self.fx_mxcsr }) .field("fx_mxcsr_mask", &{ self.fx_mxcsr_mask }) - // FIXME: .field("fx_st", &{self.fx_st}) - // FIXME: .field("fx_xmm", &{self.fx_xmm}) + // FIXME(debug): .field("fx_st", &{self.fx_st}) + // FIXME(debug): .field("fx_xmm", &{self.fx_xmm}) .finish() } } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 10ee719b9c18f..76e44cc796f1d 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -562,7 +562,7 @@ cfg_if! { f.debug_struct("sockaddr_un") .field("sun_len", &self.sun_len) .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -599,7 +599,7 @@ cfg_if! { .field("ss_family", &self.ss_family) .field("__ss_pad1", &self.__ss_pad1) .field("__ss_pad2", &self.__ss_pad2) - // FIXME: .field("__ss_pad3", &self.__ss_pad3) + // FIXME(debug): .field("__ss_pad3", &self.__ss_pad3) .finish() } } @@ -636,7 +636,7 @@ cfg_if! { .field("d_ino", &self.d_ino) .field("d_pino", &self.d_pino) .field("d_reclen", &self.d_reclen) - // FIXME: .field("d_name", &self.d_name) + // FIXME(debug): .field("d_name", &self.d_name) .finish() } } @@ -868,7 +868,7 @@ pub const LC_NUMERIC: c_int = 4; pub const LC_TIME: c_int = 5; pub const LC_MESSAGES: c_int = 6; -// FIXME: Haiku does not have MAP_FILE, but library/std/os.rs requires it +// FIXME(haiku): Haiku does not have MAP_FILE, but library/std/os.rs requires it pub const MAP_FILE: c_int = 0x00; pub const MAP_SHARED: c_int = 0x01; pub const MAP_PRIVATE: c_int = 0x02; @@ -1302,7 +1302,7 @@ pub const PTHREAD_MUTEX_NORMAL: c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 3; -pub const FIOCLEX: c_ulong = 0; // FIXME: does not exist on Haiku! +pub const FIOCLEX: c_ulong = 0; // FIXME(haiku): does not exist on Haiku! pub const RUSAGE_CHILDREN: c_int = -1; diff --git a/src/unix/haiku/x86_64.rs b/src/unix/haiku/x86_64.rs index e77588df59f4f..548c8e06b825c 100644 --- a/src/unix/haiku/x86_64.rs +++ b/src/unix/haiku/x86_64.rs @@ -94,9 +94,9 @@ cfg_if! { .field("rdp", &self.rdp) .field("mxcsr", &self.mxcsr) .field("mscsr_mask", &self.mscsr_mask) - // FIXME: .field("_fpreg", &self._fpreg) - // FIXME: .field("_xmm", &self._xmm) - // FIXME: .field("_reserved_416_511", &self._reserved_416_511) + // FIXME(debug): .field("_fpreg", &self._fpreg) + // FIXME(debug): .field("_xmm", &self._xmm) + // FIXME(debug): .field("_reserved_416_511", &self._reserved_416_511) .finish() } } @@ -133,7 +133,7 @@ cfg_if! { f.debug_struct("xstate_hdr") .field("bv", &self.bv) .field("xcomp_bv", &self.xcomp_bv) - // FIXME: .field("_reserved", &field._reserved) + // FIXME(debug): .field("_reserved", &field._reserved) .finish() } } @@ -162,7 +162,7 @@ cfg_if! { f.debug_struct("savefpu") .field("fp_fxsave", &self.fp_fxsave) .field("fp_xstate", &self.fp_xstate) - // FIXME: .field("_fp_ymm", &field._fp_ymm) + // FIXME(debug): .field("_fp_ymm", &field._fp_ymm) .finish() } } 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 291d78393fe9d..9bcc2717c7bd1 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -308,7 +308,7 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: crate::sigset_t, __private: [u8; 512], - // FIXME(linux): the shadow stack field requires glibc >= 2.28. + // FIXME(glibc): the shadow stack field requires glibc >= 2.28. // Re-add once we drop compatibility with glibc versions older than // 2.28. // diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index f58eccca4edb3..4ae82af9c5d22 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -286,7 +286,7 @@ pub const SYS_clock_settime: c_int = 112; pub const SYS_clone: c_int = 220; pub const SYS_close: c_int = 57; pub const SYS_connect: c_int = 203; -pub const SYS_copy_file_range: c_int = -1; // FIXME(musl) +pub const SYS_copy_file_range: c_int = -1; // FIXME(hexagon) pub const SYS_creat: c_int = 1064; pub const SYS_delete_module: c_int = 106; pub const SYS_dup2: c_int = 1041; diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index b6850da000d34..c1457d631acf1 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -806,7 +806,7 @@ cfg_if! { f.debug_struct("sockaddr_un") .field("sun_len", &self.sun_len) .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -1015,11 +1015,11 @@ cfg_if! { impl fmt::Debug for utsname { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) + // FIXME(debug): .field("sysname", &self.sysname) + // FIXME(debug): .field("nodename", &self.nodename) + // FIXME(debug): .field("release", &self.release) + // FIXME(debug): .field("version", &self.version) + // FIXME(debug): .field("machine", &self.machine) .finish() } } @@ -1095,7 +1095,7 @@ cfg_if! { .field("ss_family", &self.ss_family) .field("__ss_pad1", &self.__ss_pad1) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) + // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) .finish() } } diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 3a335357d6b6b..dbcc7f44e4437 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -589,7 +589,7 @@ cfg_if! { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("sockaddr_un") .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) + // FIXME(debug): .field("sun_path", &self.sun_path) .finish() } } @@ -632,11 +632,11 @@ cfg_if! { impl fmt::Debug for utsname { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) + // FIXME(debug): .field("sysname", &self.sysname) + // FIXME(debug): .field("nodename", &self.nodename) + // FIXME(debug): .field("release", &self.release) + // FIXME(debug): .field("version", &self.version) + // FIXME(debug): .field("machine", &self.machine) .finish() } } @@ -662,7 +662,7 @@ cfg_if! { impl fmt::Debug for fd_set { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("fd_set") - // FIXME: .field("fds_bits", &self.fds_bits) + // FIXME(debug): .field("fds_bits", &self.fds_bits) .finish() } } @@ -691,7 +691,7 @@ cfg_if! { .field("ss_family", &self.ss_family) .field("__ss_pad1", &self.__ss_pad1) .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) + // FIXME(debug): .field("__ss_pad2", &self.__ss_pad2) .finish() } } @@ -740,7 +740,7 @@ cfg_if! { && self.si_code == other.si_code && self.si_errno == other.si_errno { - // FIXME: The `si_pad` field in the 64-bit version of the struct is ignored + // FIXME(solarish): The `si_pad` field in the 64-bit version of the struct is ignored // (for now) when doing comparisons. let field_count = self.data_field_count(); @@ -760,7 +760,7 @@ cfg_if! { .field("si_signo", &self.si_signo) .field("si_code", &self.si_code) .field("si_errno", &self.si_errno) - // FIXME: .field("__pad", &self.__pad) + // FIXME(debug): .field("__pad", &self.__pad) .finish() } } @@ -770,7 +770,7 @@ cfg_if! { self.si_code.hash(state); self.si_errno.hash(state); - // FIXME: The `si_pad` field in the 64-bit version of the struct is ignored + // FIXME(solarish): The `si_pad` field in the 64-bit version of the struct is ignored // (for now) when doing hashing. let field_count = self.data_field_count(); @@ -803,7 +803,7 @@ cfg_if! { .field("sdl_nlen", &self.sdl_nlen) .field("sdl_alen", &self.sdl_alen) .field("sdl_slen", &self.sdl_slen) - // FIXME: .field("sdl_data", &self.sdl_data) + // FIXME(debug): .field("sdl_data", &self.sdl_data) .finish() } } @@ -853,7 +853,7 @@ cfg_if! { impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { - // FIXME: self._q == other._q || + // FIXME(solarish): self._q == other._q || self._l == other._l } } @@ -862,7 +862,7 @@ cfg_if! { impl hash::Hash for pad128_t { fn hash(&self, state: &mut H) { unsafe { - // FIXME: state.write_i64(self._q as i64); + // FIXME(solarish): state.write_i64(self._q as i64); self._l.hash(state); } } @@ -870,7 +870,7 @@ cfg_if! { impl PartialEq for upad128_t { fn eq(&self, other: &upad128_t) -> bool { unsafe { - // FIXME: self._q == other._q || + // FIXME(solarish): self._q == other._q || self._l == other._l } } @@ -879,7 +879,7 @@ cfg_if! { impl hash::Hash for upad128_t { fn hash(&self, state: &mut H) { unsafe { - // FIXME: state.write_i64(self._q as i64); + // FIXME(solarish): state.write_i64(self._q as i64); self._l.hash(state); } } From 1d231c33c7a92c30bdc2cd737372ed89c8d09f05 Mon Sep 17 00:00:00 2001 From: Tobias Heider Date: Tue, 25 Feb 2025 14:16:31 +0000 Subject: [PATCH 14/23] bsd: add devname(3) (backport ) (cherry picked from commit d27a2840b26ebd591858653bff3b684d40256721) --- libc-test/semver/apple.txt | 1 + libc-test/semver/dragonfly.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + src/unix/bsd/mod.rs | 2 ++ 6 files changed, 7 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 1b278d66a15b5..33f3682d36262 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1924,6 +1924,7 @@ cpu_type_t ctime ctime_r ctl_info +devname difftime dirfd dirname diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index c197a2edac65b..1e6a5f4791cfd 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1303,6 +1303,7 @@ cpuctl_cpuid_count_args_t cpuctl_msr_args_t cpuctl_update_args_t daemon +devname devname_r difftime dirfd diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index a5a9f9befb9d9..96b4c19b53fb7 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1907,6 +1907,7 @@ cpuset_setid cpusetid_t daemon dallocx +devname devname_r difftime dirfd diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index faeb32e76862e..7c914ebbe9fed 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1255,6 +1255,7 @@ clock_settime cmsghdr consttime_memequal daemon +devname difftime dirfd dirname diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index e09df52bb4c1b..74f7ec3183e3b 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1070,6 +1070,7 @@ clock_getres clock_settime cmsghdr daemon +devname difftime dirfd dirname diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index bddb68c8b400a..674fdc088d2b9 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -965,6 +965,8 @@ extern "C" { timeptr: *const crate::tm, locale: crate::locale_t, ) -> size_t; + + pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; } cfg_if! { From df5cd47764b35dff63900cbd8404d27055cf3d7b Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 23 Jan 2025 14:55:21 -0500 Subject: [PATCH 15/23] Use sa_sigaction instead the union for AIX. (backport ) (cherry picked from commit fcb9df0feecfd2aa3cbeda0501dbcd6bf0c9d872) --- src/unix/aix/mod.rs | 54 +++------------------------------------------ 1 file changed, 3 insertions(+), 51 deletions(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index d158ab86c8a9b..a43fcd104748c 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -533,20 +533,15 @@ s! { pub it_interval: crate::timespec, pub it_value: crate::timespec, } -} - -s_no_extra_traits! { - pub union __sigaction_sa_union { - pub __su_handler: extern "C" fn(c: c_int), - pub __su_sigaction: extern "C" fn(c: c_int, info: *mut siginfo_t, ptr: *mut c_void), - } pub struct sigaction { - pub sa_union: __sigaction_sa_union, + pub sa_sigaction: crate::sighandler_t, // FIXME(union): this field is actually a union pub sa_mask: sigset_t, pub sa_flags: c_int, } +} +s_no_extra_traits! { pub union __poll_ctl_ext_u { pub addr: *mut c_void, pub data32: u32, @@ -565,49 +560,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __sigaction_sa_union { - fn eq(&self, other: &__sigaction_sa_union) -> bool { - unsafe { - self.__su_handler == other.__su_handler - && self.__su_sigaction == other.__su_sigaction - } - } - } - impl Eq for __sigaction_sa_union {} - impl hash::Hash for __sigaction_sa_union { - fn hash(&self, state: &mut H) { - unsafe { - self.__su_handler.hash(state); - self.__su_sigaction.hash(state); - } - } - } - - impl PartialEq for sigaction { - fn eq(&self, other: &sigaction) -> bool { - self.sa_mask == other.sa_mask - && self.sa_flags == other.sa_flags - && self.sa_union == other.sa_union - } - } - impl Eq for sigaction {} - impl fmt::Debug for sigaction { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("sigaction") - .field("sa_union", &self.sa_union) - .field("sa_mask", &self.sa_mask) - .field("sa_flags", &self.sa_flags) - .finish() - } - } - impl hash::Hash for sigaction { - fn hash(&self, state: &mut H) { - self.sa_union.hash(state); - self.sa_mask.hash(state); - self.sa_flags.hash(state); - } - } - impl PartialEq for __poll_ctl_ext_u { fn eq(&self, other: &__poll_ctl_ext_u) -> bool { unsafe { From 867fc9fbbcd2eacaf03bf544016527c5410f8c08 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 26 Feb 2025 13:01:01 -0800 Subject: [PATCH 16/23] solarish: define `IP_BOUND_IF` and `IPV6_BOUND_IF` These socket options are currently defined only on macOS and friends, but they exist on illumos and Solaris as well. This commit defines these socket options on solarish operating systems. On Solaris, see the man page [`ip(7P)`]. I'd like to provide a link to the illumos manual pages, but apparently https://illumos.org/man seems to be impacted by today's AWS outage. The constants are defined in `/usr/include/netinet/in.h`: ```console eliza@atrium ~ $ uname -a SunOS atrium 5.11 helios-2.0.22827 i86pc i386 i86pc eliza@atrium ~ $ rg 'IP(V6)?_BOUND_IF' /usr/include /usr/include/netinet/in.h 978:#define IP_BOUND_IF 0x41 /* bind socket to an ifindex */ 1311:#define IPV6_BOUND_IF 0x41 /* bind to an ifindex */ ``` [`ip(7P)`]: https://docs.oracle.com/cd/E86824_01/html/E54777/ip-7p.html - [x] Relevant tests in `libc-test/semver` have been updated - [x] No placeholder or unstable values like `*LAST` or `*MAX` are included (see [#3131](https://github.com/rust-lang/libc/issues/3131)) - [x] Tested locally (`cd libc-test && cargo test --target mytarget`); especially relevant for platforms that may not be checked in CI (backport ) (cherry picked from commit 885148d575cac3dd8473369271657fd425c3e300) --- libc-test/semver/solarish.txt | 2 ++ src/unix/solarish/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index f8380fd02936b..b02baab0efac2 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -1,10 +1,12 @@ AIO_ALLDONE AIO_CANCELED AIO_NOTCANCELED +IPV6_BOUND_IF IPV6_DONTFRAG IPV6_PKTINFO IPV6_RECVTCLASS IPV6_TCLASS +IP_BOUND_IF IP_DONTFRAG IP_PKTINFO IP_TOS diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index dbcc7f44e4437..65aaccec2ba96 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1148,6 +1148,7 @@ pub const IPV6_DONTFRAG: c_int = 0x21; pub const IPV6_SEC_OPT: c_int = 0x22; pub const IPV6_TCLASS: c_int = 0x26; pub const IPV6_V6ONLY: c_int = 0x27; +pub const IPV6_BOUND_IF: c_int = 0x41; cfg_if! { if #[cfg(target_pointer_width = "64")] { @@ -1691,6 +1692,7 @@ pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 23; pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 24; pub const IP_BLOCK_SOURCE: c_int = 21; pub const IP_UNBLOCK_SOURCE: c_int = 22; +pub const IP_BOUND_IF: c_int = 0x41; // These TCP socket options are common between illumos and Solaris, while higher // numbers have generally diverged: From 44f1f92025d2cc574500a1c5117f06833d82568a Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 19 Jan 2025 13:14:14 +0000 Subject: [PATCH 17/23] adding if_nameindex/if_freenameindex support for Android. [ref](https://android.googlesource.com/platform/bionic/+/master/libc/include/net/if.h#52) close GH-4246 (backport ) (cherry picked from commit 32821d48836036550dad8f0660b7527ffdc2ac08) --- libc-test/build.rs | 5 +++++ libc-test/semver/android.txt | 2 ++ src/unix/linux_like/android/mod.rs | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 994e359d49f79..e02fcbe106122 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1906,6 +1906,8 @@ fn test_android(target: &str) { // FIXME(android): "'__uint128' undeclared" in C "__uint128" => true, + // Added in API level 24 + "if_nameindex" => true, _ => false, } @@ -2152,6 +2154,9 @@ fn test_android(target: &str) { | "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower" | "toupper" => true, + // Added in API level 24 + "if_nameindex" | "if_freenameindex" => true, + _ => false, } }); diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index a60cd024f2040..c62b76b39a938 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3382,7 +3382,9 @@ group hostent id_t idtype_t +if_freenameindex if_indextoname +if_nameindex if_nametoindex ifaddrs ifconf diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index af76f0307f8a0..ba9527c01ec2c 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -517,6 +517,11 @@ s! { pub ifr6_prefixlen: u32, pub ifr6_ifindex: c_int, } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } } s_no_extra_traits! { @@ -4136,6 +4141,9 @@ extern "C" { newpath: *const c_char, flags: c_uint, ) -> c_int; + + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); } cfg_if! { From 2aabbf03958074908a4de9fa8bade1a2e8a43165 Mon Sep 17 00:00:00 2001 From: Tobias Heider Date: Sun, 2 Mar 2025 17:47:54 +0000 Subject: [PATCH 18/23] closefrom: add NetBSD, OpenBSD, DragonflyBSD NetBSD, OpenBSD and DragonFly return c_int, FreeBSD returns void, so we can't just add it in freebsdlike. Apple doesn't seem to support closefrom at all at this point. (backport ) (cherry picked from commit 8512ab4fed718fae6555838389d95d666d0536ed) --- libc-test/semver/dragonfly.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + src/unix/bsd/freebsdlike/dragonfly/mod.rs | 2 ++ src/unix/bsd/netbsdlike/mod.rs | 2 ++ 5 files changed, 7 insertions(+) diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 1e6a5f4791cfd..20efcf664696a 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1296,6 +1296,7 @@ clock_getcpuclockid clock_getres clock_nanosleep clock_settime +closefrom cmsgcred cmsghdr cpuctl_cpuid_args_t diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 7c914ebbe9fed..d9e1b66c233a4 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1252,6 +1252,7 @@ clearerr clock_getres clock_nanosleep clock_settime +closefrom cmsghdr consttime_memequal daemon diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 74f7ec3183e3b..a340a83a92712 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1068,6 +1068,7 @@ chroot clearerr clock_getres clock_settime +closefrom cmsghdr daemon devname diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index a8c253bb976ac..5dbe69e564b33 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1702,6 +1702,8 @@ extern "C" { mntvbufp: *mut *mut crate::statvfs, flags: c_int, ) -> c_int; + + pub fn closefrom(lowfd: c_int) -> c_int; } #[link(name = "rt")] diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 7e5fa2ca87ef5..dfd58d75b74ae 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -861,6 +861,8 @@ extern "C" { flags: c_int, timeout: *mut crate::timespec, ) -> c_int; + + pub fn closefrom(lowfd: c_int) -> c_int; } cfg_if! { From 8410db8520803fb5c2f349038363cbdb1ad15c6a Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Tue, 25 Feb 2025 20:44:37 +0100 Subject: [PATCH 19/23] Add SysV semaphore constants (backport ) (cherry picked from commit f84f6181c61aa0de121803da72ea6e8ca3097e04) --- libc-test/semver/linux.txt | 11 +++++++++++ src/unix/linux_like/linux/mod.rs | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index af5ded298cb80..e0bca05e22be1 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -885,6 +885,11 @@ GENL_ID_CTRL GENL_MAX_ID GENL_MIN_ID GENL_NAMSIZ +GETALL +GETNCNT +GETPID +GETVAL +GETZCNT GLOB_ABORTED GLOB_APPEND GLOB_DOOFFS @@ -2744,6 +2749,12 @@ SEEK_DATA SEEK_HOLE SELFMAG SEM_FAILED +SEM_INFO +SEM_STAT +SEM_STAT_ANY +SEM_UNDO +SETALL +SETVAL SFD_CLOEXEC SFD_NONBLOCK SHM_EXEC diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index c3c084ed05d99..b36e0891741fa 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3018,6 +3018,19 @@ pub const MSG_NOERROR: c_int = 0o10000; pub const MSG_EXCEPT: c_int = 0o20000; pub const MSG_ZEROCOPY: c_int = 0x4000000; +pub const SEM_UNDO: c_int = 0x1000; + +pub const GETPID: c_int = 11; +pub const GETVAL: c_int = 12; +pub const GETALL: c_int = 13; +pub const GETNCNT: c_int = 14; +pub const GETZCNT: c_int = 15; +pub const SETVAL: c_int = 16; +pub const SETALL: c_int = 17; +pub const SEM_STAT: c_int = 18; +pub const SEM_INFO: c_int = 19; +pub const SEM_STAT_ANY: c_int = 20; + pub const SHM_R: c_int = 0o400; pub const SHM_W: c_int = 0o200; From fd2157c126ad79c896c25a2f0eb3f6fcd812f1f0 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Fri, 28 Feb 2025 16:58:36 +0100 Subject: [PATCH 20/23] linux/mips: Correct values for SI_TIMER, SI_MESGQ, SI_ASYNCIO See arch/mips/include/uapi/asm/siginfo.h (backport ) (cherry picked from commit 1f8474e2e4c34851ad339cf3948e7e5610878232) --- src/unix/linux_like/mod.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index c7ff2aea96e79..1d8f2747ea0ac 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1293,9 +1293,17 @@ pub const SI_LOAD_SHIFT: c_uint = 16; pub const SI_USER: c_int = 0; pub const SI_KERNEL: c_int = 0x80; pub const SI_QUEUE: c_int = -1; -pub const SI_TIMER: c_int = -2; -pub const SI_MESGQ: c_int = -3; -pub const SI_ASYNCIO: c_int = -4; +cfg_if! { + if #[cfg(not(any(target_arch = "mips", target_arch = "mips32r6")))] { + pub const SI_TIMER: c_int = -2; + pub const SI_MESGQ: c_int = -3; + pub const SI_ASYNCIO: c_int = -4; + } else { + pub const SI_TIMER: c_int = -3; + pub const SI_MESGQ: c_int = -4; + pub const SI_ASYNCIO: c_int = -2; + } +} pub const SI_SIGIO: c_int = -5; pub const SI_TKILL: c_int = -6; pub const SI_ASYNCNL: c_int = -60; From 06e704bb829187e32f5cfe58788b046098388341 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 10 Mar 2025 05:40:03 +0000 Subject: [PATCH 21/23] Change the range syntax that is giving `ctest` problems `ctest` is iffy about whether or not it accepts `..=` syntax, and I can't figure out what makes it decide whether or not to accept it and sometimes random changes seem to make things fail, so just replace the syntax. This is simpler anyway, and closer matches the upstream definition [1]. Link: https://github.com/torvalds/linux/blob/80e54e84911a923c40d7bee33a34c1b4be148d7a/Makefile#L1316 [1] (backport ) (cherry picked from commit 1779f14a0ea8bb663e1e220f006f88284fe5e1b3) --- libc-test/test/linux_kernel_version.rs | 13 +++++++------ src/unix/linux_like/mod.rs | 6 +----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/libc-test/test/linux_kernel_version.rs b/libc-test/test/linux_kernel_version.rs index 767b0db257a46..eadc4095bee96 100644 --- a/libc-test/test/linux_kernel_version.rs +++ b/libc-test/test/linux_kernel_version.rs @@ -1,15 +1,16 @@ //! Compare libc's KERNEL_VERSION macro against a specific kernel version. -#[cfg( - target_os = "linux", -)] +#[cfg(target_os = "linux")] mod t { use libc; #[test] fn test_kernel_version() { - unsafe { - assert_eq!(libc::KERNEL_VERSION(6, 0, 0), 393216); - } + assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, 0) }, 393216); + // Check that the patch level saturates + assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, 255) }, 393471); + assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, 256) }, 393471); + assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, 300) }, 393471); + assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, u32::MAX) }, 393471); } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1d8f2747ea0ac..b3e6281f48d28 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1756,11 +1756,7 @@ safe_f! { #[allow(ellipsis_inclusive_range_patterns)] pub {const} fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 { - ((a << 16) + (b << 8)) - + match c { - 0..=255 => c, - _ => 255, - } + ((a << 16) + (b << 8)) + if c > 255 { 255 } else { c } } } From f05012e4ec451eda76697a764d9b7d6846cb75a0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 10 Mar 2025 05:44:50 +0000 Subject: [PATCH 22/23] Remove tests for the `i586-pc-windows-msvc` target Since [1], this target no longer exists so we need to remove it from CI. [1]: https://github.com/rust-lang/rust/pull/137957 (backport ) (cherry picked from commit 33c320a059c3bf9ee11538f7a3430a7b19543823) --- Cargo.toml | 1 - ci/verify-build.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e3b20745500dd..f9c7268f60cc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,6 @@ targets = [ "armv7r-none-eabihf", # FIXME(hexagon): excluded due to duplicate symbol errors # "hexagon-unknown-linux-musl", - "i586-pc-windows-msvc", "i586-unknown-linux-gnu", "i586-unknown-linux-musl", "i686-linux-android", diff --git a/ci/verify-build.sh b/ci/verify-build.sh index ccdc223263641..7ee562312b410 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -192,7 +192,6 @@ armebv7r-none-eabihf \ armv7-wrs-vxworks-eabihf \ armv7r-none-eabi \ armv7r-none-eabihf \ -i586-pc-windows-msvc \ i686-pc-windows-msvc \ i686-unknown-haiku \ i686-unknown-netbsd \ From e7dcb9743a5030a4c0720cf05ef40c7de8bee36f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 10 Mar 2025 06:39:11 +0000 Subject: [PATCH 23/23] Remove the `check_cfg` job check-cfg was stabilized in 1.80, so there is no longer any need to have a specific job and environment variable to enable it only under certain conditions. (backport ) (cherry picked from commit 2065a4a0c64452ee5f2ba2b2182285711a2173ba) --- .github/workflows/ci.yaml | 13 ------------- build.rs | 10 +++------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 964d72d1d4d99..10bd55da62685 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -204,19 +204,6 @@ jobs: export PATH=$HOME/.rust_solaris/bin:$PATH ./ci/run.sh ${{ matrix.target }} - check_cfg: - name: "Check #[cfg]s" - runs-on: ubuntu-24.04 - env: - TOOLCHAIN: nightly - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: ./ci/install-rust.sh - - name: Build with check-cfg - run: LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg - # One job that "summarizes" the success state of this pipeline. This can then be added to branch # protection, rather than having to add each job separately. success: diff --git a/build.rs b/build.rs index 3439208f7e2ce..cf1a2e0da024b 100644 --- a/build.rs +++ b/build.rs @@ -44,7 +44,6 @@ fn main() { let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); - let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 11. @@ -100,12 +99,9 @@ fn main() { // Set unconditionally when ctest is not being invoked. set_cfg("libc_const_extern_fn"); - // check-cfg is a nightly cargo/rustc feature to warn when unknown cfgs are used across the - // codebase. libc can configure it if the appropriate environment variable is passed. Since - // rust-lang/rust enforces it, this is useful when using a custom libc fork there. - // - // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg - if libc_check_cfg { + // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to + // avoid warnings. + if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { if rustc_minor_ver >= 75 { println!("cargo:rustc-check-cfg=cfg({})", cfg);