496430
From 1831628c0630ae96a43586b2a25ca51cbdba3e53 Mon Sep 17 00:00:00 2001
496430
From: Paul Eggert <address@hidden>
496430
Date: Mon, 5 Mar 2018 10:56:29 -0800
496430
Subject: [PATCH] fflush: adjust to glibc 2.28 libio.h removal
496430
MIME-Version: 1.0
496430
Content-Type: text/plain; charset=UTF-8
496430
Content-Transfer-Encoding: 8bit
496430
496430
Problem reported by Daniel P. Berrangé in:
496430
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
496430
* lib/fbufmode.c (fbufmode):
496430
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
496430
(disable_seek_optimization, rpl_fflush):
496430
* lib/fpending.c (__fpending):
496430
* lib/fpurge.c (fpurge):
496430
* lib/freadable.c (freadable):
496430
* lib/freadahead.c (freadahead):
496430
* lib/freading.c (freading):
496430
* lib/freadptr.c (freadptr):
496430
* lib/freadseek.c (freadptrinc):
496430
* lib/fseeko.c (fseeko):
496430
* lib/fseterr.c (fseterr):
496430
* lib/fwritable.c (fwritable):
496430
* lib/fwriting.c (fwriting):
496430
Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
496430
* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
496430
Define if not already defined.
496430
---
496430
 ChangeLog        | 23 +++++++++++++++++++++++
496430
 lib/fbufmode.c   |  2 +-
496430
 lib/fflush.c     |  6 +++---
496430
 lib/fpending.c   |  2 +-
496430
 lib/fpurge.c     |  2 +-
496430
 lib/freadable.c  |  2 +-
496430
 lib/freadahead.c |  2 +-
496430
 lib/freading.c   |  2 +-
496430
 lib/freadptr.c   |  2 +-
496430
 lib/freadseek.c  |  2 +-
496430
 lib/fseeko.c     |  4 ++--
496430
 lib/fseterr.c    |  2 +-
496430
 lib/fwritable.c  |  2 +-
496430
 lib/fwriting.c   |  2 +-
496430
 lib/stdio-impl.h |  6 ++++++
496430
 15 files changed, 45 insertions(+), 16 deletions(-)
496430
496430
diff --git a/ChangeLog b/ChangeLog
496430
index 667f91663..beb835670 100644
496430
--- a/ChangeLog
496430
+++ b/ChangeLog
496430
@@ -1,3 +1,26 @@
496430
+2018-03-05  Paul Eggert  <address@hidden>
496430
+
496430
+	fflush: adjust to glibc 2.28 libio.h removal
496430
+	Problem reported by Daniel P. Berrangé in:
496430
+	https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
496430
+	* lib/fbufmode.c (fbufmode):
496430
+	* lib/fflush.c (clear_ungetc_buffer_preserving_position)
496430
+	(disable_seek_optimization, rpl_fflush):
496430
+	* lib/fpending.c (__fpending):
496430
+	* lib/fpurge.c (fpurge):
496430
+	* lib/freadable.c (freadable):
496430
+	* lib/freadahead.c (freadahead):
496430
+	* lib/freading.c (freading):
496430
+	* lib/freadptr.c (freadptr):
496430
+	* lib/freadseek.c (freadptrinc):
496430
+	* lib/fseeko.c (fseeko):
496430
+	* lib/fseterr.c (fseterr):
496430
+	* lib/fwritable.c (fwritable):
496430
+	* lib/fwriting.c (fwriting):
496430
+	Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
496430
+	* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
496430
+	Define if not already defined.
496430
+
496430
 2017-02-03  Jim Meyering  <meyering@fb.com>
496430
 
496430
 	version 4.4
496430
diff --git a/gnulib-tests/fflush.c b/gnulib-tests/fflush.c
496430
index 983ade0ff..a6edfa105 100644
496430
--- a/gnulib-tests/fflush.c
496430
+++ b/gnulib-tests/fflush.c
496430
@@ -33,7 +33,7 @@
496430
 #undef fflush
496430
 
496430
 
496430
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
 
496430
 /* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
496430
 static void
496430
@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
496430
 
496430
 #endif
496430
 
496430
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
496430
+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
496430
 
496430
 # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
496430
 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
496430
@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
496430
   if (stream == NULL || ! freading (stream))
496430
     return fflush (stream);
496430
 
496430
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
 
496430
   clear_ungetc_buffer_preserving_position (stream);
496430
 
496430
diff --git a/lib/fpending.c b/lib/fpending.c
496430
index c84e3a5b4..789f50e4e 100644
496430
--- a/lib/fpending.c
496430
+++ b/lib/fpending.c
496430
@@ -32,7 +32,7 @@ __fpending (FILE *fp)
496430
   /* Most systems provide FILE as a struct and the necessary bitmask in
496430
      <stdio.h>, because they need it for implementing getc() and putc() as
496430
      fast macros.  */
