59 |
* names to the expansion text. Any macros defined in `m4_macro_table' |
* names to the expansion text. Any macros defined in `m4_macro_table' |
60 |
* are installed into the M4 symbol table with m4_macro_table_install(). |
* are installed into the M4 symbol table with m4_macro_table_install(). |
61 |
* |
* |
62 |
* Each time a module is loaded, the module function |
* Each time a module is loaded, the module function |
63 |
* "void m4_init_module (lt_dlhandle handle, struct obstack *obs)" is |
* "void m4_init_module (lt_dlhandle handle, struct obstack *obs)" is |
64 |
* called, if defined. Any value stored in OBS by this function becomes |
* called, if defined. Any value stored in OBS by this function becomes |
65 |
* the expansion of the macro which called it. Before M4 exits, all |
* the expansion of the macro which called it. Before M4 exits, all |
66 |
* modules are unloaded and the function |
* modules are unloaded and the function |
67 |
* "void m4_finish_module (lt_dlhandle handle, struct obstack *obs)" is |
* "void m4_finish_module (lt_dlhandle handle, struct obstack *obs)" is |
68 |
* called, if defined. It is safe to load the same module several times: |
* called, if defined. It is safe to load the same module several times: |
69 |
* the init and finish functions will also be called multiple times in |
* the init and finish functions will also be called multiple times in |
70 |
* this case. |
* this case. |
71 |
* |
* |
72 |
* To unload a module, use m4_module_unload(). which uses |
* To unload a module, use m4_module_unload(). which uses |
73 |
* m4_remove_table_reference_symbols() to remove the builtins defined by |
* m4_symtab_remove_module_references() to remove the builtins defined by |
74 |
* the unloaded module from the symbol table. If the module has been |
* the unloaded module from the symbol table. If the module has been |
75 |
* loaded several times with calls to m4_module_load, then the module will |
* loaded several times with calls to m4_module_load, then the module will |
76 |
* not be unloaded until the same number of calls to m4_module_unload() |
* not be unloaded until the same number of calls to m4_module_unload() |
167 |
m4_module_init (void) |
m4_module_init (void) |
168 |
{ |
{ |
169 |
int errors = 0; |
int errors = 0; |
170 |
|
|
171 |
/* Do this only once! If we already have a caller_id, then the |
/* Do this only once! If we already have a caller_id, then the |
172 |
module system has already been initialised. */ |
module system has already been initialised. */ |
173 |
if (m4_caller_id) |
if (m4_caller_id) |
201 |
++errors; |
++errors; |
202 |
} |
} |
203 |
} |
} |
204 |
|
|
205 |
if (!errors) |
if (!errors) |
206 |
errors = lt_dlsetsearchpath (MODULE_PATH); |
errors = lt_dlsetsearchpath (MODULE_PATH); |
207 |
|
|
290 |
if (handle) |
if (handle) |
291 |
{ |
{ |
292 |
const lt_dlinfo *info = lt_dlgetinfo (handle); |
const lt_dlinfo *info = lt_dlgetinfo (handle); |
293 |
|
|
294 |
if (info && (info->ref_count == 1)) |
if (info && (info->ref_count == 1)) |
295 |
{ |
{ |
296 |
m4_module_data *data = XMALLOC (m4_module_data, 1); |
m4_module_data *data = XMALLOC (m4_module_data, 1); |
304 |
if (stale) |
if (stale) |
305 |
{ |
{ |
306 |
xfree (stale); |
xfree (stale); |
307 |
|
|
308 |
M4ERROR ((warning_status, 0, |
M4ERROR ((warning_status, 0, |
309 |
_("Warning: overiding stale caller data in module `%s'"), |
_("Warning: overiding stale caller data in module `%s'"), |
310 |
name)); |
name)); |
325 |
m4_module_finish_func *finish_func = 0; |
m4_module_finish_func *finish_func = 0; |
326 |
const char *name = 0; |
const char *name = 0; |
327 |
int errors = 0; |
int errors = 0; |
328 |
|
|
329 |
assert (handle); |
assert (handle); |
330 |
name = m4_module_name (handle); |
name = m4_module_name (handle); |
331 |
|
|
340 |
M4_DEBUG_MESSAGE1("module %s: finish hook called", name); |
M4_DEBUG_MESSAGE1("module %s: finish hook called", name); |
341 |
#endif /* DEBUG_MODULES */ |
#endif /* DEBUG_MODULES */ |
342 |
} |
} |
343 |
|
|
344 |
if (!lt_dlisresident (handle)) |
if (!lt_dlisresident (handle)) |
345 |
{ |
{ |
346 |
{ |
{ |
479 |
equal to 1. If m4_module_close is called again on a |
equal to 1. If m4_module_close is called again on a |
480 |
resident module after the references have already been |
resident module after the references have already been |
481 |
removed, we needn't try to remove them again! */ |
removed, we needn't try to remove them again! */ |
482 |
m4_remove_table_reference_symbols (handle); |
m4_symtab_remove_module_references (handle); |
483 |
|
|
484 |
#ifdef DEBUG_MODULES |
#ifdef DEBUG_MODULES |
485 |
M4_DEBUG_MESSAGE1("module %s: symbols unloaded", name); |
M4_DEBUG_MESSAGE1("module %s: symbols unloaded", name); |