Mercurial > cpython-lru_cache-weakref
annotate Python/dynload_shlib.c @ 33318:b57612f61ba3 legacy-trunk
Centralize WITH_TSC processing.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sun, 29 Aug 2004 15:51:52 +0000 |
| parents | e6379bda91d7 |
| children | 0bfd35a76a44 |
| 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 "Python.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 "importdl.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 <sys/types.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 <sys/stat.h> |
|
20546
73a1395a2351
Move dlfcn.h block out of NetBSD block, assuming that NetBSD before
Martin v. Löwis <martin@v.loewis.de>
parents:
20510
diff
changeset
|
9 |
|
20510
bdc486c66df0
Patch to bug #472202: Correctly recognize NetBSD before 199712.
Martin v. Löwis <martin@v.loewis.de>
parents:
19728
diff
changeset
|
10 #if defined(__NetBSD__) |
|
bdc486c66df0
Patch to bug #472202: Correctly recognize NetBSD before 199712.
Martin v. Löwis <martin@v.loewis.de>
parents:
19728
diff
changeset
|
11 #include <sys/param.h> |
|
bdc486c66df0
Patch to bug #472202: Correctly recognize NetBSD before 199712.
Martin v. Löwis <martin@v.loewis.de>
parents:
19728
diff
changeset
|
12 #if (NetBSD < 199712) |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 #include <nlist.h> |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 #include <link.h> |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 #define dlerror() "error in dynamic linking" |
|
20546
73a1395a2351
Move dlfcn.h block out of NetBSD block, assuming that NetBSD before
Martin v. Löwis <martin@v.loewis.de>
parents:
20510
diff
changeset
|
16 #endif |
|
73a1395a2351
Move dlfcn.h block out of NetBSD block, assuming that NetBSD before
Martin v. Löwis <martin@v.loewis.de>
parents:
20510
diff
changeset
|
17 #endif /* NetBSD */ |
|
73a1395a2351
Move dlfcn.h block out of NetBSD block, assuming that NetBSD before
Martin v. Löwis <martin@v.loewis.de>
parents:
20510
diff
changeset
|
18 |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 #ifdef HAVE_DLFCN_H |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 #include <dlfcn.h> |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
21 #else |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
22 #if defined(PYOS_OS2) && defined(PYCC_GCC) |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
23 #include "dlfcn.h" |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
24 #endif |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 #endif |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 |
|
20510
bdc486c66df0
Patch to bug #472202: Correctly recognize NetBSD before 199712.
Martin v. Löwis <martin@v.loewis.de>
parents:
19728
diff
changeset
|
27 #if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__) |
|
15336
bbc991ab6d32
Patch 102114, Bug 11725. On OpenBSD (but apparently not on the other
Guido van Rossum <guido@python.org>
parents:
15036
diff
changeset
|
28 #define LEAD_UNDERSCORE "_" |
|
bbc991ab6d32
Patch 102114, Bug 11725. On OpenBSD (but apparently not on the other
Guido van Rossum <guido@python.org>
parents:
15036
diff
changeset
|
29 #else |
|
bbc991ab6d32
Patch 102114, Bug 11725. On OpenBSD (but apparently not on the other
Guido van Rossum <guido@python.org>
parents:
15036
diff
changeset
|
30 #define LEAD_UNDERSCORE "" |
|
bbc991ab6d32
Patch 102114, Bug 11725. On OpenBSD (but apparently not on the other
Guido van Rossum <guido@python.org>
parents:
15036
diff
changeset
|
31 #endif |
|
bbc991ab6d32
Patch 102114, Bug 11725. On OpenBSD (but apparently not on the other
Guido van Rossum <guido@python.org>
parents:
15036
diff
changeset
|
32 |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 const struct filedescr _PyImport_DynLoadFiletab[] = { |
|
15036
6e9ff060a728
SF "bug" 115973: patches from Norman Vine so that shared libraries and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
35 #ifdef __CYGWIN__ |
|
6e9ff060a728
SF "bug" 115973: patches from Norman Vine so that shared libraries and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
36 {".dll", "rb", C_EXTENSION}, |
|
15806
3b9b8f2ddfe7
Oops, one more part of the cygwin patch (SF patch #102409 by jlt63:
Guido van Rossum <guido@python.org>
parents:
15336
diff
changeset
|
37 {"module.dll", "rb", C_EXTENSION}, |
|
15036
6e9ff060a728
SF "bug" 115973: patches from Norman Vine so that shared libraries and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
38 #else |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
39 #if defined(PYOS_OS2) && defined(PYCC_GCC) |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
40 {".pyd", "rb", C_EXTENSION}, |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
41 {".dll", "rb", C_EXTENSION}, |
|
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
42 #else |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
43 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
44 {".exe", "rb", C_EXTENSION}, |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
45 {".EXE", "rb", C_EXTENSION}, |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
46 {"module.exe", "rb", C_EXTENSION}, |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
47 {"MODULE.EXE", "rb", C_EXTENSION}, |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
48 #else |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 {".so", "rb", C_EXTENSION}, |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 {"module.so", "rb", C_EXTENSION}, |
|
15036
6e9ff060a728
SF "bug" 115973: patches from Norman Vine so that shared libraries and
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
51 #endif |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
52 #endif |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
53 #endif |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 {0, 0} |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 }; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 static struct { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 dev_t dev; |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
59 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
60 ino_t ino[3]; |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
61 #else |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 ino_t ino; |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
63 #endif |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 void *handle; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 } handles[128]; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 static int nhandles = 0; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
69 dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 const char *pathname, FILE *fp) |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 dl_funcptr p; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 void *handle; |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
74 char funcname[258]; |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
75 char pathbuf[260]; |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
15806
diff
changeset
|
76 int dlopenflags=0; |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
77 |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
78 if (strchr(pathname, '/') == NULL) { |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
79 /* Prefix bare filename with "./" */ |
|
21077
379fc66f4c96
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20546
diff
changeset
|
80 PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname); |
|
11618
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
81 pathname = pathbuf; |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
82 } |
|
528559a0b2f2
Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents:
11599
diff
changeset
|
83 |
|
21077
379fc66f4c96
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20546
diff
changeset
|
84 PyOS_snprintf(funcname, sizeof(funcname), |
|
379fc66f4c96
Use PyOS_snprintf instead of sprintf.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20546
diff
changeset
|
85 LEAD_UNDERSCORE "init%.200s", shortname); |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 if (fp != NULL) { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 int i; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 struct stat statb; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 fstat(fileno(fp), &statb); |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 for (i = 0; i < nhandles; i++) { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 if (statb.st_dev == handles[i].dev && |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 statb.st_ino == handles[i].ino) { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 p = (dl_funcptr) dlsym(handles[i].handle, |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 funcname); |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 return p; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 if (nhandles < 128) { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 handles[nhandles].dev = statb.st_dev; |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
101 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
102 handles[nhandles].ino[0] = statb.st_ino[0]; |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
103 handles[nhandles].ino[1] = statb.st_ino[1]; |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
104 handles[nhandles].ino[2] = statb.st_ino[2]; |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
105 #else |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 handles[nhandles].ino = statb.st_ino; |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
107 #endif |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
111 #if !(defined(PYOS_OS2) && defined(PYCC_GCC)) |
|
31799
e6379bda91d7
A few more PyThreadState_Get to PyThreadState_GET conversions
Nicholas Bastin <nick.bastin@gmail.com>
parents:
28949
diff
changeset
|
112 dlopenflags = PyThreadState_GET()->interp->dlopenflags; |
|
22054
5cbcfde3ad55
OS/2 EMX port changes (Python part of patch #450267):
Andrew MacIntyre <andymac@bullseye.apana.org.au>
parents:
21077
diff
changeset
|
113 #endif |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
15806
diff
changeset
|
114 |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 if (Py_VerboseFlag) |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
15806
diff
changeset
|
116 printf("dlopen(\"%s\", %x);\n", pathname, dlopenflags); |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
15806
diff
changeset
|
117 |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
118 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
119 /* VMS currently don't allow a pathname, use a logical name instead */ |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
120 /* Concatenate 'python_module_' and shortname */ |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
121 /* so "import vms.bar" will use the logical python_module_bar */ |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
122 /* As C module use only one name space this is probably not a */ |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
123 /* important limitation */ |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
124 PyOS_snprintf(pathbuf, sizeof(pathbuf), "python_module_%-.200s", |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
125 shortname); |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
126 pathname = pathbuf; |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
127 #endif |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
22054
diff
changeset
|
128 |
|
18689
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
15806
diff
changeset
|
129 handle = dlopen(pathname, dlopenflags); |
|
064de84385ca
Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Martin v. Löwis <martin@v.loewis.de>
parents:
15806
diff
changeset
|
130 |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 if (handle == NULL) { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 PyErr_SetString(PyExc_ImportError, dlerror()); |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 return NULL; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 if (fp != NULL && nhandles < 128) |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 handles[nhandles++].handle = handle; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 p = (dl_funcptr) dlsym(handle, funcname); |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 return p; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 } |
