27
27
28
28
#if defined(__linux__) || defined(_WIN32) || defined(_WIN64)
29
29
30
- #ifdef __linux__
30
+ #ifdef __linux__
31
31
32
- #include < dlfcn.h>
32
+ #include < dlfcn.h>
33
33
34
- #elif defined(_WIN32) || defined(_WIN64)
34
+ #elif defined(_WIN32) || defined(_WIN64)
35
35
36
- #define NOMINMAX
37
- #include < windows.h>
36
+ #define NOMINMAX
37
+ #include < windows.h>
38
38
39
- #endif // __linux__
39
+ #endif // __linux__
40
40
41
41
#include < cstdint>
42
42
@@ -46,51 +46,48 @@ namespace dpctl
46
46
class DynamicLibHelper final
47
47
{
48
48
public:
49
- DynamicLibHelper () = delete ;
49
+ DynamicLibHelper () = delete ;
50
50
DynamicLibHelper (const DynamicLibHelper &) = delete ;
51
- DynamicLibHelper (const char * libName, int flag)
51
+ DynamicLibHelper (const char *libName, int flag)
52
52
{
53
53
54
- #ifdef __linux__
54
+ #ifdef __linux__
55
55
_handle = dlopen (libName, flag);
56
- #elif defined(_WIN32) || defined(_WIN64)
56
+ #elif defined(_WIN32) || defined(_WIN64)
57
57
_handle = LoadLibraryA (libName);
58
- #endif
58
+ #endif
59
59
}
60
60
61
61
~DynamicLibHelper ()
62
62
{
63
- #ifdef __linux__
63
+ #ifdef __linux__
64
64
dlclose (_handle);
65
- #elif defined(_WIN32) || defined(_WIN64)
65
+ #elif defined(_WIN32) || defined(_WIN64)
66
66
FreeLibrary ((HMODULE)_handle);
67
- #endif
67
+ #endif
68
68
};
69
69
70
- template <typename T>
71
- T getSymbol (const char * symName)
70
+ template <typename T> T getSymbol (const char *symName)
72
71
{
73
- #ifdef __linux__
74
- void * sym = dlsym (_handle, symName);
75
- char * error = dlerror ();
72
+ #ifdef __linux__
73
+ void *sym = dlsym (_handle, symName);
74
+ char *error = dlerror ();
76
75
77
- if (NULL != error)
78
- {
76
+ if (NULL != error) {
79
77
return nullptr ;
80
78
}
81
- #elif defined(_WIN32) || defined(_WIN64)
82
- void * sym = (void *)GetProcAddress ((HMODULE)_handle, symName);
79
+ #elif defined(_WIN32) || defined(_WIN64)
80
+ void *sym = (void *)GetProcAddress ((HMODULE)_handle, symName);
83
81
84
- if (NULL == sym)
85
- {
82
+ if (NULL == sym) {
86
83
return nullptr ;
87
84
}
88
- #endif
85
+ #endif
89
86
90
87
return (T)sym;
91
88
}
92
89
93
- bool opened () const
90
+ bool opened () const
94
91
{
95
92
if (!_handle)
96
93
return false ;
@@ -99,7 +96,7 @@ class DynamicLibHelper final
99
96
}
100
97
101
98
private:
102
- void * _handle = nullptr ;
99
+ void *_handle = nullptr ;
103
100
};
104
101
105
102
} // namespace dpctl
0 commit comments