From d97050594b6f94f20288d4f81846b4d08207273a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 27 Apr 2023 12:57:00 -0700 Subject: [PATCH] Detect ASharedMemory_create() support Make linking with the android library optional. Signed-off-by: Bart Van Assche --- configure | 20 ++++++++++++++++++++ os/os-ashmem.h | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/configure b/configure index abb6d016..ca03350b 100755 --- a/configure +++ b/configure @@ -1345,6 +1345,23 @@ if compile_prog "" "" "sync_file_range"; then fi print_config "sync_file_range" "$sync_file_range" +########################################## +# ASharedMemory_create() probe +if test "$ASharedMemory_create" != "yes" ; then + ASharedMemory_create="no" +fi +cat > $TMPC << EOF +#include +int main(int argc, char **argv) +{ + return ASharedMemory_create("", 0); +} +EOF +if compile_prog "" "" "ASharedMemory_create"; then + ASharedMemory_create="yes" +fi +print_config "ASharedMemory_create" "$ASharedMemory_create" + ########################################## # ext4 move extent probe if test "$ext4_me" != "yes" ; then @@ -3011,6 +3028,9 @@ fi if test "$sync_file_range" = "yes" ; then output_sym "CONFIG_SYNC_FILE_RANGE" fi +if test "$ASharedMemory_create" = "yes" ; then + output_sym "CONFIG_ASHAREDMEMORY_CREATE" +fi if test "$sfaa" = "yes" ; then output_sym "CONFIG_SFAA" fi diff --git a/os/os-ashmem.h b/os/os-ashmem.h index c34ff656..80eab7c4 100644 --- a/os/os-ashmem.h +++ b/os/os-ashmem.h @@ -6,7 +6,7 @@ #include #include #include -#if __ANDROID_API__ >= __ANDROID_API_O__ +#ifdef CONFIG_ASHAREDMEMORY_CREATE #include #else #define ASHMEM_DEVICE "/dev/ashmem" @@ -27,7 +27,7 @@ static inline int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) return ret; } -#if __ANDROID_API__ >= __ANDROID_API_O__ +#ifdef CONFIG_ASHAREDMEMORY_CREATE static inline int shmget(key_t __key, size_t __size, int __shmflg) { char keybuf[11]; -- 2.25.1