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

Commitf20b328

Browse files
committed
Add configure tests for stdbool.h and sizeof bool
This will allow us to assess how many platforms have bool with a sizeother than 1, which will help us decide how to go forward with usingstdbool.h.Discussion:https://www.postgresql.org/message-id/flat/3a0fe7e1-5ed1-414b-9230-53bbc0ed1f49@2ndquadrant.com
1 parentd2d7988 commitf20b328

File tree

3 files changed

+188
-41
lines changed

3 files changed

+188
-41
lines changed

‎configure

Lines changed: 172 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,116 +2107,116 @@ $as_echo "$ac_res" >&6; }
21072107

21082108
} # ac_fn_c_check_func
21092109

2110-
#ac_fn_c_check_member LINENOAGGR MEMBER VAR INCLUDES
2111-
# ----------------------------------------------------
2112-
#Tries to find if the field MEMBERexistsin type AGGR, after including
2113-
#INCLUDES, setting cachevariable VAR accordingly.
2114-
ac_fn_c_check_member ()
2110+
#ac_fn_c_check_type LINENOTYPE VAR INCLUDES
2111+
# -------------------------------------------
2112+
#Tests whether TYPEexistsafter having included INCLUDES, setting cache
2113+
# variable VAR accordingly.
2114+
ac_fn_c_check_type ()
21152115
{
21162116
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2117-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
2118-
$as_echo_n "checking for $2.$3... " >&6; }
2119-
if eval \${$4+:} false; then :
2117+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
2118+
$as_echo_n "checking for $2... " >&6; }
2119+
if eval \${$3+:} false; then :
21202120
$as_echo_n "(cached) " >&6
21212121
else
2122+
eval "$3=no"
21222123
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21232124
/* end confdefs.h. */
2124-
$5
2125+
$4
21252126
int
21262127
main ()
21272128
{
2128-
static $2 ac_aggr;
2129-
if (ac_aggr.$3)
2130-
return 0;
2129+
if (sizeof ($2))
2130+
return 0;
21312131
;
21322132
return 0;
21332133
}
21342134
_ACEOF
21352135
if ac_fn_c_try_compile "$LINENO"; then :
2136-
eval "$4=yes"
2137-
else
21382136
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21392137
/* end confdefs.h. */
2140-
$5
2138+
$4
21412139
int
21422140
main ()
21432141
{
2144-
static $2 ac_aggr;
2145-
if (sizeof ac_aggr.$3)
2146-
return 0;
2142+
if (sizeof (($2)))
2143+
return 0;
21472144
;
21482145
return 0;
21492146
}
21502147
_ACEOF
21512148
if ac_fn_c_try_compile "$LINENO"; then :
2152-
eval "$4=yes"
2149+
21532150
else
2154-
eval "$4=no"
2151+
eval "$3=yes"
21552152
fi
21562153
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21572154
fi
21582155
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21592156
fi
2160-
eval ac_res=\$$4
2157+
eval ac_res=\$$3
21612158
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
21622159
$as_echo "$ac_res" >&6; }
21632160
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
21642161

2165-
} #ac_fn_c_check_member
2162+
} #ac_fn_c_check_type
21662163

