blob: 4841956686b66dab3347f87f906714331b7d1ca0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "config.h"
#include "dbus_wrap.h"
#ifdef HAVE_DYNLOAD
#include <mutex>
#include <type_traits>
#include "albit.h"
#include "logging.h"
void PrepareDBus()
{
static constexpr char libname[] = "libdbus-1.so.3";
auto load_func = [](auto &f, const char *name) -> void
{ f = al::bit_cast<std::remove_reference_t<decltype(f)>>(GetSymbol(dbus_handle, name)); };
#define LOAD_FUNC(x) do { \
load_func(p##x, #x); \
if(!p##x) \
{ \
WARN("Failed to load function %s\n", #x); \
CloseLib(dbus_handle); \
dbus_handle = nullptr; \
return; \
} \
} while(0);
dbus_handle = LoadLib(libname);
if(!dbus_handle)
{
WARN("Failed to load %s\n", libname);
return;
}
DBUS_FUNCTIONS(LOAD_FUNC)
#undef LOAD_FUNC
}
#endif
|