]> Savannah Git Hosting - gnulib.git/commitdiff
fflush: adjust to glibc 2.28 libio.h removal
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 5 Mar 2018 18:56:29 +0000 (10:56 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 5 Mar 2018 19:24:12 +0000 (11:24 -0800)
Problem reported by Daniel P. BerrangĂ© in:
https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
* lib/fbufmode.c (fbufmode):
* lib/fflush.c (clear_ungetc_buffer_preserving_position)
(disable_seek_optimization, rpl_fflush):
* lib/fpending.c (__fpending):
* lib/fpurge.c (fpurge):
* lib/freadable.c (freadable):
* lib/freadahead.c (freadahead):
* lib/freading.c (freading):
* lib/freadptr.c (freadptr):
* lib/freadseek.c (freadptrinc):
* lib/fseeko.c (fseeko):
* lib/fseterr.c (fseterr):
* lib/fwritable.c (fwritable):
* lib/fwriting.c (fwriting):
Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
* lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
Define if not already defined.

15 files changed:
ChangeLog
lib/fbufmode.c
lib/fflush.c
lib/fpending.c
lib/fpurge.c
lib/freadable.c
lib/freadahead.c
lib/freading.c
lib/freadptr.c
lib/freadseek.c
lib/fseeko.c
lib/fseterr.c
lib/fwritable.c
lib/fwriting.c
lib/stdio-impl.h

index 667f9166307b81450fcf6af07704c6706e39876d..beb8356705a6e094722fbd5099cd460f11c71f56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2018-03-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+       fflush: adjust to glibc 2.28 libio.h removal
+       Problem reported by Daniel P. BerrangĂ© in:
+       https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html
+       * lib/fbufmode.c (fbufmode):
+       * lib/fflush.c (clear_ungetc_buffer_preserving_position)
+       (disable_seek_optimization, rpl_fflush):
+       * lib/fpending.c (__fpending):
+       * lib/fpurge.c (fpurge):
+       * lib/freadable.c (freadable):
+       * lib/freadahead.c (freadahead):
+       * lib/freading.c (freading):
+       * lib/freadptr.c (freadptr):
+       * lib/freadseek.c (freadptrinc):
+       * lib/fseeko.c (fseeko):
+       * lib/fseterr.c (fseterr):
+       * lib/fwritable.c (fwritable):
+       * lib/fwriting.c (fwriting):
+       Check _IO_EOF_SEEN instead of _IO_ftrylockfile.
+       * lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]:
+       Define if not already defined.
+
 2018-02-27  Paul Eggert  <eggert@cs.ucla.edu>
 
        environ: fix link error on 32-bit Cygwin
