aboutsummaryrefslogtreecommitdiffstats
path: root/vppinfra/vppinfra/bihash_template.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-08-15 11:12:27 -0400
committerDave Barach <dave@barachs.net>2016-08-15 11:12:40 -0400
commitc379999665febd12ec55bfb3a7545224f2b39d3d (patch)
tree8bf0c11e52c2162e1239b6c3f4a5f74b62a07409 /vppinfra/vppinfra/bihash_template.h
parentb3d93dacfde8ab21bbce171fff2971b2ed7bce6a (diff)
VPP-327 Coding standards cleanup for vppinfra
Fix additional a few additional deviations reported elsewhere by checkstyle Change-Id: I026a8ae1c5b1856bbe3c4a555e1b690e7501b045 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vppinfra/vppinfra/bihash_template.h')
-rw-r--r--vppinfra/vppinfra/bihash_template.h155
1 files changed, 83 insertions, 72 deletions
diff --git a/vppinfra/vppinfra/bihash_template.h b/vppinfra/vppinfra/bihash_template.h
index 5f80e7af044..07c3e7daec7 100644
--- a/vppinfra/vppinfra/bihash_template.h
+++ b/vppinfra/vppinfra/bihash_template.h
@@ -16,7 +16,7 @@
/** @if DOCUMENTATION_IS_IN_BIHASH_DOC_H */
-/*
+/*
* Note: to instantiate the template multiple times in a single file,
* #undef __included_bihash_template_h__...
*/
@@ -39,22 +39,27 @@
#define __bvt(a,b) _bvt(a,b)
#define BVT(a) __bvt(a,BIHASH_TYPE)
-typedef struct BV(clib_bihash_value) {
- union {
- BVT(clib_bihash_kv) kvp[BIHASH_KVP_PER_PAGE];
- struct BV(clib_bihash_value) * next_free;
+typedef struct BV (clib_bihash_value)
+{
+ union
+ {
+ BVT (clib_bihash_kv) kvp[BIHASH_KVP_PER_PAGE];
+ struct BV (clib_bihash_value) * next_free;
};
-} BVT(clib_bihash_value);
+} BVT (clib_bihash_value);
-/*
+/*
* This is shared across all uses of the template, so it needs
* a "personal" #include recursion block
*/
#ifndef __defined_clib_bihash_bucket_t__
#define __defined_clib_bihash_bucket_t__
-typedef struct {
- union {
- struct {
+typedef struct
+{
+ union
+ {
+ struct
+ {
u32 offset;
u8 pad[3];
u8 log2_pages;
@@ -64,78 +69,77 @@ typedef struct {
} clib_bihash_bucket_t;
#endif /* __defined_clib_bihash_bucket_t__ */
-typedef struct {
- BVT(clib_bihash_value) * values;
- clib_bihash_bucket_t * buckets;
- volatile u32 * writer_lock;
+typedef struct
+{
+ BVT (clib_bihash_value) * values;
+ clib_bihash_bucket_t *buckets;
+ volatile u32 *writer_lock;
- BVT(clib_bihash_value) ** working_copies;
+ BVT (clib_bihash_value) ** working_copies;
clib_bihash_bucket_t saved_bucket;
u32 nbuckets;
u32 log2_nbuckets;
- u8 * name;
+ u8 *name;
- BVT(clib_bihash_value) **freelists;
- void * mheap;
+ BVT (clib_bihash_value) ** freelists;
+ void *mheap;
-} BVT(clib_bihash);
+} BVT (clib_bihash);
-static inline void *
-BV(clib_bihash_get_value) (BVT(clib_bihash) * h, uword offset)
+static inline void *BV (clib_bihash_get_value) (BVT (clib_bihash) * h,
+ uword offset)
{
- u8 * hp = h->mheap;
- u8 * vp = hp + offset;
+ u8 *hp = h->mheap;
+ u8 *vp = hp + offset;
return (void *) vp;
}
-static inline uword BV(clib_bihash_get_offset) (BVT(clib_bihash) * h, void * v)
+static inline uword BV (clib_bihash_get_offset) (BVT (clib_bihash) * h,
+ void *v)
{
- u8 * hp, * vp;
+ u8 *hp, *vp;
hp = (u8 *) h->mheap;
vp = (u8 *) v;
- ASSERT((vp - hp) < 0x100000000ULL);
+ ASSERT ((vp - hp) < 0x100000000ULL);
return vp - hp;
}
-void BV(clib_bihash_init)
- (BVT(clib_bihash) * h, char * name, u32 nbuckets, uword memory_size);
+void BV (clib_bihash_init)
+ (BVT (clib_bihash) * h, char *name, u32 nbuckets, uword memory_size);
-void BV(clib_bihash_free)
- (BVT(clib_bihash) * h);
+void BV (clib_bihash_free) (BVT (clib_bihash) * h);
-int BV(clib_bihash_add_del) (BVT(clib_bihash) * h,
- BVT(clib_bihash_kv) * add_v,
- int is_add);
-int BV(clib_bihash_search) (BVT(clib_bihash) * h,
- BVT(clib_bihash_kv) * search_v,
- BVT(clib_bihash_kv) * return_v);
+int BV (clib_bihash_add_del) (BVT (clib_bihash) * h,
+ BVT (clib_bihash_kv) * add_v, int is_add);
+int BV (clib_bihash_search) (BVT (clib_bihash) * h,
+ BVT (clib_bihash_kv) * search_v,
+ BVT (clib_bihash_kv) * return_v);
-void BV(clib_bihash_foreach_key_value_pair) (BVT(clib_bihash) * h,
- void *callback,
- void *arg);
+void BV (clib_bihash_foreach_key_value_pair) (BVT (clib_bihash) * h,
+ void *callback, void *arg);
-format_function_t BV(format_bihash);
-format_function_t BV(format_bihash_kvp);
+format_function_t BV (format_bihash);
+format_function_t BV (format_bihash_kvp);
-static inline int BV(clib_bihash_search_inline)
- (BVT(clib_bihash) * h, BVT(clib_bihash_kv) * kvp)
+static inline int BV (clib_bihash_search_inline)
+ (BVT (clib_bihash) * h, BVT (clib_bihash_kv) * kvp)
{
u64 hash;
u32 bucket_index;
uword value_index;
- BVT(clib_bihash_value) * v;
- clib_bihash_bucket_t * b;
+ BVT (clib_bihash_value) * v;
+ clib_bihash_bucket_t *b;
int i;
- hash = BV(clib_bihash_hash) (kvp);
+ hash = BV (clib_bihash_hash) (kvp);
- bucket_index = hash & (h->nbuckets-1);
+ bucket_index = hash & (h->nbuckets - 1);
b = &h->buckets[bucket_index];
if (b->offset == 0)
@@ -143,38 +147,37 @@ static inline int BV(clib_bihash_search_inline)
hash >>= h->log2_nbuckets;
- v = BV(clib_bihash_get_value) (h, b->offset);
- value_index = hash & ((1<<b->log2_pages)-1);
+ v = BV (clib_bihash_get_value) (h, b->offset);
+ value_index = hash & ((1 << b->log2_pages) - 1);
v += value_index;
-
+
for (i = 0; i < BIHASH_KVP_PER_PAGE; i++)
{
- if (BV(clib_bihash_key_compare)(v->kvp[i].key, kvp->key))
- {
- *kvp = v->kvp[i];
- return 0;
- }
+ if (BV (clib_bihash_key_compare) (v->kvp[i].key, kvp->key))
+ {
+ *kvp = v->kvp[i];
+ return 0;
+ }
}
return -1;
}
-static inline int BV(clib_bihash_search_inline_2)
- (BVT(clib_bihash) * h,
- BVT(clib_bihash_kv) *search_key,
- BVT(clib_bihash_kv) *valuep)
+static inline int BV (clib_bihash_search_inline_2)
+ (BVT (clib_bihash) * h,
+ BVT (clib_bihash_kv) * search_key, BVT (clib_bihash_kv) * valuep)
{
u64 hash;
u32 bucket_index;
uword value_index;
- BVT(clib_bihash_value) * v;
- clib_bihash_bucket_t * b;
+ BVT (clib_bihash_value) * v;
+ clib_bihash_bucket_t *b;
int i;
- ASSERT(valuep);
+ ASSERT (valuep);
- hash = BV(clib_bihash_hash) (search_key);
+ hash = BV (clib_bihash_hash) (search_key);
- bucket_index = hash & (h->nbuckets-1);
+ bucket_index = hash & (h->nbuckets - 1);
b = &h->buckets[bucket_index];
if (b->offset == 0)
@@ -182,17 +185,17 @@ static inline int BV(clib_bihash_search_inline_2)
hash >>= h->log2_nbuckets;
- v = BV(clib_bihash_get_value) (h, b->offset);
- value_index = hash & ((1<<b->log2_pages)-1);
+ v = BV (clib_bihash_get_value) (h, b->offset);
+ value_index = hash & ((1 << b->log2_pages) - 1);
v += value_index;
-
+
for (i = 0; i < BIHASH_KVP_PER_PAGE; i++)
{
- if (BV(clib_bihash_key_compare)(v->kvp[i].key, search_key->key))
- {
- *valuep = v->kvp[i];
- return 0;
- }
+ if (BV (clib_bihash_key_compare) (v->kvp[i].key, search_key->key))
+ {
+ *valuep = v->kvp[i];
+ return 0;
+ }
}
return -1;
}
@@ -201,3 +204,11 @@ static inline int BV(clib_bihash_search_inline_2)
#endif /* __included_bihash_template_h__ */
/** @endif */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */