stdio.h revision 129774
11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1990, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * This code is derived from software contributed to Berkeley by 61539Srgrimes * Chris Torek. 71539Srgrimes * 81539Srgrimes * Redistribution and use in source and binary forms, with or without 91539Srgrimes * modification, are permitted provided that the following conditions 101539Srgrimes * are met: 111539Srgrimes * 1. Redistributions of source code must retain the above copyright 121539Srgrimes * notice, this list of conditions and the following disclaimer. 131539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141539Srgrimes * notice, this list of conditions and the following disclaimer in the 151539Srgrimes * documentation and/or other materials provided with the distribution. 161539Srgrimes * 3. All advertising materials mentioning features or use of this software 171539Srgrimes * must display the following acknowledgement: 181539Srgrimes * This product includes software developed by the University of 191539Srgrimes * California, Berkeley and its contributors. 201539Srgrimes * 4. Neither the name of the University nor the names of its contributors 211539Srgrimes * may be used to endorse or promote products derived from this software 221539Srgrimes * without specific prior written permission. 231539Srgrimes * 241539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341539Srgrimes * SUCH DAMAGE. 351539Srgrimes * 3623655Speter * @(#)stdio.h 8.5 (Berkeley) 4/29/95 3750473Speter * $FreeBSD: head/include/stdio.h 129774 2004-05-27 10:08:44Z tjr $ 381539Srgrimes */ 391539Srgrimes 401539Srgrimes#ifndef _STDIO_H_ 411539Srgrimes#define _STDIO_H_ 421539Srgrimes 431539Srgrimes#include <sys/cdefs.h> 44123257Smarcel#include <sys/_null.h> 45102227Smike#include <sys/_types.h> 461539Srgrimes 47104585Smiketypedef __off_t fpos_t; 48104585Smike 49102227Smike#ifndef _SIZE_T_DECLARED 50102227Smiketypedef __size_t size_t; 51102227Smike#define _SIZE_T_DECLARED 521539Srgrimes#endif 531539Srgrimes 54104585Smike#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE 55104585Smike#ifndef _VA_LIST_DECLARED 56104585Smiketypedef __va_list va_list; 57104585Smike#define _VA_LIST_DECLARED 58104585Smike#endif 59104585Smike#endif 60104585Smike 611539Srgrimes#define _FSTDIO /* Define for new stdio with functions. */ 621539Srgrimes 631539Srgrimes/* 641539Srgrimes * NB: to fit things in six character monocase externals, the stdio 651539Srgrimes * code uses the prefix `__s' for stdio objects, typically followed 661539Srgrimes * by a three-character attempt at a mnemonic. 671539Srgrimes */ 681539Srgrimes 691539Srgrimes/* stdio buffers */ 701539Srgrimesstruct __sbuf { 711539Srgrimes unsigned char *_base; 721539Srgrimes int _size; 731539Srgrimes}; 741539Srgrimes 7572529Simp/* hold a buncha junk that would grow the ABI */ 7673254Sdeischenstruct __sFILEX; 7772529Simp 781539Srgrimes/* 791539Srgrimes * stdio state variables. 801539Srgrimes * 811539Srgrimes * The following always hold: 821539Srgrimes * 831539Srgrimes * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), 841539Srgrimes * _lbfsize is -_bf._size, else _lbfsize is 0 851539Srgrimes * if _flags&__SRD, _w is 0 861539Srgrimes * if _flags&__SWR, _r is 0 871539Srgrimes * 881539Srgrimes * This ensures that the getc and putc macros (or inline functions) never 891539Srgrimes * try to write or read from a file that is in `read' or `write' mode. 901539Srgrimes * (Moreover, they can, and do, automatically switch from read mode to 911539Srgrimes * write mode, and back, on "r+" and "w+" files.) 921539Srgrimes * 931539Srgrimes * _lbfsize is used only to make the inline line-buffered output stream 941539Srgrimes * code as compact as possible. 951539Srgrimes * 961539Srgrimes * _ub, _up, and _ur are used when ungetc() pushes back more characters 971539Srgrimes * than fit in the current _bf, or when ungetc() pushes back a character 981539Srgrimes * that does not match the previous one in _bf. When this happens, 991539Srgrimes * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff 1001539Srgrimes * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. 1011539Srgrimes * 1021539Srgrimes * NB: see WARNING above before changing the layout of this structure! 1031539Srgrimes */ 1041539Srgrimestypedef struct __sFILE { 1051539Srgrimes unsigned char *_p; /* current position in (some) buffer */ 1061539Srgrimes int _r; /* read space left for getc() */ 1071539Srgrimes int _w; /* write space left for putc() */ 1081539Srgrimes short _flags; /* flags, below; this FILE is free if 0 */ 1091539Srgrimes short _file; /* fileno, if Unix descriptor, else -1 */ 1101539Srgrimes struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ 1111539Srgrimes int _lbfsize; /* 0 or -_bf._size, for inline putc */ 1121539Srgrimes 1131539Srgrimes /* operations */ 1141539Srgrimes void *_cookie; /* cookie passed to io functions */ 11593032Simp int (*_close)(void *); 11693032Simp int (*_read)(void *, char *, int); 11793032Simp fpos_t (*_seek)(void *, fpos_t, int); 11893032Simp int (*_write)(void *, const char *, int); 1191539Srgrimes 1201539Srgrimes /* separate buffer for long sequences of ungetc() */ 1211539Srgrimes struct __sbuf _ub; /* ungetc buffer */ 12272529Simp struct __sFILEX *_extra; /* additions to FILE to not break ABI */ 1231539Srgrimes int _ur; /* saved _r when _r is counting ungetc data */ 1241539Srgrimes 1251539Srgrimes /* tricks to meet minimum requirements even when malloc() fails */ 1261539Srgrimes unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ 1271539Srgrimes unsigned char _nbuf[1]; /* guarantee a getc() buffer */ 1281539Srgrimes 1291539Srgrimes /* separate buffer for fgetln() when line crosses buffer boundary */ 1301539Srgrimes struct __sbuf _lb; /* buffer for fgetln() */ 1311539Srgrimes 1321539Srgrimes /* Unix stdio files get aligned to block boundaries on fseek() */ 1331539Srgrimes int _blksize; /* stat.st_blksize (may be != _bf._size) */ 1341539Srgrimes fpos_t _offset; /* current lseek offset (see WARNING) */ 1351539Srgrimes} FILE; 1361539Srgrimes 137129774Stjr#ifndef _STDSTREAM_DECLARED 1381539Srgrimes__BEGIN_DECLS 13981600Speterextern FILE *__stdinp; 14081600Speterextern FILE *__stdoutp; 14181600Speterextern FILE *__stderrp; 1421539Srgrimes__END_DECLS 143129774Stjr#define _STDSTREAM_DECLARED 144129774Stjr#endif 1451539Srgrimes 1461539Srgrimes#define __SLBF 0x0001 /* line buffered */ 1471539Srgrimes#define __SNBF 0x0002 /* unbuffered */ 1481539Srgrimes#define __SRD 0x0004 /* OK to read */ 1491539Srgrimes#define __SWR 0x0008 /* OK to write */ 1501539Srgrimes /* RD and WR are never simultaneously asserted */ 1511539Srgrimes#define __SRW 0x0010 /* open for reading & writing */ 1521539Srgrimes#define __SEOF 0x0020 /* found EOF */ 1531539Srgrimes#define __SERR 0x0040 /* found error */ 1541539Srgrimes#define __SMBF 0x0080 /* _buf is from malloc */ 1551539Srgrimes#define __SAPP 0x0100 /* fdopen()ed in append mode */ 1561539Srgrimes#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ 15713771Smpp#define __SOPT 0x0400 /* do fseek() optimization */ 15813771Smpp#define __SNPT 0x0800 /* do not do fseek() optimization */ 1591539Srgrimes#define __SOFF 0x1000 /* set iff _offset is in fact correct */ 1601539Srgrimes#define __SMOD 0x2000 /* true => fgetln modified _p text */ 16137489Speter#define __SALC 0x4000 /* allocate string space dynamically */ 16272372Sdeischen#define __SIGN 0x8000 /* ignore this file in _fwalk */ 1631539Srgrimes 1641539Srgrimes/* 1651539Srgrimes * The following three definitions are for ANSI C, which took them 1661539Srgrimes * from System V, which brilliantly took internal interface macros and 1671539Srgrimes * made them official arguments to setvbuf(), without renaming them. 1681539Srgrimes * Hence, these ugly _IOxxx names are *supposed* to appear in user code. 1691539Srgrimes * 1701539Srgrimes * Although numbered as their counterparts above, the implementation 1711539Srgrimes * does not rely on this. 1721539Srgrimes */ 1731539Srgrimes#define _IOFBF 0 /* setvbuf should set fully buffered */ 1741539Srgrimes#define _IOLBF 1 /* setvbuf should set line buffered */ 1751539Srgrimes#define _IONBF 2 /* setvbuf should set unbuffered */ 1761539Srgrimes 1771539Srgrimes#define BUFSIZ 1024 /* size of buffer used by setbuf */ 1781539Srgrimes#define EOF (-1) 1791539Srgrimes 1801539Srgrimes/* 1811539Srgrimes * FOPEN_MAX is a minimum maximum, and is the number of streams that 1821539Srgrimes * stdio can provide without attempting to allocate further resources 1831539Srgrimes * (which could fail). Do not use this for anything. 1841539Srgrimes */ 1851539Srgrimes /* must be == _POSIX_STREAM_MAX <limits.h> */ 1861539Srgrimes#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */ 1871539Srgrimes#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */ 1881539Srgrimes 1891539Srgrimes/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ 190100133Swollman#if __XSI_VISIBLE 1911539Srgrimes#define P_tmpdir "/var/tmp/" 1921539Srgrimes#endif 1931539Srgrimes#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ 1941539Srgrimes#define TMP_MAX 308915776 1951539Srgrimes 1961539Srgrimes#ifndef SEEK_SET 1971539Srgrimes#define SEEK_SET 0 /* set file offset to offset */ 1981539Srgrimes#endif 1991539Srgrimes#ifndef SEEK_CUR 2001539Srgrimes#define SEEK_CUR 1 /* set file offset to current plus offset */ 2011539Srgrimes#endif 2021539Srgrimes#ifndef SEEK_END 2031539Srgrimes#define SEEK_END 2 /* set file offset to EOF plus offset */ 2041539Srgrimes#endif 2051539Srgrimes 20681600Speter#define stdin __stdinp 20781600Speter#define stdout __stdoutp 20881600Speter#define stderr __stderrp 2091539Srgrimes 210100133Swollman__BEGIN_DECLS 2111539Srgrimes/* 2121539Srgrimes * Functions defined in ANSI C standard. 2131539Srgrimes */ 21493032Simpvoid clearerr(FILE *); 21593032Simpint fclose(FILE *); 21693032Simpint feof(FILE *); 21793032Simpint ferror(FILE *); 21893032Simpint fflush(FILE *); 21993032Simpint fgetc(FILE *); 220104989Smikeint fgetpos(FILE * __restrict, fpos_t * __restrict); 221104989Smikechar *fgets(char * __restrict, int, FILE * __restrict); 222104989SmikeFILE *fopen(const char * __restrict, const char * __restrict); 223103012Stjrint fprintf(FILE * __restrict, const char * __restrict, ...); 22493032Simpint fputc(int, FILE *); 225104989Smikeint fputs(const char * __restrict, FILE * __restrict); 226104989Smikesize_t fread(void * __restrict, size_t, size_t, FILE * __restrict); 227104989SmikeFILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict); 228104989Smikeint fscanf(FILE * __restrict, const char * __restrict, ...); 22993032Simpint fseek(FILE *, long, int); 23093032Simpint fsetpos(FILE *, const fpos_t *); 23193032Simplong ftell(FILE *); 232104989Smikesize_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); 23393032Simpint getc(FILE *); 23493032Simpint getchar(void); 23593032Simpchar *gets(char *); 23693032Simpvoid perror(const char *); 237103012Stjrint printf(const char * __restrict, ...); 23893032Simpint putc(int, FILE *); 23993032Simpint putchar(int); 24093032Simpint puts(const char *); 24193032Simpint remove(const char *); 24293032Simpint rename(const char *, const char *); 24393032Simpvoid rewind(FILE *); 244104989Smikeint scanf(const char * __restrict, ...); 245103012Stjrvoid setbuf(FILE * __restrict, char * __restrict); 246103012Stjrint setvbuf(FILE * __restrict, char * __restrict, int, size_t); 247103012Stjrint sprintf(char * __restrict, const char * __restrict, ...); 248104989Smikeint sscanf(const char * __restrict, const char * __restrict, ...); 24993032SimpFILE *tmpfile(void); 25093032Simpchar *tmpnam(char *); 25193032Simpint ungetc(int, FILE *); 252103012Stjrint vfprintf(FILE * __restrict, const char * __restrict, 253102227Smike __va_list); 254103012Stjrint vprintf(const char * __restrict, __va_list); 255103012Stjrint vsprintf(char * __restrict, const char * __restrict, 256102227Smike __va_list); 2571539Srgrimes 258100133Swollman#if __ISO_C_VISIBLE >= 1999 259103012Stjrint snprintf(char * __restrict, size_t, const char * __restrict, 260101914Srobert ...) __printflike(3, 4); 261105098Stjrint vfscanf(FILE * __restrict, const char * __restrict, __va_list) 262105098Stjr __scanflike(2, 0); 263104989Smikeint vscanf(const char * __restrict, __va_list) __scanflike(1, 0); 264103012Stjrint vsnprintf(char * __restrict, size_t, const char * __restrict, 265102227Smike __va_list) __printflike(3, 0); 266104989Smikeint vsscanf(const char * __restrict, const char * __restrict, __va_list) 267104585Smike __scanflike(2, 0); 268100133Swollman#endif 269100133Swollman 2701539Srgrimes/* 271100133Swollman * Functions defined in all versions of POSIX 1003.1. 2721539Srgrimes */ 273104585Smike#if __BSD_VISIBLE || __POSIX_VISIBLE <= 199506 27419211Swosch/* size for cuserid(3); UT_NAMESIZE + 1, see <utmp.h> */ 275104585Smike#define L_cuserid 17 /* legacy */ 276104585Smike#endif 2771539Srgrimes 278104585Smike#if __POSIX_VISIBLE 27919211Swosch#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */ 28019211Swosch 28193032Simpchar *ctermid(char *); 28293032SimpFILE *fdopen(int, const char *); 28393032Simpint fileno(FILE *); 284100133Swollman#endif /* __POSIX_VISIBLE */ 285100133Swollman 286100133Swollman#if __POSIX_VISIBLE >= 199209 287100133Swollmanint pclose(FILE *); 288100133SwollmanFILE *popen(const char *, const char *); 289100133Swollman#endif 290100133Swollman 291100133Swollman#if __POSIX_VISIBLE >= 199506 29293032Simpint ftrylockfile(FILE *); 29393032Simpvoid flockfile(FILE *); 29493032Simpvoid funlockfile(FILE *); 2951539Srgrimes 2961539Srgrimes/* 297100133Swollman * These are normally used through macros as defined below, but POSIX 298100133Swollman * requires functions as well. 29924897Sbde */ 300100133Swollmanint getc_unlocked(FILE *); 301100133Swollmanint getchar_unlocked(void); 302100133Swollmanint putc_unlocked(int, FILE *); 303100133Swollmanint putchar_unlocked(int); 30424897Sbde#endif 305109168Stjr#if __BSD_VISIBLE 306109168Stjrvoid clearerr_unlocked(FILE *); 307109168Stjrint feof_unlocked(FILE *); 308109168Stjrint ferror_unlocked(FILE *); 309109168Stjrint fileno_unlocked(FILE *); 310109168Stjr#endif 311100133Swollman 312100133Swollman#if __POSIX_VISIBLE >= 200112 313102227Smikeint fseeko(FILE *, __off_t, int); 314102227Smike__off_t ftello(FILE *); 31524897Sbde#endif 316100133Swollman 317100133Swollman#if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 318100133Swollmanint getw(FILE *); 319100133Swollmanint putw(int, FILE *); 320100133Swollman#endif /* BSD or X/Open before issue 6 */ 321100133Swollman 322100133Swollman#if __XSI_VISIBLE 323100133Swollmanchar *tempnam(const char *, const char *); 32424897Sbde#endif 32524897Sbde 32624897Sbde/* 3271539Srgrimes * Routines that are purely local. 3281539Srgrimes */ 329100133Swollman#if __BSD_VISIBLE 33093032Simpint asprintf(char **, const char *, ...) __printflike(2, 3); 33193032Simpchar *ctermid_r(char *); 33293032Simpchar *fgetln(FILE *, size_t *); 33387369Sobrien#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3 33487369Sobrien#define __ATTR_FORMAT_ARG __attribute__((__format_arg__(2))) 33587369Sobrien#else 33687369Sobrien#define __ATTR_FORMAT_ARG 33787369Sobrien#endif 33893032Simp__const char *fmtcheck(const char *, const char *) __ATTR_FORMAT_ARG; 33993032Simpint fpurge(FILE *); 34093032Simpvoid setbuffer(FILE *, char *, int); 34193032Simpint setlinebuf(FILE *); 342102227Smikeint vasprintf(char **, const char *, __va_list) 34337614Sbde __printflike(2, 0); 3441539Srgrimes 3451539Srgrimes/* 346100133Swollman * The system error table contains messages for the first sys_nerr 347100133Swollman * positive errno values. Use strerror() or strerror_r() from <string.h> 348100133Swollman * instead. 349100133Swollman */ 350100133Swollmanextern __const int sys_nerr; 351100133Swollmanextern __const char *__const sys_errlist[]; 352100133Swollman 353100133Swollman/* 3541539Srgrimes * Stdio function-access interface. 3551539Srgrimes */ 35693032SimpFILE *funopen(const void *, 35775818Sobrien int (*)(void *, char *, int), 35875818Sobrien int (*)(void *, const char *, int), 35975818Sobrien fpos_t (*)(void *, fpos_t, int), 36093032Simp int (*)(void *)); 3611539Srgrimes#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) 3621539Srgrimes#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) 3631539Srgrimes 3641539Srgrimes/* 365100133Swollman * Portability hacks. See <sys/types.h>. 366100133Swollman */ 367100133Swollman#ifndef _FTRUNCATE_DECLARED 368100133Swollman#define _FTRUNCATE_DECLARED 369102227Smikeint ftruncate(int, __off_t); 370100133Swollman#endif 371100133Swollman#ifndef _LSEEK_DECLARED 372100133Swollman#define _LSEEK_DECLARED 373102227Smike__off_t lseek(int, __off_t, int); 374100133Swollman#endif 375100133Swollman#ifndef _MMAP_DECLARED 376100133Swollman#define _MMAP_DECLARED 377102227Smikevoid *mmap(void *, size_t, int, int, int, __off_t); 378100133Swollman#endif 379100133Swollman#ifndef _TRUNCATE_DECLARED 380100133Swollman#define _TRUNCATE_DECLARED 381102227Smikeint truncate(const char *, __off_t); 382100133Swollman#endif 383100133Swollman#endif /* __BSD_VISIBLE */ 384100133Swollman 385100133Swollman/* 3861539Srgrimes * Functions internal to the implementation. 3871539Srgrimes */ 38893032Simpint __srget(FILE *); 38993032Simpint __swbuf(int, FILE *); 3901539Srgrimes 3911539Srgrimes/* 3928858Srgrimes * The __sfoo macros are here so that we can 3931539Srgrimes * define function versions in the C library. 3941539Srgrimes */ 3951539Srgrimes#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) 3961539Srgrimes#if defined(__GNUC__) && defined(__STDC__) 3971539Srgrimesstatic __inline int __sputc(int _c, FILE *_p) { 3981539Srgrimes if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) 3991539Srgrimes return (*_p->_p++ = _c); 4001539Srgrimes else 4011539Srgrimes return (__swbuf(_c, _p)); 4021539Srgrimes} 4031539Srgrimes#else 4041539Srgrimes/* 4051539Srgrimes * This has been tuned to generate reasonable code on the vax using pcc. 4061539Srgrimes */ 4071539Srgrimes#define __sputc(c, p) \ 4081539Srgrimes (--(p)->_w < 0 ? \ 4091539Srgrimes (p)->_w >= (p)->_lbfsize ? \ 4101539Srgrimes (*(p)->_p = (c)), *(p)->_p != '\n' ? \ 4111539Srgrimes (int)*(p)->_p++ : \ 4121539Srgrimes __swbuf('\n', p) : \ 4131539Srgrimes __swbuf((int)(c), p) : \ 4141539Srgrimes (*(p)->_p = (c), (int)*(p)->_p++)) 4151539Srgrimes#endif 4161539Srgrimes 4171539Srgrimes#define __sfeof(p) (((p)->_flags & __SEOF) != 0) 4181539Srgrimes#define __sferror(p) (((p)->_flags & __SERR) != 0) 4191539Srgrimes#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) 4201539Srgrimes#define __sfileno(p) ((p)->_file) 4211539Srgrimes 422127100Stjrextern int __isthreaded; 423127100Stjr 424127230Stjr#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p)) 425127230Stjr#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p)) 426127230Stjr#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p)) 427127100Stjr 428127100Stjr#if __POSIX_VISIBLE 429127230Stjr#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p)) 430127100Stjr#endif 431127100Stjr 432127230Stjr#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp)) 433127230Stjr#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp)) 434127100Stjr 435127100Stjr#define getchar() getc(stdin) 436127100Stjr#define putchar(x) putc(x, stdout) 437127100Stjr 438104585Smike#if __BSD_VISIBLE 43935127Sjb/* 44035127Sjb * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12 44135127Sjb * B.8.2.7 for the rationale behind the *_unlocked() macros. 44235127Sjb */ 44335127Sjb#define feof_unlocked(p) __sfeof(p) 44435127Sjb#define ferror_unlocked(p) __sferror(p) 44535127Sjb#define clearerr_unlocked(p) __sclearerr(p) 44635127Sjb#define fileno_unlocked(p) __sfileno(p) 447104585Smike#endif 448104585Smike#if __POSIX_VISIBLE >= 199506 44935127Sjb#define getc_unlocked(fp) __sgetc(fp) 45071580Sdeischen#define putc_unlocked(x, fp) __sputc(x, fp) 4511539Srgrimes 45235127Sjb#define getchar_unlocked() getc_unlocked(stdin) 45335127Sjb#define putchar_unlocked(x) putc_unlocked(x, stdout) 454104585Smike#endif 45524897Sbde 456100133Swollman__END_DECLS 45724897Sbde#endif /* !_STDIO_H_ */ 458