2010-05-12 03:42:16 +08:00
|
|
|
// -*- C++ -*-
|
|
|
|
//===---------------------------- cstdio ----------------------------------===//
|
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_CSTDIO
|
|
|
|
#define _LIBCPP_CSTDIO
|
|
|
|
|
|
|
|
/*
|
|
|
|
cstdio synopsis
|
|
|
|
|
|
|
|
Macros:
|
|
|
|
|
|
|
|
BUFSIZ
|
|
|
|
EOF
|
|
|
|
FILENAME_MAX
|
|
|
|
FOPEN_MAX
|
|
|
|
L_tmpnam
|
|
|
|
NULL
|
|
|
|
SEEK_CUR
|
|
|
|
SEEK_END
|
|
|
|
SEEK_SET
|
|
|
|
TMP_MAX
|
|
|
|
_IOFBF
|
|
|
|
_IOLBF
|
|
|
|
_IONBF
|
|
|
|
stderr
|
|
|
|
stdin
|
|
|
|
stdout
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
Types:
|
|
|
|
|
|
|
|
FILE
|
|
|
|
fpos_t
|
|
|
|
size_t
|
|
|
|
|
|
|
|
int remove(const char* filename);
|
|
|
|
int rename(const char* old, const char* new);
|
|
|
|
FILE* tmpfile(void);
|
|
|
|
char* tmpnam(char* s);
|
|
|
|
int fclose(FILE* stream);
|
|
|
|
int fflush(FILE* stream);
|
|
|
|
FILE* fopen(const char* restrict filename, const char* restrict mode);
|
|
|
|
FILE* freopen(const char* restrict filename, const char * restrict mode,
|
|
|
|
FILE * restrict stream);
|
|
|
|
void setbuf(FILE* restrict stream, char* restrict buf);
|
|
|
|
int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
|
|
|
|
int fprintf(FILE* restrict stream, const char* restrict format, ...);
|
|
|
|
int fscanf(FILE* restrict stream, const char * restrict format, ...);
|
|
|
|
int printf(const char* restrict format, ...);
|
|
|
|
int scanf(const char* restrict format, ...);
|
|
|
|
int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
|
|
|
|
int sprintf(char* restrict s, const char* restrict format, ...);
|
|
|
|
int sscanf(const char* restrict s, const char* restrict format, ...);
|
|
|
|
int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
|
|
|
|
int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
|
|
|
|
int vprintf(const char* restrict format, va_list arg);
|
|
|
|
int vscanf(const char* restrict format, va_list arg); // C99
|
|
|
|
int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
|
|
|
|
va_list arg);
|
|
|
|
int vsprintf(char* restrict s, const char* restrict format, va_list arg);
|
|
|
|
int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
|
|
|
|
int fgetc(FILE* stream);
|
|
|
|
char* fgets(char* restrict s, int n, FILE* restrict stream);
|
|
|
|
int fputc(int c, FILE* stream);
|
|
|
|
int fputs(const char* restrict s, FILE* restrict stream);
|
|
|
|
int getc(FILE* stream);
|
|
|
|
int getchar(void);
|
2013-10-13 03:09:47 +08:00
|
|
|
char* gets(char* s); // removed in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
int putc(int c, FILE* stream);
|
|
|
|
int putchar(int c);
|
|
|
|
int puts(const char* s);
|
|
|
|
int ungetc(int c, FILE* stream);
|
|
|
|
size_t fread(void* restrict ptr, size_t size, size_t nmemb,
|
|
|
|
FILE* restrict stream);
|
|
|
|
size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
|
|
|
|
FILE* restrict stream);
|
|
|
|
int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
|
|
|
|
int fseek(FILE* stream, long offset, int whence);
|
|
|
|
int fsetpos(FILE*stream, const fpos_t* pos);
|
|
|
|
long ftell(FILE* stream);
|
|
|
|
void rewind(FILE* stream);
|
|
|
|
void clearerr(FILE* stream);
|
|
|
|
int feof(FILE* stream);
|
|
|
|
int ferror(FILE* stream);
|
|
|
|
void perror(const char* s);
|
|
|
|
|
|
|
|
} // std
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <__config>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2011-10-18 04:05:10 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2010-05-12 03:42:16 +08:00
|
|
|
#pragma GCC system_header
|
2011-10-18 04:05:10 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::FILE _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fpos_t _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::size_t _LIBCPP_USING_IF_EXISTS;
|
|
|
|
|
|
|
|
using ::fclose _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fflush _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::setbuf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::setvbuf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fprintf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fscanf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::snprintf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::sprintf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::sscanf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::vfprintf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::vfscanf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::vsscanf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::vsnprintf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::vsprintf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fgetc _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fgets _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fputc _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fputs _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::getc _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::putc _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::ungetc _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fread _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::fwrite _LIBCPP_USING_IF_EXISTS;
|
2020-03-13 02:16:30 +08:00
|
|
|
#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::fgetpos _LIBCPP_USING_IF_EXISTS;
|
2020-03-13 02:16:30 +08:00
|
|
|
#endif
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::fseek _LIBCPP_USING_IF_EXISTS;
|
2020-03-13 02:16:30 +08:00
|
|
|
#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::fsetpos _LIBCPP_USING_IF_EXISTS;
|
2020-03-13 02:16:30 +08:00
|
|
|
#endif
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::ftell _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::rewind _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::clearerr _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::feof _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::ferror _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::perror _LIBCPP_USING_IF_EXISTS;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2015-03-26 22:35:46 +08:00
|
|
|
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::fopen _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::freopen _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::remove _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::rename _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::tmpfile _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::tmpnam _LIBCPP_USING_IF_EXISTS;
|
2015-03-26 22:35:46 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_HAS_NO_STDIN
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::getchar _LIBCPP_USING_IF_EXISTS;
|
2019-09-08 06:18:20 +08:00
|
|
|
#if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS)
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::gets _LIBCPP_USING_IF_EXISTS;
|
2015-03-26 22:35:46 +08:00
|
|
|
#endif
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::scanf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::vscanf _LIBCPP_USING_IF_EXISTS;
|
2015-03-26 22:35:46 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_HAS_NO_STDOUT
|
[libc++] Use the using_if_exists attribute when provided
As discussed on cfe-dev [1], use the using_if_exists Clang attribute when
the compiler supports it. This makes it easier to port libc++ on top of
new platforms that don't fully support the C Standard library.
Previously, libc++ would fail to build when trying to import a missing
declaration in a <cXXXX> header. With the attribute, the declaration will
simply not be imported into namespace std, and hence it won't be available
for libc++ to use. In many cases, the declarations were *not* actually
required for libc++ to work (they were only surfaced for users to use
them as std::XXXX), so not importing them into namespace std is acceptable.
The same thing could be achieved by conscious usage of `#ifdef` along
with platform detection, however that quickly creates a maintenance
problem as libc++ is ported to new platforms. Furthermore, this problem
is exacerbated when mixed with vendor internal-only platforms, which can
lead to difficulties maintaining a downstream fork of the library.
For the time being, we only use the using_if_exists attribute when it
is supported. At some point in the future, we will start removing #ifdef
paths that are unnecessary when the attribute is supported, and folks
who need those #ifdef paths will be required to use a compiler that
supports the attribute.
[1]: http://lists.llvm.org/pipermail/cfe-dev/2020-June/066038.html
Differential Revision: https://reviews.llvm.org/D90257
2021-06-02 22:41:37 +08:00
|
|
|
using ::printf _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::putchar _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::puts _LIBCPP_USING_IF_EXISTS;
|
|
|
|
using ::vprintf _LIBCPP_USING_IF_EXISTS;
|
2015-03-26 22:35:46 +08:00
|
|
|
#endif
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_CSTDIO
|