source: CIVL/include/headers/civlc.cvh@ a849fa8

1.23 2.0 main test-branch
Last change on this file since a849fa8 was 1bae50a, checked in by Alex Wilton <awilton@…>, 3 years ago

Added system function for checking whether a pointer's value is an application of

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5737 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 7.3 KB
Line 
1/* This header file contains the core definitions of the CIVL-C language,
2 * including standard types and function prototypes.
3 */
4
5#ifndef _CIVLC_
6#define _CIVLC_
7
8#pragma CIVL ACSL
9/* ********************* Standard Constants and Types ********************* */
10#define $true 1
11
12#define $false 0
13
14#ifndef NULL
15#define NULL ((void*)0)
16#endif
17
18#ifndef __UNSIGNED_BOUND
19#define __UNSIGNED_BOUND 32
20#endif
21
22#define $elaborate(x) for(int _i = 0; _i < (x); _i++)
23
24typedef unsigned long int size_t;
25
26/* ************************** Basic CIVL-C Types ************************** */
27/* The CIVL-C process reference type */
28typedef struct $proc $proc;
29
30/* The CIVL-C scope type, used to represent a scope */
31typedef struct $scope $scope;
32
33/* The CIVL-C program state refrence type */
34typedef struct $state $state;
35
36/* The CIVL-C dynamic type, used to represent a symbolic type */
37typedef struct $dynamic $dynamic;
38
39/* **************************** Misc. Functions **************************** */
40
41/* Wait for another process p to terminate. */
42/*@ depends_on \nothing;
43 @*/
44$system void $wait($proc p);
45
46/* Blocks until all processes referred to by the given
47 array terminates. */
48/*@ depends_on \nothing;
49 @*/
50$system void $waitall($proc *procs, int numProcs);
51
52/* Terminate the calling process. */
53/*@ depends_on \nothing;
54 @ executes_when \true;
55 @*/
56$system void $exit(void);
57
58/* Checks if the given process has terminated.
59 *
60 * The result returned could change from false to true
61 * if any transition in p executes. Currently we don't
62 * have any way to say "depends on any transition in p".
63 */
64/*@
65 @ executes_when \true;
66 @*/
67$system _Bool $is_terminated($proc p);
68
69/* Nondeterministic choice of integer i, such that 0<=i<n. */
70/*@ depends_on \nothing;
71 @ executes_when \true;
72 @*/
73$system int $choose_int(int n);
74
75/*@ depends_on \nothing;
76 @ executes_when \true;
77 @*/
78$system void $assert(_Bool expr, ...);
79
80/*@ depends_on \nothing;
81 @ executes_when \true;
82 @*/
83$system void $assume(_Bool expr);
84
85/* get a unique non-negative integer number for time count */
86/*@ depends_on \nothing;
87 @ executes_when \true;
88 @*/
89$system int $next_time_count(void);
90
91/* print the path condition of the current state */
92/*@
93 @ depends_on \nothing;
94 @ executes_when \true;
95 @*/
96$system void $pathCondition(void);
97
98/* is the given value concrete? */
99/*@ pure;
100 @ depends_on \nothing;
101 @ executes_when \true;
102 @*/
103$system $pure _Bool $is_concrete_int(int value);
104
105/* **************************** Memory Functions *************************** */
106
107/* The CIVL-C malloc function, which takes a reference to a scope */
108/*@ depends_on \nothing;
109 @ executes_when \true;
110 @*/
111$system void* $malloc($scope s, int size);
112
113/* The CIVL-C de-allocation function, which takes a pointer, just like
114 * the standard "free" */
115/*@ depends_on \access(p);
116 @ executes_when \true;
117 @*/
118$system void $free(void *p);
119
120
121/* Assigns arbitrary value to the memory location specified by the given pointer.
122 */
123/*@ depends_on \access(ptr);
124 @ executes_when \true;
125 @*/
126$system void $havoc(void *ptr);
127
128$abstract void* $make_unreachable(void* ptr);
129$system void* $extract_unreachable(void* ptr);
130$system _Bool $is_unreachable(void* ptr);
131
132/* Assigns default value to the object referred by the given pointer
133 * "ptr" as if the object has static storage. The definition of
134 * default values of objects having static storage conforms C11
135 * standard.
136 *
137 * The object pointed by "ptr" must have some type.
138 */
139/*@ depends_on \access(ptr);
140 @ executes_when \true;
141 @*/
142$system void $default_value(void *ptr);
143
144/* Returns the value of real number power operation with the given base and exponent.
145 */
146/*@ pure;
147 @ depends_on \nothing;
148 @ executes_when \true;
149 @*/
150$system double $pow(double base, double exp);
151
152/** returns true iff the given pointer is a dereferable pointer */
153/*@ depends_on \nothing;
154 @ executes_when \true;
155 @*/
156$system $state_f _Bool $is_derefable(void * ptr);
157
158/* Returns the reference to a snapshot of the current process from the
159 current state */
160/*@ depends_on \nothing;
161 @ executes_when \true;
162 @*/
163$system $state_f $state $get_state();
164
165/* Returns the reference to the current state */
166/*@ depends_on \nothing; */
167/*@ executes_when \true; */
168$system $state $get_full_state();
169
170// the types will be updated to $integer later
171/*@ pure;
172 @ depends_on \nothing;
173 @ executes_when \true;
174 @*/
175$system int $remainder(int x, int y);
176
177/*@ pure;
178 @ depends_on \nothing;
179 @ executes_when \true;
180 @*/
181$system int $quotient(int x, int y);
182
183/* Push an assumption into the partial path condition stack belong to
184 the calling process. */
185/*@ depends_on \nothing; */
186/*@ executes_when \true; */
187$system void $assume_push(_Bool pred);
188
189/* Pop an entry out of a partial path condition stack belong to the
190 calling process. */
191/*@ depends_on \nothing; */
192/*@ executes_when \true; */
193$system void $assume_pop();
194
195/** The system function informs the verifier that the process is
196 entering an local block. To the verifier, everything in a local
197 block is purely local, i.e., nothing can affect any other process.
198 */
199/*@ depends_on \nothing; */
200/*@ executes_when \true; */
201$system void $local_start();
202
203/** The system function informs the verifier that the process is
204 leaving an local block.
205 */
206$system void $local_end();
207
208/*********************************************************************
209 * As long as a process has a non-empty write set stack, any
210 * modification on variables and memroy heap objects will be recorded
211 * in the write set.
212 *********************************************************************/
213
214/* This is a system function which has the same specification as $when
215 but more strict requirements: The given condition can ONLY change
216 from false to true (or stay true) in any execution of a program,
217 otherwise CIVL will not guarantee the soundness for deadlock-free
218 property.
219 */
220/*@ depends_on \nothing;
221 @*/
222$system void $unidirectional_when(_Bool condition);
223
224/*@ depends_on \access(value);
225 @ executes_when \true;
226 @*/
227$atomic_f void $output_assign(void * output,const void * value, int size);
228
229/* returns the size (in bytes) of the heap of the given scope */
230$system $atomic_f size_t $heap_size($scope scope);
231
232/** The base address q of a pointer p is:
233 *
234 * 1. q := p, if p points anything other than an array element.
235 *
236 * 2. q := a pointer to the first element of the array referred by p,
237 * if p points an array element.
238 *
239 * Note that an "array" here means the physical array which is always
240 * one-dimensional. And a sequence of memory spaces allocated by
241 * malloc will be seen as an array.
242 */
243/*@ depends_on \nothing;
244 @ executes_when \true;
245 @*/
246$system $state_f void * $array_base_address_of(const void *ptr);
247
248
249/** This system function itself is a no-op. However, when a process
250 is at a call to this function, other processes are allowed to
251 interrupt this process. This behavior is in the contrary to an
252 atomic execution that a process cannot be interrupted by other
253 processes. NOTE that allowing other processes to interrupt the
254 current process does not necessarily mean that the interruption
255 will happen. Whether an interruption actually happens (i.e.,
256 transitions of more processes than the current one are enabled at
257 the current state) depends on the POR algorithm.
258 */
259/*@ depends_on \nothing;
260 @*/
261$system void $yield();
262
263#endif
264
265
266
267
Note: See TracBrowser for help on using the repository browser.