Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2105 → Rev 2106

/trunk/kernel/generic/include/adt/hash_table.h
42,7 → 42,8
typedef struct {
/** Hash function.
*
* @param key Array of keys needed to compute hash index. All keys must be passed.
* @param key Array of keys needed to compute hash index. All keys must
* be passed.
*
* @return Index into hash table.
*/
50,7 → 51,8
/** Hash table item comparison function.
*
* @param key Array of keys that will be compared with item. It is not necessary to pass all keys.
* @param key Array of keys that will be compared with item. It is not
* necessary to pass all keys.
*
* @return true if the keys match, false otherwise.
*/
71,9 → 73,11
hash_table_operations_t *op;
} hash_table_t;
 
#define hash_table_get_instance(item, type, member) list_get_instance((item), type, member)
#define hash_table_get_instance(item, type, member) \
list_get_instance((item), type, member)
 
extern void hash_table_create(hash_table_t *h, count_t m, count_t max_keys, hash_table_operations_t *op);
extern void hash_table_create(hash_table_t *h, count_t m, count_t max_keys,
hash_table_operations_t *op);
extern void hash_table_insert(hash_table_t *h, unative_t key[], link_t *item);
extern link_t *hash_table_find(hash_table_t *h, unative_t key[]);
extern void hash_table_remove(hash_table_t *h, unative_t key[], count_t keys);
/trunk/kernel/generic/include/adt/list.h
47,7 → 47,8
*
* @param name Name of the new statically allocated list.
*/
#define LIST_INITIALIZE(name) link_t name = { .prev = &name, .next = &name }
#define LIST_INITIALIZE(name) \
link_t name = { .prev = &name, .next = &name }
 
/** Initialize doubly-linked circular list link
*
107,7 → 108,8
*
* Remove item from doubly-linked circular list.
*
* @param link Pointer to link_t structure to be removed from the list it is contained in.
* @param link Pointer to link_t structure to be removed from the list it is
* contained in.
*/
static inline void list_remove(link_t *link)
{
135,8 → 137,10
* Note that the algorithm works both directions:
* concatenates splitted lists and splits concatenated lists.
*
* @param part1 Pointer to link_t structure leading the first (half of the headless) list.
* @param part2 Pointer to link_t structure leading the second (half of the headless) list.
* @param part1 Pointer to link_t structure leading the first (half of the
* headless) list.
* @param part2 Pointer to link_t structure leading the second (half of the
* headless) list.
*/
static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
{
154,8 → 158,10
*
* Split headless doubly-linked circular list.
*
* @param part1 Pointer to link_t structure leading the first half of the headless list.
* @param part2 Pointer to link_t structure leading the second half of the headless list.
* @param part1 Pointer to link_t structure leading the first half of the
* headless list.
* @param part2 Pointer to link_t structure leading the second half of the
* headless list.
*/
static inline void headless_list_split(link_t *part1, link_t *part2)
{
167,7 → 173,7
* Concatenate two headless doubly-linked circular lists.
*
* @param part1 Pointer to link_t structure leading the first headless list.
* @param part2 Pointer to link_t structure leading the second headless list.
* @param part2 Pointer to link_t structure leading the second headless list.
*/
static inline void headless_list_concat(link_t *part1, link_t *part2)
{
174,7 → 180,8
headless_list_split_or_concat(part1, part2);
}
 
#define list_get_instance(link,type,member) (type *)(((uint8_t*)(link))-((uint8_t*)&(((type *)NULL)->member)))
#define list_get_instance(link,type,member) \
((type *)(((uint8_t *)(link)) - ((uint8_t *)&(((type *)NULL)->member))))
 
extern bool list_member(const link_t *link, const link_t *head);
extern void list_concat(link_t *head1, link_t *head2);
/trunk/kernel/generic/include/adt/btree.h
48,19 → 48,25
/** Number of keys. */
count_t keys;
 
/** Keys. We currently support only single keys. Additional room for one extra key is provided. */
/**
* Keys. We currently support only single keys. Additional room for one
* extra key is provided.
*/
btree_key_t key[BTREE_MAX_KEYS + 1];
 
/**
* Pointers to values. Sorted according to the key array. Defined only in leaf-level.
* There is room for storing value for the extra key.
* Pointers to values. Sorted according to the key array. Defined only in
* leaf-level. There is room for storing value for the extra key.
*/
void *value[BTREE_MAX_KEYS + 1];
/**
* Pointers to descendants of this node sorted according to the key array.
* Pointers to descendants of this node sorted according to the key
* array.
*
* subtree[0] points to subtree with keys lesser than to key[0].
* subtree[1] points to subtree with keys greater than or equal to key[0] and lesser than key[1].
* subtree[1] points to subtree with keys greater than or equal to
* key[0] and lesser than key[1].
* ...
* There is room for storing a subtree pointer for the extra key.
*/
69,10 → 75,12
/** Pointer to parent node. Root node has NULL parent. */
struct btree_node *parent;
 
/** Link connecting leaf-level nodes. Defined only when this node is a leaf. */
/**
* Link connecting leaf-level nodes. Defined only when this node is a
* leaf. */
link_t leaf_link;
 
/** Variables needed by btree_print(). */
/* Variables needed by btree_print(). */
link_t bfs_link;
int depth;
} btree_node_t;
88,12 → 96,15
extern void btree_create(btree_t *t);
extern void btree_destroy(btree_t *t);
 
extern void btree_insert(btree_t *t, btree_key_t key, void *value, btree_node_t *leaf_node);
extern void btree_insert(btree_t *t, btree_key_t key, void *value,
btree_node_t *leaf_node);
extern void btree_remove(btree_t *t, btree_key_t key, btree_node_t *leaf_node);
extern void *btree_search(btree_t *t, btree_key_t key, btree_node_t **leaf_node);
 
extern btree_node_t *btree_leaf_node_left_neighbour(btree_t *t, btree_node_t *node);
extern btree_node_t *btree_leaf_node_right_neighbour(btree_t *t, btree_node_t *node);
extern btree_node_t *btree_leaf_node_left_neighbour(btree_t *t,
btree_node_t *node);
extern btree_node_t *btree_leaf_node_right_neighbour(btree_t *t,
btree_node_t *node);
 
extern void btree_print(btree_t *t);
#endif
/trunk/kernel/generic/include/adt/fifo.h
106,7 → 106,8
*
*/
#define fifo_push(name, value) \
name.fifo[name.tail = (name.tail + 1) < name.items ? (name.tail + 1) : 0] = (value)
name.fifo[name.tail = \
(name.tail + 1) < name.items ? (name.tail + 1) : 0] = (value)
 
/** Allocate memory for dynamic FIFO.
*