Files | Data Structures | Macros | Typedefs | Enumerations | Functions
The Module Helper Library

Different modules often share a number of fundamental requirements and concepts. Picotm comes with a large number of data structures and functions for modules to re-use. This includes locks, tree maps, arrays, reference-counting and more. More...

Files

file  picotm-lib-array.h
 
file  picotm-lib-ptr.h
 
file  picotm-lib-ref.h
 
file  picotm-lib-rwlock.h
 
file  picotm-lib-rwstate.h
 Contains struct picotm_rwstate and helpers.
 
file  picotm-lib-shared-ref-obj.h
 Contains struct picotm_shared_ref16_obj and helper functions.
 
file  picotm-lib-shared-treemap.h
 Contains struct picotm_shared_treemap and helper functions.
 
file  picotm-lib-spinlock.h
 Contains struct picotm_spinlock and helper functions.
 
file  picotm-lib-tab.h
 
file  picotm-lib-treemap.h
 Contains struct picotm_treemap and helpers.
 

Data Structures

struct  picotm_ref16
 
struct  picotm_rwlock
 A reader-writer lock. More...
 
struct  picotm_rwstate
 
struct  picotm_shared_ref16
 
struct  picotm_shared_ref16_obj
 
struct  picotm_shared_treemap
 Maps keys to values. More...
 
struct  picotm_spinlock
 Provides an operating-system-neutral, non-recursive spin-lock type. More...
 
struct  picotm_treemap
 Maps keys to values. More...
 

Macros

#define picotm_arrayat(_array, _i)
 
#define picotm_arraybeg(_array)
 
#define picotm_arrayend(_array)
 
#define picotm_arrayfirst(_array)
 
#define picotm_arraylast(_array)
 
#define picotm_arraylen(_array)
 
#define picotm_containerof(ptr, type, member)
 
#define picotm_ref_count(self)
 
#define picotm_ref_down(self)
 
#define picotm_ref_init(self, count)
 
#define PICOTM_REF_INITIALIZER(__count)
 
#define picotm_ref_up(self)
 
#define PICOTM_RWLOCK_INITIALIZER
 Initializer macro for R/W state variables.
 
#define PICOTM_RWSTATE_INITIALIZER
 Initializer macro for R/W state variables.
 
#define PICOTM_SHARED_REF16_INITIALIZER(count)
 
#define PICOTM_SHARED_REF16_OBJ_INITIALIZER
 
#define PICOTM_SHARED_REF_INITIALIZER(__count)
 
#define picotm_sizeof_align(__type)
 Returns the number of size and alignment bytes of a given type. More...
 
#define PICOTM_SPINLOCK_INITIALIZER
 Initializer macro for picotm spin locks.
 

Typedefs

typedef bool(* picotm_shared_ref16_obj_condition_function) (struct picotm_shared_ref16_obj *ref_obj, void *data, struct picotm_error *error)
 
typedef void(* picotm_shared_ref16_obj_final_ref_function) (struct picotm_shared_ref16_obj *ref_obj, void *data, struct picotm_error *error)
 
typedef void(* picotm_shared_ref16_obj_first_ref_function) (struct picotm_shared_ref16_obj *ref_obj, void *data, struct picotm_error *error)
 
typedef uintptr_t(* picotm_shared_treemap_value_create_function) (unsigned long long key, struct picotm_shared_treemap *treemap, struct picotm_error *error)
 
typedef void(* picotm_shared_treemap_value_destroy_function) (uintptr_t value, struct picotm_shared_treemap *treemap)
 
typedef int(* picotm_tab_compare_function) (const void *data0, const void *data1)
 
typedef size_t(* picotm_tabwalk_1_function) (void *data0, struct picotm_error *error)
 
typedef size_t(* picotm_tabwalk_2_function) (void *data0, void *data1, struct picotm_error *error)
 
typedef size_t(* picotm_tabwalk_3_function) (void *data0, void *data1, void *data2, struct picotm_error *error)
 
typedef void(* picotm_treemap_value_call_function) (uintptr_t value, unsigned long long key, struct picotm_treemap *treemap, void *data, struct picotm_error *error)
 
