ssm  0.0.2
Runtime Library for the Sparse Synchronous Model
Arrays

Discussion

The SSM runtime supports contiguous arrays of ssm_value_t. These are managed similarly to ADT objects (Algebraic data types), except the ssm_mm header in arrays use the 16-bit size field, meaning (1) there is no tag, and (2) arrays may accommodate up to 65536 fields (instead of 256).

Data Structures

struct  ssm_array1
 The struct template of a heap-allocated array of values. More...
 

Macros

#define ssm_array_len(v)   ((v).heap_ptr->info.size)
 The length of an array pointed by v. More...
 
#define ssm_array_elements(v)    (&*(container_of((v).heap_ptr, struct ssm_array1, mm)->elements))
 Obtain pointer to the array elements payload pointed to by @ a v. More...
 
#define ssm_array_element(v, i)   (ssm_array_elements(v)[i])
 Obtain pointer to the ith element of the array pointed by v. More...
 
#define ssm_array_size(count)    (sizeof(struct ssm_array1) + sizeof(ssm_value_t) * ((count)-1))
 Compute the size of an array with its header. More...
 
#define ssm_array_heap_size(v)   ssm_array_size(ssm_array_len(v))
 Compute the size an array in the heap from an ssm_value_t. More...
 
#define ssm_new_array(c)
 

Functions

ssm_value_t ssm_new_array_int (uint16_t count)
 Allocate an array on the heap. More...
 

Macro Definition Documentation

◆ ssm_array_len

#define ssm_array_len (   v)    ((v).heap_ptr->info.size)

The length of an array pointed by v.

Definition at line 1016 of file ssm.h.

◆ ssm_array_elements

#define ssm_array_elements (   v)     (&*(container_of((v).heap_ptr, struct ssm_array1, mm)->elements))

Obtain pointer to the array elements payload pointed to by @ a v.

Definition at line 1019 of file ssm.h.

◆ ssm_array_element

#define ssm_array_element (   v,
 
)    (ssm_array_elements(v)[i])

Obtain pointer to the ith element of the array pointed by v.

Definition at line 1023 of file ssm.h.

◆ ssm_array_size

#define ssm_array_size (   count)     (sizeof(struct ssm_array1) + sizeof(ssm_value_t) * ((count)-1))

Compute the size of an array with its header.

Parameters
countthe number of array elements, i.e., the size field.
Returns
size that a array of count elemtns occupies in the heap.

Definition at line 1030 of file ssm.h.

◆ ssm_array_heap_size

#define ssm_array_heap_size (   v)    ssm_array_size(ssm_array_len(v))

Compute the size an array in the heap from an ssm_value_t.

Parameters
vssm_value_t pointing to some blob in the heap.
Returns
size of the array that v points to.

Definition at line 1038 of file ssm.h.

◆ ssm_new_array

#define ssm_new_array (   c)
Value:
(fprintf(stderr,"%s:%d:ssm_new_array(%d)\n", \
__FILE__, __LINE__, (c)), \
ssm_new_array_int(c)

Definition at line 1051 of file ssm.h.

Function Documentation

◆ ssm_new_array_int()

ssm_value_t ssm_new_array_int ( uint16_t  count)

Allocate an array on the heap.

Note that this function returns an array with all elements uninitialized, which must be initialized before ssm_drop() can be called on the array.

Parameters
countnumber of ssm_value_t elements to be stored in the array.
Returns
ssm_value_t pointing to heap-allocated array.

Definition at line 305 of file ssm-mem.c.