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

Commit15a89e2

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 parent498f30a commit15a89e2

File tree

5 files changed

+45
-160
lines changed

5 files changed

+45
-160
lines changed

‎configure

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

20792079
} # ac_fn_c_check_func
20802080

2081-
#ac_fn_c_check_type LINENOTYPE VAR INCLUDES
2082-
# -------------------------------------------
2083-
#Tests whether TYPE exists after having included INCLUDES, setting cache
2084-
# variable VAR accordingly.
2085-
ac_fn_c_check_type ()
2081+
#ac_fn_c_check_member LINENOAGGR MEMBER VAR INCLUDES
2082+
# ----------------------------------------------------
2083+
#Tries to find if the field MEMBER exists in type AGGR, after including
2084+
#INCLUDES, setting cachevariable VAR accordingly.
2085+
ac_fn_c_check_member ()
20862086
{
20872087
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2088-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
2089-
$as_echo_n "checking for $2... " >&6; }
2090-
if eval \${$3+:} false; then :
2088+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
2089+
$as_echo_n "checking for $2.$3... " >&6; }
2090+
if eval \${$4+:} false; then :
20912091
$as_echo_n "(cached) " >&6
20922092
else
2093-
eval "$3=no"
20942093
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20952094
/* end confdefs.h. */
2096-
$4
2095+
$5
20972096
int
20982097
main ()
20992098
{
2100-
if (sizeof ($2))
2101-
return 0;
2099+
static $2 ac_aggr;
2100+
if (ac_aggr.$3)
2101+
return 0;
21022102
;
21032103
return 0;
21042104
}
21052105
_ACEOF
21062106
if ac_fn_c_try_compile "$LINENO"; then :
2107+
eval "$4=yes"
2108+
else
21072109
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21082110
/* end confdefs.h. */
2109-
$4
2111+
$5
21102112
int
21112113
main ()
21122114
{
2113-
if (sizeof (($2)))
2114-
return 0;
2115+
static $2 ac_aggr;
2116+
if (sizeof ac_aggr.$3)
2117+
return 0;
21152118
;
21162119
return 0;
21172120
}
21182121
_ACEOF
21192122
if ac_fn_c_try_compile "$LINENO"; then :
2120-
2123+
eval "$4=yes"
21212124
else
2122-
eval "$3=yes"
2125+
eval "$4=no"
21232126
fi
21242127
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21252128
fi
21262129
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21272130
fi
2128-
eval ac_res=\$$3
2131+
eval ac_res=\$$4
21292132
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
21302133
$as_echo "$ac_res" >&6; }
21312134
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
21322135

2133-
} #ac_fn_c_check_type
2136+
} #ac_fn_c_check_member
21342137

2135-
#ac_fn_c_check_member LINENOAGGR MEMBER VAR INCLUDES
2136-
# ----------------------------------------------------
2137-
#Tries to find if the field MEMBERexistsin type AGGR, after including
2138-
#INCLUDES, setting cachevariable VAR accordingly.
2139-
ac_fn_c_check_member ()
2138+
#ac_fn_c_check_type LINENOTYPE VAR INCLUDES
2139+
# -------------------------------------------
2140+
#Tests whether TYPEexistsafter having included INCLUDES, setting cache
2141+
# variable VAR accordingly.
2142+
ac_fn_c_check_type ()
21402143
{
21412144
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2142-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
2143-
$as_echo_n "checking for $2.$3... " >&6; }
2144-
if eval \${$4+:} false; then :
2145+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
2146+
$as_echo_n "checking for $2... " >&6; }
2147+
if eval \${$3+:} false; then :
21452148
$as_echo_n "(cached) " >&6
21462149
else
2150+
eval "$3=no"
21472151
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21482152
/* end confdefs.h. */
2149-
$5
2153+
$4
21502154
int
21512155
main ()
21522156
{
2153-
static $2 ac_aggr;
2154-
if (ac_aggr.$3)
2155-
return 0;
2157+
if (sizeof ($2))
2158+
return 0;
21562159
;
21572160
return 0;
21582161
}
21592162
_ACEOF
21602163
if ac_fn_c_try_compile "$LINENO"; then :
2161-
eval "$4=yes"
2162-
else
21632164
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21642165
/* end confdefs.h. */
2165-
$5
2166+
$4
21662167
int
21672168
main ()
21682169
{
2169-
static $2 ac_aggr;
2170-
if (sizeof ac_aggr.$3)
2171-
return 0;
2170+
if (sizeof (($2)))
2171+
return 0;
21722172
;
21732173
return 0;
21742174
}
21752175
_ACEOF
21762176
if ac_fn_c_try_compile "$LINENO"; then :
2177-
eval "$4=yes"
2177+
21782178
else
2179-
eval "$4=no"
2179+
eval "$3=yes"
21802180
fi
21812181
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21822182
fi
21832183
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21842184
fi
2185-
eval ac_res=\$$4
2185+
eval ac_res=\$$3
21862186
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
21872187
$as_echo "$ac_res" >&6; }
21882188
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
21892189

