summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2018-07-13 14:58:45 -0500
committerGerrit Code Review2018-07-13 14:58:45 -0500
commitdda5fe46ac03fcbb690719f5378e4ed8c0b87153 (patch)
tree806385d2c6aecff56af6e41d0565c7efaf4945c6
parenta8df2b95cb47f09d2270788ac8e97c4010aaeda8 (diff)
parent9d12725cad91a4074f01a5eb66fd2f3e6978f590 (diff)
downloadplatform-system-core-dda5fe46ac03fcbb690719f5378e4ed8c0b87153.tar.gz
platform-system-core-dda5fe46ac03fcbb690719f5378e4ed8c0b87153.tar.xz
platform-system-core-dda5fe46ac03fcbb690719f5378e4ed8c0b87153.zip
Merge "cutils: move hashmap to <pthread.h>."android-p-preview-5
-rw-r--r--libcutils/Android.bp2
-rw-r--r--libcutils/hashmap.cpp12
2 files changed, 7 insertions, 7 deletions
diff --git a/libcutils/Android.bp b/libcutils/Android.bp
index 58e59d6d9..37afb9867 100644
--- a/libcutils/Android.bp
+++ b/libcutils/Android.bp
@@ -20,6 +20,7 @@
20libcutils_nonwindows_sources = [ 20libcutils_nonwindows_sources = [
21 "android_get_control_file.cpp", 21 "android_get_control_file.cpp",
22 "fs.cpp", 22 "fs.cpp",
23 "hashmap.cpp",
23 "multiuser.cpp", 24 "multiuser.cpp",
24 "socket_inaddr_any_server_unix.cpp", 25 "socket_inaddr_any_server_unix.cpp",
25 "socket_local_client_unix.cpp", 26 "socket_local_client_unix.cpp",
@@ -61,7 +62,6 @@ cc_library {
61 "config_utils.cpp", 62 "config_utils.cpp",
62 "fs_config.cpp", 63 "fs_config.cpp",
63 "canned_fs_config.cpp", 64 "canned_fs_config.cpp",
64 "hashmap.cpp",
65 "iosched_policy.cpp", 65 "iosched_policy.cpp",
66 "load_file.cpp", 66 "load_file.cpp",
67 "native_handle.cpp", 67 "native_handle.cpp",
diff --git a/libcutils/hashmap.cpp b/libcutils/hashmap.cpp
index 2a4a52e1a..57d60067c 100644
--- a/libcutils/hashmap.cpp
+++ b/libcutils/hashmap.cpp
@@ -18,7 +18,7 @@
18 18
19#include <assert.h> 19#include <assert.h>
20#include <errno.h> 20#include <errno.h>
21#include <cutils/threads.h> 21#include <pthread.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24#include <sys/types.h> 24#include <sys/types.h>
@@ -36,7 +36,7 @@ struct Hashmap {
36 size_t bucketCount; 36 size_t bucketCount;
37 int (*hash)(void* key); 37 int (*hash)(void* key);
38 bool (*equals)(void* keyA, void* keyB); 38 bool (*equals)(void* keyA, void* keyB);
39 mutex_t lock; 39 pthread_mutex_t lock;
40 size_t size; 40 size_t size;
41}; 41};
42 42
@@ -69,7 +69,7 @@ Hashmap* hashmapCreate(size_t initialCapacity,
69 map->hash = hash; 69 map->hash = hash;
70 map->equals = equals; 70 map->equals = equals;
71 71
72 mutex_init(&map->lock); 72 pthread_mutex_init(&map->lock, nullptr);
73 73
74 return map; 74 return map;
75} 75}
@@ -129,11 +129,11 @@ static void expandIfNecessary(Hashmap* map) {
129} 129}
130 130
131void hashmapLock(Hashmap* map) { 131void hashmapLock(Hashmap* map) {
132 mutex_lock(&map->lock); 132 pthread_mutex_lock(&map->lock);
133} 133}
134 134
135void hashmapUnlock(Hashmap* map) { 135void hashmapUnlock(Hashmap* map) {
136 mutex_unlock(&map->lock); 136 pthread_mutex_unlock(&map->lock);
137} 137}
138 138
139void hashmapFree(Hashmap* map) { 139void hashmapFree(Hashmap* map) {
@@ -147,7 +147,7 @@ void hashmapFree(Hashmap* map) {
147 } 147 }
148 } 148 }
149 free(map->buckets); 149 free(map->buckets);
150 mutex_destroy(&map->lock); 150 pthread_mutex_destroy(&map->lock);
151 free(map); 151 free(map);
152} 152}
153 153