From 035933cdb16ddb6cae235ab6d54cb25e062bd46f Mon Sep 17 00:00:00 2001 From: Vincent Isambart Date: Sun, 27 Aug 2023 15:46:37 +0900 Subject: [PATCH] Add a few declarations for Apple systems --- libc-test/build.rs | 6 ++++++ libc-test/semver/apple.txt | 5 +++++ src/unix/bsd/apple/mod.rs | 27 +++++++++++++++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 48fb4df08e8e9..d6cd3b396aaa4 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -328,6 +328,9 @@ fn test_apple(target: &str) { // FIXME: XCode 13.1 doesn't have it. "TIOCREMOTE" => true, + + // Private value used by debuggers. + "_POSIX_SPAWN_DISABLE_ASLR" => true, _ => false, } }); @@ -353,6 +356,9 @@ fn test_apple(target: &str) { // FIXME: Once the SDK get updated to Ventura's level "freadlink" | "mknodat" | "mkfifoat" => true, + // Private functions + "pthread_chdir_np" | "pthread_fchdir_np" => true, + _ => false, } }); diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index d70ce6fc24749..63e18ac1597e6 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1091,6 +1091,7 @@ POSIX_SPAWN_SETPGROUP POSIX_SPAWN_SETSIGDEF POSIX_SPAWN_SETSIGMASK POSIX_SPAWN_START_SUSPENDED +_POSIX_SPAWN_DISABLE_ASLR PRIO_DARWIN_BG PRIO_DARWIN_NONUI PRIO_DARWIN_PROCESS @@ -2080,6 +2081,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 @@ -2138,6 +2141,8 @@ pthread_rwlockattr_setpshared pthread_setname_np pthread_setschedparam pthread_stack_frame_decode_np +pthread_chdir_np +pthread_fchdir_np ptrace pututxline pwritev diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index b22b40ef9b374..697dcba779ba2 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4719,12 +4719,13 @@ 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; +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_DISABLE_ASLR: ::c_int = 0x0100; pub const POSIX_SPAWN_CLOEXEC_DEFAULT: ::c_int = 0x4000; // sys/ipc.h: @@ -5466,6 +5467,8 @@ extern "C" { policy: ::c_int, param: *const sched_param, ) -> ::c_int; + pub fn pthread_chdir_np(path: *const ::c_char) -> ::c_int; + pub fn pthread_fchdir_np(fd: ::c_int) -> ::c_int; // Available from Big Sur pub fn pthread_introspection_hook_install( @@ -5779,6 +5782,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,