dlfcn.h revision 1.19.10.2 1 1.19.10.2 martin /* $NetBSD: dlfcn.h,v 1.19.10.2 2008/04/28 20:22:55 martin Exp $ */
2 1.19.10.2 martin
3 1.19.10.2 martin /*-
4 1.19.10.2 martin * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.19.10.2 martin * All rights reserved.
6 1.19.10.2 martin *
7 1.19.10.2 martin * This code is derived from software contributed to The NetBSD Foundation
8 1.19.10.2 martin * by Paul Kranenburg.
9 1.19.10.2 martin *
10 1.19.10.2 martin * Redistribution and use in source and binary forms, with or without
11 1.19.10.2 martin * modification, are permitted provided that the following conditions
12 1.19.10.2 martin * are met:
13 1.19.10.2 martin * 1. Redistributions of source code must retain the above copyright
14 1.19.10.2 martin * notice, this list of conditions and the following disclaimer.
15 1.19.10.2 martin * 2. Redistributions in binary form must reproduce the above copyright
16 1.19.10.2 martin * notice, this list of conditions and the following disclaimer in the
17 1.19.10.2 martin * documentation and/or other materials provided with the distribution.
18 1.19.10.2 martin *
19 1.19.10.2 martin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.19.10.2 martin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.19.10.2 martin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.19.10.2 martin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.19.10.2 martin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.19.10.2 martin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.19.10.2 martin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.19.10.2 martin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.19.10.2 martin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.19.10.2 martin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.19.10.2 martin * POSSIBILITY OF SUCH DAMAGE.
30 1.19.10.2 martin */
31 1.19.10.2 martin
32 1.19.10.2 martin #ifndef _DLFCN_H_
33 1.19.10.2 martin #define _DLFCN_H_
34 1.19.10.2 martin
35 1.19.10.2 martin #include <sys/featuretest.h>
36 1.19.10.2 martin #include <sys/cdefs.h>
37 1.19.10.2 martin
38 1.19.10.2 martin #if defined(_NETBSD_SOURCE)
39 1.19.10.2 martin typedef struct _dl_info {
40 1.19.10.2 martin const char *dli_fname; /* File defining the symbol */
41 1.19.10.2 martin void *dli_fbase; /* Base address */
42 1.19.10.2 martin const char *dli_sname; /* Symbol name */
43 1.19.10.2 martin const void *dli_saddr; /* Symbol address */
44 1.19.10.2 martin } Dl_info;
45 1.19.10.2 martin #endif /* defined(_NETBSD_SOURCE) */
46 1.19.10.2 martin
47 1.19.10.2 martin /*
48 1.19.10.2 martin * User interface to the run-time linker.
49 1.19.10.2 martin */
50 1.19.10.2 martin __BEGIN_DECLS
51 1.19.10.2 martin void *dlopen(const char *, int);
52 1.19.10.2 martin int dlclose(void *);
53 1.19.10.2 martin void *dlsym(void * __restrict, const char * __restrict);
54 1.19.10.2 martin #if defined(_NETBSD_SOURCE)
55 1.19.10.2 martin int dladdr(const void * __restrict, Dl_info * __restrict);
56 1.19.10.2 martin int dlctl(void *, int, void *);
57 1.19.10.2 martin #endif
58 1.19.10.2 martin __aconst char *dlerror(void);
59 1.19.10.2 martin __END_DECLS
60 1.19.10.2 martin
61 1.19.10.2 martin /* Values for dlopen `mode'. */
62 1.19.10.2 martin #define RTLD_LAZY 1
63 1.19.10.2 martin #define RTLD_NOW 2
64 1.19.10.2 martin #define RTLD_GLOBAL 0x100 /* Allow global searches in object */
65 1.19.10.2 martin #define RTLD_LOCAL 0x200
66 1.19.10.2 martin #if defined(_NETBSD_SOURCE)
67 1.19.10.2 martin #define DL_LAZY RTLD_LAZY /* Compat */
68 1.19.10.2 martin #endif
69 1.19.10.2 martin
70 1.19.10.2 martin /*
71 1.19.10.2 martin * Special handle arguments for dlsym().
72 1.19.10.2 martin */
73 1.19.10.2 martin #define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */
74 1.19.10.2 martin #define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */
75 1.19.10.2 martin #define RTLD_SELF ((void *) -3) /* Search the caller itself. */
76 1.19.10.2 martin
77 1.19.10.2 martin /*
78 1.19.10.2 martin * dlctl() commands
79 1.19.10.2 martin */
80 1.19.10.2 martin #if defined(_NETBSD_SOURCE)
81 1.19.10.2 martin #define DL_GETERRNO 1
82 1.19.10.2 martin #define DL_GETSYMBOL 2
83 1.19.10.2 martin #if 0
84 1.19.10.2 martin #define DL_SETSRCHPATH x
85 1.19.10.2 martin #define DL_GETLIST x
86 1.19.10.2 martin #define DL_GETREFCNT x
87 1.19.10.2 martin #define DL_GETLOADADDR x
88 1.19.10.2 martin #endif /* 0 */
89 1.19.10.2 martin #endif /* defined(_NETBSD_SOURCE) */
90 1.19.10.2 martin
91 1.19.10.2 martin #endif /* !defined(_DLFCN_H_) */
92