diff options
| author | Zachary Turner <zturner@google.com> | 2014-08-20 20:53:05 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2014-08-20 20:53:05 +0000 |
| commit | 75172a95678e79449df1375b6478b97bf4f2d21a (patch) | |
| tree | a5b24cd332cb1b733b265dcf51217b596e0ff2e2 /lldb/source | |
| parent | bb38f7bdaa05ad7706e990c451248feac8be424b (diff) | |
| download | bcm5719-llvm-75172a95678e79449df1375b6478b97bf4f2d21a.tar.gz bcm5719-llvm-75172a95678e79449df1375b6478b97bf4f2d21a.zip | |
Revert "Avoid global contstructors and place static variables
inside classes as static local variables and remove the static
ivars. Subclasses should use the accessor functions."
This change moved global statics to function local statics, but
forgot to make the locals static in the function, breaking all
platforms. Furthermore, MSVC doesn't support thread-safe function
local statics, so any use of a function local static on non
primitive types is undefined behavior on MSVC.
Reverting due to the fact that it's broken on all platforms, but
would like to have a discussion about the thread-safety issue
before it goes back in.
llvm-svn: 216123
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Host/common/HostInfoBase.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp index b564b254740..3b90680d451 100644 --- a/lldb/source/Host/common/HostInfoBase.cpp +++ b/lldb/source/Host/common/HostInfoBase.cpp @@ -22,86 +22,85 @@ using namespace lldb; using namespace lldb_private; +uint32_t HostInfoBase::m_number_cpus = 0; +std::string HostInfoBase::m_vendor_string; +std::string HostInfoBase::m_os_string; +std::string HostInfoBase::m_host_triple; +ArchSpec HostInfoBase::m_host_arch_32; +ArchSpec HostInfoBase::m_host_arch_64; uint32_t HostInfoBase::GetNumberCPUS() { static bool is_initialized = false; - uint32_t g_number_cpus = 0; if (!is_initialized) { - g_number_cpus = std::thread::hardware_concurrency(); + m_number_cpus = std::thread::hardware_concurrency(); is_initialized = true; } - return g_number_cpus; + return m_number_cpus; } llvm::StringRef HostInfoBase::GetVendorString() { static bool is_initialized = false; - std::string g_vendor_string; if (!is_initialized) { const ArchSpec &host_arch = HostInfo::GetArchitecture(); const llvm::StringRef &str_ref = host_arch.GetTriple().getVendorName(); - g_vendor_string.assign(str_ref.begin(), str_ref.end()); + m_vendor_string.assign(str_ref.begin(), str_ref.end()); is_initialized = true; } - return llvm::StringRef(g_vendor_string); + return m_vendor_string; } llvm::StringRef HostInfoBase::GetOSString() { static bool is_initialized = false; - std::string g_os_string; if (!is_initialized) { const ArchSpec &host_arch = HostInfo::GetArchitecture(); const llvm::StringRef &str_ref = host_arch.GetTriple().getOSName(); - g_os_string.assign(str_ref.begin(), str_ref.end()); + m_os_string.assign(str_ref.begin(), str_ref.end()); is_initialized = true; } - return llvm::StringRef(g_os_string); + return m_os_string; } llvm::StringRef HostInfoBase::GetTargetTriple() { static bool is_initialized = false; - std::string g_host_triple; if (!is_initialized) { const ArchSpec &host_arch = HostInfo::GetArchitecture(); - g_host_triple = host_arch.GetTriple().getTriple(); + m_host_triple = host_arch.GetTriple().getTriple(); is_initialized = true; } - return g_host_triple; + return m_host_triple; } const ArchSpec & HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) { static bool is_initialized = false; - static ArchSpec g_host_arch_32; - static ArchSpec g_host_arch_64; - if (!is_initialized) { - HostInfo::ComputeHostArchitectureSupport(g_host_arch_32, g_host_arch_64); + HostInfo::ComputeHostArchitectureSupport(m_host_arch_32, m_host_arch_64); is_initialized = true; } // If an explicit 32 or 64-bit architecture was requested, return that. if (arch_kind == eArchKind32) - return g_host_arch_32; + return m_host_arch_32; if (arch_kind == eArchKind64) - return g_host_arch_64; + return m_host_arch_64; // Otherwise prefer the 64-bit architecture if it is valid. - return (g_host_arch_64.IsValid()) ? g_host_arch_64 : g_host_arch_32; + return (m_host_arch_64.IsValid()) ? m_host_arch_64 : m_host_arch_32; } void |

