pike.git / src / dynamic_load.c

version» Context lines:

pike.git/src/dynamic_load.c:8:   # include "global.h"   # include "interpret.h"   # include "constants.h"   # include "pike_error.h"   # include "module.h"   # include "stralloc.h"   # include "pike_macros.h"   # include "main.h"   # include "constants.h"    - RCSID("$Id: dynamic_load.c,v 1.57 2001/11/26 14:54:07 grubba Exp $"); + RCSID("$Id: dynamic_load.c,v 1.58 2002/01/30 22:06:04 marcus Exp $");      #else /* TESTING */      #include <stdio.h>      #endif /* !TESTING */      #ifdef HAVE_ERRNO_H   #include <errno.h>   #endif /* HAVE_ERRNO_H */
pike.git/src/dynamic_load.c:325: Inside #if defined(USE_DYNAMIC_MODULES) and #if defined(NO_CAST_TO_FUN)
   void *ptr;    modfun fun;    } u;    u.ptr = ptr;    return u.fun;   }   #else /* !NO_CAST_TO_FUN */   #define CAST_TO_FUN(X) ((modfun)X)   #endif /* NO_CAST_TO_FUN */    + static void cleanup_compilation_depth(int *save_depth_p) + { +  free_program(end_program()); +  compilation_depth=*save_depth_p; + } +    /*! @decl int load_module(string module_name)    *!    *! Load a binary module.    *!    *! This function loads a module written in C or some other language    *! into Pike. The module is initialized and any programs or constants    *! defined will immediately be available.    *!    *! When a module is loaded the function @tt{pike_module_init()@} will    *! be called to initialize it. When Pike exits @tt{pike_module_exit()@}
pike.git/src/dynamic_load.c:352:   void f_load_module(INT32 args)   {    extern int compilation_depth;    extern int global_callable_flags;       void *module;    modfun init, exit;    struct module_list *new_module;    const char *module_name;    +  ONERROR err; +     int save_depth=compilation_depth;       if(sp[-args].type != T_STRING)    Pike_error("Bad argument 1 to load_module()\n");       module_name = sp[-args].u.string->str;       /* Removing RTLD_GLOBAL breaks some PiGTK themes - Hubbe */    /* Using RTLD_LAZY is faster, but makes it impossible to    * detect linking problems at runtime..
pike.git/src/dynamic_load.c:413:    new_module->exit=exit;       compilation_depth=-1;    start_new_program();       global_callable_flags|=CALLABLE_DYNAMIC;      #ifdef PIKE_DEBUG    { struct svalue *save_sp=sp;   #endif +  SET_ONERROR(err, cleanup_compilation_depth, &save_depth);    (*(modfun)init)(); -  +  UNSET_ONERROR(err);   #ifdef PIKE_DEBUG    if(sp != save_sp)    fatal("load_module(%s) left %ld droppings on stack!\n",    module_name,    PTRDIFF_T_TO_LONG(sp - save_sp));    }   #endif       pop_n_elems(args);    push_program(end_program());
pike.git/src/dynamic_load.c:448: Inside #if defined(USE_DYNAMIC_MODULES)
   tFunc(tStr,tPrg(tObj)), OPT_EXTERNAL_DEPEND);    }   #endif   }      /* Call the pike_module_exit() callbacks for the dynamic modules. */   void exit_dynamic_load(void)   {   #ifdef USE_DYNAMIC_MODULES    struct module_list *tmp; +  JMP_BUF recovery;    for (tmp = dynamic_module_list; tmp; tmp = tmp->next) -  +  { +  if(SETJMP(recovery)) +  call_handle_error(); +  else    (*tmp->exit)(); -  +  UNSETJMP(recovery); +  }   #endif   }      /* Unload all the dynamically loaded modules. */   void free_dynamic_load(void)   {   #ifdef USE_DYNAMIC_MODULES    while(dynamic_module_list)    {    struct module_list *tmp=dynamic_module_list;