Assume that we have signed integral types and flexible array members.
authorTom Lane
Fri, 21 Feb 2020 19:30:21 +0000 (14:30 -0500)
committerTom Lane
Fri, 21 Feb 2020 19:30:48 +0000 (14:30 -0500)
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

config/c-compiler.m4
configure
configure.in
src/include/c.h
src/include/pg_config.h.in
src/tools/msvc/Solution.pm

index 71b645839db053bdf9bcec61c4257977c51cea00..501b74b3a196d3f0f78d185acdf18316b79f971f 100644 (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.
index 610812d103939d24a0cc3bc6d369f1ed2c1b651f..d2c74e530c6812b0377e371d32b09b7a8ca7076a 100755 (executable)
--- a/configure
+++ b/configure
@@ -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 
-       #include 
-       #include 
-       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 :
index 8d7871a59a5f00179847ad01e30e57fbcc56c78d..0b0a871298e389c9dc57874af780cb4908aca066 100644 (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
index f2cc0338de62954a874a84cb345e180c982e2c51..831c89f473dd55e3ca35f7acbc993926c851a192 100644 (file)
 #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__
index ddc4a3f816a285a8d6aa9daef833ef6b8391463b..4fa0f770aaac0ac62f0cc89a26bcea262efdb750 100644 (file)
    (--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
 
 # 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
index b15dae16a9e65c3bd85abf2ec80f8dd1c43afde8..a6b8b92c1822d22914c13982d383aa4f60dcb0bb 100644 (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})