Mercurial > cpython-lru_cache-weakref
annotate Python/dynload_hpux.c @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | fd25030223b0 |
| children |
| rev | line source |
|---|---|
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 /* Support for dynamic loading of extension modules */ |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 #include "dl.h" |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 #include <errno.h> |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 #include "Python.h" |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 #include "importdl.h" |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
10 #if defined(__hp9000s300) |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
11 #define FUNCNAME_PATTERN "_init%.200s" |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
12 #else |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
13 #define FUNCNAME_PATTERN "init%.200s" |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
14 #endif |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 const struct filedescr _PyImport_DynLoadFiletab[] = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
17 {SHLIB_EXT, "rb", C_EXTENSION}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
18 {"module"SHLIB_EXT, "rb", C_EXTENSION}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
19 {0, 0} |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 }; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
22 dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
23 const char *pathname, FILE *fp) |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
25 dl_funcptr p; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
26 shl_t lib; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
27 int flags; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
28 char funcname[258]; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
30 flags = BIND_FIRST | BIND_DEFERRED; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
31 if (Py_VerboseFlag) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
32 flags = BIND_FIRST | BIND_IMMEDIATE | |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
33 BIND_NONFATAL | BIND_VERBOSE; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
34 printf("shl_load %s\n",pathname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
35 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
36 lib = shl_load(pathname, flags, 0); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
37 /* XXX Chuck Blake once wrote that 0 should be BIND_NOSTART? */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
38 if (lib == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
39 char buf[256]; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
40 if (Py_VerboseFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
41 perror(pathname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
42 PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s", |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
43 pathname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
44 PyErr_SetString(PyExc_ImportError, buf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
45 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
46 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
47 PyOS_snprintf(funcname, sizeof(funcname), FUNCNAME_PATTERN, shortname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
48 if (Py_VerboseFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
49 printf("shl_findsym %s\n", funcname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
50 if (shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p) == -1) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
51 shl_unload(lib); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
52 p = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
53 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
54 if (p == NULL && Py_VerboseFlag) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
55 perror(funcname); |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
38220
diff
changeset
|
57 return p; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 } |
