xen: Add stdbool.h workaround for BSD.
authorTim Deegan <tim@xen.org>
Thu, 15 Aug 2013 12:00:18 +0000 (13:00 +0100)
committerTim Deegan <tim@xen.org>
Thu, 15 Aug 2013 21:00:45 +0000 (22:00 +0100)
On *BSD, stdbool.h lives in /usr/include, but we don't want to have
that on the search path in case we pick up any headers from the build
host's C libraries.

Copy the equivalent hack already in place for stdarg.h: on all
supported compilers the contents of stdbool.h are trivial, so just
supply the things we need in a xen/stdbool.h header.

Signed-off-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Tested-by: Patrick Welche <prlw1@cam.ac.uk>
xen/include/xen/libelf.h
xen/include/xen/stdbool.h [new file with mode: 0644]

index e65db6df5a2218b985271b200750b5054eabe714..6393040f14dcc25c94d7df6b8675b0ad7c482c03 100644 (file)
@@ -29,8 +29,6 @@
 #error define architectural endianness
 #endif
 
-#include <stdbool.h>
-
 typedef int elf_errorstatus; /* 0: ok; -ve (normally -1): error */
 typedef int elf_negerrnoval; /* 0: ok; -EFOO: error */
 
@@ -39,12 +37,14 @@ typedef int elf_negerrnoval; /* 0: ok; -EFOO: error */
 #ifdef __XEN__
 #include <public/elfnote.h>
 #include <public/features.h>
+#include <xen/stdbool.h>
 #include <xen/string.h>
 #else
 #include <xen/elfnote.h>
 #include <xen/features.h>
 
 #include <stdarg.h>
+#include <stdbool.h>
 #include <string.h>
 
 struct elf_binary;
diff --git a/xen/include/xen/stdbool.h b/xen/include/xen/stdbool.h
new file mode 100644 (file)
index 0000000..2eecd52
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __XEN_STDBOOL_H__
+#define __XEN_STDBOOL_H__
+
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+#  define bool _Bool
+#  define true 1
+#  define false 0
+#  define __bool_true_false_are_defined   1
+#else
+#  include <stdbool.h>
+#endif
+
+#endif /* __XEN_STDBOOL_H__ */