Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sonar treats
[simgrid.git] / include / simgrid / modelchecker.h
1 /* simgrid/modelchecker.h - Formal Verification made possible in SimGrid    */
2
3 /* Copyright (c) 2008-2017. The SimGrid Team. All rights reserved.          */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 /** \file modelchecker.h
9  *
10  *  This is the API used by the user simulated program to communicate
11  *  with the MC.
12  */
13
14 #ifndef SIMGRID_MODELCHECKER_H
15 #define SIMGRID_MODELCHECKER_H
16
17 #include <stddef.h> /* size_t */
18
19 #include <simgrid_config.h> /* SIMGRID_HAVE_MC ? */
20
21 #include <xbt/base.h>
22
23 SG_BEGIN_DECL()
24
25 XBT_PUBLIC(int) MC_random(int min, int max);
26
27 #if SIMGRID_HAVE_MC
28
29 /* Internal variable used to check if we're running under the MC
30  *
31  * Please don't use directly: you should use MC_is_active. */
32 extern XBT_PUBLIC(int) _sg_do_model_check;
33 extern XBT_PUBLIC(int) _sg_mc_max_visited_states;
34
35 #define MC_is_active()                  _sg_do_model_check
36 #define MC_visited_reduction() _sg_mc_max_visited_states
37
38 /** Assertion for the model-checker
39  *
40  *  This function is used to define safety properties to verify.
41  */
42 XBT_PUBLIC(void) MC_assert(int);
43
44 XBT_PUBLIC(void) MC_automaton_new_propositional_symbol(const char* id, int(*fct)(void));
45 XBT_PUBLIC(void) MC_automaton_new_propositional_symbol_pointer(const char *id, int* value);
46
47 XBT_PUBLIC(void) MC_cut(void);
48 XBT_PUBLIC(void) MC_ignore(void *addr, size_t size);
49
50 XBT_PUBLIC(void) MC_ignore_heap(void* address, size_t size);
51 XBT_PUBLIC(void) MC_remove_ignore_heap(void* address, size_t size);
52 XBT_PUBLIC(void) MC_ignore_local_variable(const char* var_name, const char* frame);
53 XBT_PUBLIC(void) MC_ignore_global_variable(const char* var_name);
54
55 #else
56
57 #define MC_is_active()                  0
58 #define MC_visited_reduction()          0
59
60 #define MC_assert(a)                    xbt_assert(a)
61 #define MC_automaton_new_propositional_symbol(a, b) ((void)0)
62 #define MC_automaton_new_propositional_symbol_pointer(a, b) ((void)0)
63 #define MC_cut()                        ((void)0)
64 #define MC_ignore(a, b)                 ((void)0)
65
66 #define MC_ignore_heap(a,s)             ((void)0)
67 #define MC_remove_ignore_heap(a,s)      ((void)0)
68 #define MC_ignore_local_variable(n,f)   ((void)0)
69 #define MC_ignore_global_variable(v)    ((void)0)
70
71 #endif
72
73 SG_END_DECL()
74
75 #endif /* SIMGRID_MODELCHECKER_H */