If stdbool.h is available use it, otherwise create emulation.

basic.h defines a type 'bool' that conflicts with
the altivec keyword bool which has to be fixed upstream, see
bugs[1][2].

[1] https://bugs.gentoo.org/show_bug.cgi?id=293840
[2] https://bugs.gentoo.org/show_bug.cgi?id=297854

Signed-off-by: Alon Bar-Lev <alon.bar...@gmail.com>
---
 configure.ac                |    2 +-
 src/compat/compat-stdbool.h |   12 ++++++++++++
 src/openvpn/basic.h         |   13 -------------
 src/openvpn/syshead.h       |    1 +
 4 files changed, 14 insertions(+), 14 deletions(-)
 create mode 100644 src/compat/compat-stdbool.h

diff --git a/configure.ac b/configure.ac
index 8ac5ac4..1a284c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -354,7 +354,7 @@ AX_EMPTY_ARRAY
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned long])
 AC_CHECK_HEADERS([ \
-       stdio.h stdarg.h limits.h \
+       stdio.h stdarg.h stdbool.h limits.h \
        time.h errno.h fcntl.h io.h direct.h \
        ctype.h sys/types.h sys/socket.h \
        signal.h unistd.h dlfcn.h \
diff --git a/src/compat/compat-stdbool.h b/src/compat/compat-stdbool.h
new file mode 100644
index 0000000..9941218
--- /dev/null
+++ b/src/compat/compat-stdbool.h
@@ -0,0 +1,12 @@
+#ifndef __COMPAT_STDBOOL_H
+#define __COMPAT_STDBOOL_H
+
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#else
+typedef int bool;
+#define false 0
+#define true 1
+#endif
+
+#endif
diff --git a/src/openvpn/basic.h b/src/openvpn/basic.h
index 7c13e22..298cf10 100644
--- a/src/openvpn/basic.h
+++ b/src/openvpn/basic.h
@@ -25,19 +25,6 @@
 #ifndef BASIC_H
 #define BASIC_H

-/* bool definitions */
-#ifndef bool
-#define bool int
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef false
-#define false 0
-#endif
-
 #define BOOL_CAST(x) ((x) ? (true) : (false))

 /* size of an array */
diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h
index 0595b67..8bc4a0f 100644
--- a/src/openvpn/syshead.h
+++ b/src/openvpn/syshead.h
@@ -26,6 +26,7 @@
 #define SYSHEAD_H

 #include "compat.h"
+#include "compat-stdbool.h"

 /* branch prediction hints */
 #if defined(__GNUC__)
-- 
1.7.3.4


Reply via email to