summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmds/installd/commands.c2
-rw-r--r--include/binder/Binder.h4
-rw-r--r--libs/binder/Binder.cpp32
-rw-r--r--libs/binder/IPCThreadState.cpp2
-rw-r--r--opengl/libs/GLES2/gl2.cpp2
5 files changed, 24 insertions, 18 deletions
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index edb21bc..fd1d5bd 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -656,7 +656,7 @@ static void run_patchoat(int input_fd, int oat_fd, const char* input_file_name,
sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
sprintf(output_oat_fd_arg, "--output-oat-fd=%d", oat_fd);
sprintf(input_oat_fd_arg, "--input-oat-fd=%d", input_fd);
- ALOGE("Running %s isa=%s in-fd=%d (%s) out-fd=%d (%s)\n",
+ ALOGV("Running %s isa=%s in-fd=%d (%s) out-fd=%d (%s)\n",
PATCHOAT_BIN, instruction_set, input_fd, input_file_name, oat_fd, output_file_name);
/* patchoat, patched-image-location, no-lock, isa, input-fd, output-fd */
diff --git a/include/binder/Binder.h b/include/binder/Binder.h
index ba3ac4b..86628a0 100644
--- a/include/binder/Binder.h
+++ b/include/binder/Binder.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_BINDER_H
#define ANDROID_BINDER_H
+#include <stdatomic.h>
+#include <stdint.h>
#include <binder/IBinder.h>
// ---------------------------------------------------------------------------
@@ -69,7 +71,7 @@ private:
class Extras;
- Extras* mExtras;
+ atomic_uintptr_t mExtras; // should be atomic<Extras *>
void* mReserved0;
};
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index 71e62ab..2554351 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -16,7 +16,7 @@
#include <binder/Binder.h>
-#include <utils/Atomic.h>
+#include <stdatomic.h>
#include <utils/misc.h>
#include <binder/BpBinder.h>
#include <binder/IInterface.h>
@@ -71,8 +71,8 @@ public:
// ---------------------------------------------------------------------------
BBinder::BBinder()
- : mExtras(NULL)
{
+ atomic_init(&mExtras, 0);
}
bool BBinder::isBinderAlive() const
@@ -139,19 +139,19 @@ void BBinder::attachObject(
const void* objectID, void* object, void* cleanupCookie,
object_cleanup_func func)
{
- Extras* e = mExtras;
+ Extras* e = reinterpret_cast<Extras*>(
+ atomic_load_explicit(&mExtras, memory_order_acquire));
if (!e) {
e = new Extras;
-#ifdef __LP64__
- if (android_atomic_release_cas64(0, reinterpret_cast<int64_t>(e),
- reinterpret_cast<volatile int64_t*>(&mExtras)) != 0) {
-#else
- if (android_atomic_cmpxchg(0, reinterpret_cast<int32_t>(e),
- reinterpret_cast<volatile int32_t*>(&mExtras)) != 0) {
-#endif
+ uintptr_t expected = 0;
+ if (!atomic_compare_exchange_strong_explicit(
+ &mExtras, &expected,
+ reinterpret_cast<uintptr_t>(e),
+ memory_order_release,
+ memory_order_acquire)) {
delete e;
- e = mExtras;
+ e = reinterpret_cast<Extras*>(expected); // Filled in by CAS
}
if (e == 0) return; // out of memory
}
@@ -162,7 +162,8 @@ void BBinder::attachObject(
void* BBinder::findObject(const void* objectID) const
{
- Extras* e = mExtras;
+ Extras* e = reinterpret_cast<Extras*>(
+ atomic_load_explicit(&mExtras, memory_order_acquire));
if (!e) return NULL;
AutoMutex _l(e->mLock);
@@ -171,7 +172,8 @@ void* BBinder::findObject(const void* objectID) const
void BBinder::detachObject(const void* objectID)
{
- Extras* e = mExtras;
+ Extras* e = reinterpret_cast<Extras*>(
+ atomic_load_explicit(&mExtras, memory_order_acquire));
if (!e) return;
AutoMutex _l(e->mLock);
@@ -185,7 +187,9 @@ BBinder* BBinder::localBinder()
BBinder::~BBinder()
{
- if (mExtras) delete mExtras;
+ Extras* e = reinterpret_cast<Extras*>(
+ atomic_load_explicit(&mExtras, memory_order_relaxed));
+ if (e) delete e;
}
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 57c4638..ae8f648 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -682,7 +682,7 @@ status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy)
IPCThreadState::IPCThreadState()
: mProcess(ProcessState::self()),
- mMyThreadId(androidGetTid()),
+ mMyThreadId(gettid()),
mStrictModePolicy(0),
mLastTransactionBinderFlags(0)
{
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp
index b07228f..0157bfe 100644
--- a/opengl/libs/GLES2/gl2.cpp
+++ b/opengl/libs/GLES2/gl2.cpp
@@ -180,7 +180,7 @@ const GLubyte * glGetString(GLenum name)
const GLubyte * ret = egl_get_string_for_current_context(name);
if (ret == NULL) {
gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl;
- ret = _c->glGetString(name);
+ if(_c) ret = _c->glGetString(name);
}
return ret;
}