summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/src/debug.cc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libstdc++/src/debug.cc')
-rw-r--r--contrib/libstdc++/src/debug.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/contrib/libstdc++/src/debug.cc b/contrib/libstdc++/src/debug.cc
index 05ebc2f..415fcbf 100644
--- a/contrib/libstdc++/src/debug.cc
+++ b/contrib/libstdc++/src/debug.cc
@@ -37,9 +37,15 @@
#include <cstring>
#include <cstdio>
#include <cctype>
+#include <bits/concurrence.h>
using namespace std;
+namespace __gnu_internal
+{
+ __glibcxx_mutex_define_initialized(iterator_base_mutex);
+} // namespace __gnu_internal
+
namespace __gnu_debug
{
const char* _S_debug_messages[] =
@@ -188,6 +194,7 @@ namespace __gnu_debug
// Attach to the new sequence (if there is one)
if (__seq)
{
+ __gnu_cxx::lock sentry(__gnu_internal::iterator_base_mutex);
_M_sequence = __seq;
_M_version = _M_sequence->_M_version;
_M_prior = 0;
@@ -212,6 +219,7 @@ namespace __gnu_debug
_Safe_iterator_base::
_M_detach()
{
+ __gnu_cxx::lock sentry(__gnu_internal::iterator_base_mutex);
if (_M_sequence)
{
// Remove us from this sequence's list
@@ -569,12 +577,17 @@ namespace __gnu_debug
{
// [__start, __end) denotes the next word
__end = __start;
- while (isalnum(*__end)) ++__end;
- if (__start == __end) ++__end;
- if (isspace(*__end)) ++__end;
+ while (isalnum(*__end))
+ ++__end;
+ if (__start == __end)
+ ++__end;
+ if (isspace(*__end))
+ ++__end;
- assert(__end - __start + 1< __bufsize);
- _M_format_word(__buf, __end - __start + 1, "%s", __start);
+ const ptrdiff_t __len = __end - __start;
+ assert(__len < __bufsize);
+ memcpy(__buf, __start, __len);
+ __buf[__len] = '\0';
_M_print_word(__buf);
__start = __end;
OpenPOWER on IntegriCloud