From 19d25e3b7be9d5edec32440f8f5dc66bc187d871 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Jan 2026 17:32:16 +0000 Subject: [PATCH 01/36] build(deps): bump vmactions/solaris-vm from 1.2.3 to 1.2.6 Bumps [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) from 1.2.3 to 1.2.6. - [Release notes](https://github.com/vmactions/solaris-vm/releases) - [Commits](https://github.com/vmactions/solaris-vm/compare/v1.2.3...v1.2.6) --- updated-dependencies: - dependency-name: vmactions/solaris-vm dependency-version: 1.2.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit df9237d730156a4e04b344fd9987c5935b6fb6e0) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9befcc3e7667..106b28086343 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -272,7 +272,7 @@ jobs: steps: - uses: actions/checkout@v6 - name: test on Solaris - uses: vmactions/solaris-vm@v1.2.3 + uses: vmactions/solaris-vm@v1.2.6 if: contains(matrix.target, 'solaris') with: release: "11.4-gcc" From 19f9b523967603e7e556d00d0b9a123bffc65887 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Mon, 12 Jan 2026 22:20:04 +0100 Subject: [PATCH 02/36] Add MADV_ZERO for macOS (backport ) (cherry picked from commit 297f6ac59902c8ab0e0058f7f320b1c8e540e49e) --- libc-test/semver/apple.txt | 1 + src/unix/bsd/apple/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 09934484f379..fd88c66f313e 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -872,6 +872,7 @@ MADV_NORMAL MADV_RANDOM MADV_SEQUENTIAL MADV_WILLNEED +MADV_ZERO MADV_ZERO_WIRED_PAGES MAP_COPY MAP_FILE diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 2b2737b049f4..8798dc30f804 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2529,6 +2529,7 @@ pub const MADV_ZERO_WIRED_PAGES: c_int = 6; pub const MADV_FREE_REUSABLE: c_int = 7; pub const MADV_FREE_REUSE: c_int = 8; pub const MADV_CAN_REUSE: c_int = 9; +pub const MADV_ZERO: c_int = 11; pub const MINCORE_INCORE: c_int = 0x1; pub const MINCORE_REFERENCED: c_int = 0x2; From 63e61f9f79993bcbb1b80a98b8f53edf84286f94 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 16 Jan 2026 12:51:24 -0700 Subject: [PATCH 03/36] redox: add makedev, major, minor, and fix dev_t (backport ) (cherry picked from commit 76e737e6770fb97b9432600b9432beaf45763cba) --- src/unix/redox/mod.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index b674ea219eb6..9768cbe9e50e 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -6,7 +6,7 @@ pub type blkcnt_t = c_ulong; pub type blksize_t = c_long; pub type clock_t = c_long; pub type clockid_t = c_int; -pub type dev_t = c_long; +pub type dev_t = c_ulonglong; pub type fsblkcnt_t = c_ulong; pub type fsfilcnt_t = c_ulong; pub type ino_t = c_ulonglong; @@ -1162,6 +1162,31 @@ safe_f! { pub const fn WCOREDUMP(status: c_int) -> bool { (status & 0x80) != 0 } + + pub const fn makedev(major: c_uint, minor: c_uint) -> dev_t { + let major = major as dev_t; + let minor = minor as dev_t; + let mut dev = 0; + dev |= (major & 0x00000fff) << 8; + dev |= (major & 0xfffff000) << 32; + dev |= (minor & 0x000000ff) << 0; + dev |= (minor & 0xffffff00) << 12; + dev + } + + pub const fn major(dev: 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: dev_t) -> c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as c_uint + } } extern "C" { From 4b2c13d32f8e18868437683f96b08d96392ae58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 2 Dec 2025 23:26:11 +0100 Subject: [PATCH 04/36] cleanup: Also mark reserved fields as private Padding Some were already done, more were missing (backport ) (cherry picked from commit 2f657a93c52d361a6d463f500e3b894faabacb7e) --- src/fuchsia/mod.rs | 4 ++-- src/unix/aix/mod.rs | 14 +++++++------- src/unix/aix/powerpc64.rs | 6 +++--- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 6 +++--- src/unix/haiku/x86_64.rs | 4 ++-- src/unix/hurd/mod.rs | 4 ++-- src/unix/newlib/vita/mod.rs | 4 ++-- src/unix/nto/mod.rs | 8 ++++---- src/vxworks/mod.rs | 12 ++++++------ 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 376549e96b0a..205d9701ff29 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -326,7 +326,7 @@ s! { pub struct sockaddr_vm { pub svm_family: sa_family_t, - pub svm_reserved1: c_ushort, + svm_reserved1: Padding, pub svm_port: crate::in_port_t, pub svm_cid: c_uint, pub svm_zero: [u8; 4], @@ -895,7 +895,7 @@ s! { pub totalhigh: c_ulong, pub freehigh: c_ulong, pub mem_unit: c_uint, - pub __reserved: [c_char; 256], + __reserved: Padding<[c_char; 256]>, } pub struct sockaddr_un { diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 356d2a0c402d..5642f4d5dfda 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -316,7 +316,7 @@ s! { pub struct xutsname { pub nid: c_uint, - pub reserved: c_int, + reserved: Padding, pub longnid: c_ulonglong, } @@ -367,7 +367,7 @@ s! { pub struct sched_param { pub sched_priority: c_int, pub sched_policy: c_int, - pub sched_reserved: [c_int; 6], + sched_reserved: Padding<[c_int; 6]>, } pub struct stack_t { @@ -464,8 +464,8 @@ s! { pub shm_extshm: c_int, pub shm_pagesize: crate::int64_t, pub shm_lba: crate::uint64_t, - pub shm_reserved0: crate::int64_t, - pub shm_reserved1: crate::int64_t, + shm_reserved0: Padding, + shm_reserved1: Padding, } pub struct stat64 { @@ -487,7 +487,7 @@ s! { pub st_vfs: c_uint, pub st_type: c_uint, pub st_gen: c_uint, - pub st_reserved: [c_uint; 10], + st_reserved: Padding<[c_uint; 10]>, pub st_size: off64_t, } @@ -507,7 +507,7 @@ s! { pub cgid: crate::gid_t, pub mode: mode_t, pub seq: c_ushort, - pub __reserved: c_ushort, + __reserved: Padding, pub key: key_t, } @@ -551,7 +551,7 @@ s! { pub events: c_short, pub fd: c_int, pub u: __poll_ctl_ext_u, - pub reserved64: [u64; 6], + reserved64: Padding<[u64; 6]>, } } diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index a936ddb7e2f9..c6b24964ef20 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -77,7 +77,7 @@ s! { pub st_vfs: c_uint, pub st_type: c_uint, pub st_gen: c_uint, - pub st_reserved: [c_uint; 9], + st_reserved: Padding<[c_uint; 9]>, pub st_padto_ll: c_uint, pub st_size: off_t, } @@ -117,7 +117,7 @@ s! { pub aio_word2: c_int, pub aio_fp: c_int, pub aio_handle: *mut aiocb, - pub aio_reserved: [c_uint; 2], + aio_reserved: Padding<[c_uint; 2]>, pub aio_sigev_tid: c_long, } @@ -191,7 +191,7 @@ s! { pub __ukeys: [c_uint; 2], pub __vsx: crate::__vsx_context_t, pub __tm: crate::__tm_context_t, - pub __reserved: [c_char; 1860], + __reserved: Padding<[c_char; 1860]>, pub __extctx_magic: c_int, } diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index ba2af1327528..4dbc2957960a 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -101,7 +101,7 @@ s! { pub time_low: u32, pub time_mid: u16, pub time_hi_and_version: u16, - pub clock_seq_hi_and_reserved: u8, + clock_seq_hi_and_reserved: Padding, pub clock_seq_low: u8, pub node: [u8; 6], } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 2cce82c5b030..233026cc7837 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -432,7 +432,7 @@ s! { pub time_low: u32, pub time_mid: u16, pub time_hi_and_version: u16, - pub clock_seq_hi_and_reserved: u8, + clock_seq_hi_and_reserved: Padding, pub clock_seq_low: u8, pub node: [u8; _UUID_NODE_LEN], } @@ -559,8 +559,8 @@ s! { pub ksw_used: u_int, pub ksw_total: u_int, pub ksw_flags: c_int, - pub ksw_reserved1: u_int, - pub ksw_reserved2: u_int, + ksw_reserved1: Padding, + ksw_reserved2: Padding, } pub struct nlist { diff --git a/src/unix/haiku/x86_64.rs b/src/unix/haiku/x86_64.rs index 538ae30d438b..4a6921d8d711 100644 --- a/src/unix/haiku/x86_64.rs +++ b/src/unix/haiku/x86_64.rs @@ -12,13 +12,13 @@ s! { pub mscsr_mask: c_uint, pub _fpreg: [[c_uchar; 8]; 16], pub _xmm: [[c_uchar; 16]; 16], - pub _reserved_416_511: [c_uchar; 96], + _reserved_416_511: Padding<[c_uchar; 96]>, } pub struct xstate_hdr { pub bv: c_ulong, pub xcomp_bv: c_ulong, - pub _reserved: [c_uchar; 48], + _reserved: Padding<[c_uchar; 48]>, } pub struct savefpu { diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index e119e4b8c74f..22755f9b9a5a 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -634,8 +634,8 @@ s! { pub __shpid: c_int, pub __type: c_int, pub __flags: c_int, - pub __reserved1: c_uint, - pub __reserved2: c_uint, + __reserved1: Padding, + __reserved2: Padding, } pub struct __pthread_condattr { diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 302601de96af..2742a0424161 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -52,9 +52,9 @@ s! { pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: crate::sa_family_t, - pub __ss_pad1: [u8; 2], + __ss_pad1: Padding<[u8; 2]>, pub __ss_align: i64, - pub __ss_pad2: [u8; 116], + __ss_pad2: Padding<[u8; 116]>, } pub struct sched_param { diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 278b331f86f5..33cd1f705bd0 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -80,7 +80,7 @@ s! { pub struct dirent_extra { pub d_datalen: u16, pub d_type: u16, - pub d_reserved: u32, + d_reserved: Padding, } pub struct stat { @@ -182,14 +182,14 @@ s! { pub struct sched_param { pub sched_priority: c_int, pub sched_curpriority: c_int, - pub reserved: [c_int; 10], + reserved: Padding<[c_int; 10]>, } #[repr(align(8))] pub struct __sched_param { pub __sched_priority: c_int, pub __sched_curpriority: c_int, - pub reserved: [c_int; 10], + reserved: Padding<[c_int; 10]>, } pub struct Dl_info { @@ -236,7 +236,7 @@ s! { pub _Yes: *mut c_char, pub _Nostr: *mut c_char, pub _Yesstr: *mut c_char, - pub _Reserved: [*mut c_char; 8], + _Reserved: Padding<[*mut c_char; 8]>, } // Does not exist in io-sock diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 5f22a7cee729..52567b2ce708 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -234,10 +234,10 @@ s! { pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_attrib: c_uchar, - pub st_reserved1: c_int, - pub st_reserved2: c_int, - pub st_reserved3: c_int, - pub st_reserved4: c_int, + st_reserved1: Padding, + st_reserved2: Padding, + st_reserved3: Padding, + st_reserved4: Padding, } //b_struct__Timespec.h @@ -579,9 +579,9 @@ s_no_extra_traits! { pub struct sockaddr_storage { pub ss_len: c_uchar, pub ss_family: crate::sa_family_t, - pub __ss_pad1: [c_char; _SS_PAD1SIZE], + __ss_pad1: Padding<[c_char; _SS_PAD1SIZE]>, pub __ss_align: i32, - pub __ss_pad2: [c_char; _SS_PAD2SIZE], + __ss_pad2: Padding<[c_char; _SS_PAD2SIZE]>, } pub union sa_u_t { From 0b474fb9bff954e97a909927bc93587abd9dca3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 2 Dec 2025 23:01:54 +0100 Subject: [PATCH 05/36] cleanup: Also padding is padding! As previous commit, but tackle the *padding* fields (backport ) (cherry picked from commit a6e9b51424c467d98a00c4f65fb58c588152c0de) --- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 2 +- src/unix/cygwin/mod.rs | 4 ++-- src/unix/haiku/mod.rs | 2 +- src/unix/hurd/mod.rs | 2 +- src/unix/newlib/arm/mod.rs | 2 +- src/unix/newlib/horizon/mod.rs | 2 +- src/unix/nto/mod.rs | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 4dbc2957960a..e086b8230646 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -140,7 +140,7 @@ s! { pub st_nlink: crate::nlink_t, pub st_dev: crate::dev_t, pub st_mode: crate::mode_t, - pub st_padding1: u16, + st_padding1: Padding, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 9d3a3b55cfea..e190e18f4cd6 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -268,7 +268,7 @@ s! { pub struct _uc_fpxreg { pub significand: [u16; 4], pub exponent: u16, - pub padding: [u16; 3], + padding: Padding<[u16; 3]>, } pub struct _uc_xmmreg { @@ -286,7 +286,7 @@ s! { pub mxcr_mask: u32, pub st: [_uc_fpxreg; 8], pub xmm: [_uc_xmmreg; 16], - pub padding: [u32; 24], + padding: Padding<[u32; 24]>, } #[repr(align(16))] diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 0668f27a48d7..87caa545c183 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -371,7 +371,7 @@ s! { pub struct sem_t { pub type_: i32, pub named_sem_id: i32, // actually a union with unnamed_sem (i32) - pub padding: [i32; 2], + padding: Padding<[i32; 2]>, } pub struct ucred { diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 22755f9b9a5a..f03347f7bb5b 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -285,7 +285,7 @@ s! { pub struct sockaddr_storage { pub ss_len: c_uchar, pub ss_family: sa_family_t, - pub __ss_padding: [c_char; 122usize], + __ss_padding: Padding<[c_char; 122usize]>, pub __ss_align: __uint32_t, } diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index 26f3d52436b8..9b5978fc538c 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -26,7 +26,7 @@ s! { pub struct sockaddr_storage { pub ss_family: crate::sa_family_t, - pub __ss_padding: [u8; 26], + __ss_padding: Padding<[u8; 26]>, } } diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index ac500b1c79a3..5890a930f38f 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -41,7 +41,7 @@ s! { pub struct sockaddr_storage { pub ss_family: crate::sa_family_t, - pub __ss_padding: [c_char; 26usize], + __ss_padding: Padding<[c_char; 26usize]>, } pub struct sockaddr_in { diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 33cd1f705bd0..44ec4eba94da 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -694,9 +694,9 @@ s! { pub struct sigevent { pub sigev_notify: c_int, - pub __padding1: c_int, + __padding1: Padding, pub sigev_signo: c_int, // union - pub __padding2: c_int, + __padding2: Padding, pub sigev_value: crate::sigval, __sigev_un2: usize, // union } From a29b577ca74296ed6691e9e68bb533d9876e83fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 3 Dec 2025 00:01:37 +0100 Subject: [PATCH 06/36] cleanup: Set unused fields as private Padding (backport ) (cherry picked from commit 0cfa0b29632c8b9e5623c1641007bf87c17970da) --- src/unix/aix/mod.rs | 2 +- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 4 ++-- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- src/unix/hurd/mod.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 5642f4d5dfda..b114a780896a 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -442,7 +442,7 @@ s! { pub re_esub: [*mut c_void; 24], pub re_map: *mut c_uchar, pub __maxsub: c_int, - pub __unused: [*mut c_void; 34], + __unused: Padding<[*mut c_void; 34]>, } pub struct rlimit64 { diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index e086b8230646..60e7989bbde3 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -417,14 +417,14 @@ s! { pub ut_line: [c_char; 32], pub ut_host: [c_char; 256], - pub ut_unused: [u8; 16], + ut_unused: Padding<[u8; 16]>, pub ut_session: u16, pub ut_type: u16, pub ut_pid: crate::pid_t, ut_exit: exit_status, ut_ss: crate::sockaddr_storage, pub ut_tv: crate::timeval, - pub ut_unused2: [u8; 16], + ut_unused2: Padding<[u8; 16]>, } pub struct lastlogx { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index ecc6c8f1c7e1..642582868e7f 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -359,7 +359,7 @@ s! { } pub struct uucred { - pub cr_unused: c_ushort, + cr_unused: Padding, pub cr_uid: crate::uid_t, pub cr_gid: crate::gid_t, pub cr_ngroups: c_short, diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index f03347f7bb5b..03d0f146089d 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3330,8 +3330,8 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __shpid: 0, __type: PTHREAD_MUTEX_TIMED as c_int, __flags: 0, - __reserved1: 0, - __reserved2: 0, + __reserved1: Padding::uninit(), + __reserved2: Padding::uninit(), }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, From 38bdf647d5f7975a899c1439643da9f78c993756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 2 Dec 2025 22:54:13 +0100 Subject: [PATCH 07/36] cleanup: Mark the alignment fields to private We have some leftovers of alignment data that is exposed (backport ) (cherry picked from commit ec2139e3dae1fd53dc01234c3634b592ff382fd7) --- src/unix/hurd/mod.rs | 2 +- src/unix/newlib/vita/mod.rs | 2 +- src/vxworks/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 03d0f146089d..7e1cbc3c3871 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -286,7 +286,7 @@ s! { pub ss_len: c_uchar, pub ss_family: sa_family_t, __ss_padding: Padding<[c_char; 122usize]>, - pub __ss_align: __uint32_t, + __ss_align: __uint32_t, } pub struct sockaddr_at { diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 2742a0424161..95abf9076a05 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -53,7 +53,7 @@ s! { pub ss_len: u8, pub ss_family: crate::sa_family_t, __ss_pad1: Padding<[u8; 2]>, - pub __ss_align: i64, + __ss_align: i64, __ss_pad2: Padding<[u8; 116]>, } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 52567b2ce708..d5067250e502 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -580,7 +580,7 @@ s_no_extra_traits! { pub ss_len: c_uchar, pub ss_family: crate::sa_family_t, __ss_pad1: Padding<[c_char; _SS_PAD1SIZE]>, - pub __ss_align: i32, + __ss_align: i32, __ss_pad2: Padding<[c_char; _SS_PAD2SIZE]>, } From 297f1cf1491cb5279eae42ba6e904d8dc2500f78 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Tue, 20 Jan 2026 08:31:09 -0500 Subject: [PATCH 08/36] Make 'tv_nsec' of 'struct timespec' as type 'c_long' and use 'struct st_timespec' in 'struct stat' and 'struct stat64' to be consistent with AIX headers. (backport ) (cherry picked from commit a44a76ef02388324b38884167020428aa5c29f68) --- libc-test/build.rs | 16 ---------------- src/unix/aix/mod.rs | 15 +++------------ src/unix/aix/powerpc64.rs | 6 +++--- src/unix/mod.rs | 2 +- 4 files changed, 7 insertions(+), 32 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 66cced85f5a6..96f561a191f4 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5667,16 +5667,6 @@ fn test_aix(target: &str) { // header does not define a separate standalone union type for it. ("ld_info", "_file") => true, - // On AIX, when _ALL_SOURCE is defined, the types of the following fields - // differ from those used when _XOPEN_SOURCE is defined. The former uses - // 'struct st_timespec', while the latter uses 'struct timespec'. - ("stat", "st_atim") => true, - ("stat", "st_mtim") => true, - ("stat", "st_ctim") => true, - ("stat64", "st_atim") => true, - ("stat64", "st_mtim") => true, - ("stat64", "st_ctim") => true, - _ => false, } }); @@ -5689,12 +5679,6 @@ fn test_aix(target: &str) { // The field 'data' is actually a unnamed union in the AIX header. "pollfd_ext" if field.ident() == "data" => true, - // On AIX, declares 'tv_nsec' as 'long', but the - // underlying system calls return a 32-bit value in both 32-bit - // and 64-bit modes. In the 'libc' crate it is declared as 'i32' - // to match the system call. Skip this field. - "timespec" if field.ident() == "tv_nsec" => true, - _ => false, } }); diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index b114a780896a..71d041f7b52f 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -266,15 +266,6 @@ s! { pub tv_nsec: c_int, } - // On AIX, declares 'tv_nsec' as 'long', but the underlying - // system calls return a 4-byte value in both 32-bit and 64-bit modes. - // It is declared as 'c_int' here to avoid using the other undefined 4 - // bytes in the 64-bit mode. - pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_int, - } - pub struct statfs64 { pub f_version: c_int, pub f_type: c_int, @@ -478,9 +469,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: dev_t, pub st_ssize: c_int, - pub st_atim: crate::timespec, - pub st_mtim: crate::timespec, - pub st_ctim: crate::timespec, + pub st_atim: st_timespec, + pub st_mtim: st_timespec, + pub st_ctim: st_timespec, pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, pub st_vfstype: c_int, diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index c6b24964ef20..0862cbf854d3 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -68,9 +68,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_ssize: c_int, - pub st_atim: crate::timespec, - pub st_mtim: crate::timespec, - pub st_ctim: crate::timespec, + pub st_atim: crate::st_timespec, + pub st_mtim: crate::st_timespec, + pub st_ctim: crate::st_timespec, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_vfstype: c_int, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 227334a9d4fb..1b74684cbbb2 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -69,7 +69,7 @@ s! { // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 - #[cfg(all(not(target_env = "gnu"), not(target_os = "aix")))] + #[cfg(not(target_env = "gnu"))] pub struct timespec { pub tv_sec: time_t, #[cfg(all(musl32_time64, target_endian = "big"))] From be1fe2d90554b1507a58ff4f42bdef6ed94e60c0 Mon Sep 17 00:00:00 2001 From: Sergey Ulanov Date: Thu, 22 Jan 2026 13:50:56 -0800 Subject: [PATCH 09/36] Update SO_* constants for Fuchsia Added SO_COOKIE, SO_TIMESTAMPNS and SO_FUCHSIA_MARK. (backport ) (cherry picked from commit a940a7d6f4c2b9df9ac7012e8388ee8fee782b6d) --- libc-test/semver/fuchsia.txt | 3 +++ src/fuchsia/mod.rs | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index 12f67d8b4c60..88bd6db31a7e 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -956,7 +956,9 @@ SO_BINDTODEVICE SO_BINDTOIFINDEX SO_BSDCOMPAT SO_BUSY_POLL +SO_COOKIE SO_DOMAIN +SO_FUCHSIA_MARK SO_MARK SO_NO_CHECK SO_ORIGINAL_DST @@ -969,6 +971,7 @@ SO_RCVBUFFORCE SO_RXQ_OVFL SO_SNDBUFFORCE SO_TIMESTAMP +SO_TIMESTAMPNS SPLICE_F_GIFT SPLICE_F_MORE SPLICE_F_MOVE diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 205d9701ff29..b5fb673b7ea1 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -2684,14 +2684,6 @@ pub const B3000000: crate::speed_t = 0o010015; pub const B3500000: crate::speed_t = 0o010016; pub const B4000000: crate::speed_t = 0o010017; -pub const SO_BINDTODEVICE: c_int = 25; -pub const SO_TIMESTAMP: c_int = 29; -pub const SO_MARK: c_int = 36; -pub const SO_RXQ_OVFL: c_int = 40; -pub const SO_PEEK_OFF: c_int = 42; -pub const SO_BUSY_POLL: c_int = 46; -pub const SO_BINDTOIFINDEX: c_int = 62; - pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; @@ -2840,11 +2832,21 @@ pub const SO_RCVLOWAT: c_int = 18; pub const SO_SNDLOWAT: c_int = 19; pub const SO_RCVTIMEO: c_int = 20; pub const SO_SNDTIMEO: c_int = 21; +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_TIMESTAMP: c_int = 29; pub const SO_ACCEPTCONN: c_int = 30; pub const SO_SNDBUFFORCE: c_int = 32; pub const SO_RCVBUFFORCE: c_int = 33; +pub const SO_TIMESTAMPNS: c_int = 35; +pub const SO_MARK: c_int = 36; pub const SO_PROTOCOL: c_int = 38; pub const SO_DOMAIN: c_int = 39; +pub const SO_RXQ_OVFL: c_int = 40; +pub const SO_PEEK_OFF: c_int = 42; +pub const SO_BUSY_POLL: c_int = 46; +pub const SO_COOKIE: c_int = 57; +pub const SO_BINDTOIFINDEX: c_int = 62; +pub const SO_FUCHSIA_MARK: c_int = 10000; pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000004; From b901b678505dd26f2da0b24a068882d6a97c150a Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 19 Jan 2026 13:26:39 -0600 Subject: [PATCH 10/36] qurt: Fix type visibility and defs - Removed duplicate type definitions from legacy qurt module that conflicted with new module (socklen_t, in_addr_t, timespec, timeval, stat, tm, etc.) - Add crate:: prefix to type references in submodules - Add public re-exports for submodule contents (errno, fcntl, pthread, etc.) Type/define fixes: ssize_t, time_t, dev_t, ino_t, stat struct, dirent, DIR Added items from QuRT SDK: clock(), strptime(), _SC_NPROCESSORS_ONLN (backport ) (cherry picked from commit 9934c04c2396ac29ca509e67346b3133f51402d2) --- src/new/mod.rs | 4 +- src/new/qurt/dlfcn.rs | 26 +++ src/new/qurt/fcntl.rs | 5 +- src/new/qurt/mod.rs | 238 ++++++++++++++++++++++++-- src/new/qurt/pthread.rs | 23 +-- src/new/qurt/signal.rs | 58 ++++++- src/new/qurt/stdio.rs | 5 - src/new/qurt/sys/mman.rs | 55 ++++++ src/new/qurt/sys/mod.rs | 2 + src/new/qurt/sys/sched.rs | 24 +++ src/new/qurt/sys/stat.rs | 6 - src/new/qurt/time.rs | 26 +-- src/new/qurt/unistd.rs | 230 +++++++++++++++++++++++--- src/qurt/hexagon.rs | 340 -------------------------------------- src/qurt/mod.rs | 334 +------------------------------------ 15 files changed, 615 insertions(+), 761 deletions(-) create mode 100644 src/new/qurt/dlfcn.rs create mode 100644 src/new/qurt/sys/mman.rs create mode 100644 src/new/qurt/sys/sched.rs delete mode 100644 src/qurt/hexagon.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index 2e6b451a9917..078200ae6258 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -103,8 +103,8 @@ cfg_if! { mod openbsd; pub(crate) use openbsd::*; } else if #[cfg(target_os = "qurt")] { - mod qurt; - pub(crate) use qurt::*; + pub mod qurt; + pub use qurt::*; } else if #[cfg(target_os = "redox")] { mod redox; // pub(crate) use redox::*; diff --git a/src/new/qurt/dlfcn.rs b/src/new/qurt/dlfcn.rs new file mode 100644 index 000000000000..668fcab54c2a --- /dev/null +++ b/src/new/qurt/dlfcn.rs @@ -0,0 +1,26 @@ +//! Header: `dlfcn.h` +//! +//! Dynamic linking functions and constants from Hexagon toolchain. + +use crate::prelude::*; + +// Values for dlopen `mode` +pub const RTLD_LAZY: c_int = 1; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_LOCAL: c_int = 0x200; + +// Compatibility constant +pub const DL_LAZY: c_int = RTLD_LAZY; + +// Special handles +pub const RTLD_NEXT: *mut c_void = -1isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void; +pub const RTLD_SELF: *mut c_void = -3isize as *mut c_void; + +extern "C" { + pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; + pub fn dlclose(handle: *mut c_void) -> c_int; + pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; + pub fn dlerror() -> *mut c_char; +} diff --git a/src/new/qurt/fcntl.rs b/src/new/qurt/fcntl.rs index aa94ffc94ed5..0287292ad2f8 100644 --- a/src/new/qurt/fcntl.rs +++ b/src/new/qurt/fcntl.rs @@ -21,6 +21,9 @@ pub const O_NONBLOCK: c_int = 0x0800; pub const O_SYNC: c_int = 0x1000; pub const O_FSYNC: c_int = O_SYNC; pub const O_DSYNC: c_int = 0x1000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_CLOEXEC: c_int = 0x80000; // fcntl() commands pub const F_DUPFD: c_int = 0; @@ -31,6 +34,7 @@ pub const F_SETFL: c_int = 4; pub const F_GETLK: c_int = 5; pub const F_SETLK: c_int = 6; pub const F_SETLKW: c_int = 7; +pub const F_DUPFD_CLOEXEC: c_int = 1030; // File descriptor flags pub const FD_CLOEXEC: c_int = 1; @@ -43,7 +47,6 @@ pub const F_UNLCK: c_int = 2; // Functions extern "C" { pub fn open(pathname: *const c_char, flags: c_int, ...) -> c_int; - pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; pub fn creat(pathname: *const c_char, mode: mode_t) -> c_int; pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; } diff --git a/src/new/qurt/mod.rs b/src/new/qurt/mod.rs index b6e1fbbb8214..456b715f019e 100644 --- a/src/new/qurt/mod.rs +++ b/src/new/qurt/mod.rs @@ -6,12 +6,12 @@ use crate::prelude::*; -// Basic C types for QRT +// Basic C types for QuRT pub type intptr_t = isize; pub type uintptr_t = usize; pub type ptrdiff_t = isize; pub type size_t = uintptr_t; -pub type ssize_t = intptr_t; +pub type ssize_t = c_int; // Process and system types pub type pid_t = c_int; @@ -19,15 +19,15 @@ pub type uid_t = c_uint; pub type gid_t = c_uint; // Time types -pub type time_t = c_longlong; +pub type time_t = c_long; pub type suseconds_t = c_long; pub type useconds_t = c_ulong; pub type clockid_t = c_int; pub type timer_t = *mut c_void; // File system types -pub type dev_t = c_ulong; -pub type ino_t = c_ulong; +pub type dev_t = c_ulonglong; +pub type ino_t = c_ulonglong; pub type mode_t = c_uint; pub type nlink_t = c_uint; pub type off_t = c_long; @@ -83,7 +83,20 @@ pub type va_list = *mut c_char; // Additional missing types pub type c_schar = i8; -// Division result types +// Wide character type (hexagon-specific) +pub type wchar_t = u32; + +// Error type (compatible with std expectations) +pub type errno_t = c_int; + +// Resource limit type (for compatibility, not fully supported on QuRT) +pub type rlim_t = c_ulong; + +// Terminal types (for compatibility, not fully supported on QuRT) +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; + +// Division result types and structures s! { pub struct div_t { pub quot: c_int, @@ -105,12 +118,8 @@ s! { pub st_ino: ino_t, pub st_mode: mode_t, pub st_nlink: nlink_t, - pub st_uid: uid_t, - pub st_gid: gid_t, pub st_rdev: dev_t, pub st_size: off_t, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, pub st_atime: time_t, pub st_mtime: time_t, pub st_ctime: time_t, @@ -143,13 +152,197 @@ s! { pub it_value: timespec, } - pub struct sigevent { - pub sigev_notify: c_int, - pub sigev_signo: c_int, - pub sigev_value: c_int, + pub struct dirent { + pub d_ino: c_long, + pub d_name: [c_char; 255], + } + + pub struct DIR { + pub index: c_int, + pub entry: dirent, + } + + // Terminal I/O structure (for compatibility, limited support on QuRT) + pub struct termios { + pub c_iflag: tcflag_t, + pub c_oflag: tcflag_t, + pub c_cflag: tcflag_t, + pub c_lflag: tcflag_t, + pub c_cc: [c_uchar; 32], + pub c_ispeed: speed_t, + pub c_ospeed: speed_t, + } + + // Resource limit structures (for compatibility, limited support on QuRT) + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long, + } + + // File lock structure (for compatibility) + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: pid_t, + } +} + +// Additional pthread constants +pub const PTHREAD_NAME_LEN: c_int = 16; +pub const PTHREAD_MAX_THREADS: c_uint = 512; +pub const PTHREAD_MIN_STACKSIZE: c_int = 512; +pub const PTHREAD_MAX_STACKSIZE: c_int = 1048576; +pub const PTHREAD_DEFAULT_STACKSIZE: c_int = 16384; +pub const PTHREAD_DEFAULT_PRIORITY: c_int = 1; +pub const PTHREAD_SPINLOCK_UNLOCKED: c_int = 0; +pub const PTHREAD_SPINLOCK_LOCKED: c_int = 1; + +// Additional time constants +pub const TIME_CONV_SCLK_FREQ: c_int = 19200000; +pub const CLOCK_MONOTONIC_RAW: clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6; +pub const CLOCK_BOOTTIME: clockid_t = 7; + +// Stdio constants +pub const L_tmpnam: c_uint = 260; +pub const TMP_MAX: c_uint = 25; +pub const FOPEN_MAX: c_uint = 20; + +// Error constants +pub const EOK: c_int = 0; + +// Semaphore constants +pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; + +// Page size constants (hexagon-specific) +pub const PAGESIZE: size_t = 4096; +pub const PAGE_SIZE: size_t = 4096; + +// Directory entry types (hexagon-specific) +pub const DT_UNKNOWN: c_uchar = 0; +pub const DT_FIFO: c_uchar = 1; +pub const DT_CHR: c_uchar = 2; +pub const DT_DIR: c_uchar = 4; +pub const DT_BLK: c_uchar = 6; +pub const DT_REG: c_uchar = 8; +pub const DT_LNK: c_uchar = 10; +pub const DT_SOCK: c_uchar = 12; + +// Directory functions (dirent.h) +extern "C" { + pub fn opendir(name: *const c_char) -> *mut DIR; + pub fn readdir(dirp: *mut DIR) -> *mut dirent; + pub fn closedir(dirp: *const DIR) -> c_int; + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; +} + +// Additional pthread functions +extern "C" { + pub fn pthread_attr_getstack( + attr: *const pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setstack( + attr: *mut pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; +} + +// Additional time functions +extern "C" { + pub fn clock_getcpuclockid(pid: pid_t, clock_id: *mut clockid_t) -> c_int; +} + +// POSIX semaphore functions +extern "C" { + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; } +// Additional stdlib functions +extern "C" { + pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; +} + +// String functions (string.h) +extern "C" { + pub fn strlen(s: *const c_char) -> size_t; + pub fn strcpy(dest: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcat(dest: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncat(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; + pub fn strcoll(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strxfrm(dest: *mut c_char, src: *const c_char, n: size_t) -> size_t; + pub fn strchr(s: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(s: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(s: *const c_char, accept: *const c_char) -> size_t; + pub fn strcspn(s: *const c_char, reject: *const c_char) -> size_t; + pub fn strpbrk(s: *const c_char, accept: *const c_char) -> *mut c_char; + pub fn strstr(haystack: *const c_char, needle: *const c_char) -> *mut c_char; + pub fn strtok(s: *mut c_char, delim: *const c_char) -> *mut c_char; + pub fn strerror(errnum: c_int) -> *mut c_char; + pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void; +} + +// Additional unistd functions +extern "C" { + pub fn fork() -> pid_t; + pub fn execve( + filename: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; +} + +// Character classification functions (ctype.h) +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; +} + +pub(crate) mod dlfcn; pub(crate) mod errno; pub(crate) mod fcntl; pub(crate) mod limits; @@ -161,3 +354,20 @@ pub(crate) mod stdlib; pub(crate) mod sys; pub(crate) mod time; pub(crate) mod unistd; + +// Re-export public items from submodules +pub use dlfcn::*; +pub use errno::*; +pub use fcntl::*; +pub use limits::*; +pub use pthread::*; +pub use semaphore::*; +pub use signal::*; +pub use stdio::*; +pub use stdlib::*; +pub use sys::mman::*; +pub use sys::sched::*; +pub use sys::stat::*; +pub use sys::types::*; +pub use time::*; +pub use unistd::*; diff --git a/src/new/qurt/pthread.rs b/src/new/qurt/pthread.rs index b9859f05380f..543f7874c3dc 100644 --- a/src/new/qurt/pthread.rs +++ b/src/new/qurt/pthread.rs @@ -4,23 +4,6 @@ use super::*; use crate::prelude::*; -use crate::{ - cpu_set_t, - pthread_attr_t, - pthread_barrier_t, - pthread_barrierattr_t, - pthread_cond_t, - pthread_condattr_t, - pthread_key_t, - pthread_mutex_t, - pthread_mutexattr_t, - pthread_once_t, - pthread_rwlock_t, - pthread_rwlockattr_t, - pthread_spinlock_t, - pthread_t, - timespec, -}; // Thread creation attributes pub const PTHREAD_CREATE_JOINABLE: c_int = 0; @@ -41,11 +24,6 @@ pub const PTHREAD_PRIO_PROTECT: c_int = 2; pub const PTHREAD_MIN_PRIORITY: c_int = 0; pub const PTHREAD_MAX_PRIORITY: c_int = 255; -// Scheduling policies -pub const SCHED_OTHER: c_int = 0; -pub const SCHED_FIFO: c_int = 1; -pub const SCHED_RR: c_int = 2; - // Initializer constants pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0xFFFFFFFF; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0xFFFFFFFF; @@ -117,6 +95,7 @@ extern "C" { // Condition variable attributes pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> c_int; // Thread-local storage pub fn pthread_key_create( diff --git a/src/new/qurt/signal.rs b/src/new/qurt/signal.rs index b0180c5aa038..f525fa15ff29 100644 --- a/src/new/qurt/signal.rs +++ b/src/new/qurt/signal.rs @@ -41,13 +41,54 @@ pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; -// Signal mask operations -pub const SIG_BLOCK: c_int = 0; -pub const SIG_UNBLOCK: c_int = 1; -pub const SIG_SETMASK: c_int = 2; +// Signal mask operations (QuRT uses different values than Linux) +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 3; + +// QuRT-specific signal constants +pub const POSIX_MSG: c_int = 7; +pub const POSIX_NOTIF: c_int = 8; +pub const SIGRTMIN: c_int = 10; +pub const SIGRTMAX: c_int = 32; + +// Notification types (from QuRT signal.h) +pub const SIGEV_NONE: c_int = 0; +pub const SIGEV_SIGNAL: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; +pub const SA_SIGINFO: c_int = 1; pub type sighandler_t = size_t; +// Signal structures based on QuRT SDK headers +s! { + pub struct sigval { + pub sival_int: c_int, + pub sival_ptr: *mut c_void, + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: sigval, + pub sigev_notify_function: Option, + pub sigev_notify_attributes: *mut pthread_attr_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_value: sigval, + } + + pub struct sigaction { + pub sa_handler: Option, + pub sa_mask: sigset_t, + pub sa_flags: c_int, + pub sa_sigaction: Option, + } +} + extern "C" { pub fn signal(sig: c_int, handler: sighandler_t) -> sighandler_t; pub fn kill(pid: pid_t, sig: c_int) -> c_int; @@ -64,4 +105,13 @@ extern "C" { pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; pub fn sigpending(set: *mut sigset_t) -> c_int; pub fn sigsuspend(mask: *const sigset_t) -> c_int; + + // QuRT-specific signal functions + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn _sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const timespec, + ) -> c_int; } diff --git a/src/new/qurt/stdio.rs b/src/new/qurt/stdio.rs index fbfc94df66de..7130717764e8 100644 --- a/src/new/qurt/stdio.rs +++ b/src/new/qurt/stdio.rs @@ -3,11 +3,6 @@ use super::*; use crate::prelude::*; -// File position constants -pub const SEEK_SET: c_int = 0; -pub const SEEK_CUR: c_int = 1; -pub const SEEK_END: c_int = 2; - // Buffer size pub const BUFSIZ: c_uint = 1024; pub const FILENAME_MAX: c_uint = 260; diff --git a/src/new/qurt/sys/mman.rs b/src/new/qurt/sys/mman.rs new file mode 100644 index 000000000000..a0a3b3aad8fe --- /dev/null +++ b/src/new/qurt/sys/mman.rs @@ -0,0 +1,55 @@ +//! Header: `sys/mman.h` +//! +//! Memory mapping functions and constants from Hexagon toolchain. + +use super::super::*; +use crate::prelude::*; + +// Memory protection constants +pub const PROT_NONE: c_int = 0x00; +pub const PROT_READ: c_int = 0x01; +pub const PROT_WRITE: c_int = 0x02; +pub const PROT_EXEC: c_int = 0x04; + +// Memory mapping constants +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_ANON: c_int = 0x1000; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_RENAME: c_int = 0x0020; +pub const MAP_NORESERVE: c_int = 0x0040; +pub const MAP_INHERIT: c_int = 0x0080; +pub const MAP_HASSEMAPHORE: c_int = 0x0200; +pub const MAP_TRYFIXED: c_int = 0x0400; +pub const MAP_WIRED: c_int = 0x0800; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +// Memory sync constants +pub const MS_ASYNC: c_int = 0x01; +pub const MS_INVALIDATE: c_int = 0x02; +pub const MS_SYNC: c_int = 0x04; + +// Memory lock constants +pub const MCL_CURRENT: c_int = 0x01; +pub const MCL_FUTURE: c_int = 0x02; + +extern "C" { + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn mlock(addr: *const c_void, len: size_t) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlockall() -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; +} diff --git a/src/new/qurt/sys/mod.rs b/src/new/qurt/sys/mod.rs index 5c4547cb7895..f9ef6a435fb4 100644 --- a/src/new/qurt/sys/mod.rs +++ b/src/new/qurt/sys/mod.rs @@ -1,4 +1,6 @@ //! System headers (`sys/*`) +pub(crate) mod mman; +pub(crate) mod sched; pub(crate) mod stat; pub(crate) mod types; diff --git a/src/new/qurt/sys/sched.rs b/src/new/qurt/sys/sched.rs new file mode 100644 index 000000000000..56fed5ba0089 --- /dev/null +++ b/src/new/qurt/sys/sched.rs @@ -0,0 +1,24 @@ +//! Header: `sys/sched.h` +//! +//! QuRT scheduling parameters and functions. + +use crate::prelude::*; + +// Scheduling policies (from QuRT sys/sched.h) +pub const SCHED_FIFO: c_int = 0; +pub const SCHED_RR: c_int = 1; +pub const SCHED_SPORADIC: c_int = 2; +pub const SCHED_OTHER: c_int = 3; + +s! { + pub struct sched_param { + pub unimplemented: *mut c_void, + pub sched_priority: c_int, + } +} + +extern "C" { + pub fn sched_yield() -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; +} diff --git a/src/new/qurt/sys/stat.rs b/src/new/qurt/sys/stat.rs index 25ffa76c6490..a8ee211eb4e8 100644 --- a/src/new/qurt/sys/stat.rs +++ b/src/new/qurt/sys/stat.rs @@ -33,10 +33,4 @@ pub const S_IXOTH: mode_t = 0o0001; extern "C" { pub fn stat(pathname: *const c_char, statbuf: *mut stat) -> c_int; pub fn fstat(fd: c_int, statbuf: *mut stat) -> c_int; - pub fn lstat(pathname: *const c_char, statbuf: *mut stat) -> c_int; - pub fn chmod(pathname: *const c_char, mode: mode_t) -> c_int; - pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; - pub fn mkdir(pathname: *const c_char, mode: mode_t) -> c_int; - pub fn mkfifo(pathname: *const c_char, mode: mode_t) -> c_int; - pub fn umask(mask: mode_t) -> mode_t; } diff --git a/src/new/qurt/time.rs b/src/new/qurt/time.rs index e3535fd5bd82..ab6f4453dbea 100644 --- a/src/new/qurt/time.rs +++ b/src/new/qurt/time.rs @@ -6,15 +6,12 @@ use crate::prelude::*; // Clock types pub const CLOCK_REALTIME: clockid_t = 0; pub const CLOCK_MONOTONIC: clockid_t = 1; -pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2; -pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3; - -// Timer flags -pub const TIMER_ABSTIME: c_int = 1; +pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 2; +pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 3; extern "C" { - // Time functions pub fn time(tloc: *mut time_t) -> time_t; + pub fn clock() -> clock_t; pub fn difftime(time1: time_t, time0: time_t) -> c_double; pub fn mktime(tm: *mut tm) -> time_t; pub fn gmtime(timep: *const time_t) -> *mut tm; @@ -31,22 +28,7 @@ extern "C" { format: *const c_char, timeptr: *const tm, ) -> size_t; - - // High-resolution time functions + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut tm) -> *mut c_char; pub fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int; - pub fn clock_settime(clk_id: clockid_t, tp: *const timespec) -> c_int; - pub fn clock_getres(clk_id: clockid_t, res: *mut timespec) -> c_int; pub fn nanosleep(req: *const timespec, rem: *mut timespec) -> c_int; - - // Timer functions - pub fn timer_create(clockid: clockid_t, sevp: *mut sigevent, timerid: *mut timer_t) -> c_int; - pub fn timer_delete(timerid: timer_t) -> c_int; - pub fn timer_settime( - timerid: timer_t, - flags: c_int, - new_value: *const itimerspec, - old_value: *mut itimerspec, - ) -> c_int; - pub fn timer_gettime(timerid: timer_t, curr_value: *mut itimerspec) -> c_int; - pub fn timer_getoverrun(timerid: timer_t) -> c_int; } diff --git a/src/new/qurt/unistd.rs b/src/new/qurt/unistd.rs index 3faced7d3030..b973b60e6676 100644 --- a/src/new/qurt/unistd.rs +++ b/src/new/qurt/unistd.rs @@ -19,40 +19,230 @@ pub const SEEK_SET: c_int = 0; pub const SEEK_CUR: c_int = 1; pub const SEEK_END: c_int = 2; +// pathconf constants (from bits/confname.h) +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SOCK_MAXBUF: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_2_SYMLINKS: c_int = 20; + +// sysconf constants (from bits/confname.h) +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EQUIV_CLASS_MAX: c_int = 41; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_CHARCLASS_NAME_MAX: c_int = 45; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_PII: c_int = 53; +pub const _SC_PII_XTI: c_int = 54; +pub const _SC_PII_SOCKET: c_int = 55; +pub const _SC_PII_INTERNET: c_int = 56; +pub const _SC_PII_OSI: c_int = 57; +pub const _SC_POLL: c_int = 58; +pub const _SC_SELECT: c_int = 59; +pub const _SC_UIO_MAXIOV: c_int = 60; +pub const _SC_IOV_MAX: c_int = _SC_UIO_MAXIOV; +pub const _SC_PII_INTERNET_STREAM: c_int = 61; +pub const _SC_PII_INTERNET_DGRAM: c_int = 62; +pub const _SC_PII_OSI_COTS: c_int = 63; +pub const _SC_PII_OSI_CLTS: c_int = 64; +pub const _SC_PII_OSI_M: c_int = 65; +pub const _SC_T_IOV_MAX: c_int = 66; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_C_VERSION: c_int = 96; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_CHAR_BIT: c_int = 101; +pub const _SC_CHAR_MAX: c_int = 102; +pub const _SC_CHAR_MIN: c_int = 103; +pub const _SC_INT_MAX: c_int = 104; +pub const _SC_INT_MIN: c_int = 105; +pub const _SC_LONG_BIT: c_int = 106; +pub const _SC_WORD_BIT: c_int = 107; +pub const _SC_MB_LEN_MAX: c_int = 108; +pub const _SC_NZERO: c_int = 109; +pub const _SC_SSIZE_MAX: c_int = 110; +pub const _SC_SCHAR_MAX: c_int = 111; +pub const _SC_SCHAR_MIN: c_int = 112; +pub const _SC_SHRT_MAX: c_int = 113; +pub const _SC_SHRT_MIN: c_int = 114; +pub const _SC_UCHAR_MAX: c_int = 115; +pub const _SC_UINT_MAX: c_int = 116; +pub const _SC_ULONG_MAX: c_int = 117; +pub const _SC_USHRT_MAX: c_int = 118; +pub const _SC_NL_ARGMAX: c_int = 119; +pub const _SC_NL_LANGMAX: c_int = 120; +pub const _SC_NL_MSGMAX: c_int = 121; +pub const _SC_NL_NMAX: c_int = 122; +pub const _SC_NL_SETMAX: c_int = 123; +pub const _SC_NL_TEXTMAX: c_int = 124; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; +pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; + extern "C" { // File operations pub fn access(pathname: *const c_char, mode: c_int) -> c_int; pub fn close(fd: c_int) -> c_int; - pub fn dup(oldfd: c_int) -> c_int; - pub fn dup2(oldfd: c_int, newfd: c_int) -> c_int; pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + pub fn unlink(pathname: *const c_char) -> c_int; + + // Directory operations + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn rmdir(pathname: *const c_char) -> c_int; // Process operations pub fn getpid() -> pid_t; - pub fn getppid() -> pid_t; - pub fn getuid() -> uid_t; - pub fn geteuid() -> uid_t; - pub fn getgid() -> gid_t; - pub fn getegid() -> gid_t; - pub fn getpgid(pid: pid_t) -> pid_t; - pub fn getpgrp() -> pid_t; - pub fn setpgrp() -> pid_t; - pub fn seteuid(uid: uid_t) -> c_int; - pub fn setuid(uid: uid_t) -> c_int; - pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; - pub fn setsid() -> pid_t; - - // File synchronization - pub fn fsync(fd: c_int) -> c_int; // Sleep functions pub fn sleep(seconds: c_uint) -> c_uint; - pub fn usleep(usec: useconds_t) -> c_int; // System configuration pub fn sysconf(name: c_int) -> c_long; - pub fn pathconf(path: *const c_char, name: c_int) -> c_long; - pub fn fpathconf(fd: c_int, name: c_int) -> c_long; } diff --git a/src/qurt/hexagon.rs b/src/qurt/hexagon.rs deleted file mode 100644 index bc89521c3de0..000000000000 --- a/src/qurt/hexagon.rs +++ /dev/null @@ -1,340 +0,0 @@ -use crate::prelude::*; - -pub type wchar_t = u32; - -pub type cpu_set_t = c_uint; - -s! { - pub struct stat { - pub st_dev: crate::dev_t, - 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, - pub st_rdev: crate::dev_t, - pub st_size: crate::off_t, - pub st_blksize: crate::blksize_t, - 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, - } - - pub struct dirent { - pub d_ino: crate::ino_t, - pub d_type: c_uchar, - pub d_name: [c_char; 256], - } -} - -// File type constants for stat.st_mode -pub const S_IFMT: crate::mode_t = 0o170000; -pub const S_IFSOCK: crate::mode_t = 0o140000; -pub const S_IFLNK: crate::mode_t = 0o120000; -pub const S_IFREG: crate::mode_t = 0o100000; -pub const S_IFBLK: crate::mode_t = 0o060000; -pub const S_IFDIR: crate::mode_t = 0o040000; -pub const S_IFCHR: crate::mode_t = 0o020000; -pub const S_IFIFO: crate::mode_t = 0o010000; - -// File permission constants -pub const S_ISUID: crate::mode_t = 0o4000; -pub const S_ISGID: crate::mode_t = 0o2000; -pub const S_ISVTX: crate::mode_t = 0o1000; -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IXOTH: crate::mode_t = 0o0001; - -// Directory entry types -pub const DT_UNKNOWN: c_uchar = 0; -pub const DT_FIFO: c_uchar = 1; -pub const DT_CHR: c_uchar = 2; -pub const DT_DIR: c_uchar = 4; -pub const DT_BLK: c_uchar = 6; -pub const DT_REG: c_uchar = 8; -pub const DT_LNK: c_uchar = 10; -pub const DT_SOCK: c_uchar = 12; - -// Size types -pub const PAGESIZE: size_t = 4096; -pub const PAGE_SIZE: size_t = 4096; - -// pathconf constants (from bits/confname.h) -pub const _PC_LINK_MAX: c_int = 0; -pub const _PC_MAX_CANON: c_int = 1; -pub const _PC_MAX_INPUT: c_int = 2; -pub const _PC_NAME_MAX: c_int = 3; -pub const _PC_PATH_MAX: c_int = 4; -pub const _PC_PIPE_BUF: c_int = 5; -pub const _PC_CHOWN_RESTRICTED: c_int = 6; -pub const _PC_NO_TRUNC: c_int = 7; -pub const _PC_VDISABLE: c_int = 8; -pub const _PC_SYNC_IO: c_int = 9; -pub const _PC_ASYNC_IO: c_int = 10; -pub const _PC_PRIO_IO: c_int = 11; -pub const _PC_SOCK_MAXBUF: c_int = 12; -pub const _PC_FILESIZEBITS: c_int = 13; -pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; -pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; -pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; -pub const _PC_REC_XFER_ALIGN: c_int = 17; -pub const _PC_ALLOC_SIZE_MIN: c_int = 18; -pub const _PC_SYMLINK_MAX: c_int = 19; -pub const _PC_2_SYMLINKS: c_int = 20; - -// sysconf constants (from bits/confname.h) -pub const _SC_ARG_MAX: c_int = 0; -pub const _SC_CHILD_MAX: c_int = 1; -pub const _SC_CLK_TCK: c_int = 2; -pub const _SC_NGROUPS_MAX: c_int = 3; -pub const _SC_OPEN_MAX: c_int = 4; -pub const _SC_STREAM_MAX: c_int = 5; -pub const _SC_TZNAME_MAX: c_int = 6; -pub const _SC_JOB_CONTROL: c_int = 7; -pub const _SC_SAVED_IDS: c_int = 8; -pub const _SC_REALTIME_SIGNALS: c_int = 9; -pub const _SC_PRIORITY_SCHEDULING: c_int = 10; -pub const _SC_TIMERS: c_int = 11; -pub const _SC_ASYNCHRONOUS_IO: c_int = 12; -pub const _SC_PRIORITIZED_IO: c_int = 13; -pub const _SC_SYNCHRONIZED_IO: c_int = 14; -pub const _SC_FSYNC: c_int = 15; -pub const _SC_MAPPED_FILES: c_int = 16; -pub const _SC_MEMLOCK: c_int = 17; -pub const _SC_MEMLOCK_RANGE: c_int = 18; -pub const _SC_MEMORY_PROTECTION: c_int = 19; -pub const _SC_MESSAGE_PASSING: c_int = 20; -pub const _SC_SEMAPHORES: c_int = 21; -pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; -pub const _SC_AIO_LISTIO_MAX: c_int = 23; -pub const _SC_AIO_MAX: c_int = 24; -pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; -pub const _SC_DELAYTIMER_MAX: c_int = 26; -pub const _SC_MQ_OPEN_MAX: c_int = 27; -pub const _SC_MQ_PRIO_MAX: c_int = 28; -pub const _SC_VERSION: c_int = 29; -pub const _SC_PAGESIZE: c_int = 30; -pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; -pub const _SC_RTSIG_MAX: c_int = 31; -pub const _SC_SEM_NSEMS_MAX: c_int = 32; -pub const _SC_SEM_VALUE_MAX: c_int = 33; -pub const _SC_SIGQUEUE_MAX: c_int = 34; -pub const _SC_TIMER_MAX: c_int = 35; - -// POSIX2 sysconf options -pub const _SC_BC_BASE_MAX: c_int = 36; -pub const _SC_BC_DIM_MAX: c_int = 37; -pub const _SC_BC_SCALE_MAX: c_int = 38; -pub const _SC_BC_STRING_MAX: c_int = 39; -pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; -pub const _SC_EQUIV_CLASS_MAX: c_int = 41; -pub const _SC_EXPR_NEST_MAX: c_int = 42; -pub const _SC_LINE_MAX: c_int = 43; -pub const _SC_RE_DUP_MAX: c_int = 44; -pub const _SC_CHARCLASS_NAME_MAX: c_int = 45; - -pub const _SC_2_VERSION: c_int = 46; -pub const _SC_2_C_BIND: c_int = 47; -pub const _SC_2_C_DEV: c_int = 48; -pub const _SC_2_FORT_DEV: c_int = 49; -pub const _SC_2_FORT_RUN: c_int = 50; -pub const _SC_2_SW_DEV: c_int = 51; -pub const _SC_2_LOCALEDEF: c_int = 52; - -pub const _SC_PII: c_int = 53; -pub const _SC_PII_XTI: c_int = 54; -pub const _SC_PII_SOCKET: c_int = 55; -pub const _SC_PII_INTERNET: c_int = 56; -pub const _SC_PII_OSI: c_int = 57; -pub const _SC_POLL: c_int = 58; -pub const _SC_SELECT: c_int = 59; -pub const _SC_UIO_MAXIOV: c_int = 60; -pub const _SC_IOV_MAX: c_int = _SC_UIO_MAXIOV; -pub const _SC_PII_INTERNET_STREAM: c_int = 61; -pub const _SC_PII_INTERNET_DGRAM: c_int = 62; -pub const _SC_PII_OSI_COTS: c_int = 63; -pub const _SC_PII_OSI_CLTS: c_int = 64; -pub const _SC_PII_OSI_M: c_int = 65; -pub const _SC_T_IOV_MAX: c_int = 66; - -// POSIX threads sysconf options -pub const _SC_THREADS: c_int = 67; -pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; -pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; -pub const _SC_LOGIN_NAME_MAX: c_int = 71; -pub const _SC_TTY_NAME_MAX: c_int = 72; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; -pub const _SC_THREAD_KEYS_MAX: c_int = 74; -pub const _SC_THREAD_STACK_MIN: c_int = 75; -pub const _SC_THREAD_THREADS_MAX: c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; -pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; -pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; -pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; -pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; - -pub const _SC_NPROCESSORS_CONF: c_int = 83; -pub const _SC_NPROCESSORS_ONLN: c_int = 84; -pub const _SC_PHYS_PAGES: c_int = 85; -pub const _SC_AVPHYS_PAGES: c_int = 86; -pub const _SC_ATEXIT_MAX: c_int = 87; -pub const _SC_PASS_MAX: c_int = 88; - -pub const _SC_XOPEN_VERSION: c_int = 89; -pub const _SC_XOPEN_XCU_VERSION: c_int = 90; -pub const _SC_XOPEN_UNIX: c_int = 91; -pub const _SC_XOPEN_CRYPT: c_int = 92; -pub const _SC_XOPEN_ENH_I18N: c_int = 93; -pub const _SC_XOPEN_SHM: c_int = 94; - -pub const _SC_2_CHAR_TERM: c_int = 95; -pub const _SC_2_C_VERSION: c_int = 96; -pub const _SC_2_UPE: c_int = 97; - -pub const _SC_XOPEN_XPG2: c_int = 98; -pub const _SC_XOPEN_XPG3: c_int = 99; -pub const _SC_XOPEN_XPG4: c_int = 100; - -pub const _SC_CHAR_BIT: c_int = 101; -pub const _SC_CHAR_MAX: c_int = 102; -pub const _SC_CHAR_MIN: c_int = 103; -pub const _SC_INT_MAX: c_int = 104; -pub const _SC_INT_MIN: c_int = 105; -pub const _SC_LONG_BIT: c_int = 106; -pub const _SC_WORD_BIT: c_int = 107; -pub const _SC_MB_LEN_MAX: c_int = 108; -pub const _SC_NZERO: c_int = 109; -pub const _SC_SSIZE_MAX: c_int = 110; -pub const _SC_SCHAR_MAX: c_int = 111; -pub const _SC_SCHAR_MIN: c_int = 112; -pub const _SC_SHRT_MAX: c_int = 113; -pub const _SC_SHRT_MIN: c_int = 114; -pub const _SC_UCHAR_MAX: c_int = 115; -pub const _SC_UINT_MAX: c_int = 116; -pub const _SC_ULONG_MAX: c_int = 117; -pub const _SC_USHRT_MAX: c_int = 118; - -pub const _SC_NL_ARGMAX: c_int = 119; -pub const _SC_NL_LANGMAX: c_int = 120; -pub const _SC_NL_MSGMAX: c_int = 121; -pub const _SC_NL_NMAX: c_int = 122; -pub const _SC_NL_SETMAX: c_int = 123; -pub const _SC_NL_TEXTMAX: c_int = 124; - -pub const _SC_XBS5_ILP32_OFF32: c_int = 125; -pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; -pub const _SC_XBS5_LP64_OFF64: c_int = 127; -pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; - -pub const _SC_XOPEN_LEGACY: c_int = 129; -pub const _SC_XOPEN_REALTIME: c_int = 130; -pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; - -pub const _SC_ADVISORY_INFO: c_int = 132; -pub const _SC_BARRIERS: c_int = 133; -pub const _SC_BASE: c_int = 134; -pub const _SC_C_LANG_SUPPORT: c_int = 135; -pub const _SC_C_LANG_SUPPORT_R: c_int = 136; -pub const _SC_CLOCK_SELECTION: c_int = 137; -pub const _SC_CPUTIME: c_int = 138; -pub const _SC_THREAD_CPUTIME: c_int = 139; -pub const _SC_DEVICE_IO: c_int = 140; -pub const _SC_DEVICE_SPECIFIC: c_int = 141; -pub const _SC_DEVICE_SPECIFIC_R: c_int = 142; -pub const _SC_FD_MGMT: c_int = 143; -pub const _SC_FIFO: c_int = 144; -pub const _SC_PIPE: c_int = 145; -pub const _SC_FILE_ATTRIBUTES: c_int = 146; -pub const _SC_FILE_LOCKING: c_int = 147; -pub const _SC_FILE_SYSTEM: c_int = 148; -pub const _SC_MONOTONIC_CLOCK: c_int = 149; -pub const _SC_MULTI_PROCESS: c_int = 150; -pub const _SC_SINGLE_PROCESS: c_int = 151; -pub const _SC_NETWORKING: c_int = 152; -pub const _SC_READER_WRITER_LOCKS: c_int = 153; -pub const _SC_SPIN_LOCKS: c_int = 154; -pub const _SC_REGEXP: c_int = 155; -pub const _SC_REGEX_VERSION: c_int = 156; -pub const _SC_SHELL: c_int = 157; -pub const _SC_SIGNALS: c_int = 158; -pub const _SC_SPAWN: c_int = 159; -pub const _SC_SPORADIC_SERVER: c_int = 160; -pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; -pub const _SC_SYSTEM_DATABASE: c_int = 162; -pub const _SC_SYSTEM_DATABASE_R: c_int = 163; -pub const _SC_TIMEOUTS: c_int = 164; -pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; -pub const _SC_USER_GROUPS: c_int = 166; -pub const _SC_USER_GROUPS_R: c_int = 167; -pub const _SC_2_PBS: c_int = 168; -pub const _SC_2_PBS_ACCOUNTING: c_int = 169; -pub const _SC_2_PBS_LOCATE: c_int = 170; -pub const _SC_2_PBS_MESSAGE: c_int = 171; -pub const _SC_2_PBS_TRACK: c_int = 172; -pub const _SC_SYMLOOP_MAX: c_int = 173; -pub const _SC_STREAMS: c_int = 174; -pub const _SC_2_PBS_CHECKPOINT: c_int = 175; - -pub const _SC_V6_ILP32_OFF32: c_int = 176; -pub const _SC_V6_ILP32_OFFBIG: c_int = 177; -pub const _SC_V6_LP64_OFF64: c_int = 178; -pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; - -pub const _SC_HOST_NAME_MAX: c_int = 180; -pub const _SC_TRACE: c_int = 181; -pub const _SC_TRACE_EVENT_FILTER: c_int = 182; -pub const _SC_TRACE_INHERIT: c_int = 183; -pub const _SC_TRACE_LOG: c_int = 184; - -pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 185; -pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 186; -pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 187; -pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 188; -pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 189; -pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 190; -pub const _SC_LEVEL2_CACHE_SIZE: c_int = 191; -pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 192; -pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 193; -pub const _SC_LEVEL3_CACHE_SIZE: c_int = 194; -pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 195; -pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 196; -pub const _SC_LEVEL4_CACHE_SIZE: c_int = 197; -pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 198; -pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 199; - -pub const _SC_IPV6: c_int = 235; -pub const _SC_RAW_SOCKETS: c_int = 236; - -pub const _SC_V7_ILP32_OFF32: c_int = 237; -pub const _SC_V7_ILP32_OFFBIG: c_int = 238; -pub const _SC_V7_LP64_OFF64: c_int = 239; -pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; - -pub const _SC_SS_REPL_MAX: c_int = 241; - -pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; -pub const _SC_TRACE_NAME_MAX: c_int = 243; -pub const _SC_TRACE_SYS_MAX: c_int = 244; -pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; - -pub const _SC_XOPEN_STREAMS: c_int = 246; - -pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; -pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; - -// Note: QuRT doesn't use traditional syscalls but has its own API diff --git a/src/qurt/mod.rs b/src/qurt/mod.rs index 1ecbe172a256..b5e01f93093d 100644 --- a/src/qurt/mod.rs +++ b/src/qurt/mod.rs @@ -1,334 +1,18 @@ //! Interface to QuRT (Qualcomm Real-Time OS) C library +//! +//! This module re-exports items from the new module structure. +//! QuRT was introduced after the `src/new/` module structure was established, +//! so all definitions live in `src/new/qurt/` and are re-exported here +//! for compatibility with the existing libc structure. -use crate::prelude::*; +// Re-export everything from the new qurt module +pub use crate::new::qurt::*; -// Forward declarations for opaque types -#[derive(Debug)] -pub enum DIR {} -impl Copy for DIR {} -impl Clone for DIR { - fn clone(&self) -> DIR { - *self - } -} - -// Network types -pub type socklen_t = c_uint; -pub type in_addr_t = u32; - -// Error type -pub type errno_t = c_int; - -// Resource limit type -pub type rlim_t = c_ulong; - -// Terminal types -pub type speed_t = c_uint; -pub type tcflag_t = c_uint; - -// File descriptor set type for select() -pub type fd_set = c_ulong; - -// POSIX semaphore types -pub type sem_t = c_uint; - -// Message queue types -pub type mqd_t = c_int; - -// Additional file system types -pub type nfds_t = c_ulong; - -// Architecture-specific modules +// Architecture-specific modules (if any are needed in the future) cfg_if! { if #[cfg(target_arch = "hexagon")] { - mod hexagon; - pub use self::hexagon::*; + // Currently no hexagon-specific items needed beyond what's in new/qurt } else { // Add other architectures as needed } } - -// Structures based on QuRT headers -s! { - pub struct sigval { - pub sival_int: c_int, - pub sival_ptr: *mut c_void, - } - - pub struct sigevent { - pub sigev_notify: c_int, - pub sigev_signo: c_int, - pub sigev_value: sigval, - pub sigev_notify_function: Option, - pub sigev_notify_attributes: *mut pthread_attr_t, - } - - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_value: sigval, - } - - pub struct sigaction { - pub sa_handler: Option, - pub sa_mask: sigset_t, - pub sa_flags: c_int, - pub sa_sigaction: Option, - } - - pub struct termios { - pub c_iflag: tcflag_t, - pub c_oflag: tcflag_t, - pub c_cflag: tcflag_t, - pub c_lflag: tcflag_t, - pub c_cc: [c_uchar; 32], - pub c_ispeed: speed_t, - pub c_ospeed: speed_t, - } - - pub struct dirent { - pub d_ino: ino_t, - pub d_type: c_uchar, - pub d_name: [c_char; 256], - } - - pub struct tm { - pub tm_sec: c_int, - pub tm_min: c_int, - pub tm_hour: c_int, - pub tm_mday: c_int, - pub tm_mon: c_int, - pub tm_year: c_int, - pub tm_wday: c_int, - pub tm_yday: c_int, - pub tm_isdst: c_int, - } - - pub struct sched_param { - pub sched_priority: c_int, - } - - pub struct iovec { - pub iov_base: *mut c_void, - pub iov_len: size_t, - } - - pub struct rlimit { - pub rlim_cur: rlim_t, - pub rlim_max: rlim_t, - } - - pub struct rusage { - pub ru_utime: timeval, - pub ru_stime: timeval, - pub ru_maxrss: c_long, - pub ru_ixrss: c_long, - pub ru_idrss: c_long, - pub ru_isrss: c_long, - pub ru_minflt: c_long, - pub ru_majflt: c_long, - pub ru_nswap: c_long, - pub ru_inblock: c_long, - pub ru_oublock: c_long, - pub ru_msgsnd: c_long, - pub ru_msgrcv: c_long, - pub ru_nsignals: c_long, - pub ru_nvcsw: c_long, - pub ru_nivcsw: c_long, - } - - pub struct flock { - pub l_type: c_short, - pub l_whence: c_short, - pub l_start: off_t, - pub l_len: off_t, - pub l_pid: pid_t, - } -} - -// Memory mapping constants (from sys/mman.h) -pub const PROT_NONE: c_int = 0x00; -pub const PROT_READ: c_int = 0x01; -pub const PROT_WRITE: c_int = 0x02; -pub const PROT_EXEC: c_int = 0x04; - -pub const MAP_SHARED: c_int = 0x0001; -pub const MAP_PRIVATE: c_int = 0x0002; -pub const MAP_FIXED: c_int = 0x0010; -pub const MAP_ANON: c_int = 0x1000; -pub const MAP_ANONYMOUS: c_int = MAP_ANON; -pub const MAP_FILE: c_int = 0x0000; -pub const MAP_RENAME: c_int = 0x0020; -pub const MAP_NORESERVE: c_int = 0x0040; -pub const MAP_INHERIT: c_int = 0x0080; -pub const MAP_HASSEMAPHORE: c_int = 0x0200; -pub const MAP_TRYFIXED: c_int = 0x0400; -pub const MAP_WIRED: c_int = 0x0800; - -pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; - -pub const MS_ASYNC: c_int = 0x01; -pub const MS_INVALIDATE: c_int = 0x02; -pub const MS_SYNC: c_int = 0x04; - -pub const MCL_CURRENT: c_int = 0x01; -pub const MCL_FUTURE: c_int = 0x02; - -// Dynamic linking constants (from dlfcn.h) -pub const RTLD_LAZY: c_int = 1; -pub const RTLD_NOW: c_int = 2; -pub const RTLD_GLOBAL: c_int = 0x100; -pub const RTLD_LOCAL: c_int = 0x200; - -// Semaphore constants -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; - -// Additional constants -pub const PTHREAD_NAME_LEN: c_int = 16; -pub const PTHREAD_MAX_THREADS: c_uint = 512; -pub const PTHREAD_MIN_STACKSIZE: c_int = 512; -pub const PTHREAD_MAX_STACKSIZE: c_int = 1048576; -pub const PTHREAD_DEFAULT_STACKSIZE: c_int = 16384; -pub const PTHREAD_DEFAULT_PRIORITY: c_int = 1; -pub const PTHREAD_SPINLOCK_UNLOCKED: c_int = 0; -pub const PTHREAD_SPINLOCK_LOCKED: c_int = 1; -pub const TIME_CONV_SCLK_FREQ: c_int = 19200000; -pub const CLOCK_MONOTONIC_RAW: clockid_t = 4; -pub const CLOCK_REALTIME_COARSE: clockid_t = 5; -pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6; -pub const CLOCK_BOOTTIME: clockid_t = 7; -pub const L_tmpnam: c_uint = 260; -pub const TMP_MAX: c_uint = 25; -pub const FOPEN_MAX: c_uint = 20; -pub const AT_FDCWD: c_int = -100; -pub const AT_EACCESS: c_int = 0x200; -pub const AT_SYMLINK_NOFOLLOW: c_int = 0x100; -pub const AT_SYMLINK_FOLLOW: c_int = 0x400; -pub const AT_REMOVEDIR: c_int = 0x200; -pub const EOK: c_int = 0; -pub const POSIX_MSG: c_int = 7; -pub const POSIX_NOTIF: c_int = 8; -pub const SIGRTMIN: c_int = 10; -pub const SIGRTMAX: c_int = 32; -pub const SIGEV_NONE: c_int = 0; -pub const SIGEV_SIGNAL: c_int = 1; -pub const SIGEV_THREAD: c_int = 2; -pub const SA_SIGINFO: c_int = 1; - -// Function declarations for QuRT POSIX API -extern "C" { - // Signal functions - pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; - pub fn _sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int; - pub fn sigtimedwait( - set: *const sigset_t, - info: *mut siginfo_t, - timeout: *const timespec, - ) -> c_int; - - // Additional pthread functions - pub fn pthread_attr_getstack( - attr: *const pthread_attr_t, - stackaddr: *mut *mut c_void, - stacksize: *mut size_t, - ) -> c_int; - pub fn pthread_attr_setstack( - attr: *mut pthread_attr_t, - stackaddr: *mut c_void, - stacksize: size_t, - ) -> c_int; - pub fn pthread_mutexattr_gettype(attr: *const pthread_mutexattr_t, type_: *mut c_int) -> c_int; - pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, type_: c_int) -> c_int; - - // Additional time functions - pub fn clock_getcpuclockid(pid: pid_t, clock_id: *mut clockid_t) -> c_int; - - // POSIX semaphore functions - pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; - pub fn sem_close(sem: *mut sem_t) -> c_int; - pub fn sem_unlink(name: *const c_char) -> c_int; - - // Additional stdlib functions - pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; - - // String functions - pub fn strlen(s: *const c_char) -> size_t; - pub fn strcpy(dest: *mut c_char, src: *const c_char) -> *mut c_char; - pub fn strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; - pub fn strcat(dest: *mut c_char, src: *const c_char) -> *mut c_char; - pub fn strncat(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; - pub fn strcmp(s1: *const c_char, s2: *const c_char) -> c_int; - pub fn strncmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; - pub fn strcoll(s1: *const c_char, s2: *const c_char) -> c_int; - pub fn strxfrm(dest: *mut c_char, src: *const c_char, n: size_t) -> size_t; - pub fn strchr(s: *const c_char, c: c_int) -> *mut c_char; - pub fn strrchr(s: *const c_char, c: c_int) -> *mut c_char; - pub fn strspn(s: *const c_char, accept: *const c_char) -> size_t; - pub fn strcspn(s: *const c_char, reject: *const c_char) -> size_t; - pub fn strpbrk(s: *const c_char, accept: *const c_char) -> *mut c_char; - pub fn strstr(haystack: *const c_char, needle: *const c_char) -> *mut c_char; - pub fn strtok(s: *mut c_char, delim: *const c_char) -> *mut c_char; - pub fn strerror(errnum: c_int) -> *mut c_char; - pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; - pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; - pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; - pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; - pub fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void; - - // Additional unistd functions - pub fn fork() -> pid_t; - pub fn execve( - filename: *const c_char, - argv: *const *const c_char, - envp: *const *const c_char, - ) -> c_int; - - // Directory functions - pub fn opendir(name: *const c_char) -> *mut DIR; - pub fn closedir(dirp: *mut DIR) -> c_int; - pub fn readdir(dirp: *mut DIR) -> *mut dirent; - pub fn rewinddir(dirp: *mut DIR); - pub fn telldir(dirp: *mut DIR) -> c_long; - pub fn seekdir(dirp: *mut DIR, loc: c_long); - - // Memory mapping functions - pub fn mmap( - addr: *mut c_void, - len: size_t, - prot: c_int, - flags: c_int, - fd: c_int, - offset: off_t, - ) -> *mut c_void; - pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; - pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn mlock(addr: *const c_void, len: size_t) -> c_int; - pub fn munlock(addr: *const c_void, len: size_t) -> c_int; - pub fn mlockall(flags: c_int) -> c_int; - pub fn munlockall() -> c_int; - pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; - - // Dynamic linking functions - pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; - pub fn dlclose(handle: *mut c_void) -> c_int; - pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; - pub fn dlerror() -> *mut c_char; - - // Character classification functions - pub fn isalnum(c: c_int) -> c_int; - pub fn isalpha(c: c_int) -> c_int; - pub fn iscntrl(c: c_int) -> c_int; - pub fn isdigit(c: c_int) -> c_int; - pub fn isgraph(c: c_int) -> c_int; - pub fn islower(c: c_int) -> c_int; - pub fn isprint(c: c_int) -> c_int; - pub fn ispunct(c: c_int) -> c_int; - pub fn isspace(c: c_int) -> c_int; - pub fn isupper(c: c_int) -> c_int; - pub fn isxdigit(c: c_int) -> c_int; - pub fn tolower(c: c_int) -> c_int; - pub fn toupper(c: c_int) -> c_int; -} - -// Re-export common prelude items -pub use crate::*; From 8457db54c7d99b4fff3cf8e4924cfc23135aa8b7 Mon Sep 17 00:00:00 2001 From: "Marco C." <46560192+Marcondiro@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:27:48 +0100 Subject: [PATCH 11/36] Add PTRACE_SET_SYSCALL_INFO constant (backport ) (cherry picked from commit 0403150379d66216e90a0f8a804ae1ca33691067) --- libc-test/build.rs | 3 +++ libc-test/semver/linux-gnu.txt | 1 + src/unix/linux_like/linux/gnu/mod.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 96f561a191f4..81845f5aa604 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4647,6 +4647,9 @@ fn test_linux(target: &str) { // Linux 6.14 "AT_EXECVE_CHECK" => true, + // FIXME(linux): Requires >= 6.16 kernel headers. + "PTRACE_SET_SYSCALL_INFO" => true, + _ => false, } }); diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index a28ac82250fb..0dfc20cf9a62 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -348,6 +348,7 @@ PR_SET_VMA_ANON_NAME PTHREAD_MUTEX_ADAPTIVE_NP PTRACE_GET_SYSCALL_INFO PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG +PTRACE_SET_SYSCALL_INFO PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG PTRACE_SYSCALL_INFO_ENTRY PTRACE_SYSCALL_INFO_EXIT diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 5fa2fdf591dd..c214beb3635e 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -747,6 +747,7 @@ pub const PTRACE_PEEKSIGINFO: c_uint = 0x4209; pub const PTRACE_GETSIGMASK: c_uint = 0x420a; pub const PTRACE_SETSIGMASK: c_uint = 0x420b; pub const PTRACE_GET_SYSCALL_INFO: c_uint = 0x420e; +pub const PTRACE_SET_SYSCALL_INFO: c_uint = 0x4212; pub const PTRACE_SYSCALL_INFO_NONE: crate::__u8 = 0; pub const PTRACE_SYSCALL_INFO_ENTRY: crate::__u8 = 1; pub const PTRACE_SYSCALL_INFO_EXIT: crate::__u8 = 2; From 6fb8a8ad8fbaae0753e56a6c726b0e66173f8b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 26 Jan 2026 17:31:08 +0100 Subject: [PATCH 12/36] types: Fix wording of Padding::uninit() comment I guess I may wanted to say two different things and then I mixed the words in the resulting comment. Fix the text to make it actually have a meaning (backport ) (cherry picked from commit 92c51f3b37db83cf40cbe04cdaacb46ac39c6334) --- src/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.rs b/src/types.rs index 2d6e83f67fcd..c2873ddbf4f1 100644 --- a/src/types.rs +++ b/src/types.rs @@ -28,8 +28,8 @@ impl Padding { // when we depend on rustc 1.75.0. #[allow(unused)] pub(crate) const fn uninit() -> Self { - // We can still safely use uninit here, since padding are is something - // that can are not meant to be read or written anyways. + // We can still safely use uninit here, since padding is something + // that is not meant to be read or written anyways. Self(MaybeUninit::uninit()) } } From 4f3c447d0ad78f45ab83ef72e33a1ef2c7937b90 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Tue, 27 Jan 2026 19:39:42 +1100 Subject: [PATCH 13/36] fix(redox): incorrect values for `PTHREAD_MUTEX_{NORMAL, RECURSIVE}` See https://gitlab.redox-os.org/redox-os/relibc/-/blob/5cadc9ebbd36f5294e08f67233928e5ad6f05670/src/header/pthread/mod.rs#L60 Signed-off-by: Anhad Singh (backport ) (cherry picked from commit 3482c8046a10c57391cbf0813916378dc130b293) --- libc-test/semver/redox.txt | 4 ++++ src/unix/redox/mod.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index e993475f20b4..73a36244c09c 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -137,6 +137,10 @@ O_NOCTTY O_PATH O_SHLOCK O_SYMLINK +PTHREAD_MUTEX_DEFAULT +PTHREAD_MUTEX_ERRORCHECK +PTHREAD_MUTEX_ROBUST +PTHREAD_MUTEX_STALLED PTHREAD_STACK_MIN RLIMIT_AS RLIMIT_CORE diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 9768cbe9e50e..69566e398dc3 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -609,8 +609,14 @@ pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; // pthread.h -pub const PTHREAD_MUTEX_NORMAL: c_int = 0; -pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_NORMAL: c_int = 2; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 3; + +pub const PTHREAD_MUTEX_ROBUST: c_int = 0; +pub const PTHREAD_MUTEX_STALLED: c_int = 1; + pub const PTHREAD_MUTEX_INITIALIZER: crate::pthread_mutex_t = crate::pthread_mutex_t { bytes: [0; _PTHREAD_MUTEX_SIZE], }; From 23842d71db432ccd90fc824bb79b22eedca7ca89 Mon Sep 17 00:00:00 2001 From: Hashem Hashem Date: Tue, 27 Jan 2026 15:29:50 +0100 Subject: [PATCH 14/36] linux: add CAN error types Port libc "error.h" file for SocketCAN subsystem and expose through can.rs. (backport ) (cherry picked from commit c6ba84bd05e671c4680d464e9e7a6e3430f7c2d9) --- libc-test/build.rs | 1 + libc-test/semver/linux.txt | 62 +++++++++++++++++++++++ src/new/linux_uapi/linux/can.rs | 1 + src/new/linux_uapi/linux/can/error.rs | 73 +++++++++++++++++++++++++++ src/new/mod.rs | 1 + 5 files changed, 138 insertions(+) create mode 100644 src/new/linux_uapi/linux/can/error.rs diff --git a/libc-test/build.rs b/libc-test/build.rs index 81845f5aa604..cf4c76054135 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4005,6 +4005,7 @@ fn test_linux(target: &str) { (gnu, "linux/aio_abi.h"), "linux/can.h", "linux/can/bcm.h", + "linux/can/error.h", "linux/can/raw.h", "linux/can/j1939.h", "linux/cn_proc.h", diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 25a3a593f44e..ebe192192dfd 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -230,11 +230,73 @@ CANXL_PRIO_MASK CANXL_SEC CANXL_XLF CAN_BCM +CAN_BUS_OFF_THRESHOLD CAN_EFF_FLAG CAN_EFF_ID_BITS CAN_EFF_MASK +CAN_ERROR_PASSIVE_THRESHOLD +CAN_ERROR_WARNING_THRESHOLD +CAN_ERR_ACK +CAN_ERR_BUSERROR +CAN_ERR_BUSOFF +CAN_ERR_CNT +CAN_ERR_CRTL +CAN_ERR_CRTL_ACTIVE +CAN_ERR_CRTL_RX_OVERFLOW +CAN_ERR_CRTL_RX_PASSIVE +CAN_ERR_CRTL_RX_WARNING +CAN_ERR_CRTL_TX_OVERFLOW +CAN_ERR_CRTL_TX_PASSIVE +CAN_ERR_CRTL_TX_WARNING +CAN_ERR_CRTL_UNSPEC +CAN_ERR_DLC CAN_ERR_FLAG +CAN_ERR_LOSTARB +CAN_ERR_LOSTARB_UNSPEC CAN_ERR_MASK +CAN_ERR_PROT +CAN_ERR_PROT_ACTIVE +CAN_ERR_PROT_BIT +CAN_ERR_PROT_BIT0 +CAN_ERR_PROT_BIT1 +CAN_ERR_PROT_FORM +CAN_ERR_PROT_LOC_ACK +CAN_ERR_PROT_LOC_ACK_DEL +CAN_ERR_PROT_LOC_CRC_DEL +CAN_ERR_PROT_LOC_CRC_SEQ +CAN_ERR_PROT_LOC_DATA +CAN_ERR_PROT_LOC_DLC +CAN_ERR_PROT_LOC_EOF +CAN_ERR_PROT_LOC_ID04_00 +CAN_ERR_PROT_LOC_ID12_05 +CAN_ERR_PROT_LOC_ID17_13 +CAN_ERR_PROT_LOC_ID20_18 +CAN_ERR_PROT_LOC_ID28_21 +CAN_ERR_PROT_LOC_IDE +CAN_ERR_PROT_LOC_INTERM +CAN_ERR_PROT_LOC_RES0 +CAN_ERR_PROT_LOC_RES1 +CAN_ERR_PROT_LOC_RTR +CAN_ERR_PROT_LOC_SOF +CAN_ERR_PROT_LOC_SRTR +CAN_ERR_PROT_LOC_UNSPEC +CAN_ERR_PROT_OVERLOAD +CAN_ERR_PROT_STUFF +CAN_ERR_PROT_TX +CAN_ERR_PROT_UNSPEC +CAN_ERR_RESTARTED +CAN_ERR_TRX +CAN_ERR_TRX_CANH_NO_WIRE +CAN_ERR_TRX_CANH_SHORT_TO_BAT +CAN_ERR_TRX_CANH_SHORT_TO_GND +CAN_ERR_TRX_CANH_SHORT_TO_VCC +CAN_ERR_TRX_CANL_NO_WIRE +CAN_ERR_TRX_CANL_SHORT_TO_BAT +CAN_ERR_TRX_CANL_SHORT_TO_CANH +CAN_ERR_TRX_CANL_SHORT_TO_GND +CAN_ERR_TRX_CANL_SHORT_TO_VCC +CAN_ERR_TRX_UNSPEC +CAN_ERR_TX_TIMEOUT CAN_FD_FRAME CAN_INV_FILTER CAN_ISOTP diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 8019124749c1..54148976e625 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -1,6 +1,7 @@ //! Header: `uapi/linux/can.h` pub(crate) mod bcm; +pub(crate) mod error; pub(crate) mod j1939; pub(crate) mod raw; diff --git a/src/new/linux_uapi/linux/can/error.rs b/src/new/linux_uapi/linux/can/error.rs new file mode 100644 index 000000000000..1b298ca40eca --- /dev/null +++ b/src/new/linux_uapi/linux/can/error.rs @@ -0,0 +1,73 @@ +//! Header: `linux/can/error.h` + +pub use crate::linux::can::*; + +pub const CAN_ERR_DLC: c_int = 8; + +pub const CAN_ERR_TX_TIMEOUT: c_uint = 0x00000001; +pub const CAN_ERR_LOSTARB: c_uint = 0x00000002; +pub const CAN_ERR_CRTL: c_uint = 0x00000004; +pub const CAN_ERR_PROT: c_uint = 0x00000008; +pub const CAN_ERR_TRX: c_uint = 0x00000010; +pub const CAN_ERR_ACK: c_uint = 0x00000020; +pub const CAN_ERR_BUSOFF: c_uint = 0x00000040; +pub const CAN_ERR_BUSERROR: c_uint = 0x00000080; +pub const CAN_ERR_RESTARTED: c_uint = 0x00000100; +pub const CAN_ERR_CNT: c_uint = 0x00000200; + +pub const CAN_ERR_LOSTARB_UNSPEC: c_int = 0x00; + +pub const CAN_ERR_CRTL_UNSPEC: c_int = 0x00; +pub const CAN_ERR_CRTL_RX_OVERFLOW: c_int = 0x01; +pub const CAN_ERR_CRTL_TX_OVERFLOW: c_int = 0x02; +pub const CAN_ERR_CRTL_RX_WARNING: c_int = 0x04; +pub const CAN_ERR_CRTL_TX_WARNING: c_int = 0x08; +pub const CAN_ERR_CRTL_RX_PASSIVE: c_int = 0x10; +pub const CAN_ERR_CRTL_TX_PASSIVE: c_int = 0x20; +pub const CAN_ERR_CRTL_ACTIVE: c_int = 0x40; + +pub const CAN_ERR_PROT_UNSPEC: c_int = 0x00; +pub const CAN_ERR_PROT_BIT: c_int = 0x01; +pub const CAN_ERR_PROT_FORM: c_int = 0x02; +pub const CAN_ERR_PROT_STUFF: c_int = 0x04; +pub const CAN_ERR_PROT_BIT0: c_int = 0x08; +pub const CAN_ERR_PROT_BIT1: c_int = 0x10; +pub const CAN_ERR_PROT_OVERLOAD: c_int = 0x20; +pub const CAN_ERR_PROT_ACTIVE: c_int = 0x40; +pub const CAN_ERR_PROT_TX: c_int = 0x80; + +pub const CAN_ERR_PROT_LOC_UNSPEC: c_int = 0x00; +pub const CAN_ERR_PROT_LOC_SOF: c_int = 0x03; +pub const CAN_ERR_PROT_LOC_ID28_21: c_int = 0x02; +pub const CAN_ERR_PROT_LOC_ID20_18: c_int = 0x06; +pub const CAN_ERR_PROT_LOC_SRTR: c_int = 0x04; +pub const CAN_ERR_PROT_LOC_IDE: c_int = 0x05; +pub const CAN_ERR_PROT_LOC_ID17_13: c_int = 0x07; +pub const CAN_ERR_PROT_LOC_ID12_05: c_int = 0x0F; +pub const CAN_ERR_PROT_LOC_ID04_00: c_int = 0x0E; +pub const CAN_ERR_PROT_LOC_RTR: c_int = 0x0C; +pub const CAN_ERR_PROT_LOC_RES1: c_int = 0x0D; +pub const CAN_ERR_PROT_LOC_RES0: c_int = 0x09; +pub const CAN_ERR_PROT_LOC_DLC: c_int = 0x0B; +pub const CAN_ERR_PROT_LOC_DATA: c_int = 0x0A; +pub const CAN_ERR_PROT_LOC_CRC_SEQ: c_int = 0x08; +pub const CAN_ERR_PROT_LOC_CRC_DEL: c_int = 0x18; +pub const CAN_ERR_PROT_LOC_ACK: c_int = 0x19; +pub const CAN_ERR_PROT_LOC_ACK_DEL: c_int = 0x1B; +pub const CAN_ERR_PROT_LOC_EOF: c_int = 0x1A; +pub const CAN_ERR_PROT_LOC_INTERM: c_int = 0x12; + +pub const CAN_ERR_TRX_UNSPEC: c_int = 0x00; +pub const CAN_ERR_TRX_CANH_NO_WIRE: c_int = 0x04; +pub const CAN_ERR_TRX_CANH_SHORT_TO_BAT: c_int = 0x05; +pub const CAN_ERR_TRX_CANH_SHORT_TO_VCC: c_int = 0x06; +pub const CAN_ERR_TRX_CANH_SHORT_TO_GND: c_int = 0x07; +pub const CAN_ERR_TRX_CANL_NO_WIRE: c_int = 0x40; +pub const CAN_ERR_TRX_CANL_SHORT_TO_BAT: c_int = 0x50; +pub const CAN_ERR_TRX_CANL_SHORT_TO_VCC: c_int = 0x60; +pub const CAN_ERR_TRX_CANL_SHORT_TO_GND: c_int = 0x70; +pub const CAN_ERR_TRX_CANL_SHORT_TO_CANH: c_int = 0x80; + +pub const CAN_ERROR_WARNING_THRESHOLD: c_int = 96; +pub const CAN_ERROR_PASSIVE_THRESHOLD: c_int = 128; +pub const CAN_BUS_OFF_THRESHOLD: c_int = 256; diff --git a/src/new/mod.rs b/src/new/mod.rs index 078200ae6258..8b1fdc231743 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -177,6 +177,7 @@ cfg_if! { pub use sys::socket::*; } else if #[cfg(target_os = "linux")] { pub use linux::can::bcm::*; + pub use linux::can::error::*; pub use linux::can::j1939::*; pub use linux::can::raw::*; pub use linux::can::*; From 6a749cabd3869d15e5f691e3929ceec730f184e1 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Tue, 27 Jan 2026 19:25:19 +0100 Subject: [PATCH 15/36] Add more kqueue related constants for OpenBSD (backport ) (cherry picked from commit 506d591dd2a45a2dc4b08a37129217b3181831eb) --- libc-test/semver/openbsd.txt | 8 ++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 412ba5a4bd48..42bd6ac72279 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -187,6 +187,7 @@ EVFILT_PROC EVFILT_READ EVFILT_SIGNAL EVFILT_TIMER +EVFILT_USER EVFILT_VNODE EVFILT_WRITE EV_ADD @@ -608,6 +609,12 @@ NOTE_EOF NOTE_EXEC NOTE_EXIT NOTE_EXTEND +NOTE_FFAND +NOTE_FFCOPY +NOTE_FFCTRLMASK +NOTE_FFLAGSMASK +NOTE_FFNOP +NOTE_FFOR NOTE_FORK NOTE_LINK NOTE_LOWAT @@ -618,6 +625,7 @@ NOTE_RENAME NOTE_REVOKE NOTE_TRACK NOTE_TRACKERR +NOTE_TRIGGER NOTE_TRUNCATE NOTE_WRITE NTFS_MFLAG_ALLNAMES diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 92a59b53a6a6..14003a7bcb06 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1170,7 +1170,7 @@ pub const EVFILT_SIGNAL: i16 = -6; pub const EVFILT_TIMER: i16 = -7; pub const EVFILT_DEVICE: i16 = -8; pub const EVFILT_EXCEPT: i16 = -9; - +pub const EVFILT_USER: i16 = -10; pub const EV_ADD: u16 = 0x1; pub const EV_DELETE: u16 = 0x2; pub const EV_ENABLE: u16 = 0x4; @@ -1186,6 +1186,13 @@ pub const EV_EOF: u16 = 0x8000; #[deprecated(since = "0.2.113", note = "Not stable across OS versions")] pub const EV_SYSFLAGS: u16 = 0xf800; +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; pub const NOTE_LOWAT: u32 = 0x00000001; pub const NOTE_EOF: u32 = 0x00000002; pub const NOTE_OOB: u32 = 0x00000004; From 836c606334febae687ef9620dabd9a1f5b652917 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 28 Jan 2026 17:14:05 +0900 Subject: [PATCH 16/36] fix(ci): update aports Git repo URL (backport ) (cherry picked from commit 6ec397f84f3f8ab26139b538fbaf796bf0bc9ae9) --- ci/install-musl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/install-musl.sh b/ci/install-musl.sh index b71e4f613955..a4e4dea71606 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -101,7 +101,7 @@ rm -rf "$musl" # Alpine follows stable kernel releases, 3.20 uses Linux 6.6 headers. alpine_version=3.20 -alpine_git=https://gitlab.alpinelinux.org/alpine/aports +alpine_git=https://git.alpinelinux.org/aports # This routine piggybacks on: https://git.alpinelinux.org/aports/tree/main/linux-headers?h=3.20-stable git clone -n --depth=1 --filter=tree:0 -b "${alpine_version}-stable" "$alpine_git" From 3d202aa8a32a8850346c1897740ebceb6784db7c Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Tue, 27 Jan 2026 19:39:15 +0100 Subject: [PATCH 17/36] Add siginfo_t::si_status (backport ) (cherry picked from commit 150f1a95603523c05e32ee5045c7ce04e00c0fae) --- src/unix/bsd/netbsdlike/openbsd/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 14003a7bcb06..0e217c9d3538 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -765,6 +765,23 @@ impl siginfo_t { } (*(self as *const siginfo_t).cast::()).value } + + pub unsafe fn si_status(&self) -> c_int { + #[repr(C)] + struct siginfo_proc { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + #[cfg(target_pointer_width = "64")] + __pad1: Padding, + _pid: crate::pid_t, + _uid: crate::uid_t, + _utime: crate::clock_t, + _stime: crate::clock_t, + _status: crate::c_int, + } + (*(self as *const siginfo_t as *const siginfo_proc))._status + } } s_no_extra_traits! { From f96d01b22324149b50893c80bc46763a233a373a Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Wed, 28 Jan 2026 00:06:43 +0100 Subject: [PATCH 18/36] Fix fields (backport ) (cherry picked from commit 3749159f5b5728b53d82a2ed7b4d25d0ac23f98c) --- src/unix/bsd/netbsdlike/openbsd/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 0e217c9d3538..3b8e8669d02c 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -770,10 +770,9 @@ impl siginfo_t { #[repr(C)] struct siginfo_proc { _si_signo: c_int, - _si_errno: c_int, _si_code: c_int, - #[cfg(target_pointer_width = "64")] - __pad1: Padding, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, _pid: crate::pid_t, _uid: crate::uid_t, _utime: crate::clock_t, From b7b5e17490bb22cc639bc452234e02191fa39a7c Mon Sep 17 00:00:00 2001 From: Markus Hosch Date: Wed, 14 Jan 2026 16:15:44 +0100 Subject: [PATCH 19/36] Add a definition of max_align_t to nto The definition of this type is a bit tricky for nto for multiple reasons: * The C definition is different from the C++ definition in some versions of the QNX SDK. * It uses long double, which does not exist inside libc. * The definition on C uses alignment modifiers per field, which aren't supported in Rust. However, since they just reuse the field type, they're actually redundant so that we can safely skip them. (backport ) (cherry picked from commit 64f2ae4ff359e748d2273d91915301e204357849) --- src/unix/nto/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 44ec4eba94da..022fb0be1f78 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -795,6 +795,23 @@ s_no_extra_traits! { pub __owner: c_uint, pub __spare: c_uint, } + + // There is no canonical definition of c_longdouble in Rust. For both AArch64 and x86_64, + // however, the size and alignment properties are that of the gcc __int128 which corresponds (at + // least on rustc 1.78+ with LLVM 18, see + // https://blog.rust-lang.org/2024/03/30/i128-layout-update/) to i128. Use this instead until we + // get native f128 support. + // + // The definition was taken from the definition of the _Maxalignt struct in the QNX SDK. + // However, on QNX7, there is a different definition of std::max_align_t (the C++ version of + // this type). In practice, this doesn't make a difference for the _alignment_ properties of the + // type - however, it changes the size, so using in in any other form than the zero-sized array + // form would be bogus and it would potentially change the size of the data type. On QNX8, this + // got fixed and both C and C++ are using the same definition. + pub struct max_align_t { + _ll: crate::c_longlong, + _ld: i128, + } } pub const _SYSNAME_SIZE: usize = 256 + 1; From 22d61d97a35a09796f151e7a102d11985d91cc86 Mon Sep 17 00:00:00 2001 From: Sebastien Marie Date: Tue, 27 Jan 2026 20:16:40 +0100 Subject: [PATCH 20/36] fix struct ptrace_thread_state on OpenBSD (backport ) (cherry picked from commit 212b9c98a0f24261bfb84be7e45314f2d06103eb) --- src/unix/bsd/netbsdlike/openbsd/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 3b8e8669d02c..050020904301 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -535,6 +535,7 @@ s! { pub struct ptrace_thread_state { pub pts_tid: crate::pid_t, + pub pts_name: [c_char; PT_PTS_NAMELEN as usize], } // search.h @@ -1522,6 +1523,8 @@ pub const PT_GET_THREAD_FIRST: c_int = 15; pub const PT_GET_THREAD_NEXT: c_int = 16; pub const PT_FIRSTMACH: c_int = 32; +pub const PT_PTS_NAMELEN: c_int = 32; + pub const SOCK_CLOEXEC: c_int = 0x8000; pub const SOCK_NONBLOCK: c_int = 0x4000; pub const SOCK_DNS: c_int = 0x1000; From 61874d800121502fd2e07d0a70e14b9a30cfa7da Mon Sep 17 00:00:00 2001 From: Sebastien Marie Date: Tue, 27 Jan 2026 20:09:27 +0100 Subject: [PATCH 21/36] OpenBSD: const correct tm_zone in struct tm https://github.com/openbsd/src/commit/4a796cf042d7cd180a2f093282195306a54bbdc4 (backport ) (cherry picked from commit 7be4e601c140d73ea137eac0b1c3054f97aef380) --- src/unix/bsd/apple/mod.rs | 14 ++++++++++++++ src/unix/bsd/freebsdlike/mod.rs | 14 ++++++++++++++ src/unix/bsd/mod.rs | 14 -------------- src/unix/bsd/netbsdlike/netbsd/mod.rs | 14 ++++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 14 ++++++++++++++ 5 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 8798dc30f804..d42f0ab16fd1 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -278,6 +278,20 @@ s! { __unused8: Padding<*mut c_void>, } + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4dc4e4a20207..0ec0eecd6ede 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -121,6 +121,20 @@ s! { __unused8: Padding<*mut c_void>, } + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 8ab3632968c9..cb4781735986 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -74,20 +74,6 @@ s! { fds_bits: [i32; FD_SETSIZE as usize / 32], } - pub struct tm { - pub tm_sec: c_int, - pub tm_min: c_int, - pub tm_hour: c_int, - pub tm_mday: c_int, - pub tm_mon: c_int, - pub tm_year: c_int, - pub tm_wday: c_int, - pub tm_yday: c_int, - pub tm_isdst: c_int, - pub tm_gmtoff: c_long, - pub tm_zone: *mut c_char, - } - pub struct msghdr { pub msg_name: *mut c_void, pub msg_namelen: crate::socklen_t, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 642582868e7f..8d5cbe0aec98 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -162,6 +162,20 @@ s! { __unused8: Padding<*mut c_void>, } + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + pub struct mq_attr { pub mq_flags: c_long, pub mq_maxmsg: c_long, diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 050020904301..08bbb1b8054c 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -84,6 +84,20 @@ s! { __unused7: Padding<*mut c_void>, } + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + pub struct lconv { pub decimal_point: *mut c_char, pub thousands_sep: *mut c_char, From ce0bd367fcfb0f092caa2842eb598d275a69d147 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 29 Jan 2026 12:26:25 +0000 Subject: [PATCH 22/36] triagebot: Switch to `check-commits = "uncanonicalized"` There is now the option to check for `#xxxx`-style issue numbers that aren't attached to a specific repo. Enable it here. (backport ) (cherry picked from commit 890942ec61ae16fb10c0c305d29e8f53048ad352) --- triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index f01074c5e939..75cd387f76f1 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -13,7 +13,7 @@ contributing_url = "https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md" # Ensure issue links link to this repo [issue-links] -check-commits = false # don't forbid links to issues +check-commits = "uncanonicalized" # Enable comments linking to triagebot range-diff when a PR is rebased # onto a different base commit From ffeb6b9d7093ec7f70f89372d4ad52ac516f06fa Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 29 Jan 2026 12:39:55 +0000 Subject: [PATCH 23/36] triagebot: Simplify mention and autolabel config Simplify mentions and autolabels using the recently added glob support. (backport ) (cherry picked from commit 29eb6a680010778c4b4d6ef4a59583be025fe0f6) --- triagebot.toml | 153 ++++++++++--------------------------------------- 1 file changed, 30 insertions(+), 123 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index 75cd387f76f1..20684b995a27 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -24,167 +24,74 @@ check-commits = "uncanonicalized" trigger_files = [ ".cirrus.yml", ".github", - "src/ci", + "ci", ] [autolabel."S-waiting-on-review"] new_pr = true [autolabel."O-android"] -trigger_files = [ - "src/new/bionic_libc", - "src/unix/linux_like/android", -] +trigger_files = ["*{android,bionic}*"] [autolabel."O-arm"] -trigger_files = [ - "src/solid/arm.rs", - "src/unix/bsd/freebsdlike/freebsd/arm.rs", - "src/unix/bsd/netbsdlike/netbsd/arm.rs", - "src/unix/bsd/netbsdlike/openbsd/arm.rs", - "src/unix/linux_like/android/b32/arm.rs", - "src/unix/linux_like/linux/gnu/b32/arm/", - "src/unix/linux_like/linux/musl/b32/arm/", - "src/unix/linux_like/linux/uclibc/arm/", - "src/unix/newlib/arm/", - "src/vxworks/arm.rs", -] +trigger_files = ["*arm*"] [autolabel."O-bsd"] -trigger_files = ["src/unix/bsd/mod.rs"] +trigger_files = ["*bsd*"] [autolabel."O-dragonfly"] -trigger_files = ["src/unix/bsd/freebsdlike/dragonfly"] +trigger_files = ["*dragonfly*"] [autolabel."O-gnu"] -trigger_files = [ - "src/unix/linux_like/linux/gnu", - "src/windows/gnu", -] +trigger_files = ["*gnu*"] [autolabel."O-illumos"] -trigger_files = ["src/unix/solarish/illumos.rs"] +trigger_files = ["*illumos*"] [autolabel."O-linux"] -trigger_files = [ - "src/unix/linux_like/linux", - "src/new/linux_uapi", -] +trigger_files = ["*linux*"] [autolabel."O-linux-like"] -trigger_files = ["src/unix/linux_like/mod.rs"] +trigger_files = ["*linux_like*"] [autolabel."O-macos"] -trigger_files = [ - "src/unix/bsd/apple", - "src/new/apple_lib", - "src/new/apple_xnu", -] +trigger_files = ["*apple*"] [autolabel."O-mips"] -trigger_files = [ - "src/unix/bsd/netbsdlike/netbsd/mips.rs", - "src/unix/bsd/netbsdlike/openbsd/mips64.rs", - "src/unix/linux_like/linux/arch/mips", - "src/unix/linux_like/linux/gnu/b32/mips", - "src/unix/linux_like/linux/gnu/b64/mips64", - "src/unix/linux_like/linux/musl/b32/mips", - "src/unix/linux_like/linux/musl/b64/mips64.rs", - "src/unix/linux_like/linux/uclibc/mips", -] +trigger_files = ["*mips*"] [autolabel."O-musl"] -trigger_files = ["src/unix/linux_like/linux/musl"] +trigger_files = ["*musl*"] [autolabel."O-newlib"] -trigger_files = ["src/unix/newlib"] +trigger_files = ["*newlib*"] [autolabel."O-powerpc"] -trigger_files = [ - "src/unix/aix/powerpc64.rs", - "src/unix/bsd/freebsdlike/freebsd/powerpc.rs", - "src/unix/bsd/freebsdlike/freebsd/powerpc64.rs", - "src/unix/bsd/netbsdlike/netbsd/powerpc.rs", - "src/unix/bsd/netbsdlike/openbsd/powerpc.rs", - "src/unix/bsd/netbsdlike/openbsd/powerpc64.rs", - "src/unix/linux_like/linux/arch/powerpc/", - "src/unix/linux_like/linux/gnu/b32/powerpc.rs", - "src/unix/linux_like/linux/gnu/b64/powerpc64/", - "src/unix/linux_like/linux/musl/b32/powerpc.rs", - "src/unix/linux_like/linux/musl/b64/powerpc64.rs", - "src/unix/newlib/powerpc/", - "src/vxworks/powerpc.rs", - "src/vxworks/powerpc64.rs", -] +trigger_files = ["*powerpc*"] [autolabel."O-redox"] -trigger_files = ["src/unix/redox"] +trigger_files = ["*redox*"] [autolabel."O-riscv"] -trigger_files = [ - "src/fuchsia/riscv64.rs", - "src/unix/bsd/freebsdlike/freebsd/riscv64.rs", - "src/unix/bsd/netbsdlike/netbsd/riscv64.rs", - "src/unix/bsd/netbsdlike/openbsd/riscv64.rs", - "src/unix/linux_like/android/b64/riscv64", - "src/unix/linux_like/linux/gnu/b32/riscv32", - "src/unix/linux_like/linux/gnu/b64/riscv64", - "src/unix/linux_like/linux/musl/b32/riscv32", - "src/unix/linux_like/linux/musl/b64/riscv64", - "src/vxworks/riscv32.rs", - "src/vxworks/riscv64.rs", -] +trigger_files = ["*riscv*"] [autolabel."O-solarish"] -trigger_files = ["src/unix/solarish"] +trigger_files = ["*solarish*"] [autolabel."O-sparc"] -trigger_files = [ - "src/unix/bsd/netbsdlike/netbsd/sparc64.rs", - "src/unix/bsd/netbsdlike/openbsd/sparc64.rs", - "src/unix/linux_like/linux/arch/sparc", - "src/unix/linux_like/linux/gnu/b32/sparc", - "src/unix/linux_like/linux/gnu/b64/sparc64", -] +trigger_files = ["*sparc*"] [autolabel."O-unix"] -trigger_files = ["src/unix"] +trigger_files = ["*unix*"] [autolabel."O-wasi"] -trigger_files = ["src/wasi"] +trigger_files = ["*{wasi,wasm}*"] [autolabel."O-windows"] -trigger_files = ["src/windows"] +trigger_files = ["*windows*"] [autolabel."O-x86"] -trigger_files = [ - "src/fuchsia/x86_64.rs", - "src/unix/bsd/apple/b64/x86_64", - "src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs", - "src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs", - "src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs", - "src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs", - "src/unix/bsd/freebsdlike/freebsd/x86.rs", - "src/unix/bsd/freebsdlike/freebsd/x86_64", - "src/unix/bsd/netbsdlike/netbsd/x86.rs", - "src/unix/bsd/netbsdlike/netbsd/x86_64.rs", - "src/unix/bsd/netbsdlike/openbsd/x86.rs", - "src/unix/bsd/netbsdlike/openbsd/x86_64.rs", - "src/unix/haiku/x86_64.rs", - "src/unix/linux_like/android/b32/x86", - "src/unix/linux_like/android/b64/x86_64", - "src/unix/linux_like/linux/gnu/b32/x86", - "src/unix/linux_like/linux/gnu/b64/x86_64", - "src/unix/linux_like/linux/musl/b32/x86", - "src/unix/linux_like/linux/musl/b64/x86_64", - "src/unix/linux_like/linux/uclibc/x86_64", - "src/unix/nto/x86_64.rs", - "src/unix/solarish/x86.rs", - "src/unix/solarish/x86_64.rs", - "src/unix/solarish/x86_common.rs", - "src/vxworks/x86.rs", - "src/vxworks/x86_64.rs", -] +trigger_files = ["*{x86,i?86}"] [autolabel.ctest] trigger_files = [ @@ -206,18 +113,18 @@ add_labels = ["S-waiting-on-review"] [shortcut] -[mentions."src/unix/bsd/netbsdlike/openbsd"] -message = "Some changes occurred in OpenBSD module" +[mentions."*openbsd*"] +message = "Some changes occurred in an OpenBSD module" cc = ["@semarie"] -[mentions."src/unix/bsd/netbsdlike/mod.rs"] -message = "Some changes occurred in OpenBSD module" +[mentions."*netbsdlike*"] +message = "Some changes occurred in a NetBSD-like module" cc = ["@semarie"] -[mentions."src/unix/solarish"] -message = "Some changes occurred in solarish module" +[mentions."*solarish*"] +message = "Some changes occurred in a solarish module" cc = ["@jclulow", "@pfmooney"] -[mentions."src/unix/linux_like/android"] -message = "Some changes occurred in the Android module" +[mentions."*android*"] +message = "Some changes occurred in an Android module" cc = ["@maurer"] From b7382a44298debc5791353fd5429abadedfc87a0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 29 Jan 2026 12:52:26 +0000 Subject: [PATCH 24/36] aix: Temporarily skip checking powerpc64-ibm-aix builds This target doesn't build in the latest nightly. Link: https://github.com/rust-lang/rust/issues/151818 (backport ) (cherry picked from commit e98800a3cf17cd022d9e27d7f312df5a9692d6d3) --- ci/verify-build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/verify-build.py b/ci/verify-build.py index b3b35f1c6e0b..fb0051bec0b0 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -181,7 +181,8 @@ class TargetResult: Target("powerpc-unknown-netbsd", dist=False), Target("powerpc-wrs-vxworks", dist=False), Target("powerpc-wrs-vxworks-spe", dist=False), - Target("powerpc64-ibm-aix", dist=False), + # FIXME(rust#151818) doesn't build with the 2026-01-28 nightly + # Target("powerpc64-ibm-aix", dist=False), Target("powerpc64-unknown-freebsd", dist=False), Target("powerpc64-wrs-vxworks", dist=False), Target("riscv32-wrs-vxworks", dist=False), From ebea0e73d5cd4b6bde6080732a15f90525ccfc6b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 29 Jan 2026 13:03:41 +0000 Subject: [PATCH 25/36] triagebot: Add an autolabel for FreeBSD (backport ) (cherry picked from commit 3265b902caf7e59a453462850f4230864610b3b7) --- triagebot.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index 20684b995a27..c192178a9baa 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -42,6 +42,9 @@ trigger_files = ["*bsd*"] [autolabel."O-dragonfly"] trigger_files = ["*dragonfly*"] +[autolabel."O-freebsd"] +trigger_files = ["*freebsd*"] + [autolabel."O-gnu"] trigger_files = ["*gnu*"] From 0e3653cb780c97a8a5cef8e94378718e67e77c6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:48:56 +0000 Subject: [PATCH 26/36] build(deps): bump vmactions/solaris-vm from 1.2.6 to 1.2.8 Bumps [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) from 1.2.6 to 1.2.8. - [Release notes](https://github.com/vmactions/solaris-vm/releases) - [Commits](https://github.com/vmactions/solaris-vm/compare/v1.2.6...v1.2.8) --- updated-dependencies: - dependency-name: vmactions/solaris-vm dependency-version: 1.2.8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit 97e68897a6465b89229ef436e741f7b5f91599d1) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 106b28086343..02c0a7a7592f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -272,7 +272,7 @@ jobs: steps: - uses: actions/checkout@v6 - name: test on Solaris - uses: vmactions/solaris-vm@v1.2.6 + uses: vmactions/solaris-vm@v1.2.8 if: contains(matrix.target, 'solaris') with: release: "11.4-gcc" From 206e25492a7c83bec2595e2f80ae0cc9444172e2 Mon Sep 17 00:00:00 2001 From: LiamSnow Date: Tue, 3 Feb 2026 10:46:13 -0500 Subject: [PATCH 27/36] illumos: Add _CS_PATH constant (backport ) (cherry picked from commit 293d8cf46563cd43d4926855725776ad7840167f) --- libc-test/semver/illumos.txt | 1 + src/unix/solarish/illumos.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index 67d990269d27..54c3afbfbf90 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -19,6 +19,7 @@ TFD_CLOEXEC TFD_NONBLOCK TFD_TIMER_ABSTIME TFD_TIMER_CANCEL_ON_SET +_CS_PATH posix_fadvise posix_fallocate posix_spawn_file_actions_addfchdir_np diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index c0a17823bb9a..50e6302e7c9e 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -154,6 +154,8 @@ pub const LOCK_UN: c_int = 8; pub const _PC_LAST: c_int = 101; +pub const _CS_PATH: c_int = 65; + pub const VSTATUS: usize = 16; pub const VERASE2: usize = 17; From df80fe0d5e726291b1625c5fc9f22d13f2f68033 Mon Sep 17 00:00:00 2001 From: Goat Date: Wed, 4 Feb 2026 04:24:26 +0300 Subject: [PATCH 28/36] OpenBSD: add `ppoll` (backport ) (cherry picked from commit 9c7cb28edf38af51bb0936519a5692c1a0b47228) --- libc-test/semver/openbsd.txt | 1 + src/unix/bsd/netbsdlike/mod.rs | 6 ++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 ------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 42bd6ac72279..1dcda9147f12 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1253,6 +1253,7 @@ posix_spawnattr_setschedpolicy posix_spawnattr_setsigdefault posix_spawnattr_setsigmask posix_spawnp +ppoll preadv pseudo_AF_HDRCMPLT pseudo_AF_PFLOW diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index e1edcf9ffdc0..ac0d91286b5b 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -734,6 +734,12 @@ extern "C" { param: *mut sched_param, ) -> c_int; pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + pub fn ppoll( + fds: *mut crate::pollfd, + nfds: crate::nfds_t, + ts: *const crate::timespec, + sigmask: *const crate::sigset_t, + ) -> c_int; pub fn getgrouplist( name: *const c_char, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 8d5cbe0aec98..ffbc543d3302 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2195,12 +2195,6 @@ extern "C" { ts: *const crate::timespec, sigmask: *const crate::sigset_t, ) -> c_int; - pub fn ppoll( - fds: *mut crate::pollfd, - nfds: crate::nfds_t, - ts: *const crate::timespec, - sigmask: *const crate::sigset_t, - ) -> c_int; pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; pub fn reboot(mode: c_int, bootstr: *mut c_char) -> c_int; From 80743a163aa2b52d3bcd6fde93149ba9038dcb89 Mon Sep 17 00:00:00 2001 From: usamoi Date: Sat, 24 Jan 2026 17:34:20 +0800 Subject: [PATCH 29/36] links old version of tc{g,s}etattr for glibc on mips(64) and sparc(64) (backport ) (cherry picked from commit 6abfe754557bcdea7429f215ea3e60b1d225dc96) --- libc-test/build.rs | 4 ++++ src/unix/mod.rs | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index cf4c76054135..2dfbde6cc95d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3837,6 +3837,7 @@ fn test_linux(target: &str) { let ppc64 = target.contains("powerpc64"); let ppc32 = ppc && !ppc64; let s390x = target.contains("s390x"); + let sparc = target.contains("sparc"); let sparc64 = target.contains("sparc64"); let x32 = target.contains("x32"); let x86_32 = target.contains("i686"); @@ -4979,6 +4980,9 @@ fn test_linux(target: &str) { ] .contains(&s) }); + if mips || sparc { + cfg.skip_fn_ptrcheck(|s| ["tcgetattr", "tcsetattr"].contains(&s)); + } } ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 1b74684cbbb2..7ab584170afa 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1973,7 +1973,31 @@ extern "C" { link_name = "cfsetospeed@GLIBC_2.16" )] pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc"), + ), + link_name = "tcgetattr@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "tcgetattr@GLIBC_2.2" + )] pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int; + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc"), + ), + link_name = "tcsetattr@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "tcsetattr@GLIBC_2.2" + )] pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int; pub fn tcflow(fd: c_int, action: c_int) -> c_int; pub fn tcflush(fd: c_int, action: c_int) -> c_int; From 2d400c8b2a7983f83347ba014c20396eb49b3891 Mon Sep 17 00:00:00 2001 From: usamoi Date: Sat, 24 Jan 2026 17:36:31 +0800 Subject: [PATCH 30/36] links old version for glibc on mips{32,64}r6 (backport ) (cherry picked from commit 49acdc680c0304c68fdba2fdcbea45ad20f14537) --- src/unix/mod.rs | 76 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 7ab584170afa..ac411f152f94 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1614,7 +1614,11 @@ extern "C" { link_name = "cfgetispeed@GLIBC_2.0" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), link_name = "cfgetispeed@GLIBC_2.0" )] #[cfg_attr( @@ -1642,7 +1646,11 @@ extern "C" { link_name = "cfgetispeed@GLIBC_2.36" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips64"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), link_name = "cfgetispeed@GLIBC_2.0" )] #[cfg_attr( @@ -1707,7 +1715,11 @@ extern "C" { link_name = "cfgetospeed@GLIBC_2.0" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), link_name = "cfgetospeed@GLIBC_2.0" )] #[cfg_attr( @@ -1735,7 +1747,11 @@ extern "C" { link_name = "cfgetospeed@GLIBC_2.36" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips64"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), link_name = "cfgetospeed@GLIBC_2.0" )] #[cfg_attr( @@ -1800,7 +1816,11 @@ extern "C" { link_name = "cfsetispeed@GLIBC_2.0" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), link_name = "cfsetispeed@GLIBC_2.0" )] #[cfg_attr( @@ -1828,7 +1848,11 @@ extern "C" { link_name = "cfsetispeed@GLIBC_2.36" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips64"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), link_name = "cfsetispeed@GLIBC_2.0" )] #[cfg_attr( @@ -1893,7 +1917,11 @@ extern "C" { link_name = "cfsetospeed@GLIBC_2.0" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), link_name = "cfsetospeed@GLIBC_2.0" )] #[cfg_attr( @@ -1921,7 +1949,11 @@ extern "C" { link_name = "cfsetospeed@GLIBC_2.36" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips64"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), link_name = "cfsetospeed@GLIBC_2.0" )] #[cfg_attr( @@ -1977,7 +2009,13 @@ extern "C" { all( target_os = "linux", target_env = "gnu", - any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc"), + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "sparc" + ), ), link_name = "tcgetattr@GLIBC_2.0" )] @@ -1990,7 +2028,13 @@ extern "C" { all( target_os = "linux", target_env = "gnu", - any(target_arch = "mips", target_arch = "mips64", target_arch = "sparc"), + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "sparc" + ), ), link_name = "tcsetattr@GLIBC_2.0" )] @@ -2299,7 +2343,11 @@ cfg_if! { link_name = "cfsetspeed@GLIBC_2.0" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), link_name = "cfsetspeed@GLIBC_2.0" )] #[cfg_attr( @@ -2327,7 +2375,11 @@ cfg_if! { link_name = "cfsetspeed@GLIBC_2.36" )] #[cfg_attr( - all(target_os = "linux", target_env = "gnu", target_arch = "mips64"), + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), link_name = "cfsetspeed@GLIBC_2.0" )] #[cfg_attr( From 4b6e0ad1f3d9a28a349ebf1517ef49ebdd34ff00 Mon Sep 17 00:00:00 2001 From: usamoi Date: Wed, 28 Jan 2026 18:48:18 +0800 Subject: [PATCH 31/36] fix libc-test ctest on mips64 and sparc64 (backport ) (cherry picked from commit 36bd27a827135653fae59d87efae8aba10c2a2b8) --- libc-test/build.rs | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 2dfbde6cc95d..70a78d8ea2be 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4961,27 +4961,37 @@ fn test_linux(target: &str) { if gnu { // old constants, so tests fail if glibc is too new cfg.skip_const(|s| { + // grep -E -h '^B([0-9])*$' libc-test/semver/* [ - "B50", "B75", "B110", "B134", "B150", "B200", "B300", "B600", "B1200", "B1800", - "B2400", "B4800", "B9600", "B19200", "B38400", "EXTA", "EXTB", "B57600", "B115200", - "B230400", "B460800", "B500000", "B576000", "B921600", "B1000000", "B1152000", - "B1500000", "B2000000", "B2500000", "B3000000", "B3500000", "B4000000", + "EXTA", "EXTB", "B0", "B1000000", "B110", "B115200", "B1152000", "B1200", "B134", + "B14400", "B150", "B1500000", "B153600", "B1800", "B19200", "B200", "B2000000", + "B230400", "B2400", "B2500000", "B28800", "B300", "B3000000", "B307200", + "B3500000", "B38400", "B4000000", "B460800", "B4800", "B50", "B500000", "B57600", + "B576000", "B600", "B614400", "B7200", "B75", "B76800", "B921600", "B9600", ] .contains(&s.ident()) }); + if mips || sparc { + cfg.skip_const(|s| s.ident() == "NCCS"); + } // old symbols, so tests fail if glibc is too new - cfg.skip_fn_ptrcheck(|s| { - [ - "cfgetispeed", - "cfgetospeed", - "cfsetispeed", - "cfsetospeed", - "cfsetspeed", - ] - .contains(&s) + // note: `skip_fn_ptrcheck` overrides the previous function + cfg.skip_fn_ptrcheck(move |s| { + let mut result = false; + result = result || s == "cfgetispeed"; + result = result || s == "cfgetospeed"; + result = result || s == "cfsetispeed"; + result = result || s == "cfsetospeed"; + result = result || s == "cfsetspeed"; + if mips || sparc { + result = result || s == "tcgetattr"; + result = result || s == "tcsetattr"; + } + result }); + // old structs, so tests fail if glibc is too new if mips || sparc { - cfg.skip_fn_ptrcheck(|s| ["tcgetattr", "tcsetattr"].contains(&s)); + cfg.skip_struct(|s| s.ident() == "termios"); } } From aa6a84e6fe90bfeb4e6e8351ee36adbd3fa7f8f8 Mon Sep 17 00:00:00 2001 From: usamoi Date: Wed, 28 Jan 2026 21:05:47 +0800 Subject: [PATCH 32/36] checks termios size in the baud test (backport ) (cherry picked from commit 44b709c241d5b007927cb3daecb7a19d7a4f53cc) --- libc-test/tests/linux_gnu_baud.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/libc-test/tests/linux_gnu_baud.rs b/libc-test/tests/linux_gnu_baud.rs index f38ab6326eb6..db8f5f939342 100644 --- a/libc-test/tests/linux_gnu_baud.rs +++ b/libc-test/tests/linux_gnu_baud.rs @@ -13,21 +13,24 @@ fn baud() { assert!(ret >= 0); let terminal_fd = unsafe { open(buffer.as_ptr(), O_RDWR | O_NOCTTY) }; assert!(terminal_fd >= 0); - let mut tio: termios = unsafe { std::mem::zeroed() }; - let ret = unsafe { tcgetattr(terminal_fd, &mut tio) }; + #[repr(C)] + struct Protector(termios, [u8; 512]); + let mut tio: Protector = unsafe { Protector(std::mem::zeroed(), [0xcc; _]) }; + let ret = unsafe { tcgetattr(terminal_fd, &raw mut tio.0) }; assert!(ret >= 0); - assert_eq!(unsafe { cfgetispeed(&tio) }, B38400); - assert_eq!(unsafe { cfgetospeed(&tio) }, B38400); - let ret = unsafe { cfsetspeed(&mut tio, B1000000) }; + assert_eq!(tio.1, [0xcc; _]); + assert_eq!(unsafe { cfgetispeed(&tio.0) }, B38400); + assert_eq!(unsafe { cfgetospeed(&tio.0) }, B38400); + let ret = unsafe { cfsetspeed(&mut tio.0, B1000000) }; assert!(ret >= 0); - assert_eq!(unsafe { cfgetispeed(&tio) }, B1000000); - assert_eq!(unsafe { cfgetospeed(&tio) }, B1000000); - let ret = unsafe { cfsetispeed(&mut tio, B9600) }; + assert_eq!(unsafe { cfgetispeed(&tio.0) }, B1000000); + assert_eq!(unsafe { cfgetospeed(&tio.0) }, B1000000); + let ret = unsafe { cfsetispeed(&mut tio.0, B9600) }; assert!(ret >= 0); - assert_eq!(unsafe { cfgetispeed(&tio) }, B9600); - assert!(matches!(unsafe { cfgetospeed(&tio) }, B9600 | B1000000)); - let ret = unsafe { cfsetospeed(&mut tio, B19200) }; + assert_eq!(unsafe { cfgetispeed(&tio.0) }, B9600); + assert!(matches!(unsafe { cfgetospeed(&tio.0) }, B9600 | B1000000)); + let ret = unsafe { cfsetospeed(&mut tio.0, B19200) }; assert!(ret >= 0); - assert!(matches!(unsafe { cfgetispeed(&tio) }, B9600 | B19200)); - assert_eq!(unsafe { cfgetospeed(&tio) }, B19200); + assert!(matches!(unsafe { cfgetispeed(&tio.0) }, B9600 | B19200)); + assert_eq!(unsafe { cfgetospeed(&tio.0) }, B19200); } From 1f7ace01e68a23d5514675b340668237229bf823 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 4 Feb 2026 21:15:38 +1100 Subject: [PATCH 33/36] Remove `__item!`. It doesn't seem necessary. It dates back to a large commit "Let's just juggle everything around!" from the very old mega-PR rust-lang/libc#21. [ removed in `e!` as well for the cherry pick since that macro couldn't be removed yet on this branch - Trevor ] (backport ) (cherry picked from commit 09cb34df9d3898886a88668d3933a814d83a46cc) --- src/macros.rs | 110 +++++++++++++++++++++----------------------------- 1 file changed, 47 insertions(+), 63 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 9d3c0e7b534e..fb7733889fed 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -153,21 +153,19 @@ macro_rules! s { ); (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( - __item! { - #[repr(C)] - #[::core::prelude::v1::derive( - ::core::clone::Clone, - ::core::marker::Copy, - ::core::fmt::Debug, - )] - #[cfg_attr( - feature = "extra_traits", - ::core::prelude::v1::derive(Eq, Hash, PartialEq) - )] - #[allow(deprecated)] - $(#[$attr])* - $pub struct $i { $($field)* } - } + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] + #[allow(deprecated)] + $(#[$attr])* + $pub struct $i { $($field)* } ); } @@ -180,19 +178,17 @@ macro_rules! s_paren { $(#[$attr:meta])* pub struct $i:ident ( $($field:tt)* ); )*) => ($( - __item! { - #[cfg_attr( - feature = "extra_traits", - ::core::prelude::v1::derive(Eq, Hash, PartialEq) - )] - #[::core::prelude::v1::derive( - ::core::clone::Clone, - ::core::marker::Copy, - ::core::fmt::Debug, - )] - $(#[$attr])* - pub struct $i ( $($field)* ); - } + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + $(#[$attr])* + pub struct $i ( $($field)* ); )*); } @@ -209,12 +205,10 @@ macro_rules! s_no_extra_traits { )*); (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( - __item! { - #[repr(C)] - #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] - $(#[$attr])* - $pub union $i { $($field)* } - } + #[repr(C)] + #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] + $(#[$attr])* + $pub union $i { $($field)* } impl ::core::fmt::Debug for $i { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -224,16 +218,14 @@ macro_rules! s_no_extra_traits { ); (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( - __item! { - #[repr(C)] - #[::core::prelude::v1::derive( - ::core::clone::Clone, - ::core::marker::Copy, - ::core::fmt::Debug, - )] - $(#[$attr])* - $pub struct $i { $($field)* } - } + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + $(#[$attr])* + $pub struct $i { $($field)* } ); } @@ -268,19 +260,17 @@ macro_rules! e { $(#[$attr:meta])* pub enum $i:ident { $($field:tt)* } )*) => ($( - __item! { - #[cfg_attr( - feature = "extra_traits", - ::core::prelude::v1::derive(Eq, Hash, PartialEq) - )] - #[::core::prelude::v1::derive( - ::core::clone::Clone, - ::core::marker::Copy, - ::core::fmt::Debug, - )] - $(#[$attr])* - pub enum $i { $($field)* } - } + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + $(#[$attr])* + pub enum $i { $($field)* } )*); } @@ -407,12 +397,6 @@ macro_rules! safe_f { )+}; } -macro_rules! __item { - ($i:item) => { - $i - }; -} - // This macro is used to deprecate items that should be accessed via the mach2 crate macro_rules! deprecated_mach { (pub const $id:ident: $ty:ty = $expr:expr;) => { From f08368cfb241bb3317a923ad19843a5ed5fd659c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 4 Feb 2026 21:15:49 +1100 Subject: [PATCH 34/36] Macro cleanups. - Fix comments that incorrectly say that `Debug` is part of `extra_traits`. - Use a consistent and sensible ordering for the traits: Clone, Copy, Debug; then PartialEq, Eq, Hash. - Explain `repr` behaviour for `s_paren!`; it's different to `s!` and `s_no_extra_traits!`. - Use `$pub:vis` (instead of a hard-wired `pub`) in `s_paren!` for consistency with the other macros. (backport ) (cherry picked from commit 7983094659150b8c291cd8ae011cfda3c88c8c7d) --- src/macros.rs | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index fb7733889fed..2d2d39088471 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -135,8 +135,10 @@ macro_rules! prelude { }; } -/// Implement `Clone` and `Copy` for a struct, as well as `Debug`, `Eq`, `Hash`, and -/// `PartialEq` if the `extra_traits` feature is enabled. +/// Implement `Clone`, `Copy`, and `Debug` for one or more structs, as well as `PartialEq`, `Eq`, +/// and `Hash` if the `extra_traits` feature is enabled. +/// +/// Also mark the type with `repr(C)`. /// /// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not /// make sense, and for unions. @@ -161,7 +163,7 @@ macro_rules! s { )] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(Eq, Hash, PartialEq) + ::core::prelude::v1::derive(PartialEq, Eq, Hash) )] #[allow(deprecated)] $(#[$attr])* @@ -169,33 +171,36 @@ macro_rules! s { ); } -/// Implement `Clone` and `Copy` for a tuple struct, as well as `Debug`, `Eq`, `Hash`, -/// and `PartialEq` if the `extra_traits` feature is enabled. +/// Implement `Clone`, `Copy`, and `Debug` for a tuple struct, as well as `PartialEq`, `Eq`, +/// and `Hash` if the `extra_traits` feature is enabled. /// -/// This is the same as [`s`] but works for tuple structs. +/// Unlike `s!`, this does *not* mark the type with `repr(C)`. Users should provide their own +/// `repr` attribute via `$attr` as necessary. macro_rules! s_paren { ($( $(#[$attr:meta])* - pub struct $i:ident ( $($field:tt)* ); + $pub:vis struct $i:ident ( $($field:tt)* ); )*) => ($( - #[cfg_attr( - feature = "extra_traits", - ::core::prelude::v1::derive(Eq, Hash, PartialEq) - )] #[::core::prelude::v1::derive( ::core::clone::Clone, ::core::marker::Copy, ::core::fmt::Debug, )] + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(PartialEq, Eq, Hash) + )] $(#[$attr])* - pub struct $i ( $($field)* ); + $pub struct $i ( $($field)* ); )*); } -/// Implement `Clone`, `Copy`, and `Debug` since those can be derived, but exclude `PartialEq`, +/// Implement `Clone`, `Copy`, and `Debug` for one or more structs/unions, but exclude `PartialEq`, /// `Eq`, and `Hash`. /// -/// Most items will prefer to use [`s`]. +/// Also mark the type with `repr(C)`. +/// +/// Most structs will prefer to use [`s`]. macro_rules! s_no_extra_traits { ($( $(#[$attr:meta])* @@ -206,7 +211,10 @@ macro_rules! s_no_extra_traits { (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( #[repr(C)] - #[::core::prelude::v1::derive(::core::clone::Clone, ::core::marker::Copy)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + )] $(#[$attr])* $pub union $i { $($field)* } From 29ec6dd4d58db5a622150a93b1ddcf2f827f8b66 Mon Sep 17 00:00:00 2001 From: Marco Cavenati Date: Thu, 5 Feb 2026 09:39:24 +0100 Subject: [PATCH 35/36] CI linux: Move to Ubuntu25.04 for i686 (backport ) (cherry picked from commit 9766a977909f86bc0ee952fa19f08e92b9feb871) --- ci/docker/i686-unknown-linux-gnu/Dockerfile | 7 ++----- ci/docker/i686-unknown-linux-musl/Dockerfile | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ci/docker/i686-unknown-linux-gnu/Dockerfile b/ci/docker/i686-unknown-linux-gnu/Dockerfile index 5a2f4c9dd43e..b1596071b8f6 100644 --- a/ci/docker/i686-unknown-linux-gnu/Dockerfile +++ b/ci/docker/i686-unknown-linux-gnu/Dockerfile @@ -1,9 +1,6 @@ -FROM ubuntu:23.10 +FROM ubuntu:25.04 -# FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time -RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ - /etc/apt/sources.list && \ - apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ gcc-multilib \ libc6-dev diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index ce3abd0e538c..225823d6143c 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -1,9 +1,6 @@ -FROM ubuntu:23.10 +FROM ubuntu:25.04 -# FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time -RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ - /etc/apt/sources.list && \ - dpkg --add-architecture i386 && \ +RUN dpkg --add-architecture i386 && \ apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ From 5aced37cd826f739120ea48f2e4da62c68acb9e1 Mon Sep 17 00:00:00 2001 From: Marco Cavenati Date: Thu, 5 Feb 2026 09:41:16 +0100 Subject: [PATCH 36/36] tests linux: do not skip tests requiring kernel <= 6.8 64 bit Linux images used in CI are on kernel 6.11, headers are >=6.8 at the time of writing. Skip the tests requiring kernel >=6.8 only on 32-bit archs, that are still on old headers due to 64 bit time_t, and for musl targets that have old headers as well. (backport ) (cherry picked from commit 145625074f5dc8e0fe4dceed6014c8650471c69a) --- libc-test/build.rs | 57 +++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 70a78d8ea2be..b6685927d355 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2161,9 +2161,6 @@ fn test_android(target: &str) { // Needs a newer Android SDK for the definition "P_PIDFD" => true, - // Requires Linux kernel 5.6 - "VMADDR_CID_LOCAL" => true, - // FIXME(android): conflicts with standard C headers and is tested in // `linux_termios.rs` below: "BOTHER" => true, @@ -2172,28 +2169,10 @@ fn test_android(target: &str) { // is a private value for kernel usage normally "FUSE_SUPER_MAGIC" => true, - // linux 5.12 min - "MPOL_F_NUMA_BALANCING" => true, // GRND_INSECURE was added in platform-tools-30.0.0 "GRND_INSECURE" => true, - // kernel 5.10 minimum required - "MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ" | "MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ" => true, - - // kernel 5.18 minimum - | "MADV_COLD" - | "MADV_DONTNEED_LOCKED" - | "MADV_PAGEOUT" - | "MADV_POPULATE_READ" - | "MADV_POPULATE_WRITE" => true, - - // kernel 5.6 minimum required - "IPPROTO_MPTCP" | "IPPROTO_ETHERNET" => true, - - // kernel 6.2 minimum - "TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true, - // FIXME(android): NDK r22 minimum required | "FDB_NOTIFY_BIT" | "FDB_NOTIFY_INACTIVE_BIT" @@ -3810,6 +3789,13 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { fn test_linux(target: &str) { assert!(target.contains("linux") || target.contains("l4re")); + // FIXME(linux32): Some 32 bit targets use old kernel headers because newer distros enforce 64 + // bit time. Use this to avoid skipping tests also on 64 bit targets. + let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH") + .unwrap_or_default() + .parse::() + .unwrap_or_default(); + // target_os let linux = target.contains("linux"); let l4re = target.contains("l4re"); @@ -4186,7 +4172,7 @@ fn test_linux(target: &str) { cfg.skip_struct(move |struct_| { let ty = struct_.ident(); - // FIXME(linux): CI has old headers + // FIXME(linux): Requires >= 6.12 kernel headers. CI has old headers if ty == "ptp_sys_offset_extended" { return true; } @@ -4256,14 +4242,17 @@ fn test_linux(target: &str) { "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, - // FIXME(linux): Requires >= 6.8 kernel headers. - // A field was added in 6.8. + // FIXME(musl): A field was added in linux 6.8, not yet in musl + // FIXME(linux32): A field was added in linux 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, + "xdp_umem_reg" if musl || pointer_width == 32 => true, - // FIXME(linux): Requires >= 6.8 kernel headers. + // FIXME(1.0,linux): A new field was added to `xsk_tx_metadata_request` in linux 6.15. + // https://github.com/torvalds/linux/commit/ca4419f15abd19ba8be1e109661b60f9f5b6c9f0 + // When updating, consider giving the `__c_anonymous_` prefix to the enum variants + // `xsk_tx_metadata_request` and `xsk_tx_metadata_completion`. "xsk_tx_metadata" | "xsk_tx_metadata_request" | "xsk_tx_metadata_completion" => true, // A new field was added in kernel 5.4, this is the old version for backwards compatibility. @@ -4575,17 +4564,22 @@ fn test_linux(target: &str) { true } - // FIXME(linux): Requires >= 6.6 kernel headers. - "XDP_USE_SG" | "XDP_PKT_CONTD" => true, + // FIXME(linux32): Requires >= 6.6 kernel headers. + "XDP_USE_SG" | "XDP_PKT_CONTD" if pointer_width == 32 => true, // FIXME(linux): Missing only on this platform for some reason "PR_MDWE_NO_INHERIT" if gnueabihf => true, - // FIXME(linux): Requires >= 6.8 kernel headers. + // FIXME(musl): Not yet in musl + // FIXME(linux32): Requires >= 6.8 kernel headers. "XDP_UMEM_TX_SW_CSUM" | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" - | "XDP_TX_METADATA" => true, + | "XDP_TX_METADATA" + if musl || pointer_width == 32 => + { + true + } // FIXME(linux): Requires >= 6.11 kernel headers. "XDP_UMEM_TX_METADATA_LEN" => true, @@ -4601,9 +4595,6 @@ fn test_linux(target: &str) { true } - // FIXME(linux): Requires >= 6.6 kernel headers. - "SYS_fchmodat2" => true, - // FIXME(linux): Requires >= 6.10 kernel headers. "SYS_mseal" => true,