Skip to content

bsd: Add missing minherit system call#4849

Open
oherrala wants to merge 1 commit into
rust-lang:mainfrom
oherrala:macos-minherit
Open

bsd: Add missing minherit system call#4849
oherrala wants to merge 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
Contributor

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
Contributor

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
Contributor

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
@tgross35

Copy link
Copy Markdown
Contributor

@oherrala this seems reasonably fine to me, any reason it's marked as a draft still?

@oherrala oherrala marked this pull request as ready for review June 18, 2026 09:37
@rustbot

rustbot commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in an OpenBSD module

cc @semarie

Some changes occurred in a NetBSD-like module

cc @semarie

@oherrala

Copy link
Copy Markdown
Contributor Author

@tgross35 this is needed for one of my free time projects that has been on hold and I've forgotten about this. Sorry about that. Now marked as ready for review.

Comment thread src/unix/bsd/netbsdlike/mod.rs Outdated
#[cfg(target_os = "netbsd")]
pub const MAP_INHERIT_DONATE_COPY: c_int = 3;
#[cfg(target_os = "netbsd")]
pub const MAP_INHERIT_ZERO: c_int = 4;

@semarie semarie Jun 18, 2026

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.

MAP_INHERIT_ZERO exists in OpenBSD with value 3.
here you omit it, and still declaring it in the semver openbsd.txt file.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@semarie Good catch! Fixed:

#[cfg(target_os = "openbsd")]
pub const MAP_INHERIT_ZERO: c_int = 3;

@tgross35

Copy link
Copy Markdown
Contributor

Could you rebase this as well? There have been some changes to freebsd CI.

@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
Contributor

@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

rustbot commented Jul 13, 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.

@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.

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 S-waiting-on-author stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants