From: Martin Quinson Date: Sun, 25 Nov 2012 14:15:52 +0000 (+0100) Subject: move sg_cmdline to xbt/virtu.h module, and rename it to xbt_cmdline X-Git-Tag: v3_9_rc1~91^2~27 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b82c39e1bcdca7cad4c88dd56a131d2b4268166a move sg_cmdline to xbt/virtu.h module, and rename it to xbt_cmdline --- diff --git a/include/xbt/virtu.h b/include/xbt/virtu.h index 006bdd87d2..1d8f1afdd0 100644 --- a/include/xbt/virtu.h +++ b/include/xbt/virtu.h @@ -12,6 +12,7 @@ #include "xbt/misc.h" #include "xbt/sysdep.h" #include "xbt/function_types.h" +#include "xbt/dynar.h" SG_BEGIN_DECL() @@ -24,6 +25,9 @@ XBT_PUBLIC(double) xbt_time(void); /* Get the name of the UNIX process englobing the world */ XBT_PUBLIC_DATA(char*) xbt_binary_name; + /** Contains all the parameters we got from the command line (including argv[0]) */ + XBT_PUBLIC_DATA(xbt_dynar_t) xbt_cmdline; + /** * * Time management functions, returns the system time or sleeps a process. They work both on the simulated and real systems(GRAS). diff --git a/src/instr/instr_paje_trace.c b/src/instr/instr_paje_trace.c index 04110ab8bd..555ac028e8 100644 --- a/src/instr/instr_paje_trace.c +++ b/src/instr/instr_paje_trace.c @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "instr/instr_private.h" +#include "xbt/virtu.h" /* sg_cmdline */ #ifdef HAVE_TRACING @@ -181,7 +182,7 @@ void TRACE_paje_start(void) fprintf (tracing_file, "#["); unsigned int cpt; char *str; - xbt_dynar_foreach (sg_cmdline, cpt, str){ + xbt_dynar_foreach (xbt_cmdline, cpt, str){ fprintf(tracing_file, "%s ",str); } fprintf (tracing_file, "]\n"); diff --git a/src/surf/surf.c b/src/surf/surf.c index fc1e385857..5309c43bb7 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -411,8 +411,6 @@ void sg_version(int *ver_major,int *ver_minor,int *ver_patch) { *ver_patch = SIMGRID_VERSION_PATCH; } -xbt_dynar_t sg_cmdline = NULL; - void surf_init(int *argc, char **argv) { XBT_DEBUG("Create all Libs"); @@ -433,11 +431,6 @@ void surf_init(int *argc, char **argv) SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free); SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free); - sg_cmdline = xbt_dynar_new(sizeof(char*),NULL); - int i; - for (i=0;i<*argc;i++) { - xbt_dynar_push(sg_cmdline,&(argv[i])); - } xbt_init(argc, argv); if (!model_list) model_list = xbt_dynar_new(sizeof(surf_model_private_t), NULL); @@ -510,7 +503,6 @@ void surf_exit(void) #endif xbt_dynar_free(&surf_path); - xbt_dynar_free(&sg_cmdline); xbt_lib_free(&host_lib); xbt_lib_free(&link_lib); diff --git a/src/xbt/xbt_main.c b/src/xbt/xbt_main.c index 73e2daa1f2..93c8e5c25a 100644 --- a/src/xbt/xbt_main.c +++ b/src/xbt/xbt_main.c @@ -1,7 +1,6 @@ /* module handling */ -/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2012. The SimGrid Team. 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. */ @@ -27,6 +26,8 @@ XBT_LOG_NEW_CATEGORY(smpi, "All SMPI categories"); /* lives here even if that's char *xbt_binary_name = NULL; /* Name of the system process containing us (mandatory to retrieve neat backtraces) */ +xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */ + int xbt_initialized = 0; int _surf_do_model_check = 0; @@ -108,6 +109,8 @@ static void xbt_postexit(void) xbt_os_thread_mod_postexit(); free(xbt_binary_name); + xbt_dynar_free(&xbt_cmdline); + #ifdef MMALLOC_WANT_OVERRIDE_LEGACY mmalloc_postexit(); #endif @@ -122,6 +125,12 @@ void xbt_init(int *argc, char **argv) } xbt_binary_name = xbt_strdup(argv[0]); + xbt_cmdline = xbt_dynar_new(sizeof(char*),NULL); + int i; + for (i=0;i<*argc;i++) { + xbt_dynar_push(xbt_cmdline,&(argv[i])); + } + srand((unsigned int) time(NULL)); xbt_log_init(argc, argv);