Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 663242
Collapse All | Expand All

(-)a/old/stdio-impl.h (-9 / +98 lines)
Lines 1-5 Link Here
1
/* Implementation details of FILE streams.
1
/* Implementation details of FILE streams.
2
   Copyright (C) 2007-2008, 2010-2015 Free Software Foundation, Inc.
2
   Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc.
3
3
4
   This program is free software: you can redistribute it and/or modify
4
   This program is free software: you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 12-23 Link Here
12
   GNU General Public License for more details.
12
   GNU General Public License for more details.
13
13
14
   You should have received a copy of the GNU General Public License
14
   You should have received a copy of the GNU General Public License
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
16
16
17
/* Many stdio implementations have the same logic and therefore can share
17
/* Many stdio implementations have the same logic and therefore can share
18
   the same implementation of stdio extension API, except that some fields
18
   the same implementation of stdio extension API, except that some fields
19
   have different naming conventions, or their access requires some casts.  */
19
   have different naming conventions, or their access requires some casts.  */
20
20
21
/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
22
   problem by defining it ourselves.  FIXME: Do not rely on glibc
23
   internals.  */
24
#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
25
# define _IO_IN_BACKUP 0x100
26
#endif
21
27
22
/* BSD stdio derived implementations.  */
28
/* BSD stdio derived implementations.  */
23
29
Lines 29-38 Link Here
29
#include <errno.h>                             /* For detecting Plan9.  */
35
#include <errno.h>                             /* For detecting Plan9.  */
30
36
31
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
37
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
32
  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
38
  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
33
39
34
# if defined __DragonFly__          /* DragonFly */
40
# if defined __DragonFly__          /* DragonFly */
35
  /* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>.  */
41
  /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>.  */
36
#  define fp_ ((struct { struct __FILE_public pub; \
42
#  define fp_ ((struct { struct __FILE_public pub; \
37
                         struct { unsigned char *_base; int _size; } _bf; \
43
                         struct { unsigned char *_base; int _size; } _bf; \
38
                         void *cookie; \
44
                         void *cookie; \
Lines 49-78 Link Here
49
                         fpos_t _offset; \
55
                         fpos_t _offset; \
50
                         /* More fields, not relevant here.  */ \
56
                         /* More fields, not relevant here.  */ \
51
                       } *) fp)
57
                       } *) fp)
52
  /* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>.  */
58
  /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>.  */
53
#  define _p pub._p
59
#  define _p pub._p
54
#  define _flags pub._flags
60
#  define _flags pub._flags
55
#  define _r pub._r
61
#  define _r pub._r
56
#  define _w pub._w
62
#  define _w pub._w
63
# elif defined __ANDROID__ /* Android */
64
  /* Up to this commit from 2015-10-12
65
     <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
66
     the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
67
     see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
68
     and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
69
     After this commit, the innards of FILE are hidden.  */
70
#  define fp_ ((struct { unsigned char *_p; \
71
                         int _r; \
72
                         int _w; \
73
                         int _flags; \
74
                         int _file; \
75
                         struct { unsigned char *_base; size_t _size; } _bf; \
76
                         int _lbfsize; \
77
                         void *_cookie; \
78
                         void *_close; \
79
                         void *_read; \
80
                         void *_seek; \
81
                         void *_write; \
82
                         struct { unsigned char *_base; size_t _size; } _ext; \
83
                         unsigned char *_up; \
84
                         int _ur; \
85
                         unsigned char _ubuf[3]; \
86
                         unsigned char _nbuf[1]; \
87
                         struct { unsigned char *_base; size_t _size; } _lb; \
88
                         int _blksize; \
89
                         fpos_t _offset; \
90
                         /* More fields, not relevant here.  */ \
91
                       } *) fp)
57
# else
92
# else
58
#  define fp_ fp
93
#  define fp_ fp
59
# endif
94
# endif
60
95
61
# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __ANDROID__ /* NetBSD >= 1.5ZA, OpenBSD, Android */
96
# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
62
  /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
