blob: 50993cb5cd20645e24fd38a94f414e570b014858 (
plain) (
blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include "symbols.h"
#include <util/generic/yexception.h>
#include <util/generic/vector.h>
#include <util/generic/singleton.h>
#include <util/generic/utility.h>
#include <util/system/dynlib.h>
#include <util/string/builder.h>
#include <library/cpp/iterator/zip.h>
#define LOADSYM(name, type) {name = (TId<type>::R*)L->SymOptional(#name);}
const TInfinibandSymbols* IBSym() {
struct TSymbols: TInfinibandSymbols {
TSymbols() {
auto lib = std::make_unique<TDynamicLibrary>();
TVector<TString> catchedExceptions;
TVector<TString> paths = {"/usr/lib/libibverbs.so", "libibverbs.so", "libibverbs.so.1"};
for (auto path : paths) {
try {
lib->Open(path.c_str());
L.Reset(lib.release());
DOVERBS(LOADSYM)
return;
} catch (std::exception& ex) {
catchedExceptions.emplace_back(ex.what());
}
}
Y_ABORT_UNLESS(paths.size() == catchedExceptions.size());
TStringBuilder builder;
builder << "Cannot open any shared library. Reasons:\n";
for (const auto& [reason, path] : Zip(catchedExceptions, paths)) {
builder << "Path: " << path << " Reason: " << reason << "\n";
}
ythrow yexception() << builder;
}
THolder<TDynamicLibrary> L;
};
return SingletonWithPriority<TSymbols, 100>();
}
const TRdmaSymbols* RDSym() {
struct TSymbols: TRdmaSymbols {
TSymbols() {
L.Reset(new TDynamicLibrary("/usr/lib/librdmacm.so"));
DORDMA(LOADSYM)
}
THolder<TDynamicLibrary> L;
};
return SingletonWithPriority<TSymbols, 100>();
}
const TMlx5Symbols* M5Sym() {
struct TSymbols: TMlx5Symbols {
TSymbols() {
L.Reset(new TDynamicLibrary("/usr/lib/libmlx5.so"));
DOMLX5(LOADSYM)
}
THolder<TDynamicLibrary> L;
};
return SingletonWithPriority<TSymbols, 100>();
}
#undef LOADSYM
|