0001-fflush-adjust-to-glibc-2.28-libio.h-removal.patch 6.7 KB

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