external/efivar
修订版 | cb0b1c30103abc17dbbed14210bbc59a73802206 (tree) |
---|---|
时间 | 2019-01-08 00:30:23 |
作者 | Peter Jones <pjones@redh...> |
Commiter | Peter Jones |
util.h: add unlikely() and likely() macros
Signed-off-by: Peter Jones <pjones@redhat.com>
@@ -52,6 +52,15 @@ | ||
52 | 52 | #define PACKED __attribute__((__packed__)) |
53 | 53 | #define VERSION(sym, ver) __asm__(".symver " # sym "," # ver) |
54 | 54 | |
55 | +#define __branch_check__(x, expect, is_constant) \ | |
56 | + __builtin_expect(!!(x), expect) | |
57 | +#ifndef likely | |
58 | +#define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x))) | |
59 | +#endif | |
60 | +#ifndef unlikely | |
61 | +#define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) | |
62 | +#endif | |
63 | + | |
55 | 64 | /* |
56 | 65 | * I'm not actually sure when these appear, but they're present in the |
57 | 66 | * version in front of me. |