diff options
author | Brad King <brad.king@kitware.com> | 2013-02-01 14:28:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-02-01 14:28:50 (GMT) |
commit | 588d705cb1ec1d37f10711eb9c0a9e2398805f47 (patch) | |
tree | 71691c5a413f331682a6812f7f5a28a3430e1551 /Source/kwsys/DynamicLoader.cxx | |
parent | 163812468054601c95ac894703a6299d3b324e22 (diff) | |
parent | 23ae48412093e4acbd5270536aace226d5869679 (diff) | |
download | CMake-588d705cb1ec1d37f10711eb9c0a9e2398805f47.zip CMake-588d705cb1ec1d37f10711eb9c0a9e2398805f47.tar.gz CMake-588d705cb1ec1d37f10711eb9c0a9e2398805f47.tar.bz2 |
Merge branch 'upstream-kwsys' into update-kwsys
Diffstat (limited to 'Source/kwsys/DynamicLoader.cxx')
-rw-r--r-- | Source/kwsys/DynamicLoader.cxx | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index c4ee095..fd83752 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -428,6 +428,58 @@ const char* DynamicLoader::LastError() } // namespace KWSYS_NAMESPACE #endif +#ifdef __MINT__ +#define DYNAMICLOADER_DEFINED 1 +#define _GNU_SOURCE /* for program_invocation_name */ +#include <string.h> +#include <malloc.h> +#include <errno.h> +#include <dld.h> + +namespace KWSYS_NAMESPACE +{ + +//---------------------------------------------------------------------------- +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +{ + char *name = (char *)calloc(1, strlen(libname) + 1); + dld_init(program_invocation_name); + strncpy(name, libname, strlen(libname)); + dld_link(libname); + return (void *)name; +} + +//---------------------------------------------------------------------------- +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + dld_unlink_by_file((char *)lib, 0); + free(lib); + return 0; +} + +//---------------------------------------------------------------------------- +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const char* sym) +{ + // Hack to cast pointer-to-data to pointer-to-function. + union + { + void* pvoid; + DynamicLoader::SymbolPointer psym; + } result; + result.pvoid = dld_get_symbol(sym); + return result.psym; +} + +//---------------------------------------------------------------------------- +const char* DynamicLoader::LastError() +{ + return dld_strerror(dld_errno); +} + +} // namespace KWSYS_NAMESPACE +#endif + // --------------------------------------------------------------- // 6. Implementation for default UNIX machines. // if nothing has been defined then use this |