mirror_iproute2/include/dlfcn.h
Mike Frysinger f2e27cfb01 support static-only systems
The iptables code supports a "no shared libs" mode where it can be used
without requiring dlfcn related functionality.  This adds similar support
to iproute2 so that it can easily be used on systems like nommu Linux (but
obviously with a few limitations -- no dynamic plugins).

Rather than modify every location that uses dlfcn.h, I hooked the dlfcn.h
header with stub functions when shared library support is disabled.  Then
symbol lookup is done via a local static lookup table (which is generated
automatically at build time) so that internal symbols can be found.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-11-10 10:44:20 -08:00

40 lines
702 B
C

/*
* Stub dlfcn implementation for systems that lack shared library support
* but obviously can still reference compiled-in symbols.
*/
#ifndef NO_SHARED_LIBS
#include_next <dlfcn.h>
#else
#define RTLD_LAZY 0
#define _FAKE_DLFCN_HDL (void *)0xbeefcafe
static inline void *dlopen(const char *file, int flag)
{
if (file == NULL)
return _FAKE_DLFCN_HDL;
else
return NULL;
}
extern void *_dlsym(const char *sym);
static inline void *dlsym(void *handle, const char *sym)
{
if (handle != _FAKE_DLFCN_HDL)
return NULL;
return _dlsym(sym);
}
static inline char *dlerror(void)
{
return NULL;
}
static inline int dlclose(void *handle)
{
return (handle == _FAKE_DLFCN_HDL) ? 0 : 1;
}
#endif