aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/c++98/locale.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/libstdc++-v3/src/c++98/locale.cc b/libstdc++-v3/src/c++98/locale.cc
index d308140..1ef0c39 100644
--- a/libstdc++-v3/src/c++98/locale.cc
+++ b/libstdc++-v3/src/c++98/locale.cc
@@ -206,6 +206,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
locale::facet::_S_initialize_once()
{
+ // Need to check this because we could get called once from
+ // _S_get_c_locale() when the program is single-threaded, and then again
+ // (via __gthread_once) when it's multi-threaded.
+ if (_S_c_locale)
+ return;
+
// Initialize the underlying locale model.
_S_create_c_locale(_S_c_locale, _S_c_name);
}
@@ -216,12 +222,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef __GTHREADS
if (__gthread_active_p())
__gthread_once(&_S_once, _S_initialize_once);
- else
#endif
- {
- if (!_S_c_locale)
- _S_initialize_once();
- }
+ if (__builtin_expect (!_S_c_locale, 0))
+ _S_initialize_once();
return _S_c_locale;
}