496430
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
   return fp->_IO_write_ptr - fp->_IO_write_base;
496430
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
496430
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
496430
diff --git a/gnulib-tests/fpurge.c b/gnulib-tests/fpurge.c
496430
index b1d417c7a..3aedcc373 100644
496430
--- a/gnulib-tests/fpurge.c
496430
+++ b/gnulib-tests/fpurge.c
496430
@@ -62,7 +62,7 @@ fpurge (FILE *fp)
496430
   /* Most systems provide FILE as a struct and the necessary bitmask in
496430
      <stdio.h>, because they need it for implementing getc() and putc() as
496430
      fast macros.  */
496430
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
   fp->_IO_read_end = fp->_IO_read_ptr;
496430
   fp->_IO_write_ptr = fp->_IO_write_base;
496430
   /* Avoid memory leak when there is an active ungetc buffer.  */
496430
diff --git a/gnulib-tests/freading.c b/gnulib-tests/freading.c
496430
index 73c28acdd..c24d0c88a 100644
496430
--- a/gnulib-tests/freading.c
496430
+++ b/gnulib-tests/freading.c
496430
@@ -31,7 +31,7 @@ freading (FILE *fp)
496430
   /* Most systems provide FILE as a struct and the necessary bitmask in
496430
      <stdio.h>, because they need it for implementing getc() and putc() as
496430
      fast macros.  */
496430
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
   return ((fp->_flags & _IO_NO_WRITES) != 0
496430
           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
496430
               && fp->_IO_read_base != NULL));
496430
diff --git a/gnulib-tests/fseeko.c b/gnulib-tests/fseeko.c
496430
index 0101ab55f..193f4e8ce 100644
496430
--- a/gnulib-tests/fseeko.c
496430
+++ b/gnulib-tests/fseeko.c
496430
@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence)
496430
 #endif
496430
 
496430
   /* These tests are based on fpurge.c.  */
496430
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
   if (fp->_IO_read_end == fp->_IO_read_ptr
496430
       && fp->_IO_write_ptr == fp->_IO_write_base
496430
       && fp->_IO_save_base == NULL)
496430
@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence)
496430
           return -1;
496430
         }
496430
 
496430
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
       fp->_flags &= ~_IO_EOF_SEEN;
496430
       fp->_offset = pos;
496430
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
496430
diff --git a/lib/fwriting.c b/lib/fwriting.c
496430
index 461ab0f1f..4a3d9c8d4 100644
496430
--- a/lib/fwriting.c
496430
+++ b/lib/fwriting.c
496430
@@ -27,7 +27,7 @@ fwriting (FILE *fp)
496430
   /* Most systems provide FILE as a struct and the necessary bitmask in
496430
      <stdio.h>, because they need it for implementing getc() and putc() as
496430
      fast macros.  */
496430
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
496430
   return (fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) != 0;
496430
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
496430
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
496430
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
496430
index 78d896e9f..05c5752a2 100644
496430
--- a/lib/stdio-impl.h
496430
+++ b/lib/stdio-impl.h
496430
@@ -18,6 +18,12 @@
496430
    the same implementation of stdio extension API, except that some fields
496430
    have different naming conventions, or their access requires some casts.  */
496430
 
496430
+/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
496430
+   problem by defining it ourselves.  FIXME: Do not rely on glibc
496430
+   internals.  */
496430
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
496430
+# define _IO_IN_BACKUP 0x100
496430
+#endif
496430
 
496430
 /* BSD stdio derived implementations.  */
496430
 
496430
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
496430
index 78d896e9f..05c5752a2 100644
496430
--- a/gnulib-tests/stdio-impl.h
496430
+++ b/gnulib-tests/stdio-impl.h
496430
@@ -18,6 +18,12 @@
496430
    the same implementation of stdio extension API, except that some fields
496430
    have different naming conventions, or their access requires some casts.  */
496430
 
496430
+/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
496430
+   problem by defining it ourselves.  FIXME: Do not rely on glibc
496430
+   internals.  */
496430
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
496430
+# define _IO_IN_BACKUP 0x100
496430
+#endif
496430
 
496430
 /* BSD stdio derived implementations.  */
496430
 
496430
-- 
496430
2.14.3
496430