Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- cstdio ----------------------------------===// |
| 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_CSTDIO |
| 11 | #define _LIBCPP_CSTDIO |
| 12 | |
| 13 | /* |
| 14 | cstdio synopsis |
| 15 | |
| 16 | Macros: |
| 17 | |
| 18 | BUFSIZ |
| 19 | EOF |
| 20 | FILENAME_MAX |
| 21 | FOPEN_MAX |
| 22 | L_tmpnam |
| 23 | NULL |
| 24 | SEEK_CUR |
| 25 | SEEK_END |
| 26 | SEEK_SET |
| 27 | TMP_MAX |
| 28 | _IOFBF |
| 29 | _IOLBF |
| 30 | _IONBF |
| 31 | stderr |
| 32 | stdin |
| 33 | stdout |
| 34 | |
| 35 | namespace std |
| 36 | { |
| 37 | |
| 38 | Types: |
| 39 | |
| 40 | FILE |
| 41 | fpos_t |
| 42 | size_t |
| 43 | |
| 44 | int remove(const char* filename); |
| 45 | int rename(const char* old, const char* new); |
| 46 | FILE* tmpfile(void); |
| 47 | char* tmpnam(char* s); |
| 48 | int fclose(FILE* stream); |
| 49 | int fflush(FILE* stream); |
| 50 | FILE* fopen(const char* restrict filename, const char* restrict mode); |
| 51 | FILE* freopen(const char* restrict filename, const char * restrict mode, |
| 52 | FILE * restrict stream); |
| 53 | void setbuf(FILE* restrict stream, char* restrict buf); |
| 54 | int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size); |
| 55 | int fprintf(FILE* restrict stream, const char* restrict format, ...); |
| 56 | int fscanf(FILE* restrict stream, const char * restrict format, ...); |
| 57 | int printf(const char* restrict format, ...); |
| 58 | int scanf(const char* restrict format, ...); |
| 59 | int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99 |
| 60 | int sprintf(char* restrict s, const char* restrict format, ...); |
| 61 | int sscanf(const char* restrict s, const char* restrict format, ...); |
| 62 | int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg); |
| 63 | int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99 |
| 64 | int vprintf(const char* restrict format, va_list arg); |
| 65 | int vscanf(const char* restrict format, va_list arg); // C99 |
| 66 | int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99 |
| 67 | va_list arg); |
| 68 | int vsprintf(char* restrict s, const char* restrict format, va_list arg); |
| 69 | int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99 |
| 70 | int fgetc(FILE* stream); |
| 71 | char* fgets(char* restrict s, int n, FILE* restrict stream); |
| 72 | int fputc(int c, FILE* stream); |
| 73 | int fputs(const char* restrict s, FILE* restrict stream); |
| 74 | int getc(FILE* stream); |
| 75 | int getchar(void); |
Marshall Clow | 39a1f66 | 2013-10-12 19:09:47 +0000 | [diff] [blame] | 76 | char* gets(char* s); // removed in C++14 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 77 | int putc(int c, FILE* stream); |
| 78 | int putchar(int c); |
| 79 | int puts(const char* s); |
| 80 | int ungetc(int c, FILE* stream); |
| 81 | size_t fread(void* restrict ptr, size_t size, size_t nmemb, |
| 82 | FILE* restrict stream); |
| 83 | size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, |
| 84 | FILE* restrict stream); |
| 85 | int fgetpos(FILE* restrict stream, fpos_t* restrict pos); |
| 86 | int fseek(FILE* stream, long offset, int whence); |
| 87 | int fsetpos(FILE*stream, const fpos_t* pos); |
| 88 | long ftell(FILE* stream); |
| 89 | void rewind(FILE* stream); |
| 90 | void clearerr(FILE* stream); |
| 91 | int feof(FILE* stream); |
| 92 | int ferror(FILE* stream); |
| 93 | void perror(const char* s); |
| 94 | |
| 95 | } // std |
| 96 | */ |
| 97 | |
| 98 | #include <__config> |
| 99 | #include <stdio.h> |
| 100 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 101 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 103 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 104 | |
| 105 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 106 | |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 107 | using ::FILE _LIBCPP_USING_IF_EXISTS; |
| 108 | using ::fpos_t _LIBCPP_USING_IF_EXISTS; |
| 109 | using ::size_t _LIBCPP_USING_IF_EXISTS; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 110 | |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 111 | using ::fclose _LIBCPP_USING_IF_EXISTS; |
| 112 | using ::fflush _LIBCPP_USING_IF_EXISTS; |
| 113 | using ::setbuf _LIBCPP_USING_IF_EXISTS; |
| 114 | using ::setvbuf _LIBCPP_USING_IF_EXISTS; |
| 115 | using ::fprintf _LIBCPP_USING_IF_EXISTS; |
| 116 | using ::fscanf _LIBCPP_USING_IF_EXISTS; |
| 117 | using ::snprintf _LIBCPP_USING_IF_EXISTS; |
| 118 | using ::sprintf _LIBCPP_USING_IF_EXISTS; |
| 119 | using ::sscanf _LIBCPP_USING_IF_EXISTS; |
| 120 | using ::vfprintf _LIBCPP_USING_IF_EXISTS; |
| 121 | using ::vfscanf _LIBCPP_USING_IF_EXISTS; |
| 122 | using ::vsscanf _LIBCPP_USING_IF_EXISTS; |
| 123 | using ::vsnprintf _LIBCPP_USING_IF_EXISTS; |
| 124 | using ::vsprintf _LIBCPP_USING_IF_EXISTS; |
| 125 | using ::fgetc _LIBCPP_USING_IF_EXISTS; |
| 126 | using ::fgets _LIBCPP_USING_IF_EXISTS; |
| 127 | using ::fputc _LIBCPP_USING_IF_EXISTS; |
| 128 | using ::fputs _LIBCPP_USING_IF_EXISTS; |
| 129 | using ::getc _LIBCPP_USING_IF_EXISTS; |
| 130 | using ::putc _LIBCPP_USING_IF_EXISTS; |
| 131 | using ::ungetc _LIBCPP_USING_IF_EXISTS; |
| 132 | using ::fread _LIBCPP_USING_IF_EXISTS; |
| 133 | using ::fwrite _LIBCPP_USING_IF_EXISTS; |
Dan Albert | 073008c | 2020-03-12 11:16:30 -0700 | [diff] [blame] | 134 | #ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 135 | using ::fgetpos _LIBCPP_USING_IF_EXISTS; |
Dan Albert | 073008c | 2020-03-12 11:16:30 -0700 | [diff] [blame] | 136 | #endif |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 137 | using ::fseek _LIBCPP_USING_IF_EXISTS; |
Dan Albert | 073008c | 2020-03-12 11:16:30 -0700 | [diff] [blame] | 138 | #ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 139 | using ::fsetpos _LIBCPP_USING_IF_EXISTS; |
Dan Albert | 073008c | 2020-03-12 11:16:30 -0700 | [diff] [blame] | 140 | #endif |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 141 | using ::ftell _LIBCPP_USING_IF_EXISTS; |
| 142 | using ::rewind _LIBCPP_USING_IF_EXISTS; |
| 143 | using ::clearerr _LIBCPP_USING_IF_EXISTS; |
| 144 | using ::feof _LIBCPP_USING_IF_EXISTS; |
| 145 | using ::ferror _LIBCPP_USING_IF_EXISTS; |
| 146 | using ::perror _LIBCPP_USING_IF_EXISTS; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 147 | |
Ed Schouten | 3a75c0b | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 148 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 149 | using ::fopen _LIBCPP_USING_IF_EXISTS; |
| 150 | using ::freopen _LIBCPP_USING_IF_EXISTS; |
| 151 | using ::remove _LIBCPP_USING_IF_EXISTS; |
| 152 | using ::rename _LIBCPP_USING_IF_EXISTS; |
| 153 | using ::tmpfile _LIBCPP_USING_IF_EXISTS; |
| 154 | using ::tmpnam _LIBCPP_USING_IF_EXISTS; |
Ed Schouten | 3a75c0b | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 155 | #endif |
| 156 | |
| 157 | #ifndef _LIBCPP_HAS_NO_STDIN |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 158 | using ::getchar _LIBCPP_USING_IF_EXISTS; |
Dimitry Andric | 2e72c80 | 2019-09-07 22:18:20 +0000 | [diff] [blame] | 159 | #if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS) |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 160 | using ::gets _LIBCPP_USING_IF_EXISTS; |
Ed Schouten | 3a75c0b | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 161 | #endif |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 162 | using ::scanf _LIBCPP_USING_IF_EXISTS; |
| 163 | using ::vscanf _LIBCPP_USING_IF_EXISTS; |
Ed Schouten | 3a75c0b | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 164 | #endif |
| 165 | |
| 166 | #ifndef _LIBCPP_HAS_NO_STDOUT |
Louis Dionne | 9c660c6 | 2021-06-02 10:41:37 -0400 | [diff] [blame^] | 167 | using ::printf _LIBCPP_USING_IF_EXISTS; |
| 168 | using ::putchar _LIBCPP_USING_IF_EXISTS; |
| 169 | using ::puts _LIBCPP_USING_IF_EXISTS; |
| 170 | using ::vprintf _LIBCPP_USING_IF_EXISTS; |
Ed Schouten | 3a75c0b | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 171 | #endif |
| 172 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 173 | _LIBCPP_END_NAMESPACE_STD |
| 174 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 175 | #endif // _LIBCPP_CSTDIO |