Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 71.4% 5 / 0 / 7
Functions: 100.0% 1 / 0 / 1
Branches: 50.0% 1 / 0 / 2

OMCompiler/SimulationRuntime/cpp/Core/Utils/extension/impl/library_impl.hpp
Line Branch Exec Source
1 /*
2 * Boost.Extension / libraries management:
3 * low-level platform specific dynamic library management
4 *
5 * (C) Copyright Jeremy Pack 2007
6 * Distributed under the Boost Software License, Version 1.0. (See
7 * accompanying file LICENSE_1_0.txt or copy at
8 * http://www.boost.org/LICENSE_1_0.txt)
9 *
10 * See http://www.boost.org/ for latest version.
11 */
12
13
14 #ifndef BOOST_EXTENSION_LIBRARY_IMPL_HPP
15 #define BOOST_EXTENSION_LIBRARY_IMPL_HPP
16
17 #include <iostream>
18
19
20 #include <cstring>
21
22 #if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) \
23 && !defined(BOOST_DISABLE_WIN32) && (!defined(__GNUC__) || defined(__MINGW32__))
24
25 #ifndef _WIN32_WINNT
26 #define _WIN32_WINNT 0x0501
27 #endif
28 #ifndef BOOST_EXTENSION_NO_LEAN_WIN32
29 #ifndef WIN32_LEAN_AND_MEAN
30 #define WIN32_LEAN_AND_MEAN
31 #endif
32 #endif
33
34 #include <windows.h>
35 namespace boost {
36 namespace extensions {
37 namespace impl {
38 typedef HMODULE library_handle;
39 typedef FARPROC generic_function_ptr;
40 inline library_handle load_shared_library(const char* library_name) {
41 return LoadLibraryA(library_name);
42 }
43 inline generic_function_ptr get_function(library_handle handle,
44 const char* function_name) {
45 return GetProcAddress(handle, function_name);
46 }
47 inline bool close_shared_library(library_handle handle) {
48 return FreeLibrary(handle) != 0;
49 }
50 } // namespace impl
51 } // namespace extensions
52 } // namespace boost
53
54 # pragma comment(lib, "kernel32.lib")
55 #else
56 #include <dlfcn.h>
57 namespace boost {
58 namespace extensions {
59 namespace impl {
60 typedef void * library_handle;
61 typedef void * generic_function_ptr;
62 558 inline library_handle load_shared_library(const char* library_name) {
63 558 library_handle handle = dlopen(library_name, RTLD_LAZY);
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558 times.
558 if (!handle) {
65 ✗ std::cout << "Cannot open library: " << dlerror() << std::endl;
66 ✗ return NULL;
67 }
68 return handle;
69
70 }
71 inline generic_function_ptr get_function(library_handle handle,
72 const char* function_name) {
73 558 return dlsym(handle, function_name);
74 }
75 inline bool close_shared_library(library_handle handle) {
76 413 return dlclose(handle)==0;
77 }
78 } // namespace impl
79 } // namespace extensions
80 } // namespace boost
81
82 #endif
83
84 #endif
85