From 746dda8cd8f2a8c1064abc1073ae48ae8de9f879 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 31 Aug 2026 04:55:17 -0500 Subject: [PATCH 01/45] util: Fix the ordering of backported commits Also fix a few lints. (backport ) (cherry picked from commit 6930883d78ccb60aec75bb7093eebdaa84d5dba1) --- etc/libc-util.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/etc/libc-util.py b/etc/libc-util.py index 2181abf264d0..55a37982ea95 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -4,7 +4,6 @@ import argparse import copy import datetime as dt -from enum import StrEnum import functools import json import os @@ -13,6 +12,7 @@ import subprocess as sp import sys from dataclasses import dataclass +from enum import StrEnum from inspect import cleandoc from multiprocessing import Pool from pathlib import Path @@ -465,7 +465,7 @@ def check_all_targets( package: str, only: str | None = None, skip: str | None = None, - cargo_args: list[str] = [], + cargo_args: list[str] | None = None, ) -> None: """Run checks from the populated list.""" checks = self.checks @@ -534,7 +534,7 @@ def check_all_targets( ] + common_args + extra_args - + cargo_args, + + (cargo_args or []), env=env | {"RUSTFLAGS": " ".join(rustflags)}, ) ok = True @@ -731,8 +731,7 @@ def prepare_rebase_todo(self) -> None: # "merge" commit is the last commit on `main` from this PR, so we can # work backwards; given N commits, `merge_sha~(N-1)` will be the first PR # from the commit on `main`. - for i in reversed(range(len(pr.commits))): - n_back = len(pr.commits) - i - 1 + for n_back in reversed(range(len(pr.commits))): pick_sha = check_output( ["git", "rev-parse", f"{last_sha}~{n_back}"], quiet=True ).strip() @@ -921,7 +920,7 @@ def backport_pr_description(branch: str) -> None: """List all backported commits for a branch, for pasting into the PR body.""" commits = check_output(["git", "log", f"libc-0.2..{branch}", "--format=%b"]) urls = {x[1] for x in re.finditer(r"^\(backport <(.*)>\)", commits, re.M)} - urls = sorted(list(urls)) + urls = sorted(urls) s = "Backport the following:\n\n" for url in urls: From 3cff71bc9f901d799a58eb12339954844e1728b1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 3 Sep 2026 21:47:03 -0400 Subject: [PATCH 02/45] util: Properly escape strings passed to `printf` Avoid an error when the commit message contains a word like "don't" that ends the `'`-quoted string. Also fix a few lints. (backport ) (cherry picked from commit 0cbe30adaed7d2975061447a8f14ee02532713f0) --- etc/libc-util.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/etc/libc-util.py b/etc/libc-util.py index 55a37982ea95..da4ba6c68fbb 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 """Helper utilities for common libc tasks.""" +# ruff: noqa: FURB167 allow short regex flags + import argparse import copy import datetime as dt @@ -9,6 +11,7 @@ import os import pprint import re +import shlex import subprocess as sp import sys from dataclasses import dataclass @@ -16,6 +19,7 @@ from inspect import cleandoc from multiprocessing import Pool from pathlib import Path +from typing import ClassVar REPO_OWNER = "rust-lang" REPO = "libc" @@ -158,10 +162,10 @@ def execute(self) -> None: if state != "MERGED": print(f'expected MERGED state; got {state} for "{title}" (#{num})') - exit(1) + sys.exit(1) if base != "libc-0.2": print(f'expected libc-0.2 base ref; got {base} for "{title}" (#{num})') - exit(1) + sys.exit(1) print(f'Relabling PRs listed in {num} "{title}"') @@ -337,10 +341,10 @@ class CheckAllTargets: checks: list["CheckInvocation"] failure_limit: int - FREEBSD_VERSIONS = [13, 14, 15] + FREEBSD_VERSIONS: ClassVar = [13, 14, 15] # Targets that don't pass for one reason or another - BROKEN_TARGETS = [ + BROKEN_TARGETS: ClassVar = [ # libc problems ("aarch64-unknown-nto-qnx800", "libc error, unsupported arch"), ("aarch64.*-gnu_ilp32.*time_bits=64", "libc error, time64 mismatches"), @@ -361,7 +365,7 @@ class CheckAllTargets: ] # Flags that always need to be passed to specific targets - EXTRA_TARGET_FLAGS = { + EXTRA_TARGET_FLAGS: ClassVar = { # Target CPU must be specified "avr-none": ["-Ctarget-cpu=atmega328p"], # Emits a lot of warnings @@ -613,7 +617,7 @@ class Backporter: branch: str WORKTREE_DIR = ".libc-backports" - WORKTREE_GIT = ["git", "-C", WORKTREE_DIR] + WORKTREE_GIT: ClassVar = ["git", "-C", WORKTREE_DIR] GQL_QUERY = """ query ($endCursor: String) { repository(name: "libc", owner: "rust-lang") { @@ -702,7 +706,7 @@ def start_backports(self) -> None: delete the branch and start from scratch.{E.RST} """ print("\n" + mstr(msg)) - exit(1) + sys.exit(1) def prepare_rebase_todo(self) -> None: """Create a rebase todo list and cache it, to be picked up by the sequence @@ -722,7 +726,7 @@ def prepare_rebase_todo(self) -> None: # If we have a merge commit, take only the second (incoming) commit. if len(parents) > 2: eprint("Can't backport commits with >1 parent") - exit(1) + sys.exit(1) if len(parents) == 2: last_sha = parents[1] @@ -741,7 +745,7 @@ def prepare_rebase_todo(self) -> None: pick_short = pick_sha[:12] rebase_todo += ( f"exec printf '{E.CY_B.u}picking from PR{pr.number}: {pick_short} " - f'"{subject}"{E.RST.u}\\n\'' + f'"%s"{E.RST.u}\\n\' {shlex.quote(subject)}' "\n" f'pick {pick_short} # pick "{subject}"' "\n" @@ -800,7 +804,7 @@ def fetch_needs_backport_list(self) -> list["PullRequest"]: f"limit reached: {total_commits} total commits but could " f"only fetch {new_commit_count}" ) - exit(1) + sys.exit(1) pull_requests.append(new) @@ -822,7 +826,7 @@ def ensure_local_updated(self) -> None: f"local libc-0.2@{local[:12]} does not match upstream/libc-0.2@{upstream[:12]}!" "Fetch before retrying." ) - exit(1) + sys.exit(1) def ensure_branch(self) -> None: """Create the branch if it doesn't exist.""" From 003ef1e6694dc6623a6825ee7be88f990608ced4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 04:52:43 -0400 Subject: [PATCH 03/45] renovate: Create PRs against both `main` and `libc-0.2` * File PRs against both branches separately. This avoids the need to backport lockfile bumps, which always conflicts. * Swap to biweekly lockfile maintenance * Add applicable stable-* labels * Clean up some inconsistent syntax (backport ) (cherry picked from commit 9a7a2844e13ee4a38775b86f1e46f10ae977b83b) --- .github/renovate.json5 | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 6ce8de556d5b..a5f1270a63f7 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -5,30 +5,40 @@ ":maintainLockFilesMonthly", "helpers:pinGitHubActionDigestsToSemver" ], + baseBranchPatterns: ["main", "libc-0.2"], + lockFileMaintenance: { + enabled: true, + // Biweekly at 12:00UTC on Monday + schedule: ["0 12 1-7,15-21 * 1"] + } packageRules: [ { - matchCategories: [ - "rust" - ], - matchJsonata: [ - "isBreaking != true" - ], + matchCategories: ["rust"], + matchJsonata: ["isBreaking != true"], // Disable non-breaking change updates because they // are updated periodically with lockfile maintainance. enabled: false, }, { - matchManagers: [ - "github-actions" - ], + matchCategories: ["rust"], + // Separate PRs against main and 0.2 + addLabels: ["stable-declined"], + }, + { + matchManagers: ["github-actions"], // Every month schedule: "* 0 1 * *", groupName: "Github Actions", + // Separate PRs against main and 0.2 + addLabels: ["stable-declined"], }, { // Don't updates such as 23.10 -> mantic-20240530 - "matchDatasources": ["docker"], - "pinDigests": false + matchDatasources: ["docker"], + // Only on main, we backport these + matchBaseBranches: ["main"], + addLabels: ["stable-nominated"], + pinDigests: false } ], // Receive any update that fixes security vulnerabilities. From c4739371cfd84e4fa91b7ffea1cb1171e3c94f78 Mon Sep 17 00:00:00 2001 From: Mahdi Ali-Raihan Date: Sun, 30 Aug 2026 18:28:48 -0400 Subject: [PATCH 04/45] Unix: Add `_PATH_BSHELL` and `_PATH_DEFPATH` where available. The following are sources to each platform's `paths.h`: From BSD: * [Apple](https://github.com/apple-oss-distributions/Libc/blob/71bbe350ab79eef58113991d817ccc6165061a64/include/paths.h#L65): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [Dragonfly](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/42aaacafd14ddb7f660730a5ca5da0a2d941723a/include/paths.h#L40): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [FreeBSD](https://github.com/freebsd/freebsd-src/blob/551b7c5e12bfea623a47edf97ad5689732a1233f/include/paths.h#L40): Has `_PATH_BSHELL` and `_PATH_DEFPATH` (verified same values on version 11+) * [NetBSD](https://github.com/NetBSD/src/blob/f66621237dc60126bd8a972b6064639892b344b7/include/paths.h#L43): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [OpenBSD](https://github.com/openbsd/src/blob/7d89a3e823169cb6a1d989e3f5f93f7f3c4b5db4/include/paths.h#L39): Has `_PATH_BSHELL` and `_PATH_DEFPATH` From Linux: * [Android](https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/paths.h#48): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [glibc](https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/paths.h;h=1342ab3a96ab12065311b718e57e7235e07587f8;hb=HEAD#l36): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [musl](https://git.musl-libc.org/cgit/musl/tree/include/paths.h?id=f21a96538f78fa8e2040831b4209b35f2fb581da#n4): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [uClibc](https://github.com/kraj/uClibc/blob/ca1c74d67dd115d059a875150e10b8560a9c35a8/include/paths.h#L36): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [emscripten](https://github.com/emscripten-core/emscripten/blob/a2059f978ed206b688daf4a8774211949610c2aa/system/lib/libc/musl/include/paths.h#L4): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * l4re: There's [musl](https://github.com/l4re/l4re-core/blob/d09b1619c45d17786bc256ea219688f8ba3ff1fe/libc/musl/contrib/musl/include/paths.h#L4) and [uclibc](https://github.com/l4re/l4re-core/blob/d09b1619c45d17786bc256ea219688f8ba3ff1fe/libc/uclibc-ng/contrib/uclibc/include/paths.h#L36) `paths.h` file containing `_PATH_BSHELL` and `_PATH_DEFPATH` values Miscellaneous Platforms: * [Haiku](https://github.com/haiku/haiku/blob/8a33129223e93ea046dc62e9e09f8c93f45cfb7b/headers/compatibility/bsd/paths.h#L45): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [Hurd](https://github.com/joshumax/hurd/blob/83a6fc7641eecdb2b96c2dee2261da92573693de/hurd/paths.h#L20): Doesn't have `_PATH_BSHELL` and `_PATH_DEFPATH` in paths.h (wouldn't hurt to confirm this though in terminal) * [Cygwin](https://github.com/cygwin/cygwin/blob/cf61e0140e3d6cd21e743a38d35efc98194b63f3/winsup/cygwin/include/paths.h#L12): Has `_PATH_BSHELL` and `_PATH_DEFPATH` * [newlib](https://github.com/ourairquality/newlib/blob/0dea38754696422d526543262274703acd8317c5/newlib/libc/include/paths.h#L7): Has `_PATH_BSHELL` * [Redox](https://gitlab.redox-os.org/redox-os/relibc/-/blob/c3b3f2773a3a2622fdb632a9bfa1a77d68778150/include/paths.h): Has `_PATH_BSHELL` Platforms I'm unsure if they have `_PATH_BSHELL`/`_PATH_DEFPATH`: * Solarish: I'm unsure how to get this info since I believe Solaris is closed source? * AIX: I think this is also closed source? However, I saw this [archive repo](https://github.com/Arquivotheca/AIX-4.1.3/blob/d6fe8fe8299ececc0db4fae9c19cd3babffd28ae/bos/usr/include/paths.h#L36) of AIX 4.13 that has `_PATH_BSHELL`. * [nuttx](https://github.com/apache/nuttx): Couldn't find a `include/paths.h` file. * [NTO/QNX](https://github.com/qnx): Couldn't find a `include/paths.h` file. (backport ) (cherry picked from commit 89a22c6aa4918d4f50820249bb027f79ff32d463) --- libc-test/build/main.rs | 11 +++++++++++ libc-test/semver/android.txt | 2 ++ libc-test/semver/apple.txt | 2 ++ libc-test/semver/cygwin.txt | 2 ++ libc-test/semver/dragonfly.txt | 2 ++ libc-test/semver/espidf.txt | 1 + libc-test/semver/freebsd.txt | 2 ++ libc-test/semver/linux.txt | 2 ++ libc-test/semver/netbsd.txt | 2 ++ libc-test/semver/openbsd.txt | 2 ++ libc-test/semver/redox.txt | 1 + src/macros.rs | 1 + src/types.rs | 8 ++++++++ src/unix/bsd/apple/mod.rs | 4 ++++ src/unix/bsd/freebsdlike/dragonfly/mod.rs | 6 ++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 5 +++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 4 ++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 5 +++++ src/unix/cygwin/mod.rs | 4 ++++ src/unix/haiku/mod.rs | 4 ++++ src/unix/linux_like/android/mod.rs | 8 ++++++++ src/unix/linux_like/emscripten/mod.rs | 4 ++++ src/unix/linux_like/l4re/uclibc/mod.rs | 4 ++++ src/unix/linux_like/linux/gnu/mod.rs | 4 ++++ src/unix/linux_like/linux/musl/mod.rs | 4 ++++ src/unix/linux_like/linux/uclibc/mod.rs | 4 ++++ src/unix/newlib/mod.rs | 3 +++ src/unix/redox/mod.rs | 3 +++ 28 files changed, 104 insertions(+) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index f2d787fdc1f7..0fef1ef41188 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -202,6 +202,7 @@ fn test_apple(t: &Target) { "os/lock.h", "os/signpost.h", "os/os_sync_wait_on_address.h", + "paths.h", "poll.h", "pthread.h", "pthread_spis.h", @@ -493,6 +494,7 @@ fn test_openbsd(t: &Target) { "sys/shm.h", "sys/param.h", "sys/auxv.h", + "paths.h", ); cfg.rename_type(|ty| match ty { @@ -631,6 +633,7 @@ fn test_cygwin(t: &Target) { "net/if.h", "netdb.h", "netinet/tcp.h", + "paths.h", "poll.h", "pthread.h", "pty.h", @@ -944,6 +947,7 @@ fn test_redox(t: &Target) { "netinet/in.h", "netinet/ip.h", "netinet/tcp.h", + "paths.h", "poll.h", "pwd.h", "semaphore.h", @@ -1382,6 +1386,7 @@ fn test_netbsd(t: &Target) { "iconv.h", "utmp.h", "utmpx.h", + "paths.h", ); cfg.rename_type(move |ty| { @@ -1632,6 +1637,7 @@ fn test_dragonflybsd(t: &Target) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + "paths.h", "poll.h", "pthread.h", "pthread_np.h", @@ -2172,6 +2178,7 @@ fn test_android(t: &Target) { // generate the error 'Your time_t is already 64-bit' (t.p32(), "time64.h"), (x86, "sys/reg.h"), + "paths.h", ); // Include linux headers at the end: @@ -2661,6 +2668,7 @@ fn test_freebsd(t: &Target) { "netinet/tcp.h", "netinet/udp.h", "netinet6/in6_var.h", + "paths.h", "poll.h", "pthread.h", "pthread_np.h", @@ -3374,6 +3382,7 @@ fn test_emscripten(t: &Target) { "utmp.h", "utmpx.h", "wchar.h", + "paths.h", ); cfg.rename_struct_ty(move |ty| { @@ -4246,6 +4255,7 @@ fn test_linux(t: &Target) { // https://www.openwall.com/lists/musl/2015/04/09/3 // is not present on uclibc. (!(musl || uclibc), "execinfo.h"), + "paths.h", ); // Include linux headers at the end: @@ -5547,6 +5557,7 @@ fn test_haiku(t: &Target) { "netinet6/in6.h", "nl_types.h", "null.h", + "paths.h", "poll.h", "pthread.h", "pwd.h", diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 7ddd3dbb65a1..a29e7ecf7408 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3199,6 +3199,8 @@ X_OK _IOFBF _IOLBF _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 3ab27db12416..035e4b8c07ab 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1720,6 +1720,8 @@ _NSGetArgv _NSGetEnviron _NSGetExecutablePath _NSGetProgname +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index 691271e61ac7..6fa71843e308 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -472,6 +472,8 @@ WINDOWS_SEND XTABS _CS_PATH _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index cef23201ff9c..ce188075e353 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1175,6 +1175,8 @@ _CS_PATH _IOFBF _IOLBF _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_ACL_PATH_MAX diff --git a/libc-test/semver/espidf.txt b/libc-test/semver/espidf.txt index f9f9089b9e37..df8bd8b8037e 100644 --- a/libc-test/semver/espidf.txt +++ b/libc-test/semver/espidf.txt @@ -32,6 +32,7 @@ SIGSEGV SIGTERM SOL_SOCKET SOMAXCONN +_PATH_BSHELL __errno cmsghdr dirent diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index dd380534a4d3..5db4e7ef5778 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1779,6 +1779,8 @@ _IOR _IOW _IOWINT _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_ACL_EXTENDED _PC_ACL_NFS4 _PC_ACL_PATH_MAX diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index ba6693d4d2f6..5087ee94409c 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3871,6 +3871,8 @@ _IONBF _IOR _IOW _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 44d9380d1260..cfec566f3580 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1132,6 +1132,8 @@ _IONBF _IOR _IOW _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_FILESIZEBITS diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 8e2ca1d9f00b..99b04eb1cf0f 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -993,6 +993,8 @@ _IOR _IOW _IOWR _MAX_PAGE_SHIFT +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 8753284191f4..f308714962bc 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -258,6 +258,7 @@ _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _IOFBF _IOLBF _IONBF +_PATH_BSHELL _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/src/macros.rs b/src/macros.rs index 587438c5ec86..d10dbc4425e0 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -112,6 +112,7 @@ macro_rules! prelude { pub(crate) use crate::types::u32_cast_ioctl; #[allow(unused_imports)] pub(crate) use crate::types::{ + cstr, replace_array_items, u16_cast_short, u32_cast_int, diff --git a/src/types.rs b/src/types.rs index 02bb2d33ce89..c3036ea39ecd 100644 --- a/src/types.rs +++ b/src/types.rs @@ -140,3 +140,11 @@ pub const fn replace_array_items( } dst } + +/// Constructs a compile time cstring literal from a byte array +// FIXME(msrv): we can opt to use C-string literals directly in 1.77 +#[allow(dead_code)] +pub(crate) const fn cstr(bytes: &[u8]) -> *const c_char { + assert!(!bytes.is_empty() && bytes[bytes.len() - 1] == 0); + bytes.as_ptr().cast::() +} diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 2a953eda0b07..2a2ee82c060d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4307,6 +4307,10 @@ pub const VMADDR_CID_RESERVED: c_uint = 1; pub const VMADDR_CID_HOST: c_uint = 2; pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn __DARWIN_ALIGN32(p: usize) -> usize { const __DARWIN_ALIGNBYTES32: usize = size_of::() - 1; (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32 diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 95f7e305e457..ac137c1f5d1c 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1230,6 +1230,12 @@ pub const RTAX_MPLS3: c_int = 10; /// for details. pub const RTAX_MAX: c_int = 11; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr( + b"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/pkg/bin:/usr/pkg/sbin\0", +); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn _CMSG_ALIGN(n: usize) -> usize { (n + (size_of::() - 1)) & !(size_of::() - 1) } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 4a72335df97c..1ef120c056b7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4413,6 +4413,11 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = + cstr(b"/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 134a4e5fdebb..fd12e635c791 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1821,6 +1821,10 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 883dbaee0857..c4c29ecc50e7 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1854,6 +1854,11 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = + cstr(b"/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).offset(_ALIGN(size_of::()) as isize) diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 5645bdd2b2dc..6681080e81d6 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1678,6 +1678,10 @@ pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x0008; pub const FALLOC_FL_INSERT_RANGE: c_int = 0x0010; pub const FALLOC_FL_KEEP_SIZE: c_int = 0x1000; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 72be53de152f..ca30428a1667 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1388,6 +1388,10 @@ pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; pub const POSIX_SPAWN_SETSID: c_int = 0x40; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 7102140a26d3..9687ec0ec5be 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3414,6 +3414,14 @@ pub const RWF_NOAPPEND: c_int = 0x00000020; pub const RWF_ATOMIC: c_int = 0x00000040; pub const RWF_DONTCACHE: c_int = 0x00000080; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr( + b"/product/bin:/apex/com.android.runtime/bin:\ + /apex/com.android.art/bin:/system_ext/bin:/system/bin:\ + /system/xbin:/odm/bin:/vendor/bin:/vendor/xbin\0", +); +pub const _PATH_BSHELL: *const c_char = cstr(b"/system/bin/sh\0"); + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here. diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 6d1d9f27d1da..a19821ae51e4 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1279,6 +1279,10 @@ pub const PRIO_USER: c_int = 2; pub const SOMAXCONN: c_int = 128; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/local/bin:/bin:/usr/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index cced9a7be440..afb8f64011e2 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -478,6 +478,10 @@ pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 3; pub const __LT_SPINLOCK_INIT: c_int = 0; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock { __status: 0, __spinlock: __LT_SPINLOCK_INIT, diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 297ec8e959bb..27b967248ab5 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -871,6 +871,10 @@ pub const GLOB_TILDE_CHECK: c_int = 1 << 14; pub const MADV_COLLAPSE: c_int = 25; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + cfg_if! { if #[cfg(any( target_arch = "arm", diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 3641134f1f31..aa8a45d5eba5 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -692,6 +692,10 @@ pub const UT_HOSTSIZE: usize = 256; pub const UT_LINESIZE: usize = 32; pub const UT_NAMESIZE: usize = 32; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/local/bin:/bin:/usr/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + cfg_if! { if #[cfg(target_arch = "s390x")] { pub const POSIX_FADV_DONTNEED: c_int = 6; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 0075bddee94e..63b39133f9c5 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -263,6 +263,10 @@ pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; pub const UDP_GRO: c_int = 104; pub const UDP_SEGMENT: c_int = 103; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 933bc2eb8f6f..468845ee87d9 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -888,6 +888,9 @@ pub const PRIO_PROCESS: c_int = 0; pub const PRIO_PGRP: c_int = 1; pub const PRIO_USER: c_int = 2; +// include/paths.h from newlib's libc +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let bits = size_of_val(&(*set).fds_bits[0]) * 8; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 4e21f57b3e18..8df0877730cf 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1225,6 +1225,9 @@ pub const PRIO_USER: c_int = 2; pub const RENAME_NOREPLACE: c_uint = 1; +// include/paths.h from relibc +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { //sys/socket.h pub const unsafe fn CMSG_ALIGN(len: size_t) -> size_t { From ccec21e38c2d4835f49f34d96dd9a916876a72b3 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 23:22:35 -0400 Subject: [PATCH 05/45] musl: Move more constants to `socket.rs` Link: https://github.com/kraj/musl/blob/cec26f5164f0deede51ed36591f58fca19c10795/include/sys/socket.h#L99-L225 (backport ) (cherry picked from commit 2deb3b29ce7eef6231e918525040fb0f86462363) --- src/new/musl/sys/socket.rs | 21 +++++++++++++++++++++ src/unix/linux_like/linux/musl/mod.rs | 17 ----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs index 8083ddc2a7dc..4b53d2c0faf3 100644 --- a/src/new/musl/sys/socket.rs +++ b/src/new/musl/sys/socket.rs @@ -63,3 +63,24 @@ cfg_if! { pub const SOCK_DGRAM: c_int = 2; } } + +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] +pub const SOCK_PACKET: c_int = 10; + +pub const SOCK_NONBLOCK: c_int = crate::O_NONBLOCK; + +pub const PF_IB: c_int = 27; +pub const PF_MPLS: c_int = 28; + +pub const PF_NFC: c_int = 39; +pub const PF_VSOCK: c_int = 40; + +pub const PF_XDP: c_int = 44; + +pub const AF_IB: c_int = PF_IB; +pub const AF_MPLS: c_int = PF_MPLS; +pub const AF_NFC: c_int = PF_NFC; +pub const AF_VSOCK: c_int = PF_VSOCK; +pub const AF_XDP: c_int = PF_XDP; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index aa8a45d5eba5..ba04f8d43589 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -528,12 +528,6 @@ pub const PTHREAD_STACK_MIN: size_t = 2048; pub const MAP_ANONYMOUS: c_int = MAP_ANON; -pub const SOCK_SEQPACKET: c_int = 5; -pub const SOCK_DCCP: c_int = 6; -pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; -#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] -pub const SOCK_PACKET: c_int = 10; - pub const SOMAXCONN: c_int = 128; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -576,17 +570,6 @@ pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; pub const PTRACE_GETSIGMASK: c_uint = 0x420a; pub const PTRACE_SETSIGMASK: c_uint = 0x420b; -pub const AF_IB: c_int = 27; -pub const AF_MPLS: c_int = 28; -pub const AF_NFC: c_int = 39; -pub const AF_VSOCK: c_int = 40; -pub const AF_XDP: c_int = 44; -pub const PF_IB: c_int = AF_IB; -pub const PF_MPLS: c_int = AF_MPLS; -pub const PF_NFC: c_int = AF_NFC; -pub const PF_VSOCK: c_int = AF_VSOCK; -pub const PF_XDP: c_int = AF_XDP; - pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK; From dafef359227f6661dd4cad1401f84a44b8e80b28 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 5 Sep 2026 01:31:45 -0400 Subject: [PATCH 06/45] glibc: Closer match upstream's root structure Nest and re-export `io::sys`, and re-export other `bits` modules into top level to match how things are imported via `bits/`. (backport ) (cherry picked from commit df4fd8872431422d55bf85917a3b6dece7655116) --- src/new/glibc/bits/signum_generic.rs | 2 +- src/new/glibc/io/sys/mod.rs | 6 ++++++ src/new/glibc/{ => io}/sys/statvfs.rs | 2 +- src/new/glibc/mod.rs | 23 +++++++++++++++-------- src/new/glibc/signal.rs | 6 +++--- src/new/glibc/sys.rs | 8 ++++++++ 6 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 src/new/glibc/io/sys/mod.rs rename src/new/glibc/{ => io}/sys/statvfs.rs (90%) create mode 100644 src/new/glibc/sys.rs diff --git a/src/new/glibc/bits/signum_generic.rs b/src/new/glibc/bits/signum_generic.rs index 4dacf29dc6bc..a04027459595 100644 --- a/src/new/glibc/bits/signum_generic.rs +++ b/src/new/glibc/bits/signum_generic.rs @@ -16,4 +16,4 @@ pub const SIGKILL: c_int = 9; pub const SIGPIPE: c_int = 13; pub const SIGALRM: c_int = 14; -pub use super::super::sysdeps::unix::linux::bits::signum_arch::*; +pub use crate::new::glibc::bits::signum_arch::*; diff --git a/src/new/glibc/io/sys/mod.rs b/src/new/glibc/io/sys/mod.rs new file mode 100644 index 000000000000..9bb83fb249fe --- /dev/null +++ b/src/new/glibc/io/sys/mod.rs @@ -0,0 +1,6 @@ +//! Source directory: `io/sys/` +//! +//! + +#[cfg(target_os = "linux")] +pub(crate) mod statvfs; diff --git a/src/new/glibc/sys/statvfs.rs b/src/new/glibc/io/sys/statvfs.rs similarity index 90% rename from src/new/glibc/sys/statvfs.rs rename to src/new/glibc/io/sys/statvfs.rs index e1d7cf08e85d..8efae19a9a68 100644 --- a/src/new/glibc/sys/statvfs.rs +++ b/src/new/glibc/io/sys/statvfs.rs @@ -1,6 +1,6 @@ //! Header: `io/sys/statvfs.h` -pub use super::super::sysdeps::unix::linux::bits::statvfs::*; +pub use crate::new::glibc::bits::statvfs::*; use crate::prelude::*; extern "C" { diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 15441a20852e..990ef22be511 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -8,10 +8,23 @@ /// Source directory: `bits/` /// +/// This directory contains default +/// /// mod bits { #[cfg(target_os = "linux")] pub(crate) mod signum_generic; + #[cfg(target_os = "linux")] + pub(crate) use super::sysdeps::unix::linux::bits::{ + sigaction, + signum_arch, + statvfs, + types, + }; +} + +mod io { + pub(crate) mod sys; } /// Source directory: `posix/` @@ -24,14 +37,6 @@ mod posix { #[cfg(target_os = "linux")] pub(crate) mod signal; -/// Source directory: `io/sys/` -/// -/// -pub(crate) mod sys { - #[cfg(target_os = "linux")] - pub(crate) mod statvfs; -} - /// Source directory: `sysdeps/` /// /// @@ -45,6 +50,8 @@ mod sysdeps { // `path = "..."` wherever the generic implementation lives. } +pub(crate) mod sys; + pub(crate) use posix::*; // FIXME(pthread): eventually all platforms should use this module #[cfg(target_os = "linux")] diff --git a/src/new/glibc/signal.rs b/src/new/glibc/signal.rs index f91997f45acb..c05476eb4f72 100644 --- a/src/new/glibc/signal.rs +++ b/src/new/glibc/signal.rs @@ -1,8 +1,8 @@ //! Header: `signal/signal.h` -pub use super::bits::signum_generic::*; -pub use super::sysdeps::unix::linux::bits::sigaction::*; -pub use super::sysdeps::unix::linux::bits::types::siginfo_t::*; +pub use crate::new::glibc::bits::sigaction::*; +pub use crate::new::glibc::bits::signum_generic::*; +pub use crate::new::glibc::bits::types::siginfo_t::*; use crate::prelude::*; extern "C" { diff --git a/src/new/glibc/sys.rs b/src/new/glibc/sys.rs new file mode 100644 index 000000000000..ed3af7522977 --- /dev/null +++ b/src/new/glibc/sys.rs @@ -0,0 +1,8 @@ +//! Source directory: `sys/` +//! +//! + +#[cfg(target_os = "linux")] +pub(crate) mod statvfs { + pub use super::super::io::sys::statvfs::*; +} From 3552dd88bcc6a351d59790bfa26539a75e10bb6f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 21:20:36 -0400 Subject: [PATCH 07/45] renovate: Fix cron schedule Renovate didn't like scheduling for an exact minute, and instead requires a range. (backport ) (cherry picked from commit 819314b0c24c47234df8c209fdf58893570ce4cd) --- .github/renovate.json5 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index a5f1270a63f7..0f92d975a315 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -8,9 +8,10 @@ baseBranchPatterns: ["main", "libc-0.2"], lockFileMaintenance: { enabled: true, - // Biweekly at 12:00UTC on Monday - schedule: ["0 12 1-7,15-21 * 1"] - } + // Every other Monday. Renovate requires a range, hence `* *` rather + // than `0 0`. + schedule: ["* * 1-7,15-21 * 1"] + }, packageRules: [ { matchCategories: ["rust"], From fd0530389c1c943c045c4ac31d7f3e465befbae0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 5 Sep 2026 04:16:48 -0400 Subject: [PATCH 08/45] unix: Deprecate the POSIX-obsoleted `tmpnam`, `tempnam` `tmpnam` is TOCTOU-prone and not thread-safe if called with NULL, and has been marked obsolete by POSIX [1] and glibc [2]. `tempnam` is also TOCTOU-prone and marked obsolete by POSIX [3], and glib docs say "Never use this function". We don't have these on all platforms, but mark them deprecated where they still exist. Closes: https://github.com/rust-lang/libc/issues/5211 [1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/tmpnam.html [2]: https://man7.org/linux/man-pages/man3/tmpnam.3.html [3]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tempnam.html [4]: https://man7.org/linux/man-pages/man3/tempnam.3.html (backport ) (cherry picked from commit 0f65977d8c07d00541cc45a67b03df2bcf8ac2bc) --- src/fuchsia/mod.rs | 4 ++++ src/new/qurt/stdio.rs | 4 ++++ src/solid/mod.rs | 8 ++++++++ src/unix/mod.rs | 4 ++++ src/vxworks/mod.rs | 4 ++++ 5 files changed, 24 insertions(+) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 57ee24142aad..6fdaf83c9450 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3779,6 +3779,10 @@ extern "C" { pub fn mkstemp(template: *mut c_char) -> c_int; pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); diff --git a/src/new/qurt/stdio.rs b/src/new/qurt/stdio.rs index 7130717764e8..191bdda3fb4c 100644 --- a/src/new/qurt/stdio.rs +++ b/src/new/qurt/stdio.rs @@ -65,6 +65,10 @@ extern "C" { pub fn remove(filename: *const c_char) -> c_int; pub fn rename(old: *const c_char, new: *const c_char) -> c_int; pub fn tmpfile() -> *mut FILE; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(s: *mut c_char) -> *mut c_char; // Buffer control diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 7184ccf05719..2b096231d7ab 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -461,6 +461,10 @@ extern "C" { pub fn vprintf(arg1: *const c_char, arg2: __va_list) -> c_int; pub fn gets(arg1: *mut c_char) -> *mut c_char; pub fn sprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(arg1: *const c_char) -> *mut c_char; pub fn vsprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; pub fn rename(arg1: *const c_char, arg2: *const c_char) -> c_int; @@ -507,6 +511,10 @@ extern "C" { ) -> c_int; pub fn getw(arg1: *mut FILE) -> c_int; pub fn putw(arg1: c_int, arg2: *mut FILE) -> c_int; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tempnam(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; pub fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int) -> c_int; pub fn ftello(stream: *mut FILE) -> off_t; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index d0bf81b62467..d4823d76bc6a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -2131,6 +2131,10 @@ extern "C" { pub fn mkstemp(template: *mut c_char) -> c_int; pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 07bf8b49ec4d..83bfb0daaf52 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1780,6 +1780,10 @@ extern "C" { pub fn ftello(stream: *mut crate::FILE) -> off_t; pub fn mkstemp(template: *mut c_char) -> c_int; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); From 6b6047a2341c6f362e544c863bc6867e562be23a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 5 Sep 2026 04:59:49 -0400 Subject: [PATCH 09/45] macros: Support field attributes in `c_enum!` (backport ) (cherry picked from commit d25215c375dd1c897acbe92b1b9998e9f6fed9cf) --- src/macros.rs | 64 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index d10dbc4425e0..d13216940753 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -678,13 +678,19 @@ macro_rules! c_enum { ($( $(#[repr($repr:ty)])? $vis:vis enum $($ty_name:ident)? $(#$anon:ident)? { - $($field_vis:vis $variant:ident $(= $value:expr)?,)+ + $( + $(#[$meta:meta])* + $field_vis:vis $variant:ident $(= $value:expr)?, + )+ } )+) => { $(c_enum!(@single; $(#[repr($repr)])? $vis enum $($ty_name)? $(#$anon)? { - $($field_vis $variant $(= $value)?,)+ + $( + $(#[$meta])* + $field_vis $variant $(= $value)?, + )+ } );)+ }; @@ -693,7 +699,10 @@ macro_rules! c_enum { (@single; $(#[repr($repr:ty)])? $vis:vis enum $ty_name:ident { - $($field_vis:vis $variant:ident $(= $value:expr)?,)+ + $( + $(#[$meta:meta])* + $field_vis:vis $variant:ident $(= $value:expr)?, + )+ } ) => { $vis type $ty_name = c_enum!(@ty $($repr)?); @@ -701,7 +710,10 @@ macro_rules! c_enum { @variant; ty: $ty_name; default: 0; - variants: [$($field_vis $variant $(= $value)?,)+] + variants: [$( + $(#[$meta])* + $field_vis $variant $(= $value)?, + )+] } }; @@ -709,28 +721,41 @@ macro_rules! c_enum { (@single; $(#[repr($repr:ty)])? $vis:vis enum #anon { - $($field_vis:vis $variant:ident $(= $value:expr)?,)+ + $( + $(#[$meta:meta])* + $field_vis:vis $variant:ident $(= $value:expr)?, + )+ } ) => { c_enum! { @variant; ty: c_enum!(@ty $($repr)?); default: 0; - variants: [$($field_vis $variant $(= $value)?,)+] + variants: [$( + $(#[$meta])* + $field_vis $variant $(= $value)?, + )+] } }; // Matcher for variants: eats a single variant then recurses with the rest - (@variant; ty: $_ty_name:ty; default: $_idx:expr; variants: []) => { /* end of the chain */ }; + (@variant; + ty: $_ty_name:ty; + default: $_idx:expr; + variants: [] + ) => { /* end of the chain */ }; ( @variant; ty: $ty_name:ty; default: $default_val:expr; variants: [ + $(#[$meta:meta])* $field_vis:vis $variant:ident $(= $value:expr)?, $($tail:tt)* ] ) => { + $(#[$meta])* + #[allow(deprecated)] $field_vis const $variant: $ty_name = { #[allow(unused_variables)] let r = $default_val; @@ -1005,6 +1030,31 @@ mod tests { assert_eq!(PRIV_ON_1, 42u16); } + #[test] + fn c_enum_attrs() { + // Note this can't work with `#[cfg]` currently because our expansion uses `previous + 1` + c_enum! { + pub enum e { + VAR0, + WITH_CFG = if cfg!(target_arch = "x86_64") { 86 } else { 1234 }, + #[deprecated] + DEPRECATED, + NOT_DEPRECATED, + } + } + + if cfg!(target_arch = "x86_64") { + assert_eq!(WITH_CFG, 86); + } else { + assert_eq!(WITH_CFG, 1234); + } + + #[expect(deprecated)] + let _ = DEPRECATED; + #[deny(deprecated)] + let _ = NOT_DEPRECATED; + } + #[test] #[deny(unused_unsafe)] fn f_safety() { From fc123c0291a5ab87ec4b7bcbbf120876ac94cf0f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 23:39:21 -0400 Subject: [PATCH 10/45] glibc: Move more socket constants to `src/new` ctest must not support nonpublic constant types, during testing we get get: cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test/5b4faecd46dc6111/out/ctest_output.c:4929:8: error: unknown type name '__socket_type'; did you mean '__socklen_t'? cargo:warning= 4929 | static __socket_type ctest_const_SOCK_STREAM_val_static = SOCK_STREAM; cargo:warning= | ^~~~~~~~~~~~~ cargo:warning= | __socklen_t cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test/5b4faecd46dc6111/out/ctest_output.c:4931:14: error: unknown type name '__socket_type'; use 'enum' keyword to refer to the type cargo:warning= 4931 | CTEST_EXTERN __socket_type *ctest_const__SOCK_STREAM(void) { cargo:warning= | ^~~~~~~~~~~~~ cargo:warning= | enum cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test/5b4faecd46dc6111/out/ctest_output.c:4935:8: error: unknown type name '__socket_type'; did you mean '__socklen_t'? cargo:warning= 4935 | static __socket_type ctest_const_SOCK_DGRAM_val_static = SOCK_DGRAM; cargo:warning= | ^~~~~~~~~~~~~ cargo:warning= | __socklen_t cargo:warning=/checkout/target/x86_64-unknown-linux-gnu/debug/build/libc-test/5b4faecd46dc6111/out/ctest_output.c:4937:14: error: unknown type name '__socket_type'; use 'enum' keyword to refer to the type cargo:warning= 4937 | CTEST_EXTERN __socket_type *ctest_const__SOCK_DGRAM(void) { cargo:warning= | ^~~~~~~~~~~~~ cargo:warning= | enum Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/socket/sys/socket.h Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/sysdeps/unix/sysv/linux/bits/socket.h Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/sysdeps/unix/sysv/linux/bits/socket_type.h Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/sysdeps/unix/sysv/linux/mips/bits/socket_type.h Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/sysdeps/unix/sysv/linux/sparc/bits/socket_type.h (backport ) (cherry picked from commit 013606028ea2fb73e7b18bc01fb98435a4e7ff0b) --- src/new/glibc/mod.rs | 7 +++++++ src/new/glibc/socket/mod.rs | 6 ++++++ src/new/glibc/socket/sys/socket.rs | 3 +++ src/new/glibc/sys.rs | 5 +++++ src/new/glibc/sysdeps/unix/linux/bits/socket.rs | 3 +++ .../sysdeps/unix/linux/bits/socket_type.rs | 17 +++++++++++++++++ .../sysdeps/unix/linux/mips/bits/socket_type.rs | 17 +++++++++++++++++ src/new/glibc/sysdeps/unix/linux/mod.rs | 17 +++++++++++++++++ .../unix/linux/sparc/bits/socket_type.rs | 17 +++++++++++++++++ src/new/mod.rs | 1 + src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 3 --- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 3 --- src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 3 --- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 3 --- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 3 --- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 2 -- src/unix/linux_like/linux/gnu/b32/sparc/mod.rs | 3 --- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 3 --- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 3 --- .../linux_like/linux/gnu/b64/loongarch64/mod.rs | 3 --- src/unix/linux_like/linux/gnu/b64/mips64/mod.rs | 3 --- .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 3 --- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 2 -- src/unix/linux_like/linux/gnu/b64/s390x.rs | 3 --- .../linux_like/linux/gnu/b64/sparc64/mod.rs | 3 --- src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 3 --- src/unix/linux_like/linux/gnu/mod.rs | 7 ------- 27 files changed, 93 insertions(+), 53 deletions(-) create mode 100644 src/new/glibc/socket/mod.rs create mode 100644 src/new/glibc/socket/sys/socket.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/bits/socket.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 990ef22be511..9fd92101ef15 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -18,6 +18,7 @@ mod bits { pub(crate) use super::sysdeps::unix::linux::bits::{ sigaction, signum_arch, + socket, statvfs, types, }; @@ -37,6 +38,12 @@ mod posix { #[cfg(target_os = "linux")] pub(crate) mod signal; +/// Source directory: `socket/` +/// +/// +#[cfg(target_os = "linux")] +mod socket; + /// Source directory: `sysdeps/` /// /// diff --git a/src/new/glibc/socket/mod.rs b/src/new/glibc/socket/mod.rs new file mode 100644 index 000000000000..d34e5d58428f --- /dev/null +++ b/src/new/glibc/socket/mod.rs @@ -0,0 +1,6 @@ +//! Directory: `socket` + +/// Directory: `socket/sys` +pub(crate) mod sys { + pub(crate) mod socket; +} diff --git a/src/new/glibc/socket/sys/socket.rs b/src/new/glibc/socket/sys/socket.rs new file mode 100644 index 000000000000..d0c26b0f5703 --- /dev/null +++ b/src/new/glibc/socket/sys/socket.rs @@ -0,0 +1,3 @@ +//! Header: `socket/sys/socket.h` + +pub use crate::new::glibc::bits::socket::*; diff --git a/src/new/glibc/sys.rs b/src/new/glibc/sys.rs index ed3af7522977..c575be6fd322 100644 --- a/src/new/glibc/sys.rs +++ b/src/new/glibc/sys.rs @@ -6,3 +6,8 @@ pub(crate) mod statvfs { pub use super::super::io::sys::statvfs::*; } + +#[cfg(target_os = "linux")] +pub(crate) mod socket { + pub use super::super::socket::sys::socket::*; +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/socket.rs b/src/new/glibc/sysdeps/unix/linux/bits/socket.rs new file mode 100644 index 000000000000..da2fac5a21e4 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/socket.rs @@ -0,0 +1,3 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/socket.h` + +pub use super::socket_type::*; diff --git a/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs new file mode 100644 index 000000000000..816589112120 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs @@ -0,0 +1,17 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/socket_type.h` + +use crate::prelude::*; + +c_enum! { + // Actually called __socket_type but that causes test issues + #[repr(c_int)] + enum #anon { + pub SOCK_STREAM = 1, + pub SOCK_DGRAM = 2, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_NONBLOCK = 0o0004000, + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs new file mode 100644 index 000000000000..385704a495b0 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs @@ -0,0 +1,17 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/socket_type.h` + +use crate::prelude::*; + +c_enum! { + // Actually called __socket_type but that causes test issues + #[repr(c_int)] + enum #anon { + pub SOCK_DGRAM = 1, + pub SOCK_STREAM = 2, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_NONBLOCK = 0o0000200, + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs index f3d704d63e55..08304add3d71 100644 --- a/src/new/glibc/sysdeps/unix/linux/mod.rs +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -35,6 +35,23 @@ pub(crate) mod bits { )] pub(crate) mod signum_arch; + #[cfg_attr( + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips", + target_arch = "mips32r6", + ), + path = "../mips/bits/socket_type.rs" + )] + #[cfg_attr( + any(target_arch = "sparc", target_arch = "sparc64"), + path = "../sparc/bits/socket_type.rs" + )] + pub(crate) mod socket_type; + + pub(crate) mod socket; + pub(crate) mod statvfs; pub(crate) mod types; diff --git a/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs new file mode 100644 index 000000000000..8dbd97122e09 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs @@ -0,0 +1,17 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/socket_type.h` + +use crate::prelude::*; + +c_enum! { + // Actually called __socket_type but that causes test issues + #[repr(c_int)] + enum #anon { + pub SOCK_STREAM = 1, + pub SOCK_DGRAM = 2, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_NONBLOCK = 0x004000, + } +} diff --git a/src/new/mod.rs b/src/new/mod.rs index 8f12b20afa99..ab26bff6e621 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -204,6 +204,7 @@ cfg_if! { pub use self::{ net::route::*, signal::*, + sys::socket::*, sys::statvfs::*, }; } else if #[cfg(target_vendor = "apple")] { diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index bec3d1083093..5dd589c271c9 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -330,9 +330,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index c754ec000ea4..492736e5e394 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -256,9 +256,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index ec5a057cddf5..718a1c142c75 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -256,9 +256,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const F_GETLK: c_int = 5; pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index a4cc330710db..cf86cd474d97 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -729,9 +729,6 @@ pub const MAP_POPULATE: c_int = 0x10000; pub const MAP_NONBLOCK: c_int = 0x20000; pub const MAP_STACK: c_int = 0x40000; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 30f85c9fb688..d2c3e0581c1d 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -305,9 +305,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MCL_CURRENT: c_int = 0x2000; pub const MCL_FUTURE: c_int = 0x4000; pub const MCL_ONFAULT: c_int = 0x8000; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 610fa4065ba6..1846a32a51cf 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -294,8 +294,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 95ad74af2e4c..eb0f38796c60 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -280,9 +280,6 @@ pub const ENOTRECOVERABLE: c_int = 133; pub const EHWPOISON: c_int = 135; pub const ERFKILL: c_int = 134; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index cbfae20a68a9..741a874b2350 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -376,9 +376,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - cfg_if! { if #[cfg(gnu_file_offset_bits64)] { pub const F_GETLK: c_int = 12; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 714e609b88b6..26ea52c427dd 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -302,9 +302,6 @@ pub const ERFKILL: c_int = 132; pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index 7cea157c63d1..484c67bfdb20 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -665,9 +665,6 @@ pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const SFD_NONBLOCK: c_int = 0x800; pub const SFD_CLOEXEC: c_int = 0x080000; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 07fe19471b76..668cad4fb1cd 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -653,9 +653,6 @@ pub const MAP_NONBLOCK: c_int = 0x20000; pub const MAP_STACK: c_int = 0x40000; pub const MAP_HUGETLB: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index ecccfdb48cd4..5b063fe5de46 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -337,9 +337,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index d58948c951df..5c552ff2d6f8 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -336,8 +336,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 1dcc87aa8d0a..edd6e12d24cc 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -262,9 +262,6 @@ pub const O_NONBLOCK: c_int = 2048; pub const SIGSTKSZ: size_t = 0x2000; pub const MINSIGSTKSZ: size_t = 2048; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const O_NOCTTY: c_int = 256; pub const O_SYNC: c_int = 1052672; pub const O_RSYNC: c_int = 1052672; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 80c5528892b3..59dbfab935c7 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -262,9 +262,6 @@ pub const ENOTRECOVERABLE: c_int = 133; pub const EHWPOISON: c_int = 135; pub const ERFKILL: c_int = 134; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 1f3209f529f5..89f84f39590a 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -382,9 +382,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 27b967248ab5..f46adbbcaaa0 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -549,8 +549,6 @@ pub const RTLD_DI_PROFILEOUT: c_int = 8; pub const RTLD_DI_TLS_MODID: c_int = 9; pub const RTLD_DI_TLS_DATA: c_int = 10; -pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; - pub const SOL_RXRPC: c_int = 272; pub const SOL_PPPOL2TP: c_int = 273; pub const SOL_PNPIPE: c_int = 275; @@ -588,11 +586,6 @@ pub const LC_ALL_MASK: c_int = crate::LC_CTYPE_MASK pub const ENOTSUP: c_int = EOPNOTSUPP; -pub const SOCK_SEQPACKET: c_int = 5; -pub const SOCK_DCCP: c_int = 6; -#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] -pub const SOCK_PACKET: c_int = 10; - pub const AF_IB: c_int = 27; pub const AF_MPLS: c_int = 28; pub const AF_NFC: c_int = 39; From 6ddcfadeebd9547cc0fa601b1b2ccacba77b82fd Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 5 Sep 2026 18:16:42 -0400 Subject: [PATCH 11/45] docs: Link to online manpages in crate documentation (backport ) (cherry picked from commit 50af125582a6a1c11de9d5742480f74478a5c09f) --- CONTRIBUTING.md | 14 +------------- src/lib.rs | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4f3b18e729f..aa8f455db954 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,19 +171,7 @@ are preferred because they become part of history.) Including links to manpages is not required but can also be very helpful to include. Some platforms also publish manpages but not sources. -Common web manuals: - -* AIX: -* Apple: - is the only known official site but it is severly outdated. - or are better options. -* DragonFlyBSD: -* FreeBSD: -* Illumos: -* NetBSD: -* OpenBSD: -* Solaris: -* Windows MSVC: +See documentation in `src/lib.rs` for links to online manuals. ## Breaking change policy diff --git a/src/lib.rs b/src/lib.rs index 671e2c7dc81b..7ae80264bb99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,44 @@ //! Raw FFI bindings to platform system libraries. //! +//! # Documentation +//! +//! `libc` only provides the bindings, not instructions on how to use them. For this, please refer +//! to the relevant C documentation. +//! +//! POSIX provides OS-agnostic API definitions, which most platforms aim to comply with. Its +//! specifications are often the best place to look: +//! +//! * POSIX Base Definitions: . +//! Types and structures are defined within the _Headers_ section. +//! * POSIX System Interfaces: . +//! Functions are defined under the _System Interfaces_ section. +//! +//! For platform-specific API and caveats to the standard API, platform-specific manual pages are +//! usually the place to look. Locally you can run commands like `man 2 stat` or `man 3 printf` +//! (2 for kernel interfaces, 3 for standard library) to get documentation, but there are also +//! a number of platforms with manual pages available online: +//! +//! * Apple: Official manpages exist at +//! but are severly outdated. exists but +//! only provides API signatures without documenttion. or +//! are better options. +//! * DragonFlyBSD: +//! * FreeBSD: +//! * IBM AIX: +//! * Illumos: +//! * Linux: +//! * or provide +//! documentation of Linux API as well as the C library, with a focus on glibc. +//! * Glibc-specific documentation is available at +//! . +//! * Musl documentation states to refer to POSIX, linked above, and the C standard, available at +//! (published versions must be +//! purchased but the drafts are free). +//! * NetBSD: +//! * OpenBSD: +//! * Solaris: +//! * Windows MSVC: +//! //! # Usage Guidelines //! //! `libc` exposes non-Rust interfaces in Rust, which makes for some caveats to its use that are From 857e697bcac27f4e8a296a4c865ecc67a157f870 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 5 Sep 2026 20:05:20 -0400 Subject: [PATCH 12/45] cleanup: Replace `crate::c_*` with `c_` for types in the prelude (backport ) (cherry picked from commit 4e4a96a0d461420a6d61e430dbd5a810d1645c0b) --- src/new/helenos/bits.rs | 6 ++++-- src/unix/bsd/netbsdlike/openbsd/mod.rs | 2 +- src/unix/linux_like/linux/mod.rs | 9 ++++----- src/unix/nto/mod.rs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/new/helenos/bits.rs b/src/new/helenos/bits.rs index bcb704d8cb03..8396c579d047 100644 --- a/src/new/helenos/bits.rs +++ b/src/new/helenos/bits.rs @@ -2,8 +2,10 @@ //! //! * Headers: +use crate::prelude::*; + // `errno.h` -pub type errno_t = crate::c_int; +pub type errno_t = c_int; // `native.h` -pub type sysarg_t = crate::uintptr_t; +pub type sysarg_t = uintptr_t; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index c4c29ecc50e7..7245c28bc483 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -863,7 +863,7 @@ impl siginfo_t { _uid: crate::uid_t, _utime: crate::clock_t, _stime: crate::clock_t, - _status: crate::c_int, + _status: c_int, } (*(self as *const siginfo_t).cast::())._status } diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7ed918f41eff..2c9314778d3c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3312,12 +3312,11 @@ pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0; pub const XDP_PGOFF_RX_RING: crate::off_t = 0; pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000u32 as crate::off_t; -pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000; -pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000; +pub const XDP_UMEM_PGOFF_FILL_RING: c_ulonglong = 0x100000000; +pub const XDP_UMEM_PGOFF_COMPLETION_RING: c_ulonglong = 0x180000000; -pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48; -pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = - (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; +pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48; +pub const XSK_UNALIGNED_BUF_ADDR_MASK: c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index faec373cbec9..7276aaca09b0 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -771,7 +771,7 @@ s_no_extra_traits! { // form would be bogus and it would potentially change the size of the data type. On QNX SDP 8, this // got fixed and both C and C++ are using the same definition. pub struct max_align_t { - _ll: crate::c_longlong, + _ll: c_longlong, _ld: i128, } } From a179d627d7fb177af3b7512d42b7deaf2ef9816a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 23:39:21 -0400 Subject: [PATCH 13/45] linux: Move more `socket.h` definitions to `src/new` Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/socket/sys/socket.h Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/sysdeps/unix/sysv/linux/bits/socket.h Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/sysdeps/unix/sysv/linux/mips/bits/socket_type.h Link: https://github.com/sailfishos-mirror/glibc/blob/fe03757f67e25bc8fea1473572beb30a05508d08/sysdeps/unix/sysv/linux/sparc/bits/socket_type.h Link: https://github.com/kraj/musl/blob/cec26f5164f0deede51ed36591f58fca19c10795/include/sys/socket.h Link: https://github.com/kraj/musl/blob/cec26f5164f0deede51ed36591f58fca19c10795/arch/mips/bits/socket.h Link: https://github.com/kraj/musl/blob/cec26f5164f0deede51ed36591f58fca19c10795/arch/mips64/bits/socket.h Link: https://github.com/wbx-github/uclibc-ng/blob/e73186b69999c043b075348b5fcabc586cf76a83/include/sys/socket.h Link: https://github.com/wbx-github/uclibc-ng/blob/e73186b69999c043b075348b5fcabc586cf76a83/libc/sysdeps/linux/common/bits/socket_type.h Link: https://github.com/wbx-github/uclibc-ng/blob/e73186b69999c043b075348b5fcabc586cf76a83/libc/sysdeps/linux/mips/bits/socket_type.h (backport ) (cherry picked from commit d5c45a8c112ab6c4e634a970381e1bc4920fd38c) --- CONTRIBUTING.md | 3 + src/new/glibc/io.rs | 9 +++ src/new/glibc/socket/sys/socket.rs | 17 +++++ .../sysdeps/unix/linux/bits/socket_type.rs | 3 + .../unix/linux/mips/bits/socket_type.rs | 3 + .../unix/linux/sparc/bits/socket_type.rs | 3 + src/new/mod.rs | 7 ++- src/new/musl/arch/mips/bits/socket.rs | 3 + src/new/musl/arch/mips64/bits/socket.rs | 3 + src/new/musl/sys/socket.rs | 23 ++++++- src/new/uclibc/mod.rs | 3 + src/new/uclibc/socket.rs | 63 +++++++++++++++++++ src/unix/linux_like/android/mod.rs | 15 +++++ src/unix/linux_like/emscripten/mod.rs | 15 +++++ src/unix/linux_like/l4re/mod.rs | 15 +++++ src/unix/linux_like/linux/uclibc/arm/mod.rs | 4 -- src/unix/linux_like/linux/uclibc/mips/mod.rs | 6 -- src/unix/linux_like/linux/uclibc/mod.rs | 3 - .../linux_like/linux/uclibc/x86_64/mod.rs | 2 - src/unix/linux_like/mod.rs | 13 ---- 20 files changed, 182 insertions(+), 31 deletions(-) create mode 100644 src/new/glibc/io.rs create mode 100644 src/new/uclibc/socket.rs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa8f455db954..1425c1e5f7f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,6 +132,7 @@ Common sources include: (original) * Illumos: (official mirror), (original) +* L4RE: (original) * Linux uapi: (official mirror), (original) * Musl: (unofficial mirror), @@ -141,6 +142,8 @@ Common sources include: * OpenBSD: (official mirror), (original) * RedoxOS: +* Uclibc: (mirror), + (original) * Windows GNU: (unofficial mirror), (original) * Windows MSVC: diff --git a/src/new/glibc/io.rs b/src/new/glibc/io.rs new file mode 100644 index 000000000000..b2b7afd518bd --- /dev/null +++ b/src/new/glibc/io.rs @@ -0,0 +1,9 @@ +/// Source directory: `io/sys/` +/// +/// +pub(crate) mod sys { + #[cfg(target_os = "linux")] + pub(crate) mod statvfs; + + pub use super::socket::sys::*; +} diff --git a/src/new/glibc/socket/sys/socket.rs b/src/new/glibc/socket/sys/socket.rs index d0c26b0f5703..e0a24e548a9a 100644 --- a/src/new/glibc/socket/sys/socket.rs +++ b/src/new/glibc/socket/sys/socket.rs @@ -1,3 +1,20 @@ //! Header: `socket/sys/socket.h` pub use crate::new::glibc::bits::socket::*; +use crate::prelude::*; + +c_enum! { + #[repr(c_int)] + enum #anon { + pub SHUT_RD = 0, + pub SHUT_WR, + pub SHUT_RDWR, + } +} + +s! { + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs index 816589112120..e0db7f38d963 100644 --- a/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs +++ b/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs @@ -8,10 +8,13 @@ c_enum! { enum #anon { pub SOCK_STREAM = 1, pub SOCK_DGRAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, pub SOCK_SEQPACKET = 5, pub SOCK_DCCP = 6, #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, pub SOCK_NONBLOCK = 0o0004000, } } diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs index 385704a495b0..8fb20087da65 100644 --- a/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs @@ -8,10 +8,13 @@ c_enum! { enum #anon { pub SOCK_DGRAM = 1, pub SOCK_STREAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, pub SOCK_SEQPACKET = 5, pub SOCK_DCCP = 6, #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, pub SOCK_NONBLOCK = 0o0000200, } } diff --git a/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs index 8dbd97122e09..7a5821a1a6f3 100644 --- a/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs +++ b/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs @@ -8,10 +8,13 @@ c_enum! { enum #anon { pub SOCK_STREAM = 1, pub SOCK_DGRAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, pub SOCK_SEQPACKET = 5, pub SOCK_DCCP = 6, #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0x400000, pub SOCK_NONBLOCK = 0x004000, } } diff --git a/src/new/mod.rs b/src/new/mod.rs index ab26bff6e621..841f836f0103 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -197,8 +197,6 @@ cfg_if! { pub use linux::sctp::*; pub use linux::tls::*; pub use linux::types::*; - #[cfg(target_env = "uclibc")] - pub use sysdeps::linux::common::bits::siginfo::*; #[cfg(target_env = "gnu")] pub use self::{ @@ -207,6 +205,11 @@ cfg_if! { sys::socket::*, sys::statvfs::*, }; + #[cfg(target_env = "uclibc")] + pub use self::{ + socket::*, + sysdeps::linux::common::bits::siginfo::*, + }; } else if #[cfg(target_vendor = "apple")] { #[cfg(target_os = "macos")] pub use net::bpf::*; diff --git a/src/new/musl/arch/mips/bits/socket.rs b/src/new/musl/arch/mips/bits/socket.rs index 77b53e489c3d..8d4845fea79c 100644 --- a/src/new/musl/arch/mips/bits/socket.rs +++ b/src/new/musl/arch/mips/bits/socket.rs @@ -2,3 +2,6 @@ use crate::prelude::*; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; + +pub const SOCK_NONBLOCK: c_int = 0o200; +pub const SOCK_CLOEXEC: c_int = 0o2000000; diff --git a/src/new/musl/arch/mips64/bits/socket.rs b/src/new/musl/arch/mips64/bits/socket.rs index 77b53e489c3d..8d4845fea79c 100644 --- a/src/new/musl/arch/mips64/bits/socket.rs +++ b/src/new/musl/arch/mips64/bits/socket.rs @@ -2,3 +2,6 @@ use crate::prelude::*; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; + +pub const SOCK_NONBLOCK: c_int = 0o200; +pub const SOCK_CLOEXEC: c_int = 0o2000000; diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs index 4b53d2c0faf3..1b54c7bfdfa6 100644 --- a/src/new/musl/sys/socket.rs +++ b/src/new/musl/sys/socket.rs @@ -33,6 +33,11 @@ s! { pub cmsg_level: c_int, pub cmsg_type: c_int, } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } extern "C" { @@ -52,6 +57,10 @@ extern "C" { ) -> c_int; } +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + cfg_if! { if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { pub use crate::bits::socket::{ @@ -64,12 +73,24 @@ cfg_if! { } } +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; pub const SOCK_SEQPACKET: c_int = 5; pub const SOCK_DCCP: c_int = 6; #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] pub const SOCK_PACKET: c_int = 10; -pub const SOCK_NONBLOCK: c_int = crate::O_NONBLOCK; +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { + pub use crate::bits::socket::{ + SOCK_CLOEXEC, + SOCK_NONBLOCK, + }; + } else { + pub const SOCK_CLOEXEC: c_int = 0o2000000; + pub const SOCK_NONBLOCK: c_int = 0o4000; + } +} pub const PF_IB: c_int = 27; pub const PF_MPLS: c_int = 28; diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs index 6f99b4e95c0c..81615dc1941d 100644 --- a/src/new/uclibc/mod.rs +++ b/src/new/uclibc/mod.rs @@ -5,6 +5,9 @@ pub(crate) mod pthread; +#[cfg(target_os = "linux")] +pub(crate) mod socket; + /// Directory source: `libc/sysdeps` /// /// * Headers: (official) diff --git a/src/new/uclibc/socket.rs b/src/new/uclibc/socket.rs new file mode 100644 index 000000000000..3001cd7c408c --- /dev/null +++ b/src/new/uclibc/socket.rs @@ -0,0 +1,63 @@ +//! Header: `include/sys/socket.h` + +use crate::prelude::*; + +cfg_if! { + if #[cfg(target_arch = "mips")] { + // Header: `libc/sysdeps/linux/mips/bits/socket_type.h` + // + // Inlined for simplicity. + // Actually called __socket_type but that causes test issues + c_enum! { + #[repr(c_int)] + enum #anon { + pub SOCK_DGRAM = 1, + pub SOCK_STREAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, + pub SOCK_NONBLOCK = 0o0000200, + } + } + } else { + // Header: `libc/sysdeps/linux/common/bits/socket_type.h` + // + // Inlined for simplicity. + // Actually called __socket_type but that causes test issues + c_enum! { + #[repr(c_int)] + enum #anon { + pub SOCK_STREAM = 1, + pub SOCK_DGRAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, + pub SOCK_NONBLOCK = 0o0004000, + } + } + } +} + +c_enum! { + #[repr(c_int)] + enum #anon { + pub SHUT_RD = 0, + pub SHUT_WR, + pub SHUT_RDWR, + } +} + +s! { + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } +} diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 9687ec0ec5be..fb63c640bf54 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -610,6 +610,11 @@ s! { pub flags: crate::__u32, __reserved: Padding, } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } s_no_extra_traits! { @@ -686,6 +691,16 @@ s_no_extra_traits! { } } +// socket.h + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + pub const MADV_SOFT_OFFLINE: c_int = 101; #[allow(overflowing_literals)] // fixed in a future kernel version pub const MS_NOUSER: c_ulong = 0xffffffff80000000; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index a19821ae51e4..c4c73bfe2202 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -392,6 +392,11 @@ s! { pub struct pthread_cond_t { size: [u8; crate::__SIZEOF_PTHREAD_COND_T], } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } s_no_extra_traits! { @@ -401,6 +406,16 @@ s_no_extra_traits! { } } +// socket.h + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MS_NOUSER: c_ulong = 0x80000000; pub const MS_RMT_MASK: c_ulong = 0x02800051; diff --git a/src/unix/linux_like/l4re/mod.rs b/src/unix/linux_like/l4re/mod.rs index b3c768623f7f..e9bd6104c2d6 100644 --- a/src/unix/linux_like/l4re/mod.rs +++ b/src/unix/linux_like/l4re/mod.rs @@ -85,8 +85,23 @@ s! { pub affinity: l4_sched_cpu_set_t, pub create_flags: c_uint, } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } +// socket.h + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but // somewhere in the core libraries. uClibc wants 16k, but that's not enough. pub const PTHREAD_STACK_MIN: usize = 65536; diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 493acf40da09..948f9aeda133 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -504,10 +504,6 @@ pub const SIGXFSZ: c_int = 0x19; pub const SIG_BLOCK: c_int = 0; pub const SIG_SETMASK: c_int = 0x2; pub const SIG_UNBLOCK: c_int = 0x1; -pub const SOCK_DGRAM: c_int = 0x2; -pub const SOCK_NONBLOCK: c_int = 0o0004000; -pub const SOCK_SEQPACKET: c_int = 0x5; -pub const SOCK_STREAM: c_int = 0x1; pub const TAB1: c_int = 0x800; pub const TAB2: c_int = 0x1000; diff --git a/src/unix/linux_like/linux/uclibc/mips/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mod.rs index 8d17aa8e98e9..772a6f3326c0 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -56,8 +56,6 @@ pub const O_ASYNC: c_int = 0x1000; pub const O_LARGEFILE: c_int = 0x2000; pub const O_NDELAY: c_int = 0x80; -pub const SOCK_NONBLOCK: c_int = 128; - pub const EDEADLK: c_int = 45; pub const ENAMETOOLONG: c_int = 78; pub const ENOLCK: c_int = 46; @@ -155,10 +153,6 @@ pub const MAP_STACK: c_int = 0x40000; pub const NLDLY: crate::tcflag_t = 0o0000400; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; -pub const SOCK_SEQPACKET: c_int = 5; - pub const SA_ONSTACK: c_uint = 0x08000000; pub const SA_SIGINFO: c_uint = 0x00000008; pub const SA_NOCLDWAIT: c_int = 0x00010000; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 63b39133f9c5..39964530e2f0 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -256,9 +256,6 @@ pub const RTLD_NOLOAD: c_int = 0x00004; pub const RUSAGE_THREAD: c_int = 1; pub const SHM_EXEC: c_int = 0o100000; pub const SIGPOLL: c_int = SIGIO; -pub const SOCK_DCCP: c_int = 6; -#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] -pub const SOCK_PACKET: c_int = 10; pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; pub const UDP_GRO: c_int = 104; pub const UDP_SEGMENT: c_int = 103; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 60e5cfe72500..093ae1d3d379 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -300,8 +300,6 @@ pub const NCCS: usize = 32; pub const SIG_SETMASK: c_int = 2; // Set the set of blocked signals pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -pub const SOCK_DGRAM: c_int = 2; // connectionless, unreliable datagrams -pub const SOCK_STREAM: c_int = 1; // …/common/bits/socket_type.h pub const __SIZEOF_PTHREAD_COND_T: usize = 48; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 64fea11708e7..357a6e2f9546 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -206,11 +206,6 @@ s! { pub ar_op: u16, } - pub struct mmsghdr { - pub msg_hdr: crate::msghdr, - pub msg_len: c_uint, - } - pub struct sockaddr_un { pub sun_family: sa_family_t, pub sun_path: [c_char; 108], @@ -453,8 +448,6 @@ pub const O_RDONLY: c_int = 0; pub const O_WRONLY: c_int = 1; pub const O_RDWR: c_int = 2; -pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; - pub const S_IFIFO: mode_t = 0o1_0000; pub const S_IFCHR: mode_t = 0o2_0000; pub const S_IFBLK: mode_t = 0o6_0000; @@ -771,8 +764,6 @@ pub const MSG_CMSG_CLOEXEC: c_int = 0x40000000; pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; -pub const SOCK_RAW: c_int = 3; -pub const SOCK_RDM: c_int = 4; pub const IP_TOS: c_int = 1; pub const IP_TTL: c_int = 2; pub const IP_HDRINCL: c_int = 3; @@ -1024,10 +1015,6 @@ cfg_if! { pub const SO_DEBUG: c_int = 1; -pub const SHUT_RD: c_int = 0; -pub const SHUT_WR: c_int = 1; -pub const SHUT_RDWR: c_int = 2; - pub const LOCK_SH: c_int = 1; pub const LOCK_EX: c_int = 2; pub const LOCK_NB: c_int = 4; From 418ee2932ef11d5b7223df1d3caa8273d16ed809 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 22:46:29 -0400 Subject: [PATCH 14/45] build: Switch to an enum for config Make things a bit more type safe and prepare for better checks. (backport ) (cherry picked from commit 1f24be269266b2b35d4fd38feee8c3ea01c65278) --- build.rs | 179 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 122 insertions(+), 57 deletions(-) diff --git a/build.rs b/build.rs index 28467e7da033..419654def3bb 100644 --- a/build.rs +++ b/build.rs @@ -10,38 +10,98 @@ use std::{ str, }; -// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we -// need to know all the possible cfgs that this script will set. If you need to set another cfg -// make sure to add it to this list as well. -const ALLOWED_CFGS: &[&str] = &[ - "emscripten_old_stat_abi", - // Should be enabled by users if esp-idf (>=6.0) is build with picolibc instead of newlib. - "espidf_picolibc", - "espidf_time32", - "freebsd10", - "freebsd11", - "freebsd12", - "freebsd13", - "freebsd14", - "freebsd15", - // Corresponds to `_FILE_OFFSET_BITS=64` in glibc - "gnu_file_offset_bits64", - // Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with - // GNU to expose a 64-bit `time_t`. - "gnu_time_bits64", - "libc_deny_warnings", - "libc_elfv2", - // Corresponds to `__USE_TIME_BITS64` in UAPI - "linux_time_bits64", - "musl_v1_2", - // musl v1.2.0+ && 32-bit: time_t is i64, struct layouts change - "musl32_time64", - // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 - "musl_redir_time64", - "vxworks_lt_25_09", - "libc_pauthtest", +/// All possible cfgs that may be set. Used for check-cfg as well as self checks. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +enum Cfg { + LibcDenyWarnings, + /// MSRV-friendly version of `target_abi = "elfv2"`. + LibcElfv2, + /// MSRV-friendly version of `target_abi = "pauthtest"`. + LibcPauthtest, + + EmscriptenOldStatAbi, + + /// Should be enabled by users if esp-idf (>=6.0) is build with picolibc instead of newlib. Not + /// set by `libc` itself. + EspidfPicolibc, + /// Not set by `libc` itself. + EspidfTime32, + + Freebsd10, + Freebsd11, + Freebsd12, + Freebsd13, + Freebsd14, + Freebsd15, + + VxworksLt25_09, + + /// Corresponds to `__USE_TIME_BITS64` in UAPI + LinuxTimeBits64, + /// Corresponds to `_FILE_OFFSET_BITS=64` in glibc + GnuFileOffsetBits64, + /// Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with + /// GNU to expose a 64-bit `time_t`. + GnuTimeBits64, + /// Musl 1.2+. Implies `target_env = "musl"` + MuslV1_2, + /// musl v1.2.0+ && 32-bit: time_t is i64, struct layouts change. Implies `musl_v1_2` and + /// 32-bit arch. + Musl32Time64, + /// Corresponds to `_REDIR_TIME64` in musl, i.e. 32-bit platforms that existed prior to the + /// transition to 64-bit `time_t` and thus need `__*_time64` redirects. Implies `musl_v1_2` + /// and 32-bit arch. + MuslRedirTime64, +} + +const ALLOWED_CFGS: &[Cfg] = &[ + Cfg::LibcDenyWarnings, + Cfg::EmscriptenOldStatAbi, + Cfg::EspidfPicolibc, + Cfg::EspidfTime32, + Cfg::Freebsd10, + Cfg::Freebsd11, + Cfg::Freebsd12, + Cfg::Freebsd13, + Cfg::Freebsd14, + Cfg::Freebsd15, + Cfg::LibcElfv2, + Cfg::VxworksLt25_09, + Cfg::LibcPauthtest, + Cfg::GnuFileOffsetBits64, + Cfg::GnuTimeBits64, + Cfg::LinuxTimeBits64, + Cfg::MuslV1_2, + Cfg::Musl32Time64, + Cfg::MuslRedirTime64, ]; +impl Cfg { + fn name(self) -> &'static str { + match self { + Cfg::LibcDenyWarnings => "libc_deny_warnings", + Cfg::EmscriptenOldStatAbi => "emscripten_old_stat_abi", + Cfg::EspidfPicolibc => "espidf_picolibc", + Cfg::EspidfTime32 => "espidf_time32", + Cfg::Freebsd10 => "freebsd10", + Cfg::Freebsd11 => "freebsd11", + Cfg::Freebsd12 => "freebsd12", + Cfg::Freebsd13 => "freebsd13", + Cfg::Freebsd14 => "freebsd14", + Cfg::Freebsd15 => "freebsd15", + Cfg::LibcElfv2 => "libc_elfv2", + Cfg::VxworksLt25_09 => "vxworks_lt_25_09", + Cfg::LibcPauthtest => "libc_pauthtest", + Cfg::GnuFileOffsetBits64 => "gnu_file_offset_bits64", + Cfg::GnuTimeBits64 => "gnu_time_bits64", + Cfg::LinuxTimeBits64 => "linux_time_bits64", + Cfg::MuslV1_2 => "musl_v1_2", + Cfg::Musl32Time64 => "musl32_time64", + Cfg::MuslRedirTime64 => "musl_redir_time64", + } + } +} + // Extra values to allow for check-cfg. const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ( @@ -86,6 +146,8 @@ fn main() { VERBOSE_BUILD.store(true, Relaxed); } + let mut cfgs = Vec::new(); + let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); let libc_ci = env_flag("LIBC_CI"); let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); @@ -98,10 +160,10 @@ fn main() { // of translating its values. `target_abi` cannot be used directly in cfg // expressions on the current MSRV. if target_abi == "elfv2" { - set_cfg("libc_elfv2"); + cfgs.push(Cfg::LibcElfv2); } if target_abi == "pauthtest" { - set_cfg("libc_pauthtest"); + cfgs.push(Cfg::LibcPauthtest); } // FIXME: this can be removed in 1-2 releases @@ -131,22 +193,22 @@ fn main() { match which_freebsd { x if x < 10 => panic!("FreeBSD older than 10 is not supported"), - 10 => set_cfg("freebsd10"), - 11 => set_cfg("freebsd11"), - 12 => set_cfg("freebsd12"), - 13 => set_cfg("freebsd13"), - 14 => set_cfg("freebsd14"), - _ => set_cfg("freebsd15"), + 10 => cfgs.push(Cfg::Freebsd10), + 11 => cfgs.push(Cfg::Freebsd11), + 12 => cfgs.push(Cfg::Freebsd12), + 13 => cfgs.push(Cfg::Freebsd13), + 14 => cfgs.push(Cfg::Freebsd14), + _ => cfgs.push(Cfg::Freebsd15), } match emcc_version_code() { - Some(v) if (v < 30142) => set_cfg("emscripten_old_stat_abi"), + Some(v) if (v < 30142) => cfgs.push(Cfg::EmscriptenOldStatAbi), // Non-Emscripten or version >= 3.1.42. _ => (), } match vxworks_version_code() { - Some(v) if (v < (25, 9)) => set_cfg("vxworks_lt_25_09"), + Some(v) if (v < (25, 9)) => cfgs.push(Cfg::VxworksLt25_09), // VxWorks version >= 25.09 _ => (), } @@ -180,19 +242,19 @@ fn main() { } if musl && musl_v1_2 { - set_cfg("musl_v1_2"); + cfgs.push(Cfg::MuslV1_2); if target_ptr_width == "32" { - set_cfg("musl32_time64"); - set_cfg("linux_time_bits64"); + cfgs.push(Cfg::Musl32Time64); + cfgs.push(Cfg::LinuxTimeBits64); } if MUSL_REDIR_TIME64_ARCHES.contains(&target_arch.as_str()) { - set_cfg("musl_redir_time64"); + cfgs.push(Cfg::MuslRedirTime64); } } let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); if target_env == "uclibc" && uclibc_use_time64 { - set_cfg("linux_time_bits64"); + cfgs.push(Cfg::LinuxTimeBits64); } if target_env == "gnu" @@ -232,28 +294,35 @@ fn main() { }; if timebits == "64" { - set_cfg("linux_time_bits64"); - set_cfg("gnu_file_offset_bits64"); - set_cfg("gnu_time_bits64"); + cfgs.push(Cfg::LinuxTimeBits64); + cfgs.push(Cfg::GnuFileOffsetBits64); + cfgs.push(Cfg::GnuTimeBits64); } } // On CI: deny all warnings if libc_ci { - set_cfg("libc_deny_warnings"); + cfgs.push(Cfg::LibcDenyWarnings); } // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to // avoid warnings. if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { - println!("cargo:rustc-check-cfg=cfg({cfg})"); + println!("cargo:rustc-check-cfg=cfg({})", cfg.name()); } for &(name, values) in CHECK_CFG_EXTRA { let values = values.join("\",\""); println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); } } + + cfgs.sort_unstable(); + cfgs.dedup(); + + for cfg in cfgs { + set_cfg(cfg); + } } /// Run `rustc --version` and capture the output, adjusting arguments as needed if `clippy-driver` @@ -392,13 +461,9 @@ fn vxworks_version_code() -> Option<(u32, u32)> { Some((major, minor)) } -fn set_cfg(cfg: &str) { - assert!( - ALLOWED_CFGS.contains(&cfg), - "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS", - ); - println!("cargo:rustc-cfg={cfg}"); - info!("setting config `{cfg}`"); +fn set_cfg(cfg: Cfg) { + println!("cargo:rustc-cfg={}", cfg.name()); + info!("setting config `{}`", cfg.name()); } /// Return true if the env is set to a value other than `0`. From 1f0aa1c2b9c6e6c476fb546d77c419e00bfca550 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 22:46:29 -0400 Subject: [PATCH 15/45] build: Assert that cfg makes sense Adjust configuration so that we are not e.g. setting `freebsd12` on non-FreeBSD targets, and add assertions that similar configuration setups make sense. This also means we aren't spending the (small) time to invoke version-fetching commands on targets where they won't even be used. (backport ) (cherry picked from commit 6840d7b0fd66f756d84bf07af85a1842c7d5999e) --- build.rs | 160 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 124 insertions(+), 36 deletions(-) diff --git a/build.rs b/build.rs index 419654def3bb..d1e4b1da2560 100644 --- a/build.rs +++ b/build.rs @@ -36,12 +36,12 @@ enum Cfg { VxworksLt25_09, - /// Corresponds to `__USE_TIME_BITS64` in UAPI + /// Corresponds to `__USE_TIME_BITS64` in UAPI. Implies 32-bit Linux target. LinuxTimeBits64, - /// Corresponds to `_FILE_OFFSET_BITS=64` in glibc + /// Corresponds to `_FILE_OFFSET_BITS=64` in glibc. Implies 32-bit GNU target. GnuFileOffsetBits64, - /// Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with - /// GNU to expose a 64-bit `time_t`. + /// Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with GNU + /// to expose a 64-bit `time_t`. Implies 32-bit GNU target and 64-bit `off_t`. GnuTimeBits64, /// Musl 1.2+. Implies `target_env = "musl"` MuslV1_2, @@ -175,42 +175,49 @@ fn main() { ); } - // The ABI of libc used by std is backward compatible with FreeBSD 12. - // The ABI of libc from crates.io is backward compatible with FreeBSD 12. - // - // On CI, we detect the actual FreeBSD version and match its ABI exactly, - // running tests to ensure that the ABI is correct. - // Allow overriding the default version for testing - let which_freebsd = if let Ok(version) = env::var("CARGO_CFG_LIBC_UNSTABLE_FREEBSD_VERSION") { - let vers = version.parse().unwrap(); - println!("cargo:warning=setting FreeBSD version to {vers}"); - vers - } else if libc_ci { - which_freebsd().unwrap_or(12) - } else { - 12 - }; + if target_os == "freebsd" { + // The ABI of libc used by std is backward compatible with FreeBSD 12. + // The ABI of libc from crates.io is backward compatible with FreeBSD 12. + // + // On CI, we detect the actual FreeBSD version and match its ABI exactly, + // running tests to ensure that the ABI is correct. + // Allow overriding the default version for testing + let which_freebsd = if let Ok(version) = env::var("CARGO_CFG_LIBC_UNSTABLE_FREEBSD_VERSION") + { + let vers = version.parse().unwrap(); + println!("cargo:warning=setting FreeBSD version to {vers}"); + vers + } else if libc_ci { + which_freebsd().unwrap_or(12) + } else { + 12 // regardless of CARGO_FEATURE_RUSTC_DEP_OF_STD env var + }; - match which_freebsd { - x if x < 10 => panic!("FreeBSD older than 10 is not supported"), - 10 => cfgs.push(Cfg::Freebsd10), - 11 => cfgs.push(Cfg::Freebsd11), - 12 => cfgs.push(Cfg::Freebsd12), - 13 => cfgs.push(Cfg::Freebsd13), - 14 => cfgs.push(Cfg::Freebsd14), - _ => cfgs.push(Cfg::Freebsd15), + match which_freebsd { + x if x < 10 => panic!("FreeBSD older than 10 is not supported"), + 10 => cfgs.push(Cfg::Freebsd10), + 11 => cfgs.push(Cfg::Freebsd11), + 12 => cfgs.push(Cfg::Freebsd12), + 13 => cfgs.push(Cfg::Freebsd13), + 14 => cfgs.push(Cfg::Freebsd14), + _ => cfgs.push(Cfg::Freebsd15), + } } - match emcc_version_code() { - Some(v) if (v < 30142) => cfgs.push(Cfg::EmscriptenOldStatAbi), - // Non-Emscripten or version >= 3.1.42. - _ => (), + if target_os == "emscripten" { + match emcc_version_code() { + Some(v) if (v < 30142) => cfgs.push(Cfg::EmscriptenOldStatAbi), + // Non-Emscripten or version >= 3.1.42. + _ => (), + } } - match vxworks_version_code() { - Some(v) if (v < (25, 9)) => cfgs.push(Cfg::VxworksLt25_09), - // VxWorks version >= 25.09 - _ => (), + if target_os == "vxworks" { + match vxworks_version_code() { + Some(v) if (v < (25, 9)) => cfgs.push(Cfg::VxworksLt25_09), + // VxWorks version >= 25.09 + _ => (), + } } let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); @@ -294,7 +301,9 @@ fn main() { }; if timebits == "64" { - cfgs.push(Cfg::LinuxTimeBits64); + if target_os == "linux" { + cfgs.push(Cfg::LinuxTimeBits64); + } cfgs.push(Cfg::GnuFileOffsetBits64); cfgs.push(Cfg::GnuTimeBits64); } @@ -319,6 +328,7 @@ fn main() { cfgs.sort_unstable(); cfgs.dedup(); + validate_cfg(&cfgs, &target_env, &target_os, &target_ptr_width); for cfg in cfgs { set_cfg(cfg); @@ -403,6 +413,84 @@ fn rustc_minor_nightly() -> (u32, bool) { (minor, nightly) } +/// Check that our list of cfg makes sense for the current target. +fn validate_cfg(list: &[Cfg], target_env: &str, target_os: &str, target_ptr_width: &str) { + for cfg in list { + match cfg { + Cfg::LibcDenyWarnings => (), + Cfg::LibcElfv2 => (), + Cfg::LibcPauthtest => (), + Cfg::EspidfPicolibc => (), + Cfg::EspidfTime32 => (), + + Cfg::EmscriptenOldStatAbi => { + assert_eq!( + target_os, "emscripten", + "{cfg:?} set on non-freebsd platform" + ); + } + + Cfg::Freebsd10 + | Cfg::Freebsd11 + | Cfg::Freebsd12 + | Cfg::Freebsd13 + | Cfg::Freebsd14 + | Cfg::Freebsd15 => { + assert_eq!(target_os, "freebsd", "{cfg:?} set on non-freebsd platform"); + } + + Cfg::VxworksLt25_09 => { + assert_eq!(target_os, "vxworks", "{cfg:?} set on non-vxworks platform"); + } + + Cfg::GnuFileOffsetBits64 => { + assert_eq!(target_env, "gnu", "{cfg:?} set on non-gnu platform"); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + } + Cfg::GnuTimeBits64 => { + assert_eq!(target_env, "gnu", "{cfg:?} set on non-gnu platform"); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + assert!( + list.contains(&Cfg::GnuFileOffsetBits64), + "{cfg:?} set without 64-bit off_t" + ) + } + Cfg::LinuxTimeBits64 => { + assert_eq!(target_os, "linux", "{cfg:?} set on non-linux platform"); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + } + Cfg::MuslV1_2 => { + assert!( + matches!(target_env, "musl" | "ohos"), + "{cfg:?} set with env {target_env}" + ); + } + Cfg::Musl32Time64 => { + assert!( + matches!(target_env, "musl" | "ohos"), + "{cfg:?} set with env {target_env}" + ); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + assert!( + list.contains(&Cfg::MuslV1_2), + "{cfg:?} set on non-musl1.2 platform" + ) + } + Cfg::MuslRedirTime64 => { + assert!( + matches!(target_env, "musl" | "ohos"), + "{cfg:?} set with env {target_env}" + ); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + assert!( + list.contains(&Cfg::MuslV1_2), + "{cfg:?} set on non-musl1.2 platform" + ) + } + } + } +} + fn which_freebsd() -> Option { let output = Command::new("freebsd-version").output().ok()?; if !output.status.success() { From 5bfad6c3925cbe3ad20183920296202bf397c43f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 6 Sep 2026 04:24:31 -0400 Subject: [PATCH 16/45] util: Print the time it took to do the checks (backport ) (cherry picked from commit 7e30c329edc6f96fb2d5190d71cbbeb715432c75) --- etc/libc-util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/libc-util.py b/etc/libc-util.py index da4ba6c68fbb..418a129fbf43 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -14,6 +14,7 @@ import shlex import subprocess as sp import sys +import time from dataclasses import dataclass from enum import StrEnum from inspect import cleandoc @@ -479,6 +480,8 @@ def check_all_targets( failures = [] matched_only_already_skipped = [] + start = time.time() + if only is not None: for t in checks: if t.pattern_matches(only): @@ -556,8 +559,9 @@ def check_all_targets( if len(failures) > self.failure_limit: break + elapsed = round(time.time() - start, 2) print( - f"finished checking {ran} targets. {passed} passed, " + f"finished checking {ran} targets in {elapsed} seconds. {passed} passed, " f"{len(failures)} failed, {skipped} skipped" ) if len(matched_only_already_skipped) > 0: From 19137a4384687af5651cbaf8b3519a7a26a81b59 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 6 Sep 2026 05:09:43 -0400 Subject: [PATCH 17/45] Make `rustc-dep-of-std` work with `extra-traits` All that is needed is some import adjustments. Closes: https://github.com/rust-lang/libc/issues/2064 (backport ) (cherry picked from commit 23bab1ea5295cc4e3fe4e9945b8266f5a214c91c) --- src/macros.rs | 27 ++++++++++++++++++++++++--- src/unix/newlib/mod.rs | 4 ++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index d13216940753..2a5110b8591c 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -74,8 +74,15 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use core::clone::Clone; #[allow(unused_imports)] + pub(crate) use core::cmp::{ + Eq, + PartialEq, + }; + #[allow(unused_imports)] pub(crate) use core::default::Default; #[allow(unused_imports)] + pub(crate) use core::iter::Iterator; + #[allow(unused_imports)] pub(crate) use core::marker::{ Copy, Send, @@ -89,12 +96,14 @@ macro_rules! prelude { pub(crate) use core::{ assert, cfg, + compile_error, debug_assert, fmt, hash, iter, mem, ptr, + unimplemented, }; #[allow(unused_imports)] @@ -176,7 +185,11 @@ macro_rules! s { )] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(PartialEq, Eq, Hash) + ::core::prelude::v1::derive( + ::core::cmp::PartialEq, + ::core::cmp::Eq, + ::core::hash::Hash, + ) )] #[allow(deprecated)] $(#[$attr])* @@ -201,7 +214,11 @@ macro_rules! s_paren { )] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(PartialEq, Eq, Hash) + ::core::prelude::v1::derive( + ::core::cmp::PartialEq, + ::core::cmp::Eq, + ::core::hash::Hash, + ) )] $(#[$attr])* $pub struct $i ( $($field)* ); @@ -266,7 +283,11 @@ macro_rules! s_with_default { )] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(PartialEq, Eq, Hash) + ::core::prelude::v1::derive( + ::core::cmp::PartialEq, + ::core::cmp::Eq, + ::core::hash::Hash, + ) )] #[allow(deprecated)] } diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 468845ee87d9..5e5fd11c3590 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -25,7 +25,7 @@ cfg_if! { pub type ino_t = u32; pub type off_t = i64; } else { - core::compile_error!("unsupported target"); + compile_error!("unsupported target"); } } @@ -1030,6 +1030,6 @@ cfg_if! { mod rtems; pub use self::rtems::*; } else { - core::compile_error!("unsupported target"); + compile_error!("unsupported target"); } } From 8aa6e86484d918ef55c8b0222d89c8b76e4e8934 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 6 Sep 2026 13:40:23 +0100 Subject: [PATCH 18/45] libc: Make `rustc-dep-of-std` work in tests (backport ) (cherry picked from commit ec167aecb1bf80f4cc9efc419ac4180a1dcde986) --- src/macros.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index 2a5110b8591c..79786d9bca1a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -910,6 +910,7 @@ macro_rules! offset_of { #[cfg(test)] mod tests { use core::any::TypeId; + use core::prelude::v1::*; use crate::types::CEnumRepr; @@ -1227,6 +1228,8 @@ mod tests { #[cfg(test)] #[allow(unused)] mod macro_checks { + use core::prelude::v1::*; + s! { pub struct S1 { pub a: u32, From a9bd40b8716e891ef0f1c417d310f7a032a27adc Mon Sep 17 00:00:00 2001 From: xjtu-ctgg <1093656961@qq.com> Date: Tue, 1 Sep 2026 00:29:14 +0800 Subject: [PATCH 19/45] linux: fix unusable riscv32 GNU syscall numbers RISC-V 32-bit only provides time64 variants for these syscalls. Use the time64 syscall numbers and remove the generic names that refer to unavailable time32 syscalls. Sources: https://github.com/torvalds/linux/blob/v7.1/arch/riscv/kernel/Makefile.syscalls https://github.com/torvalds/linux/blob/v7.1/include/uapi/asm-generic/unistd.h#L269 https://github.com/bminor/glibc/blob/glibc-2.42/sysdeps/unix/sysv/linux/riscv/rv32/arch-syscall.h#L64-L68 Closes rust-lang/libc#5379 (backport ) (cherry picked from commit 181ab0106073e8f266448d6a47ab7dc18aac2d7e) --- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 1846a32a51cf..8c199bd2c70c 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -466,7 +466,6 @@ pub const SYS_shmget: c_long = 194; pub const SYS_shmat: c_long = 196; pub const SYS_shmctl: c_long = 195; pub const SYS_dup: c_long = 23; -pub const SYS_nanosleep: c_long = 101; pub const SYS_getitimer: c_long = 102; pub const SYS_setitimer: c_long = 103; pub const SYS_getpid: c_long = 172; @@ -489,7 +488,6 @@ pub const SYS_getsockopt: c_long = 209; pub const SYS_clone: c_long = 220; pub const SYS_execve: c_long = 221; pub const SYS_exit: c_long = 93; -pub const SYS_wait4: c_long = 260; pub const SYS_kill: c_long = 129; pub const SYS_uname: c_long = 160; pub const SYS_semget: c_long = 190; @@ -512,7 +510,6 @@ pub const SYS_fchdir: c_long = 50; pub const SYS_fchmod: c_long = 52; pub const SYS_fchown: c_long = 55; pub const SYS_umask: c_long = 166; -pub const SYS_gettimeofday: c_long = 169; pub const SYS_getrlimit: c_long = 163; pub const SYS_getrusage: c_long = 165; pub const SYS_sysinfo: c_long = 179; @@ -543,7 +540,7 @@ pub const SYS_getsid: c_long = 156; pub const SYS_capget: c_long = 90; pub const SYS_capset: c_long = 91; pub const SYS_rt_sigpending: c_long = 136; -pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigtimedwait_time64: c_long = 421; pub const SYS_rt_sigqueueinfo: c_long = 138; pub const SYS_rt_sigsuspend: c_long = 133; pub const SYS_sigaltstack: c_long = 132; @@ -558,7 +555,7 @@ pub const SYS_sched_setscheduler: c_long = 119; pub const SYS_sched_getscheduler: c_long = 120; pub const SYS_sched_get_priority_max: c_long = 125; pub const SYS_sched_get_priority_min: c_long = 126; -pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_sched_rr_get_interval_time64: c_long = 423; pub const SYS_mlock: c_long = 228; pub const SYS_munlock: c_long = 229; pub const SYS_mlockall: c_long = 230; @@ -566,12 +563,10 @@ pub const SYS_munlockall: c_long = 231; pub const SYS_vhangup: c_long = 58; pub const SYS_pivot_root: c_long = 41; pub const SYS_prctl: c_long = 167; -pub const SYS_adjtimex: c_long = 171; pub const SYS_setrlimit: c_long = 164; pub const SYS_chroot: c_long = 51; pub const SYS_sync: c_long = 81; pub const SYS_acct: c_long = 89; -pub const SYS_settimeofday: c_long = 170; pub const SYS_mount: c_long = 40; pub const SYS_umount2: c_long = 39; pub const SYS_swapon: c_long = 224; @@ -598,12 +593,12 @@ pub const SYS_removexattr: c_long = 14; pub const SYS_lremovexattr: c_long = 15; pub const SYS_fremovexattr: c_long = 16; pub const SYS_tkill: c_long = 130; -pub const SYS_futex: c_long = 98; +pub const SYS_futex_time64: c_long = 422; pub const SYS_sched_setaffinity: c_long = 122; pub const SYS_sched_getaffinity: c_long = 123; pub const SYS_io_setup: c_long = 0; pub const SYS_io_destroy: c_long = 1; -pub const SYS_io_getevents: c_long = 4; +pub const SYS_io_pgetevents_time64: c_long = 416; pub const SYS_io_submit: c_long = 2; pub const SYS_io_cancel: c_long = 3; pub const SYS_lookup_dcookie: c_long = 18; @@ -611,17 +606,17 @@ pub const SYS_remap_file_pages: c_long = 234; pub const SYS_getdents64: c_long = 61; pub const SYS_set_tid_address: c_long = 96; pub const SYS_restart_syscall: c_long = 128; -pub const SYS_semtimedop: c_long = 192; +pub const SYS_semtimedop_time64: c_long = 420; pub const SYS_fadvise64: c_long = 223; pub const SYS_timer_create: c_long = 107; -pub const SYS_timer_settime: c_long = 110; -pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_settime64: c_long = 409; +pub const SYS_timer_gettime64: c_long = 408; pub const SYS_timer_getoverrun: c_long = 109; pub const SYS_timer_delete: c_long = 111; -pub const SYS_clock_settime: c_long = 112; -pub const SYS_clock_gettime: c_long = 113; -pub const SYS_clock_getres: c_long = 114; -pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_clock_settime64: c_long = 404; +pub const SYS_clock_gettime64: c_long = 403; +pub const SYS_clock_getres_time64: c_long = 406; +pub const SYS_clock_nanosleep_time64: c_long = 407; pub const SYS_exit_group: c_long = 94; pub const SYS_epoll_ctl: c_long = 21; pub const SYS_tgkill: c_long = 131; @@ -630,8 +625,8 @@ pub const SYS_set_mempolicy: c_long = 237; pub const SYS_get_mempolicy: c_long = 236; pub const SYS_mq_open: c_long = 180; pub const SYS_mq_unlink: c_long = 181; -pub const SYS_mq_timedsend: c_long = 182; -pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_timedsend_time64: c_long = 418; +pub const SYS_mq_timedreceive_time64: c_long = 419; pub const SYS_mq_notify: c_long = 184; pub const SYS_mq_getsetattr: c_long = 185; pub const SYS_kexec_load: c_long = 104; @@ -655,8 +650,8 @@ pub const SYS_symlinkat: c_long = 36; pub const SYS_readlinkat: c_long = 78; pub const SYS_fchmodat: c_long = 53; pub const SYS_faccessat: c_long = 48; -pub const SYS_pselect6: c_long = 72; -pub const SYS_ppoll: c_long = 73; +pub const SYS_pselect6_time64: c_long = 413; +pub const SYS_ppoll_time64: c_long = 414; pub const SYS_unshare: c_long = 97; pub const SYS_set_robust_list: c_long = 99; pub const SYS_get_robust_list: c_long = 100; @@ -665,12 +660,12 @@ pub const SYS_tee: c_long = 77; pub const SYS_sync_file_range: c_long = 84; pub const SYS_vmsplice: c_long = 75; pub const SYS_move_pages: c_long = 239; -pub const SYS_utimensat: c_long = 88; +pub const SYS_utimensat_time64: c_long = 412; pub const SYS_epoll_pwait: c_long = 22; pub const SYS_timerfd_create: c_long = 85; pub const SYS_fallocate: c_long = 47; -pub const SYS_timerfd_settime: c_long = 86; -pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_timerfd_settime64: c_long = 411; +pub const SYS_timerfd_gettime64: c_long = 410; pub const SYS_accept4: c_long = 242; pub const SYS_signalfd4: c_long = 74; pub const SYS_eventfd2: c_long = 19; @@ -682,13 +677,13 @@ pub const SYS_preadv: c_long = 69; pub const SYS_pwritev: c_long = 70; pub const SYS_rt_tgsigqueueinfo: c_long = 240; pub const SYS_perf_event_open: c_long = 241; -pub const SYS_recvmmsg: c_long = 243; +pub const SYS_recvmmsg_time64: c_long = 417; pub const SYS_fanotify_init: c_long = 262; pub const SYS_fanotify_mark: c_long = 263; pub const SYS_prlimit64: c_long = 261; pub const SYS_name_to_handle_at: c_long = 264; pub const SYS_open_by_handle_at: c_long = 265; -pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_clock_adjtime64: c_long = 405; pub const SYS_syncfs: c_long = 267; pub const SYS_sendmmsg: c_long = 269; pub const SYS_setns: c_long = 268; From cf5bf2bd7c9f324a079264a8321a043221b0f863 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 22:46:29 -0400 Subject: [PATCH 20/45] uclibc: Also run checks with the time64 setting (backport ) (cherry picked from commit 7e9f74959ca7523465236e116bfda9714b3eaeab) --- etc/libc-util.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/etc/libc-util.py b/etc/libc-util.py index 418a129fbf43..90d58e761472 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -438,6 +438,15 @@ def prepare() -> "CheckAllTargets": ] new_checks.append(new) + if t.env == "uclibc" and t.bits == 32: + new = copy.deepcopy(base) + new.attributes = base.attributes | {"time_bits": "64"} + new.target_dir = base.target_dir / "time64" + new.extra_rustflags = base.extra_rustflags + [ + "--cfg=libc_unstable_uclibc_time64" + ] + new_checks.append(new) + # Update the name field and check whether there are any targets that we # always need to skip, or that need flags. for check in new_checks: From 28f104e594dab1419e6c35624bb53678298b7dba Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 22:46:29 -0400 Subject: [PATCH 21/45] build: Restructure time64 config MUSL_REDIR_TIME64_ARCHES are just the 32-bit arches that aren't 1.2-only, i.e. the opposite of the 32-bit arches that always set `musl_v1_2 = true`. Merge the logic for these two. riscv32 is added to this list since it is in the same boat. Additionally, restructure things to make the logic flow more clear. (backport ) (cherry picked from commit 40428695f6a9470cd59cc502a6494c3fe41a2f66) --- build.rs | 123 +++++++++++++++++++++++++++---------------------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/build.rs b/build.rs index d1e4b1da2560..2eff8ef22e6a 100644 --- a/build.rs +++ b/build.rs @@ -121,10 +121,6 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ), ]; -/// Musl architectures that define `_REDIR_TIME64` (i.e. those that transitioned -/// from 32-bit to 64-bit `time_t` and need `__*_time64` symbol redirects). -const MUSL_REDIR_TIME64_ARCHES: &[&str] = &["arm", "mips", "powerpc", "x86"]; - /// Read from env, print more debug output via `cargo:warning` if set. static VERBOSE_BUILD: AtomicBool = AtomicBool::new(false); @@ -220,93 +216,96 @@ fn main() { } } - let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); - if let Ok(old_musl_v1_2_3) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") { + let mut musl_v1_2_env = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); + if let Ok(old_musl_v1_2_3_env) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") { println!( "cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \ set `--cfg=libc_unstable_musl_v1_2`instead" ); - musl_v1_2 |= old_musl_v1_2_3 != "0"; + musl_v1_2_env |= old_musl_v1_2_3_env != "0"; } - if let Ok(old_musl_v1_2_3) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") { + if let Ok(old_musl_v1_2_3_env) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") { println!( "cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \ set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead" ); - musl_v1_2 |= old_musl_v1_2_3 != "0"; + musl_v1_2_env |= old_musl_v1_2_3_env != "0"; } - // OpenHarmony uses a fork of the musl libc - let musl = target_env == "musl" || target_env == "ohos"; - - // loongarch64, hexagon, ohos and pauthtest only exist with recent musl - if target_arch == "loongarch64" + // Targets that only exist with recent musl. 32-bit targets not in this list need + // `_REDIR_TIME64` for 64-bit `time_t`. + let only_v1_2_on_musl = target_arch == "loongarch64" || target_arch == "hexagon" + || target_arch == "riscv32" || target_env == "ohos" - || target_abi == "pauthtest" - { - musl_v1_2 = true; - } + || target_abi == "pauthtest"; + + // OpenHarmony uses a fork of the musl libc + let musl = target_env == "musl" || target_env == "ohos"; + let musl_v1_2 = musl && (musl_v1_2_env || only_v1_2_on_musl); - if musl && musl_v1_2 { + if musl_v1_2 { cfgs.push(Cfg::MuslV1_2); if target_ptr_width == "32" { cfgs.push(Cfg::Musl32Time64); cfgs.push(Cfg::LinuxTimeBits64); - } - if MUSL_REDIR_TIME64_ARCHES.contains(&target_arch.as_str()) { - cfgs.push(Cfg::MuslRedirTime64); + if !only_v1_2_on_musl { + // Older 32-bit arches need the redirects + cfgs.push(Cfg::MuslRedirTime64); + } } } - let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); - if target_env == "uclibc" && uclibc_use_time64 { + let uclibc_time64_env = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); + let uclibc_time64 = target_env == "uclibc" && uclibc_time64_env; + if uclibc_time64 { cfgs.push(Cfg::LinuxTimeBits64); } - if target_env == "gnu" - && matches!(target_os.as_str(), "linux" | "windows" | "hurd") - && target_ptr_width == "32" - && target_arch != "riscv32" - && target_arch != "x86_64" - { - let defaultbits = "32"; + let mut gnu_tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS"); - let mut tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS"); + // FIXME: remove these fallbacks in a few releases + if let Ok(old_gnu_tb_env) = env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") { + println!( + "cargo:warning=RUST_LIBC_UNSTABLE_GNU_TIME_BITS will be removed; \ + set `--cfg=libc_unstable_gnu_time_bits=\"...\"` via RUSTFLAGS instead" + ); + gnu_tb_env = gnu_tb_env.or(Ok(old_gnu_tb_env)); + } + if env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() + || env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() + { + println!( + "cargo:warning=glibc file offset can no longer be set independently of \ + `gnu_time_bits`" + ); + } - // FIXME: remove these fallbacks in a few releases - if let Ok(old_tb_env) = env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") { - println!( - "cargo:warning=RUST_LIBC_UNSTABLE_GNU_TIME_BITS will be removed; \ - set `--cfg=libc_unstable_gnu_time_bits=\"...\"` via RUSTFLAGS instead" - ); - tb_env = tb_env.or(Ok(old_tb_env)); - } - if env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() - || env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() - { - println!( - "cargo:warning=glibc file offset can no longer be set independently of \ - `gnu_time_bits`" - ); + let gnu32_timebits = match gnu_tb_env.as_deref() { + Err(_) => "32", // default to 32 + Ok(tb) if tb == "64" => tb, + Ok(tb) if tb == "32" => tb, + Ok(_) => { + panic!("Invalid value for libc_unstable_gnu_time_bits. Must be 32, 64, or unset.") } + }; - let timebits = match tb_env.as_deref() { - Err(_) => defaultbits, - Ok(tb) if tb == "64" => tb, - Ok(tb) if tb == "32" => tb, - Ok(_) => { - panic!("Invalid value for libc_unstable_gnu_time_bits. Must be 32, 64, or unset.") - } - }; - - if timebits == "64" { - if target_os == "linux" { - cfgs.push(Cfg::LinuxTimeBits64); - } - cfgs.push(Cfg::GnuFileOffsetBits64); - cfgs.push(Cfg::GnuTimeBits64); + // 32-bit arches with 64-bit time_t by default. rv32 is 64-only, `x86_64` covers the x32 arch, + // `!(linux|windows|hurd)` covers vxworks and future platforms. + let gnu32_already_time64 = target_arch == "riscv32" + || target_arch == "x86_64" + || !matches!(target_os.as_str(), "linux" | "windows" | "hurd"); + let gnu = target_env == "gnu"; + let gnu32_time64 = gnu && target_ptr_width == "32" && gnu32_timebits == "64"; + + if gnu32_time64 && !gnu32_already_time64 { + // These configs all set up nonstandard options. They are not needed on platforms like + // riscv32, where 64-bit `time_t` is the default. + if target_os == "linux" { + cfgs.push(Cfg::LinuxTimeBits64); } + cfgs.push(Cfg::GnuFileOffsetBits64); + cfgs.push(Cfg::GnuTimeBits64); } // On CI: deny all warnings From 0d200bb3d7fcdbc8e65cc784ecfd29965abccf15 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 7 Sep 2026 04:07:05 -0400 Subject: [PATCH 22/45] build: Fix a comment about what `gnu_time_bits64` implies (backport ) (cherry picked from commit 008f905256d27eb5dd416d0976678ee6c2855554) --- build.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 2eff8ef22e6a..2e3ae4cb393b 100644 --- a/build.rs +++ b/build.rs @@ -40,8 +40,9 @@ enum Cfg { LinuxTimeBits64, /// Corresponds to `_FILE_OFFSET_BITS=64` in glibc. Implies 32-bit GNU target. GnuFileOffsetBits64, - /// Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with GNU - /// to expose a 64-bit `time_t`. Implies 32-bit GNU target and 64-bit `off_t`. + /// Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with GNU to expose a + /// 64-bit `time_t`. Implies 32-bit GNU target and, on platforms other than Windows, 64-bit + /// `off_t`. GnuTimeBits64, /// Musl 1.2+. Implies `target_env = "musl"` MuslV1_2, From be1e2983c0139b5fb15758847173bdcf923b1b04 Mon Sep 17 00:00:00 2001 From: Maerten Farya Date: Fri, 4 Sep 2026 12:49:24 +0200 Subject: [PATCH 23/45] qnx: add missing definitions for io-sock (backport ) (cherry picked from commit 77e9b41e3486649840b8d3c95cb96b523f25311f) --- src/unix/nto/io_sock/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/unix/nto/io_sock/mod.rs b/src/unix/nto/io_sock/mod.rs index 303f5ca4c44b..5d0e435a65fa 100644 --- a/src/unix/nto/io_sock/mod.rs +++ b/src/unix/nto/io_sock/mod.rs @@ -50,6 +50,18 @@ s! { pub sdl_slen: c_uchar, pub sdl_data: [c_char; 46], } + + pub struct ip_mreqn { + pub imr_multiaddr: crate::in_addr, + pub imr_address: crate::in_addr, + pub imr_ifindex: c_int, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: crate::in_addr, + pub imr_sourceaddr: crate::in_addr, + pub imr_interface: crate::in_addr, + } } pub const SCM_CREDS: c_int = 0x03; @@ -89,6 +101,12 @@ pub const PF_NATM: c_int = AF_NATM; pub const pseudo_AF_HDRCMPLT: c_int = 31; pub const SIOCGIFADDR: c_int = u32_cast_int(0xc0206921); pub const SO_SETFIB: c_int = 0x1014; +pub const TCP_KEEPIDLE: c_int = 256; +pub const TCP_KEEPINTVL: c_int = 512; +pub const TCP_KEEPCNT: c_int = 1024; +pub const IP_RECVTOS: c_int = 68; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 70; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 71; extern "C" { pub fn sendmmsg( From ae11b7f8df30a4421b388522c63853678bed67a9 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 6 Sep 2026 12:17:29 +0100 Subject: [PATCH 24/45] build: Implement Display trait for Cfg (backport ) (cherry picked from commit 5cf8e76452e54f9874d7403c5647d4c51e6e15c3) --- build.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index 2e3ae4cb393b..0ef503d2a78a 100644 --- a/build.rs +++ b/build.rs @@ -7,6 +7,7 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::Relaxed; use std::{ env, + fmt, str, }; @@ -77,9 +78,9 @@ const ALLOWED_CFGS: &[Cfg] = &[ Cfg::MuslRedirTime64, ]; -impl Cfg { - fn name(self) -> &'static str { - match self { +impl fmt::Display for Cfg { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(match self { Cfg::LibcDenyWarnings => "libc_deny_warnings", Cfg::EmscriptenOldStatAbi => "emscripten_old_stat_abi", Cfg::EspidfPicolibc => "espidf_picolibc", @@ -99,7 +100,7 @@ impl Cfg { Cfg::MuslV1_2 => "musl_v1_2", Cfg::Musl32Time64 => "musl32_time64", Cfg::MuslRedirTime64 => "musl_redir_time64", - } + }) } } @@ -318,7 +319,7 @@ fn main() { // avoid warnings. if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { - println!("cargo:rustc-check-cfg=cfg({})", cfg.name()); + println!("cargo:rustc-check-cfg=cfg({cfg})"); } for &(name, values) in CHECK_CFG_EXTRA { let values = values.join("\",\""); @@ -550,8 +551,8 @@ fn vxworks_version_code() -> Option<(u32, u32)> { } fn set_cfg(cfg: Cfg) { - println!("cargo:rustc-cfg={}", cfg.name()); - info!("setting config `{}`", cfg.name()); + println!("cargo:rustc-cfg={cfg}"); + info!("setting config `{cfg}`"); } /// Return true if the env is set to a value other than `0`. From 831095fc01959c8661b1c502883a3ee1512584c8 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 8 Sep 2026 01:08:29 -0400 Subject: [PATCH 25/45] util: Bump the check-all-targets toolchain It's been a few months, so nudge to a version past the LLVM update. This fixes the m68k LLVM issue, but libc still does not build on that platform. (backport ) (cherry picked from commit 92a41dd3f88cc43a6130b5474d7c1ff323f089fc) --- etc/libc-util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/libc-util.py b/etc/libc-util.py index 90d58e761472..7be33c39a100 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -357,11 +357,11 @@ class CheckAllTargets: ("x86_64-lynx-lynxos178", "libc error, unresolved import"), ("x86_64-pc-nto-qnx800", "libc error, unsupported arch"), ("x86_64-unknown-linux-none", "libc error, unresolved import"), + ("m68k-unknown-.*", "libc error, duplicate definition"), # rustc problems ("xtensa-esp32.*", "target string mismatch in rustc"), ("amdgcn-amd-amdhsa", "unsupported instructions with some CPUs"), # llvm problems - ("m68k-unknown-.*", "llvm crash building core"), ("mipsisa32r6(el)?-.*", "llvm crash building core"), ] @@ -586,7 +586,7 @@ def check_all_targets( @staticmethod def get_cache_toolchain() -> str: # Arbitrary but reasonably recent default if unset. - return os.environ.get("RUSTC_CACHE_TOOLCHAIN") or "nightly-2026-06-24" + return os.environ.get("RUSTC_CACHE_TOOLCHAIN") or "nightly-2026-09-01" @dataclass(kw_only=True) From d3eddcba2d2abbd9912a623c8e8cd77afc8220b3 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 8 Sep 2026 03:31:35 -0400 Subject: [PATCH 26/45] docs: Be more clear about the problem with `uninit` (backport ) (cherry picked from commit 60b56d183959726a9906e4e6629a1c322a27377b) --- src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7ae80264bb99..ee1af1c93e98 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,13 +45,18 @@ //! not present in most Rust libraries. Observing the following guidelines are recommended to help //! avoid soundness and stability pitfalls. //! -//! 1. *Never* construct a `libc` struct with `MaybeUninit::uninit()`, initialize it, then call -//! `assume_init`. Many structures have padding fields or may gain fields in the future, and -//! it is far too easy to end up calling `assume_init` on partially initialized data. +//! 1. *Never* construct a `libc` struct with `MaybeUninit::uninit()`, call a `libc` function with +//! it, then call `assume_init`. Library functions do not always initialize all fields; this +//! includes obvious cases like padding fields, but also less obvious cases like fields present +//! in the `libc` struct but not on older versions of the platform's C library. It is far too +//! easy to end up with a bogus `assume_init` because not all fields have been written. //! //! Instead, use `MaybeUninit::zeroed()` or the `Default` implementations that are slowly being //! added. Alternatively, access fields only via raw pointer without ever using `assume_init`. //! +//! See also the safety docs for `MaybeUninit::assume_init` +//! . +//! //! 2. Avoid relying on the exact value of constants, the exact length of arrays, or the exact //! types of type aliases, as they may change across `libc` versions. That is, if `libc` //! contains code like: From 44fc56b7e56e7a057079b795ab91f5813e71f82b Mon Sep 17 00:00:00 2001 From: Marius Melzer Date: Tue, 8 Sep 2026 10:29:39 +0200 Subject: [PATCH 27/45] Redisable constants for L4Re These constants were disabled for uclibc (and therefore implicitly disabled for L4Re). Now that they are not disabled for uclibc anymore, explicitly disable them for L4Re. (backport ) (cherry picked from commit 7470c73a1f49ccb290c0ae407cdf3e17dc9af10d) --- src/unix/linux_like/linux_l4re_shared.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index f8a0b45e610c..dc1f27f7b6c4 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -795,6 +795,7 @@ pub const EM_M32R: u16 = 88; pub const EM_MN10300: u16 = 89; pub const EM_MN10200: u16 = 90; pub const EM_PJ: u16 = 91; +#[cfg(not(target_os = "l4re"))] pub const EM_OPENRISC: u16 = 92; #[cfg(target_env = "uclibc")] pub const EM_OR1K: u16 = 92; @@ -875,6 +876,7 @@ pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value // wherever it is defined. pub const AT_SYSINFO_EHDR: c_ulong = 33; +#[cfg(not(target_os = "l4re"))] pub const AT_MINSIGSTKSZ: c_ulong = 51; pub const GLOB_ERR: c_int = 1 << 0; From 03b63ec08849548140b8e1392ce5956784211c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 8 Sep 2026 13:07:29 +0200 Subject: [PATCH 28/45] linux: Add `BCACHEFS_SUPER_MAGIC` constant Source: https://github.com/torvalds/linux/blob/v6.10/include/uapi/linux/magic.h#L40 (backport ) (cherry picked from commit c610b5fa8060f3d46d101d93af7aac78d70a5ce8) --- libc-test/build/main.rs | 4 ++++ libc-test/semver/linux-gnu.txt | 1 + src/unix/linux_like/mod.rs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 0fef1ef41188..f041a936c283 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -2439,6 +2439,9 @@ fn test_android(t: &Target) { // FIXME(android): Requires >= 6.9 kernel headers. "AT_HWCAP3" | "AT_HWCAP4" | "RWF_NOAPPEND" => true, + // FIXME(android): Requires >= 6.10 kernel headers. + "BCACHEFS_SUPER_MAGIC" => true, + // FIXME(android): Requires >= 6.11 kernel headers. "RWF_ATOMIC" => true, @@ -4974,6 +4977,7 @@ fn test_linux(t: &Target) { // Recent additions "AT_HWCAP3" | "AT_HWCAP4" if old_musl => true, "AT_HWCAP3" | "AT_HWCAP4" => kernel < (6, 9), + "BCACHEFS_SUPER_MAGIC" => kernel < (6, 10), "PTRACE_SET_SYSCALL_INFO" => kernel < (6, 16), "TLS_INFO_TX_MAX_PAYLOAD_LEN" | "TLS_INFO_MAX" => kernel < (6, 19), diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index d846885a12c8..7bca8b6eba50 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -25,6 +25,7 @@ AT_STATX_FORCE_SYNC AT_STATX_SYNC_AS_STAT AT_STATX_SYNC_TYPE AUTOFS_SUPER_MAGIC +BCACHEFS_SUPER_MAGIC BINDERFS_SUPER_MAGIC BOOT_TIME BPF_FS_MAGIC diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 357a6e2f9546..8797a0bd354d 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1530,6 +1530,7 @@ cfg_if! { pub const AFFS_SUPER_MAGIC: c_long = 0x0000adff; pub const AFS_SUPER_MAGIC: c_long = 0x5346414f; pub const AUTOFS_SUPER_MAGIC: c_long = 0x0187; + pub const BCACHEFS_SUPER_MAGIC: c_long = u32_cast_long(0xca451a4e); pub const BPF_FS_MAGIC: c_long = u32_cast_long(0xcafe4a11); pub const BTRFS_SUPER_MAGIC: c_long = u32_cast_long(0x9123683e); pub const CGROUP2_SUPER_MAGIC: c_long = 0x63677270; @@ -1584,6 +1585,7 @@ cfg_if! { pub const AFFS_SUPER_MAGIC: c_uint = 0x0000adff; pub const AFS_SUPER_MAGIC: c_uint = 0x5346414f; pub const AUTOFS_SUPER_MAGIC: c_uint = 0x0187; + pub const BCACHEFS_SUPER_MAGIC: c_long = 0xca451a4e; pub const BPF_FS_MAGIC: c_uint = 0xcafe4a11; pub const BTRFS_SUPER_MAGIC: c_uint = 0x9123683e; pub const CGROUP2_SUPER_MAGIC: c_uint = 0x63677270; From 6d06b0f225e5ba41750b82498b2452e25de44fc7 Mon Sep 17 00:00:00 2001 From: Aelin Reidel Date: Tue, 8 Sep 2026 14:20:04 +0200 Subject: [PATCH 29/45] build: Don't warn when enabling opting into musl 1.2 via multiple ways In Alpine, we have to set both the old and new `cfg` *and* the environment variable since various versions of libc are being used by packaged software. This will then emit the warnings about the options being deprecated, even though we fully intentionally set them. I believe the primary purpose of the warnings is to tell people to migrate to the new `cfg`, so we can just not print a warning if musl 1.2 is being opted into via a different way (and the `cfg` or env var has no effect) already. (backport ) (cherry picked from commit df6561676506cd9c36ebe84b3b2f000661b64767) --- build.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index 0ef503d2a78a..b3df76b41eda 100644 --- a/build.rs +++ b/build.rs @@ -220,17 +220,21 @@ fn main() { let mut musl_v1_2_env = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); if let Ok(old_musl_v1_2_3_env) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") { - println!( - "cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \ - set `--cfg=libc_unstable_musl_v1_2`instead" - ); + if !musl_v1_2_env { + println!( + "cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \ + set `--cfg=libc_unstable_musl_v1_2`instead" + ); + } musl_v1_2_env |= old_musl_v1_2_3_env != "0"; } if let Ok(old_musl_v1_2_3_env) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") { - println!( - "cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \ - set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead" - ); + if !musl_v1_2_env { + println!( + "cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \ + set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead" + ); + } musl_v1_2_env |= old_musl_v1_2_3_env != "0"; } From c70b88f65ded31932d69baca1a7ce84fda877075 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 13 Sep 2026 11:35:11 +0900 Subject: [PATCH 30/45] ci: Test `i686-pc-windows-msvc` as without host tools (backport ) (cherry picked from commit 6b98995e26828ad7d7acca2453724e8a22aba111) --- .github/workflows/ci.yaml | 2 ++ Cargo.toml | 6 ++++-- ci/install-rust.sh | 2 +- ci/verify-build.py | 6 ++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 93e39e7fa806..8e80a142937b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -135,6 +135,7 @@ jobs: os: ubuntu-26.04-arm - target: i686-pc-windows-msvc os: windows-2025 + host: x86_64-pc-windows-msvc # Tier 1 without host tools - target: i686-unknown-linux-gnu - target: x86_64-pc-windows-gnu os: windows-2025 @@ -144,6 +145,7 @@ jobs: runs-on: ${{ matrix.os && matrix.os || 'ubuntu-26.04' }} timeout-minutes: 25 env: + RUST_HOST: ${{ matrix.host }} TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/Cargo.toml b/Cargo.toml index afc199db5a63..e0629f11f7bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,16 +24,18 @@ default-target = "x86_64-unknown-linux-gnu" targets = [ # Note: Keep this in sync with ci/verify-build.py # - # Tier 1 + # Tier 1 with host tools "aarch64-apple-darwin", "aarch64-pc-windows-msvc", "aarch64-unknown-linux-gnu", - "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", # + # Tier 1 without host tools + "i686-pc-windows-msvc", + # # Tier 2 with host tools "aarch64-pc-windows-gnullvm", "aarch64-unknown-linux-musl", diff --git a/ci/install-rust.sh b/ci/install-rust.sh index b40f1df4e7a5..9425d1a694d1 100755 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -19,7 +19,7 @@ case "$(uname -s)" in esac if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then - toolchain="$toolchain-$TARGET" + toolchain="$toolchain-${RUST_HOST:-$TARGET}" rustup set profile minimal fi diff --git a/ci/verify-build.py b/ci/verify-build.py index 83863d0a7e62..89e4e58208cc 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -80,16 +80,18 @@ class TargetResult: FREEBSD_VERSIONS = [11, 12, 13, 14, 15] TARGETS = [ - # Tier 1 + # Tier 1 with host tools Target("aarch64-apple-darwin"), Target("aarch64-pc-windows-msvc"), Target("aarch64-unknown-linux-gnu"), - Target("i686-pc-windows-msvc"), Target("i686-unknown-linux-gnu"), Target("x86_64-pc-windows-gnu"), Target("x86_64-pc-windows-msvc"), Target("x86_64-unknown-linux-gnu"), # + # Tier 1 without host tools + Target("i686-pc-windows-msvc"), + # # Tier 2 with host tools Target("aarch64-pc-windows-gnullvm", min_toolchain=Toolchain.STABLE), Target("aarch64-unknown-linux-musl"), From 2a063664bda13e248ec23c28299d0b69d0271614 Mon Sep 17 00:00:00 2001 From: Aelin Reidel Date: Sat, 12 Sep 2026 22:26:19 +0200 Subject: [PATCH 31/45] linux: Add FUTEX_ROBUST_UNLOCK and FUTEX_ROBUST_LIST32 These were added in Linux 7.2 with https://github.com/torvalds/linux/commit/3ca9595d9fb6cce6633a5b03d98c2aecb5499838 (backport ) (cherry picked from commit ca0144d6c9e0e8f9722f928ff4f69398e93e5213) --- libc-test/build/main.rs | 6 ++++++ libc-test/semver/linux.txt | 2 ++ src/new/linux_uapi/linux/futex.rs | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index f041a936c283..dbb0c4ff6e3e 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -5004,6 +5004,12 @@ fn test_linux(t: &Target) { // eabihf targets are tested using an older version of glibc "AT_HANDLE_FID" if musl || eabihf => true, + // Added in 7.2 + "FUTEX_ROBUST_UNLOCK" => kernel < (7, 2), + "FUTEX_ROBUST_LIST32" => kernel < (7, 2), + // Value changed in 7.2 + "FUTEX_CMD_MASK" => kernel < (7, 2), + _ => false, } }); diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 5087ee94409c..57b90559426b 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -953,6 +953,8 @@ FUTEX_OP_XOR FUTEX_OWNER_DIED FUTEX_PRIVATE_FLAG FUTEX_REQUEUE +FUTEX_ROBUST_LIST32 +FUTEX_ROBUST_UNLOCK FUTEX_TID_MASK FUTEX_TRYLOCK_PI FUTEX_UNLOCK_PI diff --git a/src/new/linux_uapi/linux/futex.rs b/src/new/linux_uapi/linux/futex.rs index 893dee0e0062..e65977b99bea 100644 --- a/src/new/linux_uapi/linux/futex.rs +++ b/src/new/linux_uapi/linux/futex.rs @@ -19,8 +19,11 @@ pub const FUTEX_LOCK_PI2: c_int = 13; pub const FUTEX_PRIVATE_FLAG: c_int = 128; pub const FUTEX_CLOCK_REALTIME: c_int = 256; +pub const FUTEX_ROBUST_UNLOCK: c_int = 512; +pub const FUTEX_ROBUST_LIST32: c_int = 1024; -pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); +pub const FUTEX_CMD_MASK: c_int = + !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME | FUTEX_ROBUST_UNLOCK | FUTEX_ROBUST_LIST32); pub const FUTEX2_SIZE_U8: c_int = 0x00; pub const FUTEX2_SIZE_U16: c_int = 0x01; From 5c0596af4e3b183588aaeabdefc51671f432d846 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Fri, 11 Sep 2026 17:14:36 +0200 Subject: [PATCH 32/45] build(linux): remove skip for `siginfo_t` field Remove skip for `siginfo_t` field as now the full definition is used since rust-lang/libc#5345 was merged. (backport ) (cherry picked from commit 6109bfbe67b309130d480d7daadaa46e9c7bdf2d) --- libc-test/build/main.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index dbb0c4ff6e3e..749294834c8e 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -5190,9 +5190,6 @@ fn test_linux(t: &Target) { cfg.skip_struct_field(move |struct_, field| { match (struct_.ident(), field.ident()) { - // this is actually a union on linux, so we can't represent it well and - // just insert some padding. - ("siginfo_t", "_pad") => true, // musl names this __dummy1 but it's still there ("glob_t", "gl_flags") if musl => true, // musl seems to define this as an *anonymous* bitfield From 3648af8a28d86bc24e6651c2dbcd4136cb3cf9b7 Mon Sep 17 00:00:00 2001 From: Yasser-Ameur Date: Wed, 9 Sep 2026 01:00:52 +0200 Subject: [PATCH 33/45] glibc: add `__f_unused` to `statvfs64` on riscv32 glibc gates `statvfs` and `statvfs64` on the same macro, and riscv32 satisfies it: `__WORDSIZE` is 32 there and nothing defines `__SYSCALL_WORDSIZE`. Only `statvfs` carried the field, so every `statvfs64` field after `f_fsid` sat four bytes off. This was the FIXME left in #5434. https://github.com/sailfishos-mirror/glibc/blob/92861d93cdad13834f4d8f39504b550a80ad8200/sysdeps/unix/sysv/linux/bits/statvfs.h#L24-L27 (backport ) (cherry picked from commit c065a9e8c559d04af354636d09b9f8016f6439bc) --- src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs index 03fc1ac84727..a8e36ca11981 100644 --- a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs +++ b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs @@ -37,15 +37,12 @@ s! { pub f_ffree: u64, pub f_favail: u64, pub f_fsid: c_ulong, - // FIXME(riscv32): glibc declares this field on riscv32 too, but we have - // never declared it here. + // Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because + // its `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets + // `__WORDSIZE` to 64. #[cfg(all( target_pointer_width = "32", - not(any( - target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "riscv32" - )) + not(any(target_arch = "x86_64", target_arch = "aarch64")) ))] __f_unused: Padding, pub f_flag: c_ulong, From 12e20ce42fb82f975101bf0cdcd9a3b2175270cf Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:23 +0200 Subject: [PATCH 34/45] aix: clean up item paths - Simplify crate-relative item paths to use `self`-relative paths. - Replace uses of deprecated fixed-width C integer types with Rust integer types. (backport ) (cherry picked from commit 96fcb01c28047e6cdcb9d7d6eaf7d1de6113b02d) --- src/unix/aix/mod.rs | 697 ++++++++++++++++++++------------------------ 1 file changed, 321 insertions(+), 376 deletions(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index a0e86fada7a6..3c516d40181a 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1,8 +1,4 @@ use crate::prelude::*; -use crate::{ - in_addr_t, - in_port_t, -}; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; @@ -88,7 +84,7 @@ s! { } pub struct fsid64_t { - pub val: [crate::uint64_t; 2], + pub val: [u64; 2], } pub struct timezone { @@ -103,18 +99,18 @@ s! { pub struct dirent { pub d_offset: c_ulong, - pub d_ino: crate::ino_t, + pub d_ino: ino_t, pub d_reclen: c_ushort, pub d_namlen: c_ushort, pub d_name: [c_char; 256], } pub struct termios { - pub c_iflag: crate::tcflag_t, - pub c_oflag: crate::tcflag_t, - pub c_cflag: crate::tcflag_t, - pub c_lflag: crate::tcflag_t, - pub c_cc: [crate::cc_t; crate::NCCS], + pub c_iflag: tcflag_t, + pub c_oflag: tcflag_t, + pub c_cflag: tcflag_t, + pub c_lflag: tcflag_t, + pub c_cc: [crate::cc_t; NCCS], } // FIXME(1.0,deprecate): lfs binding to be removed @@ -130,7 +126,7 @@ s! { pub struct msghdr { pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, + pub msg_namelen: socklen_t, pub msg_iov: *mut crate::iovec, pub msg_iovlen: c_int, pub msg_control: *mut c_void, @@ -140,14 +136,14 @@ s! { // FIXME(1.0,deprecate,32): lfs binding to be removed. pub struct statvfs64 { - pub f_bsize: crate::blksize64_t, - pub f_frsize: crate::blksize64_t, - pub f_blocks: crate::blkcnt64_t, - pub f_bfree: crate::blkcnt64_t, - pub f_bavail: crate::blkcnt64_t, - pub f_files: crate::blkcnt64_t, - pub f_ffree: crate::blkcnt64_t, - pub f_favail: crate::blkcnt64_t, + pub f_bsize: blksize64_t, + pub f_frsize: blksize64_t, + pub f_blocks: blkcnt64_t, + pub f_bfree: blkcnt64_t, + pub f_bavail: blkcnt64_t, + pub f_files: blkcnt64_t, + pub f_ffree: blkcnt64_t, + pub f_favail: blkcnt64_t, pub f_fsid: fsid64_t, pub f_basetype: [c_char; 16], pub f_flag: c_ulong, @@ -204,13 +200,13 @@ s! { pub ai_protocol: c_int, pub ai_addrlen: c_ulong, pub ai_canonname: *mut c_char, - pub ai_addr: *mut crate::sockaddr, + pub ai_addr: *mut sockaddr, pub ai_next: *mut addrinfo, pub ai_eflags: c_int, } pub struct in_addr { - pub s_addr: in_addr_t, + pub s_addr: crate::in_addr_t, } pub struct ip_mreq_source { @@ -239,7 +235,7 @@ s! { pub struct sockaddr_in { pub sin_len: c_uchar, pub sin_family: sa_family_t, - pub sin_port: in_port_t, + pub sin_port: crate::in_port_t, pub sin_addr: in_addr, pub sin_zero: [c_uchar; 8], } @@ -247,17 +243,17 @@ s! { pub struct sockaddr_in6 { pub sin6_len: c_uchar, pub sin6_family: c_uchar, - pub sin6_port: crate::uint16_t, - pub sin6_flowinfo: crate::uint32_t, + pub sin6_port: u16, + pub sin6_flowinfo: u32, pub sin6_addr: crate::in6_addr, - pub sin6_scope_id: crate::uint32_t, + pub sin6_scope_id: u32, } pub struct sockaddr_storage { pub __ss_len: c_uchar, pub ss_family: sa_family_t, __ss_pad1: Padding<[c_char; 6]>, - __ss_align: crate::int64_t, + __ss_align: i64, __ss_pad2: Padding<[c_char; 1265]>, } @@ -268,7 +264,7 @@ s! { } pub struct st_timespec { - pub tv_sec: crate::time_t, + pub tv_sec: time_t, pub tv_nsec: c_int, } @@ -280,8 +276,8 @@ s! { pub f_blocks: blkcnt64_t, pub f_bfree: blkcnt64_t, pub f_bavail: blkcnt64_t, - pub f_files: crate::uint64_t, - pub f_ffree: crate::uint64_t, + pub f_files: u64, + pub f_ffree: u64, pub f_fsid: fsid64_t, pub f_vfstype: c_int, pub f_fsize: blksize64_t, @@ -319,7 +315,7 @@ s! { } pub struct cmsghdr { - pub cmsg_len: crate::socklen_t, + pub cmsg_len: socklen_t, pub cmsg_level: c_int, pub cmsg_type: c_int, } @@ -349,16 +345,16 @@ s! { pub header_data: *mut c_void, pub header_length: c_uint, pub file_descriptor: c_int, - pub file_size: crate::uint64_t, - pub file_offset: crate::uint64_t, - pub file_bytes: crate::int64_t, + pub file_size: u64, + pub file_offset: u64, + pub file_bytes: i64, pub trailer_data: *mut c_void, pub trailer_length: c_uint, - pub bytes_sent: crate::uint64_t, + pub bytes_sent: u64, } pub struct mmsghdr { - pub msg_hdr: crate::msghdr, + pub msg_hdr: msghdr, pub msg_len: c_uint, } @@ -378,8 +374,8 @@ s! { pub struct posix_spawnattr_t { pub posix_attr_flags: c_short, pub posix_attr_pgroup: crate::pid_t, - pub posix_attr_sigmask: crate::sigset_t, - pub posix_attr_sigdefault: crate::sigset_t, + pub posix_attr_sigmask: sigset_t, + pub posix_attr_sigdefault: sigset_t, pub posix_attr_schedpolicy: c_int, pub posix_attr_schedparam: sched_param, } @@ -435,7 +431,7 @@ s! { pub re_cflags: c_int, pub re_erroff: size_t, pub re_len: size_t, - pub re_ucoll: [crate::wchar_t; 2], + pub re_ucoll: [wchar_t; 2], pub re_lsub: [*mut c_void; 24], pub re_esub: [*mut c_void; 24], pub re_map: *mut c_uchar, @@ -459,12 +455,12 @@ s! { pub shm_atime: time_t, pub shm_dtime: time_t, pub shm_ctime: time_t, - pub shm_handle: crate::uint32_t, + pub shm_handle: u32, pub shm_extshm: c_int, - pub shm_pagesize: crate::int64_t, - pub shm_lba: crate::uint64_t, - shm_reserved0: Padding, - shm_reserved1: Padding, + pub shm_pagesize: i64, + pub shm_lba: u64, + shm_reserved0: Padding, + shm_reserved1: Padding, } // FIXME(1.0,deprecate): lfs binding to be removed @@ -665,63 +661,63 @@ pub const GLOB_NOMATCH: c_int = 0x4000; pub const GLOB_NOSYS: c_int = 0x8000; // langinfo.h -pub const DAY_1: crate::nl_item = 13; -pub const DAY_2: crate::nl_item = 14; -pub const DAY_3: crate::nl_item = 15; -pub const DAY_4: crate::nl_item = 16; -pub const DAY_5: crate::nl_item = 17; -pub const DAY_6: crate::nl_item = 18; -pub const DAY_7: crate::nl_item = 19; -pub const ABDAY_1: crate::nl_item = 6; -pub const ABDAY_2: crate::nl_item = 7; -pub const ABDAY_3: crate::nl_item = 8; -pub const ABDAY_4: crate::nl_item = 9; -pub const ABDAY_5: crate::nl_item = 10; -pub const ABDAY_6: crate::nl_item = 11; -pub const ABDAY_7: crate::nl_item = 12; -pub const MON_1: crate::nl_item = 32; -pub const MON_2: crate::nl_item = 33; -pub const MON_3: crate::nl_item = 34; -pub const MON_4: crate::nl_item = 35; -pub const MON_5: crate::nl_item = 36; -pub const MON_6: crate::nl_item = 37; -pub const MON_7: crate::nl_item = 38; -pub const MON_8: crate::nl_item = 39; -pub const MON_9: crate::nl_item = 40; -pub const MON_10: crate::nl_item = 41; -pub const MON_11: crate::nl_item = 42; -pub const MON_12: crate::nl_item = 43; -pub const ABMON_1: crate::nl_item = 20; -pub const ABMON_2: crate::nl_item = 21; -pub const ABMON_3: crate::nl_item = 22; -pub const ABMON_4: crate::nl_item = 23; -pub const ABMON_5: crate::nl_item = 24; -pub const ABMON_6: crate::nl_item = 25; -pub const ABMON_7: crate::nl_item = 26; -pub const ABMON_8: crate::nl_item = 27; -pub const ABMON_9: crate::nl_item = 28; -pub const ABMON_10: crate::nl_item = 29; -pub const ABMON_11: crate::nl_item = 30; -pub const ABMON_12: crate::nl_item = 31; -pub const RADIXCHAR: crate::nl_item = 44; -pub const THOUSEP: crate::nl_item = 45; -pub const YESSTR: crate::nl_item = 46; -pub const NOSTR: crate::nl_item = 47; -pub const CRNCYSTR: crate::nl_item = 48; -pub const D_T_FMT: crate::nl_item = 1; -pub const D_FMT: crate::nl_item = 2; -pub const T_FMT: crate::nl_item = 3; -pub const AM_STR: crate::nl_item = 4; -pub const PM_STR: crate::nl_item = 5; -pub const CODESET: crate::nl_item = 49; -pub const T_FMT_AMPM: crate::nl_item = 55; -pub const ERA: crate::nl_item = 56; -pub const ERA_D_FMT: crate::nl_item = 57; -pub const ERA_D_T_FMT: crate::nl_item = 58; -pub const ERA_T_FMT: crate::nl_item = 59; -pub const ALT_DIGITS: crate::nl_item = 60; -pub const YESEXPR: crate::nl_item = 61; -pub const NOEXPR: crate::nl_item = 62; +pub const DAY_1: nl_item = 13; +pub const DAY_2: nl_item = 14; +pub const DAY_3: nl_item = 15; +pub const DAY_4: nl_item = 16; +pub const DAY_5: nl_item = 17; +pub const DAY_6: nl_item = 18; +pub const DAY_7: nl_item = 19; +pub const ABDAY_1: nl_item = 6; +pub const ABDAY_2: nl_item = 7; +pub const ABDAY_3: nl_item = 8; +pub const ABDAY_4: nl_item = 9; +pub const ABDAY_5: nl_item = 10; +pub const ABDAY_6: nl_item = 11; +pub const ABDAY_7: nl_item = 12; +pub const MON_1: nl_item = 32; +pub const MON_2: nl_item = 33; +pub const MON_3: nl_item = 34; +pub const MON_4: nl_item = 35; +pub const MON_5: nl_item = 36; +pub const MON_6: nl_item = 37; +pub const MON_7: nl_item = 38; +pub const MON_8: nl_item = 39; +pub const MON_9: nl_item = 40; +pub const MON_10: nl_item = 41; +pub const MON_11: nl_item = 42; +pub const MON_12: nl_item = 43; +pub const ABMON_1: nl_item = 20; +pub const ABMON_2: nl_item = 21; +pub const ABMON_3: nl_item = 22; +pub const ABMON_4: nl_item = 23; +pub const ABMON_5: nl_item = 24; +pub const ABMON_6: nl_item = 25; +pub const ABMON_7: nl_item = 26; +pub const ABMON_8: nl_item = 27; +pub const ABMON_9: nl_item = 28; +pub const ABMON_10: nl_item = 29; +pub const ABMON_11: nl_item = 30; +pub const ABMON_12: nl_item = 31; +pub const RADIXCHAR: nl_item = 44; +pub const THOUSEP: nl_item = 45; +pub const YESSTR: nl_item = 46; +pub const NOSTR: nl_item = 47; +pub const CRNCYSTR: nl_item = 48; +pub const D_T_FMT: nl_item = 1; +pub const D_FMT: nl_item = 2; +pub const T_FMT: nl_item = 3; +pub const AM_STR: nl_item = 4; +pub const PM_STR: nl_item = 5; +pub const CODESET: nl_item = 49; +pub const T_FMT_AMPM: nl_item = 55; +pub const ERA: nl_item = 56; +pub const ERA_D_FMT: nl_item = 57; +pub const ERA_D_T_FMT: nl_item = 58; +pub const ERA_T_FMT: nl_item = 59; +pub const ALT_DIGITS: nl_item = 60; +pub const YESEXPR: nl_item = 61; +pub const NOEXPR: nl_item = 62; // locale.h pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t; @@ -746,14 +742,14 @@ pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK | LC_TIME_MASK; // netdb.h -pub const NI_MAXHOST: crate::socklen_t = 1025; -pub const NI_MAXSERV: crate::socklen_t = 32; -pub const NI_NOFQDN: crate::socklen_t = 0x1; -pub const NI_NUMERICHOST: crate::socklen_t = 0x2; -pub const NI_NAMEREQD: crate::socklen_t = 0x4; -pub const NI_NUMERICSERV: crate::socklen_t = 0x8; -pub const NI_DGRAM: crate::socklen_t = 0x10; -pub const NI_NUMERICSCOPE: crate::socklen_t = 0x40; +pub const NI_MAXHOST: socklen_t = 1025; +pub const NI_MAXSERV: socklen_t = 32; +pub const NI_NOFQDN: socklen_t = 0x1; +pub const NI_NUMERICHOST: socklen_t = 0x2; +pub const NI_NAMEREQD: socklen_t = 0x4; +pub const NI_NUMERICSERV: socklen_t = 0x8; +pub const NI_DGRAM: socklen_t = 0x10; +pub const NI_NUMERICSCOPE: socklen_t = 0x40; pub const EAI_AGAIN: c_int = 2; pub const EAI_BADFLAGS: c_int = 3; pub const EAI_FAIL: c_int = 4; @@ -1157,7 +1153,7 @@ pub const NFSMNT_ACDIRMAX: c_int = 0x0800; pub const CPUSTATES: c_int = 4; // semaphore.h -pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t; +pub const SEM_FAILED: *mut sem_t = -1isize as *mut sem_t; // spawn.h // DIFF(main): changed to `c_short` in f62eb023ab @@ -1443,7 +1439,7 @@ pub const IPC_W: c_int = 0o0200; pub const IPC_O: c_int = 0o1000; pub const IPC_NOERROR: c_int = 0o10000; pub const IPC_STAT: c_int = 102; -pub const IPC_PRIVATE: crate::key_t = -1; +pub const IPC_PRIVATE: key_t = -1; pub const SHM_LOCK: c_int = 201; pub const SHM_UNLOCK: c_int = 202; @@ -2087,8 +2083,8 @@ pub const POWER_9: c_int = 0x20000; // sys/time.h pub const FD_SETSIZE: usize = 65534; pub const TIMEOFDAY: c_int = 9; -pub const CLOCK_REALTIME: crate::clockid_t = TIMEOFDAY as clockid_t; -pub const CLOCK_MONOTONIC: crate::clockid_t = 10; +pub const CLOCK_REALTIME: clockid_t = TIMEOFDAY as clockid_t; +pub const CLOCK_MONOTONIC: clockid_t = 10; pub const TIMER_ABSTIME: c_int = 999; pub const ITIMER_REAL: c_int = 0; pub const ITIMER_VIRTUAL: c_int = 1; @@ -2105,8 +2101,8 @@ pub const DST_USA: c_int = 1; pub const DST_WET: c_int = 3; // sys/termio.h -pub const CSTART: crate::tcflag_t = 0o21; -pub const CSTOP: crate::tcflag_t = 0o23; +pub const CSTART: tcflag_t = 0o21; +pub const CSTOP: tcflag_t = 0o23; pub const TCGETA: c_int = TIOC | 5; pub const TCSETA: c_int = TIOC | 6; pub const TCSETAW: c_int = TIOC | 7; @@ -2182,44 +2178,44 @@ pub const _W_STRC: c_int = 0x0000007f; // termios.h pub const NCCS: usize = 16; -pub const OLCUC: crate::tcflag_t = 2; -pub const CSIZE: crate::tcflag_t = 0x00000030; -pub const CS5: crate::tcflag_t = 0x00000000; -pub const CS6: crate::tcflag_t = 0x00000010; -pub const CS7: crate::tcflag_t = 0x00000020; -pub const CS8: crate::tcflag_t = 0x00000030; -pub const CSTOPB: crate::tcflag_t = 0x00000040; -pub const ECHO: crate::tcflag_t = 0x00000008; -pub const ECHOE: crate::tcflag_t = 0x00000010; -pub const ECHOK: crate::tcflag_t = 0x00000020; -pub const ECHONL: crate::tcflag_t = 0x00000040; -pub const ECHOCTL: crate::tcflag_t = 0x00020000; -pub const ECHOPRT: crate::tcflag_t = 0x00040000; -pub const ECHOKE: crate::tcflag_t = 0x00080000; -pub const IGNBRK: crate::tcflag_t = 0x00000001; -pub const BRKINT: crate::tcflag_t = 0x00000002; -pub const IGNPAR: crate::tcflag_t = 0x00000004; -pub const PARMRK: crate::tcflag_t = 0x00000008; -pub const INPCK: crate::tcflag_t = 0x00000010; -pub const ISTRIP: crate::tcflag_t = 0x00000020; -pub const INLCR: crate::tcflag_t = 0x00000040; -pub const IGNCR: crate::tcflag_t = 0x00000080; -pub const ICRNL: crate::tcflag_t = 0x00000100; -pub const IXON: crate::tcflag_t = 0x00000200; -pub const IXOFF: crate::tcflag_t = 0x00000400; -pub const IXANY: crate::tcflag_t = 0x00001000; -pub const IMAXBEL: crate::tcflag_t = 0x00010000; -pub const OPOST: crate::tcflag_t = 0x00000001; -pub const ONLCR: crate::tcflag_t = 0x00000004; -pub const OCRNL: crate::tcflag_t = 0x00000008; -pub const ONOCR: crate::tcflag_t = 0x00000010; -pub const ONLRET: crate::tcflag_t = 0x00000020; -pub const CREAD: crate::tcflag_t = 0x00000080; -pub const IEXTEN: crate::tcflag_t = 0x00200000; -pub const TOSTOP: crate::tcflag_t = 0x00010000; -pub const FLUSHO: crate::tcflag_t = 0x00100000; -pub const PENDIN: crate::tcflag_t = 0x20000000; -pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const OLCUC: tcflag_t = 2; +pub const CSIZE: tcflag_t = 0x00000030; +pub const CS5: tcflag_t = 0x00000000; +pub const CS6: tcflag_t = 0x00000010; +pub const CS7: tcflag_t = 0x00000020; +pub const CS8: tcflag_t = 0x00000030; +pub const CSTOPB: tcflag_t = 0x00000040; +pub const ECHO: tcflag_t = 0x00000008; +pub const ECHOE: tcflag_t = 0x00000010; +pub const ECHOK: tcflag_t = 0x00000020; +pub const ECHONL: tcflag_t = 0x00000040; +pub const ECHOCTL: tcflag_t = 0x00020000; +pub const ECHOPRT: tcflag_t = 0x00040000; +pub const ECHOKE: tcflag_t = 0x00080000; +pub const IGNBRK: tcflag_t = 0x00000001; +pub const BRKINT: tcflag_t = 0x00000002; +pub const IGNPAR: tcflag_t = 0x00000004; +pub const PARMRK: tcflag_t = 0x00000008; +pub const INPCK: tcflag_t = 0x00000010; +pub const ISTRIP: tcflag_t = 0x00000020; +pub const INLCR: tcflag_t = 0x00000040; +pub const IGNCR: tcflag_t = 0x00000080; +pub const ICRNL: tcflag_t = 0x00000100; +pub const IXON: tcflag_t = 0x00000200; +pub const IXOFF: tcflag_t = 0x00000400; +pub const IXANY: tcflag_t = 0x00001000; +pub const IMAXBEL: tcflag_t = 0x00010000; +pub const OPOST: tcflag_t = 0x00000001; +pub const ONLCR: tcflag_t = 0x00000004; +pub const OCRNL: tcflag_t = 0x00000008; +pub const ONOCR: tcflag_t = 0x00000010; +pub const ONLRET: tcflag_t = 0x00000020; +pub const CREAD: tcflag_t = 0x00000080; +pub const IEXTEN: tcflag_t = 0x00200000; +pub const TOSTOP: tcflag_t = 0x00010000; +pub const FLUSHO: tcflag_t = 0x00100000; +pub const PENDIN: tcflag_t = 0x20000000; +pub const NOFLSH: tcflag_t = 0x00000080; pub const VINTR: usize = 0; pub const VQUIT: usize = 1; pub const VERASE: usize = 2; @@ -2237,67 +2233,67 @@ pub const VREPRINT: usize = 11; pub const VDISCRD: usize = 12; pub const VWERSE: usize = 13; pub const VLNEXT: usize = 14; -pub const B0: crate::speed_t = 0x0; -pub const B50: crate::speed_t = 0x1; -pub const B75: crate::speed_t = 0x2; -pub const B110: crate::speed_t = 0x3; -pub const B134: crate::speed_t = 0x4; -pub const B150: crate::speed_t = 0x5; -pub const B200: crate::speed_t = 0x6; -pub const B300: crate::speed_t = 0x7; -pub const B600: crate::speed_t = 0x8; -pub const B1200: crate::speed_t = 0x9; -pub const B1800: crate::speed_t = 0xa; -pub const B2400: crate::speed_t = 0xb; -pub const B4800: crate::speed_t = 0xc; -pub const B9600: crate::speed_t = 0xd; -pub const B19200: crate::speed_t = 0xe; -pub const B38400: crate::speed_t = 0xf; -pub const EXTA: crate::speed_t = B19200; -pub const EXTB: crate::speed_t = B38400; -pub const IUCLC: crate::tcflag_t = 0x00000800; -pub const OFILL: crate::tcflag_t = 0x00000040; -pub const OFDEL: crate::tcflag_t = 0x00000080; -pub const CRDLY: crate::tcflag_t = 0x00000300; -pub const CR0: crate::tcflag_t = 0x00000000; -pub const CR1: crate::tcflag_t = 0x00000100; -pub const CR2: crate::tcflag_t = 0x00000200; -pub const CR3: crate::tcflag_t = 0x00000300; -pub const TABDLY: crate::tcflag_t = 0x00000c00; -pub const TAB0: crate::tcflag_t = 0x00000000; -pub const TAB1: crate::tcflag_t = 0x00000400; -pub const TAB2: crate::tcflag_t = 0x00000800; -pub const TAB3: crate::tcflag_t = 0x00000c00; -pub const BSDLY: crate::tcflag_t = 0x00001000; -pub const BS0: crate::tcflag_t = 0x00000000; -pub const BS1: crate::tcflag_t = 0x00001000; -pub const FFDLY: crate::tcflag_t = 0x00002000; -pub const FF0: crate::tcflag_t = 0x00000000; -pub const FF1: crate::tcflag_t = 0x00002000; -pub const NLDLY: crate::tcflag_t = 0x00004000; -pub const NL0: crate::tcflag_t = 0x00000000; -pub const NL1: crate::tcflag_t = 0x00004000; -pub const VTDLY: crate::tcflag_t = 0x00008000; -pub const VT0: crate::tcflag_t = 0x00000000; -pub const VT1: crate::tcflag_t = 0x00008000; -pub const OXTABS: crate::tcflag_t = 0x00040000; -pub const ONOEOT: crate::tcflag_t = 0x00080000; -pub const CBAUD: crate::tcflag_t = 0x0000000f; -pub const PARENB: crate::tcflag_t = 0x00000100; -pub const PARODD: crate::tcflag_t = 0x00000200; -pub const HUPCL: crate::tcflag_t = 0x00000400; -pub const CLOCAL: crate::tcflag_t = 0x00000800; -pub const CIBAUD: crate::tcflag_t = 0x000f0000; -pub const IBSHIFT: crate::tcflag_t = 16; -pub const PAREXT: crate::tcflag_t = 0x00100000; -pub const ISIG: crate::tcflag_t = 0x00000001; -pub const ICANON: crate::tcflag_t = 0x00000002; -pub const XCASE: crate::tcflag_t = 0x00000004; -pub const ALTWERASE: crate::tcflag_t = 0x00400000; +pub const B0: speed_t = 0x0; +pub const B50: speed_t = 0x1; +pub const B75: speed_t = 0x2; +pub const B110: speed_t = 0x3; +pub const B134: speed_t = 0x4; +pub const B150: speed_t = 0x5; +pub const B200: speed_t = 0x6; +pub const B300: speed_t = 0x7; +pub const B600: speed_t = 0x8; +pub const B1200: speed_t = 0x9; +pub const B1800: speed_t = 0xa; +pub const B2400: speed_t = 0xb; +pub const B4800: speed_t = 0xc; +pub const B9600: speed_t = 0xd; +pub const B19200: speed_t = 0xe; +pub const B38400: speed_t = 0xf; +pub const EXTA: speed_t = B19200; +pub const EXTB: speed_t = B38400; +pub const IUCLC: tcflag_t = 0x00000800; +pub const OFILL: tcflag_t = 0x00000040; +pub const OFDEL: tcflag_t = 0x00000080; +pub const CRDLY: tcflag_t = 0x00000300; +pub const CR0: tcflag_t = 0x00000000; +pub const CR1: tcflag_t = 0x00000100; +pub const CR2: tcflag_t = 0x00000200; +pub const CR3: tcflag_t = 0x00000300; +pub const TABDLY: tcflag_t = 0x00000c00; +pub const TAB0: tcflag_t = 0x00000000; +pub const TAB1: tcflag_t = 0x00000400; +pub const TAB2: tcflag_t = 0x00000800; +pub const TAB3: tcflag_t = 0x00000c00; +pub const BSDLY: tcflag_t = 0x00001000; +pub const BS0: tcflag_t = 0x00000000; +pub const BS1: tcflag_t = 0x00001000; +pub const FFDLY: tcflag_t = 0x00002000; +pub const FF0: tcflag_t = 0x00000000; +pub const FF1: tcflag_t = 0x00002000; +pub const NLDLY: tcflag_t = 0x00004000; +pub const NL0: tcflag_t = 0x00000000; +pub const NL1: tcflag_t = 0x00004000; +pub const VTDLY: tcflag_t = 0x00008000; +pub const VT0: tcflag_t = 0x00000000; +pub const VT1: tcflag_t = 0x00008000; +pub const OXTABS: tcflag_t = 0x00040000; +pub const ONOEOT: tcflag_t = 0x00080000; +pub const CBAUD: tcflag_t = 0x0000000f; +pub const PARENB: tcflag_t = 0x00000100; +pub const PARODD: tcflag_t = 0x00000200; +pub const HUPCL: tcflag_t = 0x00000400; +pub const CLOCAL: tcflag_t = 0x00000800; +pub const CIBAUD: tcflag_t = 0x000f0000; +pub const IBSHIFT: tcflag_t = 16; +pub const PAREXT: tcflag_t = 0x00100000; +pub const ISIG: tcflag_t = 0x00000001; +pub const ICANON: tcflag_t = 0x00000002; +pub const XCASE: tcflag_t = 0x00000004; +pub const ALTWERASE: tcflag_t = 0x00400000; // time.h -pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 11; -pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 12; +pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 11; +pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 12; // unistd.h pub const _POSIX_VDISABLE: c_int = 0xff; @@ -2484,7 +2480,8 @@ f! { { ptr::null_mut() } else { - // AIX does not have any alignment/padding for ancillary data, so we don't need _CMSG_ALIGN here. + // AIX does not have any alignment/padding for ancillary data, + // so we don't need _CMSG_ALIGN here. (cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr } } @@ -2571,19 +2568,19 @@ f! { false } - pub const safe fn major(dev: crate::dev_t) -> c_uint { + pub const safe fn major(dev: dev_t) -> c_uint { let x = dev >> 16; x as c_uint } - pub const safe fn minor(dev: crate::dev_t) -> c_uint { + pub const safe fn minor(dev: dev_t) -> c_uint { let y = dev & 0xFFFF; y as c_uint } - pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { - let major = major as crate::dev_t; - let minor = minor as crate::dev_t; + pub const safe 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 << 16; dev |= minor; @@ -2606,85 +2603,70 @@ extern "C" { ) -> c_int; pub fn pthread_attr_getdetachstate( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, detachstate: *mut c_int, ) -> c_int; - pub fn pthread_attr_getguardsize( - attr: *const crate::pthread_attr_t, - guardsize: *mut size_t, - ) -> c_int; + pub fn pthread_attr_getguardsize(attr: *const pthread_attr_t, guardsize: *mut size_t) -> c_int; pub fn pthread_attr_getinheritsched( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, inheritsched: *mut c_int, ) -> c_int; pub fn pthread_attr_getschedparam( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, param: *mut sched_param, ) -> c_int; pub fn pthread_attr_getstackaddr( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, stackaddr: *mut *mut c_void, ) -> c_int; - pub fn pthread_attr_getschedpolicy( - attr: *const crate::pthread_attr_t, - policy: *mut c_int, - ) -> c_int; + pub fn pthread_attr_getschedpolicy(attr: *const pthread_attr_t, policy: *mut c_int) -> c_int; - pub fn pthread_attr_getscope( - attr: *const crate::pthread_attr_t, - contentionscope: *mut c_int, - ) -> c_int; + pub fn pthread_attr_getscope(attr: *const pthread_attr_t, contentionscope: *mut c_int) + -> c_int; pub fn pthread_attr_getstack( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, stackaddr: *mut *mut c_void, stacksize: *mut size_t, ) -> c_int; - pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut pthread_attr_t, guardsize: size_t) -> c_int; - pub fn pthread_attr_setinheritsched( - attr: *mut crate::pthread_attr_t, - inheritsched: c_int, - ) -> c_int; + pub fn pthread_attr_setinheritsched(attr: *mut pthread_attr_t, inheritsched: c_int) -> c_int; pub fn pthread_attr_setschedparam( - attr: *mut crate::pthread_attr_t, + attr: *mut pthread_attr_t, param: *const sched_param, ) -> c_int; - pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; + pub fn pthread_attr_setschedpolicy(attr: *mut pthread_attr_t, policy: c_int) -> c_int; - pub fn pthread_attr_setscope(attr: *mut crate::pthread_attr_t, contentionscope: c_int) - -> c_int; + pub fn pthread_attr_setscope(attr: *mut pthread_attr_t, contentionscope: c_int) -> c_int; pub fn pthread_attr_setstack( - attr: *mut crate::pthread_attr_t, + attr: *mut pthread_attr_t, stackaddr: *mut c_void, stacksize: size_t, ) -> c_int; - pub fn pthread_attr_setstackaddr( - attr: *mut crate::pthread_attr_t, - stackaddr: *mut c_void, - ) -> c_int; + pub fn pthread_attr_setstackaddr(attr: *mut pthread_attr_t, stackaddr: *mut c_void) -> c_int; - pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_destroy(attr: *mut pthread_barrierattr_t) -> c_int; pub fn pthread_barrierattr_getpshared( - attr: *const crate::pthread_barrierattr_t, + attr: *const pthread_barrierattr_t, pshared: *mut c_int, ) -> c_int; - pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_init(attr: *mut pthread_barrierattr_t) -> c_int; pub fn pthread_barrierattr_setpshared( - attr: *mut crate::pthread_barrierattr_t, + attr: *mut pthread_barrierattr_t, pshared: c_int, ) -> c_int; @@ -2692,13 +2674,13 @@ extern "C" { pub fn pthread_barrier_init( barrier: *mut pthread_barrier_t, - attr: *const crate::pthread_barrierattr_t, + attr: *const pthread_barrierattr_t, count: c_uint, ) -> c_int; pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; - pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + pub fn pthread_cancel(thread: pthread_t) -> c_int; pub fn pthread_cleanup_pop(execute: c_int); @@ -2717,37 +2699,31 @@ extern "C" { pshared: *mut c_int, ) -> c_int; - pub fn pthread_condattr_setclock( - attr: *mut pthread_condattr_t, - clock_id: crate::clockid_t, - ) -> c_int; + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> c_int; pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; pub fn pthread_create( - thread: *mut crate::pthread_t, - attr: *const crate::pthread_attr_t, + thread: *mut pthread_t, + attr: *const pthread_attr_t, start_routine: extern "C" fn(*mut c_void) -> *mut c_void, arg: *mut c_void, ) -> c_int; pub fn pthread_getconcurrency() -> c_int; - pub fn pthread_getcpuclockid( - thread_id: crate::pthread_t, - clock_id: *mut crate::clockid_t, - ) -> c_int; + pub fn pthread_getcpuclockid(thread_id: pthread_t, clock_id: *mut clockid_t) -> c_int; pub fn pthread_getschedparam( - thread: crate::pthread_t, + thread: pthread_t, policy: *mut c_int, param: *mut sched_param, ) -> c_int; - pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn pthread_kill(thread: pthread_t, sig: c_int) -> c_int; pub fn pthread_mutexattr_getprioceiling( - attr: *const crate::pthread_mutexattr_t, + attr: *const pthread_mutexattr_t, prioceiling: *mut c_int, ) -> c_int; @@ -2762,17 +2738,14 @@ extern "C" { ) -> c_int; pub fn pthread_mutexattr_getrobust( - attr: *const crate::pthread_mutexattr_t, + attr: *const pthread_mutexattr_t, robust: *mut c_int, ) -> c_int; - pub fn pthread_mutexattr_gettype( - attr: *const crate::pthread_mutexattr_t, - _type: *mut c_int, - ) -> c_int; + pub fn pthread_mutexattr_gettype(attr: *const pthread_mutexattr_t, _type: *mut c_int) -> c_int; pub fn pthread_mutexattr_setprioceiling( - attr: *mut crate::pthread_mutexattr_t, + attr: *mut pthread_mutexattr_t, prioceiling: c_int, ) -> c_int; @@ -2780,20 +2753,17 @@ extern "C" { pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; - pub fn pthread_mutexattr_setrobust( - attr: *mut crate::pthread_mutexattr_t, - robust: c_int, - ) -> c_int; + pub fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robust: c_int) -> c_int; - pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> c_int; pub fn pthread_mutex_getprioceiling( - mutex: *const crate::pthread_mutex_t, + mutex: *const pthread_mutex_t, prioceiling: *mut c_int, ) -> c_int; pub fn pthread_mutex_setprioceiling( - mutex: *mut crate::pthread_mutex_t, + mutex: *mut pthread_mutex_t, prioceiling: c_int, old_ceiling: *mut c_int, ) -> c_int; @@ -2804,7 +2774,7 @@ extern "C" { ) -> c_int; pub fn pthread_once( - once_control: *mut crate::pthread_once_t, + once_control: *mut pthread_once_t, init_routine: Option, ) -> c_int; @@ -2816,12 +2786,12 @@ extern "C" { pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, pshared: c_int) -> c_int; pub fn pthread_rwlock_timedrdlock( - rwlock: *mut crate::pthread_rwlock_t, + rwlock: *mut pthread_rwlock_t, abstime: *const crate::timespec, ) -> c_int; pub fn pthread_rwlock_timedwrlock( - rwlock: *mut crate::pthread_rwlock_t, + rwlock: *mut pthread_rwlock_t, abstime: *const crate::timespec, ) -> c_int; @@ -2831,12 +2801,12 @@ extern "C" { pub fn pthread_setconcurrency(new_level: c_int) -> c_int; pub fn pthread_setschedparam( - thread: crate::pthread_t, + thread: pthread_t, policy: c_int, param: *const sched_param, ) -> c_int; - pub fn pthread_setschedprio(thread: crate::pthread_t, prio: c_int) -> c_int; + pub fn pthread_setschedprio(thread: pthread_t, prio: c_int) -> c_int; pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int; @@ -2865,41 +2835,37 @@ extern "C" { extern "C" { pub fn acct(filename: *mut c_char) -> c_int; #[link_name = "_posix_aio_cancel"] - pub fn aio_cancel(fildes: c_int, aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_cancel(fildes: c_int, aiocbp: *mut aiocb) -> c_int; #[link_name = "_posix_aio_error"] - pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; #[link_name = "_posix_aio_fsync"] - pub fn aio_fsync(op: c_int, aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; #[link_name = "_posix_aio_read"] - pub fn aio_read(aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; #[link_name = "_posix_aio_return"] - pub fn aio_return(aiocbp: *mut crate::aiocb) -> ssize_t; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; #[link_name = "_posix_aio_suspend"] pub fn aio_suspend( - list: *const *const crate::aiocb, + list: *const *const aiocb, nent: c_int, timeout: *const crate::timespec, ) -> c_int; #[link_name = "_posix_aio_write"] - pub fn aio_write(aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; pub fn basename(path: *mut c_char) -> *mut c_char; - pub fn bind( - socket: c_int, - address: *const crate::sockaddr, - address_len: crate::socklen_t, - ) -> c_int; + pub fn bind(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int; pub fn brk(addr: *mut c_void) -> c_int; pub fn clearenv() -> c_int; - pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; - pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; - pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut clockid_t) -> c_int; + pub fn clock_getres(clk_id: clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_nanosleep( - clk_id: crate::clockid_t, + clk_id: clockid_t, flags: c_int, rqtp: *const crate::timespec, rmtp: *mut crate::timespec, ) -> c_int; - pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn clock_settime(clock_id: clockid_t, tp: *const crate::timespec) -> c_int; pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; pub fn ctermid(s: *mut c_char) -> *mut c_char; pub fn dirfd(dirp: *mut crate::DIR) -> c_int; @@ -2925,7 +2891,7 @@ extern "C" { pub fn fgetgrent(file: *mut crate::FILE) -> *mut crate::group; // FIXME(1.0,deprecate): lfs binding to be removed pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; - pub fn fgetpwent(file: *mut crate::FILE) -> *mut crate::passwd; + pub fn fgetpwent(file: *mut crate::FILE) -> *mut passwd; // FIXME(1.0,deprecate): lfs binding to be removed pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn freelocale(loc: crate::locale_t); @@ -2948,7 +2914,7 @@ extern "C" { pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftello64(stream: *mut crate::FILE) -> off64_t; - pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t; + pub fn ftok(path: *const c_char, id: c_int) -> key_t; // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; @@ -2976,9 +2942,9 @@ extern "C" { ) -> c_int; pub fn getgrset(user: *const c_char) -> *mut c_char; pub fn gethostid() -> c_long; - pub fn getmntent(stream: *mut crate::FILE) -> *mut crate::mntent; + pub fn getmntent(stream: *mut crate::FILE) -> *mut mntent; pub fn getnameinfo( - sa: *const crate::sockaddr, + sa: *const sockaddr, salen: size_t, host: *mut c_char, hostlen: size_t, @@ -2988,8 +2954,8 @@ extern "C" { ) -> c_int; pub fn getpagesize() -> c_int; pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; - pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; - pub fn getpwent() -> *mut crate::passwd; + pub fn getpriority(which: c_int, who: id_t) -> c_int; + pub fn getpwent() -> *mut passwd; #[link_name = "_posix_getpwnam_r"] pub fn getpwnam_r( name: *const c_char, @@ -3021,10 +2987,10 @@ extern "C" { pattern: *const c_char, flags: c_int, errfunc: Option c_int>, - pglob: *mut crate::glob_t, + pglob: *mut glob_t, ) -> c_int; - pub fn globfree(pglob: *mut crate::glob_t); - pub fn hasmntopt(mnt: *const crate::mntent, opt: *const c_char) -> *mut c_char; + pub fn globfree(pglob: *mut glob_t); + pub fn hasmntopt(mnt: *const mntent, opt: *const c_char) -> *mut c_char; pub fn hcreate(nelt: size_t) -> c_int; pub fn hdestroy(); pub fn hsearch(entry: entry, action: ACTION) -> *mut entry; @@ -3064,8 +3030,8 @@ extern "C" { // FIXME(1.0,deprecate): lfs binding to be removed pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn madvise(addr: caddr_t, len: size_t, advice: c_int) -> c_int; - pub fn makecontext(ucp: *mut crate::ucontext_t, func: extern "C" fn(), argc: c_int, ...); - pub fn mallinfo() -> crate::mallinfo; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); + pub fn mallinfo() -> mallinfo; pub fn mallopt(param: c_int, value: c_int) -> c_int; pub fn memmem( haystack: *const c_void, @@ -3079,36 +3045,27 @@ extern "C" { pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int; pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn mq_close(mqd: crate::mqd_t) -> c_int; - pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; - pub fn mq_notify(mqd: crate::mqd_t, notification: *const crate::sigevent) -> c_int; - pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_close(mqd: mqd_t) -> c_int; + pub fn mq_getattr(mqd: mqd_t, attr: *mut mq_attr) -> c_int; + pub fn mq_notify(mqd: mqd_t, notification: *const sigevent) -> c_int; + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> mqd_t; pub fn mq_receive( - mqd: crate::mqd_t, + mqd: mqd_t, msg_ptr: *mut c_char, msg_len: size_t, msg_prio: *mut c_uint, ) -> ssize_t; - pub fn mq_send( - mqd: crate::mqd_t, - msg_ptr: *const c_char, - msg_len: size_t, - msg_prio: c_uint, - ) -> c_int; - pub fn mq_setattr( - mqd: crate::mqd_t, - newattr: *const crate::mq_attr, - oldattr: *mut crate::mq_attr, - ) -> c_int; + pub fn mq_send(mqd: mqd_t, msg_ptr: *const c_char, msg_len: size_t, msg_prio: c_uint) -> c_int; + pub fn mq_setattr(mqd: mqd_t, newattr: *const mq_attr, oldattr: *mut mq_attr) -> c_int; pub fn mq_timedreceive( - mqd: crate::mqd_t, + mqd: mqd_t, msg_ptr: *mut c_char, msg_len: size_t, msg_prio: *mut c_uint, abs_timeout: *const crate::timespec, ) -> ssize_t; pub fn mq_timedsend( - mqd: crate::mqd_t, + mqd: mqd_t, msg_ptr: *const c_char, msg_len: size_t, msg_prio: c_uint, @@ -3117,7 +3074,7 @@ extern "C" { pub fn mq_unlink(name: *const c_char) -> c_int; pub fn mrand48() -> c_long; pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int; - pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; + pub fn msgget(key: key_t, msgflg: c_int) -> c_int; pub fn msgrcv( msqid: c_int, msgp: *mut c_void, @@ -3128,8 +3085,8 @@ extern "C" { pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int; pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; - pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; - pub fn nl_langinfo_l(item: crate::nl_item, loc: crate::locale_t) -> *mut c_char; + pub fn nl_langinfo(item: nl_item) -> *mut c_char; + pub fn nl_langinfo_l(item: nl_item, loc: crate::locale_t) -> *mut c_char; pub fn nrand48(xseed: *mut c_ushort) -> c_long; // FIXME(1.0,deprecate): lfs binding to be removed pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; @@ -3146,16 +3103,16 @@ extern "C" { pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed - pub fn posix_fadvise64(fd: c_int, offset: off64_t, len: off64_t, advise: c_int) -> c_int; + pub fn posix_fadvise64(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed - pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn posix_fallocate64(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; pub fn posix_spawn( pid: *mut crate::pid_t, path: *const c_char, - file_actions: *const crate::posix_spawn_file_actions_t, - attrp: *const crate::posix_spawnattr_t, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, argv: *const *mut c_char, envp: *const *mut c_char, ) -> c_int; @@ -3185,7 +3142,7 @@ extern "C" { ) -> c_int; pub fn posix_spawnattr_getschedparam( attr: *const posix_spawnattr_t, - param: *mut crate::sched_param, + param: *mut sched_param, ) -> c_int; pub fn posix_spawnattr_getschedpolicy( attr: *const posix_spawnattr_t, @@ -3204,22 +3161,22 @@ extern "C" { pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; pub fn posix_spawnattr_setschedparam( attr: *mut posix_spawnattr_t, - param: *const crate::sched_param, + param: *const sched_param, ) -> c_int; pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; pub fn posix_spawnattr_setsigdefault( attr: *mut posix_spawnattr_t, - default: *const crate::sigset_t, + default: *const sigset_t, ) -> c_int; pub fn posix_spawnattr_setsigmask( attr: *mut posix_spawnattr_t, - default: *const crate::sigset_t, + default: *const sigset_t, ) -> c_int; pub fn posix_spawnp( pid: *mut crate::pid_t, file: *const c_char, - file_actions: *const crate::posix_spawn_file_actions_t, - attrp: *const crate::posix_spawnattr_t, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, argv: *const *mut c_char, envp: *const *mut c_char, ) -> c_int; @@ -3249,12 +3206,12 @@ extern "C" { buf: *mut c_void, len: size_t, flags: c_int, - addr: *mut crate::sockaddr, - addrlen: *mut crate::socklen_t, + addr: *mut sockaddr, + addrlen: *mut socklen_t, ) -> ssize_t; pub fn recvmmsg( sockfd: c_int, - msgvec: *mut crate::mmsghdr, + msgvec: *mut mmsghdr, vlen: c_uint, flags: c_int, timeout: *mut crate::timespec, @@ -3265,7 +3222,7 @@ extern "C" { pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int; pub fn regerror( errcode: c_int, - preg: *const crate::regex_t, + preg: *const regex_t, errbuf: *mut c_char, errbuf_size: size_t, ) -> size_t; @@ -3283,15 +3240,12 @@ extern "C" { pub fn sched_get_priority_max(policy: c_int) -> c_int; pub fn sched_get_priority_min(policy: c_int) -> c_int; pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; - pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; - pub fn sched_setscheduler( - pid: crate::pid_t, - policy: c_int, - param: *const crate::sched_param, - ) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const sched_param) -> c_int; + pub fn sched_setscheduler(pid: crate::pid_t, policy: c_int, param: *const sched_param) + -> c_int; pub fn sctp_opt_info( sd: c_int, - id: crate::sctp_assoc_t, + id: sctp_assoc_t, opt: c_int, arg_size: *mut c_void, size: *mut size_t, @@ -3307,7 +3261,7 @@ extern "C" { pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_unlink(name: *const c_char) -> c_int; pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; - pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int; + pub fn semget(key: key_t, nsems: c_int, semflag: c_int) -> c_int; pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int; pub fn send_file(socket: *mut c_int, iobuf: *mut sf_parms, flags: c_uint) -> ssize_t; pub fn sendmmsg(sockfd: c_int, msgvec: *mut mmsghdr, vlen: c_uint, flags: c_int) -> c_int; @@ -3326,7 +3280,7 @@ extern "C" { pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; - pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + pub fn settimeofday(tv: *const crate::timeval, tz: *const timezone) -> c_int; pub fn setitimer( which: c_int, new_value: *const crate::itimerval, @@ -3335,7 +3289,7 @@ extern "C" { pub fn setutent(); pub fn setutxent(); pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; - pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn sigsuspend(mask: *const sigset_t) -> c_int; pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -3345,7 +3299,7 @@ extern "C" { pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmdt(shmaddr: *const c_void) -> c_int; - pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut shmid_ds) -> c_int; pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; @@ -3380,30 +3334,26 @@ extern "C" { length: size_t, locale: crate::locale_t, ) -> c_int; - pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut tm) -> *mut c_char; pub fn strsep(string: *mut *mut c_char, delim: *const c_char) -> *mut c_char; pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; pub fn swapoff(path: *const c_char) -> c_int; pub fn swapon(path: *const c_char) -> c_int; pub fn sync(); pub fn telldir(dirp: *mut crate::DIR) -> c_long; - pub fn timer_create( - clockid: crate::clockid_t, - sevp: *mut crate::sigevent, - timerid: *mut crate::timer_t, - ) -> c_int; + 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_getoverrun(timerid: timer_t) -> c_int; pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> c_int; pub fn timer_settime( - timerid: crate::timer_t, + timerid: timer_t, flags: c_int, - new_value: *const crate::itimerspec, - old_value: *mut crate::itimerspec, + new_value: *const itimerspec, + old_value: *mut itimerspec, ) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; - pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn uname(buf: *mut utsname) -> c_int; pub fn updwtmp(file: *const c_char, u: *const utmp); pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; pub fn utmpname(file: *const c_char) -> c_int; @@ -3419,12 +3369,7 @@ extern "C" { options: c_int, rusage: *mut crate::rusage, ) -> crate::pid_t; - pub fn waitid( - idtype: idtype_t, - id: id_t, - infop: *mut crate::siginfo_t, - options: c_int, - ) -> c_int; + pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut siginfo_t, options: c_int) -> c_int; pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; // Use AIX thread-safe version errno. From 87df336016c0a7913df214bbf96dcf14a5678930 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:23 +0200 Subject: [PATCH 35/45] aix: tweak anonymous union ident in `poll_ctl_ext` Tweak anonymous `union` identifier to match skipping pattern in test suite. (backport ) (cherry picked from commit 6f664a1b952dfb9f9ca400dd648dd0cfa81ba06d) --- src/unix/aix/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 3c516d40181a..413b2cb546a2 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -546,13 +546,13 @@ s! { pub command: u8, pub events: c_short, pub fd: c_int, - pub u: __poll_ctl_ext_u, + pub u: __c_anonymous_poll_ctl_ext_u, reserved64: Padding<[u64; 6]>, } } s_no_extra_traits! { - pub union __poll_ctl_ext_u { + pub union __c_anonymous_poll_ctl_ext_u { pub addr: *mut c_void, pub data32: u32, pub data: u64, @@ -561,8 +561,8 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __poll_ctl_ext_u { - fn eq(&self, other: &__poll_ctl_ext_u) -> bool { + impl PartialEq for __c_anonymous_poll_ctl_ext_u { + fn eq(&self, other: &__c_anonymous_poll_ctl_ext_u) -> bool { unsafe { self.addr == other.addr && self.data32 == other.data32 @@ -570,8 +570,8 @@ cfg_if! { } } } - impl Eq for __poll_ctl_ext_u {} - impl hash::Hash for __poll_ctl_ext_u { + impl Eq for __c_anonymous_poll_ctl_ext_u {} + impl hash::Hash for __c_anonymous_poll_ctl_ext_u { fn hash(&self, state: &mut H) { unsafe { self.addr.hash(state); From 5685decc0dc5db6488668b1bb76b3a1c7f421c53 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:24 +0200 Subject: [PATCH 36/45] aix: error on unsupported target Add `compile_error` macro invocation when declaring architecture-specific definitions. This should ensure any new target either gets proper review of the required types or otherwise provides its target-specific definitions and bindings. (backport ) (cherry picked from commit 4c8afdb2c815edf8980545e64b146ec262977933) --- src/unix/aix/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 413b2cb546a2..efd9c486bd0a 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -3380,5 +3380,7 @@ cfg_if! { if #[cfg(target_arch = "powerpc64")] { mod powerpc64; pub use self::powerpc64::*; + } else { + core::compile_error!("unsupported target"); } } From 5efeb4add0183cef392de7cc43e58a56b913be59 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:17:48 +0100 Subject: [PATCH 37/45] ci: first steps to fix x86_64-unknown-redox target (backport ) (cherry picked from commit f711214055cd6117736574e616e983b4ea789f0f) --- .github/workflows/ci.yaml | 2 +- ci/docker/x86_64-unknown-redox/Dockerfile | 4 +++- src/unix/redox/mod.rs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8e80a142937b..586b3665eec7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -239,7 +239,7 @@ jobs: - target: x86_64-unknown-linux-musl env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - # FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually. + # FIXME: https://github.com/rust-lang/libc/issues/5520 # - target: x86_64-unknown-redox # FIXME(ppc): SIGILL running tests, see diff --git a/ci/docker/x86_64-unknown-redox/Dockerfile b/ci/docker/x86_64-unknown-redox/Dockerfile index 91b0cbabdc0b..17e493bb2432 100644 --- a/ci/docker/x86_64-unknown-redox/Dockerfile +++ b/ci/docker/x86_64-unknown-redox/Dockerfile @@ -2,7 +2,9 @@ FROM redoxos/redoxer RUN mv /root/.redoxer /.redoxer -ENV PATH=$PATH:/.redoxer/toolchain/bin:/rust/bin \ +RUN ln -sf /root/.redoxer ~/.redoxer + +ENV PATH=$PATH:$HOME/.redoxer/x86_64-unknown-redox/toolchain/bin \ AR_x86_64_unknown_redox="x86_64-unknown-redox-ar" \ CC_x86_64_unknown_redox="x86_64-unknown-redox-gcc" \ CARGO_TARGET_X86_64_UNKNOWN_REDOX_LINKER="x86_64-unknown-redox-gcc" \ diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 8df0877730cf..9426534783ed 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1018,8 +1018,8 @@ pub const OLCUC: crate::tcflag_t = 0o000_004; pub const OCRNL: crate::tcflag_t = 0o000_010; pub const ONOCR: crate::tcflag_t = 0o000_020; pub const ONLRET: crate::tcflag_t = 0o000_040; -pub const OFILL: crate::tcflag_t = 0o0000_100; -pub const OFDEL: crate::tcflag_t = 0o0000_200; +pub const OFILL: crate::tcflag_t = 0o0_000_100; +pub const OFDEL: crate::tcflag_t = 0o0_000_200; pub const B0: speed_t = 0o000_000; pub const B50: speed_t = 0o000_001; From c0232eb95683329800b996512226404482f183d1 Mon Sep 17 00:00:00 2001 From: Nalysius Date: Mon, 7 Sep 2026 15:05:04 +0200 Subject: [PATCH 38/45] openbsd: add sensor structure and related items The structure sensor and the SENSOR_* constants have been added, as well as the sensor_status and sensor_type enumerations. Ref: https://github.com/openbsd/src/blob/e8afce5b5b9d68772098e66f10777f7b6abb530d/sys/sys/sensors.h (backport ) (cherry picked from commit 9ed1936a0cf89ee98ff4e63648e3ee7436c91ad1) --- libc-test/build/main.rs | 10 +++++ libc-test/semver/openbsd.txt | 32 +++++++++++++++ src/new/mod.rs | 1 + src/new/openbsd/sys/mod.rs | 1 + src/new/openbsd/sys/sensors.rs | 71 ++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 src/new/openbsd/sys/sensors.rs diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 749294834c8e..f97a0e7d13c5 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -431,6 +431,7 @@ fn test_openbsd(t: &Target) { "wchar.h", "ctype.h", "dirent.h", + "sys/sensors.h", "sys/socket.h", (x86_64, "machine/fpu.h"), "net/if.h", @@ -526,6 +527,10 @@ fn test_openbsd(t: &Target) { "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), + // Field is named `type` in C but that is a Rust keyword, + // so these fields are translated to `type_` in the bindings. + "type_" if struct_ == "sensor" => "type".to_string(), + _ => return None, }; Some(replacement) @@ -583,6 +588,11 @@ fn test_openbsd(t: &Target) { cfg.rename_struct_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); cfg.rename_union_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); + cfg.alias_is_c_enum(move |ty| match ty { + "sensor_type" | "sensor_status" => true, + _ => false, + }); + cfg.skip_struct(move |struct_| { match struct_.ident() { // Extern types diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 99b04eb1cf0f..ddc662f85dba 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -889,6 +889,37 @@ SCHED_RR SCM_RIGHTS SCM_TIMESTAMP SEM_FAILED +SENSOR_ACCEL +SENSOR_AMPHOUR +SENSOR_AMPS +SENSOR_ANGLE +SENSOR_DISTANCE +SENSOR_DRIVE +SENSOR_ENERGY +SENSOR_FANRPM +SENSOR_FINVALID +SENSOR_FREQ +SENSOR_FUNKNOWN +SENSOR_HUMIDITY +SENSOR_INDICATOR +SENSOR_INTEGER +SENSOR_LUX +SENSOR_MAX_TYPES +SENSOR_OHMS +SENSOR_PERCENT +SENSOR_PRESSURE +SENSOR_S_CRIT +SENSOR_S_OK +SENSOR_S_UNKNOWN +SENSOR_S_UNSPEC +SENSOR_S_WARN +SENSOR_TEMP +SENSOR_TIMEDELTA +SENSOR_VELOCITY +SENSOR_VOLTS_AC +SENSOR_VOLTS_DC +SENSOR_WATTHOUR +SENSOR_WATTS SF_APPEND SF_ARCHIVED SF_IMMUTABLE @@ -1375,6 +1406,7 @@ sem_timedwait sem_unlink sendmmsg sendmsg +sensor setdomainname setgrent setgroups diff --git a/src/new/mod.rs b/src/new/mod.rs index 841f836f0103..557717d733b1 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -239,6 +239,7 @@ cfg_if! { pub use utmpx_::*; } else if #[cfg(target_os = "openbsd")] { pub use sys::ipc::*; + pub use sys::sensors::*; pub use sys::sysctl::*; } else if #[cfg(any(target_os = "nto", target_os = "qnx"))] { pub use net::bpf::*; diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs index 94d4e8db38a2..e292917e15ee 100644 --- a/src/new/openbsd/sys/mod.rs +++ b/src/new/openbsd/sys/mod.rs @@ -3,4 +3,5 @@ //! pub(crate) mod ipc; +pub(crate) mod sensors; pub(crate) mod sysctl; diff --git a/src/new/openbsd/sys/sensors.rs b/src/new/openbsd/sys/sensors.rs new file mode 100644 index 000000000000..c6aa7d9ddcbc --- /dev/null +++ b/src/new/openbsd/sys/sensors.rs @@ -0,0 +1,71 @@ +//! Header: `sys/sensors.h` +//! +//! + +use crate::prelude::*; +use crate::timeval; + +pub const SENSOR_FINVALID: c_int = 0x0001; +pub const SENSOR_FUNKNOWN: c_int = 0x0002; + +c_enum! { + pub enum sensor_status { + pub SENSOR_S_UNSPEC, + pub SENSOR_S_OK, + pub SENSOR_S_WARN, + pub SENSOR_S_CRIT, + pub SENSOR_S_UNKNOWN, + } +} + +c_enum! { + pub enum sensor_type { + pub SENSOR_TEMP, + pub SENSOR_FANRPM, + pub SENSOR_VOLTS_DC, + pub SENSOR_VOLTS_AC, + pub SENSOR_OHMS, + pub SENSOR_WATTS, + pub SENSOR_AMPS, + pub SENSOR_WATTHOUR, + pub SENSOR_AMPHOUR, + pub SENSOR_INDICATOR, + pub SENSOR_INTEGER, + pub SENSOR_PERCENT, + pub SENSOR_LUX, + pub SENSOR_DRIVE, + pub SENSOR_TIMEDELTA, + pub SENSOR_HUMIDITY, + pub SENSOR_FREQ, + pub SENSOR_ANGLE, + pub SENSOR_DISTANCE, + pub SENSOR_PRESSURE, + pub SENSOR_ACCEL, + pub SENSOR_VELOCITY, + pub SENSOR_ENERGY, + pub SENSOR_MAX_TYPES, + } +} + +pub const SENSOR_DRIVE_EMPTY: c_int = 1; +pub const SENSOR_DRIVE_READY: c_int = 2; +pub const SENSOR_DRIVE_POWERUP: c_int = 3; +pub const SENSOR_DRIVE_ONLINE: c_int = 4; +pub const SENSOR_DRIVE_IDLE: c_int = 5; +pub const SENSOR_DRIVE_ACTIVE: c_int = 6; +pub const SENSOR_DRIVE_REBUILD: c_int = 7; +pub const SENSOR_DRIVE_POWERDOWN: c_int = 8; +pub const SENSOR_DRIVE_FAIL: c_int = 9; +pub const SENSOR_DRIVE_PFAIL: c_int = 10; + +s! { + pub struct sensor { + pub desc: [c_char; 32], + pub tv: timeval, + pub value: i64, + pub type_: sensor_type, + pub status: sensor_status, + pub numt: c_int, + pub flags: c_int, + } +} From 02374ca27ef6e2f40b75b9078e88c30882738a54 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Fri, 11 Sep 2026 14:22:37 +0200 Subject: [PATCH 39/45] musl: fix `siginfo_t` definition Fix definition of `siginfo_t` in musl after the recent patch that moved it to `new` replaced certain untagged unions with records [^1]. [^1]: rust-lang/libc#5345 (backport ) (cherry picked from commit 9bc88f0cbc0b33d8a8527c86002b979eee4ab73b) --- src/new/musl/signal.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/new/musl/signal.rs b/src/new/musl/signal.rs index 3fa4fab66eb1..ea440e4da8cd 100644 --- a/src/new/musl/signal.rs +++ b/src/new/musl/signal.rs @@ -63,17 +63,17 @@ s_no_extra_traits! { si_arch: c_uint, } - struct __c_anonymous___si_common___first { + union __c_anonymous___si_common___first { __piduid: __c_anonymous___first___piduid, __timer: __c_anonymous___first___timer, } - struct __c_anonymous___si_common___second { + union __c_anonymous___si_common___second { si_value: crate::sigval, __sigchld: __c_anonymous___second___sigchld, } - struct __c_anonymous___sigfault___first { + union __c_anonymous___sigfault___first { __addr_band: __c_anonymous___first___addr_band, si_pkey: c_uint, } From ab875da9bf9b7c062b466862480e5f7286da03ad Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Fri, 4 Sep 2026 03:12:32 -0400 Subject: [PATCH 40/45] OpenBSD: add getexecpath() (backport ) (cherry picked from commit b99bf9dd59aae009ef10cea14785be50d6fb5aa3) --- libc-test/semver/openbsd.txt | 1 + src/unix/bsd/netbsdlike/openbsd/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index ddc662f85dba..330f8da09e06 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1224,6 +1224,7 @@ futimes getdomainname getdtablesize getentropy +getexecpath getfsstat getgrent getgrgid diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 7245c28bc483..fdf70dffb35e 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -2078,6 +2078,7 @@ extern "C" { pub fn getfsstat(buf: *mut statfs, bufsize: size_t, flags: c_int) -> c_int; pub fn elf_aux_info(aux: c_int, buf: *mut c_void, buflen: c_int) -> c_int; + pub fn getexecpath(buf: *mut c_char, bufsize: size_t) -> c_int; } #[link(name = "execinfo")] From bbb14db7c5da195fcfacd37f51aa3db1704ee8cd Mon Sep 17 00:00:00 2001 From: Yasser-Ameur Date: Wed, 9 Sep 2026 01:17:30 +0200 Subject: [PATCH 41/45] ci: normalize paths before the style ignore-file check glob returns `src\macros.rs` on Windows while `IGNORE_FILES` holds `src/macros.rs`, so the file the script means to skip was formatted anyway and rustfmt failed it on width. Comparing `as_posix()` fixes it, and nothing changes where paths already use forward slashes. (backport ) (cherry picked from commit e9c94349f87bbcf0d7ee14880ceb5949000fb624) --- ci/style.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/style.py b/ci/style.py index ca3afa2bdf2f..18731281190b 100755 --- a/ci/style.py +++ b/ci/style.py @@ -26,7 +26,7 @@ def main(): fmt_files.extend(iglob(f"{dir}/**/*.rs", recursive=True)) for file in fmt_files: - if file in IGNORE_FILES: + if Path(file).as_posix() in IGNORE_FILES: continue fmt_one(Path(file), check_only) From 4a3fd6a4be76357db13067e6d63f6e5560b4cff7 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 29 Aug 2026 17:48:44 +0200 Subject: [PATCH 42/45] macros: add support for `exhaustive` attr - Modify `struct_with_default` to automatically add a private field to all records such that they are always built field-by-field in downstream crates. - Add support for `exhaustive` custom attribute to opt out of having the record have a `__non_exhaustive` field added to it. - Annotate records without private fields under `src/new/helenos/time.rs` and `src/new/linux_uapi/linux/can.rs` with `exhaustive` attribute. (backport ) (cherry picked from commit ee871765d2a21df1b356e77f1de73b5dd2677949) --- src/macros.rs | 138 +++++++++++++++++++++++++++----- src/new/helenos/time.rs | 1 + src/new/linux_uapi/linux/can.rs | 7 +- 3 files changed, 125 insertions(+), 21 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 79786d9bca1a..2b02d2995067 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -427,24 +427,34 @@ macro_rules! union_with_debug { }; } -/// Emit a struct with the given derive attributes plus a generated `Default` impl. +/// Emit a struct with the given derive attributes plus a generated `Default` +/// impl. Ensure that the record has an additional private field added to +/// replicate `#[non_exhaustive]`, unless it is annotated with `#[exhaustive]`. /// -/// Fields default to `Default::default()`. A field whose default can't be derived must carry -/// `#[custom_default(EXPR)]` as its *first* attribute, and `EXPR` is used instead. +/// Fields default to `Default::default()`. A field whose default can't be +/// derived must carry `#[custom_default(EXPR)]` as its *first* attribute, and +/// `EXPR` is used instead. /// -/// This works by scanning each field for `#[custom_default]` attributes. If one exists, the -/// attribute's contents are added to `processed_field_defaults` and will be used in the expansion -/// for `Default`. If it does not exist, `Default::default()` is used instead. In either case, the -/// field is added to `processed_fields` with `#[custom_default]` stripped if necessary, and +/// This works by scanning each field for `#[custom_default]` attributes. If one +/// exists, the attribute's contents are added to `processed_field_defaults` and +/// will be used in the expansion for `Default`. If it does not exist, +/// `Default::default()` is used instead. In either case, the field is added to +/// `processed_fields` with `#[custom_default]` stripped if necessary, and /// `struct_with_default` is invoked again with the remaining fields. /// -/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields are scanned. Both -/// go on the struct, but only the `cfg`s are repeated on the `Default` impl. A `cfg` decides -/// whether the type exists at all, so without it a configured-out struct leaves an impl behind -/// referring to a type that isn't there. +/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields +/// are scanned. Both go on the struct, but only the `cfg`s are repeated on the +/// `Default` impl. A `cfg` decides whether the type exists at all, so without +/// it a configured-out struct leaves an impl behind referring to a type that +/// isn't there. +/// +/// Out of `other_attrs`, we scan for `#[exhaustive]`. If found, we remove it +/// but take into account that the record should be expanded _without_ an +/// additional private field. The scan for both `cfg` attributes and the +/// (non-existent) `exhaustive` attribute is done in one linear pass. macro_rules! struct_with_default { - // entry; `attrs` is the attribute block the caller wants on the struct (repr, derives, etc.), - // which is merged with the struct's own attributes. + // entry; `attrs` is the attribute block the caller wants on the struct + // (repr, derives, etc.), which is merged with the struct's own attributes. ( attrs: { $($attrs:tt)* } $(#$attr:tt)* @@ -455,6 +465,7 @@ macro_rules! struct_with_default { cfg_attrs: { } other_attrs: { } remaining_attrs: { $($attrs)* $(#$attr)* } + found_exhaustive_attr: { false } vis: { $vis } name: { $name } body: { $($body)* } @@ -470,6 +481,7 @@ macro_rules! struct_with_default { #[cfg($($cfg:tt)*)] $($tail:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } body: { $($body:tt)* } @@ -479,6 +491,34 @@ macro_rules! struct_with_default { cfg_attrs: { $($cfg_attrs)* #[cfg($($cfg)*)] } other_attrs: { $($other_attrs)* } remaining_attrs: { $($tail)* } + found_exhaustive_attr: { $found_exhaustive } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // `exhaustive` must be taken into account as many times as it appears, + // though the effect is the same with a single annotation. + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #[exhaustive] + $($tail:tt)* + } + found_exhaustive_attr: { $_:tt } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + struct_with_default! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } + remaining_attrs: { $($tail)* } + found_exhaustive_attr: { true } vis: { $vis } name: { $name } body: { $($body)* } @@ -494,6 +534,7 @@ macro_rules! struct_with_default { #$other:tt $($tail:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } body: { $($body:tt)* } @@ -503,6 +544,7 @@ macro_rules! struct_with_default { cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* #$other } remaining_attrs: { $($tail)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } body: { $($body)* } @@ -515,6 +557,7 @@ macro_rules! struct_with_default { cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } remaining_attrs: { } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } body: { $($body:tt)* } @@ -523,6 +566,7 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } processed_fields: { } @@ -536,6 +580,7 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -551,6 +596,7 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -567,6 +613,7 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -581,6 +628,7 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -597,30 +645,80 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } processed_field_defaults: { $($processed_field_defaults:tt)* } remaining_fields: { } ) => { - $($other_attrs)* - $($cfg_attrs)* - $vis struct $name { $($processed_fields)* } + emit_struct_definition! { + found_exhaustive_attr: $found_exhaustive, + body: { + $($other_attrs)* + $($cfg_attrs)* + $vis $name { $($processed_fields)* } + } + } $($cfg_attrs)* - // The impl names the type and its fields, which warns if either is deprecated. + // The impl names the type and its fields, which warns if either is + // deprecated. #[allow(deprecated)] impl ::core::default::Default for $name { - // Field attributes (`#[cfg]`, doc comments) get forwarded to the initializer too. - // Docs are harmless there but trip the lint, so silence it. + // Field attributes (`#[cfg]`, doc comments) get forwarded to the + // initializer too. Docs are harmless there but trip the lint, so + // silence it. #[allow(unused_doc_comments)] fn default() -> Self { - Self { $($processed_field_defaults)* } + emit_struct_default_body! { + found_exhaustive_attr: $found_exhaustive, + body: { $($processed_field_defaults)* } + } } } }; } +/// Expands the definition of the record defined at [`struct_with_default`], with either one of an +/// additional private field or with its verbatim fields. +macro_rules! emit_struct_definition { + ( + found_exhaustive_attr: false, + body: { $(#[$attr:meta])* $vis:vis $name:ident { $($field:tt)* } } + ) => { + $(#[$attr])* + $vis struct $name { $($field)* __non_exhaustive: () } + }; + + ( + found_exhaustive_attr: true, + body: { $(#[$attr:meta])* $vis:vis $name:ident { $($field:tt)* } } + ) => { + $(#[$attr])* + $vis struct $name { $($field)* } + }; +} + +/// Expands the `Default` implementation of the record defined at [`struct_with_default`], with +/// either one of an additional private field initialized to the unit value, or the record's fields +/// verbatim. +macro_rules! emit_struct_default_body { + ( + found_exhaustive_attr: false, + body: { $($field_default:tt)* } + ) => { + Self { $($field_default)* __non_exhaustive: () } + }; + + ( + found_exhaustive_attr: true, + body: { $($field_default:tt)* } + ) => { + Self { $($field_default)* } + }; +} + /// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, /// and `Copy`, but these aren't meaningful for extern types so they should eventually /// be removed. diff --git a/src/new/helenos/time.rs b/src/new/helenos/time.rs index 0175af24c006..3fce2df22a90 100644 --- a/src/new/helenos/time.rs +++ b/src/new/helenos/time.rs @@ -8,6 +8,7 @@ pub type time_t = c_longlong; pub type usec_t = c_longlong; s_with_default! { + #[exhaustive] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 989e854c4527..29eb348496fd 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -71,6 +71,7 @@ pub const CANXL_XLF: c_int = 0x80; pub const CANXL_SEC: c_int = 0x01; s_with_default! { + #[exhaustive] pub struct canxl_frame { pub prio: canid_t, pub flags: u8, @@ -104,6 +105,7 @@ pub const CAN_NPROTO: c_int = 8; pub const SOL_CAN_BASE: c_int = 100; s_no_extra_traits_with_default! { + #[exhaustive] pub struct sockaddr_can { pub can_family: crate::sa_family_t, pub can_ifindex: c_int, @@ -117,18 +119,21 @@ s_no_extra_traits_with_default! { } } -s! { +s_with_default! { + #[exhaustive] pub struct __c_anonymous_sockaddr_can_tp { pub rx_id: canid_t, pub tx_id: canid_t, } + #[exhaustive] pub struct __c_anonymous_sockaddr_can_j1939 { pub name: u64, pub pgn: u32, pub addr: u8, } + #[exhaustive] pub struct can_filter { pub can_id: canid_t, pub can_mask: canid_t, From 3d58e0e241e818c58db0bca3182b2147657c99a4 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 29 Aug 2026 17:59:34 +0200 Subject: [PATCH 43/45] macros: add tests for exhaustiveness Add tests to ensure two things about the private field added to enforce non-exhaustiveness in records declared within `s_with_default` and `s_no_extra_traits_with_default`. - Ensure the field is added only if the `exhaustive` attribute is not found while munching the annotated attributes of the record item. - Ensure the `exhaustive` attribute also works when it appears between other sets of attributes. (backport ) (cherry picked from commit 2614ed8b114f131d431e2f4f5ac1f63802aecc35) --- src/macros.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index 2b02d2995067..765f6a61bb32 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1222,6 +1222,56 @@ mod tests { assert_eq!(core::mem::offset_of!(Off1, d), offset_of!(Off1, d)); } + #[test] + fn s_with_default_is_non_exhaustive() { + // Without `#[exhaustive]`, the record should have an additional field + // added at the end. If this test compiles, it has it. + s_with_default! { + struct Something { + a: u32, + } + } + + let s = Something::default(); + assert_eq!(s.__non_exhaustive, ()); + } + + #[test] + fn s_with_default_uses_exhaustive() { + // With `#[exhaustive]`, the record should be regurgitated as-is. If + // this test compiles, then it works. + s_with_default! { + #[exhaustive] + struct Something { + a: u32, + } + } + + #[allow(unused)] + let s = Something { + a: Default::default(), + }; + } + + #[test] + fn s_with_default_uses_mixed_exhaustive() { + // `#[exhaustive]` should work when sandwiched between attributes. If + // the test compiles, then it works. + s_with_default! { + #[repr(align(8))] + #[exhaustive] + #[repr(align(2))] + struct Something { + a: u32, + } + } + + #[allow(unused)] + let s = Something { + a: Default::default(), + }; + } + #[test] fn s_with_default_uses_custom_default() { // A non-default value proves `custom_default` is used rather than a derived default. From b4cc4ec8c18d8678335624208e8182b63809f9d2 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:49:04 +0200 Subject: [PATCH 44/45] macros: rename `struct_with_default` and friends - Rename `s_with_default`, `s_no_extra_traits_with_default` and `struct_with_default` to `s2`, `s_no_extra_traits2`, and `custom_struct`. These macros now both add a `Default` impl and a private field to enforce non-exhaustiveness. - Rewrap comments and doc comments to follow 80 and 100 columns guides. (backport ) (cherry picked from commit 0c0db5cd9f3c658d6b511328a6dd823a270d82cb) --- src/macros.rs | 228 ++++++++++++++++++-------------- src/new/freebsd/net/route.rs | 2 +- src/new/helenos/time.rs | 2 +- src/new/linux_uapi/linux/can.rs | 10 +- 4 files changed, 137 insertions(+), 105 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 765f6a61bb32..72dea31b8a51 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,11 +1,10 @@ /// A macro for defining #[cfg] if-else statements. /// -/// This is similar to the `if/elif` C preprocessor macro by allowing definition -/// of a cascade of `#[cfg]` cases, emitting the implementation which matches -/// first. +/// This is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of +/// `#[cfg]` cases, emitting the implementation which matches first. /// -/// This allows you to conveniently provide a long list #[cfg]'d blocks of code -/// without having to rewrite each clause multiple times. +/// This allows you to conveniently provide a long list #[cfg]'d blocks of code without having to +/// rewrite each clause multiple times. macro_rules! cfg_if { // match if/else chains with a final `else` ($( @@ -162,8 +161,8 @@ macro_rules! prelude { /// /// 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. +/// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not make sense, and +/// for unions. macro_rules! s { ($( $(#[$attr:meta])* @@ -197,8 +196,8 @@ macro_rules! s { ); } -/// Implement `Clone`, `Copy`, and `Debug` for a tuple struct, as well as `PartialEq`, `Eq`, -/// and `Hash` 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. /// /// Unlike `s!`, this does *not* mark the type with `repr(C)`. Users should provide their own /// `repr` attribute via `$attr` as necessary. @@ -257,23 +256,40 @@ macro_rules! s_no_extra_traits { ); } -/// Like [`s`], but also generates a `Default` impl for every struct in the block. -macro_rules! s_with_default { +/// Like [`s`], but (1) generates a `Default` impl for every struct in the block, and (2) adds a +/// private field to the struct to replicate the effects of the `non_exhaustive` attribute while +/// rust-lang/rust#132699 gets sorted out. +/// +/// To opt out of having the private field added, annotate the struct with an `exhaustive` +/// attribute, as in: +/// +/// ```ignore +/// s2! { +/// #[exhaustive] +/// struct Something { +/// ... +/// } +/// } +/// ``` +/// +/// See [`custom_struct`] for details. +macro_rules! s2 { ($( $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); + s2!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( compile_error!( - "unions cannot derive extra traits, use s_no_extra_traits_with_default instead" + "unions cannot derive extra traits, use `s_no_extra_traits2` \ + instead" ); ); (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( - struct_with_default! { + custom_struct! { attrs: { #[repr(C)] #[::core::prelude::v1::derive( @@ -296,16 +312,30 @@ macro_rules! s_with_default { ); } -/// Like [`s_no_extra_traits`], but also generates a `Default` impl for every struct in the block. +/// Like [`s_no_extra_traits`], but (1) generates a `Default` impl for every struct in the block, +/// and (2) adds a private field to replicate the effects of the built-in `non_exhaustive` attribute +/// while rust-lang/rust#132699 gets sorted out. /// -/// Unions are emitted just like `s_no_extra_traits!` does, with no `Default`. A struct field of +/// Unions are emitted just like `s_no_extra_traits!` does, with no `Default`. A struct field of /// union type supplies its own default via `#[custom_default(...)]`. -macro_rules! s_no_extra_traits_with_default { +/// +/// To opt out of having the private field added, annotate the struct with an `exhaustive` +/// attribute, as in: +/// +/// ```ignore +/// s_no_extra_traits2! { +/// #[exhaustive] +/// struct Something { +/// ... +/// } +/// } +/// ``` +macro_rules! s_no_extra_traits2 { ($( $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); + s_no_extra_traits2!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( @@ -315,7 +345,7 @@ macro_rules! s_no_extra_traits_with_default { ); (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( - struct_with_default! { + custom_struct! { attrs: { #[repr(C)] #[::core::prelude::v1::derive( @@ -332,8 +362,8 @@ macro_rules! s_no_extra_traits_with_default { /// Emit a union plus its `Debug` impl. /// /// Unions can't derive `Debug`, so it is written out here. Attributes are split like -/// [`struct_with_default`] does. Everything goes on the union, but only the `cfg`s are repeated -/// on the impl, otherwise a union that is configured out leaves an impl behind. +/// [`custom_struct`] does. Everything goes on the union, but only the `cfg`s are repeated on the +/// impl, otherwise a union that is configured out leaves an impl behind. macro_rules! union_with_debug { ( $(#$attr:tt)* @@ -427,32 +457,28 @@ macro_rules! union_with_debug { }; } -/// Emit a struct with the given derive attributes plus a generated `Default` -/// impl. Ensure that the record has an additional private field added to -/// replicate `#[non_exhaustive]`, unless it is annotated with `#[exhaustive]`. +/// Emit a struct with the given derive attributes plus a generated `Default` impl. Ensure that the +/// record has an additional private field added to replicate `#[non_exhaustive]`, unless it is +/// annotated with `#[exhaustive]`. /// -/// Fields default to `Default::default()`. A field whose default can't be -/// derived must carry `#[custom_default(EXPR)]` as its *first* attribute, and -/// `EXPR` is used instead. +/// Fields default to `Default::default()`. A field whose default can't be derived must carry +/// `#[custom_default(EXPR)]` as its *first* attribute, and `EXPR` is used instead. /// -/// This works by scanning each field for `#[custom_default]` attributes. If one -/// exists, the attribute's contents are added to `processed_field_defaults` and -/// will be used in the expansion for `Default`. If it does not exist, -/// `Default::default()` is used instead. In either case, the field is added to -/// `processed_fields` with `#[custom_default]` stripped if necessary, and -/// `struct_with_default` is invoked again with the remaining fields. +/// This works by scanning each field for `#[custom_default]` attributes. If one exists, the +/// attribute's contents are added to `processed_field_defaults` and will be used in the expansion +/// for `Default`. If it does not exist, `Default::default()` is used instead. In either case, the +/// field is added to `processed_fields` with `#[custom_default]` stripped if necessary, and +/// `custom_struct` is invoked again with the remaining fields. /// -/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields -/// are scanned. Both go on the struct, but only the `cfg`s are repeated on the -/// `Default` impl. A `cfg` decides whether the type exists at all, so without -/// it a configured-out struct leaves an impl behind referring to a type that -/// isn't there. +/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields are scanned. Both go +/// on the struct, but only the `cfg`s are repeated on the `Default` impl. A `cfg` decides whether +/// the type exists at all, so without it a configured-out struct leaves an impl behind referring to +/// a type that isn't there. /// -/// Out of `other_attrs`, we scan for `#[exhaustive]`. If found, we remove it -/// but take into account that the record should be expanded _without_ an -/// additional private field. The scan for both `cfg` attributes and the -/// (non-existent) `exhaustive` attribute is done in one linear pass. -macro_rules! struct_with_default { +/// Out of `other_attrs`, we scan for `#[exhaustive]`. If found, we remove it but take into account +/// that the record should be expanded _without_ an additional private field. The scan for both +/// `cfg` attributes and the (non-existent) `exhaustive` attribute is done in one linear pass. +macro_rules! custom_struct { // entry; `attrs` is the attribute block the caller wants on the struct // (repr, derives, etc.), which is merged with the struct's own attributes. ( @@ -460,7 +486,7 @@ macro_rules! struct_with_default { $(#$attr:tt)* $vis:vis struct $name:ident { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @split_attrs cfg_attrs: { } other_attrs: { } @@ -486,7 +512,7 @@ macro_rules! struct_with_default { name: { $name:ident } body: { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @split_attrs cfg_attrs: { $($cfg_attrs)* #[cfg($($cfg)*)] } other_attrs: { $($other_attrs)* } @@ -513,7 +539,7 @@ macro_rules! struct_with_default { name: { $name:ident } body: { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @split_attrs cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } @@ -539,7 +565,7 @@ macro_rules! struct_with_default { name: { $name:ident } body: { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @split_attrs cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* #$other } @@ -562,7 +588,7 @@ macro_rules! struct_with_default { name: { $name:ident } body: { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } @@ -592,7 +618,7 @@ macro_rules! struct_with_default { $($tail:tt)* } ) => { - struct_with_default! { + custom_struct! { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } @@ -624,7 +650,7 @@ macro_rules! struct_with_default { $($tail:tt)* } ) => { - struct_with_default! { + custom_struct! { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } @@ -680,13 +706,14 @@ macro_rules! struct_with_default { }; } -/// Expands the definition of the record defined at [`struct_with_default`], with either one of an +/// Expands the definition of the record defined at [`custom_struct`], with either one of an /// additional private field or with its verbatim fields. macro_rules! emit_struct_definition { ( found_exhaustive_attr: false, body: { $(#[$attr:meta])* $vis:vis $name:ident { $($field:tt)* } } ) => { + #[allow(clippy::manual_non_exhaustive)] $(#[$attr])* $vis struct $name { $($field)* __non_exhaustive: () } }; @@ -700,9 +727,8 @@ macro_rules! emit_struct_definition { }; } -/// Expands the `Default` implementation of the record defined at [`struct_with_default`], with -/// either one of an additional private field initialized to the unit value, or the record's fields -/// verbatim. +/// Expands the `Default` implementation of the record defined at [`custom_struct`], with either one +/// of an additional private field initialized to the unit value, or the record's fields verbatim. macro_rules! emit_struct_default_body { ( found_exhaustive_attr: false, @@ -719,12 +745,11 @@ macro_rules! emit_struct_default_body { }; } -/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, -/// and `Copy`, but these aren't meaningful for extern types so they should eventually -/// be removed. +/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, and +/// `Copy`, but these aren't meaningful for extern types so they should eventually be removed. /// -/// Really what we want here is something that also can't be named without indirection (in -/// ADTs or function signatures), but this doesn't exist. +/// Really what we want here is something that also can't be named without indirection (in ADTs or +/// function signatures), but this doesn't exist. macro_rules! extern_ty { ($( $(#[$attr:meta])* @@ -997,7 +1022,8 @@ macro_rules! offset_of { let ptr = data.as_ptr(); // nested unsafe, see f! #[allow(unused_unsafe)] - // SAFETY: computed address is inbounds since we have a stack alloc for T + // SAFETY: computed address is inbounds since we have a stack alloc for + // T let fptr = unsafe { core::ptr::addr_of!((*ptr).$field) }; let off = (fptr as usize).checked_sub(ptr as usize).unwrap(); core::assert!(off <= core::mem::size_of::<$Ty>()); @@ -1093,8 +1119,8 @@ mod tests { #[test] fn c_enum_multiple_set_value() { - // C enums always take one more than the previous value, unless set to a specific - // value. Duplicates are allowed. + // C enums always take one more than the previous value, unless set to a + // specific value. Duplicates are allowed. c_enum! { pub enum e { VAR0, @@ -1145,8 +1171,9 @@ mod tests { assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(PUB1, 10u8 * 2); assert_eq!(PUB2, 42u16 * 2); - // Verify that the default is private. If `PRIV_ON_1` was actually public in `priv1`, this - // would be an ambiguous import and/or type mismatch error. + // Verify that the default is private. If `PRIV_ON_1` was actually + // public in `priv1`, this would be an ambiguous import and/or type + // mismatch error. assert_eq!(PRIV_ON_1, 42u16); } @@ -1223,10 +1250,10 @@ mod tests { } #[test] - fn s_with_default_is_non_exhaustive() { + fn s2_is_non_exhaustive() { // Without `#[exhaustive]`, the record should have an additional field // added at the end. If this test compiles, it has it. - s_with_default! { + s2! { struct Something { a: u32, } @@ -1237,10 +1264,10 @@ mod tests { } #[test] - fn s_with_default_uses_exhaustive() { + fn s2_uses_exhaustive() { // With `#[exhaustive]`, the record should be regurgitated as-is. If // this test compiles, then it works. - s_with_default! { + s2! { #[exhaustive] struct Something { a: u32, @@ -1254,10 +1281,10 @@ mod tests { } #[test] - fn s_with_default_uses_mixed_exhaustive() { + fn s2_uses_mixed_exhaustive() { // `#[exhaustive]` should work when sandwiched between attributes. If // the test compiles, then it works. - s_with_default! { + s2! { #[repr(align(8))] #[exhaustive] #[repr(align(2))] @@ -1273,9 +1300,10 @@ mod tests { } #[test] - fn s_with_default_uses_custom_default() { - // A non-default value proves `custom_default` is used rather than a derived default. - s_with_default! { + fn s2_uses_custom_default() { + // A non-default value proves `custom_default` is used rather than a + // derived default. + s2! { struct CustomDefault { a: u32, #[custom_default([1; 64])] @@ -1289,10 +1317,10 @@ mod tests { } #[test] - fn s_with_default_keeps_field_attrs() { - // If `custom_default` stripping ate the other field attributes, the two `a` fields - // would collide. - s_with_default! { + fn s2_keeps_field_attrs() { + // If `custom_default` stripping ate the other field attributes, the two + // `a` fields would collide. + s2! { struct FieldAttrs { #[cfg(target_arch = "x86_64")] a: u8, @@ -1309,10 +1337,10 @@ mod tests { } #[test] - fn s_with_default_single_cfg_field() { - // this field only exists on x86_64, so its default init needs the same cfg or - // Default won't build on other arches - s_with_default! { + fn s2_single_cfg_field() { + // This field only exists on x86_64, so its default init needs the same + // `cfg` or `Default` won't build on other arches. + s2! { struct SingleCfg { common: u32, #[cfg(target_arch = "x86_64")] @@ -1327,9 +1355,10 @@ mod tests { } #[test] - fn s_no_extra_traits_with_default_zeroes_union() { - // A union field's default is supplied by `custom_default(unsafe { mem::zeroed })`. - s_no_extra_traits_with_default! { + fn s_no_extra_traits2_zeroes_union() { + // A union field's default is supplied by + // `custom_default(unsafe { mem::zeroed })`. + s_no_extra_traits2! { union U { a: u32, b: f32, @@ -1348,10 +1377,11 @@ mod tests { } #[test] - fn s_with_default_keeps_struct_cfg() { - // The opposite of the configured-out types in `macro_checks`. With the `cfg` true the - // type and its `Default` both exist, and the other attributes still apply. - s_with_default! { + fn s2_keeps_struct_cfg() { + // The opposite of the configured-out types in `macro_checks`. With the + // `cfg` true the type and its `Default` both exist, and the other + // attributes still apply. + s2! { #[cfg(true)] #[repr(align(8))] /// a doc comment @@ -1417,7 +1447,7 @@ mod macro_checks { pub type Bar; } - s_with_default! { + s2! { pub struct S3 { pub a: u32, #[custom_default([1; 64])] @@ -1430,7 +1460,7 @@ mod macro_checks { } } - s_no_extra_traits_with_default! { + s_no_extra_traits2! { pub union U3 { pub a: u32, b: f32, @@ -1450,9 +1480,10 @@ mod macro_checks { assert_impls_default::(); } - // Types configured out entirely, checking that the generated impls carry the same `cfg` as - // the type. Without it they fail to compile with "cannot find type". - s_with_default! { + // Types configured out entirely, checking that the generated impls carry + // the same `cfg` as the type. Without it they fail to compile with "cannot + // find type". + s2! { #[cfg(false)] pub struct S5 { pub a: u32, @@ -1469,7 +1500,7 @@ mod macro_checks { } } - s_no_extra_traits_with_default! { + s_no_extra_traits2! { #[cfg(false)] pub union U5 { pub a: u32, @@ -1482,12 +1513,13 @@ mod macro_checks { } } - // The generated impls name the type and its fields, so they need to allow deprecation. - // `deny` turns the warning into an error if that ever stops being the case. + // The generated impls name the type and its fields, so they need to allow + // deprecation. `deny` turns the warning into an error if that ever stops + // being the case. mod deprecated_checks { #![deny(deprecated)] - s_with_default! { + s2! { #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] pub struct S7 { pub a: u32, @@ -1502,7 +1534,7 @@ mod macro_checks { } } - s_no_extra_traits_with_default! { + s_no_extra_traits2! { #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] pub union U7 { pub a: u32, diff --git a/src/new/freebsd/net/route.rs b/src/new/freebsd/net/route.rs index a67faeda2e0b..7d0350f519ca 100644 --- a/src/new/freebsd/net/route.rs +++ b/src/new/freebsd/net/route.rs @@ -4,7 +4,7 @@ use crate::prelude::*; -s_with_default! { +s2! { pub struct rt_metrics { pub rmx_locks: c_ulong, pub rmx_mtu: c_ulong, diff --git a/src/new/helenos/time.rs b/src/new/helenos/time.rs index 3fce2df22a90..daa5c1ee7937 100644 --- a/src/new/helenos/time.rs +++ b/src/new/helenos/time.rs @@ -7,7 +7,7 @@ use crate::prelude::*; pub type time_t = c_longlong; pub type usec_t = c_longlong; -s_with_default! { +s2! { #[exhaustive] pub struct timespec { pub tv_sec: time_t, diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 29eb348496fd..701f9efee352 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -37,7 +37,7 @@ pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; pub const CANXL_MIN_DLEN: usize = 1; pub const CANXL_MAX_DLEN: usize = 2048; -s_with_default! { +s2! { #[repr(align(8))] pub struct can_frame { pub can_id: canid_t, @@ -54,7 +54,7 @@ pub const CANFD_BRS: c_int = 0x01; pub const CANFD_ESI: c_int = 0x02; pub const CANFD_FDF: c_int = 0x04; -s_with_default! { +s2! { #[repr(align(8))] pub struct canfd_frame { pub can_id: canid_t, @@ -70,7 +70,7 @@ s_with_default! { pub const CANXL_XLF: c_int = 0x80; pub const CANXL_SEC: c_int = 0x01; -s_with_default! { +s2! { #[exhaustive] pub struct canxl_frame { pub prio: canid_t, @@ -104,7 +104,7 @@ pub const CAN_NPROTO: c_int = 8; pub const SOL_CAN_BASE: c_int = 100; -s_no_extra_traits_with_default! { +s_no_extra_traits2! { #[exhaustive] pub struct sockaddr_can { pub can_family: crate::sa_family_t, @@ -119,7 +119,7 @@ s_no_extra_traits_with_default! { } } -s_with_default! { +s2! { #[exhaustive] pub struct __c_anonymous_sockaddr_can_tp { pub rx_id: canid_t, From 0c17322a8b93707cf8813bb0b3242305f69de9ff Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Wed, 16 Sep 2026 17:51:04 +0100 Subject: [PATCH 45/45] redox: add FILENAME_MAX constant https://github.com/redox-os/relibc/blob/381772ec81fced6d055f0f0ba6fa92c7f3256fbb/src/header/stdio/constants.rs#L8 (backport ) (cherry picked from commit d3ec7b38939aac72002118622e8cf85db911031f) --- libc-test/semver/redox.txt | 1 + src/unix/redox/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index f308714962bc..f30f4f9ae6bc 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -101,6 +101,7 @@ EUCLEAN EUNATCH EUSERS EXFULL +FILENAME_MAX FIONREAD F_DUPFD_CLOEXEC IMAXBEL diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 9426534783ed..87f618a8faf4 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1190,6 +1190,7 @@ pub const X_OK: c_int = 1; // stdio.h pub const BUFSIZ: c_uint = 1024; +pub const FILENAME_MAX: c_int = 4096; pub const _IOFBF: c_int = 0; pub const _IOLBF: c_int = 1; pub const _IONBF: c_int = 2;