本文整理汇总了C++中shl_load函数的典型用法代码示例。如果您正苦于以下问题:C++ shl_load函数的具体用法?C++ shl_load怎么用?C++ shl_load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shl_load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vm_open
/* A function called through the vtable to open a module with this
loader. Returns an opaque representation of the newly opened
module for processing with this loader's other vtable functions. */
static lt_module
vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
lt_dladvise LT__UNUSED advise)
{
static shl_t self = (shl_t) 0;
lt_module module = shl_load (filename, LT_BIND_FLAGS, 0L);
/* Since searching for a symbol against a NULL module handle will also
look in everything else that was already loaded and exported with
the -E compiler flag, we always cache a handle saved before any
modules are loaded. */
if (!self)
{
void *address;
shl_findsym (&self, "main", TYPE_UNDEFINED, &address);
}
if (!filename)
{
module = self;
}
else
{
module = shl_load (filename, LT_BIND_FLAGS, 0L);
if (!module)
{
LT__SETERROR (CANNOT_OPEN);
}
}
return module;
}
示例2: dl_load
static int dl_load(DSO *dso, const char *filename)
{
shl_t ptr;
char translated[DSO_MAX_TRANSLATED_SIZE];
int len;
/* The same comment as in dlfcn_load applies here. bleurgh. */
len = strlen(filename) + strlen(extension);
if((dso->flags & DSO_FLAG_NAME_TRANSLATION) &&
(len + 3 < DSO_MAX_TRANSLATED_SIZE) &&
(strstr(filename, "/") == NULL))
{
sprintf(translated, "lib%s%s", filename, extension);
ptr = shl_load(translated, BIND_IMMEDIATE, NULL);
}
else
ptr = shl_load(filename, BIND_IMMEDIATE, NULL);
if(ptr == NULL)
{
DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED);
return(0);
}
if(!sk_push(dso->meth_data, (char *)ptr))
{
DSOerr(DSO_F_DL_LOAD,DSO_R_STACK_ERROR);
shl_unload(ptr);
return(0);
}
return(1);
}
示例3: TclpDlopen
int
TclpDlopen(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Obj *pathPtr, /* Name of the file containing the desired
* code (UTF-8). */
Tcl_LoadHandle *loadHandle, /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr)
/* Filled with address of Tcl_FSUnloadFileProc
* function which should be used for this
* file. */
{
shl_t handle;
CONST char *native;
char *fileName = Tcl_GetString(pathPtr);
/*
* The flags below used to be BIND_IMMEDIATE; they were changed at the
* suggestion of Wolfgang Kechel ([email protected]): "This enables
* verbosity for missing symbols when loading a shared lib and allows to
* load libtk8.0.sl into tclsh8.0 without problems. In general, this
* delays resolving symbols until they are actually needed. Shared libs
* do no longer need all libraries linked in when they are build."
*/
/*
* First try the full path the user gave us. This is particularly
* important if the cwd is inside a vfs, and we are trying to load using a
* relative path.
*/
native = Tcl_FSGetNativePath(pathPtr);
handle = shl_load(native, BIND_DEFERRED|BIND_VERBOSE, 0L);
if (handle == NULL) {
/*
* Let the OS loader examine the binary search path for whatever
* string the user gave us which hopefully refers to a file on the
* binary path.
*/
Tcl_DString ds;
native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
handle = shl_load(native, BIND_DEFERRED|BIND_VERBOSE|DYNAMIC_PATH, 0L);
Tcl_DStringFree(&ds);
}
if (handle == NULL) {
Tcl_AppendResult(interp, "couldn't load file \"", fileName, "\": ",
Tcl_PosixError(interp), (char *) NULL);
return TCL_ERROR;
}
*loadHandle = (Tcl_LoadHandle) handle;
*unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
示例4: main
int main ()
{
shl_t solib_handle;
int dummy;
int status;
int (*solib_main) (int);
/* Load a shlib, with immediate binding of all symbols.
Note that the pathname of the loaded shlib is assumed to be relative
to the testsuite directory (from whence the tested GDB is run), not
from dot/.
*/
dummy = 1; /* Put some code between shl_ calls... */
solib_handle = shl_load ("gdb.base/solib1.sl", BIND_IMMEDIATE, 0);
/* Find a function within the shlib, and call it. */
status = shl_findsym (&solib_handle,
"solib_main",
TYPE_PROCEDURE,
(long *) &solib_main);
status = (*solib_main) (dummy);
/* Unload the shlib. */
status = shl_unload (solib_handle);
/* Load a different shlib, with deferred binding of all symbols. */
dummy = 2;
solib_handle = shl_load ("gdb.base/solib2.sl", BIND_DEFERRED, 0);
/* Find a function within the shlib, and call it. */
status = shl_findsym (&solib_handle,
"solib_main",
TYPE_PROCEDURE,
(long *) &solib_main);
status = (*solib_main) (dummy);
/* Unload the shlib. */
status = shl_unload (solib_handle);
/* Reload the first shlib again, with deferred symbol binding this time. */
dummy = 3;
solib_handle = shl_load ("gdb.base/solib1.sl", BIND_IMMEDIATE, 0);
/* Unload it without trying to find any symbols in it. */
status = shl_unload (solib_handle);
/* All done. */
dummy = -1;
return 0;
}
示例5: wxASSERT_MSG
/* static */
wxDllType wxDynamicLibrary::RawLoad(const wxString& libname, int flags)
{
wxASSERT_MSG( !(flags & wxDL_NOW) || !(flags & wxDL_LAZY),
wxT("wxDL_LAZY and wxDL_NOW are mutually exclusive.") );
#ifdef USE_POSIX_DL_FUNCS
// we need to use either RTLD_NOW or RTLD_LAZY because if we call dlopen()
// with flags == 0 recent versions of glibc just fail the call, so use
// RTLD_NOW even if wxDL_NOW was not specified
int rtldFlags = flags & wxDL_LAZY ? RTLD_LAZY : RTLD_NOW;
if ( flags & wxDL_GLOBAL )
rtldFlags |= RTLD_GLOBAL;
return dlopen(libname.fn_str(), rtldFlags);
#else // !USE_POSIX_DL_FUNCS
int shlFlags = 0;
if ( flags & wxDL_LAZY )
{
shlFlags |= BIND_DEFERRED;
}
else if ( flags & wxDL_NOW )
{
shlFlags |= BIND_IMMEDIATE;
}
return shl_load(libname.fn_str(), shlFlags, 0);
#endif // USE_POSIX_DL_FUNCS/!USE_POSIX_DL_FUNCS
}
示例6: open_library
static XModuleType
open_library (void)
{
char *library = libraryName;
char *dot;
XModuleType module;
for (;;)
{
#if defined(hpux)
module = shl_load(library, BIND_DEFERRED, 0L);
#else
#ifdef _MSC_VER
module = LoadLibrary(library);
#else
module = dlopen(library, RTLD_LAZY);
#endif
#endif
if (module)
return module;
dot = strrchr (library, '.');
if (!dot)
break;
*dot = '\0';
}
return NULL;
}
示例7: UnloadPlug
GError GPlugLoader::LoadFilePlug(const GChar8 *FullLibraryName) {
GPlugHandle handle = NULL;
// we don't wanna a null filename
if (!FullLibraryName)
return G_INVALID_PARAMETER;
// unplug current library
UnloadPlug();
#if defined(G_OS_WIN) && !defined(__CYGWIN__)
handle = LoadLibraryA(FullLibraryName);
#elif defined(G_OS_HPUX)
// BIND_FIRST is necessary for some reason
handle = shl_load(FullLibraryName, BIND_DEFERRED | BIND_FIRST | BIND_VERBOSE, 0);
// other Unix (it works also on MacOSX and Tiger)
#else
handle = dlopen(FullLibraryName, RTLD_LAZY | RTLD_GLOBAL);
// dlopen will not work with files in the current directory unless
// they are prefaced with './' (DB - Nov 5, 2003).
// So we must check if file was expressed as a local file (without path)
GString fPath = StrUtils::ExtractFilePath(FullLibraryName);
if ((!handle) && (fPath.length() <= 0)) {
GString localLibraryName = GString("./") + GString(FullLibraryName);
handle = dlopen(StrUtils::ToAscii(localLibraryName), RTLD_LAZY | RTLD_GLOBAL);
}
#endif
if (!handle)
return G_INVALID_FORMAT;
gPlugHandle = handle;
return G_NO_ERROR;
}
示例8: shl_load
void *dlopen(const char *fname, int mode)
{
shl_t handle;
LibEntry entry = NULL;
dlerrno = 0;
if (fname == NULL)
handle = PROG_HANDLE;
else {
handle = shl_load(fname, mode | BIND_VERBOSE, 0L);
if (handle != NULL) {
if ((entry = find_lib_entry(handle)) == NULL) {
if ((entry = new_lib_entry(handle)) == NULL) {
shl_unload(handle);
handle = NULL;
}
}
else
increment_lib_entry_count(entry);
}
if (handle == NULL) {
dlerrno = 1;
sprintf(errbuf, "can't open %s", fname);
}
}
#ifdef DEBUG
printf("opening library %s, handle = %x, count = %d\n",
fname, handle, entry ? lib_entry_count(entry) : -1);
if (dlerrno) printf("%s\n", dlerror());
#endif
return (void *) handle;
}
示例9: _PyImport_GetDynLoadFunc
dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
dl_funcptr p;
shl_t lib;
int flags;
char funcname[258];
flags = BIND_FIRST | BIND_DEFERRED;
if (Py_VerboseFlag) {
flags = DYNAMIC_PATH | BIND_FIRST | BIND_IMMEDIATE |
BIND_NONFATAL | BIND_VERBOSE;
printf("shl_load %s\n",pathname);
}
lib = shl_load(pathname, flags, 0);
/* XXX Chuck Blake once wrote that 0 should be BIND_NOSTART? */
if (lib == NULL) {
char buf[256];
if (Py_VerboseFlag)
perror(pathname);
sprintf(buf, "Failed to load %.200s", pathname);
PyErr_SetString(PyExc_ImportError, buf);
return NULL;
}
sprintf(funcname, FUNCNAME_PATTERN, shortname);
if (Py_VerboseFlag)
printf("shl_findsym %s\n", funcname);
shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p);
if (p == NULL && Py_VerboseFlag)
perror(funcname);
return p;
}
示例10: defined
//==========================================================================================
static DLL *dll_load( const char *name )
{
#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)
return (DLL *) LoadLibrary( name );
#else // UNIX
char dllname[512];
strcpy(dllname, name);
#if defined MACOSX
strcat(dllname, ".dylib");
return (DLL *) dlopen(dllname, RTLD_NOW);
#elif defined LINUX || defined SUN
strcat( dllname, ".so" );
return (DLL *) dlopen(dllname, RTLD_NOW);
#elif defined HP || defined HPUX
strcat(dllname, ".sl");
return shl_load(dllname, BIND_DEFERRED|DYNAMIC_PATH, 0L);
#else
strcat( dllname, ".so" );
return (DLL *) dlopen(dllname, RTLD_NOW);
#endif
#endif
}
示例11: open_object
/* We reference count dlopen() and dlclose() of modules; unfortunately,
* since XCloseIM, XCloseOM, XlcClose aren't wrapped, but directly
* call the close method of the object, we leak a reference count every
* time we open then close a module. Fixing this would require
* either creating proxy objects or hooks for close_im/close_om
* in XLCd
*/
static Bool
open_object(
XI18NObjectsList object,
char *lc_dir)
{
char *path;
if (object->refcount == 0) {
path = __lc_path(object->dl_name, lc_dir);
if (!path)
return False;
#if defined(hpux)
object->dl_module = shl_load(path, BIND_DEFERRED, 0L);
#else
object->dl_module = dlopen(path, RTLD_LAZY);
#endif
Xfree(path);
if (!object->dl_module)
return False;
}
object->refcount++;
return True;
}
示例12: pg_dlopen
void *
pg_dlopen(char *filename)
{
shl_t handle = shl_load(filename, BIND_DEFERRED, 0);
return((void *) handle);
}
示例13: shl_load
static void *dlopen(const char *libname, int how)
{
shl_t lib;
lib = shl_load(libname, how, 0L);
return (void *)lib;
}
示例14: lock
void SharedLibraryImpl::loadImpl(const std::string& path)
{
FastMutex::ScopedLock lock(_mutex);
if (_handle) throw LibraryAlreadyLoadedException(path);
_handle = shl_load(path.c_str(), BIND_DEFERRED, 0);
if (!_handle) throw LibraryLoadException(path);
_path = path;
}
示例15: fi
bool QLibraryPrivate::load_sys()
{
if (QLibrary::isLibrary(fileName))
pHnd = (void*)shl_load(QFile::encodeName(fileName), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0);
if (pluginState != IsAPlugin) {
if (!pHnd)
pHnd = (void*)shl_load(QFile::encodeName(fileName + ".sl"), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0);
if (!pHnd) {
QFileInfo fi(fileName);
pHnd = (void*)shl_load(QFile::encodeName(fi.path() + "/lib" + fi.fileName() + ".sl"),
BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0);
}
}
#if defined(QT_DEBUG_COMPONENT)
if (!pHnd)
qWarning("QLibrary: Cannot load %s", QFile::encodeName(fileName).constData());
#endif
return pHnd != 0;
}