annotate lib/stdio-impl.h @ 14079:97fc9a21a8fb

maint: update almost all copyright ranges to include 2011 Run the new "make update-copyright" rule.
author Jim Meyering <meyering@redhat.com>
date Sat, 01 Jan 2011 20:17:23 +0100
parents 6fa9f46e6153
children 8250f2777afc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9979
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Implementation details of FILE streams.
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 13997
diff changeset
2 Copyright (C) 2007-2008, 2010-2011 Free Software Foundation, Inc.
9979
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Many stdio implementations have the same logic and therefore can share
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 the same implementation of stdio extension API, except that some fields
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 have different naming conventions, or their access requires some casts. */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 /* BSD stdio derived implementations. */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
13151
1adfe934d629 Port extended stdio to NetBSD 1.5.
Hauke Fath <hauke@espresso.rhein-neckar.de>
parents: 12559
diff changeset
24 #if defined __NetBSD__ /* NetBSD */
1adfe934d629 Port extended stdio to NetBSD 1.5.
Hauke Fath <hauke@espresso.rhein-neckar.de>
parents: 12559
diff changeset
25 /* Get __NetBSD_Version__. */
1adfe934d629 Port extended stdio to NetBSD 1.5.
Hauke Fath <hauke@espresso.rhein-neckar.de>
parents: 12559
diff changeset
26 # include <sys/param.h>
1adfe934d629 Port extended stdio to NetBSD 1.5.
Hauke Fath <hauke@espresso.rhein-neckar.de>
parents: 12559
diff changeset
27 #endif
1adfe934d629 Port extended stdio to NetBSD 1.5.
Hauke Fath <hauke@espresso.rhein-neckar.de>
parents: 12559
diff changeset
28
9981
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
29 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
30
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
31 # if defined __DragonFly__ /* DragonFly */
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
32 /* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
33 # define fp_ ((struct { struct __FILE_public pub; \
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
34 struct { unsigned char *_base; int _size; } _bf; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
35 void *cookie; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
36 void *_close; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
37 void *_read; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
38 void *_seek; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
39 void *_write; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
40 struct { unsigned char *_base; int _size; } _ub; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
41 int _ur; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
42 unsigned char _ubuf[3]; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
43 unsigned char _nbuf[1]; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
44 struct { unsigned char *_base; int _size; } _lb; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
45 int _blksize; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
46 fpos_t _offset; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
47 /* More fields, not relevant here. */ \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
48 } *) fp)
9981
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
49 /* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
50 # define _p pub._p
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
51 # define _flags pub._flags
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
52 # define _r pub._r
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
53 # define _w pub._w
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
54 # else
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
55 # define fp_ fp
e3d6988a9347 Add tentative support for DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 9979
diff changeset
56 # endif
9979
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57
13151
1adfe934d629 Port extended stdio to NetBSD 1.5.
Hauke Fath <hauke@espresso.rhein-neckar.de>
parents: 12559
diff changeset
58 # if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ /* NetBSD >= 1.5ZA, OpenBSD */
9979
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 struct __sfileext
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 {
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 struct __sbuf _ub; /* ungetc buffer */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 /* More fields, not relevant here. */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 };
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 # define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
13151
1adfe934d629 Port extended stdio to NetBSD 1.5.
Hauke Fath <hauke@espresso.rhein-neckar.de>
parents: 12559
diff changeset
67 # else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, MacOS X, Cygwin */
10144
6cbcb13324a6 Fix syntax error on DragonFly BSD.
Bruno Haible <bruno@clisp.org>
parents: 10143
diff changeset
68 # define fp_ub fp_->_ub
9979
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 # endif
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 # define HASUB(fp) (fp_ub._base != NULL)
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 #endif
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 /* SystemV derived implementations. */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77
13997
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
78 #ifdef __TANDEM /* NonStop Kernel */
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
79 # ifndef _IOERR
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
80 /* These values were determined by the program 'stdioext-flags' at
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
81 <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>. */
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
82 # define _IOERR 0x40
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
83 # define _IOREAD 0x80
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
84 # define _IOWRT 0x4
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
85 # define _IORW 0x100
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
86 # endif
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
87 #endif
6fa9f46e6153 Port extended stdio modules to HP NonStop Kernel.
Bruno Haible <bruno@clisp.org>
parents: 13151
diff changeset
88
9979
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 #if defined _IOERR
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 # define fp_ ((struct { unsigned char *_ptr; \
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
93 unsigned char *_base; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
94 unsigned char *_end; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
95 long _cnt; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
96 int _file; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
97 unsigned int _flag; \
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10144
diff changeset
98 } *) fp)
9979
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 # else
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 # define fp_ fp
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 # endif
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 # if defined _SCO_DS /* OpenServer */
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 # define _cnt __cnt
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 # define _ptr __ptr
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 # define _base __base
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 # define _flag __flag
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 # endif
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109
078a5c07126b New private include file lib/stdio-impl.h.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 #endif