Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few declarations for Apple systems #3328

Merged
merged 2 commits into from Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc-test/semver/apple.txt
Expand Up @@ -2084,6 +2084,8 @@ posix_spawnattr_setflags
posix_spawnattr_setpgroup
posix_spawnattr_setsigdefault
posix_spawnattr_setsigmask
posix_spawnattr_getbinpref_np
posix_spawnattr_setbinpref_np
posix_spawnattr_t
posix_spawnp
preadv
Expand Down
24 changes: 18 additions & 6 deletions src/unix/bsd/apple/mod.rs
Expand Up @@ -4998,12 +4998,12 @@ pub const MNT_SNAPSHOT: ::c_int = 0x40000000;
pub const MNT_NOBLOCK: ::c_int = 0x00020000;

// sys/spawn.h:
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
pub const POSIX_SPAWN_SETEXEC: ::c_int = 0x40;
pub const POSIX_SPAWN_START_SUSPENDED: ::c_int = 0x80;
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x0001;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are declared with 4 digits in sys/spawn.h, and having them all 4 digits aligns a bit better so I made them all 4 digits. I can revert that if you prefer.
posix_spawnattr_setflags and posix_spawnattr_getflags use short so I think they should be declared ::c_short (in C they are defined with #define so not really typed), but that would probably break compatibility so I left the type as-is, even for the _POSIX_SPAWN_DISABLE_ASLR I added.

pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x0002;
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x0004;
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x0008;
pub const POSIX_SPAWN_SETEXEC: ::c_int = 0x0040;
pub const POSIX_SPAWN_START_SUSPENDED: ::c_int = 0x0080;
pub const POSIX_SPAWN_CLOEXEC_DEFAULT: ::c_int = 0x4000;

// sys/ipc.h:
Expand Down Expand Up @@ -6058,6 +6058,18 @@ extern "C" {
subpref: *mut ::cpu_subtype_t,
ocount: *mut ::size_t,
) -> ::c_int;
pub fn posix_spawnattr_getbinpref_np(
attr: *const posix_spawnattr_t,
count: ::size_t,
pref: *mut ::cpu_type_t,
ocount: *mut ::size_t,
) -> ::c_int;
pub fn posix_spawnattr_setbinpref_np(
attr: *mut posix_spawnattr_t,
count: ::size_t,
pref: *mut ::cpu_type_t,
ocount: *mut ::size_t,
) -> ::c_int;
pub fn posix_spawnattr_set_qos_class_np(
attr: *mut posix_spawnattr_t,
qos_class: ::qos_class_t,
Expand Down