diff options
author | Bruno Haible <bruno@clisp.org> | 2020-08-15 16:54:17 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-08-15 16:54:17 +0200 |
commit | d4c637e577594532fb45781b4cac79c9a50a4c1e (patch) | |
tree | 58bf1f408907dd5a38248ea01d5632225dcf8e4f /m4 | |
parent | e6edf5094bd304779b3dc6a7948c56e002c4286c (diff) | |
download | gnulib-d4c637e577594532fb45781b4cac79c9a50a4c1e.tar.gz |
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.
Diffstat (limited to 'm4')
48 files changed, 374 insertions, 219 deletions
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index bdc5c8f71a..de64cf7ab0 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 3638187aac..e28750395d 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 () { @@ -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 462bfd0e52..a82798d6bb 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 dc2ba25183..8e894e05ca 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 e3f2f04816..cf5c87999c 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 0a5d637030..ea49906a54 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 747b865759..3ef061d848 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 562ae2395d..ea24f3d64e 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 b1909dba0b..f4d4425970 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 d9cc1a0017..454e9adf98 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 620d1a70ed..8f63c254a7 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 8eab4a699e..a5d687ab9e 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 c088aadf31..24235aa497 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 dc5cfa9411..145b8ff0d5 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 d89dddf365..d50648d1cb 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 b0eea695c5..859c7de820 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 ba68c5fb0a..a646b90a32 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 ab2e3feb37..af328644ad 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 03da2287d4..c7d1e34f6a 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 346e88e5f1..de1bf288b3 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 609c19a0fb..472a1cbba0 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 99212d914b..bd9e088591 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 28b788955a..392f97cff5 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 917e759dcb..4e7e423fa5 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 1e57c96960..5d84f2b548 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 b47f2c3050..1a720d6385 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 e97be557de..625b2ad0e8 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 6b31fbaca7..9e43dd6a4e 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 f3e5afe0b3..08a5823c6f 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 d67511f73d..030862de01 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 181bfa1adb..b77fd73c76 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 e38f8c5694..3799fb5f13 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 f8b5dbc249..4c75676ff7 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 a1bd705728..4c19f6125d 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 d03206221d..6eb4f10098 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 ad1b192098..06aaf31e5e 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 d950460bda..90d2bb9492 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 ef03673dce..5dbf913066 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 b38ade6c9e..16aefa6623 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 80514d8f1d..869edc87de 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 7bf6c91a5d..7753f6a1a0 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 b0bb731dc1..69d8ba5cd0 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 25d6243da2..f0a8235552 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 65617ac862..3d31085fc6 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 2bc1bfebb5..e9e4f26b1c 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 e1056bbba4..877bfd2a73 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 662f65a527..d0dde1cdef 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 ]) |