]> git.ipfire.org Git - pakfire.git/commitdiff
util: Introduce macros to tell the compiler how likely branches are
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Jan 2025 11:01:25 +0000 (11:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Jan 2025 11:01:25 +0000 (11:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/util.h

index c3c9f00e1228ab04a07103f07126160d904538fb..8de8827d033afbc1b867db5658e8905a9225e744 100644 (file)
 
 #include <pakfire/ctx.h>
 
+// Macros to help the compiler with branch prediction
+#define likely(x)              __builtin_expect(!!(x), 1)
+#define unlikely(x)            __builtin_expect(!!(x), 0)
+
 /*
        This implementation of realloc frees the original buffer
        if it could not be resized.