| 1 | /* Distributed under the OSI-approved BSD 3-Clause License. |
| 2 | See https://cmake.org/licensing#kwsys for details. */ |
| 3 | #ifndef DynamicLoader_hxx |
| 4 | #define DynamicLoader_hxx |
| 5 | |
| 6 | #include <string> |
| 7 | |
| 8 | #if defined(__hpux) |
| 9 | # include <dl.h> |
| 10 | #elif defined(_WIN32) && !defined(__CYGWIN__) |
| 11 | # include <windows.h> |
| 12 | #elif defined(__APPLE__) |
| 13 | # include <AvailabilityMacros.h> |
| 14 | # if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 |
| 15 | # include <mach-o/dyld.h> |
| 16 | # endif |
| 17 | #elif defined(__BEOS__) |
| 18 | # include <be/kernel/image.h> |
| 19 | #endif |
| 20 | |
| 21 | class DynamicLoader |
| 22 | { |
| 23 | public: |
| 24 | #if defined(__hpux) |
| 25 | typedef shl_t LibraryHandle; |
| 26 | #elif defined(_WIN32) && !defined(__CYGWIN__) |
| 27 | typedef HMODULE LibraryHandle; |
| 28 | #elif defined(__APPLE__) |
| 29 | # if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 |
| 30 | typedef NSModule LibraryHandle; |
| 31 | # else |
| 32 | typedef void* LibraryHandle; |
| 33 | # endif |
| 34 | #elif defined(__BEOS__) |
| 35 | typedef image_id LibraryHandle; |
| 36 | #else // POSIX |
| 37 | typedef void* LibraryHandle; |
| 38 | #endif |
| 39 | |
| 40 | typedef void (*SymbolPointer)(); |
| 41 | |
| 42 | static LibraryHandle OpenLibrary(std::string const&); |
| 43 | |
| 44 | static int CloseLibrary(LibraryHandle); |
| 45 | |
| 46 | static SymbolPointer GetSymbolAddress(LibraryHandle, std::string const&); |
| 47 | }; |
| 48 | |
| 49 | #endif |