SNode.C
Loading...
Searching...
No Matches
DynamicLoader.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef CORE_DYNAMICLOADER_H
21#define CORE_DYNAMICLOADER_H
22
23#ifndef DOXYGEN_SHOULD_SKIP_THIS
24
25#include "core/system/dlfcn.h"
26
27#include <list>
28#include <map>
29#include <string>
30
31#endif /* DOXYGEN_SHOULD_SKIP_THIS */
32
33namespace core {
34
36 private:
37 struct Library {
38 std::string fileName;
39 void* handle = nullptr;
40 };
41
42 public:
43 DynamicLoader() = delete;
44 ~DynamicLoader() = delete;
45
46#define dlOpen(libFile) dlRegisterHandle(core::system::dlopen((libFile).c_str(), RTLD_LOCAL | RTLD_LAZY), libFile)
47
48 static void* dlRegisterHandle(void* handle, const std::string& libFile);
49 static void dlCloseDelayed(void* handle);
50 static int dlClose(void* handle);
51 static void* dlSym(void* handle, const std::string& symbol);
52 static char* dlError();
53
54 private:
55 static int dlClose(const Library& library);
56
57 static int realExecDlClose(const Library& library);
58 static void execDlCloseDeleyed();
59 static void execDlCloseAll();
60
62 static std::list<void*> closeHandles;
63
64 friend class EventLoop;
65 friend class EventMultiplexer;
66 };
67
68} // namespace core
69
70#endif // CORE_DYNAMICLOADER_H
static char * dlError()
static int realExecDlClose(const Library &library)
static std::list< void * > closeHandles
static int dlClose(void *handle)
static std::map< void *, Library > dlOpenedLibraries
static void execDlCloseDeleyed()
static int dlClose(const Library &library)
static void execDlCloseAll()
static void dlCloseDelayed(void *handle)