Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Compile trace_mgr with g++. Next step: objectification
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 23 Jan 2016 21:19:55 +0000 (22:19 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 23 Jan 2016 21:55:33 +0000 (22:55 +0100)
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/surf_interface.hpp
src/surf/surf_private.h
src/surf/trace_mgr.cpp [moved from src/surf/trace_mgr.c with 96% similarity]
src/surf/trace_mgr.hpp [moved from src/include/surf/trace_mgr.h with 54% similarity]
src/surf/trace_mgr_private.h [deleted file]
teshsuite/surf/trace_usage/CMakeLists.txt
teshsuite/surf/trace_usage/trace_usage.cpp [moved from teshsuite/surf/trace_usage/trace_usage.c with 96% similarity]
tools/cmake/DefinePackages.cmake

index 2c5499c..6a1d618 100644 (file)
@@ -5,8 +5,8 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "cpu_ti.hpp"
-#include "trace_mgr_private.h"
 #include "xbt/heap.h"
+#include "src/surf/trace_mgr.hpp"
 #include "src/surf/platform.hpp"
 
 #ifndef SURF_MODEL_CPUTI_H_
index 6bcbcdc..d6d3159 100644 (file)
@@ -6,8 +6,8 @@
 
 #include <xbt/base.h>
 
-#include "cpu_interface.hpp"
-#include "trace_mgr_private.h"
+#include "src/surf/cpu_interface.hpp"
+#include "src/surf/trace_mgr.hpp"
 #include "surf/surf_routing.h"
 
 /* Epsilon */
index 951e4f2..3644497 100644 (file)
 
 #include <xbt/signal.hpp>
 
-#include "surf/trace_mgr.h"
 #include "xbt/lib.h"
 #include "surf/surf_routing.h"
 #include "simgrid/platf_interface.h"
 #include "surf/surf.h"
 #include "src/surf/surf_private.h"
+#include "src/surf/trace_mgr.hpp"
 #include "src/internal_config.h"
 
 extern XBT_PRIVATE tmgr_fes_t history;
index 730bcc7..f094f38 100644 (file)
 
 #include "surf/surf.h"
 #include "surf/maxmin.h"
-#include "surf/trace_mgr.h"
 #include "xbt/log.h"
 #include "surf/surfxml_parse.h"
 #include "surf/random_mgr.h"
+#include "src/surf/trace_mgr.hpp"
 #include "src/instr/instr_private.h"
 #include "surf/surfxml_parse_values.h"
 
similarity index 96%
rename from src/surf/trace_mgr.c
rename to src/surf/trace_mgr.cpp
index e421353..39a8d6c 100644 (file)
@@ -8,7 +8,7 @@
 #include "xbt/log.h"
 #include "xbt/str.h"
 #include "xbt/dict.h"
-#include "trace_mgr_private.h"
+#include "src/surf/trace_mgr.hpp"
 #include "surf_private.h"
 #include "xbt/RngStream.h"
 #include <math.h>
@@ -17,7 +17,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_trace, surf, "Surf trace management");
 
 static xbt_dict_t trace_list = NULL;
 
-XBT_INLINE tmgr_fes_t tmgr_history_new(void)
+tmgr_fes_t tmgr_history_new(void)
 {
   tmgr_fes_t h;
 
@@ -28,7 +28,7 @@ XBT_INLINE tmgr_fes_t tmgr_history_new(void)
   return h;
 }
 
