Skip to content

bsd: Add missing minherit system call - #4849

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
oherrala:macos-minherit
Aug 31, 2026
Merged

bsd: Add missing minherit system call#4849
tgross35 merged 1 commit into
rust-lang:mainfrom
oherrala:macos-minherit

Conversation

@oherrala

@oherrala oherrala commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

Description

Add a missing minherit() system call and constants related to it.

minherit(2) from macOS describes this call as:

The minherit() system call changes the specified pages to have the inheritance characteristic inherit, which can be set to VM_INHERIT_NONE, VM_INHERIT_COPY, or VM_INHERIT_SHARE. Not all implementations will guarantee that the inheritance characteristic can be set on a page basis; the granularity of changes may be as large as an entire region.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

@rustbot rustbot added O-macos O-unix S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Nov 27, 2025
@oherrala
oherrala marked this pull request as draft November 28, 2025 08:28
@oherrala

Copy link
Copy Markdown
Contributor Author

The arm-linux-androidabi test failed maybe because "The job has exceeded the maximum execution time of 25m0s".

@oherrala
oherrala marked this pull request as ready for review November 28, 2025 08:33

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to use mach2 instead? https://docs.rs/mach2/latest/mach2/vm_inherit/index.html. We're tryig to transition away from binding platform API like mach/ and linux/.

@rustbot

rustbot commented Nov 30, 2025

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@oherrala

oherrala commented Nov 30, 2025

Copy link
Copy Markdown
Contributor Author

@tgross35 FWIW minherit is not macOS specific. It originates from OpenBSD and is also in FreeBSD, NetBSD and DragonFly:

@tgross35

Copy link
Copy Markdown
Member

Thanks for the links. In that case I think it’s fine here, but would you mind enabling it for those other platforms as well? At least FreeBSD and NetBSD get CI here.

@rustbot rustbot added the O-bsd label Dec 1, 2025
@oherrala
oherrala marked this pull request as draft December 1, 2025 19:28
@oherrala oherrala changed the title apple: Add missing minherit system call bsd: Add missing minherit system call Dec 1, 2025
@oherrala
oherrala force-pushed the macos-minherit branch 2 times, most recently from e599cd6 to 0b039e8 Compare December 1, 2025 19:34
Comment thread libc-test/semver/netbsd.txt Outdated
Comment on lines +1088 to +1091
VM_INHERIT_COPY
VM_INHERIT_DONATE_COPY
VM_INHERIT_NONE
VM_INHERIT_SHARE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The non-Apple BSDs seem to use MAP_ as the prefix rather than VM_. I think you'll need to add those constants and update these files.

@oherrala
oherrala force-pushed the macos-minherit branch 8 times, most recently from 6a6f024 to e6d6630 Compare December 4, 2025 11:32
@rustbot

This comment has been minimized.

@oherrala

Copy link
Copy Markdown
Contributor Author

@tgross35 Rebased and also fixed the one issue semarie pointed out.

@semarie semarie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
I would personally prefer to not use #[cfg(target_os = "xxx")] and use proper netbsd/mod.rs and openbsd/mod.rs files.

View changes since this review

@tgross35

Copy link
Copy Markdown
Member

@rustbot author, CI failures are because the semver files aren't accurate

I would personally prefer to not use #[cfg(target_os = "xxx")] and use proper netbsd/mod.rs and openbsd/mod.rs files.

+1 here, could you move these to the separate files? It's fine that SHARE/COPY/NONE will be duplicated.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@oherrala

Copy link
Copy Markdown
Contributor Author

+1 here, could you move these to the separate files? It's fine that SHARE/COPY/NONE will be duplicated.

@tgross35 this is now done.

@rustbot

This comment has been minimized.

Comment thread libc-test/semver/freebsd.txt Outdated
Comment on lines +542 to +1748
@@ -1738,6 +1742,10 @@ VDISCARD
VDSUSP
VERASE2
VLNEXT
VM_INHERIT_COPY
VM_INHERIT_DONATE_COPY
VM_INHERIT_NONE
VM_INHERIT_SHARE

@tgross35 tgross35 Jul 20, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you have both versions here, causing the CI failure

(comment @rustbot ready once CI is working again to relabel for review)

View changes since the review

@rustbot

This comment has been minimized.

@oherrala

Copy link
Copy Markdown
Contributor Author

@rustbot ready

CI seems to break on unrelated issues. I can't trigger re-run.

@rustbot

rustbot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgross35
tgross35 added this pull request to the merge queue Aug 31, 2026
Merged via the queue into rust-lang:main with commit 1e49de2 Aug 31, 2026
58 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Sep 4, 2026
(backport <rust-lang#4849>)
(cherry picked from commit 1e49de2)
@tgross35 tgross35 mentioned this pull request Sep 4, 2026
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-bsd O-dragonfly O-freebsd O-macos O-unix stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants