Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0305dd3

Browse files
committed
Assume that <stdbool.h> conforms to the C standard.
Previously we checked "for <stdbool.h> that conforms to C99" usingautoconf's AC_HEADER_STDBOOL macro. We've required C99 since PostgreSQL12, so the test was redundant, and under C23 it was broken: autoconf2.69's implementation doesn't understand C23's new empty header (themacros it's looking for went away, replaced by language keywords).Later autoconf versions fixed that, but let's just remove theanachronistic test.HAVE_STDBOOL_H and HAVE__BOOL will no longer be defined, but theyweren't directly tested in core or likely extensions (except in 11, seebelow). PG_USE_STDBOOL (or USE_STDBOOL in 11 and 12) is still definedwhen sizeof(bool) is 1, which should be true on all modern systems.Otherwise we define our own bool type and values of size 1, which wouldfail to compile under C23 as revealed by the broken test. (We'llprobably clean that dead code up in master, but here we want a minimalback-patchable change.)This came to our attention when GCC 15 recently started using using C23by default and failed to compile the replacement code, as reported bySam James and build farm animal alligator.Back-patch to all supported releases, and then two older versions thatalso know about <stdbool.h>, per the recently-out-of-support policy[1].12 requires C99 so it's much like the supported releases, but 11 onlyassumes C89 so it now uses AC_CHECK_HEADERS instead of the overly pickyAC_HEADER_STDBOOL. (I could find no discussion of which historicalsystems had <stdbool.h> but failed the conformance test; if they everexisted, they surely aren't relevant to that policy's goals.)[1]https://wiki.postgresql.org/wiki/Committing_checklist#PoliciesReported-by: Sam James <sam@gentoo.org>Reviewed-by: Peter Eisentraut <peter@eisentraut.org> (master version)Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> (approach)Discussion:https://www.postgresql.org/message-id/flat/87o72eo9iu.fsf%40gentoo.org
1 parente1541d5 commit0305dd3

File tree

4 files changed

+44
-146
lines changed

4 files changed

+44
-146
lines changed

‎configure

Lines changed: 42 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,116 +2072,116 @@ $as_echo "$ac_res" >&6; }
20722072

20732073
} # ac_fn_c_check_func
20742074

2075-
#ac_fn_c_check_type LINENOTYPE VAR INCLUDES
2076-
# -------------------------------------------
2077-
#Tests whether TYPE exists after having included INCLUDES, setting cache
2078-
# variable VAR accordingly.
2079-
ac_fn_c_check_type ()
2075+
#ac_fn_c_check_member LINENOAGGR MEMBER VAR INCLUDES
2076+
# ----------------------------------------------------
2077+
#Tries to find if the field MEMBER exists in type AGGR, after including
2078+
#INCLUDES, setting cachevariable VAR accordingly.
2079+
ac_fn_c_check_member ()
20802080
{
20812081
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2082-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
2083-
$as_echo_n "checking for $2... " >&6; }
2084-
if eval \${$3+:} false; then :
2082+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
2083+
$as_echo_n "checking for $2.$3... " >&6; }
2084+
if eval \${$4+:} false; then :
20852085
$as_echo_n "(cached) " >&6
20862086
else
2087-
eval "$3=no"
20882087
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20892088
/* end confdefs.h. */
2090-
$4
2089+
$5
20912090
int
20922091
main ()
20932092
{
2094-
if (sizeof ($2))
2095-
return 0;
2093+
static $2 ac_aggr;
2094+
if (ac_aggr.$3)
2095+
return 0;
20962096
;
20972097
return 0;
20982098
}
20992099
_ACEOF
21002100
if ac_fn_c_try_compile "$LINENO"; then :
2101+
eval "$4=yes"
2102+
else
21012103
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21022104
/* end confdefs.h. */
2103-
$4
2105+
$5
21042106
int
21052107
main ()
21062108
{
2107-
if (sizeof (($2)))
2108-
return 0;
2109+
static $2 ac_aggr;
2110+
if (sizeof ac_aggr.$3)
2111+
return 0;
21092112
;
21102113
return 0;
21112114
}
21122115
_ACEOF
21132116
if ac_fn_c_try_compile "$LINENO"; then :
2114-
2117+
eval "$4=yes"
21152118
else
2116-
eval "$3=yes"
2119+
eval "$4=no"
21172120
fi
21182121
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21192122
fi
21202123
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21212124
fi
2122-
eval ac_res=\$$3
2125+
eval ac_res=\$$4
21232126
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
21242127
$as_echo "$ac_res" >&6; }
21252128
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
21262129

