Changes between Version 6 and Version 7 of Libraries


Ignore:
Timestamp:
05/22/23 14:55:52 (3 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Libraries

    v6 v7  
    1010A bundle is a sequence of objects of the same type, wrapped into an atomic package. A bundle is created using a function that specifies a region of memory. One can create a bundle from an array of integers, and another bundle from an array of reals. Both bundles have the same type, `$bundle`. They can therefore be entered into an array of `$bundle`, for example. Hence bundles are useful for mixing objects of different (even statically unknown) types into a single data structure. Later, the contents of a bundle can be extracted with another function that specifies a region of memory into which to unpack the bundle; if that memory does not have the right type to receive the contents of the bundle, a runtime error occurs.
    1111
     12=== `$bundle_size`
     13
     14{{{
     15$system int $bundle_size($bundle b)
     16}}}
     17Returns the size of the given bundle, i.e., the number of bytes consumed by all elements of the bundle.
     18This is the product of the number of elements and the size of one element.
     19
     20=== `$bundle_pack`
     21
     22{{{
     23$system $bundle $bundle_pack(void *ptr, int size)
     24}}}
     25This function creates a bundle from the memory region specified by `ptr` and `size` (the total number of bytes to copy),
     26copying the data into the new bundle.
     27It returns the new bundle.
     28
     29=== `$bundle_unpack`
     30
     31{{{
     32$system  void $bundle_unpack($bundle b, void *ptr)
     33}}}
     34This function copies the data from the given bundle into the memory region starting at `ptr`.
     35The memory region extends for `$bundle_size(b)` bytes.
     36
     37=== `$bundle_unpack_apply`
     38
     39{{{
     40$system void $bundle_unpack_apply($bundle data, void *buf, int size, $operation op);
     41}}}
     42
     43This function unpacks the bundle and applies the specified operation on the contents of the bundle.
     44For every binary operation defined in operation, the content of the bundle will be used as the left operand and `buf` will be used as the right operand.
     45The result of the operation is stored in `buf` once is it is done.
    1246
    1347
     
    2660== `concurrency.cvh`
    2761
     62== `op.h`
     63
     64Defines an enumerated type `$operation` with the following values:
     65| Constant | Description |
     66| `_NO_OP`  | no operation |
     67| `_MAX`    | maximum |
     68| `_MIN`    | minimun |
     69|  _SUM     | sum  |
     70|  _PROD    | product |
     71|  _LAND    | logical and |
     72|  _BAND    | bit-wise and |
     73|  _LOR     | logical or |
     74|  _BOR     | bit-wise or |
     75|  _LXOR    | logical exclusive or |
     76|  _BXOR    | bit-wise exclusive or |
     77|  _MINLOC  | min value and location |
     78|  _MAXLOC  | max value and location |
     79|  _EQ      | equal to |
     80|  _NEQ     | not Equal to |
     81
     82
     83typedef enum Operation $operation;
     84
     85
    2886== `pointer.cvh`
    2987