本文整理汇总了C++中shl_unload函数的典型用法代码示例。如果您正苦于以下问题:C++ shl_unload函数的具体用法?C++ shl_unload怎么用?C++ shl_unload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shl_unload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: ppl_dso_unload
ppl_status_t
ppl_dso_unload (ppl_dso_handle_t * thedso)
{
ppl_dso_handle_t *dso = thedso;
if (dso->handle == NULL)
{
osip_free (dso);
return PPL_SUCCESS;
}
#if defined(DSO_USE_SHL)
shl_unload ((shl_t) dso->handle);
#elif defined(DSO_USE_DYLD)
NSUnLinkModule (dso->handle, FALSE);
#elif defined(DSO_USE_DLFCN)
if (dlclose (dso->handle) != 0)
{
osip_free (dso);
return PPL_EINIT;
}
#endif
dso->handle = NULL;
osip_free (dso);
return PPL_SUCCESS;
}
示例3: dlclose
int
dlclose(dll_handle h)
{
shl_t hp = *((shl_t *)h);
if (hp != NULL) free(hp);
return shl_unload(h);
}
示例4: 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);
}
示例5: 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;
}
示例6: dlclose
int dlclose(void *handle)
{
LibEntry entry;
#ifdef DEBUG
entry = find_lib_entry(handle);
printf("closing library handle = %x, count = %d\n",
handle, entry ? lib_entry_count(entry) : -1);
#endif
dlerrno = 0;
if ((shl_t) handle == PROG_HANDLE)
return 0; /* ignore attempts to close main program */
else {
if ((entry = find_lib_entry((shl_t) handle)) != NULL) {
decrement_lib_entry_count(entry);
if (lib_entry_count(entry) > 0)
return 0;
else {
/* unload once reference count reaches zero */
free_lib_entry(entry);
if (shl_unload((shl_t) handle) == 0)
return 0;
}
}
/* if you get to here, an error has occurred */
dlerrno = 1;
sprintf(errbuf, "attempt to close library failed");
#ifdef DEBUG
printf("%s\n", dlerror());
#endif
return -1;
}
}
示例7: unload_sys
bool QLibraryPrivate::unload_sys()
{
if (shl_unload((shl_t)pHnd)) {
qWarning("QLibrary: Cannot unload %s", QFile::encodeName(fileName).constData());
return false;
}
return true;
}
示例8: unloadSharedObject
void
unloadSharedObject (void *object) {
#ifdef HAVE_SHL_LOAD
if (shl_unload(object) == -1)
logMessage(LOG_ERR, "Shared library unload error: %s",
strerror(errno));
#endif /* HAVE_SHL_LOAD */
}
示例9: dClose
static void dClose(void * handle)
{
#ifdef __hpux
shl_unload(handle);
#else
dlclose(handle);
#endif
}
示例10: sane_exit
void
sane_exit (void)
{
struct backend *be, *next;
struct alias *alias;
DBG(2, "sane_exit: exiting\n");
for (be = first_backend; be; be = next)
{
next = be->next;
if (be->loaded)
{
DBG(3, "sane_exit: calling backend `%s's exit function\n", be->name);
(*be->op[OP_EXIT]) ();
#ifdef HAVE_DLL
#ifdef HAVE_DLOPEN
if (be->handle)
dlclose (be->handle);
#elif defined(HAVE_SHL_LOAD)
if (be->handle)
shl_unload(be->handle);
#else
# error "Tried to compile unsupported DLL."
#endif /* HAVE_DLOPEN */
#endif /* HAVE_DLL */
}
if (!be->permanent)
{
if (be->name)
free ((void *) be->name);
free (be);
}
}
first_backend = 0;
while( (alias = first_alias) != NULL )
{
first_alias = first_alias->next;
free(alias->oldname);
free(alias);
}
if (NULL != devlist)
{ /* Release memory allocated by sane_get_devices(). */
int i = 0;
while (devlist[i])
free(devlist[i++]);
free(devlist);
devlist = NULL;
devlist_size = 0;
devlist_len = 0;
}
DBG(3, "sane_exit: finished\n");
}
示例11: ap_os_dso_unload
void ap_os_dso_unload(void *handle)
{
#if defined(HPUX) || defined(HPUX10)
shl_unload((shl_t)handle);
#else
dlclose(handle);
#endif
return;
}
示例12: defined
bool QLibraryPrivate::unload_sys()
{
#if !defined(QT_NO_DYNAMIC_LIBRARY)
# if defined(QT_HPUX_LD)
if (shl_unload((shl_t)pHnd)) {
# else
if (dlclose(pHnd)) {
# endif
errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName).arg(qdlerror());
return false;
}
#endif
errorString.clear();
return true;
}
#ifdef Q_OS_LINUX
Q_CORE_EXPORT QFunctionPointer qt_linux_find_symbol_sys(const char *symbol)
{
return QFunctionPointer(dlsym(RTLD_DEFAULT, symbol));
}
#endif
#ifdef Q_OS_MAC
Q_CORE_EXPORT QFunctionPointer qt_mac_resolve_sys(void *handle, const char *symbol)
{
return QFunctionPointer(dlsym(handle, symbol));
}
#endif
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
#if defined(QT_AOUT_UNDERSCORE)
// older a.out systems add an underscore in front of symbols
char* undrscr_symbol = new char[strlen(symbol)+2];
undrscr_symbol[0] = '_';
strcpy(undrscr_symbol+1, symbol);
QFunctionPointer address = QFunctionPointer(dlsym(pHnd, undrscr_symbol));
delete [] undrscr_symbol;
#elif defined(QT_HPUX_LD)
QFunctionPointer address = 0;
if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
address = 0;
#elif defined (QT_NO_DYNAMIC_LIBRARY)
QFunctionPointer address = 0;
#else
QFunctionPointer address = QFunctionPointer(dlsym(pHnd, symbol));
#endif
if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
QString::fromLatin1(symbol)).arg(fileName).arg(qdlerror());
} else {
errorString.clear();
}
return address;
}
示例13: _g_module_close
static void
_g_module_close (gpointer handle,
gboolean is_unref)
{
if (!is_unref)
{
if (shl_unload ((shl_t) handle) != 0)
g_module_set_error (g_strerror (errno));
}
}
示例14: myFreeLibrary
/******************************************************************
*
* Porting Free library function to different platforms
*
*******************************************************************/
void myFreeLibrary(HINSTANCE hKVFILTER)
{
#if defined(_WINDOWS)
FreeLibrary( hKVFILTER );
#elif defined(_HPUX11)
shl_unload((shl_t)hKVFILTER);
#else
dlclose(hKVFILTER);
#endif
}
示例15: TclpUnloadFile
void
TclpUnloadFile(
Tcl_LoadHandle loadHandle) /* loadHandle returned by a previous call to
* TclpDlopen(). The loadHandle is a token
* that represents the loaded file. */
{
shl_t handle;
handle = (shl_t) loadHandle;
shl_unload(handle);
}