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