4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * University Copyright- Copyright (c) 1982, 1986, 1988
31 * The Regents of the University of California
34 * University Acknowledgment- Portions of this document are derived from
35 * software developed by the University of California, Berkeley, and its
39 #pragma ident "%Z%%M% %I% %E% SMI"
42 * stdiom.h - shared guts of stdio therefore it doesn't need
43 * a surrounding #ifndef
49 typedef unsigned char Uchar
;
51 #define MAXVAL (MAXINT - (MAXINT % BUFSIZ))
54 * The number of actual pushback characters is the value
55 * of PUSHBACK plus the first byte of the buffer. The FILE buffer must,
56 * for performance reasons, start on a word aligned boundry so the value
57 * of PUSHBACK should be a multiple of word.
58 * At least 4 bytes of PUSHBACK are needed. If sizeof(int) = 1 this breaks.
61 #define PUSHBACK ((int)(((3 + sizeof (int) - 1) / sizeof (int)) * sizeof (int)))
63 /* minimum buffer size must be at least 8 or shared library will break */
64 #define _SMBFSZ (((PUSHBACK + 4) < 8) ? 8 : (PUSHBACK + 4))
66 extern Uchar
*_bufendtab
[];
69 #define MULTIBFSZ(SZ) ((SZ) & ~0x3ff)
71 #define MULTIBFSZ(SZ) ((SZ) & ~0x1ff)
73 #define MULTIBFSZ(SZ) ((SZ) - (SZ % BUFSIZ))
76 #define _bufend(iop) _realbufend(iop)
77 #define setbufend(iop, end) _setbufend(iop, end)
80 * Internal routines from _iob.c
82 extern void _cleanup(void);
83 extern void _flushlbf(void);
84 extern FILE *_findiop(void);
85 extern Uchar
*_realbufend(FILE *iop
);
86 extern void _setbufend(FILE *iop
, Uchar
*end
);
87 extern int _wrtchk(FILE *iop
);
90 * Internal routines from flush.c
92 extern void _bufsync(FILE *iop
, Uchar
*bufend
);
93 extern int _xflsbuf(FILE *iop
);
96 * Internal routines from _findbuf.c
98 extern Uchar
*_findbuf(FILE *iop
);
101 extern int _file_set(FILE *, int, const char *);
102 #define SET_FILE(iop, fd) (iop)->_magic = (fd); (iop)->__extendedfd = 0
103 #define _FILE_FD_MAX 255
107 * The following macros improve performance of the stdio by reducing the
108 * number of calls to _bufsync and _wrtchk. _needsync checks whether
109 * or not _bufsync needs to be called. _WRTCHK has the same effect as
110 * _wrtchk, but often these functions have no effect, and in those cases
111 * the macros avoid the expense of calling the functions.
114 #define _needsync(p, bufend) ((bufend - (p)->_ptr) < \
115 ((p)->_cnt < 0 ? 0 : (p)->_cnt))
117 #define _WRTCHK(iop) ((((iop->_flag & (_IOWRT | _IOEOF)) != _IOWRT) || \
118 (iop->_base == 0) || \
119 (iop->_ptr == iop->_base && iop->_cnt == 0 && \
120 !(iop->_flag & (_IONBF | _IOLBF)))) \
122 #endif /* _STDIOM_H */