Switch std::call_once to llvm::call_once
Summary:
The std::call_once implementation in libstdc++ has problems on few systems: NetBSD, OpenBSD and Linux PPC. LLVM ships with a homegrown implementation llvm::call_once to help on these platforms.
This change is required in the NetBSD LLDB port. std::call_once with libstdc++ results with crashing the debugger.
Sponsored by <The NetBSD Foundation>
Reviewers: labath, joerg, emaste, mehdi_amini, clayborg
Reviewed By: labath, clayborg
Subscribers: #lldb
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D29288
llvm-svn: 294202
diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp
index 2a01f06..1f39ca5 100644
--- a/lldb/source/Host/linux/HostInfoLinux.cpp
+++ b/lldb/source/Host/linux/HostInfoLinux.cpp
@@ -10,6 +10,8 @@
#include "lldb/Host/linux/HostInfoLinux.h"
#include "lldb/Core/Log.h"
+#include "llvm/Support/Threading.h"
+
#include <limits.h>
#include <stdio.h>
#include <string.h>
@@ -44,8 +46,8 @@
bool HostInfoLinux::GetOSVersion(uint32_t &major, uint32_t &minor,
uint32_t &update) {
static bool success = false;
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
struct utsname un;
if (uname(&un) == 0) {
@@ -100,8 +102,8 @@
llvm::StringRef HostInfoLinux::GetDistributionId() {
// Try to run 'lbs_release -i', and use that response
// for the distribution id.
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST));
if (log)