Skip to content

Commit 62a4b55

Browse files
committed
Adapt user manual description of memory primitives
1 parent 74a7648 commit 62a4b55

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

doc/cprover-manual/api.md

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,6 @@ to the program. If the expression evaluates to false, the execution
2020
aborts without failure. More detail on the use of assumptions is in the
2121
section on [Assumptions](../modeling/assumptions/).
2222
23-
#### \_\_CPROVER\_r_ok, \_\_CPROVER\_w_ok
24-
25-
```C
26-
void __CPROVER_r_ok(const void *, size_t size);
27-
void __CPROVER_w_ok(const void *, size_t size);
28-
```
29-
30-
The function **\_\_CPROVER\_r_ok** returns true if reading the piece of
31-
memory starting at the given pointer with the given size is safe.
32-
**\_\_CPROVER\_w_ok** does the same with writing.
33-
34-
#### \_\_CPROVER\_same\_object, \_\_CPROVER\_POINTER\_OBJECT, \_\_CPROVER\_POINTER\_OFFSET, \_\_CPROVER\_DYNAMIC\_OBJECT
35-
36-
```C
37-
_Bool __CPROVER_same_object(const void *, const void *);
38-
__CPROVER_size_t __CPROVER_POINTER_OBJECT(const void *p);
39-
__CPROVER_ssize_t __CPROVER_POINTER_OFFSET(const void *p);
40-
_Bool __CPROVER_DYNAMIC_OBJECT(const void *p);
41-
```
42-
43-
The function **\_\_CPROVER\_same\_object** returns true if the two
44-
pointers given as arguments point to the same object. The function
45-
**\_\_CPROVER\_POINTER\_OFFSET** returns the offset of the given pointer
46-
relative to the base address of the object. The function
47-
**\_\_CPROVER\_DYNAMIC\_OBJECT** returns true if the pointer passed as
48-
arguments points to a dynamically allocated object.
49-
5023
#### \_\_CPROVER\_input, \_\_CPROVER\_output
5124
5225
```C
@@ -156,6 +129,47 @@ the array **dest** with the given value.
156129
157130
Uninterpreted functions are documented [here](./modeling-nondeterminism.md)).
158131
132+
### Memory-Related Functions
133+
134+
The semantics of the primitives listed in this section is described in more detail in the
135+
document about [Memory Primitives](http://cprover.diffblue.com/memory-primitives.html).
136+
137+
#### \_\_CPROVER\_POINTER\_OBJECT, \_\_CPROVER\_POINTER\_OFFSET, \_\_CPROVER\_same\_object
138+
139+
```C
140+
__CPROVER_size_t __CPROVER_POINTER_OBJECT(const void *p);
141+
__CPROVER_ssize_t __CPROVER_POINTER_OFFSET(const void *p);
142+
_Bool __CPROVER_same_object(const void *p, const void *q);
143+
```
144+
145+
The function **\_\_CPROVER\_POINTER\_OBJECT** returns the ID of the object the
146+
pointer points to. The function **\_\_CPROVER\_POINTER\_OFFSET** returns the
147+
offset of the given pointer relative to the base address of the object. The
148+
function **\_\_CPROVER\_same\_object** returns true if the two pointers given as
149+
arguments point to the same object.
150+
151+
#### \_\_CPROVER\_OBJECT\_SIZE, \_\_CPROVER\_DYNAMIC\_OBJECT, \_\_CPROVER\_r\_ok, \_\_CPROVER\_w\_ok
152+
153+
The following primitives require a pointer that is null or valid in order to
154+
have well-defined semantics in all usage cases. See the document about
155+
[Memory Primitives](http://cprover.diffblue.com/memory-primitives.html)
156+
for more details. It also includes a description of the `--pointer-primitive-check`
157+
option to verify the preconditions of the primitives.
158+
159+
```C
160+
__CPROVER_size_t __CPROVER_OBJECT_SIZE(const void *p);
161+
_Bool __CPROVER_DYNAMIC_OBJECT(const void *p);
162+
void __CPROVER_r_ok(const void *p, size_t size);
163+
void __CPROVER_w_ok(const void *p, size_t size);
164+
```
165+
166+
The function **\_\_CPROVER_\_OBJECT\_SIZE** returns the size of the object the
167+
given pointer points to. The function **\_\_CPROVER\_DYNAMIC\_OBJECT** returns
168+
true if the pointer passed as an argument points to a dynamically allocated
169+
object. The function **\_\_CPROVER\_r_ok** returns true if reading the piece of
170+
memory starting at the given pointer with the given size is safe.
171+
**\_\_CPROVER\_w_ok** does the same with writing.
172+
159173
### Predefined Types and Symbols
160174
161175
#### \_\_CPROVER\_bitvector

0 commit comments

Comments
 (0)