Mercurial > cpython-lru_cache-weakref
view Python/dynload_aix.c @ 56121:ea697cde6882 3.1
Merged revisions 74881-74885,74888,74891-74895,74900,74905-74906,74931-74932,74934,74941-74942,74944,74956 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r74881 | r.david.murray | 2009-09-17 15:12:49 -0400 (Thu, 17 Sep 2009) | 2 lines
Check in first draft of maintainers.rst.
........
r74882 | eric.smith | 2009-09-17 15:22:30 -0400 (Thu, 17 Sep 2009) | 1 line
Typo.
........
r74883 | mark.dickinson | 2009-09-17 15:37:28 -0400 (Thu, 17 Sep 2009) | 1 line
Add some more module maintainers.
........
r74884 | mark.dickinson | 2009-09-17 15:39:12 -0400 (Thu, 17 Sep 2009) | 1 line
Revert accidental changes to Objects/longobject.c
........
r74885 | mark.dickinson | 2009-09-17 16:20:01 -0400 (Thu, 17 Sep 2009) | 1 line
Add decimal maintainers
........
r74888 | r.david.murray | 2009-09-17 18:10:48 -0400 (Thu, 17 Sep 2009) | 2 lines
Maintainer additions from MAL.
........
r74891 | georg.brandl | 2009-09-17 18:18:01 -0400 (Thu, 17 Sep 2009) | 1 line
Some more maintainers.
........
r74892 | r.david.murray | 2009-09-17 19:23:56 -0400 (Thu, 17 Sep 2009) | 2 lines
Add a couple interest areas for Nick per his request.
........
r74893 | r.david.murray | 2009-09-17 19:43:20 -0400 (Thu, 17 Sep 2009) | 2 lines
Benajmin is also compiler-knowledgeable.
........
r74894 | alexandre.vassalotti | 2009-09-17 20:59:05 -0400 (Thu, 17 Sep 2009) | 2 lines
Added myself to my areas of interest.
........
r74895 | brett.cannon | 2009-09-17 21:03:35 -0400 (Thu, 17 Sep 2009) | 1 line
Add myself to a couple places as maintainer.
........
r74900 | georg.brandl | 2009-09-18 05:06:37 -0400 (Fri, 18 Sep 2009) | 1 line
Add myself in interest areas.
........
r74905 | ezio.melotti | 2009-09-18 05:58:43 -0400 (Fri, 18 Sep 2009) | 1 line
Add myself in interest areas and mark effbot as inactive in winsound
........
r74906 | antoine.pitrou | 2009-09-18 09:15:23 -0400 (Fri, 18 Sep 2009) | 3 lines
Add myself in a couple of places
........
r74931 | r.david.murray | 2009-09-18 17:25:36 -0400 (Fri, 18 Sep 2009) | 5 lines
Add some names gleaned from the "Tracker Archeology" thread
on python-dev from back in February. Also consolidate
the autoconf and makefiles topics into one, and add tracker
and svn/hg topics.
........
r74932 | r.david.murray | 2009-09-18 17:32:16 -0400 (Fri, 18 Sep 2009) | 2 lines
Remove non-committer mistakenly added.
........
r74934 | r.david.murray | 2009-09-18 17:40:30 -0400 (Fri, 18 Sep 2009) | 2 lines
More descriptive/generic name for the svn/hg entry (version control)
........
r74941 | benjamin.peterson | 2009-09-18 18:45:59 -0400 (Fri, 18 Sep 2009) | 1 line
add a new category for myself
........
r74942 | benjamin.peterson | 2009-09-18 18:50:55 -0400 (Fri, 18 Sep 2009) | 1 line
add myself for symtable
........
r74944 | georg.brandl | 2009-09-19 03:39:05 -0400 (Sat, 19 Sep 2009) | 1 line
I would like to maintain the token module!
........
r74956 | r.david.murray | 2009-09-19 14:40:08 -0400 (Sat, 19 Sep 2009) | 3 lines
Add everyone who we know has been a release manager
as a resource for the 'release management' topic.
........
| author | R. David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Sat, 19 Sep 2009 19:04:37 +0000 |
| parents | 8cb686dd6e64 |
| children | fd25030223b0 |
line wrap: on
line source
/* Support for dynamic loading of extension modules */ #include "Python.h" #include "importdl.h" #include <ctype.h> /* for isdigit() */ #include <errno.h> /* for global errno */ #include <string.h> /* for strerror() */ #include <stdlib.h> /* for malloc(), free() */ #include <sys/ldr.h> #ifdef AIX_GENUINE_CPLUSPLUS #include "/usr/lpp/xlC/include/load.h" #define aix_load loadAndInit #else #define aix_load load #endif extern char *Py_GetProgramName(void); typedef struct Module { struct Module *next; void *entry; } Module, *ModulePtr; const struct filedescr _PyImport_DynLoadFiletab[] = { {".so", "rb", C_EXTENSION}, {"module.so", "rb", C_EXTENSION}, {0, 0} }; static int aix_getoldmodules(void **modlistptr) { register ModulePtr modptr, prevmodptr; register struct ld_info *ldiptr; register char *ldibuf; register int errflag, bufsize = 1024; register unsigned int offset; char *progname = Py_GetProgramName(); /* -- Get the list of loaded modules into ld_info structures. */ if ((ldibuf = malloc(bufsize)) == NULL) { PyErr_SetString(PyExc_ImportError, strerror(errno)); return -1; } while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1 && errno == ENOMEM) { free(ldibuf); bufsize += 1024; if ((ldibuf = malloc(bufsize)) == NULL) { PyErr_SetString(PyExc_ImportError, strerror(errno)); return -1; } } if (errflag == -1) { PyErr_SetString(PyExc_ImportError, strerror(errno)); return -1; } /* -- Make the modules list from the ld_info structures. */ ldiptr = (struct ld_info *)ldibuf; prevmodptr = NULL; do { if (strstr(progname, ldiptr->ldinfo_filename) == NULL && strstr(ldiptr->ldinfo_filename, "python") == NULL) { /* -- Extract only the modules belonging to the main -- executable + those containing "python" as a -- substring (like the "python[version]" binary or -- "libpython[version].a" in case it's a shared lib). */ offset = (unsigned int)ldiptr->ldinfo_next; ldiptr = (struct ld_info *)((char*)ldiptr + offset); continue; } if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) { PyErr_SetString(PyExc_ImportError, strerror(errno)); while (*modlistptr) { modptr = (ModulePtr)*modlistptr; *modlistptr = (void *)modptr->next; free(modptr); } return -1; } modptr->entry = ldiptr->ldinfo_dataorg; modptr->next = NULL; if (prevmodptr == NULL) *modlistptr = (void *)modptr; else prevmodptr->next = modptr; prevmodptr = modptr; offset = (unsigned int)ldiptr->ldinfo_next; ldiptr = (struct ld_info *)((char*)ldiptr + offset); } while (offset); free(ldibuf); return 0; } static void aix_loaderror(const char *pathname) { char *message[1024], errbuf[1024]; register int i,j; struct errtab { int errNo; char *errstr; } load_errtab[] = { {L_ERROR_TOOMANY, "too many errors, rest skipped."}, {L_ERROR_NOLIB, "can't load library:"}, {L_ERROR_UNDEF, "can't find symbol in library:"}, {L_ERROR_RLDBAD, "RLD index out of range or bad relocation type:"}, {L_ERROR_FORMAT, "not a valid, executable xcoff file:"}, {L_ERROR_MEMBER, "file not an archive or does not contain requested member:"}, {L_ERROR_TYPE, "symbol table mismatch:"}, {L_ERROR_ALIGN, "text alignment in file is wrong."}, {L_ERROR_SYSTEM, "System error:"}, {L_ERROR_ERRNO, NULL} }; #define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0])) #define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) PyOS_snprintf(errbuf, sizeof(errbuf), "from module %.200s ", pathname); if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) { ERRBUF_APPEND(strerror(errno)); ERRBUF_APPEND("\n"); } for(i = 0; message[i] && *message[i]; i++) { int nerr = atoi(message[i]); for (j=0; j<LOAD_ERRTAB_LEN ; j++) { if (nerr == load_errtab[j].errNo && load_errtab[j].errstr) ERRBUF_APPEND(load_errtab[j].errstr); } while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ; ERRBUF_APPEND(message[i]); ERRBUF_APPEND("\n"); } errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ PyErr_SetString(PyExc_ImportError, errbuf); return; } dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, const char *pathname, FILE *fp) { dl_funcptr p; /* -- Invoke load() with L_NOAUTODEFER leaving the imported symbols -- of the shared module unresolved. Thus we have to resolve them -- explicitly with loadbind. The new module is loaded, then we -- resolve its symbols using the list of already loaded modules -- (only those that belong to the python executable). Get these -- with loadquery(L_GETINFO). */ static void *staticmodlistptr = NULL; if (!staticmodlistptr) if (aix_getoldmodules(&staticmodlistptr) == -1) return NULL; p = (dl_funcptr) aix_load((char *)pathname, L_NOAUTODEFER, 0); if (p == NULL) { aix_loaderror(pathname); return NULL; } return p; }
