summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-06-06 08:56:03 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-06-07 00:44:45 -0700
commit111408a0e9eb3a9492c4057ac7d6ddbb8b365aa9 (patch)
tree9b3928219a0a3f0ff4c8fd123bb5b1a2f23df0e2 /lib
parenta14eb43215b5cbb99175d2b23f582011948b2eaa (diff)
downloademacs-111408a0e9eb3a9492c4057ac7d6ddbb8b365aa9.tar.gz
Update from Gnulib
This incorporates: 2019-06-04 copy-file-range: new module 2019-05-28 binaty-io: O_BINARY on consoles no longer fails * doc/misc/texinfo.tex, lib/binary-io.c, lib/binary-io.h: * lib/unistd.in.h, m4/unistd_h.m4: Copy from Gnulib. * lib/gnulib.mk.in: Regenerate.
Diffstat (limited to 'lib')
-rw-r--r--lib/binary-io.c16
-rw-r--r--lib/binary-io.h14
-rw-r--r--lib/gnulib.mk.in4
-rw-r--r--lib/unistd.in.h18
4 files changed, 36 insertions, 16 deletions
diff --git a/lib/binary-io.c b/lib/binary-io.c
index 01e0bf64765..77490e68e3b 100644
--- a/lib/binary-io.c
+++ b/lib/binary-io.c
@@ -20,18 +20,20 @@
#include "binary-io.h"
#if defined __DJGPP__ || defined __EMX__
-# include <errno.h>
# include <unistd.h>
int
-__gl_setmode_check (int fd)
+set_binary_mode (int fd, int mode)
{
if (isatty (fd))
- {
- errno = EINVAL;
- return -1;
- }
+ /* If FD refers to a console (not a pipe, not a regular file),
+ O_TEXT is the only reasonable mode, both on input and on output.
+ Silently ignore the request. If we were to return -1 here,
+ all programs that use xset_binary_mode would fail when run
+ with console input or console output. */
+ return O_TEXT;
else
- return 0;
+ return __gl_setmode (fd, mode);
}
+
#endif
diff --git a/lib/binary-io.h b/lib/binary-io.h
index 720b08c7551..8d4133b0f38 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -53,25 +53,21 @@ __gl_setmode (int fd _GL_UNUSED, int mode _GL_UNUSED)
}
#endif
-#if defined __DJGPP__ || defined __EMX__
-extern int __gl_setmode_check (int);
-#else
-BINARY_IO_INLINE int
-__gl_setmode_check (int fd _GL_UNUSED) { return 0; }
-#endif
-
/* Set FD's mode to MODE, which should be either O_TEXT or O_BINARY.
Return the old mode if successful, -1 (setting errno) on failure.
Ordinarily this function would be called 'setmode', since that is
its name on MS-Windows, but it is called 'set_binary_mode' here
to avoid colliding with a BSD function of another name. */
+#if defined __DJGPP__ || defined __EMX__
+extern int set_binary_mode (int fd, int mode);
+#else
BINARY_IO_INLINE int
set_binary_mode (int fd, int mode)
{
- int r = __gl_setmode_check (fd);
- return r != 0 ? r : __gl_setmode (fd, mode);
+ return __gl_setmode (fd, mode);
}
+#endif
/* This macro is obsolescent. */
#define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY))
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 1cbbff212bb..403d83829cd 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -252,6 +252,7 @@ GNULIB_CHDIR = @GNULIB_CHDIR@
GNULIB_CHOWN = @GNULIB_CHOWN@
GNULIB_CLOSE = @GNULIB_CLOSE@
GNULIB_CLOSEDIR = @GNULIB_CLOSEDIR@
+GNULIB_COPY_FILE_RANGE = @GNULIB_COPY_FILE_RANGE@
GNULIB_CTIME = @GNULIB_CTIME@
GNULIB_DIRFD = @GNULIB_DIRFD@
GNULIB_DPRINTF = @GNULIB_DPRINTF@
@@ -489,6 +490,7 @@ HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@
HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
HAVE_CHOWN = @HAVE_CHOWN@
HAVE_CLOSEDIR = @HAVE_CLOSEDIR@
+HAVE_COPY_FILE_RANGE = @HAVE_COPY_FILE_RANGE@
HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@
HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@
@@ -3115,6 +3117,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
-e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
-e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
+ -e 's/@''GNULIB_COPY_FILE_RANGE''@/$(GNULIB_COPY_FILE_RANGE)/g' \
-e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \
-e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \
-e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \
@@ -3165,6 +3168,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \
< $(srcdir)/unistd.in.h | \
sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
+ -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \
-e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
-e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
-e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 7778d25dc7e..94a8f383c99 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -331,6 +331,24 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
#endif
+#if @GNULIB_COPY_FILE_RANGE@
+# if !@HAVE_COPY_FILE_RANGE@
+_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
+ int ofd, off_t *opos,
+ size_t len, unsigned flags));
+_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
+ int ofd, off_t *opos,
+ size_t len, unsigned flags));
+# endif
+_GL_CXXALIASWARN (copy_file_range);
+#elif defined GNULIB_POSIXCHECK
+/* Assume copy_file_range is always declared. */
+_GL_WARN_ON_USE (copy_file_range,
+ "copy_file_range is unportable - "
+ "use gnulib module copy_file_range for portability");
+#endif
+
+
#if @GNULIB_DUP@
# if @REPLACE_DUP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)