97
  /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
63
     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> */
64
  struct __sfileext
100
  struct __sfileext
65
    {
101
    {
66
      struct  __sbuf _ub; /* ungetc buffer */
102
      struct  __sbuf _ub; /* ungetc buffer */
67
      /* More fields, not relevant here.  */
103
      /* More fields, not relevant here.  */
68
    };
104
    };
69
#  define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
105
#  define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
70
# else                                         /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin, Android */
106
# elif defined __ANDROID__                     /* Android */
107
  struct __sfileext
108
    {
109
      struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
110
      /* More fields, not relevant here.  */
111
    };
112
#  define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub
113
# else                                         /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
71
#  define fp_ub fp_->_ub
114
#  define fp_ub fp_->_ub
72
# endif
115
# endif
73
116
74
# define HASUB(fp) (fp_ub._base != NULL)
117
# define HASUB(fp) (fp_ub._base != NULL)
75
118
119
# if defined __ANDROID__ /* Android */
120
  /* Needed after this commit from 2016-01-25
121
     <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */
122
#  ifndef __SEOF
123
#   define __SLBF 1
124
#   define __SNBF 2
125
#   define __SRD 4
126
#   define __SWR 8
127
#   define __SRW 0x10
128
#   define __SEOF 0x20
129
#   define __SERR 0x40
130
#  endif
131
#  ifndef __SOFF
132
#   define __SOFF 0x1000
133
#  endif
134
# endif
135
76
#endif
136
#endif
77
137
78
138
Lines 81-87 Link Here
81
#ifdef __TANDEM                     /* NonStop Kernel */
141
#ifdef __TANDEM                     /* NonStop Kernel */
82
# ifndef _IOERR
142
# ifndef _IOERR
83
/* These values were determined by the program 'stdioext-flags' at
143
/* These values were determined by the program 'stdioext-flags' at
84
   <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>.  */
144
   <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>.  */
85
#  define _IOERR   0x40
145
#  define _IOERR   0x40
86
#  define _IOREAD  0x80
146
#  define _IOREAD  0x80
87
#  define _IOWRT    0x4
147
#  define _IOWRT    0x4
Lines 99-104 Link Here
99
                         int _file; \
159
                         int _file; \
100
                         unsigned int _flag; \
160
                         unsigned int _flag; \
101
                       } *) fp)
161
                       } *) fp)
162
# elif defined __VMS                /* OpenVMS */
163
#  define fp_ ((struct _iobuf *) fp)
102
# else
164
# else
103
#  define fp_ fp
165
#  define fp_ fp
104
# endif
166
# endif
Lines 110-113 Link Here
110
#  define _flag __flag
172
#  define _flag __flag
111
# endif
173
# endif
112
174
175
#elif defined _WIN32 && ! defined __CYGWIN__  /* newer Windows with MSVC */
176
177
/* <stdio.h> does not define the innards of FILE any more.  */
178
# define WINDOWS_OPAQUE_FILE
179
180
struct _gl_real_FILE
181
{
182
  /* Note: Compared to older Windows and to mingw, it has the fields
183
     _base and _cnt swapped. */
184
  unsigned char *_ptr;
185
  unsigned char *_base;
186
  int _cnt;
187
  int _flag;
188
  int _file;
189
  int _charbuf;
190
  int _bufsiz;
191
};
192
# define fp_ ((struct _gl_real_FILE *) fp)
193
194
/* These values were determined by a program similar to the one at
195
   <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>.  */