2127-
} #ac_fn_c_check_type
2130+
} #ac_fn_c_check_member
21282131

2129-
#ac_fn_c_check_member LINENOAGGR MEMBER VAR INCLUDES
2130-
# ----------------------------------------------------
2131-
#Tries to find if the field MEMBERexistsin type AGGR, after including
2132-
#INCLUDES, setting cachevariable VAR accordingly.
2133-
ac_fn_c_check_member ()
2132+
#ac_fn_c_check_type LINENOTYPE VAR INCLUDES
2133+
# -------------------------------------------
2134+
#Tests whether TYPEexistsafter having included INCLUDES, setting cache
2135+
# variable VAR accordingly.
2136+
ac_fn_c_check_type ()
21342137
{
21352138
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2136-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
2137-
$as_echo_n "checking for $2.$3... " >&6; }
2138-
if eval \${$4+:} false; then :
2139+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
2140+
$as_echo_n "checking for $2... " >&6; }
2141+
if eval \${$3+:} false; then :
21392142
$as_echo_n "(cached) " >&6
21402143
else
2144+
eval "$3=no"
21412145
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21422146
/* end confdefs.h. */
2143-
$5
2147+
$4
21442148
int
21452149
main ()
21462150
{
2147-
static $2 ac_aggr;
2148-
if (ac_aggr.$3)
2149-
return 0;
2151+
if (sizeof ($2))
2152+
return 0;
21502153
;
21512154
return 0;
21522155
}
21532156
_ACEOF
21542157
if ac_fn_c_try_compile "$LINENO"; then :
2155-
eval "$4=yes"
2156-
else
21572158
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21582159
/* end confdefs.h. */
2159-
$5
2160+
$4
21602161
int
21612162
main ()
21622163
{
2163-
static $2 ac_aggr;
2164-
if (sizeof ac_aggr.$3)
2165-
return 0;
2164+
if (sizeof (($2)))
2165+
return 0;
21662166
;
21672167
return 0;
21682168
}
21692169
_ACEOF
21702170
if ac_fn_c_try_compile "$LINENO"; then :
2171-
eval "$4=yes"
2171+
21722172
else
2173-
eval "$4=no"
2173+
eval "$3=yes"
21742174
fi
21752175
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21762176
fi
21772177
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21782178
fi
2179-
eval ac_res=\$$4
2179+
eval ac_res=\$$3
21802180
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
21812181
$as_echo "$ac_res" >&6; }
21822182
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
21832183

2184-
} #ac_fn_c_check_member
2184+
} #ac_fn_c_check_type
21852185

21862186
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
21872187
# --------------------------------------------
@@ -12910,101 +12910,7 @@ fi
1291012910
## Header files
1291112911
##
1291212912

