source: CIVL/include/headers/civlc.cvh@ 4e993a9

main test-branch
Last change on this file since 4e993a9 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

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