blob: 6a88bee6e8152c80eed85773e102aecb03251fb7 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- cstdio ----------------------------------===//
3//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// 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 Hinnantc51e1022010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_CSTDIO
11#define _LIBCPP_CSTDIO
12
13/*
14 cstdio synopsis
15
16Macros:
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
35namespace std
36{
37
38Types:
39
40FILE
41fpos_t
42size_t
43
44int remove(const char* filename);
45int rename(const char* old, const char* new);
46FILE* tmpfile(void);
47char* tmpnam(char* s);
48int fclose(FILE* stream);
49int fflush(FILE* stream);
50FILE* fopen(const char* restrict filename, const char* restrict mode);
51FILE* freopen(const char* restrict filename, const char * restrict mode,
52 FILE * restrict stream);
53void setbuf(FILE* restrict stream, char* restrict buf);
54int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
55int fprintf(FILE* restrict stream, const char* restrict format, ...);
56int fscanf(FILE* restrict stream, const char * restrict format, ...);
57int printf(const char* restrict format, ...);
58int scanf(const char* restrict format, ...);
59int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
60int sprintf(char* restrict s, const char* restrict format, ...);
61int sscanf(const char* restrict s, const char* restrict format, ...);
62int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
63int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
64int vprintf(const char* restrict format, va_list arg);
65int vscanf(const char* restrict format, va_list arg); // C99
66int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
67 va_list arg);
68int vsprintf(char* restrict s, const char* restrict format, va_list arg);
69int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
70int fgetc(FILE* stream);
71char* fgets(char* restrict s, int n, FILE* restrict stream);
72int fputc(int c, FILE* stream);
73int fputs(const char* restrict s, FILE* restrict stream);
74int getc(FILE* stream);
75int getchar(void);
Marshall Clow39a1f662013-10-12 19:09:47 +000076char* gets(char* s); // removed in C++14
Howard Hinnantc51e1022010-05-11 19:42:16 +000077int putc(int c, FILE* stream);
78int putchar(int c);
79int puts(const char* s);
80int ungetc(int c, FILE* stream);
81size_t fread(void* restrict ptr, size_t size, size_t nmemb,
82 FILE* restrict stream);
83size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
84 FILE* restrict stream);
85int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
86int fseek(FILE* stream, long offset, int whence);
87int fsetpos(FILE*stream, const fpos_t* pos);
88long ftell(FILE* stream);
89void rewind(FILE* stream);
90void clearerr(FILE* stream);
91int feof(FILE* stream);
92int ferror(FILE* stream);
93void perror(const char* s);
94
95} // std
96*/
97
98#include <__config>
99#include <stdio.h>
100
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000101#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000102#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000103#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000104
105_LIBCPP_BEGIN_NAMESPACE_STD
106
Louis Dionne9c660c62021-06-02 10:41:37 -0400107using ::FILE _LIBCPP_USING_IF_EXISTS;
108using ::fpos_t _LIBCPP_USING_IF_EXISTS;
109using ::size_t _LIBCPP_USING_IF_EXISTS;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000110
Louis Dionne9c660c62021-06-02 10:41:37 -0400111using ::fclose _LIBCPP_USING_IF_EXISTS;
112using ::fflush _LIBCPP_USING_IF_EXISTS;
113using ::setbuf _LIBCPP_USING_IF_EXISTS;
114using ::setvbuf _LIBCPP_USING_IF_EXISTS;
115using ::fprintf _LIBCPP_USING_IF_EXISTS;
116using ::fscanf _LIBCPP_USING_IF_EXISTS;
117using ::snprintf _LIBCPP_USING_IF_EXISTS;
118using ::sprintf _LIBCPP_USING_IF_EXISTS;
119using ::sscanf _LIBCPP_USING_IF_EXISTS;
120using ::vfprintf _LIBCPP_USING_IF_EXISTS;
121using ::vfscanf _LIBCPP_USING_IF_EXISTS;
122using ::vsscanf _LIBCPP_USING_IF_EXISTS;
123using ::vsnprintf _LIBCPP_USING_IF_EXISTS;
124using ::vsprintf _LIBCPP_USING_IF_EXISTS;
125using ::fgetc _LIBCPP_USING_IF_EXISTS;
126using ::fgets _LIBCPP_USING_IF_EXISTS;
127using ::fputc _LIBCPP_USING_IF_EXISTS;
128using ::fputs _LIBCPP_USING_IF_EXISTS;
129using ::getc _LIBCPP_USING_IF_EXISTS;
130using ::putc _LIBCPP_USING_IF_EXISTS;
131using ::ungetc _LIBCPP_USING_IF_EXISTS;
132using ::fread _LIBCPP_USING_IF_EXISTS;
133using ::fwrite _LIBCPP_USING_IF_EXISTS;
Dan Albert073008c2020-03-12 11:16:30 -0700134#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
Louis Dionne9c660c62021-06-02 10:41:37 -0400135using ::fgetpos _LIBCPP_USING_IF_EXISTS;
Dan Albert073008c2020-03-12 11:16:30 -0700136#endif
Louis Dionne9c660c62021-06-02 10:41:37 -0400137using ::fseek _LIBCPP_USING_IF_EXISTS;
Dan Albert073008c2020-03-12 11:16:30 -0700138#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
Louis Dionne9c660c62021-06-02 10:41:37 -0400139using ::fsetpos _LIBCPP_USING_IF_EXISTS;
Dan Albert073008c2020-03-12 11:16:30 -0700140#endif
Louis Dionne9c660c62021-06-02 10:41:37 -0400141using ::ftell _LIBCPP_USING_IF_EXISTS;
142using ::rewind _LIBCPP_USING_IF_EXISTS;
143using ::clearerr _LIBCPP_USING_IF_EXISTS;
144using ::feof _LIBCPP_USING_IF_EXISTS;
145using ::ferror _LIBCPP_USING_IF_EXISTS;
146using ::perror _LIBCPP_USING_IF_EXISTS;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000147
Louis Dionne9c660c62021-06-02 10:41:37 -0400148using ::fopen _LIBCPP_USING_IF_EXISTS;
149using ::freopen _LIBCPP_USING_IF_EXISTS;
150using ::remove _LIBCPP_USING_IF_EXISTS;
151using ::rename _LIBCPP_USING_IF_EXISTS;
152using ::tmpfile _LIBCPP_USING_IF_EXISTS;
153using ::tmpnam _LIBCPP_USING_IF_EXISTS;
Ed Schouten3a75c0b2015-03-26 14:35:46 +0000154
Louis Dionne9c660c62021-06-02 10:41:37 -0400155using ::getchar _LIBCPP_USING_IF_EXISTS;
Dimitry Andric2e72c802019-09-07 22:18:20 +0000156#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS)
Louis Dionne9c660c62021-06-02 10:41:37 -0400157using ::gets _LIBCPP_USING_IF_EXISTS;
Ed Schouten3a75c0b2015-03-26 14:35:46 +0000158#endif
Louis Dionne9c660c62021-06-02 10:41:37 -0400159using ::scanf _LIBCPP_USING_IF_EXISTS;
160using ::vscanf _LIBCPP_USING_IF_EXISTS;
Ed Schouten3a75c0b2015-03-26 14:35:46 +0000161
Louis Dionne9c660c62021-06-02 10:41:37 -0400162using ::printf _LIBCPP_USING_IF_EXISTS;
163using ::putchar _LIBCPP_USING_IF_EXISTS;
164using ::puts _LIBCPP_USING_IF_EXISTS;
165using ::vprintf _LIBCPP_USING_IF_EXISTS;
Ed Schouten3a75c0b2015-03-26 14:35:46 +0000166
Howard Hinnantc51e1022010-05-11 19:42:16 +0000167_LIBCPP_END_NAMESPACE_STD
168
Louis Dionne2b1ceaa2021-04-20 12:03:32 -0400169#endif // _LIBCPP_CSTDIO