clSPARSE  v0.10.0.0
a software library containing Sparse functions written in OpenCL
Macros | Functions
loadDynamicLibrary.hpp File Reference

Abstracts platform differences to loading dynamic libraries at runtime. More...

#include <string>
#include <dlfcn.h>

Go to the source code of this file.

Functions

void * LoadSharedLibrary (const std::string &libPrefix, std::string libraryName, bool quiet)
 Create a platform specific handle to a loaded dynamic library. More...
 
int FreeSharedLibrary (void *&libHandle)
 Release the handle to the dynamic library. More...
 
void * LoadFunctionAddr (void *libHandle, std::string funcName)
 Query for function pointer in library. More...
 

Detailed Description

Abstracts platform differences to loading dynamic libraries at runtime.

The entire implementation is written in the header file, and provides functions to load, unload and create a function address pointer to an exported library function

Function Documentation

int FreeSharedLibrary ( void *&  libHandle)
inline

Release the handle to the dynamic library.

Calls platform specific code to release the handle to a dynamic library

Parameters
[in,out]libHandlePlatform handle to the dynamic library, NULL'd on output
Returns
If the function succeeds, return value is nonzero. If the function fails, return value is zero.
void* LoadFunctionAddr ( void *  libHandle,
std::string  funcName 
)
inline

Query for function pointer in library.

This takes a shared module handle returned from LoadSharedLibrary, and a text string of a symbol to load from the module, and returns a pointer to that symbol. If the symbol is not found, NULL is returned. If the module handle is NULL, NULL is returned.

Parameters
[in]libHandlePlatform handle to the dynamic library
[in]funcNameString representing the function name of interest
Returns
Function pointer (or NULL) to the function of interest in the dynamic library
void* LoadSharedLibrary ( const std::string &  libPrefix,
std::string  libraryName,
bool  quiet 
)
inline

Create a platform specific handle to a loaded dynamic library.

Calls platform specific code to load a dynamic library and create a handle for it

Parameters
[in]libPrefixPrefix to be appended on linux style OS's
[in]libraryNameName of the library of interest
[in]quietPrint error information to the CONSOLE if true
Returns
Platform specific library handle