From f667747b6d30c524c210501f5a2ca8e543a1bb67 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon, 14 May 2012 23:06:48 -0400
Subject: [PATCH] Put back AC_REQUIRE([AC_STRUCT_TM]).

The BSD-ish members of the buildfarm all seem to think removing this
was a bad idea.  It looks to me like it resulted in omitting the system
header inclusion necessary to detect the fields of struct tm correctly.
---
 config/c-library.m4        |  3 +-
 configure                  | 62 ++++++++++++++++++++++++++++++++++++++
 src/include/pg_config.h.in |  3 ++
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/config/c-library.m4 b/config/c-library.m4
index 02331443211..c39fc8d8782 100644
--- a/config/c-library.m4
+++ b/config/c-library.m4
@@ -30,7 +30,8 @@ fi])# PGAC_VAR_INT_TIMEZONE
 # 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_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
+[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
diff --git a/configure b/configure
index 99daee9f31c..2a8082b9f99 100755
--- a/configure
+++ b/configure
@@ -15430,6 +15430,68 @@ _ACEOF
 
 fi
 fi
+{ $as_echo "$as_me:$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 test "${ac_cv_struct_tm+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* 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
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_struct_tm=time.h
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_struct_tm=sys/time.h
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
+$as_echo "$ac_cv_struct_tm" >&6; }
+if test $ac_cv_struct_tm = sys/time.h; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TM_IN_SYS_TIME 1
+_ACEOF
+
+fi
+
 { $as_echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5
 $as_echo_n "checking for struct tm.tm_zone... " >&6; }
 if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 0aa457214bf..5454efdcbe6 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -720,6 +720,9 @@
 /* Define to 1 if strerror_r() returns a int. */
 #undef STRERROR_R_INT
 
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
 /* Define to the appropriate snprintf format for unsigned 64-bit ints. */
 #undef UINT64_FORMAT
 
-- 
GitLab