1 #ifndef LLDB_TEST_DYLIB_H
2 #define LLDB_TEST_DYLIB_H
9 #define dylib_get_symbol(handle, name) GetProcAddress((HMODULE)handle, name)
10 #define dylib_close(handle) (!FreeLibrary((HMODULE)handle))
14 #define dylib_get_symbol(handle, name) dlsym(handle, name)
15 #define dylib_close(handle) dlclose(handle)
19 inline void *dylib_open(const char *name
) {
29 #elif defined(__APPLE__)
35 snprintf(fullname
, sizeof(fullname
), "%s%s%s", dylib_prefix
, name
, dylib_suffix
);
37 return LoadLibraryA(fullname
);
39 return dlopen(fullname
, RTLD_NOW
);
43 inline const char *dylib_last_error() {
47 DWORD err
= GetLastError();
49 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
50 NULL
, err
, MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), (char *)&msg
, 0, NULL
);