stdio.h revision 87369
150477Speter/*-
21817Sdg * Copyright (c) 1990, 1993
31817Sdg *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * This code is derived from software contributed to Berkeley by
61541Srgrimes * Chris Torek.
7160798Sjhb *
81541Srgrimes * Redistribution and use in source and binary forms, with or without
9146806Srwatson * modification, are permitted provided that the following conditions
10146806Srwatson * are met:
11146806Srwatson * 1. Redistributions of source code must retain the above copyright
12146806Srwatson *    notice, this list of conditions and the following disclaimer.
13146806Srwatson * 2. Redistributions in binary form must reproduce the above copyright
14194390Sjhb *    notice, this list of conditions and the following disclaimer in the
15203660Sed *    documentation and/or other materials provided with the distribution.
16194390Sjhb * 3. All advertising materials mentioning features or use of this software
17194390Sjhb *    must display the following acknowledgement:
1811294Sswallace *	This product includes software developed by the University of
1910905Sbde *	California, Berkeley and its contributors.
201541Srgrimes * 4. Neither the name of the University nor the names of its contributors
2110905Sbde *    may be used to endorse or promote products derived from this software
2210905Sbde *    without specific prior written permission.
231541Srgrimes *
241541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
251541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
261541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
271541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2899855Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29194645Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30194833Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
311541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
321541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3369449Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34194383Sjhb * SUCH DAMAGE.
35160797Sjhb *
36181972Sobrien *	@(#)stdio.h	8.5 (Berkeley) 4/29/95
37181972Sobrien * $FreeBSD: head/include/stdio.h 87369 2001-12-04 21:30:23Z obrien $
38183361Sjhb */
39181972Sobrien
40181972Sobrien#ifndef	_STDIO_H_
41181972Sobrien#define	_STDIO_H_
42181972Sobrien
43211838Skib#include <sys/cdefs.h>
44104747Srwatson#include <machine/ansi.h>
45104747Srwatson
46123408Speter#ifdef	_BSD_SIZE_T_
47123408Spetertypedef	_BSD_SIZE_T_	size_t;
481541Srgrimes#undef	_BSD_SIZE_T_
491541Srgrimes#endif
5011294Sswallace
5111294Sswallace#ifndef NULL
5211294Sswallace#define	NULL	0
5311294Sswallace#endif
541541Srgrimes
551541Srgrimestypedef	_BSD_OFF_T_	fpos_t;
561541Srgrimes
571541Srgrimes#define	_FSTDIO			/* Define for new stdio with functions. */
581541Srgrimes
591541Srgrimes/*
60160798Sjhb * NB: to fit things in six character monocase externals, the stdio
61160798Sjhb * code uses the prefix `__s' for stdio objects, typically followed
62146806Srwatson * by a three-character attempt at a mnemonic.
63160798Sjhb */
64160798Sjhb
65146806Srwatson/* stdio buffers */
66160798Sjhbstruct __sbuf {
67146806Srwatson	unsigned char *_base;
68160798Sjhb	int	_size;
6912216Sbde};
7012216Sbde
7112216Sbde/* hold a buncha junk that would grow the ABI */
72160798Sjhbstruct __sFILEX;
73160798Sjhb
74242958Skib/*
75162991Srwatson * stdio state variables.
76160798Sjhb *
77160798Sjhb * The following always hold:
78146806Srwatson *
79160798Sjhb *	if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
80160798Sjhb *		_lbfsize is -_bf._size, else _lbfsize is 0
81160798Sjhb *	if _flags&__SRD, _w is 0
82160798Sjhb *	if _flags&__SWR, _r is 0
83160798Sjhb *
84160798Sjhb * This ensures that the getc and putc macros (or inline functions) never
85146806Srwatson * try to write or read from a file that is in `read' or `write' mode.
86160798Sjhb * (Moreover, they can, and do, automatically switch from read mode to
87146806Srwatson * write mode, and back, on "r+" and "w+" files.)
88160798Sjhb *
89146806Srwatson * _lbfsize is used only to make the inline line-buffered output stream
90160798Sjhb * code as compact as possible.
91160798Sjhb *
92146806Srwatson * _ub, _up, and _ur are used when ungetc() pushes back more characters
9312216Sbde * than fit in the current _bf, or when ungetc() pushes back a character
94160798Sjhb * that does not match the previous one in _bf.  When this happens,
95160798Sjhb * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
96160798Sjhb * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
97160798Sjhb *
98160798Sjhb * NB: see WARNING above before changing the layout of this structure!
99146806Srwatson */
100160798Sjhbtypedef	struct __sFILE {
101146806Srwatson	unsigned char *_p;	/* current position in (some) buffer */
102160798Sjhb	int	_r;		/* read space left for getc() */
103146806Srwatson	int	_w;		/* write space left for putc() */
104160798Sjhb	short	_flags;		/* flags, below; this FILE is free if 0 */
105146806Srwatson	short	_file;		/* fileno, if Unix descriptor, else -1 */
106146806Srwatson	struct	__sbuf _bf;	/* the buffer (at least 1 byte, if !NULL) */
107146806Srwatson	int	_lbfsize;	/* 0 or -_bf._size, for inline putc */
108160798Sjhb
109146806Srwatson	/* operations */
110146806Srwatson	void	*_cookie;	/* cookie passed to io functions */
111160798Sjhb	int	(*_close) __P((void *));
112146806Srwatson	int	(*_read)  __P((void *, char *, int));
113146806Srwatson	fpos_t	(*_seek)  __P((void *, fpos_t, int));
114160798Sjhb	int	(*_write) __P((void *, const char *, int));
115146806Srwatson
116146806Srwatson	/* separate buffer for long sequences of ungetc() */
117227691Sed	struct	__sbuf _ub;	/* ungetc buffer */
118248597Spjd	struct __sFILEX *_extra; /* additions to FILE to not break ABI */
119248597Spjd	int	_ur;		/* saved _r when _r is counting ungetc data */
120160798Sjhb
121160798Sjhb	/* tricks to meet minimum requirements even when malloc() fails */
122160798Sjhb	unsigned char _ubuf[3];	/* guarantee an ungetc() buffer */
123160798Sjhb	unsigned char _nbuf[1];	/* guarantee a getc() buffer */
124160798Sjhb
125160798Sjhb	/* separate buffer for fgetln() when line crosses buffer boundary */
126160798Sjhb	struct	__sbuf _lb;	/* buffer for fgetln() */
127160798Sjhb
128160798Sjhb	/* Unix stdio files get aligned to block boundaries on fseek() */
129146806Srwatson	int	_blksize;	/* stat.st_blksize (may be != _bf._size) */
130160798Sjhb	fpos_t	_offset;	/* current lseek offset (see WARNING) */
131146806Srwatson} FILE;
132160798Sjhb
133146806Srwatson__BEGIN_DECLS
134146806Srwatsonextern FILE __sF[];
135160798Sjhbextern FILE *__stdinp;
136160798Sjhbextern FILE *__stdoutp;
13721776Sbdeextern FILE *__stderrp;
13821776Sbde__END_DECLS
13921776Sbde
140160798Sjhb#define	__SLBF	0x0001		/* line buffered */
141146806Srwatson#define	__SNBF	0x0002		/* unbuffered */
142160798Sjhb#define	__SRD	0x0004		/* OK to read */
143160798Sjhb#define	__SWR	0x0008		/* OK to write */
144160798Sjhb	/* RD and WR are never simultaneously asserted */
145162373Srwatson#define	__SRW	0x0010		/* open for reading & writing */
146146806Srwatson#define	__SEOF	0x0020		/* found EOF */
147160798Sjhb#define	__SERR	0x0040		/* found error */
148146806Srwatson#define	__SMBF	0x0080		/* _buf is from malloc */
149160798Sjhb#define	__SAPP	0x0100		/* fdopen()ed in append mode */
150160798Sjhb#define	__SSTR	0x0200		/* this is an sprintf/snprintf string */
151160798Sjhb#define	__SOPT	0x0400		/* do fseek() optimization */
152176215Sru#define	__SNPT	0x0800		/* do not do fseek() optimization */
153176215Sru#define	__SOFF	0x1000		/* set iff _offset is in fact correct */
154160798Sjhb#define	__SMOD	0x2000		/* true => fgetln modified _p text */
155146806Srwatson#define	__SALC	0x4000		/* allocate string space dynamically */
156160798Sjhb#define	__SIGN	0x8000		/* ignore this file in _fwalk */
157146806Srwatson
158160798Sjhb/*
159160798Sjhb * The following three definitions are for ANSI C, which took them
160160798Sjhb * from System V, which brilliantly took internal interface macros and
161146806Srwatson * made them official arguments to setvbuf(), without renaming them.
162146806Srwatson * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
163162991Srwatson *
164146806Srwatson * Although numbered as their counterparts above, the implementation
165160798Sjhb * does not rely on this.
166146806Srwatson */
167160798Sjhb#define	_IOFBF	0		/* setvbuf should set fully buffered */
168146806Srwatson#define	_IOLBF	1		/* setvbuf should set line buffered */
169146806Srwatson#define	_IONBF	2		/* setvbuf should set unbuffered */
170160798Sjhb
171160798Sjhb#define	BUFSIZ	1024		/* size of buffer used by setbuf */
172160798Sjhb#define	EOF	(-1)
173146806Srwatson
174160798Sjhb/*
175146806Srwatson * FOPEN_MAX is a minimum maximum, and is the number of streams that
176160798Sjhb * stdio can provide without attempting to allocate further resources
177160798Sjhb * (which could fail).  Do not use this for anything.
178146806Srwatson */
179160798Sjhb				/* must be == _POSIX_STREAM_MAX <limits.h> */
180146806Srwatson#define	FOPEN_MAX	20	/* must be <= OPEN_MAX <sys/syslimits.h> */
181146806Srwatson#define	FILENAME_MAX	1024	/* must be <= PATH_MAX <sys/syslimits.h> */
182146806Srwatson
183160798Sjhb/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
184146806Srwatson#ifndef _ANSI_SOURCE
185160798Sjhb#define	P_tmpdir	"/var/tmp/"
186146806Srwatson#endif
187160798Sjhb#define	L_tmpnam	1024	/* XXX must be == PATH_MAX */
188146806Srwatson#define	TMP_MAX		308915776
189160798Sjhb
190160798Sjhb#ifndef SEEK_SET
191160798Sjhb#define	SEEK_SET	0	/* set file offset to offset */
192146806Srwatson#endif
193160798Sjhb#ifndef SEEK_CUR
194160798Sjhb#define	SEEK_CUR	1	/* set file offset to current plus offset */
195160798Sjhb#endif
196146806Srwatson#ifndef SEEK_END
197160798Sjhb#define	SEEK_END	2	/* set file offset to EOF plus offset */
198146806Srwatson#endif
199146806Srwatson
200160798Sjhb/* To be removed by 5.0-RELEASE */
201146806Srwatson#if (defined(__i386__) || defined(__alpha__)) && defined(_OLD_STDIO)
202146806Srwatson#define	stdin	(&__sF[0])
203160798Sjhb#define	stdout	(&__sF[1])
204160798Sjhb#define	stderr	(&__sF[2])
205146806Srwatson#else
206160798Sjhb#define	stdin	__stdinp
207123750Speter#define	stdout	__stdoutp
20812216Sbde#define	stderr	__stderrp
209160798Sjhb#endif
210146806Srwatson
211146806Srwatson/*
212160798Sjhb * Functions defined in ANSI C standard.
213160798Sjhb */
214146806Srwatson__BEGIN_DECLS
215160798Sjhbvoid	 clearerr __P((FILE *));
216146806Srwatsonint	 fclose __P((FILE *));
217160798Sjhbint	 feof __P((FILE *));
218146806Srwatsonint	 ferror __P((FILE *));
219194390Sjhbint	 fflush __P((FILE *));
220146806Srwatsonint	 fgetc __P((FILE *));
221160798Sjhbint	 fgetpos __P((FILE *, fpos_t *));
222160798Sjhbchar	*fgets __P((char *, int, FILE *));
223146806SrwatsonFILE	*fopen __P((const char *, const char *));
224160798Sjhbint	 fprintf __P((FILE *, const char *, ...));
225146806Srwatsonint	 fputc __P((int, FILE *));
226160798Sjhbint	 fputs __P((const char *, FILE *));
227146806Srwatsonsize_t	 fread __P((void *, size_t, size_t, FILE *));
228160798SjhbFILE	*freopen __P((const char *, const char *, FILE *));
229146806Srwatsonint	 fscanf __P((FILE *, const char *, ...));
230160798Sjhbint	 fseek __P((FILE *, long, int));
231146806Srwatsonint	 fsetpos __P((FILE *, const fpos_t *));
232160798Sjhblong	 ftell __P((FILE *));
233146806Srwatsonsize_t	 fwrite __P((const void *, size_t, size_t, FILE *));
234160798Sjhbint	 getc __P((FILE *));
235146806Srwatsonint	 getchar __P((void));
236160798Sjhbchar	*gets __P((char *));
237160798Sjhb#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
238160798Sjhbextern __const int sys_nerr;		/* perror(3) external variables */
23921776Sbdeextern __const char *__const sys_errlist[];
24021776Sbde#endif
241160798Sjhbvoid	 perror __P((const char *));
242146806Srwatsonint	 printf __P((const char *, ...));
243160798Sjhbint	 putc __P((int, FILE *));
244146806Srwatsonint	 putchar __P((int));
245160798Sjhbint	 puts __P((const char *));
246146806Srwatsonint	 remove __P((const char *));
247146806Srwatsonint	 rename  __P((const char *, const char *));
248160798Sjhbvoid	 rewind __P((FILE *));
249146806Srwatsonint	 scanf __P((const char *, ...));
250160798Sjhbvoid	 setbuf __P((FILE *, char *));
251146806Srwatsonint	 setvbuf __P((FILE *, char *, int, size_t));
252160798Sjhbint	 sprintf __P((char *, const char *, ...));
253146806Srwatsonint	 sscanf __P((const char *, const char *, ...));
254146806SrwatsonFILE	*tmpfile __P((void));
255160798Sjhbchar	*tmpnam __P((char *));
256146806Srwatsonint	 ungetc __P((int, FILE *));
257160798Sjhbint	 vfprintf __P((FILE *, const char *, _BSD_VA_LIST_));
258146806Srwatsonint	 vprintf __P((const char *, _BSD_VA_LIST_));
259160798Sjhbint	 vsprintf __P((char *, const char *, _BSD_VA_LIST_));
260146806Srwatson__END_DECLS
261160798Sjhb
262160798Sjhb/*
263194390Sjhb * Functions defined in POSIX 1003.1.
264146806Srwatson */
265146806Srwatson#ifndef _ANSI_SOURCE
266146806Srwatson/* size for cuserid(3); UT_NAMESIZE + 1, see <utmp.h> */
267160798Sjhb#define	L_cuserid	17
268160798Sjhb
269160798Sjhb#define	L_ctermid	1024	/* size for ctermid(3); PATH_MAX */
270160798Sjhb
271160798Sjhb__BEGIN_DECLS
272160798Sjhbchar	*ctermid __P((char *));
273160798SjhbFILE	*fdopen __P((int, const char *));
274160798Sjhbint	 fileno __P((FILE *));
275146806Srwatsonint	 ftrylockfile __P((FILE *));
276160798Sjhbvoid	 flockfile __P((FILE *));
277160798Sjhbvoid	 funlockfile __P((FILE *));
278146806Srwatson__END_DECLS
279160798Sjhb#endif /* not ANSI */
280160798Sjhb
281160798Sjhb/*
282146806Srwatson * Portability hacks.  See <sys/types.h>.
283146806Srwatson */
284160798Sjhb#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
285146806Srwatson__BEGIN_DECLS
286160798Sjhb#ifndef _FTRUNCATE_DECLARED
287146806Srwatson#define	_FTRUNCATE_DECLARED
288160798Sjhbint	 ftruncate __P((int, _BSD_OFF_T_));
289160798Sjhb#endif
290160798Sjhb#ifndef _LSEEK_DECLARED
291146806Srwatson#define	_LSEEK_DECLARED
292160798Sjhb_BSD_OFF_T_ lseek __P((int, _BSD_OFF_T_, int));
293146806Srwatson#endif
294160798Sjhb#ifndef _MMAP_DECLARED
295160798Sjhb#define	_MMAP_DECLARED
296160798Sjhbvoid	*mmap __P((void *, size_t, int, int, int, _BSD_OFF_T_));
297146806Srwatson#endif
298160798Sjhb#ifndef _TRUNCATE_DECLARED
299194390Sjhb#define	_TRUNCATE_DECLARED
300146806Srwatsonint	 truncate __P((const char *, _BSD_OFF_T_));
301146806Srwatson#endif
3021541Srgrimes__END_DECLS
3031541Srgrimes#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
3041541Srgrimes
3051541Srgrimes/*
3061541Srgrimes * Routines that are purely local.
307146806Srwatson */
308146806Srwatson#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
309146806Srwatson__BEGIN_DECLS
310177633Sdfrint	 asprintf __P((char **, const char *, ...)) __printflike(2, 3);
311177633Sdfrchar	*ctermid_r __P((char *));
31230740Sphkchar	*fgetln __P((FILE *, size_t *));
313161325Sjhb#ifdef __GNUC__
314160798Sjhb#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3
315146806Srwatson#define	__ATTR_FORMAT_ARG	__attribute__((__format_arg__(2)))
316160798Sjhb#else
317146806Srwatson#define	__ATTR_FORMAT_ARG
318160798Sjhb#endif
319146806Srwatson__const char *fmtcheck __P((const char *, const char *)) __ATTR_FORMAT_ARG;
320146806Srwatsonint	 fpurge __P((FILE *));
321160798Sjhbint	 fseeko __P((FILE *, _BSD_OFF_T_, int));
322146806Srwatson_BSD_OFF_T_ ftello __P((FILE *));
323160798Sjhbint	 getw __P((FILE *));
324146806Srwatsonint	 pclose __P((FILE *));
325184789SedFILE	*popen __P((const char *, const char *));
326146806Srwatsonint	 putw __P((int, FILE *));
327184789Sedvoid	 setbuffer __P((FILE *, char *, int));
328146806Srwatsonint	 setlinebuf __P((FILE *));
329184789Sedchar	*tempnam __P((const char *, const char *));
330161952Srwatsonint	 snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
331161952Srwatsonint	 vasprintf __P((char **, const char *, _BSD_VA_LIST_))
332146806Srwatson	    __printflike(2, 0);
333146806Srwatsonint	 vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_))
334146806Srwatson	    __printflike(3, 0);
335160798Sjhbint	 vscanf __P((const char *, _BSD_VA_LIST_)) __scanflike(1, 0);
336146806Srwatsonint	 vsscanf __P((const char *, const char *, _BSD_VA_LIST_))
337123750Speter	    __scanflike(2, 0);
338160798Sjhb__END_DECLS
339146806Srwatson
340123750Speter/*
341160798Sjhb * This is a #define because the function is used internally and
342146806Srwatson * (unlike vfscanf) the name __vfscanf is guaranteed not to collide
343123750Speter * with a user function when _ANSI_SOURCE or _POSIX_SOURCE is defined.
344146806Srwatson */
345171209Speter#define	 vfscanf	__vfscanf
346146806Srwatson
347171209Speter/*
348171209Speter * Stdio function-access interface.
349146806Srwatson */
350178888Sjulian__BEGIN_DECLS
351161946SrwatsonFILE	*funopen __P((const void *,
352146806Srwatson	    int (*)(void *, char *, int),
353146806Srwatson	    int (*)(void *, const char *, int),
354146806Srwatson	    fpos_t (*)(void *, fpos_t, int),
355146806Srwatson	    int (*)(void *)));
3561541Srgrimes__END_DECLS
35749428Sjkh#define	fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
358160798Sjhb#define	fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
359160798Sjhb#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
360160798Sjhb
361146806Srwatson/*
362146806Srwatson * Functions internal to the implementation.
363146806Srwatson */
364146806Srwatson__BEGIN_DECLS
365160798Sjhbint	__srget __P((FILE *));
366160798Sjhbint	__vfscanf __P((FILE *, const char *, _BSD_VA_LIST_));
367160798Sjhbint	__svfscanf __P((FILE *, const char *, _BSD_VA_LIST_));
368160798Sjhbint	__swbuf __P((int, FILE *));
369160798Sjhb__END_DECLS
370146806Srwatson
371160798Sjhb/*
372146806Srwatson * The __sfoo macros are here so that we can
373146806Srwatson * define function versions in the C library.
374160798Sjhb */
375146806Srwatson#define	__sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))
376146806Srwatson#if defined(__GNUC__) && defined(__STDC__)
377160798Sjhbstatic __inline int __sputc(int _c, FILE *_p) {
378146806Srwatson	if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
379171209Speter		return (*_p->_p++ = _c);
380171209Speter	else
381171209Speter		return (__swbuf(_c, _p));
382183361Sjhb}
383146806Srwatson#else
384171209Speter/*
385171209Speter * This has been tuned to generate reasonable code on the vax using pcc.
386171209Speter */
387146806Srwatson#define	__sputc(c, p) \
388171209Speter	(--(p)->_w < 0 ? \
389146806Srwatson		(p)->_w >= (p)->_lbfsize ? \
390160798Sjhb			(*(p)->_p = (c)), *(p)->_p != '\n' ? \
391146806Srwatson				(int)*(p)->_p++ : \
392146806Srwatson				__swbuf('\n', p) : \
393160798Sjhb			__swbuf((int)(c), p) : \
394160798Sjhb		(*(p)->_p = (c), (int)*(p)->_p++))
395160798Sjhb#endif
396160798Sjhb
397160798Sjhb#define	__sfeof(p)	(((p)->_flags & __SEOF) != 0)
398146806Srwatson#define	__sferror(p)	(((p)->_flags & __SERR) != 0)
399160798Sjhb#define	__sclearerr(p)	((void)((p)->_flags &= ~(__SERR|__SEOF)))
400146806Srwatson#define	__sfileno(p)	((p)->_file)
4012124Sdg
4022124Sdg/*
4032124Sdg * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12
4042124Sdg * B.8.2.7 for the rationale behind the *_unlocked() macros.
405209579Skib */
406209579Skib#define	feof_unlocked(p)	__sfeof(p)
407209579Skib#define	ferror_unlocked(p)	__sferror(p)
408209579Skib#define	clearerr_unlocked(p)	__sclearerr(p)
409209579Skib
410209579Skib#ifndef _ANSI_SOURCE
411209579Skib#define	fileno_unlocked(p)	__sfileno(p)
412209579Skib#endif
413209579Skib
414209579Skib#define	getc_unlocked(fp)	__sgetc(fp)
41512864Speter#define	putc_unlocked(x, fp)	__sputc(x, fp)
41612864Speter
41714215Speter#define	getchar_unlocked()	getc_unlocked(stdin)
418194910Sjhb#define	putchar_unlocked(x)	putc_unlocked(x, stdout)
419194910Sjhb
420160798Sjhb#endif /* !_STDIO_H_ */
421146806Srwatson