Skip to content

Commit 5654446

Browse files
authored
[android] Support building _CFPosixSpawnFileActionsChdir() for older Android APIs too (#5210)
Phase out the existing Android scheme of adding different callbacks based on whether the posix_spawn APIs are there at runtime, by simply linking against them at compile-time instead if a build triple with API 28 or later is specified.
1 parent 873a14c commit 5654446

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Sources/CoreFoundation/CFPlatform.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ CF_CROSS_PLATFORM_EXPORT void *_CFReallocf(void *ptr, size_t size) {
19481948
#endif
19491949
}
19501950

1951-
#if TARGET_OS_ANDROID
1951+
#if TARGET_OS_ANDROID && __ANDROID_API__ < 28
19521952

19531953
#include <dlfcn.h>
19541954
#include <spawn.h>
@@ -2277,6 +2277,10 @@ CF_EXPORT int _CFPosixSpawnFileActionsAddClose(_CFPosixSpawnFileActionsRef file_
22772277
return _CFPosixSpawnFileActionsAddCloseImpl(file_actions, filedes);
22782278
}
22792279

2280+
CF_EXPORT int _CFPosixSpawnFileActionsChdir(_CFPosixSpawnFileActionsRef file_actions, const char *path) {
2281+
return ENOSYS;
2282+
}
2283+
22802284
CF_EXPORT int _CFPosixSpawn(pid_t *_CF_RESTRICT pid, const char *_CF_RESTRICT path, _CFPosixSpawnFileActionsRef file_actions, _CFPosixSpawnAttrRef _Nullable _CF_RESTRICT attrp, char *_Nullable const argv[_Nullable _CF_RESTRICT], char *_Nullable const envp[_Nullable _CF_RESTRICT]) {
22812285
_CFPosixSpawnInitialize();
22822286
return _CFPosixSpawnImpl(pid, path, file_actions, attrp, argv, envp);
@@ -2317,12 +2321,13 @@ CF_EXPORT int _CFPosixSpawnFileActionsChdir(_CFPosixSpawnFileActionsRef file_act
23172321
// Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting:
23182322
// - Amazon Linux 2 (EoL mid-2025)
23192323
return ENOSYS;
2320-
#elif defined(__OpenBSD__) || defined(__QNX__)
2324+
#elif defined(__OpenBSD__) || defined(__QNX__) || (defined(__ANDROID__) && __ANDROID_API__ < 34)
23212325
// Currently missing as of:
23222326
// - OpenBSD 7.5 (April 2024)
23232327
// - QNX 8 (December 2023)
2328+
// - Android 13
23242329
return ENOSYS;
2325-
#elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || (defined(__ANDROID__) && __ANDROID_API__ >= 34) || defined(__musl__)
2330+
#elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__musl__)
23262331
// Pre-standard posix_spawn_file_actions_addchdir_np version available in:
23272332
// - Solaris 11.3 (October 2015)
23282333
// - Glibc 2.29 (February 2019)

0 commit comments

Comments
 (0)