λ61
Loading...
Searching...
No Matches
loadSharedLibrary.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Tetex7
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18//
19// Created by tete on 09/15/2025.
20//
21
22
46
47#ifndef L61_RS_LOADSHAREDLIBRARY_H
48#define L61_RS_LOADSHAREDLIBRARY_H
49
51#ifdef __cplusplus
52# define L61_ROSETTA_CAST_SYMBOL(type, symbol) reinterpret_cast<type>(symbol)
53#include <stdexcept>
54#include <type_traits>
55#include <concepts>
56
57namespace l61::RosettaSystem
58{
59 template<typename T> requires std::is_function_v<T> && (!std::is_pointer_v<T>)
60 std::add_pointer_t<T> shared_callable_symbol_cast(l61_rosetta_SharedLibrary_symbol_t symbol)
61 {
62 if (symbol == nullptr)
63 {
64 throw std::runtime_error("Symbol is null");
65 }
66 return L61_ROSETTA_CAST_SYMBOL(std::add_pointer_t<T>, symbol);
67 }
68}
69
70#else
71# define L61_ROSETTA_CAST_SYMBOL(type, symbol) ((type)(symbol))
72#endif
73
74
75#ifdef __cplusplus
76extern "C" {
77#endif
84
93
100
110
111#ifdef __cplusplus
112}
113#endif
114#endif //L61_RS_LOADSHAREDLIBRARY_H
void * l61_rosetta_SharedLibrary_handle_t
Definition loadSharedLibraryTypes.h:29
void(* l61_rosetta_SharedLibrary_symbol_t)(void)
Definition loadSharedLibraryTypes.h:32
l61_rosetta_SharedLibrary_symbol_t l61_rosetta_getSharedLibrarySymbol(l61_rosetta_SharedLibrary_handle_t handle, const char *symbol)
Definition loadSharedLibrary.c:42
#define L61_ROSETTA_CAST_SYMBOL(type, symbol)
Definition loadSharedLibrary.h:71
int l61_rosetta_unloadSharedLibrary(l61_rosetta_SharedLibrary_handle_t handle)
Definition loadSharedLibrary.c:52
l61_rosetta_SharedLibrary_handle_t l61_rosetta_loadSharedLibrary(const char *file)
Definition loadSharedLibrary.c:31
const char * l61_rosetta_getSharedLibraryLoaderError()
Definition loadSharedLibrary.c:62
Definition EnvironmentVariable.hpp:29