| 1 | /* This header file contains the function prototypes for
|
|---|
| 2 | * pointer operations.
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #ifndef _POINTER_
|
|---|
| 6 | #define _POINTER_
|
|---|
| 7 | #pragma CIVL ACSL
|
|---|
| 8 | #include<civlc.cvh>
|
|---|
| 9 | #include<op.h>
|
|---|
| 10 |
|
|---|
| 11 | /* ******************************* Functions ******************************* */
|
|---|
| 12 |
|
|---|
| 13 | /* updates the leaf nodes of a status variable to the default value 0 */
|
|---|
| 14 | /*@ depends_on \access(obj);
|
|---|
| 15 | @ executes_when \true;
|
|---|
| 16 | @*/
|
|---|
| 17 | $system void $set_default(void *obj);
|
|---|
| 18 |
|
|---|
| 19 | /* applies the operation op on obj1 and obj2 and stores the result */
|
|---|
| 20 | /*@ depends_on \access(obj1, obj2, result);
|
|---|
| 21 | @ executes_when \true;
|
|---|
| 22 | @*/
|
|---|
| 23 | $system void $apply(void *obj1, $operation op, void *obj2, void *result);
|
|---|
| 24 |
|
|---|
| 25 | /* are the object pointed to equal? */
|
|---|
| 26 | /*@ depends_on \access(x, y);
|
|---|
| 27 | @ executes_when \true;
|
|---|
| 28 | @*/
|
|---|
| 29 | $system _Bool $equals(void *x, void *y);
|
|---|
| 30 |
|
|---|
| 31 | /* Assert that the two objects pointed are equal */
|
|---|
| 32 | /*@ depends_on \access(x, y);
|
|---|
| 33 | @ executes_when \true;
|
|---|
| 34 | @*/
|
|---|
| 35 | $system void $assert_equals(void *x, void *y, ...);
|
|---|
| 36 |
|
|---|
| 37 | /* Semantics: Does the object pointed to by obj1 contain that
|
|---|
| 38 | pointed to by obj1? */
|
|---|
| 39 | /*@ depends_on \access(obj1, obj2);
|
|---|
| 40 | @ executes_when \true;
|
|---|
| 41 | @*/
|
|---|
| 42 | $system _Bool $contains(void *obj1, void *obj2);
|
|---|
| 43 |
|
|---|
| 44 | /* Translates a pointer into one object to a pointer
|
|---|
| 45 | * into a different object with similar structure. */
|
|---|
| 46 | /*@ depends_on \nothing;
|
|---|
| 47 | @ executes_when \true;
|
|---|
| 48 | @*/
|
|---|
| 49 | $system void * $translate_ptr(void *ptr, void *obj);
|
|---|
| 50 |
|
|---|
| 51 | /* Copies the value pointed to by the right operand to the memory
|
|---|
| 52 | * location specified by the left operand. */
|
|---|
| 53 | /*@ depends_on \access(ptr, value);
|
|---|
| 54 | @ executes_when \true;
|
|---|
| 55 | @*/
|
|---|
| 56 | $system void $copy(void *ptr, void *value);
|
|---|
| 57 |
|
|---|
| 58 | /*
|
|---|
| 59 | copy the references to the leaf nodes of obj to the given array
|
|---|
| 60 | obj: pointer to type T' whose leaf node types are all type T
|
|---|
| 61 | array: pointer to array of pointer to type T
|
|---|
| 62 | */
|
|---|
| 63 | /*@ depends_on \access(array);
|
|---|
| 64 | @ executes_when \true;
|
|---|
| 65 | @*/
|
|---|
| 66 | $system void $leaf_node_ptrs(void *array, void *obj);
|
|---|
| 67 |
|
|---|
| 68 | /*
|
|---|
| 69 | returns true if the given pointer is referencing to
|
|---|
| 70 | an object by identity reference
|
|---|
| 71 | */
|
|---|
| 72 | /*@ depends_on \nothing;
|
|---|
| 73 | @ executes_when \true;
|
|---|
| 74 | @*/
|
|---|
| 75 | $system _Bool $is_identity_ref(void *obj);
|
|---|
| 76 |
|
|---|
| 77 | /*
|
|---|
| 78 | updates the leaf nodes of the given objects to with
|
|---|
| 79 | the given integer value
|
|---|
| 80 | */
|
|---|
| 81 | /*@ depends_on \access(obj);
|
|---|
| 82 | @ executes_when \true;
|
|---|
| 83 | @*/
|
|---|
| 84 | $system void $set_leaf_nodes(void *obj, int value);
|
|---|
| 85 |
|
|---|
| 86 | /*
|
|---|
| 87 | returns true iff all leaf nodes of the given
|
|---|
| 88 | object equal to the given value
|
|---|
| 89 | */
|
|---|
| 90 | /*@ depends_on \access(obj);
|
|---|
| 91 | @ executes_when \true;
|
|---|
| 92 | @*/
|
|---|
| 93 | $system _Bool $leaf_nodes_equal_to(void *obj, int value);
|
|---|
| 94 |
|
|---|
| 95 | /*
|
|---|
| 96 | returns true iff at least one leaf nodes of the given
|
|---|
| 97 | object equal to the given value
|
|---|
| 98 | */
|
|---|
| 99 | /*@ depends_on \access(obj);
|
|---|
| 100 | @ executes_when \true;
|
|---|
| 101 | @*/
|
|---|
| 102 | $system _Bool $has_leaf_node_equal_to(void *obj, int value);
|
|---|
| 103 |
|
|---|
| 104 | /*
|
|---|
| 105 | can the given pointer be safely referenced?
|
|---|
| 106 | A derefable pointer is not NULL
|
|---|
| 107 | and is referring to a memory location of some dyscope.
|
|---|
| 108 | */
|
|---|
| 109 | /*@ depends_on \nothing;
|
|---|
| 110 | @ executes_when \true;
|
|---|
| 111 | @*/
|
|---|
| 112 | $system _Bool $is_derefable_pointer(void *ptr);
|
|---|
| 113 |
|
|---|
| 114 | /*
|
|---|
| 115 | Gives a pointer addition operation. Note that the input pointer will always be
|
|---|
| 116 | casted to the form of a pointer to a primitive data type.
|
|---|
| 117 | */
|
|---|
| 118 | /*@ depends_on \nothing;
|
|---|
| 119 | @ executes_when \true;
|
|---|
| 120 | @*/
|
|---|
| 121 | $system void * $pointer_add(const void *ptr, int offset, int type_size);
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | #endif
|
|---|