[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gettimeofday: Remove workaround for Mac OS X 10.0
From: |
Bruno Haible |
Subject: |
gettimeofday: Remove workaround for Mac OS X 10.0 |
Date: |
Sun, 26 Jul 2020 13:49:05 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; ) |
Similarly, Mac OS X 10.0 is obsolete since it was end-of-support in 2004 [1].
Some people, like me, still have a Mac OS X 10.5 machine around, but 10.0
is surely extremely rare by now.
[1] https://en.wikipedia.org/wiki/MacOS#Release_history
2020-07-26 Bruno Haible <bruno@clisp.org>
gettimeofday: Remove workaround for Mac OS X 10.0.
* m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY_CLOBBER): Remove macro.
(gl_FUNC_GETTIMEOFDAY): Don't invoke it.
* lib/gettimeofday.c: Don't include localtime-buffer.h.
(gettimeofday): Don't test GETTIMEOFDAY_CLOBBERS_LOCALTIME.
* lib/localtime.c: Don't test GETTIMEOFDAY_CLOBBERS_LOCALTIME.
* modules/gettimeofday (Depends-on): Remove localtime-buffer.
* modules/localtime-buffer: Remove file.
* lib/localtime-buffer.h: Remove file.
* lib/localtime-buffer.c: Remove file.
* m4/localtime-buffer.m4: Remove file.
* MODULES.html.sh (Date and time <time.h>): Remove localtime-buffer.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 43a6dba..11a4a77 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -1727,7 +1727,6 @@ func_all_modules ()
func_begin_table
func_module fprintftime
- func_module localtime-buffer
func_module nstrftime
func_module strftime-fixes
func_module time_rz
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index 305ab98..8b758a1 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -29,8 +29,6 @@
# include <windows.h>
#endif
-#include "localtime-buffer.h"
-
#ifdef WINDOWS_NATIVE
/* Don't assume that UNICODE is not defined. */
@@ -123,11 +121,6 @@ gettimeofday (struct timeval *restrict tv, void *restrict
tz)
#else
# if HAVE_GETTIMEOFDAY
-# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
- /* Save and restore the contents of the buffer used for localtime's
- result around the call to gettimeofday. */
- struct tm save = *localtime_buffer_addr;
-# endif
# if defined timeval /* 'struct timeval' overridden by gnulib? */
# undef timeval
@@ -142,10 +135,6 @@ gettimeofday (struct timeval *restrict tv, void *restrict
tz)
int result = gettimeofday (tv, (struct timezone *) tz);
# endif
-# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
- *localtime_buffer_addr = save;
-# endif
-
return result;
# else
diff --git a/lib/localtime-buffer.c b/lib/localtime-buffer.c
deleted file mode 100644
index 91b073e..0000000
--- a/lib/localtime-buffer.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Provide access to the last buffer returned by localtime() or gmtime().
-
- Copyright (C) 2001-2003, 2005-2007, 2009-2020 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <config.h>
-
-/* Specification. */
-#include "localtime-buffer.h"
-
-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME
-
-static struct tm tm_zero_buffer;
-struct tm *localtime_buffer_addr = &tm_zero_buffer;
-
-/* This is a wrapper for localtime.
-
- On the first call, record the address of the static buffer that
- localtime uses for its result. */
-
-struct tm *
-rpl_localtime (time_t const *timep)
-#undef localtime
-{
- struct tm *tm = localtime (timep);
-
- if (localtime_buffer_addr == &tm_zero_buffer)
- localtime_buffer_addr = tm;
-
- return tm;
-}
-
-/* Same as above, since gmtime and localtime use the same buffer. */
-struct tm *
-rpl_gmtime (time_t const *timep)
-#undef gmtime
-{
- struct tm *tm = gmtime (timep);
-
- if (localtime_buffer_addr == &tm_zero_buffer)
- localtime_buffer_addr = tm;
-
- return tm;
-}
-
-#endif
diff --git a/lib/localtime-buffer.h b/lib/localtime-buffer.h
deleted file mode 100644
index 9939d81..0000000
--- a/lib/localtime-buffer.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Provide access to the last buffer returned by localtime() or gmtime().
-
- Copyright (C) 2001-2003, 2005-2007, 2009-2020 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <https://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <time.h>
-
-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME
-
-/* The address of the last buffer returned by localtime() or gmtime(). */
-extern struct tm *localtime_buffer_addr;
-
-#endif
diff --git a/lib/localtime.c b/lib/localtime.c
index 9070993..f5e6767 100644
--- a/lib/localtime.c
+++ b/lib/localtime.c
@@ -19,18 +19,15 @@
/* Specification. */
#include <time.h>
-/* Keep consistent with localtime-buffer.c! */
-#if !GETTIMEOFDAY_CLOBBERS_LOCALTIME
+#include <stdlib.h>
+#include <string.h>
-# include <stdlib.h>
-# include <string.h>
-
-# undef localtime
+#undef localtime
struct tm *
rpl_localtime (const time_t *tp)
{
-# if defined _WIN32 && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
/* Rectify the value of the environment variable TZ.
There are four possible kinds of such values:
- Traditional US time zone names, e.g. "PST8PDT". Syntax: see
@@ -56,9 +53,7 @@ rpl_localtime (const time_t *tp)
const char *tz = getenv ("TZ");
if (tz != NULL && strchr (tz, '/') != NULL)
_putenv ("TZ=");
-# endif
+#endif
return localtime (tp);
}
-
-#endif
diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4
index c72b3ea..578ed49 100644
--- a/m4/gettimeofday.m4
+++ b/m4/gettimeofday.m4
@@ -1,4 +1,4 @@
-# serial 27
+# serial 28
# Copyright (C) 2001-2003, 2005, 2007, 2009-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -19,7 +19,6 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY],
if test $ac_cv_func_gettimeofday != yes; then
HAVE_GETTIMEOFDAY=0
else
- gl_FUNC_GETTIMEOFDAY_CLOBBER
AC_CACHE_CHECK([for gettimeofday with POSIX signature],
[gl_cv_func_gettimeofday_posix_signature],
[AC_COMPILE_IFELSE(
@@ -66,63 +65,5 @@ int gettimeofday (struct timeval *restrict, struct timezone
*restrict);
declaration of the second argument to gettimeofday.])
])
-
-dnl See if gettimeofday clobbers the static buffer that localtime uses
-dnl for its return value. The gettimeofday function from Mac OS X 10.0.4
-dnl (i.e., Darwin 1.3.7) has this problem.
-dnl
-dnl If it does, then arrange to use gettimeofday and localtime only via
-dnl the wrapper functions that work around the problem.
-
-AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER],
-[
- AC_REQUIRE([gl_HEADER_SYS_TIME_H])
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
- AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS])
-
- AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
- [gl_cv_func_gettimeofday_clobber],
- [AC_RUN_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <string.h>
- #include <sys/time.h>
- #include <time.h>
- #include <stdlib.h>
- ]],
- [[
- time_t t = 0;
- struct tm *lt;
- struct tm saved_lt;
- struct timeval tv;
- lt = localtime (&t);
- saved_lt = *lt;
- gettimeofday (&tv, NULL);
- return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
- ]])],
- [gl_cv_func_gettimeofday_clobber=no],
- [gl_cv_func_gettimeofday_clobber=yes],
- [# When cross-compiling:
- case "$host_os" in
- # Guess all is fine on glibc systems.
- *-gnu* | gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
- # Guess all is fine on musl systems.
- *-musl*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
- # Guess no on native Windows.
- mingw*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
- # If we don't know, obey --enable-cross-guesses.
- *)
gl_cv_func_gettimeofday_clobber="$gl_cross_guess_inverted" ;;
- esac
- ])])
-
- case "$gl_cv_func_gettimeofday_clobber" in
- *yes)
- REPLACE_GETTIMEOFDAY=1
- AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1],
- [Define if gettimeofday clobbers the localtime buffer.])
- gl_LOCALTIME_BUFFER_NEEDED
- ;;
- esac
-])
-
# Prerequisites of lib/gettimeofday.c.
AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [:])
diff --git a/m4/localtime-buffer.m4 b/m4/localtime-buffer.m4
deleted file mode 100644
index 09df3c9..0000000
--- a/m4/localtime-buffer.m4
+++ /dev/null
@@ -1,21 +0,0 @@
-# localtime-buffer.m4 serial 1
-dnl Copyright (C) 2017-2020 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_LOCALTIME_BUFFER_DEFAULTS],
-[
- NEED_LOCALTIME_BUFFER=0
-])
-
-dnl Macro invoked from other modules, to signal that the compilation of
-dnl module 'localtime-buffer' is needed.
-AC_DEFUN([gl_LOCALTIME_BUFFER_NEEDED],
-[
- AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS])
- AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
- NEED_LOCALTIME_BUFFER=1
- REPLACE_GMTIME=1
- REPLACE_LOCALTIME=1
-])
diff --git a/modules/gettimeofday b/modules/gettimeofday
index 106e7a7..b4bdcc3 100644
--- a/modules/gettimeofday
+++ b/modules/gettimeofday
@@ -7,7 +7,6 @@ m4/gettimeofday.m4
Depends-on:
sys_time
-localtime-buffer [test $NEED_LOCALTIME_BUFFER = 1]
configure.ac:
gl_FUNC_GETTIMEOFDAY
diff --git a/modules/localtime-buffer b/modules/localtime-buffer
deleted file mode 100644
index e511d43..0000000
--- a/modules/localtime-buffer
+++ /dev/null
@@ -1,25 +0,0 @@
-Description:
-Access to the internal buffer of the localtime() function and the gmtime()
function.
-
-Files:
-lib/localtime-buffer.h
-lib/localtime-buffer.c
-m4/localtime-buffer.m4
-
-Depends-on:
-time [false]
-
-configure.ac:
-AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS])
-AC_LIBOBJ([localtime-buffer])
-
-Makefile.am:
-
-Include:
-"localtime-buffer.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all