Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Remove MC_automaton_new_propositional_symbol_callback()
[simgrid.git] / src / mc / mc_server.cpp
index b882504..8e5f940 100644 (file)
@@ -14,6 +14,8 @@
 #include <sys/signalfd.h>
 
 #include <xbt/log.h>
+#include <xbt/automaton.h>
+#include <xbt/automaton.hpp>
 
 #include "ModelChecker.hpp"
 #include "mc_protocol.h"
@@ -22,6 +24,7 @@
 #include "mc_ignore.h"
 #include "mcer_ignore.h"
 #include "mc_exit.h"
+#include "mc/mc_liveness.h"
 
 using simgrid::mc::remote;
 
@@ -35,20 +38,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_server, mc, "MC server logic");
 
 mc_server_t mc_server;
 
-struct mc_symbol_pointer_callback
-{
-  simgrid::mc::Process* process;
-  void* value;
-};
-
-static int mc_symbol_pointer_callback_evaluate(void* p)
-{
-  struct mc_symbol_pointer_callback* callback = (struct mc_symbol_pointer_callback*) p;
-  int value;
-  callback->process->read_bytes(&value, sizeof(value), remote(callback->value));
-  return value;
-}
-
 s_mc_server::s_mc_server(pid_t pid, int socket)
 {
   this->pid = pid;
@@ -226,12 +215,17 @@ bool s_mc_server::handle_events()
             xbt_die("Support for callbacks/functions symbols not implemented in client/server mode.");
           XBT_DEBUG("Received symbol: %s", message.name);
 
-          struct mc_symbol_pointer_callback* callback = xbt_new(struct mc_symbol_pointer_callback, 1);
-          callback->process = &mc_model_checker->process();
-          callback->value   = message.data;
+          if (_mc_property_automaton == NULL)
+            _mc_property_automaton = xbt_automaton_new();
+
+          simgrid::mc::Process* process = &mc_model_checker->process();
+          simgrid::mc::remote_ptr<int> address
+            = simgrid::mc::remote((int*) message.data);
+          simgrid::xbt::add_proposition(_mc_property_automaton,
+            message.name,
+            [process, address]() { return process->read(address); }
+            );
 
-          MC_automaton_new_propositional_symbol_callback(message.name,
-            mc_symbol_pointer_callback_evaluate, callback, free);
           break;
         }