xen/build: Use C99 booleans
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 13 Jul 2016 13:55:48 +0000 (14:55 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 15 Jul 2016 09:52:36 +0000 (10:52 +0100)
and switch bool_t to being of type _Bool rather than char.

Using bool_t as char causes several subtle problems; first that a bool_t
actually has more than two values, and that (bool_t)0x100 actually has the
value 0 rather than the expected 1, due to truncation.

Making this change reveals two bugs now caught by the compiler.
errata_c6_eoi_workaround() actually makes use of bool_t having more than two
states, while generic_apic_probe() has a integer in the middle of a compound
bool_t assignment (which triggers a [-Werror=parentheses] warning on Debian
Jessie).

Finally, it turns out that ARM is mixing and matching bool_t and bool, despite
their different semantics.  This change brings the semantics of bool_t to
match bool, but does not alter the current mix.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/arm/p2m.c
xen/arch/arm/platforms/xgene-storm.c
xen/arch/arm/traps.c
xen/arch/x86/acpi/cpu_idle.c
xen/arch/x86/genapic/probe.c
xen/include/asm-arm/types.h
xen/include/asm-x86/types.h
xen/include/xen/device_tree.h
xen/include/xen/types.h

index 976f97b9ea68a835b52dc6535646f51d231159ba..a4bc55a900a2ee11f02340c6425d0596e7507071 100644 (file)
@@ -1,7 +1,6 @@
 #include <xen/config.h>
 #include <xen/sched.h>
 #include <xen/lib.h>
-#include <xen/stdbool.h>
 #include <xen/errno.h>
 #include <xen/domain_page.h>
 #include <xen/bitops.h>
index 70cb655649ccc660c1080ffaeb194e6024d693e1..686b19b6f553a388b70e2c0d75806a6f6d2339b5 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <xen/config.h>
 #include <asm/platform.h>
-#include <xen/stdbool.h>
 #include <xen/vmap.h>
 #include <xen/device_tree.h>
 #include <asm/io.h>
index 33261222e0b521d3d31580e97b4b6d7dc44eff8b..a2eb1da7cd99906e30fc9af6bb8333163dabddcc 100644 (file)
@@ -17,7 +17,6 @@
  */
 
 #include <xen/config.h>
-#include <xen/stdbool.h>
 #include <xen/init.h>
 #include <xen/string.h>
 #include <xen/version.h>
index a21aeeda2d3403550ccfdd8c68393cd1a98bb5ad..7e235a3a2add7b3475e1f743da8645e4eaed4b8a 100644 (file)
@@ -480,7 +480,7 @@ void trace_exit_reason(u32 *irq_traced)
  */
 bool_t errata_c6_eoi_workaround(void)
 {
-    static bool_t fix_needed = -1;
+    static int8_t fix_needed = -1;
 
     if ( unlikely(fix_needed == -1) )
     {
index a5f2a24d15ada06a08c400e0040f23440c56b2c0..860201e5cfa46215a39fcf1fd1b34b451d16e092 100644 (file)
@@ -56,7 +56,8 @@ custom_param("apic", genapic_apic_force);
 
 void __init generic_apic_probe(void) 
 { 
-       int i, changed;
+       bool changed;
+       int i;
 
        record_boot_APIC_mode();
 
index 09e54553645f62d8bcc56b48ec8b352da80de4bb..71d2e423904dc84788213f29725d75b5ae1d57a1 100644 (file)
@@ -62,10 +62,6 @@ typedef unsigned long size_t;
 #endif
 typedef signed long ssize_t;
 
-typedef char bool_t;
-#define test_and_set_bool(b)   xchg(&(b), 1)
-#define test_and_clear_bool(b) xchg(&(b), 0)
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ARM_TYPES_H__ */
index b82fa58aa095f7dd846e46ae961b520d6d7c6060..e75b7445ba6a2aaf5ebf8abef7f34d235d95cae5 100644 (file)
@@ -41,10 +41,6 @@ typedef unsigned long size_t;
 #endif
 typedef signed long ssize_t;
 
-typedef char bool_t;
-#define test_and_set_bool(b)   xchg(&(b), 1)
-#define test_and_clear_bool(b) xchg(&(b), 0)
-
 #endif /* __ASSEMBLY__ */
 
 #endif /* __X86_TYPES_H__ */
index d7d1b40e9110bbb4f36d50e847e844f3b6d7ed57..3657ac20cd05b8dac2a830640bb989fa4cd1365a 100644 (file)
@@ -17,7 +17,6 @@
 #include <xen/init.h>
 #include <xen/string.h>
 #include <xen/types.h>
-#include <xen/stdbool.h>
 #include <xen/list.h>
 
 #define DEVICE_TREE_MAX_DEPTH 16
index 8596ded61c2691812f065f6e7b12bdd742089a50..78410decae7ccc1718a0875e7df9609ce63b8859 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __TYPES_H__
 #define __TYPES_H__
 
+#include <xen/stdbool.h>
+
 #include <asm/types.h>
 
 #define BITS_TO_LONGS(bits) \
@@ -59,4 +61,8 @@ typedef __u64 __be64;
 
 typedef unsigned long uintptr_t;
 
+typedef _Bool bool_t;
+#define test_and_set_bool(b)   xchg(&(b), true)
+#define test_and_clear_bool(b) xchg(&(b), false)
+
 #endif /* __TYPES_H__ */