19 #include <sys/utsname.h>
26 #define KVIKIO_STRINGIFY_DETAIL(x) #x
27 #define KVIKIO_STRINGIFY(x) KVIKIO_STRINGIFY_DETAIL(x)
35 inline void* load_library(
const char* name,
int mode = RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE)
38 void* ret = ::dlopen(name, mode);
39 if (ret ==
nullptr) {
throw std::runtime_error(::dlerror()); }
49 inline void* load_library(
const std::vector<const char*>& names,
50 int mode = RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE)
53 for (
const char* name : names) {
56 return load_library(name, mode);
57 }
catch (
const std::runtime_error&) {
60 throw std::runtime_error(
"cannot open shared object file, tried: " + ss.str());
72 void get_symbol(T& handle,
void* lib,
const char* name)
76 handle =
reinterpret_cast<T
>(::dlsym(lib, name));
77 const char* err = ::dlerror();
78 if (err !=
nullptr) {
throw std::runtime_error(err); }
88 [[nodiscard]]
inline bool is_running_in_wsl()
90 struct utsname buf {};
91 int err = ::uname(&buf);
93 const std::string name(
static_cast<char*
>(buf.release));
95 return name.find(
"icrosoft") != std::string::npos;
109 [[nodiscard]]
inline bool run_udev_readable()
112 return std::filesystem::is_directory(
"/run/udev");
113 }
catch (
const std::filesystem::filesystem_error&) {