]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
minios: fix incorrect {, un}likely() definitions
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 2 Jul 2014 12:46:42 +0000 (14:46 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 2 Jul 2014 12:46:42 +0000 (14:46 +0200)
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>
include/compiler.h

index e35c9d50ff3b2b7e4f0f1a1bd3585b6a44b99d4a..41882774f996db2767bdbc91014d991039d0f6b4 100644 (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_ */