No assembly language is required as glibc version >= 2.32. This is because the later glibc version has updated this optimization.
Signed-off-by: Kai Ye yekai13@huawei.com --- src/uadk_utils.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/uadk_utils.c b/src/uadk_utils.c index 2b34b3a..6e91ba2 100644 --- a/src/uadk_utils.c +++ b/src/uadk_utils.c @@ -14,9 +14,20 @@ * limitations under the License. * */ +#include <gnu/libc-version.h> #include "uadk_utils.h"
-#define UADK_MEM_IMPROVE_THRESHOLD 1024 +#define GLIBC_MAIN 2U +#define GLIBC_MINOR 32U +#define UADK_MEM_IMPROVE_THRESHOLD 1024U + +#if __ARM_NEON && defined(__GLIBC__) && defined(__GLIBC_MINOR__) +#define LIBC_VERSION_PREREQ(major, minor) \ + ((__GLIBC__ * 10000 + __GLIBC_MINOR__ * 100) < \ + (major * 10000 + minor * 100)) +#else +#define LIBC_VERSION_PREREQ(major, minor) 0 +#endif
static void *memcpy_large(void *dstpp, const void *srcpp, size_t len) { @@ -56,7 +67,9 @@ static void *memcpy_large(void *dstpp, const void *srcpp, size_t len)
void *uadk_memcpy(void *dstpp, const void *srcpp, size_t len) { - if (len >= UADK_MEM_IMPROVE_THRESHOLD) + /* No assembly language is required as glibc version >= 2.32 */ + if (len >= UADK_MEM_IMPROVE_THRESHOLD && + LIBC_VERSION_PREREQ(GLIBC_MAIN, GLIBC_MINOR)) return memcpy_large(dstpp, srcpp, len); else return memcpy(dstpp, srcpp, len);