1 /**	$MirOS: src/include/dlfcn.h,v 1.2 2006/08/30 03:46:12 tg Exp $ */
2 /*	$OpenBSD: dlfcn.h,v 1.9 2004/08/11 19:14:56 drahn Exp $	*/
3 /*	$NetBSD: dlfcn.h,v 1.2 1995/06/05 19:38:00 pk Exp $	*/
4 
5 /*
6  * Copyright (c) 1995 Paul Kranenburg
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Paul Kranenburg.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _DLFCN_H_
36 #define _DLFCN_H_
37 
38 #include <sys/cdefs.h>
39 
40 /*
41  * Structure filled in by dladdr().
42  */
43 typedef	struct dl_info {
44 	const char	*dli_fname;	/* Pathname of shared object. */
45 	void		*dli_fbase;	/* Base address of shared object. */
46 	const char	*dli_sname;	/* Name of nearest symbol. */
47 	void		*dli_saddr;	/* Address of nearest symbol. */
48 } Dl_info;
49 
50 /*
51  * User interface to the run-time linker.
52  */
53 __BEGIN_DECLS
54 extern void	*dlopen(const char *, int);
55 extern int	dlclose(void *);
56 extern void	*dlsym(void *, const char *);
57 extern int	dlctl(void *, int, void *);
58 extern const char	*dlerror(void);
59 extern int	dladdr(const void *, Dl_info *);
60 __END_DECLS
61 
62 /* Values for dlopen `mode'. */
63 #define RTLD_LAZY	1
64 #define RTLD_NOW	2
65 #define RTLD_GLOBAL	0x100
66 #define RTLD_LOCAL	0x000
67 #define RTLD_TRACE	0x200
68 #define DL_LAZY		RTLD_LAZY	/* Compat */
69 
70 /*
71  * Special handle arguments for dlsym().
72  */
73 #define	RTLD_NEXT	((void *) -1)	/* Search subsequent objects. */
74 #define	RTLD_DEFAULT	((void *) -2)	/* Use default search algorithm. */
75 #define	RTLD_SELF	((void *) -3)	/* Search the caller itself. */
76 
77 /*
78  * dlctl() commands
79  */
80 #define DL_GETERRNO	1
81 #define DL_SETSRCHPATH	x
82 #define DL_GETLIST	x
83 #define DL_GETREFCNT	x
84 #define DL_GETLOADADDR	x
85 #define DL_SETTHREADLCK	2
86 
87 #endif /* _DLFCN_H_ */
88