summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-08-16 14:22:56 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-08-16 14:30:29 -0700
commit846657afaf021e8a796335d740ac4a34056abbeb (patch)
treea6e9e88571b6ed6b257609bc743879043d02263f /lib
parent8c68a15f2ab484dabea4d4c2c760061d8ef440db (diff)
downloademacs-846657afaf021e8a796335d740ac4a34056abbeb.tar.gz
Update from Gnulib
This incorporates: 2020-08-16 time_rz: remove unused functions 2020-08-16 time_rz: fix issues with mktime_z failures 2020-08-16 nstrftime: Guide inlining also on clang 2020-08-16 intprops: Avoid bogus warning on clang 2020-08-16 libc-config: Enable __REDIRECT macro also on clang 2020-08-16 regex: Use initializer shorthand syntax also with clang 2020-08-16 regex: Use space optimization also with clang 2020-08-16 Use _Static_assert and static_assert when present on clang 2020-08-16 Use 'throw ()' for optimization in C++ mode also on clang 2020-08-16 stdio: Don't break attribute 'scanf' on clang 2020-08-16 Fix "warning: 'format' attribute ...: rpl_printf" 2020-08-16 Fix "warning: attribute declaration must precede definition" 2020-08-16 Fix undesired warnings 2020-08-16 Don't use Autoconf quadrigraphsxo 2020-08-16 Fix quoting of AC_LANG_PROGRAM arguments 2020-08-16 Assume autoconf >= 2.64 2020-08-15 nstrftime: be more predictable about errno 2020-08-15 canonicalize: Fix autoconf test on MSVC/clang 2020-08-15 Support compiling without -loldnames on native Windows 2020-08-14 mktime, mktime-internal: Remove obsolete code 2020-08-14 Assume tzset exists * lib/c++defs.h, lib/canonicalize-lgpl.c, lib/cdefs.h, lib/dup2.c: * lib/fcntl.in.h, lib/getopt-cdefs.in.h, lib/intprops.h, lib/md5.h: * lib/mktime.c, lib/nstrftime.c, lib/open.c, lib/regcomp.c: * lib/regex_internal.h, lib/stdio.in.h, lib/stdlib.in.h: * lib/strftime.h, lib/string.in.h, lib/sys_select.in.h: * lib/sys_stat.in.h, lib/sys_time.in.h, lib/time.in.h, lib/time_rz.c: * lib/unistd.in.h, lib/verify.h, m4/00gnulib.m4: * m4/absolute-header.m4, m4/alloca.m4, m4/canonicalize.m4, m4/dup2.m4: * m4/fchmodat.m4, m4/fcntl.m4, m4/fdopendir.m4, m4/fpending.m4: * m4/futimens.m4, m4/getdtablesize.m4, m4/getloadavg.m4: * m4/gnulib-common.m4, m4/include_next.m4, m4/largefile.m4: * m4/manywarnings.m4, m4/mktime.m4, m4/nstrftime.m4, m4/open-slash.m4: * m4/pselect.m4, m4/pthread_sigmask.m4, m4/time_h.m4, m4/utimens.m4: * m4/utimensat.m4, m4/utimes.m4, m4/warnings.m4: Copy from Gnulib. * lib/gnulib.mk.in: Regenerate.
Diffstat (limited to 'lib')
-rw-r--r--lib/c++defs.h10
-rw-r--r--lib/canonicalize-lgpl.c4
-rw-r--r--lib/cdefs.h7
-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_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.h23
25 files changed, 379 insertions, 70 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 @@
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
+/* _GL_CXXALIAS_MDA (func, rettype, parameters);
+ is to be used when func is a Microsoft deprecated alias, on native Windows.
+ It declares a C++ alias called GNULIB_NAMESPACE::func
+ that redirects to _func, if GNULIB_NAMESPACE is defined.
+ Example:
+ _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
+ */
+#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
+ _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
+
/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
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 @@
# include "pathmax.h"
# include "malloca.h"
# include "filename.h"
-# if HAVE_GETCWD
+# if defined _WIN32 && !defined __CYGWIN__
+# define __getcwd _getcwd
+# elif HAVE_GETCWD
# if IN_RELOCWRAPPER
/* When building the relocatable program wrapper, use the system's getcwd
function, not the gnulib override, otherwise we would get a link error.
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 4f89f4e4bf0..0cc27806a19 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -85,7 +85,7 @@
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
# else
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
# define __THROW throw ()
# define __THROWNL throw ()
# define __NTH(fct) __LEAF_ATTR fct throw ()
@@ -194,7 +194,7 @@
Example:
int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
-#if defined __GNUC__ && __GNUC__ >= 2
+#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
# ifdef __cplusplus
@@ -465,7 +465,8 @@
#if (!defined _Static_assert && !defined __cplusplus \
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
- && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
+ && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
+ || defined __STRICT_ANSI__))
# define _Static_assert(expr, diagnostic) \
extern int (*__Static_assert_function (void)) \
[!!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)
TRY_MSVC_INVAL
{
- result = dup2 (fd, desired_fd);
+ result = _dup2 (fd, desired_fd);
}
CATCH_MSVC_INVAL
{
@@ -64,7 +64,7 @@ dup2_nothrow (int fd, int desired_fd)
return result;
}
# else
-# define dup2_nothrow dup2
+# define dup2_nothrow _dup2
# endif
static 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 @@
_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef creat
+# define creat _creat
+# endif
+_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode));
# else
_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
# endif
@@ -106,6 +112,9 @@ _GL_CXXALIASWARN (creat);
/* Assume creat is always declared. */
_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
"use gnulib module creat for portability");
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef creat
+# define creat _creat
#endif
#if @GNULIB_FCNTL@
@@ -146,6 +155,12 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef open
+# define open _open
+# endif
+_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
# else
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
# endif
@@ -159,6 +174,9 @@ _GL_CXXALIASWARN (open);
/* Assume open is always declared. */
_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
"use gnulib module open for portability");
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef open
+# define open _open
#endif
#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 @@
#endif
#ifndef __THROW
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
# define __THROW throw ()
# else
# 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@
HAVE_TIMEGM = @HAVE_TIMEGM@
HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@
HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
-HAVE_TZSET = @HAVE_TZSET@
HAVE_UNISTD_H = @HAVE_UNISTD_H@
HAVE_UNLINKAT = @HAVE_UNLINKAT@
HAVE_UNLOCKPT = @HAVE_UNLOCKPT@
@@ -1159,7 +1158,7 @@ ifeq (,$(OMIT_GNULIB_MODULE_absolute-header))
# Use this preprocessor expression to decide whether #include_next works.
# Do not rely on a 'configure'-time test for this, since the expression
# might appear in an installed header, which is used by some other compiler.
-HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER)
+HAVE_INCLUDE_NEXT = (__GNUC__ || __clang__ || 60000000 <= __DECC_VER)
endif
## end gnulib module absolute-header
@@ -3185,7 +3184,6 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
- -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \
-e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
-e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
-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 @@
For now, assume all versions of GCC-like compilers generate bogus
warnings for _Generic. This matters only for compilers that
lack relevant builtins. */
-#if __GNUC__
+#if __GNUC__ || defined __clang__
# define _GL__GENERIC_BOGUS 1
#else
# 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 @@
#endif
#ifndef __THROW
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
# define __THROW throw ()
# else
# 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)
const char *tz = getenv ("TZ");
if (tz != NULL && strchr (tz, '/') != NULL)
_putenv ("TZ=");
-# elif HAVE_TZSET
+# else
tzset ();
# endif
}
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 @@
# define HAVE_TM_GMTOFF 1
# define HAVE_TM_ZONE 1
# define HAVE_TZNAME 1
-# define HAVE_TZSET 1
# include "../locale/localeinfo.h"
#else
# include <config.h>
@@ -34,6 +33,7 @@
#endif
#include <ctype.h>
+#include <errno.h>
#include <time.h>
#if HAVE_TZNAME && !HAVE_DECL_TZNAME
@@ -163,7 +163,10 @@ extern char *tzname[];
size_t _w = pad == L_('-') || width < 0 ? 0 : width; \
size_t _incr = _n < _w ? _w : _n; \
if (_incr >= maxsize - i) \
- return 0; \
+ { \
+ errno = ERANGE; \
+ return 0; \
+ } \
if (p) \
{ \
if (_n < _w) \
@@ -365,7 +368,7 @@ tm_diff (const struct tm *a, const struct tm *b)
#define ISO_WEEK1_WDAY 4 /* Thursday */
#define YDAY_MINIMUM (-366)
static int iso_week_days (int, int);
-#ifdef __GNUC__
+#if defined __GNUC__ || defined __clang__
__inline__
#endif
static int
@@ -389,7 +392,6 @@ iso_week_days (int yday, int wday)
#endif
#ifdef my_strftime
-# undef HAVE_TZSET
# define extra_args , tz, ns
# define extra_args_spec , timezone_t tz, int ns
#else
@@ -449,6 +451,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
size_t maxsize = (size_t) -1;
#endif
+ int saved_errno = errno;
int hour12 = tp->tm_hour;
#ifdef _NL_CURRENT
/* 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)
{
/* POSIX.1 requires that local time zone information be used as
though strftime called tzset. */
-# if HAVE_TZSET
+# ifndef my_strftime
if (!*tzset_called)
{
tzset ();
@@ -1188,7 +1191,13 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
time_t t;
ltm = *tp;
+ ltm.tm_yday = -1;
t = mktime_z (tz, &ltm);
+ if (ltm.tm_yday < 0)
+ {
+ errno = EOVERFLOW;
+ return 0;
+ }
/* Generate string value for T using time_t arithmetic;
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)
/* POSIX.1 requires that local time zone information be used as
though strftime called tzset. */
-# if HAVE_TZSET
+# ifndef my_strftime
if (!*tzset_called)
{
tzset ();
@@ -1486,5 +1495,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
*p = L_('\0');
#endif
+ errno = saved_errno;
return i;
}
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 @@
static int
orig_open (const char *filename, int flags, mode_t mode)
{
+#if defined _WIN32 && !defined __CYGWIN__
+ return _open (filename, flags, mode);
+#else
return open (filename, flags, mode);
+#endif
}
/* 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)
static const bitset_t utf8_sb_map =
{
/* Set the first 128 bits. */
-# if defined __GNUC__ && !defined __STRICT_ANSI__
+# if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
[0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
# else
# 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
Idx idx; /* for BACK_REF */
re_context_type ctx_type; /* for ANCHOR */
} opr;
-#if __GNUC__ >= 2 && !defined __STRICT_ANSI__
+#if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
re_token_type_t type : 8;
#else
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 - "
"use gnulib module fclose for portable POSIX compliance");
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef fcloseall
+# define fcloseall _fcloseall
+#endif
+
#if @GNULIB_FDOPEN@
# if @REPLACE_FDOPEN@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -224,6 +229,12 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fdopen
+# define fdopen _fdopen
+# endif
+_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
# else
_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
# endif
@@ -233,6 +244,9 @@ _GL_CXXALIASWARN (fdopen);
/* Assume fdopen is always declared. */
_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
"use gnulib module fdopen for portability");
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef fdopen
+# define fdopen _fdopen
#endif
#if @GNULIB_FFLUSH@
@@ -297,6 +311,11 @@ _GL_CXXALIASWARN (fgets);
# endif
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef fileno
+# define fileno _fileno
+#endif
+
#if @GNULIB_FOPEN@
# if @REPLACE_FOPEN@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -824,6 +843,11 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef getw
+# define getw _getw
+#endif
+
#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
struct obstack;
/* 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 - "
#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
|| (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
-# if defined __GNUC__
+# if defined __GNUC__ || defined __clang__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
/* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__
@@ -1037,6 +1061,11 @@ _GL_CXXALIASWARN (puts);
# endif
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef putw
+# define putw _putw
+#endif
+
#if @GNULIB_REMOVE@
# if @REPLACE_REMOVE@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1114,7 +1143,7 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
#if @GNULIB_SCANF@
# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
-# if defined __GNUC__
+# if defined __GNUC__ || defined __clang__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef scanf
/* Don't break __attribute__((format(scanf,M,N))). */
@@ -1170,7 +1199,9 @@ _GL_CXXALIAS_SYS (snprintf, int,
(char *restrict str, size_t size,
const char *restrict format, ...));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (snprintf);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef snprintf
# if HAVE_RAW_DECL_SNPRINTF
@@ -1214,6 +1245,11 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
"POSIX compliance");
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef tempnam
+# define tempnam _tempnam
+#endif
+
#if @GNULIB_TMPFILE@
# if @REPLACE_TMPFILE@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1382,7 +1418,9 @@ _GL_CXXALIAS_SYS (vfscanf, int,
(FILE *restrict stream,
const char *restrict format, va_list args));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (vfscanf);
+# endif
#endif
#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
@@ -1436,7 +1474,9 @@ _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
# else
_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (vscanf);
+# endif
#endif
#if @GNULIB_VSNPRINTF@
@@ -1464,7 +1504,9 @@ _GL_CXXALIAS_SYS (vsnprintf, int,
(char *restrict str, size_t size,
const char *restrict format, va_list args));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (vsnprintf);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef vsnprintf
# 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,
# endif
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef ecvt
+# define ecvt _ecvt
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef fcvt
+# define fcvt _fcvt
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef gcvt
+# define gcvt _gcvt
+#endif
+
#if @GNULIB_GETLOADAVG@
/* Store max(NELEM,3) load average numbers in LOADAVG[].
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 - "
# endif
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef mktemp
+# define mktemp _mktemp
+#endif
+
#if @GNULIB_POSIX_OPENPT@
/* Return an FD open to the master side of a pseudo-terminal. Flags should
include O_RDWR, and may also include O_NOCTTY. */
@@ -546,10 +566,19 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
# endif
_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (putenv, int, (char *string));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef putenv
+# define putenv _putenv
+# endif
+_GL_CXXALIAS_MDA (putenv, int, (char *string));
# else
_GL_CXXALIAS_SYS (putenv, int, (char *string));
# endif
_GL_CXXALIASWARN (putenv);
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef putenv
+# define putenv _putenv
#endif
#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" {
/* Just like strftime, but with two more arguments:
POSIX requires that strftime use the local timezone information.
Use the timezone __TZ instead. Use __NS as the number of
- nanoseconds in the %N directive. */
+ nanoseconds in the %N directive.
+
+ On error, set errno and return 0. Otherwise, return the number of
+ bytes generated (not counting the trailing NUL), preserving errno
+ if the number is 0. This errno behavior is in draft POSIX 202x
+ plus some requested changes to POSIX. */
size_t nstrftime (char *restrict, size_t, char const *, struct tm const *,
timezone_t __tz, int __ns);
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");
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef memccpy
+# define memccpy _memccpy
+#endif
+
+
/* Return the first instance of C within N bytes of S, or NULL. */
#if @GNULIB_MEMCHR@
# if @REPLACE_MEMCHR@
@@ -384,6 +390,12 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
# endif
_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strdup
+# define strdup _strdup
+# endif
+_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
# else
# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
/* strdup exists as a function and as a macro. Get rid of the macro. */
@@ -401,6 +413,9 @@ _GL_CXXALIASWARN (strdup);
_GL_WARN_ON_USE (strdup, "strdup is unportable - "
"use gnulib module strdup for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef strdup
+# define strdup _strdup
#endif
/* Append no more than N characters from SRC onto DEST. */
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)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef close
# define close close_used_without_including_unistd_h
-# else
+# elif !defined __clang__
_GL_WARN_ON_USE (close,
"close() used without including <unistd.h>");
# endif
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef gethostname
# define gethostname gethostname_used_without_including_unistd_h
-# else
+# elif !defined __clang__
_GL_WARN_ON_USE (gethostname,
"gethostname() used without including <unistd.h>");
# endif
@@ -219,7 +219,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
# define setsockopt setsockopt_used_without_including_sys_socket_h
# undef shutdown
# define shutdown shutdown_used_without_including_sys_socket_h
-# else
+# elif !defined __clang__
_GL_WARN_ON_USE (socket,
"socket() used without including <sys/socket.h>");
_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
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef chmod
+# define chmod _chmod
+#endif
+
+
#if @GNULIB_FCHMODAT@
# if @REPLACE_FCHMODAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -432,7 +438,9 @@ _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
# else
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (fstat);
+# endif
#elif @GNULIB_OVERRIDES_STRUCT_STAT@
# undef fstat
# define fstat fstat_used_without_requesting_gnulib_module_fstat
@@ -800,6 +808,12 @@ _GL_WARN_ON_USE (stat, "stat is unportable - "
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef umask
+# define umask _umask
+#endif
+
+
#if @GNULIB_UTIMENSAT@
/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
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 - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef close
# define close close_used_without_including_unistd_h
-# else
+# elif !defined __clang__
_GL_WARN_ON_USE (close,
"close() used without including <unistd.h>");
# 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);
# endif
_GL_FUNCDECL_RPL (tzset, void, (void));
_GL_CXXALIAS_RPL (tzset, void, (void));
-# else
-# if ! @HAVE_TZSET@
-_GL_FUNCDECL_SYS (tzset, void, (void));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef tzset
+# define tzset _tzset
# endif
+_GL_CXXALIAS_MDA (tzset, void, (void));
+# else
_GL_CXXALIAS_SYS (tzset, void, (void));
# endif
_GL_CXXALIASWARN (tzset);
+# elif defined _WIN32 && !defined __CYGWIN__
+# undef tzset
+# define tzset _tzset
# endif
/* 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) };
matters; the pointer is never dereferenced. */
static timezone_t const local_tz = (timezone_t) 1;
-#if HAVE_TM_ZONE || HAVE_TZNAME
-
-/* Return true if the values A and B differ according to the rules for
- tm_isdst: A and B differ if one is zero and the other positive. */
-static bool
-isdst_differ (int a, int b)
-{
- return !a != !b && 0 <= a && 0 <= b;
-}
-
-/* Return true if A and B are equal. */
-static int
-equal_tm (const struct tm *a, const struct tm *b)
-{
- return ! ((a->tm_sec ^ b->tm_sec)
- | (a->tm_min ^ b->tm_min)
- | (a->tm_hour ^ b->tm_hour)
- | (a->tm_mday ^ b->tm_mday)
- | (a->tm_mon ^ b->tm_mon)
- | (a->tm_year ^ b->tm_year)
- | isdst_differ (a->tm_isdst, b->tm_isdst));
-}
-
-#endif
-
/* Copy to ABBRS the abbreviation at ABBR with size ABBR_SIZE (this
includes its trailing null byte). Append an extra null byte to
mark the end of ABBRS. */
@@ -327,17 +302,25 @@ mktime_z (timezone_t tz, struct tm *tm)
timezone_t old_tz = set_tz (tz);
if (old_tz)
{
- time_t t = mktime (tm);
-#if HAVE_TM_ZONE || HAVE_TZNAME
- time_t badtime = -1;
struct tm tm_1;
- if ((t != badtime
- || (localtime_r (&t, &tm_1) && equal_tm (tm, &tm_1)))
- && !save_abbr (tz, tm))
- t = badtime;
+ tm_1.tm_sec = tm->tm_sec;
+ tm_1.tm_min = tm->tm_min;
+ tm_1.tm_hour = tm->tm_hour;
+ tm_1.tm_mday = tm->tm_mday;
+ tm_1.tm_mon = tm->tm_mon;
+ tm_1.tm_year = tm->tm_year;
+ tm_1.tm_yday = -1;
+ tm_1.tm_isdst = tm->tm_isdst;
+ time_t t = mktime (&tm_1);
+ bool ok = 0 <= tm_1.tm_yday;
+#if HAVE_TM_ZONE || HAVE_TZNAME
+ ok = ok && save_abbr (tz, &tm_1);
#endif
- if (revert_tz (old_tz))
- return t;
+ if (revert_tz (old_tz) && ok)
+ {
+ *tm = tm_1;
+ return t;
+ }
}
return -1;
}
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
_GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef access
+# define access _access
+# endif
+_GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
# else
_GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
# endif
@@ -286,11 +292,22 @@ _GL_WARN_ON_USE (access, "access does not always support X_OK - "
"also, this function is a security risk - "
"use the gnulib module faccessat instead");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef access
+# define access _access
#endif
#if @GNULIB_CHDIR@
+# if defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef chdir
+# define chdir _chdir
+# endif
+_GL_CXXALIAS_MDA (chdir, int, (const char *file));
+# else
_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIASWARN (chdir);
#elif defined GNULIB_POSIXCHECK
# undef chdir
@@ -298,6 +315,9 @@ _GL_CXXALIASWARN (chdir);
_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
"use gnulib module chdir for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef chdir
+# define chdir _chdir
#endif
@@ -342,6 +362,12 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
# endif
_GL_FUNCDECL_RPL (close, int, (int fd));
_GL_CXXALIAS_RPL (close, int, (int fd));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef close
+# define close _close
+# endif
+_GL_CXXALIAS_MDA (close, int, (int fd));
# else
_GL_CXXALIAS_SYS (close, int, (int fd));
# endif
@@ -354,6 +380,9 @@ _GL_CXXALIASWARN (close);
/* Assume close is always declared. */
_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
"use gnulib module close for portability");
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef close
+# define close _close
#endif
@@ -382,6 +411,12 @@ _GL_WARN_ON_USE (copy_file_range,
# endif
_GL_FUNCDECL_RPL (dup, int, (int oldfd));
_GL_CXXALIAS_RPL (dup, int, (int oldfd));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef dup
+# define dup _dup
+# endif
+_GL_CXXALIAS_MDA (dup, int, (int oldfd));
# else
_GL_CXXALIAS_SYS (dup, int, (int oldfd));
# endif
@@ -392,6 +427,9 @@ _GL_CXXALIASWARN (dup);
_GL_WARN_ON_USE (dup, "dup is unportable - "
"use gnulib module dup for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef dup
+# define dup _dup
#endif
@@ -407,6 +445,12 @@ _GL_WARN_ON_USE (dup, "dup is unportable - "
# endif
_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef dup2
+# define dup2 _dup2
+# endif
+_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
# else
_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
# endif
@@ -417,6 +461,9 @@ _GL_CXXALIASWARN (dup2);
_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
"use gnulib module dup2 for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef dup2
+# define dup2 _dup2
#endif
@@ -517,6 +564,43 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef execl
+# define execl _execl
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef execle
+# define execle _execle
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef execlp
+# define execlp _execlp
+#endif
+
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef execv
+# define execv _execv
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef execve
+# define execve _execve
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef execvp
+# define execvp _execvp
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+# undef execvpe
+# define execvpe _execvpe
+#endif
+
+
#if @GNULIB_FACCESSAT@
# if @REPLACE_FACCESSAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -692,6 +776,12 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
# endif
_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getcwd
+# define getcwd _getcwd
+# endif
+_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
# else
/* Need to cast, because on mingw, the second parameter is
int size. */
@@ -704,6 +794,9 @@ _GL_CXXALIASWARN (getcwd);
_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
"use gnulib module getcwd for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef getcwd
+# define getcwd _getcwd
#endif
@@ -1038,6 +1131,12 @@ _GL_WARN_ON_USE (getpass, "getpass is unportable - "
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef getpid
+# define getpid _getpid
+#endif
+
+
#if @GNULIB_GETUSERSHELL@
/* Return the next valid login shell on the system, or NULL when the end of
the list has been reached. */
@@ -1110,6 +1209,12 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
# endif
_GL_FUNCDECL_RPL (isatty, int, (int fd));
_GL_CXXALIAS_RPL (isatty, int, (int fd));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef isatty
+# define isatty _isatty
+# endif
+_GL_CXXALIAS_MDA (isatty, int, (int fd));
# else
_GL_CXXALIAS_SYS (isatty, int, (int fd));
# endif
@@ -1120,6 +1225,9 @@ _GL_CXXALIASWARN (isatty);
_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
"use gnulib module isatty for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef isatty
+# define isatty _isatty
#endif
@@ -1231,6 +1339,12 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
# endif
_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef lseek
+# define lseek _lseek
+# endif
+_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
# else
_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
# endif
@@ -1241,6 +1355,9 @@ _GL_CXXALIASWARN (lseek);
_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
"systems - use gnulib module lseek for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef lseek
+# define lseek _lseek
#endif
@@ -1373,6 +1490,12 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef read
+# define read _read
+# endif
+_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
# else
/* Need to cast, because on mingw, the third parameter is
unsigned int count
@@ -1380,6 +1503,9 @@ _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
# endif
_GL_CXXALIASWARN (read);
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef read
+# define read _read
#endif
@@ -1462,6 +1588,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
# endif
_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef rmdir
+# define rmdir _rmdir
+# endif
+_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
# else
_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
# endif
@@ -1472,6 +1604,9 @@ _GL_CXXALIASWARN (rmdir);
_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
"use gnulib module rmdir for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef rmdir
+# define rmdir _rmdir
#endif
@@ -1530,6 +1665,12 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
#endif
+#if defined _WIN32 && !defined __CYGWIN__
+# undef swab
+# define swab _swab
+#endif
+
+
#if @GNULIB_SYMLINK@
# if @REPLACE_SYMLINK@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1654,6 +1795,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
# endif
_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (unlink, int, (char const *file));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef unlink
+# define unlink _unlink
+# endif
+_GL_CXXALIAS_MDA (unlink, int, (char const *file));
# else
_GL_CXXALIAS_SYS (unlink, int, (char const *file));
# endif
@@ -1664,6 +1811,9 @@ _GL_CXXALIASWARN (unlink);
_GL_WARN_ON_USE (unlink, "unlink is not portable - "
"use gnulib module unlink for portability");
# endif
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef unlink
+# define unlink _unlink
#endif
@@ -1735,6 +1885,12 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef write
+# define write _write
+# endif
+_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
# else
/* Need to cast, because on mingw, the third parameter is
unsigned int count
@@ -1742,6 +1898,9 @@ _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
# endif
_GL_CXXALIASWARN (write);
+#elif defined _WIN32 && !defined __CYGWIN__
+# undef write
+# define write _write
#endif
_GL_INLINE_HEADER_END
diff --git a/lib/verify.h b/lib/verify.h
index 58172f3cb7f..0ba8d579071 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -23,11 +23,15 @@
/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC)
works as per C11. This is supported by GCC 4.6.0 and later, in C
- mode.
+ mode, and by clang (also in C++ mode).
Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
- per C2X, and define _GL_HAVE_STATIC_ASSERT1 if static_assert (R)
- works as per C++17. This is supported by GCC 9.1 and later.
+ per C2X. This is supported by GCC 9.1 and later, and by clang in
+ C++1z mode.
+
+ Define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) works as per
+ C++17. This is supported by GCC 9.1 and later, and by clang in
+ C++1z mode.
Support compilers claiming conformance to the relevant standard,
and also support GCC when not pedantic. If we were willing to slow
@@ -35,7 +39,8 @@
since this affects only the quality of diagnostics, why bother? */
#ifndef __cplusplus
# if (201112L <= __STDC_VERSION__ \
- || (!defined __STRICT_ANSI__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)))
+ || (!defined __STRICT_ANSI__ \
+ && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 4 <= __clang_major__)))
# define _GL_HAVE__STATIC_ASSERT 1
# endif
# if (202000L <= __STDC_VERSION__ \
@@ -43,7 +48,15 @@
# define _GL_HAVE__STATIC_ASSERT1 1
# endif
#else
-# if 201703L <= __cplusplus || 9 <= __GNUC__
+# if 4 <= __clang_major__
+# define _GL_HAVE__STATIC_ASSERT 1
+# endif
+# if 4 <= __clang_major__ && 201411 <= __cpp_static_assert
+# define _GL_HAVE__STATIC_ASSERT1 1
+# endif
+# if 201703L <= __cplusplus \
+ || 9 <= __GNUC__ \
+ || (4 <= __clang_major__ && 201411 <= __cpp_static_assert)
# define _GL_HAVE_STATIC_ASSERT1 1
# endif
#endif