Martin v. Löwis | f90ae20 | 2002-06-11 06:22:31 +0000 | [diff] [blame] | 1 | |
| 2 | /* Support for dynamic loading of extension modules */ |
| 3 | |
| 4 | #include <atheos/image.h> |
| 5 | #include <errno.h> |
| 6 | |
| 7 | #include "Python.h" |
| 8 | #include "importdl.h" |
| 9 | |
| 10 | |
| 11 | const struct filedescr _PyImport_DynLoadFiletab[] = { |
| 12 | {".so", "rb", C_EXTENSION}, |
| 13 | {"module.so", "rb", C_EXTENSION}, |
| 14 | {0, 0} |
| 15 | }; |
| 16 | |
| 17 | dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, |
| 18 | const char *pathname, FILE *fp) |
| 19 | { |
| 20 | void *p; |
| 21 | int lib; |
| 22 | char funcname[258]; |
| 23 | |
| 24 | if (Py_VerboseFlag) |
| 25 | printf("load_library %s\n", pathname); |
| 26 | |
| 27 | lib = load_library(pathname, 0); |
| 28 | if (lib < 0) { |
| 29 | char buf[512]; |
| 30 | if (Py_VerboseFlag) |
| 31 | perror(pathname); |
| 32 | PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s: %.200s", |
| 33 | pathname, strerror(errno)); |
| 34 | PyErr_SetString(PyExc_ImportError, buf); |
| 35 | return NULL; |
| 36 | } |
| 37 | PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); |
| 38 | if (Py_VerboseFlag) |
| 39 | printf("get_symbol_address %s\n", funcname); |
| 40 | if (get_symbol_address(lib, funcname, -1, &p) < 0) { |
| 41 | p = NULL; |
| 42 | if (Py_VerboseFlag) |
| 43 | perror(funcname); |
| 44 | } |
| 45 | |
| 46 | return (dl_funcptr) p; |
| 47 | } |