From fcd09b77254ef1056d48005a6023e682f839659f Mon Sep 17 00:00:00 2001 From: Vincent Isambart Date: Sun, 27 Aug 2023 15:46:37 +0900 Subject: [PATCH 1/2] 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 ffb972cb4145e..5ad1e92404f07 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -336,6 +336,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, } }); @@ -361,6 +364,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 46b35998fd73a..8f7eb3fc2c92a 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 @@ -2084,6 +2085,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 @@ -2142,6 +2145,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 ea06635332791..75bf71a7d1e86 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4998,12 +4998,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: @@ -5745,6 +5746,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( @@ -6058,6 +6061,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, From c861aca6c65105264c64bcf00c56d4f1fe23d5e9 Mon Sep 17 00:00:00 2001 From: Vincent Isambart Date: Thu, 19 Oct 2023 07:52:07 +0900 Subject: [PATCH 2/2] Remove private methods and constants --- libc-test/build.rs | 6 ------ libc-test/semver/apple.txt | 3 --- src/unix/bsd/apple/mod.rs | 3 --- 3 files changed, 12 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 5ad1e92404f07..ffb972cb4145e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -336,9 +336,6 @@ 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, } }); @@ -364,9 +361,6 @@ 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 8f7eb3fc2c92a..ef911271ff425 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1091,7 +1091,6 @@ 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 @@ -2145,8 +2144,6 @@ 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 75bf71a7d1e86..21efb23eb2e32 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5004,7 +5004,6 @@ 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: @@ -5746,8 +5745,6 @@ 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(