Blame SOURCES/findutils-4.6.0-gnulib-fflush.patch

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