typedef uintptr_t(* picotm_treemap_value_create_function) (unsigned long long key, struct picotm_treemap *treemap, struct picotm_error *error)
 
typedef void(* picotm_treemap_value_destroy_function) (uintptr_t value, struct picotm_treemap *treemap)
 

Enumerations

enum  picotm_rwstate_status { PICOTM_RWSTATE_UNLOCKED, PICOTM_RWSTATE_RDLOCKED, PICOTM_RWSTATE_WRLOCKED }
 

Functions

static uintptr_t picotm_address_ceil (uintptr_t addr, size_t algn)
 Rounds an address upwards to the nearest address with the given alignment. More...
 
static PICOTM_BEGIN_DECLS uintptr_t picotm_address_floor (uintptr_t addr, size_t algn)
 Rounds an address downwards to the nearest address with the given alignment. More...
 
static void * picotm_ptr_ceil (const void *ptr, size_t algn)
 Rounds a memory location upwards to the nearest address with the given alignment. More...
 
static ptrdiff_t picotm_ptr_diff (const void *hi, const void *lo)
 Subtracts two memory locations and returns the number of raw bytes between them. More...
 
static void * picotm_ptr_floor (const void *ptr, size_t algn)
 Rounds a memory location downwards to the nearest address with the given alignment. More...
 
PICOTM_NOTHROW void picotm_rwlock_init (struct picotm_rwlock *self)
 
