Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0d41344468001626b16f1d5aeecd66f215b5da89
[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 XBT_PUBLIC(int) MC_random(int min, int max);
21
22 #ifdef HAVE_MC
23
24 extern int _sg_do_model_check; /* please don't use directly: we inline MC_is_active, but that's what you should use */
25 extern int _sg_mc_visited;
26
27 #define MC_is_active()                  _sg_do_model_check
28 #define MC_visited_reduction()          _sg_mc_visited
29
30 XBT_PUBLIC(void) MC_assert(int);
31 XBT_PUBLIC(void) MC_automaton_new_propositional_symbol(const char* id, void* fct);
32 XBT_PUBLIC(void *) MC_snapshot(void);
33 XBT_PUBLIC(int) MC_compare_snapshots(void *s1, void *s2);
34 XBT_PUBLIC(void) MC_cut(void);
35 XBT_PUBLIC(void) MC_ignore(void *addr, size_t size);
36
37 #else
38
39 #define MC_is_active()                  0
40 #define MC_visited_reduction()          0
41
42 #define MC_assert(a)                    xbt_assert(a)
43 #define MC_automaton_new_propositional_symbol(a, b) ((void)0)
44 #define MC_snapshot()                   ((void*)0)
45 #define MC_compare_snapshots(a, b)      0
46 #define MC_cut()                        ((void)0)
47 #define MC_ignore(a, b)                 ((void)0)
48
49 #endif
50
51 /** Replay path (if any) in string representation
52  *
53  *  This is a path as generated by `MC_record_stack_to_string()`.
54  */
55 XBT_PUBLIC_DATA(char*) MC_record_path;
56
57 /** Whether the replay mode is enabled */
58 static inline bool MC_record_replay_is_active(void) {
59   return MC_record_path;
60 }
61
62 SG_END_DECL()
63
64 #endif /* SIMGRID_MODELCHECKER_H */