]> git.ipfire.org Git - collecty.git/commitdiff
util: Add macros for branch prediction
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Oct 2025 14:04:30 +0000 (14:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Oct 2025 14:04:30 +0000 (14:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/util.h

index bbe075bf11a5623a9120c112cdd41f7a3d9dddaf..86865e14c390ef7d943929b53015d4cfa254a60e 100644 (file)
 #include <stdint.h>
 #include <stdlib.h>
 
+// Macros to help the compiler with branch prediction
+#define likely(x)               __builtin_expect(!!(x), 1)
+#define unlikely(x)             __builtin_expect(!!(x), 0)
+
 #ifndef HAVE_SECURE_GETENV
 #  ifdef HAVE___SECURE_GETENV
 #    define secure_getenv __secure_getenv