aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdio-impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdio-impl.h')
-rw-r--r--lib/stdio-impl.h62
1 files changed, 58 insertions, 4 deletions
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 05c5752a243..393ef0cf58d 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -60,25 +60,79 @@
60# define _flags pub._flags 60# define _flags pub._flags
61# define _r pub._r 61# define _r pub._r
62# 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)
63# else 92# else
64# define fp_ fp 93# define fp_ fp
65# endif 94# endif
66 95
67# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix || defined __ANDROID__ /* NetBSD >= 1.5ZA, OpenBSD, Minix 3, Android */ 96# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
68 /* 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>
69 and <https://cvsweb.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> */
70 struct __sfileext 100 struct __sfileext
71 { 101 {
72 struct __sbuf _ub; /* ungetc buffer */ 102 struct __sbuf _ub; /* ungetc buffer */
73 /* More fields, not relevant here. */ 103 /* More fields, not relevant here. */
74 }; 104 };
75# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub 105# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
76# 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 */
77# define fp_ub fp_->_ub 114# define fp_ub fp_->_ub
78# endif 115# endif
79 116
80# define HASUB(fp) (fp_ub._base != NULL) 117# define HASUB(fp) (fp_ub._base != NULL)
81 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
82#endif 136#endif
83 137
84 138
@@ -118,7 +172,7 @@
118# define _flag __flag 172# define _flag __flag
119# endif 173# endif
120 174
121#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* newer Windows with MSVC */ 175#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */
122 176
123/* <stdio.h> does not define the innards of FILE any more. */ 177/* <stdio.h> does not define the innards of FILE any more. */
124# define WINDOWS_OPAQUE_FILE 178# define WINDOWS_OPAQUE_FILE