PR libstdc++/71312
* src/c++11/shared_ptr.cc (get_mutex): Align pool mutexes to 64 bytes.
Tested powerpc64le-linux, committed to trunk.
commit 7bdfcdf0100b2e340339388e5cef610c9f6a251f
Author: Jonathan Wakely <[email protected]>
Date: Mon Mar 11 21:18:05 2019 +0000
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.
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];
}
}