pike.git / src / dynamic_load.c

version» Context lines:

pike.git/src/dynamic_load.c:1:   #ifndef TESTING   # include "global.h"   # include "interpret.h"   # include "constants.h"   # include "error.h"   # include "module.h"   # include "stralloc.h"   # include "pike_macros.h"   #endif    - #if !defined(HAVE_DLOPEN) && defined(HAVE_DLD_LINK) && defined(HAVE_DLD_GET_FUNC) + #if !defined(HAVE_DLOPEN) +  + #if defined(HAVE_DLD_LINK) && defined(HAVE_DLD_GET_FUNC)   #define USE_DLD -  + #define HAVE_SOME_DLOPEN + #define EMULATE_DLOPEN + #else + #if defined(HAVE_LOADLIBRARY) && defined(HAVE_FREELIBRARY) && \ +  defined(HAVE_GETPROCADDRESS) && defined(HAVE_WINBASE_H) + #define USE_LOADLIBRARY + #define HAVE_SOME_DLOPEN + #define EMULATE_DLOPEN   #endif -  + #endif + #else + #define HAVE_SOME_DLOPEN + #endif    - #if defined(HAVE_DLOPEN) || defined(USE_DLD) +     -  + #ifdef HAVE_SOME_DLOPEN +    typedef void (*modfun)(void);    -  + #ifdef USE_LOADLIBRARY + #include <windows.h> +  + static TCHAR *convert_string(char *str, int len) + { +  int e; +  TCHAR *ret=(TCHAR *)xalloc((len+1) * sizeof(TCHAR)); +  for(e=0;e<len;e++) ret[e]=EXTRACT_UCHAR(str+e); +  ret[e]=0; +  return ret; + } +  + static void *dlopen(char *foo, int how) + { +  TCHAR *tmp; +  HINSTANCE ret; +  tmp=convert_string(foo, strlen(foo)); +  ret=LoadLibrary(tmp); +  free((char *)tmp); +  return (void *)ret; + } +  + static char * dlerror(void) + { +  static char buffer[200]; +  sprintf(buffer,"LoadLibrary failed with error: %d",GetLastError()); +  return buffer; + } +  + static void *dlsym(void *module, char * function) + { +  return (void *)GetProcAddress((HMODULE)module, +  function); + } +  + static void dlclose(void *module) + { +  FreeLibrary((HMODULE)module); + } +  + #define dlinit() +  + #endif +    #ifdef USE_DLD   #include <dld.h>   static void *dlopen(char *foo, int how)   {    dld_create_reference("pike_module_init");    if(dld_link(module_name))    {    return (void *)strdup(module_name);    }else{    return 0;
pike.git/src/dynamic_load.c:50: Inside #if defined(HAVE_DLOPEN) || defined(USE_DLD)
  {    extern char ** ARGV;    if(dld_init(dld_find_executable(ARGV[0])))    {    fprintf(stderr,"Failed to init dld\n");    exit(1);    }   }       - #else + #endif +  + #ifndef EMULATE_DLOPEN +    #ifdef HAVE_DLFCN_H   #include <dlfcn.h>   #endif      #define dlinit()   #endif      #ifndef RTLD_NOW   #define RTLD_NOW 0   #endif