summaryrefslogtreecommitdiffstats
path: root/m4/stdbool.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/stdbool.m4')
-rw-r--r--m4/stdbool.m457
1 files changed, 38 insertions, 19 deletions
diff --git a/m4/stdbool.m4 b/m4/stdbool.m4
index ed000c8..162f1df 100644
--- a/m4/stdbool.m4
+++ b/m4/stdbool.m4
@@ -1,21 +1,9 @@
1# Check for stdbool.h that conforms to C99. 1# Check for stdbool.h that conforms to C99.
2 2
3# Copyright (C) 2002-2003 Free Software Foundation, Inc. 3dnl Copyright (C) 2002-2005 Free Software Foundation, Inc.
4 4dnl This file is free software; the Free Software Foundation
5# This program is free software; you can redistribute it and/or modify 5dnl gives unlimited permission to copy and/or distribute it,
6# it under the terms of the GNU General Public License as published by 6dnl with or without modifications, as long as this notice is preserved.
7# the Free Software Foundation; either version 2, or (at your option)
8# any later version.
9
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18# 02111-1307, USA.
19 7
20# Prepare for substituting <stdbool.h> if it is not supported. 8# Prepare for substituting <stdbool.h> if it is not supported.
21 9
@@ -40,7 +28,10 @@ AC_DEFUN([AM_STDBOOL_H],
40 AC_SUBST([HAVE__BOOL]) 28 AC_SUBST([HAVE__BOOL])
41]) 29])
42 30
43# This macro is only needed in autoconf <= 2.54. Newer versions of autoconf 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
44# have this macro built-in. 35# have this macro built-in.
45 36
46AC_DEFUN([AC_HEADER_STDBOOL], 37AC_DEFUN([AC_HEADER_STDBOOL],
@@ -59,7 +50,7 @@ AC_DEFUN([AC_HEADER_STDBOOL],
59 "error: false is not 0" 50 "error: false is not 0"
60 #endif 51 #endif
61 #ifndef true 52 #ifndef true
62 "error: false is not defined" 53 "error: true is not defined"
63 #endif 54 #endif
64 #if true != 1 55 #if true != 1
65 "error: true is not 1" 56 "error: true is not 1"
@@ -79,8 +70,36 @@ AC_DEFUN([AC_HEADER_STDBOOL],
79 char g[true]; 70 char g[true];
80 char h[sizeof (_Bool)]; 71 char h[sizeof (_Bool)];
81 char i[sizeof s.t]; 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);
82 ], 102 ],
83 [ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ],
84 [ac_cv_header_stdbool_h=yes], 103 [ac_cv_header_stdbool_h=yes],
85 [ac_cv_header_stdbool_h=no])]) 104 [ac_cv_header_stdbool_h=no])])
86 AC_CHECK_TYPES([_Bool]) 105 AC_CHECK_TYPES([_Bool])