Mercurial > cpython-lru_cache-weakref
annotate Python/importdl.c @ 7114:fa09372f7872 legacy-trunk
Better #ifdefs for NetBSD, taking into account that at least on netBSD
1.3, dlopen() etc. are fully implemented, including dlerror().
From Jaromir Dolecek and Ty Sarna.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 19 Jan 1998 22:03:52 +0000 |
| parents | 2e3acb2140bf |
| children | c8745d205122 |
| 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" |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 #include "osdefs.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 #include "importdl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 /* 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
|
40 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 symbol -- defined for: |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 DYNAMIC_LINK -- any kind of dynamic linking |
|
2733
dc64df7f1ad6
re-enabled NeXT dynamic linking (#ifdef NeXT)
Guido van Rossum <guido@python.org>
parents:
2729
diff
changeset
|
44 USE_RLD -- NeXT dynamic linking |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 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
|
46 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
|
47 _AIX -- AIX style dynamic linking |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
48 MS_WIN32 -- Windows NT style dynamic linking (using DLLs) |
|
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
49 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
|
50 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
|
51 _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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 __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
|
57 (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
|
58 __FreeBSD__ -- FreeBSD 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 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 (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
|
61 appropriate symbols.) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 /* Configure dynamic linking */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 |
|
3327
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
66 #ifdef __hpux |
| 4042 | 67 #ifndef hpux |
|
3327
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
68 #define hpux |
|
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
69 #endif |
| 4042 | 70 #endif |
|
3327
49f7a4a1f0f6
__hpux -> hpux equivalence
Guido van Rossum <guido@python.org>
parents:
3224
diff
changeset
|
71 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 #ifdef hpux |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 #include <errno.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 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
|
76 #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
|
77 #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
|
78 #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
|
79 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
81 #if defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
82 #define DYNAMIC_LINK |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
83 #define INCL_DOSERRORS |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
84 #define INCL_DOSMODULEMGR |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
85 #include <os2.h> |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
86 typedef int (* APIENTRY dl_funcptr)(); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
87 #define _DL_FUNCPTR_DEFINED 1 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
88 #define SHORT_EXT ".pyd" |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
89 #define LONG_EXT ".dll" |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
90 #endif |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
91 |
|
7114
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
92 #ifdef HAVE_SYS_PARAM_H |
|
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
93 #include <sys/param.h> |
|
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
94 #endif |
|
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
95 |
|
fa09372f7872
Better #ifdefs for NetBSD, taking into account that at least on netBSD
Guido van Rossum <guido@python.org>
parents:
6724
diff
changeset
|
96 #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
|
97 #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
|
98 #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
|
99 |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
100 #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
|
101 #endif |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
102 |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
103 #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
|
104 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 #include <windows.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 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
|
107 #define _DL_FUNCPTR_DEFINED |
|
2085
8921a2881fc7
NT dlls have .pyd extension instead of .dll
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
108 #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
|
109 #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
|
110 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 |
|
2733
dc64df7f1ad6
re-enabled NeXT dynamic linking (#ifdef NeXT)
Guido van Rossum <guido@python.org>
parents:
2729
diff
changeset
|
112 #ifdef NeXT |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 #define USE_RLD |
|
6081
0eb14a6484f3
set sharedlib extensions properly for NeXT (Ted Horst)
Guido van Rossum <guido@python.org>
parents:
5926
diff
changeset
|
115 #define SHORT_EXT ".so" |
|
0eb14a6484f3
set sharedlib extensions properly for NeXT (Ted Horst)
Guido van Rossum <guido@python.org>
parents:
5926
diff
changeset
|
116 #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
|
117 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 #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
|
120 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 #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
|
125 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
129 #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
|
130 #define DYNAMIC_LINK |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
131 #define SHORT_EXT ".slb" |
| 4042 | 132 #ifdef __CFM68K__ |
| 133 #define LONG_EXT ".CFM68K.slb" | |
| 134 #else | |
| 135 #define LONG_EXT ".ppc.slb" | |
| 136 #endif | |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
137 #ifndef _DL_FUNCPTR_DEFINED |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
138 typedef void (*dl_funcptr)(); |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
139 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
140 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
141 |
|
4068
4c54ecfadce5
Don't require <dlfcn.h> -- rely on existence of dlopen().
Guido van Rossum <guido@python.org>
parents:
4042
diff
changeset
|
142 #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
|
143 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 #define USE_SHLIB |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 #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
|
148 #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
|
149 #define DYNAMIC_LINK |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
150 #define SHORT_EXT ".so" |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
151 #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
|
152 #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
|
153 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
|
154 #define _DL_FUNCPTR_DEFINED |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
155 static int aix_getoldmodules(void **); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
156 static int aix_bindnewmodule(void *, void *); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
157 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
|
158 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 #ifdef DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 #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
|
163 #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
|
164 #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
|
165 #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
|
166 #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
|
167 #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
|
168 #else |
|
4068
4c54ecfadce5
Don't require <dlfcn.h> -- rely on existence of dlopen().
Guido van Rossum <guido@python.org>
parents:
4042
diff
changeset
|
169 #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
|
170 #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
|
171 #endif |
|
4068
4c54ecfadce5
Don't require <dlfcn.h> -- rely on existence of dlopen().
Guido van Rossum <guido@python.org>
parents:
4042
diff
changeset
|
172 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 #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
|
174 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
|
175 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 #ifndef RTLD_LAZY |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 #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
|
178 #endif |
|
6724
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
179 #ifndef RTLD_GLOBAL |
|
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
180 #define RTLD_GLOBAL 0 |
|
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
181 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 #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
|
183 #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
|
184 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
185 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 #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
|
187 #include "dl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
190 #ifdef USE_MAC_DYNAMIC_LOADING |
|
3224
2fb398ab3e6a
Added missing include for <Aliases.h>
Jack Jansen <jack.jansen@cwi.nl>
parents:
2843
diff
changeset
|
191 #include <Aliases.h> |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
192 #include <CodeFragments.h> |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
193 #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
|
194 #define CFragConnectionID ConnectionID |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
195 #define kLoadCFrag 0x01 |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
196 #endif |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
197 #include <Files.h> |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
198 #include "macdefs.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
199 #include "macglue.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
200 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
201 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 #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
|
204 #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
|
205 #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
|
206 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
|
207 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 #endif /* USE_RLD */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
210 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
|
211 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 #ifndef FUNCNAME_PATTERN |
|
3420
013bbe4ef943
__FreeBSD__ shared libraries
Guido van Rossum <guido@python.org>
parents:
3327
diff
changeset
|
213 #if defined(__hp9000s300) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__BORLANDC__) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 #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
|
215 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 #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
|
217 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 #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
|
221 #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
|
222 #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
|
223 #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
|
224 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
227 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
|
228 #ifdef SHORT_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 {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
|
230 #endif /* !SHORT_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 #ifdef LONG_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 {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
|
233 #endif /* !LONG_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 {".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
|
235 {".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
|
236 {0, 0} |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 |
|
3898
94c6bf6fd7f4
If NO_DYNAMIC_LINK is defined, load_dynamic_module() will always fail.
Guido van Rossum <guido@python.org>
parents:
3732
diff
changeset
|
239 #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
|
240 #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
|
241 #endif |
|
94c6bf6fd7f4
If NO_DYNAMIC_LINK is defined, load_dynamic_module() will always fail.
Guido van Rossum <guido@python.org>
parents:
3732
diff
changeset
|
242 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
243 PyObject * |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
244 _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
|
245 char *name; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 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
|
247 FILE *fp; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 #ifndef DYNAMIC_LINK |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
250 PyErr_SetString(PyExc_ImportError, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
251 "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
|
252 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
253 #else |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
254 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
|
255 char funcname[258]; |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
256 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
|
257 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
|
258 #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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 } 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
|
264 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
|
265 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
|
266 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
|
267 /* 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
|
268 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
|
269 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
|
270 } |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
271 #endif |
|
5926
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
272 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
|
273 Py_INCREF(m); |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
274 return m; |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
275 } |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
276 lastdot = strrchr(name, '.'); |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
277 if (lastdot == NULL) { |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
278 packagecontext = NULL; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
279 shortname = name; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
280 } |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
281 else { |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
282 packagecontext = name; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
283 shortname = lastdot+1; |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
284 } |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
285 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
|
286 #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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 funcname); |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
296 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
|
297 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
298 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
299 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
|
300 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
|
301 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
|
302 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
303 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
304 #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
|
305 #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
|
306 /* |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
307 ** 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
|
308 ** 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
|
309 ** 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
|
310 ** 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
|
311 ** 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
|
312 ** 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
|
313 */ |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
314 { |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
315 FSSpec libspec; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
316 CFragConnectionID connID; |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
317 Ptr mainAddr; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
318 Str255 errMessage; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
319 OSErr err; |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
320 Boolean isfolder, didsomething; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
321 char buf[512]; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
322 Str63 fragname; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
323 Ptr symAddr; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
324 CFragSymbolClass class; |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
325 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
326 /* First resolve any aliases to find the real file */ |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
327 (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
|
328 err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
329 if ( err ) { |
|
5389
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
330 sprintf(buf, "%.255s: %.200s", |
|
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
331 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
|
332 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
|
333 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
334 } |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
335 /* 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 ".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
|
341 fragname[0] -= 4; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
342 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
|
343 "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
|
344 fragname[0] -= 6; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
345 /* Load the fragment |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
346 (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
|
347 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
|
348 kLoadCFrag, &connID, &mainAddr, |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
349 errMessage); |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
350 if ( err ) { |
|
5389
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
351 sprintf(buf, "%.*s: %.200s", |
|
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
352 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
|
353 PyMac_StrError(err)); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
354 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
|
355 return NULL; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
356 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
357 /* 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
|
358 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
|
359 if ( err ) { |
|
5389
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
360 sprintf(buf, "%s: %.200s", |
|
5a9706965a4e
Avoid some potential (though unlikely) sprintf buffer overflows.
Guido van Rossum <guido@python.org>
parents:
5373
diff
changeset
|
361 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
|
362 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
|
363 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
364 } |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
365 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
|
366 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
367 #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
|
368 #ifdef USE_SHLIB |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 #ifdef RTLD_NOW |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 /* 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
|
372 (i.e. core dump now if some are missing) */ |
|
6724
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
373 void *handle = dlopen(pathname, RTLD_NOW | RTLD_GLOBAL); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
374 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 void *handle; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
376 if (Py_VerboseFlag) |
|
6724
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
377 printf("dlopen(\"%s\", %d);\n", pathname, |
|
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
378 RTLD_LAZY | RTLD_GLOBAL); |
|
2e3acb2140bf
Add the flag RTLD_GLOBAL to the dlopen() options.
Guido van Rossum <guido@python.org>
parents:
6626
diff
changeset
|
379 handle = dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
380 #endif /* RTLD_NOW */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
381 if (handle == NULL) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
382 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
|
383 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
384 } |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
385 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
|
386 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
|
387 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
|
388 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
389 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
390 #ifdef _AIX |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
391 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
392 -- Invoke load() with L_NOAUTODEFER leaving the imported symbols |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
393 -- 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
|
394 -- 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
|
395 -- 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
|
396 -- (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
|
397 -- with loadquery(L_GETINFO). |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
398 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
399 { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
400 static void *staticmodlistptr = NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
401 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
402 if (!staticmodlistptr) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
403 if (aix_getoldmodules(&staticmodlistptr) == -1) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
404 return NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
405 p = (dl_funcptr) load(pathname, L_NOAUTODEFER, 0); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
406 if (p == NULL) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
407 aix_loaderror(pathname); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
408 return NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
409 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
410 if (aix_bindnewmodule((void *)p, staticmodlistptr) == -1) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
411 aix_loaderror(pathname); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
412 return NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
413 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
414 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
415 #endif /* _AIX */ |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
416 #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
|
417 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
418 HINSTANCE hDLL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 hDLL = LoadLibrary(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 if (hDLL==NULL){ |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
421 char errBuf[256]; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
422 unsigned int errorCode; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
423 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
424 /* 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
|
425 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
|
426 from system */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
427 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
|
428 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
429 errorCode = GetLastError(); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
430 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
431 theLength = FormatMessage( |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
432 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
|
433 NULL, /* message source */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
434 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
|
435 0, /* default language environment */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
436 (LPTSTR) theInfo, /* the buffer */ |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
437 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
|
438 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
|
439 |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
440 /* 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
|
441 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
|
442 if (theLength == 0) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
443 sprintf(errBuf, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
444 "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
|
445 errorCode); |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
446 } else { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
447 int len; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
448 /* 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
|
449 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
|
450 if (theLength >= 2 && |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
451 theInfo[theLength-2] == '\r' && |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
452 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
|
453 theLength -= 2; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
454 theInfo[theLength] = '\0'; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
455 } |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
456 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
|
457 len = strlen(errBuf); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
458 strncpy(errBuf+len, theInfo, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
459 sizeof(errBuf)-len); |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
460 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
|
461 } |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
462 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
|
463 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
464 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
465 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
|
466 } |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
467 #endif /* MS_WIN32 */ |
|
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
468 #ifdef MS_WIN16 |
|
3591
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
469 { |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
470 HINSTANCE hDLL; |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
471 hDLL = LoadLibrary(pathname); |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
472 if (hDLL < HINSTANCE_ERROR){ |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
473 char errBuf[256]; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
474 sprintf(errBuf, |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
475 "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
|
476 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
|
477 return NULL; |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
478 } |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
479 p = GetProcAddress(hDLL, funcname); |
|
1c18f90636fb
removed verbose decl; added win3.1 dynamic linking.
Guido van Rossum <guido@python.org>
parents:
3491
diff
changeset
|
480 } |
|
4291
1427d61f1307
Rationalized MS ifdefs
Guido van Rossum <guido@python.org>
parents:
4068
diff
changeset
|
481 #endif /* MS_WIN16 */ |
|
6626
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
482 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
483 #if defined(PYOS_OS2) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
484 { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
485 APIRET rc; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
486 HMODULE hDLL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
487 char failreason[256]; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
488 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
489 rc = DosLoadModule(failreason, |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
490 sizeof(failreason), |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
491 pathname, |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
492 &hDLL); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
493 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
494 if (rc != NO_ERROR) { |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
495 char errBuf[256]; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
496 sprintf(errBuf, |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
497 "DLL load failed, rc = %d, problem '%s': %s", rc, failreason); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
498 PyErr_SetString(PyExc_ImportError, errBuf); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
499 return NULL; |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
500 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
501 |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
502 rc = DosQueryProcAddr(hDLL, 0L, funcname, &p); |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
503 if (rc != NO_ERROR) |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
504 p = NULL; /* Signify Failure to Acquire Entrypoint */ |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
505 } |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
506 #endif /* PYOS_OS2 */ |
|
5e31d381fa47
os2 patch by Jeff Rush
Guido van Rossum <guido@python.org>
parents:
6602
diff
changeset
|
507 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 #ifdef USE_DL |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
509 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
|
510 #endif /* USE_DL */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
511 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
512 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
513 NXStream *errorStream; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
514 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
|
515 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
|
516 long ret; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 unsigned long ptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
518 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
519 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
|
520 filenames[0] = pathname; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
521 filenames[1] = NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
522 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
|
523 filenames, NULL); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
524 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
525 /* 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
|
526 if(!ret) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
527 char *streamBuf; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
528 int len, maxLen; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
529 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
530 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
|
531 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
532 NXGetMemoryBuffer(errorStream, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
533 &streamBuf, &len, &maxLen); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
534 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
|
535 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
536 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
537 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
|
538 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
|
539 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
540 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
|
541 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
542 if(!ret) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
543 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
544 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
545 #endif /* USE_RLD */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
546 #ifdef hpux |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
547 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
548 shl_t lib; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
549 int flags; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
550 |
|
4593
72d0dfb919fe
Some extra flags that an HPUX user wants me to add.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
551 flags = BIND_FIRST | BIND_DEFERRED; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
552 if (Py_VerboseFlag) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
553 { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
554 flags = DYNAMIC_PATH | BIND_FIRST | BIND_IMMEDIATE | |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
555 BIND_NONFATAL | BIND_VERBOSE; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
556 printf("shl_load %s\n",pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
557 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
558 lib = shl_load(pathname, flags, 0); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
559 if (lib == NULL) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
560 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
561 char buf[256]; |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
562 if (Py_VerboseFlag) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
563 perror(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
564 sprintf(buf, "Failed to load %.200s", pathname); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
565 PyErr_SetString(PyExc_ImportError, buf); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
566 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
567 } |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
568 if (Py_VerboseFlag) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
569 printf("shl_findsym %s\n", funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
570 shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
571 if (p == NULL && Py_VerboseFlag) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
572 perror(funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
573 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
574 #endif /* hpux */ |
|
5287
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
4593
diff
changeset
|
575 #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
|
576 got_it: |
|
5287
5af766a1b531
Tweaks to keep the Microsoft compiler quier.
Guido van Rossum <guido@python.org>
parents:
4593
diff
changeset
|
577 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
578 if (p == NULL) { |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
579 PyErr_Format(PyExc_ImportError, |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
580 "dynamic module does not define init function (%s)", |
|
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
581 funcname); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
582 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
583 } |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
584 _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
|
585 (*p)(); |
|
6602
4514a5ea3ec4
Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents:
6479
diff
changeset
|
586 _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
|
587 if (PyErr_Occurred()) |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
588 return NULL; |
|
8d2194e22e67
The last of the mass checkins for separate (sub)interpreters.
Guido van Rossum <guido@python.org>
parents:
5894
diff
changeset
|
589 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
|
590 return NULL; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
591 |
|
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
|
592 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
|
593 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
|
594 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
|
595 "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
|
596 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
597 } |
| 4042 | 598 /* 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
|
599 d = PyModule_GetDict(m); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
600 s = PyString_FromString(pathname); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
601 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
|
602 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
|
603 Py_XDECREF(s); |
|
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
604 if (Py_VerboseFlag) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
605 fprintf(stderr, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
606 "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
|
607 name, pathname); |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
608 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
|
609 return m; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
610 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
611 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
612 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
613 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
614 #ifdef _AIX |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
615 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
616 #include <ctype.h> /* for isdigit() */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
617 #include <errno.h> /* for global errno */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
618 #include <string.h> /* for strerror() */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
619 #include <stdlib.h> /* for malloc(), free() */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
620 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
621 typedef struct Module { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
622 struct Module *next; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
623 void *entry; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
624 } Module, *ModulePtr; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
625 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
626 static int |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
627 aix_getoldmodules(modlistptr) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
628 void **modlistptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
629 { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
630 register ModulePtr modptr, prevmodptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
631 register struct ld_info *ldiptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
632 register char *ldibuf; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
633 register int errflag, bufsize = 1024; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
634 register unsigned int offset; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
635 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
636 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
637 -- 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
|
638 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
639 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
|
640 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
641 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
642 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
643 while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
644 && errno == ENOMEM) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
645 free(ldibuf); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
646 bufsize += 1024; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
647 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
|
648 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
649 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
650 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
651 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
652 if (errflag == -1) { |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5314
diff
changeset
|
653 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
654 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
655 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
656 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
657 -- Make the modules list from the ld_info structures. |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
658 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
659 ldiptr = (struct ld_info *)ldibuf; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
660 prevmodptr = NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
661 do { |
|
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
|
662 if (strstr(ldiptr->ldinfo_filename, "python") == NULL) { |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
663 /* |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
664 -- Extract only the modules containing "python" as a |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
665 -- substring, like the "python[version]" executable or |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
666 -- "libpython[version].a" in case python is embedded. |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
667 */ |
|
58b4d9ea8e51
Shared libraries didn't quite work under AIX because of the change in
Guido van Rossum <guido@python.org>
parents:
6081
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 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
|
672 } |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
673 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
|
674 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
675 while (*modlistptr) { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
676 modptr = (ModulePtr)*modlistptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
677 *modlistptr = (void *)modptr->next; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
678 free(modptr); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
679 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
680 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
681 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
682 modptr->entry = ldiptr->ldinfo_dataorg; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
683 modptr->next = NULL; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
684 if (prevmodptr == NULL) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
685 *modlistptr = (void *)modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
686 else |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
687 prevmodptr->next = modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
688 prevmodptr = modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
689 offset = (unsigned int)ldiptr->ldinfo_next; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
690 ldiptr = (struct ld_info *)((unsigned int)ldiptr + offset); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
691 } while (offset); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
692 free(ldibuf); |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
693 return 0; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
694 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
695 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
696 static int |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
697 aix_bindnewmodule(newmoduleptr, modlistptr) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
698 void *newmoduleptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
699 void *modlistptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
700 { |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
701 register ModulePtr modptr; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
702 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
703 /* |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
704 -- 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
|
705 */ |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
706 for (modptr = (ModulePtr)modlistptr; modptr; modptr = modptr->next) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
707 if (loadbind(0, modptr->entry, newmoduleptr) != 0) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
708 return -1; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
709 return 0; |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
710 } |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
711 |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
712 static void |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
713 aix_loaderror(pathname) |
|
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
714 char *pathname; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
715 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
716 |
|
3732
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
717 char *message[1024], errbuf[1024]; |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
718 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
|
719 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
720 struct errtab { |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
721 int errNo; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
722 char *errstr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
723 } 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
|
724 {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
|
725 {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
|
726 {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
|
727 {L_ERROR_RLDBAD, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
728 "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
|
729 {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
|
730 {L_ERROR_MEMBER, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
731 "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
|
732 {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
|
733 {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
|
734 {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
|
735 {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
|
736 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
737 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
738 #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
|
739 #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
|
740 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
741 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
|
742 |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
743 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
|
744 ERRBUF_APPEND(strerror(errno)); |
|
3732
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
745 ERRBUF_APPEND("\n"); |
|
523f49a1e42a
Corrections to aix_loaderror(), by Manus Hand.
Guido van Rossum <guido@python.org>
parents:
3591
diff
changeset
|
746 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
747 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
|
748 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
|
749 for (j=0; j<LOAD_ERRTAB_LEN ; j++) { |
|
3907
ac1d5abfd78e
Changes for AIX sharedlibs.
Guido van Rossum <guido@python.org>
parents:
3898
diff
changeset
|
750 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
|
751 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
|
752 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
753 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
|
754 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
|
755 ERRBUF_APPEND("\n"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
756 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
757 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
|
758 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
|
759 return; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
760 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
761 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
762 #endif /* _AIX */ |
