Mercurial > cpython-lru_cache-weakref
annotate Python/importdl.c @ 11177:5f5fc1031957 legacy-trunk
Vladimir Marangozov fixes an AIX-specific problem, writing:
"""
Following up Robin Dunn's troubles with freeze, here's a patch that
fixes an oddity regarding the import logic of shared modules on AIX.
Symbol resolution of shared modules is now handled properly for the cases
when the python library is linked to a binary with an arbitrary name.
This includes the standard python[version] executable, but also applications
that are embedding the python core (i.e. linked with libpython[version].a,
the latter being static or shared).
"""
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 04 Aug 1999 18:00:12 +0000 |
| parents | 8efa37a770c6 |
| children | c05363cf1b73 |
| rev | line source |
|---|---|
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
2062
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
3 The Netherlands. |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
15 permission. |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
4291
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 ******************************************************************/ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 /* Support for dynamic loading of extension modules */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 /* If no dynamic linking is supported, this file still generates some code! */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
35 #include "Python.h" |
|
7988
0263d3324f0b
Move #include <sys/param.h> to before osdefs.h (Donn Cave).
Guido van Rossum <guido@python.org>
parents:
7121
diff
changeset
|
36 |
|
0263d3324f0b
Move #include <sys/param.h> to before osdefs.h (Donn Cave).
Guido van Rossum <guido@python.org>
parents:
7121
diff
changeset
|
37 #ifdef HAVE_SYS_PARAM_H |
|
0263d3324f0b
Move #include <sys/param.h> to before osdefs.h (Donn Cave).
Guido van Rossum <guido@python.org>
parents:
7121
diff
changeset
|
38 /* osdefs.h will define MAXPATHLEN if it's not already defined. */ |
|
0263d3324f0b
Move #include <sys/param.h> to before osdefs.h (Donn Cave).
Guido van Rossum <guido@python.org>
parents:
7121
diff
changeset
|
39 #include <sys/param.h> |
|
0263d3324f0b
Move #include <sys/param.h> to before osdefs.h (Donn Cave).
Guido van Rossum <guido@python.org>
parents:
7121
diff
changeset
|
40 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 #include "osdefs.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 #include "importdl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 /* Explanation of some of the the various #defines used by dynamic linking... |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 symbol -- defined for: |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 DYNAMIC_LINK -- any kind of dynamic linking |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
49 USE_RLD -- NeXT dynamic linking with FVM shlibs |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
50 USE_DYLD -- NeXT dynamic linking with frameworks |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 USE_DL -- Jack's dl for IRIX 4 or GNU dld with emulation for Jack's dl |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 USE_SHLIB -- SunOS or IRIX 5 (SVR4?) shared libraries |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 _AIX -- AIX style dynamic linking |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
54 MS_WIN32 -- Windows NT style dynamic linking (using DLLs) |
|
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
55 MS_WIN16 -- Windows 16-bit dynamic linking (using DLLs) |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
56 PYOS_OS2 -- IBM OS/2 dynamic linking (using DLLs) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 _DL_FUNCPTR_DEFINED -- if the typedef dl_funcptr has been defined |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
58 USE_MAC_DYNAMIC_LOADING -- Mac CFM shared libraries |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 SHORT_EXT -- short extension for dynamic module, e.g. ".so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 LONG_EXT -- long extension, e.g. "module.so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 hpux -- HP-UX Dynamic Linking - defined by the compiler |
|
7114
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
62 __NetBSD__ -- NetBSD shared libraries |
|
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
63 (assuming dlerror() was introduced between 1.2 and 1.3) |
|
3420
013bbe4ef943
__FreeBSD__ shared libraries
Guido van Rossum <guido@python.org>
parents:
3327
diff
changeset
|
64 __FreeBSD__ -- FreeBSD shared libraries |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
65 __BEOS__ -- BeOS shared libraries - defined by the compiler |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 (The other WITH_* symbols are used only once, to set the |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 appropriate symbols.) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 /* Configure dynamic linking */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 |
|
3327
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
73 #ifdef __hpux |
| 4042 | 74 #ifndef hpux |
|
3327
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
75 #define hpux |
|
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
76 #endif |
| 4042 | 77 #endif |
|
3327
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
78 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 #ifdef hpux |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 #include <errno.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 #define _DL_FUNCPTR_DEFINED 1 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 #define SHORT_EXT ".sl" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 #define LONG_EXT "module.sl" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
88 #if defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
89 #define DYNAMIC_LINK |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
90 #define INCL_DOSERRORS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
91 #define INCL_DOSMODULEMGR |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
92 #include <os2.h> |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
93 typedef int (* APIENTRY dl_funcptr)(); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
94 #define _DL_FUNCPTR_DEFINED 1 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
95 #define SHORT_EXT ".pyd" |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
96 #define LONG_EXT ".dll" |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
97 #endif |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
98 |
|
7114
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
99 #if defined(__NetBSD__) && (NetBSD < 199712) |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
100 #define DYNAMIC_LINK |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
101 #define USE_SHLIB |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
102 |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
103 #define dlerror() "error in dynamic linking" |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
104 #endif |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
105 |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
106 #ifdef MS_WINDOWS /* i.e. MS_WIN32 or MS_WIN16 */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 #include <windows.h> |
|
8569
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
109 #include <direct.h> |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 typedef FARPROC dl_funcptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 #define _DL_FUNCPTR_DEFINED |
|
8356
a7423e68cee9
In debug mode on MS Windows, DLLs are called foo_d.pyd or foo_d.dll.
Guido van Rossum <guido@python.org>
parents:
8032
diff
changeset
|
112 #ifdef _DEBUG |
|
a7423e68cee9
In debug mode on MS Windows, DLLs are called foo_d.pyd or foo_d.dll.
Guido van Rossum <guido@python.org>
parents:
8032
diff
changeset
|
113 #define SHORT_EXT "_d.pyd" |
|
a7423e68cee9
In debug mode on MS Windows, DLLs are called foo_d.pyd or foo_d.dll.
Guido van Rossum <guido@python.org>
parents:
8032
diff
changeset
|
114 #define LONG_EXT "_d.dll" |
|
a7423e68cee9
In debug mode on MS Windows, DLLs are called foo_d.pyd or foo_d.dll.
Guido van Rossum <guido@python.org>
parents:
8032
diff
changeset
|
115 #else |
|
2085
8921a2881fc7
NT dlls have .pyd extension instead of .dll
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
116 #define SHORT_EXT ".pyd" |
|
3491
16a5f6048461
Under NT, change "long" sharedlib extension to ".dll". (Mark H.)
Guido van Rossum <guido@python.org>
parents:
3420
diff
changeset
|
117 #define LONG_EXT ".dll" |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 #endif |
|
8356
a7423e68cee9
In debug mode on MS Windows, DLLs are called foo_d.pyd or foo_d.dll.
Guido van Rossum <guido@python.org>
parents:
8032
diff
changeset
|
119 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
121 #ifdef WITH_DYLD |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
122 #define DYNAMIC_LINK |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
123 #define USE_DYLD |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
124 #define SHORT_EXT ".so" |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
125 #define LONG_EXT "module.so" |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
126 #define FUNCNAME_PATTERN "_init%.200s" |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
127 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
128 |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
129 #if defined(NeXT) && !defined(DYNAMIC_LINK) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 #define USE_RLD |
|
9033
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
132 /* Define this to 1 if you want be able to load ObjC modules as well: |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
133 it switches between two different way of loading modules on the NeXT, |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
134 one that directly interfaces with the dynamic loader (rld_load(), which |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
135 does not correctly load ObjC object files), and another that uses the |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
136 ObjC runtime (objc_loadModules()) to do the job. |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
137 You'll have to add ``-ObjC'' to the compiler flags if you set this to 1. |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
138 */ |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
139 #define HANDLE_OBJC_MODULES 1 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
140 #if HANDLE_OBJC_MODULES |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
141 #include <objc/Object.h> |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
142 #include <objc/objc-load.h> |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
143 #endif |
|
6081
0eb14a6484f3
set sharedlib extensions properly for NeXT (Ted Horst)
Guido van Rossum <guido@python.org>
parents:
5926
diff
changeset
|
144 #define SHORT_EXT ".so" |
|
0eb14a6484f3
set sharedlib extensions properly for NeXT (Ted Horst)
Guido van Rossum <guido@python.org>
parents:
5926
diff
changeset
|
145 #define LONG_EXT "module.so" |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 #ifdef WITH_SGI_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 #ifdef WITH_DL_DLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
158 #ifdef USE_MAC_DYNAMIC_LOADING |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
159 #define DYNAMIC_LINK |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
160 #define SHORT_EXT ".slb" |
| 4042 | 161 #ifdef __CFM68K__ |
| 162 #define LONG_EXT ".CFM68K.slb" | |
| 163 #else | |
| 164 #define LONG_EXT ".ppc.slb" | |
| 165 #endif | |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
166 #ifndef _DL_FUNCPTR_DEFINED |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
167 typedef void (*dl_funcptr)(); |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
168 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
169 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
170 |
|
4068
4c54ecfadce5
Don't require <dlfcn.h> -- rely on existence of dlopen().
Guido van Rossum <guido@python.org>
parents:
4042
diff
changeset
|
171 #if !defined(DYNAMIC_LINK) && (defined(HAVE_DLOPEN) || defined(M_UNIX)) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 #define USE_SHLIB |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 #ifdef _AIX |
|
5894
e2df95b7be78
Removed some variables that are used to exchange data between import.c and
Guido van Rossum <guido@python.org>
parents:
5511
diff
changeset
|
177 #undef USE_SHLIB /* AIX 4.2 and higher have dlfcn.h but we don't want it */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 #define DYNAMIC_LINK |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
179 #define SHORT_EXT ".so" |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
180 #define LONG_EXT "module.so" |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 #include <sys/ldr.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 #define _DL_FUNCPTR_DEFINED |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
184 static int aix_getoldmodules(void **); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
185 static int aix_bindnewmodule(void *, void *); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
186 static void aix_loaderror(char *); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
189 #ifdef __BEOS__ |
|
9205
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
190 #undef USE_SHLIB /* probably not defined anyway */ |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
191 #define DYNAMIC_LINK |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
192 #define SHORT_EXT ".so" |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
193 #define LONG_EXT "module.so" |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
194 typedef void (*dl_funcptr)(void); |
|
9205
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
195 #define _DL_FUNCPTR_DEFINED |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
196 |
|
9205
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
197 #if defined(MAXPATHLEN) && !defined(_SYS_PARAM_H) |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
198 #undef MAXPATHLEN |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
199 #endif |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
200 |
|
9205
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
201 #include <kernel/image.h> |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
202 #include <kernel/OS.h> |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
203 #include <stdlib.h> |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
204 #include <unistd.h> |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
205 |
|
9205
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
206 #ifdef WITH_THREAD |
|
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
207 #include "pythread.h" |
|
9679
877d23bd5bdc
Thanks to Chris Herborth, the thread primitives now have proper Py*
Guido van Rossum <guido@python.org>
parents:
9329
diff
changeset
|
208 static PyThread_type_lock beos_dyn_lock; |
|
9205
0858f11c88d7
Renamed thread.h to pythread.h.
Guido van Rossum <guido@python.org>
parents:
9177
diff
changeset
|
209 #endif |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
210 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
211 static PyObject *beos_dyn_images = NULL; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
212 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
213 static void beos_init_dyn( void ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
214 static void beos_cleanup_dyn( void ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
215 static void beos_nuke_dyn( PyObject *item ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
216 static void beos_add_dyn( char *pathname, image_id id ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
217 #endif |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
218 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 #ifdef DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 #ifdef USE_SHLIB |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
222 #include <sys/types.h> |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
223 #include <sys/stat.h> |
|
7114
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
224 #if defined(__NetBSD__) && (NetBSD < 199712) |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
225 #include <nlist.h> |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
226 #include <link.h> |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
227 #else |
|
4068
4c54ecfadce5
Don't require <dlfcn.h> -- rely on existence of dlopen().
Guido van Rossum <guido@python.org>
parents:
4042
diff
changeset
|
228 #ifdef HAVE_DLFCN_H |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 #include <dlfcn.h> |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
230 #endif |
|
4068
4c54ecfadce5
Don't require <dlfcn.h> -- rely on existence of dlopen().
Guido van Rossum <guido@python.org>
parents:
4042
diff
changeset
|
231 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 #ifndef _DL_FUNCPTR_DEFINED |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 #ifndef RTLD_LAZY |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 #define RTLD_LAZY 1 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 #define SHORT_EXT ".so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 #define LONG_EXT "module.so" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 #if defined(USE_DL) || defined(hpux) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 #include "dl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
244 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
246 #ifdef USE_MAC_DYNAMIC_LOADING |
|
3224
2fb398ab3e6a
Added missing include for <Aliases.h>
Jack Jansen <jack.jansen@cwi.nl>
parents:
2843
diff
changeset
|
247 #include <Aliases.h> |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
248 #include <CodeFragments.h> |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
249 #ifdef SYMANTEC__CFM68K__ /* Really an older version of Universal Headers */ |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
250 #define CFragConnectionID ConnectionID |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
251 #define kLoadCFrag 0x01 |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
252 #endif |
|
9096
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
253 #ifdef USE_GUSI |
|
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
254 #include "TFileSpec.h" /* for Path2FSSpec() */ |
|
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
255 #endif |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
256 #include <Files.h> |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
257 #include "macdefs.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
258 #include "macglue.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
259 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
260 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
261 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 #include <mach-o/rld.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 #ifndef _DL_FUNCPTR_DEFINED |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 typedef void (*dl_funcptr)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 #endif /* USE_RLD */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
268 #ifdef USE_DYLD |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
269 #include <mach-o/dyld.h> |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
270 #ifndef _DL_FUNCPTR_DEFINED |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
271 typedef void (*dl_funcptr)(); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
272 #endif |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
273 #endif /* USE_DYLD */ |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
274 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
275 extern char *Py_GetProgramName(); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
276 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 #ifndef FUNCNAME_PATTERN |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
278 #if defined(__hp9000s300) || (defined(__NetBSD__) || defined(__FreeBSD__)) && !defined(__ELF__) || defined(__OpenBSD__) || defined(__BORLANDC__) || defined(NeXT) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 #define FUNCNAME_PATTERN "_init%.200s" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
281 #define FUNCNAME_PATTERN "init%.200s" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
282 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
283 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
284 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
285 #if !defined(SHORT_EXT) && !defined(LONG_EXT) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
286 #define SHORT_EXT ".o" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
287 #define LONG_EXT "module.o" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
288 #endif /* !SHORT_EXT && !LONG_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
289 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
290 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
291 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
292 struct filedescr _PyImport_Filetab[] = { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
293 #ifdef SHORT_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 {SHORT_EXT, "rb", C_EXTENSION}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
295 #endif /* !SHORT_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
296 #ifdef LONG_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
297 {LONG_EXT, "rb", C_EXTENSION}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 #endif /* !LONG_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 {".py", "r", PY_SOURCE}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 {".pyc", "rb", PY_COMPILED}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
301 {0, 0} |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
303 |
|
3898
94c6bf6fd7f4
If NO_DYNAMIC_LINK is defined, load_dynamic_module() will always fail.
Guido van Rossum <guido@python.org>
parents:
3732
diff
changeset
|
304 #ifdef NO_DYNAMIC_LINK |
|
94c6bf6fd7f4
If NO_DYNAMIC_LINK is defined, load_dynamic_module() will always fail.
Guido van Rossum <guido@python.org>
parents:
3732
diff
changeset
|
305 #undef DYNAMIC_LINK |
|
94c6bf6fd7f4
If NO_DYNAMIC_LINK is defined, load_dynamic_module() will always fail.
Guido van Rossum <guido@python.org>
parents:
3732
diff
changeset
|
306 #endif |
|
94c6bf6fd7f4
If NO_DYNAMIC_LINK is defined, load_dynamic_module() will always fail.
Guido van Rossum <guido@python.org>
parents:
3732
diff
changeset
|
307 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
308 PyObject * |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
309 _PyImport_LoadDynamicModule(name, pathname, fp) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 char *name; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 char *pathname; |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
312 FILE *fp; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 #ifndef DYNAMIC_LINK |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
315 PyErr_SetString(PyExc_ImportError, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
316 "dynamically linked modules not supported"); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 #else |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
319 PyObject *m, *d, *s; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
320 char funcname[258]; |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
321 char *lastdot, *shortname, *packagecontext; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
322 dl_funcptr p = NULL; |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
323 #ifdef USE_SHLIB |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
324 static struct { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
325 dev_t dev; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
326 ino_t ino; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
327 void *handle; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
328 } handles[128]; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
329 static int nhandles = 0; |
|
3988
efb3a5a2cdea
Insert "./" in front of pathname when it contains no '/' (if USE_SHLIB)
Guido van Rossum <guido@python.org>
parents:
3907
diff
changeset
|
330 char pathbuf[260]; |
|
efb3a5a2cdea
Insert "./" in front of pathname when it contains no '/' (if USE_SHLIB)
Guido van Rossum <guido@python.org>
parents:
3907
diff
changeset
|
331 if (strchr(pathname, '/') == NULL) { |
|
efb3a5a2cdea
Insert "./" in front of pathname when it contains no '/' (if USE_SHLIB)
Guido van Rossum <guido@python.org>
parents:
3907
diff
changeset
|
332 /* Prefix bare filename with "./" */ |
|
efb3a5a2cdea
Insert "./" in front of pathname when it contains no '/' (if USE_SHLIB)
Guido van Rossum <guido@python.org>
parents:
3907
diff
changeset
|
333 sprintf(pathbuf, "./%-.255s", pathname); |
|
efb3a5a2cdea
Insert "./" in front of pathname when it contains no '/' (if USE_SHLIB)
Guido van Rossum <guido@python.org>
parents:
3907
diff
changeset
|
334 pathname = pathbuf; |
|
efb3a5a2cdea
Insert "./" in front of pathname when it contains no '/' (if USE_SHLIB)
Guido van Rossum <guido@python.org>
parents:
3907
diff
changeset
|
335 } |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
336 #endif |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
337 if ((m = _PyImport_FindExtension(name, pathname)) != NULL) { |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
338 Py_INCREF(m); |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
339 return m; |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
340 } |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
341 lastdot = strrchr(name, '.'); |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
342 if (lastdot == NULL) { |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
343 packagecontext = NULL; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
344 shortname = name; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
345 } |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
346 else { |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
347 packagecontext = name; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
348 shortname = lastdot+1; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
349 } |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
350 sprintf(funcname, FUNCNAME_PATTERN, shortname); |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
351 #ifdef USE_SHLIB |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
352 if (fp != NULL) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
353 int i; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
354 struct stat statb; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
355 fstat(fileno(fp), &statb); |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
356 for (i = 0; i < nhandles; i++) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
357 if (statb.st_dev == handles[i].dev && |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
358 statb.st_ino == handles[i].ino) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
359 p = (dl_funcptr) dlsym(handles[i].handle, |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
360 funcname); |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
361 goto got_it; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
362 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
363 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
364 if (nhandles < 128) { |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
365 handles[nhandles].dev = statb.st_dev; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
366 handles[nhandles].ino = statb.st_ino; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
367 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
368 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
369 #endif /* USE_SHLIB */ |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
370 #ifdef USE_MAC_DYNAMIC_LOADING |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
371 /* |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
372 ** Dynamic loading of CFM shared libraries on the Mac. The |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
373 ** code has become more convoluted than it was, because we |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
374 ** want to be able to put multiple modules in a single |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
375 ** file. For this reason, we have to determine the fragment |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
376 ** name, and we cannot use the library entry point but we have |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
377 ** to locate the correct init routine "by hand". |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
378 */ |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
379 { |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
380 FSSpec libspec; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
381 CFragConnectionID connID; |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
382 Ptr mainAddr; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
383 Str255 errMessage; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
384 OSErr err; |
|
9096
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
385 #ifndef USE_GUSI |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
386 Boolean isfolder, didsomething; |
|
9096
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
387 #endif |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
388 char buf[512]; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
389 Str63 fragname; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
390 Ptr symAddr; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
391 CFragSymbolClass class; |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
392 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
393 /* First resolve any aliases to find the real file */ |
|
9096
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
394 #ifdef USE_GUSI |
|
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
395 err = Path2FSSpec(pathname, &libspec); |
|
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
396 #else |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
397 (void)FSMakeFSSpec(0, 0, Pstring(pathname), &libspec); |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
398 err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); |
|
9096
2088f80253db
Mac-specific mod to enable aliases on import paths.
Guido van Rossum <guido@python.org>
parents:
9033
diff
changeset
|
399 #endif |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
400 if ( err ) { |
|
5389
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
401 sprintf(buf, "%.255s: %.200s", |
|
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
402 pathname, PyMac_StrError(err)); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
403 PyErr_SetString(PyExc_ImportError, buf); |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
404 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
405 } |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
406 /* Next, determine the fragment name, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
407 by stripping '.slb' and 'module' */ |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
408 memcpy(fragname+1, libspec.name+1, libspec.name[0]); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
409 fragname[0] = libspec.name[0]; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
410 if( strncmp((char *)(fragname+1+fragname[0]-4), |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
411 ".slb", 4) == 0 ) |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
412 fragname[0] -= 4; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
413 if ( strncmp((char *)(fragname+1+fragname[0]-6), |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
414 "module", 6) == 0 ) |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
415 fragname[0] -= 6; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
416 /* Load the fragment |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
417 (or return the connID if it is already loaded */ |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
418 err = GetDiskFragment(&libspec, 0, 0, fragname, |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
419 kLoadCFrag, &connID, &mainAddr, |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
420 errMessage); |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
421 if ( err ) { |
|
5389
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
422 sprintf(buf, "%.*s: %.200s", |
|
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
423 errMessage[0], errMessage+1, |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
424 PyMac_StrError(err)); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
425 PyErr_SetString(PyExc_ImportError, buf); |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
426 return NULL; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
427 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
428 /* Locate the address of the correct init function */ |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
429 err = FindSymbol(connID, Pstring(funcname), &symAddr, &class); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
430 if ( err ) { |
|
5389
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
431 sprintf(buf, "%s: %.200s", |
|
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
432 funcname, PyMac_StrError(err)); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
433 PyErr_SetString(PyExc_ImportError, buf); |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
434 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
435 } |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
436 p = (dl_funcptr)symAddr; |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
437 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
438 #endif /* USE_MAC_DYNAMIC_LOADING */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
439 #ifdef USE_SHLIB |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
440 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
441 #ifdef RTLD_NOW |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
442 /* RTLD_NOW: resolve externals now |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
443 (i.e. core dump now if some are missing) */ |
|
8361
e80d4c3dbb78
Remove use of RTLD_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
8356
diff
changeset
|
444 void *handle = dlopen(pathname, RTLD_NOW); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
445 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
446 void *handle; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
447 if (Py_VerboseFlag) |
|
6724
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
448 printf("dlopen(\"%s\", %d);\n", pathname, |
|
8361
e80d4c3dbb78
Remove use of RTLD_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
8356
diff
changeset
|
449 RTLD_LAZY); |
|
e80d4c3dbb78
Remove use of RTLD_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
8356
diff
changeset
|
450 handle = dlopen(pathname, RTLD_LAZY); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
451 #endif /* RTLD_NOW */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
452 if (handle == NULL) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
453 PyErr_SetString(PyExc_ImportError, dlerror()); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
454 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
455 } |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
456 if (fp != NULL && nhandles < 128) |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
457 handles[nhandles++].handle = handle; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
458 p = (dl_funcptr) dlsym(handle, funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
459 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
460 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
461 #ifdef _AIX |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
462 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
463 -- Invoke load() with L_NOAUTODEFER leaving the imported symbols |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
464 -- of the shared module unresolved. Thus we have to resolve them |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
465 -- explicitely with loadbind. The new module is loaded, then we |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
466 -- resolve its symbols using the list of already loaded modules |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
467 -- (only those that belong to the python executable). Get these |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
468 -- with loadquery(L_GETINFO). |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
469 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
470 { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
471 static void *staticmodlistptr = NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
472 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
473 if (!staticmodlistptr) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
474 if (aix_getoldmodules(&staticmodlistptr) == -1) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
475 return NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
476 p = (dl_funcptr) load(pathname, L_NOAUTODEFER, 0); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
477 if (p == NULL) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
478 aix_loaderror(pathname); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
479 return NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
480 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
481 if (aix_bindnewmodule((void *)p, staticmodlistptr) == -1) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
482 aix_loaderror(pathname); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
483 return NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
484 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
485 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 #endif /* _AIX */ |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
487 #ifdef MS_WIN32 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
488 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
489 HINSTANCE hDLL; |
|
8569
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
490 char pathbuf[260]; |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
491 if (strchr(pathname, SEP) == NULL && |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
492 strchr(pathname, ALTSEP) == NULL) |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
493 { |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
494 /* Prefix bare filename with ".\" */ |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
495 char *p = pathbuf; |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
496 *p = '\0'; |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
497 _getcwd(pathbuf, sizeof pathbuf); |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
498 if (*p != '\0' && p[1] == ':') |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
499 p += 2; |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
500 sprintf(p, ".\\%-.255s", pathname); |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
501 pathname = pathbuf; |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
502 } |
| 9299 | 503 /* Look for dependent DLLs in directory of pathname first */ |
| 504 /* XXX This call doesn't exist in Windows CE */ | |
| 505 hDLL = LoadLibraryEx(pathname, NULL, | |
| 506 LOAD_WITH_ALTERED_SEARCH_PATH); | |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
507 if (hDLL==NULL){ |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
508 char errBuf[256]; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
509 unsigned int errorCode; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
510 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
511 /* Get an error string from Win32 error code */ |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
512 char theInfo[256]; /* Pointer to error text |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
513 from system */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
514 int theLength; /* Length of error text */ |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
515 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
516 errorCode = GetLastError(); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
517 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
518 theLength = FormatMessage( |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
519 FORMAT_MESSAGE_FROM_SYSTEM, /* flags */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
520 NULL, /* message source */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
521 errorCode, /* the message (error) ID */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
522 0, /* default language environment */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
523 (LPTSTR) theInfo, /* the buffer */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
524 sizeof(theInfo), /* the buffer size */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
525 NULL); /* no additional format args. */ |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
526 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
527 /* Problem: could not get the error message. |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
528 This should not happen if called correctly. */ |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
529 if (theLength == 0) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
530 sprintf(errBuf, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
531 "DLL load failed with error code %d", |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
532 errorCode); |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
533 } else { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
534 int len; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
535 /* For some reason a \r\n |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
536 is appended to the text */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
537 if (theLength >= 2 && |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
538 theInfo[theLength-2] == '\r' && |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
539 theInfo[theLength-1] == '\n') { |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
540 theLength -= 2; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
541 theInfo[theLength] = '\0'; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
542 } |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
543 strcpy(errBuf, "DLL load failed: "); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
544 len = strlen(errBuf); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
545 strncpy(errBuf+len, theInfo, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
546 sizeof(errBuf)-len); |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
547 errBuf[sizeof(errBuf)-1] = '\0'; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
548 } |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
549 PyErr_SetString(PyExc_ImportError, errBuf); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
550 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
551 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
552 p = GetProcAddress(hDLL, funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
553 } |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
554 #endif /* MS_WIN32 */ |
|
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
555 #ifdef MS_WIN16 |
|
3591
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
556 { |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
557 HINSTANCE hDLL; |
|
8569
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
558 char pathbuf[16]; |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
559 if (strchr(pathname, SEP) == NULL && |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
560 strchr(pathname, ALTSEP) == NULL) |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
561 { |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
562 /* Prefix bare filename with ".\" */ |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
563 sprintf(pathbuf, ".\\%-.13s", pathname); |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
564 pathname = pathbuf; |
|
450076068b22
Windows-specific hack to make sure that when LoadLibrary() is called,
Guido van Rossum <guido@python.org>
parents:
8361
diff
changeset
|
565 } |
|
3591
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
566 hDLL = LoadLibrary(pathname); |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
567 if (hDLL < HINSTANCE_ERROR){ |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
568 char errBuf[256]; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
569 sprintf(errBuf, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
570 "DLL load failed with error code %d", hDLL); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
571 PyErr_SetString(PyExc_ImportError, errBuf); |
|
3591
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
572 return NULL; |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
573 } |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
574 p = GetProcAddress(hDLL, funcname); |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
575 } |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
576 #endif /* MS_WIN16 */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
577 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
578 #if defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
579 { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
580 APIRET rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
581 HMODULE hDLL; |
|
8650
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
582 char failreason[256]; |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
583 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
584 rc = DosLoadModule(failreason, |
|
8650
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
585 sizeof(failreason), |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
586 pathname, |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
587 &hDLL); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
588 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
589 if (rc != NO_ERROR) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
590 char errBuf[256]; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
591 sprintf(errBuf, |
|
8650
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
592 "DLL load failed, rc = %d, problem '%s': %s", |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
593 rc, failreason); |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
594 PyErr_SetString(PyExc_ImportError, errBuf); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
595 return NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
596 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
597 |
|
8650
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
598 rc = DosQueryProcAddr(hDLL, 0L, funcname, &p); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
599 if (rc != NO_ERROR) |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
600 p = NULL; /* Signify Failure to Acquire Entrypoint */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
601 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
602 #endif /* PYOS_OS2 */ |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
603 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
604 #ifdef USE_DL |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
605 p = dl_loadmod(Py_GetProgramName(), pathname, funcname); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
606 #endif /* USE_DL */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
607 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
608 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
609 NXStream *errorStream; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
610 struct mach_header *new_header; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
611 const char *filenames[2]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
612 long ret; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
613 unsigned long ptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
614 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
615 errorStream = NXOpenMemory(NULL, 0, NX_WRITEONLY); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
616 filenames[0] = pathname; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
617 filenames[1] = NULL; |
|
9033
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
618 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
619 #if HANDLE_OBJC_MODULES |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
620 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
621 /* The following very bogus line of code ensures that |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
622 objc_msgSend, etc are linked into the binary. Without |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
623 it, dynamic loading of a module that includes objective-c |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
624 method calls will fail with "undefined symbol _objc_msgSend()". |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
625 This remains true even in the presence of the -ObjC flag |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
626 to the compiler |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
627 */ |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
628 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
629 [Object name]; |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
630 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
631 /* objc_loadModules() dynamically loads the object files |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
632 indicated by the paths in filenames. If there are any |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
633 errors generated during loading -- typically due to the |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
634 inability to find particular symbols -- an error message |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
635 will be written to errorStream. |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
636 It returns 0 if the module is successfully loaded, 1 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
637 otherwise. |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
638 */ |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
639 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
640 ret = !objc_loadModules(filenames, errorStream, |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
641 NULL, &new_header, NULL); |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
642 |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
643 #else /* !HANDLE_OBJC_MODULES */ |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
644 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
645 ret = rld_load(errorStream, &new_header, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
646 filenames, NULL); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
647 |
|
9033
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
648 #endif /* HANDLE_OBJC_MODULES */ |
|
9962833d49fd
Ted Horst writes in psa-members@python.org:
Guido van Rossum <guido@python.org>
parents:
8822
diff
changeset
|
649 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
650 /* extract the error messages for the exception */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
651 if(!ret) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
652 char *streamBuf; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
653 int len, maxLen; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
654 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
655 NXPutc(errorStream, (char)0); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
656 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
657 NXGetMemoryBuffer(errorStream, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
658 &streamBuf, &len, &maxLen); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
659 PyErr_SetString(PyExc_ImportError, streamBuf); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
660 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
661 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
662 if(ret && rld_lookup(errorStream, funcname, &ptr)) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
663 p = (dl_funcptr) ptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
664 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
665 NXCloseMemory(errorStream, NX_FREEBUFFER); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
666 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
667 if(!ret) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
668 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
669 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
670 #endif /* USE_RLD */ |
|
9970
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
671 #ifdef USE_DYLD |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
672 /* This is also NeXT-specific. However, frameworks (the new style |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
673 of shared library) and rld() can't be used in the same program; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
674 instead, you have to use dyld, which is mostly unimplemented. */ |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
675 { |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
676 NSObjectFileImageReturnCode rc; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
677 NSObjectFileImage image; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
678 NSModule newModule; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
679 NSSymbol theSym; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
680 void *symaddr; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
681 const char *errString; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
682 |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
683 rc = NSCreateObjectFileImageFromFile(pathname, &image); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
684 switch(rc) { |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
685 default: |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
686 case NSObjectFileImageFailure: |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
687 NSObjectFileImageFormat: |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
688 /* for these a message is printed on stderr by dyld */ |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
689 errString = "Can't create object file image"; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
690 break; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
691 case NSObjectFileImageSuccess: |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
692 errString = NULL; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
693 break; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
694 case NSObjectFileImageInappropriateFile: |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
695 errString = "Inappropriate file type for dynamic loading"; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
696 break; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
697 case NSObjectFileImageArch: |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
698 errString = "Wrong CPU type in object file"; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
699 break; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
700 NSObjectFileImageAccess: |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
701 errString = "Can't read object file (no access)"; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
702 break; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
703 } |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
704 if (errString == NULL) { |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
705 newModule = NSLinkModule(image, pathname, TRUE); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
706 if (!newModule) |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
707 errString = "Failure linking new module"; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
708 } |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
709 if (errString != NULL) { |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
710 PyErr_SetString(PyExc_ImportError, errString); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
711 return NULL; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
712 } |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
713 if (!NSIsSymbolNameDefined(funcname)) { |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
714 /* UnlinkModule() isn't implimented in current versions, but calling it does no harm */ |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
715 NSUnLinkModule(newModule, FALSE); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
716 PyErr_Format(PyExc_ImportError, "Loaded module does not contain symbol %s", funcname); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
717 return NULL; |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
718 } |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
719 theSym = NSLookupAndBindSymbol(funcname); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
720 p = (dl_funcptr)NSAddressOfSymbol(theSym); |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
721 } |
|
8efa37a770c6
Patches by William Lewis for Nextstep descendants.
Guido van Rossum <guido@python.org>
parents:
9808
diff
changeset
|
722 #endif /* USE_DYLD */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
723 #ifdef hpux |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
724 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
725 shl_t lib; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
726 int flags; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
727 |
|
4593
72d0dfb919fe
Some extra flags that an HPUX user wants me to add.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
728 flags = BIND_FIRST | BIND_DEFERRED; |
|
8650
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
729 if (Py_VerboseFlag) { |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
730 flags = DYNAMIC_PATH | BIND_FIRST | BIND_IMMEDIATE | |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
731 BIND_NONFATAL | BIND_VERBOSE; |
|
8650
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
732 printf("shl_load %s\n",pathname); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
733 } |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
734 lib = shl_load(pathname, flags, 0); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
735 /* XXX Chuck Blake once wrote that 0 should be BIND_NOSTART? */ |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
736 if (lib == NULL) { |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
737 char buf[256]; |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
738 if (Py_VerboseFlag) |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
739 perror(pathname); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
740 sprintf(buf, "Failed to load %.200s", pathname); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
741 PyErr_SetString(PyExc_ImportError, buf); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
742 return NULL; |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
743 } |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
744 if (Py_VerboseFlag) |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
745 printf("shl_findsym %s\n", funcname); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
746 shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p); |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
747 if (p == NULL && Py_VerboseFlag) |
|
3be906467740
Reindented some OS/2 and hpux code that looked ugly or at least
Guido van Rossum <guido@python.org>
parents:
8569
diff
changeset
|
748 perror(funcname); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
749 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
750 #endif /* hpux */ |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
751 #ifdef __BEOS__ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
752 { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
753 image_id the_id; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
754 status_t retval; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
755 char fullpath[PATH_MAX]; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
756 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
757 if( Py_VerboseFlag ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
758 printf( "load_add_on( %s )\n", pathname ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
759 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
760 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
761 /* Hmm, this old bug appears to have regenerated itself; if the |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
762 * path isn't absolute, load_add_on() will fail. Reported to Be |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
763 * April 21, 1998. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
764 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
765 if( pathname[0] != '/' ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
766 (void)getcwd( fullpath, PATH_MAX ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
767 (void)strncat( fullpath, "/", PATH_MAX ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
768 (void)strncat( fullpath, pathname, PATH_MAX ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
769 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
770 if( Py_VerboseFlag ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
771 printf( "load_add_on( %s )\n", fullpath ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
772 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
773 } else { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
774 (void)strcpy( fullpath, pathname ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
775 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
776 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
777 the_id = load_add_on( fullpath ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
778 if( the_id < B_NO_ERROR ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
779 /* It's too bad load_add_on() doesn't set errno or something... |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
780 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
781 char buff[256]; /* hate hard-coded string sizes... */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
782 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
783 if( Py_VerboseFlag ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
784 printf( "load_add_on( %s ) failed", fullpath ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
785 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
786 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
787 switch( the_id ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
788 case B_ERROR: |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
789 sprintf( buff, "BeOS: Failed to load %.200s", fullpath ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
790 break; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
791 default: |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
792 sprintf( buff, "Unknown error loading %.200s", fullpath ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
793 break; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
794 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
795 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
796 PyErr_SetString( PyExc_ImportError, buff ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
797 return NULL; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
798 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
799 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
800 if( Py_VerboseFlag ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
801 printf( "get_image_symbol( %s )\n", funcname ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
802 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
803 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
804 retval = get_image_symbol( the_id, funcname, B_SYMBOL_TYPE_TEXT, &p ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
805 if( retval != B_NO_ERROR || p == NULL ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
806 /* That's bad, we can't find that symbol in the module... |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
807 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
808 char buff[256]; /* hate hard-coded string sizes... */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
809 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
810 if( Py_VerboseFlag ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
811 printf( "get_image_symbol( %s ) failed", funcname ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
812 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
813 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
814 switch( retval ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
815 case B_BAD_IMAGE_ID: |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
816 sprintf( buff, "can't load init function for dynamic module: " |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
817 "Invalid image ID for %.180s", fullpath ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
818 break; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
819 case B_BAD_INDEX: |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
820 sprintf( buff, "can't load init function for dynamic module: " |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
821 "Bad index for %.180s", funcname ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
822 break; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
823 default: |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
824 sprintf( buff, "can't load init function for dynamic module: " |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
825 "Unknown error looking up %.180s", funcname ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
826 break; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
827 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
828 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
829 retval = unload_add_on( the_id ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
830 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
831 PyErr_SetString( PyExc_ImportError, buff ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
832 return NULL; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
833 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
834 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
835 /* Save the module name and image ID for later so we can clean up |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
836 * gracefully. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
837 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
838 beos_add_dyn( name, the_id ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
839 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
840 #endif /* __BEOS__ */ |
|
5287
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
4593
diff
changeset
|
841 #ifdef USE_SHLIB |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
842 got_it: |
|
5287
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
4593
diff
changeset
|
843 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
844 if (p == NULL) { |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
845 PyErr_Format(PyExc_ImportError, |
|
7121
c8745d205122
Protect PyErr_Format format string argument from overflow.
Guido van Rossum <guido@python.org>
parents:
7114
diff
changeset
|
846 "dynamic module does not define init function (%.200s)", |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
847 funcname); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
848 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
849 } |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
850 _Py_PackageContext = packagecontext; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
851 (*p)(); |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
852 _Py_PackageContext = NULL; |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
853 if (PyErr_Occurred()) |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
854 return NULL; |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
855 if (_PyImport_FixupExtension(name, pathname) == NULL) |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
856 return NULL; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
857 |
|
5894
e2df95b7be78
Removed some variables that are used to exchange data between import.c and
Guido van Rossum <guido@python.org>
parents:
5511
diff
changeset
|
858 m = PyDict_GetItemString(PyImport_GetModuleDict(), name); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
859 if (m == NULL) { |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
860 PyErr_SetString(PyExc_SystemError, |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
861 "dynamic module not initialized properly"); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
862 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
863 } |
| 4042 | 864 /* Remember the filename as the __file__ attribute */ |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
865 d = PyModule_GetDict(m); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
866 s = PyString_FromString(pathname); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
867 if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0) |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
868 PyErr_Clear(); /* Not important enough to report */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
869 Py_XDECREF(s); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
870 if (Py_VerboseFlag) |
|
9329
7f242f29a45f
Replace fprintf(stderr, ...) with PySys_WriteStderr(...).
Guido van Rossum <guido@python.org>
parents:
9299
diff
changeset
|
871 PySys_WriteStderr( |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
872 "import %s # dynamically loaded from %s\n", |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
873 name, pathname); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
874 Py_INCREF(m); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
875 return m; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
876 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
877 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
878 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
879 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
880 #ifdef _AIX |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
881 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
882 #include <ctype.h> /* for isdigit() */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
883 #include <errno.h> /* for global errno */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
884 #include <string.h> /* for strerror() */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
885 #include <stdlib.h> /* for malloc(), free() */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
886 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
887 typedef struct Module { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
888 struct Module *next; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
889 void *entry; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
890 } Module, *ModulePtr; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
891 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
892 static int |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
893 aix_getoldmodules(modlistptr) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
894 void **modlistptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
895 { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
896 register ModulePtr modptr, prevmodptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
897 register struct ld_info *ldiptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
898 register char *ldibuf; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
899 register int errflag, bufsize = 1024; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
900 register unsigned int offset; |
|
11177
5f5fc1031957
Vladimir Marangozov fixes an AIX-specific problem, writing:
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
901 char *progname = Py_GetProgramName(); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
902 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
903 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
904 -- Get the list of loaded modules into ld_info structures. |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
905 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
906 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
907 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
908 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
909 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
910 while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
911 && errno == ENOMEM) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
912 free(ldibuf); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
913 bufsize += 1024; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
914 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
915 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
916 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
917 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
918 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
919 if (errflag == -1) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
920 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
921 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
922 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
923 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
924 -- Make the modules list from the ld_info structures. |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
925 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
926 ldiptr = (struct ld_info *)ldibuf; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
927 prevmodptr = NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
928 do { |
|
11177
5f5fc1031957
Vladimir Marangozov fixes an AIX-specific problem, writing:
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
929 if (strstr(progname, ldiptr->ldinfo_filename) == NULL && |
|
5f5fc1031957
Vladimir Marangozov fixes an AIX-specific problem, writing:
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
930 strstr(ldiptr->ldinfo_filename, "python") == NULL) { |
|
6479
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
931 /* |
|
11177
5f5fc1031957
Vladimir Marangozov fixes an AIX-specific problem, writing:
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
932 -- Extract only the modules belonging to the main |
|
5f5fc1031957
Vladimir Marangozov fixes an AIX-specific problem, writing:
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
933 -- executable + those containing "python" as a |
|
5f5fc1031957
Vladimir Marangozov fixes an AIX-specific problem, writing:
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
934 -- substring (like the "python[version]" binary or |
|
5f5fc1031957
Vladimir Marangozov fixes an AIX-specific problem, writing:
Guido van Rossum <guido@python.org>
parents:
9970
diff
changeset
|
935 -- "libpython[version].a" in case it's a shared lib). |
|
6479
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
936 */ |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
937 offset = (unsigned int)ldiptr->ldinfo_next; |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
938 ldiptr = (struct ld_info *)((unsigned int) |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
939 ldiptr + offset); |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
940 continue; |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
941 } |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
942 if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
943 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
944 while (*modlistptr) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
945 modptr = (ModulePtr)*modlistptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
946 *modlistptr = (void *)modptr->next; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
947 free(modptr); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
948 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
949 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
950 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
951 modptr->entry = ldiptr->ldinfo_dataorg; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
952 modptr->next = NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
953 if (prevmodptr == NULL) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
954 *modlistptr = (void *)modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
955 else |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
956 prevmodptr->next = modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
957 prevmodptr = modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
958 offset = (unsigned int)ldiptr->ldinfo_next; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
959 ldiptr = (struct ld_info *)((unsigned int)ldiptr + offset); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
960 } while (offset); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
961 free(ldibuf); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
962 return 0; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
963 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
964 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
965 static int |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
966 aix_bindnewmodule(newmoduleptr, modlistptr) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
967 void *newmoduleptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
968 void *modlistptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
969 { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
970 register ModulePtr modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
971 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
972 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
973 -- Bind the new module with the list of loaded modules. |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
974 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
975 for (modptr = (ModulePtr)modlistptr; modptr; modptr = modptr->next) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
976 if (loadbind(0, modptr->entry, newmoduleptr) != 0) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
977 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
978 return 0; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
979 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
980 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
981 static void |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
982 aix_loaderror(pathname) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
983 char *pathname; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
984 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
985 |
|
3732
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
986 char *message[1024], errbuf[1024]; |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
987 register int i,j; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
988 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
989 struct errtab { |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
990 int errNo; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
991 char *errstr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
992 } load_errtab[] = { |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
993 {L_ERROR_TOOMANY, "too many errors, rest skipped."}, |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
994 {L_ERROR_NOLIB, "can't load library:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
995 {L_ERROR_UNDEF, "can't find symbol in library:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
996 {L_ERROR_RLDBAD, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
997 "RLD index out of range or bad relocation type:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
998 {L_ERROR_FORMAT, "not a valid, executable xcoff file:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
999 {L_ERROR_MEMBER, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1000 "file not an archive or does not contain requested member:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1001 {L_ERROR_TYPE, "symbol table mismatch:"}, |
|
3732
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
1002 {L_ERROR_ALIGN, "text alignment in file is wrong."}, |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1003 {L_ERROR_SYSTEM, "System error:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1004 {L_ERROR_ERRNO, NULL} |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1005 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1006 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1007 #define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0])) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1008 #define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1009 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
1010 sprintf(errbuf, "from module %.200s ", pathname); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1011 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
1012 if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1013 ERRBUF_APPEND(strerror(errno)); |
|
3732
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
1014 ERRBUF_APPEND("\n"); |
|
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
1015 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1016 for(i = 0; message[i] && *message[i]; i++) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1017 int nerr = atoi(message[i]); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1018 for (j=0; j<LOAD_ERRTAB_LEN ; j++) { |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
1019 if (nerr == load_errtab[j].errNo && load_errtab[j].errstr) |
|
3732
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
1020 ERRBUF_APPEND(load_errtab[j].errstr); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1021 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1022 while (isdigit(*message[i])) message[i]++ ; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1023 ERRBUF_APPEND(message[i]); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1024 ERRBUF_APPEND("\n"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1025 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1026 errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
1027 PyErr_SetString(PyExc_ImportError, errbuf); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1028 return; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1029 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1030 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1031 #endif /* _AIX */ |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1032 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1033 #ifdef __BEOS__ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1034 /* ---------------------------------------------------------------------- |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1035 * BeOS dynamic loading support |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1036 * |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1037 * This uses shared libraries, but BeOS has its own way of doing things |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1038 * (much easier than dlfnc.h, from the look of things). We'll use a |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1039 * Python Dictionary object to store the images_ids so we can be very |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1040 * nice and unload them when we exit. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1041 * |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1042 * Note that this is thread-safe. Probably irrelevent, because of losing |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1043 * systems... Python probably disables threads while loading modules. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1044 * Note the use of "probably"! Better to be safe than sorry. [chrish] |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1045 * |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1046 * As of 1.5.1 this should also work properly when you've configured |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1047 * Python without thread support; the 1.5 version required it, which wasn't |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1048 * very friendly. Note that I haven't tested it without threading... why |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1049 * would you want to avoid threads on BeOS? [chrish] |
|
9760
3e7c43453e5e
Chris Herborth writes:
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
1050 * |
|
3e7c43453e5e
Chris Herborth writes:
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
1051 * As of 1.5.2, the PyImport_BeImageID() function has been removed; Donn |
|
3e7c43453e5e
Chris Herborth writes:
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
1052 * tells me it's not necessary anymore because of PyCObject_Import(). |
|
3e7c43453e5e
Chris Herborth writes:
Guido van Rossum <guido@python.org>
parents:
9679
diff
changeset
|
1053 * [chrish] |
|
8822
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1054 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1055 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1056 /* |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1057 * Initialize our dictionary, and the dictionary mutex. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1058 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1059 static void beos_init_dyn( void ) |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1060 { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1061 /* We're protected from a race condition here by the atomic init_count |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1062 * variable. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1063 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1064 static int32 init_count = 0; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1065 int32 val; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1066 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1067 val = atomic_add( &init_count, 1 ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1068 if( beos_dyn_images == NULL && val == 0 ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1069 beos_dyn_images = PyDict_New(); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1070 #ifdef WITH_THREAD |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1071 beos_dyn_lock = PyThread_allocate_lock(); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1072 #endif |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1073 atexit( beos_cleanup_dyn ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1074 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1075 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1076 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1077 /* atexit() handler that'll call unload_add_on() for every item in the |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1078 * dictionary. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1079 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1080 static void beos_cleanup_dyn( void ) |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1081 { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1082 if( beos_dyn_images ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1083 int idx; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1084 int list_size; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1085 PyObject *id_list; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1086 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1087 #ifdef WITH_THREAD |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1088 PyThread_acquire_lock( beos_dyn_lock, 1 ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1089 #endif |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1090 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1091 id_list = PyDict_Values( beos_dyn_images ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1092 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1093 list_size = PyList_Size( id_list ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1094 for( idx = 0; idx < list_size; idx++ ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1095 PyObject *the_item; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1096 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1097 the_item = PyList_GetItem( id_list, idx ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1098 beos_nuke_dyn( the_item ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1099 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1100 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1101 PyDict_Clear( beos_dyn_images ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1102 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1103 #ifdef WITH_THREAD |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1104 PyThread_free_lock( beos_dyn_lock ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1105 #endif |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1106 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1107 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1108 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1109 /* Whack an item; the item is an image_id in disguise, so we'll call |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1110 * unload_add_on() for it. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1111 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1112 static void beos_nuke_dyn( PyObject *item ) |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1113 { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1114 status_t retval; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1115 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1116 if( item ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1117 image_id id = (image_id)PyInt_AsLong( item ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1118 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1119 retval = unload_add_on( id ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1120 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1121 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1122 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1123 /* |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1124 * Add an image_id to the dictionary; the module name of the loaded image |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1125 * is the key. Note that if the key is already in the dict, we unload |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1126 * that image; this should allow reload() to work on dynamically loaded |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1127 * modules (super-keen!). |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1128 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1129 static void beos_add_dyn( char *name, image_id id ) |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1130 { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1131 int retval; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1132 PyObject *py_id; |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1133 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1134 if( beos_dyn_images == NULL ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1135 beos_init_dyn(); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1136 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1137 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1138 #ifdef WITH_THREAD |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1139 retval = PyThread_acquire_lock( beos_dyn_lock, 1 ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1140 #endif |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1141 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1142 /* If there's already an object with this key in the dictionary, |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1143 * we're doing a reload(), so let's nuke it. |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1144 */ |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1145 py_id = PyDict_GetItemString( beos_dyn_images, name ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1146 if( py_id ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1147 beos_nuke_dyn( py_id ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1148 retval = PyDict_DelItemString( beos_dyn_images, name ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1149 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1150 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1151 py_id = PyInt_FromLong( (long)id ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1152 if( py_id ) { |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1153 retval = PyDict_SetItemString( beos_dyn_images, name, py_id ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1154 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1155 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1156 #ifdef WITH_THREAD |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1157 PyThread_release_lock( beos_dyn_lock ); |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1158 #endif |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1159 } |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1160 |
|
bd47ee068b83
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8650
diff
changeset
|
1161 #endif /* __BEOS__ */ |
