| 3457 | } |
| 3458 | |
| 3459 | void* loadLibrary(const char* lib_path) { |
| 3460 | #if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__FreeBSD__) |
| 3461 | #error Port me! |
| 3462 | #endif |
| 3463 | |
| 3464 | void* dlobj = nullptr; |
| 3465 | |
| 3466 | #if defined(__unixish__) |
| 3467 | dlobj = dlopen(lib_path, |
| 3468 | RTLD_LAZY | RTLD_LOCAL |
| 3469 | #ifdef USE_SANITIZER // Keep alive dlopen()-ed libs for symbolized XSAN backtrace |
| 3470 | | RTLD_NODELETE |
| 3471 | #endif |
| 3472 | ); |
| 3473 | if (dlobj == nullptr) { |
| 3474 | TraceEvent(SevWarn, "LoadLibraryFailed").detail("Library", lib_path).detail("Error", dlerror()); |
| 3475 | } |
| 3476 | #else |
| 3477 | dlobj = LoadLibrary(lib_path); |
| 3478 | if (dlobj == nullptr) { |
| 3479 | TraceEvent(SevWarn, "LoadLibraryFailed").detail("Library", lib_path).GetLastError(); |
| 3480 | } |
| 3481 | #endif |
| 3482 | |
| 3483 | return dlobj; |
| 3484 | } |
| 3485 | |
| 3486 | void* loadFunction(void* lib, const char* func_name) { |
| 3487 | void* dlfcn = nullptr; |
no test coverage detected