NVCtrl loader

pull/109/head
FlightlessMango 4 years ago
parent 1915352c86
commit 8ee0ec2c3f

@ -0,0 +1,88 @@
// This is generated file. Do not modify directly.
// Path to the code generator: /home/crz/git/MangoHud/generate_library_loader.py .
#include "loader_nvctrl.h"
// Put these sanity checks here so that they fire at most once
// (to avoid cluttering the build output).
#if !defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN) && !defined(LIBRARY_LOADER_NVCTRL_H_DT_NEEDED)
#error neither LIBRARY_LOADER_NVCTRL_H_DLOPEN nor LIBRARY_LOADER_NVCTRL_H_DT_NEEDED defined
#endif
#if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN) && defined(LIBRARY_LOADER_NVCTRL_H_DT_NEEDED)
#error both LIBRARY_LOADER_NVCTRL_H_DLOPEN and LIBRARY_LOADER_NVCTRL_H_DT_NEEDED defined
#endif
libnvctrl_loader::libnvctrl_loader() : loaded_(false) {
}
libnvctrl_loader::~libnvctrl_loader() {
CleanUp(loaded_);
}
bool libnvctrl_loader::Load(const std::string& library_name) {
if (loaded_) {
return false;
}
#if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN)
library_ = dlopen(library_name.c_str(), RTLD_LAZY);
if (!library_)
return false;
XNVCTRLQueryVersion =
reinterpret_cast<decltype(this->XNVCTRLQueryVersion)>(
dlsym(library_, "XNVCTRLQueryVersion"));
if (!XNVCTRLQueryVersion) {
CleanUp(true);
return false;
}
XNVCTRLQueryAttribute =
reinterpret_cast<decltype(this->XNVCTRLQueryAttribute)>(
dlsym(library_, "XNVCTRLQueryAttribute"));
if (!XNVCTRLQueryAttribute) {
CleanUp(true);
return false;
}
XNVCTRLQueryTargetStringAttribute =
reinterpret_cast<decltype(this->XNVCTRLQueryTargetStringAttribute)>(
dlsym(library_, "XNVCTRLQueryTargetStringAttribute"));
if (!XNVCTRLQueryTargetStringAttribute) {
CleanUp(true);
return false;
}
XNVCTRLQueryTargetAttribute =
reinterpret_cast<decltype(this->XNVCTRLQueryTargetAttribute)>(
dlsym(library_, "XNVCTRLQueryTargetAttribute"));
if (!XNVCTRLQueryTargetAttribute) {
CleanUp(true);
return false;
}
#endif
#if defined(LIBRARY_LOADER_NVCTRL_H_DT_NEEDED)
XNVCTRLQueryVersion = &::XNVCTRLQueryVersion;
XNVCTRLQueryAttribute = &::XNVCTRLQueryAttribute;
#endif
loaded_ = true;
return true;
}
void libnvctrl_loader::CleanUp(bool unload) {
#if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN)
if (unload) {
dlclose(library_);
library_ = NULL;
}
#endif
loaded_ = false;
XNVCTRLQueryVersion = NULL;
XNVCTRLQueryAttribute = NULL;
}

@ -0,0 +1,43 @@
// This is generated file. Do not modify directly.
// Path to the code generator: /home/crz/git/MangoHud/generate_library_loader.py .
#ifndef LIBRARY_LOADER_NVCTRL_H
#define LIBRARY_LOADER_NVCTRL_H
#define Bool bool
#include <X11/Xlib.h>
#include "NVCtrl/NVCtrlLib.h"
#define LIBRARY_LOADER_NVCTRL_H_DLOPEN
#include <string>
#include <dlfcn.h>
class libnvctrl_loader {
public:
libnvctrl_loader();
libnvctrl_loader(const std::string& library_name) { Load(library_name); }
~libnvctrl_loader();
bool Load(const std::string& library_name);
bool IsLoaded() { return loaded_; }
decltype(&::XNVCTRLQueryVersion) XNVCTRLQueryVersion;
decltype(&::XNVCTRLQueryAttribute) XNVCTRLQueryAttribute;
decltype(&::XNVCTRLQueryTargetStringAttribute) XNVCTRLQueryTargetStringAttribute;
decltype(&::XNVCTRLQueryTargetAttribute) XNVCTRLQueryTargetAttribute;
private:
void CleanUp(bool unload);
#if defined(LIBRARY_LOADER_NVCTRL_H_DLOPEN)
void* library_;
#endif
bool loaded_;
// Disallow copy constructor and assignment operator.
libnvctrl_loader(const libnvctrl_loader&);
void operator=(const libnvctrl_loader&);
};
#endif // LIBRARY_LOADER_NVCTRL_H

@ -44,6 +44,7 @@ vklayer_files = files(
'font_unispace.c',
'cpu.cpp',
'loaders/loader_nvml.cpp',
'loaders/loader_nvctrl.cpp',
'nvml.cpp',
'file_utils.cpp',
'memory.cpp',

Loading…
Cancel
Save