From 3d8e98f8bd98134fb909c3876a92536959033ce2 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 25 Jan 2023 23:33:39 +0000 Subject: [PATCH] Add (no-op) ifuncs for SVE optimized routines. This patch doesn't *enable* the SVE optimized routines, but it does let us see if switching them to ifuncs will cause any app compat issues, so that we can more easily use the optimized routines in future. Test: treehugger Change-Id: Ic5fe570bd21687da397b48127bf688f7ec68dd0c --- libc/arch-arm64/dynamic_function_dispatch.cpp | 12 ++++++++++++ libc/arch-arm64/static_function_dispatch.S | 2 ++ 2 files changed, 14 insertions(+) diff --git a/libc/arch-arm64/dynamic_function_dispatch.cpp b/libc/arch-arm64/dynamic_function_dispatch.cpp index 0edc7f702..cd5531163 100644 --- a/libc/arch-arm64/dynamic_function_dispatch.cpp +++ b/libc/arch-arm64/dynamic_function_dispatch.cpp @@ -41,6 +41,12 @@ DEFINE_IFUNC_FOR(memchr) { } } +typedef void* memcmp_func(void*, const void*, size_t); +DEFINE_IFUNC_FOR(memcmp) { + // TODO: enable the SVE version. + RETURN_FUNC(memcmp_func, __memcmp_aarch64); +} + typedef void* memcpy_func(void*, const void*, size_t); DEFINE_IFUNC_FOR(memcpy) { if (arg->_hwcap & HWCAP_ASIMD) { @@ -110,6 +116,12 @@ DEFINE_IFUNC_FOR(strncmp) { RETURN_FUNC(strncmp_func, __strncmp_aarch64); } +typedef size_t strnlen_func(const char*); +DEFINE_IFUNC_FOR(strnlen) { + // TODO: enable the SVE version. + RETURN_FUNC(strnlen_func, __strnlen_aarch64); +} + typedef char* strrchr_func(const char*, int); DEFINE_IFUNC_FOR(strrchr) { if (arg->_hwcap2 & HWCAP2_MTE) { diff --git a/libc/arch-arm64/static_function_dispatch.S b/libc/arch-arm64/static_function_dispatch.S index 5c36de694..c7557f851 100644 --- a/libc/arch-arm64/static_function_dispatch.S +++ b/libc/arch-arm64/static_function_dispatch.S @@ -34,6 +34,7 @@ ENTRY(name); \ END(name) FUNCTION_DELEGATE(memchr, __memchr_aarch64_mte) +FUNCTION_DELEGATE(memcmp, __memcmp_aarch64) FUNCTION_DELEGATE(memcpy, __memcpy_aarch64) FUNCTION_DELEGATE(memmove, __memmove_aarch64) FUNCTION_DELEGATE(stpcpy, __stpcpy_aarch64) @@ -44,5 +45,6 @@ FUNCTION_DELEGATE(strcpy, __strcpy_aarch64) FUNCTION_DELEGATE(strlen, __strlen_aarch64_mte) FUNCTION_DELEGATE(strrchr, __strrchr_aarch64_mte) FUNCTION_DELEGATE(strncmp, __strncmp_aarch64) +FUNCTION_DELEGATE(strnlen, __strnlen_aarch64) NOTE_GNU_PROPERTY()