remove the dynload_next.c file (closes bpo-32386) (#4957)
This commit is contained in:
parent
424315fa86
commit
62ed6be8da
|
@ -1,111 +0,0 @@
|
||||||
|
|
||||||
/* Support for dynamic loading of extension modules on Mac OS X
|
|
||||||
** All references to "NeXT" are for historical reasons.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Python.h"
|
|
||||||
#include "importdl.h"
|
|
||||||
|
|
||||||
#include <mach-o/dyld.h>
|
|
||||||
|
|
||||||
const char *_PyImport_DynLoadFiletab[] = {".so", NULL};
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Python modules are Mach-O MH_BUNDLE files. The best way to load these
|
|
||||||
** is each in a private namespace, so you can load, say, a module bar and a
|
|
||||||
** module foo.bar. If we load everything in the global namespace the two
|
|
||||||
** initbar() symbols will conflict.
|
|
||||||
** However, it seems some extension packages depend upon being able to access
|
|
||||||
** each others' global symbols. There seems to be no way to eat our cake and
|
|
||||||
** have it, so the USE_DYLD_GLOBAL_NAMESPACE define determines which behaviour
|
|
||||||
** you get.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef USE_DYLD_GLOBAL_NAMESPACE
|
|
||||||
#define LINKOPTIONS NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR
|
|
||||||
#else
|
|
||||||
#define LINKOPTIONS NSLINKMODULE_OPTION_BINDNOW| \
|
|
||||||
NSLINKMODULE_OPTION_RETURN_ON_ERROR|NSLINKMODULE_OPTION_PRIVATE
|
|
||||||
#endif
|
|
||||||
dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix,
|
|
||||||
const char *shortname,
|
|
||||||
const char *pathname, FILE *fp)
|
|
||||||
{
|
|
||||||
dl_funcptr p = NULL;
|
|
||||||
char funcname[258];
|
|
||||||
NSObjectFileImageReturnCode rc;
|
|
||||||
NSObjectFileImage image;
|
|
||||||
NSModule newModule;
|
|
||||||
NSSymbol theSym;
|
|
||||||
const char *errString;
|
|
||||||
char errBuf[512];
|
|
||||||
|
|
||||||
PyOS_snprintf(funcname, sizeof(funcname), "_%.20s_%.200s", prefix, shortname);
|
|
||||||
|
|
||||||
#ifdef USE_DYLD_GLOBAL_NAMESPACE
|
|
||||||
if (NSIsSymbolNameDefined(funcname)) {
|
|
||||||
theSym = NSLookupAndBindSymbol(funcname);
|
|
||||||
p = (dl_funcptr)NSAddressOfSymbol(theSym);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
rc = NSCreateObjectFileImageFromFile(pathname, &image);
|
|
||||||
switch(rc) {
|
|
||||||
default:
|
|
||||||
case NSObjectFileImageFailure:
|
|
||||||
case NSObjectFileImageFormat:
|
|
||||||
/* for these a message is printed on stderr by dyld */
|
|
||||||
errString = "Can't create object file image";
|
|
||||||
break;
|
|
||||||
case NSObjectFileImageSuccess:
|
|
||||||
errString = NULL;
|
|
||||||
break;
|
|
||||||
case NSObjectFileImageInappropriateFile:
|
|
||||||
errString = "Inappropriate file type for dynamic loading";
|
|
||||||
break;
|
|
||||||
case NSObjectFileImageArch:
|
|
||||||
errString = "Wrong CPU type in object file";
|
|
||||||
break;
|
|
||||||
case NSObjectFileImageAccess:
|
|
||||||
errString = "Can't read object file (no access)";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (errString == NULL) {
|
|
||||||
newModule = NSLinkModule(image, pathname, LINKOPTIONS);
|
|
||||||
if (newModule == NULL) {
|
|
||||||
int errNo;
|
|
||||||
const char *fileName, *moreErrorStr;
|
|
||||||
NSLinkEditErrors c;
|
|
||||||
NSLinkEditError( &c, &errNo, &fileName, &moreErrorStr );
|
|
||||||
PyOS_snprintf(errBuf, 512, "Failure linking new module: %s: %s",
|
|
||||||
fileName, moreErrorStr);
|
|
||||||
errString = errBuf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (errString != NULL) {
|
|
||||||
PyErr_SetString(PyExc_ImportError, errString);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#ifdef USE_DYLD_GLOBAL_NAMESPACE
|
|
||||||
if (!NSIsSymbolNameDefined(funcname)) {
|
|
||||||
/* UnlinkModule() isn't implemented in current versions, but calling it does no harm */
|
|
||||||
/* NSUnLinkModule(newModule, FALSE); removed: causes problems for ObjC code */
|
|
||||||
PyErr_Format(PyExc_ImportError,
|
|
||||||
"Loaded module does not contain symbol %.200s",
|
|
||||||
funcname);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
theSym = NSLookupAndBindSymbol(funcname);
|
|
||||||
#else
|
|
||||||
theSym = NSLookupSymbolInModule(newModule, funcname);
|
|
||||||
if ( theSym == NULL ) {
|
|
||||||
/* NSUnLinkModule(newModule, FALSE); removed: causes problems for ObjC code */
|
|
||||||
PyErr_Format(PyExc_ImportError,
|
|
||||||
"Loaded module does not contain symbol %.200s",
|
|
||||||
funcname);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
p = (dl_funcptr)NSAddressOfSymbol(theSym);
|
|
||||||
return p;
|
|
||||||
}
|
|
|
@ -778,6 +778,7 @@ infodir
|
||||||
docdir
|
docdir
|
||||||
oldincludedir
|
oldincludedir
|
||||||
includedir
|
includedir
|
||||||
|
runstatedir
|
||||||
localstatedir
|
localstatedir
|
||||||
sharedstatedir
|
sharedstatedir
|
||||||
sysconfdir
|
sysconfdir
|
||||||
|
@ -889,6 +890,7 @@ datadir='${datarootdir}'
|
||||||
sysconfdir='${prefix}/etc'
|
sysconfdir='${prefix}/etc'
|
||||||
sharedstatedir='${prefix}/com'
|
sharedstatedir='${prefix}/com'
|
||||||
localstatedir='${prefix}/var'
|
localstatedir='${prefix}/var'
|
||||||
|
runstatedir='${localstatedir}/run'
|
||||||
includedir='${prefix}/include'
|
includedir='${prefix}/include'
|
||||||
oldincludedir='/usr/include'
|
oldincludedir='/usr/include'
|
||||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||||
|
@ -1141,6 +1143,15 @@ do
|
||||||
| -silent | --silent | --silen | --sile | --sil)
|
| -silent | --silent | --silen | --sile | --sil)
|
||||||
silent=yes ;;
|
silent=yes ;;
|
||||||
|
|
||||||
|
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
||||||
|
| --runstate | --runstat | --runsta | --runst | --runs \
|
||||||
|
| --run | --ru | --r)
|
||||||
|
ac_prev=runstatedir ;;
|
||||||
|
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
||||||
|
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
||||||
|
| --run=* | --ru=* | --r=*)
|
||||||
|
runstatedir=$ac_optarg ;;
|
||||||
|
|
||||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||||
ac_prev=sbindir ;;
|
ac_prev=sbindir ;;
|
||||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||||
|
@ -1278,7 +1289,7 @@ fi
|
||||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||||
libdir localedir mandir
|
libdir localedir mandir runstatedir
|
||||||
do
|
do
|
||||||
eval ac_val=\$$ac_var
|
eval ac_val=\$$ac_var
|
||||||
# Remove trailing slashes.
|
# Remove trailing slashes.
|
||||||
|
@ -1431,6 +1442,7 @@ Fine tuning of the installation directories:
|
||||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||||
|
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
||||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||||
--includedir=DIR C header files [PREFIX/include]
|
--includedir=DIR C header files [PREFIX/include]
|
||||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||||
|
@ -9125,7 +9137,7 @@ then
|
||||||
LDCXXSHARED='$(CXX) -shared'
|
LDCXXSHARED='$(CXX) -shared'
|
||||||
else
|
else
|
||||||
LDSHARED='$(CC) -b'
|
LDSHARED='$(CC) -b'
|
||||||
LDCXXSHARED='$(CXX) -shared'
|
LDCXXSHARED='$(CXX) -b'
|
||||||
fi ;;
|
fi ;;
|
||||||
Darwin/1.3*)
|
Darwin/1.3*)
|
||||||
LDSHARED='$(CC) -bundle'
|
LDSHARED='$(CC) -bundle'
|
||||||
|
@ -9872,6 +9884,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
|
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
|
||||||
if test -n "$ac_tool_prefix"; then
|
if test -n "$ac_tool_prefix"; then
|
||||||
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
|
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
|
||||||
|
@ -11099,8 +11112,6 @@ then
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
|
hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
|
||||||
# Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
|
|
||||||
Darwin/[0156]\..*) DYNLOADFILE="dynload_next.o";;
|
|
||||||
*)
|
*)
|
||||||
# use dynload_shlib.c and dlopen() if we have it; otherwise stub
|
# use dynload_shlib.c and dlopen() if we have it; otherwise stub
|
||||||
# out any dynamic loading
|
# out any dynamic loading
|
||||||
|
|
|
@ -3373,8 +3373,6 @@ then
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
|
hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
|
||||||
# Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
|
|
||||||
Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
|
|
||||||
*)
|
*)
|
||||||
# use dynload_shlib.c and dlopen() if we have it; otherwise stub
|
# use dynload_shlib.c and dlopen() if we have it; otherwise stub
|
||||||
# out any dynamic loading
|
# out any dynamic loading
|
||||||
|
|
Loading…
Reference in New Issue