diff options
Diffstat (limited to 'libc/include/stdio.h')
-rw-r--r-- | libc/include/stdio.h | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/libc/include/stdio.h b/libc/include/stdio.h index a0161de..f5ed652 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -38,6 +38,14 @@ #ifndef _STDIO_H_ #define _STDIO_H_ +/* + * This file must contain a reference to __gnuc_va_list so that GCC's + * fixincludes knows that that's what's being used for va_list, and so + * to leave our <stdio.h> alone. (fixincludes gets in the way of pointing + * one toolchain at various different sets of platform headers.) + * If you alter this comment, be sure to keep "__gnuc_va_list" in it! + */ + #include <sys/cdefs.h> #include <sys/types.h> @@ -49,8 +57,6 @@ __BEGIN_DECLS -#define _FSTDIO /* Define for new stdio with functions. */ - typedef off_t fpos_t; /* stdio file position type */ /* @@ -138,7 +144,16 @@ typedef struct __sFILE { fpos_t _offset; /* current lseek offset */ } FILE; +/* Legacy BSD implementation of stdin/stdout/stderr. */ extern FILE __sF[]; +/* More obvious implementation. */ +extern FILE* stdin; +extern FILE* stdout; +extern FILE* stderr; +/* C99 and earlier plus current C++ standards say these must be macros. */ +#define stdin stdin +#define stdout stdout +#define stderr stderr #define __SLBF 0x0001 /* line buffered */ #define __SNBF 0x0002 /* unbuffered */ @@ -190,20 +205,9 @@ extern FILE __sF[]; #define L_tmpnam 1024 /* XXX must be == PATH_MAX */ #define TMP_MAX 308915776 -/* Always ensure that these are consistent with <fcntl.h> and <unistd.h>! */ -#ifndef SEEK_SET -#define SEEK_SET 0 /* set file offset to offset */ -#endif -#ifndef SEEK_CUR -#define SEEK_CUR 1 /* set file offset to current plus offset */ -#endif -#ifndef SEEK_END -#define SEEK_END 2 /* set file offset to EOF plus offset */ -#endif - -#define stdin (&__sF[0]) -#define stdout (&__sF[1]) -#define stderr (&__sF[2]) +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 /* * Functions defined in ANSI C standard. @@ -260,27 +264,38 @@ int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0); #ifndef __AUDIT__ #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L -char* gets(char*) __warnattr("gets is very unsafe; consider using fgets"); +char* gets(char*) __attribute__((deprecated("gets is unsafe, use fgets instead"))); #endif int sprintf(char* __restrict, const char* __restrict, ...) __printflike(2, 3) __warnattr("sprintf is often misused; please use snprintf"); -char* tmpnam(char*) __warnattr("tmpnam possibly used unsafely; consider using mkstemp"); int vsprintf(char* __restrict, const char* __restrict, __va_list) __printflike(2, 0) __warnattr("vsprintf is often misused; please use vsnprintf"); +char* tmpnam(char*) __attribute__((deprecated("tmpnam is unsafe, use mkstemp or tmpfile instead"))); #if __XPG_VISIBLE char* tempnam(const char*, const char*) - __warnattr("tempnam possibly used unsafely; consider using mkstemp"); + __attribute__((deprecated("tempnam is unsafe, use mkstemp or tmpfile instead"))); #endif #endif extern int rename(const char*, const char*); extern int renameat(int, const char*, int, const char*); +#if defined(__USE_FILE_OFFSET64) +/* Not possible. */ +int fgetpos(FILE * __restrict, fpos_t * __restrict) + __attribute__((__error__("not available with _FILE_OFFSET_BITS=64"))); +int fsetpos(FILE *, const fpos_t *) + __attribute__((__error__("not available with _FILE_OFFSET_BITS=64"))); +int fseeko(FILE *, off_t, int) + __attribute__((__error__("not available with _FILE_OFFSET_BITS=64"))); +off_t ftello(FILE *) + __attribute__((__error__("not available with _FILE_OFFSET_BITS=64"))); +#else int fgetpos(FILE * __restrict, fpos_t * __restrict); int fsetpos(FILE *, const fpos_t *); - int fseeko(FILE *, off_t, int); off_t ftello(FILE *); +#endif #if __ISO_C_VISIBLE >= 1999 || __BSD_VISIBLE int snprintf(char * __restrict, size_t, const char * __restrict, ...) @@ -324,6 +339,11 @@ int putc_unlocked(int, FILE *); int putchar_unlocked(int); #endif /* __POSIX_VISIBLE >= 199506 */ +#if __POSIX_VISIBLE >= 200809 +FILE* fmemopen(void*, size_t, const char*); +FILE* open_memstream(char**, size_t*); +#endif /* __POSIX_VISIBLE >= 200809 */ + #endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */ /* @@ -340,6 +360,10 @@ int vasprintf(char ** __restrict, const char * __restrict, __va_list) __printflike(2, 0); +void clearerr_unlocked(FILE*); +int feof_unlocked(FILE*); +int ferror_unlocked(FILE*); + /* * Stdio function-access interface. */ |