aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--admin/ChangeLog3
-rwxr-xr-xadmin/merge-gnulib2
-rw-r--r--lib/binary-io.c3
-rw-r--r--lib/binary-io.h72
-rw-r--r--lib/gnulib.mk8
-rw-r--r--lib/pipe2.c13
-rw-r--r--m4/gnulib-comp.m43
8 files changed, 101 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index c9571aec61c..6a451c85cde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
12013-07-09 Paul Eggert <eggert@cs.ucla.edu> 12013-07-09 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Port recent close-on-exec changes to Cygwin (Bug#14821).
4 * lib/binary-io.c, lib/binary-io.h: New files.
5 Merge from gnulib, incorporating:
6 2013-07-09 accept4, dup3, pipe2: port to Cygwin
7 * lib/pipe2.c: Update from gnulib, as part of this merge.
8 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
9
3 Handle errno and exit status a bit more carefully. 10 Handle errno and exit status a bit more carefully.
4 * lib/ignore-value.h: Remove this gnulib-imported file. 11 * lib/ignore-value.h: Remove this gnulib-imported file.
5 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. 12 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
diff --git a/admin/ChangeLog b/admin/ChangeLog
index deb3059f8d2..b9dc8cbafdc 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,5 +1,8 @@
12013-07-09 Paul Eggert <eggert@cs.ucla.edu> 12013-07-09 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Port recent close-on-exec changes to Cygwin (Bug#14821).
4 * merge-gnulib (GNULIB_TOOL_FLAGS): Don't avoid binary-io.
5
3 Handle error numbers a bit more reliably. 6 Handle error numbers a bit more reliably.
4 * merge-gnulib (GNULIB_MODULES): Remove ignore-value. 7 * merge-gnulib (GNULIB_MODULES): Remove ignore-value.
5 8
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index be4dfdd409c..82e0cd77fca 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -41,7 +41,7 @@ GNULIB_MODULES='
41' 41'
42 42
43GNULIB_TOOL_FLAGS=' 43GNULIB_TOOL_FLAGS='
44 --avoid=binary-io --avoid=close --avoid=dup 44 --avoid=close --avoid=dup
45 --avoid=fchdir --avoid=fstat 45 --avoid=fchdir --avoid=fstat
46 --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow 46 --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow
47 --avoid=open --avoid=openat-die --avoid=opendir 47 --avoid=open --avoid=openat-die --avoid=opendir
diff --git a/lib/binary-io.c b/lib/binary-io.c
new file mode 100644
index 00000000000..8bbdb44d121
--- /dev/null
+++ b/lib/binary-io.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define BINARY_IO_INLINE _GL_EXTERN_INLINE
3#include "binary-io.h"
diff --git a/lib/binary-io.h b/lib/binary-io.h
new file mode 100644
index 00000000000..317fe3d3c20
--- /dev/null
+++ b/lib/binary-io.h
@@ -0,0 +1,72 @@
1/* Binary mode I/O.
2 Copyright (C) 2001, 2003, 2005, 2008-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _BINARY_H
18#define _BINARY_H
19
20/* For systems that distinguish between text and binary I/O.
21 O_BINARY is guaranteed by the gnulib <fcntl.h>. */
22#include <fcntl.h>
23
24/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...',
25 so we include it here first. */
26#include <stdio.h>
27
28_GL_INLINE_HEADER_BEGIN
29#ifndef BINARY_IO_INLINE
30# define BINARY_IO_INLINE _GL_INLINE
31#endif
32
33/* set_binary_mode (fd, mode)
34 sets the binary/text I/O mode of file descriptor fd to the given mode
35 (must be O_BINARY or O_TEXT) and returns the previous mode. */
36#if O_BINARY
37# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
38# include <io.h> /* declares setmode() */
39# define set_binary_mode setmode
40# else
41# define set_binary_mode _setmode
42# undef fileno
43# define fileno _fileno
44# endif
45#else
46 /* On reasonable systems, binary I/O is the only choice. */
47 /* Use a function rather than a macro, to avoid gcc warnings
48 "warning: statement with no effect". */
49BINARY_IO_INLINE int
50set_binary_mode (int fd, int mode)
51{
52 (void) fd;
53 (void) mode;
54 return O_BINARY;
55}
56#endif
57
58/* SET_BINARY (fd);
59 changes the file descriptor fd to perform binary I/O. */
60#ifdef __DJGPP__
61# include <unistd.h> /* declares isatty() */
62 /* Avoid putting stdin/stdout in binary mode if it is connected to
63 the console, because that would make it impossible for the user
64 to interrupt the program through Ctrl-C or Ctrl-Break. */
65# define SET_BINARY(fd) ((void) (!isatty (fd) ? (set_binary_mode (fd, O_BINARY), 0) : 0))
66#else
67# define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY))
68#endif
69
70_GL_INLINE_HEADER_END
71
72#endif /* _BINARY_H */
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 1bb1bea5f93..d053e15efc1 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=binary-io --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings 24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv utimens warnings
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -75,6 +75,12 @@ EXTRA_libgnu_a_SOURCES += openat-proc.c
75 75
76## end gnulib module at-internal 76## end gnulib module at-internal
77 77
78## begin gnulib module binary-io
79
80libgnu_a_SOURCES += binary-io.h binary-io.c
81
82## end gnulib module binary-io
83
78## begin gnulib module c-ctype 84## begin gnulib module c-ctype
79 85
80libgnu_a_SOURCES += c-ctype.h c-ctype.c 86libgnu_a_SOURCES += c-ctype.h c-ctype.c
diff --git a/lib/pipe2.c b/lib/pipe2.c
index 3858c328f76..211d75545c0 100644
--- a/lib/pipe2.c
+++ b/lib/pipe2.c
@@ -22,10 +22,7 @@
22#include <errno.h> 22#include <errno.h>
23#include <fcntl.h> 23#include <fcntl.h>
24 24
25#if GNULIB_BINARY_IO 25#include "binary-io.h"
26# include "binary-io.h"
27#endif
28
29#include "verify.h" 26#include "verify.h"
30 27
31#if GNULIB_defined_O_NONBLOCK 28#if GNULIB_defined_O_NONBLOCK
@@ -141,13 +138,13 @@ pipe2 (int fd[2], int flags)
141# if O_BINARY 138# if O_BINARY
142 if (flags & O_BINARY) 139 if (flags & O_BINARY)
143 { 140 {
144 setmode (fd[1], O_BINARY); 141 set_binary_mode (fd[1], O_BINARY);
145 setmode (fd[0], O_BINARY); 142 set_binary_mode (fd[0], O_BINARY);
146 } 143 }
147 else if (flags & O_TEXT) 144 else if (flags & O_TEXT)
148 { 145 {
149 setmode (fd[1], O_TEXT); 146 set_binary_mode (fd[1], O_TEXT);
150 setmode (fd[0], O_TEXT); 147 set_binary_mode (fd[0], O_TEXT);
151 } 148 }
152# endif 149# endif
153 150
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index a909927f319..d7062e862de 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -41,6 +41,7 @@ AC_DEFUN([gl_EARLY],
41 # Code from module alloca-opt: 41 # Code from module alloca-opt:
42 # Code from module allocator: 42 # Code from module allocator:
43 # Code from module at-internal: 43 # Code from module at-internal:
44 # Code from module binary-io:
44 # Code from module c-ctype: 45 # Code from module c-ctype:
45 # Code from module c-strcase: 46 # Code from module c-strcase:
46 # Code from module careadlinkat: 47 # Code from module careadlinkat:
@@ -754,6 +755,8 @@ AC_DEFUN([gl_FILE_LIST], [
754 lib/allocator.c 755 lib/allocator.c
755 lib/allocator.h 756 lib/allocator.h
756 lib/at-func.c 757 lib/at-func.c
758 lib/binary-io.c
759 lib/binary-io.h
757 lib/c-ctype.c 760 lib/c-ctype.c
758 lib/c-ctype.h 761 lib/c-ctype.h
759 lib/c-strcase.h 762 lib/c-strcase.h