196
# define _IOREAD   0x1
197
# define _IOWRT    0x2
198
# define _IORW     0x4
199
# define _IOEOF    0x8
200
# define _IOERR   0x10
201
113
#endif
202
#endif
(-)a/old/fseeko.c (-13 / +15 lines)
Lines 1-5 Link Here
1
/* An fseeko() function that, together with fflush(), is POSIX compliant.
1
/* An fseeko() function that, together with fflush(), is POSIX compliant.
2
   Copyright (C) 2007-2015 Free Software Foundation, Inc.
2
   Copyright (C) 2007-2018 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 12-18 Link Here
12
   GNU General Public License for more details.
12
   GNU General Public License for more details.
13
13
14
   You should have received a copy of the GNU General Public License along
14
   You should have received a copy of the GNU General Public License along
15
   with this program; if not, see <http://www.gnu.org/licenses/>.  */
15
   with this program; if not, see <https://www.gnu.org/licenses/>.  */
16
16
17
#include <config.h>
17
#include <config.h>
18
18
Lines 33-41 fseeko (FILE *fp, off_t offset, int whence) Link Here
33
#endif
33
#endif
34
#if _GL_WINDOWS_64_BIT_OFF_T
34
#if _GL_WINDOWS_64_BIT_OFF_T
35
# undef fseeko
35
# undef fseeko
36
# if HAVE__FSEEKI64 /* msvc, mingw64 */
36
# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
37
#  define fseeko _fseeki64
37
#  define fseeko _fseeki64
38
# else /* mingw */
38
# else /* mingw before msvcrt8.0 */
39
#  define fseeko fseeko64
39
#  define fseeko fseeko64
40
# endif
40
# endif
41
#endif
41
#endif
Lines 47-58 fseeko (FILE *fp, off_t offset, int whence) Link Here
47
#endif
47
#endif
48
48
49
  /* These tests are based on fpurge.c.  */
49
  /* These tests are based on fpurge.c.  */
50
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
50
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
51
  /* GNU libc, BeOS, Haiku, Linux libc5 */
51
  if (fp->_IO_read_end == fp->_IO_read_ptr
52
  if (fp->_IO_read_end == fp->_IO_read_ptr
52
      && fp->_IO_write_ptr == fp->_IO_write_base
53
      && fp->_IO_write_ptr == fp->_IO_write_base
53
      && fp->_IO_save_base == NULL)
54
      && fp->_IO_save_base == NULL)
54
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
55
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
55
  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
56
  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
56
# if defined __SL64 && defined __SCLE /* Cygwin */
57
# if defined __SL64 && defined __SCLE /* Cygwin */
57
  if ((fp->_flags & __SL64) == 0)
58
  if ((fp->_flags & __SL64) == 0)
