annotate src/sysdll.c @ 5032:9b80fa04e7d7

Fix Windows build by removing reference to no longer existent term.texi file
author Vin Shelton <acs@xemacs.org>
date Thu, 18 Feb 2010 19:23:32 -0500
parents 4aebb0131297
children f283b08ff0c9
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 later version.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
24 /* 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
25
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
430
a5df635868b2 Import from CVS: tag r21-2-23
cvs
parents: 428
diff changeset
30 #include <stdlib.h>
1272
df61d2b1d4c3 [xemacs-hg @ 2003-02-07 21:40:22 by james]
james
parents: 880
diff changeset
31 #include "lisp.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "sysdll.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
34 #ifdef DLSYM_NEEDS_UNDERSCORE
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
35 #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
36 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
37 *buf = '_'; \
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
38 qxestrcpy (buf + 1, n); \
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
39 n = buf; \
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
40 } while (0)
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
41 #else
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
42 #define MAYBE_PREPEND_UNDERSCORE(n)
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
43 #endif
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
44
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 /* This whole file is conditional upon HAVE_SHLIB */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #ifdef HAVE_SHLIB
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 /* Thankfully, most systems follow the ELFish dlopen() method.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 */
452
3d3049ae1304 Import from CVS: tag r21-2-41
cvs
parents: 442
diff changeset
50 #if defined(HAVE_DLOPEN)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #include <dlfcn.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 #ifndef RTLD_LAZY
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
54 # ifdef DL_LAZY
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
55 # define RTLD_LAZY DL_LAZY
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
56 # else
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
57 # define RTLD_LAZY 1
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
58 # endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #endif /* RTLD_LAZY isn't defined under FreeBSD - ick */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
61 #ifndef RTLD_NOW
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
62 # ifdef DL_NOW
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
63 # define RTLD_NOW DL_NOW
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
64 # else
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
65 # define RTLD_NOW 2
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
66 # endif
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
67 #endif
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 452
diff changeset
68
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
70 dll_open (Lisp_Object fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
72 Extbyte *soname;
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 if (NILP (fname))
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 soname = NULL;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
77 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
78 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
79 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
80 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
81 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
82 return (dll_handle) dlopen (soname, RTLD_NOW);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
88 return dlclose ((void *) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
92 dll_function (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
94 Extbyte *next;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
95 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
96 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
97 return (dll_func) dlsym ((void *) h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 dll_var
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
101 dll_variable (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
103 Extbyte *next;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
104 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
105 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
106 return (dll_var)dlsym ((void *)h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
109 Lisp_Object
1811
3fe1a35b705d [xemacs-hg @ 2003-11-29 22:11:47 by james]
james
parents: 1706
diff changeset
110 dll_error ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
112 const Extbyte *msg;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 #if defined(HAVE_DLERROR) || defined(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 #elif defined(HAVE__DLERROR)
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
116 msg = (const Extbyte *) _dlerror();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 #else
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
118 msg = (const Extbyte *) "Shared library error";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 #endif
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
120 return build_extstring (msg, Qerror_message_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 #elif defined(HAVE_SHL_LOAD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 /* This is the HP/UX version */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 #include <dl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
127 dll_open (Lisp_Object fname)
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 Extbyte *soname;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
131 if (NILP (fname))
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 soname = NULL;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
134 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
135 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
136 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
137 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
138 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
139 return (dll_handle) shl_load (soname, BIND_DEFERRED, 0L);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
145 return shl_unload ((shl_t) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 dll_func
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
149 dll_function (dll_handle h, const CIbyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
153 if (shl_findsym ((shl_t *) &h, n, TYPE_PROCEDURE, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
156 return (dll_func) handle;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 dll_var
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
160 dll_variable (dll_handle h, const CIbyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 long handle = 0L;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
164 if (shl_findsym ((shl_t *) &h, n, TYPE_DATA, &handle))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
167 return (dll_var) handle;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
170 Lisp_Object
1811
3fe1a35b705d [xemacs-hg @ 2003-11-29 22:11:47 by james]
james
parents: 1706
diff changeset
171 dll_error ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 /* #### WTF?! Shouldn't this at least attempt to get strerror or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 something? --hniksic */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
175 return build_ascstring ("Generic shared library error");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1596
diff changeset
178 #elif defined (WIN32_NATIVE) || defined (CYGWIN)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
179
1632
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1596
diff changeset
180 #include "syswindows.h"
64eaceca611d [xemacs-hg @ 2003-08-19 02:07:03 by james]
james
parents: 1596
diff changeset
181 #include "sysfile.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 430
diff changeset
182
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
184 dll_open (Lisp_Object fname)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
186 Extbyte *soname;
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 if (NILP (fname))
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 soname = NULL;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
191 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
192 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
193 {
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
194 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
195 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
196 return (dll_handle) qxeLoadLibrary (soname);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 dll_close (dll_handle h)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
202 return FreeLibrary ((HMODULE) h);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
206 dll_function (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
208 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
209 return (dll_func) GetProcAddress ((HINSTANCE) h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
213 dll_variable (dll_handle h, const Ibyte *n)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
215 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
216 return (dll_func) GetProcAddress ((HINSTANCE) h, next);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
219 Lisp_Object
1811
3fe1a35b705d [xemacs-hg @ 2003-11-29 22:11:47 by james]
james
parents: 1706
diff changeset
220 dll_error ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
222 Ascbyte err[32];
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
223 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
224 return build_ascstring (err);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 }
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
226 #elif defined (HAVE_DYLD)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
227 /* This section supports MacOSX dynamic libraries. Dynamically
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
228 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
229 */
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 #include <mach-o/dyld.h>
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
232
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
233 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
234 dll_open (Lisp_Object fname)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
235 {
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
236 Extbyte *soname;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
237 NSObjectFileImage file;
1418
c7045d239c2b [xemacs-hg @ 2003-04-16 20:24:06 by james]
james
parents: 1383
diff changeset
238 NSModule out;
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
239 NSObjectFileImageReturnCode ret;
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
240
2855
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
241 /*
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
242 * 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
243 * 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
244 * 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
245 * 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
246 */
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
247 if (NILP (fname))
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
248 {
2855
612eb81b76eb [xemacs-hg @ 2005-07-12 12:22:11 by malcolmp]
malcolmp
parents: 2078
diff changeset
249 return NULL;
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
250 }
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
251 else
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
252 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
253 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
254 }
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
255 ret = NSCreateObjectFileImageFromFile (soname, &file);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
256 if (ret != NSObjectFileImageSuccess)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
257 return NULL;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
258 out = NSLinkModule (file, soname,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
259 NSLINKMODULE_OPTION_BINDNOW |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
260 NSLINKMODULE_OPTION_PRIVATE |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
261 NSLINKMODULE_OPTION_RETURN_ON_ERROR);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
262 return (dll_handle) out;
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
263 }
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
264
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
265 int
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
266 dll_close (dll_handle h)
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
267 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
268 return NSUnLinkModule ((NSModule) h, NSUNLINKMODULE_OPTION_NONE);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
269 }
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
270
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
271 /* 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
272 * 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
273 *
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
274 * 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
275 * based on code from the dlcompat library
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
276 * (http://www.opendarwin.org/projects/dlcompat).
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
277 */
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
278
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
279 static const struct mach_header *
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
280 image_for_address (void *address)
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
281 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
282 unsigned long i;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
283 unsigned long count = _dyld_image_count ();
3841
5989b9bbb612 [xemacs-hg @ 2007-02-22 16:19:40 by stephent]
stephent
parents: 2855
diff changeset
284 const struct mach_header *mh = 0;
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
285
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
286 for (i = 0; i < count; i++)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
287 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
288 unsigned long addr = (unsigned long) address -
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
289 _dyld_get_image_vmaddr_slide (i);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
290 mh = _dyld_get_image_header (i);
1851
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 if (mh)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
293 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
294 struct load_command *lc =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
295 (struct load_command *) ((Rawbyte *) mh +
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
296 sizeof(struct mach_header));
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
297 unsigned long j;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
298
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
299 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
300 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
301 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
302 if (LC_SEGMENT == lc->cmd &&
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
303 addr >= ((struct segment_command *)lc)->vmaddr &&
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
304 addr <
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
305 ((struct segment_command *)lc)->vmaddr +
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
306 ((struct segment_command *)lc)->vmsize)
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 goto image_found;
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 }
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 mh = 0;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
314 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
315
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
316 image_found:
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
317 return mh;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
318 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
319
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
320 static const struct mach_header *
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
321 my_find_image (const char *name)
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
322 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
323 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
324 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
325 NSADDIMAGE_OPTION_RETURN_ON_ERROR);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
326
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
327 if (!mh)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
328 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
329 int count = _dyld_image_count ();
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
330 int j;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
331
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
332 for (j = 0; j < count; j++)
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 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
335
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
336 if (!strcmp (id, name))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
337 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
338 mh = _dyld_get_image_header (j);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
339 break;
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 }
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 return mh;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
345 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
346
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
347 /*
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
348 * dyld adds libraries by first adding the directly dependant libraries in
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
349 * 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
350 * 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
351 * 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
352 * dependencies, then it probably isn't there.
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
353 */
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
354 static NSSymbol
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
355 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
356 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1851
diff changeset
357 unsigned long n;
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
358 NSSymbol nssym = 0;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
359
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
360 struct load_command *lc =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
361 (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
362
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
363 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
364 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
365 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
366 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
367 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
368 struct mach_header *wh;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
369
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
370 if ((wh = (struct mach_header *)
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
371 my_find_image((Rawbyte *)
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
372 (((struct dylib_command *) lc)->
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
373 dylib.name.offset + (Rawbyte *) lc))))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
374 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
375 Extbyte *symext =
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
376 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
377 if (NSIsSymbolNameDefinedInImage (wh, symext))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
378 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
379 nssym =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
380 NSLookupSymbolInImage
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
381 (wh,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
382 symext,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
383 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
384 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
385 break;
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 }
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 return nssym;
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
392 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
393
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
394 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
395 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
396 {
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
397 NSSymbol sym = 0;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
398 Extbyte *next;
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
399
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
400 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
401 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
402
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
403 /* 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
404
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
405 if (h == NULL)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
406 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
407 /* 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
408 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
409 const struct mach_header* my_mh =
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
410 image_for_address ((void*) &dll_function);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
411
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
412 if (NSIsSymbolNameDefinedInImage (my_mh, next))
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
413 {
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
414 sym =
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
415 NSLookupSymbolInImage
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
416 (my_mh,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
417 next,
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
418 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
419 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
420 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
421
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
422 if (!sym)
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
423 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
424 sym = search_linked_libs (my_mh, n);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
425 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
426 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
427 else
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
428 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
429 sym = NSLookupSymbolInModule ((NSModule)h, next);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
430 }
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
431
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
432 if (sym == 0) return 0;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
433 return (dll_func) NSAddressOfSymbol (sym);
1851
7fdde2d3ae5f [xemacs-hg @ 2004-01-03 23:06:49 by james]
james
parents: 1811
diff changeset
434 }
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
435
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
436 dll_var
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
437 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
438 {
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
439 NSSymbol sym;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
440 Extbyte *next;
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
441
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
442 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
443 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
444
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
445 sym = NSLookupSymbolInModule ((NSModule) h, n);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
446 if (sym == 0) return 0;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
447 return (dll_var) NSAddressOfSymbol (sym);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
448 }
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
449
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
450 Lisp_Object
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
451 dll_error (void)
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
452 {
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
453 NSLinkEditErrors c;
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
454 int errorNumber;
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
455 const Extbyte *fileNameWithError, *errorString;
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
456 NSLinkEditError (&c, &errorNumber, &fileNameWithError, &errorString);
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
457 return build_extstring (errorString, Qerror_message_encoding);
1383
517919955e3f [xemacs-hg @ 2003-03-26 04:22:47 by james]
james
parents: 1272
diff changeset
458 }
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
459 #elif HAVE_LTDL
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
460 /* Libtool's libltdl */
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
461 #include <ltdl.h>
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
462
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
463 dll_handle
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
464 dll_open (Lisp_Object fname)
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 Extbyte *soname;
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 if (NILP (fname))
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 soname = NULL;
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
471 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
472 else
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
473 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
474 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
475 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
476 return (dll_handle) lt_dlopen (soname);
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
477 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
478
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
479 int
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
480 dll_close (dll_handle 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 return lt_dlclose ((lt_dlhandle) h);
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
483 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
484
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
485 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
486 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
487 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
488 Extbyte *next;
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
489 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
490 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
491 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
492 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
493
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
494 dll_var
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
495 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
496 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
497 Extbyte *next;
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
498 MAYBE_PREPEND_UNDERSCORE (n);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
499 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
500 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
501 }
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
502
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
503 Lisp_Object
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
504 dll_error (void)
2078
0bcc1e4dfd91 [xemacs-hg @ 2004-05-14 15:34:36 by james]
james
parents: 2054
diff changeset
505 {
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
506 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
507 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 #else
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
509 /* 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
510 dll_handle
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
511 dll_open (Lisp_Object fname)
428
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 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 dll_close (dll_handle h)
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 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
523 dll_function (dll_handle h, const Ibyte *n)
428
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 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 dll_func
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
529 dll_variable (dll_handle h, const Ibyte *n)
428
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 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
1706
9fc738581a9d [xemacs-hg @ 2003-09-22 03:21:12 by james]
james
parents: 1632
diff changeset
534 Lisp_Object
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
535 dll_error (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4834
diff changeset
537 return build_ascstring ("Shared libraries not implemented on this system");
428
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 /* System conditionals */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 #endif /* HAVE_SHLIB */