2#include "Logging/Logger.h"
15 std::span<const char*> dllVersions() {
17 static std::array paths = {
".x64.Debug.so" };
18 return std::span<const char*>(paths);
19#elif defined( OSOMP_EnableProfiler )
20 static std::array paths = {
".x64.ReleaseMemProfile.so",
".x64.Release.so" };
21 return std::span<const char*>(paths);
23 static std::array paths = {
".x64.ReleaseASan.so",
".x64.Release.so" };
24 return std::span<const char*>(paths);
26 static std::array paths = {
".x64.ReleaseTSan.so",
".x64.Release.so" };
27 return std::span<const char*>(paths);
29 static std::array paths = {
".x64.Release.so" };
30 return std::span<const char*>(paths);
46 if (path.find(
".so") == std::string::npos) {
48 std::span<const char*> versions = dllVersions();
49 std::string libraryPath;
50 libraryPath.reserve(path.size() + 40);
52 for (
const char* version : versions) {
56 libraryPath += version;
58 handle = ::dlopen(libraryPath.c_str(), RTLD_NOW | RTLD_LOCAL);
63 handle = ::dlopen(path.c_str(), RTLD_NOW | RTLD_LOCAL);
65 if(handle ==
nullptr) {
66 LOG_ERROR(logger,
"dlopen failed: %s", dlerror());
68 status = handle ? LoadStatus::Loaded : LoadStatus::Failed;
71void Cogs::Module::unload(
void* handle) {
83void* Cogs::Module::getProcAddress(
void* handle,
const char* procName) {
84 return dlsym(handle, procName);
Log implementation class.
static void load(const std::string &path, LoadStatus &status, void *&handle)
Attempts to load a shared library with the given name.
constexpr Log getLogger(const char(&name)[LEN]) noexcept