2167-
#ac_fn_c_check_type LINENOTYPE VAR INCLUDES
2168-
# -------------------------------------------
2169-
#Tests whether TYPE exists after having included INCLUDES, setting cache
2170-
# variable VAR accordingly.
2171-
ac_fn_c_check_type ()
2164+
#ac_fn_c_check_member LINENOAGGR MEMBER VAR INCLUDES
2165+
# ----------------------------------------------------
2166+
#Tries to find if the field MEMBER exists in type AGGR, after including
2167+
#INCLUDES, setting cachevariable VAR accordingly.
2168+
ac_fn_c_check_member ()
21722169
{
21732170
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2174-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
2175-
$as_echo_n "checking for $2... " >&6; }
2176-
if eval \${$3+:} false; then :
2171+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
2172+
$as_echo_n "checking for $2.$3... " >&6; }
2173+
if eval \${$4+:} false; then :
21772174
$as_echo_n "(cached) " >&6
21782175
else
2179-
eval "$3=no"
21802176
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21812177
/* end confdefs.h. */
2182-
$4
2178+
$5
21832179
int
21842180
main ()
21852181
{
2186-
if (sizeof ($2))
2187-
return 0;
2182+
static $2 ac_aggr;
2183+
if (ac_aggr.$3)
2184+
return 0;
21882185
;
21892186
return 0;
21902187
}
21912188
_ACEOF
21922189
if ac_fn_c_try_compile "$LINENO"; then :
2190+
eval "$4=yes"
2191+
else
21932192
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21942193
/* end confdefs.h. */
2195-
$4
2194+
$5
21962195
int
21972196
main ()
21982197
{
2199-
if (sizeof (($2)))
2200-
return 0;
2198+
static $2 ac_aggr;
2199+
if (sizeof ac_aggr.$3)
2200+
return 0;
22012201
;
22022202
return 0;
22032203
}
22042204
_ACEOF
22052205
if ac_fn_c_try_compile "$LINENO"; then :
2206-
2206+
eval "$4=yes"
22072207
else
2208-
eval "$3=yes"
2208+
eval "$4=no"
22092209
fi
22102210
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22112211
fi
22122212
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22132213
fi
2214-
eval ac_res=\$$3
2214+
eval ac_res=\$$4
22152215
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
22162216
$as_echo "$ac_res" >&6; }
22172217
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
22182218

2219-
} #ac_fn_c_check_type
2219+
} #ac_fn_c_check_member
22202220

22212221
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
22222222
# --------------------------------------------
@@ -12305,6 +12305,100 @@ fi
1230512305
## Header files
1230612306
##
1230712307

12308+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
12309+
$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
12310+
if ${ac_cv_header_stdbool_h+:} false; then :
12311+
$as_echo_n "(cached) " >&6
12312+
else
12313+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12314+
/* end confdefs.h. */
12315+
12316+
#include <stdbool.h>
12317+
#ifndef bool
12318+
"error: bool is not defined"
12319+
#endif
12320+
#ifndef false
12321+
"error: false is not defined"
12322+
#endif
12323+
#if false
12324+
"error: false is not 0"
12325+
#endif
12326+
#ifndef true
12327+
"error: true is not defined"
12328+
#endif
12329+
#if true != 1
12330+
"error: true is not 1"
12331+
#endif
12332+
#ifndef __bool_true_false_are_defined
12333+
"error: __bool_true_false_are_defined is not defined"
12334+
#endif
12335+
12336+
struct s { _Bool s: 1; _Bool t; } s;
12337+
12338+
char a[true == 1 ? 1 : -1];
12339+
char b[false == 0 ? 1 : -1];
12340+
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
12341+
char d[(bool) 0.5 == true ? 1 : -1];
12342+
/* See body of main program for 'e'. */
12343+
char f[(_Bool) 0.0 == false ? 1 : -1];
12344+
char g[true];
12345+
char h[sizeof (_Bool)];
12346+
char i[sizeof s.t];
12347+
enum { j = false, k = true, l = false * true, m = true * 256 };
12348+
/* The following fails for
12349+
HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
12350+
_Bool n[m];
12351+
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
12352+
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
12353+
/* Catch a bug in an HP-UX C compiler. See
12354+
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
12355+
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
12356+
*/
12357+
_Bool q = true;
12358+
_Bool *pq = &q;
12359+
12360+
int
12361+
main ()
12362+
{
12363+
12364+
bool e = &s;
12365+
*pq |= q;
12366+
*pq |= ! q;
12367+
/* Refer to every declared value, to avoid compiler optimizations. */
12368+
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
12369+
+ !m + !n + !o + !p + !q + !pq);
12370+
12371+
;
12372+
return 0;
12373+
}
12374+
_ACEOF
12375+
if ac_fn_c_try_compile "$LINENO"; then :
12376+
ac_cv_header_stdbool_h=yes
12377+
else
12378+
ac_cv_header_stdbool_h=no
12379+
fi
12380+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12381+
fi
12382+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
12383+
$as_echo "$ac_cv_header_stdbool_h" >&6; }
12384+
ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
12385+
if test "x$ac_cv_type__Bool" = xyes; then :
12386+
12387+
cat >>confdefs.h <<_ACEOF
12388+
#define HAVE__BOOL 1
12389+
_ACEOF
12390+
12391+
12392+
fi
12393+
12394+
12395+
if test $ac_cv_header_stdbool_h = yes; then
12396+
12397+
$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
12398+
12399+
fi
12400+
12401+
1230812402
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
1230912403
do :
1231012404
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -14483,6 +14577,43 @@ if test "$ac_cv_sizeof_off_t" -lt 8 -a "$segsize" != "1"; then
1448314577
as_fn_error $? "Large file support is not enabled. Segment size cannot be larger than 1GB." "$LINENO" 5
1448414578
fi
1448514579

