Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cc1888eca0524cc0381364c9eb423a3778b5a2b3
[simgrid.git] / include / simgrid / modelchecker.h
1 /* simgrid/modelchecker.h - Formal Verification made possible in SimGrid    */
2
3 /* Copyright (c) 2008-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include <stdbool.h>
10
11 #include <simgrid_config.h> /* HAVE_MC ? */
12 #include <xbt.h>
13 #include "xbt/automaton.h"
14
15 #ifndef SIMGRID_MODELCHECKER_H
16 #define SIMGRID_MODELCHECKER_H
17
18 SG_BEGIN_DECL()
19
20 /** Replay path (if any) in string representation
21  *
22  *  This is a path as generated by `MC_record_stack_to_string()`.
23  */
24 XBT_PUBLIC_DATA(char*) MC_record_path;
25
26 /** Whether the replay mode is enabled */
27 static inline bool MC_record_replay_is_active(void) {
28   return MC_record_path;
29 }
30
31 XBT_PUBLIC(int) MC_random(int min, int max);
32
33 #ifdef HAVE_MC
34
35 extern int _sg_do_model_check; /* please don't use directly: we inline MC_is_active, but that's what you should use */
36 extern int _sg_mc_visited;
37
38 #define MC_is_active()                  _sg_do_model_check
39 #define MC_visited_reduction()          _sg_mc_visited
40
41 XBT_PUBLIC(void) MC_assert(int);
42 XBT_PUBLIC(void) MC_automaton_new_propositional_symbol(const char* id, int(*fct)(void));
43 XBT_PUBLIC(void *) MC_snapshot(void);
44 XBT_PUBLIC(int) MC_compare_snapshots(void *s1, void *s2);
45 XBT_PUBLIC(void) MC_cut(void);
46 XBT_PUBLIC(void) MC_ignore(void *addr, size_t size);
47
48 #else
49
50 #define MC_is_active()                  0
51 #define MC_visited_reduction()          0
52
53 #define MC_assert(a)                    xbt_assert(a)
54 #define MC_automaton_new_propositional_symbol(a, b) ((void)0)
55 #define MC_snapshot()                   ((void*)0)
56 #define MC_compare_snapshots(a, b)      0
57 #define MC_cut()                        ((void)0)
58 #define MC_ignore(a, b)                 ((void)0)
59
60 #endif
61
62 SG_END_DECL()
63
64 #endif /* SIMGRID_MODELCHECKER_H */