From: redi Date: Mon, 29 Apr 2019 12:55:29 +0000 (+0000) Subject: PR libstdc++/71312 Increase alignment of pooled mutexes X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e3600f25710f52dfd5880869c3de35f783536e61;p=thirdparty%2Fgcc.git PR libstdc++/71312 Increase alignment of pooled mutexes PR libstdc++/71312 * src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 bytes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270649 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a5482bbcdf76..2168a795f48c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2019-04-29 Jonathan Wakely + PR libstdc++/71312 + * src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 bytes. + * include/bits/stl_bvector.h (vector::empty()): Add nodiscard attribute. diff --git a/libstdc++-v3/src/c++11/shared_ptr.cc b/libstdc++-v3/src/c++11/shared_ptr.cc index 1f1323ef89f5..a4e833bf4c87 100644 --- a/libstdc++-v3/src/c++11/shared_ptr.cc +++ b/libstdc++-v3/src/c++11/shared_ptr.cc @@ -34,7 +34,9 @@ namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden) __gnu_cxx::__mutex& get_mutex(unsigned char i) { - static __gnu_cxx::__mutex m[mask + 1]; + // increase alignment to put each lock on a separate cache line + struct alignas(64) M : __gnu_cxx::__mutex { }; + static M m[mask + 1]; return m[i]; } }