mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-30 12:25:10 +01:00
MFC r309126 (by emaste):
Correct lld llvm-tblgen dependency file name
MFC r309169:
Get rid of separate Subversion mergeinfo properties for llvm-dwarfdump
and llvm-lto. The mergeinfo confuses Subversion enormously, and these
directories will just use the mergeinfo for llvm itself.
MFC r312765:
Pull in r276136 from upstream llvm trunk (by Wei Mi):
Use ValueOffsetPair to enhance value reuse during SCEV expansion.
In D12090, the ExprValueMap was added to reuse existing value during
SCEV expansion. However, const folding and sext/zext distribution can
make the reuse still difficult.
A simplified case is: suppose we know S1 expands to V1 in
ExprValueMap, and
S1 = S2 + C_a
S3 = S2 + C_b
where C_a and C_b are different SCEVConstants. Then we'd like to
expand S3 as V1 - C_a + C_b instead of expanding S2 literally. It is
helpful when S2 is a complex SCEV expr and S2 has no entry in
ExprValueMap, which is usually caused by the fact that S3 is
generated from S1 after const folding.
In order to do that, we represent ExprValueMap as a mapping from SCEV
to ValueOffsetPair. We will save both S1->{V1, 0} and S2->{V1, C_a}
into the ExprValueMap when we create SCEV for V1. When S3 is
expanded, it will first expand S2 to V1 - C_a because of S2->{V1,
C_a} in the map, then expand S3 to V1 - C_a + C_b.
Differential Revision: https://reviews.llvm.org/D21313
This should fix assertion failures when building OpenCV >= 3.1.
PR: 215649
MFC r312831:
Revert r312765 for now, since it causes assertions when building
lang/spidermonkey24.
Reported by: antoine
PR: 215649
MFC r316511 (by jhb):
Add an implementation of __ffssi2() derived from __ffsdi2().
Newer versions of GCC include an __ffssi2() symbol in libgcc and the
compiler can emit calls to it in generated code. This is true for at
least GCC 6.2 when compiling world for mips and mips64.
Reviewed by: jmallett, dim
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10086
MFC r318601 (by adrian):
[libcompiler-rt] add bswapdi2/bswapsi2
This is required for mips gcc 6.3 userland to build/run.
Reviewed by: emaste, dim
Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D10838
MFC r318884 (by emaste):
lldb: map TRAP_CAP to a trace trap
In the absense of a more specific handler for TRAP_CAP (generated by
ENOTCAPABLE or ECAPMODE while in capability mode) treat it as a trace
trap.
Example usage (testing the bug in PR219173):
% proccontrol -m trapcap lldb usr.bin/hexdump/obj/hexdump -- -Cv -s 1 /bin/ls
...
(lldb) run
Process 12980 launching
Process 12980 launched: '.../usr.bin/hexdump/obj/hexdump' (x86_64)
Process 12980 stopped
* thread #1, stop reason = trace
frame #0: 0x0000004b80c65f1a libc.so.7`__sys_lseek + 10
...
In the future we should have LLDB control the trapcap procctl itself
(as it does with ASLR), as well as report a specific stop reason.
This change eliminates an assertion failure from LLDB for now.
MFC r319796:
Remove a few unneeded files from libllvm, libclang and liblldb.
MFC r319885 (by emaste):
lld: ELF: Fix ICF crash on absolute symbol relocations.
If two sections contained relocations to absolute symbols with the same
value we would crash when trying to access their sections. Add a check that
both symbols point to sections before accessing their sections, and treat
absolute symbols as equal if their values are equal.
Obtained from: LLD commit r292578
MFC r319918:
Revert r319796 for now, it can cause undefined references when linking
in some circumstances.
Reported by: Shawn Webb <[email protected]>
MFC r319957 (by emaste):
lld: Add armelf emulation mode
Obtained from: LLD r305375
MFC r321369:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.0 (trunk r308421). Upstream has branched for the 5.0.0 release,
which should be in about a month. Please report bugs and regressions,
so we can get them into the release.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
MFC r321420:
Add a few more object files to liblldb, which should solve errors when
linking the lldb executable in some cases. In particular, when the
-ffunction-sections -fdata-sections options are turned off, or
ineffective.
Reported by: Shawn Webb, Mark Millard
MFC r321433:
Cleanup stale Options.inc files from the previous libllvm build for
clang 4.0.0. Otherwise, these can get included before the two newly
generated ones (which are different) for clang 5.0.0.
Reported by: Mark Millard
MFC r321439 (by bdrewery):
Move llvm Options.inc hack from r321433 for NO_CLEAN to lib/clang/libllvm.
The files are only ever generated to .OBJDIR, not to WORLDTMP (as a
sysroot) and are only ever included from a compilation. So using
a beforebuild target here removes the file before the compilation
tries to include it.
MFC r321664:
Pull in r308891 from upstream llvm trunk (by Benjamin Kramer):
[CodeGenPrepare] Cut off FindAllMemoryUses if there are too many uses.
This avoids excessive compile time. The case I'm looking at is
Function.cpp from an old version of LLVM that still had the giant
memcmp string matcher in it. Before r308322 this compiled in about 2
minutes, after it, clang takes infinite* time to compile it. With
this patch we're at 5 min, which is still bad but this is a
pathological case.
The cut off at 20 uses was chosen by looking at other cut-offs in LLVM
for user scanning. It's probably too high, but does the job and is
very unlikely to regress anything.
Fixes PR33900.
* I'm impatient and aborted after 15 minutes, on the bug report it was
killed after 2h.
Pull in r308986 from upstream llvm trunk (by Simon Pilgrim):
[X86][CGP] Reduce memcmp() expansion to 2 load pairs (PR33914)
D35067/rL308322 attempted to support up to 4 load pairs for memcmp
inlining which resulted in regressions for some optimized libc memcmp
implementations (PR33914).
Until we can match these more optimal cases, this patch reduces the
memcmp expansion to a maximum of 2 load pairs (which matches what we
do for -Os).
This patch should be considered for the 5.0.0 release branch as well
Differential Revision: https://reviews.llvm.org/D35830
These fix a hang (or extremely long compile time) when building older
LLVM ports.
Reported by: antoine
PR: 219139
MFC r321719:
Pull in r309503 from upstream clang trunk (by Richard Smith):
PR33902: Invalidate line number cache when adding more text to
existing buffer.
This led to crashes as the line number cache would report a bogus
line number for a line of code, and we'd try to find a nonexistent
column within the line when printing diagnostics.
This fixes an assertion when building the graphics/champlain port.
Reported by: antoine, kwm
PR: 219139
MFC r321723:
Upgrade our copies of clang, llvm, lld and lldb to r309439 from the
upstream release_50 branch. This is just after upstream's 5.0.0-rc1.
MFC r322320:
Upgrade our copies of clang, llvm and libc++ to r310316 from the
upstream release_50 branch.
MFC r322326 (by emaste):
lldb: Make i386-*-freebsd expression work on JIT path
* Enable i386 ABI creation for freebsd
* Added an extra argument in ABISysV_i386::PrepareTrivialCall for mmap
syscall
* Unlike linux, the last argument of mmap is actually 64-bit(off_t).
This requires us to push an additional word for the higher order bits.
* Prior to this change, ktrace dump will show mmap failures due to
invalid argument coming from the 6th mmap argument.
Submitted by: Karnajit Wangkhem
Differential Revision: https://reviews.llvm.org/D34776
MFC r322360 (by emaste):
lldb: Report inferior signals as signals, not exceptions, on FreeBSD
This is the FreeBSD equivalent of LLVM r238549.
This serves 2 purposes:
* LLDB should handle inferior process signals SIGSEGV/SIGILL/SIGBUS/
SIGFPE the way it is suppose to be handled. Prior to this fix these
signals will neither create a coredump, nor exit from the debugger
or work for signal handling scenario.
* eInvalidCrashReason need not report "unknown crash reason" if we have
a valid si_signo
llvm.org/pr23699
Patch by Karnajit Wangkhem
Differential Revision: https://reviews.llvm.org/D35223
Submitted by: Karnajit Wangkhem
Obtained from: LLVM r310591
MFC r322474 (by emaste):
lld: Add `-z muldefs` option.
Obtained from: LLVM r310757
MFC r322740:
Upgrade our copies of clang, llvm, lld and libc++ to r311219 from the
upstream release_50 branch.
MFC r322855:
Upgrade our copies of clang, llvm, lldb and compiler-rt to r311606 from
the upstream release_50 branch.
As of this version, lib/msun's trig test should also work correctly
again (see bug 220989 for more information).
PR: 220989
MFC r323112:
Upgrade our copies of clang, llvm, lldb and compiler-rt to r312293 from
the upstream release_50 branch. This corresponds to 5.0.0 rc4.
As of this version, the cad/stepcode port should now compile in a more
reasonable time on i386 (see bug 221836 for more information).
PR: 221836
MFC r323245:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.0 release (upstream r312559).
Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/5.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/5.0.0/tools/lld/docs/ReleaseNotes.html>
Relnotes: yes
1046 lines
25 KiB
C++
1046 lines
25 KiB
C++
// -*- C++ -*-
|
|
//===---------------------------- ios -------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef _LIBCPP_IOS
|
|
#define _LIBCPP_IOS
|
|
|
|
/*
|
|
ios synopsis
|
|
|
|
#include <iosfwd>
|
|
|
|
namespace std
|
|
{
|
|
|
|
typedef OFF_T streamoff;
|
|
typedef SZ_T streamsize;
|
|
template <class stateT> class fpos;
|
|
|
|
class ios_base
|
|
{
|
|
public:
|
|
class failure;
|
|
|
|
typedef T1 fmtflags;
|
|
static constexpr fmtflags boolalpha;
|
|
static constexpr fmtflags dec;
|
|
static constexpr fmtflags fixed;
|
|
static constexpr fmtflags hex;
|
|
static constexpr fmtflags internal;
|
|
static constexpr fmtflags left;
|
|
static constexpr fmtflags oct;
|
|
static constexpr fmtflags right;
|
|
static constexpr fmtflags scientific;
|
|
static constexpr fmtflags showbase;
|
|
static constexpr fmtflags showpoint;
|
|
static constexpr fmtflags showpos;
|
|
static constexpr fmtflags skipws;
|
|
static constexpr fmtflags unitbuf;
|
|
static constexpr fmtflags uppercase;
|
|
static constexpr fmtflags adjustfield;
|
|
static constexpr fmtflags basefield;
|
|
static constexpr fmtflags floatfield;
|
|
|
|
typedef T2 iostate;
|
|
static constexpr iostate badbit;
|
|
static constexpr iostate eofbit;
|
|
static constexpr iostate failbit;
|
|
static constexpr iostate goodbit;
|
|
|
|
typedef T3 openmode;
|
|
static constexpr openmode app;
|
|
static constexpr openmode ate;
|
|
static constexpr openmode binary;
|
|
static constexpr openmode in;
|
|
static constexpr openmode out;
|
|
static constexpr openmode trunc;
|
|
|
|
typedef T4 seekdir;
|
|
static constexpr seekdir beg;
|
|
static constexpr seekdir cur;
|
|
static constexpr seekdir end;
|
|
|
|
class Init;
|
|
|
|
// 27.5.2.2 fmtflags state:
|
|
fmtflags flags() const;
|
|
fmtflags flags(fmtflags fmtfl);
|
|
fmtflags setf(fmtflags fmtfl);
|
|
fmtflags setf(fmtflags fmtfl, fmtflags mask);
|
|
void unsetf(fmtflags mask);
|
|
|
|
streamsize precision() const;
|
|
streamsize precision(streamsize prec);
|
|
streamsize width() const;
|
|
streamsize width(streamsize wide);
|
|
|
|
// 27.5.2.3 locales:
|
|
locale imbue(const locale& loc);
|
|
locale getloc() const;
|
|
|
|
// 27.5.2.5 storage:
|
|
static int xalloc();
|
|
long& iword(int index);
|
|
void*& pword(int index);
|
|
|
|
// destructor
|
|
virtual ~ios_base();
|
|
|
|
// 27.5.2.6 callbacks;
|
|
enum event { erase_event, imbue_event, copyfmt_event };
|
|
typedef void (*event_callback)(event, ios_base&, int index);
|
|
void register_callback(event_callback fn, int index);
|
|
|
|
ios_base(const ios_base&) = delete;
|
|
ios_base& operator=(const ios_base&) = delete;
|
|
|
|
static bool sync_with_stdio(bool sync = true);
|
|
|
|
protected:
|
|
ios_base();
|
|
};
|
|
|
|
template <class charT, class traits = char_traits<charT> >
|
|
class basic_ios
|
|
: public ios_base
|
|
{
|
|
public:
|
|
// types:
|
|
typedef charT char_type;
|
|
typedef typename traits::int_type int_type; // removed in C++17
|
|
typedef typename traits::pos_type pos_type; // removed in C++17
|
|
typedef typename traits::off_type off_type; // removed in C++17
|
|
typedef traits traits_type;
|
|
|
|
operator unspecified-bool-type() const;
|
|
bool operator!() const;
|
|
iostate rdstate() const;
|
|
void clear(iostate state = goodbit);
|
|
void setstate(iostate state);
|
|
bool good() const;
|
|
bool eof() const;
|
|
bool fail() const;
|
|
bool bad() const;
|
|
|
|
iostate exceptions() const;
|
|
void exceptions(iostate except);
|
|
|
|
// 27.5.4.1 Constructor/destructor:
|
|
explicit basic_ios(basic_streambuf<charT,traits>* sb);
|
|
virtual ~basic_ios();
|
|
|
|
// 27.5.4.2 Members:
|
|
basic_ostream<charT,traits>* tie() const;
|
|
basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
|
|
|
|
basic_streambuf<charT,traits>* rdbuf() const;
|
|
basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
|
|
|
|
basic_ios& copyfmt(const basic_ios& rhs);
|
|
|
|
char_type fill() const;
|
|
char_type fill(char_type ch);
|
|
|
|
locale imbue(const locale& loc);
|
|
|
|
char narrow(char_type c, char dfault) const;
|
|
char_type widen(char c) const;
|
|
|
|
basic_ios(const basic_ios& ) = delete;
|
|
basic_ios& operator=(const basic_ios&) = delete;
|
|
|
|
protected:
|
|
basic_ios();
|
|
void init(basic_streambuf<charT,traits>* sb);
|
|
void move(basic_ios& rhs);
|
|
void swap(basic_ios& rhs) noexcept;
|
|
void set_rdbuf(basic_streambuf<charT, traits>* sb);
|
|
};
|
|
|
|
// 27.5.5, manipulators:
|
|
ios_base& boolalpha (ios_base& str);
|
|
ios_base& noboolalpha(ios_base& str);
|
|
ios_base& showbase (ios_base& str);
|
|
ios_base& noshowbase (ios_base& str);
|
|
ios_base& showpoint (ios_base& str);
|
|
ios_base& noshowpoint(ios_base& str);
|
|
ios_base& showpos (ios_base& str);
|
|
ios_base& noshowpos (ios_base& str);
|
|
ios_base& skipws (ios_base& str);
|
|
ios_base& noskipws (ios_base& str);
|
|
ios_base& uppercase (ios_base& str);
|
|
ios_base& nouppercase(ios_base& str);
|
|
ios_base& unitbuf (ios_base& str);
|
|
ios_base& nounitbuf (ios_base& str);
|
|
|
|
// 27.5.5.2 adjustfield:
|
|
ios_base& internal (ios_base& str);
|
|
ios_base& left (ios_base& str);
|
|
ios_base& right (ios_base& str);
|
|
|
|
// 27.5.5.3 basefield:
|
|
ios_base& dec (ios_base& str);
|
|
ios_base& hex (ios_base& str);
|
|
ios_base& oct (ios_base& str);
|
|
|
|
// 27.5.5.4 floatfield:
|
|
ios_base& fixed (ios_base& str);
|
|
ios_base& scientific (ios_base& str);
|
|
ios_base& hexfloat (ios_base& str);
|
|
ios_base& defaultfloat(ios_base& str);
|
|
|
|
// 27.5.5.5 error reporting:
|
|
enum class io_errc
|
|
{
|
|
stream = 1
|
|
};
|
|
|
|
concept_map ErrorCodeEnum<io_errc> { };
|
|
error_code make_error_code(io_errc e) noexcept;
|
|
error_condition make_error_condition(io_errc e) noexcept;
|
|
storage-class-specifier const error_category& iostream_category() noexcept;
|
|
|
|
} // std
|
|
|
|
*/
|
|
|
|
#include <__config>
|
|
#include <iosfwd>
|
|
#include <__locale>
|
|
#include <system_error>
|
|
|
|
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
|
#include <atomic> // for __xindex_
|
|
#endif
|
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
#pragma GCC system_header
|
|
#endif
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
typedef ptrdiff_t streamsize;
|
|
|
|
class _LIBCPP_TYPE_VIS ios_base
|
|
{
|
|
public:
|
|
class _LIBCPP_EXCEPTION_ABI failure;
|
|
|
|
typedef unsigned int fmtflags;
|
|
static const fmtflags boolalpha = 0x0001;
|
|
static const fmtflags dec = 0x0002;
|
|
static const fmtflags fixed = 0x0004;
|
|
static const fmtflags hex = 0x0008;
|
|
static const fmtflags internal = 0x0010;
|
|
static const fmtflags left = 0x0020;
|
|
static const fmtflags oct = 0x0040;
|
|
static const fmtflags right = 0x0080;
|
|
static const fmtflags scientific = 0x0100;
|
|
static const fmtflags showbase = 0x0200;
|
|
static const fmtflags showpoint = 0x0400;
|
|
static const fmtflags showpos = 0x0800;
|
|
static const fmtflags skipws = 0x1000;
|
|
static const fmtflags unitbuf = 0x2000;
|
|
static const fmtflags uppercase = 0x4000;
|
|
static const fmtflags adjustfield = left | right | internal;
|
|
static const fmtflags basefield = dec | oct | hex;
|
|
static const fmtflags floatfield = scientific | fixed;
|
|
|
|
typedef unsigned int iostate;
|
|
static const iostate badbit = 0x1;
|
|
static const iostate eofbit = 0x2;
|
|
static const iostate failbit = 0x4;
|
|
static const iostate goodbit = 0x0;
|
|
|
|
typedef unsigned int openmode;
|
|
static const openmode app = 0x01;
|
|
static const openmode ate = 0x02;
|
|
static const openmode binary = 0x04;
|
|
static const openmode in = 0x08;
|
|
static const openmode out = 0x10;
|
|
static const openmode trunc = 0x20;
|
|
|
|
enum seekdir {beg, cur, end};
|
|
|
|
#if _LIBCPP_STD_VER <= 14
|
|
typedef iostate io_state;
|
|
typedef openmode open_mode;
|
|
typedef seekdir seek_dir;
|
|
|
|
typedef _VSTD::streamoff streamoff;
|
|
typedef _VSTD::streampos streampos;
|
|
#endif
|
|
|
|
class _LIBCPP_TYPE_VIS Init;
|
|
|
|
// 27.5.2.2 fmtflags state:
|
|
_LIBCPP_INLINE_VISIBILITY fmtflags flags() const;
|
|
_LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl);
|
|
_LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl);
|
|
_LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
|
|
_LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY streamsize precision() const;
|
|
_LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec);
|
|
_LIBCPP_INLINE_VISIBILITY streamsize width() const;
|
|
_LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide);
|
|
|
|
// 27.5.2.3 locales:
|
|
locale imbue(const locale& __loc);
|
|
locale getloc() const;
|
|
|
|
// 27.5.2.5 storage:
|
|
static int xalloc();
|
|
long& iword(int __index);
|
|
void*& pword(int __index);
|
|
|
|
// destructor
|
|
virtual ~ios_base();
|
|
|
|
// 27.5.2.6 callbacks;
|
|
enum event { erase_event, imbue_event, copyfmt_event };
|
|
typedef void (*event_callback)(event, ios_base&, int __index);
|
|
void register_callback(event_callback __fn, int __index);
|
|
|
|
private:
|
|
ios_base(const ios_base&); // = delete;
|
|
ios_base& operator=(const ios_base&); // = delete;
|
|
|
|
public:
|
|
static bool sync_with_stdio(bool __sync = true);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const;
|
|
void clear(iostate __state = goodbit);
|
|
_LIBCPP_INLINE_VISIBILITY void setstate(iostate __state);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY bool good() const;
|
|
_LIBCPP_INLINE_VISIBILITY bool eof() const;
|
|
_LIBCPP_INLINE_VISIBILITY bool fail() const;
|
|
_LIBCPP_INLINE_VISIBILITY bool bad() const;
|
|
|
|
_LIBCPP_INLINE_VISIBILITY iostate exceptions() const;
|
|
_LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate);
|
|
|
|
void __set_badbit_and_consider_rethrow();
|
|
void __set_failbit_and_consider_rethrow();
|
|
|
|
protected:
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
ios_base() {// purposefully does no initialization
|
|
}
|
|
|
|
void init(void* __sb);
|
|
_LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;}
|
|
|
|
_LIBCPP_ALWAYS_INLINE
|
|
void rdbuf(void* __sb)
|
|
{
|
|
__rdbuf_ = __sb;
|
|
clear();
|
|
}
|
|
|
|
void __call_callbacks(event);
|
|
void copyfmt(const ios_base&);
|
|
void move(ios_base&);
|
|
void swap(ios_base&) _NOEXCEPT;
|
|
|
|
_LIBCPP_ALWAYS_INLINE
|
|
void set_rdbuf(void* __sb)
|
|
{
|
|
__rdbuf_ = __sb;
|
|
}
|
|
|
|
private:
|
|
// All data members must be scalars
|
|
fmtflags __fmtflags_;
|
|
streamsize __precision_;
|
|
streamsize __width_;
|
|
iostate __rdstate_;
|
|
iostate __exceptions_;
|
|
void* __rdbuf_;
|
|
void* __loc_;
|
|
event_callback* __fn_;
|
|
int* __index_;
|
|
size_t __event_size_;
|
|
size_t __event_cap_;
|
|
// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
|
|
// enabled with clang.
|
|
#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
|
|
static atomic<int> __xindex_;
|
|
#else
|
|
static int __xindex_;
|
|
#endif
|
|
long* __iarray_;
|
|
size_t __iarray_size_;
|
|
size_t __iarray_cap_;
|
|
void** __parray_;
|
|
size_t __parray_size_;
|
|
size_t __parray_cap_;
|
|
};
|
|
|
|
//enum class io_errc
|
|
_LIBCPP_DECLARE_STRONG_ENUM(io_errc)
|
|
{
|
|
stream = 1
|
|
};
|
|
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
|
|
|
|
template <>
|
|
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
|
|
|
|
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
|
|
template <>
|
|
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
|
|
#endif
|
|
|
|
_LIBCPP_FUNC_VIS
|
|
const error_category& iostream_category() _NOEXCEPT;
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
error_code
|
|
make_error_code(io_errc __e) _NOEXCEPT
|
|
{
|
|
return error_code(static_cast<int>(__e), iostream_category());
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
error_condition
|
|
make_error_condition(io_errc __e) _NOEXCEPT
|
|
{
|
|
return error_condition(static_cast<int>(__e), iostream_category());
|
|
}
|
|
|
|
class _LIBCPP_EXCEPTION_ABI ios_base::failure
|
|
: public system_error
|
|
{
|
|
public:
|
|
explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
|
|
explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
|
|
virtual ~failure() throw();
|
|
};
|
|
|
|
class _LIBCPP_TYPE_VIS ios_base::Init
|
|
{
|
|
public:
|
|
Init();
|
|
~Init();
|
|
};
|
|
|
|
// fmtflags
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base::fmtflags
|
|
ios_base::flags() const
|
|
{
|
|
return __fmtflags_;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base::fmtflags
|
|
ios_base::flags(fmtflags __fmtfl)
|
|
{
|
|
fmtflags __r = __fmtflags_;
|
|
__fmtflags_ = __fmtfl;
|
|
return __r;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base::fmtflags
|
|
ios_base::setf(fmtflags __fmtfl)
|
|
{
|
|
fmtflags __r = __fmtflags_;
|
|
__fmtflags_ |= __fmtfl;
|
|
return __r;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
void
|
|
ios_base::unsetf(fmtflags __mask)
|
|
{
|
|
__fmtflags_ &= ~__mask;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base::fmtflags
|
|
ios_base::setf(fmtflags __fmtfl, fmtflags __mask)
|
|
{
|
|
fmtflags __r = __fmtflags_;
|
|
unsetf(__mask);
|
|
__fmtflags_ |= __fmtfl & __mask;
|
|
return __r;
|
|
}
|
|
|
|
// precision
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
streamsize
|
|
ios_base::precision() const
|
|
{
|
|
return __precision_;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
streamsize
|
|
ios_base::precision(streamsize __prec)
|
|
{
|
|
streamsize __r = __precision_;
|
|
__precision_ = __prec;
|
|
return __r;
|
|
}
|
|
|
|
// width
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
streamsize
|
|
ios_base::width() const
|
|
{
|
|
return __width_;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
streamsize
|
|
ios_base::width(streamsize __wide)
|
|
{
|
|
streamsize __r = __width_;
|
|
__width_ = __wide;
|
|
return __r;
|
|
}
|
|
|
|
// iostate
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base::iostate
|
|
ios_base::rdstate() const
|
|
{
|
|
return __rdstate_;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
void
|
|
ios_base::setstate(iostate __state)
|
|
{
|
|
clear(__rdstate_ | __state);
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
bool
|
|
ios_base::good() const
|
|
{
|
|
return __rdstate_ == 0;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
bool
|
|
ios_base::eof() const
|
|
{
|
|
return (__rdstate_ & eofbit) != 0;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
bool
|
|
ios_base::fail() const
|
|
{
|
|
return (__rdstate_ & (failbit | badbit)) != 0;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
bool
|
|
ios_base::bad() const
|
|
{
|
|
return (__rdstate_ & badbit) != 0;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base::iostate
|
|
ios_base::exceptions() const
|
|
{
|
|
return __exceptions_;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
void
|
|
ios_base::exceptions(iostate __iostate)
|
|
{
|
|
__exceptions_ = __iostate;
|
|
clear(__rdstate_);
|
|
}
|
|
|
|
#if defined(_LIBCPP_CXX03_LANG)
|
|
struct _LIBCPP_TYPE_VIS __cxx03_bool {
|
|
typedef void (__cxx03_bool::*__bool_type)();
|
|
void __true_value() {}
|
|
};
|
|
#endif
|
|
|
|
template <class _CharT, class _Traits>
|
|
class _LIBCPP_TEMPLATE_VIS basic_ios
|
|
: public ios_base
|
|
{
|
|
public:
|
|
// types:
|
|
typedef _CharT char_type;
|
|
typedef _Traits traits_type;
|
|
|
|
typedef typename traits_type::int_type int_type;
|
|
typedef typename traits_type::pos_type pos_type;
|
|
typedef typename traits_type::off_type off_type;
|
|
|
|
// __true_value will generate undefined references when linking unless
|
|
// we give it internal linkage.
|
|
|
|
#if defined(_LIBCPP_CXX03_LANG)
|
|
_LIBCPP_ALWAYS_INLINE
|
|
operator __cxx03_bool::__bool_type() const {
|
|
return !fail() ? &__cxx03_bool::__true_value : nullptr;
|
|
}
|
|
#else
|
|
_LIBCPP_ALWAYS_INLINE
|
|
_LIBCPP_EXPLICIT operator bool() const {return !fail();}
|
|
#endif
|
|
|
|
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
|
|
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
|
|
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
|
|
_LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);}
|
|
_LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();}
|
|
_LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();}
|
|
_LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();}
|
|
_LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();}
|
|
|
|
_LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();}
|
|
_LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);}
|
|
|
|
// 27.5.4.1 Constructor/destructor:
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
|
|
virtual ~basic_ios();
|
|
|
|
// 27.5.4.2 Members:
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
basic_ostream<char_type, traits_type>* tie() const;
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
basic_streambuf<char_type, traits_type>* rdbuf() const;
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
|
|
|
|
basic_ios& copyfmt(const basic_ios& __rhs);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
char_type fill() const;
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
char_type fill(char_type __ch);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
locale imbue(const locale& __loc);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
char narrow(char_type __c, char __dfault) const;
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
char_type widen(char __c) const;
|
|
|
|
protected:
|
|
_LIBCPP_ALWAYS_INLINE
|
|
basic_ios() {// purposefully does no initialization
|
|
}
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
void init(basic_streambuf<char_type, traits_type>* __sb);
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
void move(basic_ios& __rhs);
|
|
#ifndef _LIBCPP_CXX03_LANG
|
|
_LIBCPP_ALWAYS_INLINE
|
|
void move(basic_ios&& __rhs) {move(__rhs);}
|
|
#endif
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
void swap(basic_ios& __rhs) _NOEXCEPT;
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
|
|
private:
|
|
basic_ostream<char_type, traits_type>* __tie_;
|
|
mutable int_type __fill_;
|
|
};
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb)
|
|
{
|
|
init(__sb);
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
basic_ios<_CharT, _Traits>::~basic_ios()
|
|
{
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
void
|
|
basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
|
|
{
|
|
ios_base::init(__sb);
|
|
__tie_ = 0;
|
|
__fill_ = traits_type::eof();
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
basic_ostream<_CharT, _Traits>*
|
|
basic_ios<_CharT, _Traits>::tie() const
|
|
{
|
|
return __tie_;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
basic_ostream<_CharT, _Traits>*
|
|
basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr)
|
|
{
|
|
basic_ostream<char_type, traits_type>* __r = __tie_;
|
|
__tie_ = __tiestr;
|
|
return __r;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
basic_streambuf<_CharT, _Traits>*
|
|
basic_ios<_CharT, _Traits>::rdbuf() const
|
|
{
|
|
return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
basic_streambuf<_CharT, _Traits>*
|
|
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb)
|
|
{
|
|
basic_streambuf<char_type, traits_type>* __r = rdbuf();
|
|
ios_base::rdbuf(__sb);
|
|
return __r;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
locale
|
|
basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
|
|
{
|
|
locale __r = getloc();
|
|
ios_base::imbue(__loc);
|
|
if (rdbuf())
|
|
rdbuf()->pubimbue(__loc);
|
|
return __r;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
char
|
|
basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
|
|
{
|
|
return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
_CharT
|
|
basic_ios<_CharT, _Traits>::widen(char __c) const
|
|
{
|
|
return use_facet<ctype<char_type> >(getloc()).widen(__c);
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
_CharT
|
|
basic_ios<_CharT, _Traits>::fill() const
|
|
{
|
|
if (traits_type::eq_int_type(traits_type::eof(), __fill_))
|
|
__fill_ = widen(' ');
|
|
return __fill_;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
_CharT
|
|
basic_ios<_CharT, _Traits>::fill(char_type __ch)
|
|
{
|
|
char_type __r = __fill_;
|
|
__fill_ = __ch;
|
|
return __r;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
basic_ios<_CharT, _Traits>&
|
|
basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
|
|
{
|
|
if (this != &__rhs)
|
|
{
|
|
__call_callbacks(erase_event);
|
|
ios_base::copyfmt(__rhs);
|
|
__tie_ = __rhs.__tie_;
|
|
__fill_ = __rhs.__fill_;
|
|
__call_callbacks(copyfmt_event);
|
|
exceptions(__rhs.exceptions());
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
void
|
|
basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
|
|
{
|
|
ios_base::move(__rhs);
|
|
__tie_ = __rhs.__tie_;
|
|
__rhs.__tie_ = 0;
|
|
__fill_ = __rhs.__fill_;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
void
|
|
basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT
|
|
{
|
|
ios_base::swap(__rhs);
|
|
_VSTD::swap(__tie_, __rhs.__tie_);
|
|
_VSTD::swap(__fill_, __rhs.__fill_);
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
void
|
|
basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb)
|
|
{
|
|
ios_base::set_rdbuf(__sb);
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
boolalpha(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::boolalpha);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
noboolalpha(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::boolalpha);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
showbase(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::showbase);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
noshowbase(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::showbase);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
showpoint(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::showpoint);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
noshowpoint(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::showpoint);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
showpos(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::showpos);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
noshowpos(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::showpos);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
skipws(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::skipws);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
noskipws(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::skipws);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
uppercase(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::uppercase);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
nouppercase(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::uppercase);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
unitbuf(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::unitbuf);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
nounitbuf(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::unitbuf);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
internal(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::internal, ios_base::adjustfield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
left(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::left, ios_base::adjustfield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
right(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::right, ios_base::adjustfield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
dec(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::dec, ios_base::basefield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
hex(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::hex, ios_base::basefield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
oct(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::oct, ios_base::basefield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
fixed(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::fixed, ios_base::floatfield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
scientific(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::scientific, ios_base::floatfield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
hexfloat(ios_base& __str)
|
|
{
|
|
__str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
|
|
return __str;
|
|
}
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
ios_base&
|
|
defaultfloat(ios_base& __str)
|
|
{
|
|
__str.unsetf(ios_base::floatfield);
|
|
return __str;
|
|
}
|
|
|
|
template <class _CharT, class _Traits>
|
|
class __save_flags
|
|
{
|
|
typedef basic_ios<_CharT, _Traits> __stream_type;
|
|
typedef typename __stream_type::fmtflags fmtflags;
|
|
|
|
__stream_type& __stream_;
|
|
fmtflags __fmtflags_;
|
|
_CharT __fill_;
|
|
|
|
__save_flags(const __save_flags&);
|
|
__save_flags& operator=(const __save_flags&);
|
|
public:
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
explicit __save_flags(__stream_type& __stream)
|
|
: __stream_(__stream),
|
|
__fmtflags_(__stream.flags()),
|
|
__fill_(__stream.fill())
|
|
{}
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
~__save_flags()
|
|
{
|
|
__stream_.flags(__fmtflags_);
|
|
__stream_.fill(__fill_);
|
|
}
|
|
};
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
#endif // _LIBCPP_IOS
|