1 Fix build failure on glibc-2.28:
2 fseeko.c: In function 'rpl_fseeko':
3 fseeko.c:110:4: error: #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
4 #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
6 Patch by milan hodoscek.
8 https://bugs.gentoo.org/663242
10 +++ b/gl/lib/stdio-impl.h
12 /* Implementation details of FILE streams.
13 - Copyright (C) 2007-2008, 2010-2015 Free Software Foundation, Inc.
14 + Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc.
16 This program is free software: you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 - along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 + along with this program. If not, see <https://www.gnu.org/licenses/>. */
25 /* Many stdio implementations have the same logic and therefore can share
26 the same implementation of stdio extension API, except that some fields
27 have different naming conventions, or their access requires some casts. */
29 +/* Glibc 2.28 made _IO_IN_BACKUP private. For now, work around this
30 + problem by defining it ourselves. FIXME: Do not rely on glibc
32 +#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
33 +# define _IO_IN_BACKUP 0x100
36 /* BSD stdio derived implementations. */
39 #include <errno.h> /* For detecting Plan9. */
41 #if defined __sferror || defined __DragonFly__ || defined __ANDROID__
42 - /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
43 + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
45 # if defined __DragonFly__ /* DragonFly */
46 - /* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
47 + /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>. */
48 # define fp_ ((struct { struct __FILE_public pub; \
49 struct { unsigned char *_base; int _size; } _bf; \
53 /* More fields, not relevant here. */ \
55 - /* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
56 + /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>. */
58 # define _flags pub._flags
61 +# elif defined __ANDROID__ /* Android */
62 + /* Up to this commit from 2015-10-12
63 + <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
64 + the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
65 + see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
66 + and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
67 + After this commit, the innards of FILE are hidden. */
68 +# define fp_ ((struct { unsigned char *_p; \
73 + struct { unsigned char *_base; size_t _size; } _bf; \
80 + struct { unsigned char *_base; size_t _size; } _ext; \
81 + unsigned char *_up; \
83 + unsigned char _ubuf[3]; \
84 + unsigned char _nbuf[1]; \
85 + struct { unsigned char *_base; size_t _size; } _lb; \
88 + /* More fields, not relevant here. */ \
94 -# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __ANDROID__ /* NetBSD >= 1.5ZA, OpenBSD, Android */
95 +# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
96 /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
97 - and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
98 + and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
99 + and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
102 struct __sbuf _ub; /* ungetc buffer */
103 /* More fields, not relevant here. */
105 # define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
106 -# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin, Android */
107 +# elif defined __ANDROID__ /* Android */
110 + struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
111 + /* More fields, not relevant here. */
113 +# define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub
114 +# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
115 # define fp_ub fp_->_ub
118 # define HASUB(fp) (fp_ub._base != NULL)
120 +# if defined __ANDROID__ /* Android */
121 + /* Needed after this commit from 2016-01-25
122 + <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */
129 +# define __SEOF 0x20
130 +# define __SERR 0x40
133 +# define __SOFF 0x1000
141 #ifdef __TANDEM /* NonStop Kernel */
143 /* These values were determined by the program 'stdioext-flags' at
144 - <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>. */
145 + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
147 # define _IOREAD 0x80
151 unsigned int _flag; \
153 +# elif defined __VMS /* OpenVMS */
154 +# define fp_ ((struct _iobuf *) fp)
159 # define _flag __flag
162 +#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */
164 +/* <stdio.h> does not define the innards of FILE any more. */
165 +# define WINDOWS_OPAQUE_FILE
167 +struct _gl_real_FILE
169 + /* Note: Compared to older Windows and to mingw, it has the fields
170 + _base and _cnt swapped. */
171 + unsigned char *_ptr;
172 + unsigned char *_base;
179 +# define fp_ ((struct _gl_real_FILE *) fp)
181 +/* These values were determined by a program similar to the one at
182 + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
183 +# define _IOREAD 0x1
187 +# define _IOERR 0x10
191 +++ b/gl/lib/fseeko.c
193 /* An fseeko() function that, together with fflush(), is POSIX compliant.
194 - Copyright (C) 2007-2015 Free Software Foundation, Inc.
195 + Copyright (C) 2007-2018 Free Software Foundation, Inc.
197 This program is free software; you can redistribute it and/or modify
198 it under the terms of the GNU General Public License as published by
200 GNU General Public License for more details.
202 You should have received a copy of the GNU General Public License along
203 - with this program; if not, see <http://www.gnu.org/licenses/>. */
204 + with this program; if not, see <https://www.gnu.org/licenses/>. */
208 @@ -33,9 +33,9 @@ fseeko (FILE *fp, off_t offset, int whence)
210 #if _GL_WINDOWS_64_BIT_OFF_T
212 -# if HAVE__FSEEKI64 /* msvc, mingw64 */
213 +# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
214 # define fseeko _fseeki64
216 +# else /* mingw before msvcrt8.0 */
217 # define fseeko fseeko64
220 @@ -47,12 +47,13 @@ fseeko (FILE *fp, off_t offset, int whence)
223 /* These tests are based on fpurge.c. */
224 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
225 +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
226 + /* GNU libc, BeOS, Haiku, Linux libc5 */
227 if (fp->_IO_read_end == fp->_IO_read_ptr
228 && fp->_IO_write_ptr == fp->_IO_write_base
229 && fp->_IO_save_base == NULL)
230 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
231 - /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
232 + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
233 # if defined __SL64 && defined __SCLE /* Cygwin */
234 if ((fp->_flags & __SL64) == 0)
236 @@ -80,7 +81,7 @@ fseeko (FILE *fp, off_t offset, int whence)
237 #elif defined __minix /* Minix */
238 if (fp_->_ptr == fp_->_buf
239 && (fp_->_ptr == NULL || fp_->_count == 0))
240 -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
241 +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
242 if (fp_->_ptr == fp_->_base
243 && (fp_->_ptr == NULL || fp_->_cnt == 0))
244 #elif defined __UCLIBC__ /* uClibc */
245 @@ -117,18 +118,19 @@ fseeko (FILE *fp, off_t offset, int whence)
248 #if defined __sferror || defined __DragonFly__ || defined __ANDROID__
249 - /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
250 + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
251 fp_->_flags &= ~__SOFF;
256 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
257 +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
258 + /* GNU libc, BeOS, Haiku, Linux libc5 */
259 fp->_flags &= ~_IO_EOF_SEEN;
261 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
262 - /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
263 -# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000)
264 + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
265 +# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
266 /* fp_->_offset is typed as an integer. */
269 @@ -150,8 +152,8 @@ fseeko (FILE *fp, off_t offset, int whence)
270 fp_->_flags &= ~__SEOF;
271 #elif defined __EMX__ /* emx+gcc */
272 fp->_flags &= ~_IOEOF;
273 -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
274 - fp->_flag &= ~_IOEOF;
275 +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
276 + fp_->_flag &= ~_IOEOF;
277 #elif defined __MINT__ /* Atari FreeMiNT */
280 --- a/old/freadahead.c
281 +++ b/gl/lib/freadahead.c
283 /* Retrieve information about a FILE stream.
284 - Copyright (C) 2007-2015 Free Software Foundation, Inc.
285 + Copyright (C) 2007-2018 Free Software Foundation, Inc.
287 This program is free software: you can redistribute it and/or modify
288 it under the terms of the GNU General Public License as published by
290 GNU General Public License for more details.
292 You should have received a copy of the GNU General Public License
293 - along with this program. If not, see <http://www.gnu.org/licenses/>. */
294 + along with this program. If not, see <https://www.gnu.org/licenses/>. */
300 #include "stdio-impl.h"
302 +#if defined __DragonFly__
303 +/* Defined in libc, but not declared in <stdio.h>. */
304 +extern size_t __sreadahead (FILE *);
307 +/* This file is not used on systems that have the __freadahead function,
308 + namely musl libc. */
311 freadahead (FILE *fp)
313 -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
314 +#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
315 + /* GNU libc, BeOS, Haiku, Linux libc5 */
316 if (fp->_IO_write_ptr > fp->_IO_write_base)
318 return (fp->_IO_read_end - fp->_IO_read_ptr)
319 + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
321 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
322 - /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
323 + /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
324 if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
326 # if defined __DragonFly__
327 @@ -53,7 +62,7 @@ freadahead (FILE *fp)
328 if ((fp_->_flags & _IOWRITING) != 0)
331 -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
332 +#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
333 if ((fp_->_flag & _IOWRT) != 0)