aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild-aux/config.guess8
-rw-r--r--lib/dup2.c44
-rw-r--r--lib/fcntl.c6
-rw-r--r--lib/fsync.c6
-rw-r--r--lib/getdtablesize.c11
-rw-r--r--lib/getopt.c3
-rw-r--r--lib/gettimeofday.c71
-rw-r--r--lib/gnulib.mk.in10
-rw-r--r--lib/mktime.c25
-rw-r--r--lib/stat-time.h4
-rw-r--r--lib/sys_stat.in.h178
-rw-r--r--lib/unistd.in.h30
-rw-r--r--lib/utimens.c6
-rw-r--r--m4/gettimeofday.m410
-rw-r--r--m4/gnulib-comp.m42
-rw-r--r--m4/largefile.m421
-rw-r--r--m4/sys_stat_h.m418
-rw-r--r--m4/sys_time_h.m43
-rw-r--r--m4/time_h.m44
-rw-r--r--m4/time_rz.m42
-rw-r--r--m4/unistd_h.m49
21 files changed, 343 insertions, 128 deletions
diff --git a/build-aux/config.guess b/build-aux/config.guess
index 69ed3e573bb..faa63aa9429 100755
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -2,7 +2,7 @@
2# Attempt to guess a canonical system name. 2# Attempt to guess a canonical system name.
3# Copyright 1992-2017 Free Software Foundation, Inc. 3# Copyright 1992-2017 Free Software Foundation, Inc.
4 4
5timestamp='2017-03-05' 5timestamp='2017-05-11'
6 6
7# This file is free software; you can redistribute it and/or modify it 7# This file is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by 8# under the terms of the GNU General Public License as published by
@@ -1335,16 +1335,16 @@ EOF
1335 *:QNX:*:4*) 1335 *:QNX:*:4*)
1336 echo i386-pc-qnx 1336 echo i386-pc-qnx
1337 exit ;; 1337 exit ;;
1338 NEO-?:NONSTOP_KERNEL:*:*) 1338 NEO-*:NONSTOP_KERNEL:*:*)
1339 echo neo-tandem-nsk${UNAME_RELEASE} 1339 echo neo-tandem-nsk${UNAME_RELEASE}
1340 exit ;; 1340 exit ;;
1341 NSE-*:NONSTOP_KERNEL:*:*) 1341 NSE-*:NONSTOP_KERNEL:*:*)
1342 echo nse-tandem-nsk${UNAME_RELEASE} 1342 echo nse-tandem-nsk${UNAME_RELEASE}
1343 exit ;; 1343 exit ;;
1344 NSR-?:NONSTOP_KERNEL:*:*) 1344 NSR-*:NONSTOP_KERNEL:*:*)
1345 echo nsr-tandem-nsk${UNAME_RELEASE} 1345 echo nsr-tandem-nsk${UNAME_RELEASE}
1346 exit ;; 1346 exit ;;
1347 NSX-?:NONSTOP_KERNEL:*:*) 1347 NSX-*:NONSTOP_KERNEL:*:*)
1348 echo nsx-tandem-nsk${UNAME_RELEASE} 1348 echo nsx-tandem-nsk${UNAME_RELEASE}
1349 exit ;; 1349 exit ;;
1350 *:NonStop-UX:*:*) 1350 *:NonStop-UX:*:*)
diff --git a/lib/dup2.c b/lib/dup2.c
index c0c7cadf4a8..002dc8c76cb 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -35,10 +35,39 @@
35# define WIN32_LEAN_AND_MEAN 35# define WIN32_LEAN_AND_MEAN
36# include <windows.h> 36# include <windows.h>
37 37
38# include "msvc-inval.h" 38# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
39# include "msvc-inval.h"
40# endif
39 41
40/* Get _get_osfhandle. */ 42/* Get _get_osfhandle. */
41# include "msvc-nothrow.h" 43# if GNULIB_MSVC_NOTHROW
44# include "msvc-nothrow.h"
45# else
46# include <io.h>
47# endif
48
49# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
50static int
51dup2_nothrow (int fd, int desired_fd)
52{
53 int result;
54
55 TRY_MSVC_INVAL
56 {
57 result = dup2 (fd, desired_fd);
58 }
59 CATCH_MSVC_INVAL
60 {
61 errno = EBADF;
62 result = -1;
63 }
64 DONE_MSVC_INVAL;
65
66 return result;
67}
68# else
69# define dup2_nothrow dup2
70# endif
42 71
43static int 72static int
44ms_windows_dup2 (int fd, int desired_fd) 73ms_windows_dup2 (int fd, int desired_fd)
@@ -66,16 +95,7 @@ ms_windows_dup2 (int fd, int desired_fd)
66 return -1; 95 return -1;
67 } 96 }
68 97
69 TRY_MSVC_INVAL 98 result = dup2_nothrow (fd, desired_fd);
70 {
71 result = dup2 (fd, desired_fd);
72 }
73 CATCH_MSVC_INVAL
74 {
75 errno = EBADF;
76 result = -1;
77 }
78 DONE_MSVC_INVAL;
79 99
80 if (result == 0) 100 if (result == 0)
81 result = desired_fd; 101 result = desired_fd;
diff --git a/lib/fcntl.c b/lib/fcntl.c
index afe15468ffa..d4dd144e05d 100644
--- a/lib/fcntl.c
+++ b/lib/fcntl.c
@@ -38,7 +38,11 @@
38# include <windows.h> 38# include <windows.h>
39 39
40/* Get _get_osfhandle. */ 40/* Get _get_osfhandle. */
41# include "msvc-nothrow.h" 41# if GNULIB_MSVC_NOTHROW
42# include "msvc-nothrow.h"
43# else
44# include <io.h>
45# endif
42 46
43/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */ 47/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
44# define OPEN_MAX_MAX 0x10000 48# define OPEN_MAX_MAX 0x10000
diff --git a/lib/fsync.c b/lib/fsync.c
index 46dd59b3d2c..5a4945ef2bf 100644
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -34,7 +34,11 @@
34# include <errno.h> 34# include <errno.h>
35 35
36/* Get _get_osfhandle. */ 36/* Get _get_osfhandle. */
37# include "msvc-nothrow.h" 37# if GNULIB_MSVC_NOTHROW
38# include "msvc-nothrow.h"
39# else
40# include <io.h>
41# endif
38 42
39int 43int
40fsync (int fd) 44fsync (int fd)
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index 7fabb51e2c6..c356cf4aa97 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -24,7 +24,9 @@
24 24
25# include <stdio.h> 25# include <stdio.h>
26 26
27# include "msvc-inval.h" 27# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
28# include "msvc-inval.h"
29# endif
28 30
29# if HAVE_MSVC_INVALID_PARAMETER_HANDLER 31# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
30static int 32static int
@@ -44,7 +46,8 @@ _setmaxstdio_nothrow (int newmax)
44 46
45 return result; 47 return result;
46} 48}
47# define _setmaxstdio _setmaxstdio_nothrow 49# else
50# define _setmaxstdio_nothrow _setmaxstdio
48# endif 51# endif
49 52
50/* Cache for the previous getdtablesize () result. Safe to cache because 53/* Cache for the previous getdtablesize () result. Safe to cache because
@@ -76,9 +79,9 @@ getdtablesize (void)
76 freed when we call _setmaxstdio with the original value. */ 79 freed when we call _setmaxstdio with the original value. */
77 int orig_max_stdio = _getmaxstdio (); 80 int orig_max_stdio = _getmaxstdio ();
78 unsigned int bound; 81 unsigned int bound;
79 for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2) 82 for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
80 ; 83 ;
81 _setmaxstdio (orig_max_stdio); 84 _setmaxstdio_nothrow (orig_max_stdio);
82 dtablesize = bound; 85 dtablesize = bound;
83 } 86 }
84 return dtablesize; 87 return dtablesize;
diff --git a/lib/getopt.c b/lib/getopt.c
index a7db39b68df..9a2867db277 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -45,7 +45,8 @@
45# define _(msgid) gettext (msgid) 45# define _(msgid) gettext (msgid)
46/* When used standalone, flockfile and funlockfile might not be 46/* When used standalone, flockfile and funlockfile might not be
47 available. */ 47 available. */
48# ifndef _POSIX_THREAD_SAFE_FUNCTIONS 48# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
49 || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
49# define flockfile(fp) /* nop */ 50# define flockfile(fp) /* nop */
50# define funlockfile(fp) /* nop */ 51# define funlockfile(fp) /* nop */
51# endif 52# endif
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index 1039f77d182..8ae7622af31 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -64,42 +64,20 @@ int
64gettimeofday (struct timeval *restrict tv, void *restrict tz) 64gettimeofday (struct timeval *restrict tv, void *restrict tz)
65{ 65{
66#undef gettimeofday 66#undef gettimeofday
67#if HAVE_GETTIMEOFDAY 67#ifdef WINDOWS_NATIVE
68# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
69 /* Save and restore the contents of the buffer used for localtime's
70 result around the call to gettimeofday. */
71 struct tm save = *localtime_buffer_addr;
72# endif
73
74# if defined timeval /* 'struct timeval' overridden by gnulib? */
75# undef timeval
76 struct timeval otv;
77 int result = gettimeofday (&otv, (struct timezone *) tz);
78 if (result == 0)
79 {
80 tv->tv_sec = otv.tv_sec;
81 tv->tv_usec = otv.tv_usec;
82 }
83# else
84 int result = gettimeofday (tv, (struct timezone *) tz);
85# endif
86
87# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
88 *localtime_buffer_addr = save;
89# endif
90
91 return result;
92
93#else
94
95# ifdef WINDOWS_NATIVE
96 68
97 /* On native Windows, there are two ways to get the current time: 69 /* On native Windows, there are two ways to get the current time:
98 GetSystemTimeAsFileTime 70 GetSystemTimeAsFileTime
99 <https://msdn.microsoft.com/en-us/library/ms724397.aspx> 71 <https://msdn.microsoft.com/en-us/library/ms724397.aspx>
100 or 72 or
101 GetSystemTimePreciseAsFileTime 73 GetSystemTimePreciseAsFileTime
102 <https://msdn.microsoft.com/en-us/library/hh706895.aspx>. */ 74 <https://msdn.microsoft.com/en-us/library/hh706895.aspx>.
75 GetSystemTimeAsFileTime produces values that jump by increments of
76 15.627 milliseconds (!) on average.
77 Whereas GetSystemTimePreciseAsFileTime values usually jump by 1 or 2
78 microseconds.
79 More discussion on this topic:
80 <http://www.windowstimestamp.com/description>. */
103 FILETIME current_time; 81 FILETIME current_time;
104 82
105 if (!initialized) 83 if (!initialized)
@@ -122,6 +100,36 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
122 tv->tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000; 100 tv->tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000;
123 tv->tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000; 101 tv->tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000;
124 102
103 return 0;
104
105#else
106
107# if HAVE_GETTIMEOFDAY
108# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
109 /* Save and restore the contents of the buffer used for localtime's
110 result around the call to gettimeofday. */
111 struct tm save = *localtime_buffer_addr;
112# endif
113
114# if defined timeval /* 'struct timeval' overridden by gnulib? */
115# undef timeval
116 struct timeval otv;
117 int result = gettimeofday (&otv, (struct timezone *) tz);
118 if (result == 0)
119 {
120 tv->tv_sec = otv.tv_sec;
121 tv->tv_usec = otv.tv_usec;
122 }
123# else
124 int result = gettimeofday (tv, (struct timezone *) tz);
125# endif
126
127# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
128 *localtime_buffer_addr = save;
129# endif
130
131 return result;
132
125# else 133# else
126 134
127# if !defined OK_TO_USE_1S_CLOCK 135# if !defined OK_TO_USE_1S_CLOCK
@@ -131,9 +139,8 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
131 tv->tv_sec = time (NULL); 139 tv->tv_sec = time (NULL);
132 tv->tv_usec = 0; 140 tv->tv_usec = 0;
133 141
134# endif
135
136 return 0; 142 return 0;
137 143
144# endif
138#endif 145#endif
139} 146}
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 51ae1891244..d4afafbecc9 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -225,6 +225,7 @@ GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
225GNULIB_OPEN = @GNULIB_OPEN@ 225GNULIB_OPEN = @GNULIB_OPEN@
226GNULIB_OPENAT = @GNULIB_OPENAT@ 226GNULIB_OPENAT = @GNULIB_OPENAT@
227GNULIB_OPENDIR = @GNULIB_OPENDIR@ 227GNULIB_OPENDIR = @GNULIB_OPENDIR@
228GNULIB_OVERRIDES_STRUCT_STAT = @GNULIB_OVERRIDES_STRUCT_STAT@
228GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@ 229GNULIB_OVERRIDES_WINT_T = @GNULIB_OVERRIDES_WINT_T@
229GNULIB_PCLOSE = @GNULIB_PCLOSE@ 230GNULIB_PCLOSE = @GNULIB_PCLOSE@
230GNULIB_PERROR = @GNULIB_PERROR@ 231GNULIB_PERROR = @GNULIB_PERROR@
@@ -306,6 +307,7 @@ GNULIB_TIMEGM = @GNULIB_TIMEGM@
306GNULIB_TIME_R = @GNULIB_TIME_R@ 307GNULIB_TIME_R = @GNULIB_TIME_R@
307GNULIB_TIME_RZ = @GNULIB_TIME_RZ@ 308GNULIB_TIME_RZ = @GNULIB_TIME_RZ@
308GNULIB_TMPFILE = @GNULIB_TMPFILE@ 309GNULIB_TMPFILE = @GNULIB_TMPFILE@
310GNULIB_TRUNCATE = @GNULIB_TRUNCATE@
309GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@ 311GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@
310GNULIB_TZSET = @GNULIB_TZSET@ 312GNULIB_TZSET = @GNULIB_TZSET@
311GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@ 313GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@
@@ -504,6 +506,7 @@ HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
504HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ 506HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
505HAVE_TIMEGM = @HAVE_TIMEGM@ 507HAVE_TIMEGM = @HAVE_TIMEGM@
506HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@ 508HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@
509HAVE_TRUNCATE = @HAVE_TRUNCATE@
507HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ 510HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
508HAVE_TZSET = @HAVE_TZSET@ 511HAVE_TZSET = @HAVE_TZSET@
509HAVE_UNISTD_H = @HAVE_UNISTD_H@ 512HAVE_UNISTD_H = @HAVE_UNISTD_H@
@@ -781,6 +784,7 @@ REPLACE_SYMLINK = @REPLACE_SYMLINK@
781REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@ 784REPLACE_SYMLINKAT = @REPLACE_SYMLINKAT@
782REPLACE_TIMEGM = @REPLACE_TIMEGM@ 785REPLACE_TIMEGM = @REPLACE_TIMEGM@
783REPLACE_TMPFILE = @REPLACE_TMPFILE@ 786REPLACE_TMPFILE = @REPLACE_TMPFILE@
787REPLACE_TRUNCATE = @REPLACE_TRUNCATE@
784REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@ 788REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@
785REPLACE_TZSET = @REPLACE_TZSET@ 789REPLACE_TZSET = @REPLACE_TZSET@
786REPLACE_UNLINK = @REPLACE_UNLINK@ 790REPLACE_UNLINK = @REPLACE_UNLINK@
@@ -834,6 +838,7 @@ WERROR_CFLAGS = @WERROR_CFLAGS@
834WIDGET_OBJ = @WIDGET_OBJ@ 838WIDGET_OBJ = @WIDGET_OBJ@
835WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@ 839WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@
836WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@ 840WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@
841WINDOWS_STAT_TIMESPEC = @WINDOWS_STAT_TIMESPEC@
837WINDOW_SYSTEM_OBJ = @WINDOW_SYSTEM_OBJ@ 842WINDOW_SYSTEM_OBJ = @WINDOW_SYSTEM_OBJ@
838WINDRES = @WINDRES@ 843WINDRES = @WINDRES@
839WINT_T_SUFFIX = @WINT_T_SUFFIX@ 844WINT_T_SUFFIX = @WINT_T_SUFFIX@
@@ -2586,6 +2591,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
2586 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2591 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2587 -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ 2592 -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
2588 -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ 2593 -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
2594 -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
2589 -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ 2595 -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
2590 -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \ 2596 -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
2591 -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ 2597 -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
@@ -2599,6 +2605,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
2599 -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \ 2605 -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
2600 -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \ 2606 -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
2601 -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \ 2607 -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
2608 -e 's/@''GNULIB_OVERRIDES_STRUCT_STAT''@/$(GNULIB_OVERRIDES_STRUCT_STAT)/g' \
2602 -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ 2609 -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
2603 -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ 2610 -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
2604 -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ 2611 -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
@@ -2893,6 +2900,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2893 -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ 2900 -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \
2894 -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ 2901 -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \
2895 -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ 2902 -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \
2903 -e 's/@''GNULIB_TRUNCATE''@/$(GNULIB_TRUNCATE)/g' \
2896 -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \ 2904 -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \
2897 -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \ 2905 -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \
2898 -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \ 2906 -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \
@@ -2930,6 +2938,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2930 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ 2938 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
2931 -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ 2939 -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
2932 -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ 2940 -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
2941 -e 's|@''HAVE_TRUNCATE''@|$(HAVE_TRUNCATE)|g' \
2933 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ 2942 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
2934 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ 2943 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
2935 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ 2944 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
@@ -2971,6 +2980,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2971 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ 2980 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
2972 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ 2981 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
2973 -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ 2982 -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
2983 -e 's|@''REPLACE_TRUNCATE''@|$(REPLACE_TRUNCATE)|g' \
2974 -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ 2984 -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
2975 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ 2985 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
2976 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ 2986 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
diff --git a/lib/mktime.c b/lib/mktime.c
index 06d5916e910..058ab65c03e 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -491,9 +491,28 @@ time_t
491mktime (struct tm *tp) 491mktime (struct tm *tp)
492{ 492{
493# if NEED_MKTIME_WINDOWS 493# if NEED_MKTIME_WINDOWS
494 /* If the environment variable TZ has been set by Cygwin, neutralize it. 494 /* Rectify the value of the environment variable TZ.
495 The Microsoft CRT interprets TZ differently than Cygwin and produces 495 There are four possible kinds of such values:
496 incorrect results if TZ has the syntax used by Cygwin. */ 496 - Traditional US time zone names, e.g. "PST8PDT". Syntax: see
497 <https://msdn.microsoft.com/en-us/library/90s5c885.aspx>
498 - Time zone names based on geography, that contain one or more
499 slashes, e.g. "Europe/Moscow".
500 - Time zone names based on geography, without slashes, e.g.
501 "Singapore".
502 - Time zone names that contain explicit DST rules. Syntax: see
503 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03>
504 The Microsoft CRT understands only the first kind. It produces incorrect
505 results if the value of TZ is of the other kinds.
506 But in a Cygwin environment, /etc/profile.d/tzset.sh sets TZ to a value
507 of the second kind for most geographies, or of the first kind in a few
508 other geographies. If it is of the second kind, neutralize it. For the
509 Microsoft CRT, an absent or empty TZ means the time zone that the user
510 has set in the Windows Control Panel.
511 If the value of TZ is of the third or fourth kind -- Cygwin programs
512 understand these syntaxes as well --, it does not matter whether we
513 neutralize it or not, since these values occur only when a Cygwin user
514 has set TZ explicitly; this case is 1. rare and 2. under the user's
515 responsibility. */
497 const char *tz = getenv ("TZ"); 516 const char *tz = getenv ("TZ");
498 if (tz != NULL && strchr (tz, '/') != NULL) 517 if (tz != NULL && strchr (tz, '/') != NULL)
499 _putenv ("TZ="); 518 _putenv ("TZ=");
diff --git a/lib/stat-time.h b/lib/stat-time.h
index 154d62a01f5..88dcc7f3e0d 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -43,8 +43,8 @@ extern "C" {
43 time respectively. 43 time respectively.
44 44
45 These macros are private to stat-time.h. */ 45 These macros are private to stat-time.h. */
46#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 46#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
47# ifdef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 47# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
48# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim) 48# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
49# else 49# else
50# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec) 50# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index d5ca343437f..1831740900b 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -1,4 +1,4 @@
1/* Provide a more complete sys/stat header file. 1/* Provide a more complete sys/stat.h header file.
2 Copyright (C) 2005-2017 Free Software Foundation, Inc. 2 Copyright (C) 2005-2017 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
@@ -72,6 +72,75 @@
72# define stat _stati64 72# define stat _stati64
73#endif 73#endif
74 74
75/* Optionally, override 'struct stat' on native Windows. */
76#if @GNULIB_OVERRIDES_STRUCT_STAT@
77
78# undef stat
79# if @GNULIB_STAT@
80# define stat rpl_stat
81# else
82 /* Provoke a clear link error if stat() is used as a function and
83 module 'stat' is not in use. */
84# define stat stat_used_without_requesting_gnulib_module_stat
85# endif
86
87# if !GNULIB_defined_struct_stat
88struct stat
89{
90 dev_t st_dev;
91 ino_t st_ino;
92 mode_t st_mode;
93 nlink_t st_nlink;
94# if 0
95 uid_t st_uid;
96# else /* uid_t is not defined by default on native Windows. */
97 short st_uid;
98# endif
99# if 0
100 gid_t st_gid;
101# else /* gid_t is not defined by default on native Windows. */
102 short st_gid;
103# endif
104 dev_t st_rdev;
105 off_t st_size;
106# if 0
107 blksize_t st_blksize;
108 blkcnt_t st_blocks;
109# endif
110
111# if @WINDOWS_STAT_TIMESPEC@
112 struct timespec st_atim;
113 struct timespec st_mtim;
114 struct timespec st_ctim;
115# else
116 time_t st_atime;
117 time_t st_mtime;
118 time_t st_ctime;
119# endif
120};
121# if @WINDOWS_STAT_TIMESPEC@
122# define st_atime st_atim.tv_sec
123# define st_mtime st_mtim.tv_sec
124# define st_ctime st_ctim.tv_sec
125 /* Indicator, for gnulib internal purposes. */
126# define _GL_WINDOWS_STAT_TIMESPEC 1
127# endif
128# define GNULIB_defined_struct_stat 1
129# endif
130
131/* Other possible values of st_mode. */
132# if 0
133# define _S_IFBLK 0x6000
134# endif
135# if 0
136# define _S_IFLNK 0xA000
137# endif
138# if 0
139# define _S_IFSOCK 0xC000
140# endif
141
142#endif
143
75#ifndef S_IFIFO 144#ifndef S_IFIFO
76# ifdef _S_IFIFO 145# ifdef _S_IFIFO
77# define S_IFIFO _S_IFIFO 146# define S_IFIFO _S_IFIFO
@@ -345,6 +414,9 @@ _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
345_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); 414_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
346# endif 415# endif
347_GL_CXXALIASWARN (fstat); 416_GL_CXXALIASWARN (fstat);
417#elif @GNULIB_OVERRIDES_STRUCT_STAT@
418# undef fstat
419# define fstat fstat_used_without_requesting_gnulib_module_fstat
348#elif @WINDOWS_64_BIT_ST_SIZE@ 420#elif @WINDOWS_64_BIT_ST_SIZE@
349/* Above, we define stat to _stati64. */ 421/* Above, we define stat to _stati64. */
350# define fstat _fstati64 422# define fstat _fstati64
@@ -378,6 +450,9 @@ _GL_CXXALIAS_SYS (fstatat, int,
378 (int fd, char const *name, struct stat *st, int flags)); 450 (int fd, char const *name, struct stat *st, int flags));
379# endif 451# endif
380_GL_CXXALIASWARN (fstatat); 452_GL_CXXALIASWARN (fstatat);
453#elif @GNULIB_OVERRIDES_STRUCT_STAT@
454# undef fstatat
455# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
381#elif defined GNULIB_POSIXCHECK 456#elif defined GNULIB_POSIXCHECK
382# undef fstatat 457# undef fstatat
383# if HAVE_RAW_DECL_FSTATAT 458# if HAVE_RAW_DECL_FSTATAT
@@ -476,6 +551,9 @@ _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
476# if @HAVE_LSTAT@ 551# if @HAVE_LSTAT@
477_GL_CXXALIASWARN (lstat); 552_GL_CXXALIASWARN (lstat);
478# endif 553# endif
554#elif @GNULIB_OVERRIDES_STRUCT_STAT@
555# undef lstat
556# define lstat lstat_used_without_requesting_gnulib_module_lstat
479#elif defined GNULIB_POSIXCHECK 557#elif defined GNULIB_POSIXCHECK
480# undef lstat 558# undef lstat
481# if HAVE_RAW_DECL_LSTAT 559# if HAVE_RAW_DECL_LSTAT
@@ -625,63 +703,69 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
625 703
626#if @GNULIB_STAT@ 704#if @GNULIB_STAT@
627# if @REPLACE_STAT@ 705# if @REPLACE_STAT@
628/* We can't use the object-like #define stat rpl_stat, because of 706# if !@GNULIB_OVERRIDES_STRUCT_STAT@
629 struct stat. This means that rpl_stat will not be used if the user 707 /* We can't use the object-like #define stat rpl_stat, because of
630 does (stat)(a,b). Oh well. */ 708 struct stat. This means that rpl_stat will not be used if the user
631# if defined _AIX && defined stat && defined _LARGE_FILES 709 does (stat)(a,b). Oh well. */
632 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, 710# if defined _AIX && defined stat && defined _LARGE_FILES
633 so we have to replace stat64() instead of stat(). */ 711 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
634# undef stat64 712 so we have to replace stat64() instead of stat(). */
635# define stat64(name, st) rpl_stat (name, st) 713# undef stat64
636# elif @WINDOWS_64_BIT_ST_SIZE@ 714# define stat64(name, st) rpl_stat (name, st)
637 /* Above, we define stat to _stati64. */ 715# elif @WINDOWS_64_BIT_ST_SIZE@
638# if defined __MINGW32__ && defined _stati64 716 /* Above, we define stat to _stati64. */
639# ifndef _USE_32BIT_TIME_T 717# if defined __MINGW32__ && defined _stati64
640 /* The system headers define _stati64 to _stat64. */ 718# ifndef _USE_32BIT_TIME_T
641# undef _stat64 719 /* The system headers define _stati64 to _stat64. */
642# define _stat64(name, st) rpl_stat (name, st) 720# undef _stat64
721# define _stat64(name, st) rpl_stat (name, st)
722# endif
723# elif defined _MSC_VER && defined _stati64
724# ifdef _USE_32BIT_TIME_T
725 /* The system headers define _stati64 to _stat32i64. */
726# undef _stat32i64
727# define _stat32i64(name, st) rpl_stat (name, st)
728# else
729 /* The system headers define _stati64 to _stat64. */
730# undef _stat64
731# define _stat64(name, st) rpl_stat (name, st)
732# endif
733# else
734# undef _stati64
735# define _stati64(name, st) rpl_stat (name, st)
643# endif 736# endif
644# elif defined _MSC_VER && defined _stati64 737# elif defined __MINGW32__ && defined stat
645# ifdef _USE_32BIT_TIME_T 738# ifdef _USE_32BIT_TIME_T
646 /* The system headers define _stati64 to _stat32i64. */ 739 /* The system headers define stat to _stat32i64. */
647# undef _stat32i64 740# undef _stat32i64
648# define _stat32i64(name, st) rpl_stat (name, st) 741# define _stat32i64(name, st) rpl_stat (name, st)
649# else 742# else
650 /* The system headers define _stati64 to _stat64. */ 743 /* The system headers define stat to _stat64. */
651# undef _stat64 744# undef _stat64
652# define _stat64(name, st) rpl_stat (name, st) 745# define _stat64(name, st) rpl_stat (name, st)
653# endif 746# endif
654# else 747# elif defined _MSC_VER && defined stat
655# undef _stati64 748# ifdef _USE_32BIT_TIME_T
656# define _stati64(name, st) rpl_stat (name, st) 749 /* The system headers define stat to _stat32. */
657# endif 750# undef _stat32
658# elif defined __MINGW32__ && defined stat 751# define _stat32(name, st) rpl_stat (name, st)
659# ifdef _USE_32BIT_TIME_T 752# else
660 /* The system headers define stat to _stat32i64. */ 753 /* The system headers define stat to _stat64i32. */
661# undef _stat32i64 754# undef _stat64i32
662# define _stat32i64(name, st) rpl_stat (name, st) 755# define _stat64i32(name, st) rpl_stat (name, st)
663# else 756# endif
664 /* The system headers define stat to _stat64. */ 757# else /* !(_AIX || __MINGW32__ || _MSC_VER) */
665# undef _stat64 758# undef stat
666# define _stat64(name, st) rpl_stat (name, st) 759# define stat(name, st) rpl_stat (name, st)
667# endif 760# endif /* !_LARGE_FILES */
668# elif defined _MSC_VER && defined stat 761# endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
669# ifdef _USE_32BIT_TIME_T
670 /* The system headers define stat to _stat32. */
671# undef _stat32
672# define _stat32(name, st) rpl_stat (name, st)
673# else
674 /* The system headers define stat to _stat64i32. */
675# undef _stat64i32
676# define _stat64i32(name, st) rpl_stat (name, st)
677# endif
678# else /* !(_AIX ||__MINGW32__ || _MSC_VER) */
679# undef stat
680# define stat(name, st) rpl_stat (name, st)
681# endif /* !_LARGE_FILES */
682_GL_EXTERN_C int stat (const char *name, struct stat *buf) 762_GL_EXTERN_C int stat (const char *name, struct stat *buf)
683 _GL_ARG_NONNULL ((1, 2)); 763 _GL_ARG_NONNULL ((1, 2));
684# endif 764# endif
765#elif @GNULIB_OVERRIDES_STRUCT_STAT@
766/* see above:
767 #define stat stat_used_without_requesting_gnulib_module_stat
768 */
685#elif defined GNULIB_POSIXCHECK 769#elif defined GNULIB_POSIXCHECK
686# undef stat 770# undef stat
687# if HAVE_RAW_DECL_STAT 771# if HAVE_RAW_DECL_STAT
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index cb9321e502d..f366caffa55 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1457,6 +1457,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1457#endif 1457#endif
1458 1458
1459 1459
1460#if @GNULIB_TRUNCATE@
1461/* Change the size of the file designated by FILENAME to become equal to LENGTH.
1462 Return 0 if successful, otherwise -1 and errno set.
1463 See the POSIX:2008 specification
1464 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
1465# if @REPLACE_TRUNCATE@
1466# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1467# undef truncate
1468# define truncate rpl_truncate
1469# endif
1470_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
1471 _GL_ARG_NONNULL ((1)));
1472_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
1473# else
1474# if !@HAVE_TRUNCATE@
1475_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
1476 _GL_ARG_NONNULL ((1)));
1477# endif
1478_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
1479# endif
1480_GL_CXXALIASWARN (truncate);
1481#elif defined GNULIB_POSIXCHECK
1482# undef truncate
1483# if HAVE_RAW_DECL_TRUNCATE
1484_GL_WARN_ON_USE (truncate, "truncate is unportable - "
1485 "use gnulib module truncate for portability");
1486# endif
1487#endif
1488
1489
1460#if @GNULIB_TTYNAME_R@ 1490#if @GNULIB_TTYNAME_R@
1461/* Store at most BUFLEN characters of the pathname of the terminal FD is 1491/* Store at most BUFLEN characters of the pathname of the terminal FD is
1462 open on in BUF. Return 0 on success, otherwise an error number. */ 1492 open on in BUF. Return 0 on success, otherwise an error number. */
diff --git a/lib/utimens.c b/lib/utimens.c
index b4bfa8e3222..ff4eab073c1 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -44,7 +44,11 @@
44# define USE_SETFILETIME 44# define USE_SETFILETIME
45# define WIN32_LEAN_AND_MEAN 45# define WIN32_LEAN_AND_MEAN
46# include <windows.h> 46# include <windows.h>
47# include "msvc-nothrow.h" 47# if GNULIB_MSVC_NOTHROW
48# include "msvc-nothrow.h"
49# else
50# include <io.h>
51# endif
48#endif 52#endif
49 53
50/* Avoid recursion with rpl_futimens or rpl_utimensat. */ 54/* Avoid recursion with rpl_futimens or rpl_utimensat. */
diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4
index 34adc64778f..8ee206eea24 100644
--- a/m4/gettimeofday.m4
+++ b/m4/gettimeofday.m4
@@ -1,4 +1,4 @@
1# serial 22 1# serial 23
2 2
3# Copyright (C) 2001-2003, 2005, 2007, 2009-2017 Free Software Foundation, Inc. 3# Copyright (C) 2001-2003, 2005, 2007, 2009-2017 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4# This file is free software; the Free Software Foundation
@@ -9,9 +9,10 @@ dnl From Jim Meyering.
9 9
10AC_DEFUN([gl_FUNC_GETTIMEOFDAY], 10AC_DEFUN([gl_FUNC_GETTIMEOFDAY],
11[ 11[
12 AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
12 AC_REQUIRE([AC_C_RESTRICT]) 13 AC_REQUIRE([AC_C_RESTRICT])
14 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([gl_HEADER_SYS_TIME_H]) 15 AC_REQUIRE([gl_HEADER_SYS_TIME_H])
14 AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
15 AC_CHECK_FUNCS_ONCE([gettimeofday]) 16 AC_CHECK_FUNCS_ONCE([gettimeofday])
16 17
17 gl_gettimeofday_timezone=void 18 gl_gettimeofday_timezone=void
@@ -54,6 +55,11 @@ int gettimeofday (struct timeval *restrict, struct timezone *restrict);
54 if test $REPLACE_STRUCT_TIMEVAL = 1; then 55 if test $REPLACE_STRUCT_TIMEVAL = 1; then
55 REPLACE_GETTIMEOFDAY=1 56 REPLACE_GETTIMEOFDAY=1
56 fi 57 fi
58 dnl On mingw, the original gettimeofday has only a precision of 15.6
59 dnl milliseconds. So override it.
60 case "$host_os" in
61 mingw*) REPLACE_GETTIMEOFDAY=1 ;;
62 esac
57 fi 63 fi
58 AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone], 64 AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone],
59 [Define this to 'void' or 'struct timezone' to match the system's 65 [Define this to 'void' or 'struct timezone' to match the system's
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 74b197c8633..8295e483582 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -391,7 +391,7 @@ AC_DEFUN([gl_INIT],
391 fi 391 fi
392 gl_TIME_MODULE_INDICATOR([time_r]) 392 gl_TIME_MODULE_INDICATOR([time_r])
393 gl_TIME_RZ 393 gl_TIME_RZ
394 if test "$HAVE_TIMEZONE_T" = 0; then 394 if test $HAVE_TIMEZONE_T = 0; then
395 AC_LIBOBJ([time_rz]) 395 AC_LIBOBJ([time_rz])
396 fi 396 fi
397 gl_TIME_MODULE_INDICATOR([time_rz]) 397 gl_TIME_MODULE_INDICATOR([time_rz])
diff --git a/m4/largefile.m4 b/m4/largefile.m4
index 790f7c0ad39..edc1a9b41ba 100644
--- a/m4/largefile.m4
+++ b/m4/largefile.m4
@@ -126,9 +126,24 @@ AC_DEFUN([gl_LARGEFILE],
126 else 126 else
127 WINDOWS_64_BIT_OFF_T=0 127 WINDOWS_64_BIT_OFF_T=0
128 fi 128 fi
129 dnl But all native Windows platforms (including mingw64) have a 32-bit 129 dnl Some mingw versions define, if _FILE_OFFSET_BITS=64, 'struct stat'
130 dnl st_size member in 'struct stat'. 130 dnl to 'struct _stat32i64' or 'struct _stat64' (depending on
131 WINDOWS_64_BIT_ST_SIZE=1 131 dnl _USE_32BIT_TIME_T), which has a 32-bit st_size member.
132 AC_CACHE_CHECK([for 64-bit st_size], [gl_cv_member_st_size_64],
133 [AC_COMPILE_IFELSE(
134 [AC_LANG_PROGRAM(
135 [[#include <sys/types.h>
136 struct stat buf;
137 int verify_st_size_size[sizeof (buf.st_size) >= 8 ? 1 : -1];
138 ]],
139 [[]])],
140 [gl_cv_member_st_size_64=yes], [gl_cv_member_st_size_64=no])
141 ])
142 if test $gl_cv_member_st_size_64 = no; then
143 WINDOWS_64_BIT_ST_SIZE=1
144 else
145 WINDOWS_64_BIT_ST_SIZE=0
146 fi
132 ;; 147 ;;
133 *) 148 *)
134 dnl Nothing to do on gnulib's side. 149 dnl Nothing to do on gnulib's side.
diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4
index 1e34ac40da1..89342789828 100644
--- a/m4/sys_stat_h.m4
+++ b/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
1# sys_stat_h.m4 serial 28 -*- Autoconf -*- 1# sys_stat_h.m4 serial 31 -*- Autoconf -*-
2dnl Copyright (C) 2006-2017 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -19,18 +19,21 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H],
19 dnl Ensure the type mode_t gets defined. 19 dnl Ensure the type mode_t gets defined.
20 AC_REQUIRE([AC_TYPE_MODE_T]) 20 AC_REQUIRE([AC_TYPE_MODE_T])
21 21
22 dnl Whether to override 'struct stat'. 22 dnl Whether to enable precise timestamps in 'struct stat'.
23 m4_ifdef([gl_WINDOWS_STAT_TIMESPEC], [
24 AC_REQUIRE([gl_WINDOWS_STAT_TIMESPEC])
25 ], [
26 WINDOWS_STAT_TIMESPEC=0
27 ])
28 AC_SUBST([WINDOWS_STAT_TIMESPEC])
29
30 dnl Whether to ensure that struct stat.st_size is 64-bit wide.
23 m4_ifdef([gl_LARGEFILE], [ 31 m4_ifdef([gl_LARGEFILE], [
24 AC_REQUIRE([gl_LARGEFILE]) 32 AC_REQUIRE([gl_LARGEFILE])
25 ], [ 33 ], [
26 WINDOWS_64_BIT_ST_SIZE=0 34 WINDOWS_64_BIT_ST_SIZE=0
27 ]) 35 ])
28 AC_SUBST([WINDOWS_64_BIT_ST_SIZE]) 36 AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
29 if test $WINDOWS_64_BIT_ST_SIZE = 1; then
30 AC_DEFINE([_GL_WINDOWS_64_BIT_ST_SIZE], [1],
31 [Define to 1 if Gnulib overrides 'struct stat' on Windows so that
32 struct stat.st_size becomes 64-bit.])
33 fi
34 37
35 dnl Define types that are supposed to be defined in <sys/types.h> or 38 dnl Define types that are supposed to be defined in <sys/types.h> or
36 dnl <sys/stat.h>. 39 dnl <sys/stat.h>.
@@ -72,6 +75,7 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
72 GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT]) 75 GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT])
73 GNULIB_STAT=0; AC_SUBST([GNULIB_STAT]) 76 GNULIB_STAT=0; AC_SUBST([GNULIB_STAT])
74 GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT]) 77 GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT])
78 GNULIB_OVERRIDES_STRUCT_STAT=0; AC_SUBST([GNULIB_OVERRIDES_STRUCT_STAT])
75 dnl Assume proper GNU behavior unless another module says otherwise. 79 dnl Assume proper GNU behavior unless another module says otherwise.
76 HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) 80 HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
77 HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) 81 HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4
index e622dbe9a24..1c8c3cfcc32 100644
--- a/m4/sys_time_h.m4
+++ b/m4/sys_time_h.m4
@@ -1,5 +1,5 @@
1# Configure a replacement for <sys/time.h>. 1# Configure a replacement for <sys/time.h>.
2# serial 8 2# serial 9
3 3
4# Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc. 4# Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
@@ -105,7 +105,6 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS],
105 HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) 105 HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY])
106 HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) 106 HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL])
107 HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) 107 HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H])
108 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
109 REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) 108 REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY])
110 REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL]) 109 REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL])
111]) 110])
diff --git a/m4/time_h.m4 b/m4/time_h.m4
index f52b60192e8..28e22092e14 100644
--- a/m4/time_h.m4
+++ b/m4/time_h.m4
@@ -2,7 +2,7 @@
2 2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2017 Free Software Foundation, Inc. 3# Copyright (C) 2000-2001, 2003-2007, 2009-2017 Free Software Foundation, Inc.
4 4
5# serial 10 5# serial 11
6 6
7# This file is free software; the Free Software Foundation 7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it, 8# gives unlimited permission to copy and/or distribute it,
@@ -120,6 +120,8 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
120 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) 120 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
121 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 121 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
122 HAVE_TZSET=1; AC_SUBST([HAVE_TZSET]) 122 HAVE_TZSET=1; AC_SUBST([HAVE_TZSET])
123 dnl Even GNU libc does not have timezone_t yet.
124 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
123 dnl If another module says to replace or to not replace, do that. 125 dnl If another module says to replace or to not replace, do that.
124 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 126 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
125 dnl this lets maintainers check for portability. 127 dnl this lets maintainers check for portability.
diff --git a/m4/time_rz.m4 b/m4/time_rz.m4
index 079e933b4e6..3991118b61c 100644
--- a/m4/time_rz.m4
+++ b/m4/time_rz.m4
@@ -10,7 +10,7 @@ dnl Written by Paul Eggert.
10AC_DEFUN([gl_TIME_RZ], 10AC_DEFUN([gl_TIME_RZ],
11[ 11[
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_TIME_H_DEFAULTS])
14 AC_REQUIRE([AC_STRUCT_TIMEZONE]) 14 AC_REQUIRE([AC_STRUCT_TIMEZONE])
15 15
16 AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]]) 16 AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 25aef19ec9d..cc44677d9eb 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
1# unistd_h.m4 serial 69 1# unistd_h.m4 serial 70
2dnl Copyright (C) 2006-2017 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -46,8 +46,8 @@ AC_DEFUN([gl_UNISTD_H],
46 gethostname getlogin getlogin_r getpagesize 46 gethostname getlogin getlogin_r getpagesize
47 getusershell setusershell endusershell 47 getusershell setusershell endusershell
48 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite 48 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
49 readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r 49 readlink readlinkat rmdir sethostname sleep symlink symlinkat
50 unlink unlinkat usleep]) 50 truncate ttyname_r unlink unlinkat usleep])
51]) 51])
52 52
53AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], 53AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
@@ -102,6 +102,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
102 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) 102 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
103 GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK]) 103 GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
104 GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT]) 104 GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
105 GNULIB_TRUNCATE=0; AC_SUBST([GNULIB_TRUNCATE])
105 GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) 106 GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R])
106 GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING]) 107 GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
107 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE]) 108 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
@@ -139,6 +140,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
139 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) 140 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
140 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) 141 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
141 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) 142 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
143 HAVE_TRUNCATE=1; AC_SUBST([HAVE_TRUNCATE])
142 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) 144 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
143 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) 145 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
144 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) 146 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
@@ -179,6 +181,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
179 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) 181 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
180 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) 182 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
181 REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT]) 183 REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT])
184 REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE])
182 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) 185 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R])
183 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) 186 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
184 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) 187 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])