2190-
} #ac_fn_c_check_member
2190+
} #ac_fn_c_check_type
21912191

21922192
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
21932193
# --------------------------------------------
@@ -13253,100 +13253,6 @@ fi
1325313253
## Header files
1325413254
##
1325513255

13256-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
13257-
$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
13258-
if ${ac_cv_header_stdbool_h+:} false; then :
13259-
$as_echo_n "(cached) " >&6
13260-
else
13261-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13262-
/* end confdefs.h. */
13263-
13264-
#include <stdbool.h>
13265-
#ifndef bool
13266-
"error: bool is not defined"
13267-
#endif
13268-
#ifndef false
13269-
"error: false is not defined"
13270-
#endif
13271-
#if false
13272-
"error: false is not 0"
13273-
#endif
13274-
#ifndef true
13275-
"error: true is not defined"
13276-
#endif
13277-
#if true != 1
13278-
"error: true is not 1"
13279-
#endif
13280-
#ifndef __bool_true_false_are_defined
13281-
"error: __bool_true_false_are_defined is not defined"
13282-
#endif
13283-
13284-
struct s { _Bool s: 1; _Bool t; } s;
13285-
13286-
char a[true == 1 ? 1 : -1];
13287-
char b[false == 0 ? 1 : -1];
13288-
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
13289-
char d[(bool) 0.5 == true ? 1 : -1];
13290-
/* See body of main program for 'e'. */
13291-
char f[(_Bool) 0.0 == false ? 1 : -1];
13292-
char g[true];
13293-
char h[sizeof (_Bool)];
13294-
char i[sizeof s.t];
13295-
enum { j = false, k = true, l = false * true, m = true * 256 };
13296-
/* The following fails for
13297-
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
13298-
_Bool n[m];
13299-
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
13300-
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
13301-
/* Catch a bug in an HP-UX C compiler. See
13302-
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
13303-
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
13304-
*/
13305-
_Bool q = true;
13306-
_Bool *pq = &q;
13307-
13308-
int
13309-
main ()
13310-
{
13311-
13312-
bool e = &s;
13313-
*pq |= q;
13314-
*pq |= ! q;
13315-
/* Refer to every declared value, to avoid compiler optimizations. */
13316-
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
13317-
+ !m + !n + !o + !p + !q + !pq);
13318-
13319-
;
13320-
return 0;
13321-
}
13322-
_ACEOF
13323-
if ac_fn_c_try_compile "$LINENO"; then :
13324-
ac_cv_header_stdbool_h=yes
13325-
else
13326-
ac_cv_header_stdbool_h=no
13327-
fi
13328-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13329-
fi
13330-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
13331-
$as_echo "$ac_cv_header_stdbool_h" >&6; }
13332-
ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
13333-
if test "x$ac_cv_type__Bool" = xyes; then :
13334-
13335-
cat >>confdefs.h <<_ACEOF
13336-
#define HAVE__BOOL 1
13337-
_ACEOF
13338-
13339-
13340-
fi
13341-
13342-
13343-
if test $ac_cv_header_stdbool_h = yes; then
13344-
13345-
$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
13346-
13347-
fi
13348-
13349-
1335013256
for ac_header in atomic.h copyfile.h crypt.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.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
1335113257
do :
1335213258
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -15496,9 +15402,7 @@ $as_echo_n "checking size of bool... " >&6; }
1549615402
if ${ac_cv_sizeof_bool+:} false; then :
1549715403
$as_echo_n "(cached) " >&6
1549815404
else
15499-
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (bool))" "ac_cv_sizeof_bool" "#ifdef HAVE_STDBOOL_H
15500-
#include <stdbool.h>
15501-
#endif
15405+
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (bool))" "ac_cv_sizeof_bool" "#include <stdbool.h>
1550215406
"; then :
1550315407

