From: Jonathan Wakely Date: Mon, 29 Apr 2019 12:55:29 +0000 (+0100) Subject: PR libstdc++/71312 Increase alignment of pooled mutexes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7bbdd8d13e6cc06d77321209a945edf64350a5ac;p=gcc.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. From-SVN: r270649 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a5482bbcdf7..2168a795f48 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 1f1323ef89f..a4e833bf4c8 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]; } }