source: CIVL/include/headers/civlc.cvh@ 01cf13a

main test-branch
Last change on this file since 01cf13a was 6698ce0, checked in by Alex Wilton <awilton@…>, 3 years ago

Generalized , , and to work with all pointer values.

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

  • Property mode set to 100644
File size: 7.9 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/* Special $abstract function meant to temporarily "hide" a pointer value from
129 * being considered reachable by POR analysis
130 */
131$abstract void* $hide(const void* ptr);
132
133/* Replaces any subexpressions of the value of ptr of the form $hide(p_expr) with
134 * p_expr. In other words, it pulls out the arguments to any calls to $hide,
135 * "revealing" them to be reachable by POR again.
136 */
137/*@ pure;
138 @ depends_on \nothing;
139 @ executes_when \true;
140 @*/
141$system void* $reveal(const void* ptr);
142
143/* Determines if a given pointer value is an application of the $abstract function
144 * $hide (potentially, inside of a cast and/or with an offset)
145 */
146/*@ pure;
147 @ depends_on \nothing;
148 @ executes_when \true;
149 @*/
150$system _Bool $hidden(const void* ptr);
151
152/* Assigns default value to the object referred by the given pointer
153 * "ptr" as if the object has static storage. The definition of
154 * default values of objects having static storage conforms C11
155 * standard.
156 *
157 * The object pointed by "ptr" must have some type.
158 */
159/*@ depends_on \access(ptr);
160 @ executes_when \true;
161 @*/
162$system void $default_value(void *ptr);
163
164/* Returns the value of real number power operation with the given base and exponent.
165 */
166/*@ pure;
167 @ depends_on \nothing;
168 @ executes_when \true;
169 @*/
170$system double $pow(double base, double exp);
171
172/** returns true iff the given pointer is a dereferable pointer */
173/*@ depends_on \nothing;
174 @ executes_when \true;
175 @*/
176$system $state_f _Bool $is_derefable(void * ptr);
177
178/* Returns the reference to a snapshot of the current process from the
179 current state */
180/*@ depends_on \nothing;
181 @ executes_when \true;
182 @*/
183$system $state_f $state $get_state();
184
185/* Returns the reference to the current state */
186/*@ depends_on \nothing; */
187/*@ executes_when \true; */
188$system $state $get_full_state();
189
190// the types will be updated to $integer later
191/*@ pure;
192 @ depends_on \nothing;
193 @ executes_when \true;
194 @*/
195$system int $remainder(int x, int y);
196
197/*@ pure;
198 @ depends_on \nothing;
199 @ executes_when \true;
200 @*/
201$system int $quotient(int x, int y);
202
203/* Push an assumption into the partial path condition stack belong to
204 the calling process. */
205/*@ depends_on \nothing; */
206/*@ executes_when \true; */
207$system void $assume_push(_Bool pred);
208
209/* Pop an entry out of a partial path condition stack belong to the
210 calling process. */
211/*@ depends_on \nothing; */
212/*@ executes_when \true; */
213$system void $assume_pop();
214
215/** The system function informs the verifier that the process is
216 entering an local block. To the verifier, everything in a local
217 block is purely local, i.e., nothing can affect any other process.
218 */
219/*@ depends_on \nothing; */
220/*@ executes_when \true; */
221$system void $local_start();
222
223/** The system function informs the verifier that the process is
224 leaving an local block.
225 */
226$system void $local_end();
227
228/*********************************************************************
229 * As long as a process has a non-empty write set stack, any
230 * modification on variables and memroy heap objects will be recorded
231 * in the write set.
232 *********************************************************************/
233
234/* This is a system function which has the same specification as $when
235 but more strict requirements: The given condition can ONLY change
236 from false to true (or stay true) in any execution of a program,
237 otherwise CIVL will not guarantee the soundness for deadlock-free
238 property.
239 */
240/*@ depends_on \nothing;
241 @*/
242$system void $unidirectional_when(_Bool condition);
243
244/*@ depends_on \access(value);
245 @ executes_when \true;
246 @*/
247$atomic_f void $output_assign(void * output,const void * value, int size);
248
249/* returns the size (in bytes) of the heap of the given scope */
250$system $atomic_f size_t $heap_size($scope scope);
251
252/** The base address q of a pointer p is:
253 *
254 * 1. q := p, if p points anything other than an array element.
255 *
256 * 2. q := a pointer to the first element of the array referred by p,
257 * if p points an array element.
258 *
259 * Note that an "array" here means the physical array which is always
260 * one-dimensional. And a sequence of memory spaces allocated by
261 * malloc will be seen as an array.
262 */
263/*@ depends_on \nothing;
264 @ executes_when \true;
265 @*/
266$system $state_f void * $array_base_address_of(const void *ptr);
267
268
269/** This system function itself is a no-op. However, when a process
270 is at a call to this function, other processes are allowed to
271 interrupt this process. This behavior is in the contrary to an
272 atomic execution that a process cannot be interrupted by other
273 processes. NOTE that allowing other processes to interrupt the
274 current process does not necessarily mean that the interruption
275 will happen. Whether an interruption actually happens (i.e.,
276 transitions of more processes than the current one are enabled at
277 the current state) depends on the POR algorithm.
278 */
279/*@ depends_on \nothing;
280 @*/
281$system void $yield();
282
283#endif
284
285
286
287
Note: See TracBrowser for help on using the repository browser.