PICOTM_NOTHROW void picotm_rwlock_try_rdlock (struct picotm_rwlock *self, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_rwlock_try_wrlock (struct picotm_rwlock *self, bool upgrade, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_rwlock_uninit (struct picotm_rwlock *self)
 
PICOTM_NOTHROW void picotm_rwlock_unlock (struct picotm_rwlock *self)
 
PICOTM_NOTHROW enum picotm_rwstate_status picotm_rwstate_get_status (const struct picotm_rwstate *self)
 
PICOTM_NOTHROW void picotm_rwstate_init (struct picotm_rwstate *self)
 
PICOTM_NOTHROW void picotm_rwstate_set_status (struct picotm_rwstate *self, enum picotm_rwstate_status status)
 
PICOTM_NOTHROW void picotm_rwstate_try_rdlock (struct picotm_rwstate *self, struct picotm_rwlock *rwlock, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_rwstate_try_wrlock (struct picotm_rwstate *self, struct picotm_rwlock *rwlock, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_rwstate_uninit (struct picotm_rwstate *self)
 
PICOTM_NOTHROW void picotm_rwstate_unlock (struct picotm_rwstate *self, struct picotm_rwlock *rwlock)
 
uint16_t picotm_shared_ref16_obj_count (struct picotm_shared_ref16_obj *self)
 
void picotm_shared_ref16_obj_down (struct picotm_shared_ref16_obj *self, void *data, picotm_shared_ref16_obj_condition_function cond, picotm_shared_ref16_obj_final_ref_function final_ref)
 
void picotm_shared_ref16_obj_init (struct picotm_shared_ref16_obj *self, struct picotm_error *error)
 
void picotm_shared_ref16_obj_uninit (struct picotm_shared_ref16_obj *self)
 
void picotm_shared_ref16_obj_up (struct picotm_shared_ref16_obj *self, void *data, picotm_shared_ref16_obj_condition_function cond, picotm_shared_ref16_obj_first_ref_function first_ref, struct picotm_error *error)
 
PICOTM_NOTHROW uintptr_t picotm_shared_treemap_find_value (struct picotm_shared_treemap *self, unsigned long long key, picotm_shared_treemap_value_create_function value_create, picotm_shared_treemap_value_destroy_function value_destroy, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_shared_treemap_init (struct picotm_shared_treemap *self, unsigned long key_nbits, unsigned long level_nbits)
 
PICOTM_NOTHROW void picotm_shared_treemap_uninit (struct picotm_shared_treemap *self, picotm_shared_treemap_value_destroy_function value_destroy)
 
PICOTM_NOTHROW void picotm_tabfree (void *base)
 
PICOTM_NOTHROW void * picotm_tabresize (void *base, size_t nelems, size_t newnelems, size_t siz, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabrwalk_1 (void *base, size_t nelems, size_t siz, picotm_tabwalk_1_function walk, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabrwalk_2 (void *base, size_t nelems, size_t siz, picotm_tabwalk_2_function walk, void *data, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabuniq (void *base, size_t nelems, size_t siz, picotm_tab_compare_function compare)
 
PICOTM_NOTHROW size_t picotm_tabwalk_1 (void *base, size_t nelems, size_t siz, picotm_tabwalk_1_function walk, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabwalk_2 (void *base, size_t nelems, size_t siz, picotm_tabwalk_2_function walk, void *data, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabwalk_3 (void *base, size_t nelems, size_t siz, picotm_tabwalk_3_function walk, void *data1, void *data2, struct picotm_error *error)
 
PICOTM_NOTHROW uintptr_t picotm_treemap_find_value (struct picotm_treemap *self, unsigned long long key, picotm_treemap_value_create_function value_create, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_treemap_for_each_value (struct picotm_treemap *self, void *data, picotm_treemap_value_call_function value_call, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_treemap_init (struct picotm_treemap *self, unsigned long level_nbits)
 
PICOTM_NOTHROW void picotm_treemap_uninit (struct picotm_treemap *self, picotm_treemap_value_destroy_function value_destroy)
 

Detailed Description

Macro Definition Documentation

◆ picotm_arrayat

#define picotm_arrayat (   _array,
  _i 
)

Returns the address of the element at the specified index in a static C array.

◆ picotm_arraybeg

#define picotm_arraybeg (   _array)

Returns the beginning of a static C array.

◆ picotm_arrayend

#define picotm_arrayend (   _array)

Returns the address after a static C array.

◆ picotm_arrayfirst

#define picotm_arrayfirst (   _array)

Returns the address of the first element in a static C array.

◆ picotm_arraylast

#define picotm_arraylast (   _array)

Returns the address of the last element in a static C array.

◆ picotm_arraylen

#define picotm_arraylen (   _array)

Computes the number of elements in a static C array.

◆ picotm_containerof

#define picotm_containerof (   ptr,
  type,
  member 
)

Returns the container of a data structure.

Parameters
ptrA pointer to a data structure.
typeThe type of the container.
memberThe name of the container's member field.
Returns
A pointer to the container data structure.

◆ picotm_ref_count

#define picotm_ref_count (   self)

Reads a reference counter's value.

Parameters
selfreference counter
Returns
The current value of the reference counter.

◆ picotm_ref_down

#define picotm_ref_down (   self)

Decrements a reference counter.

Parameters
selfA reference counter
Returns
True is this is the final reference, false otherwise.

◆ picotm_ref_init

#define picotm_ref_init (   self,
  count 
)

Initializes a reference counter with the given value.

Parameters
selfA reference counter
countThe initial reference count

◆ PICOTM_REF_INITIALIZER

#define PICOTM_REF_INITIALIZER (   __count)

Initializes a statically allocated reference counter with the given value.

Parameters
__countThe initial reference count

◆ picotm_ref_up

#define picotm_ref_up (   self)

Increments a reference counter.

Parameters
selfA reference counter
Returns
True is this is the first reference, false otherwise.

◆ PICOTM_SHARED_REF16_INITIALIZER

#define PICOTM_SHARED_REF16_INITIALIZER (   count)

Initializes a static reference counter with the given value.

Parameters
countThe initial reference count

◆ PICOTM_SHARED_REF16_OBJ_INITIALIZER

#define PICOTM_SHARED_REF16_OBJ_INITIALIZER

Initializes a statically allocated shared-ref16 object.

◆ PICOTM_SHARED_REF_INITIALIZER

#define PICOTM_SHARED_REF_INITIALIZER (   __count)

Initializes a statically allocated reference counter with the given value.

Parameters
__countThe initial reference count

◆ picotm_sizeof_align

#define picotm_sizeof_align (   __type)
Parameters
__typeThe type.
Returns
The number of bytes to hold a value of the given type and its aligment bytes.

Typedef Documentation

◆ picotm_shared_ref16_obj_condition_function

typedef bool(* picotm_shared_ref16_obj_condition_function) (struct picotm_shared_ref16_obj *ref_obj, void *data, struct picotm_error *error)

Invoked by picotm's shared-ref16 object to test if a reference shall be acquired ore released.

Parameters
ref_objThe shared-ref16 object.
dataUser data.
error[out]Returns an error to the caller.
Returns
True if the performed test succeeds, or false otherwise.

◆ picotm_shared_ref16_obj_final_ref_function

typedef void(* picotm_shared_ref16_obj_final_ref_function) (struct picotm_shared_ref16_obj *ref_obj, void *data, struct picotm_error *error)

Invoked by picotm's shared-ref16 object to finalize an object after releasing the final refrence.

Parameters
ref_objThe shared-ref16 object.
dataUser data.
[out]errorReturns an error to the caller.

◆ picotm_shared_ref16_obj_first_ref_function

typedef void(* picotm_shared_ref16_obj_first_ref_function) (struct picotm_shared_ref16_obj *ref_obj, void *data, struct picotm_error *error)

Invoked by picotm's shared-ref16 object to initialize the object after acquiring the first refrence.

Parameters
ref_objThe shared-ref16 object.
dataUser data.
[out]errorReturns an error to the caller.

◆ picotm_shared_treemap_value_create_function

typedef uintptr_t(* picotm_shared_treemap_value_create_function) (unsigned long long key, struct picotm_shared_treemap *treemap, struct picotm_error *error)

Invoked by picotm's shared treemap to create a new shared value.

Parameters
keyThe value's key.
treemapThe value's shared treemap.
[out]errorReturns an error from the creator function.
Returns
A pointer to the created value.

◆ picotm_shared_treemap_value_destroy_function

typedef void(* picotm_shared_treemap_value_destroy_function) (uintptr_t value, struct picotm_shared_treemap *treemap)

Invoked by picotm's shared treemap to destroy a value.

Parameters
valueThe value to destroy.
treemapThe value's shared treemap.

◆ picotm_tab_compare_function

typedef int(* picotm_tab_compare_function) (const void *data0, const void *data1)

Invoked by table functions for comparing two elements.

Parameters
data0A table element.
data1A table element.
Returns
A value less, equal, or greater to zero if data0 is less, equal, or greatet than data1.

◆ picotm_tabwalk_1_function

typedef size_t(* picotm_tabwalk_1_function) (void *data0, struct picotm_error *error)

Invoked by table functions when walking over the elements of a table.

Parameters
data0The table element.
[out]errorReturns an error from the module.
Returns
The number of element to advance.

◆ picotm_tabwalk_2_function

typedef size_t(* picotm_tabwalk_2_function) (void *data0, void *data1, struct picotm_error *error)

Invoked by table functions when walking over the elements of a table.

Parameters
data0The table element.
data1An additional argument.
[out]errorReturns an error from the module.
Returns
The number of element to advance.

◆ picotm_tabwalk_3_function

typedef size_t(* picotm_tabwalk_3_function) (void *data0, void *data1, void *data2, struct picotm_error *error)

Invoked by table functions when walking over the elements of a table.

Parameters
data0The table element.
data1An additional argument.
data2An additional argument.
[out]errorReturns an error from the module.
Returns
The number of element to advance.

◆ picotm_treemap_value_call_function

typedef void(* picotm_treemap_value_call_function) (uintptr_t value, unsigned long long key, struct picotm_treemap *treemap, void *data, struct picotm_error *error)

Invoked by picotm's treemap to call a value.

Parameters
valueThe value.
keyThe value's key.
treemapThe value's treemap.
dataUser data.
[out]errorReturns an error from the creator function.

◆ picotm_treemap_value_create_function

typedef uintptr_t(* picotm_treemap_value_create_function) (unsigned long long key, struct picotm_treemap *treemap, struct picotm_error *error)

Invoked by picotm's treemap to create a new value.

Parameters
keyThe value's key.
treemapThe value's treemap.
[out]errorReturns an error from the creator function.
Returns
A pointer to the created value.

◆ picotm_treemap_value_destroy_function

typedef void(* picotm_treemap_value_destroy_function) (uintptr_t value, struct picotm_treemap *treemap)

Invoked by picotm's treemap to destroy a value.

Parameters
valueThe value to destroy.
treemapThe value's treemap.

Enumeration Type Documentation

◆ picotm_rwstate_status

Signals a shared state's status wrt. a transaction

Enumerator
PICOTM_RWSTATE_UNLOCKED 

The transaction has not acquired the lock.

PICOTM_RWSTATE_RDLOCKED 

The transaction has acquired a reader lock.

PICOTM_RWSTATE_WRLOCKED 

The transaction has acquired a writer lock.

Function Documentation

◆ picotm_address_ceil()

static uintptr_t picotm_address_ceil ( uintptr_t  addr,
size_t  algn 
)
inlinestatic
Parameters
addrA memory address.
algnThe alignment of the result address.
Returns
The next higher address with the given alignment.

◆ picotm_address_floor()

static PICOTM_BEGIN_DECLS uintptr_t picotm_address_floor ( uintptr_t  addr,
size_t  algn 
)
inlinestatic
Parameters
addrA memory address.
algnThe alignment of the result address.
Returns
The next lower address with the given alignment.

◆ picotm_ptr_ceil()

static void* picotm_ptr_ceil ( const void *  ptr,
size_t  algn 
)
inlinestatic
Parameters
ptrA pointer to a memory location.
algnThe alignment of the result memory location.
Returns
The next higher memory location with the given alignment.

◆ picotm_ptr_diff()

static ptrdiff_t picotm_ptr_diff ( const void *  hi,
const void *  lo 
)
inlinestatic
Parameters
hiThe higher memory location.
loThe lower memory location.
Returns
The number of bytes between lo an hi.

◆ picotm_ptr_floor()

static void* picotm_ptr_floor ( const void *  ptr,
size_t  algn 
)
inlinestatic
Parameters
ptrA pointer to a memory location.
algnThe alignment of the result memory location.
Returns
The next lower memory location with the given alignment.

◆ picotm_rwlock_init()

PICOTM_NOTHROW void picotm_rwlock_init ( struct picotm_rwlock self)

Initializes a reader-writer lock.

Parameters
selfThe reader-writer lock to initialize.

◆ picotm_rwlock_try_rdlock()

PICOTM_NOTHROW void picotm_rwlock_try_rdlock ( struct picotm_rwlock self,
struct picotm_error error 
)

Tries to acquire a read lock. If the lock could not be acquired, the error parameter will return a conflict.

Parameters
selfThe reader lock to acquire.
[out]errorReturns a error.

◆ picotm_rwlock_try_wrlock()

PICOTM_NOTHROW void picotm_rwlock_try_wrlock ( struct picotm_rwlock self,
bool  upgrade,
struct picotm_error error 
)

Tries to acquire a writer lock or upgrade an acquired reader lock to a writer lock. If the lock could not be acquired, the error parameter will return a conflict.

Parameters
selfThe writer lock to acquire.
upgradeTrue to upgrade a previously acquired reader lock.
[out]errorReturns a error.

◆ picotm_rwlock_uninit()

PICOTM_NOTHROW void picotm_rwlock_uninit ( struct picotm_rwlock self)

Uninitializes a reader-writer lock.

Parameters
selfThe reader-writer lock to uninitialize.

◆ picotm_rwlock_unlock()

PICOTM_NOTHROW void picotm_rwlock_unlock ( struct picotm_rwlock self)

Releases a reader-writer lock.

Parameters
selfThe reader-writer lock to release.

◆ picotm_rwstate_get_status()

PICOTM_NOTHROW enum picotm_rwstate_status picotm_rwstate_get_status ( const struct picotm_rwstate self)

Returns a reader/writer state's current status.

Parameters
selfThe reader/writer state.
Returns
The reader/writer state's status.

◆ picotm_rwstate_init()

PICOTM_NOTHROW void picotm_rwstate_init ( struct picotm_rwstate self)

Initializes a reader-writer state.

Parameters
selfThe reader-writer state to initialize.

◆ picotm_rwstate_set_status()

PICOTM_NOTHROW void picotm_rwstate_set_status ( struct picotm_rwstate self,
enum picotm_rwstate_status  status 
)

Sets a reader/writer state's status.

Parameters
selfThe reader/writer state.
statusThe status to set.
Returns
The reader/writer state's status.

◆ picotm_rwstate_try_rdlock()

PICOTM_NOTHROW void picotm_rwstate_try_rdlock ( struct picotm_rwstate self,
struct picotm_rwlock rwlock,
struct picotm_error error 
)

Tries to acquire a reader lock for the state variable. If the lock could not be acquired, the error parameter will return a conflict.

Parameters
selfThe reader/writer state.
rwlockThe reader lock to acquire.
[out]errorReturns a error.

◆ picotm_rwstate_try_wrlock()

PICOTM_NOTHROW void picotm_rwstate_try_wrlock ( struct picotm_rwstate self,
struct picotm_rwlock rwlock,
struct picotm_error error 
)

Tries to acquire a writer lock for the state variable or upgrade an acquired reader lock to a writer lock. If the lock could not be acquired, the error parameter will return a conflict.

Parameters
selfThe reader/writer state.
rwlockThe reader lock to acquire.
[out]errorReturns a error.

◆ picotm_rwstate_uninit()

PICOTM_NOTHROW void picotm_rwstate_uninit ( struct picotm_rwstate self)

Uninitializes a reader-writer state.

Parameters
selfThe reader-writer state to uninitialize.

◆ picotm_rwstate_unlock()

PICOTM_NOTHROW void picotm_rwstate_unlock ( struct picotm_rwstate self,
struct picotm_rwlock rwlock 
)

Releases a reader-writer lock.

Parameters
selfThe reader/writer state.
rwlockThe reader/writer lock to release.

◆ picotm_shared_ref16_obj_count()

uint16_t picotm_shared_ref16_obj_count ( struct picotm_shared_ref16_obj self)

Reads the value of a shared-ref16 object's counter.

Parameters
selfThe shared-ref16 object.
Returns
The current value of the reference counter.

◆ picotm_shared_ref16_obj_down()

void picotm_shared_ref16_obj_down ( struct picotm_shared_ref16_obj self,
void *  data,
picotm_shared_ref16_obj_condition_function  cond,
picotm_shared_ref16_obj_final_ref_function  final_ref 
)

Releases a reference on the shared-ref16 object.

Parameters
selfThe shared-ref16 object.
dataUser data.
condAn optional condition to test if the reference should be released.
final_refAn optional function to finalize the object when the final reference gets released.

The conditional and finalizer functions are synchronized with the reference counter. The down function internally locks the shared-ref16 object while performing these operations.

◆ picotm_shared_ref16_obj_init()

void picotm_shared_ref16_obj_init ( struct picotm_shared_ref16_obj self,
struct picotm_error error 
)

Initializes a shared-ref16 object.

Parameters
selfThe shared-ref16 object.
[out]errorReturns an error to the caller.

◆ picotm_shared_ref16_obj_uninit()

void picotm_shared_ref16_obj_uninit ( struct picotm_shared_ref16_obj self)

Uninitializes a shared-ref16 object.

Parameters
selfThe shared-ref16 object.

◆ picotm_shared_ref16_obj_up()

void picotm_shared_ref16_obj_up ( struct picotm_shared_ref16_obj self,
void *  data,
picotm_shared_ref16_obj_condition_function  cond,
picotm_shared_ref16_obj_first_ref_function  first_ref,
struct picotm_error error 
)

Acquires a reference on the shared-ref16 object.

Parameters
selfThe shared-ref16 object.
dataUser data.
condAn optional condition to test if the reference should be acquired.
first_refAn optional function to initialize the object when the first reference gets acquired.
[out]errorReturns an error to the caller.

The conditional and initializer functions are synchronized with the reference counter. The up function internally locks the shared-ref16 object while performing these operations.

◆ picotm_shared_treemap_find_value()

PICOTM_NOTHROW uintptr_t picotm_shared_treemap_find_value ( struct picotm_shared_treemap self,
unsigned long long  key,
picotm_shared_treemap_value_create_function  value_create,
picotm_shared_treemap_value_destroy_function  value_destroy,
struct picotm_error error 
)

Retrieves the value for a key from a shared treemap.

Parameters
selfThe shared treemap.
keyThe value's key.
value_createThe creator function for shared values.
value_destroyThe destroy function for shared values.
[out]errorReturns an error from the look-up function.
Returns
The key's element.

◆ picotm_shared_treemap_init()

PICOTM_NOTHROW void picotm_shared_treemap_init ( struct picotm_shared_treemap self,
unsigned long  key_nbits,
unsigned long  level_nbits 
)

Initializes a shared treemap.

Parameters
selfThe shared treemap to initialize.
key_nbitsThe maximum number of bits per key.
level_nbitsThe number of bits per directory level.

◆ picotm_shared_treemap_uninit()

PICOTM_NOTHROW void picotm_shared_treemap_uninit ( struct picotm_shared_treemap self,
picotm_shared_treemap_value_destroy_function  value_destroy 
)

Uninitializes a shared treemap.

Parameters
selfThe shared treemap to initialize.
value_destroyThe destroy function for shared values.

◆ picotm_tabfree()

PICOTM_NOTHROW void picotm_tabfree ( void *  base)

Free table memory.

Parameters
baseA pointer to the table's first element.

◆ picotm_tabresize()

PICOTM_NOTHROW void* picotm_tabresize ( void *  base,
size_t  nelems,
size_t  newnelems,
size_t  siz,
struct picotm_error error 
)

Allocate or resize table.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
newnelemsThe new number of elements in the table.
sizThe number of bytes per element.
[out]errorReturns an error from the module.
Returns
A pointer to the resized table on success, or NULL otherwise.

◆ picotm_tabrwalk_1()

PICOTM_NOTHROW size_t picotm_tabrwalk_1 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_1_function  walk,
struct picotm_error error 
)

Walk over table in reversed order.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabrwalk_2()

PICOTM_NOTHROW size_t picotm_tabrwalk_2 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_2_function  walk,
void *  data,
struct picotm_error error 
)

Walk over table in reversed order.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
dataAn additional second argument to the call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabuniq()

PICOTM_NOTHROW size_t picotm_tabuniq ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tab_compare_function  compare 
)

Filters out duplicate elements

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
compareThe call-back function for comparing elements.
Returns
The new number of elements in the table.

◆ picotm_tabwalk_1()

PICOTM_NOTHROW size_t picotm_tabwalk_1 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_1_function  walk,
struct picotm_error error 
)

Walk over table elements.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabwalk_2()

PICOTM_NOTHROW size_t picotm_tabwalk_2 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_2_function  walk,
void *  data,
struct picotm_error error 
)

Walk over table elements.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
dataAn additional second argument to the call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabwalk_3()

PICOTM_NOTHROW size_t picotm_tabwalk_3 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_3_function  walk,
void *  data1,
void *  data2,
struct picotm_error error 
)

Walk over table elements.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
data1An additional second argument to the call-back function.
data2An additional third argument to the call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_treemap_find_value()

PICOTM_NOTHROW uintptr_t picotm_treemap_find_value ( struct picotm_treemap self,
unsigned long long  key,
picotm_treemap_value_create_function  value_create,
struct picotm_error error 
)

Retrieves the value for a key from a treemap.

Parameters
selfThe treemap.
keyThe value's key.
value_createThe creator function for values.
[out]errorReturns an error from the look-up function.
Returns
The key's element.

◆ picotm_treemap_for_each_value()

PICOTM_NOTHROW void picotm_treemap_for_each_value ( struct picotm_treemap self,
void *  data,
picotm_treemap_value_call_function  value_call,
struct picotm_error error 
)

Iterates over all values stored in a treemap.

Parameters
selfThe treemap.
dataUser data.
value_callThe call-back function for values.
[out]errorReturns an error from the look-up function.

◆ picotm_treemap_init()

PICOTM_NOTHROW void picotm_treemap_init ( struct picotm_treemap self,
unsigned long  level_nbits 
)

Initializes a treemap.

Parameters
selfThe treemap to initialize.
level_nbitsThe number of bits per directory level.

◆ picotm_treemap_uninit()

PICOTM_NOTHROW void picotm_treemap_uninit ( struct picotm_treemap self,
picotm_treemap_value_destroy_function  value_destroy 
)

Uninitializes a treemap.

Parameters
selfThe treemap to initialize.
value_destroyThe destroy function for values.