diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2019-09-13 15:28:06 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2019-09-13 15:28:06 +0000 |
commit | 7b81a13bfcd1d92f478109f1c87971dafba639d2 (patch) | |
tree | 1dc90fe12b7adbacc6ae297317d628366c245ee1 /libcxx/src | |
parent | 24c1ab26331ae218f27659a1a26cc72d8a264482 (diff) | |
download | bcm5719-llvm-7b81a13bfcd1d92f478109f1c87971dafba639d2.tar.gz bcm5719-llvm-7b81a13bfcd1d92f478109f1c87971dafba639d2.zip |
Only initialize the streams cout/wcout/cerr/wcerr etc once, rather than any time Init::Init is called. Fixes PR#43300
llvm-svn: 371864
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/iostream.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/libcxx/src/iostream.cpp b/libcxx/src/iostream.cpp index 0a5d6e8d226..ad1920abc65 100644 --- a/libcxx/src/iostream.cpp +++ b/libcxx/src/iostream.cpp @@ -97,7 +97,13 @@ static void force_locale_initialization() { #endif } -ios_base::Init::Init() +class DoIOSInit { +public: + DoIOSInit(); + ~DoIOSInit(); +}; + +DoIOSInit::DoIOSInit() { force_locale_initialization(); @@ -126,7 +132,7 @@ ios_base::Init::Init() #endif } -ios_base::Init::~Init() +DoIOSInit::~DoIOSInit() { #ifndef _LIBCPP_HAS_NO_STDOUT ostream* cout_ptr = reinterpret_cast<ostream*>(cout); @@ -141,4 +147,13 @@ ios_base::Init::~Init() wclog_ptr->flush(); } +ios_base::Init::Init() +{ + static DoIOSInit init_the_streams; // gets initialized once +} + +ios_base::Init::~Init() +{ +} + _LIBCPP_END_NAMESPACE_STD |