Assume that we have signed integral types and flexible array members.

These compiler features are required by C99, so remove the configure
probes for them.

This is part of a series of commits to get rid of no-longer-relevant
configure checks and dead src/port/ code.  I'm committing them separately
to make it easier to back out individual changes if they prove less
portable than I expect.

Discussion: https://postgr.es/m/15379.1582221614@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2020-02-21 14:30:21 -05:00
parent 97cf1fa4ed
commit f4d59369d2
6 changed files with 10 additions and 103 deletions

View File

@ -2,21 +2,6 @@
# config/c-compiler.m4
# PGAC_C_SIGNED
# -------------
# Check if the C compiler understands signed types.
AC_DEFUN([PGAC_C_SIGNED],
[AC_CACHE_CHECK(for signed types, pgac_cv_c_signed,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[signed char c; signed short s; signed int i;])],
[pgac_cv_c_signed=yes],
[pgac_cv_c_signed=no])])
if test x"$pgac_cv_c_signed" = xno ; then
AC_DEFINE(signed,, [Define to empty if the C compiler does not understand signed types.])
fi])# PGAC_C_SIGNED
# PGAC_C_PRINTF_ARCHETYPE
# -----------------------
# Select the format archetype to be used by gcc to check printf-type functions.

72
configure vendored
View File

@ -13694,78 +13694,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flexible array members" >&5
$as_echo_n "checking for flexible array members... " >&6; }
if ${ac_cv_c_flexmember+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
struct s { int n; double d[]; };
int
main ()
{
int m = getchar ();
struct s *p = malloc (offsetof (struct s, d)
+ m * sizeof (double));
p->d[0] = 0.0;
return p->d != (double *) NULL;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_flexmember=yes
else
ac_cv_c_flexmember=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_flexmember" >&5
$as_echo "$ac_cv_c_flexmember" >&6; }
if test $ac_cv_c_flexmember = yes; then
$as_echo "#define FLEXIBLE_ARRAY_MEMBER /**/" >>confdefs.h
else
$as_echo "#define FLEXIBLE_ARRAY_MEMBER 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed types" >&5
$as_echo_n "checking for signed types... " >&6; }
if ${pgac_cv_c_signed+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
signed char c; signed short s; signed int i;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
pgac_cv_c_signed=yes
else
pgac_cv_c_signed=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_c_signed" >&5
$as_echo "$pgac_cv_c_signed" >&6; }
if test x"$pgac_cv_c_signed" = xno ; then
$as_echo "#define signed /**/" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __func__" >&5
$as_echo_n "checking for __func__... " >&6; }
if ${pgac_cv_funcname_func_support+:} false; then :

View File

@ -1458,8 +1458,6 @@ m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
AC_C_BIGENDIAN
AC_C_INLINE
PGAC_PRINTF_ARCHETYPE
AC_C_FLEXIBLE_ARRAY_MEMBER
PGAC_C_SIGNED
PGAC_C_FUNCNAME_SUPPORT
PGAC_C_STATIC_ASSERT
PGAC_C_TYPEOF

View File

@ -265,6 +265,16 @@
#define dummyret char
#endif
/*
* We require C99, hence the compiler should understand flexible array
* members. However, for documentation purposes we still consider it to be
* project style to write "field[FLEXIBLE_ARRAY_MEMBER]" not just "field[]".
* When computing the size of such an object, use "offsetof(struct s, f)"
* for portability. Don't use "offsetof(struct s, f[0])", as this doesn't
* work with MSVC and with C++ compilers.
*/
#define FLEXIBLE_ARRAY_MEMBER /* empty */
/* Which __func__ symbol do we have, if any? */
#ifdef HAVE_FUNCNAME__FUNC
#define PG_FUNCNAME_MACRO __func__

View File

@ -64,15 +64,6 @@
(--enable-thread-safety) */
#undef ENABLE_THREAD_SAFETY
/* Define to nothing if C supports flexible array members, and to 1 if it does
not. That way, with a declaration like `struct s { int n; double
d[FLEXIBLE_ARRAY_MEMBER]; };', the struct hack can be used with pre-C99
compilers. When computing the size of such an object, don't use 'sizeof
(struct s)' as it overestimates the size. Use 'offsetof (struct s, d)'
instead. Don't use 'offsetof (struct s, d[0])', as this doesn't work with
MSVC and with C++ compilers. */
#undef FLEXIBLE_ARRAY_MEMBER
/* Define to 1 if gettimeofday() takes only 1 argument. */
#undef GETTIMEOFDAY_1ARG
@ -976,8 +967,5 @@
# define __restrict__
#endif
/* Define to empty if the C compiler does not understand signed types. */
#undef signed
/* Define to how the compiler spells `typeof'. */
#undef typeof

View File

@ -201,7 +201,6 @@ sub GenerateFiles
ENABLE_GSS => $self->{options}->{gss} ? 1 : undef,
ENABLE_NLS => $self->{options}->{nls} ? 1 : undef,
ENABLE_THREAD_SAFETY => 1,
FLEXIBLE_ARRAY_MEMBER => '/**/',
GETTIMEOFDAY_1ARG => undef,
HAVE_APPEND_HISTORY => undef,
HAVE_ASN1_STRING_GET0_DATA => undef,
@ -483,7 +482,6 @@ sub GenerateFiles
pg_restrict => '__restrict',
# not defined, because it'd conflict with __declspec(restrict)
restrict => undef,
signed => undef,
typeof => undef,);
if ($self->{options}->{uuid})