Revert back to standard AC_STRUCT_TIMEZONE Autoconf macro
Instead of AC_STRUCT_TIMEZONE we use our own variant called
PGAC_STRUCT_TIMEZONE that checks for tzname even if other variants were
found first. But since 63bd0db12199c5df043e1dea0f2b574f622b3a4c we
don't use tzname anymore, so we don't need this anymore.
The attached patches revert back to the standard AC_STRUCT_TIMEZONE
macro and do some related cleanup.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0001-Remove-use-of-deprecated-Autoconf-define.patchtext/plain; charset=UTF-8; name=0001-Remove-use-of-deprecated-Autoconf-define.patch; x-mac-creator=0; x-mac-type=0Download
From 78597561e3f8e9119d6fd07e4106cc780e58507b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 30 Sep 2019 20:50:16 +0200
Subject: [PATCH 1/2] Remove use of deprecated Autoconf define
Change from HAVE_TM_ZONE to HAVE_STRUCT_TM_TM_ZONE.
---
src/interfaces/ecpg/pgtypeslib/dt_common.c | 4 ++--
src/interfaces/ecpg/pgtypeslib/timestamp.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c
index e71defaa66..29c1117546 100644
--- a/src/interfaces/ecpg/pgtypeslib/dt_common.c
+++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c
@@ -995,7 +995,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn)
tm->tm_sec = tx->tm_sec;
tm->tm_isdst = tx->tm_isdst;
-#if defined(HAVE_TM_ZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE)
tm->tm_gmtoff = tx->tm_gmtoff;
tm->tm_zone = tx->tm_zone;
@@ -1041,7 +1041,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn)
}
else
tm->tm_isdst = -1;
-#else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
+#else /* not (HAVE_STRUCT_TM_TM_ZONE || HAVE_INT_TIMEZONE) */
if (tzp != NULL)
{
/* default to UTC */
diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c
index e830ee737e..2be151f7e6 100644
--- a/src/interfaces/ecpg/pgtypeslib/timestamp.c
+++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c
@@ -100,7 +100,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
int64 dDate,
date0;
int64 time;
-#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
time_t utime;
struct tm *tx;
#endif
@@ -134,7 +134,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
*/
if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
{
-#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
utime = dt / USECS_PER_SEC +
((date0 - date2j(1970, 1, 1)) * INT64CONST(86400));
@@ -147,7 +147,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
tm->tm_min = tx->tm_min;
tm->tm_isdst = tx->tm_isdst;
-#if defined(HAVE_TM_ZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE)
tm->tm_gmtoff = tx->tm_gmtoff;
tm->tm_zone = tx->tm_zone;
@@ -159,7 +159,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
if (tzn != NULL)
*tzn = TZNAME_GLOBAL[(tm->tm_isdst > 0)];
#endif
-#else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
+#else /* not (HAVE_STRUCT_TM_TM_ZONE || HAVE_INT_TIMEZONE) */
*tzp = 0;
/* Mark this as *no* time zone available */
tm->tm_isdst = -1;
--
2.23.0
0002-Revert-back-to-standard-AC_STRUCT_TIMEZONE-Autoconf-.patchtext/plain; charset=UTF-8; name=0002-Revert-back-to-standard-AC_STRUCT_TIMEZONE-Autoconf-.patch; x-mac-creator=0; x-mac-type=0Download
From 5fb3fb899b74f9eb8ba63c23da8a65582b5b2eb0 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 30 Sep 2019 21:12:58 +0200
Subject: [PATCH 2/2] Revert back to standard AC_STRUCT_TIMEZONE Autoconf macro
We used to use our own variant of this called PGAC_STRUCT_TIMEZONE
that checked for tzname even if other variants were found first. But
since 63bd0db12199c5df043e1dea0f2b574f622b3a4c we don't use tzname
anymore, so we don't need this anymore.
---
config/c-library.m4 | 33 ----
configure | 300 +++++++++++++++++++------------------
configure.in | 2 +-
src/include/pg_config.h.in | 7 +-
4 files changed, 163 insertions(+), 179 deletions(-)
diff --git a/config/c-library.m4 b/config/c-library.m4
index 6f2b0fbb4e..a8fa6edd26 100644
--- a/config/c-library.m4
+++ b/config/c-library.m4
@@ -23,39 +23,6 @@ if test x"$pgac_cv_var_int_timezone" = xyes ; then
fi])# PGAC_VAR_INT_TIMEZONE
-# PGAC_STRUCT_TIMEZONE
-# ------------------
-# Figure out how to get the current timezone. If `struct tm' has a
-# `tm_zone' member, define `HAVE_TM_ZONE'. Also, if the
-# external array `tzname' is found, define `HAVE_TZNAME'.
-# This is the same as the standard macro AC_STRUCT_TIMEZONE, except that
-# tzname[] is checked for regardless of whether we find tm_zone.
-AC_DEFUN([PGAC_STRUCT_TIMEZONE],
-[AC_REQUIRE([AC_STRUCT_TM])dnl
-AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
-#include <$ac_cv_struct_tm>
-])
-if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
- AC_DEFINE(HAVE_TM_ZONE, 1,
- [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
- `HAVE_STRUCT_TM_TM_ZONE' instead.])
-fi
-AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[#include <stdlib.h>
-#include <time.h>
-#ifndef tzname /* For SGI. */
-extern char *tzname[]; /* RS6000 and others reject char **tzname. */
-#endif
-]],
-[atoi(*tzname);])], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
-if test $ac_cv_var_tzname = yes; then
- AC_DEFINE(HAVE_TZNAME, 1,
- [Define to 1 if you have the external array `tzname'.])
-fi
-])# PGAC_STRUCT_TIMEZONE
-
-
# PGAC_FUNC_GETTIMEOFDAY_1ARG
# ---------------------------
# Check if gettimeofday() has only one arguments. (Normal is two.)
diff --git a/configure b/configure
index b3c92764be..8c399bda7c 100755
--- a/configure
+++ b/configure
@@ -2182,6 +2182,56 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_member
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ # Initialize each $ac_[]_AC_LANG_ABBREV[]_decl_warn_flag once.
+ as_decl_name=`echo $2|sed 's/ *(.*//'`
+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag="$ac_c_decl_warn_flag$ac_c_werror_flag"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+ (void) $as_decl_use;
+#else
+ (void) $as_decl_name;
+#endif
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_werror_flag
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
# --------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
@@ -2364,56 +2414,6 @@ rm -f conftest.val
as_fn_set_status $ac_retval
} # ac_fn_c_compute_int
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- # Initialize each $ac_[]_AC_LANG_ABBREV[]_decl_warn_flag once.
- as_decl_name=`echo $2|sed 's/ *(.*//'`
- as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_save_werror_flag=$ac_c_werror_flag
- ac_c_werror_flag="$ac_c_decl_warn_flag$ac_c_werror_flag"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
- (void) $as_decl_use;
-#else
- (void) $as_decl_name;
-#endif
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- ac_c_werror_flag=$ac_save_werror_flag
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -13999,6 +13999,94 @@ $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
fi
+# The Clang compiler raises a warning for an undeclared identifier that matches
+# a compiler builtin function. All extant Clang versions are affected, as of
+# Clang 3.6.0. Test a builtin known to every version. This problem affects the
+# C and Objective C languages, but Clang does report an error under C++ and
+# Objective C++.
+#
+# Passing -fno-builtin to the compiler would suppress this problem. That
+# strategy would have the advantage of being insensitive to stray warnings, but
+# it would make tests less realistic.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how $CC reports undeclared, standard C functions" >&5
+$as_echo_n "checking how $CC reports undeclared, standard C functions... " >&6; }
+if ${ac_cv_c_decl_report+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+(void) strchr;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ if test -s conftest.err; then :
+ # For AC_CHECK_DECL to react to warnings, the compiler must be silent on
+ # valid AC_CHECK_DECL input. No library function is consistently available
+ # on freestanding implementations, so test against a dummy declaration.
+ # Include always-available headers on the off chance that they somehow
+ # elicit warnings.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <float.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stddef.h>
+extern void ac_decl (int, char *);
+int
+main ()
+{
+#ifdef __cplusplus
+ (void) ac_decl ((int) 0, (char *) 0);
+ (void) ac_decl;
+#else
+ (void) ac_decl;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ if test -s conftest.err; then :
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot detect from compiler exit status or warnings
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ ac_cv_c_decl_report=warning
+fi
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compile a simple declaration test
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "compiler does not report undeclared identifiers
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+else
+ ac_cv_c_decl_report=error
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_decl_report" >&5
+$as_echo "$ac_cv_c_decl_report" >&6; }
+
+case $ac_cv_c_decl_report in
+ warning) ac_c_decl_warn_flag=yes ;;
+ *) ac_c_decl_warn_flag= ;;
+esac
+
ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -14016,24 +14104,35 @@ if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
$as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h
+else
+ ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include <time.h>
+"
+if test "x$ac_cv_have_decl_tzname" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_TZNAME $ac_have_decl
+_ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5
$as_echo_n "checking for tzname... " >&6; }
if ${ac_cv_var_tzname+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include <stdlib.h>
#include <time.h>
-#ifndef tzname /* For SGI. */
-extern char *tzname[]; /* RS6000 and others reject char **tzname. */
+#if !HAVE_DECL_TZNAME
+extern char *tzname[];
#endif
int
main ()
{
-atoi(*tzname);
+return tzname[0][0];
;
return 0;
}
@@ -14048,10 +14147,11 @@ rm -f core conftest.err conftest.$ac_objext \
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5
$as_echo "$ac_cv_var_tzname" >&6; }
-if test $ac_cv_var_tzname = yes; then
+ if test $ac_cv_var_tzname = yes; then
$as_echo "#define HAVE_TZNAME 1" >>confdefs.h
+ fi
fi
ac_fn_c_check_type "$LINENO" "union semun" "ac_cv_type_union_semun" "#include <sys/types.h>
@@ -15427,94 +15527,6 @@ esac
# posix_fadvise() is a no-op on Solaris, so don't incur function overhead
# by calling it, 2009-04-02
# http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/posix_fadvise.c
-# The Clang compiler raises a warning for an undeclared identifier that matches
-# a compiler builtin function. All extant Clang versions are affected, as of
-# Clang 3.6.0. Test a builtin known to every version. This problem affects the
-# C and Objective C languages, but Clang does report an error under C++ and
-# Objective C++.
-#
-# Passing -fno-builtin to the compiler would suppress this problem. That
-# strategy would have the advantage of being insensitive to stray warnings, but
-# it would make tests less realistic.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how $CC reports undeclared, standard C functions" >&5
-$as_echo_n "checking how $CC reports undeclared, standard C functions... " >&6; }
-if ${ac_cv_c_decl_report+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-(void) strchr;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- if test -s conftest.err; then :
- # For AC_CHECK_DECL to react to warnings, the compiler must be silent on
- # valid AC_CHECK_DECL input. No library function is consistently available
- # on freestanding implementations, so test against a dummy declaration.
- # Include always-available headers on the off chance that they somehow
- # elicit warnings.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <float.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <stddef.h>
-extern void ac_decl (int, char *);
-int
-main ()
-{
-#ifdef __cplusplus
- (void) ac_decl ((int) 0, (char *) 0);
- (void) ac_decl;
-#else
- (void) ac_decl;
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- if test -s conftest.err; then :
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot detect from compiler exit status or warnings
-See \`config.log' for more details" "$LINENO" 5; }
-else
- ac_cv_c_decl_report=warning
-fi
-else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compile a simple declaration test
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "compiler does not report undeclared identifiers
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-else
- ac_cv_c_decl_report=error
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_decl_report" >&5
-$as_echo "$ac_cv_c_decl_report" >&6; }
-
-case $ac_cv_c_decl_report in
- warning) ac_c_decl_warn_flag=yes ;;
- *) ac_c_decl_warn_flag= ;;
-esac
-
if test "$PORTNAME" != "solaris"; then :
for ac_func in posix_fadvise
diff --git a/configure.in b/configure.in
index 0d16c1a971..d55b67b984 100644
--- a/configure.in
+++ b/configure.in
@@ -1462,7 +1462,7 @@ PGAC_C_TYPES_COMPATIBLE
PGAC_C_BUILTIN_CONSTANT_P
PGAC_C_BUILTIN_UNREACHABLE
PGAC_C_COMPUTED_GOTO
-PGAC_STRUCT_TIMEZONE
+AC_STRUCT_TIMEZONE
PGAC_UNION_SEMUN
PGAC_STRUCT_SOCKADDR_UN
PGAC_STRUCT_SOCKADDR_STORAGE
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index c6014e83fa..ece6a5def7 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -186,6 +186,10 @@
don't. */
#undef HAVE_DECL_STRTOULL
+/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+ */
+#undef HAVE_DECL_TZNAME
+
/* Define to 1 if you have the `dlopen' function. */
#undef HAVE_DLOPEN
@@ -661,7 +665,8 @@
/* Define to 1 if your compiler understands `typeof' or something similar. */
#undef HAVE_TYPEOF
-/* Define to 1 if you have the external array `tzname'. */
+/* Define to 1 if you don't have `tm_zone' but do have the external array
+ `tzname'. */
#undef HAVE_TZNAME
/* Define to 1 if you have the <ucred.h> header file. */
--
2.23.0
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
Instead of AC_STRUCT_TIMEZONE we use our own variant called
PGAC_STRUCT_TIMEZONE that checks for tzname even if other variants were
found first. But since 63bd0db12199c5df043e1dea0f2b574f622b3a4c we
don't use tzname anymore, so we don't need this anymore.
Hmm. I wonder if we need AC_STRUCT_TIMEZONE either? Seems like
we should only be using our own struct pg_tm. If we could get
rid of that configure macro altogether, we could remove some dubious
junk like plpython.h's "#undef HAVE_TZNAME".
regards, tom lane
On 2019-09-30 21:36, Tom Lane wrote:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
Instead of AC_STRUCT_TIMEZONE we use our own variant called
PGAC_STRUCT_TIMEZONE that checks for tzname even if other variants were
found first. But since 63bd0db12199c5df043e1dea0f2b574f622b3a4c we
don't use tzname anymore, so we don't need this anymore.Hmm. I wonder if we need AC_STRUCT_TIMEZONE either? Seems like
we should only be using our own struct pg_tm.
There are a few places that seem to need it, such as initdb/findtimezone.c.
If we could get
rid of that configure macro altogether, we could remove some dubious
junk like plpython.h's "#undef HAVE_TZNAME".
We could keep just the part of AC_STRUCT_TIMEZONE that we need, namely
the check for tm_zone, and remove the part about tzname.
New patch attached.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
v2-0001-Remove-use-of-deprecated-Autoconf-define.patchtext/plain; charset=UTF-8; name=v2-0001-Remove-use-of-deprecated-Autoconf-define.patch; x-mac-creator=0; x-mac-type=0Download
From 78597561e3f8e9119d6fd07e4106cc780e58507b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Mon, 30 Sep 2019 20:50:16 +0200
Subject: [PATCH v2 1/2] Remove use of deprecated Autoconf define
Change from HAVE_TM_ZONE to HAVE_STRUCT_TM_TM_ZONE.
---
src/interfaces/ecpg/pgtypeslib/dt_common.c | 4 ++--
src/interfaces/ecpg/pgtypeslib/timestamp.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c
index e71defaa66..29c1117546 100644
--- a/src/interfaces/ecpg/pgtypeslib/dt_common.c
+++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c
@@ -995,7 +995,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn)
tm->tm_sec = tx->tm_sec;
tm->tm_isdst = tx->tm_isdst;
-#if defined(HAVE_TM_ZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE)
tm->tm_gmtoff = tx->tm_gmtoff;
tm->tm_zone = tx->tm_zone;
@@ -1041,7 +1041,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn)
}
else
tm->tm_isdst = -1;
-#else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
+#else /* not (HAVE_STRUCT_TM_TM_ZONE || HAVE_INT_TIMEZONE) */
if (tzp != NULL)
{
/* default to UTC */
diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c
index e830ee737e..2be151f7e6 100644
--- a/src/interfaces/ecpg/pgtypeslib/timestamp.c
+++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c
@@ -100,7 +100,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
int64 dDate,
date0;
int64 time;
-#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
time_t utime;
struct tm *tx;
#endif
@@ -134,7 +134,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
*/
if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
{
-#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
utime = dt / USECS_PER_SEC +
((date0 - date2j(1970, 1, 1)) * INT64CONST(86400));
@@ -147,7 +147,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
tm->tm_min = tx->tm_min;
tm->tm_isdst = tx->tm_isdst;
-#if defined(HAVE_TM_ZONE)
+#if defined(HAVE_STRUCT_TM_TM_ZONE)
tm->tm_gmtoff = tx->tm_gmtoff;
tm->tm_zone = tx->tm_zone;
@@ -159,7 +159,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t
if (tzn != NULL)
*tzn = TZNAME_GLOBAL[(tm->tm_isdst > 0)];
#endif
-#else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
+#else /* not (HAVE_STRUCT_TM_TM_ZONE || HAVE_INT_TIMEZONE) */
*tzp = 0;
/* Mark this as *no* time zone available */
tm->tm_isdst = -1;
--
2.23.0
v2-0002-Simplify-PGAC_STRUCT_TIMEZONE-Autoconf-macro.patchtext/plain; charset=UTF-8; name=v2-0002-Simplify-PGAC_STRUCT_TIMEZONE-Autoconf-macro.patch; x-mac-creator=0; x-mac-type=0Download
From 716fb6c09648b03ba563a61b1cd2f353ed7acfca Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 2 Oct 2019 07:26:08 +0200
Subject: [PATCH v2 2/2] Simplify PGAC_STRUCT_TIMEZONE Autoconf macro
Since 63bd0db12199c5df043e1dea0f2b574f622b3a4c we don't use tzname
anymore, so we don't need to check for it. Instead, just keep the
part of PGAC_STRUCT_TIMEZONE that we need, which is the check for
struct tm.tm_zone.
---
config/c-library.m4 | 31 +++-----------
configure | 78 +----------------------------------
src/include/pg_config.h.in | 10 -----
src/include/pg_config.h.win32 | 10 -----
src/pl/plpython/plpython.h | 1 -
5 files changed, 7 insertions(+), 123 deletions(-)
diff --git a/config/c-library.m4 b/config/c-library.m4
index 6f2b0fbb4e..d9a31d7664 100644
--- a/config/c-library.m4
+++ b/config/c-library.m4
@@ -26,33 +26,14 @@ fi])# PGAC_VAR_INT_TIMEZONE
# PGAC_STRUCT_TIMEZONE
# ------------------
# Figure out how to get the current timezone. If `struct tm' has a
-# `tm_zone' member, define `HAVE_TM_ZONE'. Also, if the
-# external array `tzname' is found, define `HAVE_TZNAME'.
-# This is the same as the standard macro AC_STRUCT_TIMEZONE, except that
-# tzname[] is checked for regardless of whether we find tm_zone.
+# `tm_zone' member, define `HAVE_STRUCT_TM_TM_ZONE'. Unlike the
+# standard macro AC_STRUCT_TIMEZONE, we don't check for `tzname[]' if
+# not found, since we don't use it. (We use `int timezone' as a
+# fallback.)
AC_DEFUN([PGAC_STRUCT_TIMEZONE],
-[AC_REQUIRE([AC_STRUCT_TM])dnl
-AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
-#include <$ac_cv_struct_tm>
-])
-if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
- AC_DEFINE(HAVE_TM_ZONE, 1,
- [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
- `HAVE_STRUCT_TM_TM_ZONE' instead.])
-fi
-AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[#include <stdlib.h>
+[AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
#include <time.h>
-#ifndef tzname /* For SGI. */
-extern char *tzname[]; /* RS6000 and others reject char **tzname. */
-#endif
-]],
-[atoi(*tzname);])], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
-if test $ac_cv_var_tzname = yes; then
- AC_DEFINE(HAVE_TZNAME, 1,
- [Define to 1 if you have the external array `tzname'.])
-fi
+])
])# PGAC_STRUCT_TIMEZONE
diff --git a/configure b/configure
index b3c92764be..74627a7eed 100755
--- a/configure
+++ b/configure
@@ -13964,43 +13964,8 @@ if test x"$pgac_cv_computed_goto" = xyes ; then
$as_echo "#define HAVE_COMPUTED_GOTO 1" >>confdefs.h
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
-$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
-if ${ac_cv_struct_tm+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <time.h>
-
-int
-main ()
-{
-struct tm tm;
- int *p = &tm.tm_sec;
- return !p;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_struct_tm=time.h
-else
- ac_cv_struct_tm=sys/time.h
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5
-$as_echo "$ac_cv_struct_tm" >&6; }
-if test $ac_cv_struct_tm = sys/time.h; then
-
-$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
-
-fi
-
ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include <sys/types.h>
-#include <$ac_cv_struct_tm>
+#include <time.h>
"
if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then :
@@ -14012,47 +13977,6 @@ _ACEOF
fi
-if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
-
-$as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5
-$as_echo_n "checking for tzname... " >&6; }
-if ${ac_cv_var_tzname+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <time.h>
-#ifndef tzname /* For SGI. */
-extern char *tzname[]; /* RS6000 and others reject char **tzname. */
-#endif
-
-int
-main ()
-{
-atoi(*tzname);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_var_tzname=yes
-else
- ac_cv_var_tzname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5
-$as_echo "$ac_cv_var_tzname" >&6; }
-if test $ac_cv_var_tzname = yes; then
-
-$as_echo "#define HAVE_TZNAME 1" >>confdefs.h
-
-fi
ac_fn_c_check_type "$LINENO" "union semun" "ac_cv_type_union_semun" "#include <sys/types.h>
#ifdef HAVE_SYS_IPC_H
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index c6014e83fa..53e6fe3398 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -654,16 +654,9 @@
/* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
-/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
- `HAVE_STRUCT_TM_TM_ZONE' instead. */
-#undef HAVE_TM_ZONE
-
/* Define to 1 if your compiler understands `typeof' or something similar. */
#undef HAVE_TYPEOF
-/* Define to 1 if you have the external array `tzname'. */
-#undef HAVE_TZNAME
-
/* Define to 1 if you have the <ucred.h> header file. */
#undef HAVE_UCRED_H
@@ -884,9 +877,6 @@
/* Define to 1 if strerror_r() returns int. */
#undef STRERROR_R_INT
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
-#undef TM_IN_SYS_TIME
-
/* Define to 1 to use ARMv8 CRC Extension. */
#undef USE_ARMV8_CRC32C
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 5bbf476990..a330df9d9d 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -508,16 +508,9 @@
/* Define to 1 if you have the <termios.h> header file. */
/* #undef HAVE_TERMIOS_H */
-/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
- `HAVE_STRUCT_TM_TM_ZONE' instead. */
-/* #undef HAVE_TM_ZONE */
-
/* Define to 1 if your compiler understands `typeof' or something similar. */
/* #undef HAVE_TYPEOF */
-/* Define to 1 if you have the external array `tzname'. */
-/* #undef HAVE_TZNAME */
-
/* Define to 1 if the system has the type `uint64'. */
/* #undef HAVE_UINT64 */
@@ -686,9 +679,6 @@
/* Define to 1 if strerror_r() returns int. */
/* #undef STRERROR_R_INT */
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
-/* #undef TM_IN_SYS_TIME */
-
/* Define to 1 to build with assertion checks. (--enable-cassert) */
/* #undef USE_ASSERT_CHECKING */
diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h
index 3a1f0d56d7..dc8fcee001 100644
--- a/src/pl/plpython/plpython.h
+++ b/src/pl/plpython/plpython.h
@@ -28,7 +28,6 @@
*/
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
-#undef HAVE_TZNAME
/*
* Sometimes python carefully scribbles on our *printf macros.
--
2.23.0
On 2019-10-02 07:30, Peter Eisentraut wrote:
On 2019-09-30 21:36, Tom Lane wrote:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
Instead of AC_STRUCT_TIMEZONE we use our own variant called
PGAC_STRUCT_TIMEZONE that checks for tzname even if other variants were
found first. But since 63bd0db12199c5df043e1dea0f2b574f622b3a4c we
don't use tzname anymore, so we don't need this anymore.Hmm. I wonder if we need AC_STRUCT_TIMEZONE either? Seems like
we should only be using our own struct pg_tm.There are a few places that seem to need it, such as initdb/findtimezone.c.
If we could get
rid of that configure macro altogether, we could remove some dubious
junk like plpython.h's "#undef HAVE_TZNAME".We could keep just the part of AC_STRUCT_TIMEZONE that we need, namely
the check for tm_zone, and remove the part about tzname.New patch attached.
committed
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services