Skip to content

Commit bc18126

Browse files
committed
Add configure test to see if the C compiler has gcc-style computed gotos.
We'll need this for the upcoming patch to speed up expression evaluation. Might as well push it now to see if it behaves sanely in the buildfarm. Andres Freund Discussion: https://postgr.es/m/20170320062511.hp5qeurtxrwsvfxr@alap3.anarazel.de
1 parent 14a7252 commit bc18126

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

config/c-compiler.m4

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,30 @@ fi])# PGAC_C_BUILTIN_UNREACHABLE
273273

274274

275275

276+
# PGAC_C_COMPUTED_GOTO
277+
# -----------------------
278+
# Check if the C compiler knows computed gotos (gcc extension, also
279+
# available in at least clang). If so, define HAVE_COMPUTED_GOTO.
280+
#
281+
# Checking whether computed gotos are supported syntax-wise ought to
282+
# be enough, as the syntax is otherwise illegal.
283+
AC_DEFUN([PGAC_C_COMPUTED_GOTO],
284+
[AC_CACHE_CHECK(for computed goto support, pgac_cv_computed_goto,
285+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
286+
[[void *labeladdrs[] = {&&my_label};
287+
goto *labeladdrs[0];
288+
my_label:
289+
return 1;
290+
]])],
291+
[pgac_cv_computed_goto=yes],
292+
[pgac_cv_computed_goto=no])])
293+
if test x"$pgac_cv_computed_goto" = xyes ; then
294+
AC_DEFINE(HAVE_COMPUTED_GOTO, 1,
295+
[Define to 1 if your compiler handles computed gotos.])
296+
fi])# PGAC_C_COMPUTED_GOTO
297+
298+
299+
276300
# PGAC_C_VA_ARGS
277301
# --------------
278302
# Check if the C compiler understands C99-style variadic macros,

configure

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11531,6 +11531,40 @@ if test x"$pgac_cv__builtin_unreachable" = xyes ; then
1153111531

1153211532
$as_echo "#define HAVE__BUILTIN_UNREACHABLE 1" >>confdefs.h
1153311533

11534+
fi
11535+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for computed goto support" >&5
11536+
$as_echo_n "checking for computed goto support... " >&6; }
11537+
if ${pgac_cv_computed_goto+:} false; then :
11538+
$as_echo_n "(cached) " >&6
11539+
else
11540+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11541+
/* end confdefs.h. */
11542+
11543+
int
11544+
main ()
11545+
{
11546+
void *labeladdrs[] = {&&my_label};
11547+
goto *labeladdrs[0];
11548+
my_label:
11549+
return 1;
11550+
11551+
;
11552+
return 0;
11553+
}
11554+
_ACEOF
11555+
if ac_fn_c_try_compile "$LINENO"; then :
11556+
pgac_cv_computed_goto=yes
11557+
else
11558+
pgac_cv_computed_goto=no
11559+
fi
11560+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11561+
fi
11562+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_computed_goto" >&5
11563+
$as_echo "$pgac_cv_computed_goto" >&6; }
11564+
if test x"$pgac_cv_computed_goto" = xyes ; then
11565+
11566+
$as_echo "#define HAVE_COMPUTED_GOTO 1" >>confdefs.h
11567+
1153411568
fi
1153511569
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __VA_ARGS__" >&5
1153611570
$as_echo_n "checking for __VA_ARGS__... " >&6; }

configure.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,7 @@ PGAC_C_BUILTIN_BSWAP32
13221322
PGAC_C_BUILTIN_BSWAP64
13231323
PGAC_C_BUILTIN_CONSTANT_P
13241324
PGAC_C_BUILTIN_UNREACHABLE
1325+
PGAC_C_COMPUTED_GOTO
13251326
PGAC_C_VA_ARGS
13261327
PGAC_STRUCT_TIMEZONE
13271328
PGAC_UNION_SEMUN

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
/* Define to 1 if you have the `clock_gettime' function. */
109109
#undef HAVE_CLOCK_GETTIME
110110

111+
/* Define to 1 if your compiler handles computed gotos. */
112+
#undef HAVE_COMPUTED_GOTO
113+
111114
/* Define to 1 if you have the <crtdefs.h> header file. */
112115
#undef HAVE_CRTDEFS_H
113116

src/include/pg_config.h.win32

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
/* Define to 1 if you have the `clock_gettime' function. */
7979
/* #undef HAVE_CLOCK_GETTIME */
8080

81+
/* Define to 1 if your compiler handles computed gotos. */
82+
/* #undef HAVE_COMPUTED_GOTO */
83+
8184
/* Define to 1 if you have the `crypt' function. */
8285
/* #undef HAVE_CRYPT */
8386

0 commit comments

Comments
 (0)