cmDynamicLoader: Remove unused code

It has not been used since commit dc0c6734d3 (CMP0031: Remove support
for OLD load_command command, 2024-11-26, v4.0.0-rc1~174^2~21).
This commit is contained in:
Brad King
2025-04-21 19:36:26 -04:00
parent 15daf279f2
commit b4b0d3f118
5 changed files with 1 additions and 134 deletions

View File

@@ -186,8 +186,6 @@ add_library(
cmDependsCompiler.h
cmDocumentation.cxx
cmDocumentationFormatter.cxx
cmDynamicLoader.cxx
cmDynamicLoader.h
cmDyndepCollation.cxx
cmDyndepCollation.h
cmELF.h

View File

@@ -47,7 +47,6 @@
#include "cmCTestTestHandler.h"
#include "cmCTestTypes.h"
#include "cmCommandLineArgument.h"
#include "cmDynamicLoader.h"
#include "cmExecutionStatus.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
@@ -2744,11 +2743,7 @@ int cmCTest::ExecuteTests(std::vector<std::string> const& args)
int cmCTest::RunCMakeAndTest()
{
int retv = this->Impl->BuildAndTest.Run();
#ifndef CMAKE_BOOTSTRAP
cmDynamicLoader::FlushCache();
#endif
return retv;
return this->Impl->BuildAndTest.Run();
}
void cmCTest::SetNotesFiles(std::string const& notes)

View File

@@ -1,92 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "cmDynamicLoader.h"
#include <map>
#include <string>
#include <utility>
namespace {
class cmDynamicLoaderCache
{
public:
~cmDynamicLoaderCache();
void CacheFile(char const* path, cmsys::DynamicLoader::LibraryHandle /*p*/);
bool GetCacheFile(char const* path,
cmsys::DynamicLoader::LibraryHandle& /*p*/);
bool FlushCache(char const* path);
void FlushCache();
static cmDynamicLoaderCache& GetInstance();
private:
std::map<std::string, cmsys::DynamicLoader::LibraryHandle> CacheMap;
static cmDynamicLoaderCache Instance;
};
cmDynamicLoaderCache cmDynamicLoaderCache::Instance;
}
cmDynamicLoaderCache::~cmDynamicLoaderCache() = default;
void cmDynamicLoaderCache::CacheFile(char const* path,
cmsys::DynamicLoader::LibraryHandle p)
{
cmsys::DynamicLoader::LibraryHandle h;
if (this->GetCacheFile(path, h)) {
this->FlushCache(path);
}
this->CacheMap[path] = p;
}
bool cmDynamicLoaderCache::GetCacheFile(char const* path,
cmsys::DynamicLoader::LibraryHandle& p)
{
auto it = this->CacheMap.find(path);
if (it != this->CacheMap.end()) {
p = it->second;
return true;
}
return false;
}
bool cmDynamicLoaderCache::FlushCache(char const* path)
{
auto it = this->CacheMap.find(path);
bool ret = false;
if (it != this->CacheMap.end()) {
cmsys::DynamicLoader::CloseLibrary(it->second);
this->CacheMap.erase(it);
ret = true;
}
return ret;
}
void cmDynamicLoaderCache::FlushCache()
{
for (auto const& it : this->CacheMap) {
cmsys::DynamicLoader::CloseLibrary(it.second);
}
this->CacheMap.clear();
}
cmDynamicLoaderCache& cmDynamicLoaderCache::GetInstance()
{
return cmDynamicLoaderCache::Instance;
}
cmsys::DynamicLoader::LibraryHandle cmDynamicLoader::OpenLibrary(
char const* libname)
{
cmsys::DynamicLoader::LibraryHandle lh;
if (cmDynamicLoaderCache::GetInstance().GetCacheFile(libname, lh)) {
return lh;
}
lh = cmsys::DynamicLoader::OpenLibrary(libname);
cmDynamicLoaderCache::GetInstance().CacheFile(libname, lh);
return lh;
}
void cmDynamicLoader::FlushCache()
{
cmDynamicLoaderCache::GetInstance().FlushCache();
}

View File

@@ -1,30 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
// .NAME cmDynamicLoader - class interface to system dynamic libraries
// .SECTION Description
// cmDynamicLoader provides a portable interface to loading dynamic
// libraries into a process.
#pragma once
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmsys/DynamicLoader.hxx" // IWYU pragma: export
class cmDynamicLoader
{
public:
// Description:
// Load a dynamic library into the current process.
// The returned cmsys::DynamicLoader::LibraryHandle can be used to access
// the symbols in the library.
static cmsys::DynamicLoader::LibraryHandle OpenLibrary(char const*);
// Description:
// Flush the cache of dynamic loader.
static void FlushCache();
protected:
cmDynamicLoader() = default;
~cmDynamicLoader() = default;
};

View File

@@ -43,7 +43,6 @@
#ifndef CMAKE_BOOTSTRAP
# include "cmDocumentation.h"
# include "cmDynamicLoader.h"
#endif
#include "cmsys/Encoding.hxx"
@@ -1181,9 +1180,6 @@ int main(int ac, char const* const* av)
}
}
int ret = do_cmake(ac, av);
#ifndef CMAKE_BOOTSTRAP
cmDynamicLoader::FlushCache();
#endif
if (uv_loop_t* loop = uv_default_loop()) {
uv_loop_close(loop);
}