Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Cleanup mc_hash
[simgrid.git] / src / mc / mc_client_api.cpp
1 /* Copyright (c) 2008-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <xbt/log.h>
8 #include <xbt/fifo.h>
9 #include <xbt/sysdep.h>
10 #include <simgrid/modelchecker.h>
11
12 #include "mc_record.h"
13 #include "mc_private.h"
14 #include "mc_mmalloc.h"
15 #include "mc_ignore.h"
16 #include "mc_protocol.h"
17 #include "mc_client.h"
18 #include "ModelChecker.hpp"
19
20 extern "C" {
21
22 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client_api, mc,
23   "Public API for the model-checked application");
24
25 void MC_assert(int prop)
26 {
27   if (MC_is_active() && !prop) {
28     MC_client_send_simple_message(MC_MESSAGE_ASSERTION_FAILED);
29     MC_client_handle_messages();
30   }
31 }
32
33 // TODO, MC_automaton_new_propositional_symbol
34
35 void *MC_snapshot(void)
36 {
37   return simcall_mc_snapshot();
38 }
39
40 int simcall_HANDLER_mc_compare_snapshots(smx_simcall_t simcall,
41                                    mc_snapshot_t s1, mc_snapshot_t s2)
42 {
43   return snapshot_compare(s1, s2);
44 }
45
46 int MC_compare_snapshots(void *s1, void *s2)
47 {
48   return simcall_mc_compare_snapshots(s1, s2);
49 }
50
51 void MC_cut(void)
52 {
53   user_max_depth_reached = 1;
54 }
55
56 void MC_ignore(void* addr, size_t size)
57 {
58   if (mc_mode == MC_MODE_CLIENT) {
59     s_mc_ignore_memory_message_t message;
60     message.type = MC_MESSAGE_IGNORE_MEMORY;
61     message.addr = (std::uintptr_t) addr;
62     message.size = size;
63     MC_client_send_message(&message, sizeof(message));
64   }
65 }
66
67 }