summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--avltree.c50
-rw-r--r--avltree.h12
-rw-r--r--avltree_i.h18
-rw-r--r--cpu.h3
-rw-r--r--error.c9
-rw-r--r--hash.h12
-rw-r--r--list.c15
-rw-r--r--list.h57
-rw-r--r--mem.c170
-rw-r--r--mem_malloc.c15
-rw-r--r--phys.c97
-rw-r--r--rbtree.c54
-rw-r--r--rbtree.h12
-rw-r--r--rbtree_i.h21
-rw-r--r--rdxtree.c122
-rw-r--r--rdxtree.h6
-rw-r--r--test/test_avltree.c15
-rw-r--r--test/test_mem.c3
-rw-r--r--test/test_mem_cache.c9
-rw-r--r--test/test_mem_cache_double_free.c6
-rw-r--r--test/test_mem_cache_invalid_free.c6
-rw-r--r--test/test_mem_cache_write_beyond.c9
-rw-r--r--test/test_mem_cache_write_buftag.c9
-rw-r--r--test/test_mem_cache_write_free.c9
-rw-r--r--test/test_mem_offbyone.c3
-rw-r--r--test/test_phys.c3
-rw-r--r--test/test_rbtree.c15
-rw-r--r--test/test_rdxtree.c95
-rw-r--r--test/test_xprintf.c3
-rw-r--r--xprintf.c24
30 files changed, 551 insertions, 331 deletions
diff --git a/avltree.c b/avltree.c
index 3782fb5..0acaaf2 100644
--- a/avltree.c
+++ b/avltree.c
@@ -36,8 +36,9 @@
* The parent parameter must not be null, and must be the parent of the
* given node.
*/
-static inline int avltree_index(const struct avltree_node *node,
- const struct avltree_node *parent)
+static inline int
+avltree_index(const struct avltree_node *node,
+ const struct avltree_node *parent)
{
assert(parent != NULL);
assert((node == NULL) || (avltree_parent(node) == parent));
@@ -54,7 +55,8 @@ static inline int avltree_index(const struct avltree_node *node,
* Convert an index of the children array (0 or 1) into a balance value
* (-1 or 1).
*/
-static inline int avltree_i2b(int index)
+static inline int
+avltree_i2b(int index)
{
assert(avltree_check_index(index));
return (index - 1) | 1;
@@ -63,7 +65,8 @@ static inline int avltree_i2b(int index)
/*
* Return the balance of a node.
*/
-static inline int avltree_balance(const struct avltree_node *node)
+static inline int
+avltree_balance(const struct avltree_node *node)
{
int balance;
@@ -76,8 +79,8 @@ static inline int avltree_balance(const struct avltree_node *node)
/*
* Set the parent of a node, retaining its current balance.
*/
-static inline void avltree_set_parent(struct avltree_node *node,
- struct avltree_node *parent)
+static inline void
+avltree_set_parent(struct avltree_node *node, struct avltree_node *parent)
{
assert(avltree_check_alignment(node));
assert(avltree_check_alignment(parent));
@@ -88,7 +91,8 @@ static inline void avltree_set_parent(struct avltree_node *node,
/*
* Set the balance of a node, retaining its current parent.
*/
-static inline void avltree_set_balance(struct avltree_node *node, int balance)
+static inline void
+avltree_set_balance(struct avltree_node *node, int balance)
{
assert((-1 <= balance) && (balance <= 1));
node->parent = (node->parent & AVLTREE_PARENT_MASK) | (balance + 1);
@@ -104,8 +108,8 @@ static inline void avltree_set_balance(struct avltree_node *node, int balance)
* Return true if the overall height of the subtree rooted at node has
* decreased, false otherwise.
*/
-static int avltree_rotate(struct avltree *tree, struct avltree_node *node,
- int balance)
+static int
+avltree_rotate(struct avltree *tree, struct avltree_node *node, int balance)
{
struct avltree_node *parent, *lnode, *lrnode, *lrlnode, *lrrnode;
int left, right, lweight, rweight, lbalance;
@@ -207,8 +211,9 @@ static int avltree_rotate(struct avltree *tree, struct avltree_node *node,
return 1;
}
-void avltree_insert_rebalance(struct avltree *tree, struct avltree_node *parent,
- int index, struct avltree_node *node)
+void
+avltree_insert_rebalance(struct avltree *tree, struct avltree_node *parent,
+ int index, struct avltree_node *node)
{
int old_balance, new_balance;
@@ -272,7 +277,8 @@ void avltree_insert_rebalance(struct avltree *tree, struct avltree_node *parent,
avltree_rotate(tree, node, new_balance);
}
-void avltree_remove(struct avltree *tree, struct avltree_node *node)
+void
+avltree_remove(struct avltree *tree, struct avltree_node *node)
{
struct avltree_node *child, *parent;
int left, right, index, old_balance, new_balance;
@@ -403,8 +409,8 @@ update_balance:
}
}
-struct avltree_node * avltree_nearest(struct avltree_node *parent, int index,
- int direction)
+struct avltree_node *
+avltree_nearest(struct avltree_node *parent, int index, int direction)
{
assert(avltree_check_index(direction));
@@ -419,8 +425,8 @@ struct avltree_node * avltree_nearest(struct avltree_node *parent, int index,
return avltree_walk(parent, direction);
}
-struct avltree_node * avltree_firstlast(const struct avltree *tree,
- int direction)
+struct avltree_node *
+avltree_firstlast(const struct avltree *tree, int direction)
{
struct avltree_node *prev, *cur;
@@ -434,7 +440,8 @@ struct avltree_node * avltree_firstlast(const struct avltree *tree,
return prev;
}
-struct avltree_node * avltree_walk(struct avltree_node *node, int direction)
+struct avltree_node *
+avltree_walk(struct avltree_node *node, int direction)
{
int left, right;
@@ -475,7 +482,8 @@ struct avltree_node * avltree_walk(struct avltree_node *node, int direction)
/*
* Return the left-most deepest child node of the given node.
*/
-static struct avltree_node * avltree_find_deepest(struct avltree_node *node)
+static struct avltree_node *
+avltree_find_deepest(struct avltree_node *node)
{
struct avltree_node *parent;
@@ -494,7 +502,8 @@ static struct avltree_node * avltree_find_deepest(struct avltree_node *node)
}
}
-struct avltree_node * avltree_postwalk_deepest(const struct avltree *tree)
+struct avltree_node *
+avltree_postwalk_deepest(const struct avltree *tree)
{
struct avltree_node *node;
@@ -506,7 +515,8 @@ struct avltree_node * avltree_postwalk_deepest(const struct avltree *tree)
return avltree_find_deepest(node);
}
-struct avltree_node * avltree_postwalk_unlink(struct avltree_node *node)
+struct avltree_node *
+avltree_postwalk_unlink(struct avltree_node *node)
{
struct avltree_node *parent;
int index;
diff --git a/avltree.h b/avltree.h
index 3f73e05..e6f6877 100644
--- a/avltree.h
+++ b/avltree.h
@@ -65,7 +65,8 @@ struct avltree;
/*
* Initialize a tree.
*/
-static inline void avltree_init(struct avltree *tree)
+static inline void
+avltree_init(struct avltree *tree)
{
tree->root = NULL;
}
@@ -75,7 +76,8 @@ static inline void avltree_init(struct avltree *tree)
*
* A node is in no tree when its parent points to itself.
*/
-static inline void avltree_node_init(struct avltree_node *node)
+static inline void
+avltree_node_init(struct avltree_node *node)
{
assert(avltree_check_alignment(node));
@@ -87,7 +89,8 @@ static inline void avltree_node_init(struct avltree_node *node)
/*
* Return true if node is in no tree.
*/
-static inline int avltree_node_unlinked(const struct avltree_node *node)
+static inline int
+avltree_node_unlinked(const struct avltree_node *node)
{
return avltree_parent(node) == node;
}
@@ -101,7 +104,8 @@ static inline int avltree_node_unlinked(const struct avltree_node *node)
/*
* Return true if tree is empty.
*/
-static inline int avltree_empty(const struct avltree *tree)
+static inline int
+avltree_empty(const struct avltree *tree)
{
return tree->root == NULL;
}
diff --git a/avltree_i.h b/avltree_i.h
index e09c7f4..300655e 100644
--- a/avltree_i.h
+++ b/avltree_i.h
@@ -85,7 +85,8 @@ struct avltree {
/*
* Return true if the given pointer is suitably aligned.
*/
-static inline int avltree_check_alignment(const struct avltree_node *node)
+static inline int
+avltree_check_alignment(const struct avltree_node *node)
{
return ((unsigned long)node & AVLTREE_BALANCE_MASK) == 0;
}
@@ -93,7 +94,8 @@ static inline int avltree_check_alignment(const struct avltree_node *node)
/*
* Return true if the given index is a valid child index.
*/
-static inline int avltree_check_index(int index)
+static inline int
+avltree_check_index(int index)
{
return index == (index & 1);
}
@@ -104,7 +106,8 @@ static inline int avltree_check_index(int index)
*
* This function is mostly used when looking up a node.
*/
-static inline int avltree_d2i(int diff)
+static inline int
+avltree_d2i(int diff)
{
return !(diff <= 0);
}
@@ -121,7 +124,8 @@ avltree_parent(const struct avltree_node *node)
/*
* Translate an insertion point into a slot.
*/
-static inline unsigned long avltree_slot(struct avltree_node *parent, int index)
+static inline unsigned long
+avltree_slot(struct avltree_node *parent, int index)
{
assert(avltree_check_alignment(parent));
assert(avltree_check_index(index));
@@ -131,7 +135,8 @@ static inline unsigned long avltree_slot(struct avltree_node *parent, int index)
/*
* Extract the parent address from a slot.
*/
-static inline struct avltree_node * avltree_slot_parent(unsigned long slot)
+static inline struct avltree_node *
+avltree_slot_parent(unsigned long slot)
{
return (struct avltree_node *)(slot & AVLTREE_SLOT_PARENT_MASK);
}
@@ -139,7 +144,8 @@ static inline struct avltree_node * avltree_slot_parent(unsigned long slot)
/*
* Extract the index from a slot.
*/
-static inline int avltree_slot_index(unsigned long slot)
+static inline int
+avltree_slot_index(unsigned long slot)
{
return slot & AVLTREE_SLOT_INDEX_MASK;
}
diff --git a/cpu.h b/cpu.h
index df2fff4..de66d86 100644
--- a/cpu.h
+++ b/cpu.h
@@ -61,7 +61,8 @@
* The returned CPU ID cannot be greater than the maximum number of supported
* processors.
*/
-static inline int cpu_id(void)
+static inline int
+cpu_id(void)
{
#if NR_CPUS == 1
return 0;
diff --git a/error.c b/error.c
index 116473d..dcc574f 100644
--- a/error.c
+++ b/error.c
@@ -53,7 +53,8 @@ static const char *errormsg_table[] = {
#define ERRORMSG_TABLE_SIZE ARRAY_SIZE(errormsg_table)
-const char * error_str(unsigned int error)
+const char *
+error_str(unsigned int error)
{
if (error >= ERRORMSG_TABLE_SIZE)
return "invalid error code";
@@ -61,7 +62,8 @@ const char * error_str(unsigned int error)
return errormsg_table[error];
}
-unsigned int error_from_errno(int errno_code)
+unsigned int
+error_from_errno(int errno_code)
{
switch (errno_code) {
case 0:
@@ -84,7 +86,8 @@ unsigned int error_from_errno(int errno_code)
}
}
-void error_die(unsigned int error)
+void
+error_die(unsigned int error)
{
fprintf(stderr, "process terminating, reason: %s\n", error_str(error));
abort();
diff --git a/hash.h b/hash.h
index ca60730..3bd6439 100644
--- a/hash.h
+++ b/hash.h
@@ -57,7 +57,8 @@
#define hash_long(n, bits) hash_int32(n, bits)
#endif
-static inline uint32_t hash_int32(uint32_t n, unsigned int bits)
+static inline uint32_t
+hash_int32(uint32_t n, unsigned int bits)
{
uint32_t hash;
@@ -72,7 +73,8 @@ static inline uint32_t hash_int32(uint32_t n, unsigned int bits)
return hash >> (32 - bits);
}
-static inline uint64_t hash_int64(uint64_t n, unsigned int bits)
+static inline uint64_t
+hash_int64(uint64_t n, unsigned int bits)
{
uint64_t hash;
@@ -88,12 +90,14 @@ static inline uint64_t hash_int64(uint64_t n, unsigned int bits)
return hash >> (64 - bits);
}
-static inline unsigned long hash_ptr(const void *ptr, unsigned int bits)
+static inline unsigned long
+hash_ptr(const void *ptr, unsigned int bits)
{
return hash_long((unsigned long)ptr, bits);
}
-static inline unsigned long hash_str(const char *str, unsigned int bits)
+static inline unsigned long
+hash_str(const char *str, unsigned int bits)
{
unsigned long hash;
char c;
diff --git a/list.c b/list.c
index 6f978bc..8163b4d 100644
--- a/list.c
+++ b/list.c
@@ -44,8 +44,9 @@
* the "right" list is actually the list_size first entries of input_list
* after completion.
*/
-static void _list_divide(struct list *input_list, struct list *left_list,
- unsigned int list_size)
+static void
+_list_divide(struct list *input_list, struct list *left_list,
+ unsigned int list_size)
{
struct list *node;
unsigned int i;
@@ -61,9 +62,10 @@ static void _list_divide(struct list *input_list, struct list *left_list,
/*
* Merge left_list and right_list at the tail of output_list.
*/
-static void _list_merge(struct list *left_list, struct list *right_list,
- struct list *output_list, unsigned int right_list_size,
- list_sort_cmp_fn_t cmp_fn)
+static void
+_list_merge(struct list *left_list, struct list *right_list,
+ struct list *output_list, unsigned int right_list_size,
+ list_sort_cmp_fn_t cmp_fn)
{
struct list *left, *right;
@@ -109,7 +111,8 @@ static void _list_merge(struct list *left_list, struct list *right_list,
}
}
-void list_sort(struct list *list, list_sort_cmp_fn_t cmp_fn)
+void
+list_sort(struct list *list, list_sort_cmp_fn_t cmp_fn)
{
struct list left_list, output_list;
unsigned int list_size, nr_merges;
diff --git a/list.h b/list.h
index c8f4c7e..c1bbbbd 100644
--- a/list.h
+++ b/list.h
@@ -76,7 +76,8 @@ static inline void list_init(struct list *list)
*
* An entry is in no list when its node members point to NULL.
*/
-static inline void list_node_init(struct list *node)
+static inline void
+list_node_init(struct list *node)
{
node->prev = NULL;
node->next = NULL;
@@ -85,7 +86,8 @@ static inline void list_node_init(struct list *node)
/*
* Return true if node is in no list.
*/
-static inline int list_node_unlinked(const struct list *node)
+static inline int
+list_node_unlinked(const struct list *node)
{
return node->prev == NULL;
}
@@ -99,7 +101,8 @@ static inline int list_node_unlinked(const struct list *node)
/*
* Return the first node of a list.
*/
-static inline struct list * list_first(const struct list *list)
+static inline struct list *
+list_first(const struct list *list)
{
return list->next;
}
@@ -107,7 +110,8 @@ static inline struct list * list_first(const struct list *list)
/*
* Return the last node of a list.
*/
-static inline struct list * list_last(const struct list *list)
+static inline struct list *
+list_last(const struct list *list)
{
return list->prev;
}
@@ -115,7 +119,8 @@ static inline struct list * list_last(const struct list *list)
/*
* Return the node next to the given node.
*/
-static inline struct list * list_next(const struct list *node)
+static inline struct list *
+list_next(const struct list *node)
{
return node->next;
}
@@ -123,7 +128,8 @@ static inline struct list * list_next(const struct list *node)
/*
* Return the node previous to the given node.
*/
-static inline struct list * list_prev(const struct list *node)
+static inline struct list *
+list_prev(const struct list *node)
{
return node->prev;
}
@@ -143,7 +149,8 @@ static inline struct list * list_prev(const struct list *node)
/*
* Return true if node is after the last or before the first node of the list.
*/
-static inline int list_end(const struct list *list, const struct list *node)
+static inline int
+list_end(const struct list *list, const struct list *node)
{
return list == node;
}
@@ -151,7 +158,8 @@ static inline int list_end(const struct list *list, const struct list *node)
/*
* Return true if list is empty.
*/
-static inline int list_empty(const struct list *list)
+static inline int
+list_empty(const struct list *list)
{
return list == list->next;
}
@@ -159,7 +167,8 @@ static inline int list_empty(const struct list *list)
/*
* Return true if list contains exactly one node.
*/
-static inline int list_singular(const struct list *list)
+static inline int
+list_singular(const struct list *list)
{
return (list != list->next) && (list->next == list->prev);
}
@@ -170,8 +179,8 @@ static inline int list_singular(const struct list *list)
*
* If list2 is empty, or node is list2 or list2->next, nothing is done.
*/
-static inline void list_split(struct list *list1, struct list *list2,
- struct list *node)
+static inline void
+list_split(struct list *list1, struct list *list2, struct list *node)
{
if (list_empty(list2) || (list2->next == node) || list_end(list2, node))
return;
@@ -191,7 +200,8 @@ static inline void list_split(struct list *list1, struct list *list2,
*
* After completion, list2 is stale.
*/
-static inline void list_concat(struct list *list1, const struct list *list2)
+static inline void
+list_concat(struct list *list1, const struct list *list2)
{
struct list *last1, *first2, *last2;
@@ -218,8 +228,8 @@ static inline void list_concat(struct list *list1, const struct list *list2)
*
* After completion, old_head is stale.
*/
-static inline void list_set_head(struct list *new_head,
- const struct list *old_head)
+static inline void
+list_set_head(struct list *new_head, const struct list *old_head)
{
if (list_empty(old_head)) {
list_init(new_head);
@@ -234,8 +244,8 @@ static inline void list_set_head(struct list *new_head,
/*
* Add a node between two nodes.
*/
-static inline void list_add(struct list *prev, struct list *next,
- struct list *node)
+static inline void
+list_add(struct list *prev, struct list *next, struct list *node)
{
next->prev = node;
node->next = next;
@@ -247,7 +257,8 @@ static inline void list_add(struct list *prev, struct list *next,
/*
* Insert a node at the head of a list.
*/
-static inline void list_insert(struct list *list, struct list *node)
+static inline void
+list_insert(struct list *list, struct list *node)
{
list_add(list, list->next, node);
}
@@ -255,7 +266,8 @@ static inline void list_insert(struct list *list, struct list *node)
/*
* Insert a node at the tail of a list.
*/
-static inline void list_insert_tail(struct list *list, struct list *node)
+static inline void
+list_insert_tail(struct list *list, struct list *node)
{
list_add(list->prev, list, node);
}
@@ -263,7 +275,8 @@ static inline void list_insert_tail(struct list *list, struct list *node)
/*
* Insert a node before another node.
*/
-static inline void list_insert_before(struct list *next, struct list *node)
+static inline void
+list_insert_before(struct list *next, struct list *node)
{
list_add(next->prev, next, node);
}
@@ -271,7 +284,8 @@ static inline void list_insert_before(struct list *next, struct list *node)
/*
* Insert a node after another node.
*/
-static inline void list_insert_after(struct list *prev, struct list *node)
+static inline void
+list_insert_after(struct list *prev, struct list *node)
{
list_add(prev, prev->next, node);
}
@@ -281,7 +295,8 @@ static inline void list_insert_after(struct list *prev, struct list *node)
*
* After completion, the node is stale.
*/
-static inline void list_remove(struct list *node)
+static inline void
+list_remove(struct list *node)
{
node->prev->next = node->next;
node->next->prev = node->prev;
diff --git a/mem.c b/mem.c
index c5e7043..abe2b29 100644
--- a/mem.c
+++ b/mem.c
@@ -415,17 +415,20 @@ static void mem_cache_free_to_slab(struct mem_cache *cache, void *buf);
#ifdef CONFIG_MEM_USE_PHYS
#include "phys.h"
-static void * mem_default_alloc(size_t size)
+static void *
+mem_default_alloc(size_t size)
{
return (void *)phys_alloc(size);
}
-static void mem_default_free(void *ptr, size_t size)
+static void
+mem_default_free(void *ptr, size_t size)
{
phys_free((phys_paddr_t)ptr, size);
}
#else /* CONFIG_MEM_USE_PHYS */
-static void * mem_default_alloc(size_t size)
+static void *
+mem_default_alloc(size_t size)
{
void *addr;
@@ -438,13 +441,15 @@ static void * mem_default_alloc(size_t size)
return addr;
}
-static void mem_default_free(void *ptr, size_t size)
+static void
+mem_default_free(void *ptr, size_t size)
{
munmap(ptr, size);
}
#endif /* CONFIG_MEM_USE_PHYS */
-static void * mem_buf_verify_bytes(void *buf, void *pattern, size_t size)
+static void *
+mem_buf_verify_bytes(void *buf, void *pattern, size_t size)
{
char *ptr, *pattern_ptr, *end;
@@ -457,7 +462,8 @@ static void * mem_buf_verify_bytes(void *buf, void *pattern, size_t size)
return NULL;
}
-static void * mem_buf_verify(void *buf, uint64_t pattern, size_t size)
+static void *
+mem_buf_verify(void *buf, uint64_t pattern, size_t size)
{
uint64_t *ptr, *end;
@@ -473,7 +479,8 @@ static void * mem_buf_verify(void *buf, uint64_t pattern, size_t size)
return NULL;
}
-static void mem_buf_fill(void *buf, uint64_t pattern, size_t size)
+static void
+mem_buf_fill(void *buf, uint64_t pattern, size_t size)
{
uint64_t *ptr, *end;
@@ -486,8 +493,8 @@ static void mem_buf_fill(void *buf, uint64_t pattern, size_t size)
*ptr = pattern;
}
-static void * mem_buf_verify_fill(void *buf, uint64_t old, uint64_t new,
- size_t size)
+static void *
+mem_buf_verify_fill(void *buf, uint64_t old, uint64_t new, size_t size)
{
uint64_t *ptr, *end;
@@ -506,26 +513,26 @@ static void * mem_buf_verify_fill(void *buf, uint64_t old, uint64_t new,
return NULL;
}
-static inline union mem_bufctl * mem_buf_to_bufctl(void *buf,
- struct mem_cache *cache)
+static inline union mem_bufctl *
+mem_buf_to_bufctl(void *buf, struct mem_cache *cache)
{
return (union mem_bufctl *)(buf + cache->bufctl_dist);
}
-static inline struct mem_buftag * mem_buf_to_buftag(void *buf,
- struct mem_cache *cache)
+static inline struct mem_buftag *
+mem_buf_to_buftag(void *buf, struct mem_cache *cache)
{
return (struct mem_buftag *)(buf + cache->buftag_dist);
}
-static inline void * mem_bufctl_to_buf(union mem_bufctl *bufctl,
- struct mem_cache *cache)
+static inline void *
+mem_bufctl_to_buf(union mem_bufctl *bufctl, struct mem_cache *cache)
{
return (void *)bufctl - cache->bufctl_dist;
}
-static void mem_slab_create_verify(struct mem_slab *slab,
- struct mem_cache *cache)
+static void
+mem_slab_create_verify(struct mem_slab *slab, struct mem_cache *cache)
{
struct mem_buftag *buftag;
size_t buf_size;
@@ -549,7 +556,8 @@ static void mem_slab_create_verify(struct mem_slab *slab,
*
* The caller must drop all locks before calling this function.
*/
-static struct mem_slab * mem_slab_create(struct mem_cache *cache, size_t color)
+static struct mem_slab *
+mem_slab_create(struct mem_cache *cache, size_t color)
{
struct mem_slab *slab;
union mem_bufctl *bufctl;
@@ -594,8 +602,8 @@ static struct mem_slab * mem_slab_create(struct mem_cache *cache, size_t color)
return slab;
}
-static void mem_slab_destroy_verify(struct mem_slab *slab,
- struct mem_cache *cache)
+static void
+mem_slab_destroy_verify(struct mem_slab *slab, struct mem_cache *cache)
{
struct mem_buftag *buftag;
size_t buf_size;
@@ -625,7 +633,8 @@ static void mem_slab_destroy_verify(struct mem_slab *slab,
*
* The caller must drop all locks before calling this function.
*/
-static void mem_slab_destroy(struct mem_slab *slab, struct mem_cache *cache)
+static void
+mem_slab_destroy(struct mem_slab *slab, struct mem_cache *cache)
{
void *slab_buf;
@@ -642,13 +651,14 @@ static void mem_slab_destroy(struct mem_slab *slab, struct mem_cache *cache)
mem_cache_free(&mem_slab_cache, slab);
}
-static inline int mem_slab_use_tree(int flags)
+static inline int
+mem_slab_use_tree(int flags)
{
return !(flags & MEM_CF_DIRECT) || (flags & MEM_CF_VERIFY);
}
-static inline int mem_slab_cmp_lookup(const void *addr,
- const struct avltree_node *node)
+static inline int
+mem_slab_cmp_lookup(const void *addr, const struct avltree_node *node)
{
struct mem_slab *slab;
@@ -662,8 +672,8 @@ static inline int mem_slab_cmp_lookup(const void *addr,
return 1;
}
-static inline int mem_slab_cmp_insert(const struct avltree_node *a,
- const struct avltree_node *b)
+static inline int
+mem_slab_cmp_insert(const struct avltree_node *a, const struct avltree_node *b)
{
struct mem_slab *slab;
@@ -671,8 +681,8 @@ static inline int mem_slab_cmp_insert(const struct avltree_node *a,
return mem_slab_cmp_lookup(slab->addr, b);
}
-static void mem_cpu_pool_init(struct mem_cpu_pool *cpu_pool,
- struct mem_cache *cache)
+static void
+mem_cpu_pool_init(struct mem_cpu_pool *cpu_pool, struct mem_cache *cache)
{
pthread_mutex_init(&cpu_pool->lock, NULL);
cpu_pool->flags = cache->flags;
@@ -692,13 +702,15 @@ static void mem_cpu_pool_init(struct mem_cpu_pool *cpu_pool,
* allocator operations in any other way, as CPU pools are always valid, and
* their access is serialized by a lock.
*/
-static inline struct mem_cpu_pool * mem_cpu_pool_get(struct mem_cache *cache)
+static inline struct mem_cpu_pool *
+mem_cpu_pool_get(struct mem_cache *cache)
{
return &cache->cpu_pools[cpu_id()];
}
-static inline void mem_cpu_pool_build(struct mem_cpu_pool *cpu_pool,
- struct mem_cache *cache, void **array)
+static inline void
+mem_cpu_pool_build(struct mem_cpu_pool *cpu_pool, struct mem_cache *cache,
+ void **array)
{
cpu_pool->size = cache->cpu_pool_type->array_size;
cpu_pool->transfer_size = (cpu_pool->size + MEM_CPU_POOL_TRANSFER_RATIO - 1)
@@ -706,20 +718,22 @@ static inline void mem_cpu_pool_build(struct mem_cpu_pool *cpu_pool,
cpu_pool->array = array;
}
-static inline void * mem_cpu_pool_pop(struct mem_cpu_pool *cpu_pool)
+static inline void *
+mem_cpu_pool_pop(struct mem_cpu_pool *cpu_pool)
{
cpu_pool->nr_objs--;
return cpu_pool->array[cpu_pool->nr_objs];
}
-static inline void mem_cpu_pool_push(struct mem_cpu_pool *cpu_pool, void *obj)
+static inline void
+mem_cpu_pool_push(struct mem_cpu_pool *cpu_pool, void *obj)
{
cpu_pool->array[cpu_pool->nr_objs] = obj;
cpu_pool->nr_objs++;
}
-static int mem_cpu_pool_fill(struct mem_cpu_pool *cpu_pool,
- struct mem_cache *cache)
+static int
+mem_cpu_pool_fill(struct mem_cpu_pool *cpu_pool, struct mem_cache *cache)
{
void *obj;
int i;
@@ -740,8 +754,8 @@ static int mem_cpu_pool_fill(struct mem_cpu_pool *cpu_pool,
return i;
}
-static void mem_cpu_pool_drain(struct mem_cpu_pool *cpu_pool,
- struct mem_cache *cache)
+static void
+mem_cpu_pool_drain(struct mem_cpu_pool *cpu_pool, struct mem_cache *cache)
{
void *obj;
int i;
@@ -756,8 +770,8 @@ static void mem_cpu_pool_drain(struct mem_cpu_pool *cpu_pool,
pthread_mutex_unlock(&cache->lock);
}
-static void mem_cache_error(struct mem_cache *cache, void *buf, int error,
- void *arg)
+static void
+mem_cache_error(struct mem_cache *cache, void *buf, int error, void *arg)
{
struct mem_buftag *buftag;
@@ -801,7 +815,8 @@ static void mem_cache_error(struct mem_cache *cache, void *buf, int error,
* (buffers per slab and maximum color). It can also set the MEM_CF_DIRECT
* and/or MEM_CF_SLAB_EXTERNAL flags depending on the resulting layout.
*/
-static void mem_cache_compute_sizes(struct mem_cache *cache, int flags)
+static void
+mem_cache_compute_sizes(struct mem_cache *cache, int flags)
{
size_t i, buffers, buf_size, slab_size, free_slab_size, optimal_size;
size_t waste, waste_min;
@@ -866,9 +881,10 @@ static void mem_cache_compute_sizes(struct mem_cache *cache, int flags)
}
}
-static void mem_cache_init(struct mem_cache *cache, const char *name,
- size_t obj_size, size_t align, mem_cache_ctor_t ctor,
- const struct mem_source *source, int flags)
+static void
+mem_cache_init(struct mem_cache *cache, const char *name,
+ size_t obj_size, size_t align, mem_cache_ctor_t ctor,
+ const struct mem_source *source, int flags)
{
struct mem_cpu_pool_type *cpu_pool_type;
size_t i, buf_size;
@@ -940,9 +956,10 @@ static void mem_cache_init(struct mem_cache *cache, const char *name,
pthread_mutex_unlock(&mem_cache_list_lock);
}
-struct mem_cache * mem_cache_create(const char *name, size_t obj_size,
- size_t align, mem_cache_ctor_t ctor,
- const struct mem_source *source, int flags)
+struct mem_cache *
+mem_cache_create(const char *name, size_t obj_size, size_t align,
+ mem_cache_ctor_t ctor, const struct mem_source *source,
+ int flags)
{
struct mem_cache *cache;
@@ -956,12 +973,14 @@ struct mem_cache * mem_cache_create(const char *name, size_t obj_size,
return cache;
}
-static inline int mem_cache_empty(struct mem_cache *cache)
+static inline int
+mem_cache_empty(struct mem_cache *cache)
{
return cache->nr_objs == cache->nr_bufs;
}
-static int mem_cache_grow(struct mem_cache *cache)
+static int
+mem_cache_grow(struct mem_cache *cache)
{
struct mem_slab *slab;
size_t color;
@@ -1004,7 +1023,8 @@ static int mem_cache_grow(struct mem_cache *cache)
return !empty;
}
-static void mem_cache_reap(struct mem_cache *cache)
+static void
+mem_cache_reap(struct mem_cache *cache)
{
struct mem_slab *slab;
struct list dead_slabs;
@@ -1031,7 +1051,8 @@ static void mem_cache_reap(struct mem_cache *cache)
}
}
-void mem_cache_destroy(struct mem_cache *cache)
+void
+mem_cache_destroy(struct mem_cache *cache)
{
struct mem_cpu_pool *cpu_pool;
void **ptr;
@@ -1096,7 +1117,8 @@ void mem_cache_destroy(struct mem_cache *cache)
*
* The cache must be locked before calling this function.
*/
-static void * mem_cache_alloc_from_slab(struct mem_cache *cache)
+static void *
+mem_cache_alloc_from_slab(struct mem_cache *cache)
{
struct mem_slab *slab;
union mem_bufctl *bufctl;
@@ -1172,7 +1194,8 @@ static void * mem_cache_alloc_from_slab(struct mem_cache *cache)
*
* The cache must be locked before calling this function.
*/
-static void mem_cache_free_to_slab(struct mem_cache *cache, void *buf)
+static void
+mem_cache_free_to_slab(struct mem_cache *cache, void *buf)
{
struct mem_slab *slab;
union mem_bufctl *bufctl;
@@ -1251,8 +1274,8 @@ static void mem_cache_free_to_slab(struct mem_cache *cache, void *buf)
}
}
-static void mem_cache_alloc_verify(struct mem_cache *cache, void *buf,
- int construct)
+static void
+mem_cache_alloc_verify(struct mem_cache *cache, void *buf, int construct)
{
struct mem_buftag *buftag;
union mem_bufctl *bufctl;
@@ -1280,7 +1303,8 @@ static void mem_cache_alloc_verify(struct mem_cache *cache, void *buf,
cache->ctor(buf);
}
-void * mem_cache_alloc(struct mem_cache *cache)
+void *
+mem_cache_alloc(struct mem_cache *cache)
{
struct mem_cpu_pool *cpu_pool;
int filled;
@@ -1343,7 +1367,8 @@ slow_alloc_retry:
return buf;
}
-static void mem_cache_free_verify(struct mem_cache *cache, void *buf)
+static void
+mem_cache_free_verify(struct mem_cache *cache, void *buf)
{
struct avltree_node *node;
struct mem_buftag *buftag;
@@ -1405,7 +1430,8 @@ static void mem_cache_free_verify(struct mem_cache *cache, void *buf)
buftag->state = MEM_BUFTAG_FREE;
}
-void mem_cache_free(struct mem_cache *cache, void *obj)
+void
+mem_cache_free(struct mem_cache *cache, void *obj)
{
struct mem_cpu_pool *cpu_pool;
void **array;
@@ -1453,7 +1479,8 @@ fast_free_retry:
mem_cache_free_to_slab(cache, obj);
}
-void mem_cache_info(struct mem_cache *cache)
+void
+mem_cache_info(struct mem_cache *cache)
{
struct mem_cache *cache_stats;
char flags_str[64];
@@ -1521,7 +1548,8 @@ void mem_cache_info(struct mem_cache *cache)
mem_free(cache_stats, sizeof(*cache_stats));
}
-static void * mem_gc(void *arg)
+static void *
+mem_gc(void *arg)
{
struct mem_cache *cache;
struct timespec ts;
@@ -1562,7 +1590,8 @@ static void * mem_gc(void *arg)
return NULL;
}
-void mem_setup(void)
+void
+mem_setup(void)
{
static int mem_initialized = 0;
struct mem_cpu_pool_type *cpu_pool_type;
@@ -1627,7 +1656,8 @@ void mem_setup(void)
* Return the mem cache index matching the given allocation size, which
* must be strictly greater than 0.
*/
-static inline size_t mem_get_index(size_t size)
+static inline size_t
+mem_get_index(size_t size)
{
assert(size != 0);
@@ -1639,7 +1669,8 @@ static inline size_t mem_get_index(size_t size)
return (sizeof(long) * CHAR_BIT) - __builtin_clzl(size);
}
-static void mem_alloc_verify(struct mem_cache *cache, void *buf, size_t size)
+static void
+mem_alloc_verify(struct mem_cache *cache, void *buf, size_t size)
{
size_t redzone_size;
void *redzone;
@@ -1651,7 +1682,8 @@ static void mem_alloc_verify(struct mem_cache *cache, void *buf, size_t size)
memset(redzone, MEM_REDZONE_BYTE, redzone_size);
}
-void * mem_alloc(size_t size)
+void *
+mem_alloc(size_t size)
{
size_t index;
void *buf;
@@ -1676,7 +1708,8 @@ void * mem_alloc(size_t size)
return buf;
}
-void * mem_zalloc(size_t size)
+void *
+mem_zalloc(size_t size)
{
void *ptr;
@@ -1689,7 +1722,8 @@ void * mem_zalloc(size_t size)
return ptr;
}
-static void mem_free_verify(struct mem_cache *cache, void *buf, size_t size)
+static void
+mem_free_verify(struct mem_cache *cache, void *buf, size_t size)
{
unsigned char *redzone_byte, *redzone_end;
@@ -1706,7 +1740,8 @@ static void mem_free_verify(struct mem_cache *cache, void *buf, size_t size)
}
}
-void mem_free(void *ptr, size_t size)
+void
+mem_free(void *ptr, size_t size)
{
size_t index;
@@ -1729,7 +1764,8 @@ void mem_free(void *ptr, size_t size)
}
}
-void mem_info(void)
+void
+mem_info(void)
{
struct mem_cache *cache, *cache_stats;
size_t mem_usage, mem_reclaimable;
diff --git a/mem_malloc.c b/mem_malloc.c
index 0e38768..2f25e0b 100644
--- a/mem_malloc.c
+++ b/mem_malloc.c
@@ -42,7 +42,8 @@ struct btag {
size_t size;
} __aligned(8);
-void * malloc(size_t size)
+void *
+malloc(size_t size)
{
struct btag *btag;
@@ -62,7 +63,8 @@ void * malloc(size_t size)
return btag + 1;
}
-void * calloc(size_t nmemb, size_t size)
+void *
+calloc(size_t nmemb, size_t size)
{
size_t bytes;
void *buf;
@@ -80,7 +82,8 @@ void * calloc(size_t nmemb, size_t size)
return buf;
}
-void * realloc(void *ptr, size_t size)
+void *
+realloc(void *ptr, size_t size)
{
struct btag *btag;
size_t old_size;
@@ -108,7 +111,8 @@ void * realloc(void *ptr, size_t size)
return buf;
}
-int posix_memalign(void **ptr, size_t align, size_t size)
+int
+posix_memalign(void **ptr, size_t align, size_t size)
{
struct btag *btag;
char *buf;
@@ -134,7 +138,8 @@ int posix_memalign(void **ptr, size_t align, size_t size)
return 0;
}
-void free(void *ptr)
+void
+free(void *ptr)
{
struct btag *btag;
diff --git a/phys.c b/phys.c
index 3fbdc66..b8bbbc6 100644
--- a/phys.c
+++ b/phys.c
@@ -184,15 +184,16 @@ static unsigned int phys_segs_size;
#define phys_atop(addr) ((addr) / PAGE_SIZE)
#define phys_ptoa(pfn) ((pfn) * PAGE_SIZE)
-static void phys_page_init(struct phys_page *page, struct phys_seg *seg,
- phys_paddr_t pa)
+static void
+phys_page_init(struct phys_page *page, struct phys_seg *seg, phys_paddr_t pa)
{
page->seg = seg;
page->phys_addr = pa;
page->level = PHYS_LEVEL_ALLOCATED;
}
-static inline struct phys_page * phys_page_lookup(phys_paddr_t pa)
+static inline struct phys_page *
+phys_page_lookup(phys_paddr_t pa)
{
struct phys_seg *seg;
unsigned int i;
@@ -207,14 +208,15 @@ static inline struct phys_page * phys_page_lookup(phys_paddr_t pa)
return NULL;
}
-static void phys_free_list_init(struct phys_free_list *free_list)
+static void
+phys_free_list_init(struct phys_free_list *free_list)
{
free_list->size = 0;
list_init(&free_list->blocks);
}
-static inline void phys_free_list_insert(struct phys_free_list *free_list,
- struct phys_page *page)
+static inline void
+phys_free_list_insert(struct phys_free_list *free_list, struct phys_page *page)
{
assert(page->level == PHYS_LEVEL_ALLOCATED);
@@ -222,8 +224,8 @@ static inline void phys_free_list_insert(struct phys_free_list *free_list,
list_insert(&free_list->blocks, &page->node);
}
-static inline void phys_free_list_remove(struct phys_free_list *free_list,
- struct phys_page *page)
+static inline void
+phys_free_list_remove(struct phys_free_list *free_list, struct phys_page *page)
{
assert(free_list->size != 0);
assert(!list_empty(&free_list->blocks));
@@ -233,8 +235,8 @@ static inline void phys_free_list_remove(struct phys_free_list *free_list,
list_remove(&page->node);
}
-static struct phys_page * phys_seg_alloc_from_buddy(struct phys_seg *seg,
- unsigned int level)
+static struct phys_page *
+phys_seg_alloc_from_buddy(struct phys_seg *seg, unsigned int level)
{
struct phys_free_list *free_list;
struct phys_page *page, *buddy;
@@ -267,9 +269,9 @@ static struct phys_page * phys_seg_alloc_from_buddy(struct phys_seg *seg,
return page;
}
-static void phys_seg_free_to_buddy(struct phys_seg *seg,
- struct phys_page *page,
- unsigned int level)
+static void
+phys_seg_free_to_buddy(struct phys_seg *seg, struct phys_page *page,
+ unsigned int level)
{
struct phys_page *buddy;
phys_paddr_t pa, buddy_pa;
@@ -306,7 +308,8 @@ static void phys_seg_free_to_buddy(struct phys_seg *seg,
seg->nr_free_pages += nr_pages;
}
-static void phys_cpu_pool_init(struct phys_cpu_pool *cpu_pool, int size)
+static void
+phys_cpu_pool_init(struct phys_cpu_pool *cpu_pool, int size)
{
cpu_pool->size = size;
cpu_pool->transfer_size = (size + PHYS_CPU_POOL_TRANSFER_RATIO - 1)
@@ -325,7 +328,8 @@ static void phys_cpu_pool_init(struct phys_cpu_pool *cpu_pool, int size)
* allocator operations in any other way, as CPU pools are always valid, and
* their access is serialized by a lock.
*/
-static inline struct phys_cpu_pool * phys_cpu_pool_get(struct phys_seg *seg)
+static inline struct phys_cpu_pool *
+phys_cpu_pool_get(struct phys_seg *seg)
{
return &seg->cpu_pools[cpu_id()];
}
@@ -342,16 +346,16 @@ phys_cpu_pool_pop(struct phys_cpu_pool *cpu_pool)
return page;
}
-static inline void phys_cpu_pool_push(struct phys_cpu_pool *cpu_pool,
- struct phys_page *page)
+static inline void
+phys_cpu_pool_push(struct phys_cpu_pool *cpu_pool, struct phys_page *page)
{
assert(cpu_pool->nr_pages < cpu_pool->size);
cpu_pool->nr_pages++;
list_insert(&cpu_pool->pages, &page->node);
}
-static int phys_cpu_pool_fill(struct phys_cpu_pool *cpu_pool,
- struct phys_seg *seg)
+static int
+phys_cpu_pool_fill(struct phys_cpu_pool *cpu_pool, struct phys_seg *seg)
{
struct phys_page *page;
int i;
@@ -374,8 +378,8 @@ static int phys_cpu_pool_fill(struct phys_cpu_pool *cpu_pool,
return i;
}
-static void phys_cpu_pool_drain(struct phys_cpu_pool *cpu_pool,
- struct phys_seg *seg)
+static void
+phys_cpu_pool_drain(struct phys_cpu_pool *cpu_pool, struct phys_seg *seg)
{
struct phys_page *page;
int i;
@@ -392,22 +396,26 @@ static void phys_cpu_pool_drain(struct phys_cpu_pool *cpu_pool,
pthread_mutex_unlock(&seg->lock);
}
-static inline phys_paddr_t phys_seg_start(struct phys_seg *seg)
+static inline phys_paddr_t
+phys_seg_start(struct phys_seg *seg)
{
return seg->start;
}
-static inline phys_paddr_t phys_seg_end(struct phys_seg *seg)
+static inline phys_paddr_t
+phys_seg_end(struct phys_seg *seg)
{
return seg->end;
}
-static inline phys_paddr_t phys_seg_size(struct phys_seg *seg)
+static inline phys_paddr_t
+phys_seg_size(struct phys_seg *seg)
{
return phys_seg_end(seg) - phys_seg_start(seg);
}
-static int phys_seg_compute_pool_size(struct phys_seg *seg)
+static int
+phys_seg_compute_pool_size(struct phys_seg *seg)
{
phys_paddr_t size;
@@ -421,7 +429,8 @@ static int phys_seg_compute_pool_size(struct phys_seg *seg)
return size;
}
-static void phys_seg_init(struct phys_seg *seg, struct phys_page *pages)
+static void
+phys_seg_init(struct phys_seg *seg, struct phys_page *pages)
{
phys_paddr_t pa;
int pool_size;
@@ -449,7 +458,8 @@ static void phys_seg_init(struct phys_seg *seg, struct phys_page *pages)
* Return the level (i.e. the index in the free lists array) matching the
* given size.
*/
-static inline unsigned int phys_get_level(phys_size_t size)
+static inline unsigned int
+phys_get_level(phys_size_t size)
{
size = P2ROUND(size, PAGE_SIZE) / PAGE_SIZE;
assert(size != 0);
@@ -461,7 +471,8 @@ static inline unsigned int phys_get_level(phys_size_t size)
return (sizeof(size) * CHAR_BIT) - __builtin_clzl(size);
}
-static struct phys_page * phys_seg_alloc(struct phys_seg *seg, phys_size_t size)
+static struct phys_page *
+phys_seg_alloc(struct phys_seg *seg, phys_size_t size)
{
struct phys_cpu_pool *cpu_pool;
struct phys_page *page;
@@ -495,8 +506,8 @@ static struct phys_page * phys_seg_alloc(struct phys_seg *seg, phys_size_t size)
return page;
}
-static void phys_seg_free(struct phys_seg *seg, struct phys_page *page,
- phys_size_t size)
+static void
+phys_seg_free(struct phys_seg *seg, struct phys_page *page, phys_size_t size)
{
struct phys_cpu_pool *cpu_pool;
unsigned int level;
@@ -525,8 +536,9 @@ static void phys_seg_free(struct phys_seg *seg, struct phys_page *page,
*
* This function partially initializes a segment.
*/
-static void phys_load_segment(const char *name, phys_paddr_t start,
- phys_paddr_t end, unsigned int seg_list_prio)
+static void
+phys_load_segment(const char *name, phys_paddr_t start, phys_paddr_t end,
+ unsigned int seg_list_prio)
{
static int initialized = 0;
struct phys_seg *seg;
@@ -565,7 +577,8 @@ static void phys_load_segment(const char *name, phys_paddr_t start,
* this implementation, an Intel machine with two segments of RAM is
* virtualized.
*/
-static void phys_load_segments(void)
+static void
+phys_load_segments(void)
{
phys_paddr_t start, end;
size_t size;
@@ -600,7 +613,8 @@ static void phys_load_segments(void)
phys_load_segment("normal", start, end, PHYS_SEGLIST_NORMAL);
}
-void phys_setup(void)
+void
+phys_setup(void)
{
struct phys_seg *seg, *map_seg;
struct phys_page *page, *map;
@@ -676,7 +690,8 @@ found:
}
}
-struct phys_page * phys_alloc_pages(phys_size_t size)
+struct phys_page *
+phys_alloc_pages(phys_size_t size)
{
struct list *seg_list;
struct phys_seg *seg;
@@ -695,12 +710,14 @@ struct phys_page * phys_alloc_pages(phys_size_t size)
return NULL;
}
-void phys_free_pages(struct phys_page *page, phys_size_t size)
+void
+phys_free_pages(struct phys_page *page, phys_size_t size)
{
phys_seg_free(page->seg, page, size);
}
-phys_paddr_t phys_alloc(phys_size_t size)
+phys_paddr_t
+phys_alloc(phys_size_t size)
{
struct phys_page *page;
@@ -716,7 +733,8 @@ phys_paddr_t phys_alloc(phys_size_t size)
return page->phys_addr;
}
-void phys_free(phys_paddr_t pa, phys_size_t size)
+void
+phys_free(phys_paddr_t pa, phys_size_t size)
{
struct phys_page *page;
@@ -725,7 +743,8 @@ void phys_free(phys_paddr_t pa, phys_size_t size)
phys_free_pages(page, size);
}
-void phys_info(void)
+void
+phys_info(void)
{
struct phys_seg *seg;
unsigned int i, j;
diff --git a/rbtree.c b/rbtree.c
index 75bf22a..a81327b 100644
--- a/rbtree.c
+++ b/rbtree.c
@@ -36,8 +36,8 @@
* The parent parameter must not be null, and must be the parent of the
* given node.
*/
-static inline int rbtree_index(const struct rbtree_node *node,
- const struct rbtree_node *parent)
+static inline int
+rbtree_index(const struct rbtree_node *node, const struct rbtree_node *parent)
{
assert(parent != NULL);
assert((node == NULL) || (rbtree_parent(node) == parent));
@@ -53,7 +53,8 @@ static inline int rbtree_index(const struct rbtree_node *node,
/*
* Return the color of a node.
*/
-static inline int rbtree_color(const struct rbtree_node *node)
+static inline int
+rbtree_color(const struct rbtree_node *node)
{
return node->parent & RBTREE_COLOR_MASK;
}
@@ -61,7 +62,8 @@ static inline int rbtree_color(const struct rbtree_node *node)
/*
* Return true if the node is red.
*/
-static inline int rbtree_is_red(const struct rbtree_node *node)
+static inline int
+rbtree_is_red(const struct rbtree_node *node)
{
return rbtree_color(node) == RBTREE_COLOR_RED;
}
@@ -69,7 +71,8 @@ static inline int rbtree_is_red(const struct rbtree_node *node)
/*
* Return true if the node is black.
*/
-static inline int rbtree_is_black(const struct rbtree_node *node)
+static inline int
+rbtree_is_black(const struct rbtree_node *node)
{
return rbtree_color(node) == RBTREE_COLOR_BLACK;
}
@@ -77,8 +80,8 @@ static inline int rbtree_is_black(const struct rbtree_node *node)
/*
* Set the parent of a node, retaining its current color.
*/
-static inline void rbtree_set_parent(struct rbtree_node *node,
- struct rbtree_node *parent)
+static inline void
+rbtree_set_parent(struct rbtree_node *node, struct rbtree_node *parent)
{
assert(rbtree_check_alignment(node));
assert(rbtree_check_alignment(parent));
@@ -89,7 +92,8 @@ static inline void rbtree_set_parent(struct rbtree_node *node,
/*
* Set the color of a node, retaining its current parent.
*/
-static inline void rbtree_set_color(struct rbtree_node *node, int color)
+static inline void
+rbtree_set_color(struct rbtree_node *node, int color)
{
assert((color & ~RBTREE_COLOR_MASK) == 0);
node->parent = (node->parent & RBTREE_PARENT_MASK) | color;
@@ -98,7 +102,8 @@ static inline void rbtree_set_color(struct rbtree_node *node, int color)
/*
* Set the color of a node to red, retaining its current parent.
*/
-static inline void rbtree_set_red(struct rbtree_node *node)
+static inline void
+rbtree_set_red(struct rbtree_node *node)
{
rbtree_set_color(node, RBTREE_COLOR_RED);
}
@@ -106,7 +111,8 @@ static inline void rbtree_set_red(struct rbtree_node *node)
/*
* Set the color of a node to black, retaining its current parent.
*/
-static inline void rbtree_set_black(struct rbtree_node *node)
+static inline void
+rbtree_set_black(struct rbtree_node *node)
{
rbtree_set_color(node, RBTREE_COLOR_BLACK);
}
@@ -117,8 +123,8 @@ static inline void rbtree_set_black(struct rbtree_node *node)
* The direction parameter defines the rotation direction and is either
* RBTREE_LEFT or RBTREE_RIGHT.
*/
-static void rbtree_rotate(struct rbtree *tree, struct rbtree_node *node,
- int direction)
+static void
+rbtree_rotate(struct rbtree *tree, struct rbtree_node *node, int direction)
{
struct rbtree_node *parent, *rnode;
int left, right;
@@ -144,8 +150,9 @@ static void rbtree_rotate(struct rbtree *tree, struct rbtree_node *node,
rbtree_set_parent(node, rnode);
}
-void rbtree_insert_rebalance(struct rbtree *tree, struct rbtree_node *parent,
- int index, struct rbtree_node *node)
+void
+rbtree_insert_rebalance(struct rbtree *tree, struct rbtree_node *parent,
+ int index, struct rbtree_node *node)
{
struct rbtree_node *grand_parent, *uncle, *tmp;
int left, right;
@@ -355,8 +362,8 @@ update_color:
assert((tree->root == NULL) || rbtree_is_black(tree->root));
}
-struct rbtree_node * rbtree_nearest(struct rbtree_node *parent, int index,
- int direction)
+struct rbtree_node *
+rbtree_nearest(struct rbtree_node *parent, int index, int direction)
{
assert(rbtree_check_index(direction));
@@ -371,7 +378,8 @@ struct rbtree_node * rbtree_nearest(struct rbtree_node *parent, int index,
return rbtree_walk(parent, direction);
}
-struct rbtree_node * rbtree_firstlast(const struct rbtree *tree, int direction)
+struct rbtree_node *
+rbtree_firstlast(const struct rbtree *tree, int direction)
{
struct rbtree_node *prev, *cur;
@@ -385,7 +393,8 @@ struct rbtree_node * rbtree_firstlast(const struct rbtree *tree, int direction)
return prev;
}
-struct rbtree_node * rbtree_walk(struct rbtree_node *node, int direction)
+struct rbtree_node *
+rbtree_walk(struct rbtree_node *node, int direction)
{
int left, right;
@@ -426,7 +435,8 @@ struct rbtree_node * rbtree_walk(struct rbtree_node *node, int direction)
/*
* Return the left-most deepest child node of the given node.
*/
-static struct rbtree_node * rbtree_find_deepest(struct rbtree_node *node)
+static struct rbtree_node *
+rbtree_find_deepest(struct rbtree_node *node)
{
struct rbtree_node *parent;
@@ -445,7 +455,8 @@ static struct rbtree_node * rbtree_find_deepest(struct rbtree_node *node)
}
}
-struct rbtree_node * rbtree_postwalk_deepest(const struct rbtree *tree)
+struct rbtree_node *
+rbtree_postwalk_deepest(const struct rbtree *tree)
{
struct rbtree_node *node;
@@ -457,7 +468,8 @@ struct rbtree_node * rbtree_postwalk_deepest(const struct rbtree *tree)
return rbtree_find_deepest(node);
}
-struct rbtree_node * rbtree_postwalk_unlink(struct rbtree_node *node)
+struct rbtree_node *
+rbtree_postwalk_unlink(struct rbtree_node *node)
{
struct rbtree_node *parent;
int index;
diff --git a/rbtree.h b/rbtree.h
index 5ecba72..ef3c96c 100644
--- a/rbtree.h
+++ b/rbtree.h
@@ -60,7 +60,8 @@ struct rbtree;
/*
* Initialize a tree.
*/
-static inline void rbtree_init(struct rbtree *tree)
+static inline void
+rbtree_init(struct rbtree *tree)
{
tree->root = NULL;
}
@@ -70,7 +71,8 @@ static inline void rbtree_init(struct rbtree *tree)
*
* A node is in no tree when its parent points to itself.
*/
-static inline void rbtree_node_init(struct rbtree_node *node)
+static inline void
+rbtree_node_init(struct rbtree_node *node)
{
assert(rbtree_check_alignment(node));
@@ -82,7 +84,8 @@ static inline void rbtree_node_init(struct rbtree_node *node)
/*
* Return true if node is in no tree.
*/
-static inline int rbtree_node_unlinked(const struct rbtree_node *node)
+static inline int
+rbtree_node_unlinked(const struct rbtree_node *node)
{
return rbtree_parent(node) == node;
}
@@ -96,7 +99,8 @@ static inline int rbtree_node_unlinked(const struct rbtree_node *node)
/*
* Return true if tree is empty.
*/
-static inline int rbtree_empty(const struct rbtree *tree)
+static inline int
+rbtree_empty(const struct rbtree *tree)
{
return tree->root == NULL;
}
diff --git a/rbtree_i.h b/rbtree_i.h
index c54f3c1..4d4ea26 100644
--- a/rbtree_i.h
+++ b/rbtree_i.h
@@ -80,7 +80,8 @@ struct rbtree {
/*
* Return true if the given pointer is suitably aligned.
*/
-static inline int rbtree_check_alignment(const struct rbtree_node *node)
+static inline int
+rbtree_check_alignment(const struct rbtree_node *node)
{
return ((unsigned long)node & (~RBTREE_PARENT_MASK)) == 0;
}
@@ -88,7 +89,8 @@ static inline int rbtree_check_alignment(const struct rbtree_node *node)
/*
* Return true if the given index is a valid child index.
*/
-static inline int rbtree_check_index(int index)
+static inline int
+rbtree_check_index(int index)
{
return index == (index & 1);
}
@@ -99,7 +101,8 @@ static inline int rbtree_check_index(int index)
*
* This function is mostly used when looking up a node.
*/
-static inline int rbtree_d2i(int diff)
+static inline int
+rbtree_d2i(int diff)
{
return !(diff <= 0);
}
@@ -107,7 +110,8 @@ static inline int rbtree_d2i(int diff)
/*
* Return the parent of a node.
*/
-static inline struct rbtree_node * rbtree_parent(const struct rbtree_node *node)
+static inline struct rbtree_node *
+rbtree_parent(const struct rbtree_node *node)
{
return (struct rbtree_node *)(node->parent & RBTREE_PARENT_MASK);
}
@@ -115,7 +119,8 @@ static inline struct rbtree_node * rbtree_parent(const struct rbtree_node *node)
/*
* Translate an insertion point into a slot.
*/
-static inline unsigned long rbtree_slot(struct rbtree_node *parent, int index)
+static inline unsigned long
+rbtree_slot(struct rbtree_node *parent, int index)
{
assert(rbtree_check_alignment(parent));
assert(rbtree_check_index(index));
@@ -125,7 +130,8 @@ static inline unsigned long rbtree_slot(struct rbtree_node *parent, int index)
/*
* Extract the parent address from a slot.
*/
-static inline struct rbtree_node * rbtree_slot_parent(unsigned long slot)
+static inline struct rbtree_node *
+rbtree_slot_parent(unsigned long slot)
{
return (struct rbtree_node *)(slot & RBTREE_SLOT_PARENT_MASK);
}
@@ -133,7 +139,8 @@ static inline struct rbtree_node * rbtree_slot_parent(unsigned long slot)
/*
* Extract the index from a slot.
*/
-static inline int rbtree_slot_index(unsigned long slot)
+static inline int
+rbtree_slot_index(unsigned long slot)
{
return slot & RBTREE_SLOT_INDEX_MASK;
}
diff --git a/rdxtree.c b/rdxtree.c
index 0847e2c..40f2da7 100644
--- a/rdxtree.c
+++ b/rdxtree.c
@@ -84,7 +84,8 @@ struct rdxtree_node {
void *slots[RDXTREE_RADIX_SIZE];
};
-static struct rdxtree_node * rdxtree_node_create(void)
+static struct rdxtree_node *
+rdxtree_node_create(void)
{
struct rdxtree_node *node;
@@ -100,37 +101,41 @@ static struct rdxtree_node * rdxtree_node_create(void)
return node;
}
-static void rdxtree_node_destroy(struct rdxtree_node *node)
+static void
+rdxtree_node_destroy(struct rdxtree_node *node)
{
free(node);
}
-static inline void rdxtree_node_link(struct rdxtree_node *node,
- struct rdxtree_node *parent,
- unsigned int index)
+static inline void
+rdxtree_node_link(struct rdxtree_node *node, struct rdxtree_node *parent,
+ unsigned int index)
{
node->parent = parent;
node->index = index;
}
-static inline void rdxtree_node_unlink(struct rdxtree_node *node)
+static inline void
+rdxtree_node_unlink(struct rdxtree_node *node)
{
assert(node->parent != NULL);
node->parent = NULL;
}
-static inline int rdxtree_node_full(struct rdxtree_node *node)
+static inline int
+rdxtree_node_full(struct rdxtree_node *node)
{
return (node->nr_slots == ARRAY_SIZE(node->slots));
}
-static inline int rdxtree_node_empty(struct rdxtree_node *node)
+static inline int
+rdxtree_node_empty(struct rdxtree_node *node)
{
return (node->nr_slots == 0);
}
-static inline void rdxtree_node_insert(struct rdxtree_node *node,
- unsigned int index, void *ptr)
+static inline void
+rdxtree_node_insert(struct rdxtree_node *node, unsigned int index, void *ptr)
{
assert(node->slots[index] == NULL);
@@ -138,8 +143,8 @@ static inline void rdxtree_node_insert(struct rdxtree_node *node,
node->slots[index] = ptr;
}
-static inline void rdxtree_node_remove(struct rdxtree_node *node,
- unsigned int index)
+static inline void
+rdxtree_node_remove(struct rdxtree_node *node, unsigned int index)
{
assert(node->slots[index] != NULL);
@@ -147,8 +152,8 @@ static inline void rdxtree_node_remove(struct rdxtree_node *node,
node->slots[index] = NULL;
}
-static inline void ** rdxtree_node_find(struct rdxtree_node *node,
- unsigned int index)
+static inline void **
+rdxtree_node_find(struct rdxtree_node *node, unsigned int index)
{
while (index < ARRAY_SIZE(node->slots)) {
if (node->slots[index] != NULL)
@@ -160,35 +165,38 @@ static inline void ** rdxtree_node_find(struct rdxtree_node *node,
return NULL;
}
-static inline void rdxtree_node_bm_set(struct rdxtree_node *node,
- unsigned int index)
+static inline void
+rdxtree_node_bm_set(struct rdxtree_node *node, unsigned int index)
{
node->alloc_bm |= (rdxtree_bm_t)1 << index;
}
-static inline void rdxtree_node_bm_clear(struct rdxtree_node *node,
- unsigned int index)
+static inline void
+rdxtree_node_bm_clear(struct rdxtree_node *node, unsigned int index)
{
node->alloc_bm &= ~((rdxtree_bm_t)1 << index);
}
-static inline int rdxtree_node_bm_is_set(struct rdxtree_node *node,
- unsigned int index)
+static inline int
+rdxtree_node_bm_is_set(struct rdxtree_node *node, unsigned int index)
{
return (node->alloc_bm & ((rdxtree_bm_t)1 << index));
}
-static inline int rdxtree_node_bm_empty(struct rdxtree_node *node)
+static inline int
+rdxtree_node_bm_empty(struct rdxtree_node *node)
{
return (node->alloc_bm == RDXTREE_BM_EMPTY);
}
-static inline int rdxtree_node_bm_first(struct rdxtree_node *node)
+static inline int
+rdxtree_node_bm_first(struct rdxtree_node *node)
{
return rdxtree_ffs(node->alloc_bm) - 1;
}
-static inline unsigned long rdxtree_max_key(int height)
+static inline unsigned long
+rdxtree_max_key(int height)
{
unsigned int shift;
@@ -200,7 +208,8 @@ static inline unsigned long rdxtree_max_key(int height)
return (1 << shift) - 1;
}
-static void rdxtree_shrink(struct rdxtree *tree)
+static void
+rdxtree_shrink(struct rdxtree *tree)
{
struct rdxtree_node *node, *child;
@@ -225,7 +234,8 @@ static void rdxtree_shrink(struct rdxtree *tree)
}
}
-static int rdxtree_grow(struct rdxtree *tree, unsigned long key)
+static int
+rdxtree_grow(struct rdxtree *tree, unsigned long key)
{
struct rdxtree_node *node;
int new_height;
@@ -266,7 +276,8 @@ static int rdxtree_grow(struct rdxtree *tree, unsigned long key)
return ERR_SUCCESS;
}
-static void rdxtree_cleanup(struct rdxtree *tree, struct rdxtree_node *node)
+static void
+rdxtree_cleanup(struct rdxtree *tree, struct rdxtree_node *node)
{
struct rdxtree_node *prev;
@@ -292,8 +303,8 @@ static void rdxtree_cleanup(struct rdxtree *tree, struct rdxtree_node *node)
}
}
-static void rdxtree_insert_bm_clear(struct rdxtree_node *node,
- unsigned int index)
+static void
+rdxtree_insert_bm_clear(struct rdxtree_node *node, unsigned int index)
{
for (;;) {
rdxtree_node_bm_clear(node, index);
@@ -306,8 +317,9 @@ static void rdxtree_insert_bm_clear(struct rdxtree_node *node,
}
}
-static int rdxtree_insert_prim(struct rdxtree *tree, unsigned long key,
- void *ptr, void ***slotp)
+static int
+rdxtree_insert_prim(struct rdxtree *tree, unsigned long key, void *ptr,
+ void ***slotp)
{
struct rdxtree_node *node, *prev;
unsigned int index = index;
@@ -380,19 +392,22 @@ static int rdxtree_insert_prim(struct rdxtree *tree, unsigned long key,
return ERR_SUCCESS;
}
-int rdxtree_insert(struct rdxtree *tree, unsigned long key, void *ptr)
+int
+rdxtree_insert(struct rdxtree *tree, unsigned long key, void *ptr)
{
return rdxtree_insert_prim(tree, key, ptr, NULL);
}
-int rdxtree_insert_slot(struct rdxtree *tree, unsigned long key, void *ptr,
- void ***slotp)
+int
+rdxtree_insert_slot(struct rdxtree *tree, unsigned long key, void *ptr,
+ void ***slotp)
{
return rdxtree_insert_prim(tree, key, ptr, slotp);
}
-static int rdxtree_insert_alloc_prim(struct rdxtree *tree, void *ptr,
- unsigned long *keyp, void ***slotp)
+static int
+rdxtree_insert_alloc_prim(struct rdxtree *tree, void *ptr, unsigned long *keyp,
+ void ***slotp)
{
struct rdxtree_node *node, *prev;
unsigned long key;
@@ -466,19 +481,21 @@ out:
return ERR_SUCCESS;
}
-int rdxtree_insert_alloc(struct rdxtree *tree, void *ptr, unsigned long *keyp)
+int
+rdxtree_insert_alloc(struct rdxtree *tree, void *ptr, unsigned long *keyp)
{
return rdxtree_insert_alloc_prim(tree, ptr, keyp, NULL);
}
-int rdxtree_insert_alloc_slot(struct rdxtree *tree, void *ptr,
- unsigned long *keyp, void ***slotp)
+int
+rdxtree_insert_alloc_slot(struct rdxtree *tree, void *ptr, unsigned long *keyp,
+ void ***slotp)
{
return rdxtree_insert_alloc_prim(tree, ptr, keyp, slotp);
}
-static void rdxtree_remove_bm_set(struct rdxtree_node *node,
- unsigned int index)
+static void
+rdxtree_remove_bm_set(struct rdxtree_node *node, unsigned int index)
{
do {
rdxtree_node_bm_set(node, index);
@@ -491,7 +508,8 @@ static void rdxtree_remove_bm_set(struct rdxtree_node *node,
} while (!rdxtree_node_bm_is_set(node, index));
}
-void * rdxtree_remove(struct rdxtree *tree, unsigned long key)
+void *
+rdxtree_remove(struct rdxtree *tree, unsigned long key)
{
struct rdxtree_node *node, *prev;
unsigned int index;
@@ -531,7 +549,8 @@ void * rdxtree_remove(struct rdxtree *tree, unsigned long key)
return node;
}
-static void ** rdxtree_lookup_prim(struct rdxtree *tree, unsigned long key)
+static void **
+rdxtree_lookup_prim(struct rdxtree *tree, unsigned long key)
{
struct rdxtree_node *node, *prev;
unsigned int index;
@@ -569,7 +588,8 @@ static void ** rdxtree_lookup_prim(struct rdxtree *tree, unsigned long key)
return &prev->slots[index];
}
-void * rdxtree_lookup(struct rdxtree *tree, unsigned long key)
+void *
+rdxtree_lookup(struct rdxtree *tree, unsigned long key)
{
void **slot;
@@ -577,12 +597,14 @@ void * rdxtree_lookup(struct rdxtree *tree, unsigned long key)
return (slot == NULL) ? NULL : *slot;
}
-void ** rdxtree_lookup_slot(struct rdxtree *tree, unsigned long key)
+void **
+rdxtree_lookup_slot(struct rdxtree *tree, unsigned long key)
{
return rdxtree_lookup_prim(tree, key);
}
-void * rdxtree_replace_slot(void **slot, void *ptr)
+void *
+rdxtree_replace_slot(void **slot, void *ptr)
{
void *old;
@@ -594,8 +616,8 @@ void * rdxtree_replace_slot(void **slot, void *ptr)
return old;
}
-static struct rdxtree_node * rdxtree_walk(struct rdxtree *tree,
- struct rdxtree_node *node)
+static struct rdxtree_node *
+rdxtree_walk(struct rdxtree *tree, struct rdxtree_node *node)
{
struct rdxtree_node *prev;
void **slot;
@@ -644,7 +666,8 @@ static struct rdxtree_node * rdxtree_walk(struct rdxtree *tree,
return node;
}
-void * rdxtree_iter_next(struct rdxtree *tree, struct rdxtree_iter *iter)
+void *
+rdxtree_iter_next(struct rdxtree *tree, struct rdxtree_iter *iter)
{
unsigned int index;
@@ -674,7 +697,8 @@ void * rdxtree_iter_next(struct rdxtree *tree, struct rdxtree_iter *iter)
return *iter->slot;
}
-void rdxtree_remove_all(struct rdxtree *tree)
+void
+rdxtree_remove_all(struct rdxtree *tree)
{
struct rdxtree_node *node, *next;
int height;
diff --git a/rdxtree.h b/rdxtree.h
index 438e446..61c33c7 100644
--- a/rdxtree.h
+++ b/rdxtree.h
@@ -60,7 +60,8 @@ struct rdxtree_iter {
/*
* Initialize a tree.
*/
-static inline void rdxtree_init(struct rdxtree *tree)
+static inline void
+rdxtree_init(struct rdxtree *tree)
{
tree->height = 0;
tree->root = NULL;
@@ -69,7 +70,8 @@ static inline void rdxtree_init(struct rdxtree *tree)
/*
* Initialize an iterator.
*/
-static inline void rdxtree_iter_init(struct rdxtree_iter *iter)
+static inline void
+rdxtree_iter_init(struct rdxtree_iter *iter)
{
iter->node = NULL;
iter->slot = NULL;
diff --git a/test/test_avltree.c b/test/test_avltree.c
index f8fcec8..a08c7e2 100644
--- a/test/test_avltree.c
+++ b/test/test_avltree.c
@@ -39,7 +39,8 @@ struct obj {
int id;
};
-static inline int obj_cmp_lookup(int id, struct avltree_node *node)
+static inline int
+obj_cmp_lookup(int id, struct avltree_node *node)
{
struct obj *obj;
@@ -47,7 +48,8 @@ static inline int obj_cmp_lookup(int id, struct avltree_node *node)
return id - obj->id;
}
-static void print_subtree(struct avltree_node *node, int level)
+static void
+print_subtree(struct avltree_node *node, int level)
{
struct obj *obj;
char balance;
@@ -83,17 +85,20 @@ static void print_subtree(struct avltree_node *node, int level)
print_subtree(node->children[AVLTREE_LEFT], level + 1);
}
-static void print_tree(struct avltree *tree)
+static void
+print_tree(struct avltree *tree)
{
print_subtree(tree->root, 0);
}
-static int get_id(int i)
+static int
+get_id(int i)
{
return hash_int32(i, 6);
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct avltree tree;
struct avltree_node *node, *tmp;
diff --git a/test/test_mem.c b/test/test_mem.c
index 95887ca..eb7a56c 100644
--- a/test/test_mem.c
+++ b/test/test_mem.c
@@ -32,7 +32,8 @@
#define STRING "This is a test string."
#define STRING_SIZE (STRLEN(STRING) + 1)
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
char *s;
diff --git a/test/test_mem_cache.c b/test/test_mem_cache.c
index 2ae17fc..518dc09 100644
--- a/test/test_mem_cache.c
+++ b/test/test_mem_cache.c
@@ -52,7 +52,8 @@ struct obj {
char name[16];
};
-static void obj_ctor(void *ptr)
+static void
+obj_ctor(void *ptr)
{
struct obj *obj;
@@ -64,7 +65,8 @@ static struct mem_cache *obj_cache;
static volatile int work;
static struct result results[NTHREADS];
-static void * run(void *arg)
+static void *
+run(void *arg)
{
struct obj *objs[OBJSPERLOOP];
struct result *result;
@@ -90,7 +92,8 @@ static void * run(void *arg)
return NULL;
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
pthread_t threads[NTHREADS];
unsigned long ops;
diff --git a/test/test_mem_cache_double_free.c b/test/test_mem_cache_double_free.c
index 241533d..de356a3 100644
--- a/test/test_mem_cache_double_free.c
+++ b/test/test_mem_cache_double_free.c
@@ -35,7 +35,8 @@ struct obj {
char name[16];
};
-static void obj_ctor(void *ptr)
+static void
+obj_ctor(void *ptr)
{
struct obj *obj;
@@ -43,7 +44,8 @@ static void obj_ctor(void *ptr)
obj->nr_refs = 0;
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct mem_cache *obj_cache;
struct obj *obj;
diff --git a/test/test_mem_cache_invalid_free.c b/test/test_mem_cache_invalid_free.c
index 9efddb9..767ee6b 100644
--- a/test/test_mem_cache_invalid_free.c
+++ b/test/test_mem_cache_invalid_free.c
@@ -35,7 +35,8 @@ struct obj {
char name[16];
};
-static void obj_ctor(void *ptr)
+static void
+obj_ctor(void *ptr)
{
struct obj *obj;
@@ -43,7 +44,8 @@ static void obj_ctor(void *ptr)
obj->nr_refs = 0;
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct mem_cache *obj_cache;
struct obj *obj;
diff --git a/test/test_mem_cache_write_beyond.c b/test/test_mem_cache_write_beyond.c
index ba0c4ce..05bea2e 100644
--- a/test/test_mem_cache_write_beyond.c
+++ b/test/test_mem_cache_write_beyond.c
@@ -35,7 +35,8 @@ struct obj {
char name[16];
};
-static void obj_ctor(void *ptr)
+static void
+obj_ctor(void *ptr)
{
struct obj *obj;
@@ -43,7 +44,8 @@ static void obj_ctor(void *ptr)
obj->nr_refs = 0;
}
-static void obj_print(struct obj *obj, size_t size)
+static void
+obj_print(struct obj *obj, size_t size)
{
unsigned char *ptr, *end;
@@ -55,7 +57,8 @@ static void obj_print(struct obj *obj, size_t size)
printf("\n");
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct mem_cache *obj_cache;
struct obj *obj;
diff --git a/test/test_mem_cache_write_buftag.c b/test/test_mem_cache_write_buftag.c
index 1d437f9..539d399 100644
--- a/test/test_mem_cache_write_buftag.c
+++ b/test/test_mem_cache_write_buftag.c
@@ -35,7 +35,8 @@ struct obj {
char name[16];
};
-static void obj_ctor(void *ptr)
+static void
+obj_ctor(void *ptr)
{
struct obj *obj;
@@ -43,7 +44,8 @@ static void obj_ctor(void *ptr)
obj->nr_refs = 0;
}
-static void obj_print(struct obj *obj, size_t size)
+static void
+obj_print(struct obj *obj, size_t size)
{
unsigned char *ptr, *end;
@@ -55,7 +57,8 @@ static void obj_print(struct obj *obj, size_t size)
printf("\n");
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct mem_cache *obj_cache;
struct obj *obj;
diff --git a/test/test_mem_cache_write_free.c b/test/test_mem_cache_write_free.c
index b07fac9..fd1c9db 100644
--- a/test/test_mem_cache_write_free.c
+++ b/test/test_mem_cache_write_free.c
@@ -38,7 +38,8 @@ struct obj {
char name[16];
};
-static void obj_ctor(void *ptr)
+static void
+obj_ctor(void *ptr)
{
struct obj *obj;
@@ -46,7 +47,8 @@ static void obj_ctor(void *ptr)
obj->nr_refs = 0;
}
-static void obj_print(struct obj *obj)
+static void
+obj_print(struct obj *obj)
{
unsigned char *ptr, *end;
@@ -60,7 +62,8 @@ static void obj_print(struct obj *obj)
printf("\n");
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct mem_cache *obj_cache;
struct obj *obj;
diff --git a/test/test_mem_offbyone.c b/test/test_mem_offbyone.c
index 1a2072f..b9e7d75 100644
--- a/test/test_mem_offbyone.c
+++ b/test/test_mem_offbyone.c
@@ -30,7 +30,8 @@
#define BUFSIZE 200
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
char *s;
diff --git a/test/test_phys.c b/test/test_phys.c
index ba6fbe4..d9ad154 100644
--- a/test/test_phys.c
+++ b/test/test_phys.c
@@ -29,7 +29,8 @@
#include "../phys.c"
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct phys_page *page;
diff --git a/test/test_rbtree.c b/test/test_rbtree.c
index e379fb8..840465f 100644
--- a/test/test_rbtree.c
+++ b/test/test_rbtree.c
@@ -39,7 +39,8 @@ struct obj {
int id;
};
-static inline int obj_cmp_lookup(int id, struct rbtree_node *node)
+static inline int
+obj_cmp_lookup(int id, struct rbtree_node *node)
{
struct obj *obj;
@@ -47,7 +48,8 @@ static inline int obj_cmp_lookup(int id, struct rbtree_node *node)
return id - obj->id;
}
-static void print_subtree(struct rbtree_node *node, int level)
+static void
+print_subtree(struct rbtree_node *node, int level)
{
struct obj *obj;
char color;
@@ -68,17 +70,20 @@ static void print_subtree(struct rbtree_node *node, int level)
print_subtree(node->children[RBTREE_LEFT], level + 1);
}
-static void print_tree(struct rbtree *tree)
+static void
+print_tree(struct rbtree *tree)
{
print_subtree(tree->root, 0);
}
-static int get_id(int i)
+static int
+get_id(int i)
{
return hash_int32(i, 6);
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
struct rbtree tree;
struct rbtree_node *node, *tmp;
diff --git a/test/test_rdxtree.c b/test/test_rdxtree.c
index fb3b674..250ce69 100644
--- a/test/test_rdxtree.c
+++ b/test/test_rdxtree.c
@@ -46,7 +46,11 @@ struct obj {
unsigned long id;
};
-static struct obj * obj_create(unsigned long id)
+static void print_subtree(struct rdxtree_node *node, int height, size_t index,
+ size_t level);
+
+static struct obj *
+obj_create(unsigned long id)
{
struct obj *obj;
@@ -56,15 +60,14 @@ static struct obj * obj_create(unsigned long id)
return obj;
}
-static void obj_destroy(struct obj *obj)
+static void
+obj_destroy(struct obj *obj)
{
free(obj);
}
-static void print_subtree(struct rdxtree_node *node, int height, size_t index,
- size_t level);
-
-static void print_value(void *ptr, size_t index, size_t level)
+static void
+print_value(void *ptr, size_t index, size_t level)
{
struct obj *obj;
int i;
@@ -80,7 +83,8 @@ static void print_value(void *ptr, size_t index, size_t level)
printf("%zu:%lu\n", index, obj->id);
}
-static void print_values(struct rdxtree_node *node, size_t index, size_t level)
+static void
+print_values(struct rdxtree_node *node, size_t index, size_t level)
{
size_t i;
@@ -93,8 +97,8 @@ static void print_values(struct rdxtree_node *node, size_t index, size_t level)
print_value(node->slots[i], i, level + 1);
}
-static void print_node(struct rdxtree_node *node, int height, size_t index,
- size_t level)
+static void
+print_node(struct rdxtree_node *node, int height, size_t index, size_t level)
{
size_t i;
@@ -107,8 +111,8 @@ static void print_node(struct rdxtree_node *node, int height, size_t index,
print_subtree(node->slots[i], height - 1, i, level + 1);
}
-static void print_subtree(struct rdxtree_node *node, int height, size_t index,
- size_t level)
+static void
+print_subtree(struct rdxtree_node *node, int height, size_t index, size_t level)
{
if (node == NULL)
return;
@@ -119,7 +123,8 @@ static void print_subtree(struct rdxtree_node *node, int height, size_t index,
print_node(node, height, index, level);
}
-static void print_tree(struct rdxtree *tree)
+static void
+print_tree(struct rdxtree *tree)
{
if (tree->height == 0)
print_value(tree->root, 0, 0);
@@ -127,7 +132,8 @@ static void print_tree(struct rdxtree *tree)
print_subtree(tree->root, tree->height, 0, 0);
}
-static void destroy_tree(struct rdxtree *tree)
+static void
+destroy_tree(struct rdxtree *tree)
{
struct rdxtree_iter iter;
struct obj *obj;
@@ -138,7 +144,8 @@ static void destroy_tree(struct rdxtree *tree)
rdxtree_remove_all(tree);
}
-static void test_1(void)
+static void
+test_1(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -154,7 +161,8 @@ static void test_1(void)
destroy_tree(&tree);
}
-static void test_2(void)
+static void
+test_2(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -170,7 +178,8 @@ static void test_2(void)
destroy_tree(&tree);
}
-static void test_3(void)
+static void
+test_3(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -189,7 +198,8 @@ static void test_3(void)
destroy_tree(&tree);
}
-static void test_4(void)
+static void
+test_4(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -208,7 +218,8 @@ static void test_4(void)
destroy_tree(&tree);
}
-static void test_5(void)
+static void
+test_5(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -227,7 +238,8 @@ static void test_5(void)
destroy_tree(&tree);
}
-static void test_6(void)
+static void
+test_6(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -246,7 +258,8 @@ static void test_6(void)
destroy_tree(&tree);
}
-static void test_7(void)
+static void
+test_7(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -265,7 +278,8 @@ static void test_7(void)
print_tree(&tree);
}
-static void test_8(void)
+static void
+test_8(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -284,7 +298,8 @@ static void test_8(void)
print_tree(&tree);
}
-static void test_9(void)
+static void
+test_9(void)
{
struct rdxtree tree;
struct obj *obj1, *obj2;
@@ -309,7 +324,8 @@ static void test_9(void)
print_tree(&tree);
}
-static void test_10(void)
+static void
+test_10(void)
{
struct rdxtree tree;
struct obj *obj1, *obj2;
@@ -334,7 +350,8 @@ static void test_10(void)
print_tree(&tree);
}
-static void test_11(void)
+static void
+test_11(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -359,7 +376,8 @@ static void test_11(void)
print_tree(&tree);
}
-static void test_12(void)
+static void
+test_12(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -384,7 +402,8 @@ static void test_12(void)
print_tree(&tree);
}
-static void test_13(void)
+static void
+test_13(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -405,7 +424,8 @@ static void test_13(void)
destroy_tree(&tree);
}
-static void test_14(void)
+static void
+test_14(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -429,7 +449,8 @@ static void test_14(void)
destroy_tree(&tree);
}
-static void test_15(void)
+static void
+test_15(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -454,7 +475,8 @@ static void test_15(void)
destroy_tree(&tree);
}
-static void test_16(void)
+static void
+test_16(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -479,7 +501,8 @@ static void test_16(void)
destroy_tree(&tree);
}
-static void test_17(void)
+static void
+test_17(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -516,7 +539,8 @@ static void test_17(void)
destroy_tree(&tree);
}
-static void test_18(void)
+static void
+test_18(void)
{
struct rdxtree tree;
struct obj *obj;
@@ -540,7 +564,8 @@ static void test_18(void)
destroy_tree(&tree);
}
-static void test_19(void)
+static void
+test_19(void)
{
struct rdxtree tree;
struct obj *obj1, *obj2, *tmp;
@@ -565,7 +590,8 @@ static void test_19(void)
destroy_tree(&tree);
}
-static void test_20(void)
+static void
+test_20(void)
{
struct rdxtree tree;
struct obj *obj1, *obj2, *tmp;
@@ -590,7 +616,8 @@ static void test_20(void)
destroy_tree(&tree);
}
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
(void)argc;
(void)argv;
diff --git a/test/test_xprintf.c b/test/test_xprintf.c
index 84a4176..ff157b8 100644
--- a/test/test_xprintf.c
+++ b/test/test_xprintf.c
@@ -43,7 +43,8 @@ MACRO_BEGIN \
assert(strcmp(stra, strb) == 0); \
MACRO_END
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
(void)argc;
(void)argv;
diff --git a/xprintf.c b/xprintf.c
index 384fab4..7efb786 100644
--- a/xprintf.c
+++ b/xprintf.c
@@ -90,7 +90,8 @@ static pthread_mutex_t xprint_mutex = PTHREAD_MUTEX_INITIALIZER;
static const char digits[] = "0123456789ABCDEF";
-static inline char * xputchar(char *str, char *end, char c)
+static inline char *
+xputchar(char *str, char *end, char c)
{
if (str < end)
*str = c;
@@ -100,12 +101,14 @@ static inline char * xputchar(char *str, char *end, char c)
return str;
}
-static inline int xisdigit(char c)
+static inline int
+xisdigit(char c)
{
return (c >= '0') && (c <= '9');
}
-int xprintf(const char *format, ...)
+int
+xprintf(const char *format, ...)
{
va_list ap;
int length;
@@ -117,7 +120,8 @@ int xprintf(const char *format, ...)
return length;
}
-int xvprintf(const char *format, va_list ap)
+int
+xvprintf(const char *format, va_list ap)
{
size_t size;
int length;
@@ -133,7 +137,8 @@ int xvprintf(const char *format, va_list ap)
return length;
}
-int xsprintf(char *str, const char *format, ...)
+int
+xsprintf(char *str, const char *format, ...)
{
va_list ap;
int length;
@@ -145,12 +150,14 @@ int xsprintf(char *str, const char *format, ...)
return length;
}
-int xvsprintf(char *str, const char *format, va_list ap)
+int
+xvsprintf(char *str, const char *format, va_list ap)
{
return xvsnprintf(str, XPRINT_NOLIMIT, format, ap);
}
-int xsnprintf(char *str, size_t size, const char *format, ...)
+int
+xsnprintf(char *str, size_t size, const char *format, ...)
{
va_list ap;
int length;
@@ -162,7 +169,8 @@ int xsnprintf(char *str, size_t size, const char *format, ...)
return length;
}
-int xvsnprintf(char *str, size_t size, const char *format, va_list ap)
+int
+xvsnprintf(char *str, size_t size, const char *format, va_list ap)
{
unsigned long long n;
int i, len, found, flags, width, precision, modifier, specifier, shift;