summaryrefslogtreecommitdiffstats
path: root/m4/stdbool.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/stdbool.m4')
-rw-r--r--m4/stdbool.m4108
1 files changed, 0 insertions, 108 deletions
diff --git a/m4/stdbool.m4 b/m4/stdbool.m4
deleted file mode 100644
index 162f1dfc..00000000
--- a/m4/stdbool.m4
+++ /dev/null
@@ -1,108 +0,0 @@
1# Check for stdbool.h that conforms to C99.
2
3dnl Copyright (C) 2002-2005 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Prepare for substituting <stdbool.h> if it is not supported.
9
10AC_DEFUN([AM_STDBOOL_H],
11[
12 AC_REQUIRE([AC_HEADER_STDBOOL])
13
14 # Define two additional variables used in the Makefile substitution.
15
16 if test "$ac_cv_header_stdbool_h" = yes; then
17 STDBOOL_H=''
18 else
19 STDBOOL_H='stdbool.h'
20 fi
21 AC_SUBST([STDBOOL_H])
22
23 if test "$ac_cv_type__Bool" = yes; then
24 HAVE__BOOL=1
25 else
26 HAVE__BOOL=0
27 fi
28 AC_SUBST([HAVE__BOOL])
29])
30
31# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
32AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
33
34# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf
35# have this macro built-in.
36
37AC_DEFUN([AC_HEADER_STDBOOL],
38 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
39 [ac_cv_header_stdbool_h],
40 [AC_TRY_COMPILE(
41 [
42 #include <stdbool.h>
43 #ifndef bool
44 "error: bool is not defined"
45 #endif
46 #ifndef false
47 "error: false is not defined"
48 #endif
49 #if false
50 "error: false is not 0"
51 #endif
52 #ifndef true
53 "error: true is not defined"
54 #endif
55 #if true != 1
56 "error: true is not 1"
57 #endif
58 #ifndef __bool_true_false_are_defined
59 "error: __bool_true_false_are_defined is not defined"
60 #endif
61
62 struct s { _Bool s: 1; _Bool t; } s;
63
64 char a[true == 1 ? 1 : -1];
65 char b[false == 0 ? 1 : -1];
66 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
67 char d[(bool) -0.5 == true ? 1 : -1];
68 bool e = &s;
69 char f[(_Bool) -0.0 == false ? 1 : -1];
70 char g[true];
71 char h[sizeof (_Bool)];
72 char i[sizeof s.t];
73 enum { j = false, k = true, l = false * true, m = true * 256 };
74 _Bool n[m];
75 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
76 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
77 #if defined __xlc__ || __GNUC__
78 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
79 reported by James Lemley on 2005-10-05; see
80 <http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html>.
81 This test is not quite right, since xlc is allowed to
82 reject this program, as the initializer for xlcbug is
83 not one of the forms that C requires support for.
84 However, doing the test right would require a run-time
85 test, and that would make cross-compilation harder.
86 Let us hope that IBM fixes the xlc bug, and also adds
87 support for this kind of constant expression. In the
88 meantime, this test will reject xlc, which is OK, since
89 our stdbool.h substitute should suffice. */
90 char digs[] = "0123456789";
91 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
92 #endif
93 _Bool q = true;
94 _Bool *pq = &q;
95 ],
96 [
97 *pq |= q;
98 *pq |= ! q;
99 /* Refer to every declared value, to avoid compiler optimizations. */
100 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
101 + !m + !n + !o + !p + !q + !pq);
102 ],
103 [ac_cv_header_stdbool_h=yes],
104 [ac_cv_header_stdbool_h=no])])
105 AC_CHECK_TYPES([_Bool])
106 if test $ac_cv_header_stdbool_h = yes; then
107 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
108 fi])