summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__std_stream
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-06-28 21:40:28 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-06-28 21:40:28 +0000
commite9672d0448384ecedac4e2fb98010ee182455084 (patch)
tree0bbe3c65e6f1bd147b80c9bf96652acd0060231b /libcxx/include/__std_stream
parentb595f53069f9c9b5693df2be6aaa7cd1c7a94048 (diff)
downloadbcm5719-llvm-e9672d0448384ecedac4e2fb98010ee182455084.tar.gz
bcm5719-llvm-e9672d0448384ecedac4e2fb98010ee182455084.zip
Make cout a little more thread-safe. This fixes http://llvm.org/bugs/show_bug.cgi?id=12158
llvm-svn: 185222
Diffstat (limited to 'libcxx/include/__std_stream')
-rw-r--r--libcxx/include/__std_stream19
1 files changed, 9 insertions, 10 deletions
diff --git a/libcxx/include/__std_stream b/libcxx/include/__std_stream
index 2148f05767e..cff43317e58 100644
--- a/libcxx/include/__std_stream
+++ b/libcxx/include/__std_stream
@@ -263,30 +263,31 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
char_type __1buf;
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
- this->setp(&__1buf, &__1buf+1);
- *this->pptr() = traits_type::to_char_type(__c);
- this->pbump(1);
+ __1buf = traits_type::to_char_type(__c);
if (__always_noconv_)
{
- if (fwrite(this->pbase(), sizeof(char_type), 1, __file_) != 1)
+ if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
return traits_type::eof();
}
else
{
char* __extbe = __extbuf;
codecvt_base::result __r;
+ char_type* pbase = &__1buf;
+ char_type* pptr = pbase + 1;
+ char_type* epptr = pptr;
do
{
const char_type* __e;
- __r = __cv_->out(*__st_, this->pbase(), this->pptr(), __e,
+ __r = __cv_->out(*__st_, pbase, pptr, __e,
__extbuf,
__extbuf + sizeof(__extbuf),
__extbe);
- if (__e == this->pbase())
+ if (__e == pbase)
return traits_type::eof();
if (__r == codecvt_base::noconv)
{
- if (fwrite(this->pbase(), 1, 1, __file_) != 1)
+ if (fwrite(pbase, 1, 1, __file_) != 1)
return traits_type::eof();
}
else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
@@ -296,15 +297,13 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
return traits_type::eof();
if (__r == codecvt_base::partial)
{
- this->setp((char_type*)__e, this->pptr());
- this->pbump(static_cast<int>(this->epptr() - this->pbase()));
+ pbase = (char_type*)__e;
}
}
else
return traits_type::eof();
} while (__r == codecvt_base::partial);
}
- this->setp(0, 0);
}
return traits_type::not_eof(__c);
}
OpenPOWER on IntegriCloud