当前位置: 首页>>代码示例>>C++>>正文


C++ shl_load函数代码示例

本文整理汇总了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;
}
开发者ID:ILUZIO,项目名称:libtool,代码行数:36,代码来源:shl_load.c

示例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);
	}
开发者ID:aosm,项目名称:OpenSSL096,代码行数:30,代码来源:dso_dl.c

示例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;
}
开发者ID:AbaqusPowerUsers,项目名称:AbaqusPythonScripts,代码行数:58,代码来源:tclLoadShl.c

示例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;
}
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:51,代码来源:solib.c

示例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
}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:31,代码来源:dlunix.cpp

示例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;
}
开发者ID:erdincay,项目名称:vcxsrv-linux2windows,代码行数:26,代码来源:CrGlCur.c

示例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;
}
开发者ID:BackupTheBerlios,项目名称:amanith-svn,代码行数:34,代码来源:gpluglib.cpp

示例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;
}
开发者ID:csilles,项目名称:cxxr,代码行数:32,代码来源:hpdlfcn.c

示例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;
}
开发者ID:asottile,项目名称:ancient-pythons,代码行数:33,代码来源:dynload_hpux.c

示例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
}
开发者ID:sndae,项目名称:winter-sense,代码行数:28,代码来源:isense.c

示例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;
}
开发者ID:iquiw,项目名称:xsrc,代码行数:32,代码来源:XlcDL.c

示例12: pg_dlopen

void *
pg_dlopen(char *filename)
{
    shl_t handle = shl_load(filename, BIND_DEFERRED, 0);

    return((void *) handle);
}
开发者ID:jarulraj,项目名称:postgres95,代码行数:7,代码来源:dynloader.c

示例13: shl_load

static void *dlopen(const char *libname, int how)
{
  shl_t lib;

  lib = shl_load(libname, how, 0L);

  return (void *)lib;
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:8,代码来源:dynamic_load.c

示例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;
}
开发者ID:BrianHoldsworth,项目名称:Poco,代码行数:9,代码来源:SharedLibrary_HPUX.cpp

示例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;
}
开发者ID:psi-im,项目名称:neatstuff,代码行数:19,代码来源:qlibrary_unix.cpp


注:本文中的shl_load函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。