From 86c86183abf43da82113bfbf0f58eb87a5d2df78 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 1 Dec 2011 13:49:46 -0500 Subject: [PATCH] Add stdbool.h for systems without it. --- compat/stdbool.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ config.h.in | 3 +++ configure | 3 ++- configure.in | 2 +- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 compat/stdbool.h diff --git a/compat/stdbool.h b/compat/stdbool.h new file mode 100644 index 000000000..bd06a1db3 --- /dev/null +++ b/compat/stdbool.h @@ -0,0 +1,44 @@ +/* $OpenBSD: stdbool.h,v 1.5 2010/07/24 22:17:03 guenther Exp $ */ + +/* + * Written by Marc Espie, September 25, 1999 + * Public domain. + */ + +#ifndef _COMPAT_STDBOOL_H_ +#define _COMPAT_STDBOOL_H_ + +#ifndef __cplusplus + +#if (defined(__GNUC__) && __GNUC__ >= 3) || defined(__PCC__) || defined(lint) +/* Support for _C99: type _Bool is already built-in. */ +#define false 0 +#define true 1 + +#else +/* `_Bool' type must promote to `int' or `unsigned int'. */ +typedef enum { + false = 0, + true = 1 +} _Bool; + +/* And those constants must also be available as macros. */ +#define false false +#define true true + +#endif + +/* User visible type `bool' is provided as a macro which may be redefined */ +#define bool _Bool + +#else /* __cplusplus */ +#define _Bool bool +#define bool bool +#define false false +#define true true +#endif /* __cplusplus */ + +/* Inform that everything is fine */ +#define __bool_true_false_are_defined 1 + +#endif /* _COMPAT_STDBOOL_H_ */ diff --git a/config.h.in b/config.h.in index db4cbd73b..b2163abed 100644 --- a/config.h.in +++ b/config.h.in @@ -468,6 +468,9 @@ /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF +/* Define to 1 if you have the header file. */ +#undef HAVE_STDBOOL_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff --git a/configure b/configure index 21227dd10..036709b1f 100755 --- a/configure +++ b/configure @@ -15067,7 +15067,7 @@ $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi -for ac_header in malloc.h paths.h utime.h netgroup.h utmpx.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h sys/sysmacros.h +for ac_header in malloc.h paths.h stdbool.h utime.h netgroup.h utmpx.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h sys/sysmacros.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -22088,5 +22088,6 @@ fi + diff --git a/configure.in b/configure.in index 3955862d0..a91ae0192 100644 --- a/configure.in +++ b/configure.in @@ -1955,7 +1955,7 @@ dnl AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_TIME -AC_CHECK_HEADERS(malloc.h paths.h utime.h netgroup.h utmpx.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h sys/sysmacros.h) +AC_CHECK_HEADERS(malloc.h paths.h stdbool.h utime.h netgroup.h utmpx.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h sys/sysmacros.h) dnl dnl Check for large file support. HP-UX 11.23 has a broken sys/type.h dnl when large files support is enabled so work around it. -- 2.40.0