On 06/30/2016 10:21 AM, Ludovic Courtès wrote:
Gnulib’s ‘mktime’ replacement gets used on glibc systems (glibc 2.22
here) due to ‘__mktime_internal’ being unavailable, even though
gl_cv_func_working_mktime=yes on these systems.  Is this intended?

No, and I don't observe it on Fedora 23 x86-64, which uses glibc 2.22. I ran './gnulib-tool --create-testdir --dir foo mktime; cd foo; ./configure; make' and the resulting build did not compile mktime.c.

Perhaps your package is using the mktime-internal module? That would explain why mktime.c is getting compiled for you. If not, could you investigate why your package is compiling mktime.c even when glibc 2.22 is being used?

I believe “#ifdef _LIBC” should be changed to something like:

--8<---------------cut here---------------start------------->8---
#ifdef _LIBC
   __tzset ();
#else
   tzset ();
#endif
--8<---------------cut here---------------end--------------->8---

otherwise the current ‘TZ’ variable value ends up being ignored (we
noticed this problem with Guile’s test suite.)


Yes, thanks, the old code dated back to when the substitute mktime.c was not intended to be thread-safe and so used localtime instead of localtime_r, so there was no need to call tzset. I installed the attached patch to fix that.
>From 913c424ef1a10bacf63597ca7565b29908d6135b Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 3 Jul 2016 12:59:54 +0200
Subject: [PATCH] mktime: call tzset as per POSIX
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Ludovic Courtès in:
http://lists.gnu.org/archive/html/bug-gnulib/2016-06/msg00068.html
* lib/mktime.c (mktime) [!_LIBC && HAVE_TZSET]: Call tzset.
* m4/mktime.m4 (gl_FUNC_MKTIME): Check for tzset.
---
 ChangeLog    | 8 ++++++++
 lib/mktime.c | 2 ++
 m4/mktime.m4 | 3 ++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 34b651f..ef33268 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-07-03  Paul Eggert  <egg...@cs.ucla.edu>
+
+	mktime: call tzset as per POSIX
+	Problem reported by Ludovic Courtès in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2016-06/msg00068.html
+	* lib/mktime.c (mktime) [!_LIBC && HAVE_TZSET]: Call tzset.
+	* m4/mktime.m4 (gl_FUNC_MKTIME): Check for tzset.
+
 2016-06-26  Pádraig Brady  <p...@draigbrady.com>
 
 	fts: handle readdir() errors
diff --git a/lib/mktime.c b/lib/mktime.c
index 87ab633..9eb3e76 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -470,6 +470,8 @@ mktime (struct tm *tp)
      time zone names contained in the external variable 'tzname' shall
      be set as if the tzset() function had been called.  */
   __tzset ();
+#elif HAVE_TZSET
+  tzset ();
 #endif
 
   return __mktime_internal (tp, __localtime_r, &localtime_offset);
diff --git a/m4/mktime.m4 b/m4/mktime.m4
index 5a0f2d8..23cad73 100644
--- a/m4/mktime.m4
+++ b/m4/mktime.m4
@@ -1,4 +1,4 @@
-# serial 26
+# serial 27
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2016 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -30,6 +30,7 @@ AC_DEFUN([gl_FUNC_MKTIME],
   dnl in Autoconf and because it invokes AC_LIBOBJ.
   AC_CHECK_HEADERS_ONCE([unistd.h])
   AC_CHECK_DECLS_ONCE([alarm])
+  AC_CHECK_FUNCS_ONCE([tzset])
   AC_REQUIRE([gl_MULTIARCH])
   if test $APPLE_UNIVERSAL_BUILD = 1; then
     # A universal build on Apple Mac OS X platforms.
-- 
2.5.5

Reply via email to