From 6c5039bad1879efc87495d762b8c99e56b7a6588 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 14 Apr 2020 14:20:56 +0100 Subject: [PATCH 1/2] Android build fix proposal. malloc_usable_size has different signature on this platform. thread and real time apis are part of bionic. --- CMakeLists.txt | 10 ++++++---- src/alloc-override.c | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61303345..508934dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,10 +146,12 @@ endif() if(WIN32) list(APPEND mi_libraries psapi shell32 user32 bcrypt) else() - list(APPEND mi_libraries pthread) - find_library(LIBRT rt) - if(LIBRT) - list(APPEND mi_libraries ${LIBRT}) + if(NOT ${CC} MATCHES "android") + list(APPEND mi_libraries pthread) + find_library(LIBRT rt) + if(LIBRT) + list(APPEND mi_libraries ${LIBRT}) + endif() endif() endif() diff --git a/src/alloc-override.c b/src/alloc-override.c index c0e7bc2b..569e60ef 100644 --- a/src/alloc-override.c +++ b/src/alloc-override.c @@ -165,7 +165,11 @@ extern "C" { void* reallocf(void* p, size_t newsize) MI_FORWARD2(mi_reallocf,p,newsize); size_t malloc_size(void* p) MI_FORWARD1(mi_usable_size,p); +#if !defined(__ANDROID__) size_t malloc_usable_size(void *p) MI_FORWARD1(mi_usable_size,p); +#else +size_t malloc_usable_size(const void *p) MI_FORWARD1(mi_usable_size,p); +#endif void cfree(void* p) MI_FORWARD0(mi_free, p); // no forwarding here due to aliasing/name mangling issues From 80aeb1bd1d6f22094744bb61bfcfdae5b266f14d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 15 Apr 2020 05:34:07 +0100 Subject: [PATCH 2/2] Fix compiler detection --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 508934dc..e37b5083 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,7 +146,7 @@ endif() if(WIN32) list(APPEND mi_libraries psapi shell32 user32 bcrypt) else() - if(NOT ${CC} MATCHES "android") + if(NOT ${CMAKE_C_COMPILER} MATCHES "android") list(APPEND mi_libraries pthread) find_library(LIBRT rt) if(LIBRT)