[Lldb-commits] [lldb] 38b419e - Factor out reference-counting code from PlatformApple*
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 7 14:25:42 PDT 2020
Author: Adrian Prantl
Date: 2020-08-07T14:25:32-07:00
New Revision: 38b419eb9330c1f1bcec31764f57e932c07fb42c
URL: https://github.com/llvm/llvm-project/commit/38b419eb9330c1f1bcec31764f57e932c07fb42c
DIFF: https://github.com/llvm/llvm-project/commit/38b419eb9330c1f1bcec31764f57e932c07fb42c.diff
LOG: Factor out reference-counting code from PlatformApple*
into PlatformAppleSimulator. This is legal because that is the only
entry point for the Terminate/Initialize functions.
Added:
Modified:
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 5201e203f77e..3ca9e6c37fe2 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -514,24 +514,19 @@ static llvm::StringRef GetXcodeSDKDir(std::string preferred,
return sdk;
}
-static unsigned g_ios_initialize_count = 0;
static const char *g_ios_plugin_name = "ios-simulator";
static const char *g_ios_description = "iPhone simulator platform plug-in.";
/// IPhone Simulator Plugin.
struct PlatformiOSSimulator {
static void Initialize() {
- if (g_ios_initialize_count++ == 0) {
- PluginManager::RegisterPlugin(ConstString(g_ios_plugin_name),
- g_ios_description,
- PlatformiOSSimulator::CreateInstance);
- }
+ PluginManager::RegisterPlugin(ConstString(g_ios_plugin_name),
+ g_ios_description,
+ PlatformiOSSimulator::CreateInstance);
}
static void Terminate() {
- if (g_ios_initialize_count > 0)
- if (--g_ios_initialize_count == 0)
- PluginManager::UnregisterPlugin(PlatformiOSSimulator::CreateInstance);
+ PluginManager::UnregisterPlugin(PlatformiOSSimulator::CreateInstance);
}
static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
@@ -567,24 +562,19 @@ struct PlatformiOSSimulator {
}
};
-static unsigned g_tvos_initialize_count = 0;
static const char *g_tvos_plugin_name = "tvos-simulator";
static const char *g_tvos_description = "tvOS simulator platform plug-in.";
/// Apple TV Simulator Plugin.
struct PlatformAppleTVSimulator {
static void Initialize() {
- if (g_tvos_initialize_count++ == 0) {
- PluginManager::RegisterPlugin(ConstString(g_tvos_plugin_name),
- g_tvos_description,
- PlatformAppleTVSimulator::CreateInstance);
- }
+ PluginManager::RegisterPlugin(ConstString(g_tvos_plugin_name),
+ g_tvos_description,
+ PlatformAppleTVSimulator::CreateInstance);
}
static void Terminate() {
- if (g_tvos_initialize_count > 0)
- if (--g_tvos_initialize_count == 0)
- PluginManager::UnregisterPlugin(PlatformAppleTVSimulator::CreateInstance);
+ PluginManager::UnregisterPlugin(PlatformAppleTVSimulator::CreateInstance);
}
static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
@@ -611,7 +601,6 @@ struct PlatformAppleTVSimulator {
};
-static unsigned g_watchos_initialize_count = 0;
static const char *g_watchos_plugin_name = "watchos-simulator";
static const char *g_watchos_description =
"Apple Watch simulator platform plug-in.";
@@ -619,18 +608,14 @@ static const char *g_watchos_description =
/// Apple Watch Simulator Plugin.
struct PlatformAppleWatchSimulator {
static void Initialize() {
- if (g_watchos_initialize_count++ == 0) {
- PluginManager::RegisterPlugin(
- ConstString(g_watchos_plugin_name), g_watchos_description,
- PlatformAppleWatchSimulator::CreateInstance);
- }
+ PluginManager::RegisterPlugin(ConstString(g_watchos_plugin_name),
+ g_watchos_description,
+ PlatformAppleWatchSimulator::CreateInstance);
}
static void Terminate() {
- if (g_watchos_initialize_count > 0)
- if (--g_watchos_initialize_count == 0)
- PluginManager::UnregisterPlugin(
- PlatformAppleWatchSimulator::CreateInstance);
+ PluginManager::UnregisterPlugin(
+ PlatformAppleWatchSimulator::CreateInstance);
}
static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
@@ -657,18 +642,25 @@ struct PlatformAppleWatchSimulator {
};
+static unsigned g_initialize_count = 0;
+
// Static Functions
void PlatformAppleSimulator::Initialize() {
- PlatformDarwin::Initialize();
- PlatformiOSSimulator::Initialize();
- PlatformAppleTVSimulator::Initialize();
- PlatformAppleWatchSimulator::Initialize();
+ if (g_initialize_count++ == 0) {
+ PlatformDarwin::Initialize();
+ PlatformiOSSimulator::Initialize();
+ PlatformAppleTVSimulator::Initialize();
+ PlatformAppleWatchSimulator::Initialize();
+ }
}
void PlatformAppleSimulator::Terminate() {
- PlatformAppleWatchSimulator::Terminate();
- PlatformAppleTVSimulator::Terminate();
- PlatformiOSSimulator::Terminate();
- PlatformDarwin::Terminate();
+ if (g_initialize_count > 0)
+ if (--g_initialize_count == 0) {
+ PlatformAppleWatchSimulator::Terminate();
+ PlatformAppleTVSimulator::Terminate();
+ PlatformiOSSimulator::Terminate();
+ PlatformDarwin::Terminate();
+ }
}
More information about the lldb-commits
mailing list