pike.git / src / module.c

version» Context lines:

pike.git/src/module.c:366:   #endif /* DO_PIKE_CLEANUP */   }      typedef void (*modfun)(void);      struct static_module   {    char *name;    modfun init;    modfun exit; +  int semidynamic;   };      static const struct static_module module_list[] = { -  { "Builtin", init_builtin_modules, exit_builtin_modules } +  { "Builtin", init_builtin_modules, exit_builtin_modules, 0 }   #include "modules/modlist.h"   #ifndef PRE_PIKE   #include "post_modules/modlist.h"   #endif   };    -  + /* The follwing are used to simulate dlopen() et al. */ +  + const struct static_module *find_semidynamic_module(const char *name, int namelen) + { +  unsigned int e; +  for(e=0;e<NELEM(module_list);e++) { +  if (module_list[e].semidynamic && +  !strncmp(module_list[e].name, name, namelen) && +  !module_list[e].name[namelen]) { +  TRACE((stderr, "Found semidynamic module #%d: \"%s\"...\n", +  e, module_list[e].name)); +  return module_list+e; +  } +  } +  return NULL; + } +  + void *get_semidynamic_init_fun(const struct static_module *sm) + { +  if (!sm) return NULL; +  return sm->init; + } +  + void *get_semidynamic_exit_fun(const struct static_module *sm) + { +  if (!sm) return NULL; +  return sm->exit; + } +  +    /*! @decl object _static_modules    *!    *! This is an object containing the classes for all static    *! (ie non-dynamic) C-modules.    *!    *! In a typic Pike with support for dynamic modules the contained    *! module classes are:    *! @dl    *! @item @[Builtin]    *! @item @[Gmp]
pike.git/src/module.c:412:    start_new_program();    Pike_compiler->new_program->id=PROG___BUILTIN_ID;       for(e=0;e<NELEM(module_list);e++)    {    JMP_BUF recovery;    if (!p) {    start_new_program();    p = Pike_compiler->new_program;    } +  if (module_list[e].semidynamic) continue;    if(SETJMP(recovery)) {    /* FIXME: We could loop here until we find p. */    free_program(end_program());    p = NULL;    call_handle_error();    } else {    TRACE((stderr, "Initializing static module #%d: \"%s\"...\n",    e, module_list[e].name));    module_list[e].init();    if (
pike.git/src/module.c:495: Inside #if defined(DO_PIKE_CLEANUP)
   gc_destruct_everything = 0;    exit_cleanup_in_progress = 1; /* Warn about object creation from now on. */    }       /* Unload dynamic modules before static ones. */    exit_dynamic_load();   #endif /* DO_PIKE_CLEANUP */       for(e=NELEM(module_list)-1;e>=0;e--)    { +  if (module_list[e].semidynamic) continue;    if(SETJMP(recovery))    call_handle_error();    else {    TRACE((stderr, "Exiting static module #%d: \"%s\"...\n",    e, module_list[e].name));    module_list[e].exit();    }    UNSETJMP(recovery);    }   }