iproute2/include/dlfcn.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Stub dlfcn implementation for systems that lack shared library support
   4 * but obviously can still reference compiled-in symbols.
   5 */
   6
   7#ifndef NO_SHARED_LIBS
   8#include_next <dlfcn.h>
   9#else
  10
  11#define RTLD_LAZY 0
  12#define RTLD_GLOBAL 1
  13#define _FAKE_DLFCN_HDL (void *)0xbeefcafe
  14
  15static inline void *dlopen(const char *file, int flag)
  16{
  17        if (file == NULL)
  18                return _FAKE_DLFCN_HDL;
  19        else
  20                return NULL;
  21}
  22
  23void *_dlsym(const char *sym);
  24static inline void *dlsym(void *handle, const char *sym)
  25{
  26        if (handle != _FAKE_DLFCN_HDL)
  27                return NULL;
  28        return _dlsym(sym);
  29}
  30
  31static inline char *dlerror(void)
  32{
  33        return NULL;
  34}
  35
  36static inline int dlclose(void *handle)
  37{
  38        return (handle == _FAKE_DLFCN_HDL) ? 0 : 1;
  39}
  40
  41#endif
  42