annotate src/sysdll.c @ 5697:40fbceabaafd

menubar-items.el (default-menubar): Reorganize. Add PROBLEMS to toplevel. New "More about XEmacs" submenu for NEWS, licensing, etc. New "Recent History" menu for messages, lossage, etc. Get rid of ugly and unexpressive ellipses.
author Stephen J. Turnbull <stephen@xemacs.org>
date Mon, 24 Dec 2012 03:08:33 +0900
parents 4dee0387b9de
children 5d5aeb79edb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* sysdll.c --- system dependent support for dynamic linked libraries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1998 Free Software Foundation, Inc.
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
3 Copyright (C) 2010 Ben Wing.
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
4
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 Author: William Perry <wmperry@aventail.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
9 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
11 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
12 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5183
diff changeset
20 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
22 /* This file has been Mule-ized, Ben Wing, 1-26-10. */
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
23
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
28 #include <stdlib.h>
1272
df61d2b1d4c3 [xemacs-hg @ 2003-02-07 21:40:22 by james]
james
parents: 880
diff changeset
29 #include "lisp.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "sysdll.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
32 #ifdef DLSYM_NEEDS_UNDERSCORE
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
33 #define MAYBE_PREPEND_UNDERSCORE(n) do { \
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
34 Ibyte *buf = alloca_array (Ibyte, qxestrlen (n) + 2); \
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
35 *buf = '_'; \
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
36 qxestrcpy (buf + 1, n); \
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
37 n = buf; \
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
38 } while (0)
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
39 #else
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
40 #define MAYBE_PREPEND_UNDERSCORE(n)
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
41 #endif
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
42
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 /* This whole file is conditional upon HAVE_SHLIB */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #ifdef HAVE_SHLIB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 /* Thankfully, most systems follow the ELFish dlopen() method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 442
diff changeset
48 #if defined(HAVE_DLOPEN)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #include <dlfcn.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #ifndef RTLD_LAZY
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
52 # ifdef DL_LAZY
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
53 # define RTLD_LAZY DL_LAZY
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
54 # else
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
55 # define RTLD_LAZY 1
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
56 # endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #endif /* RTLD_LAZY isn't defined under FreeBSD - ick */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
59 #ifndef RTLD_NOW
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
60 # ifdef DL_NOW
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
61 # define RTLD_NOW DL_NOW
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
62 # else
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
63 # define RTLD_NOW 2
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
64 # endif
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
65 #endif
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
66
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
68 dll_open (Lisp_Object fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
70 Extbyte *soname;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
71
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
72 if (NILP (fname))
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
73 {
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
74 soname = NULL;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
75 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
76 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
77 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
78 soname = LISP_STRING_TO_EXTERNAL (fname, Qdll_filename_encoding);
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
79 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
80 return (dll_handle) dlopen (soname, RTLD_NOW);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
86 return dlclose ((void *) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
90 dll_function (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
92 Extbyte *next;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
93 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
94 next = ITEXT_TO_EXTERNAL (n, Qdll_function_name_encoding);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
95 return (dll_func) dlsym ((void *) h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 dll_var
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
99 dll_variable (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
101 Extbyte *next;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
102 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
103 next = ITEXT_TO_EXTERNAL (n, Qdll_variable_name_encoding);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
104 return (dll_var)dlsym ((void *)h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
107 Lisp_Object
1811
3fe1a35b705d [xemacs-hg @ 2003-11-29 22:11:47 by james]
james
parents: 1706
diff changeset
108 dll_error ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
110 const Extbyte *msg;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 #if defined(HAVE_DLERROR) || defined(dlerror)
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
112 msg = (const Extbyte *) dlerror ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 #elif defined(HAVE__DLERROR)
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
114 msg = (const Extbyte *) _dlerror();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 #else
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
116 msg = (const Extbyte *) "Shared library error";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 #endif
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
118 return build_extstring (msg, Qerror_message_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 #elif defined(HAVE_SHL_LOAD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 /* This is the HP/UX version */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 #include <dl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
125 dll_open (Lisp_Object fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
127 Extbyte *soname;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
129 if (NILP (fname))
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
130 {
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
131 soname = NULL;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
132 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
133 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
134 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
135 soname = LISP_STRING_TO_EXTERNAL (fname, Qdll_filename_encoding);
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
136 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
137 return (dll_handle) shl_load (soname, BIND_DEFERRED, 0L);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
143 return shl_unload ((shl_t) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 dll_func
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
147 dll_function (dll_handle h, const CIbyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
151 if (shl_findsym ((shl_t *) &h, n, TYPE_PROCEDURE, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
154 return (dll_func) handle;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 dll_var
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
158 dll_variable (dll_handle h, const CIbyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
162 if (shl_findsym ((shl_t *) &h, n, TYPE_DATA, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
165 return (dll_var) handle;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
168 Lisp_Object
1811
3fe1a35b705d [xemacs-hg @ 2003-11-29 22:11:47 by james]
james
parents: 1706
diff changeset
169 dll_error ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 /* #### WTF?! Shouldn't this at least attempt to get strerror or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 something? --hniksic */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
173 return build_ascstring ("Generic shared library error");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1596
diff changeset
176 #elif defined (WIN32_NATIVE) || defined (CYGWIN)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
177
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1596
diff changeset
178 #include "syswindows.h"
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1596
diff changeset
179 #include "sysfile.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
180
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
182 dll_open (Lisp_Object fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
184 Extbyte *soname;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
185
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
186 if (NILP (fname))
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
187 {
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
188 soname = NULL;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
189 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
190 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
191 {
4834
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 3841
diff changeset
192 LISP_LOCAL_FILE_FORMAT_TO_TSTR (fname, soname);
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
193 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
194 return (dll_handle) qxeLoadLibrary (soname);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
200 return FreeLibrary ((HMODULE) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
204 dll_function (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
206 Extbyte *next = ITEXT_TO_EXTERNAL (n, Qmswindows_multibyte);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
207 return (dll_func) GetProcAddress ((HINSTANCE) h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
211 dll_variable (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
213 Extbyte *next = ITEXT_TO_EXTERNAL (n, Qmswindows_multibyte);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
214 return (dll_func) GetProcAddress ((HINSTANCE) h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
217 Lisp_Object
1811
3fe1a35b705d [xemacs-hg @ 2003-11-29 22:11:47 by james]
james
parents: 1706
diff changeset
218 dll_error ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
220 Ascbyte err[32];
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
221 snprintf (err, 32, "Windows DLL Error %lu", GetLastError ());
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
222 return build_ascstring (err);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 }
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
224 #elif defined (HAVE_DYLD)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
225 /* This section supports MacOSX dynamic libraries. Dynamically
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
226 loadable libraries must be compiled as bundles, not dynamiclibs.
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
227 */
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
228
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
229 #include <mach-o/dyld.h>
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
230
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
231 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
232 dll_open (Lisp_Object fname)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
233 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
234 Extbyte *soname;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
235 NSObjectFileImage file;
1418
c7045d239c2b [xemacs-hg @ 2003-04-16 20:24:06 by james]
james
parents: 1383
diff changeset
236 NSModule out;
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
237 NSObjectFileImageReturnCode ret;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
238
2855
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
239 /*
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
240 * MacOS X dll support is for bundles, not the current executable, so return
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
241 * NULL is this case. However, dll_function() uses a special hack where a
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
242 * NULL handle can be used to find executable symbols. This satisfies the
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
243 * needs of ui-gtk.c but is not a general solution.
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
244 */
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
245 if (NILP (fname))
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
246 {
2855
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
247 return NULL;
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
248 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
249 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
250 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
251 soname = LISP_STRING_TO_EXTERNAL (fname, Qdll_filename_encoding);
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
252 }
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
253 ret = NSCreateObjectFileImageFromFile (soname, &file);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
254 if (ret != NSObjectFileImageSuccess)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
255 return NULL;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
256 out = NSLinkModule (file, soname,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
257 NSLINKMODULE_OPTION_BINDNOW |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
258 NSLINKMODULE_OPTION_PRIVATE |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
259 NSLINKMODULE_OPTION_RETURN_ON_ERROR);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
260 return (dll_handle) out;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
261 }
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
262
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
263 int
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
264 dll_close (dll_handle h)
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
265 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
266 return NSUnLinkModule ((NSModule) h, NSUNLINKMODULE_OPTION_NONE);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
267 }
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
268
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
269 /* Given an address, return the mach_header for the image containing it
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
270 * or zero if the given address is not contained in any loaded images.
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
271 *
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
272 * Note: image_for_address(), my_find_image() and search_linked_libs() are
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
273 * based on code from the dlcompat library
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
274 * (http://www.opendarwin.org/projects/dlcompat).
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
275 */
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
276
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
277 static const struct mach_header *
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
278 image_for_address (void *address)
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
279 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
280 unsigned long i;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
281 unsigned long count = _dyld_image_count ();
3841
5989b9bbb612 [xemacs-hg @ 2007-02-22 16:19:40 by stephent]
stephent
parents: 2855
diff changeset
282 const struct mach_header *mh = 0;
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
283
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
284 for (i = 0; i < count; i++)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
285 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
286 unsigned long addr = (unsigned long) address -
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
287 _dyld_get_image_vmaddr_slide (i);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
288 mh = _dyld_get_image_header (i);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
289
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
290 if (mh)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
291 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
292 struct load_command *lc =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
293 (struct load_command *) ((Rawbyte *) mh +
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
294 sizeof(struct mach_header));
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
295 unsigned long j;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
296
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
297 for (j = 0; j < mh->ncmds;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
298 j++, lc = (struct load_command *) ((Rawbyte *)lc + lc->cmdsize))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
299 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
300 if (LC_SEGMENT == lc->cmd &&
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
301 addr >= ((struct segment_command *)lc)->vmaddr &&
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
302 addr <
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
303 ((struct segment_command *)lc)->vmaddr +
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
304 ((struct segment_command *)lc)->vmsize)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
305 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
306 goto image_found;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
307 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
308 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
309 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
310
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
311 mh = 0;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
312 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
313
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
314 image_found:
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
315 return mh;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
316 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
317
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
318 static const struct mach_header *
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
319 my_find_image (const char *name)
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
320 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
321 const struct mach_header *mh = (struct mach_header *)
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
322 NSAddImage (name, NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
323 NSADDIMAGE_OPTION_RETURN_ON_ERROR);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
324
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
325 if (!mh)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
326 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
327 int count = _dyld_image_count ();
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
328 int j;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
329
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
330 for (j = 0; j < count; j++)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
331 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
332 const char *id = _dyld_get_image_name (j);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
333
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
334 if (!strcmp (id, name))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
335 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
336 mh = _dyld_get_image_header (j);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
337 break;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
338 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
339 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
340 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
341
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
342 return mh;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
343 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
344
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
345 /*
5384
3889ef128488 Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents: 5183
diff changeset
346 * dyld adds libraries by first adding the directly dependent libraries in
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
347 * link order, and then adding the dependencies for those libraries, so we
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
348 * should do the same... but we don't bother adding the extra dependencies, if
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
349 * the symbols are neither in the loaded image nor any of it's direct
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
350 * dependencies, then it probably isn't there.
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
351 */
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
352 static NSSymbol
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
353 search_linked_libs (const struct mach_header * mh, const Ibyte *symbol)
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
354 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1851
diff changeset
355 unsigned long n;
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
356 NSSymbol nssym = 0;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
357
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
358 struct load_command *lc =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
359 (struct load_command *) ((Rawbyte *) mh + sizeof (struct mach_header));
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
360
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
361 for (n = 0; n < mh->ncmds;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
362 n++, lc = (struct load_command *) ((Rawbyte *) lc + lc->cmdsize))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
363 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
364 if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB == lc->cmd))
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
365 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
366 struct mach_header *wh;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
367
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
368 if ((wh = (struct mach_header *)
5183
f283b08ff0c9 Avoid build failure, Apple's g++-4.0.1, Mac OS 10.4.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4981
diff changeset
369 my_find_image((const Chbyte *)
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
370 (((struct dylib_command *) lc)->
5183
f283b08ff0c9 Avoid build failure, Apple's g++-4.0.1, Mac OS 10.4.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4981
diff changeset
371 dylib.name.offset + (const Chbyte *) lc))))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
372 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
373 Extbyte *symext =
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
374 ITEXT_TO_EXTERNAL (symbol, Qdll_symbol_encoding);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
375 if (NSIsSymbolNameDefinedInImage (wh, symext))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
376 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
377 nssym =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
378 NSLookupSymbolInImage
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
379 (wh,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
380 symext,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
381 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
382 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
383 break;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
384 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
385 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
386 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
387 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
388
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
389 return nssym;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
390 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
391
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
392 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
393 dll_function (dll_handle h, const Ibyte *n)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
394 {
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
395 NSSymbol sym = 0;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
396 Extbyte *next;
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
397
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
398 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
399 next = ITEXT_TO_EXTERNAL (n, Qdll_function_name_encoding);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
400
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
401 /* NULL means the program image and shared libraries, not bundles. */
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
402
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
403 if (h == NULL)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
404 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
405 /* NOTE: This assumes that this function is included in the main program
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
406 and not in a shared library. */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
407 const struct mach_header* my_mh =
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
408 image_for_address ((void*) &dll_function);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
409
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
410 if (NSIsSymbolNameDefinedInImage (my_mh, next))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
411 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
412 sym =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
413 NSLookupSymbolInImage
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
414 (my_mh,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
415 next,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
416 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
417 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
418 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
419
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
420 if (!sym)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
421 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
422 sym = search_linked_libs (my_mh, n);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
423 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
424 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
425 else
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
426 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
427 sym = NSLookupSymbolInModule ((NSModule)h, next);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
428 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
429
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
430 if (sym == 0) return 0;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
431 return (dll_func) NSAddressOfSymbol (sym);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
432 }
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
433
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
434 dll_var
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
435 dll_variable (dll_handle h, const Ibyte *n)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
436 {
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
437 NSSymbol sym;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
438 Extbyte *next;
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
439
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
440 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
441 next = ITEXT_TO_EXTERNAL (n, Qdll_variable_name_encoding);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
442
5183
f283b08ff0c9 Avoid build failure, Apple's g++-4.0.1, Mac OS 10.4.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4981
diff changeset
443 sym = NSLookupSymbolInModule ((NSModule) h, (const Chbyte *)n);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
444 if (sym == 0) return 0;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
445 return (dll_var) NSAddressOfSymbol (sym);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
446 }
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
447
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
448 Lisp_Object
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
449 dll_error (void)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
450 {
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
451 NSLinkEditErrors c;
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
452 int errorNumber;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
453 const Extbyte *fileNameWithError, *errorString;
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
454 NSLinkEditError (&c, &errorNumber, &fileNameWithError, &errorString);
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
455 return build_extstring (errorString, Qerror_message_encoding);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
456 }
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
457 #elif HAVE_LTDL
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
458 /* Libtool's libltdl */
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
459 #include <ltdl.h>
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
460
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
461 dll_handle
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
462 dll_open (Lisp_Object fname)
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
463 {
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
464 Extbyte *soname;
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
465
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
466 if (NILP (fname))
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
467 {
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
468 soname = NULL;
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
469 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
470 else
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
471 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
472 soname = LISP_STRING_TO_EXTERNAL (fname, Qdll_filename_encoding);
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
473 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
474 return (dll_handle) lt_dlopen (soname);
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
475 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
476
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
477 int
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
478 dll_close (dll_handle h)
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
479 {
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
480 return lt_dlclose ((lt_dlhandle) h);
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
481 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
482
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
483 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
484 dll_function (dll_handle h, const Ibyte *n)
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
485 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
486 Extbyte *next;
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
487 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
488 next = ITEXT_TO_EXTERNAL (n, Qdll_function_name_encoding);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
489 return (dll_func) lt_dlsym ((lt_dlhandle) h, next);
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
490 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
491
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
492 dll_var
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
493 dll_variable (dll_handle h, const Ibyte *n)
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
494 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
495 Extbyte *next;
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
496 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
497 next = ITEXT_TO_EXTERNAL (n, Qdll_variable_name_encoding);
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
498 return (dll_var) lt_dlsym ((lt_dlhandle) h, next);
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
499 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
500
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
501 Lisp_Object
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
502 dll_error (void)
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
503 {
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
504 return build_extstring (lt_dlerror (), Qerror_message_encoding);
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
505 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 #else
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
507 /* Catchall if we don't know about this system's method of dynamic loading */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
509 dll_open (Lisp_Object fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
521 dll_function (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
527 dll_variable (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
532 Lisp_Object
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
533 dll_error (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
535 return build_ascstring ("Shared libraries not implemented on this system");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 #endif /* System conditionals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 #endif /* HAVE_SHLIB */