pike.git / src / dynamic_load.c

version» Context lines:

pike.git/src/dynamic_load.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: dynamic_load.c,v 1.90 2008/04/14 10:14:38 grubba Exp $ + || $Id: dynamic_load.c,v 1.91 2008/04/26 19:04:25 grubba Exp $   */      #ifdef TESTING   #define NO_PIKE_INCLUDES   #define CREATE_MAIN   #define NO_PIKE_GUTS   #endif      #ifndef NO_PIKE_INCLUDES   # include "global.h"
pike.git/src/dynamic_load.c:370: 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 */    - struct compilation_save + static void cleanup_compilation(void *ignored)   { -  struct lex lex; -  int compilation_depth; - }; -  - static void cleanup_compilation(struct compilation_save *save) - { +     struct program *p = end_program();    if (p) {    free_program(p);    } -  compilation_depth = save->compilation_depth; +    }      /*! @decl program 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.    *!
pike.git/src/dynamic_load.c:404:    *! be called to initialize it. When Pike exits @tt{pike_module_exit()@}    *! will be called. These two functions @b{must@} be available in the module.    *!    *! @note    *! The current working directory is normally not searched for    *! dynamic modules. Please use @expr{"./name.so"@} instead of just    *! @expr{"name.so"@} to load modules from the current directory.    */   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;    struct pike_string *module_name;       ONERROR err;    -  struct compilation_save save; -  +     module_name = Pike_sp[-args].u.string;       if((Pike_sp[-args].type != T_STRING) ||    (module_name->size_shift) ||    string_has_null(module_name)) {    Pike_error("Bad argument 1 to load_module()\n");    }       {    struct module_list *mp;
pike.git/src/dynamic_load.c:531:    new_module->next=dynamic_module_list;    dynamic_module_list=new_module;    new_module->module=module;    copy_shared_string(new_module->name, Pike_sp[-args].u.string);    new_module->module_prog = NULL;    new_module->init=init;    new_module->exit=exit;       enter_compiler(new_module->name, 1);    -  save.compilation_depth=compilation_depth; -  compilation_depth=-1; +     start_new_program();       global_callable_flags|=CALLABLE_DYNAMIC;      #ifdef PIKE_DEBUG    { struct svalue *save_sp=Pike_sp;   #endif -  SET_ONERROR(err, cleanup_compilation, &save); +  SET_ONERROR(err, cleanup_compilation, NULL);   #if defined(__NT__) && defined(_M_IA64)    fprintf(stderr, "Calling pike_module_init()...\n");   #endif /* __NT__ && _M_IA64 */    (*(modfun)init)();   #if defined(__NT__) && defined(_M_IA64)    fprintf(stderr, "pike_module_init() done.\n");   #endif /* __NT__ && _M_IA64 */    UNSET_ONERROR(err);   #ifdef PIKE_DEBUG    if(Pike_sp != save_sp)    Pike_fatal("load_module(%s) left %ld droppings on stack!\n",    module_name->str,    PTRDIFF_T_TO_LONG(Pike_sp - save_sp));    }   #endif       pop_n_elems(args);    {    struct program *p = end_program();    exit_compiler(); -  compilation_depth = save.compilation_depth; +     if (p) {    if (   #if 0    p->num_identifier_references   #else /* !0 */    1   #endif /* 0 */    ) {    push_program(p);    add_ref(new_module->module_prog = Pike_sp[-1].u.program);