minios: fix incorrect {, un}likely() definitions

As identified in e5545fb6, likely() and unlikely() must convert their
expressions to booleans before comparing to 1 or 0, to avoid truncation
issues.

While editing this file, add inclusion guards.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
Andrew Cooper authored and Jan Beulich committed 2014-07-02 14:46:42 +02:00
1 parent 1f83dbf0b5
commit 7915fc1587
1 file changed
+7 -2
+7 -2
View File
@@ -1,5 +1,10 @@
#ifndef __MINIOS_COMPILER_H_
#define __MINIOS_COMPILER_H_
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
#define __builtin_expect(x, expected_value) (x)
#endif
#define unlikely(x) __builtin_expect((x),0)
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect(!!(x),0)
#define likely(x) __builtin_expect(!!(x),1)
#endif /* __MINIOS_COMPILER_H_ */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.