Use separate 32-bit second and nanosecond atomics for the clock
[openal-soft.git] / common / dynload.cpp
blob333a9435ee0722c4be41cdd502682da110260bea
2 #include "config.h"
4 #include "dynload.h"
6 #ifdef _WIN32
7 #define WIN32_LEAN_AND_MEAN
8 #include <windows.h>
10 #include "strutils.h"
12 void *LoadLib(const char *name)
14 std::wstring wname{utf8_to_wstr(name)};
15 return LoadLibraryW(wname.c_str());
17 void CloseLib(void *handle)
18 { FreeLibrary(static_cast<HMODULE>(handle)); }
19 void *GetSymbol(void *handle, const char *name)
20 { return reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle), name)); }
22 #elif defined(HAVE_DLFCN_H)
24 #include <dlfcn.h>
26 void *LoadLib(const char *name)
28 dlerror();
29 void *handle{dlopen(name, RTLD_NOW)};
30 const char *err{dlerror()};
31 if(err) handle = nullptr;
32 return handle;
34 void CloseLib(void *handle)
35 { dlclose(handle); }
36 void *GetSymbol(void *handle, const char *name)
38 dlerror();
39 void *sym{dlsym(handle, name)};
40 const char *err{dlerror()};
41 if(err) sym = nullptr;
42 return sym;
44 #endif