From 7f3b6d5468c716da1d54e74e12528f28938320dd Mon Sep 17 00:00:00 2001 From: r00490903 Date: Tue, 30 May 2023 11:27:38 +0800 Subject: [PATCH] Publish mallopt api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provides memory cache management interfaces for third-party applications. Issue: I79COU Test:Build & Boot devices Signed-off-by: goblinrs --- libc-test/src/functional/test-mallopt.c | 2 +- ndk_musl_include/malloc.h | 11 +++++++++++ ndk_script/adapter/libc.ndk.json | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libc-test/src/functional/test-mallopt.c b/libc-test/src/functional/test-mallopt.c index 4a9e5c42..35d6e08e 100644 --- a/libc-test/src/functional/test-mallopt.c +++ b/libc-test/src/functional/test-mallopt.c @@ -18,7 +18,7 @@ static int test_mallopt() { - return mallopt(0, 0) != 0; + return mallopt(0, 0) == 0; } int main() diff --git a/ndk_musl_include/malloc.h b/ndk_musl_include/malloc.h index 09c9f225..003d9197 100644 --- a/ndk_musl_include/malloc.h +++ b/ndk_musl_include/malloc.h @@ -9,6 +9,16 @@ extern "C" { #include +#define M_SET_THREAD_CACHE -1001 +#define M_THREAD_CACHE_ENABLE 1 +#define M_THREAD_CACHE_DISABLE 0 + +#define M_FLUSH_THREAD_CACHE -1002 + +#define M_DELAYED_FREE -1003 +#define M_DELAYED_FREE_ENABLE 1 +#define M_DELAYED_FREE_DISABLE 0 + void *malloc (size_t); void *calloc (size_t, size_t); void *realloc (void *, size_t); @@ -17,6 +27,7 @@ void *valloc (size_t); void *memalign(size_t, size_t); size_t malloc_usable_size(void *); +int mallopt(int param, int value); struct mallinfo { int arena; diff --git a/ndk_script/adapter/libc.ndk.json b/ndk_script/adapter/libc.ndk.json index 5fa6bc83..d6551612 100644 --- a/ndk_script/adapter/libc.ndk.json +++ b/ndk_script/adapter/libc.ndk.json @@ -736,6 +736,7 @@ { "name": "lutimes" }, { "name": "madvise" }, { "name": "malloc" }, + { "name": "mallopt" }, { "name": "malloc_usable_size" }, { "name": "mblen" }, { "name": "mbrlen" }, -- GitLab