14580+
# The cast to long int works around a bug in the HP C Compiler
14581+
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
14582+
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
14583+
# This bug is HP SR number 8606223364.
14584+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of bool" >&5
14585+
$as_echo_n "checking size of bool... " >&6; }
14586+
if ${ac_cv_sizeof_bool+:} false; then :
14587+
$as_echo_n "(cached) " >&6
14588+
else
14589+
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (bool))" "ac_cv_sizeof_bool" "#ifdef HAVE_STDBOOL_H
14590+
#include <stdbool.h>
14591+
#endif
14592+
"; then :
14593+
14594+
else
14595+
if test "$ac_cv_type_bool" = yes; then
14596+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
14597+
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
14598+
as_fn_error 77 "cannot compute sizeof (bool)
14599+
See \`config.log' for more details" "$LINENO" 5; }
14600+
else
14601+
ac_cv_sizeof_bool=0
14602+
fi
14603+
fi
14604+
14605+
fi
14606+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_bool" >&5
14607+
$as_echo "$ac_cv_sizeof_bool" >&6; }
14608+
14609+
14610+
14611+
cat >>confdefs.h <<_ACEOF
14612+
#define SIZEOF_BOOL $ac_cv_sizeof_bool
14613+
_ACEOF
14614+
14615+
14616+
1448614617

1448714618
##
1448814619
## Functions, global variables

‎configure.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ AC_SUBST(UUID_LIBS)
12451245
## Header files
12461246
##
12471247

1248+
AC_HEADER_STDBOOL
1249+
12481250
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])
12491251

12501252
# On BSD, test for net/if.h will fail unless sys/socket.h
@@ -1503,6 +1505,11 @@ if test "$ac_cv_sizeof_off_t" -lt 8 -a "$segsize" != "1"; then
15031505
AC_MSG_ERROR([Large file support is not enabled. Segment size cannot be larger than 1GB.])
15041506
fi
15051507

1508+
AC_CHECK_SIZEOF([bool], [],
1509+
[#ifdef HAVE_STDBOOL_H
1510+
#include <stdbool.h>
1511+
#endif])
1512+
15061513

15071514
##
15081515
## Functions, global variables

‎src/include/pg_config.h.in

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

504+
/* Define to 1 if stdbool.h conforms to C99. */
505+
#undef HAVE_STDBOOL_H
506+
504507
/* Define to 1 if you have the <stdint.h> header file. */
505508
#undef HAVE_STDINT_H
506509

@@ -703,6 +706,9 @@
703706
/* Define to 1 if you have the `X509_get_signature_nid' function. */
704707
#undef HAVE_X509_GET_SIGNATURE_NID
705708

709+
/* Define to 1 if the system has the type `_Bool'. */
710+
#undef HAVE__BOOL
711+
706712
/* Define to 1 if your compiler understands __builtin_bswap16. */
707713
#undef HAVE__BUILTIN_BSWAP16
708714

@@ -812,6 +818,9 @@
812818
RELSEG_SIZE requires an initdb. */
813819
#undef RELSEG_SIZE
814820

821+
/* The size of `bool', as computed by sizeof. */
822+
#undef SIZEOF_BOOL
823+
815824
/* The size of `long', as computed by sizeof. */
816825
#undef SIZEOF_LONG
817826

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp