| 1 | /* This header file contains function prototypes for sequence operations.
|
|---|
| 2 | * In CIVL-C, a sequence of type T is defined as an incomplete array of type T.
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #ifndef _SEQ_
|
|---|
| 6 | #define _SEQ_
|
|---|
| 7 | #pragma CIVL ACSL
|
|---|
| 8 | /* ******************************* Functions ******************************* */
|
|---|
| 9 |
|
|---|
| 10 | /* Given a pointer to an object of type "array-of-T", returns the
|
|---|
| 11 | * length of the array. */
|
|---|
| 12 | /*@ depends_on \access(array);
|
|---|
| 13 | @ executes_when \true;
|
|---|
| 14 | @*/
|
|---|
| 15 | $system int $seq_length(void *array);
|
|---|
| 16 |
|
|---|
| 17 | /* Given a pointer to an object of type "incomplete-array-of-T",
|
|---|
| 18 | * sets that object to be the array of length count in which every
|
|---|
| 19 | * element has the same value, specified by the given pointer value.
|
|---|
| 20 | *
|
|---|
| 21 | * Parameters:
|
|---|
| 22 | * array: pointer-to-incomplete-array-of-T
|
|---|
| 23 | * count: any integer type, must be nonnegative
|
|---|
| 24 | * values: pointer-to-T
|
|---|
| 25 | */
|
|---|
| 26 | /*@ depends_on \access(array, value);
|
|---|
| 27 | @ executes_when \true;
|
|---|
| 28 | @*/
|
|---|
| 29 | $system void $seq_init(void *array, int count, void *value);
|
|---|
| 30 |
|
|---|
| 31 | /* Given a pointer to an object of type "incomplete-array-of-T",
|
|---|
| 32 | * inserts count elements into the array starting at position
|
|---|
| 33 | * index. The subsequence elements of the array are shifted up,
|
|---|
| 34 | * and the final length of the array will be its original length
|
|---|
| 35 | * plus count. The values to be inserted are taken from the
|
|---|
| 36 | * region specified by parameters values. Must have
|
|---|
| 37 | * 0<=index<=length, where length is the length of the array in
|
|---|
| 38 | * the pre-state. If index=length, this appends the elements
|
|---|
| 39 | * to the end of the array. If index=0, this inserts the elements
|
|---|
| 40 | * at the beginning of the array. If count=0, this is a no-op
|
|---|
| 41 | * and values will not be evaluated (hence may be NULL).
|
|---|
| 42 | *
|
|---|
| 43 | * Parameters:
|
|---|
| 44 | * array: pointer-to-incomplete-array-of-T
|
|---|
| 45 | * index: any integer type, 0<=index<=length
|
|---|
| 46 | * values: pointer-to-T
|
|---|
| 47 | * count: any integer type, count>=0
|
|---|
| 48 | *
|
|---|
| 49 | */
|
|---|
| 50 | /*@ depends_on \access(array, values);
|
|---|
| 51 | @ executes_when \true;
|
|---|
| 52 | @*/
|
|---|
| 53 | $system void $seq_insert(void *array, int index, void *values, int count);
|
|---|
| 54 |
|
|---|
| 55 | /* Removes count elements from the array, starting at position
|
|---|
| 56 | * index. If values is not NULL, the removed elements will be copied
|
|---|
| 57 | * to the memory region beginning with values.
|
|---|
| 58 | * Parameters:
|
|---|
| 59 | * array: pointer-to-incomplete-array-of-T
|
|---|
| 60 | * index: any integer type, 0<=index<length
|
|---|
| 61 | * values: pointer-to-T
|
|---|
| 62 | * count: any integer type, 0<=count<=length-index
|
|---|
| 63 | */
|
|---|
| 64 | /*@ depends_on \access(array, values);
|
|---|
| 65 | @ executes_when \true;
|
|---|
| 66 | @*/
|
|---|
| 67 | $system void $seq_remove(void *array, int index, void *values, int count);
|
|---|
| 68 |
|
|---|
| 69 | /* Given a pointer to an object of type "incomplete-array-of-T",
|
|---|
| 70 | * appends count elements at the end of the array.
|
|---|
| 71 | * The final length of the array will be its original length
|
|---|
| 72 | * plus count. The values to be inserted are taken from the
|
|---|
| 73 | * region specified by parameters values. If count=0, this is
|
|---|
| 74 | * a no-op and values will not be evaluated (hence may be NULL).
|
|---|
| 75 | *
|
|---|
| 76 | * Parameters:
|
|---|
| 77 | * array: pointer-to-incomplete-array-of-T
|
|---|
| 78 | * values: pointer-to-T
|
|---|
| 79 | * count: any integer type, count>=0
|
|---|
| 80 | *
|
|---|
| 81 | */
|
|---|
| 82 | /*@ depends_on \access(array, values);
|
|---|
| 83 | @*/
|
|---|
| 84 | $atomic_f void $seq_append(void *array, void *values, int count);
|
|---|
| 85 |
|
|---|
| 86 | #endif
|
|---|