34 lines
955 B
Diff
34 lines
955 B
Diff
|
From cb0b1c30103abc17dbbed14210bbc59a73802206 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/86] 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.24.1
|
||
|
|