Eli Zaretskii wrote:
> > Would a gnulib-wide option "ignore MSVC portability" be useful for Emacs?
>
> Yes, most probably, because Emacs no longer supports MSVC builds
> (although you might still find traces of that in the sources).
OK, so I'm documenting that the existing practice of Emacs (namely,
--avoid=msvc-inval --avoid=msvc-nothrow) works for this purpose, and
make it work throughout gnulib.
2017-05-10 Bruno Haible <***@clisp.org>
Implement a way to opt out from MSVC support.
This is useful for Emacs.
* modules/msvc-nothrow (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/accept4.c: Include <io.h> as an alternative to msvc-nothrow.h.
* lib/error.c: Likewise.
* lib/fcntl.c: Likewise.
* lib/flock.c: Likewise.
* lib/fstat.c: Likewise.
* lib/fsync.c: Likewise.
* lib/ioctl.c: Likewise.
* lib/isapipe.c: Likewise.
* lib/lseek.c: Likewise.
* lib/nonblocking.c: Likewise.
* lib/poll.c: Likewise.
* lib/select.c: Likewise.
* lib/sockets.h: Likewise.
* lib/sockets.c: Likewise.
* lib/stdio-read.c: Likewise.
* lib/stdio-write.c: Likewise.
* lib/utimens.c: Likewise.
* lib/w32sock.h: Likewise.
* lib/w32spawn.h: Likewise.
* tests/test-cloexec.c: Likewise.
* tests/test-dup-safer.c: Likewise.
* tests/test-dup2.c: Likewise.
* tests/test-dup3.c: Likewise.
* tests/test-fcntl.c: Likewise.
* tests/test-pipe.c: Likewise.
* tests/test-pipe2.c: Likewise.
* lib/ftruncate.c: Likewise.
(chsize_nothrow): Renamed from chsize.
* lib/msvc-nothrow.c: Don't include msvc-inval.h if
HAVE_MSVC_INVALID_PARAMETER_HANDLER is not defined.
* lib/close.c: Likewise.
* lib/dup.c: Likewise.
* lib/fclose.c: Likewise.
* lib/raise.c: Likewise.
* tests/test-fgetc.c: Likewise.
* tests/test-fputc.c: Likewise.
* tests/test-fread.c: Likewise.
* tests/test-fwrite.c: Likewise.
* lib/getdtablesize.c: Likewise.
(_setmaxstdio_nothrow): Renamed from _setmaxstdio.
* lib/isatty.c: Don't include msvc-inval.h if
HAVE_MSVC_INVALID_PARAMETER_HANDLER is not defined.
Include <io.h> as an alternative to msvc-nothrow.h.
* lib/read.c: Likewise.
* lib/write.c: Likewise.
* lib/dup2.c: Likewise.
(dup2_nothrow): New function.
(ms_windows_dup2): Use it.
* m4/close.m4 (gl_FUNC_CLOSE): Invoke gl_MSVC_INVAL and test
HAVE_MSVC_INVALID_PARAMETER_HANDLER only if gl_MSVC_INVAL is defined.
* m4/dup.m4 (gl_FUNC_DUP): Likewise.
* m4/fdopen.m4 (gl_FUNC_FDOPEN): Likewise.
* m4/raise.m4 (gl_FUNC_RAISE): Likewise.
* m4/read.m4 (gl_FUNC_READ): Likewise.
* m4/write.m4 (gl_FUNC_WRITE): Likewise.
* doc/windows-without-msvc.texi: New file.
* doc/gnulib.texi (Native Windows Support without MSVC Support): New
section.
diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index 378cee6..d23ab9c 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -6324,12 +6324,15 @@ to POSIX that it can be treated like any other Unix-like platform.
@menu
* Libtool and Windows::
* Windows sockets::
+* Native Windows Support without MSVC Support::
@end menu
@include windows-libtool.texi
@include windows-sockets.texi
+@include windows-without-msvc.texi
+
@node Particular Modules
@chapter Particular Modules
diff --git a/doc/windows-without-msvc.texi b/doc/windows-without-msvc.texi
new file mode 100644
index 0000000..781612b
--- /dev/null
+++ b/doc/windows-without-msvc.texi
@@ -0,0 +1,8 @@
+@node Native Windows Support without MSVC Support
+@section Native Windows Support without MSVC Support
+
+If your package does not desire to have MSVC support, that is, if MinGW
+shall be the only native Windows platform that you wish to get support
+for from Gnulib, and you wish to minimize the number of files imported
+from Gnulib accordingly, you can do so by passing the options
+@samp{--avoid=msvc-inval --avoid=msvc-nothrow} to @code{gnulib-tool}.
diff --git a/lib/accept4.c b/lib/accept4.c
index 040fb9f..997f75a 100644
--- a/lib/accept4.c
+++ b/lib/accept4.c
@@ -22,7 +22,11 @@
#include <errno.h>
#include <fcntl.h>
#include "binary-io.h"
-#include "msvc-nothrow.h"
+#if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+#else
+# include <io.h>
+#endif
#ifndef SOCK_CLOEXEC
# define SOCK_CLOEXEC 0
diff --git a/lib/close.c b/lib/close.c
index 3e45187..6a72c32 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -22,7 +22,9 @@
#include <errno.h>
#include "fd-hook.h"
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#undef close
diff --git a/lib/dup.c b/lib/dup.c
index 819e9e3..69887b0 100644
--- a/lib/dup.c
+++ b/lib/dup.c
@@ -22,7 +22,9 @@
#include <errno.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#undef dup
diff --git a/lib/dup2.c b/lib/dup2.c
index c0c7cad..002dc8c 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -35,10 +35,39 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
-# include "msvc-inval.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static int
+dup2_nothrow (int fd, int desired_fd)
+{
+ int result;
+
+ TRY_MSVC_INVAL
+ {
+ result = dup2 (fd, desired_fd);
+ }
+ CATCH_MSVC_INVAL
+ {
+ errno = EBADF;
+ result = -1;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+# else
+# define dup2_nothrow dup2
+# endif
static int
ms_windows_dup2 (int fd, int desired_fd)
@@ -66,16 +95,7 @@ ms_windows_dup2 (int fd, int desired_fd)
return -1;
}
- TRY_MSVC_INVAL
- {
- result = dup2 (fd, desired_fd);
- }
- CATCH_MSVC_INVAL
- {
- errno = EBADF;
- result = -1;
- }
- DONE_MSVC_INVAL;
+ result = dup2_nothrow (fd, desired_fd);
if (result == 0)
result = desired_fd;
diff --git a/lib/error.c b/lib/error.c
index ed9b37a..418d1ab 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -98,7 +98,11 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# endif
/* The gnulib override of fcntl is not needed in this file. */
diff --git a/lib/fclose.c b/lib/fclose.c
index facff2b..fc6f608 100644
--- a/lib/fclose.c
+++ b/lib/fclose.c
@@ -23,7 +23,9 @@
#include <unistd.h>
#include "freading.h"
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#undef fclose
diff --git a/lib/fcntl.c b/lib/fcntl.c
index afe1546..d4dd144 100644
--- a/lib/fcntl.c
+++ b/lib/fcntl.c
@@ -38,7 +38,11 @@
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
# define OPEN_MAX_MAX 0x10000
diff --git a/lib/flock.c b/lib/flock.c
index 7698e43..0c55d52 100644
--- a/lib/flock.c
+++ b/lib/flock.c
@@ -33,7 +33,11 @@
# include <errno.h>
/* _get_osfhandle */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
/* Determine the current size of a file. Because the other braindead
* APIs we'll call need lower/upper 32 bit pairs, keep the file size
diff --git a/lib/fstat.c b/lib/fstat.c
index a4896e3..605ac7d 100644
--- a/lib/fstat.c
+++ b/lib/fstat.c
@@ -56,7 +56,11 @@ orig_fstat (int fd, struct stat *buf)
#ifdef WINDOWS_NATIVE
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# include "stat-w32.h"
#endif
diff --git a/lib/fsync.c b/lib/fsync.c
index d7de6d8..846f308 100644
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -34,7 +34,11 @@
# include <errno.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
int
fsync (int fd)
diff --git a/lib/ftruncate.c b/lib/ftruncate.c
index 913df19..f0ecae2 100644
--- a/lib/ftruncate.c
+++ b/lib/ftruncate.c
@@ -38,7 +38,11 @@
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
static BOOL
SetFileSize (HANDLE h, LONGLONG size)
@@ -175,13 +179,14 @@ chsize_nothrow (int fd, long length)
return result;
}
-# define chsize chsize_nothrow
+# else
+# define chsize_nothrow chsize
# endif
int
ftruncate (int fd, off_t length)
{
- return chsize (fd, length);
+ return chsize_nothrow (fd, length);
}
# endif
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index 7fabb51..c356cf4 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -24,7 +24,9 @@
# include <stdio.h>
-# include "msvc-inval.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
@@ -44,7 +46,8 @@ _setmaxstdio_nothrow (int newmax)
return result;
}
-# define _setmaxstdio _setmaxstdio_nothrow
+# else
+# define _setmaxstdio_nothrow _setmaxstdio
# endif
/* Cache for the previous getdtablesize () result. Safe to cache because
@@ -76,9 +79,9 @@ getdtablesize (void)
freed when we call _setmaxstdio with the original value. */
int orig_max_stdio = _getmaxstdio ();
unsigned int bound;
- for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2)
+ for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
;
- _setmaxstdio (orig_max_stdio);
+ _setmaxstdio_nothrow (orig_max_stdio);
dtablesize = bound;
}
return dtablesize;
diff --git a/lib/ioctl.c b/lib/ioctl.c
index a28a3ae..f142558 100644
--- a/lib/ioctl.c
+++ b/lib/ioctl.c
@@ -52,7 +52,11 @@ rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */)
# include "fd-hook.h"
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
static int
primary_ioctl (int fd, int request, void *arg)
diff --git a/lib/isapipe.c b/lib/isapipe.c
index dbc63b5..535ece9 100644
--- a/lib/isapipe.c
+++ b/lib/isapipe.c
@@ -30,7 +30,11 @@
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
int
isapipe (int fd)
diff --git a/lib/isatty.c b/lib/isatty.c
index f050426..dba4380 100644
--- a/lib/isatty.c
+++ b/lib/isatty.c
@@ -27,10 +27,16 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
/* Get _get_osfhandle(). */
-#include "msvc-nothrow.h"
+#if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+#else
+# include <io.h>
+#endif
static BOOL IsConsoleHandle (HANDLE h)
{
diff --git a/lib/lseek.c b/lib/lseek.c
index e603539..9c991a3 100644
--- a/lib/lseek.c
+++ b/lib/lseek.c
@@ -24,7 +24,11 @@
/* Get GetFileType. */
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#else
# include <sys/stat.h>
#endif
diff --git a/lib/msvc-nothrow.c b/lib/msvc-nothrow.c
index 300ed41..86a8808 100644
--- a/lib/msvc-nothrow.c
+++ b/lib/msvc-nothrow.c
@@ -24,7 +24,9 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#undef _get_osfhandle
diff --git a/lib/nonblocking.c b/lib/nonblocking.c
index 3d031aa..b9ed86a 100644
--- a/lib/nonblocking.c
+++ b/lib/nonblocking.c
@@ -32,7 +32,11 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
int
get_nonblocking_flag (int desc)
diff --git a/lib/poll.c b/lib/poll.c
index 078b1ba..9115bcd 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -41,7 +41,11 @@
# include <io.h>
# include <stdio.h>
# include <conio.h>
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#else
# include <sys/time.h>
# include <unistd.h>
diff --git a/lib/raise.c b/lib/raise.c
index d3325a6..0a6d8ca 100644
--- a/lib/raise.c
+++ b/lib/raise.c
@@ -27,7 +27,9 @@
# include <errno.h>
-# include "msvc-inval.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
# undef raise
diff --git a/lib/read.c b/lib/read.c
index 08108f7..a9b943f 100644
--- a/lib/read.c
+++ b/lib/read.c
@@ -28,8 +28,14 @@
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
-# include "msvc-inval.h"
-# include "msvc-nothrow.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# undef read
diff --git a/lib/select.c b/lib/select.c
index ac86c49..01b1982 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -39,7 +39,11 @@
/* Get the overridden 'struct timeval'. */
#include <sys/time.h>
-#include "msvc-nothrow.h"
+#if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+#else
+# include <io.h>
+#endif
#undef select
diff --git a/lib/sockets.c b/lib/sockets.c
index 9333ee4..028e20e 100644
--- a/lib/sockets.c
+++ b/lib/sockets.c
@@ -28,7 +28,11 @@
# include <sys/socket.h>
# include "fd-hook.h"
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
# include "w32sock.h"
diff --git a/lib/sockets.h b/lib/sockets.h
index 8392e57..23ad74d 100644
--- a/lib/sockets.h
+++ b/lib/sockets.h
@@ -18,7 +18,7 @@
/* Written by Simon Josefsson */
#ifndef SOCKETS_H
-# define SOCKETS_H 1
+#define SOCKETS_H 1
#define SOCKETS_1_0 0x0001
#define SOCKETS_1_1 0x0101
@@ -43,9 +43,13 @@ int gl_sockets_cleanup (void)
other library that only accepts sockets. */
#ifdef WINDOWS_SOCKETS
-#include <sys/socket.h>
+# include <sys/socket.h>
-#include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
static inline SOCKET
gl_fd_to_handle (int fd)
@@ -55,7 +59,7 @@ gl_fd_to_handle (int fd)
#else
-#define gl_fd_to_handle(x) (x)
+# define gl_fd_to_handle(x) (x)
#endif /* WINDOWS_SOCKETS */
diff --git a/lib/stdio-read.c b/lib/stdio-read.c
index 8caf2f0..98db749 100644
--- a/lib/stdio-read.c
+++ b/lib/stdio-read.c
@@ -37,7 +37,11 @@
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# define CALL_WITH_ERRNO_FIX(RETTYPE, EXPRESSION, FAILED) \
if (ferror (stream)) \
diff --git a/lib/stdio-write.c b/lib/stdio-write.c
index 8ad693b..34b22f5 100644
--- a/lib/stdio-write.c
+++ b/lib/stdio-write.c
@@ -39,7 +39,11 @@
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# if GNULIB_NONBLOCKING
# define CLEAR_ERRNO \
diff --git a/lib/utimens.c b/lib/utimens.c
index b4bfa8e..ff4eab0 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -44,7 +44,11 @@
# define USE_SETFILETIME
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
/* Avoid recursion with rpl_futimens or rpl_utimensat. */
diff --git a/lib/w32sock.h b/lib/w32sock.h
index 8ac8ab7..2f753fb 100644
--- a/lib/w32sock.h
+++ b/lib/w32sock.h
@@ -26,7 +26,11 @@
#include <io.h>
/* Get _get_osfhandle(). */
-#include "msvc-nothrow.h"
+#if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+#else
+# include <io.h>
+#endif
#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY))
diff --git a/lib/w32spawn.h b/lib/w32spawn.h
index 7932662..26ff658 100644
--- a/lib/w32spawn.h
+++ b/lib/w32spawn.h
@@ -30,7 +30,11 @@
#include <errno.h>
/* Get _get_osfhandle(). */
-#include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#include "cloexec.h"
#include "xalloc.h"
diff --git a/lib/write.c b/lib/write.c
index 6a3b623..b81db62 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -34,8 +34,14 @@
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
-# include "msvc-inval.h"
-# include "msvc-nothrow.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# undef write
diff --git a/m4/close.m4 b/m4/close.m4
index 005a43a..ed357ab 100644
--- a/m4/close.m4
+++ b/m4/close.m4
@@ -1,4 +1,4 @@
-# close.m4 serial 8
+# close.m4 serial 9
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,10 +7,12 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_CLOSE],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
- AC_REQUIRE([gl_MSVC_INVAL])
- if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
- REPLACE_CLOSE=1
- fi
+ m4_ifdef([gl_MSVC_INVAL], [
+ AC_REQUIRE([gl_MSVC_INVAL])
+ if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+ REPLACE_CLOSE=1
+ fi
+ ])
m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [
gl_PREREQ_SYS_H_WINSOCK2
if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then
diff --git a/m4/dup.m4 b/m4/dup.m4
index 74fa9bd..75307cb 100644
--- a/m4/dup.m4
+++ b/m4/dup.m4
@@ -1,4 +1,4 @@
-# dup.m4 serial 4
+# dup.m4 serial 5
dnl Copyright (C) 2011-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,10 +7,12 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_DUP],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
- AC_REQUIRE([gl_MSVC_INVAL])
- if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
- REPLACE_DUP=1
- fi
+ m4_ifdef([gl_MSVC_INVAL], [
+ AC_REQUIRE([gl_MSVC_INVAL])
+ if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+ REPLACE_DUP=1
+ fi
+ ])
dnl Replace dup() for supporting the gnulib-defined fchdir() function,
dnl to keep fchdir's bookkeeping up-to-date.
m4_ifdef([gl_FUNC_FCHDIR], [
diff --git a/m4/fdopen.m4 b/m4/fdopen.m4
index 8e8619c..42f928e 100644
--- a/m4/fdopen.m4
+++ b/m4/fdopen.m4
@@ -1,4 +1,4 @@
-# fdopen.m4 serial 3
+# fdopen.m4 serial 4
dnl Copyright (C) 2011-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -8,10 +8,13 @@ AC_DEFUN([gl_FUNC_FDOPEN],
[
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
- AC_REQUIRE([gl_MSVC_INVAL])
- if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
- REPLACE_FDOPEN=1
- else
+ m4_ifdef([gl_MSVC_INVAL], [
+ AC_REQUIRE([gl_MSVC_INVAL])
+ if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+ REPLACE_FDOPEN=1
+ fi
+ ])
+ if test $REPLACE_FDOPEN = 0; then
dnl Test whether fdopen() sets errno when it fails due to a bad fd argument.
AC_CACHE_CHECK([whether fdopen sets errno], [gl_cv_func_fdopen_works],
[
diff --git a/m4/raise.m4 b/m4/raise.m4
index 28c2e0b..fe6e068 100644
--- a/m4/raise.m4
+++ b/m4/raise.m4
@@ -1,4 +1,4 @@
-# raise.m4 serial 3
+# raise.m4 serial 4
dnl Copyright (C) 2011-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -8,14 +8,16 @@ AC_DEFUN([gl_FUNC_RAISE],
[
AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
- AC_REQUIRE([gl_MSVC_INVAL])
AC_CHECK_FUNCS([raise])
if test $ac_cv_func_raise = no; then
HAVE_RAISE=0
else
- if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
- REPLACE_RAISE=1
- fi
+ m4_ifdef([gl_MSVC_INVAL], [
+ AC_REQUIRE([gl_MSVC_INVAL])
+ if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+ REPLACE_RAISE=1
+ fi
+ ])
m4_ifdef([gl_SIGNALBLOCKING], [
gl_SIGNALBLOCKING
if test $HAVE_POSIX_SIGNALBLOCKING = 0; then
diff --git a/m4/read.m4 b/m4/read.m4
index 36249ab..2466802 100644
--- a/m4/read.m4
+++ b/m4/read.m4
@@ -1,4 +1,4 @@
-# read.m4 serial 4
+# read.m4 serial 5
dnl Copyright (C) 2011-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,10 +7,12 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_READ],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
- AC_REQUIRE([gl_MSVC_INVAL])
- if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
- REPLACE_READ=1
- fi
+ m4_ifdef([gl_MSVC_INVAL], [
+ AC_REQUIRE([gl_MSVC_INVAL])
+ if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+ REPLACE_READ=1
+ fi
+ ])
dnl This ifdef is just an optimization, to avoid performing a configure
dnl check whose result is not used. It does not make the test of
dnl GNULIB_UNISTD_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
diff --git a/m4/write.m4 b/m4/write.m4
index fd46acc..2f4a235 100644
--- a/m4/write.m4
+++ b/m4/write.m4
@@ -1,4 +1,4 @@
-# write.m4 serial 5
+# write.m4 serial 6
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,10 +7,12 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_WRITE],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
- AC_REQUIRE([gl_MSVC_INVAL])
- if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
- REPLACE_WRITE=1
- fi
+ m4_ifdef([gl_MSVC_INVAL], [
+ AC_REQUIRE([gl_MSVC_INVAL])
+ if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
+ REPLACE_WRITE=1
+ fi
+ ])
dnl This ifdef is just an optimization, to avoid performing a configure
dnl check whose result is not used. It does not make the test of
dnl GNULIB_UNISTD_H_SIGPIPE or GNULIB_SIGPIPE redundant.
diff --git a/modules/msvc-nothrow b/modules/msvc-nothrow
index 2e670f9..d187eea 100644
--- a/modules/msvc-nothrow
+++ b/modules/msvc-nothrow
@@ -15,6 +15,7 @@ AC_REQUIRE([gl_MSVC_NOTHROW])
if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
AC_LIBOBJ([msvc-nothrow])
fi
+gl_MODULE_INDICATOR([msvc-nothrow])
Makefile.am:
diff --git a/tests/test-cloexec.c b/tests/test-cloexec.c
index e30e130..cbfded1 100644
--- a/tests/test-cloexec.c
+++ b/tests/test-cloexec.c
@@ -29,7 +29,11 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
#include "binary-io.h"
diff --git a/tests/test-dup-safer.c b/tests/test-dup-safer.c
index a41950a..936e484 100644
--- a/tests/test-dup-safer.c
+++ b/tests/test-dup-safer.c
@@ -34,7 +34,11 @@
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
#if !O_BINARY
diff --git a/tests/test-dup2.c b/tests/test-dup2.c
index 8f7df3a..f98486a 100644
--- a/tests/test-dup2.c
+++ b/tests/test-dup2.c
@@ -41,7 +41,11 @@ SIGNATURE_CHECK (dup2, int, (int, int));
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
#include "macros.h"
diff --git a/tests/test-dup3.c b/tests/test-dup3.c
index 8b0eef4..85f3256 100644
--- a/tests/test-dup3.c
+++ b/tests/test-dup3.c
@@ -33,7 +33,11 @@ SIGNATURE_CHECK (dup3, int, (int, int, int));
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
#include "binary-io.h"
diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c
index 5df9027..a249f9a 100644
--- a/tests/test-fcntl.c
+++ b/tests/test-fcntl.c
@@ -35,7 +35,11 @@ SIGNATURE_CHECK (fcntl, int, (int, int, ...));
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
#include "binary-io.h"
diff --git a/tests/test-fgetc.c b/tests/test-fgetc.c
index f1a3188..17edf13 100644
--- a/tests/test-fgetc.c
+++ b/tests/test-fgetc.c
@@ -25,7 +25,9 @@ SIGNATURE_CHECK (fgetc, int, (FILE *));
#include <fcntl.h>
#include <unistd.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#include "macros.h"
diff --git a/tests/test-fputc.c b/tests/test-fputc.c
index dd6993e..448e5f2 100644
--- a/tests/test-fputc.c
+++ b/tests/test-fputc.c
@@ -25,7 +25,9 @@ SIGNATURE_CHECK (fputc, int, (int, FILE *));
#include <fcntl.h>
#include <unistd.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#include "macros.h"
diff --git a/tests/test-fread.c b/tests/test-fread.c
index 1b7c42a..751774d 100644
--- a/tests/test-fread.c
+++ b/tests/test-fread.c
@@ -25,7 +25,9 @@ SIGNATURE_CHECK (fread, size_t, (void *, size_t, size_t, FILE *));
#include <fcntl.h>
#include <unistd.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#include "macros.h"
diff --git a/tests/test-fwrite.c b/tests/test-fwrite.c
index f50bbfc..0dfb15b 100644
--- a/tests/test-fwrite.c
+++ b/tests/test-fwrite.c
@@ -25,7 +25,9 @@ SIGNATURE_CHECK (fwrite, size_t, (const void *, size_t, size_t, FILE *));
#include <fcntl.h>
#include <unistd.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#include "macros.h"
diff --git a/tests/test-pipe.c b/tests/test-pipe.c
index d6dc267..08cfe92 100644
--- a/tests/test-pipe.c
+++ b/tests/test-pipe.c
@@ -29,7 +29,11 @@ SIGNATURE_CHECK (pipe, int, (int[2]));
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
#include "binary-io.h"
diff --git a/tests/test-pipe2.c b/tests/test-pipe2.c
index 6cebd33..b50ea99 100644
--- a/tests/test-pipe2.c
+++ b/tests/test-pipe2.c
@@ -29,7 +29,11 @@ SIGNATURE_CHECK (pipe2, int, (int[2], int));
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#endif
#include "binary-io.h"