Skip to content

Commit 13ee00d

Browse files
committed
[debugserver] Use dlsym for posix_spawnattr_setarchpref_np
The @available check did not work as I thought it did. Use good old dlsym instead.
1 parent 37f0c8d commit 13ee00d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3273,9 +3273,14 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
32733273
bool slice_preference_set = false;
32743274

32753275
if (cpu_subtype != 0) {
3276-
if (@available(macOS 10.16, ios 10.14, watchos 7.0, tvos 14.0, *)) {
3277-
err.SetError(posix_spawnattr_setarchpref_np(&attr, 1, &cpu_type,
3278-
&cpu_subtype, &ocount));
3276+
typedef int (*posix_spawnattr_setarchpref_np_t)(
3277+
posix_spawnattr_t *, size_t, cpu_type_t *, cpu_subtype_t *, size_t *);
3278+
posix_spawnattr_setarchpref_np_t posix_spawnattr_setarchpref_np_fn =
3279+
(posix_spawnattr_setarchpref_np_t)dlsym(
3280+
RTLD_DEFAULT, "posix_spawnattr_setarchpref_np");
3281+
if (posix_spawnattr_setarchpref_np_fn) {
3282+
err.SetError((*posix_spawnattr_setarchpref_np)(&attr, 1, &cpu_type,
3283+
&cpu_subtype, &ocount));
32793284
slice_preference_set = err.Success();
32803285
if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
32813286
err.LogThreaded(

0 commit comments

Comments
 (0)