aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/c++defs.h10
-rw-r--r--lib/canonicalize-lgpl.c4
-rw-r--r--lib/cdefs.h9
-rw-r--r--lib/dup2.c4
-rw-r--r--lib/fcntl.in.h18
-rw-r--r--lib/getopt-cdefs.in.h2
-rw-r--r--lib/gnulib.mk.in4
-rw-r--r--lib/intprops.h2
-rw-r--r--lib/md5.h2
-rw-r--r--lib/mktime.c2
-rw-r--r--lib/nstrftime.c22
-rw-r--r--lib/open.c4
-rw-r--r--lib/regcomp.c2
-rw-r--r--lib/regex_internal.h2
-rw-r--r--lib/stdio.in.h46
-rw-r--r--lib/stdlib.in.h29
-rw-r--r--lib/strftime.h7
-rw-r--r--lib/string.in.h15
-rw-r--r--lib/sys_random.in.h4
-rw-r--r--lib/sys_select.in.h6
-rw-r--r--lib/sys_stat.in.h14
-rw-r--r--lib/sys_time.in.h2
-rw-r--r--lib/time.in.h12
-rw-r--r--lib/time_rz.c51
-rw-r--r--lib/unistd.in.h159
-rw-r--r--lib/verify.h41
26 files changed, 391 insertions, 82 deletions
diff --git a/lib/c++defs.h b/lib/c++defs.h
index 90e6fd62e6d..6a9bf295eb5 100644
--- a/lib/c++defs.h
+++ b/lib/c++defs.h
@@ -146,6 +146,16 @@
146 _GL_EXTERN_C int _gl_cxxalias_dummy 146 _GL_EXTERN_C int _gl_cxxalias_dummy
147#endif 147#endif
148 148
149/* _GL_CXXALIAS_MDA (func, rettype, parameters);
150 is to be used when func is a Microsoft deprecated alias, on native Windows.
151 It declares a C++ alias called GNULIB_NAMESPACE::func
152 that redirects to _func, if GNULIB_NAMESPACE is defined.
153 Example:
154 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
155 */
156#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
157 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
158
149/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 159/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
150 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 160 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
151 except that the C function rpl_func may have a slightly different 161 except that the C function rpl_func may have a slightly different
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 9f990988393..0b89d2a1842 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -52,7 +52,9 @@
52# include "pathmax.h" 52# include "pathmax.h"
53# include "malloca.h" 53# include "malloca.h"
54# include "filename.h" 54# include "filename.h"
55# if HAVE_GETCWD 55# if defined _WIN32 && !defined __CYGWIN__
56# define __getcwd _getcwd
57# elif HAVE_GETCWD
56# if IN_RELOCWRAPPER 58# if IN_RELOCWRAPPER
57 /* When building the relocatable program wrapper, use the system's getcwd 59 /* When building the relocatable program wrapper, use the system's getcwd
58 function, not the gnulib override, otherwise we would get a link error. 60 function, not the gnulib override, otherwise we would get a link error.
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 4f89f4e4bf0..b1870fd0a93 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -85,7 +85,7 @@
85# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct 85# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
86# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct 86# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
87# else 87# else
88# if defined __cplusplus && __GNUC_PREREQ (2,8) 88# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
89# define __THROW throw () 89# define __THROW throw ()
90# define __THROWNL throw () 90# define __THROWNL throw ()
91# define __NTH(fct) __LEAF_ATTR fct throw () 91# define __NTH(fct) __LEAF_ATTR fct throw ()
@@ -148,7 +148,7 @@
148# define __warnattr(msg) __attribute__((__warning__ (msg))) 148# define __warnattr(msg) __attribute__((__warning__ (msg)))
149# define __errordecl(name, msg) \ 149# define __errordecl(name, msg) \
150 extern void name (void) __attribute__((__error__ (msg))) 150 extern void name (void) __attribute__((__error__ (msg)))
151#elif __glibc_clang_has_attribute (__diagnose_if__) 151#elif __glibc_clang_has_attribute (__diagnose_if__) && 0 /* fails on Fedora 31 with Clang 9. */
152# define __warndecl(name, msg) \ 152# define __warndecl(name, msg) \
153 extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning"))) 153 extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning")))
154# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning"))) 154# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
@@ -194,7 +194,7 @@
194 Example: 194 Example:
195 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ 195 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
196 196
197#if defined __GNUC__ && __GNUC__ >= 2 197#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
198 198
199# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) 199# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
200# ifdef __cplusplus 200# ifdef __cplusplus
@@ -465,7 +465,8 @@
465 465
466#if (!defined _Static_assert && !defined __cplusplus \ 466#if (!defined _Static_assert && !defined __cplusplus \
467 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ 467 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
468 && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__)) 468 && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
469 || defined __STRICT_ANSI__))
469# define _Static_assert(expr, diagnostic) \ 470# define _Static_assert(expr, diagnostic) \
470 extern int (*__Static_assert_function (void)) \ 471 extern int (*__Static_assert_function (void)) \
471 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] 472 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
diff --git a/lib/dup2.c b/lib/dup2.c
index 9bc3951f3d2..323e19b25ec 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -52,7 +52,7 @@ dup2_nothrow (int fd, int desired_fd)
52 52
53 TRY_MSVC_INVAL 53 TRY_MSVC_INVAL
54 { 54 {
55 result = dup2 (fd, desired_fd); 55 result = _dup2 (fd, desired_fd);
56 } 56 }
57 CATCH_MSVC_INVAL 57 CATCH_MSVC_INVAL
58 { 58 {
@@ -64,7 +64,7 @@ dup2_nothrow (int fd, int desired_fd)
64 return result; 64 return result;
65} 65}
66# else 66# else
67# define dup2_nothrow dup2 67# define dup2_nothrow _dup2
68# endif 68# endif
69 69
70static int 70static int
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 0a21c957baf..6f16bc66921 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -97,6 +97,12 @@
97_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) 97_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
98 _GL_ARG_NONNULL ((1))); 98 _GL_ARG_NONNULL ((1)));
99_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); 99_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
100# elif defined _WIN32 && !defined __CYGWIN__
101# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
102# undef creat
103# define creat _creat
104# endif
105_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode));
100# else 106# else
101_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); 107_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
102# endif 108# endif
@@ -106,6 +112,9 @@ _GL_CXXALIASWARN (creat);
106/* Assume creat is always declared. */ 112/* Assume creat is always declared. */
107_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " 113_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
108 "use gnulib module creat for portability"); 114 "use gnulib module creat for portability");
115#elif defined _WIN32 && !defined __CYGWIN__
116# undef creat
117# define creat _creat
109#endif 118#endif
110 119
111#if @GNULIB_FCNTL@ 120#if @GNULIB_FCNTL@
@@ -146,6 +155,12 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
146_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 155_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
147 _GL_ARG_NONNULL ((1))); 156 _GL_ARG_NONNULL ((1)));
148_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 157_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
158# elif defined _WIN32 && !defined __CYGWIN__
159# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
160# undef open
161# define open _open
162# endif
163_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
149# else 164# else
150_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 165_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
151# endif 166# endif
@@ -159,6 +174,9 @@ _GL_CXXALIASWARN (open);
159/* Assume open is always declared. */ 174/* Assume open is always declared. */
160_GL_WARN_ON_USE (open, "open is not always POSIX compliant - " 175_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
161 "use gnulib module open for portability"); 176 "use gnulib module open for portability");
177#elif defined _WIN32 && !defined __CYGWIN__
178# undef open
179# define open _open
162#endif 180#endif
163 181
164#if @GNULIB_OPENAT@ 182#if @GNULIB_OPENAT@
diff --git a/lib/getopt-cdefs.in.h b/lib/getopt-cdefs.in.h
index c510ab163c3..674838c666a 100644
--- a/lib/getopt-cdefs.in.h
+++ b/lib/getopt-cdefs.in.h
@@ -57,7 +57,7 @@
57#endif 57#endif
58 58
59#ifndef __THROW 59#ifndef __THROW
60# if defined __cplusplus && __GNUC_PREREQ (2,8) 60# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
61# define __THROW throw () 61# define __THROW throw ()
62# else 62# else
63# define __THROW 63# define __THROW
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 92d0621c61a..7b4fc74219f 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -682,7 +682,6 @@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
682HAVE_TIMEGM = @HAVE_TIMEGM@ 682HAVE_TIMEGM = @HAVE_TIMEGM@
683HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@ 683HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@
684HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ 684HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
685HAVE_TZSET = @HAVE_TZSET@
686HAVE_UNISTD_H = @HAVE_UNISTD_H@ 685HAVE_UNISTD_H = @HAVE_UNISTD_H@
687HAVE_UNLINKAT = @HAVE_UNLINKAT@ 686HAVE_UNLINKAT = @HAVE_UNLINKAT@
688HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ 687HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
@@ -1159,7 +1158,7 @@ ifeq (,$(OMIT_GNULIB_MODULE_absolute-header))
1159# Use this preprocessor expression to decide whether #include_next works. 1158# Use this preprocessor expression to decide whether #include_next works.
1160# Do not rely on a 'configure'-time test for this, since the expression 1159# Do not rely on a 'configure'-time test for this, since the expression
1161# might appear in an installed header, which is used by some other compiler. 1160# might appear in an installed header, which is used by some other compiler.
1162HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER) 1161HAVE_INCLUDE_NEXT = (__GNUC__ || __clang__ || 60000000 <= __DECC_VER)
1163 1162
1164endif 1163endif
1165## end gnulib module absolute-header 1164## end gnulib module absolute-header
@@ -3185,7 +3184,6 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
3185 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ 3184 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
3186 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ 3185 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
3187 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ 3186 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
3188 -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \
3189 -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \ 3187 -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
3190 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ 3188 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
3191 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ 3189 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
diff --git a/lib/intprops.h b/lib/intprops.h
index 220f532e499..f2f70b3e733 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -396,7 +396,7 @@
396 For now, assume all versions of GCC-like compilers generate bogus 396 For now, assume all versions of GCC-like compilers generate bogus
397 warnings for _Generic. This matters only for compilers that 397 warnings for _Generic. This matters only for compilers that
398 lack relevant builtins. */ 398 lack relevant builtins. */
399#if __GNUC__ 399#if __GNUC__ || defined __clang__
400# define _GL__GENERIC_BOGUS 1 400# define _GL__GENERIC_BOGUS 1
401#else 401#else
402# define _GL__GENERIC_BOGUS 0 402# define _GL__GENERIC_BOGUS 0
diff --git a/lib/md5.h b/lib/md5.h
index 3c6048242b0..c728ba1b6f2 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -40,7 +40,7 @@
40#endif 40#endif
41 41
42#ifndef __THROW 42#ifndef __THROW
43# if defined __cplusplus && __GNUC_PREREQ (2,8) 43# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
44# define __THROW throw () 44# define __THROW throw ()
45# else 45# else
46# define __THROW 46# define __THROW
diff --git a/lib/mktime.c b/lib/mktime.c
index 92c00b2b14b..5b4c144ecad 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -94,7 +94,7 @@ my_tzset (void)
94 const char *tz = getenv ("TZ"); 94 const char *tz = getenv ("TZ");
95 if (tz != NULL && strchr (tz, '/') != NULL) 95 if (tz != NULL && strchr (tz, '/') != NULL)
96 _putenv ("TZ="); 96 _putenv ("TZ=");
97# elif HAVE_TZSET 97# else
98 tzset (); 98 tzset ();
99# endif 99# endif
100} 100}
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 2816cf4d58b..7d5a97f7635 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -21,7 +21,6 @@
21# define HAVE_TM_GMTOFF 1 21# define HAVE_TM_GMTOFF 1
22# define HAVE_TM_ZONE 1 22# define HAVE_TM_ZONE 1
23# define HAVE_TZNAME 1 23# define HAVE_TZNAME 1
24# define HAVE_TZSET 1
25# include "../locale/localeinfo.h" 24# include "../locale/localeinfo.h"
26#else 25#else
27# include <config.h> 26# include <config.h>
@@ -34,6 +33,7 @@
34#endif 33#endif
35 34
36#include <ctype.h> 35#include <ctype.h>
36#include <errno.h>
37#include <time.h> 37#include <time.h>
38 38
39#if HAVE_TZNAME && !HAVE_DECL_TZNAME 39#if HAVE_TZNAME && !HAVE_DECL_TZNAME
@@ -163,7 +163,10 @@ extern char *tzname[];
163 size_t _w = pad == L_('-') || width < 0 ? 0 : width; \ 163 size_t _w = pad == L_('-') || width < 0 ? 0 : width; \
164 size_t _incr = _n < _w ? _w : _n; \ 164 size_t _incr = _n < _w ? _w : _n; \
165 if (_incr >= maxsize - i) \ 165 if (_incr >= maxsize - i) \
166 return 0; \ 166 { \
167 errno = ERANGE; \
168 return 0; \
169 } \
167 if (p) \ 170 if (p) \
168 { \ 171 { \
169 if (_n < _w) \ 172 if (_n < _w) \
@@ -365,7 +368,7 @@ tm_diff (const struct tm *a, const struct tm *b)
365#define ISO_WEEK1_WDAY 4 /* Thursday */ 368#define ISO_WEEK1_WDAY 4 /* Thursday */
366#define YDAY_MINIMUM (-366) 369#define YDAY_MINIMUM (-366)
367static int iso_week_days (int, int); 370static int iso_week_days (int, int);
368#ifdef __GNUC__ 371#if defined __GNUC__ || defined __clang__
369__inline__ 372__inline__
370#endif 373#endif
371static int 374static int
@@ -389,7 +392,6 @@ iso_week_days (int yday, int wday)
389#endif 392#endif
390 393
391#ifdef my_strftime 394#ifdef my_strftime
392# undef HAVE_TZSET
393# define extra_args , tz, ns 395# define extra_args , tz, ns
394# define extra_args_spec , timezone_t tz, int ns 396# define extra_args_spec , timezone_t tz, int ns
395#else 397#else
@@ -449,6 +451,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
449 size_t maxsize = (size_t) -1; 451 size_t maxsize = (size_t) -1;
450#endif 452#endif
451 453
454 int saved_errno = errno;
452 int hour12 = tp->tm_hour; 455 int hour12 = tp->tm_hour;
453#ifdef _NL_CURRENT 456#ifdef _NL_CURRENT
454 /* We cannot make the following values variables since we must delay 457 /* We cannot make the following values variables since we must delay
@@ -523,7 +526,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
523 { 526 {
524 /* POSIX.1 requires that local time zone information be used as 527 /* POSIX.1 requires that local time zone information be used as
525 though strftime called tzset. */ 528 though strftime called tzset. */
526# if HAVE_TZSET 529# ifndef my_strftime
527 if (!*tzset_called) 530 if (!*tzset_called)
528 { 531 {
529 tzset (); 532 tzset ();
@@ -1188,7 +1191,13 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
1188 time_t t; 1191 time_t t;
1189 1192
1190 ltm = *tp; 1193 ltm = *tp;
1194 ltm.tm_yday = -1;
1191 t = mktime_z (tz, &ltm); 1195 t = mktime_z (tz, &ltm);
1196 if (ltm.tm_yday < 0)
1197 {
1198 errno = EOVERFLOW;
1199 return 0;
1200 }
1192 1201
1193 /* Generate string value for T using time_t arithmetic; 1202 /* Generate string value for T using time_t arithmetic;
1194 this works even if sizeof (long) < sizeof (time_t). */ 1203 this works even if sizeof (long) < sizeof (time_t). */
@@ -1417,7 +1426,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
1417 1426
1418 /* POSIX.1 requires that local time zone information be used as 1427 /* POSIX.1 requires that local time zone information be used as
1419 though strftime called tzset. */ 1428 though strftime called tzset. */
1420# if HAVE_TZSET 1429# ifndef my_strftime
1421 if (!*tzset_called) 1430 if (!*tzset_called)
1422 { 1431 {
1423 tzset (); 1432 tzset ();
@@ -1486,5 +1495,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
1486 *p = L_('\0'); 1495 *p = L_('\0');
1487#endif 1496#endif
1488 1497
1498 errno = saved_errno;
1489 return i; 1499 return i;
1490} 1500}
diff --git a/lib/open.c b/lib/open.c
index 751b42d7dcf..0f7c6e9b9d3 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -30,7 +30,11 @@
30static int 30static int
31orig_open (const char *filename, int flags, mode_t mode) 31orig_open (const char *filename, int flags, mode_t mode)
32{ 32{
33#if defined _WIN32 && !defined __CYGWIN__
34 return _open (filename, flags, mode);
35#else
33 return open (filename, flags, mode); 36 return open (filename, flags, mode);
37#endif
34} 38}
35 39
36/* Specification. */ 40/* Specification. */
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 84044be5e09..a4b95b0b2ff 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -558,7 +558,7 @@ weak_alias (__regerror, regerror)
558static const bitset_t utf8_sb_map = 558static const bitset_t utf8_sb_map =
559{ 559{
560 /* Set the first 128 bits. */ 560 /* Set the first 128 bits. */
561# if defined __GNUC__ && !defined __STRICT_ANSI__ 561# if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
562 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX 562 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
563# else 563# else
564# if 4 * BITSET_WORD_BITS < ASCII_CHARS 564# if 4 * BITSET_WORD_BITS < ASCII_CHARS
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 9a0c2ed97c8..0c72e3f7b01 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -335,7 +335,7 @@ typedef struct
335 Idx idx; /* for BACK_REF */ 335 Idx idx; /* for BACK_REF */
336 re_context_type ctx_type; /* for ANCHOR */ 336 re_context_type ctx_type; /* for ANCHOR */
337 } opr; 337 } opr;
338#if __GNUC__ >= 2 && !defined __STRICT_ANSI__ 338#if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
339 re_token_type_t type : 8; 339 re_token_type_t type : 8;
340#else 340#else
341 re_token_type_t type; 341 re_token_type_t type;
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index cbebc8462fd..6d12cd826de 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -215,6 +215,11 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
215 "use gnulib module fclose for portable POSIX compliance"); 215 "use gnulib module fclose for portable POSIX compliance");
216#endif 216#endif
217 217
218#if defined _WIN32 && !defined __CYGWIN__
219# undef fcloseall
220# define fcloseall _fcloseall
221#endif
222
218#if @GNULIB_FDOPEN@ 223#if @GNULIB_FDOPEN@
219# if @REPLACE_FDOPEN@ 224# if @REPLACE_FDOPEN@
220# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 225# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -224,6 +229,12 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
224_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) 229_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
225 _GL_ARG_NONNULL ((2))); 230 _GL_ARG_NONNULL ((2)));
226_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); 231_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
232# elif defined _WIN32 && !defined __CYGWIN__
233# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
234# undef fdopen
235# define fdopen _fdopen
236# endif
237_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
227# else 238# else
228_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); 239_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
229# endif 240# endif
@@ -233,6 +244,9 @@ _GL_CXXALIASWARN (fdopen);
233/* Assume fdopen is always declared. */ 244/* Assume fdopen is always declared. */
234_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " 245_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
235 "use gnulib module fdopen for portability"); 246 "use gnulib module fdopen for portability");
247#elif defined _WIN32 && !defined __CYGWIN__
248# undef fdopen
249# define fdopen _fdopen
236#endif 250#endif
237 251
238#if @GNULIB_FFLUSH@ 252#if @GNULIB_FFLUSH@
@@ -297,6 +311,11 @@ _GL_CXXALIASWARN (fgets);
297# endif 311# endif
298#endif 312#endif
299 313
314#if defined _WIN32 && !defined __CYGWIN__
315# undef fileno
316# define fileno _fileno
317#endif
318
300#if @GNULIB_FOPEN@ 319#if @GNULIB_FOPEN@
301# if @REPLACE_FOPEN@ 320# if @REPLACE_FOPEN@
302# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 321# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -824,6 +843,11 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
824_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 843_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
825#endif 844#endif
826 845
846#if defined _WIN32 && !defined __CYGWIN__
847# undef getw
848# define getw _getw
849#endif
850
827#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ 851#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
828struct obstack; 852struct obstack;
829/* Grow an obstack with formatted output. Return the number of 853/* Grow an obstack with formatted output. Return the number of
@@ -940,7 +964,7 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
940#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 964#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
941# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 965# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
942 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 966 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
943# if defined __GNUC__ 967# if defined __GNUC__ || defined __clang__
944# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 968# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
945/* Don't break __attribute__((format(printf,M,N))). */ 969/* Don't break __attribute__((format(printf,M,N))). */
946# define printf __printf__ 970# define printf __printf__
@@ -1037,6 +1061,11 @@ _GL_CXXALIASWARN (puts);
1037# endif 1061# endif
1038#endif 1062#endif
1039 1063
1064#if defined _WIN32 && !defined __CYGWIN__
1065# undef putw
1066# define putw _putw
1067#endif
1068
1040#if @GNULIB_REMOVE@ 1069#if @GNULIB_REMOVE@
1041# if @REPLACE_REMOVE@ 1070# if @REPLACE_REMOVE@
1042# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1071# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1114,7 +1143,7 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
1114 1143
1115#if @GNULIB_SCANF@ 1144#if @GNULIB_SCANF@
1116# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ 1145# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1117# if defined __GNUC__ 1146# if defined __GNUC__ || defined __clang__
1118# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1147# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119# undef scanf 1148# undef scanf
1120/* Don't break __attribute__((format(scanf,M,N))). */ 1149/* Don't break __attribute__((format(scanf,M,N))). */
@@ -1170,7 +1199,9 @@ _GL_CXXALIAS_SYS (snprintf, int,
1170 (char *restrict str, size_t size, 1199 (char *restrict str, size_t size,
1171 const char *restrict format, ...)); 1200 const char *restrict format, ...));
1172# endif 1201# endif
1202# if __GLIBC__ >= 2
1173_GL_CXXALIASWARN (snprintf); 1203_GL_CXXALIASWARN (snprintf);
1204# endif
1174#elif defined GNULIB_POSIXCHECK 1205#elif defined GNULIB_POSIXCHECK
1175# undef snprintf 1206# undef snprintf
1176# if HAVE_RAW_DECL_SNPRINTF 1207# if HAVE_RAW_DECL_SNPRINTF
@@ -1214,6 +1245,11 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1214 "POSIX compliance"); 1245 "POSIX compliance");
1215#endif 1246#endif
1216 1247
1248#if defined _WIN32 && !defined __CYGWIN__
1249# undef tempnam
1250# define tempnam _tempnam
1251#endif
1252
1217#if @GNULIB_TMPFILE@ 1253#if @GNULIB_TMPFILE@
1218# if @REPLACE_TMPFILE@ 1254# if @REPLACE_TMPFILE@
1219# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1382,7 +1418,9 @@ _GL_CXXALIAS_SYS (vfscanf, int,
1382 (FILE *restrict stream, 1418 (FILE *restrict stream,
1383 const char *restrict format, va_list args)); 1419 const char *restrict format, va_list args));
1384# endif 1420# endif
1421# if __GLIBC__ >= 2
1385_GL_CXXALIASWARN (vfscanf); 1422_GL_CXXALIASWARN (vfscanf);
1423# endif
1386#endif 1424#endif
1387 1425
1388#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ 1426#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
@@ -1436,7 +1474,9 @@ _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
1436# else 1474# else
1437_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); 1475_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
1438# endif 1476# endif
1477# if __GLIBC__ >= 2
1439_GL_CXXALIASWARN (vscanf); 1478_GL_CXXALIASWARN (vscanf);
1479# endif
1440#endif 1480#endif
1441 1481
1442#if @GNULIB_VSNPRINTF@ 1482#if @GNULIB_VSNPRINTF@
@@ -1464,7 +1504,9 @@ _GL_CXXALIAS_SYS (vsnprintf, int,
1464 (char *restrict str, size_t size, 1504 (char *restrict str, size_t size,
1465 const char *restrict format, va_list args)); 1505 const char *restrict format, va_list args));
1466# endif 1506# endif
1507# if __GLIBC__ >= 2
1467_GL_CXXALIASWARN (vsnprintf); 1508_GL_CXXALIASWARN (vsnprintf);
1509# endif
1468#elif defined GNULIB_POSIXCHECK 1510#elif defined GNULIB_POSIXCHECK
1469# undef vsnprintf 1511# undef vsnprintf
1470# if HAVE_RAW_DECL_VSNPRINTF 1512# if HAVE_RAW_DECL_VSNPRINTF
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 5c598a275d1..47a1309e633 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -217,6 +217,21 @@ _GL_WARN_ON_USE (canonicalize_file_name,
217# endif 217# endif
218#endif 218#endif
219 219
220#if defined _WIN32 && !defined __CYGWIN__
221# undef ecvt
222# define ecvt _ecvt
223#endif
224
225#if defined _WIN32 && !defined __CYGWIN__
226# undef fcvt
227# define fcvt _fcvt
228#endif
229
230#if defined _WIN32 && !defined __CYGWIN__
231# undef gcvt
232# define gcvt _gcvt
233#endif
234
220#if @GNULIB_GETLOADAVG@ 235#if @GNULIB_GETLOADAVG@
221/* Store max(NELEM,3) load average numbers in LOADAVG[]. 236/* Store max(NELEM,3) load average numbers in LOADAVG[].
222 The three numbers are the load average of the last 1 minute, the last 5 237 The three numbers are the load average of the last 1 minute, the last 5
@@ -468,6 +483,11 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
468# endif 483# endif
469#endif 484#endif
470 485
486#if defined _WIN32 && !defined __CYGWIN__
487# undef mktemp
488# define mktemp _mktemp
489#endif
490
471#if @GNULIB_POSIX_OPENPT@ 491#if @GNULIB_POSIX_OPENPT@
472/* Return an FD open to the master side of a pseudo-terminal. Flags should 492/* Return an FD open to the master side of a pseudo-terminal. Flags should
473 include O_RDWR, and may also include O_NOCTTY. */ 493 include O_RDWR, and may also include O_NOCTTY. */
@@ -546,10 +566,19 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
546# endif 566# endif
547_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); 567_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
548_GL_CXXALIAS_RPL (putenv, int, (char *string)); 568_GL_CXXALIAS_RPL (putenv, int, (char *string));
569# elif defined _WIN32 && !defined __CYGWIN__
570# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
571# undef putenv
572# define putenv _putenv
573# endif
574_GL_CXXALIAS_MDA (putenv, int, (char *string));
549# else 575# else
550_GL_CXXALIAS_SYS (putenv, int, (char *string)); 576_GL_CXXALIAS_SYS (putenv, int, (char *string));
551# endif 577# endif
552_GL_CXXALIASWARN (putenv); 578_GL_CXXALIASWARN (putenv);
579#elif defined _WIN32 && !defined __CYGWIN__
580# undef putenv
581# define putenv _putenv
553#endif 582#endif
554 583
555#if @GNULIB_QSORT_R@ 584#if @GNULIB_QSORT_R@
diff --git a/lib/strftime.h b/lib/strftime.h
index e8501631573..fe0c4195a59 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -24,7 +24,12 @@ extern "C" {
24/* Just like strftime, but with two more arguments: 24/* Just like strftime, but with two more arguments:
25 POSIX requires that strftime use the local timezone information. 25 POSIX requires that strftime use the local timezone information.
26 Use the timezone __TZ instead. Use __NS as the number of 26 Use the timezone __TZ instead. Use __NS as the number of
27 nanoseconds in the %N directive. */ 27 nanoseconds in the %N directive.
28
29 On error, set errno and return 0. Otherwise, return the number of
30 bytes generated (not counting the trailing NUL), preserving errno
31 if the number is 0. This errno behavior is in draft POSIX 202x
32 plus some requested changes to POSIX. */
28size_t nstrftime (char *restrict, size_t, char const *, struct tm const *, 33size_t nstrftime (char *restrict, size_t, char const *, struct tm const *,
29 timezone_t __tz, int __ns); 34 timezone_t __tz, int __ns);
30 35
diff --git a/lib/string.in.h b/lib/string.in.h
index c0c1a54f39d..7d83668f6ec 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -123,6 +123,12 @@ _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
123#endif 123#endif
124 124
125 125
126#if defined _WIN32 && !defined __CYGWIN__
127# undef memccpy
128# define memccpy _memccpy
129#endif
130
131
126/* Return the first instance of C within N bytes of S, or NULL. */ 132/* Return the first instance of C within N bytes of S, or NULL. */
127#if @GNULIB_MEMCHR@ 133#if @GNULIB_MEMCHR@
128# if @REPLACE_MEMCHR@ 134# if @REPLACE_MEMCHR@
@@ -384,6 +390,12 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
384# endif 390# endif
385_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 391_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
386_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 392_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
393# elif defined _WIN32 && !defined __CYGWIN__
394# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
395# undef strdup
396# define strdup _strdup
397# endif
398_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
387# else 399# else
388# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 400# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
389 /* strdup exists as a function and as a macro. Get rid of the macro. */ 401 /* strdup exists as a function and as a macro. Get rid of the macro. */
@@ -401,6 +413,9 @@ _GL_CXXALIASWARN (strdup);
401_GL_WARN_ON_USE (strdup, "strdup is unportable - " 413_GL_WARN_ON_USE (strdup, "strdup is unportable - "
402 "use gnulib module strdup for portability"); 414 "use gnulib module strdup for portability");
403# endif 415# endif
416#elif defined _WIN32 && !defined __CYGWIN__
417# undef strdup
418# define strdup _strdup
404#endif 419#endif
405 420
406/* Append no more than N characters from SRC onto DEST. */ 421/* Append no more than N characters from SRC onto DEST. */
diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h
index f14ac1f5723..a82d716de2e 100644
--- a/lib/sys_random.in.h
+++ b/lib/sys_random.in.h
@@ -23,6 +23,10 @@
23 23
24#if @HAVE_SYS_RANDOM_H@ 24#if @HAVE_SYS_RANDOM_H@
25 25
26/* On uClibc, <sys/random.h> assumes prior inclusion of <stddef.h>. */
27# if defined __UCLIBC__
28# include <stddef.h>
29# endif
26/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>. 30/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
27 On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that 31 On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
28 includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */ 32 includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index 7a7b157d545..72cb9ba7b0f 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -177,14 +177,14 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
177# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 177# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
178# undef close 178# undef close
179# define close close_used_without_including_unistd_h 179# define close close_used_without_including_unistd_h
180# else 180# elif !defined __clang__
181 _GL_WARN_ON_USE (close, 181 _GL_WARN_ON_USE (close,
182 "close() used without including <unistd.h>"); 182 "close() used without including <unistd.h>");
183# endif 183# endif
184# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 184# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185# undef gethostname 185# undef gethostname
186# define gethostname gethostname_used_without_including_unistd_h 186# define gethostname gethostname_used_without_including_unistd_h
187# else 187# elif !defined __clang__
188 _GL_WARN_ON_USE (gethostname, 188 _GL_WARN_ON_USE (gethostname,
189 "gethostname() used without including <unistd.h>"); 189 "gethostname() used without including <unistd.h>");
190# endif 190# endif
@@ -219,7 +219,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
219# define setsockopt setsockopt_used_without_including_sys_socket_h 219# define setsockopt setsockopt_used_without_including_sys_socket_h
220# undef shutdown 220# undef shutdown
221# define shutdown shutdown_used_without_including_sys_socket_h 221# define shutdown shutdown_used_without_including_sys_socket_h
222# else 222# elif !defined __clang__
223 _GL_WARN_ON_USE (socket, 223 _GL_WARN_ON_USE (socket,
224 "socket() used without including <sys/socket.h>"); 224 "socket() used without including <sys/socket.h>");
225 _GL_WARN_ON_USE (connect, 225 _GL_WARN_ON_USE (connect,
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 89e167f6d1c..3e0e4b27b7e 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -391,6 +391,12 @@ struct stat
391#endif 391#endif
392 392
393 393
394#if defined _WIN32 && !defined __CYGWIN__
395# undef chmod
396# define chmod _chmod
397#endif
398
399
394#if @GNULIB_FCHMODAT@ 400#if @GNULIB_FCHMODAT@
395# if @REPLACE_FCHMODAT@ 401# if @REPLACE_FCHMODAT@
396# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 402# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -432,7 +438,9 @@ _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
432# else 438# else
433_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); 439_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
434# endif 440# endif
441# if __GLIBC__ >= 2
435_GL_CXXALIASWARN (fstat); 442_GL_CXXALIASWARN (fstat);
443# endif
436#elif @GNULIB_OVERRIDES_STRUCT_STAT@ 444#elif @GNULIB_OVERRIDES_STRUCT_STAT@
437# undef fstat 445# undef fstat
438# define fstat fstat_used_without_requesting_gnulib_module_fstat 446# define fstat fstat_used_without_requesting_gnulib_module_fstat
@@ -800,6 +808,12 @@ _GL_WARN_ON_USE (stat, "stat is unportable - "
800#endif 808#endif
801 809
802 810
811#if defined _WIN32 && !defined __CYGWIN__
812# undef umask
813# define umask _umask
814#endif
815
816
803#if @GNULIB_UTIMENSAT@ 817#if @GNULIB_UTIMENSAT@
804/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat 818/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
805 implementation relies on futimesat, which on Solaris 10 makes an invocation 819 implementation relies on futimesat, which on Solaris 10 makes an invocation
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index d30b26719b2..1c12d5f13d7 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -135,7 +135,7 @@ _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
135# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 135# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
136# undef close 136# undef close
137# define close close_used_without_including_unistd_h 137# define close close_used_without_including_unistd_h
138# else 138# elif !defined __clang__
139 _GL_WARN_ON_USE (close, 139 _GL_WARN_ON_USE (close,
140 "close() used without including <unistd.h>"); 140 "close() used without including <unistd.h>");
141# endif 141# endif
diff --git a/lib/time.in.h b/lib/time.in.h
index 1d11650e77f..32e6ec03ef4 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -135,13 +135,19 @@ _GL_CXXALIASWARN (nanosleep);
135# endif 135# endif
136_GL_FUNCDECL_RPL (tzset, void, (void)); 136_GL_FUNCDECL_RPL (tzset, void, (void));
137_GL_CXXALIAS_RPL (tzset, void, (void)); 137_GL_CXXALIAS_RPL (tzset, void, (void));
138# else 138# elif defined _WIN32 && !defined __CYGWIN__
139# if ! @HAVE_TZSET@ 139# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
140_GL_FUNCDECL_SYS (tzset, void, (void)); 140# undef tzset
141# define tzset _tzset
141# endif 142# endif
143_GL_CXXALIAS_MDA (tzset, void, (void));
144# else
142_GL_CXXALIAS_SYS (tzset, void, (void)); 145_GL_CXXALIAS_SYS (tzset, void, (void));
143# endif 146# endif
144_GL_CXXALIASWARN (tzset); 147_GL_CXXALIASWARN (tzset);
148# elif defined _WIN32 && !defined __CYGWIN__
149# undef tzset
150# define tzset _tzset
145# endif 151# endif
146 152
147/* Return the 'time_t' representation of TP and normalize TP. */ 153/* Return the 'time_t' representation of TP and normalize TP. */
diff --git a/lib/time_rz.c b/lib/time_rz.c
index 5d85963c9ed..95438cf876e 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -54,31 +54,6 @@ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) };
54 matters; the pointer is never dereferenced. */ 54 matters; the pointer is never dereferenced. */
55static timezone_t const local_tz = (timezone_t) 1; 55static timezone_t const local_tz = (timezone_t) 1;
56 56
57#if HAVE_TM_ZONE || HAVE_TZNAME
58
59/* Return true if the values A and B differ according to the rules for
60 tm_isdst: A and B differ if one is zero and the other positive. */
61static bool
62isdst_differ (int a, int b)
63{
64 return !a != !b && 0 <= a && 0 <= b;
65}
66
67/* Return true if A and B are equal. */
68static int
69equal_tm (const struct tm *a, const struct tm *b)
70{
71 return ! ((a->tm_sec ^ b->tm_sec)
72 | (a->tm_min ^ b->tm_min)
73 | (a->tm_hour ^ b->tm_hour)
74 | (a->tm_mday ^ b->tm_mday)
75 | (a->tm_mon ^ b->tm_mon)
76 | (a->tm_year ^ b->tm_year)
77 | isdst_differ (a->tm_isdst, b->tm_isdst));
78}
79
80#endif
81
82/* Copy to ABBRS the abbreviation at ABBR with size ABBR_SIZE (this 57/* Copy to ABBRS the abbreviation at ABBR with size ABBR_SIZE (this
83 includes its trailing null byte). Append an extra null byte to 58 includes its trailing null byte). Append an extra null byte to
84 mark the end of ABBRS. */ 59 mark the end of ABBRS. */
@@ -327,17 +302,25 @@ mktime_z (timezone_t tz, struct tm *tm)
327 timezone_t old_tz = set_tz (tz); 302 timezone_t old_tz = set_tz (tz);
328 if (old_tz) 303 if (old_tz)
329 { 304 {
330 time_t t = mktime (tm);
331#if HAVE_TM_ZONE || HAVE_TZNAME
332 time_t badtime = -1;
333 struct tm tm_1; 305 struct tm tm_1;
334 if ((t != badtime 306 tm_1.tm_sec = tm->tm_sec;
335 || (localtime_r (&t, &tm_1) && equal_tm (tm, &tm_1))) 307 tm_1.tm_min = tm->tm_min;
336 && !save_abbr (tz, tm)) 308 tm_1.tm_hour = tm->tm_hour;
337 t = badtime; 309 tm_1.tm_mday = tm->tm_mday;
310 tm_1.tm_mon = tm->tm_mon;
311 tm_1.tm_year = tm->tm_year;
312 tm_1.tm_yday = -1;
313 tm_1.tm_isdst = tm->tm_isdst;
314 time_t t = mktime (&tm_1);
315 bool ok = 0 <= tm_1.tm_yday;
316#if HAVE_TM_ZONE || HAVE_TZNAME
317 ok = ok && save_abbr (tz, &tm_1);
338#endif 318#endif
339 if (revert_tz (old_tz)) 319 if (revert_tz (old_tz) && ok)
340 return t; 320 {
321 *tm = tm_1;
322 return t;
323 }
341 } 324 }
342 return -1; 325 return -1;
343 } 326 }
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index a81a14fe873..357a35e3881 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -273,6 +273,12 @@ _GL_INLINE_HEADER_BEGIN
273_GL_FUNCDECL_RPL (access, int, (const char *file, int mode) 273_GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
274 _GL_ARG_NONNULL ((1))); 274 _GL_ARG_NONNULL ((1)));
275_GL_CXXALIAS_RPL (access, int, (const char *file, int mode)); 275_GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
276# elif defined _WIN32 && !defined __CYGWIN__
277# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
278# undef access
279# define access _access
280# endif
281_GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
276# else 282# else
277_GL_CXXALIAS_SYS (access, int, (const char *file, int mode)); 283_GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
278# endif 284# endif
@@ -286,11 +292,22 @@ _GL_WARN_ON_USE (access, "access does not always support X_OK - "
286 "also, this function is a security risk - " 292 "also, this function is a security risk - "
287 "use the gnulib module faccessat instead"); 293 "use the gnulib module faccessat instead");
288# endif 294# endif
295#elif defined _WIN32 && !defined __CYGWIN__
296# undef access
297# define access _access
289#endif 298#endif
290 299
291 300
292#if @GNULIB_CHDIR@ 301#if @GNULIB_CHDIR@
302# if defined _WIN32 && !defined __CYGWIN__
303# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
304# undef chdir
305# define chdir _chdir
306# endif
307_GL_CXXALIAS_MDA (chdir, int, (const char *file));
308# else
293_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); 309_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
310# endif
294_GL_CXXALIASWARN (chdir); 311_GL_CXXALIASWARN (chdir);
295#elif defined GNULIB_POSIXCHECK 312#elif defined GNULIB_POSIXCHECK
296# undef chdir 313# undef chdir
@@ -298,6 +315,9 @@ _GL_CXXALIASWARN (chdir);
298_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - " 315_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
299 "use gnulib module chdir for portability"); 316 "use gnulib module chdir for portability");
300# endif 317# endif
318#elif defined _WIN32 && !defined __CYGWIN__
319# undef chdir
320# define chdir _chdir
301#endif 321#endif
302 322
303 323
@@ -342,6 +362,12 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
342# endif 362# endif
343_GL_FUNCDECL_RPL (close, int, (int fd)); 363_GL_FUNCDECL_RPL (close, int, (int fd));
344_GL_CXXALIAS_RPL (close, int, (int fd)); 364_GL_CXXALIAS_RPL (close, int, (int fd));
365# elif defined _WIN32 && !defined __CYGWIN__
366# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
367# undef close
368# define close _close
369# endif
370_GL_CXXALIAS_MDA (close, int, (int fd));
345# else 371# else
346_GL_CXXALIAS_SYS (close, int, (int fd)); 372_GL_CXXALIAS_SYS (close, int, (int fd));
347# endif 373# endif
@@ -354,6 +380,9 @@ _GL_CXXALIASWARN (close);
354/* Assume close is always declared. */ 380/* Assume close is always declared. */
355_GL_WARN_ON_USE (close, "close does not portably work on sockets - " 381_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
356 "use gnulib module close for portability"); 382 "use gnulib module close for portability");
383#elif defined _WIN32 && !defined __CYGWIN__
384# undef close
385# define close _close
357#endif 386#endif
358 387
359 388
@@ -382,6 +411,12 @@ _GL_WARN_ON_USE (copy_file_range,
382# endif 411# endif
383_GL_FUNCDECL_RPL (dup, int, (int oldfd)); 412_GL_FUNCDECL_RPL (dup, int, (int oldfd));
384_GL_CXXALIAS_RPL (dup, int, (int oldfd)); 413_GL_CXXALIAS_RPL (dup, int, (int oldfd));
414# elif defined _WIN32 && !defined __CYGWIN__
415# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
416# undef dup
417# define dup _dup
418# endif
419_GL_CXXALIAS_MDA (dup, int, (int oldfd));
385# else 420# else
386_GL_CXXALIAS_SYS (dup, int, (int oldfd)); 421_GL_CXXALIAS_SYS (dup, int, (int oldfd));
387# endif 422# endif
@@ -392,6 +427,9 @@ _GL_CXXALIASWARN (dup);
392_GL_WARN_ON_USE (dup, "dup is unportable - " 427_GL_WARN_ON_USE (dup, "dup is unportable - "
393 "use gnulib module dup for portability"); 428 "use gnulib module dup for portability");
394# endif 429# endif
430#elif defined _WIN32 && !defined __CYGWIN__
431# undef dup
432# define dup _dup
395#endif 433#endif
396 434
397 435
@@ -407,6 +445,12 @@ _GL_WARN_ON_USE (dup, "dup is unportable - "
407# endif 445# endif
408_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); 446_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
409_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); 447_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
448# elif defined _WIN32 && !defined __CYGWIN__
449# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
450# undef dup2
451# define dup2 _dup2
452# endif
453_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
410# else 454# else
411_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); 455_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
412# endif 456# endif
@@ -417,6 +461,9 @@ _GL_CXXALIASWARN (dup2);
417_GL_WARN_ON_USE (dup2, "dup2 is unportable - " 461_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
418 "use gnulib module dup2 for portability"); 462 "use gnulib module dup2 for portability");
419# endif 463# endif
464#elif defined _WIN32 && !defined __CYGWIN__
465# undef dup2
466# define dup2 _dup2
420#endif 467#endif
421 468
422 469
@@ -517,6 +564,43 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
517#endif 564#endif
518 565
519 566
567#if defined _WIN32 && !defined __CYGWIN__
568# undef execl
569# define execl _execl
570#endif
571
572#if defined _WIN32 && !defined __CYGWIN__
573# undef execle
574# define execle _execle
575#endif
576
577#if defined _WIN32 && !defined __CYGWIN__
578# undef execlp
579# define execlp _execlp
580#endif
581
582
583#if defined _WIN32 && !defined __CYGWIN__
584# undef execv
585# define execv _execv
586#endif
587
588#if defined _WIN32 && !defined __CYGWIN__
589# undef execve
590# define execve _execve
591#endif
592
593#if defined _WIN32 && !defined __CYGWIN__
594# undef execvp
595# define execvp _execvp
596#endif
597
598#if defined _WIN32 && !defined __CYGWIN__
599# undef execvpe
600# define execvpe _execvpe
601#endif
602
603
520#if @GNULIB_FACCESSAT@ 604#if @GNULIB_FACCESSAT@
521# if @REPLACE_FACCESSAT@ 605# if @REPLACE_FACCESSAT@
522# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 606# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -692,6 +776,12 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
692# endif 776# endif
693_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); 777_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
694_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); 778_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
779# elif defined _WIN32 && !defined __CYGWIN__
780# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
781# undef getcwd
782# define getcwd _getcwd
783# endif
784_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
695# else 785# else
696/* Need to cast, because on mingw, the second parameter is 786/* Need to cast, because on mingw, the second parameter is
697 int size. */ 787 int size. */
@@ -704,6 +794,9 @@ _GL_CXXALIASWARN (getcwd);
704_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " 794_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
705 "use gnulib module getcwd for portability"); 795 "use gnulib module getcwd for portability");
706# endif 796# endif
797#elif defined _WIN32 && !defined __CYGWIN__
798# undef getcwd
799# define getcwd _getcwd
707#endif 800#endif
708 801
709 802
@@ -1038,6 +1131,12 @@ _GL_WARN_ON_USE (getpass, "getpass is unportable - "
1038#endif 1131#endif
1039 1132
1040 1133
1134#if defined _WIN32 && !defined __CYGWIN__
1135# undef getpid
1136# define getpid _getpid
1137#endif
1138
1139
1041#if @GNULIB_GETUSERSHELL@ 1140#if @GNULIB_GETUSERSHELL@
1042/* Return the next valid login shell on the system, or NULL when the end of 1141/* Return the next valid login shell on the system, or NULL when the end of
1043 the list has been reached. */ 1142 the list has been reached. */
@@ -1110,6 +1209,12 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
1110# endif 1209# endif
1111_GL_FUNCDECL_RPL (isatty, int, (int fd)); 1210_GL_FUNCDECL_RPL (isatty, int, (int fd));
1112_GL_CXXALIAS_RPL (isatty, int, (int fd)); 1211_GL_CXXALIAS_RPL (isatty, int, (int fd));
1212# elif defined _WIN32 && !defined __CYGWIN__
1213# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1214# undef isatty
1215# define isatty _isatty
1216# endif
1217_GL_CXXALIAS_MDA (isatty, int, (int fd));
1113# else 1218# else
1114_GL_CXXALIAS_SYS (isatty, int, (int fd)); 1219_GL_CXXALIAS_SYS (isatty, int, (int fd));
1115# endif 1220# endif
@@ -1120,6 +1225,9 @@ _GL_CXXALIASWARN (isatty);
1120_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " 1225_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
1121 "use gnulib module isatty for portability"); 1226 "use gnulib module isatty for portability");
1122# endif 1227# endif
1228#elif defined _WIN32 && !defined __CYGWIN__
1229# undef isatty
1230# define isatty _isatty
1123#endif 1231#endif
1124 1232
1125 1233
@@ -1231,6 +1339,12 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1231# endif 1339# endif
1232_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1340_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1233_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1341_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1342# elif defined _WIN32 && !defined __CYGWIN__
1343# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1344# undef lseek
1345# define lseek _lseek
1346# endif
1347_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1234# else 1348# else
1235_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); 1349_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1236# endif 1350# endif
@@ -1241,6 +1355,9 @@ _GL_CXXALIASWARN (lseek);
1241_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " 1355_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1242 "systems - use gnulib module lseek for portability"); 1356 "systems - use gnulib module lseek for portability");
1243# endif 1357# endif
1358#elif defined _WIN32 && !defined __CYGWIN__
1359# undef lseek
1360# define lseek _lseek
1244#endif 1361#endif
1245 1362
1246 1363
@@ -1373,6 +1490,12 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1373_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) 1490_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1374 _GL_ARG_NONNULL ((2))); 1491 _GL_ARG_NONNULL ((2)));
1375_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); 1492_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1493# elif defined _WIN32 && !defined __CYGWIN__
1494# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1495# undef read
1496# define read _read
1497# endif
1498_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1376# else 1499# else
1377/* Need to cast, because on mingw, the third parameter is 1500/* Need to cast, because on mingw, the third parameter is
1378 unsigned int count 1501 unsigned int count
@@ -1380,6 +1503,9 @@ _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1380_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count)); 1503_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1381# endif 1504# endif
1382_GL_CXXALIASWARN (read); 1505_GL_CXXALIASWARN (read);
1506#elif defined _WIN32 && !defined __CYGWIN__
1507# undef read
1508# define read _read
1383#endif 1509#endif
1384 1510
1385 1511
@@ -1462,6 +1588,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1462# endif 1588# endif
1463_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); 1589_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1464_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); 1590_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1591# elif defined _WIN32 && !defined __CYGWIN__
1592# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1593# undef rmdir
1594# define rmdir _rmdir
1595# endif
1596_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1465# else 1597# else
1466_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); 1598_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1467# endif 1599# endif
@@ -1472,6 +1604,9 @@ _GL_CXXALIASWARN (rmdir);
1472_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " 1604_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1473 "use gnulib module rmdir for portability"); 1605 "use gnulib module rmdir for portability");
1474# endif 1606# endif
1607#elif defined _WIN32 && !defined __CYGWIN__
1608# undef rmdir
1609# define rmdir _rmdir
1475#endif 1610#endif
1476 1611
1477 1612
@@ -1530,6 +1665,12 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1530#endif 1665#endif
1531 1666
1532 1667
1668#if defined _WIN32 && !defined __CYGWIN__
1669# undef swab
1670# define swab _swab
1671#endif
1672
1673
1533#if @GNULIB_SYMLINK@ 1674#if @GNULIB_SYMLINK@
1534# if @REPLACE_SYMLINK@ 1675# if @REPLACE_SYMLINK@
1535# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1676# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1654,6 +1795,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1654# endif 1795# endif
1655_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); 1796_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1656_GL_CXXALIAS_RPL (unlink, int, (char const *file)); 1797_GL_CXXALIAS_RPL (unlink, int, (char const *file));
1798# elif defined _WIN32 && !defined __CYGWIN__
1799# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1800# undef unlink
1801# define unlink _unlink
1802# endif
1803_GL_CXXALIAS_MDA (unlink, int, (char const *file));
1657# else 1804# else
1658_GL_CXXALIAS_SYS (unlink, int, (char const *file)); 1805_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1659# endif 1806# endif
@@ -1664,6 +1811,9 @@ _GL_CXXALIASWARN (unlink);
1664_GL_WARN_ON_USE (unlink, "unlink is not portable - " 1811_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1665 "use gnulib module unlink for portability"); 1812 "use gnulib module unlink for portability");
1666# endif 1813# endif
1814#elif defined _WIN32 && !defined __CYGWIN__
1815# undef unlink
1816# define unlink _unlink
1667#endif 1817#endif
1668 1818
1669 1819
@@ -1735,6 +1885,12 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1735_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) 1885_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1736 _GL_ARG_NONNULL ((2))); 1886 _GL_ARG_NONNULL ((2)));
1737_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 1887_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1888# elif defined _WIN32 && !defined __CYGWIN__
1889# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1890# undef write
1891# define write _write
1892# endif
1893_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
1738# else 1894# else
1739/* Need to cast, because on mingw, the third parameter is 1895/* Need to cast, because on mingw, the third parameter is
1740 unsigned int count 1896 unsigned int count
@@ -1742,6 +1898,9 @@ _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1742_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); 1898_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1743# endif 1899# endif
1744_GL_CXXALIASWARN (write); 1900_GL_CXXALIASWARN (write);
1901#elif defined _WIN32 && !defined __CYGWIN__
1902# undef write
1903# define write _write
1745#endif 1904#endif
1746 1905
1747_GL_INLINE_HEADER_END 1906_GL_INLINE_HEADER_END
diff --git a/lib/verify.h b/lib/verify.h
index 58172f3cb7f..d485a0283a9 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -23,11 +23,15 @@
23 23
24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC) 24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC)
25 works as per C11. This is supported by GCC 4.6.0 and later, in C 25 works as per C11. This is supported by GCC 4.6.0 and later, in C
26 mode. 26 mode, and by clang (also in C++ mode).
27 27
28 Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as 28 Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
29 per C2X, and define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) 29 per C2X. This is supported by GCC 9.1 and later, and by clang in
30 works as per C++17. This is supported by GCC 9.1 and later. 30 C++1z mode.
31
32 Define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) works as per
33 C++17. This is supported by GCC 9.1 and later, and by clang in
34 C++1z mode.
31 35
32 Support compilers claiming conformance to the relevant standard, 36 Support compilers claiming conformance to the relevant standard,
33 and also support GCC when not pedantic. If we were willing to slow 37 and also support GCC when not pedantic. If we were willing to slow
@@ -35,7 +39,8 @@
35 since this affects only the quality of diagnostics, why bother? */ 39 since this affects only the quality of diagnostics, why bother? */
36#ifndef __cplusplus 40#ifndef __cplusplus
37# if (201112L <= __STDC_VERSION__ \ 41# if (201112L <= __STDC_VERSION__ \
38 || (!defined __STRICT_ANSI__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__))) 42 || (!defined __STRICT_ANSI__ \
43 && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 4 <= __clang_major__)))
39# define _GL_HAVE__STATIC_ASSERT 1 44# define _GL_HAVE__STATIC_ASSERT 1
40# endif 45# endif
41# if (202000L <= __STDC_VERSION__ \ 46# if (202000L <= __STDC_VERSION__ \
@@ -43,7 +48,15 @@
43# define _GL_HAVE__STATIC_ASSERT1 1 48# define _GL_HAVE__STATIC_ASSERT1 1
44# endif 49# endif
45#else 50#else
46# if 201703L <= __cplusplus || 9 <= __GNUC__ 51# if 4 <= __clang_major__
52# define _GL_HAVE__STATIC_ASSERT 1
53# endif
54# if 4 <= __clang_major__ && 201411 <= __cpp_static_assert
55# define _GL_HAVE__STATIC_ASSERT1 1
56# endif
57# if 201703L <= __cplusplus \
58 || 9 <= __GNUC__ \
59 || (4 <= __clang_major__ && 201411 <= __cpp_static_assert)
47# define _GL_HAVE_STATIC_ASSERT1 1 60# define _GL_HAVE_STATIC_ASSERT1 1
48# endif 61# endif
49#endif 62#endif
@@ -233,13 +246,6 @@ template <int w>
233 246
234/* @assert.h omit start@ */ 247/* @assert.h omit start@ */
235 248
236#if defined __has_builtin
237/* <https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions> */
238# define _GL_HAS_BUILTIN_ASSUME __has_builtin (__builtin_assume)
239#else
240# define _GL_HAS_BUILTIN_ASSUME 0
241#endif
242
243#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)) 249#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
244# define _GL_HAS_BUILTIN_TRAP 1 250# define _GL_HAS_BUILTIN_TRAP 1
245#elif defined __has_builtin 251#elif defined __has_builtin
@@ -299,11 +305,14 @@ template <int w>
299 305
300 Although assuming R can help a compiler generate better code or 306 Although assuming R can help a compiler generate better code or
301 diagnostics, performance can suffer if R uses hard-to-optimize 307 diagnostics, performance can suffer if R uses hard-to-optimize
302 features such as function calls not inlined by the compiler. */ 308 features such as function calls not inlined by the compiler.
309
310 Avoid Clang’s __builtin_assume, as clang 9.0.1 -Wassume can
311 generate a bogus diagnostic "the argument to '__builtin_assume' has
312 side effects that will be discarded" even when the argument has no
313 side effects. */
303 314
304#if _GL_HAS_BUILTIN_ASSUME 315#if _GL_HAS_BUILTIN_UNREACHABLE
305# define assume(R) __builtin_assume (R)
306#elif _GL_HAS_BUILTIN_UNREACHABLE
307# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ()) 316# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
308#elif 1200 <= _MSC_VER 317#elif 1200 <= _MSC_VER
309# define assume(R) __assume (R) 318# define assume(R) __assume (R)