aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2017-04-30 14:52:10 -0700
committerPaul Eggert2017-04-30 14:53:17 -0700
commitb6aa3446df5e715fd74f010afad75c3c8589a9a1 (patch)
tree3b5377b3651ef95a0a77becaa7ee7ccba7b37168 /lib
parent3ad9d5c347739bb6c5450ed443ffa1608a94394c (diff)
downloademacs-b6aa3446df5e715fd74f010afad75c3c8589a9a1.tar.gz
emacs-b6aa3446df5e715fd74f010afad75c3c8589a9a1.zip
Merge from gnulib
This incorporates: 2017-04-30 strftime-fixes: New module 2017-04-30 mktime: Work around TZ problem on native Windows 2017-04-30 ctime, localtime: New modules 2017-04-30 gettimeofday: Provide higher resolution on native Windows 2017-04-29 utime-h: Modernize handling of 'struct utimbuf' 2017-04-29 Make use of module 'utime-h' 2017-04-30 Fix a few typos * admin/merge-gnulib (AVOIDED_MODULES): Avoid utime-h, too. * lib/gettimeofday.c, lib/mktime.c, lib/time.in.h, lib/utimens.c: * m4/gettimeofday.m4, m4/include_next.m4, m4/mktime.m4: * m4/strftime.m4, m4/time_h.m4, m4/timegm.m4, m4/utimens.m4: Copy from gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
Diffstat (limited to 'lib')
-rw-r--r--lib/gettimeofday.c62
-rw-r--r--lib/gnulib.mk.in12
-rw-r--r--lib/mktime.c47
-rw-r--r--lib/time.in.h37
-rw-r--r--lib/utimens.c15
5 files changed, 146 insertions, 27 deletions
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index 18dcbda4db5..86f1a8c1d28 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -24,8 +24,9 @@
24 24
25#include <time.h> 25#include <time.h>
26 26
27#if HAVE_SYS_TIMEB_H 27#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
28# include <sys/timeb.h> 28# define WINDOWS_NATIVE
29# include <windows.h>
29#endif 30#endif
30 31
31#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME 32#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
@@ -92,6 +93,28 @@ rpl_tzset (void)
92 tzset (); 93 tzset ();
93 *localtime_buffer_addr = save; 94 *localtime_buffer_addr = save;
94} 95}
96
97#endif
98
99#ifdef WINDOWS_NATIVE
100
101/* GetSystemTimePreciseAsFileTime was introduced only in Windows 8. */
102typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
103static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL;
104static BOOL initialized = FALSE;
105
106static void
107initialize (void)
108{
109 HMODULE kernel32 = LoadLibrary ("kernel32.dll");
110 if (kernel32 != NULL)
111 {
112 GetSystemTimePreciseAsFileTimeFunc =
113 (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
114 }
115 initialized = TRUE;
116}
117
95#endif 118#endif
96 119
97/* This is a wrapper for gettimeofday. It is used only on systems 120/* This is a wrapper for gettimeofday. It is used only on systems
@@ -130,12 +153,35 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
130 153
131#else 154#else
132 155
133# if HAVE__FTIME 156# ifdef WINDOWS_NATIVE
134 157
135 struct _timeb timebuf; 158 /* On native Windows, there are two ways to get the current time:
136 _ftime (&timebuf); 159 GetSystemTimeAsFileTime
137 tv->tv_sec = timebuf.time; 160 <https://msdn.microsoft.com/en-us/library/ms724397.aspx>
138 tv->tv_usec = timebuf.millitm * 1000; 161 or
162 GetSystemTimePreciseAsFileTime
163 <https://msdn.microsoft.com/en-us/library/hh706895.aspx>. */
164 FILETIME current_time;
165
166 if (!initialized)
167 initialize ();
168 if (GetSystemTimePreciseAsFileTimeFunc != NULL)
169 GetSystemTimePreciseAsFileTimeFunc (&current_time);
170 else
171 GetSystemTimeAsFileTime (&current_time);
172
173 /* Convert from FILETIME to 'struct timeval'. */
174 /* FILETIME: <https://msdn.microsoft.com/en-us/library/ms724284.aspx> */
175 ULONGLONG since_1601 =
176 ((ULONGLONG) current_time.dwHighDateTime << 32)
177 | (ULONGLONG) current_time.dwLowDateTime;
178 /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89 leap
179 years, in total 134774 days. */
180 ULONGLONG since_1970 =
181 since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000;
182 ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10;
183 tv->tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000;
184 tv->tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000;
139 185
140# else 186# else
141 187
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index af26648c0e0..59cdbdb847a 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 --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=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
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -117,6 +117,7 @@ GNULIB_CHDIR = @GNULIB_CHDIR@
117GNULIB_CHOWN = @GNULIB_CHOWN@ 117GNULIB_CHOWN = @GNULIB_CHOWN@
118GNULIB_CLOSE = @GNULIB_CLOSE@ 118GNULIB_CLOSE = @GNULIB_CLOSE@
119GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@ 119GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@
120GNULIB_CTIME = @GNULIB_CTIME@
120GNULIB_DIRFD = @GNULIB_DIRFD@ 121GNULIB_DIRFD = @GNULIB_DIRFD@
121GNULIB_DPRINTF = @GNULIB_DPRINTF@ 122GNULIB_DPRINTF = @GNULIB_DPRINTF@
122GNULIB_DUP = @GNULIB_DUP@ 123GNULIB_DUP = @GNULIB_DUP@
@@ -183,6 +184,7 @@ GNULIB_LCHMOD = @GNULIB_LCHMOD@
183GNULIB_LCHOWN = @GNULIB_LCHOWN@ 184GNULIB_LCHOWN = @GNULIB_LCHOWN@
184GNULIB_LINK = @GNULIB_LINK@ 185GNULIB_LINK = @GNULIB_LINK@
185GNULIB_LINKAT = @GNULIB_LINKAT@ 186GNULIB_LINKAT = @GNULIB_LINKAT@
187GNULIB_LOCALTIME = @GNULIB_LOCALTIME@
186GNULIB_LSEEK = @GNULIB_LSEEK@ 188GNULIB_LSEEK = @GNULIB_LSEEK@
187GNULIB_LSTAT = @GNULIB_LSTAT@ 189GNULIB_LSTAT = @GNULIB_LSTAT@
188GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@ 190GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
@@ -281,6 +283,7 @@ GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@
281GNULIB_STRDUP = @GNULIB_STRDUP@ 283GNULIB_STRDUP = @GNULIB_STRDUP@
282GNULIB_STRERROR = @GNULIB_STRERROR@ 284GNULIB_STRERROR = @GNULIB_STRERROR@
283GNULIB_STRERROR_R = @GNULIB_STRERROR_R@ 285GNULIB_STRERROR_R = @GNULIB_STRERROR_R@
286GNULIB_STRFTIME = @GNULIB_STRFTIME@
284GNULIB_STRNCAT = @GNULIB_STRNCAT@ 287GNULIB_STRNCAT = @GNULIB_STRNCAT@
285GNULIB_STRNDUP = @GNULIB_STRNDUP@ 288GNULIB_STRNDUP = @GNULIB_STRNDUP@
286GNULIB_STRNLEN = @GNULIB_STRNLEN@ 289GNULIB_STRNLEN = @GNULIB_STRNLEN@
@@ -669,6 +672,7 @@ REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
669REPLACE_CHOWN = @REPLACE_CHOWN@ 672REPLACE_CHOWN = @REPLACE_CHOWN@
670REPLACE_CLOSE = @REPLACE_CLOSE@ 673REPLACE_CLOSE = @REPLACE_CLOSE@
671REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ 674REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
675REPLACE_CTIME = @REPLACE_CTIME@
672REPLACE_DIRFD = @REPLACE_DIRFD@ 676REPLACE_DIRFD = @REPLACE_DIRFD@
673REPLACE_DPRINTF = @REPLACE_DPRINTF@ 677REPLACE_DPRINTF = @REPLACE_DPRINTF@
674REPLACE_DUP = @REPLACE_DUP@ 678REPLACE_DUP = @REPLACE_DUP@
@@ -760,6 +764,7 @@ REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@
760REPLACE_STRDUP = @REPLACE_STRDUP@ 764REPLACE_STRDUP = @REPLACE_STRDUP@
761REPLACE_STRERROR = @REPLACE_STRERROR@ 765REPLACE_STRERROR = @REPLACE_STRERROR@
762REPLACE_STRERROR_R = @REPLACE_STRERROR_R@ 766REPLACE_STRERROR_R = @REPLACE_STRERROR_R@
767REPLACE_STRFTIME = @REPLACE_STRFTIME@
763REPLACE_STRNCAT = @REPLACE_STRNCAT@ 768REPLACE_STRNCAT = @REPLACE_STRNCAT@
764REPLACE_STRNDUP = @REPLACE_STRNDUP@ 769REPLACE_STRNDUP = @REPLACE_STRNDUP@
765REPLACE_STRNLEN = @REPLACE_STRNLEN@ 770REPLACE_STRNLEN = @REPLACE_STRNLEN@
@@ -2701,9 +2706,12 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
2701 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2706 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2702 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2707 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2703 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ 2708 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
2709 -e 's/@''GNULIB_CTIME''@/$(GNULIB_CTIME)/g' \
2704 -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ 2710 -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
2711 -e 's/@''GNULIB_LOCALTIME''@/$(GNULIB_LOCALTIME)/g' \
2705 -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ 2712 -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
2706 -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ 2713 -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
2714 -e 's/@''GNULIB_STRFTIME''@/$(GNULIB_STRFTIME)/g' \
2707 -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ 2715 -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
2708 -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ 2716 -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
2709 -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ 2717 -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
@@ -2713,11 +2721,13 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
2713 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ 2721 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
2714 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ 2722 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
2715 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ 2723 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
2724 -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
2716 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ 2725 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
2717 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ 2726 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
2718 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ 2727 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
2719 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ 2728 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
2720 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ 2729 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
2730 -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
2721 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ 2731 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
2722 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2732 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
2723 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2733 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
diff --git a/lib/mktime.c b/lib/mktime.c
index 998882f5860..06d5916e910 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -23,6 +23,19 @@
23# define DEBUG_MKTIME 0 23# define DEBUG_MKTIME 0
24#endif 24#endif
25 25
26/* The following macros influence what gets defined when this file is compiled:
27
28 Macro/expression Which gnulib module This compilation unit
29 should define
30
31 NEED_MKTIME_WORKING mktime rpl_mktime
32 || NEED_MKTIME_WINDOWS
33
34 NEED_MKTIME_INTERNAL mktime-internal mktime_internal
35
36 DEBUG_MKTIME (defined manually) my_mktime, main
37 */
38
26#if !defined _LIBC && !DEBUG_MKTIME 39#if !defined _LIBC && !DEBUG_MKTIME
27# include <config.h> 40# include <config.h>
28#endif 41#endif
@@ -51,6 +64,13 @@
51# define mktime my_mktime 64# define mktime my_mktime
52#endif 65#endif
53 66
67#if NEED_MKTIME_WINDOWS /* on native Windows */
68# include <stdlib.h>
69# include <string.h>
70#endif
71
72#if NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL || DEBUG_MKTIME
73
54/* A signed type that can represent an integer number of years 74/* A signed type that can represent an integer number of years
55 multiplied by three times the number of seconds in a year. It is 75 multiplied by three times the number of seconds in a year. It is
56 needed when converting a tm_year value times the number of seconds 76 needed when converting a tm_year value times the number of seconds
@@ -458,25 +478,46 @@ __mktime_internal (struct tm *tp,
458 return t; 478 return t;
459} 479}
460 480
481#endif /* NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL || DEBUG_MKTIME */
482
483#if NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS || DEBUG_MKTIME
461 484
485# if NEED_MKTIME_WORKING || DEBUG_MKTIME
462static mktime_offset_t localtime_offset; 486static mktime_offset_t localtime_offset;
487# endif
463 488
464/* Convert *TP to a time_t value. */ 489/* Convert *TP to a time_t value. */
465time_t 490time_t
466mktime (struct tm *tp) 491mktime (struct tm *tp)
467{ 492{
468#ifdef _LIBC 493# if NEED_MKTIME_WINDOWS
494 /* If the environment variable TZ has been set by Cygwin, neutralize it.
495 The Microsoft CRT interprets TZ differently than Cygwin and produces
496 incorrect results if TZ has the syntax used by Cygwin. */
497 const char *tz = getenv ("TZ");
498 if (tz != NULL && strchr (tz, '/') != NULL)
499 _putenv ("TZ=");
500# endif
501
502# if NEED_MKTIME_WORKING || DEBUG_MKTIME
503# ifdef _LIBC
469 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the 504 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the
470 time zone names contained in the external variable 'tzname' shall 505 time zone names contained in the external variable 'tzname' shall
471 be set as if the tzset() function had been called. */ 506 be set as if the tzset() function had been called. */
472 __tzset (); 507 __tzset ();
473#elif HAVE_TZSET 508# elif HAVE_TZSET
474 tzset (); 509 tzset ();
475#endif 510# endif
476 511
477 return __mktime_internal (tp, __localtime_r, &localtime_offset); 512 return __mktime_internal (tp, __localtime_r, &localtime_offset);
513# else
514# undef mktime
515 return mktime (tp);
516# endif
478} 517}
479 518
519#endif /* NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS || DEBUG_MKTIME */
520
480#ifdef weak_alias 521#ifdef weak_alias
481weak_alias (mktime, timelocal) 522weak_alias (mktime, timelocal)
482#endif 523#endif
diff --git a/lib/time.in.h b/lib/time.in.h
index fef89807f8a..d2a0302f464 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -187,7 +187,7 @@ _GL_CXXALIASWARN (gmtime_r);
187/* Convert TIMER to RESULT, assuming local time and UTC respectively. See 187/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
188 <http://www.opengroup.org/susv3xsh/localtime.html> and 188 <http://www.opengroup.org/susv3xsh/localtime.html> and
189 <http://www.opengroup.org/susv3xsh/gmtime.html>. */ 189 <http://www.opengroup.org/susv3xsh/gmtime.html>. */
190# if @GNULIB_GETTIMEOFDAY@ 190# if @GNULIB_LOCALTIME@ || @GNULIB_GETTIMEOFDAY@
191# if @REPLACE_LOCALTIME@ 191# if @REPLACE_LOCALTIME@
192# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 192# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
193# undef localtime 193# undef localtime
@@ -233,6 +233,41 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
233_GL_CXXALIASWARN (strptime); 233_GL_CXXALIASWARN (strptime);
234# endif 234# endif
235 235
236/* Convert *TP to a date and time string. See
237 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
238# if @GNULIB_CTIME@
239# if @REPLACE_CTIME@
240# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
241# define ctime rpl_ctime
242# endif
243_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
244 _GL_ARG_NONNULL ((1)));
245_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
246# else
247_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
248# endif
249_GL_CXXALIASWARN (ctime);
250# endif
251
252/* Convert *TP to a date and time string. See
253 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
254# if @GNULIB_STRFTIME@
255# if @REPLACE_STRFTIME@
256# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257# define strftime rpl_strftime
258# endif
259_GL_FUNCDECL_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
260 const char *__fmt, const struct tm *__tp)
261 _GL_ARG_NONNULL ((1, 3, 4)));
262_GL_CXXALIAS_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
263 const char *__fmt, const struct tm *__tp));
264# else
265_GL_CXXALIAS_SYS (strftime, size_t, (char *__buf, size_t __bufsize,
266 const char *__fmt, const struct tm *__tp));
267# endif
268_GL_CXXALIASWARN (strftime);
269# endif
270
236# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@ 271# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
237typedef struct tm_zone *timezone_t; 272typedef struct tm_zone *timezone_t;
238_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name)); 273_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
diff --git a/lib/utimens.c b/lib/utimens.c
index 3643668c3a5..3b451193350 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -30,24 +30,11 @@
30#include <sys/stat.h> 30#include <sys/stat.h>
31#include <sys/time.h> 31#include <sys/time.h>
32#include <unistd.h> 32#include <unistd.h>
33#include <utime.h>
33 34
34#include "stat-time.h" 35#include "stat-time.h"
35#include "timespec.h" 36#include "timespec.h"
36 37
37#if HAVE_UTIME_H
38# include <utime.h>
39#endif
40
41/* Some systems (even some that do have <utime.h>) don't declare this
42 structure anywhere. */
43#ifndef HAVE_STRUCT_UTIMBUF
44struct utimbuf
45{
46 long actime;
47 long modtime;
48};
49#endif
50
51/* Avoid recursion with rpl_futimens or rpl_utimensat. */ 38/* Avoid recursion with rpl_futimens or rpl_utimensat. */
52#undef futimens 39#undef futimens
53#undef utimensat 40#undef utimensat