diff options
| author | Paul Eggert | 2017-05-01 15:33:06 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-05-01 15:33:26 -0700 |
| commit | 634d0a907ff7ba5901dfe3624e58d718f3f37cec (patch) | |
| tree | 6bf86cf04d8b28a79693df9cdef1063c9b06ca76 | |
| parent | 16b49e214ad828de29ceb57ad1b443eece9bba03 (diff) | |
| download | emacs-634d0a907ff7ba5901dfe3624e58d718f3f37cec.tar.gz emacs-634d0a907ff7ba5901dfe3624e58d718f3f37cec.zip | |
Merge from gnulib
This incorporates:
2017-05-01 New module 'localtime-buffer'
2017-04-30 utimens: Add support for native Windows
* admin/merge-gnulib (AVOIDED_MODULES): Add tzset.
* configure.ac (tzset): No need for Emacs itself to check now.
* lib/gettimeofday.c, lib/time.in.h, lib/time_rz.c, lib/utimens.c:
* m4/gettimeofday.m4, m4/time_h.m4, m4/time_rz.m4: Copy from gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib/localtime-buffer.c, lib/localtime-buffer.h:
* m4/localtime-buffer.m4: New files, copied from gnulib.
* src/editfns.c (init_editfns): Assume tzset is callable.
| -rwxr-xr-x | admin/merge-gnulib | 2 | ||||
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | lib/gettimeofday.c | 73 | ||||
| -rw-r--r-- | lib/gnulib.mk.in | 23 | ||||
| -rw-r--r-- | lib/localtime-buffer.c | 58 | ||||
| -rw-r--r-- | lib/localtime-buffer.h | 27 | ||||
| -rw-r--r-- | lib/time.in.h | 22 | ||||
| -rw-r--r-- | lib/time_rz.c | 4 | ||||
| -rw-r--r-- | lib/utimens.c | 82 | ||||
| -rw-r--r-- | m4/gettimeofday.m4 | 21 | ||||
| -rw-r--r-- | m4/gnulib-comp.m4 | 17 | ||||
| -rw-r--r-- | m4/localtime-buffer.m4 | 21 | ||||
| -rw-r--r-- | m4/time_h.m4 | 3 | ||||
| -rw-r--r-- | m4/time_rz.m4 | 1 | ||||
| -rw-r--r-- | src/editfns.c | 6 |
15 files changed, 261 insertions, 101 deletions
diff --git a/admin/merge-gnulib b/admin/merge-gnulib index c2ab3571fee..45e4a788a35 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib | |||
| @@ -49,7 +49,7 @@ AVOIDED_MODULES=' | |||
| 49 | malloc-posix msvc-inval msvc-nothrow | 49 | malloc-posix msvc-inval msvc-nothrow |
| 50 | open openat-die opendir raise | 50 | open openat-die opendir raise |
| 51 | save-cwd select setenv sigprocmask stat stdarg stdbool | 51 | save-cwd select setenv sigprocmask stat stdarg stdbool |
| 52 | threadlib unsetenv utime-h | 52 | threadlib tzset unsetenv utime utime-h |
| 53 | ' | 53 | ' |
| 54 | 54 | ||
| 55 | GNULIB_TOOL_FLAGS=' | 55 | GNULIB_TOOL_FLAGS=' |
diff --git a/configure.ac b/configure.ac index c545663e9ed..45cfdfcb4b9 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -4195,7 +4195,7 @@ AC_CHECK_HEADERS(valgrind/valgrind.h) | |||
| 4195 | 4195 | ||
| 4196 | AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]]) | 4196 | AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]]) |
| 4197 | 4197 | ||
| 4198 | AC_CHECK_FUNCS_ONCE([sbrk tzset]) | 4198 | AC_CHECK_FUNCS_ONCE([sbrk]) |
| 4199 | 4199 | ||
| 4200 | ok_so_far=yes | 4200 | ok_so_far=yes |
| 4201 | AC_CHECK_FUNC(socket, , ok_so_far=no) | 4201 | AC_CHECK_FUNC(socket, , ok_so_far=no) |
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c index 86f1a8c1d28..1039f77d182 100644 --- a/lib/gettimeofday.c +++ b/lib/gettimeofday.c | |||
| @@ -29,72 +29,7 @@ | |||
| 29 | # include <windows.h> | 29 | # include <windows.h> |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME | 32 | #include "localtime-buffer.h" |
| 33 | |||
| 34 | /* Work around the bug in some systems whereby gettimeofday clobbers | ||
| 35 | the static buffer that localtime uses for its return value. The | ||
| 36 | gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has | ||
| 37 | this problem. The tzset replacement is necessary for at least | ||
| 38 | Solaris 2.5, 2.5.1, and 2.6. */ | ||
| 39 | |||
| 40 | static struct tm tm_zero_buffer; | ||
| 41 | static struct tm *localtime_buffer_addr = &tm_zero_buffer; | ||
| 42 | |||
| 43 | # undef localtime | ||
| 44 | extern struct tm *localtime (time_t const *); | ||
| 45 | |||
| 46 | # undef gmtime | ||
| 47 | extern struct tm *gmtime (time_t const *); | ||
| 48 | |||
| 49 | /* This is a wrapper for localtime. It is used only on systems for which | ||
| 50 | gettimeofday clobbers the static buffer used for localtime's result. | ||
| 51 | |||
| 52 | On the first call, record the address of the static buffer that | ||
| 53 | localtime uses for its result. */ | ||
| 54 | |||
| 55 | struct tm * | ||
| 56 | rpl_localtime (time_t const *timep) | ||
| 57 | { | ||
| 58 | struct tm *tm = localtime (timep); | ||
| 59 | |||
| 60 | if (localtime_buffer_addr == &tm_zero_buffer) | ||
| 61 | localtime_buffer_addr = tm; | ||
| 62 | |||
| 63 | return tm; | ||
| 64 | } | ||
| 65 | |||
| 66 | /* Same as above, since gmtime and localtime use the same buffer. */ | ||
| 67 | struct tm * | ||
| 68 | rpl_gmtime (time_t const *timep) | ||
| 69 | { | ||
| 70 | struct tm *tm = gmtime (timep); | ||
| 71 | |||
| 72 | if (localtime_buffer_addr == &tm_zero_buffer) | ||
| 73 | localtime_buffer_addr = tm; | ||
| 74 | |||
| 75 | return tm; | ||
| 76 | } | ||
| 77 | |||
| 78 | #endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ | ||
| 79 | |||
| 80 | #if TZSET_CLOBBERS_LOCALTIME | ||
| 81 | |||
| 82 | # undef tzset | ||
| 83 | extern void tzset (void); | ||
| 84 | |||
| 85 | /* This is a wrapper for tzset, for systems on which tzset may clobber | ||
| 86 | the static buffer used for localtime's result. */ | ||
| 87 | void | ||
| 88 | rpl_tzset (void) | ||
| 89 | { | ||
| 90 | /* Save and restore the contents of the buffer used for localtime's | ||
| 91 | result around the call to tzset. */ | ||
| 92 | struct tm save = *localtime_buffer_addr; | ||
| 93 | tzset (); | ||
| 94 | *localtime_buffer_addr = save; | ||
| 95 | } | ||
| 96 | |||
| 97 | #endif | ||
| 98 | 33 | ||
| 99 | #ifdef WINDOWS_NATIVE | 34 | #ifdef WINDOWS_NATIVE |
| 100 | 35 | ||
| @@ -119,7 +54,11 @@ initialize (void) | |||
| 119 | 54 | ||
| 120 | /* This is a wrapper for gettimeofday. It is used only on systems | 55 | /* This is a wrapper for gettimeofday. It is used only on systems |
| 121 | that lack this function, or whose implementation of this function | 56 | that lack this function, or whose implementation of this function |
| 122 | causes problems. */ | 57 | causes problems. |
| 58 | Work around the bug in some systems whereby gettimeofday clobbers | ||
| 59 | the static buffer that localtime uses for its return value. The | ||
| 60 | gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has | ||
| 61 | this problem. */ | ||
| 123 | 62 | ||
| 124 | int | 63 | int |
| 125 | gettimeofday (struct timeval *restrict tv, void *restrict tz) | 64 | gettimeofday (struct timeval *restrict tv, void *restrict tz) |
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 59cdbdb847a..51ae1891244 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | # the same distribution terms as the rest of that program. | 21 | # the same distribution terms as the rest of that program. |
| 22 | # | 22 | # |
| 23 | # Generated by gnulib-tool. | 23 | # Generated by gnulib-tool. |
| 24 | # Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stat --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=unsetenv --avoid=utime-h --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub update-copyright utimens vla warnings | 24 | # Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stat --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=tzset --avoid=unsetenv --avoid=utime --avoid=utime-h --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub update-copyright utimens vla warnings |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | MOSTLYCLEANFILES += core *.stackdump | 27 | MOSTLYCLEANFILES += core *.stackdump |
| @@ -307,6 +307,7 @@ GNULIB_TIME_R = @GNULIB_TIME_R@ | |||
| 307 | GNULIB_TIME_RZ = @GNULIB_TIME_RZ@ | 307 | GNULIB_TIME_RZ = @GNULIB_TIME_RZ@ |
| 308 | GNULIB_TMPFILE = @GNULIB_TMPFILE@ | 308 | GNULIB_TMPFILE = @GNULIB_TMPFILE@ |
| 309 | GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ | 309 | GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ |
| 310 | GNULIB_TZSET = @GNULIB_TZSET@ | ||
| 310 | GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@ | 311 | GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@ |
| 311 | GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ | 312 | GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@ |
| 312 | GNULIB_UNLINK = @GNULIB_UNLINK@ | 313 | GNULIB_UNLINK = @GNULIB_UNLINK@ |
| @@ -504,6 +505,7 @@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ | |||
| 504 | HAVE_TIMEGM = @HAVE_TIMEGM@ | 505 | HAVE_TIMEGM = @HAVE_TIMEGM@ |
| 505 | HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@ | 506 | HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@ |
| 506 | HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ | 507 | HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ |
| 508 | HAVE_TZSET = @HAVE_TZSET@ | ||
| 507 | HAVE_UNISTD_H = @HAVE_UNISTD_H@ | 509 | HAVE_UNISTD_H = @HAVE_UNISTD_H@ |
| 508 | HAVE_UNLINKAT = @HAVE_UNLINKAT@ | 510 | HAVE_UNLINKAT = @HAVE_UNLINKAT@ |
| 509 | HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ | 511 | HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ |
| @@ -780,6 +782,7 @@ REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@ | |||
| 780 | REPLACE_TIMEGM = @REPLACE_TIMEGM@ | 782 | REPLACE_TIMEGM = @REPLACE_TIMEGM@ |
| 781 | REPLACE_TMPFILE = @REPLACE_TMPFILE@ | 783 | REPLACE_TMPFILE = @REPLACE_TMPFILE@ |
| 782 | REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ | 784 | REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ |
| 785 | REPLACE_TZSET = @REPLACE_TZSET@ | ||
| 783 | REPLACE_UNLINK = @REPLACE_UNLINK@ | 786 | REPLACE_UNLINK = @REPLACE_UNLINK@ |
| 784 | REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ | 787 | REPLACE_UNLINKAT = @REPLACE_UNLINKAT@ |
| 785 | REPLACE_UNSETENV = @REPLACE_UNSETENV@ | 788 | REPLACE_UNSETENV = @REPLACE_UNSETENV@ |
| @@ -879,6 +882,7 @@ gamedir = @gamedir@ | |||
| 879 | gamegroup = @gamegroup@ | 882 | gamegroup = @gamegroup@ |
| 880 | gameuser = @gameuser@ | 883 | gameuser = @gameuser@ |
| 881 | gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@ | 884 | gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@ |
| 885 | gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9 = @gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9@ | ||
| 882 | gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@ | 886 | gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@ |
| 883 | gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@ | 887 | gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@ |
| 884 | gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@ | 888 | gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@ |
| @@ -1700,6 +1704,19 @@ EXTRA_DIST += limits.in.h | |||
| 1700 | endif | 1704 | endif |
| 1701 | ## end gnulib module limits-h | 1705 | ## end gnulib module limits-h |
| 1702 | 1706 | ||
| 1707 | ## begin gnulib module localtime-buffer | ||
| 1708 | ifeq (,$(OMIT_GNULIB_MODULE_localtime-buffer)) | ||
| 1709 | |||
| 1710 | ifneq (,$(gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9)) | ||
| 1711 | |||
| 1712 | endif | ||
| 1713 | EXTRA_DIST += localtime-buffer.c localtime-buffer.h | ||
| 1714 | |||
| 1715 | EXTRA_libgnu_a_SOURCES += localtime-buffer.c | ||
| 1716 | |||
| 1717 | endif | ||
| 1718 | ## end gnulib module localtime-buffer | ||
| 1719 | |||
| 1703 | ## begin gnulib module lstat | 1720 | ## begin gnulib module lstat |
| 1704 | ifeq (,$(OMIT_GNULIB_MODULE_lstat)) | 1721 | ifeq (,$(OMIT_GNULIB_MODULE_lstat)) |
| 1705 | 1722 | ||
| @@ -2707,7 +2724,6 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( | |||
| 2707 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ | 2724 | -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ |
| 2708 | -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ | 2725 | -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ |
| 2709 | -e 's/@''GNULIB_CTIME''@/$(GNULIB_CTIME)/g' \ | 2726 | -e 's/@''GNULIB_CTIME''@/$(GNULIB_CTIME)/g' \ |
| 2710 | -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ | ||
| 2711 | -e 's/@''GNULIB_LOCALTIME''@/$(GNULIB_LOCALTIME)/g' \ | 2727 | -e 's/@''GNULIB_LOCALTIME''@/$(GNULIB_LOCALTIME)/g' \ |
| 2712 | -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ | 2728 | -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ |
| 2713 | -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ | 2729 | -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ |
| @@ -2716,11 +2732,13 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( | |||
| 2716 | -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ | 2732 | -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ |
| 2717 | -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ | 2733 | -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ |
| 2718 | -e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \ | 2734 | -e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \ |
| 2735 | -e 's/@''GNULIB_TZSET''@/$(GNULIB_TZSET)/g' \ | ||
| 2719 | -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ | 2736 | -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ |
| 2720 | -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ | 2737 | -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ |
| 2721 | -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ | 2738 | -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ |
| 2722 | -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ | 2739 | -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ |
| 2723 | -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ | 2740 | -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ |
| 2741 | -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \ | ||
| 2724 | -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \ | 2742 | -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \ |
| 2725 | -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ | 2743 | -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ |
| 2726 | -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ | 2744 | -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ |
| @@ -2729,6 +2747,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( | |||
| 2729 | -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ | 2747 | -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ |
| 2730 | -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \ | 2748 | -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \ |
| 2731 | -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ | 2749 | -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ |
| 2750 | -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \ | ||
| 2732 | -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ | 2751 | -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ |
| 2733 | -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ | 2752 | -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ |
| 2734 | -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ | 2753 | -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ |
diff --git a/lib/localtime-buffer.c b/lib/localtime-buffer.c new file mode 100644 index 00000000000..f84ad3e8238 --- /dev/null +++ b/lib/localtime-buffer.c | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | /* Provide access to the last buffer returned by localtime() or gmtime(). | ||
| 2 | |||
| 3 | Copyright (C) 2001-2003, 2005-2007, 2009-2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This program is free software; you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation; either version 3, or (at your option) | ||
| 8 | any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ | ||
| 17 | |||
| 18 | /* written by Jim Meyering */ | ||
| 19 | |||
| 20 | #include <config.h> | ||
| 21 | |||
| 22 | /* Specification. */ | ||
| 23 | #include "localtime-buffer.h" | ||
| 24 | |||
| 25 | #if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME | ||
| 26 | |||
| 27 | static struct tm tm_zero_buffer; | ||
| 28 | struct tm *localtime_buffer_addr = &tm_zero_buffer; | ||
| 29 | |||
| 30 | /* This is a wrapper for localtime. | ||
| 31 | |||
| 32 | On the first call, record the address of the static buffer that | ||
| 33 | localtime uses for its result. */ | ||
| 34 | |||
| 35 | struct tm * | ||
| 36 | rpl_localtime (time_t const *timep) | ||
| 37 | { | ||
| 38 | struct tm *tm = localtime (timep); | ||
| 39 | |||
| 40 | if (localtime_buffer_addr == &tm_zero_buffer) | ||
| 41 | localtime_buffer_addr = tm; | ||
| 42 | |||
| 43 | return tm; | ||
| 44 | } | ||
| 45 | |||
| 46 | /* Same as above, since gmtime and localtime use the same buffer. */ | ||
| 47 | struct tm * | ||
| 48 | rpl_gmtime (time_t const *timep) | ||
| 49 | { | ||
| 50 | struct tm *tm = gmtime (timep); | ||
| 51 | |||
| 52 | if (localtime_buffer_addr == &tm_zero_buffer) | ||
| 53 | localtime_buffer_addr = tm; | ||
| 54 | |||
| 55 | return tm; | ||
| 56 | } | ||
| 57 | |||
| 58 | #endif | ||
diff --git a/lib/localtime-buffer.h b/lib/localtime-buffer.h new file mode 100644 index 00000000000..483a579bda4 --- /dev/null +++ b/lib/localtime-buffer.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* Provide access to the last buffer returned by localtime() or gmtime(). | ||
| 2 | |||
| 3 | Copyright (C) 2001-2003, 2005-2007, 2009-2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This program is free software; you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation; either version 3, or (at your option) | ||
| 8 | any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ | ||
| 17 | |||
| 18 | /* written by Jim Meyering */ | ||
| 19 | |||
| 20 | #include <time.h> | ||
| 21 | |||
| 22 | #if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME | ||
| 23 | |||
| 24 | /* The address of the last buffer returned by localtime() or gmtime(). */ | ||
| 25 | extern struct tm *localtime_buffer_addr; | ||
| 26 | |||
| 27 | #endif | ||
diff --git a/lib/time.in.h b/lib/time.in.h index d2a0302f464..f0c7ef86667 100644 --- a/lib/time.in.h +++ b/lib/time.in.h | |||
| @@ -120,6 +120,24 @@ _GL_CXXALIAS_SYS (nanosleep, int, | |||
| 120 | _GL_CXXALIASWARN (nanosleep); | 120 | _GL_CXXALIASWARN (nanosleep); |
| 121 | # endif | 121 | # endif |
| 122 | 122 | ||
| 123 | /* Initialize time conversion information. */ | ||
| 124 | # if @GNULIB_TZSET@ | ||
| 125 | # if @REPLACE_TZSET@ | ||
| 126 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 127 | # undef tzset | ||
| 128 | # define tzset rpl_tzset | ||
| 129 | # endif | ||
| 130 | _GL_FUNCDECL_RPL (tzset, void, (void)); | ||
| 131 | _GL_CXXALIAS_RPL (tzset, void, (void)); | ||
| 132 | # else | ||
| 133 | # if ! @HAVE_TZSET@ | ||
| 134 | _GL_FUNCDECL_SYS (tzset, void, (void)); | ||
| 135 | # endif | ||
| 136 | _GL_CXXALIAS_SYS (tzset, void, (void)); | ||
| 137 | # endif | ||
| 138 | _GL_CXXALIASWARN (tzset); | ||
| 139 | # endif | ||
| 140 | |||
| 123 | /* Return the 'time_t' representation of TP and normalize TP. */ | 141 | /* Return the 'time_t' representation of TP and normalize TP. */ |
| 124 | # if @GNULIB_MKTIME@ | 142 | # if @GNULIB_MKTIME@ |
| 125 | # if @REPLACE_MKTIME@ | 143 | # if @REPLACE_MKTIME@ |
| @@ -187,7 +205,7 @@ _GL_CXXALIASWARN (gmtime_r); | |||
| 187 | /* Convert TIMER to RESULT, assuming local time and UTC respectively. See | 205 | /* Convert TIMER to RESULT, assuming local time and UTC respectively. See |
| 188 | <http://www.opengroup.org/susv3xsh/localtime.html> and | 206 | <http://www.opengroup.org/susv3xsh/localtime.html> and |
| 189 | <http://www.opengroup.org/susv3xsh/gmtime.html>. */ | 207 | <http://www.opengroup.org/susv3xsh/gmtime.html>. */ |
| 190 | # if @GNULIB_LOCALTIME@ || @GNULIB_GETTIMEOFDAY@ | 208 | # if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@ |
| 191 | # if @REPLACE_LOCALTIME@ | 209 | # if @REPLACE_LOCALTIME@ |
| 192 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 210 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 193 | # undef localtime | 211 | # undef localtime |
| @@ -202,7 +220,7 @@ _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); | |||
| 202 | _GL_CXXALIASWARN (localtime); | 220 | _GL_CXXALIASWARN (localtime); |
| 203 | # endif | 221 | # endif |
| 204 | 222 | ||
| 205 | # if @GNULIB_GETTIMEOFDAY@ | 223 | # if 0 || @REPLACE_GMTIME@ |
| 206 | # if @REPLACE_GMTIME@ | 224 | # if @REPLACE_GMTIME@ |
| 207 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 225 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 208 | # undef gmtime | 226 | # undef gmtime |
diff --git a/lib/time_rz.c b/lib/time_rz.c index c41a8ef47ac..17bc11c20e9 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c | |||
| @@ -40,10 +40,6 @@ | |||
| 40 | # define SIZE_MAX ((size_t) -1) | 40 | # define SIZE_MAX ((size_t) -1) |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | #if !HAVE_TZSET | ||
| 44 | static void tzset (void) { } | ||
| 45 | #endif | ||
| 46 | |||
| 47 | /* The approximate size to use for small allocation requests. This is | 43 | /* The approximate size to use for small allocation requests. This is |
| 48 | the largest "small" request for the GNU C library malloc. */ | 44 | the largest "small" request for the GNU C library malloc. */ |
| 49 | enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; | 45 | enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; |
diff --git a/lib/utimens.c b/lib/utimens.c index 3b451193350..0b3b8e2f3af 100644 --- a/lib/utimens.c +++ b/lib/utimens.c | |||
| @@ -35,6 +35,12 @@ | |||
| 35 | #include "stat-time.h" | 35 | #include "stat-time.h" |
| 36 | #include "timespec.h" | 36 | #include "timespec.h" |
| 37 | 37 | ||
| 38 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 39 | # define WIN32_LEAN_AND_MEAN | ||
| 40 | # include <windows.h> | ||
| 41 | # include "msvc-nothrow.h" | ||
| 42 | #endif | ||
| 43 | |||
| 38 | /* Avoid recursion with rpl_futimens or rpl_utimensat. */ | 44 | /* Avoid recursion with rpl_futimens or rpl_utimensat. */ |
| 39 | #undef futimens | 45 | #undef futimens |
| 40 | #undef utimensat | 46 | #undef utimensat |
| @@ -271,6 +277,82 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2]) | |||
| 271 | lutimensat_works_really = -1; | 277 | lutimensat_works_really = -1; |
| 272 | #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ | 278 | #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ |
| 273 | 279 | ||
| 280 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 281 | /* On native Windows, use SetFileTime(). See | ||
| 282 | <https://msdn.microsoft.com/en-us/library/ms724933.aspx> | ||
| 283 | <https://msdn.microsoft.com/en-us/library/ms724284.aspx> */ | ||
| 284 | if (0 <= fd) | ||
| 285 | { | ||
| 286 | HANDLE handle; | ||
| 287 | FILETIME current_time; | ||
| 288 | FILETIME last_access_time; | ||
| 289 | FILETIME last_write_time; | ||
| 290 | |||
| 291 | handle = (HANDLE) _get_osfhandle (fd); | ||
| 292 | if (handle == INVALID_HANDLE_VALUE) | ||
| 293 | { | ||
| 294 | errno = EBADF; | ||
| 295 | return -1; | ||
| 296 | } | ||
| 297 | |||
| 298 | if (ts == NULL || ts[0].tv_nsec == UTIME_NOW || ts[1].tv_nsec == UTIME_NOW) | ||
| 299 | { | ||
| 300 | /* GetSystemTimeAsFileTime | ||
| 301 | <https://msdn.microsoft.com/en-us/library/ms724397.aspx>. | ||
| 302 | It would be overkill to use | ||
| 303 | GetSystemTimePreciseAsFileTime | ||
| 304 | <https://msdn.microsoft.com/en-us/library/hh706895.aspx>. */ | ||
| 305 | GetSystemTimeAsFileTime (¤t_time); | ||
| 306 | } | ||
| 307 | |||
| 308 | if (ts == NULL || ts[0].tv_nsec == UTIME_NOW) | ||
| 309 | { | ||
| 310 | last_access_time = current_time; | ||
| 311 | } | ||
| 312 | else if (ts[0].tv_nsec == UTIME_OMIT) | ||
| 313 | { | ||
| 314 | last_access_time.dwLowDateTime = 0; | ||
| 315 | last_access_time.dwHighDateTime = 0; | ||
| 316 | } | ||
| 317 | else | ||
| 318 | { | ||
| 319 | ULONGLONG time_since_16010101 = | ||
| 320 | (ULONGLONG) ts[0].tv_sec * 10000000 + ts[0].tv_nsec / 100 + 116444736000000000LL; | ||
| 321 | last_access_time.dwLowDateTime = (DWORD) time_since_16010101; | ||
| 322 | last_access_time.dwHighDateTime = time_since_16010101 >> 32; | ||
| 323 | } | ||
| 324 | |||
| 325 | if (ts == NULL || ts[1].tv_nsec == UTIME_NOW) | ||
| 326 | { | ||
| 327 | last_write_time = current_time; | ||
| 328 | } | ||
| 329 | else if (ts[1].tv_nsec == UTIME_OMIT) | ||
| 330 | { | ||
| 331 | last_write_time.dwLowDateTime = 0; | ||
| 332 | last_write_time.dwHighDateTime = 0; | ||
| 333 | } | ||
| 334 | else | ||
| 335 | { | ||
| 336 | ULONGLONG time_since_16010101 = | ||
| 337 | (ULONGLONG) ts[1].tv_sec * 10000000 + ts[1].tv_nsec / 100 + 116444736000000000LL; | ||
| 338 | last_write_time.dwLowDateTime = (DWORD) time_since_16010101; | ||
| 339 | last_write_time.dwHighDateTime = time_since_16010101 >> 32; | ||
| 340 | } | ||
| 341 | |||
| 342 | if (SetFileTime (handle, NULL, &last_access_time, &last_write_time)) | ||
| 343 | return 0; | ||
| 344 | else | ||
| 345 | { | ||
| 346 | #if 0 | ||
| 347 | DWORD sft_error = GetLastError (); | ||
| 348 | fprintf (stderr, "utime SetFileTime error 0x%x\n", (unsigned int) sft_error); | ||
| 349 | #endif | ||
| 350 | errno = EINVAL; | ||
| 351 | return -1; | ||
| 352 | } | ||
| 353 | } | ||
| 354 | #endif | ||
| 355 | |||
| 274 | /* The platform lacks an interface to set file timestamps with | 356 | /* The platform lacks an interface to set file timestamps with |
| 275 | nanosecond resolution, so do the best we can, discarding any | 357 | nanosecond resolution, so do the best we can, discarding any |
| 276 | fractional part of the timestamp. */ | 358 | fractional part of the timestamp. */ |
diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index 742b6c9e10e..34adc64778f 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 | |||
| @@ -54,19 +54,6 @@ int gettimeofday (struct timeval *restrict, struct timezone *restrict); | |||
| 54 | if test $REPLACE_STRUCT_TIMEVAL = 1; then | 54 | if test $REPLACE_STRUCT_TIMEVAL = 1; then |
| 55 | REPLACE_GETTIMEOFDAY=1 | 55 | REPLACE_GETTIMEOFDAY=1 |
| 56 | fi | 56 | fi |
| 57 | m4_ifdef([gl_FUNC_TZSET_CLOBBER], [ | ||
| 58 | gl_FUNC_TZSET_CLOBBER | ||
| 59 | case "$gl_cv_func_tzset_clobber" in | ||
| 60 | *yes) | ||
| 61 | REPLACE_GETTIMEOFDAY=1 | ||
| 62 | gl_GETTIMEOFDAY_REPLACE_LOCALTIME | ||
| 63 | AC_DEFINE([tzset], [rpl_tzset], | ||
| 64 | [Define to rpl_tzset if the wrapper function should be used.]) | ||
| 65 | AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1], | ||
| 66 | [Define if tzset clobbers localtime's static buffer.]) | ||
| 67 | ;; | ||
| 68 | esac | ||
| 69 | ]) | ||
| 70 | fi | 57 | fi |
| 71 | AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone], | 58 | AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone], |
| 72 | [Define this to 'void' or 'struct timezone' to match the system's | 59 | [Define this to 'void' or 'struct timezone' to match the system's |
| @@ -85,6 +72,7 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], | |||
| 85 | [ | 72 | [ |
| 86 | AC_REQUIRE([gl_HEADER_SYS_TIME_H]) | 73 | AC_REQUIRE([gl_HEADER_SYS_TIME_H]) |
| 87 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | 74 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 75 | AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS]) | ||
| 88 | 76 | ||
| 89 | AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], | 77 | AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], |
| 90 | [gl_cv_func_gettimeofday_clobber], | 78 | [gl_cv_func_gettimeofday_clobber], |
| @@ -119,17 +107,12 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], | |||
| 119 | case "$gl_cv_func_gettimeofday_clobber" in | 107 | case "$gl_cv_func_gettimeofday_clobber" in |
| 120 | *yes) | 108 | *yes) |
| 121 | REPLACE_GETTIMEOFDAY=1 | 109 | REPLACE_GETTIMEOFDAY=1 |
| 122 | gl_GETTIMEOFDAY_REPLACE_LOCALTIME | ||
| 123 | AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1], | 110 | AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1], |
| 124 | [Define if gettimeofday clobbers the localtime buffer.]) | 111 | [Define if gettimeofday clobbers the localtime buffer.]) |
| 112 | gl_LOCALTIME_BUFFER_NEEDED | ||
| 125 | ;; | 113 | ;; |
| 126 | esac | 114 | esac |
| 127 | ]) | 115 | ]) |
| 128 | 116 | ||
| 129 | AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [ | ||
| 130 | REPLACE_GMTIME=1 | ||
| 131 | REPLACE_LOCALTIME=1 | ||
| 132 | ]) | ||
| 133 | |||
| 134 | # Prerequisites of lib/gettimeofday.c. | 117 | # Prerequisites of lib/gettimeofday.c. |
| 135 | AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [:]) | 118 | AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [:]) |
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 136762430e0..74b197c8633 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 | |||
| @@ -101,6 +101,7 @@ AC_DEFUN([gl_EARLY], | |||
| 101 | # Code from module largefile: | 101 | # Code from module largefile: |
| 102 | AC_REQUIRE([AC_SYS_LARGEFILE]) | 102 | AC_REQUIRE([AC_SYS_LARGEFILE]) |
| 103 | # Code from module limits-h: | 103 | # Code from module limits-h: |
| 104 | # Code from module localtime-buffer: | ||
| 104 | # Code from module lstat: | 105 | # Code from module lstat: |
| 105 | # Code from module manywarnings: | 106 | # Code from module manywarnings: |
| 106 | # Code from module memrchr: | 107 | # Code from module memrchr: |
| @@ -413,6 +414,7 @@ AC_DEFUN([gl_INIT], | |||
| 413 | gl_gnulib_enabled_getgroups=false | 414 | gl_gnulib_enabled_getgroups=false |
| 414 | gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false | 415 | gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false |
| 415 | gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false | 416 | gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false |
| 417 | gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9=false | ||
| 416 | gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false | 418 | gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false |
| 417 | gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false | 419 | gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false |
| 418 | gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false | 420 | gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false |
| @@ -512,6 +514,14 @@ AC_DEFUN([gl_INIT], | |||
| 512 | fi | 514 | fi |
| 513 | fi | 515 | fi |
| 514 | } | 516 | } |
| 517 | func_gl_gnulib_m4code_2049e887c7e5308faad27b3f894bb8c9 () | ||
| 518 | { | ||
| 519 | if ! $gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9; then | ||
| 520 | AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS]) | ||
| 521 | AC_LIBOBJ([localtime-buffer]) | ||
| 522 | gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9=true | ||
| 523 | fi | ||
| 524 | } | ||
| 515 | func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 () | 525 | func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 () |
| 516 | { | 526 | { |
| 517 | if ! $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31; then | 527 | if ! $gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31; then |
| @@ -618,6 +628,9 @@ AC_DEFUN([gl_INIT], | |||
| 618 | if test $REPLACE_GETOPT = 1; then | 628 | if test $REPLACE_GETOPT = 1; then |
| 619 | func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 | 629 | func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 |
| 620 | fi | 630 | fi |
| 631 | if test $NEED_LOCALTIME_BUFFER = 1; then | ||
| 632 | func_gl_gnulib_m4code_2049e887c7e5308faad27b3f894bb8c9 | ||
| 633 | fi | ||
| 621 | if test $REPLACE_LSTAT = 1; then | 634 | if test $REPLACE_LSTAT = 1; then |
| 622 | func_gl_gnulib_m4code_dosname | 635 | func_gl_gnulib_m4code_dosname |
| 623 | fi | 636 | fi |
| @@ -651,6 +664,7 @@ AC_DEFUN([gl_INIT], | |||
| 651 | AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) | 664 | AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) |
| 652 | AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) | 665 | AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) |
| 653 | AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) | 666 | AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) |
| 667 | AM_CONDITIONAL([gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9], [$gl_gnulib_enabled_2049e887c7e5308faad27b3f894bb8c9]) | ||
| 654 | AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) | 668 | AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) |
| 655 | AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) | 669 | AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) |
| 656 | AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) | 670 | AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) |
| @@ -880,6 +894,8 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 880 | lib/intprops.h | 894 | lib/intprops.h |
| 881 | lib/inttypes.in.h | 895 | lib/inttypes.in.h |
| 882 | lib/limits.in.h | 896 | lib/limits.in.h |
| 897 | lib/localtime-buffer.c | ||
| 898 | lib/localtime-buffer.h | ||
| 883 | lib/lstat.c | 899 | lib/lstat.c |
| 884 | lib/md5.c | 900 | lib/md5.c |
| 885 | lib/md5.h | 901 | lib/md5.h |
| @@ -997,6 +1013,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 997 | m4/inttypes.m4 | 1013 | m4/inttypes.m4 |
| 998 | m4/largefile.m4 | 1014 | m4/largefile.m4 |
| 999 | m4/limits-h.m4 | 1015 | m4/limits-h.m4 |
| 1016 | m4/localtime-buffer.m4 | ||
| 1000 | m4/longlong.m4 | 1017 | m4/longlong.m4 |
| 1001 | m4/lstat.m4 | 1018 | m4/lstat.m4 |
| 1002 | m4/manywarnings.m4 | 1019 | m4/manywarnings.m4 |
diff --git a/m4/localtime-buffer.m4 b/m4/localtime-buffer.m4 new file mode 100644 index 00000000000..3965b5d9f2b --- /dev/null +++ b/m4/localtime-buffer.m4 | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | # localtime-buffer.m4 serial 1 | ||
| 2 | dnl Copyright (C) 2017 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | ||
| 4 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 5 | dnl with or without modifications, as long as this notice is preserved. | ||
| 6 | |||
| 7 | AC_DEFUN([gl_LOCALTIME_BUFFER_DEFAULTS], | ||
| 8 | [ | ||
| 9 | NEED_LOCALTIME_BUFFER=0 | ||
| 10 | ]) | ||
| 11 | |||
| 12 | dnl Macro invoked from other modules, to signal that the compilation of | ||
| 13 | dnl module 'localtime-buffer' is needed. | ||
| 14 | AC_DEFUN([gl_LOCALTIME_BUFFER_NEEDED], | ||
| 15 | [ | ||
| 16 | AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS]) | ||
| 17 | AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) | ||
| 18 | NEED_LOCALTIME_BUFFER=1 | ||
| 19 | REPLACE_GMTIME=1 | ||
| 20 | REPLACE_LOCALTIME=1 | ||
| 21 | ]) | ||
diff --git a/m4/time_h.m4 b/m4/time_h.m4 index e0f663ec711..f52b60192e8 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 | |||
| @@ -113,11 +113,13 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], | |||
| 113 | GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) | 113 | GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) |
| 114 | GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) | 114 | GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) |
| 115 | GNULIB_TIME_RZ=0; AC_SUBST([GNULIB_TIME_RZ]) | 115 | GNULIB_TIME_RZ=0; AC_SUBST([GNULIB_TIME_RZ]) |
| 116 | GNULIB_TZSET=0; AC_SUBST([GNULIB_TZSET]) | ||
| 116 | dnl Assume proper GNU behavior unless another module says otherwise. | 117 | dnl Assume proper GNU behavior unless another module says otherwise. |
| 117 | HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) | 118 | HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) |
| 118 | HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) | 119 | HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) |
| 119 | HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) | 120 | HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) |
| 120 | HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) | 121 | HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) |
| 122 | HAVE_TZSET=1; AC_SUBST([HAVE_TZSET]) | ||
| 121 | dnl If another module says to replace or to not replace, do that. | 123 | dnl If another module says to replace or to not replace, do that. |
| 122 | dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; | 124 | dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; |
| 123 | dnl this lets maintainers check for portability. | 125 | dnl this lets maintainers check for portability. |
| @@ -127,6 +129,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], | |||
| 127 | REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) | 129 | REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) |
| 128 | REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME]) | 130 | REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME]) |
| 129 | REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) | 131 | REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) |
| 132 | REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET]) | ||
| 130 | 133 | ||
| 131 | dnl Hack so that the time module doesn't depend on the sys_time module. | 134 | dnl Hack so that the time module doesn't depend on the sys_time module. |
| 132 | dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent. | 135 | dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent. |
diff --git a/m4/time_rz.m4 b/m4/time_rz.m4 index 79060e00fcc..079e933b4e6 100644 --- a/m4/time_rz.m4 +++ b/m4/time_rz.m4 | |||
| @@ -12,7 +12,6 @@ AC_DEFUN([gl_TIME_RZ], | |||
| 12 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | 12 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 13 | AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) | 13 | AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) |
| 14 | AC_REQUIRE([AC_STRUCT_TIMEZONE]) | 14 | AC_REQUIRE([AC_STRUCT_TIMEZONE]) |
| 15 | AC_CHECK_FUNCS_ONCE([tzset]) | ||
| 16 | 15 | ||
| 17 | AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]]) | 16 | AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]]) |
| 18 | if test "$ac_cv_type_timezone_t" = yes; then | 17 | if test "$ac_cv_type_timezone_t" = yes; then |
diff --git a/src/editfns.c b/src/editfns.c index 2dafd8e7b1b..38530437a2f 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -226,7 +226,7 @@ tzlookup (Lisp_Object zone, bool settz) | |||
| 226 | void | 226 | void |
| 227 | init_editfns (bool dumping) | 227 | init_editfns (bool dumping) |
| 228 | { | 228 | { |
| 229 | #if !defined CANNOT_DUMP && defined HAVE_TZSET | 229 | #if !defined CANNOT_DUMP |
| 230 | /* A valid but unlikely setting for the TZ environment variable. | 230 | /* A valid but unlikely setting for the TZ environment variable. |
| 231 | It is OK (though a bit slower) if the user chooses this value. */ | 231 | It is OK (though a bit slower) if the user chooses this value. */ |
| 232 | static char dump_tz_string[] = "TZ=UtC0"; | 232 | static char dump_tz_string[] = "TZ=UtC0"; |
| @@ -245,17 +245,15 @@ init_editfns (bool dumping) | |||
| 245 | and skip the rest of this function. */ | 245 | and skip the rest of this function. */ |
| 246 | if (dumping) | 246 | if (dumping) |
| 247 | { | 247 | { |
| 248 | # ifdef HAVE_TZSET | ||
| 249 | xputenv (dump_tz_string); | 248 | xputenv (dump_tz_string); |
| 250 | tzset (); | 249 | tzset (); |
| 251 | # endif | ||
| 252 | return; | 250 | return; |
| 253 | } | 251 | } |
| 254 | #endif | 252 | #endif |
| 255 | 253 | ||
| 256 | char *tz = getenv ("TZ"); | 254 | char *tz = getenv ("TZ"); |
| 257 | 255 | ||
| 258 | #if !defined CANNOT_DUMP && defined HAVE_TZSET | 256 | #if !defined CANNOT_DUMP |
| 259 | /* If the execution TZ happens to be the same as the dump TZ, | 257 | /* If the execution TZ happens to be the same as the dump TZ, |
| 260 | change it to some other value and then change it back, | 258 | change it to some other value and then change it back, |
| 261 | to force the underlying implementation to reload the TZ info. | 259 | to force the underlying implementation to reload the TZ info. |