efivar/SOURCES/0001-util.h-add-unlikely-and-likely-macros.patch
2021-09-09 16:19:47 +00:00

34 lines
955 B
Diff

From 9a35c81ba28788831a003c071a96acfab81ca354 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 7 Jan 2019 10:30:23 -0500
Subject: [PATCH 01/63] util.h: add unlikely() and likely() macros
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/util.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/util.h b/src/util.h
index f63a8907611..ba8fee35ae9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -52,6 +52,15 @@
#define PACKED __attribute__((__packed__))
#define VERSION(sym, ver) __asm__(".symver " # sym "," # ver)
+#define __branch_check__(x, expect, is_constant) \
+ __builtin_expect(!!(x), expect)
+#ifndef likely
+#define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x)))
+#endif
+#ifndef unlikely
+#define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
+#endif
+
/*
* I'm not actually sure when these appear, but they're present in the
* version in front of me.
--
2.26.2