sl@0: /*- sl@0: * Portions Copyright (c) 2006 Nokia Corporation sl@0: * All Rights Reserved. sl@0: * sl@0: * Copyright (c) 1994 sl@0: * The Regents of the University of California. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 4. Neither the name of the University nor the names of its contributors sl@0: * may be used to endorse or promote products derived from this software sl@0: * without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND sl@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE sl@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL sl@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS sl@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT sl@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY sl@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF sl@0: * SUCH DAMAGE. sl@0: * sl@0: * $FreeBSD: src/include/dlfcn.h,v 1.19 2003/02/13 17:47:43 kan Exp $ sl@0: */ sl@0: sl@0: #ifndef _DLFCN_H_ sl@0: #define _DLFCN_H_ sl@0: sl@0: #include sl@0: sl@0: /* sl@0: * Modes and flags for dlopen(). sl@0: */ sl@0: #define RTLD_LAZY 1 /* Bind function calls lazily. */ sl@0: #define RTLD_NOW 2 /* Bind function calls immediately. */ sl@0: #define RTLD_MODEMASK 0x3 sl@0: #define RTLD_GLOBAL 0x100 /* Make symbols globally available. */ sl@0: #define RTLD_LOCAL 0 /* Opposite of RTLD_GLOBAL, and the default. */ sl@0: #define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */ sl@0: sl@0: /* sl@0: * Request arguments for dlinfo(). sl@0: */ sl@0: #define RTLD_DI_LINKMAP 2 /* Obtain link map. */ sl@0: #define RTLD_DI_SERINFO 4 /* Obtain search path info. */ sl@0: #define RTLD_DI_SERINFOSIZE 5 /* ... query for required space. */ sl@0: #define RTLD_DI_ORIGIN 6 /* Obtain object origin */ sl@0: #define RTLD_DI_MAX RTLD_DI_ORIGIN sl@0: sl@0: /* sl@0: * Special handle arguments for dlsym()/dlinfo(). sl@0: */ sl@0: #define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ sl@0: #define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ sl@0: #define RTLD_SELF ((void *) -3) /* Search the caller itself. */ sl@0: sl@0: #if __BSD_VISIBLE sl@0: sl@0: #ifndef _SIZE_T_DECLARED sl@0: typedef __size_t size_t; sl@0: #define _SIZE_T_DECLARED sl@0: #endif sl@0: sl@0: /* sl@0: * Structure filled in by dladdr(). sl@0: */ sl@0: typedef struct dl_info { sl@0: const char *dli_fname; /* Pathname of shared object. */ sl@0: void *dli_fbase; /* Base address of shared object. */ sl@0: const char *dli_sname; /* Name of nearest symbol. */ sl@0: void *dli_saddr; /* Address of nearest symbol. */ sl@0: } Dl_info; sl@0: sl@0: /*- sl@0: * The actual type declared by this typedef is immaterial, provided that sl@0: * it is a function pointer. Its purpose is to provide a return type for sl@0: * dlfunc() which can be cast to a function pointer type without depending sl@0: * on behavior undefined by the C standard, which might trigger a compiler sl@0: * diagnostic. We intentionally declare a unique type signature to force sl@0: * a diagnostic should the application not cast the return value of dlfunc() sl@0: * appropriately. sl@0: */ sl@0: struct __dlfunc_arg { sl@0: int __dlfunc_dummy; sl@0: }; sl@0: sl@0: typedef void (*dlfunc_t)(struct __dlfunc_arg); sl@0: sl@0: /* sl@0: * Structures, returned by the RTLD_DI_SERINFO dlinfo() request. sl@0: */ sl@0: typedef struct dl_serpath { sl@0: char * dls_name; /* single search path entry */ sl@0: unsigned int dls_flags; /* path information */ sl@0: } Dl_serpath; sl@0: sl@0: typedef struct dl_serinfo { sl@0: size_t dls_size; /* total buffer size */ sl@0: unsigned int dls_cnt; /* number of path entries */ sl@0: Dl_serpath dls_serpath[1]; /* there may be more than one */ sl@0: } Dl_serinfo; sl@0: sl@0: #endif /* __BSD_VISIBLE */ sl@0: sl@0: __BEGIN_DECLS sl@0: /* XSI functions first. */ sl@0: sl@0: IMPORT_C void *dlopen(const char *filename, int flag); sl@0: sl@0: IMPORT_C void *dlsym(void *handle, const char *symbol); sl@0: sl@0: IMPORT_C char *dlerror(void); sl@0: sl@0: IMPORT_C int dlclose(void *handle); sl@0: sl@0: __END_DECLS sl@0: sl@0: #endif /* !_DLFCN_H_ */