aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include/cpplib.h
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-11-24 12:29:30 +0000
committerJonathan Wakely <jwakely@redhat.com>2020-11-24 14:59:40 +0000
commite253d36214015ed10ffd335e3628ccaac22dd5c7 (patch)
tree92f4310a31283e95f47fdb77b241ad79641518af /libcpp/include/cpplib.h
parent97981e13b7f7b1ffd1c9ccf3d96d574b7b3caada (diff)
downloadgcc-e253d36214015ed10ffd335e3628ccaac22dd5c7.zip
gcc-e253d36214015ed10ffd335e3628ccaac22dd5c7.tar.gz
gcc-e253d36214015ed10ffd335e3628ccaac22dd5c7.tar.bz2
libstdc++: Use __libc_single_threaded for locale initialization
Most initialization of locales and facets happens before main() during startup, when the program is likely to only have one thread. By using the new __gnu_cxx::__is_single_threaded() function instead of checking __gthread_active_p() we can avoid using pthread_once or atomics for the common case. That said, I'm not sure why we don't just use a local static variable instead, as __cxa_guard_acquire() already optimizes for the single-threaded case: static const bool init = (_S_initialize_once(), true); I'll revisit that for GCC 12. libstdc++-v3/ChangeLog: * src/c++98/locale.cc (locale::facet::_S_get_c_locale()) (locale::id::_M_id() const): Use __is_single_threaded. * src/c++98/locale_init.cc (locale::_S_initialize()): Likewise.
Diffstat (limited to 'libcpp/include/cpplib.h')
0 files changed, 0 insertions, 0 deletions