clang on Windows, by default, does not link with '-loldnames' (like mingw and MSVC 14 do). This means that programs that use open(), close(), etc. will get link errors by default.
For more than 10 years, Microsoft has been deprecating these function names: access chdir chmod close creat dup dup2 ecvt execl execle execlp execv execve execvp execvpe fcloseall fcvt fdopen fileno gcvt getcwd getpid getw isatty j0 j1 jn lfind lsearch lseek memccpy mkdir mktemp open putenv putw read rmdir strdup swab tempnam tzset umask unlink utime wcsdup write y0 y1 yn mkdir is special: 2 args in POSIX, 1 arg on Windows. utime is special: no redirect in the header files, there are variants _utime32 and _utime64. Using these function names means that * You need to link with -loldnames explicitly. While this can be easy for executables, I don't think it's worth the trouble when it comes to creating libraries. * With clang, you also need to add '-Wno-deprecated-declarations' to the CPPFLAGS, or you will get a warning for each reference to these function names. * When looking up the documentation for the functions, you stumble across stub pages, such as https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-close https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-tzset https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getcwd https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strdup-wcsdup https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/mkdir * You are living on the "backward compatibility" edge of the existence. https://docs.microsoft.com/en-us/cpp/c-runtime-library/backward-compatibility I'm therefore changing gnulib to use the underscore-prefixed function names instead on native Windows. Not only with clang, but also with MSVC and with mingw. Essentially this means moving the link-time redirection (from oldnames.lib) to a preprocessor redirection. Gnulib already does plenty of preprocessor redirection ("#define foo rpl_foo"); therefore we know that it's a technique that works. I'm adding these redirections also when the corresponding gnulib module is not present. Otherwise there would be the need to add many new module dependencies, leading to the perception of code bloat for many packages that use Gnulib. The first patch is a preparation: ensure that gnulib always generates an 'utime.h' from 'utime.in.h', so that the '#define utime _utime' becomes always visible. The second patch contains all the preprocessor redirections. 2020-08-15 Bruno Haible <br...@clisp.org> Support compiling without -loldnames on native Windows. * m4/gnulib-common.m4 (GL_MDA_DEFINES, _GL_MDA_DEFINES): New macros. * m4/chown.m4 (AC_FUNC_CHOWN): In the test programs, use GL_MDA_DEFINES. (gl_FUNC_CHOWN, gl_FUNC_CHOWN_FOLLOWS_SYMLINK): Likewise. * m4/dup.m4 (gl_FUNC_DUP): Likewise. * m4/dup2.m4 (gl_FUNC_DUP2): Likewise. * m4/fchdir.m4 (gl_FUNC_FCHDIR): Likewise. * m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Likewise. * m4/fchownat.m4 (gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG): Likewise. * m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Likewise. * m4/fcntl.m4 (gl_FUNC_FCNTL): Likewise. * m4/fdopen.m4 (gl_FUNC_FDOPEN): Likewise. * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Likewise. * m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise. * m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Likewise. * m4/freopen.m4 (gl_FUNC_FREOPEN): Likewise. * m4/futimens.m4 (gl_FUNC_FUTIMENS): Likewise. * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Likewise. * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Likewise. * m4/getcwd.m4 (gl_FUNC_GETCWD_NULL, gl_FUNC_GETCWD_SIGNATURE): Likewise. * m4/getdtablesize.m4 (gl_FUNC_GETDTABLESIZE): Likewise. * m4/linkat.m4 (gl_FUNC_LINKAT): Likewise. * m4/lseek.m4 (gl_FUNC_LSEEK): Likewise. * m4/mkdir.m4 (gl_FUNC_MKDIR): Likewise. * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Likewise. * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Likewise. * m4/open-slash.m4 (gl_OPEN_TRAILING_SLASH_BUG): Likewise. * m4/poll.m4 (gl_FUNC_POLL): Likewise. * m4/posix_spawn.m4 (gl_POSIX_SPAWN_WORKS): Likewise. * m4/pread.m4 (gl_FUNC_PREAD): Likewise. * m4/pselect.m4 (gl_FUNC_PSELECT): Likewise. * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Likewise. * m4/ptsname_r.m4 (gl_PREREQ_PTSNAME_R): Likewise. * m4/putenv.m4 (gl_FUNC_PUTENV): Likewise. * m4/pwrite.m4 (gl_FUNC_PWRITE): Likewise. * m4/rename.m4 (gl_FUNC_RENAME): Likewise. * m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise. * m4/rmdir.m4 (gl_FUNC_RMDIR): Likewise. * m4/select.m4 (gl_FUNC_SELECT): Likewise. * m4/setenv.m4 (gl_FUNC_UNSETENV): Likewise. * m4/strncat.m4 (gl_FUNC_STRNCAT): Likewise. * m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Likewise. * m4/unlink-busy.m4 (gl_FUNC_UNLINK_BUSY_TEXT): Likewise. * m4/unlink.m4 (gl_FUNC_UNLINK): Likewise. * m4/utimens.m4 (gl_UTIMENS): Likewise. * m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Likewise. * m4/utimes.m4 (gl_FUNC_UTIMES): Likewise. * m4/canonicalize.m4 (gl_CANONICALIZE_LGPL): On native Windows, don't test for getcwd. * m4/utime.m4 (gl_FUNC_UTIME): On native Windows, don't test for utime. * m4/wcsdup.m4 (gl_FUNC_WCSDUP): To test for wcsdup, use a test program with GL_MDA_DEFINES. * lib/c++defs.h (_GL_CXXALIAS_MDA): New macro. * lib/fcntl.in.h (creat, open): On native Windows, use the underscore- prefixed symbol. * lib/search.in.h (lfind, lsearch): Likewise. * lib/stdio.in.h (fcloseall, fdopen, fileno, getw, putw, tempnam): Likewise. * lib/stdlib.in.h (ecvt, fcvt, gcvt, mktemp, putenv): Likewise. * lib/string.in.h (memccpy, strdup): Likewise. * lib/sys_stat.in.h (chmod, umask): Likewise. * lib/time.in.h (tzset): Likewise. * lib/unistd.in.h (access, chdir, close, dup, dup2, execl, execle, execlp, execv, execve, execvp, execvpe, getcwd, getpid, isatty, lseek, read, rmdir, swab, unlink, write): Likewise. * lib/utime.in.h (utime): Likewise. * lib/wchar.in.h (wcsdup): Likewise. * lib/math.in.h (j0, j1, jn, y0, y1, yn): Likewise. (isfinite, isinf, isnan, signbit): On native Windows, don't define as an rpl_-prefixed macro. * lib/canonicalize-lgpl.c (__getcwd): On native Windows, use _getcwd. * lib/close.c (close_nothrow): On native Windows, use _close. * lib/creat.c (orig_creat): On native Windows, use _creat. * lib/dup.c (dup_nothrow): On native Windows, use _dup. * lib/dup2.c (dup2_nothrow): Use _dup2. * lib/fdopen.c (fdopen_nothrow): On native Windows, use _fdopen. * lib/getcwd-lgpl.c: On native Windows, use _getcwd. * lib/getcwd.c (getcwd_nothrow): Use _getcwd also on mingw. * lib/open.c (orig_open): On native Windows, use _open. * lib/read.c (read_nothrow): Use _read. * lib/rmdir.c: On native Windows, use _rmdir. * lib/unlink.c: On native Windows, use _unlink. * lib/write.c (write_nothrow): Use _write. * lib/sys_select.in.h (close): With clang, don't attach a warning on an undefined symbol. * lib/sys_socket.in.h (close): Likewise. * lib/sys_time.in.h (close): Likewise. * tests/test-spawn-pipe-child.c: On native Windows, use _fdopen. 2020-08-14 Bruno Haible <br...@clisp.org> utime-h: Generate an utime.h file always. * modules/utime-h (Makefile.am): Generate utime.h always. * m4/utime_h.m4 (gl_UTIME_H): Don't set UTIME_H. Don't define GL_GENERATE_UTIME_H.
>From 3fa8acc90ad1662bd0b59e71bb84c9d2dc72a17a Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sat, 15 Aug 2020 00:14:14 +0200 Subject: [PATCH 1/5] utime-h: Generate an utime.h file always. * modules/utime-h (Makefile.am): Generate utime.h always. * m4/utime_h.m4 (gl_UTIME_H): Don't set UTIME_H. Don't define GL_GENERATE_UTIME_H. --- ChangeLog | 7 +++++++ m4/utime_h.m4 | 24 +----------------------- modules/utime-h | 7 +------ 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23e7442..1810d56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2020-08-14 Bruno Haible <br...@clisp.org> + utime-h: Generate an utime.h file always. + * modules/utime-h (Makefile.am): Generate utime.h always. + * m4/utime_h.m4 (gl_UTIME_H): Don't set UTIME_H. Don't define + GL_GENERATE_UTIME_H. + +2020-08-14 Bruno Haible <br...@clisp.org> + mktime, mktime-internal: Remove obsolete code. * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Don't #undef putenv. diff --git a/m4/utime_h.m4 b/m4/utime_h.m4 index 2a73636..6b5dfc5 100644 --- a/m4/utime_h.m4 +++ b/m4/utime_h.m4 @@ -1,4 +1,4 @@ -# utime_h.m4 serial 3 +# utime_h.m4 serial 4 dnl Copyright (C) 2017-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -21,28 +21,6 @@ AC_DEFUN([gl_UTIME_H], fi AC_SUBST([HAVE_UTIME_H]) - m4_ifdef([gl_POSIXCHECK], - [UTIME_H=utime.h], - [UTIME_H='' - if m4_ifdef([gl_ANSI_CXX], [test "$CXX" != no], [false]); then - dnl Override <utime.h> always, to support the C++ GNULIB_NAMESPACE. - UTIME_H=utime.h - else - if test $ac_cv_header_utime_h != yes; then - dnl Provide a substitute <utime.h> file. - UTIME_H=utime.h - else - case "$host_os" in - mingw*) dnl Need special handling of 'struct utimbuf'. - UTIME_H=utime.h - ;; - esac - fi - fi - ]) - AC_SUBST([UTIME_H]) - AM_CONDITIONAL([GL_GENERATE_UTIME_H], [test -n "$UTIME_H"]) - dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include <utime.h> diff --git a/modules/utime-h b/modules/utime-h index 5cd5317..fb1f1ba 100644 --- a/modules/utime-h +++ b/modules/utime-h @@ -15,11 +15,10 @@ configure.ac: gl_UTIME_H Makefile.am: -BUILT_SOURCES += $(UTIME_H) +BUILT_SOURCES += utime.h # We need the following in order to create <utime.h> when the system # doesn't have one that works with the given compiler. -if GL_GENERATE_UTIME_H utime.h: utime.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ @@ -38,10 +37,6 @@ utime.h: utime.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) < $(srcdir)/utime.in.h; \ } > $@-t && \ mv $@-t $@ -else -utime.h: $(top_builddir)/config.status - rm -f $@ -endif MOSTLYCLEANFILES += utime.h utime.h-t Include: -- 2.7.4
>From d4c637e577594532fb45781b4cac79c9a50a4c1e Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sat, 15 Aug 2020 16:54:17 +0200 Subject: [PATCH 5/5] Support compiling without -loldnames on native Windows. * m4/gnulib-common.m4 (GL_MDA_DEFINES, _GL_MDA_DEFINES): New macros. * m4/chown.m4 (AC_FUNC_CHOWN): In the test programs, use GL_MDA_DEFINES. (gl_FUNC_CHOWN, gl_FUNC_CHOWN_FOLLOWS_SYMLINK): Likewise. * m4/dup.m4 (gl_FUNC_DUP): Likewise. * m4/dup2.m4 (gl_FUNC_DUP2): Likewise. * m4/fchdir.m4 (gl_FUNC_FCHDIR): Likewise. * m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Likewise. * m4/fchownat.m4 (gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG): Likewise. * m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Likewise. * m4/fcntl.m4 (gl_FUNC_FCNTL): Likewise. * m4/fdopen.m4 (gl_FUNC_FDOPEN): Likewise. * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Likewise. * m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise. * m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Likewise. * m4/freopen.m4 (gl_FUNC_FREOPEN): Likewise. * m4/futimens.m4 (gl_FUNC_FUTIMENS): Likewise. * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Likewise. * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Likewise. * m4/getcwd.m4 (gl_FUNC_GETCWD_NULL, gl_FUNC_GETCWD_SIGNATURE): Likewise. * m4/getdtablesize.m4 (gl_FUNC_GETDTABLESIZE): Likewise. * m4/linkat.m4 (gl_FUNC_LINKAT): Likewise. * m4/lseek.m4 (gl_FUNC_LSEEK): Likewise. * m4/mkdir.m4 (gl_FUNC_MKDIR): Likewise. * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Likewise. * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Likewise. * m4/open-slash.m4 (gl_OPEN_TRAILING_SLASH_BUG): Likewise. * m4/poll.m4 (gl_FUNC_POLL): Likewise. * m4/posix_spawn.m4 (gl_POSIX_SPAWN_WORKS): Likewise. * m4/pread.m4 (gl_FUNC_PREAD): Likewise. * m4/pselect.m4 (gl_FUNC_PSELECT): Likewise. * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Likewise. * m4/ptsname_r.m4 (gl_PREREQ_PTSNAME_R): Likewise. * m4/putenv.m4 (gl_FUNC_PUTENV): Likewise. * m4/pwrite.m4 (gl_FUNC_PWRITE): Likewise. * m4/rename.m4 (gl_FUNC_RENAME): Likewise. * m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise. * m4/rmdir.m4 (gl_FUNC_RMDIR): Likewise. * m4/select.m4 (gl_FUNC_SELECT): Likewise. * m4/setenv.m4 (gl_FUNC_UNSETENV): Likewise. * m4/strncat.m4 (gl_FUNC_STRNCAT): Likewise. * m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Likewise. * m4/unlink-busy.m4 (gl_FUNC_UNLINK_BUSY_TEXT): Likewise. * m4/unlink.m4 (gl_FUNC_UNLINK): Likewise. * m4/utimens.m4 (gl_UTIMENS): Likewise. * m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Likewise. * m4/utimes.m4 (gl_FUNC_UTIMES): Likewise. * m4/canonicalize.m4 (gl_CANONICALIZE_LGPL): On native Windows, don't test for getcwd. * m4/utime.m4 (gl_FUNC_UTIME): On native Windows, don't test for utime. * m4/wcsdup.m4 (gl_FUNC_WCSDUP): To test for wcsdup, use a test program with GL_MDA_DEFINES. * lib/c++defs.h (_GL_CXXALIAS_MDA): New macro. * lib/fcntl.in.h (creat, open): On native Windows, use the underscore- prefixed symbol. * lib/search.in.h (lfind, lsearch): Likewise. * lib/stdio.in.h (fcloseall, fdopen, fileno, getw, putw, tempnam): Likewise. * lib/stdlib.in.h (ecvt, fcvt, gcvt, mktemp, putenv): Likewise. * lib/string.in.h (memccpy, strdup): Likewise. * lib/sys_stat.in.h (chmod, umask): Likewise. * lib/time.in.h (tzset): Likewise. * lib/unistd.in.h (access, chdir, close, dup, dup2, execl, execle, execlp, execv, execve, execvp, execvpe, getcwd, getpid, isatty, lseek, read, rmdir, swab, unlink, write): Likewise. * lib/utime.in.h (utime): Likewise. * lib/wchar.in.h (wcsdup): Likewise. * lib/math.in.h (j0, j1, jn, y0, y1, yn): Likewise. (isfinite, isinf, isnan, signbit): On native Windows, don't define as an rpl_-prefixed macro. * lib/canonicalize-lgpl.c (__getcwd): On native Windows, use _getcwd. * lib/close.c (close_nothrow): On native Windows, use _close. * lib/creat.c (orig_creat): On native Windows, use _creat. * lib/dup.c (dup_nothrow): On native Windows, use _dup. * lib/dup2.c (dup2_nothrow): Use _dup2. * lib/fdopen.c (fdopen_nothrow): On native Windows, use _fdopen. * lib/getcwd-lgpl.c: On native Windows, use _getcwd. * lib/getcwd.c (getcwd_nothrow): Use _getcwd also on mingw. * lib/open.c (orig_open): On native Windows, use _open. * lib/read.c (read_nothrow): Use _read. * lib/rmdir.c: On native Windows, use _rmdir. * lib/unlink.c: On native Windows, use _unlink. * lib/write.c (write_nothrow): Use _write. * lib/sys_select.in.h (close): With clang, don't attach a warning on an undefined symbol. * lib/sys_socket.in.h (close): Likewise. * lib/sys_time.in.h (close): Likewise. * tests/test-spawn-pipe-child.c: On native Windows, use _fdopen. --- ChangeLog | 92 ++++++++++++++++++++++++ lib/c++defs.h | 10 +++ lib/canonicalize-lgpl.c | 4 +- lib/close.c | 8 ++- lib/creat.c | 4 ++ lib/dup.c | 8 ++- lib/dup2.c | 4 +- lib/fcntl.in.h | 18 +++++ lib/fdopen.c | 8 ++- lib/getcwd-lgpl.c | 4 ++ lib/getcwd.c | 2 +- lib/math.in.h | 40 +++++++++-- lib/open.c | 4 ++ lib/read.c | 4 +- lib/rmdir.c | 3 + lib/search.in.h | 11 +++ lib/stdio.in.h | 34 +++++++++ lib/stdlib.in.h | 29 ++++++++ lib/string.in.h | 15 ++++ lib/sys_select.in.h | 2 +- lib/sys_socket.in.h | 2 +- lib/sys_stat.in.h | 12 ++++ lib/sys_time.in.h | 2 +- lib/time.in.h | 9 +++ lib/unistd.in.h | 159 ++++++++++++++++++++++++++++++++++++++++++ lib/unlink.c | 3 + lib/utime.in.h | 9 +++ lib/wchar.in.h | 15 +++- lib/write.c | 4 +- m4/canonicalize.m4 | 13 +++- m4/chown.m4 | 12 ++-- m4/dup.m4 | 5 +- m4/dup2.m4 | 3 +- m4/fchdir.m4 | 35 +++++----- m4/fchmodat.m4 | 4 +- m4/fchownat.m4 | 4 +- m4/fcntl-o.m4 | 3 +- m4/fcntl.m4 | 3 +- m4/fdopen.m4 | 3 +- m4/fdopendir.m4 | 3 +- m4/fflush.m4 | 5 +- m4/fopen.m4 | 3 +- m4/freopen.m4 | 4 +- m4/futimens.m4 | 5 +- m4/getcwd-abort-bug.m4 | 3 +- m4/getcwd-path-max.m4 | 4 +- m4/getcwd.m4 | 8 ++- m4/getdtablesize.m4 | 19 ++--- m4/gnulib-common.m4 | 72 ++++++++++++++++++- m4/linkat.m4 | 4 +- m4/lseek.m4 | 5 +- m4/mkdir.m4 | 89 +++++++++++------------ m4/mkstemp.m4 | 5 +- m4/mktime.m4 | 4 +- m4/open-slash.m4 | 3 +- m4/poll.m4 | 3 +- m4/posix_spawn.m4 | 4 +- m4/pread.m4 | 4 +- m4/pselect.m4 | 5 +- m4/pthread_sigmask.m4 | 3 +- m4/ptsname_r.m4 | 4 +- m4/putenv.m4 | 62 ++++++++-------- m4/pwrite.m4 | 4 +- m4/rename.m4 | 4 +- m4/rmdir-errno.m4 | 3 +- m4/rmdir.m4 | 21 +++--- m4/select.m4 | 5 +- m4/setenv.m4 | 64 +++++++++-------- m4/strncat.m4 | 5 +- m4/ttyname_r.m4 | 4 +- m4/unlink-busy.m4 | 5 +- m4/unlink.m4 | 5 +- m4/utime.m4 | 30 ++++---- m4/utimens.m4 | 5 +- m4/utimensat.m4 | 5 +- m4/utimes.m4 | 3 +- m4/wcsdup.m4 | 24 ++++++- tests/test-spawn-pipe-child.c | 3 + 78 files changed, 873 insertions(+), 242 deletions(-) diff --git a/ChangeLog b/ChangeLog index d84d53f..9b08d6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,97 @@ 2020-08-15 Bruno Haible <br...@clisp.org> + Support compiling without -loldnames on native Windows. + * m4/gnulib-common.m4 (GL_MDA_DEFINES, _GL_MDA_DEFINES): New macros. + * m4/chown.m4 (AC_FUNC_CHOWN): In the test programs, use GL_MDA_DEFINES. + (gl_FUNC_CHOWN, gl_FUNC_CHOWN_FOLLOWS_SYMLINK): Likewise. + * m4/dup.m4 (gl_FUNC_DUP): Likewise. + * m4/dup2.m4 (gl_FUNC_DUP2): Likewise. + * m4/fchdir.m4 (gl_FUNC_FCHDIR): Likewise. + * m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Likewise. + * m4/fchownat.m4 (gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG): Likewise. + * m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Likewise. + * m4/fcntl.m4 (gl_FUNC_FCNTL): Likewise. + * m4/fdopen.m4 (gl_FUNC_FDOPEN): Likewise. + * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Likewise. + * m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise. + * m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Likewise. + * m4/freopen.m4 (gl_FUNC_FREOPEN): Likewise. + * m4/futimens.m4 (gl_FUNC_FUTIMENS): Likewise. + * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Likewise. + * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Likewise. + * m4/getcwd.m4 (gl_FUNC_GETCWD_NULL, gl_FUNC_GETCWD_SIGNATURE): + Likewise. + * m4/getdtablesize.m4 (gl_FUNC_GETDTABLESIZE): Likewise. + * m4/linkat.m4 (gl_FUNC_LINKAT): Likewise. + * m4/lseek.m4 (gl_FUNC_LSEEK): Likewise. + * m4/mkdir.m4 (gl_FUNC_MKDIR): Likewise. + * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Likewise. + * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Likewise. + * m4/open-slash.m4 (gl_OPEN_TRAILING_SLASH_BUG): Likewise. + * m4/poll.m4 (gl_FUNC_POLL): Likewise. + * m4/posix_spawn.m4 (gl_POSIX_SPAWN_WORKS): Likewise. + * m4/pread.m4 (gl_FUNC_PREAD): Likewise. + * m4/pselect.m4 (gl_FUNC_PSELECT): Likewise. + * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Likewise. + * m4/ptsname_r.m4 (gl_PREREQ_PTSNAME_R): Likewise. + * m4/putenv.m4 (gl_FUNC_PUTENV): Likewise. + * m4/pwrite.m4 (gl_FUNC_PWRITE): Likewise. + * m4/rename.m4 (gl_FUNC_RENAME): Likewise. + * m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise. + * m4/rmdir.m4 (gl_FUNC_RMDIR): Likewise. + * m4/select.m4 (gl_FUNC_SELECT): Likewise. + * m4/setenv.m4 (gl_FUNC_UNSETENV): Likewise. + * m4/strncat.m4 (gl_FUNC_STRNCAT): Likewise. + * m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Likewise. + * m4/unlink-busy.m4 (gl_FUNC_UNLINK_BUSY_TEXT): Likewise. + * m4/unlink.m4 (gl_FUNC_UNLINK): Likewise. + * m4/utimens.m4 (gl_UTIMENS): Likewise. + * m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Likewise. + * m4/utimes.m4 (gl_FUNC_UTIMES): Likewise. + * m4/canonicalize.m4 (gl_CANONICALIZE_LGPL): On native Windows, don't + test for getcwd. + * m4/utime.m4 (gl_FUNC_UTIME): On native Windows, don't test for utime. + * m4/wcsdup.m4 (gl_FUNC_WCSDUP): To test for wcsdup, use a test program + with GL_MDA_DEFINES. + * lib/c++defs.h (_GL_CXXALIAS_MDA): New macro. + * lib/fcntl.in.h (creat, open): On native Windows, use the underscore- + prefixed symbol. + * lib/search.in.h (lfind, lsearch): Likewise. + * lib/stdio.in.h (fcloseall, fdopen, fileno, getw, putw, tempnam): + Likewise. + * lib/stdlib.in.h (ecvt, fcvt, gcvt, mktemp, putenv): Likewise. + * lib/string.in.h (memccpy, strdup): Likewise. + * lib/sys_stat.in.h (chmod, umask): Likewise. + * lib/time.in.h (tzset): Likewise. + * lib/unistd.in.h (access, chdir, close, dup, dup2, execl, execle, + execlp, execv, execve, execvp, execvpe, getcwd, getpid, isatty, lseek, + read, rmdir, swab, unlink, write): Likewise. + * lib/utime.in.h (utime): Likewise. + * lib/wchar.in.h (wcsdup): Likewise. + * lib/math.in.h (j0, j1, jn, y0, y1, yn): Likewise. + (isfinite, isinf, isnan, signbit): On native Windows, don't define as an + rpl_-prefixed macro. + * lib/canonicalize-lgpl.c (__getcwd): On native Windows, use _getcwd. + * lib/close.c (close_nothrow): On native Windows, use _close. + * lib/creat.c (orig_creat): On native Windows, use _creat. + * lib/dup.c (dup_nothrow): On native Windows, use _dup. + * lib/dup2.c (dup2_nothrow): Use _dup2. + * lib/fdopen.c (fdopen_nothrow): On native Windows, use _fdopen. + * lib/getcwd-lgpl.c: On native Windows, use _getcwd. + * lib/getcwd.c (getcwd_nothrow): Use _getcwd also on mingw. + * lib/open.c (orig_open): On native Windows, use _open. + * lib/read.c (read_nothrow): Use _read. + * lib/rmdir.c: On native Windows, use _rmdir. + * lib/unlink.c: On native Windows, use _unlink. + * lib/write.c (write_nothrow): Use _write. + * lib/sys_select.in.h (close): With clang, don't attach a warning on an + undefined symbol. + * lib/sys_socket.in.h (close): Likewise. + * lib/sys_time.in.h (close): Likewise. + * tests/test-spawn-pipe-child.c: On native Windows, use _fdopen. + +2020-08-15 Bruno Haible <br...@clisp.org> + Fix "unknown pragma ignored" warnings with clang on native Windows. * lib/cbrt.c: Don't use '#pragma fenv_access (off)' with clang. * lib/cbrtf.c: Likewise. diff --git a/lib/c++defs.h b/lib/c++defs.h index cd56ea2..de956d2 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 9f99098..0b89d2a 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/close.c b/lib/close.c index 0c8780d..32503c0 100644 --- a/lib/close.c +++ b/lib/close.c @@ -28,7 +28,8 @@ #undef close -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +#if defined _WIN32 && !defined __CYGWIN__ +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER static int close_nothrow (int fd) { @@ -36,7 +37,7 @@ close_nothrow (int fd) TRY_MSVC_INVAL { - result = close (fd); + result = _close (fd); } CATCH_MSVC_INVAL { @@ -47,6 +48,9 @@ close_nothrow (int fd) return result; } +# else +# define close_nothrow _close +# endif #else # define close_nothrow close #endif diff --git a/lib/creat.c b/lib/creat.c index dcab4aa..a530828 100644 --- a/lib/creat.c +++ b/lib/creat.c @@ -28,7 +28,11 @@ static int orig_creat (const char *filename, mode_t mode) { +#if defined _WIN32 && !defined __CYGWIN__ + return _creat (filename, mode); +#else return creat (filename, mode); +#endif } /* Specification. */ diff --git a/lib/dup.c b/lib/dup.c index 974d446..0e38348 100644 --- a/lib/dup.c +++ b/lib/dup.c @@ -28,7 +28,8 @@ #undef dup -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +#if defined _WIN32 && !defined __CYGWIN__ +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER static int dup_nothrow (int fd) { @@ -36,7 +37,7 @@ dup_nothrow (int fd) TRY_MSVC_INVAL { - result = dup (fd); + result = _dup (fd); } CATCH_MSVC_INVAL { @@ -47,6 +48,9 @@ dup_nothrow (int fd) return result; } +# else +# define dup_nothrow _dup +# endif #elif defined __KLIBC__ # include <fcntl.h> # include <sys/stat.h> diff --git a/lib/dup2.c b/lib/dup2.c index 9bc3951..323e19b 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 0a21c95..6f16bc6 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/fdopen.c b/lib/fdopen.c index b0f13fa..16ee607 100644 --- a/lib/fdopen.c +++ b/lib/fdopen.c @@ -27,7 +27,8 @@ #undef fdopen -#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +#if defined _WIN32 && !defined __CYGWIN__ +# if HAVE_MSVC_INVALID_PARAMETER_HANDLER static FILE * fdopen_nothrow (int fd, const char *mode) { @@ -35,7 +36,7 @@ fdopen_nothrow (int fd, const char *mode) TRY_MSVC_INVAL { - result = fdopen (fd, mode); + result = _fdopen (fd, mode); } CATCH_MSVC_INVAL { @@ -45,6 +46,9 @@ fdopen_nothrow (int fd, const char *mode) return result; } +# else +# define fdopen_nothrow _fdopen +# endif #else # define fdopen_nothrow fdopen #endif diff --git a/lib/getcwd-lgpl.c b/lib/getcwd-lgpl.c index fca6bde..90cfa0f 100644 --- a/lib/getcwd-lgpl.c +++ b/lib/getcwd-lgpl.c @@ -38,6 +38,10 @@ typedef int dummy; necessary. */ # undef getcwd +# if defined _WIN32 && !defined __CYGWIN__ +# define getcwd _getcwd +# endif + char * rpl_getcwd (char *buf, size_t size) { diff --git a/lib/getcwd.c b/lib/getcwd.c index 1a42ef1..07c7927 100644 --- a/lib/getcwd.c +++ b/lib/getcwd.c @@ -104,7 +104,7 @@ # undef closedir #endif -#ifdef _MSC_VER +#if defined _WIN32 && !defined __CYGWIN__ # if HAVE_MSVC_INVALID_PARAMETER_HANDLER static char * getcwd_nothrow (char *buf, size_t size) diff --git a/lib/math.in.h b/lib/math.in.h index 4654a46..5dd162e 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -1293,6 +1293,22 @@ _GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - " #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef j0 +# define j0 _j0 +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef j1 +# define j1 _j1 +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef jn +# define jn _jn +#endif + + /* Return x * 2^exp. */ #if @GNULIB_LDEXPF@ # if !@HAVE_LDEXPF@ @@ -2241,6 +2257,22 @@ _GL_WARN_ON_USE (truncl, "truncl is unportable - " #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef y0 +# define y0 _y0 +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef y1 +# define y1 _y1 +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef yn +# define yn _yn +#endif + + /* Definitions of function-like macros come here, after the function declarations. */ @@ -2260,7 +2292,7 @@ _GL_EXTERN_C int gl_isfinitel (long double x); # if defined isfinite || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) # undef isfinite -# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined _AIX)) +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__))) /* This platform's <cmath> possibly defines isfinite through a set of inline functions. */ _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool) @@ -2294,7 +2326,7 @@ _GL_EXTERN_C int gl_isinfl (long double x); # if defined isinf || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) # undef isinf -# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__)) +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || (defined _WIN32 && !defined __CYGWIN__))) /* This platform's <cmath> possibly defines isinf through a set of inline functions. */ _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, rpl_isinf, bool) @@ -2421,7 +2453,7 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; # if defined isnan || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) # undef isnan -# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__)) +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || (defined _WIN32 && !defined __CYGWIN__))) /* This platform's <cmath> possibly defines isnan through a set of inline functions. */ _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool) @@ -2504,7 +2536,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg); # if defined signbit || defined GNULIB_NAMESPACE _GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) # undef signbit -# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined _AIX)) +# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__))) /* This platform's <cmath> possibly defines signbit through a set of inline functions. */ _GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool) diff --git a/lib/open.c b/lib/open.c index 751b42d..0f7c6e9 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/read.c b/lib/read.c index 90d1053..0fc60ea 100644 --- a/lib/read.c +++ b/lib/read.c @@ -51,7 +51,7 @@ read_nothrow (int fd, void *buf, size_t count) TRY_MSVC_INVAL { - result = read (fd, buf, count); + result = _read (fd, buf, count); } CATCH_MSVC_INVAL { @@ -63,7 +63,7 @@ read_nothrow (int fd, void *buf, size_t count) return result; } # else -# define read_nothrow read +# define read_nothrow _read # endif ssize_t diff --git a/lib/rmdir.c b/lib/rmdir.c index 2155224..18c386b 100644 --- a/lib/rmdir.c +++ b/lib/rmdir.c @@ -26,6 +26,9 @@ #include "filename.h" #undef rmdir +#if defined _WIN32 && !defined __CYGWIN__ +# define rmdir _rmdir +#endif /* Remove directory DIR. Return 0 if successful, -1 if not. */ diff --git a/lib/search.in.h b/lib/search.in.h index 61116ed..d991dc7 100644 --- a/lib/search.in.h +++ b/lib/search.in.h @@ -38,6 +38,17 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ +#if defined _WIN32 && !defined __CYGWIN__ +# undef lfind +# define lfind _lfind +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef lsearch +# define lsearch _lsearch +#endif + + #if @GNULIB_TSEARCH@ # if @REPLACE_TSEARCH@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) diff --git a/lib/stdio.in.h b/lib/stdio.in.h index f050e10..7308f40 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 @@ -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) @@ -1214,6 +1243,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) diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 5c598a2..47a1309 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/string.in.h b/lib/string.in.h index 34b64cb..4c88a37 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 40212d2..90bd540 100644 --- a/lib/sys_select.in.h +++ b/lib/sys_select.in.h @@ -177,7 +177,7 @@ 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 diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h index 577947d..813fb3b 100644 --- a/lib/sys_socket.in.h +++ b/lib/sys_socket.in.h @@ -256,7 +256,7 @@ 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 diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index c1618a6..68b9cf4 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) @@ -800,6 +806,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 65fa753..712b989 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 7ad7d00..3b539c2 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -135,10 +135,19 @@ _GL_CXXALIASWARN (nanosleep); # endif _GL_FUNCDECL_RPL (tzset, void, (void)); _GL_CXXALIAS_RPL (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/unistd.in.h b/lib/unistd.in.h index 3a49813..efe237f 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/unlink.c b/lib/unlink.c index 35463fd..ba5f626 100644 --- a/lib/unlink.c +++ b/lib/unlink.c @@ -27,6 +27,9 @@ #include "filename.h" #undef unlink +#if defined _WIN32 && !defined __CYGWIN__ +# define unlink _unlink +#endif /* Remove file NAME. Return 0 if successful, -1 if not. */ diff --git a/lib/utime.in.h b/lib/utime.in.h index 8ae44ed..923826e 100644 --- a/lib/utime.in.h +++ b/lib/utime.in.h @@ -62,6 +62,12 @@ _GL_FUNCDECL_RPL (utime, int, (const char *filename, const struct utimbuf *ts) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (utime, int, (const char *filename, const struct utimbuf *ts)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef utime +# define utime _utime +# endif +_GL_CXXALIAS_MDA (utime, int, (const char *filename, const struct utimbuf *ts)); # else # if !@HAVE_UTIME@ _GL_FUNCDECL_SYS (utime, int, (const char *filename, const struct utimbuf *ts) @@ -77,6 +83,9 @@ _GL_WARN_ON_USE (utime, "utime is unportable - " "use gnulib module canonicalize-lgpl for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef utime +# define utime _utime #endif #if @GNULIB_UTIME@ diff --git a/lib/wchar.in.h b/lib/wchar.in.h index e524533..d09c2cb 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -942,10 +942,18 @@ _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - " /* Duplicate S, returning an identical malloc'd string. */ #if @GNULIB_WCSDUP@ -# if !@HAVE_WCSDUP@ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef wcsdup +# define wcsdup _wcsdup +# endif +_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); +# else +# if !@HAVE_WCSDUP@ _GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s)); -# endif +# endif _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); +# endif _GL_CXXALIASWARN (wcsdup); #elif defined GNULIB_POSIXCHECK # undef wcsdup @@ -953,6 +961,9 @@ _GL_CXXALIASWARN (wcsdup); _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " "use gnulib module wcsdup for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef wcsdup +# define wcsdup _wcsdup #endif diff --git a/lib/write.c b/lib/write.c index 581e674..deafb2a 100644 --- a/lib/write.c +++ b/lib/write.c @@ -57,7 +57,7 @@ write_nothrow (int fd, const void *buf, size_t count) TRY_MSVC_INVAL { - result = write (fd, buf, count); + result = _write (fd, buf, count); } CATCH_MSVC_INVAL { @@ -69,7 +69,7 @@ write_nothrow (int fd, const void *buf, size_t count) return result; } # else -# define write_nothrow write +# define write_nothrow _write # endif ssize_t diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index bdc5c8f..de64cf7 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,4 +1,4 @@ -# canonicalize.m4 serial 31 +# canonicalize.m4 serial 32 dnl Copyright (C) 2003-2007, 2009-2020 Free Software Foundation, Inc. @@ -56,7 +56,16 @@ AC_DEFUN([gl_CANONICALIZE_LGPL], AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([canonicalize_file_name getcwd readlink]) + AC_CHECK_FUNCS_ONCE([canonicalize_file_name readlink]) + + dnl On native Windows, we use _getcwd(), regardless whether getcwd() is + dnl available through the linker option '-loldnames'. + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) ;; + *) AC_CHECK_FUNCS([getcwd]) ;; + esac + AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) AC_REQUIRE([gl_FUNC_REALPATH_WORKS]) AC_CHECK_HEADERS_ONCE([sys/param.h]) diff --git a/m4/chown.m4 b/m4/chown.m4 index 3638187..e287503 100644 --- a/m4/chown.m4 +++ b/m4/chown.m4 @@ -1,4 +1,4 @@ -# serial 34 +# serial 35 # Determine whether we need the chown wrapper. dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009-2020 Free Software @@ -27,7 +27,7 @@ AC_DEFUN([AC_FUNC_CHOWN], [AC_LANG_PROGRAM( [AC_INCLUDES_DEFAULT [#include <fcntl.h> - ]], + ]GL_MDA_DEFINES], [[ char *f = "conftest.chown"; struct stat before, after; @@ -104,7 +104,8 @@ AC_DEFUN_ONCE([gl_FUNC_CHOWN], #include <unistd.h> #include <stdlib.h> #include <errno.h> -]], [[ if (symlink ("conftest.file", "conftest.link")) return 1; +]GL_MDA_DEFINES], + [[if (symlink ("conftest.file", "conftest.link")) return 1; if (chown ("conftest.link/", getuid (), getgid ()) == 0) return 2; ]])], [gl_cv_func_chown_slash_works=yes], @@ -137,7 +138,8 @@ AC_DEFUN_ONCE([gl_FUNC_CHOWN], #include <errno.h> #include <fcntl.h> #include <sys/stat.h> -]], [[ struct stat st1, st2; +]GL_MDA_DEFINES], + [[struct stat st1, st2; if (close (creat ("conftest.file", 0600))) return 1; if (stat ("conftest.file", &st1)) return 2; sleep (1); @@ -179,7 +181,7 @@ AC_DEFUN_ONCE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK], #include <unistd.h> #include <stdlib.h> #include <errno.h> - +]GL_MDA_DEFINES[ int main () { diff --git a/m4/dup.m4 b/m4/dup.m4 index 1bf0234..892de99 100644 --- a/m4/dup.m4 +++ b/m4/dup.m4 @@ -1,4 +1,4 @@ -# dup.m4 serial 6 +# dup.m4 serial 7 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -26,7 +26,8 @@ AC_DEFUN([gl_FUNC_DUP], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([[#include <unistd.h> #include <fcntl.h> - #include <errno.h>]], + #include <errno.h> + ]GL_MDA_DEFINES], [[/* On OS/2 kLIBC, dup does not work on a directory fd. */ int fd = open (".", O_RDONLY); return fd < 0 ? 1 : dup (fd) < 0 ? 2 : 0; diff --git a/m4/dup2.m4 b/m4/dup2.m4 index 462bfd0..a82798d 100644 --- a/m4/dup2.m4 +++ b/m4/dup2.m4 @@ -1,4 +1,4 @@ -#serial 26 +#serial 27 dnl Copyright (C) 2002, 2005, 2007, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -16,6 +16,7 @@ AC_DEFUN([gl_FUNC_DUP2], #include <limits.h> #include <sys/resource.h> #include <unistd.h> + ]GL_MDA_DEFINES[ #ifndef RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY #endif diff --git a/m4/fchdir.m4 b/m4/fchdir.m4 index dc2ba25..8e894e0 100644 --- a/m4/fchdir.m4 +++ b/m4/fchdir.m4 @@ -1,4 +1,4 @@ -# fchdir.m4 serial 25 +# fchdir.m4 serial 26 dnl Copyright (C) 2006-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -26,21 +26,24 @@ AC_DEFUN([gl_FUNC_FCHDIR], dnl fstatat, since no platform has fstatat but lacks fchdir. AC_CACHE_CHECK([whether open can visit directories], [gl_cv_func_open_directory_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h> -]], [return open(".", O_RDONLY) < 0;])], - [gl_cv_func_open_directory_works=yes], - [gl_cv_func_open_directory_works=no], - [case "$host_os" in - # Guess yes on Linux systems. - linux-* | linux) gl_cv_func_open_directory_works="guessing yes" ;; - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_open_directory_works="guessing yes" ;; - # Guess no on native Windows. - mingw*) gl_cv_func_open_directory_works="guessing no" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_open_directory_works="$gl_cross_guess_normal" ;; - esac - ])]) + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include <fcntl.h> + ]GL_MDA_DEFINES], + [[return open(".", O_RDONLY) < 0;]])], + [gl_cv_func_open_directory_works=yes], + [gl_cv_func_open_directory_works=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_open_directory_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_open_directory_works="guessing yes" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_open_directory_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_open_directory_works="$gl_cross_guess_normal" ;; + esac + ])]) case "$gl_cv_func_open_directory_works" in *yes) ;; *) diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4 index e3f2f04..cf5c879 100644 --- a/m4/fchmodat.m4 +++ b/m4/fchmodat.m4 @@ -1,4 +1,4 @@ -# fchmodat.m4 serial 4 +# fchmodat.m4 serial 5 dnl Copyright (C) 2004-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -40,7 +40,7 @@ AC_DEFUN([gl_FUNC_FCHMODAT], #ifndef S_IRWXO #define S_IRWXO 0007 #endif - ]], + ]GL_MDA_DEFINES], [[ int permissive = S_IRWXU | S_IRWXG | S_IRWXO; int desired = S_IRUSR | S_IWUSR; diff --git a/m4/fchownat.m4 b/m4/fchownat.m4 index 0a5d637..ea49906 100644 --- a/m4/fchownat.m4 +++ b/m4/fchownat.m4 @@ -1,4 +1,4 @@ -# fchownat.m4 serial 6 +# fchownat.m4 serial 7 dnl Copyright (C) 2004-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -90,7 +90,7 @@ AC_DEFUN([gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG], #include <fcntl.h> /* Android 4.3 declares fchownat() in <sys/stat.h> instead. */ #include <sys/stat.h> - ]], + ]GL_MDA_DEFINES], [[int fd; int ret; if (mkdir ("conftestdir", 0700) < 0) diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4 index 747b865..3ef061d 100644 --- a/m4/fcntl-o.m4 +++ b/m4/fcntl-o.m4 @@ -1,4 +1,4 @@ -# fcntl-o.m4 serial 6 +# fcntl-o.m4 serial 7 dnl Copyright (C) 2006, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,6 +32,7 @@ AC_DEFUN([gl_FCNTL_O_FLAGS], # defined sleep(n) _sleep ((n) * 1000) #endif #include <fcntl.h> + ]GL_MDA_DEFINES[ #ifndef O_NOATIME #define O_NOATIME 0 #endif diff --git a/m4/fcntl.m4 b/m4/fcntl.m4 index 562ae23..ea24f3d 100644 --- a/m4/fcntl.m4 +++ b/m4/fcntl.m4 @@ -1,4 +1,4 @@ -# fcntl.m4 serial 9 +# fcntl.m4 serial 10 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -34,6 +34,7 @@ AC_DEFUN([gl_FUNC_FCNTL], #include <limits.h> #include <sys/resource.h> #include <unistd.h> + ]GL_MDA_DEFINES[ #ifndef RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY #endif diff --git a/m4/fdopen.m4 b/m4/fdopen.m4 index b1909db..f4d4425 100644 --- a/m4/fdopen.m4 +++ b/m4/fdopen.m4 @@ -1,4 +1,4 @@ -# fdopen.m4 serial 4 +# fdopen.m4 serial 5 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -22,6 +22,7 @@ AC_DEFUN([gl_FUNC_FDOPEN], [AC_LANG_SOURCE([[ #include <stdio.h> #include <errno.h> +]GL_MDA_DEFINES[ int main (void) { diff --git a/m4/fdopendir.m4 b/m4/fdopendir.m4 index d9cc1a0..454e9ad 100644 --- a/m4/fdopendir.m4 +++ b/m4/fdopendir.m4 @@ -1,4 +1,4 @@ -# serial 12 +# serial 13 # See if we need to provide fdopendir. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -29,6 +29,7 @@ AC_DEFUN([gl_FUNC_FDOPENDIR], #include <dirent.h> #include <fcntl.h> #include <unistd.h> +]GL_MDA_DEFINES[ #if !HAVE_DECL_FDOPENDIR extern # ifdef __cplusplus diff --git a/m4/fflush.m4 b/m4/fflush.m4 index 620d1a7..8f63c25 100644 --- a/m4/fflush.m4 +++ b/m4/fflush.m4 @@ -1,4 +1,4 @@ -# fflush.m4 serial 17 +# fflush.m4 serial 18 # Copyright (C) 2007-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -38,7 +38,8 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN], #else /* on Windows with MSVC */ # include <io.h> #endif - ]], [[FILE *f = fopen ("conftest.txt", "r"); + ]GL_MDA_DEFINES], + [[FILE *f = fopen ("conftest.txt", "r"); char buffer[10]; int fd; int c; diff --git a/m4/fopen.m4 b/m4/fopen.m4 index 8eab4a6..a5d687a 100644 --- a/m4/fopen.m4 +++ b/m4/fopen.m4 @@ -1,4 +1,4 @@ -# fopen.m4 serial 11 +# fopen.m4 serial 12 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -104,6 +104,7 @@ int main () #include <stdio.h> #include <errno.h> #include <fcntl.h> +]GL_MDA_DEFINES[ int main () { FILE *fp = fopen ("conftest.x", "re"); diff --git a/m4/freopen.m4 b/m4/freopen.m4 index c088aad..24235aa 100644 --- a/m4/freopen.m4 +++ b/m4/freopen.m4 @@ -1,4 +1,4 @@ -# freopen.m4 serial 6 +# freopen.m4 serial 7 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_FREOPEN], [AC_LANG_PROGRAM( [[#include <stdio.h> #include <unistd.h> - ]], + ]GL_MDA_DEFINES], [[close (0); return !(freopen ("/dev/null", "r", stdin) && getchar () == EOF diff --git a/m4/futimens.m4 b/m4/futimens.m4 index dc5cfa9..145b8ff 100644 --- a/m4/futimens.m4 +++ b/m4/futimens.m4 @@ -1,4 +1,4 @@ -# serial 8 +# serial 9 # See if we need to provide futimens replacement. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -24,7 +24,8 @@ AC_DEFUN([gl_FUNC_FUTIMENS], #include <sys/stat.h> #include <unistd.h> #include <errno.h> -]], [[struct timespec ts[2]; +]GL_MDA_DEFINES], + [[struct timespec ts[2]; int fd = creat ("conftest.file", 0600); struct stat st; if (fd < 0) return 1; diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4 index d89dddf..d50648d 100644 --- a/m4/getcwd-abort-bug.m4 +++ b/m4/getcwd-abort-bug.m4 @@ -1,4 +1,4 @@ -# serial 12 +# serial 13 # Determine whether getcwd aborts when the length of the working directory # name is unusually large. Any length between 4k and 16k trigger the bug # when using glibc-2.4.90-9 or older. @@ -45,6 +45,7 @@ AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG], #include <sys/stat.h> ]gl_PATHMAX_SNIPPET[ +]GL_MDA_DEFINES[ #ifndef S_IRWXU # define S_IRWXU 0700 diff --git a/m4/getcwd-path-max.m4 b/m4/getcwd-path-max.m4 index b0eea69..859c7de 100644 --- a/m4/getcwd-path-max.m4 +++ b/m4/getcwd-path-max.m4 @@ -1,4 +1,4 @@ -# serial 24 +# serial 25 # Check for several getcwd bugs with long file names. # If so, arrange to compile the wrapper function. @@ -55,6 +55,8 @@ AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX], /* Use the getcwd function, not any macro. */ #undef getcwd +]GL_MDA_DEFINES[ + #ifndef S_IRWXU # define S_IRWXU 0700 #endif diff --git a/m4/getcwd.m4 b/m4/getcwd.m4 index ba68c5f..a646b90 100644 --- a/m4/getcwd.m4 +++ b/m4/getcwd.m4 @@ -6,7 +6,7 @@ # with or without modifications, as long as this notice is preserved. # Written by Paul Eggert. -# serial 18 +# serial 19 AC_DEFUN([gl_FUNC_GETCWD_NULL], [ @@ -21,12 +21,13 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL], # else /* on Windows with MSVC */ # include <direct.h> # endif + ]GL_MDA_DEFINES[ # ifndef getcwd char *getcwd (); # endif ]], [[ #if defined _WIN32 && ! defined __CYGWIN__ -/* mingw cwd does not start with '/', but getcwd does allocate. +/* mingw cwd does not start with '/', but _getcwd does allocate. However, mingw fails to honor non-zero size. */ #else if (chdir ("/") != 0) @@ -66,7 +67,8 @@ AC_DEFUN([gl_FUNC_GETCWD_SIGNATURE], [gl_cv_func_getcwd_posix_signature], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#include <unistd.h>]], + [[#include <unistd.h> + ]GL_MDA_DEFINES], [[extern #ifdef __cplusplus "C" diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4 index ab2e3fe..af32864 100644 --- a/m4/getdtablesize.m4 +++ b/m4/getdtablesize.m4 @@ -1,4 +1,4 @@ -# getdtablesize.m4 serial 7 +# getdtablesize.m4 serial 8 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -29,13 +29,16 @@ AC_DEFUN([gl_FUNC_GETDTABLESIZE], dnl correctly require setrlimit before getdtablesize() can report dnl a larger value. AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[#include <unistd.h>]], - [int size = getdtablesize(); - if (dup2 (0, getdtablesize()) != -1) - return 1; - if (size != getdtablesize()) - return 2; - ])], + AC_LANG_PROGRAM( + [[#include <unistd.h>] + GL_MDA_DEFINES + ], + [[int size = getdtablesize(); + if (dup2 (0, getdtablesize()) != -1) + return 1; + if (size != getdtablesize()) + return 2; + ]])], [gl_cv_func_getdtablesize_works=yes], [gl_cv_func_getdtablesize_works=no], [case "$host_os" in diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 03da228..c7d1e34 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 55 +# gnulib-common.m4 serial 56 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -663,3 +663,73 @@ AC_DEFUN([gl_CACHE_VAL_SILENT], # AS_VAR_COPY was added in autoconf 2.63b m4_define_default([AS_VAR_COPY], [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])]) + +dnl Expands to some code for use in .c programs that, on native Windows, defines +dnl the Microsoft deprecated alias function names to the underscore-prefixed +dnl actual function names. With this macro, these function names are available +dnl without linking with '-loldnames' and without generating warnings. +dnl Usage: Use it after all system header files are included. +dnl #include <...> +dnl #include <...> +dnl ]GL_MDA_DEFINES[ +dnl ... +AC_DEFUN([GL_MDA_DEFINES],[ +AC_REQUIRE([_GL_MDA_DEFINES]) +[$gl_mda_defines] +]) +AC_DEFUN([_GL_MDA_DEFINES], +[gl_mda_defines=' +#if defined _WIN32 && !defined __CYGWIN__ +#define access _access +#define chdir _chdir +#define chmod _chmod +#define close _close +#define creat _creat +#define dup _dup +#define dup2 _dup2 +#define ecvt _ecvt +#define execl _execl +#define execle _execle +#define execlp _execlp +#define execv _execv +#define execve _execve +#define execvp _execvp +#define execvpe _execvpe +#define fcloseall _fcloseall +#define fcvt _fcvt +#define fdopen _fdopen +#define fileno _fileno +#define gcvt _gcvt +#define getcwd _getcwd +#define getpid _getpid +#define getw _getw +#define isatty _isatty +#define j0 _j0 +#define j1 _j1 +#define jn _jn +#define lfind _lfind +#define lsearch _lsearch +#define lseek _lseek +#define memccpy _memccpy +#define mkdir _mkdir +#define mktemp _mktemp +#define open _open +#define putenv _putenv +#define putw _putw +#define read _read +#define rmdir _rmdir +#define strdup _strdup +#define swab _swab +#define tempnam _tempnam +#define tzset _tzset +#define umask _umask +#define unlink _unlink +#define utime _utime +#define wcsdup _wcsdup +#define write _write +#define y0 _y0 +#define y1 _y1 +#define yn _yn +#endif +' +]) diff --git a/m4/linkat.m4 b/m4/linkat.m4 index 346e88e..de1bf28 100644 --- a/m4/linkat.m4 +++ b/m4/linkat.m4 @@ -1,4 +1,4 @@ -# serial 11 +# serial 12 # See if we need to provide linkat replacement. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -58,7 +58,7 @@ AC_DEFUN([gl_FUNC_LINKAT], #include <fcntl.h> #include <errno.h> #include <stdio.h> - ]], + ]GL_MDA_DEFINES], [[int result; int fd; /* Create a regular file. */ diff --git a/m4/lseek.m4 b/m4/lseek.m4 index 609c19a..472a1cb 100644 --- a/m4/lseek.m4 +++ b/m4/lseek.m4 @@ -1,4 +1,4 @@ -# lseek.m4 serial 10 +# lseek.m4 serial 11 dnl Copyright (C) 2007, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -32,7 +32,8 @@ AC_DEFUN([gl_FUNC_LSEEK], #else /* on Windows with MSVC */ # include <io.h> #endif -]], [[ +]GL_MDA_DEFINES], +[[ /* Exit with success only if stdin is seekable. */ return lseek (0, (off_t)0, SEEK_CUR) < 0; ]])], diff --git a/m4/mkdir.m4 b/m4/mkdir.m4 index 99212d9..bd9e088 100644 --- a/m4/mkdir.m4 +++ b/m4/mkdir.m4 @@ -1,4 +1,4 @@ -# serial 16 +# serial 17 # Copyright (C) 2001, 2003-2004, 2006, 2008-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -16,33 +16,34 @@ AC_DEFUN([gl_FUNC_MKDIR], AC_CACHE_CHECK([whether mkdir handles trailing slash], [gl_cv_func_mkdir_trailing_slash_works], [rm -rf conftest.dir - AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -# include <sys/types.h> -# include <sys/stat.h> -]], [return mkdir ("conftest.dir/", 0700);])], - [gl_cv_func_mkdir_trailing_slash_works=yes], - [gl_cv_func_mkdir_trailing_slash_works=no], - [case "$host_os" in - # Guess yes on Linux systems. - linux-* | linux) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; - # Guess yes on MSVC, no on mingw. - mingw*) AC_EGREP_CPP([Known], [ + AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #include <sys/types.h> + #include <sys/stat.h> + ]GL_MDA_DEFINES], + [[return mkdir ("conftest.dir/", 0700);]])], + [gl_cv_func_mkdir_trailing_slash_works=yes], + [gl_cv_func_mkdir_trailing_slash_works=no], + [case "$host_os" in + # Guess yes on Linux systems. + linux-* | linux) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;; + # Guess yes on MSVC, no on mingw. + mingw*) AC_EGREP_CPP([Known], [ #ifdef _MSC_VER Known #endif - ], - [gl_cv_func_mkdir_trailing_slash_works="guessing yes"], - [gl_cv_func_mkdir_trailing_slash_works="guessing no"]) - ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_mkdir_trailing_slash_works="$gl_cross_guess_normal" ;; - esac - ]) - rm -rf conftest.dir - ] - ) + ], + [gl_cv_func_mkdir_trailing_slash_works="guessing yes"], + [gl_cv_func_mkdir_trailing_slash_works="guessing no"]) + ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_mkdir_trailing_slash_works="$gl_cross_guess_normal" ;; + esac + ]) + rm -rf conftest.dir + ]) case "$gl_cv_func_mkdir_trailing_slash_works" in *yes) ;; *) @@ -53,24 +54,26 @@ AC_DEFUN([gl_FUNC_MKDIR], AC_CACHE_CHECK([whether mkdir handles trailing dot], [gl_cv_func_mkdir_trailing_dot_works], [rm -rf conftest.dir - AC_RUN_IFELSE([AC_LANG_PROGRAM([[ -# include <sys/types.h> -# include <sys/stat.h> -]], [return !mkdir ("conftest.dir/./", 0700);])], - [gl_cv_func_mkdir_trailing_dot_works=yes], - [gl_cv_func_mkdir_trailing_dot_works=no], - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; - # Guess no on native Windows. - mingw*) gl_cv_func_mkdir_trailing_dot_works="guessing no" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_mkdir_trailing_dot_works="$gl_cross_guess_normal" ;; - esac - ]) - rm -rf conftest.dir + AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #include <sys/types.h> + #include <sys/stat.h> + ]GL_MDA_DEFINES], + [[return !mkdir ("conftest.dir/./", 0700);]])], + [gl_cv_func_mkdir_trailing_dot_works=yes], + [gl_cv_func_mkdir_trailing_dot_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_mkdir_trailing_dot_works="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_mkdir_trailing_dot_works="$gl_cross_guess_normal" ;; + esac + ]) + rm -rf conftest.dir ] ) case "$gl_cv_func_mkdir_trailing_dot_works" in diff --git a/m4/mkstemp.m4 b/m4/mkstemp.m4 index 28b7889..392f97c 100644 --- a/m4/mkstemp.m4 +++ b/m4/mkstemp.m4 @@ -1,4 +1,4 @@ -#serial 27 +#serial 28 # Copyright (C) 2001, 2003-2007, 2009-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -26,7 +26,8 @@ AC_DEFUN([gl_FUNC_MKSTEMP], mkdir conftest.mkstemp AC_RUN_IFELSE( [AC_LANG_PROGRAM( - [AC_INCLUDES_DEFAULT], + [AC_INCLUDES_DEFAULT + GL_MDA_DEFINES], [[int result = 0; int i; off_t large = (off_t) 4294967295u; diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 917e759..4e7e423 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,4 +1,4 @@ -# serial 34 +# serial 35 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2020 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -54,6 +54,8 @@ AC_DEFUN([gl_FUNC_MKTIME_WORKS], # include <signal.h> #endif +]GL_MDA_DEFINES[ + #ifndef TIME_T_IS_SIGNED # define TIME_T_IS_SIGNED 0 #endif diff --git a/m4/open-slash.m4 b/m4/open-slash.m4 index 1e57c96..5d84f2b 100644 --- a/m4/open-slash.m4 +++ b/m4/open-slash.m4 @@ -1,4 +1,4 @@ -# open-slash.m4 serial 1 +# open-slash.m4 serial 2 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -25,6 +25,7 @@ AC_DEFUN([gl_OPEN_TRAILING_SLASH_BUG], #if HAVE_UNISTD_H # include <unistd.h> #endif +]GL_MDA_DEFINES[ int main () { int result = 0; diff --git a/m4/poll.m4 b/m4/poll.m4 index b47f2c3..1a720d6 100644 --- a/m4/poll.m4 +++ b/m4/poll.m4 @@ -1,4 +1,4 @@ -# poll.m4 serial 19 +# poll.m4 serial 20 dnl Copyright (c) 2003, 2005-2007, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,6 +19,7 @@ AC_DEFUN([gl_FUNC_POLL], AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <fcntl.h> #include <poll.h> +]GL_MDA_DEFINES[ int main() { int result = 0; diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4 index e97be55..625b2ad 100644 --- a/m4/posix_spawn.m4 +++ b/m4/posix_spawn.m4 @@ -1,4 +1,4 @@ -# posix_spawn.m4 serial 17 +# posix_spawn.m4 serial 18 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -123,6 +123,7 @@ AC_DEFUN([gl_POSIX_SPAWN_WORKS], #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> +]GL_MDA_DEFINES[ extern char **environ; @@ -266,6 +267,7 @@ main () #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> +]GL_MDA_DEFINES[ extern char **environ; diff --git a/m4/pread.m4 b/m4/pread.m4 index 6b31fba..9e43dd6 100644 --- a/m4/pread.m4 +++ b/m4/pread.m4 @@ -1,4 +1,4 @@ -# pread.m4 serial 5 +# pread.m4 serial 6 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -37,7 +37,7 @@ changequote([,])dnl #include <unistd.h> #include <fcntl.h> #include <stdio.h> - ]], + ]GL_MDA_DEFINES], [[ { int result = 0; diff --git a/m4/pselect.m4 b/m4/pselect.m4 index f3e5afe..08a5823 100644 --- a/m4/pselect.m4 +++ b/m4/pselect.m4 @@ -1,4 +1,4 @@ -# pselect.m4 serial 8 +# pselect.m4 serial 9 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -37,7 +37,8 @@ AC_DEFUN([gl_FUNC_PSELECT], #endif #include <unistd.h> #include <errno.h> -]],[[ +]GL_MDA_DEFINES], +[[ fd_set set; dup2(0, 16); FD_ZERO(&set); diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index d67511f..030862d 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 18 +# pthread_sigmask.m4 serial 19 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -220,6 +220,7 @@ int main () #include <stdio.h> #include <stdlib.h> #include <unistd.h> +]GL_MDA_DEFINES[ static volatile int sigint_occurred; static void sigint_handler (int sig) diff --git a/m4/ptsname_r.m4 b/m4/ptsname_r.m4 index 181bfa1..b77fd73 100644 --- a/m4/ptsname_r.m4 +++ b/m4/ptsname_r.m4 @@ -1,4 +1,4 @@ -# ptsname_r.m4 serial 6 +# ptsname_r.m4 serial 7 dnl Copyright (C) 2010-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -90,7 +90,7 @@ AC_DEFUN([gl_PREREQ_PTSNAME_R], [ #else # include <unistd.h> #endif - ]], + ]GL_MDA_DEFINES], [[errno = 0; isatty (-1); return errno == 0; diff --git a/m4/putenv.m4 b/m4/putenv.m4 index e38f8c5..3799fb5 100644 --- a/m4/putenv.m4 +++ b/m4/putenv.m4 @@ -1,4 +1,4 @@ -# putenv.m4 serial 24 +# putenv.m4 serial 25 dnl Copyright (C) 2002-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -14,37 +14,41 @@ AC_DEFUN([gl_FUNC_PUTENV], AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([for putenv compatible with GNU and SVID], - [gl_cv_func_svid_putenv], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[ - /* Put it in env. */ - if (putenv ("CONFTEST_putenv=val")) - return 1; + [gl_cv_func_svid_putenv], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT + GL_MDA_DEFINES], + [[ + /* Put it in env. */ + if (putenv ("CONFTEST_putenv=val")) + return 1; - /* Try to remove it. */ - if (putenv ("CONFTEST_putenv")) - return 2; + /* Try to remove it. */ + if (putenv ("CONFTEST_putenv")) + return 2; - /* Make sure it was deleted. */ - if (getenv ("CONFTEST_putenv") != 0) - return 3; + /* Make sure it was deleted. */ + if (getenv ("CONFTEST_putenv") != 0) + return 3; - return 0; - ]])], - gl_cv_func_svid_putenv=yes, - gl_cv_func_svid_putenv=no, - dnl When crosscompiling, assume putenv is broken. - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;; - # Guess yes on musl systems. - *-musl*) gl_cv_func_svid_putenv="guessing yes" ;; - # Guess no on native Windows. - mingw*) gl_cv_func_svid_putenv="guessing no" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;; - esac - ]) - ]) + return 0; + ]])], + [gl_cv_func_svid_putenv=yes], + [gl_cv_func_svid_putenv=no], + [dnl When crosscompiling, assume putenv is broken. + case "$host_os" in + # Guess yes on glibc systems. + *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;; + # Guess yes on musl systems. + *-musl*) gl_cv_func_svid_putenv="guessing yes" ;; + # Guess no on native Windows. + mingw*) gl_cv_func_svid_putenv="guessing no" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;; + esac + ]) + ]) case "$gl_cv_func_svid_putenv" in *yes) ;; *) diff --git a/m4/pwrite.m4 b/m4/pwrite.m4 index f8b5dbc..4c75676 100644 --- a/m4/pwrite.m4 +++ b/m4/pwrite.m4 @@ -1,4 +1,4 @@ -# pwrite.m4 serial 5 +# pwrite.m4 serial 6 dnl Copyright (C) 2010-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -37,7 +37,7 @@ changequote([,])dnl #include <sys/types.h> #include <unistd.h> #include <fcntl.h> - ]], + ]GL_MDA_DEFINES], [[ { /* This test fails on HP-UX 11.00..11.11. */ diff --git a/m4/rename.m4 b/m4/rename.m4 index a1bd705..4c19f61 100644 --- a/m4/rename.m4 +++ b/m4/rename.m4 @@ -1,4 +1,4 @@ -# serial 32 +# serial 33 # Copyright (C) 2001, 2003, 2005-2006, 2009-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -150,7 +150,7 @@ AC_DEFUN([gl_FUNC_RENAME], # include <stdio.h> # include <stdlib.h> # include <unistd.h> - ]], + ]GL_MDA_DEFINES], [[int result = 0; if (rename ("conftest.f", "conftest.f1")) result |= 1; diff --git a/m4/rmdir-errno.m4 b/m4/rmdir-errno.m4 index d032062..6eb4f10 100644 --- a/m4/rmdir-errno.m4 +++ b/m4/rmdir-errno.m4 @@ -1,4 +1,4 @@ -# serial 13 +# serial 14 # Copyright (C) 2000-2001, 2005-2006, 2009-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -26,6 +26,7 @@ AC_DEFUN([gl_FUNC_RMDIR_NOTEMPTY], #ifdef HAVE_UNISTD_H # include <unistd.h> #endif +]GL_MDA_DEFINES[ int main () { FILE *s; diff --git a/m4/rmdir.m4 b/m4/rmdir.m4 index ad1b192..06aaf31 100644 --- a/m4/rmdir.m4 +++ b/m4/rmdir.m4 @@ -1,4 +1,4 @@ -# rmdir.m4 serial 17 +# rmdir.m4 serial 18 dnl Copyright (C) 2002, 2005, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -22,15 +22,16 @@ AC_DEFUN([gl_FUNC_RMDIR], #else /* on Windows with MSVC */ # include <direct.h> #endif -]], [[int result = 0; - if (!rmdir ("conftest.file/")) - result |= 1; - else if (errno != ENOTDIR) - result |= 2; - if (!rmdir ("conftest.dir/./")) - result |= 4; - return result; - ]])], + ]GL_MDA_DEFINES], + [[int result = 0; + if (!rmdir ("conftest.file/")) + result |= 1; + else if (errno != ENOTDIR) + result |= 2; + if (!rmdir ("conftest.dir/./")) + result |= 4; + return result; + ]])], [gl_cv_func_rmdir_works=yes], [gl_cv_func_rmdir_works=no], [case "$host_os" in # Guess yes on Linux systems. diff --git a/m4/select.m4 b/m4/select.m4 index d950460..90d2bb9 100644 --- a/m4/select.m4 +++ b/m4/select.m4 @@ -1,4 +1,4 @@ -# select.m4 serial 11 +# select.m4 serial 12 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -60,7 +60,8 @@ changequote([,])dnl #endif #include <unistd.h> #include <errno.h> -]],[[ +]GL_MDA_DEFINES], +[[ fd_set set; dup2(0, 16); FD_ZERO(&set); diff --git a/m4/setenv.m4 b/m4/setenv.m4 index ef03673..5dbf913 100644 --- a/m4/setenv.m4 +++ b/m4/setenv.m4 @@ -1,4 +1,4 @@ -# setenv.m4 serial 29 +# setenv.m4 serial 30 dnl Copyright (C) 2001-2004, 2006-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -106,35 +106,39 @@ int unsetenv (const char *name); dnl OpenBSD 4.7 unsetenv("") does not fail. AC_CACHE_CHECK([whether unsetenv obeys POSIX], [gl_cv_func_unsetenv_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ - #include <stdlib.h> - #include <errno.h> - extern char **environ; - ]], [[ - char entry1[] = "a=1"; - char entry2[] = "b=2"; - char *env[] = { entry1, entry2, NULL }; - if (putenv ((char *) "a=1")) return 1; - if (putenv (entry2)) return 2; - entry2[0] = 'a'; - unsetenv ("a"); - if (getenv ("a")) return 3; - if (!unsetenv ("") || errno != EINVAL) return 4; - entry2[0] = 'b'; - environ = env; - if (!getenv ("a")) return 5; - entry2[0] = 'a'; - unsetenv ("a"); - if (getenv ("a")) return 6; - ]])], - [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], - [case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; - # If we don't know, obey --enable-cross-guesses. - *) gl_cv_func_unsetenv_works="$gl_cross_guess_normal" ;; - esac - ])]) + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ + #include <stdlib.h> + #include <errno.h> + extern char **environ; + ]GL_MDA_DEFINES], + [[ + char entry1[] = "a=1"; + char entry2[] = "b=2"; + char *env[] = { entry1, entry2, NULL }; + if (putenv ((char *) "a=1")) return 1; + if (putenv (entry2)) return 2; + entry2[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 3; + if (!unsetenv ("") || errno != EINVAL) return 4; + entry2[0] = 'b'; + environ = env; + if (!getenv ("a")) return 5; + entry2[0] = 'a'; + unsetenv ("a"); + if (getenv ("a")) return 6; + ]])], + [gl_cv_func_unsetenv_works=yes], + [gl_cv_func_unsetenv_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; + # If we don't know, obey --enable-cross-guesses. + *) gl_cv_func_unsetenv_works="$gl_cross_guess_normal" ;; + esac + ]) + ]) case "$gl_cv_func_unsetenv_works" in *yes) ;; *) diff --git a/m4/strncat.m4 b/m4/strncat.m4 index b38ade6..16aefa6 100644 --- a/m4/strncat.m4 +++ b/m4/strncat.m4 @@ -1,4 +1,4 @@ -# strncat.m4 serial 4 +# strncat.m4 serial 5 dnl Copyright (C) 2002-2004, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -31,7 +31,8 @@ AC_DEFUN_ONCE([gl_FUNC_STRNCAT], # define MAP_FILE 0 # endif #endif -]], [[ +]GL_MDA_DEFINES], +[[ char *fence = NULL; #if HAVE_SYS_MMAN_H && HAVE_MPROTECT # if HAVE_MAP_ANONYMOUS diff --git a/m4/ttyname_r.m4 b/m4/ttyname_r.m4 index 80514d8..869edc8 100644 --- a/m4/ttyname_r.m4 +++ b/m4/ttyname_r.m4 @@ -1,4 +1,4 @@ -# ttyname_r.m4 serial 10 +# ttyname_r.m4 serial 11 dnl Copyright (C) 2010-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -57,6 +57,7 @@ AC_DEFUN([gl_FUNC_TTYNAME_R], [AC_LANG_SOURCE([[ #include <errno.h> #include <unistd.h> +]GL_MDA_DEFINES[ int main (void) { @@ -96,6 +97,7 @@ changequote([,])dnl [AC_LANG_SOURCE([[ #include <fcntl.h> #include <unistd.h> +]GL_MDA_DEFINES[ int main (void) { diff --git a/m4/unlink-busy.m4 b/m4/unlink-busy.m4 index 7bf6c91..7753f6a 100644 --- a/m4/unlink-busy.m4 +++ b/m4/unlink-busy.m4 @@ -1,4 +1,4 @@ -#serial 14 +#serial 15 dnl From J. David Anglin. @@ -16,7 +16,8 @@ AC_DEFUN([gl_FUNC_UNLINK_BUSY_TEXT], [ AC_RUN_IFELSE( [AC_LANG_SOURCE( - [AC_INCLUDES_DEFAULT[ + [AC_INCLUDES_DEFAULT + GL_MDA_DEFINES[ int main (int argc, char **argv) { diff --git a/m4/unlink.m4 b/m4/unlink.m4 index b0bb731..69d8ba5 100644 --- a/m4/unlink.m4 +++ b/m4/unlink.m4 @@ -1,4 +1,4 @@ -# unlink.m4 serial 14 +# unlink.m4 serial 15 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -26,7 +26,7 @@ AC_DEFUN([gl_FUNC_UNLINK], # include <io.h> #endif #include <errno.h> - ]], + ]GL_MDA_DEFINES], [[int result = 0; if (!unlink ("conftest.file/")) result |= 1; @@ -98,6 +98,7 @@ AC_DEFUN([gl_FUNC_UNLINK], # include <direct.h> # include <io.h> #endif + ]GL_MDA_DEFINES[ int main () { int result = 0; diff --git a/m4/utime.m4 b/m4/utime.m4 index 25d6243..f0a8235 100644 --- a/m4/utime.m4 +++ b/m4/utime.m4 @@ -1,4 +1,4 @@ -# utime.m4 serial 1 +# utime.m4 serial 2 dnl Copyright (C) 2017-2020 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,18 +8,22 @@ AC_DEFUN([gl_FUNC_UTIME], [ AC_REQUIRE([gl_UTIME_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CHECK_FUNCS_ONCE([utime]) - if test $ac_cv_func_utime = no; then - HAVE_UTIME=0 - else - case "$host_os" in - mingw*) - dnl On this platform, the original utime() or _utime() produces - dnl timestamps that are affected by the time zone. - REPLACE_UTIME=1 - ;; - esac - fi + case "$host_os" in + mingw*) + dnl On this platform, the original utime() or _utime() produces + dnl timestamps that are affected by the time zone. + dnl Use the function name 'rpl_utime' always, in order to avoid a + dnl possible conflict with the function name 'utime' from oldnames.lib + dnl (MSVC) or liboldnames.a (mingw). + REPLACE_UTIME=1 + ;; + *) + AC_CHECK_FUNCS([utime]) + if test $ac_cv_func_utime = no; then + HAVE_UTIME=0 + fi + ;; + esac ]) # Prerequisites of lib/utime.c. diff --git a/m4/utimens.m4 b/m4/utimens.m4 index 65617ac..3d31085 100644 --- a/m4/utimens.m4 +++ b/m4/utimens.m4 @@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl serial 10 +dnl serial 11 AC_DEFUN([gl_UTIMENS], [ @@ -24,7 +24,8 @@ AC_DEFUN([gl_UTIMENS], #include <stddef.h> #include <sys/times.h> #include <fcntl.h> -]], [[ int fd = open ("conftest.file", O_RDWR); +]GL_MDA_DEFINES], + [[int fd = open ("conftest.file", O_RDWR); if (fd < 0) return 1; if (futimesat (fd, NULL, NULL)) return 2; ]])], diff --git a/m4/utimensat.m4 b/m4/utimensat.m4 index 2bc1bfe..e9e4f26 100644 --- a/m4/utimensat.m4 +++ b/m4/utimensat.m4 @@ -1,4 +1,4 @@ -# serial 6 +# serial 7 # See if we need to provide utimensat replacement. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -23,7 +23,8 @@ AC_DEFUN([gl_FUNC_UTIMENSAT], #include <fcntl.h> #include <sys/stat.h> #include <unistd.h> -]], [[int result = 0; +]GL_MDA_DEFINES], + [[int result = 0; const char *f = "conftest.file"; if (close (creat (f, 0600))) return 1; diff --git a/m4/utimes.m4 b/m4/utimes.m4 index e1056bb..877bfd2 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -1,5 +1,5 @@ # Detect some bugs in glibc's implementation of utimes. -# serial 7 +# serial 8 dnl Copyright (C) 2003-2005, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -34,6 +34,7 @@ AC_DEFUN([gl_FUNC_UTIMES], #include <stdio.h> #include <utime.h> #include <errno.h> +]GL_MDA_DEFINES[ static int inorder (time_t a, time_t b, time_t c) diff --git a/m4/wcsdup.m4 b/m4/wcsdup.m4 index 662f65a..d0dde1c 100644 --- a/m4/wcsdup.m4 +++ b/m4/wcsdup.m4 @@ -1,4 +1,4 @@ -# wcsdup.m4 serial 2 +# wcsdup.m4 serial 3 dnl Copyright (C) 2011-2020 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,8 +7,26 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_WCSDUP], [ AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - AC_CHECK_FUNCS_ONCE([wcsdup]) - if test $ac_cv_func_wcsdup = no; then + AC_CACHE_CHECK([for wcsdup], + [gl_cv_func_wcsdup], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before + <wchar.h>. + BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included + before <wchar.h>. */ +#include <stddef.h> +#include <stdio.h> +#include <time.h> +#include <wchar.h> + ]GL_MDA_DEFINES], + [[return wcsdup (L"hello") != NULL;]]) + ], + [gl_cv_func_wcsdup=yes], + [gl_cv_func_wcsdup=no]) + ]) + if test $gl_cv_func_wcsdup = no; then HAVE_WCSDUP=0 fi ]) diff --git a/tests/test-spawn-pipe-child.c b/tests/test-spawn-pipe-child.c index 36abb83..2767d1e 100644 --- a/tests/test-spawn-pipe-child.c +++ b/tests/test-spawn-pipe-child.c @@ -48,6 +48,9 @@ static FILE *myerr; #undef fprintf #undef read #undef write +#if defined _WIN32 && !defined __CYGWIN__ +# define fdopen _fdopen +#endif /* Return non-zero if FD is open. */ static int -- 2.7.4