Back to index

python3.2  3.2.2
Classes | Defines | Typedefs | Functions
dynload_aix.c File Reference
#include "Python.h"
#include "importdl.h"
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ldr.h>

Go to the source code of this file.


struct  Module


#define aix_load   load
#define LOAD_ERRTAB_LEN   (sizeof(load_errtab)/sizeof(load_errtab[0]))
#define ERRBUF_APPEND(s)   strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)


typedef struct Module Module
typedef struct ModuleModulePtr


char * Py_GetProgramName (void)
static int aix_getoldmodules (void **modlistptr)
static void aix_loaderror (const char *pathname)
dl_funcptr _PyImport_GetDynLoadFunc (const char *fqname, const char *shortname, const char *pathname, FILE *fp)

Class Documentation

struct Module

Definition at line 24 of file dynload_aix.c.

Collaboration diagram for Module:
Class Members
void * entry
struct Module * next

Define Documentation

#define aix_load   load

Definition at line 18 of file dynload_aix.c.

#define ERRBUF_APPEND (   s)    strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
#define LOAD_ERRTAB_LEN   (sizeof(load_errtab)/sizeof(load_errtab[0]))

Typedef Documentation

typedef struct Module Module
typedef struct Module * ModulePtr

Function Documentation

dl_funcptr _PyImport_GetDynLoadFunc ( const char *  fqname,
const char *  shortname,
const char *  pathname,
FILE *  fp 

Definition at line 157 of file dynload_aix.c.

    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) {
        return NULL;

    return p;

Here is the call graph for this function:

static int aix_getoldmodules ( void **  modlistptr) [static]

Definition at line 36 of file dynload_aix.c.

    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) {
        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);
        if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) {
            PyErr_SetString(PyExc_ImportError, strerror(errno));
            while (*modlistptr) {
                modptr = (ModulePtr)*modlistptr;
                *modlistptr = (void *)modptr->next;
            return -1;
        modptr->entry = ldiptr->ldinfo_dataorg;
        modptr->next  = NULL;
        if (prevmodptr == NULL)
            *modlistptr = (void *)modptr;
            prevmodptr->next = modptr;
        prevmodptr = modptr;
        offset = (unsigned int)ldiptr->ldinfo_next;
        ldiptr = (struct ld_info *)((char*)ldiptr + offset);
    } while (offset);
    return 0;

Here is the call graph for this function:

Here is the caller graph for this function:

static void aix_loaderror ( const char *  pathname) [static]

Definition at line 108 of file dynload_aix.c.


    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:"},
         "RLD index out of range or bad relocation type:"},
        {L_ERROR_FORMAT,                "not a valid, executable xcoff file:"},
         "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))) {
    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)
        while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ;
    errbuf[strlen(errbuf)-1] = '\0';            /* trim off last newline */
    PyErr_SetString(PyExc_ImportError, errbuf);

Here is the call graph for this function:

Here is the caller graph for this function:

char* Py_GetProgramName ( void  )

Definition at line 686 of file pythonrun.c.

    return progname;

Here is the caller graph for this function: