summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2011-11-16 03:33:00 +0059
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-07-10 20:08:05 +0100
commit531ea6d1139f46910b09cdd76e8f0fb8d450fe2a (patch)
tree8b8db21e5cdb7c7aa84d1b7ba33af51293a22c30
parentb6accc69d0faafed89513b9669a8788b652e9e95 (diff)
downloadandroid_dalvik-531ea6d1139f46910b09cdd76e8f0fb8d450fe2a.tar.gz
android_dalvik-531ea6d1139f46910b09cdd76e8f0fb8d450fe2a.tar.bz2
android_dalvik-531ea6d1139f46910b09cdd76e8f0fb8d450fe2a.zip
dalvik: Fix various compile failures with gcc 4.6
This fixes numerous compile errors with gcc 4.6, and combinations of -DNDEBUG, -DLOG_NDEBUG resulting in variables being defined but not used - resulting in a compiler warning (or build breakage with -Werror). Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> dalvik: Fix aliasing violation Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> dalvik/libdex: Change to -O2 if we're building with -O3 This is a workaround for an apparent gcc bug. https://bugs.launchpad.net/linaro-android/+bug/948255 Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> dalvik: Fix build with ISO C++11 Fixes some confusion between jchar and the new char16_t Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r--libdex/Android.mk4
-rw-r--r--libdex/sha1.cpp4
-rw-r--r--vm/Init.cpp14
-rw-r--r--vm/LinearAlloc.cpp6
-rw-r--r--vm/StdioConverter.cpp6
-rw-r--r--vm/Sync.cpp6
-rw-r--r--vm/Thread.cpp12
-rw-r--r--vm/analysis/CodeVerify.cpp5
-rw-r--r--vm/analysis/DexPrepare.cpp4
-rw-r--r--vm/analysis/VfyBasicBlock.cpp5
-rw-r--r--vm/compiler/Compiler.cpp6
-rw-r--r--vm/compiler/codegen/arm/CodegenDriver.cpp6
-rw-r--r--vm/hprof/HprofClass.cpp4
-rw-r--r--vm/interp/Interp.cpp16
-rw-r--r--vm/jdwp/JdwpAdb.cpp4
-rw-r--r--vm/jdwp/JdwpHandler.cpp14
-rw-r--r--vm/jdwp/JdwpSocket.cpp4
-rw-r--r--vm/reflect/Annotation.cpp8
18 files changed, 115 insertions, 13 deletions
diff --git a/libdex/Android.mk b/libdex/Android.mk
index ad85ea7ea..adae003a8 100644
--- a/libdex/Android.mk
+++ b/libdex/Android.mk
@@ -48,6 +48,10 @@ ifneq ($(SDK_ONLY),true) # SDK_only doesn't need device version
include $(CLEAR_VARS)
#LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1
+ifneq ($(findstring -O3, $(TARGET_GLOBAL_CFLAGS)),)
+# Workaround for https://bugs.launchpad.net/linaro-android/+bug/948255
+LOCAL_CFLAGS += -O2
+endif
LOCAL_SRC_FILES := $(dex_src_files)
LOCAL_C_INCLUDES += $(dex_include_files)
LOCAL_MODULE_TAGS := optional
diff --git a/libdex/sha1.cpp b/libdex/sha1.cpp
index 15a81cca3..aefa2222e 100644
--- a/libdex/sha1.cpp
+++ b/libdex/sha1.cpp
@@ -142,8 +142,8 @@ union CHAR64LONG16 {
};
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
-static unsigned char workspace[64];
- block = (CHAR64LONG16*)workspace;
+static CHAR64LONG16 workspace;
+ block = &workspace;
memcpy(block, buffer, 64);
#else
block = (CHAR64LONG16*)buffer;
diff --git a/vm/Init.cpp b/vm/Init.cpp
index 48cc6c1c5..7254af9f2 100644
--- a/vm/Init.cpp
+++ b/vm/Init.cpp
@@ -1165,6 +1165,12 @@ static void blockSignals()
cc = sigaction(SIGBUS, &sa, NULL);
assert(cc == 0);
}
+#ifdef NDEBUG
+ // assert() is defined to nothing - resulting in
+ // cc: variable defined but not used (which breaks
+ // the build if -Werror is on)
+ (void)cc;
+#endif
}
class ScopedShutdown {
@@ -1465,10 +1471,12 @@ static bool initZygote()
*/
bool dvmInitAfterZygote()
{
+#ifndef LOG_NDEBUG
u8 startHeap, startQuit, startJdwp;
u8 endHeap, endQuit, endJdwp;
startHeap = dvmGetRelativeTimeUsec();
+#endif
/*
* Post-zygote heap initialization, including starting
@@ -1477,8 +1485,10 @@ bool dvmInitAfterZygote()
if (!dvmGcStartupAfterZygote())
return false;
+#ifndef LOG_NDEBUG
endHeap = dvmGetRelativeTimeUsec();
startQuit = dvmGetRelativeTimeUsec();
+#endif
/* start signal catcher thread that dumps stacks on SIGQUIT */
if (!gDvm.reduceSignals && !gDvm.noQuitHandler) {
@@ -1492,8 +1502,10 @@ bool dvmInitAfterZygote()
return false;
}
+#ifndef LOG_NDEBUG
endQuit = dvmGetRelativeTimeUsec();
startJdwp = dvmGetRelativeTimeUsec();
+#endif
/*
* Start JDWP thread. If the command-line debugger flags specified
@@ -1504,7 +1516,9 @@ bool dvmInitAfterZygote()
ALOGD("JDWP init failed; continuing anyway");
}
+#ifndef LOG_NDEBUG
endJdwp = dvmGetRelativeTimeUsec();
+#endif
ALOGV("thread-start heap=%d quit=%d jdwp=%d total=%d usec",
(int)(endHeap-startHeap), (int)(endQuit-startQuit),
diff --git a/vm/LinearAlloc.cpp b/vm/LinearAlloc.cpp
index 359893f64..213ba3cf2 100644
--- a/vm/LinearAlloc.cpp
+++ b/vm/LinearAlloc.cpp
@@ -524,6 +524,12 @@ static void updatePages(Object* classLoader, void* mem, int direction)
}
dvmUnlockMutex(&pHdr->lock);
+#ifdef NDEBUG
+ // cc is used only in assert() statements -> not used
+ // in NDEBUG mode -> variable defined but not used
+ // warning (or error with -Werror)
+ (void)cc;
+#endif
}
/*
diff --git a/vm/StdioConverter.cpp b/vm/StdioConverter.cpp
index f420c4d13..d261687a8 100644
--- a/vm/StdioConverter.cpp
+++ b/vm/StdioConverter.cpp
@@ -196,6 +196,12 @@ static void* stdioConverterThreadStart(void* arg)
/* change back for shutdown sequence */
dvmChangeStatus(NULL, THREAD_RUNNING);
+#ifdef NDEBUG
+ // cc is used only in assert() statements -> not used in NDEBUG
+ // mode - causing variable defined but not used warning,
+ // breaking the build with -Werror
+ (void)cc;
+#endif
return NULL;
}
diff --git a/vm/Sync.cpp b/vm/Sync.cpp
index 8a3803eb4..d1f3ba843 100644
--- a/vm/Sync.cpp
+++ b/vm/Sync.cpp
@@ -757,6 +757,12 @@ done:
dvmThrowInterruptedException(NULL);
}
}
+#ifdef NDEBUG
+ // ret is used only in assert() statements ==> not used in
+ // NDEBUG builds at all, causing variable defined but not
+ // used warning, breaking the build with -Werror
+ (void)ret;
+#endif
}
/*
diff --git a/vm/Thread.cpp b/vm/Thread.cpp
index d82f15afe..36cba53b7 100644
--- a/vm/Thread.cpp
+++ b/vm/Thread.cpp
@@ -2153,6 +2153,10 @@ void dvmDetachCurrentThread()
// cond var guarded by threadListLock, which we already hold
cc = pthread_cond_signal(&gDvm.vmExitCond);
assert(cc == 0);
+#ifdef NDEBUG
+ // not used -> variable defined but not used warning
+ (void)cc;
+#endif
}
}
@@ -2710,6 +2714,10 @@ void dvmResumeAllThreads(SuspendCause why)
lockThreadSuspendCount();
cc = pthread_cond_broadcast(&gDvm.threadSuspendCountCond);
assert(cc == 0);
+#ifdef NDEBUG
+ // not used -> variable defined but not used warning
+ (void)cc;
+#endif
unlockThreadSuspendCount();
LOG_THREAD("threadid=%d: ResumeAll complete", self->threadId);
@@ -2759,6 +2767,10 @@ void dvmUndoDebuggerSuspensions()
lockThreadSuspendCount();
cc = pthread_cond_broadcast(&gDvm.threadSuspendCountCond);
assert(cc == 0);
+#ifdef NDEBUG
+ // not used -> variable defined but not used warning
+ (void)cc;
+#endif
unlockThreadSuspendCount();
unlockThreadSuspend();
diff --git a/vm/analysis/CodeVerify.cpp b/vm/analysis/CodeVerify.cpp
index 4a0d3d71d..768e3e40d 100644
--- a/vm/analysis/CodeVerify.cpp
+++ b/vm/analysis/CodeVerify.cpp
@@ -4318,6 +4318,11 @@ static bool verifyInstruction(const Method* meth, InsnFlags* insnFlags,
valueType = primitiveTypeToRegType(
resClass->elementClass->primitiveType);
assert(valueType != kRegTypeUnknown);
+#ifdef NDEBUG
+ // assert is optimized out, leaving valueType defined but
+ // not used, causing a compiler warning -> error on -Werror
+ (void)valueType;
+#endif
/*
* Now verify if the element width in the table matches the element
diff --git a/vm/analysis/DexPrepare.cpp b/vm/analysis/DexPrepare.cpp
index e8112d543..82e2c0605 100644
--- a/vm/analysis/DexPrepare.cpp
+++ b/vm/analysis/DexPrepare.cpp
@@ -1043,7 +1043,9 @@ static void verifyAndOptimizeClasses(DexFile* pDexFile, bool doVerify,
static void verifyAndOptimizeClass(DexFile* pDexFile, ClassObject* clazz,
const DexClassDef* pClassDef, bool doVerify, bool doOpt)
{
+#ifndef LOG_NDEBUG
const char* classDescriptor;
+#endif
bool verified = false;
if (clazz->pDvmDex->pDexFile != pDexFile) {
@@ -1059,7 +1061,9 @@ static void verifyAndOptimizeClass(DexFile* pDexFile, ClassObject* clazz,
return;
}
+#ifndef LOG_NDEBUG
classDescriptor = dexStringByTypeIdx(pDexFile, pClassDef->classIdx);
+#endif
/*
* First, try to verify it.
diff --git a/vm/analysis/VfyBasicBlock.cpp b/vm/analysis/VfyBasicBlock.cpp
index d6c4b79df..346e4206f 100644
--- a/vm/analysis/VfyBasicBlock.cpp
+++ b/vm/analysis/VfyBasicBlock.cpp
@@ -178,6 +178,11 @@ static bool setPredecessors(VerifierData* vdata, VfyBasicBlock* curBlock,
gotBranch = dvmGetBranchOffset(meth, insnFlags, curIdx,
&branchOffset, &unused);
assert(gotBranch);
+#ifdef NDEBUG
+ // assert is optimized out, leaving gotBranch defined but
+ // not used, causing a compiler warning -> error on -Werror
+ (void)gotBranch;
+#endif
absOffset = curIdx + branchOffset;
assert(absOffset >= 0 && (u4) absOffset < vdata->insnsSize);
diff --git a/vm/compiler/Compiler.cpp b/vm/compiler/Compiler.cpp
index b9b310516..73da6a0b5 100644
--- a/vm/compiler/Compiler.cpp
+++ b/vm/compiler/Compiler.cpp
@@ -138,6 +138,9 @@ bool dvmCompilerWorkEnqueue(const u2 *pc, WorkOrderKind kind, void* info)
gDvmJit.compilerQueueLength++;
cc = pthread_cond_signal(&gDvmJit.compilerQueueActivity);
assert(cc == 0);
+#ifdef NDEBUG
+ (void)cc; // prevent error on -Werror
+#endif
dvmUnlockMutex(&gDvmJit.compilerLock);
return result;
@@ -641,6 +644,9 @@ static void *compilerThreadStart(void *arg)
int cc;
cc = pthread_cond_signal(&gDvmJit.compilerQueueEmpty);
assert(cc == 0);
+#ifdef NDEBUG
+ (void)cc; // prevent bug on -Werror
+#endif
pthread_cond_wait(&gDvmJit.compilerQueueActivity,
&gDvmJit.compilerLock);
continue;
diff --git a/vm/compiler/codegen/arm/CodegenDriver.cpp b/vm/compiler/codegen/arm/CodegenDriver.cpp
index 5e1696d4f..e440310ad 100644
--- a/vm/compiler/codegen/arm/CodegenDriver.cpp
+++ b/vm/compiler/codegen/arm/CodegenDriver.cpp
@@ -2223,7 +2223,9 @@ static bool handleEasyMultiply(CompilationUnit *cUnit,
// Can we simplify this multiplication?
bool powerOfTwo = false;
bool popCountLE2 = false;
- bool powerOfTwoMinusOne = false;
+#ifndef NDEBUG
+ bool powerOfTwoMinusOne = false; // used only in assert
+#endif
if (lit < 2) {
// Avoid special cases.
return false;
@@ -2232,7 +2234,9 @@ static bool handleEasyMultiply(CompilationUnit *cUnit,
} else if (isPopCountLE2(lit)) {
popCountLE2 = true;
} else if (isPowerOfTwo(lit + 1)) {
+#ifndef NDEBUG
powerOfTwoMinusOne = true;
+#endif
} else {
return false;
}
diff --git a/vm/hprof/HprofClass.cpp b/vm/hprof/HprofClass.cpp
index 023efdbb4..b5462440a 100644
--- a/vm/hprof/HprofClass.cpp
+++ b/vm/hprof/HprofClass.cpp
@@ -89,6 +89,10 @@ hprof_class_object_id hprofLookupClassId(const ClassObject *clazz)
val = dvmHashTableLookup(gClassHashTable, computeClassHash(clazz),
(void *)clazz, classCmp, true);
assert(val != NULL);
+#ifdef NDEBUG
+ // variable defined but not used warning breaks -Werror
+ (void)val;
+#endif
dvmHashTableUnlock(gClassHashTable);
diff --git a/vm/interp/Interp.cpp b/vm/interp/Interp.cpp
index 41097644f..8fd01fa65 100644
--- a/vm/interp/Interp.cpp
+++ b/vm/interp/Interp.cpp
@@ -766,7 +766,9 @@ static void updateDebugger(const Method* method, const u2* pc, const u4* fp,
if (pCtrl->active && pCtrl->thread == self) {
int frameDepth;
bool doStop = false;
+#ifndef LOG_NDEBUG
const char* msg = NULL;
+#endif
assert(!dvmIsNativeMethod(method));
@@ -778,14 +780,20 @@ static void updateDebugger(const Method* method, const u2* pc, const u4* fp,
*/
if (pCtrl->method != method) {
doStop = true;
+#ifndef LOG_NDEBUG
msg = "new method";
+#endif
} else if (pCtrl->size == SS_MIN) {
doStop = true;
+#ifndef LOG_NDEBUG
msg = "new instruction";
+#endif
} else if (!dvmAddressSetGet(
pCtrl->pAddressSet, pc - method->insns)) {
doStop = true;
+#ifndef LOG_NDEBUG
msg = "new line";
+#endif
}
} else if (pCtrl->depth == SD_OVER) {
/*
@@ -799,16 +807,22 @@ static void updateDebugger(const Method* method, const u2* pc, const u4* fp,
if (frameDepth < pCtrl->frameDepth) {
/* popped up one or more frames, always trigger */
doStop = true;
+#ifndef LOG_NDEBUG
msg = "method pop";
+#endif
} else if (frameDepth == pCtrl->frameDepth) {
/* same depth, see if we moved */
if (pCtrl->size == SS_MIN) {
doStop = true;
+#ifndef LOG_NDEBUG
msg = "new instruction";
+#endif
} else if (!dvmAddressSetGet(pCtrl->pAddressSet,
pc - method->insns)) {
doStop = true;
+#ifndef LOG_NDEBUG
msg = "new line";
+#endif
}
}
} else {
@@ -824,7 +838,9 @@ static void updateDebugger(const Method* method, const u2* pc, const u4* fp,
frameDepth = dvmComputeVagueFrameDepth(self, fp);
if (frameDepth < pCtrl->frameDepth) {
doStop = true;
+#ifndef LOG_NDEBUG
msg = "method pop";
+#endif
}
}
diff --git a/vm/jdwp/JdwpAdb.cpp b/vm/jdwp/JdwpAdb.cpp
index 87db1d24b..5bdfd9413 100644
--- a/vm/jdwp/JdwpAdb.cpp
+++ b/vm/jdwp/JdwpAdb.cpp
@@ -430,7 +430,7 @@ static bool handlePacket(JdwpState* state)
JdwpReqHeader hdr;
u4 length, id;
u1 flags, cmdSet, cmd;
- u2 error;
+// u2 error;
bool reply;
int dataLen;
@@ -441,7 +441,7 @@ static bool handlePacket(JdwpState* state)
flags = read1(&buf);
if ((flags & kJDWPFlagReply) != 0) {
reply = true;
- error = read2BE(&buf);
+ /*error =*/ read2BE(&buf);
} else {
reply = false;
cmdSet = read1(&buf);
diff --git a/vm/jdwp/JdwpHandler.cpp b/vm/jdwp/JdwpHandler.cpp
index b41139a4c..d51afc7d4 100644
--- a/vm/jdwp/JdwpHandler.cpp
+++ b/vm/jdwp/JdwpHandler.cpp
@@ -964,9 +964,12 @@ static JdwpError handleOR_EnableCollection(JdwpState* state,
static JdwpError handleOR_IsCollected(JdwpState* state,
const u1* buf, int dataLen, ExpandBuf* pReply)
{
+#ifndef LOG_NDEBUG
ObjectId objectId;
- objectId = dvmReadObjectId(&buf);
+ objectId =
+#endif
+ dvmReadObjectId(&buf);
ALOGV(" Req IsCollected(0x%llx)", objectId);
// TODO: currently returning false; must integrate with GC
@@ -1172,9 +1175,9 @@ static JdwpError handleTR_FrameCount(JdwpState* state,
static JdwpError handleTR_CurrentContendedMonitor(JdwpState* state,
const u1* buf, int dataLen, ExpandBuf* pReply)
{
- ObjectId threadId;
+ //ObjectId threadId;
- threadId = dvmReadObjectId(&buf);
+ /*threadId =*/ dvmReadObjectId(&buf);
// TODO: create an Object to represent the monitor (we're currently
// just using a raw Monitor struct in the VM)
@@ -1557,8 +1560,11 @@ static JdwpError handleER_Set(JdwpState* state,
static JdwpError handleER_Clear(JdwpState* state,
const u1* buf, int dataLen, ExpandBuf* pReply)
{
+#ifndef LOG_NDEBUG
u1 eventKind;
- eventKind = read1(&buf);
+ eventKind =
+#endif
+ read1(&buf);
u4 requestId = read4BE(&buf);
ALOGV(" Req to clear eventKind=%d requestId=%#x", eventKind, requestId);
diff --git a/vm/jdwp/JdwpSocket.cpp b/vm/jdwp/JdwpSocket.cpp
index ad0a287ca..babb4a9da 100644
--- a/vm/jdwp/JdwpSocket.cpp
+++ b/vm/jdwp/JdwpSocket.cpp
@@ -586,7 +586,7 @@ static bool handlePacket(JdwpState* state)
JdwpReqHeader hdr;
u4 length, id;
u1 flags, cmdSet, cmd;
- u2 error;
+ //u2 error;
bool reply;
int dataLen;
@@ -599,7 +599,7 @@ static bool handlePacket(JdwpState* state)
flags = read1(&buf);
if ((flags & kJDWPFlagReply) != 0) {
reply = true;
- error = read2BE(&buf);
+ /*error =*/ read2BE(&buf);
} else {
reply = false;
cmdSet = read1(&buf);
diff --git a/vm/reflect/Annotation.cpp b/vm/reflect/Annotation.cpp
index 233db0881..7a1cbca59 100644
--- a/vm/reflect/Annotation.cpp
+++ b/vm/reflect/Annotation.cpp
@@ -598,6 +598,10 @@ static Object* convertReturnType(Object* valueObj, ClassObject* methodReturn)
}
ALOGV("HEY: converting valueObj from [%s to [%s",
srcElemClass->descriptor, dstElemClass->descriptor);
+#ifdef LOG_NDEBUG
+ // variable defined but not used => breakage on -Werror
+ (void)srcElemClass;
+#endif
ArrayObject* srcArray = (ArrayObject*) valueObj;
u4 length = srcArray->length;
@@ -1101,9 +1105,9 @@ static const u1* searchEncodedAnnotation(const ClassObject* clazz,
const u1* ptr, const char* name)
{
DexFile* pDexFile = clazz->pDvmDex->pDexFile;
- u4 typeIdx, size;
+ u4 /*typeIdx,*/ size;
- typeIdx = readUleb128(&ptr);
+ /*typeIdx =*/ readUleb128(&ptr);
size = readUleb128(&ptr);
//printf("##### searching ptr=%p type=%u size=%u\n", ptr, typeIdx, size);