Skip to content

Commit f367fa2

Browse files
committed
Auto merge of #3328 - vincentisambart:apple-additional-decls, r=JohnTitor
Add a few declarations for Apple systems I added the following definitions for Apple systems: <del> - `_POSIX_SPAWN_DISABLE_ASLR` - It is a private flag for `posix_spawnattr_setflags` that disables [ASLR](https://en.wikipedia.org/wiki/Address_space_layout_randomization) for the child process. - It is mainly used by debuggers. Its declaration in LLDB's source code: https://github.com/llvm/llvm-project/blob/2051a4121957a4bfc015b5102d06ffd6d0852d33/lldb/tools/debugserver/source/MacOSX/MachProcess.mm#L507-L509 - `pthread_chdir_np` and `pthread_fchdir_np` - Private functions that change the working directory only for the current thread. - They are declared and documented in Apple's libpthread: https://github.com/apple-oss-distributions/libpthread/blob/67e155c94093be9a204b69637d198eceff2c7c46/private/pthread/private.h#L44-L89 - They are for example used by Chromium in [this file](https://chromium.googlesource.com/chromium/src/base/+/master/process/launch_mac.cc). - LLDB also uses the [equivalent](https://github.com/apple-oss-distributions/libpthread/blob/main/src/pthread_cwd.c) `__pthread_chdir` and `__pthread_fchdir` in [this file](https://github.com/llvm/llvm-project/blob/main/lldb/source/Host/macosx/objcxx/Host.mm). </del> - `posix_spawnattr_getbinpref_np` and `posix_spawnattr_setbinpref_np` - These methods are public and declared in `/usr/include/spawn.h`. - They are pretty close to the already present `posix_spawnattr_getarchpref_np` and `posix_spawnattr_setarchpref_np`, but you can see that in [this file](https://github.com/llvm/llvm-project/blob/main/lldb/source/Host/macosx/objcxx/Host.mm) LLDB does use both `binpref` and `archpref`.
2 parents a104192 + c861aca commit f367fa2

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

libc-test/semver/apple.txt

+2
Original file line numberDiff line numberDiff line change
@@ -2084,6 +2084,8 @@ posix_spawnattr_setflags
20842084
posix_spawnattr_setpgroup
20852085
posix_spawnattr_setsigdefault
20862086
posix_spawnattr_setsigmask
2087+
posix_spawnattr_getbinpref_np
2088+
posix_spawnattr_setbinpref_np
20872089
posix_spawnattr_t
20882090
posix_spawnp
20892091
preadv

src/unix/bsd/apple/mod.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -4998,12 +4998,12 @@ pub const MNT_SNAPSHOT: ::c_int = 0x40000000;
49984998
pub const MNT_NOBLOCK: ::c_int = 0x00020000;
49994999

50005000
// sys/spawn.h:
5001-
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
5002-
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
5003-
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
5004-
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
5005-
pub const POSIX_SPAWN_SETEXEC: ::c_int = 0x40;
5006-
pub const POSIX_SPAWN_START_SUSPENDED: ::c_int = 0x80;
5001+
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x0001;
5002+
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x0002;
5003+
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x0004;
5004+
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x0008;
5005+
pub const POSIX_SPAWN_SETEXEC: ::c_int = 0x0040;
5006+
pub const POSIX_SPAWN_START_SUSPENDED: ::c_int = 0x0080;
50075007
pub const POSIX_SPAWN_CLOEXEC_DEFAULT: ::c_int = 0x4000;
50085008

50095009
// sys/ipc.h:
@@ -6058,6 +6058,18 @@ extern "C" {
60586058
subpref: *mut ::cpu_subtype_t,
60596059
ocount: *mut ::size_t,
60606060
) -> ::c_int;
6061+
pub fn posix_spawnattr_getbinpref_np(
6062+
attr: *const posix_spawnattr_t,
6063+
count: ::size_t,
6064+
pref: *mut ::cpu_type_t,
6065+
ocount: *mut ::size_t,
6066+
) -> ::c_int;
6067+
pub fn posix_spawnattr_setbinpref_np(
6068+
attr: *mut posix_spawnattr_t,
6069+
count: ::size_t,
6070+
pref: *mut ::cpu_type_t,
6071+
ocount: *mut ::size_t,
6072+
) -> ::c_int;
60616073
pub fn posix_spawnattr_set_qos_class_np(
60626074
attr: *mut posix_spawnattr_t,
60636075
qos_class: ::qos_class_t,

0 commit comments

Comments
 (0)