From bad06bb2398e4892668fb1e84242ab44108e53ba Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 11 May 2025 22:56:04 +0100 Subject: [PATCH 01/27] Adding strftime* for illumos/solaris. [ref](https://smartos.org/man/3C/strftime) [ref](https://docs.oracle.com/cd/E88353_01/html/E37843/strftime-3c.html) Fixes: #4449 (backport ) (cherry picked from commit f4964b534a01893f2eb7f2f880ddea6277555a19) --- libc-test/semver/solarish.txt | 2 ++ src/unix/solarish/mod.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index b02baab0efac2..cee5977fc35ee 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -75,3 +75,5 @@ posix_spawnattr_setsigmask posix_spawnp recvmsg sendmsg +strftime +strftime_l diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 48f13cdc59ae4..fc89d1d6d2a62 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -3130,6 +3130,21 @@ extern "C" { pub fn arc4random_uniform(upper_bound: u32) -> u32; pub fn secure_getenv(name: *const c_char) -> *mut c_char; + + #[cfg_attr(target_os = "solaris", link_name = "__strftime_xpg7")] + pub fn strftime( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + ) -> size_t; + pub fn strftime_l( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + loc: crate::locale_t, + ) -> size_t; } #[link(name = "sendfile")] From 9bc12691850e863b872fcdfef4eaff9d0557f4ed Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 26 Jul 2025 01:29:53 -0500 Subject: [PATCH 02/27] Enable the `rust_2024_compatibility` lint Enable this lint with the expectation that we will eventually be upgrading editions. There are some exceptions needed, and `unsafe_op_in_unsafe_fn` will take a while to go through. (backport ) (cherry picked from commit 2fe8b17c7582e91ed935a8bc6add5b575e087e06) --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index fb901944b22bd..703a985b7acb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,15 @@ unused_macros, unused_macro_rules, )] +// Prepare for a future upgrade +#![warn(rust_2024_compatibility)] +// Things missing for 2024 that are blocked on MSRV or breakage +#![allow( + missing_unsafe_on_extern, + edition_2024_expr_fragment_specifier, + // Allowed globally, the warning is enabled in individual modules as we work through them + unsafe_op_in_unsafe_fn +)] #![cfg_attr(libc_deny_warnings, deny(warnings))] // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] From 4ab6184419a31eb86e23fad53b06a10269852ca0 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Sun, 29 Jun 2025 09:29:04 -0400 Subject: [PATCH 03/27] add prctl constants on android Add all constants from bionic's `prctl.h` header https://android.googlesource.com/platform/bionic/+/7ac54f5c391bf3aeb9fec84a158939421fd8f505/libc/kernel/uapi/linux/prctl.h (backport ) (cherry picked from commit eb505fb30cd201e146e2aa16b2b843c111a1d033) --- libc-test/semver/android.txt | 156 ++++++++++++++++++++++++++ src/unix/linux_like/android/mod.rs | 173 +++++++++++++++++++++++++++-- 2 files changed, 317 insertions(+), 12 deletions(-) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index a52cc25077a95..80066883c7db0 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -1947,17 +1947,171 @@ PROT_GROWSUP PROT_NONE PROT_READ PROT_WRITE +PR_CAPBSET_DROP +PR_CAPBSET_READ +PR_CAP_AMBIENT +PR_CAP_AMBIENT_CLEAR_ALL +PR_CAP_AMBIENT_IS_SET +PR_CAP_AMBIENT_LOWER +PR_CAP_AMBIENT_RAISE +PR_ENDIAN_BIG +PR_ENDIAN_LITTLE +PR_ENDIAN_PPC_LITTLE +PR_FPEMU_NOPRINT +PR_FPEMU_SIGFPE +PR_FP_EXC_ASYNC +PR_FP_EXC_DISABLED +PR_FP_EXC_DIV +PR_FP_EXC_INV +PR_FP_EXC_NONRECOV +PR_FP_EXC_OVF +PR_FP_EXC_PRECISE +PR_FP_EXC_RES +PR_FP_EXC_SW_ENABLE +PR_FP_EXC_UND +PR_FP_MODE_FR +PR_FP_MODE_FRE +PR_GET_AUXV +PR_GET_CHILD_SUBREAPER +PR_GET_DUMPABLE +PR_GET_ENDIAN +PR_GET_FPEMU +PR_GET_FPEXC +PR_GET_FP_MODE +PR_GET_IO_FLUSHER +PR_GET_KEEPCAPS +PR_GET_MDWE +PR_GET_MEMORY_MERGE PR_GET_NAME PR_GET_NO_NEW_PRIVS +PR_GET_PDEATHSIG PR_GET_SECCOMP +PR_GET_SECUREBITS +PR_GET_SPECULATION_CTRL +PR_GET_TAGGED_ADDR_CTRL +PR_GET_THP_DISABLE +PR_GET_TID_ADDRESS +PR_GET_TIMERSLACK PR_GET_TIMING +PR_GET_TSC +PR_GET_UNALIGN +PR_MCE_KILL +PR_MCE_KILL_CLEAR +PR_MCE_KILL_DEFAULT +PR_MCE_KILL_EARLY +PR_MCE_KILL_GET +PR_MCE_KILL_LATE +PR_MCE_KILL_SET +PR_MDWE_NO_INHERIT +PR_MDWE_REFUSE_EXEC_GAIN +PR_MPX_DISABLE_MANAGEMENT +PR_MPX_ENABLE_MANAGEMENT +PR_MTE_TAG_MASK +PR_MTE_TAG_SHIFT +PR_MTE_TCF_ASYNC +PR_MTE_TCF_MASK +PR_MTE_TCF_NONE +PR_MTE_TCF_SHIFT +PR_MTE_TCF_SYNC +PR_PAC_APDAKEY +PR_PAC_APDBKEY +PR_PAC_APGAKEY +PR_PAC_APIAKEY +PR_PAC_APIBKEY +PR_PAC_GET_ENABLED_KEYS +PR_PAC_RESET_KEYS +PR_PAC_SET_ENABLED_KEYS +PR_RISCV_V_GET_CONTROL +PR_RISCV_V_SET_CONTROL +PR_RISCV_V_VSTATE_CTRL_CUR_MASK +PR_RISCV_V_VSTATE_CTRL_DEFAULT +PR_RISCV_V_VSTATE_CTRL_INHERIT +PR_RISCV_V_VSTATE_CTRL_MASK +PR_RISCV_V_VSTATE_CTRL_NEXT_MASK +PR_RISCV_V_VSTATE_CTRL_OFF +PR_RISCV_V_VSTATE_CTRL_ON +PR_SCHED_CORE +PR_SCHED_CORE_CREATE +PR_SCHED_CORE_GET +PR_SCHED_CORE_MAX +PR_SCHED_CORE_SCOPE_PROCESS_GROUP +PR_SCHED_CORE_SCOPE_THREAD +PR_SCHED_CORE_SCOPE_THREAD_GROUP +PR_SCHED_CORE_SHARE_FROM +PR_SCHED_CORE_SHARE_TO +PR_SET_CHILD_SUBREAPER +PR_SET_DUMPABLE +PR_SET_ENDIAN +PR_SET_FPEMU +PR_SET_FPEXC +PR_SET_FP_MODE +PR_SET_IO_FLUSHER +PR_SET_KEEPCAPS +PR_SET_MDWE +PR_SET_MEMORY_MERGE +PR_SET_MM +PR_SET_MM_ARG_END +PR_SET_MM_ARG_START +PR_SET_MM_AUXV +PR_SET_MM_BRK +PR_SET_MM_END_CODE +PR_SET_MM_END_DATA +PR_SET_MM_ENV_END +PR_SET_MM_ENV_START +PR_SET_MM_EXE_FILE +PR_SET_MM_MAP +PR_SET_MM_MAP_SIZE +PR_SET_MM_START_BRK +PR_SET_MM_START_CODE +PR_SET_MM_START_DATA +PR_SET_MM_START_STACK PR_SET_NAME PR_SET_NO_NEW_PRIVS +PR_SET_PDEATHSIG +PR_SET_PTRACER +PR_SET_PTRACER_ANY PR_SET_SECCOMP +PR_SET_SECUREBITS +PR_SET_SPECULATION_CTRL +PR_SET_SYSCALL_USER_DISPATCH +PR_SET_TAGGED_ADDR_CTRL +PR_SET_THP_DISABLE +PR_SET_TIMERSLACK +PR_SET_TIMING +PR_SET_TSC +PR_SET_UNALIGN PR_SET_VMA PR_SET_VMA_ANON_NAME +PR_SME_GET_VL +PR_SME_SET_VL +PR_SME_SET_VL_ONEXEC +PR_SME_VL_INHERIT +PR_SME_VL_LEN_MASK +PR_SPEC_DISABLE +PR_SPEC_DISABLE_NOEXEC +PR_SPEC_ENABLE +PR_SPEC_FORCE_DISABLE +PR_SPEC_INDIRECT_BRANCH +PR_SPEC_L1D_FLUSH +PR_SPEC_NOT_AFFECTED +PR_SPEC_PRCTL +PR_SPEC_STORE_BYPASS +PR_SVE_GET_VL +PR_SVE_SET_VL +PR_SVE_SET_VL_ONEXEC +PR_SVE_VL_INHERIT +PR_SVE_VL_LEN_MASK +PR_SYS_DISPATCH_OFF +PR_SYS_DISPATCH_ON +PR_TAGGED_ADDR_ENABLE +PR_TASK_PERF_EVENTS_DISABLE +PR_TASK_PERF_EVENTS_ENABLE PR_TIMING_STATISTICAL PR_TIMING_TIMESTAMP +PR_TSC_ENABLE +PR_TSC_SIGSEGV +PR_UNALIGN_NOPRINT +PR_UNALIGN_SIGBUS PTHREAD_BARRIER_SERIAL_THREAD PTHREAD_COND_INITIALIZER PTHREAD_CREATE_DETACHED @@ -2516,6 +2670,8 @@ SW_CNT SW_MAX SYN_CNT SYN_MAX +SYSCALL_DISPATCH_FILTER_ALLOW +SYSCALL_DISPATCH_FILTER_BLOCK SYS_accept4 SYS_acct SYS_add_key diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 100008ce5d8e9..ac76616b68cfb 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -2912,29 +2912,178 @@ pub const PF_VSOCK: c_int = AF_VSOCK; pub const SOMAXCONN: c_int = 128; -// sys/prctl.h -pub const PR_SET_PDEATHSIG: c_int = 1; -pub const PR_GET_PDEATHSIG: c_int = 2; -pub const PR_GET_SECUREBITS: c_int = 27; -pub const PR_SET_SECUREBITS: c_int = 28; - // sys/system_properties.h pub const PROP_VALUE_MAX: c_int = 92; pub const PROP_NAME_MAX: c_int = 32; // sys/prctl.h -pub const PR_SET_VMA: c_int = 0x53564d41; -pub const PR_SET_VMA_ANON_NAME: c_int = 0; -pub const PR_SET_NO_NEW_PRIVS: c_int = 38; -pub const PR_GET_NO_NEW_PRIVS: c_int = 39; -pub const PR_GET_SECCOMP: c_int = 21; -pub const PR_SET_SECCOMP: c_int = 22; +pub const PR_SET_PDEATHSIG: c_int = 1; +pub const PR_GET_PDEATHSIG: c_int = 2; +pub const PR_GET_DUMPABLE: c_int = 3; +pub const PR_SET_DUMPABLE: c_int = 4; +pub const PR_GET_UNALIGN: c_int = 5; +pub const PR_SET_UNALIGN: c_int = 6; +pub const PR_UNALIGN_NOPRINT: c_int = 1; +pub const PR_UNALIGN_SIGBUS: c_int = 2; +pub const PR_GET_KEEPCAPS: c_int = 7; +pub const PR_SET_KEEPCAPS: c_int = 8; +pub const PR_GET_FPEMU: c_int = 9; +pub const PR_SET_FPEMU: c_int = 10; +pub const PR_FPEMU_NOPRINT: c_int = 1; +pub const PR_FPEMU_SIGFPE: c_int = 2; +pub const PR_GET_FPEXC: c_int = 11; +pub const PR_SET_FPEXC: c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: c_int = 0x80; +pub const PR_FP_EXC_DIV: c_int = 0x010000; +pub const PR_FP_EXC_OVF: c_int = 0x020000; +pub const PR_FP_EXC_UND: c_int = 0x040000; +pub const PR_FP_EXC_RES: c_int = 0x080000; +pub const PR_FP_EXC_INV: c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: c_int = 0; +pub const PR_FP_EXC_NONRECOV: c_int = 1; +pub const PR_FP_EXC_ASYNC: c_int = 2; +pub const PR_FP_EXC_PRECISE: c_int = 3; pub const PR_GET_TIMING: c_int = 13; pub const PR_SET_TIMING: c_int = 14; pub const PR_TIMING_STATISTICAL: c_int = 0; pub const PR_TIMING_TIMESTAMP: c_int = 1; pub const PR_SET_NAME: c_int = 15; pub const PR_GET_NAME: c_int = 16; +pub const PR_GET_ENDIAN: c_int = 19; +pub const PR_SET_ENDIAN: c_int = 20; +pub const PR_ENDIAN_BIG: c_int = 0; +pub const PR_ENDIAN_LITTLE: c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: c_int = 2; +pub const PR_GET_SECCOMP: c_int = 21; +pub const PR_SET_SECCOMP: c_int = 22; +pub const PR_CAPBSET_READ: c_int = 23; +pub const PR_CAPBSET_DROP: c_int = 24; +pub const PR_GET_TSC: c_int = 25; +pub const PR_SET_TSC: c_int = 26; +pub const PR_TSC_ENABLE: c_int = 1; +pub const PR_TSC_SIGSEGV: c_int = 2; +pub const PR_GET_SECUREBITS: c_int = 27; +pub const PR_SET_SECUREBITS: c_int = 28; +pub const PR_SET_TIMERSLACK: c_int = 29; +pub const PR_GET_TIMERSLACK: c_int = 30; +pub const PR_TASK_PERF_EVENTS_DISABLE: c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: c_int = 32; +pub const PR_MCE_KILL: c_int = 33; +pub const PR_MCE_KILL_CLEAR: c_int = 0; +pub const PR_MCE_KILL_SET: c_int = 1; +pub const PR_MCE_KILL_LATE: c_int = 0; +pub const PR_MCE_KILL_EARLY: c_int = 1; +pub const PR_MCE_KILL_DEFAULT: c_int = 2; +pub const PR_MCE_KILL_GET: c_int = 34; +pub const PR_SET_MM: c_int = 35; +pub const PR_SET_MM_START_CODE: c_int = 1; +pub const PR_SET_MM_END_CODE: c_int = 2; +pub const PR_SET_MM_START_DATA: c_int = 3; +pub const PR_SET_MM_END_DATA: c_int = 4; +pub const PR_SET_MM_START_STACK: c_int = 5; +pub const PR_SET_MM_START_BRK: c_int = 6; +pub const PR_SET_MM_BRK: c_int = 7; +pub const PR_SET_MM_ARG_START: c_int = 8; +pub const PR_SET_MM_ARG_END: c_int = 9; +pub const PR_SET_MM_ENV_START: c_int = 10; +pub const PR_SET_MM_ENV_END: c_int = 11; +pub const PR_SET_MM_AUXV: c_int = 12; +pub const PR_SET_MM_EXE_FILE: c_int = 13; +pub const PR_SET_MM_MAP: c_int = 14; +pub const PR_SET_MM_MAP_SIZE: c_int = 15; +pub const PR_SET_PTRACER: c_int = 0x59616d61; +pub const PR_SET_PTRACER_ANY: c_ulong = 0xffffffffffffffff; +pub const PR_SET_CHILD_SUBREAPER: c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: c_int = 37; +pub const PR_SET_NO_NEW_PRIVS: c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: c_int = 39; +pub const PR_GET_TID_ADDRESS: c_int = 40; +pub const PR_SET_THP_DISABLE: c_int = 41; +pub const PR_GET_THP_DISABLE: c_int = 42; +pub const PR_MPX_ENABLE_MANAGEMENT: c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: c_int = 44; +pub const PR_SET_FP_MODE: c_int = 45; +pub const PR_GET_FP_MODE: c_int = 46; +pub const PR_FP_MODE_FR: c_int = 1 << 0; +pub const PR_FP_MODE_FRE: c_int = 1 << 1; +pub const PR_CAP_AMBIENT: c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: c_int = 4; +pub const PR_SVE_SET_VL: c_int = 50; +pub const PR_SVE_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SVE_GET_VL: c_int = 51; +pub const PR_SVE_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SVE_VL_INHERIT: c_int = 1 << 17; +pub const PR_GET_SPECULATION_CTRL: c_int = 52; +pub const PR_SET_SPECULATION_CTRL: c_int = 53; +pub const PR_SPEC_STORE_BYPASS: c_int = 0; +pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1; +pub const PR_SPEC_L1D_FLUSH: c_int = 2; +pub const PR_SPEC_NOT_AFFECTED: c_int = 0; +pub const PR_SPEC_PRCTL: c_ulong = 1 << 0; +pub const PR_SPEC_ENABLE: c_ulong = 1 << 1; +pub const PR_SPEC_DISABLE: c_ulong = 1 << 2; +pub const PR_SPEC_FORCE_DISABLE: c_ulong = 1 << 3; +pub const PR_SPEC_DISABLE_NOEXEC: c_ulong = 1 << 4; +pub const PR_PAC_RESET_KEYS: c_int = 54; +pub const PR_PAC_APIAKEY: c_ulong = 1 << 0; +pub const PR_PAC_APIBKEY: c_ulong = 1 << 1; +pub const PR_PAC_APDAKEY: c_ulong = 1 << 2; +pub const PR_PAC_APDBKEY: c_ulong = 1 << 3; +pub const PR_PAC_APGAKEY: c_ulong = 1 << 4; +pub const PR_SET_TAGGED_ADDR_CTRL: c_int = 55; +pub const PR_GET_TAGGED_ADDR_CTRL: c_int = 56; +pub const PR_TAGGED_ADDR_ENABLE: c_ulong = 1 << 0; +pub const PR_MTE_TCF_NONE: c_ulong = 0; +pub const PR_MTE_TCF_SYNC: c_ulong = 1 << 1; +pub const PR_MTE_TCF_ASYNC: c_ulong = 1 << 2; +pub const PR_MTE_TCF_MASK: c_ulong = PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC; +pub const PR_MTE_TAG_SHIFT: c_ulong = 3; +pub const PR_MTE_TAG_MASK: c_ulong = 0xffff << PR_MTE_TAG_SHIFT; +pub const PR_MTE_TCF_SHIFT: c_ulong = 1; +pub const PR_SET_IO_FLUSHER: c_int = 57; +pub const PR_GET_IO_FLUSHER: c_int = 58; +pub const PR_SET_SYSCALL_USER_DISPATCH: c_int = 59; +pub const PR_SYS_DISPATCH_OFF: c_int = 0; +pub const PR_SYS_DISPATCH_ON: c_int = 1; +pub const SYSCALL_DISPATCH_FILTER_ALLOW: c_int = 0; +pub const SYSCALL_DISPATCH_FILTER_BLOCK: c_int = 1; +pub const PR_PAC_SET_ENABLED_KEYS: c_int = 60; +pub const PR_PAC_GET_ENABLED_KEYS: c_int = 61; +pub const PR_SCHED_CORE: c_int = 62; +pub const PR_SCHED_CORE_GET: c_int = 0; +pub const PR_SCHED_CORE_CREATE: c_int = 1; +pub const PR_SCHED_CORE_SHARE_TO: c_int = 2; +pub const PR_SCHED_CORE_SHARE_FROM: c_int = 3; +pub const PR_SCHED_CORE_MAX: c_int = 4; +pub const PR_SCHED_CORE_SCOPE_THREAD: c_int = 0; +pub const PR_SCHED_CORE_SCOPE_THREAD_GROUP: c_int = 1; +pub const PR_SCHED_CORE_SCOPE_PROCESS_GROUP: c_int = 2; +pub const PR_SME_SET_VL: c_int = 63; +pub const PR_SME_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SME_GET_VL: c_int = 64; +pub const PR_SME_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SME_VL_INHERIT: c_int = 1 << 17; +pub const PR_SET_MDWE: c_int = 65; +pub const PR_MDWE_REFUSE_EXEC_GAIN: c_ulong = 1 << 0; +pub const PR_MDWE_NO_INHERIT: c_ulong = 1 << 1; +pub const PR_GET_MDWE: c_int = 66; +pub const PR_SET_VMA: c_int = 0x53564d41; +pub const PR_SET_VMA_ANON_NAME: c_int = 0; +pub const PR_GET_AUXV: c_int = 0x41555856; +pub const PR_SET_MEMORY_MERGE: c_int = 67; +pub const PR_GET_MEMORY_MERGE: c_int = 68; +pub const PR_RISCV_V_SET_CONTROL: c_int = 69; +pub const PR_RISCV_V_GET_CONTROL: c_int = 70; +pub const PR_RISCV_V_VSTATE_CTRL_DEFAULT: c_int = 0; +pub const PR_RISCV_V_VSTATE_CTRL_OFF: c_int = 1; +pub const PR_RISCV_V_VSTATE_CTRL_ON: c_int = 2; +pub const PR_RISCV_V_VSTATE_CTRL_INHERIT: c_int = 1 << 4; +pub const PR_RISCV_V_VSTATE_CTRL_CUR_MASK: c_int = 0x3; +pub const PR_RISCV_V_VSTATE_CTRL_NEXT_MASK: c_int = 0xc; +pub const PR_RISCV_V_VSTATE_CTRL_MASK: c_int = 0x1f; // linux/if_addr.h pub const IFA_UNSPEC: c_ushort = 0; From 92b7c1b60baebccfd9c7c784c8cc2ad3b798f9bb Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 28 Jul 2025 11:12:02 +0000 Subject: [PATCH 04/27] l4re: Move `pthread_attr_t` into `s!` Resolve the `improper_ctypes` warning on l4re-uclibc that we are getting in CI. The current version was added in e412497d3e0d ("Move L4Re-specific code into separate module.") and doesn't seem to have been intentional. (backport ) (cherry picked from commit 95c140034157f4c0aafc7b5130ed026390ffd098) --- .../linux_like/linux/uclibc/x86_64/l4re.rs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs index 380077711d797..536c716ca4868 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -26,22 +26,21 @@ s! { /// Bitmap of CPUs. map: l4_umword_t, } -} -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub struct pthread_attr_t { - pub __detachstate: c_int, - pub __schedpolicy: c_int, - pub __schedparam: super::__sched_param, - pub __inheritsched: c_int, - pub __scope: c_int, - pub __guardsize: size_t, - pub __stackaddr_set: c_int, - pub __stackaddr: *mut c_void, // better don't use it - pub __stacksize: size_t, - // L4Re specifics - pub affinity: l4_sched_cpu_set_t, - pub create_flags: c_uint, + pub struct pthread_attr_t { + pub __detachstate: c_int, + pub __schedpolicy: c_int, + pub __schedparam: super::__sched_param, + pub __inheritsched: c_int, + pub __scope: c_int, + pub __guardsize: size_t, + pub __stackaddr_set: c_int, + pub __stackaddr: *mut c_void, // better don't use it + pub __stacksize: size_t, + // L4Re specifics + pub affinity: l4_sched_cpu_set_t, + pub create_flags: c_uint, + } } // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but From 91179ca4df3d56db012e326a4ec8a682de80d05f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 10 Aug 2025 20:42:23 -0500 Subject: [PATCH 05/27] Update the `c_enum` macro to take multiple values Partial cherry pick of a541bf4f6dc5 ("libc: remove uses of enum as per #4419"). Co-authored-by: mbyx --- src/macros.rs | 30 ++++++++++++++++++++++-------- src/unix/linux_like/linux/mod.rs | 8 +++----- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 5f2a08d5de32d..d0a55fa2fca29 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -223,10 +223,24 @@ macro_rules! e { /// /// See for more. macro_rules! c_enum { - ( + ($( + $(#[repr($repr:ty)])? + pub enum $ty_name:ident { + $($variant:ident $(= $value:expr)?,)+ + } + )+) => { + $(c_enum!(@expand; + $(#[repr($repr)])? + pub enum $ty_name { + $($variant $(= $value)?,)+ + } + );)+ + }; + + (@expand; $(#[repr($repr:ty)])? - enum $ty_name:ident { - $($variant:ident $(= $value:literal)?,)+ + pub enum $ty_name:ident { + $($variant:ident $(= $value:expr)?,)+ } ) => { pub type $ty_name = c_enum!(@ty $($repr)?); @@ -237,7 +251,7 @@ macro_rules! c_enum { (@one; $_ty_name:ident; $_idx:expr;) => {}; ( @one; $ty_name:ident; $default_val:expr; - $variant:ident $(= $value:literal)?, + $variant:ident $(= $value:expr)?, $($tail:tt)* ) => { pub const $variant: $ty_name = { @@ -413,7 +427,7 @@ mod tests { fn c_enumbasic() { // By default, variants get sequential values. c_enum! { - enum e { + pub enum e { VAR0, VAR1, VAR2, @@ -430,7 +444,7 @@ mod tests { // By default, variants get sequential values. c_enum! { #[repr(u16)] - enum e { + pub enum e { VAR0, } } @@ -442,7 +456,7 @@ mod tests { fn c_enumset_value() { // Setting an explicit value resets the count. c_enum! { - enum e { + pub enum e { VAR2 = 2, VAR3, VAR4, @@ -459,7 +473,7 @@ mod tests { // C enums always take one more than the previous value, unless set to a specific // value. Duplicates are allowed. c_enum! { - enum e { + pub enum e { VAR0, VAR2_0 = 2, VAR3_0, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7fd24d480c53a..182889574eadd 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -84,7 +84,7 @@ e! { } c_enum! { - enum pid_type { + pub enum pid_type { PIDTYPE_PID, PIDTYPE_TGID, PIDTYPE_PGID, @@ -4468,14 +4468,12 @@ pub const RTNLGRP_STATS: c_uint = 0x24; // linux/cn_proc.h c_enum! { - enum proc_cn_mcast_op { + pub enum proc_cn_mcast_op { PROC_CN_MCAST_LISTEN = 1, PROC_CN_MCAST_IGNORE = 2, } -} -c_enum! { - enum proc_cn_event { + pub enum proc_cn_event { PROC_EVENT_NONE = 0x00000000, PROC_EVENT_FORK = 0x00000001, PROC_EVENT_EXEC = 0x00000002, From 2f5ae6cd20ae95c9cc45f8b5f5fae704447b1fde Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 10 Aug 2025 20:42:23 -0500 Subject: [PATCH 06/27] haiku: Switch from `e!` to `c_enum!` The enums used on Haiku are currently broken: they have no `repr` attribute so Rust is treating them as a `u8` when they need to be `c_int`. This is flagged by `improper_ctypes`, which only shows up now that this lint got removed. Since this is broken anyway, we may as well just switch to `c_enum!`. This is a user-visible breaking change, but allowed as the target is tier 3. Partially cherry picked from commit a541bf4f6dc5 ("libc: remove uses of enum as per #4419"). Co-authored-by: mbyx --- src/unix/haiku/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 082e85b326ead..f3eaf623a59a5 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -46,7 +46,7 @@ pub type thread_func = extern "C" fn(*mut c_void) -> status_t; // kernel/image.h pub type image_id = i32; -e! { +c_enum! { // kernel/OS.h pub enum thread_state { B_THREAD_RUNNING = 1, From e2396b10889744215e5424619773b43dc3537441 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 10 Aug 2025 21:47:19 -0500 Subject: [PATCH 07/27] psp: Correct char -> c_char --- src/psp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/psp.rs b/src/psp.rs index 131ef3180332b..823567127c401 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -3271,18 +3271,18 @@ extern "C" { pub fn sceRtcGetWin32FileTime(date: *mut ScePspDateTime, time: *mut u64) -> i32; pub fn sceRtcParseDateTime(dest_tick: *mut u64, date_string: *const u8) -> i32; pub fn sceRtcFormatRFC3339( - psz_date_time: *mut char, + psz_date_time: *mut c_char, p_utc: *const u64, time_zone_minutes: i32, ) -> i32; - pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32; + pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; pub fn sceRtcParseRFC3339(p_utc: *mut u64, psz_date_time: *const u8) -> i32; pub fn sceRtcFormatRFC2822( - psz_date_time: *mut char, + psz_date_time: *mut c_char, p_utc: *const u64, time_zone_minutes: i32, ) -> i32; - pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32; + pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; pub fn sceIoOpen(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; pub fn sceIoOpenAsync(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; From c409f7d39dae1f7c6e924f20dd486f88d34072b1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 26 Jul 2025 01:27:28 -0500 Subject: [PATCH 08/27] Don't allow `improper_ctypes` Most of what this crate does is interact with C, so the lint should be useful. It can be disabled on a case-by-case basis as needed. There are a few fixes needed for enums, which will be going away anyway (rust-lang/libc#4419). Additionally, switch the `bad_style` lint to the newer name `nonstandard_style`. (backport ) (cherry picked from commit 38bb46e21cfbf5fa0f5c879be7b98079de75c9e6) --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 703a985b7acb6..5989c64da6287 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,9 +4,8 @@ #![allow( renamed_and_removed_lints, // Keep this order. unknown_lints, // Keep this order. - bad_style, + nonstandard_style, overflowing_literals, - improper_ctypes, unused_macros, unused_macro_rules, )] From 3b8b9ac39e6a1b10edbe1e92724e86ee6caeed40 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 24 Jul 2025 15:41:01 -0400 Subject: [PATCH 09/27] Add 'struct ld_info' and friends. (backport ) (cherry picked from commit 925eb0c94f5ceab848c666bc1bac4b34044a5c7b) --- libc-test/build.rs | 17 +++++++++ libc-test/semver/aix.txt | 6 ++++ src/unix/aix/powerpc64.rs | 75 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7ea00da688a19..ce3a3fda4e1f6 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5702,6 +5702,18 @@ fn test_aix(target: &str) { // allow type 'double' to be used in signal contexts. "fpreg_t" => true, + // This type is defined for a union used within `struct ld_info`. + // The AIX header does not declare a separate standalone union + // type for it. + "__ld_info_file" => true, + + // This is a simplified version of the AIX union `_simple_lock`. + "_kernel_simple_lock" => true, + + // These structures are guarded by the `_KERNEL` macro in the AIX + // header. + "fileops_t" | "file" => true, + _ => false, } }); @@ -5719,6 +5731,11 @@ fn test_aix(target: &str) { // The _ALL_SOURCE type of 'f_fsid' differs from POSIX's on AIX. ("statvfs", "f_fsid") => true, + // The type of `_file` is `__ld_info_file`, which is defined + // specifically for the union inside `struct ld_info`. The AIX + // header does not define a separate standalone union type for it. + ("ld_info", "_file") => true, + _ => false, } }); diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index 1f3324e213f54..73163c854f30d 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -1791,12 +1791,14 @@ _W_STOPPED _W_STRC __context64 __extctx_t +__ld_info_file __pollfd_ext_u __tm_context_t __vmx_context_t __vmxreg_t __vsx_context_t _exit +_kernel_simple_lock abort accept access @@ -1915,7 +1917,9 @@ fgetpos fgetpos64 fgetpwent fgets +file fileno +fileops_t flock flock64 fnmatch @@ -2079,6 +2083,7 @@ kill lchown lcong48 lconv +ld_info lfind linger link @@ -2090,6 +2095,7 @@ locale_t localeconv localtime localtime_r +lock_data_instrumented lpar_get_info lpar_set_resources lrand48 diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index b2b7ea88f6e4e..1a8ebb1cc7f6b 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -1,6 +1,12 @@ use crate::off_t; use crate::prelude::*; +// Define lock_data_instrumented as an empty enum +missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum lock_data_instrumented {} +} + s! { pub struct sigset_t { pub ss_set: [c_ulong; 4], @@ -256,6 +262,74 @@ s_no_extra_traits! { pub __pad: [c_int; 3], } + pub union _kernel_simple_lock { + pub _slock: c_long, + pub _slockp: *mut lock_data_instrumented, + } + + pub struct fileops_t { + pub fo_rw: Option< + extern "C" fn( + file: *mut file, + rw: crate::uio_rw, + io: *mut c_void, + ext: c_long, + secattr: *mut c_void, + ) -> c_int, + >, + pub fo_ioctl: Option< + extern "C" fn( + file: *mut file, + a: c_long, + b: crate::caddr_t, + c: c_long, + d: c_long, + ) -> c_int, + >, + pub fo_select: Option< + extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int, + >, + pub fo_close: Option c_int>, + pub fo_fstat: Option c_int>, + } + + pub struct file { + pub f_flag: c_long, + pub f_count: c_int, + pub f_options: c_short, + pub f_type: c_short, + // Should be pointer to 'vnode' + pub f_data: *mut c_void, + pub f_offset: c_longlong, + pub f_dir_off: c_long, + // Should be pointer to 'cred' + pub f_cred: *mut c_void, + pub f_lock: _kernel_simple_lock, + pub f_offset_lock: _kernel_simple_lock, + pub f_vinfo: crate::caddr_t, + pub f_ops: *mut fileops_t, + pub f_parentp: crate::caddr_t, + pub f_fnamep: crate::caddr_t, + pub f_fdata: [c_char; 160], + } + + pub union __ld_info_file { + pub _ldinfo_fd: c_int, + pub _ldinfo_fp: *mut file, + pub _core_offset: c_long, + } + + pub struct ld_info { + pub ldinfo_next: c_uint, + pub ldinfo_flags: c_uint, + pub _file: __ld_info_file, + pub ldinfo_textorg: *mut c_void, + pub ldinfo_textsize: c_ulong, + pub ldinfo_dataorg: *mut c_void, + pub ldinfo_datasize: c_ulong, + pub ldinfo_filename: [c_char; 2], + } + pub union __pollfd_ext_u { pub addr: *mut c_void, pub data32: u32, @@ -327,6 +401,7 @@ cfg_if! { self.__si_flags.hash(state); } } + impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { From fe5a394505dab879d20a020ded10876d1c8cc03f Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Mon, 28 Jul 2025 11:53:03 -0400 Subject: [PATCH 10/27] Remove duplicate constant definitions FIND and ENTER. (backport ) (cherry picked from commit bdc4b7df37ec8bbac325ddd6cdba712a0abe3bcd) --- src/unix/aix/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 1ee8c53b5505b..9a4eac63dea63 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1159,10 +1159,6 @@ pub const NFSMNT_ACDIRMAX: c_int = 0x0800; // rpcsvc/rstat.h pub const CPUSTATES: c_int = 4; -// search.h -pub const FIND: c_int = 0; -pub const ENTER: c_int = 1; - // semaphore.h pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t; From 181138a65ef7c2a2f679423a25024e780b572205 Mon Sep 17 00:00:00 2001 From: qinghon Date: Sun, 25 May 2025 00:44:44 +0800 Subject: [PATCH 11/27] netbsd/openbsd: Export ioctl request generator macros (backport ) (cherry picked from commit e7cf1cc51c715d495cfd41fa3a1e7b10eb9f6f57) --- libc-test/semver/netbsd.txt | 16 +++++++++++++++ libc-test/semver/openbsd.txt | 14 +++++++++++++ src/unix/bsd/netbsdlike/mod.rs | 28 ++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 23 +++++++++++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 17 ++++++++++++++++ 5 files changed, 98 insertions(+) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 57e1cf5c4bd1b..677e37ea0a155 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -426,6 +426,17 @@ IFF_SIMPLEX IFF_UP IMAXBEL INIT_PROCESS +IOCBASECMD +IOCGROUP +IOCGROUP_SHIFT +IOCPARM_LEN +IOCPARM_MASK +IOCPARM_SHIFT +IOC_DIRMASK +IOC_IN +IOC_INOUT +IOC_OUT +IOC_VOID IOV_MAX IPC_CREAT IPC_EXCL @@ -1116,9 +1127,14 @@ XATTR_CREATE XATTR_REPLACE YESEXPR YESSTR +_IO +_IOC _IOFBF _IOLBF _IONBF +_IOR +_IOW +_IOWR _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_FILESIZEBITS diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index a340a83a92712..c63c347723834 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -267,6 +267,15 @@ IFF_SIMPLEX IFF_STATICARP IFF_UP IMAXBEL +IOCBASECMD +IOCGROUP +IOCPARM_LEN +IOCPARM_MASK +IOC_DIRMASK +IOC_IN +IOC_INOUT +IOC_OUT +IOC_VOID IOV_MAX IPC_CREAT IPC_EXCL @@ -912,9 +921,14 @@ WSTOPPED WTRAPPED YESEXPR YESSTR +_IO +_IOC _IOFBF _IOLBF _IONBF +_IOR +_IOW +_IOWR _MAX_PAGE_SHIFT _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 682b8b7e9fe74..b9c35fe7f41f3 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -440,6 +440,34 @@ pub const MNT_NODEV: c_int = 0x00000010; pub const MNT_LOCAL: c_int = 0x00001000; pub const MNT_QUOTA: c_int = 0x00002000; +// sys/ioccom.h in NetBSD and OpenBSD +pub const IOCPARM_MASK: u32 = 0x1fff; + +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + +pub const fn _IO(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_VOID, g, n, 0) +} + +/// Build an ioctl number for an read-only ioctl. +pub const fn _IOR(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_OUT, g, n, mem::size_of::() as c_ulong) +} + +/// Build an ioctl number for an write-only ioctl. +pub const fn _IOW(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_IN, g, n, mem::size_of::() as c_ulong) +} + +/// Build an ioctl number for a read-write ioctl. +pub const fn _IOWR(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_INOUT, g, n, mem::size_of::() as c_ulong) +} + pub const AF_UNSPEC: c_int = 0; pub const AF_LOCAL: c_int = 1; pub const AF_UNIX: c_int = AF_LOCAL; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 1367276762d61..507905f532d3b 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1712,6 +1712,29 @@ pub const MNT_WAIT: c_int = 1; pub const MNT_NOWAIT: c_int = 2; pub const MNT_LAZY: c_int = 3; +// sys/ioccom.h +pub const IOCPARM_SHIFT: u32 = 16; +pub const IOCGROUP_SHIFT: u32 = 8; + +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> IOCPARM_SHIFT) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << IOCPARM_SHIFT)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> IOCGROUP_SHIFT) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) + | (((len) & crate::IOCPARM_MASK as c_ulong) << IOCPARM_SHIFT) + | ((group) << IOCGROUP_SHIFT) + | (num) +} + // pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 3a7aeadf4656d..5ee6bc0ca04f3 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1738,6 +1738,23 @@ pub const PF_R: u32 = 0x4; pub const PF_MASKOS: u32 = 0x0ff00000; pub const PF_MASKPROC: u32 = 0xf0000000; +// sys/ioccom.h +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> 16) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << 16)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> 8) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) | (((len) & crate::IOCPARM_MASK as c_ulong) << 16) | ((group) << 8) | (num) +} + // sys/mount.h pub const MNT_NOPERM: c_int = 0x00000020; pub const MNT_WXALLOWED: c_int = 0x00000800; From 3a7e489b5aa414582900803772f305887f276539 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Tue, 29 Jul 2025 12:08:16 -0400 Subject: [PATCH 12/27] Fix the types of 'struct stat'/'stat stat64' fields 'st_*tim'. (backport ) (cherry picked from commit cf82fdf3f22ccfa98ba120efc50d5f39ab2d52ff) --- libc-test/build.rs | 10 ++++++++++ src/unix/aix/mod.rs | 6 +++--- src/unix/aix/powerpc64.rs | 6 +++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index ce3a3fda4e1f6..fb9367d2ff958 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5736,6 +5736,16 @@ fn test_aix(target: &str) { // header does not define a separate standalone union type for it. ("ld_info", "_file") => true, + // On AIX, when _ALL_SOURCE is defined, the types of the following fields + // differ from those used when _XOPEN_SOURCE is defined. The former uses + // 'struct st_timespec', while the latter uses 'struct timespec'. + ("stat", "st_atim") => true, + ("stat", "st_mtim") => true, + ("stat", "st_ctim") => true, + ("stat64", "st_atim") => true, + ("stat64", "st_mtim") => true, + ("stat64", "st_ctim") => true, + _ => false, } }); diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 9a4eac63dea63..a4e975ad8030e 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -463,9 +463,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: dev_t, pub st_ssize: c_int, - pub st_atim: st_timespec, - pub st_mtim: st_timespec, - pub st_ctim: st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: blksize_t, pub st_blocks: blkcnt_t, pub st_vfstype: c_int, diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 1a8ebb1cc7f6b..856fd0d127d70 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -69,9 +69,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_ssize: c_int, - pub st_atim: crate::st_timespec, - pub st_mtim: crate::st_timespec, - pub st_ctim: crate::st_timespec, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_vfstype: c_int, From 44169ade4fe6f7367f08c0dd5f0647b58d88df42 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 29 Jul 2025 05:53:53 -0500 Subject: [PATCH 13/27] NetBSD: mark an enum `#[repr(C)]` Resolve an instance of `improper_ctypes`. --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 507905f532d3b..b6b3639c37916 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -39,6 +39,7 @@ pub type Elf64_Xword = u64; pub type iconv_t = *mut c_void; e! { + #[repr(C)] pub enum fae_action { FAE_OPEN, FAE_DUP2, From 9f11c859c2b1e2f8eb93460a9b8ff24697cd8664 Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Fri, 1 Aug 2025 21:39:50 +0200 Subject: [PATCH 14/27] NetBSD: add ptsname_r support (backport ) (cherry picked from commit e634372f7ebe918abccfa9b0de25f6dda2399f66) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index b6b3639c37916..8179de20797e5 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2497,6 +2497,8 @@ extern "C" { winp: *mut crate::winsize, ) -> crate::pid_t; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + #[link_name = "__lutimes50"] pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; #[link_name = "__gettimeofday50"] From f6d06e40fd1268721e892ab78704af466fd23b30 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Wed, 6 Aug 2025 15:21:45 +0200 Subject: [PATCH 15/27] Export UDP socket option consts on Android (backport ) (cherry picked from commit a43bdc34b235b4992289a0903ec24d86121af4c0) --- libc-test/semver/android.txt | 6 ++++++ src/unix/linux_like/android/mod.rs | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 80066883c7db0..96c77cb43c5ef 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3096,6 +3096,12 @@ TUN_F_USO4 TUN_F_USO6 TUN_PKT_STRIP TUN_TX_TIMESTAMP +UDP_CORK +UDP_ENCAP +UDP_GRO +UDP_NO_CHECK6_RX +UDP_NO_CHECK6_TX +UDP_SEGMENT UINPUT_MAX_NAME_SIZE UINPUT_VERSION UIO_MAXIOV diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index ac76616b68cfb..df901a36635a8 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1323,6 +1323,15 @@ pub const SOL_ATALK: c_int = 258; pub const SOL_NETROM: c_int = 259; pub const SOL_ROSE: c_int = 260; +/* UDP socket options */ +// include/uapi/linux/udp.h +pub const UDP_CORK: c_int = 1; +pub const UDP_ENCAP: c_int = 100; +pub const UDP_NO_CHECK6_TX: c_int = 101; +pub const UDP_NO_CHECK6_RX: c_int = 102; +pub const UDP_SEGMENT: c_int = 103; +pub const UDP_GRO: c_int = 104; + /* DCCP socket options */ pub const DCCP_SOCKOPT_PACKET_SIZE: c_int = 1; pub const DCCP_SOCKOPT_SERVICE: c_int = 2; From 46acaae29e0a6ead4b910df6acb9728cd9b9b792 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 2 Aug 2025 12:49:42 -0700 Subject: [PATCH 16/27] riscv32: Define plain syscalls as their time64 variants RISCV32 is "time64-only" from the beginning on the kernel side. Based on musl change [1] [1] https://git.musl-libc.org/cgit/musl/commit/?id=4bbd7baea7c8538b3fb8e30f7b022a1eee071450 (backport ) (cherry picked from commit 458c5a0fb8668ec2f19f4a8ce023934809c58e52) --- .../linux_like/linux/musl/b32/riscv32/mod.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index 0e2f53edcad4c..ea4b51f006f0f 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -633,3 +633,23 @@ pub const SYS_faccessat2: c_long = 439; pub const SYS_process_madvise: c_long = 440; pub const SYS_epoll_pwait2: c_long = 441; pub const SYS_mount_setattr: c_long = 442; + +// Plain syscalls aliased to their time64 variants +pub const SYS_clock_gettime: c_long = SYS_clock_gettime64; +pub const SYS_clock_settime: c_long = SYS_clock_settime64; +pub const SYS_clock_adjtime: c_long = SYS_clock_adjtime64; +pub const SYS_clock_getres: c_long = SYS_clock_getres_time64; +pub const SYS_clock_nanosleep: c_long = SYS_clock_nanosleep_time64; +pub const SYS_timer_gettime: c_long = SYS_timer_gettime64; +pub const SYS_timer_settime: c_long = SYS_timer_settime64; +pub const SYS_timerfd_gettime: c_long = SYS_timerfd_gettime64; +pub const SYS_timerfd_settime: c_long = SYS_timerfd_settime64; +pub const SYS_utimensat: c_long = SYS_utimensat_time64; +pub const SYS_pselect6: c_long = SYS_pselect6_time64; +pub const SYS_ppoll: c_long = SYS_ppoll_time64; +pub const SYS_recvmmsg: c_long = SYS_recvmmsg_time64; +pub const SYS_mq_timedsend: c_long = SYS_mq_timedsend_time64; +pub const SYS_mq_timedreceive: c_long = SYS_mq_timedreceive_time64; +pub const SYS_rt_sigtimedwait: c_long = SYS_rt_sigtimedwait_time64; +pub const SYS_futex: c_long = SYS_futex_time64; +pub const SYS_sched_rr_get_interval: c_long = SYS_sched_rr_get_interval_time64; From b3b9be4accb69b23f03479236ec1aa59862e697e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Oct 2024 09:05:59 +0200 Subject: [PATCH 17/27] Enable statx on musl-libc Version 1.2.5 of musl-libc added support for the statx system call[1]. [1]: https://musl.libc.org/releases.html (backport ) (cherry picked from commit ef3c046a1a839d3eef28d69de6b397e83ce9b94a) --- src/unix/linux_like/mod.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 98a093db2e742..b044caf109ee1 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -234,7 +234,11 @@ cfg_if! { } cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { s! { pub struct statx { pub stx_mask: crate::__u32, @@ -1663,7 +1667,11 @@ cfg_if! { } cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; pub const AT_STATX_SYNC_AS_STAT: c_int = 0x0000; pub const AT_STATX_FORCE_SYNC: c_int = 0x2000; @@ -2181,7 +2189,11 @@ cfg_if! { // The statx syscall, available on some libcs. cfg_if! { - if #[cfg(any(target_env = "gnu", target_os = "android"))] { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { extern "C" { pub fn statx( dirfd: c_int, From 4e8bc3b647a80070489a16d557c45441930de2eb Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Mon, 23 Dec 2024 10:16:15 +0000 Subject: [PATCH 18/27] Haiku: move BSD API to a separate file Haiku implements various parts of the (non-POSIX) BSD API. This moves it to a separate file, for easier future maintenance. No functional change intended; the changes are synchronized with R1Beta5 (backport ) (cherry picked from commit f1091a7e87f04c0f7f78ef4b0dee15a0b1d71618) --- src/unix/haiku/bsd.rs | 81 +++++++++++++++++++++++++++++++++++++++ src/unix/haiku/mod.rs | 83 +++++++++++++--------------------------- src/unix/haiku/native.rs | 14 +------ 3 files changed, 109 insertions(+), 69 deletions(-) create mode 100644 src/unix/haiku/bsd.rs diff --git a/src/unix/haiku/bsd.rs b/src/unix/haiku/bsd.rs new file mode 100644 index 0000000000000..f093911d0c9c8 --- /dev/null +++ b/src/unix/haiku/bsd.rs @@ -0,0 +1,81 @@ +//! This file contains the BSD APIs available in Haiku. It corresponds to the +//! header files in `headers/compatibility/bsd`. +//! +//! Note that Haiku's BSD compatibility is a combination of system APIs and +//! utility libraries. There should only be system APIs in `libc`. When you are +//! trying to determine whether something should be included in this file, the +//! best indicator is whether it also exists in the BSD-specific definitions in +//! this libc crate. + +use crate::prelude::*; + +// stringlist.h (utility library) +// Note: this is kept because it was previously introduced +pub type StringList = _stringlist; + +s! { + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub struct _stringlist { + pub sl_str: *mut *mut c_char, + pub sl_max: size_t, + pub sl_cur: size_t, + } + + // sys/link_elf.h + pub struct dl_phdr_info { + pub dlpi_addr: crate::Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const crate::Elf_Phdr, + pub dlpi_phnum: crate::Elf_Half, + } +} + +#[link(name = "bsd")] +extern "C" { + // stdlib.h + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn getprogname() -> *const c_char; + pub fn setprogname(progname: *const c_char); + pub fn arc4random() -> u32; + pub fn arc4random_uniform(upper_bound: u32) -> u32; + pub fn arc4random_buf(buf: *mut c_void, n: size_t); + + // pty.h + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn login_tty(_fd: c_int) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + + // string.h + pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; + pub fn explicit_bzero(buf: *mut c_void, len: size_t); + + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub fn sl_init() -> *mut StringList; + pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; + pub fn sl_free(sl: *mut StringList, i: c_int); + pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; + + // sys/link_elf.h + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + // sys/time.h + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; +} diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 790591fc0b9f7..71eb890d30452 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1,5 +1,29 @@ use crate::prelude::*; +// This module contains bindings to the native Haiku API. The Haiku API +// originates from BeOS, and it was the original way to perform low level +// system and IO operations. The POSIX API was in that era was like a +// compatibility layer. In current Haiku development, both the POSIX API and +// the Haiku API are considered to be co-equal status. However, they are not +// integrated like they are on other UNIX platforms, which means that for many +// low level concepts there are two versions, like processes (POSIX) and +// teams (Haiku), or pthreads and native threads. +// +// Both the POSIX API and the Haiku API live in libroot.so, the library that is +// linked to any binary by default. Additionally, Haiku supports several +// non-POSIX APIs from BSD and GNU, which live in libbsd.so and libgnu.so. These +// modules are also supported. +// +// The module is comprised of the following files: +// - `mod.rs` (this file) implements the C11 and POSIX API found in +// `headers/posix` +// - `b32.rs`, `b64.rs` and `x86_64.rs` contain platform-specific definitions +// of the C11 and POSIX APIs +// - `native.rs` defines the native Haiku API that is implemented in +// `libroot.so` and that are found in `headers/os`. +// - `bsd.rs` defines the BSD customizations available on Haiku found in +// `headers/compatibility/bsd` + pub type rlim_t = crate::uintptr_t; pub type sa_family_t = u8; pub type pthread_key_t = c_int; @@ -56,8 +80,6 @@ pub type ACTION = c_int; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -pub type StringList = _stringlist; - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl Copy for timezone {} @@ -440,19 +462,6 @@ s! { pub flag: *mut c_int, pub val: c_int, } - - pub struct _stringlist { - pub sl_str: *mut *mut c_char, - pub sl_max: size_t, - pub sl_cur: size_t, - } - - pub struct dl_phdr_info { - pub dlpi_addr: crate::Elf_Addr, - pub dlpi_name: *const c_char, - pub dlpi_phdr: *const crate::Elf_Phdr, - pub dlpi_phnum: crate::Elf_Half, - } } s_no_extra_traits! { @@ -1772,7 +1781,6 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; - pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; pub fn bind( @@ -2032,46 +2040,6 @@ extern "C" { pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; } -#[link(name = "bsd")] -extern "C" { - pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; - pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; - pub fn forkpty( - amaster: *mut c_int, - name: *mut c_char, - termp: *mut termios, - winp: *mut crate::winsize, - ) -> crate::pid_t; - pub fn openpty( - amaster: *mut c_int, - aslave: *mut c_int, - name: *mut c_char, - termp: *mut termios, - winp: *mut crate::winsize, - ) -> c_int; - pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; - pub fn explicit_bzero(buf: *mut c_void, len: size_t); - pub fn login_tty(_fd: c_int) -> c_int; - - pub fn sl_init() -> *mut StringList; - pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; - pub fn sl_free(sl: *mut StringList, i: c_int); - pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; - - pub fn getprogname() -> *const c_char; - pub fn setprogname(progname: *const c_char); - pub fn dl_iterate_phdr( - callback: Option< - unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, - >, - data: *mut c_void, - ) -> c_int; - - pub fn arc4random() -> u32; - pub fn arc4random_uniform(upper_bound: u32) -> u32; - pub fn arc4random_buf(buf: *mut c_void, n: size_t); -} - #[link(name = "gnu")] extern "C" { pub fn memmem( @@ -2115,5 +2083,8 @@ cfg_if! { } } +mod bsd; +pub use self::bsd::*; + mod native; pub use self::native::*; diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index f3eaf623a59a5..13a203f92ff56 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -1,19 +1,7 @@ use crate::off_t; use crate::prelude::*; -// This module contains bindings to the native Haiku API. The Haiku API -// originates from BeOS, and it was the original way to perform low level -// system and IO operations. The POSIX API was in that era was like a -// compatibility layer. In current Haiku development, both the POSIX API and -// the Haiku API are considered to be co-equal status. However, they are not -// integrated like they are on other UNIX platforms, which means that for many -// low level concepts there are two versions, like processes (POSIX) and -// teams (Haiku), or pthreads and native threads. -// -// Both the POSIX API and the Haiku API live in libroot.so, the library that is -// linked to any binary by default. -// -// This file follows the Haiku API for Haiku R1 beta 2. It is organized by the +// This file follows the Haiku API for Haiku R1 beta 5. It is organized by the // C/C++ header files in which the concepts can be found, while adhering to the // style guide for this crate. From 2d19d49c07bf78bc2e7a398f5b8e7daf3e546dc6 Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Wed, 25 Dec 2024 16:54:36 +0000 Subject: [PATCH 19/27] Haiku: add additional functionality in libbsd.so This includes: * sys/event.h: `kevent()`, `kqueue()`, data structure and constants * sys/iocomm.h: constants that are also defined for other platforms * stdlib.h: `mkstemps()` and `strtonum()` * sys/uov.h: `preadv()` and `pwritev()` * sys/wait.h: `wait4()` (backport ) (cherry picked from commit 7fd1b1a7b956bb345506a380874e6dfc523f93ba) --- src/unix/haiku/bsd.rs | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/unix/haiku/bsd.rs b/src/unix/haiku/bsd.rs index f093911d0c9c8..1e3881e2c67ff 100644 --- a/src/unix/haiku/bsd.rs +++ b/src/unix/haiku/bsd.rs @@ -22,6 +22,17 @@ s! { pub sl_cur: size_t, } + // sys/event.h + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + // sys/link_elf.h pub struct dl_phdr_info { pub dlpi_addr: crate::Elf_Addr, @@ -31,6 +42,25 @@ s! { } } +// sys/event.h +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_PROC: i16 = -5; +pub const EV_ADD: u16 = 0x0001; +pub const EV_DELETE: u16 = 0x0002; +pub const EV_ONESHOT: u16 = 0x0010; +pub const EV_CLEAR: u16 = 0x0020; +pub const EV_EOF: u16 = 0x8000; +pub const EV_ERROR: u16 = 0x4000; +pub const NOTE_EXIT: u32 = 0x80000000; + +// sys/ioccom.h +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + #[link(name = "bsd")] extern "C" { // stdlib.h @@ -40,6 +70,13 @@ extern "C" { pub fn arc4random() -> u32; pub fn arc4random_uniform(upper_bound: u32) -> u32; pub fn arc4random_buf(buf: *mut c_void, n: size_t); + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn strtonum( + nptr: *const c_char, + minval: c_longlong, + maxval: c_longlong, + errstr: *mut *const c_char, + ) -> c_longlong; // pty.h pub fn openpty( @@ -68,6 +105,17 @@ extern "C" { pub fn sl_free(sl: *mut StringList, i: c_int); pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; + // sys/event.h + pub fn kqueue() -> c_int; + pub fn kevent( + kq: c_int, + changelist: *const kevent, + nchanges: c_int, + eventlist: *mut kevent, + nevents: c_int, + timeout: *const crate::timespec, + ) -> c_int; + // sys/link_elf.h pub fn dl_iterate_phdr( callback: Option< @@ -78,4 +126,26 @@ extern "C" { // sys/time.h pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + // sys/uov.h + pub fn preadv( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + pub fn pwritev( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + + // sys/wait.h + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; } From 20476f203b7d5242889d33f48de9ab0a2ca17885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Jul 2025 16:02:37 +0200 Subject: [PATCH 20/27] freebsd: Fix type of struct xktls_session_onedir, field ifnet For the upstream definition, see: https://github.com/freebsd/freebsd-src/commit/c9e9a0fe5b0f88561f55fb2f6f5354fbbd96dd5d (backport ) (cherry picked from commit 985d95bb29c2156adcebf881266fd2f1a8708c6e) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3466e3b38d8cb..e2ee8e21f0c6f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1758,7 +1758,7 @@ s_no_extra_traits! { pub tls_bs: u8, pub flags: u8, pub drv_st_len: u16, - pub ifnet: [u8; 16], + pub ifnet: [c_char; 16], } pub struct xktls_session { From 9f3d6cf8e78d05910a14d71ac896275daad697ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Thu, 24 Jul 2025 17:38:51 +0200 Subject: [PATCH 21/27] freebsd: Document avoidance of reserved name `gen` (backport ) (cherry picked from commit 99e33735dbc69837d5f4d1ea91a4ed353695985e) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index e2ee8e21f0c6f..f60eb1a3e9cbe 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1741,6 +1741,8 @@ s_no_extra_traits! { } pub struct xktls_session_onedir { + // Note: this field is called `gen` in upstream FreeBSD, but `gen` is + // reserved keyword in Rust since the 2024 Edition, hence `gennum`. pub gennum: u64, _rsrv1: [u64; 8], _rsrv2: [u32; 8], From 57adc474cfdb68db78949401df3ce45079c6949b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Thu, 24 Jul 2025 17:50:17 +0200 Subject: [PATCH 22/27] libc-test: Account for xktls_session_onedir::gen (freebsd) (backport ) (cherry picked from commit 56a04abb0c9f0cd84c7234451456eda4f796ae26) --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index fb9367d2ff958..1304d3bf14202 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2585,6 +2585,8 @@ fn test_freebsd(target: &str) { "type_" if struct_ == "sockstat" => "type".to_string(), "type_" if struct_ == "devstat_match_table" => "type".to_string(), "type_" if struct_ == "input_event" => "type".to_string(), + // Field is named `gennum` in Rust because `gen` is a keyword + "gennum" if struct_ == "xktls_session_onedir" => "gen".to_string(), s => s.to_string(), } }); From 2a1f8fb96f8514930bd58c0d58152d622f011e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Jul 2025 16:04:28 +0200 Subject: [PATCH 23/27] libc-test: include sys/ktls.h on freebsd is necessary in order to find the xktls_* structs. See also: https://github.com/freebsd/freebsd-src/commit/c9e9a0fe5b0f88561f55fb2f6f5354fbbd96dd5d (backport ) (cherry picked from commit 4147a8b2689dfd281b3ca148c755e452936143f4) --- libc-test/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 1304d3bf14202..af273130833df 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2503,7 +2503,8 @@ fn test_freebsd(target: &str) { "sys/shm.h", "sys/socket.h", "sys/socketvar.h", - "netinet/in_pcb.h", // must be after sys/socketvar.h + [freebsd15]:"sys/ktls.h", + "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h "sys/stat.h", "sys/statvfs.h", "sys/sysctl.h", From 0b2b433b61cf40ae7df3203435dae81bf384d946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Jul 2025 16:29:16 +0200 Subject: [PATCH 24/27] freebsd15: Add ki_uerrmsg to struct kinfo_proc Upstream commit: https://github.com/freebsd/freebsd-src/commit/7212b37345936899e979c63d0b054e114576faa0 (backport ) (cherry picked from commit e2404b45f790d0b0e7fccc252c496b2d2b852aef) --- src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 6a02d7b35c186..97912bdebcdb2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -226,6 +226,8 @@ s! { // This is normally "struct pwddesc". /// Pointer to process paths info. pub ki_pd: *mut c_void, + /// Address of the ext err msg place + pub ki_uerrmsg: *mut c_void, pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], /// PS_* flags. @@ -445,7 +447,7 @@ pub const KF_TYPE_EVENTFD: c_int = 13; /// max length of devicename pub const SPECNAMELEN: c_int = 255; -pub const KI_NSPARE_PTR: usize = 5; +pub const KI_NSPARE_PTR: usize = 4; /// domainset policies pub const DOMAINSET_POLICY_INVALID: c_int = 0; From 1b01afde184692d1f25f2f0e483e95e344d7e0a8 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 16 Dec 2024 09:33:31 +0000 Subject: [PATCH 25/27] freebsd adding further TCP stack related constants. ref: https://github.com/freebsd/freebsd-src/commit/e570d231f48957dcf0757b7b716330f3bd64e362#diff-c354fa9fe15a3e5c90079f38792a8e5458d76677437a53ee7537a62fbc72e100R255 (backport ) (cherry picked from commit 0442ebb48baf9cd1d599a889f29eb44b68a461d6) --- libc-test/semver/freebsd.txt | 20 ++++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index d0b64323282c1..e8f385fe78982 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1507,15 +1507,35 @@ TAB3 TABDLY TCP_BBR_ALGORITHM TCP_BBR_DRAIN_PG +TCP_BBR_EXTRA_STATE +TCP_BBR_FLOOR_MIN_TSO +TCP_BBR_HDWR_PACE TCP_BBR_IWINTSO TCP_BBR_MAX_RTO TCP_BBR_MIN_RTO +TCP_BBR_MIN_TOPACEOUT +TCP_BBR_PACE_CROSS +TCP_BBR_PACE_DEL_TAR TCP_BBR_PACE_OH +TCP_BBR_PACE_PER_SEC +TCP_BBR_PACE_SEG_MAX +TCP_BBR_PACE_SEG_MIN +TCP_BBR_POLICER_DETECT +TCP_BBR_PROBE_RTT_GAIN TCP_BBR_PROBE_RTT_INT +TCP_BBR_PROBE_RTT_LEN +TCP_BBR_RACK_INIT_RATE +TCP_BBR_RACK_RTT_USE +TCP_BBR_RETRAN_WTSO +TCP_BBR_SEND_IWND_IN_TSO TCP_BBR_STARTUP_LOSS_EXIT TCP_BBR_STARTUP_PG +TCP_BBR_TMR_PACE_OH TCP_BBR_TSLIMITS +TCP_BBR_TSTMP_RAISES TCP_BBR_USEDEL_RATE +TCP_BBR_USE_RACK_RR +TCP_BBR_UTTER_MAX_TSO TCP_CCALGOOPT TCP_CONGESTION TCP_DELACK diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index f60eb1a3e9cbe..f64d079fd04c5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3638,6 +3638,26 @@ pub const TCP_BBR_USEDEL_RATE: c_int = 1079; pub const TCP_BBR_MIN_RTO: c_int = 1080; pub const TCP_BBR_MAX_RTO: c_int = 1081; pub const TCP_BBR_ALGORITHM: c_int = 1083; +pub const TCP_BBR_PACE_PER_SEC: c_int = 1086; +pub const TCP_BBR_PACE_DEL_TAR: c_int = 1087; +pub const TCP_BBR_PACE_SEG_MAX: c_int = 1088; +pub const TCP_BBR_PACE_SEG_MIN: c_int = 1089; +pub const TCP_BBR_PACE_CROSS: c_int = 1090; +pub const TCP_BBR_TMR_PACE_OH: c_int = 1096; +pub const TCP_BBR_RACK_RTT_USE: c_int = 1098; +pub const TCP_BBR_RETRAN_WTSO: c_int = 1099; +pub const TCP_BBR_PROBE_RTT_GAIN: c_int = 1101; +pub const TCP_BBR_PROBE_RTT_LEN: c_int = 1102; +pub const TCP_BBR_SEND_IWND_IN_TSO: c_int = 1103; +pub const TCP_BBR_USE_RACK_RR: c_int = 1104; +pub const TCP_BBR_HDWR_PACE: c_int = 1105; +pub const TCP_BBR_UTTER_MAX_TSO: c_int = 1106; +pub const TCP_BBR_EXTRA_STATE: c_int = 1107; +pub const TCP_BBR_FLOOR_MIN_TSO: c_int = 1108; +pub const TCP_BBR_MIN_TOPACEOUT: c_int = 1109; +pub const TCP_BBR_TSTMP_RAISES: c_int = 1110; +pub const TCP_BBR_POLICER_DETECT: c_int = 1111; +pub const TCP_BBR_RACK_INIT_RATE: c_int = 1112; pub const IP_BINDANY: c_int = 24; pub const IP_BINDMULTI: c_int = 25; From 7a56b98de50f96e53591bb379ea3277b12755bd0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 9 Aug 2025 19:28:27 -0500 Subject: [PATCH 26/27] Rename the ctest file from `main` to `ctest` Make it more obvious what this test is about. (backport ) (cherry picked from commit fef089cce47331eac7f087dc968917fa9a578965) --- ci/create-artifacts.py | 4 ++-- libc-test/Cargo.toml | 4 ++-- libc-test/build.rs | 34 ++++++++++++++-------------- libc-test/test/{main.rs => ctest.rs} | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) rename libc-test/test/{main.rs => ctest.rs} (53%) diff --git a/ci/create-artifacts.py b/ci/create-artifacts.py index 23710c9cf602a..2854daa563154 100755 --- a/ci/create-artifacts.py +++ b/ci/create-artifacts.py @@ -14,9 +14,9 @@ def main(): - # Find the most recently touched file named "main.c" in the target + # Find the most recently touched file named "ctest_output.c" in the target # directory. This will be libc-tests's `OUT_DIR` - marker_files = [Path(p) for p in glob("target/**/main.c", recursive=True)] + marker_files = [Path(p) for p in glob("target/**/ctest_output.c", recursive=True)] marker_files.sort(key=lambda path: path.stat().st_mtime) build_dir = marker_files[0].parent print(f"Located build directory '{build_dir}'") diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 6c9d8c82ab07f..32d98257e335e 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -31,8 +31,8 @@ align = ["libc/align"] extra_traits = ["libc/extra_traits"] [[test]] -name = "main" -path = "test/main.rs" +name = "ctest" +path = "test/ctest.rs" harness = false [[test]] diff --git a/libc-test/build.rs b/libc-test/build.rs index af273130833df..8cb82e8a8d833 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -504,7 +504,7 @@ fn test_apple(target: &str) { "uuid_t" | "vol_capabilities_set_t" => true, _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_openbsd(target: &str) { @@ -694,7 +694,7 @@ fn test_openbsd(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_cygwin(target: &str) { @@ -866,7 +866,7 @@ fn test_cygwin(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_windows(target: &str) { @@ -995,7 +995,7 @@ fn test_windows(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_redox(target: &str) { @@ -1045,7 +1045,7 @@ fn test_redox(target: &str) { "wchar.h", } - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_solarish(target: &str) { @@ -1335,7 +1335,7 @@ fn test_solarish(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_netbsd(target: &str) { @@ -1551,7 +1551,7 @@ fn test_netbsd(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_dragonflybsd(target: &str) { @@ -1776,7 +1776,7 @@ fn test_dragonflybsd(target: &str) { (struct_ == "sigevent" && field == "sigev_notify_thread_id") }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_wasi(target: &str) { @@ -1883,7 +1883,7 @@ fn test_wasi(target: &str) { // doesn't support sizeof. cfg.skip_field(|s, field| s == "dirent" && field == "d_name"); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_android(target: &str) { @@ -2390,7 +2390,7 @@ fn test_android(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); test_linux_like_apis(target); } @@ -3079,7 +3079,7 @@ fn test_freebsd(target: &str) { }); } - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_emscripten(target: &str) { @@ -3319,7 +3319,7 @@ fn test_emscripten(target: &str) { ].contains(&field)) }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_neutrino(target: &str) { @@ -3592,7 +3592,7 @@ fn test_neutrino(target: &str) { cfg.skip_static(move |name| name == "__dso_handle"); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_vxworks(target: &str) { @@ -3698,7 +3698,7 @@ fn test_vxworks(target: &str) { _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { @@ -5019,7 +5019,7 @@ fn test_linux(target: &str) { _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); test_linux_like_apis(target); } @@ -5537,7 +5537,7 @@ fn test_haiku(target: &str) { s => s.to_string(), } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } fn test_aix(target: &str) { @@ -5834,5 +5834,5 @@ fn test_aix(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); + cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); } diff --git a/libc-test/test/main.rs b/libc-test/test/ctest.rs similarity index 53% rename from libc-test/test/main.rs rename to libc-test/test/ctest.rs index c3fdcb56e54df..0b48c4af2975e 100644 --- a/libc-test/test/main.rs +++ b/libc-test/test/ctest.rs @@ -2,4 +2,4 @@ use libc::*; -include!(concat!(env!("OUT_DIR"), "/main.rs")); +include!(concat!(env!("OUT_DIR"), "/ctest_output.rs")); From 57fc44a84c7bb3dab730081b7966d59b4e59cedc Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 9 Aug 2025 21:11:26 -0500 Subject: [PATCH 27/27] cleanup: Format a file that was missed Also start validating formatting in CI for files in `ci/`. (backport ) (cherry picked from commit c0071cc9f9385da6352e40824cfd77334e85f72d) --- ci/ios/deploy_and_run_on_ios_simulator.rs | 100 +++++++++++++--------- ci/style.sh | 2 +- 2 files changed, 59 insertions(+), 43 deletions(-) diff --git a/ci/ios/deploy_and_run_on_ios_simulator.rs b/ci/ios/deploy_and_run_on_ios_simulator.rs index 7e0b80268ffbc..0398a9d3f888d 100644 --- a/ci/ios/deploy_and_run_on_ios_simulator.rs +++ b/ci/ios/deploy_and_run_on_ios_simulator.rs @@ -6,18 +6,19 @@ // (https://github.com/snipsco/dinghy): cargo dinghy install, then cargo dinghy // test. -use std::env; use std::fs::{self, File}; use std::io::Write; use std::path::Path; -use std::process; use std::process::Command; +use std::{env, process}; macro_rules! t { - ($e:expr) => (match $e { - Ok(e) => e, - Err(e) => panic!("{} failed with: {e}", stringify!($e)), - }) + ($e:expr) => { + match $e { + Ok(e) => e, + Err(e) => panic!("{} failed with: {e}", stringify!($e)), + } + }; } // Step one: Wrap as an app @@ -25,11 +26,15 @@ fn package_as_simulator_app(crate_name: &str, test_binary_path: &Path) { println!("Packaging simulator app"); drop(fs::remove_dir_all("ios_simulator_app")); t!(fs::create_dir("ios_simulator_app")); - t!(fs::copy(test_binary_path, - Path::new("ios_simulator_app").join(crate_name))); + t!(fs::copy( + test_binary_path, + Path::new("ios_simulator_app").join(crate_name) + )); let mut f = t!(File::create("ios_simulator_app/Info.plist")); - t!(f.write_all(format!(r#" + t!(f.write_all( + format!( + r#" com.rust.unittests - "#, crate_name).as_bytes())); + "#, + crate_name + ) + .as_bytes() + )); } // Step two: Start the iOS simulator @@ -57,8 +66,10 @@ fn start_simulator() { for line in stdout.lines() { if line.contains("rust_ios") { if found_rust_sim { - panic!("Duplicate rust_ios simulators found. Please \ - double-check xcrun simctl list."); + panic!( + "Duplicate rust_ios simulators found. Please \ + double-check xcrun simctl list." + ); } simulator_exists = true; simulator_booted = line.contains("(Booted)"); @@ -69,62 +80,67 @@ fn start_simulator() { if simulator_exists == false { println!("Creating iOS simulator"); Command::new("xcrun") - .arg("simctl") - .arg("create") - .arg("rust_ios") - .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE") - .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2") - .check_status(); + .arg("simctl") + .arg("create") + .arg("rust_ios") + .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE") + .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2") + .check_status(); } else if simulator_booted == true { println!("Shutting down already-booted simulator"); Command::new("xcrun") - .arg("simctl") - .arg("shutdown") - .arg("rust_ios") - .check_status(); + .arg("simctl") + .arg("shutdown") + .arg("rust_ios") + .check_status(); } println!("Starting iOS simulator"); // We can't uninstall the app (if present) as that will hang if the // simulator isn't completely booted; just erase the simulator instead. - Command::new("xcrun").arg("simctl").arg("erase").arg("rust_ios").check_status(); - Command::new("xcrun").arg("simctl").arg("boot").arg("rust_ios").check_status(); + Command::new("xcrun") + .arg("simctl") + .arg("erase") + .arg("rust_ios") + .check_status(); + Command::new("xcrun") + .arg("simctl") + .arg("boot") + .arg("rust_ios") + .check_status(); } // Step three: Install the app fn install_app_to_simulator() { println!("Installing app to simulator"); Command::new("xcrun") - .arg("simctl") - .arg("install") - .arg("booted") - .arg("ios_simulator_app/") - .check_status(); + .arg("simctl") + .arg("install") + .arg("booted") + .arg("ios_simulator_app/") + .check_status(); } // Step four: Run the app fn run_app_on_simulator() { println!("Running app"); let output = t!(Command::new("xcrun") - .arg("simctl") - .arg("launch") - .arg("--console") - .arg("booted") - .arg("com.rust.unittests") - .output()); + .arg("simctl") + .arg("launch") + .arg("--console") + .arg("booted") + .arg("com.rust.unittests") + .output()); println!("status: {}", output.status); println!("stdout --\n{}\n", String::from_utf8_lossy(&output.stdout)); println!("stderr --\n{}\n", String::from_utf8_lossy(&output.stderr)); let stdout = String::from_utf8_lossy(&output.stdout); - let passed = stdout.lines() - .find(|l| - (l.contains("PASSED") && - l.contains("tests")) || - l.contains("test result: ok") - ) - .unwrap_or(false); + let passed = stdout + .lines() + .find(|l| (l.contains("PASSED") && l.contains("tests")) || l.contains("test result: ok")) + .unwrap_or(false); println!("Shutting down simulator"); Command::new("xcrun") diff --git a/ci/style.sh b/ci/style.sh index 72465f71c760a..2d3e874e38998 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -11,7 +11,7 @@ rustfmt -V # Save a list of all source files tmpfile="file-list~" # trailing tilde for gitignore -find src -name '*.rs' > "$tmpfile" +find src ci -name '*.rs' > "$tmpfile" # Before formatting, replace all macro identifiers with a function signature. # This allows `rustfmt` to format it.