]>
Commit | Line | Data |
---|---|---|
e63cc45b MT |
1 | From 1831628c0630ae96a43586b2a25ca51cbdba3e53 Mon Sep 17 00:00:00 2001 |
2 | From: Paul Eggert <address@hidden> | |
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 | ||
9 | Problem reported by Daniel P. Berrangé in: | |
10 | https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html | |
11 | * lib/fbufmode.c (fbufmode): | |
12 | * lib/fflush.c (clear_ungetc_buffer_preserving_position) | |
13 | (disable_seek_optimization, rpl_fflush): | |
14 | * lib/fpending.c (__fpending): | |
15 | * lib/fpurge.c (fpurge): | |
16 | * lib/freadable.c (freadable): | |
17 | * lib/freadahead.c (freadahead): | |
18 | * lib/freading.c (freading): | |
19 | * lib/freadptr.c (freadptr): | |
20 | * lib/freadseek.c (freadptrinc): | |
21 | * lib/fseeko.c (fseeko): | |
22 | * lib/fseterr.c (fseterr): | |
23 | * lib/fwritable.c (fwritable): | |
24 | * lib/fwriting.c (fwriting): | |
25 | Check _IO_EOF_SEEN instead of _IO_ftrylockfile. | |
26 | * lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]: | |
27 | Define if not already defined. | |
28 | --- | |
29 | ChangeLog | 23 +++++++++++++++++++++++ | |
30 | lib/fbufmode.c | 2 +- | |
31 | lib/fflush.c | 6 +++--- | |
32 | lib/fpending.c | 2 +- | |
33 | lib/fpurge.c | 2 +- | |
34 | lib/freadable.c | 2 +- | |
35 | lib/freadahead.c | 2 +- | |
36 | lib/freading.c | 2 +- | |
37 | lib/freadptr.c | 2 +- | |
38 | lib/freadseek.c | 2 +- | |
39 | lib/fseeko.c | 4 ++-- | |
40 | lib/fseterr.c | 2 +- | |
41 | lib/fwritable.c | 2 +- | |
42 | lib/fwriting.c | 2 +- | |
43 | lib/stdio-impl.h | 6 ++++++ | |
44 | 15 files changed, 45 insertions(+), 16 deletions(-) | |
45 | ||
46 | diff --git a/ChangeLog b/ChangeLog | |
47 | index 667f91663..beb835670 100644 | |
48 | --- a/ChangeLog | |
49 | +++ b/ChangeLog | |
50 | @@ -1,3 +1,26 @@ | |
51 | +2018-03-05 Paul Eggert <address@hidden> | |
52 | + | |
53 | + fflush: adjust to glibc 2.28 libio.h removal | |
54 | + Problem reported by Daniel P. Berrangé in: | |
55 | + https://lists.gnu.org/r/bug-gnulib/2018-03/msg00000.html | |
56 | + * lib/fbufmode.c (fbufmode): | |
57 | + * lib/fflush.c (clear_ungetc_buffer_preserving_position) | |
58 | + (disable_seek_optimization, rpl_fflush): | |
59 | + * lib/fpending.c (__fpending): | |
60 | + * lib/fpurge.c (fpurge): | |
61 | + * lib/freadable.c (freadable): | |
62 | + * lib/freadahead.c (freadahead): | |
63 | + * lib/freading.c (freading): | |
64 | + * lib/freadptr.c (freadptr): | |
65 | + * lib/freadseek.c (freadptrinc): | |
66 | + * lib/fseeko.c (fseeko): | |
67 | + * lib/fseterr.c (fseterr): | |
68 | + * lib/fwritable.c (fwritable): | |
69 | + * lib/fwriting.c (fwriting): | |
70 | + Check _IO_EOF_SEEN instead of _IO_ftrylockfile. | |
71 | + * lib/stdio-impl.h (_IO_IN_BACKUP) [_IO_EOF_SEEN]: | |
72 | + Define if not already defined. | |
73 | + | |
74 | 2018-01-07 Jim Meyering <meyering@fb.com> | |
75 | ||
76 | version 1.9 | |
77 | * NEWS: Record release date. | |
78 | diff --git a/lib/fflush.c b/lib/fflush.c | |
79 | index 983ade0ff..a6edfa105 100644 | |
80 | --- a/lib/fflush.c | |
81 | +++ b/lib/fflush.c | |
82 | @@ -33,7 +33,7 @@ | |
83 | #undef fflush | |
84 | ||
85 | ||
86 | -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
87 | +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
88 | ||
89 | /* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */ | |
90 | static void | |
91 | @@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp) | |
92 | ||
93 | #endif | |
94 | ||
95 | -#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) | |
96 | +#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */) | |
97 | ||
98 | # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT | |
99 | /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ | |
100 | @@ -148,7 +148,7 @@ rpl_fflush (FILE *stream) | |
101 | if (stream == NULL || ! freading (stream)) | |
102 | return fflush (stream); | |
103 | ||
104 | -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
105 | +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
106 | ||
107 | clear_ungetc_buffer_preserving_position (stream); | |
108 | ||
109 | diff --git a/lib/fpurge.c b/lib/fpurge.c | |
110 | index b1d417c7a..3aedcc373 100644 | |
111 | --- a/lib/fpurge.c | |
112 | +++ b/lib/fpurge.c | |
113 | @@ -62,7 +62,7 @@ fpurge (FILE *fp) | |
114 | /* Most systems provide FILE as a struct and the necessary bitmask in | |
115 | <stdio.h>, because they need it for implementing getc() and putc() as | |
116 | fast macros. */ | |
117 | -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
118 | +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
119 | fp->_IO_read_end = fp->_IO_read_ptr; | |
120 | fp->_IO_write_ptr = fp->_IO_write_base; | |
121 | /* Avoid memory leak when there is an active ungetc buffer. */ | |
122 | diff --git a/lib/freading.c b/lib/freading.c | |
123 | index 73c28acdd..c24d0c88a 100644 | |
124 | --- a/lib/freading.c | |
125 | +++ b/lib/freading.c | |
126 | @@ -31,7 +31,7 @@ freading (FILE *fp) | |
127 | /* Most systems provide FILE as a struct and the necessary bitmask in | |
128 | <stdio.h>, because they need it for implementing getc() and putc() as | |
129 | fast macros. */ | |
130 | -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
131 | +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
132 | return ((fp->_flags & _IO_NO_WRITES) != 0 | |
133 | || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0 | |
134 | && fp->_IO_read_base != NULL)); | |
135 | diff --git a/lib/fseeko.c b/lib/fseeko.c | |
136 | index 0101ab55f..193f4e8ce 100644 | |
137 | --- a/lib/fseeko.c | |
138 | +++ b/lib/fseeko.c | |
139 | @@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence) | |
140 | #endif | |
141 | ||
142 | /* These tests are based on fpurge.c. */ | |
143 | -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
144 | +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
145 | if (fp->_IO_read_end == fp->_IO_read_ptr | |
146 | && fp->_IO_write_ptr == fp->_IO_write_base | |
147 | && fp->_IO_save_base == NULL) | |
148 | @@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence) | |
149 | return -1; | |
150 | } | |
151 | ||
152 | -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
153 | +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
154 | fp->_flags &= ~_IO_EOF_SEEN; | |
155 | fp->_offset = pos; | |
156 | #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ | |
157 | diff --git a/lib/fseterr.c b/lib/fseterr.c | |
158 | index 82649c3ac..adb637256 100644 | |
159 | --- a/lib/fseterr.c | |
160 | +++ b/lib/fseterr.c | |
161 | @@ -29,7 +29,7 @@ fseterr (FILE *fp) | |
162 | /* Most systems provide FILE as a struct and the necessary bitmask in | |
163 | <stdio.h>, because they need it for implementing getc() and putc() as | |
164 | fast macros. */ | |
165 | -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
166 | +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ | |
167 | fp->_flags |= _IO_ERR_SEEN; | |
168 | #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__ | |
169 | /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */ | |
170 | diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h | |
171 | index 78d896e9f..05c5752a2 100644 | |
172 | --- a/lib/stdio-impl.h | |
173 | +++ b/lib/stdio-impl.h | |
174 | @@ -18,6 +18,12 @@ | |
175 | the same implementation of stdio extension API, except that some fields | |
176 | have different naming conventions, or their access requires some casts. */ | |
177 | ||
178 | +/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this | |
179 | + problem by defining it ourselves. FIXME: Do not rely on glibc | |
180 | + internals. */ | |
181 | +#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN | |
182 | +# define _IO_IN_BACKUP 0x100 | |
183 | +#endif | |
184 | ||
185 | /* BSD stdio derived implementations. */ | |
186 | ||
187 | -- | |
188 | 2.14.3 | |
189 |