|
|
10a327 |
From 80cdfba079627e15129a926a133825b961d41e36 Mon Sep 17 00:00:00 2001
|
|
|
10a327 |
From: Paul Eggert <eggert@cs.ucla.edu>
|
|
|
10a327 |
Date: Mon, 5 Mar 2018 10:56:29 -0800
|
|
|
10a327 |
Subject: [PATCH] fflush: adjust to glibc 2.28 libio.h removal
|
|
|
10a327 |
MIME-Version: 1.0
|
|
|
10a327 |
Content-Type: text/plain; charset=UTF-8
|
|
|
10a327 |
Content-Transfer-Encoding: 8bit
|
|
|
10a327 |
|
|
|
10a327 |
Problem reported by Daniel P. Berrangé in:
|
|
|
10a327 |
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
|
|
|
10a327 |
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
|
|
|
10a327 |
(disable_seek_optimization, rpl_fflush):
|
|
|
10a327 |
* lib/fpurge.c (fpurge):
|
|
|
10a327 |
* lib/freadahead.c (freadahead):
|
|
|
10a327 |
* lib/freading.c (freading):
|
|
|
10a327 |
* lib/fseeko.c (fseeko):
|
|
|
10a327 |
* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
|
|
|
10a327 |
Define if not already defined.
|
|
|
10a327 |
|
|
|
10a327 |
Upstream-commit: 4af4a4a71827c0bc5e0ec67af23edef4f15cee8e
|
|
|
10a327 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
10a327 |
---
|
|
|
10a327 |
gl/lib/fflush.c | 6 +++---
|
|
|
10a327 |
gl/lib/fpurge.c | 2 +-
|
|
|
10a327 |
gl/lib/freadahead.c | 2 +-
|
|
|
10a327 |
gl/lib/freading.c | 2 +-
|
|
|
10a327 |
gl/lib/fseeko.c | 4 ++--
|
|
|
10a327 |
gl/lib/stdio-impl.h | 6 ++++++
|
|
|
10a327 |
6 files changed, 14 insertions(+), 8 deletions(-)
|
|
|
10a327 |
|
|
|
10a327 |
diff --git a/gl/lib/fflush.c b/gl/lib/fflush.c
|
|
|
10a327 |
index 5ae3e41..7a82470 100644
|
|
|
10a327 |
--- a/gl/lib/fflush.c
|
|
|
10a327 |
+++ b/gl/lib/fflush.c
|
|
|
10a327 |
@@ -33,7 +33,7 @@
|
|
|
10a327 |
#undef fflush
|
|
|
10a327 |
|
|
|
10a327 |
|
|
|
10a327 |
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
|
|
|
10a327 |
/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
|
|
|
10a327 |
static void
|
|
|
10a327 |
@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
|
|
|
10a327 |
|
|
|
10a327 |
#endif
|
|
|
10a327 |
|
|
|
10a327 |
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
|
|
|
10a327 |
+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
|
|
|
10a327 |
|
|
|
10a327 |
# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
|
|
|
10a327 |
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
|
|
|
10a327 |
@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
|
|
|
10a327 |
if (stream == NULL || ! freading (stream))
|
|
|
10a327 |
return fflush (stream);
|
|
|
10a327 |
|
|
|
10a327 |
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
|
|
|
10a327 |
clear_ungetc_buffer_preserving_position (stream);
|
|
|
10a327 |
|
|
|
10a327 |
diff --git a/gl/lib/fpurge.c b/gl/lib/fpurge.c
|
|
|
10a327 |
index f313b22..ecdf82d 100644
|
|
|
10a327 |
--- a/gl/lib/fpurge.c
|
|
|
10a327 |
+++ b/gl/lib/fpurge.c
|
|
|
10a327 |
@@ -62,7 +62,7 @@ fpurge (FILE *fp)
|
|
|
10a327 |
/* Most systems provide FILE as a struct and the necessary bitmask in
|
|
|
10a327 |
<stdio.h>, because they need it for implementing getc() and putc() as
|
|
|
10a327 |
fast macros. */
|
|
|
10a327 |
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
fp->_IO_read_end = fp->_IO_read_ptr;
|
|
|
10a327 |
fp->_IO_write_ptr = fp->_IO_write_base;
|
|
|
10a327 |
/* Avoid memory leak when there is an active ungetc buffer. */
|
|
|
10a327 |
diff --git a/gl/lib/freadahead.c b/gl/lib/freadahead.c
|
|
|
10a327 |
index 094daab..3f8101e 100644
|
|
|
10a327 |
--- a/gl/lib/freadahead.c
|
|
|
10a327 |
+++ b/gl/lib/freadahead.c
|
|
|
10a327 |
@@ -25,7 +25,7 @@
|
|
|
10a327 |
size_t
|
|
|
10a327 |
freadahead (FILE *fp)
|
|
|
10a327 |
{
|
|
|
10a327 |
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
if (fp->_IO_write_ptr > fp->_IO_write_base)
|
|
|
10a327 |
return 0;
|
|
|
10a327 |
return (fp->_IO_read_end - fp->_IO_read_ptr)
|
|
|
10a327 |
diff --git a/gl/lib/freading.c b/gl/lib/freading.c
|
|
|
10a327 |
index 0512b19..8c48fe4 100644
|
|
|
10a327 |
--- a/gl/lib/freading.c
|
|
|
10a327 |
+++ b/gl/lib/freading.c
|
|
|
10a327 |
@@ -31,7 +31,7 @@ freading (FILE *fp)
|
|
|
10a327 |
/* Most systems provide FILE as a struct and the necessary bitmask in
|
|
|
10a327 |
<stdio.h>, because they need it for implementing getc() and putc() as
|
|
|
10a327 |
fast macros. */
|
|
|
10a327 |
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
return ((fp->_flags & _IO_NO_WRITES) != 0
|
|
|
10a327 |
|| ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
|
|
|
10a327 |
&& fp->_IO_read_base != NULL));
|
|
|
10a327 |
diff --git a/gl/lib/fseeko.c b/gl/lib/fseeko.c
|
|
|
10a327 |
index 1c65d2a..9026408 100644
|
|
|
10a327 |
--- a/gl/lib/fseeko.c
|
|
|
10a327 |
+++ b/gl/lib/fseeko.c
|
|
|
10a327 |
@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence)
|
|
|
10a327 |
#endif
|
|
|
10a327 |
|
|
|
10a327 |
/* These tests are based on fpurge.c. */
|
|
|
10a327 |
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
if (fp->_IO_read_end == fp->_IO_read_ptr
|
|
|
10a327 |
&& fp->_IO_write_ptr == fp->_IO_write_base
|
|
|
10a327 |
&& fp->_IO_save_base == NULL)
|
|
|
10a327 |
@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence)
|
|
|
10a327 |
return -1;
|
|
|
10a327 |
}
|
|
|
10a327 |
|
|
|
10a327 |
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
|
|
|
10a327 |
fp->_flags &= ~_IO_EOF_SEEN;
|
|
|
10a327 |
fp->_offset = pos;
|
|
|
10a327 |
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
|
|
|
10a327 |
diff --git a/gl/lib/stdio-impl.h b/gl/lib/stdio-impl.h
|
|
|
10a327 |
index 502d891..ea38ee2 100644
|
|
|
10a327 |
--- a/gl/lib/stdio-impl.h
|
|
|
10a327 |
+++ b/gl/lib/stdio-impl.h
|
|
|
10a327 |
@@ -18,6 +18,12 @@
|
|
|
10a327 |
the same implementation of stdio extension API, except that some fields
|
|
|
10a327 |
have different naming conventions, or their access requires some casts. */
|
|
|
10a327 |
|
|
|
10a327 |
+/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
|
|
|
10a327 |
+ problem by defining it ourselves. FIXME: Do not rely on glibc
|
|
|
10a327 |
+ internals. */
|
|
|
10a327 |
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
|
|
|
10a327 |
+# define _IO_IN_BACKUP 0x100
|
|
|
10a327 |
+#endif
|
|
|
10a327 |
|
|
|
10a327 |
/* BSD stdio derived implementations. */
|
|
|
10a327 |
|
|
|
10a327 |
--
|
|
|
10a327 |
2.16.2
|
|
|
10a327 |
|