summaryrefslogtreecommitdiff
path: root/gl
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-06-05 19:10:04 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-06-05 19:10:04 +0200
commit75ed5f82a8b6a5f697c06feb1254152bb8b1f0ff (patch)
tree545a22b12ecce630acc5fa48d877b5898340f93e /gl
parenta8f5d585a2b482b3d33ce7f5e8ff2785b6ac4f8e (diff)
downloadgnutls-75ed5f82a8b6a5f697c06feb1254152bb8b1f0ff.tar.gz
updated gnulib
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am4
-rw-r--r--gl/errno.in.h48
-rw-r--r--gl/fseeko.c8
-rw-r--r--gl/fstat.c4
-rw-r--r--gl/ftello.c8
-rw-r--r--gl/lseek.c4
-rw-r--r--gl/m4/dup2.m423
-rw-r--r--gl/m4/errno_h.m411
-rw-r--r--gl/m4/fseeko.m414
-rw-r--r--gl/m4/fstat.m419
-rw-r--r--gl/m4/ftello.m417
-rw-r--r--gl/m4/ftruncate.m421
-rw-r--r--gl/m4/getcwd.m419
-rw-r--r--gl/m4/getdelim.m414
-rw-r--r--gl/m4/getline.m420
-rw-r--r--gl/m4/gettimeofday.m445
-rw-r--r--gl/m4/gnulib-common.m43
-rw-r--r--gl/m4/gnulib-comp.m48
-rw-r--r--gl/m4/largefile.m445
-rw-r--r--gl/m4/lseek.m459
-rw-r--r--gl/m4/lstat.m433
-rw-r--r--gl/m4/malloc.m440
-rw-r--r--gl/m4/manywarnings.m43
-rw-r--r--gl/m4/memmem.m424
-rw-r--r--gl/m4/mmap-anon.m48
-rw-r--r--gl/m4/off_t.m418
-rw-r--r--gl/m4/putenv.m420
-rw-r--r--gl/m4/realloc.m440
-rw-r--r--gl/m4/setenv.m438
-rw-r--r--gl/m4/signbit.m4173
-rw-r--r--gl/m4/sleep.m420
-rw-r--r--gl/m4/stat.m415
-rw-r--r--gl/m4/strerror.m448
-rw-r--r--gl/m4/symlink.m420
-rw-r--r--gl/m4/sys_stat_h.m415
-rw-r--r--gl/m4/sys_types_h.m45
-rw-r--r--gl/m4/ungetc.m422
-rw-r--r--gl/m4/unistd_h.m46
-rw-r--r--gl/m4/warnings.m447
-rw-r--r--gl/select.c61
-rw-r--r--gl/stdint.in.h49
-rw-r--r--gl/stdio.in.h3
-rw-r--r--gl/strerror-override.c16
-rw-r--r--gl/strerror-override.h5
-rw-r--r--gl/sys_stat.in.h33
-rw-r--r--gl/sys_types.in.h12
-rw-r--r--gl/tests/binary-io.h41
-rw-r--r--gl/tests/fcntl.in.h4
-rw-r--r--gl/tests/ftruncate.c157
-rw-r--r--gl/tests/ignore-value.h10
-rw-r--r--gl/tests/init.sh8
-rw-r--r--gl/tests/stat.c14
-rw-r--r--gl/tests/test-binary-io.c26
-rwxr-xr-xgl/tests/test-binary-io.sh8
-rw-r--r--gl/tests/test-errno.c2
-rw-r--r--gl/u64.h11
-rw-r--r--gl/unistd.in.h18
57 files changed, 1124 insertions, 343 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 4170af2620..a492e6a032 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -2110,6 +2110,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
-e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
-e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
-e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
@@ -2205,6 +2206,7 @@ sys/types.h: sys_types.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
< $(srcdir)/sys_types.in.h; \
} > $@-t && \
mv $@-t $@
@@ -2357,6 +2359,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
-e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
-e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
-e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
@@ -2455,6 +2458,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
-e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+ -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
-e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
diff --git a/gl/errno.in.h b/gl/errno.in.h
index 2f426121da..5e5af9276e 100644
--- a/gl/errno.in.h
+++ b/gl/errno.in.h
@@ -84,6 +84,16 @@
# define GNULIB_defined_ECANCELED 1
# endif
+# ifndef EOWNERDEAD
+# define EOWNERDEAD 133
+# define GNULIB_defined_EOWNERDEAD 1
+# endif
+
+# ifndef ENOTRECOVERABLE
+# define ENOTRECOVERABLE 127
+# define GNULIB_defined_ENOTRECOVERABLE 1
+# endif
+
# ifndef EINPROGRESS
# define EINPROGRESS 112
# define EALREADY 103
@@ -108,15 +118,17 @@
# define ELOOP 114
# define EHOSTUNREACH 110
# define EWOULDBLOCK 140
+# define GNULIB_defined_ESOCK 1
+# endif
+
+# ifndef ETXTBSY
# define ETXTBSY 139
# define ENODATA 120 /* not required by POSIX */
# define ENOSR 124 /* not required by POSIX */
# define ENOSTR 125 /* not required by POSIX */
-# define ENOTRECOVERABLE 127 /* not required by POSIX */
-# define EOWNERDEAD 133 /* not required by POSIX */
# define ETIME 137 /* not required by POSIX */
# define EOTHER 131 /* not required by POSIX */
-# define GNULIB_defined_ESOCK 1
+# define GNULIB_defined_ESTREAMS 1
# endif
/* These are intentionally the same values as the WSA* error numbers, defined
@@ -227,6 +239,36 @@
# define GNULIB_defined_ECANCELED 1
# endif
+/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not
+ defined. */
+
+# ifndef EOWNERDEAD
+# if defined __sun
+ /* Use the same values as defined for Solaris >= 8, for
+ interoperability. */
+# define EOWNERDEAD 58
+# define ENOTRECOVERABLE 59
+# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* We have a conflict here: pthreads-win32 defines these values
+ differently than MSVC 10. It's hairy to decide which one to use. */
+# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
+ /* Use the same values as defined by pthreads-win32, for
+ interoperability. */
+# define EOWNERDEAD 43
+# define ENOTRECOVERABLE 44
+# else
+ /* Use the same values as defined by MSVC 10, for
+ interoperability. */
+# define EOWNERDEAD 133
+# define ENOTRECOVERABLE 127
+# endif
+# else
+# define EOWNERDEAD 2013
+# define ENOTRECOVERABLE 2014
+# endif
+# define GNULIB_defined_EOWNERDEAD 1
+# define GNULIB_defined_ENOTRECOVERABLE 1
+# endif
#endif /* _@GUARD_PREFIX@_ERRNO_H */
#endif /* _@GUARD_PREFIX@_ERRNO_H */
diff --git a/gl/fseeko.c b/gl/fseeko.c
index 64c0640810..c372a5c142 100644
--- a/gl/fseeko.c
+++ b/gl/fseeko.c
@@ -31,6 +31,14 @@ fseeko (FILE *fp, off_t offset, int whence)
# undef fseek
# define fseeko fseek
#endif
+#if _GL_WINDOWS_64_BIT_OFF_T
+# undef fseeko
+# if HAVE__FSEEKI64 /* msvc, mingw64 */
+# define fseeko _fseeki64
+# else /* mingw */
+# define fseeko fseeko64
+# endif
+#endif
{
#if LSEEK_PIPE_BROKEN
/* mingw gives bogus answers rather than failure on non-seekable files. */
diff --git a/gl/fstat.c b/gl/fstat.c
index 4918495bc7..ac2b1effe3 100644
--- a/gl/fstat.c
+++ b/gl/fstat.c
@@ -23,6 +23,10 @@
/* Get the original definition of fstat. It might be defined as a macro. */
#include <sys/types.h>
#include <sys/stat.h>
+#if _GL_WINDOWS_64_BIT_ST_SIZE
+# define stat _stati64
+# define fstat _fstati64
+#endif
#undef __need_system_sys_stat_h
static inline int
diff --git a/gl/ftello.c b/gl/ftello.c
index 1beb202968..1f581c5a4c 100644
--- a/gl/ftello.c
+++ b/gl/ftello.c
@@ -31,6 +31,14 @@ ftello (FILE *fp)
# undef ftell
# define ftello ftell
#endif
+#if _GL_WINDOWS_64_BIT_OFF_T
+# undef ftello
+# if HAVE__FTELLI64 /* msvc, mingw64 */
+# define ftello _ftelli64
+# else /* mingw */
+# define ftello ftello64
+# endif
+#endif
{
#if LSEEK_PIPE_BROKEN
/* mingw gives bogus answers rather than failure on non-seekable files. */
diff --git a/gl/lseek.c b/gl/lseek.c
index cd7e2d62c4..794c230447 100644
--- a/gl/lseek.c
+++ b/gl/lseek.c
@@ -59,5 +59,9 @@ rpl_lseek (int fd, off_t offset, int whence)
return -1;
}
#endif
+#if _GL_WINDOWS_64_BIT_OFF_T
+ return _lseeki64 (fd, offset, whence);
+#else
return lseek (fd, offset, whence);
+#endif
}
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
index dec27faeeb..fc86e8085b 100644
--- a/gl/m4/dup2.m4
+++ b/gl/m4/dup2.m4
@@ -1,4 +1,4 @@
-#serial 17
+#serial 18
dnl Copyright (C) 2002, 2005, 2007, 2009-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -45,22 +45,25 @@ AC_DEFUN([gl_FUNC_DUP2],
[gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
[case "$host_os" in
mingw*) # on this platform, dup2 always returns 0 for success
- gl_cv_func_dup2_works=no;;
+ gl_cv_func_dup2_works="guessing no" ;;
cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
- gl_cv_func_dup2_works=no;;
+ gl_cv_func_dup2_works="guessing no" ;;
linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
# closed fd may yield -EBADF instead of -1 / errno=EBADF.
- gl_cv_func_dup2_works=no;;
+ gl_cv_func_dup2_works="guessing no" ;;
freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
- gl_cv_func_dup2_works=no;;
+ gl_cv_func_dup2_works="guessing no" ;;
haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
- gl_cv_func_dup2_works=no;;
- *) gl_cv_func_dup2_works=yes;;
+ gl_cv_func_dup2_works="guessing no" ;;
+ *) gl_cv_func_dup2_works="guessing yes" ;;
esac])
])
- if test "$gl_cv_func_dup2_works" = no; then
- REPLACE_DUP2=1
- fi
+ case "$gl_cv_func_dup2_works" in
+ *yes) ;;
+ *)
+ REPLACE_DUP2=1
+ ;;
+ esac
fi
dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
dnl to keep fchdir's bookkeeping up-to-date.
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index 4f0bb83597..1e76ba270a 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,4 +1,4 @@
-# errno_h.m4 serial 10
+# errno_h.m4 serial 11
dnl Copyright (C) 2004, 2006, 2008-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -10,6 +10,9 @@ AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
AC_EGREP_CPP([booboo],[
#include <errno.h>
+#if !defined ETXTBSY
+booboo
+#endif
#if !defined ENOMSG
booboo
#endif
@@ -49,6 +52,12 @@ booboo
#if !defined ECANCELED
booboo
#endif
+#if !defined EOWNERDEAD
+booboo
+#endif
+#if !defined ENOTRECOVERABLE
+booboo
+#endif
],
[gl_cv_header_errno_h_complete=no],
[gl_cv_header_errno_h_complete=yes])
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
index be5bb35edd..1bb88c7613 100644
--- a/gl/m4/fseeko.m4
+++ b/gl/m4/fseeko.m4
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 15
+# fseeko.m4 serial 16
dnl Copyright (C) 2007-2012 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,6 +8,7 @@ AC_DEFUN([gl_FUNC_FSEEKO],
[
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
+ AC_REQUIRE([gl_SYS_TYPES_H])
AC_REQUIRE([AC_PROG_CC])
dnl Persuade glibc <stdio.h> to declare fseeko().
@@ -28,6 +29,9 @@ AC_DEFUN([gl_FUNC_FSEEKO],
if test $gl_cv_func_fseeko = no; then
HAVE_FSEEKO=0
else
+ if test $WINDOWS_64_BIT_OFF_T = 1; then
+ REPLACE_FSEEKO=1
+ fi
if test $gl_cv_var_stdin_large_offset = no; then
REPLACE_FSEEKO=1
fi
@@ -59,3 +63,11 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
[gl_cv_var_stdin_large_offset=yes],
[gl_cv_var_stdin_large_offset=no])])
])
+
+# Prerequisites of lib/fseeko.c.
+AC_DEFUN([gl_PREREQ_FSEEKO],
+[
+ dnl Native Windows has the function _fseeki64. mingw hides it, but mingw64
+ dnl makes it usable again.
+ AC_CHECK_FUNCS([_fseeki64])
+])
diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4
index e3f8f3e2ee..3ab3297b2c 100644
--- a/gl/m4/fstat.m4
+++ b/gl/m4/fstat.m4
@@ -1,4 +1,4 @@
-# fstat.m4 serial 1
+# fstat.m4 serial 3
dnl Copyright (C) 2011-2012 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,16 +7,27 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_FSTAT],
[
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+
AC_REQUIRE([gl_MSVC_INVAL])
if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
REPLACE_FSTAT=1
fi
+
+ AC_REQUIRE([gl_HEADER_SYS_STAT_H])
+ if test $WINDOWS_64_BIT_ST_SIZE = 1; then
+ REPLACE_FSTAT=1
+ fi
+
dnl Replace fstat() for supporting the gnulib-defined open() on directories.
m4_ifdef([gl_FUNC_FCHDIR], [
gl_TEST_FCHDIR
- if test $HAVE_FCHDIR = 0 \
- && test "$gl_cv_func_open_directory_works" != yes; then
- REPLACE_FSTAT=1
+ if test $HAVE_FCHDIR = 0; then
+ case "$gl_cv_func_open_directory_works" in
+ *yes) ;;
+ *)
+ REPLACE_FSTAT=1
+ ;;
+ esac
fi
])
])
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4
index 42be83e5a9..ab7b548eba 100644
--- a/gl/m4/ftello.m4
+++ b/gl/m4/ftello.m4
@@ -1,4 +1,4 @@
-# ftello.m4 serial 10
+# ftello.m4 serial 11
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,7 @@ AC_DEFUN([gl_FUNC_FTELLO],
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
+ AC_REQUIRE([gl_SYS_TYPES_H])
dnl Persuade glibc <stdio.h> to declare ftello().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -30,9 +31,13 @@ AC_DEFUN([gl_FUNC_FTELLO],
if test $gl_cv_func_ftello = no; then
HAVE_FTELLO=0
else
+ if test $WINDOWS_64_BIT_OFF_T = 1; then
+ REPLACE_FTELLO=1
+ fi
if test $gl_cv_var_stdin_large_offset = no; then
REPLACE_FTELLO=1
- else
+ fi
+ if test $REPLACE_FTELLO = 0; then
dnl Detect bug on Solaris.
dnl ftell and ftello produce incorrect results after putc that followed a
dnl getc call that reached EOF on Solaris. This is because the _IOREAD
@@ -125,3 +130,11 @@ main (void)
fi
fi
])
+
+# Prerequisites of lib/ftello.c.
+AC_DEFUN([gl_PREREQ_FTELLO],
+[
+ dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64
+ dnl makes it usable again.
+ AC_CHECK_FUNCS([_ftelli64])
+])
diff --git a/gl/m4/ftruncate.m4 b/gl/m4/ftruncate.m4
index 1007f34120..969eb0412d 100644
--- a/gl/m4/ftruncate.m4
+++ b/gl/m4/ftruncate.m4
@@ -1,4 +1,4 @@
-# serial 18
+# serial 19
# See if we need to emulate a missing ftruncate function using chsize.
@@ -11,7 +11,24 @@ AC_DEFUN([gl_FUNC_FTRUNCATE],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([ftruncate])
- if test $ac_cv_func_ftruncate = no; then
+ if test $ac_cv_func_ftruncate = yes; then
+ m4_ifdef([gl_LARGEFILE], [
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case "$host_os" in
+ mingw*)
+ dnl Native Windows, and Large File Support is requested.
+ dnl The MSVCRT _chsize() function only accepts a 32-bit file size,
+ dnl and the mingw64 ftruncate64() function is unreliable (it may
+ dnl delete the file, see
+ dnl <http://mingw-w64.sourcearchive.com/documentation/2.0-1/ftruncate64_8c_source.html>).
+ dnl Use gnulib's ftruncate() implementation instead.
+ REPLACE_FTRUNCATE=1
+ ;;
+ esac
+ ], [
+ :
+ ])
+ else
HAVE_FTRUNCATE=0
fi
])
diff --git a/gl/m4/getcwd.m4 b/gl/m4/getcwd.m4
index ccb1f47bd3..50b96c666c 100644
--- a/gl/m4/getcwd.m4
+++ b/gl/m4/getcwd.m4
@@ -6,7 +6,7 @@
# with or without modifications, as long as this notice is preserved.
# Written by Paul Eggert.
-# serial 11
+# serial 12
AC_DEFUN([gl_FUNC_GETCWD_NULL],
[
@@ -45,15 +45,14 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
]])],
[gl_cv_func_getcwd_null=yes],
[gl_cv_func_getcwd_null=no],
- [[
- case "$host_os" in
- # Guess yes on glibc systems.
- *-gnu*) gl_cv_func_getcwd_null="guessing yes";;
- # Guess yes on Cygwin.
- cygwin*) gl_cv_func_getcwd_null="guessing yes";;
- # If we don't know, assume the worst.
- *) gl_cv_func_getcwd_null="guessing no";;
- esac
+ [[case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_getcwd_null="guessing yes";;
+ # Guess yes on Cygwin.
+ cygwin*) gl_cv_func_getcwd_null="guessing yes";;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_getcwd_null="guessing no";;
+ esac
]])])
])
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
index 8bd3d3f862..a6f487217e 100644
--- a/gl/m4/getdelim.m4
+++ b/gl/m4/getdelim.m4
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 9
+# getdelim.m4 serial 10
dnl Copyright (C) 2005-2007, 2009-2012 Free Software Foundation, Inc.
dnl
@@ -63,12 +63,14 @@ AC_DEFUN([gl_FUNC_GETDELIM],
#endif
#endif
],
- [gl_cv_func_working_getdelim=yes],
- [gl_cv_func_working_getdelim=no])]
+ [gl_cv_func_working_getdelim="guessing yes"],
+ [gl_cv_func_working_getdelim="guessing no"])]
)])
- if test $gl_cv_func_working_getdelim = no; then
- REPLACE_GETDELIM=1
- fi
+ case "$gl_cv_func_working_getdelim" in
+ *no)
+ REPLACE_GETDELIM=1
+ ;;
+ esac
else
HAVE_GETDELIM=0
fi
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
index 01f38cfb9c..72fbc9d44b 100644
--- a/gl/m4/getline.m4
+++ b/gl/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 25
+# getline.m4 serial 26
dnl Copyright (C) 1998-2003, 2005-2007, 2009-2012 Free Software Foundation,
dnl Inc.
@@ -70,8 +70,8 @@ AC_DEFUN([gl_FUNC_GETLINE],
#endif
#endif
],
- [am_cv_func_working_getline=yes],
- [am_cv_func_working_getline=no])]
+ [am_cv_func_working_getline="guessing yes"],
+ [am_cv_func_working_getline="guessing no"])]
)])
fi
@@ -79,12 +79,14 @@ AC_DEFUN([gl_FUNC_GETLINE],
HAVE_DECL_GETLINE=0
fi
- if test $am_cv_func_working_getline = no; then
- dnl Set REPLACE_GETLINE always: Even if we have not found the broken
- dnl getline function among $LIBS, it may exist in libinet and the
- dnl executable may be linked with -linet.
- REPLACE_GETLINE=1
- fi
+ case "$am_cv_func_working_getline" in
+ *no)
+ dnl Set REPLACE_GETLINE always: Even if we have not found the broken
+ dnl getline function among $LIBS, it may exist in libinet and the
+ dnl executable may be linked with -linet.
+ REPLACE_GETLINE=1
+ ;;
+ esac
])
# Prerequisites of lib/getline.c.
diff --git a/gl/m4/gettimeofday.m4 b/gl/m4/gettimeofday.m4
index dc68c43ae3..eda97027a9 100644
--- a/gl/m4/gettimeofday.m4
+++ b/gl/m4/gettimeofday.m4
@@ -1,4 +1,4 @@
-# serial 18
+# serial 20
# Copyright (C) 2001-2003, 2005, 2007, 2009-2012 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -56,14 +56,16 @@ int gettimeofday (struct timeval *restrict, struct timezone *restrict);
fi
m4_ifdef([gl_FUNC_TZSET_CLOBBER], [
gl_FUNC_TZSET_CLOBBER
- if test $gl_cv_func_tzset_clobber = yes; then
- REPLACE_GETTIMEOFDAY=1
- gl_GETTIMEOFDAY_REPLACE_LOCALTIME
- AC_DEFINE([tzset], [rpl_tzset],
- [Define to rpl_tzset if the wrapper function should be used.])
- AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1],
- [Define if tzset clobbers localtime's static buffer.])
- fi
+ case "$gl_cv_func_tzset_clobber" in
+ *yes)
+ REPLACE_GETTIMEOFDAY=1
+ gl_GETTIMEOFDAY_REPLACE_LOCALTIME
+ AC_DEFINE([tzset], [rpl_tzset],
+ [Define to rpl_tzset if the wrapper function should be used.])
+ AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1],
+ [Define if tzset clobbers localtime's static buffer.])
+ ;;
+ esac
])
fi
AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone],
@@ -82,6 +84,7 @@ dnl the wrapper functions that work around the problem.
AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER],
[
AC_REQUIRE([gl_HEADER_SYS_TIME_H])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
[gl_cv_func_gettimeofday_clobber],
@@ -104,15 +107,23 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER],
]])],
[gl_cv_func_gettimeofday_clobber=no],
[gl_cv_func_gettimeofday_clobber=yes],
- dnl When crosscompiling, assume it is broken.
- [gl_cv_func_gettimeofday_clobber=yes])])
+ [# When cross-compiling:
+ case "$host_os" in
+ # Guess all is fine on glibc systems.
+ *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_gettimeofday_clobber="guessing yes" ;;
+ esac
+ ])])
- if test $gl_cv_func_gettimeofday_clobber = yes; then
- REPLACE_GETTIMEOFDAY=1
- gl_GETTIMEOFDAY_REPLACE_LOCALTIME
- AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1],
- [Define if gettimeofday clobbers the localtime buffer.])
- fi
+ case "$gl_cv_func_gettimeofday_clobber" in
+ *yes)
+ REPLACE_GETTIMEOFDAY=1
+ gl_GETTIMEOFDAY_REPLACE_LOCALTIME
+ AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1],
+ [Define if gettimeofday clobbers the localtime buffer.])
+ ;;
+ esac
])
AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index ae4d25483c..d62b7677ab 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -14,7 +14,8 @@ AC_DEFUN([gl_COMMON], [
AC_DEFUN([gl_COMMON_BODY], [
AH_VERBATIM([_Noreturn],
[/* The _Noreturn keyword of C11. */
-#ifndef _Noreturn
+#if ! (defined _Noreturn \
+ || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 461d7e5bab..4d134505cb 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -447,6 +447,7 @@ gl_STDIO_MODULE_INDICATOR([fseek])
gl_FUNC_FSEEKO
if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
AC_LIBOBJ([fseeko])
+ gl_PREREQ_FSEEKO
fi
gl_STDIO_MODULE_INDICATOR([fseeko])
gl_FUNC_FSTAT
@@ -463,6 +464,7 @@ gl_STDIO_MODULE_INDICATOR([ftell])
gl_FUNC_FTELLO
if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
AC_LIBOBJ([ftello])
+ gl_PREREQ_FTELLO
fi
gl_STDIO_MODULE_INDICATOR([ftello])
gl_FUNC
@@ -570,6 +572,7 @@ if test $gl_func_isnanl_no_libm != yes; then
AC_LIBOBJ([isnanl])
gl_PREREQ_ISNANL
fi
+AC_REQUIRE([gl_LARGEFILE])
gl_LD_OUTPUT_DEF
gl_LD_VERSION_SCRIPT
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
@@ -834,7 +837,6 @@ gl_FUNC_VPRINTF_POSIX
gl_STDIO_MODULE_INDICATOR([vprintf-posix])
gl_FUNC_VSNPRINTF
gl_STDIO_MODULE_INDICATOR([vsnprintf])
-AC_SUBST([WARN_CFLAGS])
gl_WCHAR_H
gl_XSIZE
# End of code from modules
@@ -883,6 +885,7 @@ changequote([, ])dnl
AC_SUBST([gltests_WITNESS])
gl_module_indicator_condition=$gltests_WITNESS
m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition])
+AC_REQUIRE([AC_C_INLINE])
gl_FUNC_DUP2
if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
AC_LIBOBJ([dup2])
@@ -903,7 +906,7 @@ gl_FUNC_UNGETC_WORKS
gl_FUNC_UNGETC_WORKS
gl_FUNC_UNGETC_WORKS
gl_FUNC_FTRUNCATE
-if test $HAVE_FTRUNCATE = 0; then
+if test $HAVE_FTRUNCATE = 0 || test $REPLACE_FTRUNCATE = 1; then
AC_LIBOBJ([ftruncate])
gl_PREREQ_FTRUNCATE
fi
@@ -1396,6 +1399,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/netinet_in_h.m4
m4/nls.m4
m4/nocrash.m4
+ m4/off_t.m4
m4/open.m4
m4/opendir.m4
m4/pathmax.m4
diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4
index 1369bbe525..a159f4ab2c 100644
--- a/gl/m4/largefile.m4
+++ b/gl/m4/largefile.m4
@@ -102,3 +102,48 @@ fi
])# AC_SYS_LARGEFILE
])# m4_version_prereq 2.69
+
+# Enable large files on systems where this is implemented by Gnulib, not by the
+# system headers.
+# Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib
+# overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively.
+AC_DEFUN([gl_LARGEFILE],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case "$host_os" in
+ mingw*)
+ dnl Native Windows.
+ dnl mingw64 defines off_t to a 64-bit type already, if
+ dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE.
+ AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/types.h>
+ int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1];
+ ]],
+ [[]])],
+ [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no])
+ ])
+ if test $gl_cv_type_off_t_64 = no; then
+ WINDOWS_64_BIT_OFF_T=1
+ else
+ WINDOWS_64_BIT_OFF_T=0
+ fi
+ dnl But all native Windows platforms (including mingw64) have a 32-bit
+ dnl st_size member in 'struct stat'.
+ WINDOWS_64_BIT_ST_SIZE=1
+ ;;
+ *)
+ dnl Nothing to do on gnulib's side.
+ dnl A 64-bit off_t is
+ dnl - already the default on MacOS X, FreeBSD, NetBSD, OpenBSD, IRIX,
+ dnl OSF/1, Cygwin,
+ dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on
+ dnl glibc, HP-UX, Solaris,
+ dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX,
+ dnl - impossible to achieve on Minix 3.1.8.
+ WINDOWS_64_BIT_OFF_T=0
+ WINDOWS_64_BIT_ST_SIZE=0
+ ;;
+ esac
+])
diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4
index 86db59ecdc..bdda7f659b 100644
--- a/gl/m4/lseek.m4
+++ b/gl/m4/lseek.m4
@@ -1,4 +1,4 @@
-# lseek.m4 serial 8
+# lseek.m4 serial 10
dnl Copyright (C) 2007, 2009-2012 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,11 +7,24 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_LSEEK],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_CHECK_HEADERS_ONCE([unistd.h])
AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
- [if test $cross_compiling = no; then
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ [case "$host_os" in
+ mingw*)
+ dnl Native Windows.
+ dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or
+ dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT)
+ dnl for a pipe depends on the environment: In a Cygwin 1.5
+ dnl environment it succeeds (wrong); in a Cygwin 1.7 environment
+ dnl it fails with a wrong errno value.
+ gl_cv_func_lseek_pipe=no
+ ;;
+ *)
+ if test $cross_compiling = no; then
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h> /* for off_t */
#include <stdio.h> /* for SEEK_CUR */
#if HAVE_UNISTD_H
@@ -23,26 +36,36 @@ AC_DEFUN([gl_FUNC_LSEEK],
/* Exit with success only if stdin is seekable. */
return lseek (0, (off_t)0, SEEK_CUR) < 0;
]])],
- [if test -s conftest$ac_exeext \
- && ./conftest$ac_exeext < conftest.$ac_ext \
- && test 1 = "`echo hi \
- | { ./conftest$ac_exeext; echo $?; cat >/dev/null; }`"; then
- gl_cv_func_lseek_pipe=yes
- else
- gl_cv_func_lseek_pipe=no
- fi],
- [gl_cv_func_lseek_pipe=no])
- else
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
-#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) || defined __BEOS__
-/* mingw and BeOS mistakenly return 0 when trying to seek on pipes. */
+ [if test -s conftest$ac_exeext \
+ && ./conftest$ac_exeext < conftest.$ac_ext \
+ && test 1 = "`echo hi \
+ | { ./conftest$ac_exeext; echo $?; cat >/dev/null; }`"; then
+ gl_cv_func_lseek_pipe=yes
+ else
+ gl_cv_func_lseek_pipe=no
+ fi
+ ],
+ [gl_cv_func_lseek_pipe=no])
+ else
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([[
+#if defined __BEOS__
+/* BeOS mistakenly return 0 when trying to seek on pipes. */
Choke me.
#endif]])],
- [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
- fi])
+ [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
+ fi
+ ;;
+ esac
+ ])
if test $gl_cv_func_lseek_pipe = no; then
REPLACE_LSEEK=1
AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
[Define to 1 if lseek does not detect pipes.])
fi
+
+ AC_REQUIRE([gl_SYS_TYPES_H])
+ if test $WINDOWS_64_BIT_OFF_T = 1; then
+ REPLACE_LSEEK=1
+ fi
])
diff --git a/gl/m4/lstat.m4 b/gl/m4/lstat.m4
index b83858bdb6..b7335bda1b 100644
--- a/gl/m4/lstat.m4
+++ b/gl/m4/lstat.m4
@@ -1,4 +1,4 @@
-# serial 24
+# serial 25
# Copyright (C) 1997-2001, 2003-2012 Free Software Foundation, Inc.
#
@@ -16,9 +16,11 @@ AC_DEFUN([gl_FUNC_LSTAT],
AC_CHECK_FUNCS_ONCE([lstat])
if test $ac_cv_func_lstat = yes; then
AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
- if test $gl_cv_func_lstat_dereferences_slashed_symlink = no; then
- REPLACE_LSTAT=1
- fi
+ case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
+ *no)
+ REPLACE_LSTAT=1
+ ;;
+ esac
else
HAVE_LSTAT=0
fi
@@ -51,20 +53,25 @@ AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
]])],
[gl_cv_func_lstat_dereferences_slashed_symlink=yes],
[gl_cv_func_lstat_dereferences_slashed_symlink=no],
- [# When cross-compiling, be pessimistic so we will end up using the
- # replacement version of lstat that checks for trailing slashes and
- # calls lstat a second time when necessary.
- gl_cv_func_lstat_dereferences_slashed_symlink=no
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
+ esac
])
else
# If the 'ln -s' command failed, then we probably don't even
# have an lstat function.
- gl_cv_func_lstat_dereferences_slashed_symlink=no
+ gl_cv_func_lstat_dereferences_slashed_symlink="guessing no"
fi
rm -f conftest.sym conftest.file
])
- test $gl_cv_func_lstat_dereferences_slashed_symlink = yes &&
- AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
- [Define to 1 if 'lstat' dereferences a symlink specified
- with a trailing slash.])
+ case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
+ *yes)
+ AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
+ [Define to 1 if 'lstat' dereferences a symlink specified
+ with a trailing slash.])
+ ;;
+ esac
])
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index d3c39f5d96..8fa48e93bc 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,9 +1,47 @@
-# malloc.m4 serial 13
+# malloc.m4 serial 14
dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
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.
+m4_version_prereq([2.70], [] ,[
+
+# This is taken from the following Autoconf patch:
+# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
+AC_DEFUN([_AC_FUNC_MALLOC_IF],
+[
+ AC_REQUIRE([AC_HEADER_STDC])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
+ AC_CHECK_HEADERS([stdlib.h])
+ AC_CACHE_CHECK([for GNU libc compatible malloc],
+ [ac_cv_func_malloc_0_nonnull],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+ # include <stdlib.h>
+ #else
+ char *malloc ();
+ #endif
+ ]],
+ [[return ! malloc (0);]])
+ ],
+ [ac_cv_func_malloc_0_nonnull=yes],
+ [ac_cv_func_malloc_0_nonnull=no],
+ [case "$host_os" in
+ # Guess yes on platforms where we know the result.
+ *-gnu* | freebsd* | netbsd* | openbsd* \
+ | hpux* | solaris* | cygwin* | mingw*)
+ ac_cv_func_malloc_0_nonnull=yes ;;
+ # If we don't know, assume the worst.
+ *) ac_cv_func_malloc_0_nonnull=no ;;
+ esac
+ ])
+ ])
+ AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
+])# _AC_FUNC_MALLOC_IF
+
+])
+
# gl_FUNC_MALLOC_GNU
# ------------------
# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if
diff --git a/gl/m4/manywarnings.m4 b/gl/m4/manywarnings.m4
index fd0e3722d3..864fc85198 100644
--- a/gl/m4/manywarnings.m4
+++ b/gl/m4/manywarnings.m4
@@ -1,4 +1,4 @@
-# manywarnings.m4 serial 3
+# manywarnings.m4 serial 4
dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -143,7 +143,6 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
for gl_manywarn_item in \
-Wattributes \
-Wcoverage-mismatch \
- -Wmultichar \
-Wunused-macros \
; do
gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
diff --git a/gl/m4/memmem.m4 b/gl/m4/memmem.m4
index eebe94c24e..88f9e20521 100644
--- a/gl/m4/memmem.m4
+++ b/gl/m4/memmem.m4
@@ -1,4 +1,4 @@
-# memmem.m4 serial 23
+# memmem.m4 serial 24
dnl Copyright (C) 2002-2004, 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -67,13 +67,16 @@ AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE],
Lucky user
#endif
],
- [gl_cv_func_memmem_works_always=yes],
+ [gl_cv_func_memmem_works_always="guessing yes"],
[gl_cv_func_memmem_works_always="guessing no"])
])
])
- if test "$gl_cv_func_memmem_works_always" != yes; then
- REPLACE_MEMMEM=1
- fi
+ case "$gl_cv_func_memmem_works_always" in
+ *yes) ;;
+ *)
+ REPLACE_MEMMEM=1
+ ;;
+ esac
fi
gl_PREREQ_MEMMEM
]) # gl_FUNC_MEMMEM_SIMPLE
@@ -131,13 +134,16 @@ static void quit (int sig) { exit (sig + 128); }
#endif
#endif
],
- [gl_cv_func_memmem_works_fast=yes],
+ [gl_cv_func_memmem_works_fast="guessing yes"],
[gl_cv_func_memmem_works_fast="guessing no"])
])
])
- if test "$gl_cv_func_memmem_works_fast" != yes; then
- REPLACE_MEMMEM=1
- fi
+ case "$gl_cv_func_memmem_works_fast" in
+ *yes) ;;
+ *)
+ REPLACE_MEMMEM=1
+ ;;
+ esac
fi
]) # gl_FUNC_MEMMEM
diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4
index 4613cbe5ba..579323f15a 100644
--- a/gl/m4/mmap-anon.m4
+++ b/gl/m4/mmap-anon.m4
@@ -27,18 +27,18 @@ AC_DEFUN([gl_FUNC_MMAP_ANON],
gl_have_mmap_anonymous=no
if test $gl_have_mmap = yes; then
AC_MSG_CHECKING([for MAP_ANONYMOUS])
- AC_EGREP_CPP([I cant identify this map], [
+ AC_EGREP_CPP([I cannot identify this map], [
#include <sys/mman.h>
#ifdef MAP_ANONYMOUS
- I cant identify this map
+ I cannot identify this map
#endif
],
[gl_have_mmap_anonymous=yes])
if test $gl_have_mmap_anonymous != yes; then
- AC_EGREP_CPP([I cant identify this map], [
+ AC_EGREP_CPP([I cannot identify this map], [
#include <sys/mman.h>
#ifdef MAP_ANON
- I cant identify this map
+ I cannot identify this map
#endif
],
[AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4
new file mode 100644
index 0000000000..dfca2dfd23
--- /dev/null
+++ b/gl/m4/off_t.m4
@@ -0,0 +1,18 @@
+# off_t.m4 serial 1
+dnl Copyright (C) 2012 Free Software Foundation, Inc.
+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 Check whether to override the 'off_t' type.
+dnl Set WINDOWS_64_BIT_OFF_T.
+
+AC_DEFUN([gl_TYPE_OFF_T],
+[
+ m4_ifdef([gl_LARGEFILE], [
+ AC_REQUIRE([gl_LARGEFILE])
+ ], [
+ WINDOWS_64_BIT_OFF_T=0
+ ])
+ AC_SUBST([WINDOWS_64_BIT_OFF_T])
+])
diff --git a/gl/m4/putenv.m4 b/gl/m4/putenv.m4
index 1cb23a594f..b971b1204d 100644
--- a/gl/m4/putenv.m4
+++ b/gl/m4/putenv.m4
@@ -1,4 +1,4 @@
-# putenv.m4 serial 18
+# putenv.m4 serial 19
dnl Copyright (C) 2002-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,7 @@ dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
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],[[
@@ -32,9 +33,18 @@ AC_DEFUN([gl_FUNC_PUTENV],
gl_cv_func_svid_putenv=yes,
gl_cv_func_svid_putenv=no,
dnl When crosscompiling, assume putenv is broken.
- gl_cv_func_svid_putenv=no)
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_svid_putenv="guessing no" ;;
+ esac
+ ])
])
- if test $gl_cv_func_svid_putenv = no; then
- REPLACE_PUTENV=1
- fi
+ case "$gl_cv_func_svid_putenv" in
+ *yes) ;;
+ *)
+ REPLACE_PUTENV=1
+ ;;
+ esac
])
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
index 039ed192a6..954c2f0e58 100644
--- a/gl/m4/realloc.m4
+++ b/gl/m4/realloc.m4
@@ -1,9 +1,47 @@
-# realloc.m4 serial 12
+# realloc.m4 serial 13
dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
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.
+m4_version_prereq([2.70], [] ,[
+
+# This is taken from the following Autoconf patch:
+# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
+AC_DEFUN([_AC_FUNC_REALLOC_IF],
+[
+ AC_REQUIRE([AC_HEADER_STDC])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
+ AC_CHECK_HEADERS([stdlib.h])
+ AC_CACHE_CHECK([for GNU libc compatible realloc],
+ [ac_cv_func_realloc_0_nonnull],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+ # include <stdlib.h>
+ #else
+ char *realloc ();
+ #endif
+ ]],
+ [[return ! realloc (0, 0);]])
+ ],
+ [ac_cv_func_realloc_0_nonnull=yes],
+ [ac_cv_func_realloc_0_nonnull=no],
+ [case "$host_os" in
+ # Guess yes on platforms where we know the result.
+ *-gnu* | freebsd* | netbsd* | openbsd* \
+ | hpux* | solaris* | cygwin* | mingw*)
+ ac_cv_func_realloc_0_nonnull=yes ;;
+ # If we don't know, assume the worst.
+ *) ac_cv_func_realloc_0_nonnull=no ;;
+ esac
+ ])
+ ])
+ AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
+])# AC_FUNC_REALLOC
+
+])
+
# gl_FUNC_REALLOC_GNU
# -------------------
# Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index a1f30bc47b..e1931e7eb2 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,4 +1,4 @@
-# setenv.m4 serial 25
+# setenv.m4 serial 26
dnl Copyright (C) 2001-2004, 2006-2012 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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_SETENV],
[
AC_REQUIRE([gl_FUNC_SETENV_SEPARATE])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
if test $ac_cv_func_setenv = no; then
HAVE_SETENV=0
else
@@ -33,10 +34,19 @@ AC_DEFUN([gl_FUNC_SETENV],
return result;
]])],
[gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
- [gl_cv_func_setenv_works="guessing no"])])
- if test "$gl_cv_func_setenv_works" != yes; then
- REPLACE_SETENV=1
- fi
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_setenv_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_setenv_works="guessing no" ;;
+ esac
+ ])])
+ case "$gl_cv_func_setenv_works" in
+ *yes) ;;
+ *)
+ REPLACE_SETENV=1
+ ;;
+ esac
fi
])
@@ -56,6 +66,7 @@ AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
AC_DEFUN([gl_FUNC_UNSETENV],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CHECK_DECLS_ONCE([unsetenv])
if test $ac_cv_have_decl_unsetenv = no; then
HAVE_DECL_UNSETENV=0
@@ -115,10 +126,19 @@ int unsetenv (const char *name);
if (getenv ("a")) return 6;
]])],
[gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no],
- [gl_cv_func_unsetenv_works="guessing no"])])
- if test "$gl_cv_func_unsetenv_works" != yes; then
- REPLACE_UNSETENV=1
- fi
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_unsetenv_works="guessing no" ;;
+ esac
+ ])])
+ case "$gl_cv_func_unsetenv_works" in
+ *yes) ;;
+ *)
+ REPLACE_UNSETENV=1
+ ;;
+ esac
fi
])
diff --git a/gl/m4/signbit.m4 b/gl/m4/signbit.m4
index 8955326051..e9877f68f5 100644
--- a/gl/m4/signbit.m4
+++ b/gl/m4/signbit.m4
@@ -1,4 +1,4 @@
-# signbit.m4 serial 11
+# signbit.m4 serial 12
dnl Copyright (C) 2007-2012 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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_SIGNBIT],
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([for signbit macro], [gl_cv_func_signbit],
[
AC_RUN_IFELSE(
@@ -27,7 +28,13 @@ AC_DEFUN([gl_SIGNBIT],
])],
[gl_cv_func_signbit=yes],
[gl_cv_func_signbit=no],
- [gl_cv_func_signbit="guessing no"])
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_signbit="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_signbit="guessing no" ;;
+ esac
+ ])
])
dnl GCC 4.0 and newer provides three built-ins for signbit.
dnl They can be used without warnings, also in C++, regardless of <math.h>.
@@ -50,87 +57,99 @@ AC_DEFUN([gl_SIGNBIT],
])],
[gl_cv_func_signbit_gcc=yes],
[gl_cv_func_signbit_gcc=no],
- [gl_cv_func_signbit_gcc="guessing no"])
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_signbit_gcc="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_signbit_gcc="guessing no" ;;
+ esac
+ ])
])
dnl Use the compiler built-ins whenever possible, because they are more
dnl efficient than the system library functions (if they exist).
- if test "$gl_cv_func_signbit_gcc" = yes; then
- REPLACE_SIGNBIT_USING_GCC=1
- else
- if test "$gl_cv_func_signbit" != yes; then
- dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built.
- REPLACE_SIGNBIT=1
- gl_FLOAT_SIGN_LOCATION
- gl_DOUBLE_SIGN_LOCATION
- gl_LONG_DOUBLE_SIGN_LOCATION
- if test "$gl_cv_cc_float_signbit" = unknown; then
- dnl Test whether copysignf() is declared.
- AC_CHECK_DECLS([copysignf], , , [[#include <math.h>]])
- if test "$ac_cv_have_decl_copysignf" = yes; then
- dnl Test whether copysignf() can be used without libm.
- AC_CACHE_CHECK([whether copysignf can be used without linking with libm],
- [gl_cv_func_copysignf_no_libm],
- [
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <math.h>
- float x, y;]],
- [[return copysignf (x, y) < 0;]])],
- [gl_cv_func_copysignf_no_libm=yes],
- [gl_cv_func_copysignf_no_libm=no])
- ])
- if test $gl_cv_func_copysignf_no_libm = yes; then
- AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1],
- [Define if the copysignf function is declared in <math.h> and available in libc.])
+ case "$gl_cv_func_signbit_gcc" in
+ *yes)
+ REPLACE_SIGNBIT_USING_GCC=1
+ ;;
+ *)
+ case "$gl_cv_func_signbit" in
+ *yes) ;;
+ *)
+ dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built.
+ REPLACE_SIGNBIT=1
+ gl_FLOAT_SIGN_LOCATION
+ gl_DOUBLE_SIGN_LOCATION
+ gl_LONG_DOUBLE_SIGN_LOCATION
+ if test "$gl_cv_cc_float_signbit" = unknown; then
+ dnl Test whether copysignf() is declared.
+ AC_CHECK_DECLS([copysignf], , , [[#include <math.h>]])
+ if test "$ac_cv_have_decl_copysignf" = yes; then
+ dnl Test whether copysignf() can be used without libm.
+ AC_CACHE_CHECK([whether copysignf can be used without linking with libm],
+ [gl_cv_func_copysignf_no_libm],
+ [
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <math.h>
+ float x, y;]],
+ [[return copysignf (x, y) < 0;]])],
+ [gl_cv_func_copysignf_no_libm=yes],
+ [gl_cv_func_copysignf_no_libm=no])
+ ])
+ if test $gl_cv_func_copysignf_no_libm = yes; then
+ AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1],
+ [Define if the copysignf function is declared in <math.h> and available in libc.])
+ fi
+ fi
fi
- fi
- fi
- if test "$gl_cv_cc_double_signbit" = unknown; then
- dnl Test whether copysign() is declared.
- AC_CHECK_DECLS([copysign], , , [[#include <math.h>]])
- if test "$ac_cv_have_decl_copysign" = yes; then
- dnl Test whether copysign() can be used without libm.
- AC_CACHE_CHECK([whether copysign can be used without linking with libm],
- [gl_cv_func_copysign_no_libm],
- [
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <math.h>
- double x, y;]],
- [[return copysign (x, y) < 0;]])],
- [gl_cv_func_copysign_no_libm=yes],
- [gl_cv_func_copysign_no_libm=no])
- ])
- if test $gl_cv_func_copysign_no_libm = yes; then
- AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1],
- [Define if the copysign function is declared in <math.h> and available in libc.])
+ if test "$gl_cv_cc_double_signbit" = unknown; then
+ dnl Test whether copysign() is declared.
+ AC_CHECK_DECLS([copysign], , , [[#include <math.h>]])
+ if test "$ac_cv_have_decl_copysign" = yes; then
+ dnl Test whether copysign() can be used without libm.
+ AC_CACHE_CHECK([whether copysign can be used without linking with libm],
+ [gl_cv_func_copysign_no_libm],
+ [
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <math.h>
+ double x, y;]],
+ [[return copysign (x, y) < 0;]])],
+ [gl_cv_func_copysign_no_libm=yes],
+ [gl_cv_func_copysign_no_libm=no])
+ ])
+ if test $gl_cv_func_copysign_no_libm = yes; then
+ AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1],
+ [Define if the copysign function is declared in <math.h> and available in libc.])
+ fi
+ fi
fi
- fi
- fi
- if test "$gl_cv_cc_long_double_signbit" = unknown; then
- dnl Test whether copysignl() is declared.
- AC_CHECK_DECLS([copysignl], , , [[#include <math.h>]])
- if test "$ac_cv_have_decl_copysignl" = yes; then
- dnl Test whether copysignl() can be used without libm.
- AC_CACHE_CHECK([whether copysignl can be used without linking with libm],
- [gl_cv_func_copysignl_no_libm],
- [
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <math.h>
- long double x, y;]],
- [[return copysignl (x, y) < 0;]])],
- [gl_cv_func_copysignl_no_libm=yes],
- [gl_cv_func_copysignl_no_libm=no])
- ])
- if test $gl_cv_func_copysignl_no_libm = yes; then
- AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1],
- [Define if the copysignl function is declared in <math.h> and available in libc.])
+ if test "$gl_cv_cc_long_double_signbit" = unknown; then
+ dnl Test whether copysignl() is declared.
+ AC_CHECK_DECLS([copysignl], , , [[#include <math.h>]])
+ if test "$ac_cv_have_decl_copysignl" = yes; then
+ dnl Test whether copysignl() can be used without libm.
+ AC_CACHE_CHECK([whether copysignl can be used without linking with libm],
+ [gl_cv_func_copysignl_no_libm],
+ [
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <math.h>
+ long double x, y;]],
+ [[return copysignl (x, y) < 0;]])],
+ [gl_cv_func_copysignl_no_libm=yes],
+ [gl_cv_func_copysignl_no_libm=no])
+ ])
+ if test $gl_cv_func_copysignl_no_libm = yes; then
+ AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1],
+ [Define if the copysignl function is declared in <math.h> and available in libc.])
+ fi
+ fi
fi
- fi
- fi
- fi
- fi
+ ;;
+ esac
+ ;;
+ esac
])
AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[
diff --git a/gl/m4/sleep.m4 b/gl/m4/sleep.m4
index 7e736d454f..49197faf1a 100644
--- a/gl/m4/sleep.m4
+++ b/gl/m4/sleep.m4
@@ -1,4 +1,4 @@
-# sleep.m4 serial 6
+# sleep.m4 serial 7
dnl Copyright (C) 2007-2012 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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_SLEEP],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
dnl We expect to see the declaration of sleep() in a header file.
dnl Older versions of mingw have a sleep() function that is an alias to
dnl _sleep() in MSVCRT. It has a different signature than POSIX sleep():
@@ -44,9 +45,18 @@ handle_alarm (int sig)
return 0;
]])],
[gl_cv_func_sleep_works=yes], [gl_cv_func_sleep_works=no],
- [gl_cv_func_sleep_works="guessing no"])])
- if test "$gl_cv_func_sleep_works" != yes; then
- REPLACE_SLEEP=1
- fi
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_sleep_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_sleep_works="guessing no" ;;
+ esac
+ ])])
+ case "$gl_cv_func_sleep_works" in
+ *yes) ;;
+ *)
+ REPLACE_SLEEP=1
+ ;;
+ esac
fi
])
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
index d67dbcdecd..a8b79f5bcb 100644
--- a/gl/m4/stat.m4
+++ b/gl/m4/stat.m4
@@ -1,4 +1,4 @@
-# serial 8
+# serial 10
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
#
@@ -23,8 +23,9 @@ AC_DEFUN([gl_FUNC_STAT],
mingw*) gl_cv_func_stat_dir_slash="guessing no";;
*) gl_cv_func_stat_dir_slash="guessing yes";;
esac])])
- dnl AIX 7.1, Solaris 9 mistakenly succeed on stat("file/")
- dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
+ dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
+ dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
+ dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
AC_CACHE_CHECK([whether stat handles trailing slashes on files],
[gl_cv_func_stat_file_slash],
[touch conftest.tmp
@@ -46,7 +47,13 @@ AC_DEFUN([gl_FUNC_STAT],
return result;
]])],
[gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
- [gl_cv_func_stat_file_slash="guessing no"])
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_stat_file_slash="guessing no" ;;
+ esac
+ ])
rm -f conftest.tmp conftest.lnk])
case $gl_cv_func_stat_dir_slash in
*no) REPLACE_STAT=1
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index 6bf14ef178..1c96e526da 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,4 +1,4 @@
-# strerror.m4 serial 16
+# strerror.m4 serial 17
dnl Copyright (C) 2002, 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,7 @@ AC_DEFUN([gl_FUNC_STRERROR],
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
AC_REQUIRE([gl_HEADER_ERRNO_H])
AC_REQUIRE([gl_FUNC_STRERROR_0])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
])
@@ -22,14 +23,22 @@ AC_DEFUN([gl_FUNC_STRERROR],
[[if (!*strerror (-2)) return 1;]])],
[gl_cv_func_working_strerror=yes],
[gl_cv_func_working_strerror=no],
- [dnl Be pessimistic on cross-compiles for now.
- gl_cv_func_working_strerror="guessing no"])
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_working_strerror="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_working_strerror="guessing no" ;;
+ esac
+ ])
])
- if test "$gl_cv_func_working_strerror" != yes; then
- dnl The system's strerror() fails to return a string for out-of-range
- dnl integers. Replace it.
- REPLACE_STRERROR=1
- fi
+ case "$gl_cv_func_working_strerror" in
+ *yes) ;;
+ *)
+ dnl The system's strerror() fails to return a string for out-of-range
+ dnl integers. Replace it.
+ REPLACE_STRERROR=1
+ ;;
+ esac
m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's
dnl buffer, we must replace strerror.
@@ -48,6 +57,7 @@ dnl Detect if strerror(0) passes (that is, does not set errno, and does not
dnl return a string that matches strerror(-1)).
AC_DEFUN([gl_FUNC_STRERROR_0],
[
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
REPLACE_STRERROR_0=0
AC_CACHE_CHECK([whether strerror(0) succeeds],
[gl_cv_func_strerror_0_works],
@@ -67,12 +77,20 @@ AC_DEFUN([gl_FUNC_STRERROR_0],
return result;]])],
[gl_cv_func_strerror_0_works=yes],
[gl_cv_func_strerror_0_works=no],
- [dnl Be pessimistic on cross-compiles for now.
- gl_cv_func_strerror_0_works="guessing no"])
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_strerror_0_works="guessing no" ;;
+ esac
+ ])
])
- if test "$gl_cv_func_strerror_0_works" != yes; then
- REPLACE_STRERROR_0=1
- AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0)
- does not return a message implying success.])
- fi
+ case "$gl_cv_func_strerror_0_works" in
+ *yes) ;;
+ *)
+ REPLACE_STRERROR_0=1
+ AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0)
+ does not return a message implying success.])
+ ;;
+ esac
])
diff --git a/gl/m4/symlink.m4 b/gl/m4/symlink.m4
index f84b21e40e..cfd90ec2b6 100644
--- a/gl/m4/symlink.m4
+++ b/gl/m4/symlink.m4
@@ -1,4 +1,4 @@
-# serial 5
+# serial 6
# See if we need to provide symlink replacement.
dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
@@ -11,6 +11,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_SYMLINK],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CHECK_FUNCS_ONCE([symlink])
dnl The best we can do on mingw is provide a dummy that always fails, so
dnl that compilation can proceed with fewer ifdefs. On FreeBSD 7.2, AIX 7.1,
@@ -34,10 +35,19 @@ AC_DEFUN([gl_FUNC_SYMLINK],
return result;
]])],
[gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
- [gl_cv_func_symlink_works="guessing no"])
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_symlink_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_symlink_works="guessing no" ;;
+ esac
+ ])
rm -f conftest.f conftest.link conftest.lnk2])
- if test "$gl_cv_func_symlink_works" != yes; then
- REPLACE_SYMLINK=1
- fi
+ case "$gl_cv_func_symlink_works" in
+ *yes) ;;
+ *)
+ REPLACE_SYMLINK=1
+ ;;
+ esac
fi
])
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
index a0b96bc376..f45dee1dc4 100644
--- a/gl/m4/sys_stat_h.m4
+++ b/gl/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
-# sys_stat_h.m4 serial 26 -*- Autoconf -*-
+# sys_stat_h.m4 serial 27 -*- Autoconf -*-
dnl Copyright (C) 2006-2012 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,19 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H],
dnl Ensure the type mode_t gets defined.
AC_REQUIRE([AC_TYPE_MODE_T])
+ dnl Whether to override 'struct stat'.
+ m4_ifdef([gl_LARGEFILE], [
+ AC_REQUIRE([gl_LARGEFILE])
+ ], [
+ WINDOWS_64_BIT_ST_SIZE=0
+ ])
+ AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
+ if test $WINDOWS_64_BIT_ST_SIZE = 1; then
+ AC_DEFINE([_GL_WINDOWS_64_BIT_ST_SIZE], [1],
+ [Define to 1 if Gnulib overrides 'struct stat' on Windows so that
+ struct stat.st_size becomes 64-bit.])
+ fi
+
dnl Define types that are supposed to be defined in <sys/types.h> or
dnl <sys/stat.h>.
AC_CHECK_TYPE([nlink_t], [],
diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4
index 8d18ddb4d1..f11eef2fe8 100644
--- a/gl/m4/sys_types_h.m4
+++ b/gl/m4/sys_types_h.m4
@@ -1,4 +1,4 @@
-# sys_types_h.m4 serial 2
+# sys_types_h.m4 serial 4
dnl Copyright (C) 2011-2012 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,6 +14,9 @@ AC_DEFUN([gl_SYS_TYPES_H],
dnl Ensure the type mode_t gets defined.
AC_REQUIRE([AC_TYPE_MODE_T])
+
+ dnl Whether to override the 'off_t' type.
+ AC_REQUIRE([gl_TYPE_OFF_T])
])
AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4
index 95bb3eb3b0..9bc1ce7635 100644
--- a/gl/m4/ungetc.m4
+++ b/gl/m4/ungetc.m4
@@ -1,4 +1,4 @@
-# ungetc.m4 serial 2
+# ungetc.m4 serial 3
dnl Copyright (C) 2009-2012 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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
[
AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([whether ungetc works on arbitrary bytes],
[gl_cv_func_ungetc_works],
@@ -27,10 +28,19 @@ AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
if (fgetc (f) != 'c') return 11;
fclose (f); remove ("conftest.tmp");])],
[gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
- [gl_cv_func_ungetc_works='guessing no'])
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_ungetc_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_ungetc_works="guessing no" ;;
+ esac
+ ])
])
- if test "$gl_cv_func_ungetc_works" != yes; then
- AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
- [Define to 1 if ungetc is broken when used on arbitrary bytes.])
- fi
+ case "$gl_cv_func_ungetc_works" in
+ *yes) ;;
+ *)
+ AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
+ [Define to 1 if ungetc is broken when used on arbitrary bytes.])
+ ;;
+ esac
])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 7595534fdf..7e7651b9d2 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 63
+# unistd_h.m4 serial 65
dnl Copyright (C) 2006-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -24,6 +24,9 @@ AC_DEFUN([gl_UNISTD_H],
dnl Ensure the type pid_t gets defined.
AC_REQUIRE([AC_TYPE_PID_T])
+ dnl Determine WINDOWS_64_BIT_OFF_T.
+ AC_REQUIRE([gl_TYPE_OFF_T])
+
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([[
@@ -155,6 +158,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
+ REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
diff --git a/gl/m4/warnings.m4 b/gl/m4/warnings.m4
index c14c4801e7..28b8294ef0 100644
--- a/gl/m4/warnings.m4
+++ b/gl/m4/warnings.m4
@@ -1,4 +1,4 @@
-# warnings.m4 serial 6
+# warnings.m4 serial 7
dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -15,28 +15,47 @@ m4_ifdef([AS_VAR_APPEND],
[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
-# gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
-# ------------------------------------------------
-# Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
-# gl_WARN_ADD([-Wparentheses]).
+# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED],
+# [PROGRAM = AC_LANG_PROGRAM()])
+# -----------------------------------------------------------------
+# Check if the compiler supports OPTION when compiling PROGRAM.
#
-# If VARIABLE is a variable name, AC_SUBST it.
-AC_DEFUN([gl_WARN_ADD],
-dnl FIXME: gl_Warn must be used unquoted until we can assume
-dnl autoconf 2.64 or newer.
+# FIXME: gl_Warn must be used unquoted until we can assume Autoconf
+# 2.64 or newer.
+AC_DEFUN([gl_COMPILER_OPTION_IF],
[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
gl_save_compiler_FLAGS="$gl_Flags"
- gl_Flags="$gl_Flags $1"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+ gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $1"])
+ AC_COMPILE_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])],
[AS_VAR_SET(gl_Warn, [yes])],
[AS_VAR_SET(gl_Warn, [no])])
gl_Flags="$gl_save_compiler_FLAGS"
])
-AS_VAR_IF(gl_Warn, [yes],
- [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])])
+AS_VAR_IF(gl_Warn, [yes], [$2], [$3])
AS_VAR_POPDEF([gl_Flags])dnl
AS_VAR_POPDEF([gl_Warn])dnl
-m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
])
+
+
+# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS],
+# [PROGRAM = AC_LANG_PROGRAM()])
+# ---------------------------------------------
+# Adds parameter to WARN_CFLAGS if the compiler supports it when
+# compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]).
+#
+# If VARIABLE is a variable name, AC_SUBST it.
+AC_DEFUN([gl_WARN_ADD],
+[gl_COMPILER_OPTION_IF([$1],
+ [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])],
+ [],
+ [$3])
+m4_ifval([$2],
+ [AS_LITERAL_IF([$2], [AC_SUBST([$2])])],
+ [AC_SUBST([WARN_CFLAGS])])dnl
+])
+
+# Local Variables:
+# mode: autoconf
+# End:
diff --git a/gl/select.c b/gl/select.c
index d1360f0dbd..d6acb5c371 100644
--- a/gl/select.c
+++ b/gl/select.c
@@ -385,6 +385,10 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
}
}
+ /* Place a sentinel at the end of the array. */
+ handle_array[nhandles] = NULL;
+
+restart:
if (wait_timeout == 0 || nsock == 0)
rc = 0;
else
@@ -427,13 +431,44 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
if (rc == 0 && nsock > 0)
rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
+ if (nhandles > 1)
+ {
+ /* Count results that are not counted in the return value of select. */
+ nhandles = 1;
+ for (i = 0; i < nfds; i++)
+ {
+ if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
+ continue;
+
+ h = (HANDLE) _get_osfhandle (i);
+ if (h == handle_array[nhandles])
+ {
+ /* Not a socket. */
+ nhandles++;
+ windows_poll_handle (h, i, &rbits, &wbits, &xbits);
+ if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))
+ || wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))
+ || xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+ rc++;
+ }
+ }
+
+ if (rc == 0 && wait_timeout == INFINITE)
+ {
+ /* Sleep 1 millisecond to avoid busy wait and retry with the
+ original fd_sets. */
+ memcpy (&handle_rfds, rfds, sizeof (fd_set));
+ memcpy (&handle_wfds, wfds, sizeof (fd_set));
+ memcpy (&handle_xfds, xfds, sizeof (fd_set));
+ SleepEx (1, TRUE);
+ goto restart;
+ }
+ }
+
/* Now fill in the results. */
FD_ZERO (rfds);
FD_ZERO (wfds);
FD_ZERO (xfds);
-
- /* Place a sentinel at the end of the array. */
- handle_array[nhandles] = NULL;
nhandles = 1;
for (i = 0; i < nfds; i++)
{
@@ -443,8 +478,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
h = (HANDLE) _get_osfhandle (i);
if (h != handle_array[nhandles])
{
- /* Perform handle->descriptor mapping. Don't update rc, as these
- results are counted in the return value of Winsock's select. */
+ /* Perform handle->descriptor mapping. */
WSAEventSelect ((SOCKET) h, NULL, 0);
if (FD_ISSET (h, &handle_rfds))
FD_SET (i, rfds);
@@ -457,22 +491,12 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
{
/* Not a socket. */
nhandles++;
- windows_poll_handle (h, i, &rbits, &wbits, &xbits);
if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
- {
- rc++;
- FD_SET (i, rfds);
- }
+ FD_SET (i, rfds);
if (wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
- {
- rc++;
- FD_SET (i, wfds);
- }
+ FD_SET (i, wfds);
if (xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
- {
- rc++;
- FD_SET (i, xfds);
- }
+ FD_SET (i, xfds);
}
}
@@ -482,6 +506,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
#else /* ! Native Windows. */
#include <sys/select.h>
+#include <stddef.h> /* NULL */
#undef select
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index 8e4c8228ca..59c00d59c0 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -90,7 +90,8 @@
# include <sys/types.h>
#endif
-/* Get LONG_MIN, LONG_MAX, ULONG_MAX. */
+/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
+ LONG_MIN, LONG_MAX, ULONG_MAX. */
#include <limits.h>
#if @HAVE_INTTYPES_H@
@@ -246,8 +247,9 @@ typedef unsigned long long int gl_uint64_t;
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
- are taken from the same list of types. Assume that 'long int'
- is fast enough for all narrower integers. */
+ are taken from the same list of types. The following code normally
+ uses types consistent with glibc, as that lessens the chance of
+ incompatibility with older GNU hosts. */
#undef int_fast8_t
#undef uint_fast8_t
@@ -257,12 +259,21 @@ typedef unsigned long long int gl_uint64_t;
#undef uint_fast32_t
#undef int_fast64_t
#undef uint_fast64_t
-typedef long int gl_int_fast8_t;
-typedef unsigned long int gl_uint_fast8_t;
-typedef long int gl_int_fast16_t;
-typedef unsigned long int gl_uint_fast16_t;
+typedef signed char gl_int_fast8_t;
+typedef unsigned char gl_uint_fast8_t;
+
+#ifdef __sun
+/* Define types compatible with SunOS 5.10, so that code compiled under
+ earlier SunOS versions works with code compiled under SunOS 5.10. */
+typedef int gl_int_fast32_t;
+typedef unsigned int gl_uint_fast32_t;
+#else
typedef long int gl_int_fast32_t;
typedef unsigned long int gl_uint_fast32_t;
+#endif
+typedef gl_int_fast32_t gl_int_fast16_t;
+typedef gl_uint_fast32_t gl_uint_fast16_t;
+
#define int_fast8_t gl_int_fast8_t
#define uint_fast8_t gl_uint_fast8_t
#define int_fast16_t gl_int_fast16_t
@@ -418,23 +429,29 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
#undef INT_FAST8_MIN
#undef INT_FAST8_MAX
#undef UINT_FAST8_MAX
-#define INT_FAST8_MIN LONG_MIN
-#define INT_FAST8_MAX LONG_MAX
-#define UINT_FAST8_MAX ULONG_MAX
+#define INT_FAST8_MIN SCHAR_MIN
+#define INT_FAST8_MAX SCHAR_MAX
+#define UINT_FAST8_MAX UCHAR_MAX
#undef INT_FAST16_MIN
#undef INT_FAST16_MAX
#undef UINT_FAST16_MAX
-#define INT_FAST16_MIN LONG_MIN
-#define INT_FAST16_MAX LONG_MAX
-#define UINT_FAST16_MAX ULONG_MAX
+#define INT_FAST16_MIN INT_FAST32_MIN
+#define INT_FAST16_MAX INT_FAST32_MAX
+#define UINT_FAST16_MAX UINT_FAST32_MAX
#undef INT_FAST32_MIN
#undef INT_FAST32_MAX
#undef UINT_FAST32_MAX
-#define INT_FAST32_MIN LONG_MIN
-#define INT_FAST32_MAX LONG_MAX
-#define UINT_FAST32_MAX ULONG_MAX
+#ifdef __sun
+# define INT_FAST32_MIN INT_MIN
+# define INT_FAST32_MAX INT_MAX
+# define UINT_FAST32_MAX UINT_MAX
+#else
+# define INT_FAST32_MIN LONG_MIN
+# define INT_FAST32_MAX LONG_MAX
+# define UINT_FAST32_MAX ULONG_MAX
+#endif
#undef INT_FAST64_MIN
#undef INT_FAST64_MAX
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 4d3f0bb7b5..b1b543dee7 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -52,7 +52,8 @@
#include <stddef.h>
/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
- and eglibc 2.11.2. */
+ and eglibc 2.11.2.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* The __attribute__ feature is available in gcc versions 2.5 and later.
diff --git a/gl/strerror-override.c b/gl/strerror-override.c
index 9ca6523490..9f55cfa9ac 100644
--- a/gl/strerror-override.c
+++ b/gl/strerror-override.c
@@ -89,6 +89,8 @@ strerror_override (int errnum)
return "No route to host";
case EWOULDBLOCK:
return "Operation would block";
+#endif
+#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
case ETXTBSY:
return "Text file busy";
case ENODATA:
@@ -97,10 +99,6 @@ strerror_override (int errnum)
return "Out of streams resources";
case ENOSTR:
return "Device not a stream";
- case ENOTRECOVERABLE:
- return "State not recoverable";
- case EOWNERDEAD:
- return "Owner died";
case ETIME:
return "Timer expired";
case EOTHER:
@@ -283,6 +281,16 @@ strerror_override (int errnum)
return "Operation canceled";
#endif
+#if GNULIB_defined_EOWNERDEAD
+ case EOWNERDEAD:
+ return "Owner died";
+#endif
+
+#if GNULIB_defined_ENOTRECOVERABLE
+ case ENOTRECOVERABLE:
+ return "State not recoverable";
+#endif
+
default:
return NULL;
}
diff --git a/gl/strerror-override.h b/gl/strerror-override.h
index 09526ea91a..fe1fb2c229 100644
--- a/gl/strerror-override.h
+++ b/gl/strerror-override.h
@@ -30,6 +30,7 @@
describing the error. Otherwise return NULL. */
# if REPLACE_STRERROR_0 \
|| GNULIB_defined_ESOCK \
+ || GNULIB_defined_ESTREAMS \
|| GNULIB_defined_EWINSOCK \
|| GNULIB_defined_ENOMSG \
|| GNULIB_defined_EIDRM \
@@ -43,7 +44,9 @@
|| GNULIB_defined_ECONNABORTED \
|| GNULIB_defined_ESTALE \
|| GNULIB_defined_EDQUOT \
- || GNULIB_defined_ECANCELED
+ || GNULIB_defined_ECANCELED \
+ || GNULIB_defined_EOWNERDEAD \
+ || GNULIB_defined_ENOTRECOVERABLE
extern const char *strerror_override (int errnum);
# else
# define strerror_override(ignored) NULL
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
index e4331c78cf..2efc1e92e0 100644
--- a/gl/sys_stat.in.h
+++ b/gl/sys_stat.in.h
@@ -35,7 +35,8 @@
#ifndef _@GUARD_PREFIX@_SYS_STAT_H
-/* Get nlink_t. */
+/* Get nlink_t.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* Get struct timespec. */
@@ -66,6 +67,11 @@
# include <io.h>
#endif
+/* Large File Support on native Windows. */
+#if @WINDOWS_64_BIT_ST_SIZE@
+# define stat _stati64
+#endif
+
#ifndef S_IFIFO
# ifdef _S_IFIFO
# define S_IFIFO _S_IFIFO
@@ -335,6 +341,9 @@ _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
# endif
_GL_CXXALIASWARN (fstat);
+#elif @WINDOWS_64_BIT_ST_SIZE@
+/* Above, we define stat to _stati64. */
+# define fstat _fstati64
#elif defined GNULIB_POSIXCHECK
# undef fstat
# if HAVE_RAW_DECL_FSTAT
@@ -620,6 +629,28 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
so we have to replace stat64() instead of stat(). */
# undef stat64
# define stat64(name, st) rpl_stat (name, st)
+# elif @WINDOWS_64_BIT_ST_SIZE@
+ /* Above, we define stat to _stati64. */
+# if defined __MINGW32__ && defined _stati64
+# ifndef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# elif defined _MSC_VER && defined _stati64
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat32i64. */
+# undef _stat32i64
+# define _stat32i64(name, st) rpl_stat (name, st)
+# else
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# else
+# undef _stati64
+# define _stati64(name, st) rpl_stat (name, st)
+# endif
# elif defined __MINGW32__ && defined stat
# ifdef _USE_32BIT_TIME_T
/* The system headers define stat to _stat32i64. */
diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h
index 574fe518ea..8139d98f6a 100644
--- a/gl/sys_types.in.h
+++ b/gl/sys_types.in.h
@@ -28,6 +28,18 @@
#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
#define _@GUARD_PREFIX@_SYS_TYPES_H
+/* Override off_t if Large File Support is requested on native Windows. */
+#if @WINDOWS_64_BIT_OFF_T@
+/* Same as int64_t in <stdint.h>. */
+# if defined _MSC_VER
+# define off_t __int64
+# else
+# define off_t long long int
+# endif
+/* Indicator, for gnulib internal purposes. */
+# define _GL_WINDOWS_64_BIT_OFF_T 1
+#endif
+
/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
/* But avoid namespace pollution on glibc systems. */
#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
diff --git a/gl/tests/binary-io.h b/gl/tests/binary-io.h
index 824ad5b78a..a33e32aee2 100644
--- a/gl/tests/binary-io.h
+++ b/gl/tests/binary-io.h
@@ -25,28 +25,41 @@
so we include it here first. */
#include <stdio.h>
-/* SET_BINARY (fd);
- changes the file descriptor fd to perform binary I/O. */
+/* set_binary_mode (fd, mode)
+ sets the binary/text I/O mode of file descriptor fd to the given mode
+ (must be O_BINARY or O_TEXT) and returns the previous mode. */
#if O_BINARY
# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
# include <io.h> /* declares setmode() */
+# define set_binary_mode setmode
# else
-# define setmode _setmode
+# define set_binary_mode _setmode
# undef fileno
# define fileno _fileno
# endif
-# ifdef __DJGPP__
-# include <unistd.h> /* declares isatty() */
- /* Avoid putting stdin/stdout in binary mode if it is connected to
- the console, because that would make it impossible for the user
- to interrupt the program through Ctrl-C or Ctrl-Break. */
-# define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0))
-# else
-# define SET_BINARY(fd) ((void) setmode (fd, O_BINARY))
-# endif
#else
- /* On reasonable systems, binary I/O is the default. */
-# define SET_BINARY(fd) /* do nothing */ ((void) 0)
+ /* On reasonable systems, binary I/O is the only choice. */
+ /* Use an inline function rather than a macro, to avoid gcc warnings
+ "warning: statement with no effect". */
+static inline int
+set_binary_mode (int fd, int mode)
+{
+ (void) fd;
+ (void) mode;
+ return O_BINARY;
+}
+#endif
+
+/* SET_BINARY (fd);
+ changes the file descriptor fd to perform binary I/O. */
+#ifdef __DJGPP__
+# include <unistd.h> /* declares isatty() */
+ /* Avoid putting stdin/stdout in binary mode if it is connected to
+ the console, because that would make it impossible for the user
+ to interrupt the program through Ctrl-C or Ctrl-Break. */
+# define SET_BINARY(fd) ((void) (!isatty (fd) ? (set_binary_mode (fd, O_BINARY), 0) : 0))
+#else
+# define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY))
#endif
#endif /* _BINARY_H */
diff --git a/gl/tests/fcntl.in.h b/gl/tests/fcntl.in.h
index 344bbe4d3d..76e12f78a6 100644
--- a/gl/tests/fcntl.in.h
+++ b/gl/tests/fcntl.in.h
@@ -25,6 +25,8 @@
#if defined __need_system_fcntl_h
/* Special invocation convention. */
+/* Needed before <sys/stat.h>.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
@@ -42,6 +44,8 @@
#ifndef _@GUARD_PREFIX@_FCNTL_H
+/* Needed before <sys/stat.h>.
+ May also define off_t to a 64-bit type on native Windows. */
#include <sys/types.h>
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
diff --git a/gl/tests/ftruncate.c b/gl/tests/ftruncate.c
index ae1e85890c..e243adda60 100644
--- a/gl/tests/ftruncate.c
+++ b/gl/tests/ftruncate.c
@@ -1,5 +1,18 @@
/* ftruncate emulations for native Windows.
- This file is in the public domain. */
+ Copyright (C) 1992-2012 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
@@ -7,12 +20,143 @@
#include <unistd.h>
#if HAVE_CHSIZE
+/* A native Windows platform. */
# include <errno.h>
-# include <io.h>
-# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-# include "msvc-inval.h"
+# if _GL_WINDOWS_64_BIT_OFF_T
+
+/* Large File Support: off_t is 64-bit, but chsize() takes only a 32-bit
+ argument. So, define a 64-bit safe SetFileSize function ourselves. */
+
+/* Ensure that <windows.h> declares GetFileSizeEx. */
+# undef _WIN32_WINNT
+# define _WIN32_WINNT 0x500
+
+/* Get declarations of the native Windows API functions. */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+/* Get _get_osfhandle. */
+# include "msvc-nothrow.h"
+
+static BOOL
+SetFileSize (HANDLE h, LONGLONG size)
+{
+ LARGE_INTEGER old_size;
+
+ if (!GetFileSizeEx (h, &old_size))
+ return FALSE;
+
+ if (size != old_size.QuadPart)
+ {
+ /* Duplicate the handle, so we are free to modify its file position. */
+ HANDLE curr_process = GetCurrentProcess ();
+ HANDLE tmph;
+
+ if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
+ h, /* SourceHandle */
+ curr_process, /* TargetProcessHandle */
+ (PHANDLE) &tmph, /* TargetHandle */
+ (DWORD) 0, /* DesiredAccess */
+ FALSE, /* InheritHandle */
+ DUPLICATE_SAME_ACCESS)) /* Options */
+ return FALSE;
+
+ if (size < old_size.QuadPart)
+ {
+ /* Reduce the size. */
+ LONG size_hi = (LONG) (size >> 32);
+ if (SetFilePointer (tmph, (LONG) size, &size_hi, FILE_BEGIN)
+ == INVALID_SET_FILE_POINTER
+ && GetLastError() != NO_ERROR)
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ if (!SetEndOfFile (tmph))
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Increase the size by adding zero bytes at the end. */
+ static char zero_bytes[1024];
+ LONG pos_hi = 0;
+ LONG pos_lo = SetFilePointer (tmph, (LONG) 0, &pos_hi, FILE_END);
+ LONGLONG pos;
+ if (pos_lo == INVALID_SET_FILE_POINTER
+ && GetLastError() != NO_ERROR)
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ pos = ((LONGLONG) pos_hi << 32) | (ULONGLONG) (ULONG) pos_lo;
+ while (pos < size)
+ {
+ DWORD written;
+ LONGLONG count = size - pos;
+ if (count > sizeof (zero_bytes))
+ count = sizeof (zero_bytes);
+ if (!WriteFile (tmph, zero_bytes, (DWORD) count, &written, NULL)
+ || written == 0)
+ {
+ CloseHandle (tmph);
+ return FALSE;
+ }
+ pos += (ULONGLONG) (ULONG) written;
+ }
+ }
+ /* Close the handle. */
+ CloseHandle (tmph);
+ }
+ return TRUE;
+}
+
+int
+ftruncate (int fd, off_t length)
+{
+ HANDLE handle = (HANDLE) _get_osfhandle (fd);
+
+ if (handle == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ if (length < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ if (!SetFileSize (handle, length))
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_ACCESS_DENIED:
+ errno = EACCES;
+ break;
+ case ERROR_HANDLE_DISK_FULL:
+ case ERROR_DISK_FULL:
+ case ERROR_DISK_TOO_FRAGMENTED:
+ errno = ENOSPC;
+ break;
+ default:
+ errno = EIO;
+ break;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+# else
+
+# include <io.h>
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
static inline int
chsize_nothrow (int fd, long length)
{
@@ -31,8 +175,8 @@ chsize_nothrow (int fd, long length)
return result;
}
-# define chsize chsize_nothrow
-# endif
+# define chsize chsize_nothrow
+# endif
int
ftruncate (int fd, off_t length)
@@ -40,4 +184,5 @@ ftruncate (int fd, off_t length)
return chsize (fd, length);
}
+# endif
#endif
diff --git a/gl/tests/ignore-value.h b/gl/tests/ignore-value.h
index 52919de8f1..2e34435094 100644
--- a/gl/tests/ignore-value.h
+++ b/gl/tests/ignore-value.h
@@ -35,16 +35,6 @@
#ifndef _GL_IGNORE_VALUE_H
# define _GL_IGNORE_VALUE_H
-# ifndef _GL_ATTRIBUTE_DEPRECATED
-/* The __attribute__((__deprecated__)) feature
- is available in gcc versions 3.1 and newer. */
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
-# define _GL_ATTRIBUTE_DEPRECATED /* empty */
-# else
-# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
-# endif
-# endif
-
/* The __attribute__((__warn_unused_result__)) feature
is available in gcc versions 3.4 and newer,
while the typeof feature has been available since 2.7 at least. */
diff --git a/gl/tests/init.sh b/gl/tests/init.sh
index ae867144d0..f525a7cab4 100644
--- a/gl/tests/init.sh
+++ b/gl/tests/init.sh
@@ -207,6 +207,14 @@ else
fi
fi
+# If this is bash, turn off all aliases.
+test -n "$BASH_VERSION" && unalias -a
+
+# Note that when supporting $EXEEXT (transparently mapping from PROG_NAME to
+# PROG_NAME.exe), we want to support hyphen-containing names like test-acos.
+# That is part of the shell-selection test above. Why use aliases rather
+# than functions? Because support for hyphen-containing aliases is more
+# widespread than that for hyphen-containing function names.
test -n "$EXEEXT" && shopt -s expand_aliases
# Enable glibc's malloc-perturbing option.
diff --git a/gl/tests/stat.c b/gl/tests/stat.c
index 9ea53c1c0c..1fc633eeef 100644
--- a/gl/tests/stat.c
+++ b/gl/tests/stat.c
@@ -27,6 +27,20 @@
#include <sys/stat.h>
#undef __need_system_sys_stat_h
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if _GL_WINDOWS_64_BIT_ST_SIZE
+# define stat _stati64
+# define REPLACE_FUNC_STAT_DIR 1
+# undef REPLACE_FUNC_STAT_FILE
+# elif REPLACE_FUNC_STAT_FILE
+/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
+ Bypass it. */
+# define stat _stat
+# define REPLACE_FUNC_STAT_DIR 1
+# undef REPLACE_FUNC_STAT_FILE
+# endif
+#endif
+
static inline int
orig_stat (const char *filename, struct stat *buf)
{
diff --git a/gl/tests/test-binary-io.c b/gl/tests/test-binary-io.c
index c695454ecd..4f284e7015 100644
--- a/gl/tests/test-binary-io.c
+++ b/gl/tests/test-binary-io.c
@@ -30,26 +30,40 @@
#include "macros.h"
int
-main ()
+main (int argc, char *argv[])
{
/* Test the O_BINARY macro. */
{
int fd =
- open ("t-bin-out2.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600);
+ open ("t-bin-out0.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600);
if (write (fd, "Hello\n", 6) < 0)
exit (1);
close (fd);
}
{
struct stat statbuf;
- if (stat ("t-bin-out2.tmp", &statbuf) < 0)
+ if (stat ("t-bin-out0.tmp", &statbuf) < 0)
exit (1);
ASSERT (statbuf.st_size == 6);
}
- /* Test the SET_BINARY macro. */
- SET_BINARY (1);
- fputs ("Hello\n", stdout);
+ switch (argv[1][0])
+ {
+ case '1':
+ /* Test the set_binary_mode() function. */
+ set_binary_mode (1, O_BINARY);
+ fputs ("Hello\n", stdout);
+ break;
+
+ case '2':
+ /* Test the SET_BINARY macro. */
+ SET_BINARY (1);
+ fputs ("Hello\n", stdout);
+ break;
+
+ default:
+ break;
+ }
return 0;
}
diff --git a/gl/tests/test-binary-io.sh b/gl/tests/test-binary-io.sh
index 272edef179..c4dd6e9295 100755
--- a/gl/tests/test-binary-io.sh
+++ b/gl/tests/test-binary-io.sh
@@ -3,9 +3,11 @@
tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15
-tmpfiles="$tmpfiles t-bin-out1.tmp t-bin-out2.tmp"
-./test-binary-io${EXEEXT} > t-bin-out1.tmp || exit 1
-cmp t-bin-out1.tmp t-bin-out2.tmp > /dev/null || exit 1
+tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp t-bin-out2.tmp"
+./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1
+cmp t-bin-out0.tmp t-bin-out1.tmp > /dev/null || exit 1
+./test-binary-io${EXEEXT} 2 > t-bin-out2.tmp || exit 1
+cmp t-bin-out0.tmp t-bin-out2.tmp > /dev/null || exit 1
rm -fr $tmpfiles
diff --git a/gl/tests/test-errno.c b/gl/tests/test-errno.c
index d9a030f448..8d0071741f 100644
--- a/gl/tests/test-errno.c
+++ b/gl/tests/test-errno.c
@@ -98,6 +98,8 @@ int e115 = EINPROGRESS;
int e116 = ESTALE;
int e122 = EDQUOT;
int e125 = ECANCELED;
+int e130 = EOWNERDEAD;
+int e131 = ENOTRECOVERABLE;
/* Don't verify that these errno values are all different, except for possibly
EWOULDBLOCK == EAGAIN. Even Linux/x86 does not pass this check: it has
diff --git a/gl/u64.h b/gl/u64.h
index dadd6d741f..f5ec9ebcb3 100644
--- a/gl/u64.h
+++ b/gl/u64.h
@@ -30,6 +30,7 @@ typedef uint64_t u64;
# define u64hilo(hi, lo) ((u64) (((u64) (hi) << 32) + (lo)))
# define u64init(hi, lo) u64hilo (hi, lo)
# define u64lo(x) ((u64) (x))
+# define u64size(x) u64lo (x)
# define u64lt(x, y) ((x) < (y))
# define u64and(x, y) ((x) & (y))
# define u64or(x, y) ((x) | (y))
@@ -72,6 +73,16 @@ u64lo (uint32_t lo)
return r;
}
+/* Return a u64 value representing SIZE. */
+static inline u64
+u64size (size_t size)
+{
+ u64 r;
+ r.hi = size >> 31 >> 1;
+ r.lo = size;
+ return r;
+}
+
/* Return X < Y. */
static inline int
u64lt (u64 x, u64 y)
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 1b26c09707..9115486cf3 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -107,8 +107,9 @@
# include <netdb.h>
#endif
-/* MSVC defines off_t in <sys/types.h>. */
-#if !@HAVE_UNISTD_H@
+/* MSVC defines off_t in <sys/types.h>.
+ May also define off_t to a 64-bit type on native Windows. */
+#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
/* Get off_t. */
# include <sys/types.h>
#endif
@@ -562,10 +563,19 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2008 specification
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
-# if !@HAVE_FTRUNCATE@
+# if @REPLACE_FTRUNCATE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ftruncate
+# define ftruncate rpl_ftruncate
+# endif
+_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
+_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
+# else
+# if !@HAVE_FTRUNCATE@
_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
-# endif
+# endif
_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
+# endif
_GL_CXXALIASWARN (ftruncate);
#elif defined GNULIB_POSIXCHECK
# undef ftruncate