dlfcn.h revision 103212
1103196Smike/*- 233236Sjdp * Copyright (c) 1994 333236Sjdp * The Regents of the University of California. All rights reserved. 433236Sjdp * 533236Sjdp * Redistribution and use in source and binary forms, with or without 633236Sjdp * modification, are permitted provided that the following conditions 733236Sjdp * are met: 833236Sjdp * 1. Redistributions of source code must retain the above copyright 933236Sjdp * notice, this list of conditions and the following disclaimer. 1033236Sjdp * 2. Redistributions in binary form must reproduce the above copyright 1133236Sjdp * notice, this list of conditions and the following disclaimer in the 1233236Sjdp * documentation and/or other materials provided with the distribution. 1333236Sjdp * 3. All advertising materials mentioning features or use of this software 1433236Sjdp * must display the following acknowledgement: 1533236Sjdp * This product includes software developed by the University of 1633236Sjdp * California, Berkeley and its contributors. 1733236Sjdp * 4. Neither the name of the University nor the names of its contributors 1833236Sjdp * may be used to endorse or promote products derived from this software 1933236Sjdp * without specific prior written permission. 2033236Sjdp * 2133236Sjdp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2233236Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2333236Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2433236Sjdp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2533236Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2633236Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2733236Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2833236Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2933236Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3033236Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3133236Sjdp * SUCH DAMAGE. 3233236Sjdp * 3350473Speter * $FreeBSD: head/include/dlfcn.h 103212 2002-09-11 05:04:06Z mike $ 3433236Sjdp */ 3533236Sjdp 3633236Sjdp#ifndef _DLFCN_H_ 3733236Sjdp#define _DLFCN_H_ 38103196Smike 3933236Sjdp#include <sys/cdefs.h> 4033236Sjdp 4133236Sjdp/* 4250603Sjdp * Modes and flags for dlopen(). 4333236Sjdp */ 44103196Smike#define RTLD_LAZY 1 /* Bind function calls lazily. */ 45103196Smike#define RTLD_NOW 2 /* Bind function calls immediately. */ 46103196Smike#define RTLD_MODEMASK 0x3 47103196Smike#define RTLD_GLOBAL 0x100 /* Make symbols globally available. */ 48103196Smike#define RTLD_LOCAL 0 /* Opposite of RTLD_GLOBAL, and the default. */ 49103196Smike#define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */ 5033236Sjdp 5133236Sjdp/* 5266055Sjdp * Special handle arguments for dlsym(). 5333236Sjdp */ 54103196Smike#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ 55103196Smike#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ 5633236Sjdp 57103212Smike#if __BSD_VISIBLE 5833236Sjdp/* 5933236Sjdp * Structure filled in by dladdr(). 6033236Sjdp */ 61103196Smiketypedef struct dl_info { 62103196Smike const char *dli_fname; /* Pathname of shared object. */ 63103196Smike void *dli_fbase; /* Base address of shared object. */ 64103196Smike const char *dli_sname; /* Name of nearest symbol. */ 65103196Smike void *dli_saddr; /* Address of nearest symbol. */ 6633236Sjdp} Dl_info; 6733236Sjdp 68103196Smike/*- 6997475Swollman * The actual type declared by this typedef is immaterial, provided that 7097475Swollman * it is a function pointer. Its purpose is to provide a return type for 7197475Swollman * dlfunc() which can be cast to a function pointer type without depending 7297475Swollman * on behavior undefined by the C standard, which might trigger a compiler 7397475Swollman * diagnostic. We intentionally declare a unique type signature to force 7497475Swollman * a diagnostic should the application not cast the return value of dlfunc() 7597475Swollman * appropriately. 7697475Swollman */ 7797475Swollmanstruct __dlfunc_arg { 78103196Smike int __dlfunc_dummy; 7997475Swollman}; 8097475Swollman 81103196Smiketypedef void (*dlfunc_t)(struct __dlfunc_arg); 8297475Swollman 83103212Smike#endif /* __BSD_VISIBLE */ 84103212Smike 8533236Sjdp__BEGIN_DECLS 86103196Smike/* XSI functions first. */ 87103196Smikeint dlclose(void *); 88103196Smikeconst char * 89103196Smike dlerror(void); 90103196Smikevoid *dlopen(const char *, int); 91103212Smikevoid *dlsym(void * __restrict, const char * __restrict); 9297475Swollman 9397475Swollman#if __BSD_VISIBLE 94103196Smikeint dladdr(const void *, Dl_info *); 95103212Smikedlfunc_t dlfunc(void * __restrict, const char * __restrict); 96103196Smikevoid dllockinit(void *_context, 97103196Smike void *(*_lock_create)(void *_context), 98103196Smike void (*_rlock_acquire)(void *_lock), 99103196Smike void (*_wlock_acquire)(void *_lock), 100103196Smike void (*_lock_release)(void *_lock), 101103196Smike void (*_lock_destroy)(void *_lock), 102103196Smike void (*_context_destroy)(void *_context)); 10397475Swollman#endif /* __BSD_VISIBLE */ 10433236Sjdp__END_DECLS 10533236Sjdp 10633236Sjdp#endif /* !_DLFCN_H_ */ 107