index 73aa5fc07ce5b5b773acadc3af2f5a064ef196ea..f711fdfb78b053e323da2e79dce47ceb07a63664 100644 (file)
@@ -31,7 +31,7 @@ fbufmode (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 # if HAVE___FLBF                    /* glibc >= 2.2 */
   if (__flbf (fp))
     return _IOLBF;
index 983ade0ffbd9528fe8331480467112ebf8894ee9..a6edfa105b01a8bda1adc1a64e6687968ceaaf7b 100644 (file)
@@ -33,7 +33,7 @@
 #undef fflush
 
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 
 /* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
 static void
@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
 
 #endif
 
-#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
 
 # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
   if (stream == NULL || ! freading (stream))
     return fflush (stream);
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
 
   clear_ungetc_buffer_preserving_position (stream);
 
index c84e3a5b4ecf81609825b0d1c3bfee18594f22f2..789f50e4e4bc7b3ba9e1def09eb4cd131ef3d946 100644 (file)
@@ -32,7 +32,7 @@ __fpending (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return fp->_IO_write_ptr - fp->_IO_write_base;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
index b1d417c7a2b09a7753ca876c61fc12a20bf53246..3aedcc3734685f7a1db2b7a92b1adb8adb4569cf 100644 (file)
@@ -62,7 +62,7 @@ fpurge (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   fp->_IO_read_end = fp->_IO_read_ptr;
   fp->_IO_write_ptr = fp->_IO_write_base;
   /* Avoid memory leak when there is an active ungetc buffer.  */
index 03b50e1864454a2e3fcfbdbaadf2f92198084118..c4ca0b86e5fa5e80b8c2ce540ccf914060a5ec11 100644 (file)
@@ -31,7 +31,7 @@ freadable (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return (fp->_flags & _IO_NO_READS) == 0;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
index c2ecb5b28a8111f0a9b08343629f5c914966c098..23ec76ee53911f0f7920ec76118223ccb1a146cd 100644 (file)
@@ -30,7 +30,7 @@ extern size_t __sreadahead (FILE *);
 size_t
 freadahead (FILE *fp)
 {
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   if (fp->_IO_write_ptr > fp->_IO_write_base)
     return 0;
   return (fp->_IO_read_end - fp->_IO_read_ptr)
index 73c28acddfdc48ee5ed00d86d6ef2b919567f459..c24d0c88abf66ba1a932920380d3cffe6912584d 100644 (file)
@@ -31,7 +31,7 @@ freading (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return ((fp->_flags & _IO_NO_WRITES) != 0
           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
               && fp->_IO_read_base != NULL));
index 5aeadf3da1e56b5744d4fea81d3636b3300b8804..ffb8010392e24c98a9d21ff212be130dd1da0608 100644 (file)
@@ -29,7 +29,7 @@ freadptr (FILE *fp, size_t *sizep)
   size_t size;
 
   /* Keep this code in sync with freadahead!  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   if (fp->_IO_write_ptr > fp->_IO_write_base)
     return NULL;
   size = fp->_IO_read_end - fp->_IO_read_ptr;
index e7b0c7bdb32b5c96b60115d207d1409281725db0..5fd2dd7cac238e49261443a056e77795e03b0984 100644 (file)
@@ -36,7 +36,7 @@ freadptrinc (FILE *fp, size_t increment)
   /* Keep this code in sync with freadptr!  */
 #if HAVE___FREADPTRINC              /* musl libc */
   __freadptrinc (fp, increment);
-#elif defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#elif defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   fp->_IO_read_ptr += increment;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
index 0101ab55f703b1f7ea4a5d3a1aa3047ec4e7e0cc..193f4e8ce5155a300636bfe56acf1546a3f74b91 100644 (file)
@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence)
 #endif
 
   /* These tests are based on fpurge.c.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   if (fp->_IO_read_end == fp->_IO_read_ptr
       && fp->_IO_write_ptr == fp->_IO_write_base
       && fp->_IO_save_base == NULL)
@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence)
           return -1;
         }
 
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
       fp->_flags &= ~_IO_EOF_SEEN;
       fp->_offset = pos;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
index 82649c3ac1bf139dea7b2a7a6fc0832371a304c0..adb637256dcf159a969045831926106ccf438faf 100644 (file)
@@ -29,7 +29,7 @@ fseterr (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   fp->_flags |= _IO_ERR_SEEN;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
index 9813821636cf9db5b9b74efd8cca5660447a477c..3b1a380ec72be792b17a646e60e6c12546add652 100644 (file)
@@ -31,7 +31,7 @@ fwritable (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return (fp->_flags & _IO_NO_WRITES) == 0;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
index 461ab0f1f4e86852ceb40c19e4fd598f64d7f8fa..4a3d9c8d4f2f74bca82c05399fdbb4c9a435708f 100644 (file)
@@ -27,7 +27,7 @@ fwriting (FILE *fp)
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return (fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) != 0;
 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
index 78d896e9f5528eb670db149d147e7bc7e48e99ae..05c5752a24367b92408d768a01e4d0a887e5f2a5 100644 (file)
    the same implementation of stdio extension API, except that some fields
    have different naming conventions, or their access requires some casts.  */
 
+/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
+   problem by defining it ourselves.  FIXME: Do not rely on glibc
+   internals.  */
+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
+# define _IO_IN_BACKUP 0x100
+#endif
 
 /* BSD stdio derived implementations.  */