pike.git / src / dynamic_load.c

version» Context lines:

pike.git/src/dynamic_load.c:1: Inside #if undefined(TESTING)
  #ifndef TESTING   # include "global.h"   # include "interpret.h"   # include "constants.h"   # include "error.h"   # include "module.h"   # include "stralloc.h"   # include "pike_macros.h"    - RCSID("$Id: dynamic_load.c,v 1.28 1998/05/15 19:01:05 grubba Exp $"); + RCSID("$Id: dynamic_load.c,v 1.29 1998/07/09 12:45:35 grubba Exp $");    - #endif + #endif /* !TESTING */    -  + #ifdef HAVE_ERRNO_H + #include <errno.h> + #endif /* HAVE_ERRNO_H */ + #ifdef HAVE_STRING_H + #include <string.h> + #endif /* HAVE_STRING_H */ +    #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_SHL_LOAD) && defined(HAVE_DL_H) + #define USE_HPUX_DL + #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 -  + #endif   #else   #define HAVE_SOME_DLOPEN   #endif         #ifdef HAVE_SOME_DLOPEN      typedef void (*modfun)(void);      #ifdef USE_LOADLIBRARY
pike.git/src/dynamic_load.c:69: Inside #if defined(HAVE_SOME_DLOPEN)
   function);   }      static void dlclose(void *module)   {    FreeLibrary((HMODULE)module);   }      #define dlinit()    - #endif + #endif /* USE_LOADLIBRARY */    -  +    #ifdef USE_DLD   #include <dld.h> - static void *dlopen(char *foo, int how) + static void *dlopen(char *module_name, 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:111:   static void dlinit(void)   {    extern char ** ARGV;    if(dld_init(dld_find_executable(ARGV[0])))    {    fprintf(stderr,"Failed to init dld\n");    exit(1);    }   }    + #endif /* USE_DLD */    -  +  + #ifdef USE_HPUX_DL +  + #include <dl.h> +  + #if defined(TESTING) && defined(BIND_VERBOSE) + #define RTLD_NOW BIND_IMMEDIATE | BIND_VERBOSE + #else + #define RTLD_NOW BIND_IMMEDIATE + #endif /* TESTING && BIND_VERBOSE */ +  + extern int errno; +  + static void *dlopen(char *libname, int how) + { +  shl_t lib; +  +  lib = shl_load(libname, how, 0L); +  +  return (void *)lib; + } +  + static char *dlerror(void) + { + #ifdef HAVE_STRERROR +  return strerror(errno); + #else +  return ""; /* I hope it's better than null..*/   #endif -  + }    -  + static void *dlsym(void *module, char *function) + { +  void *func; +  int result; +  shl_t mod = (shl_t)module; +  +  result = shl_findsym(&mod, function, TYPE_UNDEFINED, &func); +  if (result == -1) +  return NULL; +  return func; + } +  + static void dlclose(void *module) + { +  shl_unload((shl_t)module); + } +  + #define dlinit() +  + #endif /* USE_HPUX_DL */ +  +    #ifndef EMULATE_DLOPEN      #ifdef HAVE_DLFCN_H   #include <dlfcn.h>   #endif      #define dlinit() - #endif + #endif /* !EMULATE_DLOPEN */    -  +    #ifndef RTLD_NOW   #define RTLD_NOW 0   #endif    -  + #endif    - #endif /* !EMULATE_DLOPEN */ +       #ifndef TESTING    - #if defined(HAVE_DLOPEN) || defined(USE_DLD) + #if defined(HAVE_DLOPEN) || defined(USE_DLD) || defined(USE_HPUX_DL)      struct module_list   {    struct module_list * next;    void *module;    modfun init, exit;   };      struct module_list *dynamic_module_list = 0;   
pike.git/src/dynamic_load.c:203: Inside #if undefined(TESTING) and #if defined(HAVE_DLOPEN) || defined(USE_DLD)
   new_module->init=init;    new_module->exit=exit;       pop_n_elems(args);    start_new_program();    (*(modfun)init)();       push_program(end_program());   }    + #endif /* HAVE_DLOPEN || USE_DLD || USE_HPUX_DL */    - #endif /* HAVE_DLOPEN || USE_DLD */ +       void init_dynamic_load(void)   { - #if defined(HAVE_DLOPEN) || defined(USE_DLD) + #if defined(HAVE_DLOPEN) || defined(USE_DLD) || defined(USE_HPUX_DL)    dlinit();       add_efun("load_module",f_load_module,"function(string:program)",OPT_EXTERNAL_DEPEND);   #endif   }      void exit_dynamic_load(void)   { - #if defined(HAVE_DLOPEN) || defined(USE_DLD) + #if defined(HAVE_DLOPEN) || defined(USE_DLD) || defined(USE_HPUX_DL)    while(dynamic_module_list)    {    struct module_list *tmp=dynamic_module_list;    dynamic_module_list=tmp->next;    (*tmp->exit)();   #ifndef DEBUG_MALLOC    dlclose(tmp->module);   #endif    free((char *)tmp);    }