Likely/unlikely
This commit is contained in:
parent
4ee23cd145
commit
129b29eaf3
1 changed files with 15 additions and 0 deletions
15
kern/libkern/util.h
Normal file
15
kern/libkern/util.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
/*
|
||||
* Give hints to the compiler for branch prediction optimization.
|
||||
*/
|
||||
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 2))
|
||||
#define likely(c) (__builtin_expect(!!(c), 1))
|
||||
#define unlikely(c) (__builtin_expect(!!(c), 0))
|
||||
#else
|
||||
#define likely(c) (c)
|
||||
#define unlikely(c) (c)
|
||||
#endif
|
||||
|
||||
#endif // UTIL_H
|
Loading…
Add table
Reference in a new issue