Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move sg_cmdline to xbt/virtu.h module, and rename it to xbt_cmdline
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 25 Nov 2012 14:15:52 +0000 (15:15 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 25 Nov 2012 14:15:52 +0000 (15:15 +0100)
include/xbt/virtu.h
src/instr/instr_paje_trace.c
src/surf/surf.c
src/xbt/xbt_main.c

index 006bdd8..1d8f1af 100644 (file)
@@ -12,6 +12,7 @@
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "xbt/function_types.h"
 #include "xbt/misc.h"
 #include "xbt/sysdep.h"
 #include "xbt/function_types.h"
+#include "xbt/dynar.h"
 
 SG_BEGIN_DECL()
 
 
 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;
 
     /* 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).
     /**
      *
      * Time management functions, returns the system time or sleeps a process. They work both on the simulated and real systems(GRAS).
index 04110ab..555ac02 100644 (file)
@@ -5,6 +5,7 @@
   * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "instr/instr_private.h"
   * 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
 
 
 #ifdef HAVE_TRACING
 
@@ -181,7 +182,7 @@ void TRACE_paje_start(void)
   fprintf (tracing_file, "#[");
   unsigned int cpt;
   char *str;
   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");
     fprintf(tracing_file, "%s ",str);
   }
   fprintf (tracing_file, "]\n");
index fc1e385..5309c43 100644 (file)
@@ -411,8 +411,6 @@ void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
   *ver_patch = SIMGRID_VERSION_PATCH;
 }
 
   *ver_patch = SIMGRID_VERSION_PATCH;
 }
 
-xbt_dynar_t sg_cmdline = NULL;
-
 void surf_init(int *argc, char **argv)
 {
   XBT_DEBUG("Create all Libs");
 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);
 
   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);
   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);
 #endif
 
   xbt_dynar_free(&surf_path);
-  xbt_dynar_free(&sg_cmdline);
 
   xbt_lib_free(&host_lib);
   xbt_lib_free(&link_lib);
 
   xbt_lib_free(&host_lib);
   xbt_lib_free(&link_lib);
index 73e2daa..93c8e5c 100644 (file)
@@ -1,7 +1,6 @@
 /* module handling                                                          */
 
 /* 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. */
 
 /* 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) */
 
 
 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;
 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_os_thread_mod_postexit();
 
   free(xbt_binary_name);
+  xbt_dynar_free(&xbt_cmdline);
+
 #ifdef MMALLOC_WANT_OVERRIDE_LEGACY
   mmalloc_postexit();
 #endif
 #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_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);
   srand((unsigned int) time(NULL));
 
   xbt_log_init(argc, argv);