-XBT_INLINE void tmgr_history_free(tmgr_fes_t h)
+void tmgr_history_free(tmgr_fes_t h)
 {
   xbt_heap_free(h->heap);
   free(h);
@@ -261,7 +261,7 @@ tmgr_trace_t tmgr_trace_new_from_string(const char *id, const char *input,
   char *val;
 
   if (trace_list) {
-    trace = xbt_dict_get_or_null(trace_list, id);
+    trace = (tmgr_trace_t)xbt_dict_get_or_null(trace_list, id);
     if (trace) {
       XBT_WARN("Ignoring redefinition of trace %s", id);
       return trace;
@@ -305,9 +305,7 @@ tmgr_trace_t tmgr_trace_new_from_string(const char *id, const char *input,
       }
     }
     xbt_dynar_push(trace->s_list.event_list, &event);
-    last_event =
-        xbt_dynar_get_ptr(trace->s_list.event_list,
-                          xbt_dynar_length(trace->s_list.event_list) - 1);
+    last_event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, xbt_dynar_length(trace->s_list.event_list) - 1);
   }
   if (last_event)
     last_event->delta = periodicity;
@@ -331,7 +329,7 @@ tmgr_trace_t tmgr_trace_new_from_file(const char *filename)
     return NULL;
 
   if (trace_list) {
-    trace = xbt_dict_get_or_null(trace_list, filename);
+    trace = (tmgr_trace_t)xbt_dict_get_or_null(trace_list, filename);
     if (trace) {
       XBT_WARN("Ignoring redefinition of trace %s", filename);
       return trace;
@@ -367,7 +365,7 @@ tmgr_trace_t tmgr_empty_trace_new(void)
   return trace;
 }
 
-XBT_INLINE void tmgr_trace_free(tmgr_trace_t trace)
+void tmgr_trace_free(tmgr_trace_t trace)
 {
   if (!trace)
     return;
@@ -427,7 +425,7 @@ tmgr_trace_iterator_t tmgr_history_get_next_event_leq(tmgr_fes_t h,
   if (event_date > date)
     return NULL;
 
-  if (!(trace_iterator = xbt_heap_pop(h->heap)))
+  if (!(trace_iterator = (tmgr_trace_iterator_t)xbt_heap_pop(h->heap)))
     return NULL;
 
   trace = trace_iterator->trace;
@@ -436,7 +434,7 @@ tmgr_trace_iterator_t tmgr_history_get_next_event_leq(tmgr_fes_t h,
   switch(trace->type) {
     case e_trace_list:
 
-      event = xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
+      event = (tmgr_event_t)xbt_dynar_get_ptr(trace->s_list.event_list, trace_iterator->idx);
 
       *value = event->value;
 
@@ -476,7 +474,7 @@ tmgr_trace_iterator_t tmgr_history_get_next_event_leq(tmgr_fes_t h,
   return trace_iterator;
 }
 
-XBT_INLINE void tmgr_finalize(void)
+void tmgr_finalize(void)
 {
   xbt_dict_free(&trace_list);
 }
similarity index 54%
rename from src/include/surf/trace_mgr.h
rename to src/surf/trace_mgr.hpp
index 2598b77..1c42547 100644 (file)
 #include "simgrid/platf_interface.h"
 
 SG_BEGIN_DECL()
+#include "xbt/base.h"
+#include "xbt/swag.h"
+#include "xbt/heap.h"
+#include "trace_mgr.hpp"
+#include "xbt/RngStream.h"
+
+typedef struct tmgr_event {
+  double delta;
+  double value;
+} s_tmgr_event_t, *tmgr_event_t;
+
+enum e_trace_type {
+  e_trace_list, e_trace_probabilist
+};
+
+enum e_event_generator_type {
+  e_generator_uniform, e_generator_exponential, e_generator_weibull
+};
+
+typedef struct probabilist_event_generator {
+  enum e_event_generator_type type;
+  RngStream rng_stream;
+  double next_value;
+  union {
+    struct {
+      double min;
+      double max;
+    } s_uniform_parameters;
+    struct {
+      double rate;
+    } s_exponential_parameters;
+    struct {
+      double scale;
+      double shape;
+    } s_weibull_parameters;
+  };
+} s_probabilist_event_generator_t;
+
+typedef struct tmgr_trace {
+  enum e_trace_type type;
+  union {
+    struct {
+      xbt_dynar_t event_list;
+    } s_list;
+    struct {
+      probabilist_event_generator_t event_generator[2];
+      int is_state_trace;
+      int next_event;
+    } s_probabilist;
+  };
+} s_tmgr_trace_t;
+
+/* Iterator within a trace */
+typedef struct tmgr_trace_iterator {
+  tmgr_trace_t trace;
+  unsigned int idx;
+  void *resource;
+  int free_me;
+} s_tmgr_trace_event_t;
+
+/* Future Event Set (collection of iterators over the traces)
+ * That's useful to quickly know which is the next occurring event in a set of traces. */
+typedef struct tmgr_fes {
+  xbt_heap_t heap; /* Content: only trace_events */
+} s_tmgr_history_t;
+
+XBT_PRIVATE double tmgr_event_generator_next_value(probabilist_event_generator_t generator);
 
 /* Creation functions */
 XBT_PUBLIC(tmgr_fes_t) tmgr_history_new(void);
diff --git a/src/surf/trace_mgr_private.h b/src/surf/trace_mgr_private.h
deleted file mode 100644 (file)
index d05ba5b..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright (c) 2004, 2007, 2009-2010, 2012-2014. 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. */
-
-#ifndef _SURF_TMGR_PRIVATE_H
-#define _SURF_TMGR_PRIVATE_H
-
-#include "xbt/base.h"
-#include "xbt/swag.h"
-#include "xbt/heap.h"
-#include "surf/trace_mgr.h"
-#include "xbt/RngStream.h"
-
-typedef struct tmgr_event {
-  double delta;
-  double value;
-} s_tmgr_event_t, *tmgr_event_t;
-
-enum e_trace_type {
-  e_trace_list, e_trace_probabilist
-};
-
-enum e_event_generator_type {
-  e_generator_uniform, e_generator_exponential, e_generator_weibull
-};
-
-typedef struct probabilist_event_generator {
-  enum e_event_generator_type type;
-  RngStream rng_stream;
-  double next_value;
-  union {
-    struct {
-      double min;
-      double max;
-    } s_uniform_parameters;
-    struct {
-      double rate;
-    } s_exponential_parameters;
-    struct {
-      double scale;
-      double shape;
-    } s_weibull_parameters;
-  };
-} s_probabilist_event_generator_t;
-
-typedef struct tmgr_trace {
-  enum e_trace_type type;
-  union {
-    struct {
-      xbt_dynar_t event_list;
-    } s_list;
-    struct {
-      probabilist_event_generator_t event_generator[2];
-      int is_state_trace;
-      int next_event;
-    } s_probabilist;
-  };
-} s_tmgr_trace_t;
-
-/* Iterator within a trace */
-typedef struct tmgr_trace_iterator {
-  tmgr_trace_t trace;
-  unsigned int idx;
-  void *resource;
-  int free_me;
-} s_tmgr_trace_event_t;
-
-/* Future Event Set (collection of iterators over the traces)
- * That's useful to quickly know which is the next occurring event in a set of traces. */
-typedef struct tmgr_fes {
-  xbt_heap_t heap; /* Content: only trace_events */
-} s_tmgr_history_t;
-
-XBT_PRIVATE double tmgr_event_generator_next_value(probabilist_event_generator_t generator);
-
-#endif                          /* _SURF_TMGR_PRIVATE_H */
index bbe4500..f4345e8 100644 (file)
@@ -1,10 +1,10 @@
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
 
-add_executable(trace_usage ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/trace_usage/trace_usage.c)
+add_executable(trace_usage ${CMAKE_HOME_DIRECTORY}/teshsuite/surf/trace_usage/trace_usage.cpp)
 
 ### Add definitions for compile
 if(NOT WIN32)
-  target_link_libraries(trace_usage simgrid m )
+  target_link_libraries(trace_usage simgrid m)
 else()
   target_link_libraries(trace_usage simgrid )
 endif()
@@ -20,7 +20,7 @@ set(xml_files
   )
 set(testsuite_src
   ${testsuite_src}
-  ${CMAKE_CURRENT_SOURCE_DIR}/trace_usage.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/trace_usage.cpp
   PARENT_SCOPE
   )
 set(bin_files
similarity index 96%
rename from teshsuite/surf/trace_usage/trace_usage.c
rename to teshsuite/surf/trace_usage/trace_usage.cpp
index 06450c7..34005e4 100644 (file)
@@ -6,7 +6,6 @@
 /* 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. */
 
-#include "surf/trace_mgr.h"
 #include "surf/surf.h"
 
 #include "xbt/log.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "src/surf/trace_mgr.hpp"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
                              "Messages specific for surf example");
 
-void test(void);
-void test(void)
+static void test(void)
 {
   tmgr_fes_t history = tmgr_history_new();
   tmgr_trace_t trace_A = tmgr_trace_new_from_file("trace_A.txt");
index c6c5889..d1d57e1 100644 (file)
@@ -16,7 +16,6 @@ set(EXTRA_DIST
   src/include/surf/random_mgr.h
   src/include/surf/surf.h
   src/include/surf/surfxml_parse_values.h
-  src/include/surf/trace_mgr.h
   src/include/xbt/win32_ucontext.h
   src/include/xbt/wine_dbghelp.h
   src/msg/msg_mailbox.h
@@ -83,7 +82,6 @@ set(EXTRA_DIST
   src/surf/surf_routing_private.hpp
   src/surf/surf_routing_vivaldi.hpp
   src/surf/surfxml_parse.c
-  src/surf/trace_mgr_private.h
   src/surf/vm_hl13.hpp
   src/surf/PropertyHolder.hpp
   src/surf/virtual_machine.hpp
@@ -345,7 +343,8 @@ set(SURF_SRC
   src/surf/surf_routing_vivaldi.cpp
   src/surf/surfxml_parse.c
   src/surf/surfxml_parseplatf.c
-  src/surf/trace_mgr.c
+  src/surf/trace_mgr.hpp
+  src/surf/trace_mgr.cpp
   src/surf/vm_hl13.cpp
   src/surf/virtual_machine.cpp
   src/surf/host_clm03.cpp