Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #65 from fabienchaix/master
[simgrid.git] / include / simgrid / modelchecker.h
1 /* simgrid/modelchecker.h - Formal Verification made possible in SimGrid    */
2
3 /* Copyright (c) 2008-2015. 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 /** \file modelchecker.h
10  *
11  *  This is the API used by the user simulated program to communicate
12  *  with the MC.
13  */
14
15 #ifndef SIMGRID_MODELCHECKER_H
16 #define SIMGRID_MODELCHECKER_H
17
18 #include <stdbool.h>
19
20 #include <simgrid_config.h> /* HAVE_MC ? */
21
22 #include <xbt/base.h>
23 #include <xbt/automaton.h>
24
25 SG_BEGIN_DECL()
26
27 XBT_PUBLIC(int) MC_random(int min, int max);
28
29 #ifdef HAVE_MC
30
31 /* Internal variable used to check if we're running under the MC
32  *
33  * Please don't use directly: you should use MC_is_active. */
34 extern XBT_PUBLIC(int) _sg_do_model_check;
35 extern XBT_PUBLIC(int) _sg_mc_visited;
36
37 #define MC_is_active()                  _sg_do_model_check
38 #define MC_visited_reduction()          _sg_mc_visited
39
40 /** Assertion for the model-checker
41  *
42  *  This function is used to define safety properties to verify.
43  */
44 XBT_PUBLIC(void) MC_assert(int);
45
46 XBT_PUBLIC(void) MC_automaton_new_propositional_symbol(const char* id, int(*fct)(void));
47 XBT_PUBLIC(void) MC_automaton_new_propositional_symbol_pointer(const char *id, int* value);
48
49 XBT_PUBLIC(void *) MC_snapshot(void);
50 XBT_PUBLIC(int) MC_compare_snapshots(void *s1, void *s2);
51 XBT_PUBLIC(void) MC_cut(void);
52 XBT_PUBLIC(void) MC_ignore(void *addr, size_t size);
53
54 #else
55
56 #define MC_is_active()                  0
57 #define MC_visited_reduction()          0
58
59 #define MC_assert(a)                    xbt_assert(a)
60 #define MC_automaton_new_propositional_symbol(a, b) ((void)0)
61 #define MC_automaton_new_propositional_symbol_pointer(a, b) ((void)0)
62 #define MC_snapshot()                   ((void*)0)
63 #define MC_compare_snapshots(a, b)      0
64 #define MC_cut()                        ((void)0)
65 #define MC_ignore(a, b)                 ((void)0)
66
67 #endif
68
69 SG_END_DECL()
70
71 #endif /* SIMGRID_MODELCHECKER_H */