]> git.cworth.org Git - tar/blob - gnu/stdio-impl.h
a05563f72d4b7d641193353d0f1bbd4619882a41
[tar] / gnu / stdio-impl.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Implementation details of FILE streams.
4    Copyright (C) 2007-2010 Free Software Foundation, Inc.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 /* Many stdio implementations have the same logic and therefore can share
20    the same implementation of stdio extension API, except that some fields
21    have different naming conventions, or their access requires some casts.  */
22
23
24 /* BSD stdio derived implementations.  */
25
26 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
27
28 # if defined __DragonFly__          /* DragonFly */
29   /* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>.  */
30 #  define fp_ ((struct { struct __FILE_public pub; \
31                          struct { unsigned char *_base; int _size; } _bf; \
32                          void *cookie; \
33                          void *_close; \
34                          void *_read; \
35                          void *_seek; \
36                          void *_write; \
37                          struct { unsigned char *_base; int _size; } _ub; \
38                          int _ur; \
39                          unsigned char _ubuf[3]; \
40                          unsigned char _nbuf[1]; \
41                          struct { unsigned char *_base; int _size; } _lb; \
42                          int _blksize; \
43                          fpos_t _offset; \
44                          /* More fields, not relevant here.  */ \
45                        } *) fp)
46   /* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>.  */
47 #  define _p pub._p
48 #  define _flags pub._flags
49 #  define _r pub._r
50 #  define _w pub._w
51 # else
52 #  define fp_ fp
53 # endif
54
55 # if defined __NetBSD__ || defined __OpenBSD__ /* NetBSD, OpenBSD */
56   /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
57      and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
58   struct __sfileext
59     {
60       struct  __sbuf _ub; /* ungetc buffer */
61       /* More fields, not relevant here.  */
62     };
63 #  define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
64 # else                                         /* FreeBSD, DragonFly, MacOS X, Cygwin */
65 #  define fp_ub fp_->_ub
66 # endif
67
68 # define HASUB(fp) (fp_ub._base != NULL)
69
70 #endif
71
72
73 /* SystemV derived implementations.  */
74
75 #if defined _IOERR
76
77 # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
78 #  define fp_ ((struct { unsigned char *_ptr; \
79                          unsigned char *_base; \
80                          unsigned char *_end; \
81                          long _cnt; \
82                          int _file; \
83                          unsigned int _flag; \
84                        } *) fp)
85 # else
86 #  define fp_ fp
87 # endif
88
89 # if defined _SCO_DS                /* OpenServer */
90 #  define _cnt __cnt
91 #  define _ptr __ptr
92 #  define _base __base
93 #  define _flag __flag
94 # endif
95
96 #endif