summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-08-23 21:53:53 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2026-08-23 21:53:53 +0300
commitf36435782e973ca1cf25ad7d7791d61a6b1b83c7 (patch)
tree0679eddffc221bd14668cd111caeab7ba04639f6 /include
parente962c7a4c70b6e2c3f2df89be176c491d62739e7 (diff)
downloadconts-f36435782e973ca1cf25ad7d7791d61a6b1b83c7.tar.gz
conts-f36435782e973ca1cf25ad7d7791d61a6b1b83c7.zip
rename MAP_TYPE
+ Collides with MMAP flags, oops.
Diffstat (limited to 'include')
-rw-r--r--include/conts/map.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/include/conts/map.h b/include/conts/map.h
index 2060658..571eda2 100644
--- a/include/conts/map.h
+++ b/include/conts/map.h
@@ -1,9 +1,9 @@
-#ifndef MAP_KEY
-#error "Need map key"
+#ifndef MAP_KEY_TYPE
+#error "Need map key type"
#endif
-#ifndef MAP_TYPE
-#error "Need map type"
+#ifndef MAP_VALUE_TYPE
+#error "Need map value type"
#endif
#ifndef MAP_CMP
@@ -72,14 +72,14 @@ enum conts_map_state {
#endif /* CONTS_MAP_H */
-static inline size_t MAP(generic_hash)(MAP_KEY *key)
+static inline size_t MAP(generic_hash)(MAP_KEY_TYPE *key)
{
return conts_map_generic_hash((const char *)key, sizeof(*key));
}
struct MAP_TUPLE {
- MAP_KEY key;
- MAP_TYPE data;
+ MAP_KEY_TYPE key;
+ MAP_VALUE_TYPE data;
};
#define MAP_SPVEC(x) CONTS_JOIN(MAP(spvec), x)
@@ -127,7 +127,7 @@ static inline void MAP(destroy)(struct MAP_ROOT *root)
MAP_SPVEC(destroy)(&root->buf);
}
-static inline MAP_TYPE *MAP(find_hash)(struct MAP_ROOT *root, MAP_KEY key, uint32_t hash)
+static inline MAP_VALUE_TYPE *MAP(find_hash)(struct MAP_ROOT *root, MAP_KEY_TYPE key, uint32_t hash)
{
for (size_t s = MAP_SPVEC(len)(&root->buf); s >= conts_spvec_size(0); s /= 2) {
@@ -160,17 +160,17 @@ static inline MAP_TYPE *MAP(find_hash)(struct MAP_ROOT *root, MAP_KEY key, uint3
return NULL;
}
-static inline MAP_TYPE *MAP(find)(struct MAP_ROOT *root, MAP_KEY key)
+static inline MAP_VALUE_TYPE *MAP(find)(struct MAP_ROOT *root, MAP_KEY_TYPE key)
{
uint32_t hash = MAP_HASH(key) & 0x3fffffff;
return MAP(find_hash)(root, key, hash);
}
-static inline MAP_TYPE *MAP(insert)(struct MAP_ROOT *root, MAP_KEY key, MAP_TYPE data)
+static inline MAP_VALUE_TYPE *MAP(insert)(struct MAP_ROOT *root, MAP_KEY_TYPE key, MAP_VALUE_TYPE data)
{
/* mask top bit away to get 31 bit hash value as used by the nodes */
uint32_t hash = MAP_HASH(key) & 0x3fffffff;
- MAP_TYPE *exists = MAP(find_hash)(root, key, hash);
+ MAP_VALUE_TYPE *exists = MAP(find_hash)(root, key, hash);
if (exists)
return exists;
@@ -219,7 +219,7 @@ static inline MAP_TYPE *MAP(insert)(struct MAP_ROOT *root, MAP_KEY key, MAP_TYPE
return NULL;
}
-static inline void MAP(remove_found)(struct MAP_ROOT *root, MAP_TYPE *data)
+static inline void MAP(remove_found)(struct MAP_ROOT *root, MAP_VALUE_TYPE *data)
{
struct MAP_TUPLE *tuple = CONTAINER_OF(data, struct MAP_TUPLE, data);
struct MAP_NODE *node = CONTAINER_OF(tuple, struct MAP_NODE, t);
@@ -227,9 +227,9 @@ static inline void MAP(remove_found)(struct MAP_ROOT *root, MAP_TYPE *data)
root->n--;
}
-static inline void MAP(remove)(struct MAP_ROOT *root, MAP_KEY key)
+static inline void MAP(remove)(struct MAP_ROOT *root, MAP_KEY_TYPE key)
{
- MAP_TYPE *found = MAP(find)(root, key);
+ MAP_VALUE_TYPE *found = MAP(find)(root, key);
if (!found)
return;
@@ -289,8 +289,8 @@ static inline size_t MAP(len)(struct MAP_ROOT *root)
#undef MAP_TUPLE
#undef MAP_BUCKET
#undef MAP_ROOT
-#undef MAP_KEY
-#undef MAP_TYPE
+#undef MAP_KEY_TYPE
+#undef MAP_VALUE_TYPE
#undef MAP_CMP
#undef MAP_HASH
#undef MAP_NAME