Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[simix] Declare the real type of the argument od run_kernel()
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 26 May 2016 11:18:31 +0000 (13:18 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 26 May 2016 12:04:31 +0000 (14:04 +0200)
src/simix/libsmx.cpp
src/simix/popping.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_generated.cpp
src/simix/popping_private.h
src/simix/simcalls.in
src/simix/simcalls.py

index 115a0e8..5f66232 100644 (file)
@@ -1126,7 +1126,7 @@ xbt_dict_t simcall_storage_get_content(smx_storage_t storage)
 
 void simcall_run_kernel(std::function<void()> const& code)
 {
 
 void simcall_run_kernel(std::function<void()> const& code)
 {
-  return simcall_BODY_run_kernel((void*) &code);
+  return simcall_BODY_run_kernel(&code);
 }
 
 int simcall_mc_random(int min, int max) {
 }
 
 int simcall_mc_random(int min, int max) {
index 832686d..8e93873 100644 (file)
@@ -40,8 +40,7 @@ void SIMIX_simcall_exit(smx_synchro_t synchro)
   synchro->post();
 }
 
   synchro->post();
 }
 
-void SIMIX_run_kernel(void* code)
+void SIMIX_run_kernel(std::function<void()> const* code)
 {
 {
-  std::function<void()>* function = (std::function<void()>*) code;
-  (*function)();
+  (*code)();
 }
 }
index 84a2a0f..5e913d9 100644 (file)
@@ -1143,11 +1143,11 @@ static inline void simcall_set_category__set__category(smx_simcall_t simcall, co
     simgrid::simix::marshal<const char*>(simcall->args[1], arg);
 }
 
     simgrid::simix::marshal<const char*>(simcall->args[1], arg);
 }
 
-static inline void* simcall_run_kernel__get__code(smx_simcall_t simcall) {
-  return simgrid::simix::unmarshal<void*>(simcall->args[0]);
+static inline std::function<void()> const* simcall_run_kernel__get__code(smx_simcall_t simcall) {
+  return simgrid::simix::unmarshal<std::function<void()> const*>(simcall->args[0]);
 }
 }
-static inline void simcall_run_kernel__set__code(smx_simcall_t simcall, void* arg) {
-    simgrid::simix::marshal<void*>(simcall->args[0], arg);
+static inline void simcall_run_kernel__set__code(smx_simcall_t simcall, std::function<void()> const* arg) {
+    simgrid::simix::marshal<std::function<void()> const*>(simcall->args[0], arg);
 }
 
 /* The prototype of all simcall handlers, automatically generated for you */
 }
 
 /* The prototype of all simcall handlers, automatically generated for you */
index 5a5ef80..74b4dcf 100644 (file)
@@ -13,6 +13,7 @@
  * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :)
  */
 
  * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :)
  */
 
+#include <functional>
 #include "smx_private.h"
 #include "src/mc/mc_forward.hpp"
 #include "xbt/ex.h"
 #include "smx_private.h"
 #include "src/mc/mc_forward.hpp"
 #include "xbt/ex.h"
@@ -436,8 +437,8 @@ inline static void simcall_BODY_set_category(smx_synchro_t synchro, const char*
     return simcall<void, smx_synchro_t, const char*>(SIMCALL_SET_CATEGORY, synchro, category);
   }
   
     return simcall<void, smx_synchro_t, const char*>(SIMCALL_SET_CATEGORY, synchro, category);
   }
   
-inline static void simcall_BODY_run_kernel(void* code) {
+inline static void simcall_BODY_run_kernel(std::function<void()> const* code) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) SIMIX_run_kernel(code);
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) SIMIX_run_kernel(code);
-    return simcall<void, void*>(SIMCALL_RUN_KERNEL, code);
+    return simcall<void, std::function<void()> const*>(SIMCALL_RUN_KERNEL, code);
   }/** @endcond */
   }/** @endcond */
index 77604ab..f7b5259 100644 (file)
@@ -420,7 +420,7 @@ case SIMCALL_SET_CATEGORY:
       break;
 
 case SIMCALL_RUN_KERNEL:
       break;
 
 case SIMCALL_RUN_KERNEL:
-      SIMIX_run_kernel(simgrid::simix::unmarshal<void*>(simcall->args[0]));
+      SIMIX_run_kernel(simgrid::simix::unmarshal<std::function<void()> const*>(simcall->args[0]));
       SIMIX_simcall_answer(simcall);
       break;
     case NUM_SIMCALLS:
       SIMIX_simcall_answer(simcall);
       break;
     case NUM_SIMCALLS:
index 3415362..93f0bfe 100644 (file)
@@ -59,7 +59,7 @@ XBT_PRIVATE void SIMIX_simcall_answer(smx_simcall_t);
 XBT_PRIVATE void SIMIX_simcall_handle(smx_simcall_t, int);
 XBT_PRIVATE void SIMIX_simcall_exit(smx_synchro_t);
 XBT_PRIVATE const char *SIMIX_simcall_name(e_smx_simcall_t kind);
 XBT_PRIVATE void SIMIX_simcall_handle(smx_simcall_t, int);
 XBT_PRIVATE void SIMIX_simcall_exit(smx_synchro_t);
 XBT_PRIVATE const char *SIMIX_simcall_name(e_smx_simcall_t kind);
-XBT_PRIVATE void SIMIX_run_kernel(void* code);
+XBT_PRIVATE void SIMIX_run_kernel(std::function<void()> const* code);
 
 SG_END_DECL()
 
 
 SG_END_DECL()
 
index 75cb831..c8cf973 100644 (file)
@@ -115,4 +115,4 @@ xbt_dict_t asr_get_properties(const char* name);
 int        mc_random(int min, int max);
 void       set_category(smx_synchro_t synchro, const char* category) [[nohandler]];
 
 int        mc_random(int min, int max);
 void       set_category(smx_synchro_t synchro, const char* category) [[nohandler]];
 
-void       run_kernel(void* code) [[nohandler]];
+void       run_kernel(std::function<void()> const* code) [[nohandler]];
index 83f7d02..adca709 100755 (executable)
@@ -171,7 +171,7 @@ def parse(fn):
         if line.startswith('#') or not line:
             continue
         match = re.match(
         if line.startswith('#') or not line:
             continue
         match = re.match(
-            r'^(\S+)\s+([^\)\(\s]+)\s*\(*([^\(\)]*)\)\s*(\[\[.*\]\])?\s*;\s*?$', line)
+            r'^(\S+)\s+([^\)\(\s]+)\s*\(*(.*)\)\s*(\[\[.*\]\])?\s*;\s*?$', line)
         assert match, line
         ret, name, args, attrs = match.groups()
         sargs = []
         assert match, line
         ret, name, args, attrs = match.groups()
         sargs = []
@@ -344,6 +344,7 @@ if __name__ == '__main__':
     # smx_popping_bodies.cpp
     #
     fd = header('popping_bodies.cpp')
     # smx_popping_bodies.cpp
     #
     fd = header('popping_bodies.cpp')
+    fd.write('#include <functional>\n')
     fd.write('#include "smx_private.h"\n')
     fd.write('#include "src/mc/mc_forward.hpp"\n')
     fd.write('#include "xbt/ex.h"\n')
     fd.write('#include "smx_private.h"\n')
     fd.write('#include "src/mc/mc_forward.hpp"\n')
     fd.write('#include "xbt/ex.h"\n')