2002-05-29 16:25:43 +00:00
|
|
|
/*
|
|
|
|
* This source file is in the public domain.
|
|
|
|
* Garrett A. Wollman, 2002-05-28.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implement the dlfunc() interface, which behaves exactly the same as
|
|
|
|
* dlsym() except that it returns a function pointer instead of a data
|
|
|
|
* pointer. This can be used by applications to avoid compiler warnings
|
|
|
|
* about undefined behavior, and is intended as prior art for future
|
|
|
|
* POSIX standardization. This function requires that all pointer types
|
|
|
|
* have the same representation, which is true on all platforms FreeBSD
|
|
|
|
* runs on, but is not guaranteed by the C standard.
|
|
|
|
*/
|
2002-05-29 19:35:13 +00:00
|
|
|
dlfunc_t
|
2002-09-11 05:05:48 +00:00
|
|
|
dlfunc(void * __restrict handle, const char * __restrict symbol)
|
2002-05-29 16:25:43 +00:00
|
|
|
{
|
|
|
|
union {
|
|
|
|
void *d;
|
2002-05-29 19:35:13 +00:00
|
|
|
dlfunc_t f;
|
2002-05-29 16:25:43 +00:00
|
|
|
} rv;
|
|
|
|
|
|
|
|
rv.d = dlsym(handle, symbol);
|
|
|
|
return (rv.f);
|
|
|
|
}
|
|
|
|
|