|
Packit Bot |
06c835 |
# Check for stdbool.h that conforms to C99.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc.
|
|
Packit Bot |
06c835 |
dnl This file is free software; the Free Software Foundation
|
|
Packit Bot |
06c835 |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit Bot |
06c835 |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#serial 5
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
# Prepare for substituting <stdbool.h> if it is not supported.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
AC_DEFUN([AM_STDBOOL_H],
|
|
Packit Bot |
06c835 |
[
|
|
Packit Bot |
06c835 |
AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
# Define two additional variables used in the Makefile substitution.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
if test "$ac_cv_header_stdbool_h" = yes; then
|
|
Packit Bot |
06c835 |
STDBOOL_H=''
|
|
Packit Bot |
06c835 |
else
|
|
Packit Bot |
06c835 |
STDBOOL_H='stdbool.h'
|
|
Packit Bot |
06c835 |
fi
|
|
Packit Bot |
06c835 |
AC_SUBST([STDBOOL_H])
|
|
Packit Bot |
06c835 |
AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
if test "$ac_cv_type__Bool" = yes; then
|
|
Packit Bot |
06c835 |
HAVE__BOOL=1
|
|
Packit Bot |
06c835 |
else
|
|
Packit Bot |
06c835 |
HAVE__BOOL=0
|
|
Packit Bot |
06c835 |
fi
|
|
Packit Bot |
06c835 |
AC_SUBST([HAVE__BOOL])
|
|
Packit Bot |
06c835 |
])
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
|
|
Packit Bot |
06c835 |
AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
# This version of the macro is needed in autoconf <= 2.68.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
|
|
Packit Bot |
06c835 |
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
|
|
Packit Bot |
06c835 |
[ac_cv_header_stdbool_h],
|
|
Packit Bot |
06c835 |
[AC_COMPILE_IFELSE(
|
|
Packit Bot |
06c835 |
[AC_LANG_PROGRAM(
|
|
Packit Bot |
06c835 |
[[
|
|
Packit Bot |
06c835 |
#include <stdbool.h>
|
|
Packit Bot |
06c835 |
#ifndef bool
|
|
Packit Bot |
06c835 |
"error: bool is not defined"
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
#ifndef false
|
|
Packit Bot |
06c835 |
"error: false is not defined"
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
#if false
|
|
Packit Bot |
06c835 |
"error: false is not 0"
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
#ifndef true
|
|
Packit Bot |
06c835 |
"error: true is not defined"
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
#if true != 1
|
|
Packit Bot |
06c835 |
"error: true is not 1"
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
#ifndef __bool_true_false_are_defined
|
|
Packit Bot |
06c835 |
"error: __bool_true_false_are_defined is not defined"
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
struct s { _Bool s: 1; _Bool t; } s;
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
char a[true == 1 ? 1 : -1];
|
|
Packit Bot |
06c835 |
char b[false == 0 ? 1 : -1];
|
|
Packit Bot |
06c835 |
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
|
|
Packit Bot |
06c835 |
char d[(bool) 0.5 == true ? 1 : -1];
|
|
Packit Bot |
06c835 |
/* See body of main program for 'e'. */
|
|
Packit Bot |
06c835 |
char f[(_Bool) 0.0 == false ? 1 : -1];
|
|
Packit Bot |
06c835 |
char g[true];
|
|
Packit Bot |
06c835 |
char h[sizeof (_Bool)];
|
|
Packit Bot |
06c835 |
char i[sizeof s.t];
|
|
Packit Bot |
06c835 |
enum { j = false, k = true, l = false * true, m = true * 256 };
|
|
Packit Bot |
06c835 |
/* The following fails for
|
|
Packit Bot |
06c835 |
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
|
|
Packit Bot |
06c835 |
_Bool n[m];
|
|
Packit Bot |
06c835 |
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
|
|
Packit Bot |
06c835 |
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
|
|
Packit Bot |
06c835 |
/* Catch a bug in an HP-UX C compiler. See
|
|
Packit Bot |
06c835 |
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
|
|
Packit Bot |
06c835 |
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
|
|
Packit Bot |
06c835 |
*/
|
|
Packit Bot |
06c835 |
_Bool q = true;
|
|
Packit Bot |
06c835 |
_Bool *pq = &q;
|
|
Packit Bot |
06c835 |
]],
|
|
Packit Bot |
06c835 |
[[
|
|
Packit Bot |
06c835 |
bool e = &s;
|
|
Packit Bot |
06c835 |
*pq |= q;
|
|
Packit Bot |
06c835 |
*pq |= ! q;
|
|
Packit Bot |
06c835 |
/* Refer to every declared value, to avoid compiler optimizations. */
|
|
Packit Bot |
06c835 |
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
|
|
Packit Bot |
06c835 |
+ !m + !n + !o + !p + !q + !pq);
|
|
Packit Bot |
06c835 |
]])],
|
|
Packit Bot |
06c835 |
[ac_cv_header_stdbool_h=yes],
|
|
Packit Bot |
06c835 |
[ac_cv_header_stdbool_h=no])])
|
|
Packit Bot |
06c835 |
AC_CHECK_TYPES([_Bool])
|
|
Packit Bot |
06c835 |
])
|