1cdc920a0Smrg/************************************************************************** 2cdc920a0Smrg * 3cdc920a0Smrg * Copyright 2009 VMware, Inc. 4cdc920a0Smrg * All Rights Reserved. 5cdc920a0Smrg * 6cdc920a0Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7cdc920a0Smrg * copy of this software and associated documentation files (the 8cdc920a0Smrg * "Software"), to deal in the Software without restriction, including 9cdc920a0Smrg * without limitation the rights to use, copy, modify, merge, publish, 10cdc920a0Smrg * distribute, sub license, and/or sell copies of the Software, and to 11cdc920a0Smrg * permit persons to whom the Software is furnished to do so, subject to 12cdc920a0Smrg * the following conditions: 13cdc920a0Smrg * 14cdc920a0Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15cdc920a0Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16cdc920a0Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 17cdc920a0Smrg * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 18cdc920a0Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19cdc920a0Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20cdc920a0Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 21cdc920a0Smrg * 22cdc920a0Smrg * The above copyright notice and this permission notice (including the 23cdc920a0Smrg * next paragraph) shall be included in all copies or substantial portions 24cdc920a0Smrg * of the Software. 25cdc920a0Smrg * 26cdc920a0Smrg **************************************************************************/ 27cdc920a0Smrg 28cdc920a0Smrg 29cdc920a0Smrg#ifndef U_DL_H_ 30cdc920a0Smrg#define U_DL_H_ 31cdc920a0Smrg 32cdc920a0Smrg 33cdc920a0Smrg#include "pipe/p_config.h" 34cdc920a0Smrg 3501e04c3fSmrg#ifdef __cplusplus 3601e04c3fSmrgextern "C" { 3701e04c3fSmrg#endif 38cdc920a0Smrg 39cdc920a0Smrg#if defined(PIPE_OS_WINDOWS) 40cdc920a0Smrg# define UTIL_DL_EXT ".dll" 413464ebd5Sriastradh# define UTIL_DL_PREFIX "" 42cdc920a0Smrg#elif defined(PIPE_OS_APPLE) 43cdc920a0Smrg# define UTIL_DL_EXT ".dylib" 443464ebd5Sriastradh# define UTIL_DL_PREFIX "lib" 45cdc920a0Smrg#else 46cdc920a0Smrg# define UTIL_DL_EXT ".so" 473464ebd5Sriastradh# define UTIL_DL_PREFIX "lib" 48cdc920a0Smrg#endif 49cdc920a0Smrg 50cdc920a0Smrg 51cdc920a0Smrgstruct util_dl_library; 52cdc920a0Smrg 53cdc920a0Smrg 54cdc920a0Smrgtypedef void (*util_dl_proc)(void); 55cdc920a0Smrg 56cdc920a0Smrg 57cdc920a0Smrg/** 58cdc920a0Smrg * Open a library dynamically. 59cdc920a0Smrg */ 60cdc920a0Smrgstruct util_dl_library * 61cdc920a0Smrgutil_dl_open(const char *filename); 62cdc920a0Smrg 63cdc920a0Smrg 64cdc920a0Smrg/** 65cdc920a0Smrg * Lookup a function in a library. 66cdc920a0Smrg */ 67cdc920a0Smrgutil_dl_proc 68cdc920a0Smrgutil_dl_get_proc_address(struct util_dl_library *library, 69cdc920a0Smrg const char *procname); 70cdc920a0Smrg 71cdc920a0Smrg 72cdc920a0Smrg/** 73cdc920a0Smrg * Close a library. 74cdc920a0Smrg */ 75cdc920a0Smrgvoid 76cdc920a0Smrgutil_dl_close(struct util_dl_library *library); 77cdc920a0Smrg 78cdc920a0Smrg 793464ebd5Sriastradh/** 803464ebd5Sriastradh * Return most recent error message. 813464ebd5Sriastradh */ 823464ebd5Sriastradhconst char * 833464ebd5Sriastradhutil_dl_error(void); 843464ebd5Sriastradh 8501e04c3fSmrg#ifdef __cplusplus 8601e04c3fSmrg} 8701e04c3fSmrg#endif 883464ebd5Sriastradh 89cdc920a0Smrg#endif /* U_DL_H_ */ 90