aboutsummaryrefslogtreecommitdiff
path: root/libltdl/ltdl.h
diff options
context:
space:
mode:
Diffstat (limited to 'libltdl/ltdl.h')
-rw-r--r--libltdl/ltdl.h252
1 files changed, 118 insertions, 134 deletions
diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h
index 995d4038..2e246515 100644
--- a/libltdl/ltdl.h
+++ b/libltdl/ltdl.h
@@ -28,9 +28,9 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28#ifndef LTDL_H 28#ifndef LTDL_H
29#define LTDL_H 1 29#define LTDL_H 1
30 30
31#include <sys/types.h> /* for size_t declaration */ 31#include <sys/types.h> /* for size_t declaration */
32
33 32
33
34/* --- MACROS FOR PORTABILITY --- */ 34/* --- MACROS FOR PORTABILITY --- */
35 35
36 36
@@ -44,13 +44,11 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
44# define LT_BEGIN_C_DECLS extern "C" { 44# define LT_BEGIN_C_DECLS extern "C" {
45# define LT_END_C_DECLS } 45# define LT_END_C_DECLS }
46#else 46#else
47# define LT_BEGIN_C_DECLS /* empty */ 47# define LT_BEGIN_C_DECLS /* empty */
48# define LT_END_C_DECLS /* empty */ 48# define LT_END_C_DECLS /* empty */
49#endif 49#endif
50 50
51LT_BEGIN_C_DECLS 51LT_BEGIN_C_DECLS
52
53
54/* LT_PARAMS is a macro used to wrap function prototypes, so that compilers 52/* LT_PARAMS is a macro used to wrap function prototypes, so that compilers
55 that don't understand ANSI C prototypes still work, and ANSI C 53 that don't understand ANSI C prototypes still work, and ANSI C
56 compilers can issue warnings about type mismatches. */ 54 compilers can issue warnings about type mismatches. */
@@ -61,7 +59,6 @@ LT_BEGIN_C_DECLS
61# define LT_PARAMS(protos) () 59# define LT_PARAMS(protos) ()
62# define lt_ptr char* 60# define lt_ptr char*
63#endif 61#endif
64
65/* LT_STMT_START/END are used to create macros which expand to a 62/* LT_STMT_START/END are used to create macros which expand to a
66 a single compound statement in a portable way. */ 63 a single compound statement in a portable way. */
67#if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus) 64#if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
@@ -76,7 +73,6 @@ LT_BEGIN_C_DECLS
76# define LT_STMT_END while (0) 73# define LT_STMT_END while (0)
77# endif 74# endif
78#endif 75#endif
79
80/* LT_CONC creates a new concatenated symbol for the compiler 76/* LT_CONC creates a new concatenated symbol for the compiler
81 in a portable way. */ 77 in a portable way. */
82#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER) 78#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER)
@@ -84,15 +80,9 @@ LT_BEGIN_C_DECLS
84#else 80#else
85# define LT_CONC(s,t) s/**/t 81# define LT_CONC(s,t) s/**/t
86#endif 82#endif
87
88/* LT_STRLEN can be used safely on NULL pointers. */ 83/* LT_STRLEN can be used safely on NULL pointers. */
89#define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0) 84#define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0)
90 85 /* --- WINDOWS SUPPORT --- */
91
92
93/* --- WINDOWS SUPPORT --- */
94
95
96/* Canonicalise Windows and Cygwin recognition macros. */ 86/* Canonicalise Windows and Cygwin recognition macros. */
97#ifdef __CYGWIN32__ 87#ifdef __CYGWIN32__
98# ifndef __CYGWIN__ 88# ifndef __CYGWIN__
@@ -110,8 +100,6 @@ LT_BEGIN_C_DECLS
110# endif 100# endif
111# endif 101# endif
112#endif 102#endif
113
114
115#ifdef __WINDOWS__ 103#ifdef __WINDOWS__
116# ifndef __CYGWIN__ 104# ifndef __CYGWIN__
117/* LT_DIRSEP_CHAR is accepted *in addition* to '/' as a directory 105/* LT_DIRSEP_CHAR is accepted *in addition* to '/' as a directory
@@ -123,81 +111,72 @@ LT_BEGIN_C_DECLS
123#ifndef LT_PATHSEP_CHAR 111#ifndef LT_PATHSEP_CHAR
124# define LT_PATHSEP_CHAR ':' 112# define LT_PATHSEP_CHAR ':'
125#endif 113#endif
126
127/* DLL building support on win32 hosts; mostly to workaround their 114/* DLL building support on win32 hosts; mostly to workaround their
128 ridiculous implementation of data symbol exporting. */ 115 ridiculous implementation of data symbol exporting. */
129#ifndef LT_SCOPE 116#ifndef LT_SCOPE
130# ifdef __WINDOWS__ 117# ifdef __WINDOWS__
131# ifdef DLL_EXPORT /* defined by libtool (if required) */ 118# ifdef DLL_EXPORT /* defined by libtool (if required) */
132# define LT_SCOPE __declspec(dllexport) 119# define LT_SCOPE __declspec(dllexport)
133# endif 120# endif
134# ifdef LIBLTDL_DLL_IMPORT /* define if linking with this dll */ 121# ifdef LIBLTDL_DLL_IMPORT /* define if linking with this dll */
135# define LT_SCOPE extern __declspec(dllimport) 122# define LT_SCOPE extern __declspec(dllimport)
136# endif 123# endif
137# endif 124# endif
138# ifndef LT_SCOPE /* static linking or !__WINDOWS__ */ 125# ifndef LT_SCOPE /* static linking or !__WINDOWS__ */
139# define LT_SCOPE extern 126# define LT_SCOPE extern
140# endif 127# endif
141#endif 128#endif
142 129#if defined(_MSC_VER) /* Visual Studio */
143
144#if defined(_MSC_VER) /* Visual Studio */
145# define R_OK 4 130# define R_OK 4
146#endif 131#endif
147 132 /* --- DYNAMIC MODULE LOADING API --- */
148 133typedef struct lt_dlhandle_struct *lt_dlhandle; /* A loaded module. */
149
150/* --- DYNAMIC MODULE LOADING API --- */
151
152
153typedef struct lt_dlhandle_struct *lt_dlhandle; /* A loaded module. */
154 134
155/* Initialisation and finalisation functions for libltdl. */ 135/* Initialisation and finalisation functions for libltdl. */
156LT_SCOPE int lt_dlinit LT_PARAMS((void)); 136LT_SCOPE int lt_dlinit LT_PARAMS ((void));
157LT_SCOPE int lt_dlexit LT_PARAMS((void)); 137LT_SCOPE int lt_dlexit LT_PARAMS ((void));
158 138
159/* Module search path manipulation. */ 139/* Module search path manipulation. */
160LT_SCOPE int lt_dladdsearchdir LT_PARAMS((const char *search_dir)); 140LT_SCOPE int lt_dladdsearchdir LT_PARAMS ((const char *search_dir));
161LT_SCOPE int lt_dlinsertsearchdir LT_PARAMS((const char *before, 141LT_SCOPE int lt_dlinsertsearchdir LT_PARAMS ((const char *before,
162 const char *search_dir)); 142 const char *search_dir));
163LT_SCOPE int lt_dlsetsearchpath LT_PARAMS((const char *search_path)); 143LT_SCOPE int lt_dlsetsearchpath LT_PARAMS ((const char *search_path));
164LT_SCOPE const char *lt_dlgetsearchpath LT_PARAMS((void)); 144LT_SCOPE const char *lt_dlgetsearchpath LT_PARAMS ((void));
165LT_SCOPE int lt_dlforeachfile LT_PARAMS(( 145LT_SCOPE int lt_dlforeachfile LT_PARAMS ((const char *search_path,
166 const char *search_path, 146 int (*func) (const char *filename,
167 int (*func) (const char *filename, lt_ptr data), 147 lt_ptr data),
168 lt_ptr data)); 148 lt_ptr data));
169 149
170/* Portable libltdl versions of the system dlopen() API. */ 150/* Portable libltdl versions of the system dlopen() API. */
171LT_SCOPE lt_dlhandle lt_dlopen LT_PARAMS((const char *filename)); 151LT_SCOPE lt_dlhandle lt_dlopen LT_PARAMS ((const char *filename));
172LT_SCOPE lt_dlhandle lt_dlopenext LT_PARAMS((const char *filename)); 152LT_SCOPE lt_dlhandle lt_dlopenext LT_PARAMS ((const char *filename));
173LT_SCOPE lt_ptr lt_dlsym LT_PARAMS((lt_dlhandle handle, 153LT_SCOPE lt_ptr lt_dlsym LT_PARAMS ((lt_dlhandle handle, const char *name));
174 const char *name)); 154LT_SCOPE const char *lt_dlerror LT_PARAMS ((void));
175LT_SCOPE const char *lt_dlerror LT_PARAMS((void)); 155LT_SCOPE int lt_dlclose LT_PARAMS ((lt_dlhandle handle));
176LT_SCOPE int lt_dlclose LT_PARAMS((lt_dlhandle handle));
177 156
178/* Module residency management. */ 157/* Module residency management. */
179LT_SCOPE int lt_dlmakeresident LT_PARAMS((lt_dlhandle handle)); 158LT_SCOPE int lt_dlmakeresident LT_PARAMS ((lt_dlhandle handle));
180LT_SCOPE int lt_dlisresident LT_PARAMS((lt_dlhandle handle)); 159LT_SCOPE int lt_dlisresident LT_PARAMS ((lt_dlhandle handle));
160
181 161
182 162
183 163
184
185/* --- MUTEX LOCKING --- */ 164/* --- MUTEX LOCKING --- */
186 165
187 166
188typedef void lt_dlmutex_lock LT_PARAMS((void)); 167typedef void lt_dlmutex_lock LT_PARAMS ((void));
189typedef void lt_dlmutex_unlock LT_PARAMS((void)); 168typedef void lt_dlmutex_unlock LT_PARAMS ((void));
190typedef void lt_dlmutex_seterror LT_PARAMS((const char *errmsg)); 169typedef void lt_dlmutex_seterror LT_PARAMS ((const char *errmsg));
191typedef const char *lt_dlmutex_geterror LT_PARAMS((void)); 170typedef const char *lt_dlmutex_geterror LT_PARAMS ((void));
192 171
193LT_SCOPE int lt_dlmutex_register LT_PARAMS((lt_dlmutex_lock *lock, 172LT_SCOPE int lt_dlmutex_register LT_PARAMS ((lt_dlmutex_lock * lock,
194 lt_dlmutex_unlock *unlock, 173 lt_dlmutex_unlock * unlock,
195 lt_dlmutex_seterror *seterror, 174 lt_dlmutex_seterror * seterror,
196 lt_dlmutex_geterror *geterror)); 175 lt_dlmutex_geterror * geterror));
176
197 177
198 178
199 179
200
201/* --- MEMORY HANDLING --- */ 180/* --- MEMORY HANDLING --- */
202 181
203 182
@@ -206,103 +185,109 @@ LT_SCOPE int lt_dlmutex_register LT_PARAMS((lt_dlmutex_lock *lock,
206 libltdl relies on a featureful realloc, but if you are sure yours 185 libltdl relies on a featureful realloc, but if you are sure yours
207 has the right semantics then you can assign it directly. Generally, 186 has the right semantics then you can assign it directly. Generally,
208 it is safe to assign just a malloc() and a free() function. */ 187 it is safe to assign just a malloc() and a free() function. */
209LT_SCOPE lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size)); 188LT_SCOPE
210LT_SCOPE lt_ptr (*lt_dlrealloc) LT_PARAMS((lt_ptr ptr, size_t size)); 189lt_ptr (*lt_dlmalloc)
211LT_SCOPE void (*lt_dlfree) LT_PARAMS((lt_ptr ptr)); 190LT_PARAMS ((size_t size));
191 LT_SCOPE lt_ptr (*lt_dlrealloc) LT_PARAMS ((lt_ptr ptr, size_t size));
192 LT_SCOPE void (*lt_dlfree) LT_PARAMS ((lt_ptr ptr));
193
212 194
213 195
214 196
215
216/* --- PRELOADED MODULE SUPPORT --- */ 197/* --- PRELOADED MODULE SUPPORT --- */
217 198
218 199
219/* A preopened symbol. Arrays of this type comprise the exported 200/* A preopened symbol. Arrays of this type comprise the exported
220 symbols for a dlpreopened module. */ 201 symbols for a dlpreopened module. */
221typedef struct { 202 typedef struct
222 const char *name; 203 {
223 lt_ptr address; 204 const char *name;
224} lt_dlsymlist; 205 lt_ptr address;
206 } lt_dlsymlist;
225 207
226LT_SCOPE int lt_dlpreload LT_PARAMS((const lt_dlsymlist *preloaded)); 208 LT_SCOPE int lt_dlpreload LT_PARAMS ((const lt_dlsymlist * preloaded));
227LT_SCOPE int lt_dlpreload_default 209 LT_SCOPE int lt_dlpreload_default
228 LT_PARAMS((const lt_dlsymlist *preloaded)); 210 LT_PARAMS ((const lt_dlsymlist * preloaded));
229 211
230#define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \ 212#define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \
231 extern const lt_dlsymlist lt_preloaded_symbols[]; \ 213 extern const lt_dlsymlist lt_preloaded_symbols[]; \
232 lt_dlpreload_default(lt_preloaded_symbols); \ 214 lt_dlpreload_default(lt_preloaded_symbols); \
233 }LT_STMT_END 215 }LT_STMT_END
216
234 217
235 218
236 219
237
238/* --- MODULE INFORMATION --- */ 220/* --- MODULE INFORMATION --- */
239 221
240 222
241/* Read only information pertaining to a loaded module. */ 223/* Read only information pertaining to a loaded module. */
242typedef struct { 224 typedef struct
243 char *filename; /* file name */ 225 {
244 char *name; /* module name */ 226 char *filename; /* file name */
245 int ref_count; /* number of times lt_dlopened minus 227 char *name; /* module name */
246 number of times lt_dlclosed. */ 228 int ref_count; /* number of times lt_dlopened minus
247} lt_dlinfo; 229 number of times lt_dlclosed. */
248 230 } lt_dlinfo;
249LT_SCOPE const lt_dlinfo *lt_dlgetinfo LT_PARAMS((lt_dlhandle handle)); 231
250LT_SCOPE lt_dlhandle lt_dlhandle_next LT_PARAMS((lt_dlhandle place)); 232 LT_SCOPE const lt_dlinfo *lt_dlgetinfo LT_PARAMS ((lt_dlhandle handle));
251LT_SCOPE int lt_dlforeach LT_PARAMS(( 233 LT_SCOPE lt_dlhandle lt_dlhandle_next LT_PARAMS ((lt_dlhandle place));
252 int (*func) (lt_dlhandle handle, lt_ptr data), 234 LT_SCOPE int lt_dlforeach
253 lt_ptr data)); 235 LT_PARAMS ((int (*func) (lt_dlhandle handle, lt_ptr data),
236 lt_ptr data));
254 237
255/* Associating user data with loaded modules. */ 238/* Associating user data with loaded modules. */
256typedef unsigned lt_dlcaller_id; 239 typedef unsigned lt_dlcaller_id;
257 240
258LT_SCOPE lt_dlcaller_id lt_dlcaller_register LT_PARAMS((void)); 241 LT_SCOPE lt_dlcaller_id lt_dlcaller_register LT_PARAMS ((void));
259LT_SCOPE lt_ptr lt_dlcaller_set_data LT_PARAMS((lt_dlcaller_id key, 242 LT_SCOPE lt_ptr lt_dlcaller_set_data LT_PARAMS ((lt_dlcaller_id key,
260 lt_dlhandle handle, 243 lt_dlhandle handle,
261 lt_ptr data)); 244 lt_ptr data));
262LT_SCOPE lt_ptr lt_dlcaller_get_data LT_PARAMS((lt_dlcaller_id key, 245 LT_SCOPE lt_ptr lt_dlcaller_get_data LT_PARAMS ((lt_dlcaller_id key,
263 lt_dlhandle handle)); 246 lt_dlhandle handle));
247
264 248
265 249
266
267/* --- USER MODULE LOADER API --- */ 250/* --- USER MODULE LOADER API --- */
268 251
269 252
270typedef struct lt_dlloader lt_dlloader; 253 typedef struct lt_dlloader lt_dlloader;
271typedef lt_ptr lt_user_data; 254 typedef lt_ptr lt_user_data;
272typedef lt_ptr lt_module; 255 typedef lt_ptr lt_module;
273 256
274/* Function pointer types for creating user defined module loaders. */ 257/* Function pointer types for creating user defined module loaders. */
275typedef lt_module lt_module_open LT_PARAMS((lt_user_data loader_data, 258 typedef lt_module lt_module_open LT_PARAMS ((lt_user_data loader_data,
276 const char *filename)); 259 const char *filename));
277typedef int lt_module_close LT_PARAMS((lt_user_data loader_data, 260 typedef int lt_module_close LT_PARAMS ((lt_user_data loader_data,
278 lt_module handle)); 261 lt_module handle));
279typedef lt_ptr lt_find_sym LT_PARAMS((lt_user_data loader_data, 262 typedef lt_ptr lt_find_sym LT_PARAMS ((lt_user_data loader_data,
280 lt_module handle, 263 lt_module handle,
281 const char *symbol)); 264 const char *symbol));
282typedef int lt_dlloader_exit LT_PARAMS((lt_user_data loader_data)); 265 typedef int lt_dlloader_exit LT_PARAMS ((lt_user_data loader_data));
283 266
284struct lt_user_dlloader { 267 struct lt_user_dlloader
285 const char *sym_prefix; 268 {
286 lt_module_open *module_open; 269 const char *sym_prefix;
287 lt_module_close *module_close; 270 lt_module_open *module_open;
288 lt_find_sym *find_sym; 271 lt_module_close *module_close;
289 lt_dlloader_exit *dlloader_exit; 272 lt_find_sym *find_sym;
290 lt_user_data dlloader_data; 273 lt_dlloader_exit *dlloader_exit;
291}; 274 lt_user_data dlloader_data;
292 275 };
293LT_SCOPE lt_dlloader *lt_dlloader_next LT_PARAMS((lt_dlloader *place)); 276
294LT_SCOPE lt_dlloader *lt_dlloader_find LT_PARAMS(( 277 LT_SCOPE lt_dlloader *lt_dlloader_next LT_PARAMS ((lt_dlloader * place));
295 const char *loader_name)); 278 LT_SCOPE lt_dlloader *lt_dlloader_find
296LT_SCOPE const char *lt_dlloader_name LT_PARAMS((lt_dlloader *place)); 279 LT_PARAMS ((const char *loader_name));
297LT_SCOPE lt_user_data *lt_dlloader_data LT_PARAMS((lt_dlloader *place)); 280 LT_SCOPE const char *lt_dlloader_name LT_PARAMS ((lt_dlloader * place));
298LT_SCOPE int lt_dlloader_add LT_PARAMS((lt_dlloader *place, 281 LT_SCOPE lt_user_data *lt_dlloader_data
299 const struct lt_user_dlloader *dlloader, 282 LT_PARAMS ((lt_dlloader * place));
300 const char *loader_name)); 283 LT_SCOPE int lt_dlloader_add
301LT_SCOPE int lt_dlloader_remove LT_PARAMS(( 284 LT_PARAMS ((lt_dlloader * place,
302 const char *loader_name)); 285 const struct lt_user_dlloader * dlloader,
286 const char *loader_name));
287 LT_SCOPE int lt_dlloader_remove LT_PARAMS ((const char *loader_name));
288
303 289
304 290
305
306/* --- ERROR MESSAGE HANDLING --- */ 291/* --- ERROR MESSAGE HANDLING --- */
307 292
308 293
@@ -332,21 +317,21 @@ LT_SCOPE int lt_dlloader_remove LT_PARAMS((
332 LT_ERROR(INVALID_POSITION, "invalid search path insert position") 317 LT_ERROR(INVALID_POSITION, "invalid search path insert position")
333 318
334/* Enumerate the symbolic error names. */ 319/* Enumerate the symbolic error names. */
335enum { 320 enum
321 {
336#define LT_ERROR(name, diagnostic) LT_CONC(LT_ERROR_, name), 322#define LT_ERROR(name, diagnostic) LT_CONC(LT_ERROR_, name),
337 lt_dlerror_table 323 lt_dlerror_table
338#undef LT_ERROR 324#undef LT_ERROR
339 325 LT_ERROR_MAX
340 LT_ERROR_MAX 326 };
341};
342 327
343/* These functions are only useful from inside custom module loaders. */ 328/* These functions are only useful from inside custom module loaders. */
344LT_SCOPE int lt_dladderror LT_PARAMS((const char *diagnostic)); 329 LT_SCOPE int lt_dladderror LT_PARAMS ((const char *diagnostic));
345LT_SCOPE int lt_dlseterror LT_PARAMS((int errorcode)); 330 LT_SCOPE int lt_dlseterror LT_PARAMS ((int errorcode));
331
346 332
347 333
348 334
349
350/* --- SOURCE COMPATIBILITY WITH OLD LIBLTDL --- */ 335/* --- SOURCE COMPATIBILITY WITH OLD LIBLTDL --- */
351 336
352 337
@@ -362,5 +347,4 @@ LT_SCOPE int lt_dlseterror LT_PARAMS((int errorcode));
362#endif 347#endif
363 348
364LT_END_C_DECLS 349LT_END_C_DECLS
365
366#endif /* !LTDL_H */ 350#endif /* !LTDL_H */