mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Add dlopenflags to PyInterpreterState, and use it in dlopen calls.
This commit is contained in:
parent
984158d25b
commit
f0473d511b
6 changed files with 103 additions and 13 deletions
|
@ -22,10 +22,6 @@
|
|||
#define LEAD_UNDERSCORE ""
|
||||
#endif
|
||||
|
||||
#ifndef RTLD_LAZY
|
||||
#define RTLD_LAZY 1
|
||||
#endif
|
||||
|
||||
|
||||
const struct filedescr _PyImport_DynLoadFiletab[] = {
|
||||
#ifdef __CYGWIN__
|
||||
|
@ -53,6 +49,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
|
|||
void *handle;
|
||||
char funcname[258];
|
||||
char pathbuf[260];
|
||||
int dlopenflags=0;
|
||||
|
||||
if (strchr(pathname, '/') == NULL) {
|
||||
/* Prefix bare filename with "./" */
|
||||
|
@ -80,16 +77,13 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef RTLD_NOW
|
||||
/* RTLD_NOW: resolve externals now
|
||||
(i.e. core dump now if some are missing) */
|
||||
handle = dlopen(pathname, RTLD_NOW);
|
||||
#else
|
||||
dlopenflags = PyThreadState_Get()->interp->dlopenflags;
|
||||
|
||||
if (Py_VerboseFlag)
|
||||
printf("dlopen(\"%s\", %d);\n", pathname,
|
||||
RTLD_LAZY);
|
||||
handle = dlopen(pathname, RTLD_LAZY);
|
||||
#endif /* RTLD_NOW */
|
||||
printf("dlopen(\"%s\", %x);\n", pathname, dlopenflags);
|
||||
|
||||
handle = dlopen(pathname, dlopenflags);
|
||||
|
||||
if (handle == NULL) {
|
||||
PyErr_SetString(PyExc_ImportError, dlerror());
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue