From 1c4cebb84b9e33aea9a90adfadb031d1f1eba927 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 26 Nov 2024 16:15:25 +0800 Subject: malloc: Optimize small memory clearing for calloc Add calloc-clear-memory.h to clear memory size up to 36 bytes (72 bytes on 64-bit targets) for calloc. Use repeated stores with 1 branch, instead of up to 3 branches. On x86-64, it is faster than memset since calling memset needs 1 indirect branch, 1 broadcast, and up to 4 branches. Signed-off-by: H.J. Lu Reviewed-by: Wilco Dijkstra --- malloc/malloc-internal.h | 1 + 1 file changed, 1 insertion(+) (limited to 'malloc/malloc-internal.h') diff --git a/malloc/malloc-internal.h b/malloc/malloc-internal.h index cba03433fe..3349e2d1fe 100644 --- a/malloc/malloc-internal.h +++ b/malloc/malloc-internal.h @@ -23,6 +23,7 @@ #include #include #include +#include /* Called in the parent process before a fork. */ void __malloc_fork_lock_parent (void) attribute_hidden; -- cgit v1.2.3