From 30a785d9629dace326d58f3a575c795da959965f Mon Sep 17 00:00:00 2001 From: Finagolfin Date: Fri, 9 May 2025 10:05:44 +0530 Subject: [PATCH] [android] Support building `_CFPosixSpawnFileActionsChdir()` for older Android APIs too 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. --- Sources/CoreFoundation/CFPlatform.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sources/CoreFoundation/CFPlatform.c b/Sources/CoreFoundation/CFPlatform.c index 5769a3317e..238f2ecbc8 100644 --- a/Sources/CoreFoundation/CFPlatform.c +++ b/Sources/CoreFoundation/CFPlatform.c @@ -1948,7 +1948,7 @@ CF_CROSS_PLATFORM_EXPORT void *_CFReallocf(void *ptr, size_t size) { #endif } -#if TARGET_OS_ANDROID +#if TARGET_OS_ANDROID && __ANDROID_API__ < 28 #include #include @@ -2277,6 +2277,10 @@ CF_EXPORT int _CFPosixSpawnFileActionsAddClose(_CFPosixSpawnFileActionsRef file_ return _CFPosixSpawnFileActionsAddCloseImpl(file_actions, filedes); } +CF_EXPORT int _CFPosixSpawnFileActionsChdir(_CFPosixSpawnFileActionsRef file_actions, const char *path) { + return ENOSYS; +} + 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]) { _CFPosixSpawnInitialize(); return _CFPosixSpawnImpl(pid, path, file_actions, attrp, argv, envp); @@ -2317,12 +2321,13 @@ CF_EXPORT int _CFPosixSpawnFileActionsChdir(_CFPosixSpawnFileActionsRef file_act // Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting: // - Amazon Linux 2 (EoL mid-2025) return ENOSYS; - #elif defined(__OpenBSD__) || defined(__QNX__) + #elif defined(__OpenBSD__) || defined(__QNX__) || (defined(__ANDROID__) && __ANDROID_API__ < 34) // Currently missing as of: // - OpenBSD 7.5 (April 2024) // - QNX 8 (December 2023) + // - Android 13 return ENOSYS; - #elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || (defined(__ANDROID__) && __ANDROID_API__ >= 34) || defined(__musl__) + #elif defined(__GLIBC__) || TARGET_OS_DARWIN || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__musl__) // Pre-standard posix_spawn_file_actions_addchdir_np version available in: // - Solaris 11.3 (October 2015) // - Glibc 2.29 (February 2019)