Skip to content

Commit 89e775a

Browse files
kevinfreiKevin Frei
andauthored
Switch from the std::shared_mutex to an LLVM RWMutex (#74383)
@nico pointed out that my usage of `std::shared_mutex` broke builds on older macOS devices. Switching to `llvm::sys::RWMutex` is the solution that they provided. Tracked in issue #74382 Co-authored-by: Kevin Frei <[email protected]>
1 parent b3392c4 commit 89e775a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Debuginfod/Debuginfod.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ using llvm::object::BuildIDRef;
5151
namespace {
5252
std::optional<SmallVector<StringRef>> DebuginfodUrls;
5353
// Many Readers/Single Writer lock protecting the global debuginfod URL list.
54-
std::shared_mutex UrlsMutex;
54+
llvm::sys::RWMutex UrlsMutex;
5555
} // namespace
5656

5757
static std::string uniqueKey(llvm::StringRef S) {
@@ -69,12 +69,12 @@ bool canUseDebuginfod() {
6969
}
7070

7171
SmallVector<StringRef> getDefaultDebuginfodUrls() {
72-
std::shared_lock<std::shared_mutex> ReadGuard(UrlsMutex);
72+
std::shared_lock<llvm::sys::RWMutex> ReadGuard(UrlsMutex);
7373
if (!DebuginfodUrls) {
7474
// Only read from the environment variable if the user hasn't already
7575
// set the value
7676
ReadGuard.unlock();
77-
std::unique_lock<std::shared_mutex> WriteGuard(UrlsMutex);
77+
std::unique_lock<llvm::sys::RWMutex> WriteGuard(UrlsMutex);
7878
DebuginfodUrls = SmallVector<StringRef>();
7979
if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) {
8080
StringRef(DebuginfodUrlsEnv)
@@ -88,7 +88,7 @@ SmallVector<StringRef> getDefaultDebuginfodUrls() {
8888

8989
// Set the default debuginfod URL list, override the environment variable
9090
void setDefaultDebuginfodUrls(const SmallVector<StringRef> &URLs) {
91-
std::unique_lock<std::shared_mutex> WriteGuard(UrlsMutex);
91+
std::unique_lock<llvm::sys::RWMutex> WriteGuard(UrlsMutex);
9292
DebuginfodUrls = URLs;
9393
}
9494

0 commit comments

Comments
 (0)