op_pk_vvec_set()
Abstract
Inserts a value vector into a value vector packet.
Syntax
op_pk_vvec_set (vvec_pk_ptr, value_vector)
| Argument | Type | Description |
|---|---|---|
vvec_pk_ptr |
Packet* |
pointer to a value vector packet |
value_vector |
Vvec_Vector |
value vector to be placed into the packet [A value vector must be of type bit to be inserted into a value vector packet.] |
Return Type
Compcode
Completion code indicating whether the value vector was successfully set.
[This value can be compared to the two symbolic constants OPC_COMPCODE_SUCCESS and OPC_COMPCODE_FAILURE.]
Example
/* Append a "partition" value vector onto the contents of a */
/* value vector packet. */
/* Determine if there is already a value vector in this packet */
if (op_pk_vvec_is_set (pkptr))
{
/* There is an existing value vector already in this packet. */
/* Append the "partition" to the existing value vector. */
op_pk_vvec_get (pkptr, ¤t_vvec);
end_pos = op_vvec_size_get (current_vvec);
op_vvec_insert (current_vvec, end_pos, partition_vvec);
}
else
{
/* When op_pk_vvec_set () is called, the Kernel */
/* takes ownership of the value vector. */
/* Therefore, create a duplicate of "partition" */
/* to install into the value vector packet. */
current_vvec = op_vvec_copy (partition_vvec, 0,
op_vvec_size_get (partition_vvec));
}
op_pk_vvec_set (pkptr, current_vvec);
Details
The value vector being inserted must be of type bit. Any value vector inside the packet when this KP is called is destroyed (that is, the memory associated with it is deallocated). The Simulation Kernel assumes ownership of the value vector when it is inside the packet, and it therefore cannot be modified in any way. After this KP’s invocation, the value vector packet’s size is the size of the value vector plus the bulk size.
Note: If a Sar segment is passed as an argument to op_pk_vvec_set() and the Sar segment is also a value vector packet, the KP replaces the value vector that had been in the packet with the new one provided that the two value vectors are the same size.
Purpose
Provides a mechanism to insert value vectors into value vector packets.
Errors
- Program Abort: Packet pointer references unowned packet (
<pk_id>). - Program Abort: Packet pointer references destroyed packet.
- Program Abort: Packet pointer does not reference value vector packet.
- Recoverable Error: Value vector is invalid.
Reference
- Use the KP op_pk_vvec_get() to retrieve value vectors from value vector packets
- Use the KP op_pk_vvec_is_set() to determine if a value vector packet contains a value vector
- Use the KP op_vvec_create() to create a new value vector
- Use the KP op_pk_destroy() to deallocate memory associated with a packet