summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2018-07-13 11:13:42 -0700
committer Elliott Hughes <enh@google.com> 2018-07-13 11:13:42 -0700
commit5bf516f8b7ac0721cb2e68d11ff123a16c97d5e4 (patch)
treed799f6fbfe9a0fe0edd69113379439b23baefd27
parent8b8ce408fb1d6183dbe1aa1ffa560a7fce17ba18 (diff)
libbinder: move to <pthread.h> mutexes.
Bug: N/A Test: builds Change-Id: Ia3a3719c7d66b6cbd2f3aaa18cff4ca11967f34b
-rw-r--r--libs/binder/BufferedTextOutput.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/libs/binder/BufferedTextOutput.cpp b/libs/binder/BufferedTextOutput.cpp
index 0946aca876..d516eb1d54 100644
--- a/libs/binder/BufferedTextOutput.cpp
+++ b/libs/binder/BufferedTextOutput.cpp
@@ -25,6 +25,7 @@
#include <private/binder/Static.h>
+#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
@@ -87,7 +88,7 @@ struct BufferedTextOutput::ThreadState
Vector<sp<BufferedTextOutput::BufferState> > states;
};
-static mutex_t gMutex;
+static pthread_mutex_t gMutex = PTHREAD_MUTEX_INITIALIZER;
static thread_store_t tls;
@@ -113,7 +114,7 @@ static int32_t allocBufferIndex()
{
int32_t res = -1;
- mutex_lock(&gMutex);
+ pthread_mutex_lock(&gMutex);
if (gFreeBufferIndex >= 0) {
res = gFreeBufferIndex;
@@ -125,17 +126,17 @@ static int32_t allocBufferIndex()
gTextBuffers.add(-1);
}
- mutex_unlock(&gMutex);
+ pthread_mutex_unlock(&gMutex);
return res;
}
static void freeBufferIndex(int32_t idx)
{
- mutex_lock(&gMutex);
+ pthread_mutex_lock(&gMutex);
gTextBuffers.editItemAt(idx) = gFreeBufferIndex;
gFreeBufferIndex = idx;
- mutex_unlock(&gMutex);
+ pthread_mutex_unlock(&gMutex);
}
// ---------------------------------------------------------------------------