X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4e0b0a957106c8c55b7aa24f118ed5862e98064d..75ab9579163d7854f8a262ab0cc04739d876b538:/src/xbt/module.c diff --git a/src/xbt/module.c b/src/xbt/module.c index d435369a7e..652b0c795a 100644 --- a/src/xbt/module.c +++ b/src/xbt/module.c @@ -2,28 +2,24 @@ /* module handling */ -/* Authors: Martin Quinson */ -/* Copyright (C) 2003 the OURAGAN project. */ +/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include "xbt/config.h" -#include "gras/process.h" /* FIXME: bad loop */ - #include "xbt/module.h" /* this module */ #include "xbt_modinter.h" /* prototype of other module's init/exit in XBT */ -#include "gras_modinter.h" /* same in GRAS */ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module,xbt, "module handling"); -static int xbt_running_process = 0; +char *xbt_binary_name=NULL; /* Mandatory to retrieve neat backtraces */ +int xbt_initialized=0; struct xbt_module_ { xbt_dynar_t *deps; @@ -33,70 +29,26 @@ struct xbt_module_ { xbt_module_finalize_fct_t finalize; }; +/** @brief Initialize the xbt mechanisms. */ void xbt_init(int *argc, char **argv) { - xbt_init_defaultlog(argc, argv, NULL); -} + xbt_initialized++; -/** - * xbt_init_defaultlog: - * @argc: - * @argv: - * - * Initialize the gras mecanisms. - */ -void -xbt_init_defaultlog(int *argc,char **argv, const char *defaultlog) { - int i,j; - char *opt; - int found=0; + if (xbt_initialized!=1) + return; - INFO0("Initialize GRAS"); + xbt_binary_name = strdup(argv[0]); + VERB0("Initialize XBT"); - /** Set logs and init log submodule */ - for (i=1; i<*argc; i++) { - if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) { - found = 1; - opt=strchr(argv[i],'='); - opt++; - xbt_log_control_set(opt); - DEBUG1("Did apply '%s' as log setting",opt); - /*remove this from argv*/ - for (j=i+1; j<*argc; j++) { - argv[j-1] = argv[j]; - } - argv[j-1] = NULL; - (*argc)--; - i--; /* compensate effect of next loop incrementation */ - } - } - if (!found && defaultlog) { - xbt_log_control_set(defaultlog); - } - - gras_process_init(); /* calls procdata_init, which calls dynar_new */ - /** init other submodules */ - if (xbt_running_process++ == 0) { - gras_msg_init(); - gras_trp_init(); - gras_datadesc_init(); - } + xbt_log_init(argc,argv); } -/** - * xbt_exit: - * - * Finalize the gras mecanisms. - */ +/** @brief Finalize the xbt mechanisms. */ void xbt_exit(){ - INFO0("Exiting GRAS"); - gras_process_exit(); - if (--xbt_running_process == 0) { - gras_msg_exit(); - gras_trp_exit(); - gras_datadesc_exit(); - } + xbt_initialized--; + if (xbt_initialized == 0) + free(xbt_binary_name); xbt_log_exit(); - DEBUG0("Exited GRAS"); } +