[Python-checkins] CVS: python/dist/src/Python dynload_aix.c,2.2,2.3 dynload_beos.c,2.1,2.2 dynload_dl.c,2.1,2.2 dynload_hpux.c,2.1,2.2 dynload_mac.c,2.1,2.2 dynload_next.c,2.1,2.2 dynload_os2.c,2.1,2.2 dynload_shlib.c,2.1,2.2 dynload_win.c,2.1,2.2 import.c,2.127,2.128 importdl.c,2.63,2.64
Guido van Rossum
guido@cnri.reston.va.us
Wed, 22 Dec 1999 09:09:39 -0500 (EST)
Update of /projects/cvsroot/python/dist/src/Python
In directory eric:/projects/python/develop/guido/src/Python
Modified Files:
dynload_aix.c dynload_beos.c dynload_dl.c dynload_hpux.c
dynload_mac.c dynload_next.c dynload_os2.c dynload_shlib.c
dynload_win.c import.c importdl.c
Log Message:
Cleanup patches from Greg Stein:
* in import.c, #ifdef out references to dynamic loading based on
HAVE_DYNAMIC_LOADING
* clean out the platform-specific crud from importdl.c.
[ maybe fold this function into import.c and drop the importdl.c file? Greg.]
* change GetDynLoadFunc's "funcname" parameter to "shortname". change
"name" to "fqname" for clarification.
* each GetDynLoadFunc now creates its own funcname value.
WARNING: as I mentioned previously, we may run into an issue with a
missing "_" on some platforms. Testing will show this pretty quickly,
however.
* move pathname munging into dynload_shlib.c
Index: dynload_aix.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_aix.c,v
retrieving revision 2.2
retrieving revision 2.3
diff -C2 -r2.2 -r2.3
*** dynload_aix.c 1999/12/21 15:55:47 2.2
--- dynload_aix.c 1999/12/22 14:09:35 2.3
***************
*** 203,207 ****
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
--- 203,207 ----
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
Index: dynload_beos.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_beos.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_beos.c 1999/12/20 21:18:48 2.1
--- dynload_beos.c 1999/12/22 14:09:35 2.2
***************
*** 186,190 ****
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
--- 186,190 ----
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
***************
*** 193,196 ****
--- 193,197 ----
status_t retval;
char fullpath[PATH_MAX];
+ char funcname[258];
if( Py_VerboseFlag ) {
***************
*** 237,240 ****
--- 238,242 ----
}
+ sprintf(funcname, "init%.200s", shortname);
if( Py_VerboseFlag ) {
printf( "get_image_symbol( %s )\n", funcname );
***************
*** 275,279 ****
* gracefully.
*/
! beos_add_dyn( name, the_id );
return p;
--- 277,281 ----
* gracefully.
*/
! beos_add_dyn( fqname, the_id );
return p;
Index: dynload_dl.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_dl.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_dl.c 1999/12/20 21:18:48 2.1
--- dynload_dl.c 1999/12/22 14:09:35 2.2
***************
*** 47,53 ****
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
return dl_loadmod(Py_GetProgramName(), pathname, funcname);
}
--- 47,56 ----
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
+ char funcname[258];
+
+ sprintf(funcname, "init%.200s", shortname);
return dl_loadmod(Py_GetProgramName(), pathname, funcname);
}
Index: dynload_hpux.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_hpux.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_hpux.c 1999/12/20 21:18:48 2.1
--- dynload_hpux.c 1999/12/22 14:09:35 2.2
***************
*** 38,41 ****
--- 38,46 ----
#include "importdl.h"
+ #if defined(__hp9000s300)
+ #define FUNCNAME_PATTERN "_init%.200s"
+ #else
+ #define FUNCNAME_PATTERN "init%.200s"
+ #endif
const struct filedescr _PyImport_DynLoadFiletab[] = {
***************
*** 45,49 ****
};
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
--- 50,54 ----
};
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
***************
*** 51,54 ****
--- 56,60 ----
shl_t lib;
int flags;
+ char funcname[258];
flags = BIND_FIRST | BIND_DEFERRED;
***************
*** 68,71 ****
--- 74,78 ----
return NULL;
}
+ sprintf(funcname, FUNCNAME_PATTERN, shortname);
if (Py_VerboseFlag)
printf("shl_findsym %s\n", funcname);
Index: dynload_mac.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_mac.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_mac.c 1999/12/20 21:18:48 2.1
--- dynload_mac.c 1999/12/22 14:09:35 2.2
***************
*** 60,67 ****
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
dl_funcptr p;
/*
--- 60,68 ----
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
dl_funcptr p;
+ char funcname[258];
/*
***************
*** 122,125 ****
--- 123,127 ----
}
/* Locate the address of the correct init function */
+ sprintf(funcname, "init%.200s", shortname);
err = FindSymbol(connID, Pstring(funcname), &symAddr, &class);
if ( err ) {
Index: dynload_next.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_next.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_next.c 1999/12/20 21:18:48 2.1
--- dynload_next.c 1999/12/22 14:09:35 2.2
***************
*** 69,76 ****
};
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
dl_funcptr p = NULL;
#ifdef USE_RLD
--- 69,79 ----
};
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
dl_funcptr p = NULL;
+ char funcname[258];
+
+ sprintf(funcname, "_init%.200s", shortname);
#ifdef USE_RLD
Index: dynload_os2.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_os2.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_os2.c 1999/12/20 21:18:48 2.1
--- dynload_os2.c 1999/12/22 14:09:35 2.2
***************
*** 46,50 ****
};
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
--- 46,50 ----
};
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
***************
*** 53,56 ****
--- 53,57 ----
HMODULE hDLL;
char failreason[256];
+ char funcname[258];
rc = DosLoadModule(failreason,
***************
*** 68,71 ****
--- 69,73 ----
}
+ sprintf(funcname, "init%.200s", shortname);
rc = DosQueryProcAddr(hDLL, 0L, funcname, &p);
if (rc != NO_ERROR)
Index: dynload_shlib.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_shlib.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_shlib.c 1999/12/20 21:18:48 2.1
--- dynload_shlib.c 1999/12/22 14:09:35 2.2
***************
*** 66,74 ****
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
dl_funcptr p;
void *handle;
if (fp != NULL) {
--- 66,85 ----
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
dl_funcptr p;
void *handle;
+ char funcname[258];
+ char pathbuf[260];
+
+ if (strchr(pathname, '/') == NULL) {
+ /* Prefix bare filename with "./" */
+ sprintf(pathbuf, "./%-.255s", pathname);
+ pathname = pathbuf;
+ }
+
+ /* ### should there be a leading underscore for some platforms? */
+ sprintf(funcname, "init%.200s", shortname);
if (fp != NULL) {
Index: dynload_win.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/dynload_win.c,v
retrieving revision 2.1
retrieving revision 2.2
diff -C2 -r2.1 -r2.2
*** dynload_win.c 1999/12/20 21:18:49 2.1
--- dynload_win.c 1999/12/22 14:09:35 2.2
***************
*** 50,57 ****
! dl_funcptr _PyImport_GetDynLoadFunc(const char *name, const char *funcname,
const char *pathname, FILE *fp)
{
dl_funcptr p;
#ifdef MS_WIN32
--- 50,60 ----
! dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
const char *pathname, FILE *fp)
{
dl_funcptr p;
+ char funcname[258];
+
+ sprintf(funcname, "init%.200s", shortname);
#ifdef MS_WIN32
Index: import.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/import.c,v
retrieving revision 2.127
retrieving revision 2.128
diff -C2 -r2.127 -r2.128
*** import.c 1999/12/20 21:23:41 2.127
--- import.c 1999/12/22 14:09:35 2.128
***************
*** 1235,1241 ****
--- 1235,1243 ----
break;
+ #ifdef HAVE_DYNAMIC_LOADING
case C_EXTENSION:
m = _PyImport_LoadDynamicModule(name, buf, fp);
break;
+ #endif
#ifdef macintosh
***************
*** 2159,2162 ****
--- 2161,2166 ----
}
+ #ifdef HAVE_DYNAMIC_LOADING
+
static PyObject *
imp_load_dynamic(self, args)
***************
*** 2181,2184 ****
--- 2185,2190 ----
}
+ #endif /* HAVE_DYNAMIC_LOADING */
+
static PyObject *
imp_load_source(self, args)
***************
*** 2331,2335 ****
--- 2337,2343 ----
{"is_frozen", imp_is_frozen, 1},
{"load_compiled", imp_load_compiled, 1},
+ #ifdef HAVE_DYNAMIC_LOADING
{"load_dynamic", imp_load_dynamic, 1},
+ #endif
{"load_package", imp_load_package, 1},
#ifdef macintosh
Index: importdl.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/importdl.c,v
retrieving revision 2.63
retrieving revision 2.64
diff -C2 -r2.63 -r2.64
*** importdl.c 1999/12/20 21:20:42 2.63
--- importdl.c 1999/12/22 14:09:35 2.64
***************
*** 31,89 ****
/* Support for dynamic loading of extension modules */
- /* If no dynamic linking is supported, this file still generates some code! */
#include "Python.h"
- #include "importdl.h"
-
- /* Explanation of some of the the various #defines used by dynamic linking...
! symbol -- defined for:
!
! HAVE_DYNAMIC_LOADING -- any kind of dynamic linking (from ./configure)
! USE_SHLIB -- SunOS or IRIX 5 (SVR4?) shared libraries
! _AIX -- AIX style dynamic linking
! __NetBSD__ -- NetBSD shared libraries
! (assuming dlerror() was introduced between 1.2 and 1.3)
! __BEOS__ -- BeOS shared libraries - defined by the compiler
*/
-
- /* Configure dynamic linking */
-
#ifdef HAVE_DYNAMIC_LOADING
extern dl_funcptr _PyImport_GetDynLoadFunc(const char *name,
! const char *funcname,
const char *pathname, FILE *fp);
- /* ### given NeXT, is WITH_DYLD not necessary? */
-
- #if defined(__hp9000s300) || (defined(__NetBSD__) || defined(__FreeBSD__)) && !defined(__ELF__) || defined(__OpenBSD__) || defined(__BORLANDC__) || defined(NeXT) || defined(WITH_DYLD)
- #define FUNCNAME_PATTERN "_init%.200s"
- #else
- #define FUNCNAME_PATTERN "init%.200s"
- #endif
-
- /* ### temporary, for setting USE_SHLIB */
- #if defined(__NetBSD__) && (NetBSD < 199712)
- #define USE_SHLIB
- #else
- #if defined(HAVE_DLOPEN) || defined(M_UNIX)
- #define USE_SHLIB
- #endif
- #endif
- #ifdef _AIX
- #undef USE_SHLIB
- #endif
- #ifdef __BEOS__
- #undef USE_SHLIB
- #endif
- #endif /* HAVE_DYNAMIC_LOADING */
-
- #ifdef NO_DYNAMIC_LINK
- #undef HAVE_DYNAMIC_LOADING
- #endif
-
PyObject *
_PyImport_LoadDynamicModule(name, pathname, fp)
--- 31,52 ----
/* Support for dynamic loading of extension modules */
#include "Python.h"
! /* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is
! supported on this platform. configure will then compile and link in one
! of the dynload_*.c files, as appropriate. We will call a function in
! those modules to get a function pointer to the module's init function.
*/
#ifdef HAVE_DYNAMIC_LOADING
+ #include "importdl.h"
+
extern dl_funcptr _PyImport_GetDynLoadFunc(const char *name,
! const char *shortname,
const char *pathname, FILE *fp);
PyObject *
_PyImport_LoadDynamicModule(name, pathname, fp)
***************
*** 92,113 ****
FILE *fp;
{
- #ifndef HAVE_DYNAMIC_LOADING
- PyErr_SetString(PyExc_ImportError,
- "dynamically linked modules not supported");
- return NULL;
- #else
PyObject *m, *d, *s;
- char funcname[258];
char *lastdot, *shortname, *packagecontext;
! dl_funcptr p = NULL;
!
! #ifdef USE_SHLIB
! char pathbuf[260];
! if (strchr(pathname, '/') == NULL) {
! /* Prefix bare filename with "./" */
! sprintf(pathbuf, "./%-.255s", pathname);
! pathname = pathbuf;
! }
! #endif /* USE_SHLIB */
if ((m = _PyImport_FindExtension(name, pathname)) != NULL) {
--- 55,61 ----
FILE *fp;
{
PyObject *m, *d, *s;
char *lastdot, *shortname, *packagecontext;
! dl_funcptr p;
if ((m = _PyImport_FindExtension(name, pathname)) != NULL) {
***************
*** 124,136 ****
shortname = lastdot+1;
}
- sprintf(funcname, FUNCNAME_PATTERN, shortname);
! p = _PyImport_GetDynLoadFunc(name, funcname, pathname, fp);
if (PyErr_Occurred())
return NULL;
if (p == NULL) {
PyErr_Format(PyExc_ImportError,
! "dynamic module does not define init function (%.200s)",
! funcname);
return NULL;
}
--- 72,83 ----
shortname = lastdot+1;
}
! p = _PyImport_GetDynLoadFunc(name, shortname, pathname, fp);
if (PyErr_Occurred())
return NULL;
if (p == NULL) {
PyErr_Format(PyExc_ImportError,
! "dynamic module does not define init function (init%.200s)",
! shortname);
return NULL;
}
***************
*** 161,164 ****
Py_INCREF(m);
return m;
- #endif /* HAVE_DYNAMIC_LOADING */
}
--- 108,112 ----
Py_INCREF(m);
return m;
}
+
+ #endif /* HAVE_DYNAMIC_LOADING */