|
| 1 | +From 4af4a4a71827c0bc5e0ec67af23edef4f15cee8e Mon Sep 17 00:00:00 2001 |
| 2 | +From: Paul Eggert < [email protected]> |
| 3 | +Date: Mon, 5 Mar 2018 10:56:29 -0800 |
| 4 | +Subject: [PATCH] fflush: adjust to glibc 2.28 libio.h removal |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +Problem reported by Daniel P. Berrangé in: |
| 10 | +https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html |
| 11 | +* lib/fbufmode.c (fbufmode): |
| 12 | +* lib/fflush.c (clear_ungetc_buffer_preserving_position) |
| 13 | +(disable_seek_optimization, rpl_fflush): |
| 14 | +* lib/fpending.c (__fpending): |
| 15 | +* lib/fpurge.c (fpurge): |
| 16 | +* lib/freadable.c (freadable): |
| 17 | +* lib/freadahead.c (freadahead): |
| 18 | +* lib/freading.c (freading): |
| 19 | +* lib/freadptr.c (freadptr): |
| 20 | +* lib/freadseek.c (freadptrinc): |
| 21 | +* lib/fseeko.c (fseeko): |
| 22 | +* lib/fseterr.c (fseterr): |
| 23 | +* lib/fwritable.c (fwritable): |
| 24 | +* lib/fwriting.c (fwriting): |
| 25 | +Check _IO_EOF_SEEN instead of _IO_ftrylockfile. |
| 26 | +* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]: |
| 27 | +Define if not already defined. |
| 28 | + |
| 29 | +[ [email protected]: partially backport from upstream gnulib] |
| 30 | +Signed-off-by: "Yann E. MORIN" < [email protected]> |
| 31 | + |
| 32 | +--- |
| 33 | + lib/fflush.c | 6 +++--- |
| 34 | + lib/fpending.c | 2 +- |
| 35 | + lib/fpurge.c | 2 +- |
| 36 | + lib/freadahead.c | 2 +- |
| 37 | + lib/freading.c | 2 +- |
| 38 | + lib/fseeko.c | 4 ++-- |
| 39 | + lib/stdio-impl.h | 6 ++++++ |
| 40 | + 7 files changed, 15 insertions(+), 9 deletions(-) |
| 41 | + |
| 42 | +diff --git a/lib/fflush.c b/build-aux/gnulib/lib/fflush.c |
| 43 | +index 983ade0ff..a6edfa105 100644 |
| 44 | +--- a/lib/fflush.c |
| 45 | ++++ b/lib/fflush.c |
| 46 | +@@ -33,7 +33,7 @@ |
| 47 | + #undef fflush |
| 48 | + |
| 49 | + |
| 50 | +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 51 | ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 52 | + |
| 53 | + /* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */ |
| 54 | + static void |
| 55 | +@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp) |
| 56 | + |
| 57 | + #endif |
| 58 | + |
| 59 | +-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) |
| 60 | ++#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) |
| 61 | + |
| 62 | + # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT |
| 63 | + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ |
| 64 | +@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream) |
| 65 | + if (stream == NULL || ! freading (stream)) |
| 66 | + return fflush (stream); |
| 67 | + |
| 68 | +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 69 | ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 70 | + |
| 71 | + clear_ungetc_buffer_preserving_position (stream); |
| 72 | + |
| 73 | +diff --git a/lib/fpending.c b/build-aux/gnulib/lib/fpending.c |
| 74 | +index c84e3a5b4..789f50e4e 100644 |
| 75 | +--- a/lib/fpending.c |
| 76 | ++++ b/lib/fpending.c |
| 77 | +@@ -32,7 +32,7 @@ __fpending (FILE *fp) |
| 78 | + /* Most systems provide FILE as a struct and the necessary bitmask in |
| 79 | + <stdio.h>, because they need it for implementing getc() and putc() as |
| 80 | + fast macros. */ |
| 81 | +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 82 | ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 83 | + return fp->_IO_write_ptr - fp->_IO_write_base; |
| 84 | + #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ |
| 85 | + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ |
| 86 | +diff --git a/lib/fpurge.c b/build-aux/gnulib/lib/fpurge.c |
| 87 | +index b1d417c7a..3aedcc373 100644 |
| 88 | +--- a/lib/fpurge.c |
| 89 | ++++ b/lib/fpurge.c |
| 90 | +@@ -62,7 +62,7 @@ fpurge (FILE *fp) |
| 91 | + /* Most systems provide FILE as a struct and the necessary bitmask in |
| 92 | + <stdio.h>, because they need it for implementing getc() and putc() as |
| 93 | + fast macros. */ |
| 94 | +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 95 | ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 96 | + fp->_IO_read_end = fp->_IO_read_ptr; |
| 97 | + fp->_IO_write_ptr = fp->_IO_write_base; |
| 98 | + /* Avoid memory leak when there is an active ungetc buffer. */ |
| 99 | +diff --git a/lib/freadahead.c b/build-aux/gnulib/lib/freadahead.c |
| 100 | +index c2ecb5b28..23ec76ee5 100644 |
| 101 | +--- a/lib/freadahead.c |
| 102 | ++++ b/lib/freadahead.c |
| 103 | +@@ -30,7 +30,7 @@ extern size_t __sreadahead (FILE *); |
| 104 | + size_t |
| 105 | + freadahead (FILE *fp) |
| 106 | + { |
| 107 | +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 108 | ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 109 | + if (fp->_IO_write_ptr > fp->_IO_write_base) |
| 110 | + return 0; |
| 111 | + return (fp->_IO_read_end - fp->_IO_read_ptr) |
| 112 | +diff --git a/lib/freading.c b/build-aux/gnulib/lib/freading.c |
| 113 | +index 73c28acdd..c24d0c88a 100644 |
| 114 | +--- a/lib/freading.c |
| 115 | ++++ b/lib/freading.c |
| 116 | +@@ -31,7 +31,7 @@ freading (FILE *fp) |
| 117 | + /* Most systems provide FILE as a struct and the necessary bitmask in |
| 118 | + <stdio.h>, because they need it for implementing getc() and putc() as |
| 119 | + fast macros. */ |
| 120 | +-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 121 | ++# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 122 | + return ((fp->_flags & _IO_NO_WRITES) != 0 |
| 123 | + || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 |
| 124 | + && fp->_IO_read_base != NULL)); |
| 125 | +diff --git a/lib/fseeko.c b/build-aux/gnulib/lib/fseeko.c |
| 126 | +index 0101ab55f..193f4e8ce 100644 |
| 127 | +--- a/lib/fseeko.c |
| 128 | ++++ b/lib/fseeko.c |
| 129 | +@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence) |
| 130 | + #endif |
| 131 | + |
| 132 | + /* These tests are based on fpurge.c. */ |
| 133 | +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 134 | ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 135 | + if (fp->_IO_read_end == fp->_IO_read_ptr |
| 136 | + && fp->_IO_write_ptr == fp->_IO_write_base |
| 137 | + && fp->_IO_save_base == NULL) |
| 138 | +@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence) |
| 139 | + return -1; |
| 140 | + } |
| 141 | + |
| 142 | +-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 143 | ++#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ |
| 144 | + fp->_flags &= ~_IO_EOF_SEEN; |
| 145 | + fp->_offset = pos; |
| 146 | + #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ |
| 147 | +diff --git a/lib/stdio-impl.h b/build-aux/gnulib/lib/stdio-impl.h |
| 148 | +index 78d896e9f..05c5752a2 100644 |
| 149 | +--- a/lib/stdio-impl.h |
| 150 | ++++ b/lib/stdio-impl.h |
| 151 | +@@ -18,6 +18,12 @@ |
| 152 | + the same implementation of stdio extension API, except that some fields |
| 153 | + have different naming conventions, or their access requires some casts. */ |
| 154 | + |
| 155 | ++/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this |
| 156 | ++ problem by defining it ourselves. FIXME: Do not rely on glibc |
| 157 | ++ internals. */ |
| 158 | ++#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN |
| 159 | ++# define _IO_IN_BACKUP 0x100 |
| 160 | ++#endif |
| 161 | + |
| 162 | + /* BSD stdio derived implementations. */ |
| 163 | + |
| 164 | +-- |
| 165 | +2.14.1 |
| 166 | + |
0 commit comments