forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule_loading_unix.cpp
More file actions
37 lines (29 loc) · 1004 Bytes
/
module_loading_unix.cpp
File metadata and controls
37 lines (29 loc) · 1004 Bytes
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
/*******************************************************
* Copyright (c) 2018, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <common/defines.hpp>
#include <common/module_loading.hpp>
#include <dlfcn.h>
#include <string>
using std::string;
namespace common {
void* getFunctionPointer(LibHandle handle, const char* symbolName) {
return dlsym(handle, symbolName);
}
LibHandle loadLibrary(const char* library_name) {
return dlopen(library_name, RTLD_LAZY);
}
void unloadLibrary(LibHandle handle) { dlclose(handle); }
string getErrorMessage() {
char* errMsg = dlerror();
if (errMsg) { return string(errMsg); }
// constructing std::basic_string from NULL/0 address is
// invalid and has undefined behavior
return string("No Error");
}
} // namespace common