1550415408
else

‎configure.in

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,8 +1397,6 @@ AC_SUBST(UUID_LIBS)
13971397
## Header files
13981398
##
13991399

1400-
AC_HEADER_STDBOOL
1401-
14021400
AC_CHECK_HEADERS(m4_normalize([
14031401
atomic.h
14041402
copyfile.h
@@ -1695,10 +1693,7 @@ if test "$ac_cv_sizeof_off_t" -lt 8 -a "$segsize" != "1"; then
16951693
AC_MSG_ERROR([Large file support is not enabled. Segment size cannot be larger than 1GB.])
16961694
fi
16971695

1698-
AC_CHECK_SIZEOF([bool], [],
1699-
[#ifdef HAVE_STDBOOL_H
1700-
#include <stdbool.h>
1701-
#endif])
1696+
AC_CHECK_SIZEOF([bool], [], [#include <stdbool.h>])
17021697

17031698

17041699
##

‎src/include/c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
* bool
329329
*Boolean value, either true or false.
330330
*
331-
*Usestdbool.h ifavailable and itsbool has size 1. That's useful for
331+
*We usestdbool.h if bool has size 1 after including it. That's useful for
332332
* better compiler and debugger output and for compatibility with third-party
333333
* libraries. But PostgreSQL currently cannot deal with bool of other sizes;
334334
* there are static assertions around the code to prevent that.
@@ -339,7 +339,7 @@
339339

340340
#ifndef__cplusplus
341341

342-
#ifdefined(HAVE_STDBOOL_H)&&SIZEOF_BOOL==1
342+
#ifSIZEOF_BOOL==1
343343
#include<stdbool.h>
344344
#defineUSE_STDBOOL 1
345345
#else

‎src/include/pg_config.h.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,6 @@
519519
/* Define to 1 if you have the `SSL_get_current_compression' function. */
520520
#undef HAVE_SSL_GET_CURRENT_COMPRESSION
521521

522-
/* Define to 1 if stdbool.h conforms to C99. */
523-
#undef HAVE_STDBOOL_H
524-
525522
/* Define to 1 if you have the <stdint.h> header file. */
526523
#undef HAVE_STDINT_H
527524

@@ -742,9 +739,6 @@
742739
/* Define to 1 if the assembler supports X86_64's POPCNTQ instruction. */
743740
#undef HAVE_X86_64_POPCNTQ
744741

745-
/* Define to 1 if the system has the type `_Bool'. */
746-
#undef HAVE__BOOL
747-
748742
/* Define to 1 if your compiler understands __builtin_bswap16. */
749743
#undef HAVE__BUILTIN_BSWAP16
750744

‎src/include/pg_config.h.win32

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,6 @@
395395
/* Define to 1 if you have the `SSL_get_current_compression' function. */
396396
#define HAVE_SSL_GET_CURRENT_COMPRESSION 1
397397

398-
/* Define to 1 if stdbool.h conforms to C99. */
399-
#if (_MSC_VER >= 1800)
400-
#define HAVE_STDBOOL_H 1
401-
#endif
402-
403398
/* Define to 1 if you have the <stdint.h> header file. */
404399
/* #undef HAVE_STDINT_H */
405400

@@ -581,9 +576,6 @@
581576
/* Define to 1 if the assembler supports X86_64's POPCNTQ instruction. */
582577
/* #undef HAVE_X86_64_POPCNTQ */
583578

584-
/* Define to 1 if the system has the type `_Bool'. */
585-
/* #undef HAVE__BOOL */
586-
587579
/* Define to 1 if your compiler understands __builtin_bswap16. */
588580
/* #undef HAVE__BUILTIN_BSWAP16 */
589581

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp