diff options
Diffstat (limited to 'libs/binder/IPCThreadState.cpp')
-rw-r--r-- | libs/binder/IPCThreadState.cpp | 66 |
1 files changed, 24 insertions, 42 deletions
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index dd04dcf..9f68aa8 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -29,21 +29,14 @@ #include <private/binder/binder_module.h> #include <private/binder/Static.h> -#include <sys/ioctl.h> -#include <signal.h> #include <errno.h> -#include <stdio.h> -#include <unistd.h> - -#ifdef HAVE_PTHREADS #include <pthread.h> #include <sched.h> +#include <signal.h> +#include <stdio.h> +#include <sys/ioctl.h> #include <sys/resource.h> -#endif -#ifdef HAVE_WIN32_THREADS -#include <windows.h> -#endif - +#include <unistd.h> #if LOG_NDEBUG @@ -70,13 +63,11 @@ namespace android { static const char* getReturnString(size_t idx); -static const char* getCommandString(size_t idx); static const void* printReturnCommand(TextOutput& out, const void* _cmd); static const void* printCommand(TextOutput& out, const void* _cmd); -// This will result in a missing symbol failure if the IF_LOG_COMMANDS() -// conditionals don't get stripped... but that is probably what we want. -#if !LOG_NDEBUG +// Static const and functions will be optimized out if not used, +// when LOG_NDEBUG and references in IF_LOG_COMMANDS() are optimized out. static const char *kReturnStrings[] = { "BR_ERROR", "BR_OK", @@ -126,14 +117,6 @@ static const char* getReturnString(size_t idx) return "unknown"; } -static const char* getCommandString(size_t idx) -{ - if (idx < sizeof(kCommandStrings) / sizeof(kCommandStrings[0])) - return kCommandStrings[idx]; - else - return "unknown"; -} - static const void* printBinderTransactionData(TextOutput& out, const void* data) { const binder_transaction_data* btd = @@ -145,7 +128,7 @@ static const void* printBinderTransactionData(TextOutput& out, const void* data) out << "target.ptr=" << btd->target.ptr; } out << " (cookie " << btd->cookie << ")" << endl - << "code=" << TypeCode(btd->code) << ", flags=" << (void*)btd->flags << endl + << "code=" << TypeCode(btd->code) << ", flags=" << (void*)(long)btd->flags << endl << "data=" << btd->data.ptr.buffer << " (" << (void*)btd->data_size << " bytes)" << endl << "offsets=" << btd->data.ptr.offsets << " (" << (void*)btd->offsets_size @@ -157,10 +140,10 @@ static const void* printReturnCommand(TextOutput& out, const void* _cmd) { static const size_t N = sizeof(kReturnStrings)/sizeof(kReturnStrings[0]); const int32_t* cmd = (const int32_t*)_cmd; - int32_t code = *cmd++; + uint32_t code = (uint32_t)*cmd++; size_t cmdIndex = code & 0xff; - if (code == (int32_t) BR_ERROR) { - out << "BR_ERROR: " << (void*)(*cmd++) << endl; + if (code == BR_ERROR) { + out << "BR_ERROR: " << (void*)(long)(*cmd++) << endl; return cmd; } else if (cmdIndex >= N) { out << "Unknown reply: " << code << endl; @@ -187,21 +170,21 @@ static const void* printReturnCommand(TextOutput& out, const void* _cmd) case BR_DECREFS: { const int32_t b = *cmd++; const int32_t c = *cmd++; - out << ": target=" << (void*)b << " (cookie " << (void*)c << ")"; + out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << ")"; } break; case BR_ATTEMPT_ACQUIRE: { const int32_t p = *cmd++; const int32_t b = *cmd++; const int32_t c = *cmd++; - out << ": target=" << (void*)b << " (cookie " << (void*)c + out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << "), pri=" << p; } break; case BR_DEAD_BINDER: case BR_CLEAR_DEATH_NOTIFICATION_DONE: { const int32_t c = *cmd++; - out << ": death cookie " << (void*)c; + out << ": death cookie " << (void*)(long)c; } break; default: @@ -218,7 +201,7 @@ static const void* printCommand(TextOutput& out, const void* _cmd) { static const size_t N = sizeof(kCommandStrings)/sizeof(kCommandStrings[0]); const int32_t* cmd = (const int32_t*)_cmd; - int32_t code = *cmd++; + uint32_t code = (uint32_t)*cmd++; size_t cmdIndex = code & 0xff; if (cmdIndex >= N) { @@ -242,7 +225,7 @@ static const void* printCommand(TextOutput& out, const void* _cmd) case BC_FREE_BUFFER: { const int32_t buf = *cmd++; - out << ": buffer=" << (void*)buf; + out << ": buffer=" << (void*)(long)buf; } break; case BC_INCREFS: @@ -257,7 +240,7 @@ static const void* printCommand(TextOutput& out, const void* _cmd) case BC_ACQUIRE_DONE: { const int32_t b = *cmd++; const int32_t c = *cmd++; - out << ": target=" << (void*)b << " (cookie " << (void*)c << ")"; + out << ": target=" << (void*)(long)b << " (cookie " << (void*)(long)c << ")"; } break; case BC_ATTEMPT_ACQUIRE: { @@ -270,12 +253,12 @@ static const void* printCommand(TextOutput& out, const void* _cmd) case BC_CLEAR_DEATH_NOTIFICATION: { const int32_t h = *cmd++; const int32_t c = *cmd++; - out << ": handle=" << h << " (death cookie " << (void*)c << ")"; + out << ": handle=" << h << " (death cookie " << (void*)(long)c << ")"; } break; case BC_DEAD_BINDER_DONE: { const int32_t c = *cmd++; - out << ": death cookie " << (void*)c; + out << ": death cookie " << (void*)(long)c; } break; default: @@ -287,7 +270,6 @@ static const void* printCommand(TextOutput& out, const void* _cmd) out << endl; return cmd; } -#endif static pthread_mutex_t gTLSMutex = PTHREAD_MUTEX_INITIALIZER; static bool gHaveTLS = false; @@ -361,12 +343,12 @@ status_t IPCThreadState::clearLastError() return err; } -int IPCThreadState::getCallingPid() const +pid_t IPCThreadState::getCallingPid() const { return mCallingPid; } -int IPCThreadState::getCallingUid() const +uid_t IPCThreadState::getCallingUid() const { return mCallingUid; } @@ -682,7 +664,7 @@ status_t IPCThreadState::clearDeathNotification(int32_t handle, BpBinder* proxy) IPCThreadState::IPCThreadState() : mProcess(ProcessState::self()), - mMyThreadId(androidGetTid()), + mMyThreadId(gettid()), mStrictModePolicy(0), mLastTransactionBinderFlags(0) { @@ -708,7 +690,7 @@ status_t IPCThreadState::sendReply(const Parcel& reply, uint32_t flags) status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult) { - int32_t cmd; + uint32_t cmd; int32_t err; while (1) { @@ -717,7 +699,7 @@ status_t IPCThreadState::waitForResponse(Parcel *reply, status_t *acquireResult) if (err < NO_ERROR) break; if (mIn.dataAvail() == 0) continue; - cmd = mIn.readInt32(); + cmd = (uint32_t)mIn.readInt32(); IF_LOG_COMMANDS() { alog << "Processing waitForResponse Command: " @@ -947,7 +929,7 @@ status_t IPCThreadState::executeCommand(int32_t cmd) RefBase::weakref_type* refs; status_t result = NO_ERROR; - switch (cmd) { + switch ((uint32_t)cmd) { case BR_ERROR: result = mIn.readInt32(); break; |