diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2021-11-17 01:05:54 +0100 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2022-07-24 19:35:11 +0200 |
commit | a405fc138596f552581d2011fd6de02d5c8186c4 (patch) | |
tree | 4c084700b5cb5e9fcedf982a2d921bbc41d9935a /gl/m4/stdbool.m4 | |
parent | 9f2a9ca3d72023ff9b5707d1872c54d65edc9017 (diff) | |
download | monitoring-plugins-a405fc1.tar.gz |
Sync with the latest Gnulib code (1a268176f)
Diffstat (limited to 'gl/m4/stdbool.m4')
-rw-r--r-- | gl/m4/stdbool.m4 | 84 |
1 files changed, 53 insertions, 31 deletions
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4 index 80d5559a..3169779d 100644 --- a/gl/m4/stdbool.m4 +++ b/gl/m4/stdbool.m4 | |||
@@ -1,22 +1,36 @@ | |||
1 | # Check for stdbool.h that conforms to C99. | 1 | # Check for stdbool.h that conforms to C99. |
2 | 2 | ||
3 | dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. | 3 | dnl Copyright (C) 2002-2006, 2009-2021 Free Software Foundation, Inc. |
4 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
5 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
6 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
7 | 7 | ||
8 | #serial 5 | 8 | #serial 8 |
9 | 9 | ||
10 | # Prepare for substituting <stdbool.h> if it is not supported. | 10 | # Prepare for substituting <stdbool.h> if it is not supported. |
11 | 11 | ||
12 | AC_DEFUN([AM_STDBOOL_H], | 12 | AC_DEFUN([AM_STDBOOL_H], |
13 | [ | 13 | [ |
14 | AC_REQUIRE([AC_CHECK_HEADER_STDBOOL]) | 14 | AC_REQUIRE([AC_CHECK_HEADER_STDBOOL]) |
15 | AC_REQUIRE([AC_CANONICAL_HOST]) | ||
15 | 16 | ||
16 | # Define two additional variables used in the Makefile substitution. | 17 | dnl On some platforms, <stdbool.h> does not exist or does not conform to C99. |
17 | 18 | dnl On Solaris 10 with CC=cc CXX=CC, <stdbool.h> exists but is not usable | |
19 | dnl in C++ mode (and no <cstdbool> exists). In this case, we use our | ||
20 | dnl replacement, also in C mode (for binary compatibility between C and C++). | ||
18 | if test "$ac_cv_header_stdbool_h" = yes; then | 21 | if test "$ac_cv_header_stdbool_h" = yes; then |
19 | STDBOOL_H='' | 22 | case "$host_os" in |
23 | solaris*) | ||
24 | if test -z "$GCC"; then | ||
25 | STDBOOL_H='stdbool.h' | ||
26 | else | ||
27 | STDBOOL_H='' | ||
28 | fi | ||
29 | ;; | ||
30 | *) | ||
31 | STDBOOL_H='' | ||
32 | ;; | ||
33 | esac | ||
20 | else | 34 | else |
21 | STDBOOL_H='stdbool.h' | 35 | STDBOOL_H='stdbool.h' |
22 | fi | 36 | fi |
@@ -43,56 +57,64 @@ AC_DEFUN([AC_CHECK_HEADER_STDBOOL], | |||
43 | [AC_LANG_PROGRAM( | 57 | [AC_LANG_PROGRAM( |
44 | [[ | 58 | [[ |
45 | #include <stdbool.h> | 59 | #include <stdbool.h> |
46 | #ifndef bool | 60 | |
47 | "error: bool is not defined" | 61 | #ifdef __cplusplus |
48 | #endif | 62 | typedef bool Bool; |
49 | #ifndef false | 63 | #else |
50 | "error: false is not defined" | 64 | typedef _Bool Bool; |
51 | #endif | 65 | #ifndef bool |
52 | #if false | 66 | "error: bool is not defined" |
53 | "error: false is not 0" | 67 | #endif |
54 | #endif | 68 | #ifndef false |
55 | #ifndef true | 69 | "error: false is not defined" |
56 | "error: true is not defined" | 70 | #endif |
57 | #endif | 71 | #if false |
58 | #if true != 1 | 72 | "error: false is not 0" |
59 | "error: true is not 1" | 73 | #endif |
74 | #ifndef true | ||
75 | "error: true is not defined" | ||
76 | #endif | ||
77 | #if true != 1 | ||
78 | "error: true is not 1" | ||
79 | #endif | ||
60 | #endif | 80 | #endif |
81 | |||
61 | #ifndef __bool_true_false_are_defined | 82 | #ifndef __bool_true_false_are_defined |
62 | "error: __bool_true_false_are_defined is not defined" | 83 | "error: __bool_true_false_are_defined is not defined" |
63 | #endif | 84 | #endif |
64 | 85 | ||
65 | struct s { _Bool s: 1; _Bool t; } s; | 86 | struct s { Bool s: 1; Bool t; bool u: 1; bool v; } s; |
66 | 87 | ||
67 | char a[true == 1 ? 1 : -1]; | 88 | char a[true == 1 ? 1 : -1]; |
68 | char b[false == 0 ? 1 : -1]; | 89 | char b[false == 0 ? 1 : -1]; |
69 | char c[__bool_true_false_are_defined == 1 ? 1 : -1]; | 90 | char c[__bool_true_false_are_defined == 1 ? 1 : -1]; |
70 | char d[(bool) 0.5 == true ? 1 : -1]; | 91 | char d[(bool) 0.5 == true ? 1 : -1]; |
71 | /* See body of main program for 'e'. */ | 92 | /* See body of main program for 'e'. */ |
72 | char f[(_Bool) 0.0 == false ? 1 : -1]; | 93 | char f[(Bool) 0.0 == false ? 1 : -1]; |
73 | char g[true]; | 94 | char g[true]; |
74 | char h[sizeof (_Bool)]; | 95 | char h[sizeof (Bool)]; |
75 | char i[sizeof s.t]; | 96 | char i[sizeof s.t]; |
76 | enum { j = false, k = true, l = false * true, m = true * 256 }; | 97 | enum { j = false, k = true, l = false * true, m = true * 256 }; |
77 | /* The following fails for | 98 | /* The following fails for |
78 | HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ | 99 | HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ |
79 | _Bool n[m]; | 100 | Bool n[m]; |
80 | char o[sizeof n == m * sizeof n[0] ? 1 : -1]; | 101 | char o[sizeof n == m * sizeof n[0] ? 1 : -1]; |
81 | char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; | 102 | char p[-1 - (Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; |
82 | /* Catch a bug in an HP-UX C compiler. See | 103 | /* Catch a bug in an HP-UX C compiler. See |
83 | http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html | 104 | https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html |
84 | http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html | 105 | https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html |
85 | */ | 106 | */ |
86 | _Bool q = true; | 107 | Bool q = true; |
87 | _Bool *pq = &q; | 108 | Bool *pq = &q; |
109 | bool *qq = &q; | ||
88 | ]], | 110 | ]], |
89 | [[ | 111 | [[ |
90 | bool e = &s; | 112 | bool e = &s; |
91 | *pq |= q; | 113 | *pq |= q; *pq |= ! q; |
92 | *pq |= ! q; | 114 | *qq |= q; *qq |= ! q; |
93 | /* Refer to every declared value, to avoid compiler optimizations. */ | 115 | /* Refer to every declared value, to avoid compiler optimizations. */ |
94 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l | 116 | return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l |
95 | + !m + !n + !o + !p + !q + !pq); | 117 | + !m + !n + !o + !p + !q + !pq + !qq); |
96 | ]])], | 118 | ]])], |
97 | [ac_cv_header_stdbool_h=yes], | 119 | [ac_cv_header_stdbool_h=yes], |
98 | [ac_cv_header_stdbool_h=no])]) | 120 | [ac_cv_header_stdbool_h=no])]) |