12913-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
12914-
$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
12915-
if ${ac_cv_header_stdbool_h+:} false; then :
12916-
$as_echo_n "(cached) " >&6
12917-
else
12918-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12919-
/* end confdefs.h. */
12920-
12921-
#include <stdbool.h>
12922-
#ifndef bool
12923-
"error: bool is not defined"
12924-
#endif
12925-
#ifndef false
12926-
"error: false is not defined"
12927-
#endif
12928-
#if false
12929-
"error: false is not 0"
12930-
#endif
12931-
#ifndef true
12932-
"error: true is not defined"
12933-
#endif
12934-
#if true != 1
12935-
"error: true is not 1"
12936-
#endif
12937-
#ifndef __bool_true_false_are_defined
12938-
"error: __bool_true_false_are_defined is not defined"
12939-
#endif
12940-
12941-
struct s { _Bool s: 1; _Bool t; } s;
12942-
12943-
char a[true == 1 ? 1 : -1];
12944-
char b[false == 0 ? 1 : -1];
12945-
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
12946-
char d[(bool) 0.5 == true ? 1 : -1];
12947-
/* See body of main program for 'e'. */
12948-
char f[(_Bool) 0.0 == false ? 1 : -1];
12949-
char g[true];
12950-
char h[sizeof (_Bool)];
12951-
char i[sizeof s.t];
12952-
enum { j = false, k = true, l = false * true, m = true * 256 };
12953-
/* The following fails for
12954-
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
12955-
_Bool n[m];
12956-
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
12957-
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
12958-
/* Catch a bug in an HP-UX C compiler. See
12959-
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
12960-
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
12961-
*/
12962-
_Bool q = true;
12963-
_Bool *pq = &q;
12964-
12965-
int
12966-
main ()
12967-
{
12968-
12969-
bool e = &s;
12970-
*pq |= q;
12971-
*pq |= ! q;
12972-
/* Refer to every declared value, to avoid compiler optimizations. */
12973-
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
12974-
+ !m + !n + !o + !p + !q + !pq);
12975-
12976-
;
12977-
return 0;
12978-
}
12979-
_ACEOF
12980-
if ac_fn_c_try_compile "$LINENO"; then :
12981-
ac_cv_header_stdbool_h=yes
12982-
else
12983-
ac_cv_header_stdbool_h=no
12984-
fi
12985-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12986-
fi
12987-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
12988-
$as_echo "$ac_cv_header_stdbool_h" >&6; }
12989-
ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
12990-
if test "x$ac_cv_type__Bool" = xyes; then :
12991-
12992-
cat >>confdefs.h <<_ACEOF
12993-
#define HAVE__BOOL 1
12994-
_ACEOF
12995-
12996-
12997-
fi
12998-
12999-
13000-
if test $ac_cv_header_stdbool_h = yes; then
13001-
13002-
$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
13003-
13004-
fi
13005-
13006-
13007-
for ac_header in atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h
12913+
for ac_header in atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h stdbool.h sys/epoll.h sys/ipc.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h
1300812914
do :
1300912915
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
1301012916
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"

‎configure.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,9 +1392,7 @@ AC_SUBST(UUID_LIBS)
13921392
## Header files
13931393
##
13941394

1395-
AC_HEADER_STDBOOL
1396-
1397-
AC_CHECK_HEADERS([atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h])
1395+
AC_CHECK_HEADERS([atomic.h crypt.h dld.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h stdbool.h sys/epoll.h sys/ipc.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h])
13981396

13991397
# On BSD, test for net/if.h will fail unless sys/socket.h
14001398
# is included first.

‎src/include/pg_config.h.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@
507507
/* Define to 1 if you have the `SSL_get_current_compression' function. */
508508
#undef HAVE_SSL_GET_CURRENT_COMPRESSION
509509

510-
/* Define to 1 if stdbool.h conforms to C99. */
510+
/* Define to 1 ifyou have the <stdbool.h> header file. */
511511
#undef HAVE_STDBOOL_H
512512

513513
/* Define to 1 if you have the <stdint.h> header file. */
@@ -721,9 +721,6 @@
721721
/* Define to 1 if you have the `X509_get_signature_nid' function. */
722722
#undef HAVE_X509_GET_SIGNATURE_NID
723723

724-
/* Define to 1 if the system has the type `_Bool'. */
725-
#undef HAVE__BOOL
726-
727724
/* Define to 1 if your compiler understands __builtin_bswap16. */
728725
#undef HAVE__BUILTIN_BSWAP16
729726

‎src/include/pg_config.h.win32

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,6 @@
574574
/* Define to 1 if you have the `X509_get_signature_nid' function. */
575575
#define HAVE_X509_GET_SIGNATURE_NID 1
576576

577-
/* Define to 1 if the system has the type `_Bool'. */
578-
/* #undef HAVE__BOOL */
579-
580577
/* Define to 1 if your compiler understands __builtin_bswap16. */
581578
/* #undef HAVE__BUILTIN_BSWAP16 */
582579

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp