Skip to content

Commit 21405d8

Browse files
authored
Merge pull request #38698 from compnerd/static-mutex
runtime: replace use of `std::mutex` with `StaticMutex`
2 parents ea8b066 + 6c50325 commit 21405d8

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

stdlib/public/runtime/Errors.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,18 @@ static bool getSymbolNameAddr(llvm::StringRef libraryName,
9292
// providing failure status instead of just returning the original string like
9393
// swift demangle.
9494
#if defined(_WIN32)
95-
DWORD dwFlags = UNDNAME_COMPLETE;
96-
#if !defined(_WIN64)
97-
dwFlags |= UNDNAME_32_BIT_DECODE;
98-
#endif
99-
static std::mutex mutex;
95+
static StaticMutex mutex;
10096

10197
char szUndName[1024];
102-
DWORD dwResult;
98+
DWORD dwResult = mutex.withLock([&syminfo, &szUndName]() {
99+
DWORD dwFlags = UNDNAME_COMPLETE;
100+
#if !defined(_WIN64)
101+
dwFlags |= UNDNAME_32_BIT_DECODE;
102+
#endif
103103

104-
{
105-
std::lock_guard<std::mutex> lock(mutex);
106-
dwResult = UnDecorateSymbolName(syminfo.symbolName.get(), szUndName,
107-
sizeof(szUndName), dwFlags);
108-
}
104+
return UnDecorateSymbolName(syminfo.symbolName.get(), szUndName,
105+
sizeof(szUndName), dwFlags);
106+
});
109107

110108
if (dwResult == TRUE) {
111109
symbolName += szUndName;

0 commit comments

Comments
 (0)