58
    {
59
    {
Lines 80-86 fseeko (FILE *fp, off_t offset, int whence) Link Here
80
#elif defined __minix               /* Minix */
81
#elif defined __minix               /* Minix */
81
  if (fp_->_ptr == fp_->_buf
82
  if (fp_->_ptr == fp_->_buf
82
      && (fp_->_ptr == NULL || fp_->_count == 0))
83
      && (fp_->_ptr == NULL || fp_->_count == 0))
83
#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
84
#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
84
  if (fp_->_ptr == fp_->_base
85
  if (fp_->_ptr == fp_->_base
85
      && (fp_->_ptr == NULL || fp_->_cnt == 0))
86
      && (fp_->_ptr == NULL || fp_->_cnt == 0))
86
#elif defined __UCLIBC__            /* uClibc */
87
#elif defined __UCLIBC__            /* uClibc */
Lines 117-134 fseeko (FILE *fp, off_t offset, int whence) Link Here
117
      if (pos == -1)
118
      if (pos == -1)
118
        {
119
        {
119
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
120
#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
120
          /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
121
          /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
121
          fp_->_flags &= ~__SOFF;
122
          fp_->_flags &= ~__SOFF;
122
#endif
123
#endif
123
          return -1;
124
          return -1;
124
        }
125
        }
125
126
126
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
127
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
128
      /* GNU libc, BeOS, Haiku, Linux libc5 */
127
      fp->_flags &= ~_IO_EOF_SEEN;
129
      fp->_flags &= ~_IO_EOF_SEEN;
128
      fp->_offset = pos;
130
      fp->_offset = pos;
129
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
131
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
130
      /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
132
      /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
131
# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000)
133
# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
132
      /* fp_->_offset is typed as an integer.  */
134
      /* fp_->_offset is typed as an integer.  */
133
      fp_->_offset = pos;
135
      fp_->_offset = pos;
134
# else
136
# else
Lines 150-157 fseeko (FILE *fp, off_t offset, int whence) Link Here
150
      fp_->_flags &= ~__SEOF;
152
      fp_->_flags &= ~__SEOF;
151
#elif defined __EMX__               /* emx+gcc */
153
#elif defined __EMX__               /* emx+gcc */
152
      fp->_flags &= ~_IOEOF;
154
      fp->_flags &= ~_IOEOF;
153
#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
155
#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
154
      fp->_flag &= ~_IOEOF;
156
      fp_->_flag &= ~_IOEOF;
155
#elif defined __MINT__              /* Atari FreeMiNT */
157
#elif defined __MINT__              /* Atari FreeMiNT */
156
      fp->__offset = pos;
158
      fp->__offset = pos;
157
      fp->__eof = 0;
159
      fp->__eof = 0;
(-)a/old/freadahead.c (-5 / +14 lines)
Lines 1-5 Link Here
1
/* Retrieve information about a FILE stream.
1
/* Retrieve information about a FILE stream.
2
   Copyright (C) 2007-2015 Free Software Foundation, Inc.
2
   Copyright (C) 2007-2018 Free Software Foundation, Inc.
3
3
4
   This program is free software: you can redistribute it and/or modify
4
   This program is free software: you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 12-18 Link Here
12
   GNU General Public License for more details.
12
   GNU General Public License for more details.
13
13
14
   You should have received a copy of the GNU General Public License
14
   You should have received a copy of the GNU General Public License
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
16
16
17
#include <config.h>
17
#include <config.h>
18
18
Lines 22-38 Link Here
22
#include <stdlib.h>
22
#include <stdlib.h>
23
#include "stdio-impl.h"
23
#include "stdio-impl.h"
24
24
25
#if defined __DragonFly__
26
/* Defined in libc, but not declared in <stdio.h>.  */
27
extern size_t __sreadahead (FILE *);
28
#endif
29
30
/* This file is not used on systems that have the __freadahead function,
31
   namely musl libc.  */
32
25
size_t
33
size_t
26
freadahead (FILE *fp)
34
freadahead (FILE *fp)
27
{
35
{
28
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
36
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
37
  /* GNU libc, BeOS, Haiku, Linux libc5 */
29
  if (fp->_IO_write_ptr > fp->_IO_write_base)
38
  if (fp->_IO_write_ptr > fp->_IO_write_base)
30
    return 0;
39
    return 0;
31
  return (fp->_IO_read_end - fp->_IO_read_ptr)
40
  return (fp->_IO_read_end - fp->_IO_read_ptr)
32
         + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
41
         + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
33
            0);
42
            0);
34
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
43
#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
35
  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
44
  /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
36
  if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
45
  if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
37
    return 0;
46
    return 0;
38
# if defined __DragonFly__
47
# if defined __DragonFly__
Lines 53-59 freadahead (FILE *fp) Link Here
53
  if ((fp_->_flags & _IOWRITING) != 0)
62
  if ((fp_->_flags & _IOWRITING) != 0)
54
    return 0;
63
    return 0;
55
  return fp_->_count;
64
  return fp_->_count;
56
#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
65
#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel, OpenVMS */
57
  if ((fp_->_flag & _IOWRT) != 0)
66
  if ((fp_->_flag & _IOWRT) != 0)
58
    return 0;
67
    return 0;
59
  return fp_->_cnt;
68
  return fp_->_cnt;

Return to bug 663242