Mercurial > cpython-lru_cache-weakref
annotate Python/importdl.c @ 3323:6098aaa8ae7f legacy-trunk
changes for complex numbers
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 12 Jan 1996 01:09:56 +0000 |
| parents | 2fb398ab3e6a |
| children | 49f7a4a1f0f6 |
| 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 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
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 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
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 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 /* 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
|
26 /* 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
|
27 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #include "allobjects.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 #include "osdefs.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 #include "importdl.h" |
|
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 extern int verbose; /* Defined in pythonrun.c */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 /* 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
|
35 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 symbol -- defined for: |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 _AIX -- AIX style dynamic linking |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 NT -- NT style dynamic linking (using DLLs) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 _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
|
45 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
|
46 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
|
47 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
|
48 hpux -- HP-UX Dynamic Linking - defined by the compiler |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
49 __NetBSD__ -- NetBSD shared libraries (not quite SVR4 compatible) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 (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
|
52 appropriate symbols.) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 /* Configure dynamic linking */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 #ifdef hpux |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 #include <errno.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 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
|
61 #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
|
62 #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
|
63 #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
|
64 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
66 #ifdef __NetBSD__ |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
67 #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
|
68 #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
|
69 |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
70 #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
|
71 #endif |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
72 |
| 2435 | 73 #ifdef __WIN32__ |
| 74 #define NT | |
| 75 #endif | |
| 76 | |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 #ifdef NT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 #include <windows.h> |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 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
|
81 #define _DL_FUNCPTR_DEFINED |
|
2085
8921a2881fc7
NT dlls have .pyd extension instead of .dll
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
82 #define SHORT_EXT ".pyd" |
|
8921a2881fc7
NT dlls have .pyd extension instead of .dll
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
83 #define LONG_EXT "module.pyd" |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 |
|
2733
dc64df7f1ad6
re-enabled NeXT dynamic linking (#ifdef NeXT)
Guido van Rossum <guido@python.org>
parents:
2729
diff
changeset
|
86 #ifdef NeXT |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 #define USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 #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
|
92 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 #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
|
97 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 #define USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
101 #ifdef __CFM68K__ |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
102 #define 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
|
103 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
105 #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
|
106 #define DYNAMIC_LINK |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
107 #define SHORT_EXT ".slb" |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
108 #define LONG_EXT "module.slb" |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
109 #ifndef _DL_FUNCPTR_DEFINED |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
110 typedef void (*dl_funcptr)(); |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
111 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
112 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
113 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 #if !defined(DYNAMIC_LINK) && defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 #define DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 #define USE_SHLIB |
|
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 _AIX |
|
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 #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
|
122 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
|
123 #define _DL_FUNCPTR_DEFINED |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 static void aix_loaderror(char *name); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 #ifdef DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 #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
|
130 #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
|
131 #include <sys/stat.h> |
|
2199
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
132 #ifdef __NetBSD__ |
|
f4671b681ab9
added changes for NetBSD dynamic linking; removed shared linking for NeXT
Guido van Rossum <guido@python.org>
parents:
2094
diff
changeset
|
133 #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
|
134 #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
|
135 #else |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 #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
|
137 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 #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
|
139 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
|
140 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 #ifndef RTLD_LAZY |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 #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
|
143 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 #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
|
145 #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
|
146 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 #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
|
149 #include "dl.h" |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
152 #ifdef USE_MAC_DYNAMIC_LOADING |
|
3224
2fb398ab3e6a
Added missing include for <Aliases.h>
Jack Jansen <jack.jansen@cwi.nl>
parents:
2843
diff
changeset
|
153 #include <Aliases.h> |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
154 #include <CodeFragments.h> |
| 2793 | 155 #ifdef SYMANTEC__CFM68K__ /* Really just 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
|
156 #define CFragConnectionID ConnectionID |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
157 #define kLoadCFrag 0x01 |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
158 #endif |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
159 #include <Files.h> |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
160 #include "macdefs.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
161 #include "macglue.h" |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
162 #endif |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
163 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 #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
|
166 #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
|
167 #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
|
168 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
|
169 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 #endif /* USE_RLD */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 extern char *getprogramname(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 #ifndef FUNCNAME_PATTERN |
| 2435 | 175 #if defined(__hp9000s300) || defined(__NetBSD__) || defined(__BORLANDC__) |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 #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
|
177 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 #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
|
179 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 #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
|
183 #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
|
184 #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
|
185 #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
|
186 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
189 /* Max length of module suffix searched for -- accommodates "module.slb" */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
190 #ifndef MAXSUFFIXSIZE |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
191 #define MAXSUFFIXSIZE 12 |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 #endif |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 /* Pass it on to import.c */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 int import_maxsuffixsize = MAXSUFFIXSIZE; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 struct filedescr import_filetab[] = { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 #ifdef SHORT_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 {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
|
200 #endif /* !SHORT_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 #ifdef LONG_EXT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 {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
|
203 #endif /* !LONG_EXT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 {".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
|
205 {".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
|
206 {0, 0} |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 object * |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
210 load_dynamic_module(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
|
211 char *name; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 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
|
213 FILE *fp; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 #ifndef DYNAMIC_LINK |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 err_setstr(ImportError, "dynamically linked modules not supported"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 object *m; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 char funcname[258]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 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
|
222 #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
|
223 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
|
224 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
|
225 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
|
226 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
|
227 } 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
|
228 static int nhandles = 0; |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
229 #endif |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 sprintf(funcname, FUNCNAME_PATTERN, name); |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
231 #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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 funcname); |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
241 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
|
242 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
243 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
244 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
|
245 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
|
246 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
|
247 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
248 } |
|
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
249 #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
|
250 #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
|
251 /* |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
252 ** Dynamic loading of CFM shared libraries on the Mac. |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
253 ** The code has become more convoluted than it was, because we want to be able |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
254 ** to put multiple modules in a single file. For this reason, we have to determine |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
255 ** the fragment name, and we cannot use the library entry point but we have to locate |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
256 ** the correct init routine "by hand". |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
257 */ |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
258 { |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
259 FSSpec libspec; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
260 CFragConnectionID connID; |
|
2374
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
261 Ptr mainAddr; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
262 Str255 errMessage; |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
263 OSErr err; |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
264 Boolean isfolder, didsomething; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
265 char buf[512]; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
266 Str63 fragname; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
267 Ptr symAddr; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
268 CFragSymbolClass class; |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
269 |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
270 /* 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
|
271 (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
|
272 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
|
273 if ( err ) { |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
274 sprintf(buf, "%s: %s", pathname, PyMac_StrError(err)); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
275 err_setstr(ImportError, buf); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
276 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
277 } |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
278 /* Next, determine the fragment name, by stripping '.slb' and 'module' */ |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
279 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
|
280 fragname[0] = libspec.name[0]; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
281 if( strncmp((char *)(fragname+1+fragname[0]-4), ".slb", 4) == 0 ) |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
282 fragname[0] -= 4; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
283 if ( strncmp((char *)(fragname+1+fragname[0]-6), "module", 6) == 0 ) |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
284 fragname[0] -= 6; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
285 /* Load the fragment (or return the connID if it is already loaded */ |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
286 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
|
287 kLoadCFrag, &connID, &mainAddr, |
|
397478bca0c4
ported to 68K Mac; changed suffix to .slb
Guido van Rossum <guido@python.org>
parents:
2331
diff
changeset
|
288 errMessage); |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
289 if ( err ) { |
|
2420
6beef17871f9
change ifdefs and fix "%#s" format
Guido van Rossum <guido@python.org>
parents:
2374
diff
changeset
|
290 sprintf(buf, "%.*s: %s", errMessage[0], errMessage+1, PyMac_StrError(err)); |
|
2331
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
291 err_setstr(ImportError, buf); |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
292 return NULL; |
|
242dd5ed3b08
Added code to import dynamic modules using mac CFM.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2199
diff
changeset
|
293 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
294 /* 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
|
295 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
|
296 if ( err ) { |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
297 sprintf(buf, "%s: %s", funcname, PyMac_StrError(err)); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
298 err_setstr(ImportError, buf); |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
299 return NULL; |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
300 } |
|
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
301 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
|
302 } |
|
2729
5af6db1f6c0c
Mac dynloading is now enabled by USE_MAC_DYNAMIC_LOADING.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2724
diff
changeset
|
303 #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
|
304 #ifdef USE_SHLIB |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
305 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 #ifdef RTLD_NOW |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
307 /* 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
|
308 (i.e. core dump now if some are missing) */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
309 void *handle = dlopen(pathname, RTLD_NOW); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
310 #else |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
311 void *handle; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
312 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
313 printf("dlopen(\"%s\", %d);\n", pathname, RTLD_LAZY); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
314 handle = dlopen(pathname, RTLD_LAZY); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
315 #endif /* RTLD_NOW */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
316 if (handle == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
317 err_setstr(ImportError, dlerror()); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
318 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
319 } |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
320 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
|
321 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
|
322 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
|
323 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
324 #endif /* USE_SHLIB */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
325 #ifdef _AIX |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
326 p = (dl_funcptr) load(pathname, 1, 0); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
327 if (p == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
328 aix_loaderror(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
329 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
330 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
331 #endif /* _AIX */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
332 #ifdef NT |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
333 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
334 HINSTANCE hDLL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
335 hDLL = LoadLibrary(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
336 if (hDLL==NULL){ |
|
2843
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
337 char errBuf[256]; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
338 unsigned int errorCode; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
339 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
340 /* Get an error string from Win32 error code */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
341 char theInfo[256]; /* Pointer to error text from system */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
342 int theLength; /* Length of error text */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
343 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
344 errorCode = GetLastError(); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
345 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
346 theLength = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, /* flags */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
347 NULL, /* message source */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
348 errorCode, /* the message (error) ID */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
349 0, /* default language environment */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
350 (LPTSTR) theInfo, /* the buffer */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
351 sizeof(theInfo), /* the buffer size */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
352 NULL); /* no additional format args. */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
353 |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
354 /* Problem: could not get the error message. This should not happen if called correctly. */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
355 if (theLength == 0) { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
356 sprintf(errBuf, "DLL load failed with error code %d", errorCode); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
357 } else { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
358 int len; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
359 /* For some reason a \r\n is appended to the text */ |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
360 if (theLength >= 2 && theInfo[theLength-2] == '\r' && theInfo[theLength-1] == '\n') { |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
361 theLength -= 2; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
362 theInfo[theLength] = '\0'; |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
363 } |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
364 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
|
365 len = strlen(errBuf); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
366 strncpy(errBuf+len, theInfo, sizeof(errBuf)-len); |
|
8d92a3bb9c1f
NT specific change for nicer error message (Mark H)
Guido van Rossum <guido@python.org>
parents:
2793
diff
changeset
|
367 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
|
368 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
369 err_setstr(ImportError, errBuf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
370 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
371 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
372 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
|
373 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
374 #endif /* NT */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
375 #ifdef USE_DL |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
376 p = dl_loadmod(getprogramname(), pathname, funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
377 #endif /* USE_DL */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
378 #ifdef USE_RLD |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
379 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
380 NXStream *errorStream; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
381 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
|
382 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
|
383 long ret; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
384 unsigned long ptr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
385 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
386 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
|
387 filenames[0] = pathname; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
388 filenames[1] = NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
389 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
|
390 filenames, NULL); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
391 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
392 /* 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
|
393 if(!ret) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
394 char *streamBuf; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
395 int len, maxLen; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
396 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
397 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
|
398 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
399 NXGetMemoryBuffer(errorStream, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
400 &streamBuf, &len, &maxLen); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
401 err_setstr(ImportError, streamBuf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
402 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
403 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
404 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
|
405 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
|
406 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
407 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
|
408 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
409 if(!ret) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
410 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
411 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
412 #endif /* USE_RLD */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
413 #ifdef hpux |
|
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 shl_t lib; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
416 int flags; |
|
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 flags = BIND_DEFERRED; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
419 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
420 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
421 flags = BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
422 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
|
423 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
424 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
|
425 if (lib == NULL) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
426 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
427 char buf[256]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
428 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
429 perror(pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
430 sprintf(buf, "Failed to load %.200s", pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
431 err_setstr(ImportError, buf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
432 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
433 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
434 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
435 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
|
436 shl_findsym(&lib, funcname, TYPE_UNDEFINED, (void *) &p); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
437 if (p == NULL && verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
438 perror(funcname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
439 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
440 #endif /* hpux */ |
|
2724
6a9ecb05c679
Check if we've already loaded a dynamic module under a different name.
Sjoerd Mullender <sjoerd@acm.org>
parents:
2435
diff
changeset
|
441 got_it: |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
442 if (p == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
443 err_setstr(ImportError, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
444 "dynamic module does not define init function"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
445 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
446 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
447 (*p)(); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
448 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
449 m = dictlookup(import_modules, name); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
450 if (m == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
451 if (err_occurred() == NULL) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
452 err_setstr(SystemError, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
453 "dynamic module not initialized properly"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
454 return NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
455 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
456 if (verbose) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
457 fprintf(stderr, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
458 "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
|
459 name, pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
460 INCREF(m); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
461 return m; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
462 #endif /* DYNAMIC_LINK */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
463 } |
|
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 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
466 #ifdef _AIX |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
467 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
468 #include <ctype.h> /* for isdigit() */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
469 #include <errno.h> /* for global errno */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
470 #include <string.h> /* for strerror() */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
471 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
472 void aix_loaderror(char *pathname) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
473 { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
474 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
475 char *message[8], errbuf[1024]; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
476 int i,j; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
477 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
478 struct errtab { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
479 int errno; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
480 char *errstr; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
481 } 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
|
482 {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
|
483 {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
|
484 {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
|
485 {L_ERROR_RLDBAD, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
486 "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
|
487 {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
|
488 {L_ERROR_MEMBER, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
489 "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
|
490 {L_ERROR_TYPE, "symbol table mismatch:"}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
491 {L_ERROR_ALIGN, "text allignment in file is wrong."}, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
492 {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
|
493 {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
|
494 }; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
495 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
496 #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
|
497 #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
|
498 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
499 sprintf(errbuf, " from module %.200s ", pathname); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
500 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
501 if (!loadquery(1, &message[0], sizeof(message))) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
502 ERRBUF_APPEND(strerror(errno)); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
503 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
|
504 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
|
505 for (j=0; j<LOAD_ERRTAB_LEN ; j++) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
506 if (nerr == load_errtab[i].errno && load_errtab[i].errstr) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
507 ERRBUF_APPEND(load_errtab[i].errstr); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
508 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
509 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
|
510 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
|
511 ERRBUF_APPEND("\n"); |
|
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 errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
514 err_setstr(ImportError, errbuf); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
515 return; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
516 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
517 |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
518 #endif /* _AIX */ |
