chiark / gitweb /
Prep v221: Update and clean up build system to sync with upstream
[elogind.git] / src / basic / hashmap.c
similarity index 99%
rename from src/shared/hashmap.c
rename to src/basic/hashmap.c
index e5f05f36f8fb93daf02b744d0cf5791f7ee1a9cc..55e198960b03e8a76197e01b50bd162a0013f99f 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <stdlib.h>
 #include <errno.h>
+#include <pthread.h>
 
 #include "util.h"
 #include "hashmap.h"
@@ -157,6 +158,7 @@ struct hashmap_debug_info {
 
 /* Tracks all existing hashmaps. Get at it from gdb. See sd_dump_hashmaps.py */
 static LIST_HEAD(struct hashmap_debug_info, hashmap_debug_list);
+static pthread_mutex_t hashmap_debug_list_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 #define HASHMAP_DEBUG_FIELDS struct hashmap_debug_info debug;
 
@@ -806,10 +808,12 @@ static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enu
         }
 
 #ifdef ENABLE_DEBUG_HASHMAP
-        LIST_PREPEND(debug_list, hashmap_debug_list, &h->debug);
         h->debug.func = func;
         h->debug.file = file;
         h->debug.line = line;
+        assert_se(pthread_mutex_lock(&hashmap_debug_list_mutex) == 0);
+        LIST_PREPEND(debug_list, hashmap_debug_list, &h->debug);
+        assert_se(pthread_mutex_unlock(&hashmap_debug_list_mutex) == 0);
 #endif
 
         return h;
@@ -861,7 +865,9 @@ static void hashmap_free_no_clear(HashmapBase *h) {
         assert(!h->n_direct_entries);
 
 #ifdef ENABLE_DEBUG_HASHMAP
+        assert_se(pthread_mutex_lock(&hashmap_debug_list_mutex) == 0);
         LIST_REMOVE(debug_list, hashmap_debug_list, &h->debug);
+        assert_se(pthread_mutex_unlock(&hashmap_debug_list_mutex) == 0);
 #endif
 
         if (h->from_pool)
@@ -1794,6 +1800,8 @@ char **internal_hashmap_get_strv(HashmapBase *h) {
         return sv;
 }
 
+/// UNNEEDED by elogind
+#if 0
 void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
         struct ordered_hashmap_entry *e;
         unsigned hash, idx;
@@ -1811,7 +1819,7 @@ void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
                 return NULL;
         return ordered_bucket_at(h, e->iterate_next)->p.value;
 }
-
+#endif // 0
 int set_consume(Set *s, void *value) {
         int r;
 
@@ -1840,6 +1848,8 @@ int set_put_strdup(Set *s, const char *p) {
         return r;
 }
 
+/// UNNEEDED by elogind
+#if 0
 int set_put_strdupv(Set *s, char **l) {
         int n = 0, r;
         char **i;
@@ -1854,3 +1864,4 @@ int set_put_strdupv(Set *s, char **l) {
 
         return n;
 }
+#endif // 0