1// -*- C++ -*- 2//===---------------------------- cstdio ----------------------------------===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is dual licensed under the MIT and the University of Illinois Open 7// Source Licenses. See LICENSE.TXT for details. 8// 9//===----------------------------------------------------------------------===// 10 11#ifndef _LIBCPP_CSTDIO 12#define _LIBCPP_CSTDIO 13 14/* 15 cstdio synopsis 16 17Macros: 18 19 BUFSIZ 20 EOF 21 FILENAME_MAX 22 FOPEN_MAX 23 L_tmpnam 24 NULL 25 SEEK_CUR 26 SEEK_END 27 SEEK_SET 28 TMP_MAX 29 _IOFBF 30 _IOLBF 31 _IONBF 32 stderr 33 stdin 34 stdout 35 36namespace std 37{ 38 39Types: 40 41FILE 42fpos_t 43size_t 44 45int remove(const char* filename); 46int rename(const char* old, const char* new); 47FILE* tmpfile(void); 48char* tmpnam(char* s); 49int fclose(FILE* stream); 50int fflush(FILE* stream); 51FILE* fopen(const char* restrict filename, const char* restrict mode); 52FILE* freopen(const char* restrict filename, const char * restrict mode, 53 FILE * restrict stream); 54void setbuf(FILE* restrict stream, char* restrict buf); 55int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size); 56int fprintf(FILE* restrict stream, const char* restrict format, ...); 57int fscanf(FILE* restrict stream, const char * restrict format, ...); 58int printf(const char* restrict format, ...); 59int scanf(const char* restrict format, ...); 60int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99 61int sprintf(char* restrict s, const char* restrict format, ...); 62int sscanf(const char* restrict s, const char* restrict format, ...); 63int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg); 64int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99 65int vprintf(const char* restrict format, va_list arg); 66int vscanf(const char* restrict format, va_list arg); // C99 67int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99 68 va_list arg); 69int vsprintf(char* restrict s, const char* restrict format, va_list arg); 70int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99 71int fgetc(FILE* stream); 72char* fgets(char* restrict s, int n, FILE* restrict stream); 73int fputc(int c, FILE* stream); 74int fputs(const char* restrict s, FILE* restrict stream); 75int getc(FILE* stream); 76int getchar(void); 77char* gets(char* s); // removed in C++14 78int putc(int c, FILE* stream); 79int putchar(int c); 80int puts(const char* s); 81int ungetc(int c, FILE* stream); 82size_t fread(void* restrict ptr, size_t size, size_t nmemb, 83 FILE* restrict stream); 84size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, 85 FILE* restrict stream); 86int fgetpos(FILE* restrict stream, fpos_t* restrict pos); 87int fseek(FILE* stream, long offset, int whence); 88int fsetpos(FILE*stream, const fpos_t* pos); 89long ftell(FILE* stream); 90void rewind(FILE* stream); 91void clearerr(FILE* stream); 92int feof(FILE* stream); 93int ferror(FILE* stream); 94void perror(const char* s); 95 96} // std 97*/ 98 99#include <__config> 100#include <stdio.h> 101 102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 103#pragma GCC system_header 104#endif 105 106// snprintf 107#if defined(_LIBCPP_MSVCRT) 108#include "support/win32/support.h" 109#endif 110 111#ifdef getc 112inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);} 113#undef getc 114inline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);} 115#endif // getc 116 117#ifdef getchar 118inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getchar(void) {return getchar();} 119#undef getchar 120inline _LIBCPP_INLINE_VISIBILITY int getchar(void) {return __libcpp_getchar();} 121#endif // getchar 122 123#ifdef putc 124inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);} 125#undef putc 126inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);} 127#endif // putc 128 129#ifdef __ANDROID__ 130// In bionic's stdio.h, putchar appears as both a function prototype and a macro (later 131// in the same header). Because it's defined as a macro, the following code snippet replaces 132// it with a function but with *different* visibility. GCC 4.x complains [-Wattributes] 133// 134// include/stdio.h:236:5: warning: conflicts with previous declaration here [-Wattributes] 135// int putchar(int); 136// 137// Undefine putchar to avoid redefinition, and putchar does exist in libc.so 138// 139#undef putchar 140#endif 141 142#ifdef putchar 143inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putchar(int __c) {return putchar(__c);} 144#undef putchar 145inline _LIBCPP_INLINE_VISIBILITY int putchar(int __c) {return __libcpp_putchar(__c);} 146#endif // putchar 147 148#ifdef clearerr 149inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) {return clearerr(__stream);} 150#undef clearerr 151inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) {return __libcpp_clearerr(__stream);} 152#endif // clearerr 153 154#ifdef feof 155inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) {return feof(__stream);} 156#undef feof 157inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) {return __libcpp_feof(__stream);} 158#endif // feof 159 160#ifdef ferror 161inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) {return ferror(__stream);} 162#undef ferror 163inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) {return __libcpp_ferror(__stream);} 164#endif // ferror 165 166_LIBCPP_BEGIN_NAMESPACE_STD 167 168using ::FILE; 169using ::fpos_t; 170using ::size_t; 171 172using ::remove; 173using ::rename; 174using ::tmpfile; 175using ::tmpnam; 176using ::fclose; 177using ::fflush; 178using ::fopen; 179using ::freopen; 180using ::setbuf; 181using ::setvbuf; 182using ::fprintf; 183using ::fscanf; 184using ::printf; 185using ::scanf; 186using ::snprintf; 187using ::sprintf; 188using ::sscanf; 189#ifndef _LIBCPP_MSVCRT 190using ::vfprintf; 191using ::vfscanf; 192using ::vscanf; 193using ::vsscanf; 194#endif // _LIBCPP_MSVCRT 195using ::vprintf; 196using ::vsnprintf; 197using ::vsprintf; 198using ::fgetc; 199using ::fgets; 200using ::fputc; 201using ::fputs; 202using ::getc; 203using ::getchar; 204#if _LIBCPP_STD_VER <= 11 205using ::gets; 206#endif 207using ::putc; 208using ::putchar; 209using ::puts; 210using ::ungetc; 211using ::fread; 212using ::fwrite; 213using ::fgetpos; 214using ::fseek; 215using ::fsetpos; 216using ::ftell; 217using ::rewind; 218using ::clearerr; 219using ::feof; 220using ::ferror; 221using ::perror; 222 223_LIBCPP_END_NAMESPACE_STD 224 225#endif // _LIBCPP_CSTDIO 226