summaryrefslogtreecommitdiff
path: root/m4/stdbool.m4
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-06-22 08:27:18 +0000
committerJim Meyering <jim@meyering.net>2002-06-22 08:27:18 +0000
commit1cbf3518b88e2c1553f64d7483260dad4f02c619 (patch)
tree6d2a42d12893dbd856c40f44dba5749747582196 /m4/stdbool.m4
parent7d04e0b63cba4c1120901eba4e8605721a28b5fb (diff)
downloadcoreutils-1cbf3518b88e2c1553f64d7483260dad4f02c619.tar.xz
New file, from diffutils-2.8.2.
Diffstat (limited to 'm4/stdbool.m4')
-rw-r--r--m4/stdbool.m462
1 files changed, 62 insertions, 0 deletions
diff --git a/m4/stdbool.m4 b/m4/stdbool.m4
new file mode 100644
index 000000000..14e590294
--- /dev/null
+++ b/m4/stdbool.m4
@@ -0,0 +1,62 @@
+# Check for stdbool.h that conforms to C99.
+
+# Copyright (C) 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_DEFUN([AC_HEADER_STDBOOL],
+ [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
+ [ac_cv_header_stdbool_h],
+ [AC_TRY_COMPILE(
+ [
+ #include <stdbool.h>
+ #ifndef bool
+ "error: bool is not defined"
+ #endif
+ #ifndef false
+ "error: false is not defined"
+ #endif
+ #if false
+ "error: false is not 0"
+ #endif
+ #ifndef true
+ "error: false is not defined"
+ #endif
+ #if true != 1
+ "error: true is not 1"
+ #endif
+ #ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+ #endif
+
+ struct s { _Bool s: 1; _Bool t; } s;
+
+ char a[true == 1 ? 1 : -1];
+ char b[false == 0 ? 1 : -1];
+ char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+ char d[(bool) -0.5 == true ? 1 : -1];
+ bool e = &s;
+ char f[(_Bool) -0.0 == false ? 1 : -1];
+ char g[true];
+ char h[sizeof (_Bool)];
+ char i[sizeof s.t];
+ ],
+ [ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ],
+ [ac_cv_header_stdbool_h=yes],
+ [ac_cv_header_stdbool_h=no])])
+ if test $ac_cv_header_stdbool_h = yes; then
+ AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
+ fi])