| [aad342c] | 1 | /* This header file contains the data types and function prototypes for bundle.
|
|---|
| 2 | */
|
|---|
| 3 |
|
|---|
| 4 | #ifndef _BUNDLE_
|
|---|
| 5 | #define _BUNDLE_
|
|---|
| 6 |
|
|---|
| 7 | /* includes civlc.cvh because this library references $operation */
|
|---|
| 8 | #include<op.h>
|
|---|
| 9 | #pragma CIVL ACSL
|
|---|
| 10 | /* *********************** Types *********************** */
|
|---|
| 11 |
|
|---|
| 12 | /* A system type for bundling any slice of memory into
|
|---|
| 13 | * a single value. */
|
|---|
| 14 | typedef struct _bundle $bundle;
|
|---|
| 15 |
|
|---|
| 16 | /* *********************** Functions *********************** */
|
|---|
| 17 |
|
|---|
| 18 | /* Returns the size of the given bundle b. */
|
|---|
| 19 | /*@ depends_on \nothing;
|
|---|
| 20 | @ executes_when \true;
|
|---|
| 21 | @*/
|
|---|
| 22 | $system int $bundle_size($bundle b);
|
|---|
| 23 |
|
|---|
| 24 | /* Creates a bundle from the memory region specified by
|
|---|
| 25 | * ptr and size, copying the data into the new bundle */
|
|---|
| 26 | /*@ depends_on \access(ptr);
|
|---|
| 27 | @ executes_when \true;
|
|---|
| 28 | @*/
|
|---|
| 29 | $system $bundle $bundle_pack(const void *ptr, int size);
|
|---|
| 30 |
|
|---|
| 31 | /* Copies the data out of the bundle into the region specified */
|
|---|
| 32 | /*@ depends_on \access(ptr);
|
|---|
| 33 | @ executes_when \true;
|
|---|
| 34 | @*/
|
|---|
| 35 | $system void $bundle_unpack($bundle bundle, void *ptr);
|
|---|
| 36 |
|
|---|
| 37 | /* Unpacks the bundle and applies the specified operation on the content of the bundle.
|
|---|
| 38 | * For every binary operation defined in &operation, the content of the bundle will be used as the left operand
|
|---|
| 39 | * and buf will be used as the right operand. The result of the operation is stored in result once is it is done.
|
|---|
| 40 | *
|
|---|
| 41 | * Requires buf and result are pointers-to-T;
|
|---|
| 42 | * the bundle--data contains sizeof(T) * count amount of objects;
|
|---|
| 43 | * \valid(buf + (0 .. count-1) && \valid(result + (0 .. count-1);
|
|---|
| 44 | * \separate(buf, result);
|
|---|
| 45 | */
|
|---|
| 46 | /*@ depends_on \access(buf);
|
|---|
| 47 | @ depends_on \access(result);
|
|---|
| 48 | @ executes_when \true;
|
|---|
| 49 | @*/
|
|---|
| 50 | $atomic_f void $bundle_unpack_apply($bundle data, void *buf, $operation op, int count, void *result);
|
|---|
| 51 |
|
|---|
| 52 | #endif
|
|---|