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-global-state.h |
Contains global-state helper macros. | |
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-state.h |
Contains shared-state helper macros. | |
file | picotm-lib-shared-treemap.h |
Contains struct picotm_shared_treemap and helper functions. | |
file | picotm-lib-slist.h |
Contains struct picotm_slist and helpers. | |
file | picotm-lib-spinlock.h |
Contains struct picotm_spinlock and helper functions. | |
file | picotm-lib-state.h |
Contains state helper macros. | |
file | picotm-lib-tab.h |
file | picotm-lib-thread-state.h |
Contains thread-state helper macros. | |
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_slist |
Entry in a singly-linked list. 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_GLOBAL_STATE_GET(_name) |
#define | PICOTM_GLOBAL_STATE_REF(_name, _error) |
#define | PICOTM_GLOBAL_STATE_STATIC_IMPL(_name) |
#define | PICOTM_GLOBAL_STATE_UNREF(_name) |
#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_SHARED_STATE(_name, _type) |
#define | PICOTM_SHARED_STATE_INITIALIZER |
#define | PICOTM_SHARED_STATE_REF(_name, _self, _error) |
#define | PICOTM_SHARED_STATE_STATIC_IMPL(_name, _type, _init, _uninit) |
#define | PICOTM_SHARED_STATE_TYPE(_name) |
#define | PICOTM_SHARED_STATE_UNREF(_name, _self) |
#define | picotm_sizeof_align(__type) |
Returns the number of size and alignment bytes of a given type. More... | |
#define | PICOTM_SLIST_HEAD_INITIALIZER(head_) |
#define | PICOTM_SLIST_ITEM_INITIALIZER |
#define | PICOTM_SPINLOCK_INITIALIZER |
Initializer macro for picotm spin locks. | |
#define | PICOTM_STATE(_name, _type) |
#define | PICOTM_STATE_ACQUIRE(_name, _self, _initialize, _error) |
#define | PICOTM_STATE_INITIALIZER |
#define | PICOTM_STATE_RELEASE(_name, _self) |
#define | PICOTM_STATE_STATIC_DECL(_name, _type) |
#define | PICOTM_STATE_STATIC_IMPL(_name, _type, _init, _uninit) |
#define | PICOTM_STATE_TYPE(_name) |
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) |
static struct picotm_slist * | picotm_slist_back (const struct picotm_slist *head) |
static struct picotm_slist * | picotm_slist_begin (const struct picotm_slist *head) |
static void | picotm_slist_cleanup_0 (struct picotm_slist *head, void(*cleanup)(struct picotm_slist *)) |
static void | picotm_slist_cleanup_1 (struct picotm_slist *head, void(*cleanup)(struct picotm_slist *, void *), void *data1) |
static void | picotm_slist_cleanup_2 (struct picotm_slist *head, void(*cleanup)(struct picotm_slist *, void *, void *), void *data1, void *data2) |
static void | picotm_slist_dequeue (struct picotm_slist *item) |
static void | picotm_slist_dequeue_front (struct picotm_slist *head) |
static const struct picotm_slist * | picotm_slist_end (const struct picotm_slist *head) |
static void | picotm_slist_enqueue_after (struct picotm_slist *item, struct picotm_slist *newitem) |
static void | picotm_slist_enqueue_back (struct picotm_slist *head, struct picotm_slist *newitem) |
static void | picotm_slist_enqueue_before (struct picotm_slist *item, struct picotm_slist *newitem) |
static void | picotm_slist_enqueue_front (struct picotm_slist *head, struct picotm_slist *newitem) |
static void | picotm_slist_enqueue_sorted (struct picotm_slist *head, struct picotm_slist *newitem, int(*cmp)(struct picotm_slist *, struct picotm_slist *)) |
static struct picotm_slist * | picotm_slist_find_0 (const struct picotm_slist *head, _Bool(*test)(const struct picotm_slist *)) |
static struct picotm_slist * | picotm_slist_find_1 (const struct picotm_slist *head, _Bool(*test)(const struct picotm_slist *, void *), void *data) |
static struct picotm_slist * | picotm_slist_find_2 (const struct picotm_slist *head, _Bool(*test)(const struct picotm_slist *, void *, void *), void *data1, void *data2) |
static struct picotm_slist * | picotm_slist_front (const struct picotm_slist *head) |
static struct picotm_slist * | picotm_slist_init_head (struct picotm_slist *head) |
static struct picotm_slist * | picotm_slist_init_item (struct picotm_slist *item) |
static _Bool | picotm_slist_is_empty (const struct picotm_slist *head) |
static _Bool | picotm_slist_is_enqueued (const struct picotm_slist *item) |
static struct picotm_slist * | picotm_slist_next (const struct picotm_slist *item) |
static struct picotm_slist * | picotm_slist_prev (const struct picotm_slist *item) |
static void | picotm_slist_uninit_head (struct picotm_slist *head) |
static void | picotm_slist_uninit_item (struct picotm_slist *item) |
static struct picotm_slist * | picotm_slist_walk_0 (const struct picotm_slist *head, size_t(*walk)(struct picotm_slist *)) |
static struct picotm_slist * | picotm_slist_walk_1 (const struct picotm_slist *head, size_t(*walk)(struct picotm_slist *, void *data), void *data) |
static struct picotm_slist * | picotm_slist_walk_2 (const struct picotm_slist *head, size_t(*walk)(struct picotm_slist *, void *data1, void *data2), void *data1, void *data2) |
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) |
#define picotm_arrayat | ( | _array, | |
_i | |||
) |
Returns the address of the element at the specified index in a static C array.
#define picotm_arraybeg | ( | _array | ) |
Returns the beginning of a static C array.
#define picotm_arrayend | ( | _array | ) |
Returns the address after a static C array.
#define picotm_arrayfirst | ( | _array | ) |
Returns the address of the first element in a static C array.
#define picotm_arraylast | ( | _array | ) |
Returns the address of the last element in a static C array.
#define picotm_arraylen | ( | _array | ) |
Computes the number of elements in a static C array.
#define picotm_containerof | ( | ptr, | |
type, | |||
member | |||
) |
Returns the container of a data structure.
ptr | A pointer to a data structure. |
type | The type of the container. |
member | The name of the container's member field. |
#define PICOTM_GLOBAL_STATE_GET | ( | _name | ) |
Returns the statically allocated global state. Callers must already hold a reference.
_name | The state name. |
#define PICOTM_GLOBAL_STATE_REF | ( | _name, | |
_error | |||
) |
Acquires a reference to an instance of a global state.
_name | The state name. | |
[out] | _error | Returns an error to the caller. |
#define PICOTM_GLOBAL_STATE_STATIC_IMPL | ( | _name | ) |
Expands to the implementation of a global state.
_name | The state name. |
#define PICOTM_GLOBAL_STATE_UNREF | ( | _name | ) |
Releases a reference to an instance of a global state.
_name | The state name. |
#define picotm_ref_count | ( | self | ) |
Reads a reference counter's value.
self | reference counter |
#define picotm_ref_down | ( | self | ) |
Decrements a reference counter.
self | A reference counter |
#define picotm_ref_init | ( | self, | |
count | |||
) |
Initializes a reference counter with the given value.
self | A reference counter |
count | The initial reference count |
#define PICOTM_REF_INITIALIZER | ( | __count | ) |
Initializes a statically allocated reference counter with the given value.
__count | The initial reference count |
#define picotm_ref_up | ( | self | ) |
Increments a reference counter.
self | A reference counter |
#define PICOTM_SHARED_REF16_INITIALIZER | ( | count | ) |
Initializes a static reference counter with the given value.
count | The initial reference count |
#define PICOTM_SHARED_REF16_OBJ_INITIALIZER |
Initializes a statically allocated shared-ref16 object.
#define PICOTM_SHARED_REF_INITIALIZER | ( | __count | ) |
Initializes a statically allocated reference counter with the given value.
__count | The initial reference count |
#define PICOTM_SHARED_STATE | ( | _name, | |
_type | |||
) |
Defines a shared-state structure.
_name | The state name. |
_type | The state type. |
#define PICOTM_SHARED_STATE_INITIALIZER |
Initializes a shared-state structure.
#define PICOTM_SHARED_STATE_REF | ( | _name, | |
_self, | |||
_error | |||
) |
Acquires a reference to an instance of a shared state.
_name | The state name. | |
_self | The state's instance. | |
[out] | _error | Returns an error to the caller. |
#define PICOTM_SHARED_STATE_STATIC_IMPL | ( | _name, | |
_type, | |||
_init, | |||
_uninit | |||
) |
Expands to the implementation of a shared state.
_name | The state name. |
_type | The state type. |
_init | The state's initializer function. |
_uninit | The state's clean-up function. |
#define PICOTM_SHARED_STATE_TYPE | ( | _name | ) |
Expands to the name of the shared-state structure.
_name | The state name. |
#define PICOTM_SHARED_STATE_UNREF | ( | _name, | |
_self | |||
) |
Releases a reference to an instance of a shared state.
_name | The state name. |
_self | The state's instance. |
#define picotm_sizeof_align | ( | __type | ) |
__type | The type. |
#define PICOTM_SLIST_HEAD_INITIALIZER | ( | head_ | ) |
Static-initializer macro for singly-linked list heads.
head_ | The singly-linked list's head entry. |
#define PICOTM_SLIST_ITEM_INITIALIZER |
Static-initializer macro for singly-linked list items.
#define PICOTM_STATE | ( | _name, | |
_type | |||
) |
Defines a state structure.
_name | The state name. |
_type | The state type. |
#define PICOTM_STATE_ACQUIRE | ( | _name, | |
_self, | |||
_initialize, | |||
_error | |||
) |
Acquires a state.
_name | The state name. | |
_initialize | True to initialize if necessary. | |
_self | The state's instance. | |
[out] | _error | Returns an error to the caller. |
#define PICOTM_STATE_INITIALIZER |
Initializes a state structure.
#define PICOTM_STATE_RELEASE | ( | _name, | |
_self | |||
) |
Releases a previously acquired state.
_name | The state name. |
_self | The state's instance. |
#define PICOTM_STATE_STATIC_DECL | ( | _name, | |
_type | |||
) |
Expands to the forward declaration of a state.
_name | The state name. |
_type | The state type. |
#define PICOTM_STATE_STATIC_IMPL | ( | _name, | |
_type, | |||
_init, | |||
_uninit | |||
) |
Expands to the implementation of a state.
_name | The state name. |
_type | The state type. |
_init | The state's initializer function. |
_uninit | The state's clean-up function. |
#define PICOTM_STATE_TYPE | ( | _name | ) |
Expands to the name of the state structure.
_name | The state name. |
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.
ref_obj | The shared-ref16 object. |
data | User data. |
error[out] | Returns an error to the caller. |
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.
ref_obj | The shared-ref16 object. | |
data | User data. | |
[out] | error | Returns an error to the caller. |
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.
ref_obj | The shared-ref16 object. | |
data | User data. | |
[out] | error | Returns an error to the caller. |
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.
key | The value's key. | |
treemap | The value's shared treemap. | |
[out] | error | Returns an error from the creator 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.
value | The value to destroy. |
treemap | The value's shared treemap. |
typedef int(* picotm_tab_compare_function) (const void *data0, const void *data1) |
Invoked by table functions for comparing two elements.
data0 | A table element. |
data1 | A table element. |
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.
data0 | The table element. | |
[out] | error | Returns an error from the module. |
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.
data0 | The table element. | |
data1 | An additional argument. | |
[out] | error | Returns an error from the module. |
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.
data0 | The table element. | |
data1 | An additional argument. | |
data2 | An additional argument. | |
[out] | error | Returns an error from the module. |
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.
value | The value. | |
key | The value's key. | |
treemap | The value's treemap. | |
data | User data. | |
[out] | error | Returns an error from the creator 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.
key | The value's key. | |
treemap | The value's treemap. | |
[out] | error | Returns an error from the creator function. |
typedef void(* picotm_treemap_value_destroy_function) (uintptr_t value, struct picotm_treemap *treemap) |
Invoked by picotm's treemap to destroy a value.
value | The value to destroy. |
treemap | The value's treemap. |
|
inlinestatic |
addr | A memory address. |
algn | The alignment of the result address. |
|
inlinestatic |
addr | A memory address. |
algn | The alignment of the result address. |
|
inlinestatic |
ptr | A pointer to a memory location. |
algn | The alignment of the result memory location. |
|
inlinestatic |
hi | The higher memory location. |
lo | The lower memory location. |
|
inlinestatic |
ptr | A pointer to a memory location. |
algn | The alignment of the result memory location. |
PICOTM_NOTHROW void picotm_rwlock_init | ( | struct picotm_rwlock * | self | ) |
Initializes a reader-writer lock.
self | The reader-writer lock to initialize. |
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.
self | The reader lock to acquire. | |
[out] | error | Returns a error. |
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.
self | The writer lock to acquire. | |
upgrade | True to upgrade a previously acquired reader lock. | |
[out] | error | Returns a error. |
PICOTM_NOTHROW void picotm_rwlock_uninit | ( | struct picotm_rwlock * | self | ) |
Uninitializes a reader-writer lock.
self | The reader-writer lock to uninitialize. |
PICOTM_NOTHROW void picotm_rwlock_unlock | ( | struct picotm_rwlock * | self | ) |
Releases a reader-writer lock.
self | The reader-writer lock to release. |
PICOTM_NOTHROW enum picotm_rwstate_status picotm_rwstate_get_status | ( | const struct picotm_rwstate * | self | ) |
Returns a reader/writer state's current status.
self | The reader/writer state. |
PICOTM_NOTHROW void picotm_rwstate_init | ( | struct picotm_rwstate * | self | ) |
Initializes a reader-writer state.
self | The reader-writer state to initialize. |
PICOTM_NOTHROW void picotm_rwstate_set_status | ( | struct picotm_rwstate * | self, |
enum picotm_rwstate_status | status | ||
) |
Sets a reader/writer state's status.
self | The reader/writer state. |
status | The status to set. |
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.
self | The reader/writer state. | |
rwlock | The reader lock to acquire. | |
[out] | error | Returns a error. |
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.
self | The reader/writer state. | |
rwlock | The reader lock to acquire. | |
[out] | error | Returns a error. |
PICOTM_NOTHROW void picotm_rwstate_uninit | ( | struct picotm_rwstate * | self | ) |
Uninitializes a reader-writer state.
self | The reader-writer state to uninitialize. |
PICOTM_NOTHROW void picotm_rwstate_unlock | ( | struct picotm_rwstate * | self, |
struct picotm_rwlock * | rwlock | ||
) |
Releases a reader-writer lock.
self | The reader/writer state. |
rwlock | The reader/writer lock to release. |
uint16_t picotm_shared_ref16_obj_count | ( | struct picotm_shared_ref16_obj * | self | ) |
Reads the value of a shared-ref16 object's counter.
self | The shared-ref16 object. |
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.
self | The shared-ref16 object. |
data | User data. |
cond | An optional condition to test if the reference should be released. |
final_ref | An 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.
void picotm_shared_ref16_obj_init | ( | struct picotm_shared_ref16_obj * | self, |
struct picotm_error * | error | ||
) |
Initializes a shared-ref16 object.
self | The shared-ref16 object. | |
[out] | error | Returns an error to the caller. |
void picotm_shared_ref16_obj_uninit | ( | struct picotm_shared_ref16_obj * | self | ) |
Uninitializes a shared-ref16 object.
self | The shared-ref16 object. |
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.
self | The shared-ref16 object. | |
data | User data. | |
cond | An optional condition to test if the reference should be acquired. | |
first_ref | An optional function to initialize the object when the first reference gets acquired. | |
[out] | error | Returns 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_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.
self | The shared treemap. | |
key | The value's key. | |
value_create | The creator function for shared values. | |
value_destroy | The destroy function for shared values. | |
[out] | error | Returns an error from the look-up function. |
PICOTM_NOTHROW void picotm_shared_treemap_init | ( | struct picotm_shared_treemap * | self, |
unsigned long | key_nbits, | ||
unsigned long | level_nbits | ||
) |
Initializes a shared treemap.
self | The shared treemap to initialize. |
key_nbits | The maximum number of bits per key. |
level_nbits | The number of bits per directory level. |
PICOTM_NOTHROW void picotm_shared_treemap_uninit | ( | struct picotm_shared_treemap * | self, |
picotm_shared_treemap_value_destroy_function | value_destroy | ||
) |
Uninitializes a shared treemap.
self | The shared treemap to initialize. |
value_destroy | The destroy function for shared values. |
|
inlinestatic |
Returns the final item of a singly-linked list.
head | The singly-linked list's head entry. |
|
inlinestatic |
Returns the first entry in a singly-linked list.
head | The singly-linked list's head entry. |
|
inlinestatic |
Cleans up all items of a singly-linked list.
head | The singly-linked list's head entry. |
cleanup | The clean-up function for each item. |
|
inlinestatic |
Cleans up all items of a singly-linked list.
head | The singly-linked list's head entry. |
cleanup | The clean-up function for each item. |
data1 | The first data parameter for the walk function. |
|
inlinestatic |
Cleans up all items of a singly-linked list.
head | The singly-linked list's head entry. |
cleanup | The clean-up function for each item. |
data1 | The first data parameter for the walk function. |
data2 | The second data parameter for the walk function. |
|
inlinestatic |
Dequeues an item of a singly-linked list.
item | The singly-linked list's exiting entry. |
|
inlinestatic |
Dequeues the front item of a singly-linked list.
head | The singly-linked list's head entry. |
|
inlinestatic |
Returns the terminating entry in a singly-linked list.
head | The singly-linked list's head entry. |
|
inlinestatic |
Enqueues an item to a singly-linked list after an existing item.
item | The singly-linked list's exiting entry. |
newitem | The new entry for the singly-linked list. |
|
inlinestatic |
Enqueues an item at the end of a singly-linked list.
head | The singly-linked list's head entry. |
newitem | The new entry for the singly-linked list. |
|
inlinestatic |
Enqueues an item to a singly-linked list before an existing item.
item | The singly-linked list's exiting entry. |
newitem | The new entry for the singly-linked list. |
|
inlinestatic |
Enqueues an item at the beginning of a singly-linked list.
head | The singly-linked list's head entry. |
newitem | The new entry for the singly-linked list. |
|
inlinestatic |
Enqueues an item to a sorted singly-linked list.
head | The singly-linked list's head entry. |
newitem | The new entry for the singly-linked list. |
cmp | The compare-function for sorting the entries. |
|
inlinestatic |
Finds an item in a singly-linked list.
head | The singly-linked list's head entry. |
test | The test function for the find operation. |
|
inlinestatic |
Finds an item in a singly-linked list.
head | The singly-linked list's head entry. |
test | The test function for the find operation. |
data | The data parameter for the test function. |
|
inlinestatic |
Finds an item in a singly-linked list.
head | The singly-linked list's head entry. |
test | The test function for the find operation. |
data1 | The first data parameter for the test function. |
data2 | The second data parameter for the test function. |
|
inlinestatic |
Returns the front item of a singly-linked list.
head | The singly-linked list's head entry. |
|
inlinestatic |
Initialize the head entry of a singly-linked list.
head | The singly-linked list's head entry. |
|
inlinestatic |
Initialize an entry of a singly-linked list.
item | The singly-linked list's entry. |
|
inlinestatic |
Returns true if a singly-linked list is empty.
head | The singly-linked list's head entry. |
|
inlinestatic |
Returns true if a singly-linked list item is enqueued.
item | The singly-linked list entry. |
|
inlinestatic |
Returns the next entry in a singly-linked list.
item | The singly-linked list's current entry. |
|
inlinestatic |
Returns the previous entry in a singly-linked list.
item | The singly-linked list's current entry. |
|
inlinestatic |
Uninitialize the head entry of a singly-linked list.
head | The singly-linked list's head entry. |
|
inlinestatic |
Uninitialize an entry of a singly-linked list.
item | The singly-linked list's entry. |
|
inlinestatic |
Walks over all items in a singly-linked list.
head | The singly-linked list's head entry. |
walk | The call-back function for each item. |
|
inlinestatic |
Walks over all items in a singly-linked list.
head | The singly-linked list's head entry. |
walk | The call-back function for each item. |
data | The data parameter for the walk function. |
|
inlinestatic |
Walks over all items in a singly-linked list.
head | The singly-linked list's head entry. |
walk | The call-back function for each item. |
data1 | The first data parameter for the walk function. |
data2 | The second data parameter for the walk function. |
PICOTM_NOTHROW void picotm_tabfree | ( | void * | base | ) |
Free table memory.
base | A pointer to the table's first element. |
PICOTM_NOTHROW void* picotm_tabresize | ( | void * | base, |
size_t | nelems, | ||
size_t | newnelems, | ||
size_t | siz, | ||
struct picotm_error * | error | ||
) |
Allocate or resize table.
base | A pointer to the table's first element. | |
nelems | The number of elements in the table. | |
newnelems | The new number of elements in the table. | |
siz | The number of bytes per element. | |
[out] | error | Returns an error from the module. |
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.
base | A pointer to the table's first element. | |
nelems | The number of elements in the table. | |
siz | The number of bytes per element. | |
walk | The call-back function. | |
[out] | error | Returns an error from the module. |
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.
base | A pointer to the table's first element. | |
nelems | The number of elements in the table. | |
siz | The number of bytes per element. | |
walk | The call-back function. | |
data | An additional second argument to the call-back function. | |
[out] | error | Returns an error from the module. |
PICOTM_NOTHROW size_t picotm_tabuniq | ( | void * | base, |
size_t | nelems, | ||
size_t | siz, | ||
picotm_tab_compare_function | compare | ||
) |
Filters out duplicate elements
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
siz | The number of bytes per element. |
compare | The call-back function for comparing elements. |
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.
base | A pointer to the table's first element. | |
nelems | The number of elements in the table. | |
siz | The number of bytes per element. | |
walk | The call-back function. | |
[out] | error | Returns an error from the module. |
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.
base | A pointer to the table's first element. | |
nelems | The number of elements in the table. | |
siz | The number of bytes per element. | |
walk | The call-back function. | |
data | An additional second argument to the call-back function. | |
[out] | error | Returns an error from the module. |
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.
base | A pointer to the table's first element. | |
nelems | The number of elements in the table. | |
siz | The number of bytes per element. | |
walk | The call-back function. | |
data1 | An additional second argument to the call-back function. | |
data2 | An additional third argument to the call-back function. | |
[out] | error | Returns an error from the module. |
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.
self | The treemap. | |
key | The value's key. | |
value_create | The creator function for values. | |
[out] | error | Returns an error from the look-up function. |
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.
self | The treemap. | |
data | User data. | |
value_call | The call-back function for values. | |
[out] | error | Returns an error from the look-up function. |
PICOTM_NOTHROW void picotm_treemap_init | ( | struct picotm_treemap * | self, |
unsigned long | level_nbits | ||
) |
Initializes a treemap.
self | The treemap to initialize. |
level_nbits | The number of bits per directory level. |
PICOTM_NOTHROW void picotm_treemap_uninit | ( | struct picotm_treemap * | self, |
picotm_treemap_value_destroy_function | value_destroy | ||
) |
Uninitializes a treemap.
self | The treemap to initialize. |
value_destroy | The destroy function for values. |