summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdex/SysUtil.h8
-rw-r--r--vm/AllocTracker.h8
-rw-r--r--vm/Atomic.h8
-rw-r--r--vm/BitVector.h8
-rw-r--r--vm/Common.h69
-rw-r--r--vm/Dalvik.h2
-rw-r--r--vm/Ddm.h8
-rw-r--r--vm/Debugger.h10
-rw-r--r--vm/Dvm.mk32
-rw-r--r--vm/DvmDex.h8
-rw-r--r--vm/Exception.h8
-rw-r--r--vm/Globals.h8
-rw-r--r--vm/Hash.h8
-rw-r--r--vm/IndirectRefTable.h9
-rw-r--r--vm/Init.h8
-rw-r--r--vm/InlineNative.h8
-rw-r--r--vm/Intern.h8
-rw-r--r--vm/JarFile.h8
-rw-r--r--vm/JniInternal.h8
-rw-r--r--vm/LinearAlloc.h8
-rw-r--r--vm/Misc.h11
-rw-r--r--vm/Native.h8
-rw-r--r--vm/PointerSet.h8
-rw-r--r--vm/Profile.h8
-rw-r--r--vm/Properties.h8
-rw-r--r--vm/RawDexFile.h8
-rw-r--r--vm/ReferenceTable.h8
-rw-r--r--vm/SignalCatcher.h8
-rw-r--r--vm/StdioConverter.h8
-rw-r--r--vm/Sync.h8
-rw-r--r--vm/Thread.h7
-rw-r--r--vm/UtfString.h8
-rw-r--r--vm/alloc/Alloc.cpp (renamed from vm/alloc/Alloc.c)0
-rw-r--r--vm/alloc/Alloc.h8
-rw-r--r--vm/alloc/CardTable.cpp (renamed from vm/alloc/CardTable.c)0
-rw-r--r--vm/alloc/CardTable.h8
-rw-r--r--vm/alloc/Copying.cpp (renamed from vm/alloc/Copying.c)0
-rw-r--r--vm/alloc/DdmHeap.cpp (renamed from vm/alloc/DdmHeap.c)2
-rw-r--r--vm/alloc/DdmHeap.h8
-rw-r--r--vm/alloc/Heap.cpp (renamed from vm/alloc/Heap.c)10
-rw-r--r--vm/alloc/Heap.h2
-rw-r--r--vm/alloc/HeapBitmap.cpp (renamed from vm/alloc/HeapBitmap.c)0
-rw-r--r--vm/alloc/HeapBitmap.h8
-rw-r--r--vm/alloc/HeapDebug.cpp (renamed from vm/alloc/HeapDebug.c)0
-rw-r--r--vm/alloc/HeapDebug.h8
-rw-r--r--vm/alloc/HeapInternal.h5
-rw-r--r--vm/alloc/HeapSource.cpp (renamed from vm/alloc/HeapSource.c)8
-rw-r--r--vm/alloc/MarkSweep.cpp (renamed from vm/alloc/MarkSweep.c)6
-rw-r--r--vm/alloc/Verify.cpp (renamed from vm/alloc/Verify.c)0
-rw-r--r--vm/alloc/Visit.cpp (renamed from vm/alloc/Visit.c)0
-rw-r--r--vm/alloc/Visit.h8
-rw-r--r--vm/alloc/VisitInlines.h2
-rw-r--r--vm/alloc/WriteBarrier.h8
-rw-r--r--vm/analysis/CodeVerify.h7
-rw-r--r--vm/analysis/RegisterMap.h8
-rw-r--r--vm/compiler/Compiler.h15
-rw-r--r--vm/hprof/Hprof.cpp (renamed from vm/hprof/Hprof.c)0
-rw-r--r--vm/hprof/Hprof.h23
-rw-r--r--vm/hprof/HprofClass.cpp (renamed from vm/hprof/HprofClass.c)0
-rw-r--r--vm/hprof/HprofHeap.cpp (renamed from vm/hprof/HprofHeap.c)8
-rw-r--r--vm/hprof/HprofOutput.cpp (renamed from vm/hprof/HprofOutput.c)0
-rw-r--r--vm/hprof/HprofString.cpp (renamed from vm/hprof/HprofString.c)0
-rw-r--r--vm/interp/Jit.h8
-rw-r--r--vm/interp/Stack.h7
-rw-r--r--vm/native/InternalNative.h8
-rw-r--r--vm/native/InternalNativePriv.h8
-rw-r--r--vm/oo/AccessCheck.h8
-rw-r--r--vm/oo/Array.h8
-rw-r--r--vm/oo/Class.h8
-rw-r--r--vm/oo/Object.h11
-rw-r--r--vm/oo/ObjectInlines.h8
-rw-r--r--vm/oo/Resolve.h8
-rw-r--r--vm/oo/TypeCheck.h8
73 files changed, 468 insertions, 114 deletions
diff --git a/libdex/SysUtil.h b/libdex/SysUtil.h
index 4de028974..1f704f446 100644
--- a/libdex/SysUtil.h
+++ b/libdex/SysUtil.h
@@ -22,6 +22,10 @@
#include <sys/types.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* System page size. Normally you're expected to get this from
* sysconf(_SC_PAGESIZE) or some system-specific define (usually PAGESIZE
@@ -119,4 +123,8 @@ int sysWriteFully(int fd, const void* buf, size_t count, const char* logMsg);
*/
int sysCopyFileToFile(int outFd, int inFd, size_t count);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_SYSUTIL*/
diff --git a/vm/AllocTracker.h b/vm/AllocTracker.h
index 84ac9b8fb..b6d668d9d 100644
--- a/vm/AllocTracker.h
+++ b/vm/AllocTracker.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_ALLOCTRACKER
#define _DALVIK_ALLOCTRACKER
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* initialization */
bool dvmAllocTrackerStartup(void);
void dvmAllocTrackerShutdown(void);
@@ -60,4 +64,8 @@ bool dvmGenerateTrackedAllocationReport(u1** pData, size_t* pDataLen);
*/
void dvmDumpTrackedAllocations(bool enable);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_ALLOCTRACKER*/
diff --git a/vm/Atomic.h b/vm/Atomic.h
index 6c3a66f6b..713c5b4cc 100644
--- a/vm/Atomic.h
+++ b/vm/Atomic.h
@@ -23,6 +23,10 @@
#include <cutils/atomic.h> /* use common Android atomic ops */
#include <cutils/atomic-inline.h> /* and some uncommon ones */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* NOTE: Two "quasiatomic" operations on the exact same memory address
* are guaranteed to operate atomically with respect to each other,
@@ -52,4 +56,8 @@ int64_t dvmQuasiAtomicRead64(volatile const int64_t* addr);
int dvmQuasiAtomicCas64(int64_t oldvalue, int64_t newvalue,
volatile int64_t* addr);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_ATOMIC*/
diff --git a/vm/BitVector.h b/vm/BitVector.h
index d1a0ca31d..0d2335091 100644
--- a/vm/BitVector.h
+++ b/vm/BitVector.h
@@ -20,6 +20,10 @@
#ifndef _DALVIK_BITVECTOR
#define _DALVIK_BITVECTOR
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Expanding bitmap, used for tracking resources. Bits are numbered starting
* from zero.
@@ -100,4 +104,8 @@ void dvmBitVectorIteratorInit(BitVector* pBits, BitVectorIterator* iterator);
/* Return the next position set to 1. -1 means end-of-vector reached */
int dvmBitVectorIteratorNext(BitVectorIterator* iterator);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_BITVECTOR*/
diff --git a/vm/Common.h b/vm/Common.h
index 7d8424ed9..0ec9ec4ff 100644
--- a/vm/Common.h
+++ b/vm/Common.h
@@ -24,8 +24,16 @@
# define LOG_TAG "dalvikvm"
#endif
+#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
#include <assert.h>
+#include <endian.h>
+#include "utils/Log.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#if !defined(NDEBUG) && defined(WITH_DALVIK_ASSERT)
# undef assert
@@ -67,8 +75,6 @@
/*
* These match the definitions in the VM specification.
*/
-#ifdef HAVE_STDINT_H
-# include <stdint.h> /* C99 */
typedef uint8_t u1;
typedef uint16_t u2;
typedef uint32_t u4;
@@ -77,16 +83,6 @@ typedef int8_t s1;
typedef int16_t s2;
typedef int32_t s4;
typedef int64_t s8;
-#else
-typedef unsigned char u1;
-typedef unsigned short u2;
-typedef unsigned int u4;
-typedef unsigned long long u8;
-typedef signed char s1;
-typedef signed short s2;
-typedef signed int s4;
-typedef signed long long s8;
-#endif
/*
* Storage for primitive types and object references.
@@ -108,55 +104,10 @@ typedef union JValue {
void* l;
} JValue;
-/*
- * The <stdbool.h> definition uses _Bool, a type known to the compiler.
- */
-#ifdef HAVE_STDBOOL_H
-# include <stdbool.h> /* C99 */
-#else
-# ifndef __bool_true_false_are_defined
-typedef enum { false=0, true=!false } bool;
-# define __bool_true_false_are_defined 1
-# endif
-#endif
-
#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
-
-#if defined(HAVE_ENDIAN_H)
-# include <endian.h>
-#else /*not HAVE_ENDIAN_H*/
-# define __BIG_ENDIAN 4321
-# define __LITTLE_ENDIAN 1234
-# if defined(HAVE_LITTLE_ENDIAN)
-# define __BYTE_ORDER __LITTLE_ENDIAN
-# else
-# define __BYTE_ORDER __BIG_ENDIAN
-# endif
-#endif /*not HAVE_ENDIAN_H*/
-
-
-#if 0
-/*
- * Pretend we have the Android logging macros. These are replaced by the
- * Android logging implementation.
- */
-#define ANDROID_LOG_DEBUG 3
-#define LOGV(...) LOG_PRI(2, 0, __VA_ARGS__)
-#define LOGD(...) LOG_PRI(3, 0, __VA_ARGS__)
-#define LOGI(...) LOG_PRI(4, 0, __VA_ARGS__)
-#define LOGW(...) LOG_PRI(5, 0, __VA_ARGS__)
-#define LOGE(...) LOG_PRI(6, 0, __VA_ARGS__)
-#define MIN_LOG_LEVEL 2
-
-#define LOG_PRI(priority, tag, ...) do { \
- if (priority >= MIN_LOG_LEVEL) { \
- dvmFprintf(stdout, "%s:%-4d ", __FILE__, __LINE__); \
- dvmFprintf(stdout, __VA_ARGS__); \
- } \
- } while(0)
-#else
-# include "utils/Log.h"
+#ifdef __cplusplus
+}
#endif
#endif /*_DALVIK_COMMON*/
diff --git a/vm/Dalvik.h b/vm/Dalvik.h
index 534ea2d4c..a47388a9f 100644
--- a/vm/Dalvik.h
+++ b/vm/Dalvik.h
@@ -20,8 +20,6 @@
#ifndef _DALVIK_DALVIK
#define _DALVIK_DALVIK
-#include <pthread.h>
-
#include "Common.h"
#include "Inlines.h"
#include "Misc.h"
diff --git a/vm/Ddm.h b/vm/Ddm.h
index 01f5d18ba..af7f6e1ec 100644
--- a/vm/Ddm.h
+++ b/vm/Ddm.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_DDM
#define _DALVIK_DDM
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Handle a packet full of DDM goodness.
*
@@ -84,4 +88,8 @@ ArrayObject* dvmDdmGetStackTraceById(u4 threadId);
*/
ArrayObject* dvmDdmGetRecentAllocations(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_DDM*/
diff --git a/vm/Debugger.h b/vm/Debugger.h
index 9a45b393d..dd9679f62 100644
--- a/vm/Debugger.h
+++ b/vm/Debugger.h
@@ -21,10 +21,14 @@
#ifndef _DALVIK_DEBUGGER
#define _DALVIK_DEBUGGER
+#include <pthread.h>
#include "Common.h"
#include "Misc.h"
#include "jdwp/Jdwp.h"
-#include <pthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/* fwd decl */
struct Object;
@@ -307,4 +311,8 @@ void dvmDbgDdmSendChunkV(int type, const struct iovec* iov, int iovcnt);
#define CHUNK_TYPE(_name) \
((_name)[0] << 24 | (_name)[1] << 16 | (_name)[2] << 8 | (_name)[3])
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_DEBUGGER*/
diff --git a/vm/Dvm.mk b/vm/Dvm.mk
index d655a3a09..add220763 100644
--- a/vm/Dvm.mk
+++ b/vm/Dvm.mk
@@ -116,14 +116,14 @@ LOCAL_SRC_FILES := \
Sync.c \
Thread.c \
UtfString.c \
- alloc/Alloc.c \
- alloc/CardTable.c \
- alloc/HeapBitmap.c.arm \
- alloc/HeapDebug.c \
- alloc/Heap.c.arm \
- alloc/DdmHeap.c \
- alloc/Verify.c \
- alloc/Visit.c \
+ alloc/Alloc.cpp \
+ alloc/CardTable.cpp \
+ alloc/HeapBitmap.cpp.arm \
+ alloc/HeapDebug.cpp \
+ alloc/Heap.cpp.arm \
+ alloc/DdmHeap.cpp \
+ alloc/Verify.cpp \
+ alloc/Visit.cpp \
analysis/CodeVerify.c \
analysis/DexPrepare.c \
analysis/DexVerify.c \
@@ -132,11 +132,11 @@ LOCAL_SRC_FILES := \
analysis/RegisterMap.c \
analysis/VerifySubs.c \
analysis/VfyBasicBlock.c \
- hprof/Hprof.c \
- hprof/HprofClass.c \
- hprof/HprofHeap.c \
- hprof/HprofOutput.c \
- hprof/HprofString.c \
+ hprof/Hprof.cpp \
+ hprof/HprofClass.cpp \
+ hprof/HprofHeap.cpp \
+ hprof/HprofOutput.cpp \
+ hprof/HprofString.cpp \
interp/Interp.c.arm \
interp/Stack.c \
jdwp/ExpandBuf.c \
@@ -195,11 +195,11 @@ WITH_COPYING_GC := $(strip $(WITH_COPYING_GC))
ifeq ($(WITH_COPYING_GC),true)
LOCAL_CFLAGS += -DWITH_COPYING_GC
LOCAL_SRC_FILES += \
- alloc/Copying.c.arm
+ alloc/Copying.cpp.arm
else
LOCAL_SRC_FILES += \
- alloc/HeapSource.c \
- alloc/MarkSweep.c.arm
+ alloc/HeapSource.cpp \
+ alloc/MarkSweep.cpp.arm
endif
WITH_JIT := $(strip $(WITH_JIT))
diff --git a/vm/DvmDex.h b/vm/DvmDex.h
index ad82e5424..937f09dfd 100644
--- a/vm/DvmDex.h
+++ b/vm/DvmDex.h
@@ -21,6 +21,10 @@
#ifndef _DALVIK_DVMDEX
#define _DALVIK_DVMDEX
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "libdex/DexFile.h"
/* extern */
@@ -158,4 +162,8 @@ INLINE void dvmDexSetResolvedField(DvmDex* pDvmDex, u4 fieldIdx,
pDvmDex->pResFields[fieldIdx] = field;
}
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_DVMDEX*/
diff --git a/vm/Exception.h b/vm/Exception.h
index 509d3b2e7..40f348202 100644
--- a/vm/Exception.h
+++ b/vm/Exception.h
@@ -20,6 +20,10 @@
#ifndef _DALVIK_EXCEPTION
#define _DALVIK_EXCEPTION
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Create a Throwable and throw an exception in the current thread (where
* "throwing" just means "set the thread's exception pointer").
@@ -483,4 +487,8 @@ void dvmThrowVerifyError(const char* descriptor);
*/
void dvmThrowVirtualMachineError(const char* msg);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_EXCEPTION*/
diff --git a/vm/Globals.h b/vm/Globals.h
index faafcc646..163ce99f1 100644
--- a/vm/Globals.h
+++ b/vm/Globals.h
@@ -33,6 +33,10 @@
#include <stdarg.h>
#include <pthread.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define MAX_BREAKPOINTS 20 /* used for a debugger optimization */
/* private structures */
@@ -959,4 +963,8 @@ extern int gDvmICHitCount;
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_GLOBALS*/
diff --git a/vm/Hash.h b/vm/Hash.h
index cfd754491..2c6bd5e07 100644
--- a/vm/Hash.h
+++ b/vm/Hash.h
@@ -22,6 +22,10 @@
#ifndef _DALVIK_HASH
#define _DALVIK_HASH
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* compute the hash of an item with a specific type */
typedef u4 (*HashCompute)(const void* item);
@@ -218,4 +222,8 @@ typedef u4 (*HashCalcFunc)(const void* item);
void dvmHashTableProbeCount(HashTable* pHashTable, HashCalcFunc calcFunc,
HashCompareFunc cmpFunc);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_HASH*/
diff --git a/vm/IndirectRefTable.h b/vm/IndirectRefTable.h
index 7248a7b43..36d18baad 100644
--- a/vm/IndirectRefTable.h
+++ b/vm/IndirectRefTable.h
@@ -16,6 +16,11 @@
#ifndef _DALVIK_INDIRECTREFTABLE
#define _DALVIK_INDIRECTREFTABLE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Maintain a table of indirect references. Used for local/global JNI
* references.
@@ -389,4 +394,8 @@ bool dvmRemoveFromIndirectRefTable(IndirectRefTable* pRef, u4 cookie,
*/
void dvmDumpIndirectRefTable(const IndirectRefTable* pRef, const char* descr);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_INDIRECTREFTABLE*/
diff --git a/vm/Init.h b/vm/Init.h
index ef56f26e8..9e38da9fa 100644
--- a/vm/Init.h
+++ b/vm/Init.h
@@ -20,6 +20,10 @@
#ifndef _DALVIK_INIT
#define _DALVIK_INIT
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Standard VM initialization, usually invoked through JNI.
*/
@@ -78,4 +82,8 @@ int dvmFprintf(FILE* fp, const char* format, ...)
#endif
;
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_INIT*/
diff --git a/vm/InlineNative.h b/vm/InlineNative.h
index 4ca90e2fe..4f86cef5f 100644
--- a/vm/InlineNative.h
+++ b/vm/InlineNative.h
@@ -20,6 +20,10 @@
#ifndef _DALVIK_INLINENATIVE
#define _DALVIK_INLINENATIVE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* startup/shutdown */
bool dvmInlineNativeStartup(void);
void dvmInlineNativeShutdown(void);
@@ -121,4 +125,8 @@ bool dvmPerformInlineOp4Dbg(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
*/
Method* dvmResolveInlineNative(int opIndex);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_INLINENATIVE*/
diff --git a/vm/Intern.h b/vm/Intern.h
index 6630b69f3..b6e669ae6 100644
--- a/vm/Intern.h
+++ b/vm/Intern.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_INTERN
#define _DALVIK_INTERN
+#ifdef __cplusplus
+extern "C" {
+#endif
+
bool dvmStringInternStartup(void);
void dvmStringInternShutdown(void);
StringObject* dvmLookupInternedString(StringObject* strObj);
@@ -26,4 +30,8 @@ StringObject* dvmLookupImmortalInternedString(StringObject* strObj);
bool dvmIsWeakInternedString(const StringObject* strObj);
void dvmGcDetachDeadInternedStrings(int (*isUnmarkedObject)(void *));
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_INTERN*/
diff --git a/vm/JarFile.h b/vm/JarFile.h
index 36849ec19..0569ee2e9 100644
--- a/vm/JarFile.h
+++ b/vm/JarFile.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_JARFILE
#define _DALVIK_JARFILE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* This represents an open, scanned Jar file. (It's actually for any Zip
* archive that happens to hold a Dex file.)
@@ -68,4 +72,8 @@ typedef enum DexCacheStatus {
*/
DexCacheStatus dvmDexCacheStatus(const char *fileName);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_JARFILE*/
diff --git a/vm/JniInternal.h b/vm/JniInternal.h
index bc88cadb9..d81373fb0 100644
--- a/vm/JniInternal.h
+++ b/vm/JniInternal.h
@@ -21,6 +21,10 @@
#include "jni.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* system init/shutdown */
bool dvmJniStartup(void);
void dvmJniShutdown(void);
@@ -197,4 +201,8 @@ void dvmReleaseJniMonitors(Thread* self);
*/
void dvmDumpJniReferenceTables(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_JNIINTERNAL*/
diff --git a/vm/LinearAlloc.h b/vm/LinearAlloc.h
index aa33fe1fc..c06d2abfa 100644
--- a/vm/LinearAlloc.h
+++ b/vm/LinearAlloc.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_LINEARALLOC
#define _DALVIK_LINEARALLOC
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* If this is set, we create additional data structures and make many
* additional mprotect() calls.
@@ -117,4 +121,8 @@ void dvmLinearAllocDump(Object* classLoader);
*/
bool dvmLinearAllocContains(const void* start, size_t length);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_LINEARALLOC*/
diff --git a/vm/Misc.h b/vm/Misc.h
index c1c3d474e..89818246c 100644
--- a/vm/Misc.h
+++ b/vm/Misc.h
@@ -20,11 +20,14 @@
#ifndef _DALVIK_MISC
#define _DALVIK_MISC
-#include "Inlines.h"
-
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
+#include "Inlines.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
* Used to shut up the compiler when a parameter isn't used.
@@ -299,4 +302,8 @@ bool dvmGetThreadStats(ProcStatData* pData, pid_t tid);
*/
const char* dvmPathToAbsolutePortion(const char* path);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_MISC*/
diff --git a/vm/Native.h b/vm/Native.h
index f60ccce67..7599bcc31 100644
--- a/vm/Native.h
+++ b/vm/Native.h
@@ -22,6 +22,10 @@
#ifndef _DALVIK_NATIVE
#define _DALVIK_NATIVE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Method description; equivalent to a JNI struct.
*/
@@ -119,4 +123,8 @@ void dvmLogNativeMethodEntry(const Method* method, const u4* newFp);
void dvmLogNativeMethodExit(const Method* method, struct Thread* self,
const JValue retval);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_NATIVE*/
diff --git a/vm/PointerSet.h b/vm/PointerSet.h
index ffc063569..6e43f672b 100644
--- a/vm/PointerSet.h
+++ b/vm/PointerSet.h
@@ -20,6 +20,10 @@
#ifndef _DALVIK_POINTERSET
#define _DALVIK_POINTERSET
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct PointerSet; /* private */
typedef struct PointerSet PointerSet;
@@ -92,4 +96,8 @@ void dvmPointerSetIntersect(PointerSet* pSet, const void** ptrArray, int count);
*/
void dvmPointerSetDump(const PointerSet* pSet);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_POINTERSET*/
diff --git a/vm/Profile.h b/vm/Profile.h
index b821394f4..12063b9a1 100644
--- a/vm/Profile.h
+++ b/vm/Profile.h
@@ -24,6 +24,10 @@
#include <stdio.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct Thread; // extern
@@ -171,4 +175,8 @@ enum {
#define METHOD_ACTION(_method) (((unsigned int)(_method)) & METHOD_ACTION_MASK)
#define METHOD_COMBINE(_method, _action) ((_method) | (_action))
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_PROFILE*/
diff --git a/vm/Properties.h b/vm/Properties.h
index 138be417b..6226d7f80 100644
--- a/vm/Properties.h
+++ b/vm/Properties.h
@@ -19,10 +19,18 @@
#ifndef _DALVIK_PROPERTIES
#define _DALVIK_PROPERTIES
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Initialization.
*/
bool dvmPropertiesStartup(void);
void dvmPropertiesShutdown(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_PROPERTIES*/
diff --git a/vm/RawDexFile.h b/vm/RawDexFile.h
index cbcb3b6f6..f2c1b68f7 100644
--- a/vm/RawDexFile.h
+++ b/vm/RawDexFile.h
@@ -21,6 +21,10 @@
#ifndef _DALVIK_RAWDEXFILE
#define _DALVIK_RAWDEXFILE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Structure representing a "raw" DEX file, in its unswapped unoptimized
* state.
@@ -68,4 +72,8 @@ INLINE const char* dvmGetRawDexFileCacheFileName(RawDexFile* pRawDexFile) {
return pRawDexFile->cacheFileName;
}
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_RAWDEXFILE*/
diff --git a/vm/ReferenceTable.h b/vm/ReferenceTable.h
index f434f554d..35bc61b1b 100644
--- a/vm/ReferenceTable.h
+++ b/vm/ReferenceTable.h
@@ -23,6 +23,10 @@
#ifndef _DALVIK_REFERENCETABLE
#define _DALVIK_REFERENCETABLE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Table definition.
*
@@ -122,4 +126,8 @@ void dvmDumpReferenceTable(const ReferenceTable* pRef, const char* descr);
void dvmDumpReferenceTableContents(Object* const* refs, size_t count,
const char* descr);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_REFERENCETABLE*/
diff --git a/vm/SignalCatcher.h b/vm/SignalCatcher.h
index ece052c5c..f9e1dd70a 100644
--- a/vm/SignalCatcher.h
+++ b/vm/SignalCatcher.h
@@ -19,7 +19,15 @@
#ifndef _DALVIK_SIGNALCATCHER
#define _DALVIK_SIGNALCATCHER
+#ifdef __cplusplus
+extern "C" {
+#endif
+
bool dvmSignalCatcherStartup(void);
void dvmSignalCatcherShutdown(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_SIGNALCATCHER*/
diff --git a/vm/StdioConverter.h b/vm/StdioConverter.h
index ffbf80731..37384eb98 100644
--- a/vm/StdioConverter.h
+++ b/vm/StdioConverter.h
@@ -19,7 +19,15 @@
#ifndef _DALVIK_STDOUTCONVERTER
#define _DALVIK_STDOUTCONVERTER
+#ifdef __cplusplus
+extern "C" {
+#endif
+
bool dvmStdioConverterStartup(void);
void dvmStdioConverterShutdown(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_STDOUTCONVERTER*/
diff --git a/vm/Sync.h b/vm/Sync.h
index 520366e23..a03948334 100644
--- a/vm/Sync.h
+++ b/vm/Sync.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_SYNC
#define _DALVIK_SYNC
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Monitor shape field. Used to distinguish immediate thin locks from
* indirecting fat locks.
@@ -157,4 +161,8 @@ bool dvmHoldsLock(struct Thread* thread, struct Object* obj);
int dvmRelativeCondWait(pthread_cond_t* cond, pthread_mutex_t* mutex,
s8 msec, s4 nsec);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_SYNC*/
diff --git a/vm/Thread.h b/vm/Thread.h
index 4ad3974f5..c42a9e841 100644
--- a/vm/Thread.h
+++ b/vm/Thread.h
@@ -26,6 +26,9 @@
#include <errno.h>
#include <cutils/sched_policy.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
#if defined(CHECK_MUTEX) && !defined(__USE_UNIX98)
/* glibc lacks this unless you #define __USE_UNIX98 */
@@ -595,4 +598,8 @@ void dvmDumpAllThreadsEx(const DebugOutputTarget* target, bool grabLock);
*/
void dvmNukeThread(Thread* thread);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_THREAD*/
diff --git a/vm/UtfString.h b/vm/UtfString.h
index 793d8bcb8..f0413a48e 100644
--- a/vm/UtfString.h
+++ b/vm/UtfString.h
@@ -21,6 +21,10 @@
#ifndef _DALVIK_STRING
#define _DALVIK_STRING
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* (This is private to UtfString.c, but we cheat a bit and also use it
* for InlineNative.c. Not really worth creating a separate header.)
@@ -145,4 +149,8 @@ const u2* dvmStringChars(StringObject* jstr);
*/
int dvmHashcmpStrings(const void* vstrObj1, const void* vstrObj2);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_STRING*/
diff --git a/vm/alloc/Alloc.c b/vm/alloc/Alloc.cpp
index 33f45e86f..33f45e86f 100644
--- a/vm/alloc/Alloc.c
+++ b/vm/alloc/Alloc.cpp
diff --git a/vm/alloc/Alloc.h b/vm/alloc/Alloc.h
index aeba3f5d9..fc62ed085 100644
--- a/vm/alloc/Alloc.h
+++ b/vm/alloc/Alloc.h
@@ -21,6 +21,10 @@
#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Initialization.
*/
@@ -143,4 +147,8 @@ void dvmClearGrowthLimit(void);
*/
bool dvmIsHeapAddress(void *address);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_ALLOC_ALLOC*/
diff --git a/vm/alloc/CardTable.c b/vm/alloc/CardTable.cpp
index 533d5bc8a..533d5bc8a 100644
--- a/vm/alloc/CardTable.c
+++ b/vm/alloc/CardTable.cpp
diff --git a/vm/alloc/CardTable.h b/vm/alloc/CardTable.h
index 96131d1ec..1c15a5409 100644
--- a/vm/alloc/CardTable.h
+++ b/vm/alloc/CardTable.h
@@ -23,6 +23,10 @@
#ifndef _DALVIK_ALLOC_CARDTABLE
#define _DALVIK_ALLOC_CARDTABLE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define GC_CARD_SHIFT 7
#define GC_CARD_SIZE (1 << GC_CARD_SHIFT)
#define GC_CARD_CLEAN 0
@@ -70,4 +74,8 @@ void dvmMarkCard(const void *addr);
*/
void dvmVerifyCardTable(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_ALLOC_CARDTABLE*/
diff --git a/vm/alloc/Copying.c b/vm/alloc/Copying.cpp
index 097efae78..097efae78 100644
--- a/vm/alloc/Copying.c
+++ b/vm/alloc/Copying.cpp
diff --git a/vm/alloc/DdmHeap.c b/vm/alloc/DdmHeap.cpp
index b377b1b8a..8008113fa 100644
--- a/vm/alloc/DdmHeap.c
+++ b/vm/alloc/DdmHeap.cpp
@@ -357,7 +357,7 @@ enum HpsgWhat {
*/
#define HPSx_CHUNK_SIZE (16384 - 16)
-void dlmalloc_walk_heap(void(*)(const void*, size_t, const void*, size_t, void*),void*);
+extern "C" void dlmalloc_walk_heap(void(*)(const void*, size_t, const void*, size_t, void*),void*);
static void
walkHeap(bool merge, bool native)
diff --git a/vm/alloc/DdmHeap.h b/vm/alloc/DdmHeap.h
index c3e11dc29..32b96f964 100644
--- a/vm/alloc/DdmHeap.h
+++ b/vm/alloc/DdmHeap.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_ALLOC_DDMHEAP
#define _DALVIK_ALLOC_DDMHEAP
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Sends the current heap info to the DDM server.
* Should be called after a GC when gcHeap->ddmHpifWhen
@@ -38,4 +42,8 @@ void dvmDdmSendHeapInfo(int reason, bool shouldLock);
*/
void dvmDdmSendHeapSegments(bool shouldLock, bool native);
+#ifdef __cplusplus
+}
+#endif
+
#endif // _DALVIK_ALLOC_DDMHEAP
diff --git a/vm/alloc/Heap.c b/vm/alloc/Heap.cpp
index f38eb121d..9ca0ebfee 100644
--- a/vm/alloc/Heap.c
+++ b/vm/alloc/Heap.cpp
@@ -37,7 +37,7 @@
static const GcSpec kGcForMallocSpec = {
true, /* isPartial */
false, /* isConcurrent */
- PRESERVE,
+ true, /* doPreserve */
"GC_FOR_ALLOC"
};
@@ -46,7 +46,7 @@ const GcSpec *GC_FOR_MALLOC = &kGcForMallocSpec;
static const GcSpec kGcConcurrentSpec = {
true, /* isPartial */
true, /* isConcurrent */
- PRESERVE,
+ true, /* doPreserve */
"GC_CONCURRENT"
};
@@ -55,7 +55,7 @@ const GcSpec *GC_CONCURRENT = &kGcConcurrentSpec;
static const GcSpec kGcExplicitSpec = {
false, /* isPartial */
true, /* isConcurrent */
- PRESERVE,
+ true, /* doPreserve */
"GC_EXPLICIT"
};
@@ -64,7 +64,7 @@ const GcSpec *GC_EXPLICIT = &kGcExplicitSpec;
static const GcSpec kGcBeforeOomSpec = {
false, /* isPartial */
false, /* isConcurrent */
- CLEAR,
+ false, /* doPreserve */
"GC_BEFORE_OOM"
};
@@ -622,7 +622,7 @@ void dvmCollectGarbageInternal(const GcSpec* spec)
* weakly-reachable objects discovered while tracing.
*/
dvmHeapProcessReferences(&gcHeap->softReferences,
- spec->softReferencePolicy == CLEAR,
+ spec->doPreserve == false,
&gcHeap->weakReferences,
&gcHeap->finalizerReferences,
&gcHeap->phantomReferences);
diff --git a/vm/alloc/Heap.h b/vm/alloc/Heap.h
index 01a50d242..4333486f8 100644
--- a/vm/alloc/Heap.h
+++ b/vm/alloc/Heap.h
@@ -25,7 +25,7 @@ typedef struct {
/* If true, the trace is run concurrently with the mutator. */
bool isConcurrent;
/* Toggles for the soft reference clearing policy. */
- enum { CLEAR, PRESERVE } softReferencePolicy;
+ bool doPreserve;
/* A name for this garbage collection mode. */
const char *reason;
} GcSpec;
diff --git a/vm/alloc/HeapBitmap.c b/vm/alloc/HeapBitmap.cpp
index ffeff623e..ffeff623e 100644
--- a/vm/alloc/HeapBitmap.c
+++ b/vm/alloc/HeapBitmap.cpp
diff --git a/vm/alloc/HeapBitmap.h b/vm/alloc/HeapBitmap.h
index fecc2a95b..dd374cc20 100644
--- a/vm/alloc/HeapBitmap.h
+++ b/vm/alloc/HeapBitmap.h
@@ -19,6 +19,10 @@
#include <limits.h>
#include <stdint.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define HB_OBJECT_ALIGNMENT 8
#define HB_BITS_PER_WORD (sizeof(unsigned long) * CHAR_BIT)
@@ -127,4 +131,8 @@ void dvmHeapBitmapSweepWalk(const HeapBitmap *liveHb, const HeapBitmap *markHb,
uintptr_t base, uintptr_t max,
BitmapSweepCallback *callback, void *callbackArg);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _DALVIK_HEAP_BITMAP */
diff --git a/vm/alloc/HeapDebug.c b/vm/alloc/HeapDebug.cpp
index 9bd6799d0..9bd6799d0 100644
--- a/vm/alloc/HeapDebug.c
+++ b/vm/alloc/HeapDebug.cpp
diff --git a/vm/alloc/HeapDebug.h b/vm/alloc/HeapDebug.h
index f36b7abf0..3dd1d5429 100644
--- a/vm/alloc/HeapDebug.h
+++ b/vm/alloc/HeapDebug.h
@@ -16,6 +16,10 @@
#ifndef _DALVIK_HEAPDEBUG
#define _DALVIK_HEAPDEBUG
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum HeapDebugInfoType {
kVirtualHeapSize = 0,
kNativeHeapSize = 1,
@@ -29,4 +33,8 @@ typedef enum HeapDebugInfoType {
*/
int dvmGetHeapDebugInfo(HeapDebugInfoType info);
+#ifdef __cplusplus
+}
+#endif
+
#endif // _DALVIK_HEAPDEBUG
diff --git a/vm/alloc/HeapInternal.h b/vm/alloc/HeapInternal.h
index 1d1be0756..8529422cc 100644
--- a/vm/alloc/HeapInternal.h
+++ b/vm/alloc/HeapInternal.h
@@ -85,7 +85,10 @@ void dvmUnlockHeap(void);
#define LOGD_HEAP(...) LOG(LOG_DEBUG, HEAP_LOG_TAG, __VA_ARGS__)
#endif
#define LOGI_HEAP(...) \
- (!gDvm.zygote ? LOG(LOG_INFO, HEAP_LOG_TAG, __VA_ARGS__) : (void)0)
+ do { \
+ if (!gDvm.zygote) { LOG(LOG_INFO, HEAP_LOG_TAG, __VA_ARGS__); } \
+ } while (0)
+
#define LOGW_HEAP(...) LOG(LOG_WARN, HEAP_LOG_TAG, __VA_ARGS__)
#define LOGE_HEAP(...) LOG(LOG_ERROR, HEAP_LOG_TAG, __VA_ARGS__)
diff --git a/vm/alloc/HeapSource.c b/vm/alloc/HeapSource.cpp
index 4b613581a..50303b7cb 100644
--- a/vm/alloc/HeapSource.c
+++ b/vm/alloc/HeapSource.cpp
@@ -15,10 +15,12 @@
*/
#include <cutils/mspace.h>
-#include <stdint.h> // for SIZE_MAX
+#include <stdint.h>
#include <sys/mman.h>
#include <errno.h>
+#define SIZE_MAX UINT_MAX // TODO: get SIZE_MAX from stdint.h
+
#include "Dalvik.h"
#include "alloc/Heap.h"
#include "alloc/HeapInternal.h"
@@ -27,8 +29,8 @@
#include "alloc/HeapBitmapInlines.h"
// TODO: find a real header file for these.
-extern int dlmalloc_trim(size_t);
-extern void dlmalloc_walk_free_pages(void(*)(void*, void*, void*), void*);
+extern "C" int dlmalloc_trim(size_t);
+extern "C" void dlmalloc_walk_free_pages(void(*)(void*, void*, void*), void*);
static void snapIdealFootprint(void);
static void setIdealFootprint(size_t max);
diff --git a/vm/alloc/MarkSweep.c b/vm/alloc/MarkSweep.cpp
index 8e924d5bc..9b527cbc5 100644
--- a/vm/alloc/MarkSweep.c
+++ b/vm/alloc/MarkSweep.cpp
@@ -144,7 +144,7 @@ static void markObject(const Object *obj, GcMarkContext *ctx)
* marking. Marks white objects but does not push them on the mark
* stack.
*/
-static void rootMarkObjectVisitor(void *addr, RootType type, u4 thread,
+static void rootMarkObjectVisitor(void *addr, u4 thread, RootType type,
void *arg)
{
Object *obj;
@@ -363,7 +363,7 @@ void dvmHeapMarkRootSet()
* Callback applied to root references during root remarking. Marks
* white objects and pushes them on the mark stack.
*/
-static void rootReMarkObjectVisitor(void *addr, RootType type, u4 thread,
+static void rootReMarkObjectVisitor(void *addr, u4 thread, RootType type,
void *arg)
{
Object *obj;
@@ -492,7 +492,7 @@ static void scanArrayObject(const Object *obj, GcMarkContext *ctx)
markObject((const Object *)obj->clazz, ctx);
if (IS_CLASS_FLAG_SET(obj->clazz, CLASS_ISOBJECTARRAY)) {
const ArrayObject *array = (const ArrayObject *)obj;
- const Object **contents = (const Object **)array->contents;
+ const Object **contents = (const Object **)(void *)array->contents;
size_t i;
for (i = 0; i < array->length; ++i) {
markObject(contents[i], ctx);
diff --git a/vm/alloc/Verify.c b/vm/alloc/Verify.cpp
index f36f44bf1..f36f44bf1 100644
--- a/vm/alloc/Verify.c
+++ b/vm/alloc/Verify.cpp
diff --git a/vm/alloc/Visit.c b/vm/alloc/Visit.cpp
index 6ca143992..6ca143992 100644
--- a/vm/alloc/Visit.c
+++ b/vm/alloc/Visit.cpp
diff --git a/vm/alloc/Visit.h b/vm/alloc/Visit.h
index a66839d14..1616889cc 100644
--- a/vm/alloc/Visit.h
+++ b/vm/alloc/Visit.h
@@ -19,6 +19,10 @@
#include "Dalvik.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum {
ROOT_UNKNOWN = 0,
ROOT_JNI_GLOBAL,
@@ -58,4 +62,8 @@ void dvmVisitObject(Visitor *visitor, Object *obj, void *arg);
*/
void dvmVisitRoots(RootVisitor *visitor, void *arg);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _DALVIK_ALLOC_VISIT */
diff --git a/vm/alloc/VisitInlines.h b/vm/alloc/VisitInlines.h
index 7f90678f0..eb889af57 100644
--- a/vm/alloc/VisitInlines.h
+++ b/vm/alloc/VisitInlines.h
@@ -120,7 +120,7 @@ static void visitArrayObject(Visitor *visitor, Object *obj, void *arg)
(*visitor)(&obj->clazz, arg);
if (IS_CLASS_FLAG_SET(obj->clazz, CLASS_ISOBJECTARRAY)) {
ArrayObject *array = (ArrayObject *)obj;
- Object **contents = (Object **)array->contents;
+ Object **contents = (Object **)(void *)array->contents;
size_t i;
for (i = 0; i < array->length; ++i) {
(*visitor)(&contents[i], arg);
diff --git a/vm/alloc/WriteBarrier.h b/vm/alloc/WriteBarrier.h
index dd8f129c0..4c660a077 100644
--- a/vm/alloc/WriteBarrier.h
+++ b/vm/alloc/WriteBarrier.h
@@ -17,6 +17,10 @@
#ifndef _DALVIK_ALLOC_WRITEBARRIER
#define _DALVIK_ALLOC_WRITEBARRIER
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Note writes to the heap. These functions must be called if a field
* of an Object in the heap changes, and before any GC safe-point. The
@@ -50,4 +54,8 @@ INLINE void dvmWriteBarrierArray(const ArrayObject *obj,
dvmMarkCard((Object *)obj);
}
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _DALVIK_ALLOC_WRITEBARRIER */
diff --git a/vm/analysis/CodeVerify.h b/vm/analysis/CodeVerify.h
index 9369537a5..4fbf700d4 100644
--- a/vm/analysis/CodeVerify.h
+++ b/vm/analysis/CodeVerify.h
@@ -23,6 +23,9 @@
#include "analysis/VerifySubs.h"
#include "analysis/VfyBasicBlock.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
* Enumeration for register type values. The "hi" piece of a 64-bit value
@@ -322,4 +325,8 @@ void dvmFreeUninitInstanceMap(UninitInstanceMap* uninitMap);
*/
bool dvmVerifyCodeFlow(VerifierData* vdata);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_CODEVERIFY*/
diff --git a/vm/analysis/RegisterMap.h b/vm/analysis/RegisterMap.h
index 886d0b06f..becb1de39 100644
--- a/vm/analysis/RegisterMap.h
+++ b/vm/analysis/RegisterMap.h
@@ -25,6 +25,10 @@
#include "analysis/VerifySubs.h"
#include "analysis/CodeVerify.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Format enumeration for RegisterMap data area.
*/
@@ -263,4 +267,8 @@ INLINE const RegisterMap* dvmGetExpandedRegisterMap(Method* method)
/* dump stats gathered during register map creation process */
void dvmRegisterMapDumpStats(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_REGISTERMAP*/
diff --git a/vm/compiler/Compiler.h b/vm/compiler/Compiler.h
index 35d34b3e2..384cb1414 100644
--- a/vm/compiler/Compiler.h
+++ b/vm/compiler/Compiler.h
@@ -14,12 +14,16 @@
* limitations under the License.
*/
-#include <Thread.h>
-#include <setjmp.h>
-
#ifndef _DALVIK_VM_COMPILER
#define _DALVIK_VM_COMPILER
+#include <setjmp.h>
+#include "Thread.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Uncomment the following to enable JIT signature breakpoint
* #define SIGNATURE_BREAKPOINT
@@ -241,4 +245,9 @@ void *dvmCompilerGetInterpretTemplate();
JitInstructionSetType dvmCompilerGetInterpretTemplateSet();
u8 dvmGetRegResourceMask(int reg);
void dvmDumpCFG(struct CompilationUnit *cUnit, const char *dirPrefix);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _DALVIK_VM_COMPILER */
diff --git a/vm/hprof/Hprof.c b/vm/hprof/Hprof.cpp
index 3f5e3162f..3f5e3162f 100644
--- a/vm/hprof/Hprof.c
+++ b/vm/hprof/Hprof.cpp
diff --git a/vm/hprof/Hprof.h b/vm/hprof/Hprof.h
index c62dd9cc8..1721a6e9a 100644
--- a/vm/hprof/Hprof.h
+++ b/vm/hprof/Hprof.h
@@ -18,6 +18,10 @@
#include "Dalvik.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define HPROF_ID_SIZE (sizeof (u4))
#define UNIQUE_ERROR() \
@@ -144,7 +148,7 @@ typedef struct hprof_context_t {
/*
- * HprofString.c functions
+ * HprofString.cpp functions
*/
hprof_string_id hprofLookupStringId(const char *str);
@@ -156,7 +160,7 @@ int hprofShutdown_String(void);
/*
- * HprofClass.c functions
+ * HprofClass.cpp functions
*/
hprof_class_object_id hprofLookupClassId(const ClassObject *clazz);
@@ -168,7 +172,7 @@ int hprofShutdown_Class(void);
/*
- * HprofHeap.c functions
+ * HprofHeap.cpp functions
*/
int hprofStartHeapDump(hprof_context_t *ctx);
@@ -182,7 +186,7 @@ int hprofMarkRootObject(hprof_context_t *ctx,
int hprofDumpHeapObject(hprof_context_t *ctx, const Object *obj);
/*
- * HprofOutput.c functions
+ * HprofOutput.cpp functions
*/
void hprofContextInit(hprof_context_t *ctx, char *fileName, int fd,
@@ -215,18 +219,17 @@ int hprofAddU8ListToRecord(hprof_record_t *rec,
hprofAddU4ListToRecord((rec), (const u4 *)(values), (numValues))
/*
- * Hprof.c functions
+ * Hprof.cpp functions
*/
hprof_context_t* hprofStartup(const char *outputFileName, int fd,
bool directToDdms);
bool hprofShutdown(hprof_context_t *ctx);
void hprofFreeContext(hprof_context_t *ctx);
-
-/*
- * HprofVisit.c functions
- */
-
int hprofDumpHeap(const char* fileName, int fd, bool directToDdms);
+#ifdef __cplusplus
+}
+#endif
+
#endif // _DALVIK_HPROF_HPROF
diff --git a/vm/hprof/HprofClass.c b/vm/hprof/HprofClass.cpp
index 755e96855..755e96855 100644
--- a/vm/hprof/HprofClass.c
+++ b/vm/hprof/HprofClass.cpp
diff --git a/vm/hprof/HprofHeap.c b/vm/hprof/HprofHeap.cpp
index ee24a7aa1..8ec0100ee 100644
--- a/vm/hprof/HprofHeap.c
+++ b/vm/hprof/HprofHeap.cpp
@@ -129,7 +129,7 @@ hprofMarkRootObject(hprof_context_t *ctx, const Object *obj, jobject jniObj)
{
hprof_record_t *rec = &ctx->curRec;
int err;
- hprof_heap_tag_t heapTag = ctx->gcScanState;
+ hprof_heap_tag_t heapTag = (hprof_heap_tag_t)ctx->gcScanState;
if (heapTag == 0) {
return 0;
@@ -382,7 +382,7 @@ hprofDumpHeapObject(hprof_context_t *ctx, const Object *obj)
/* Dump the elements, which are always objects or NULL.
*/
hprofAddIdListToRecord(rec,
- (const hprof_object_id *)aobj->contents, length);
+ (const hprof_object_id *)(void *)aobj->contents, length);
} else {
hprof_basic_type t;
size_t size;
@@ -410,10 +410,10 @@ hprofDumpHeapObject(hprof_context_t *ctx, const Object *obj)
hprofAddU1ListToRecord(rec, (const u1 *)aobj->contents,
length);
} else if (size == 2) {
- hprofAddU2ListToRecord(rec, (const u2 *)aobj->contents,
+ hprofAddU2ListToRecord(rec, (const u2 *)(void *)aobj->contents,
length);
} else if (size == 4) {
- hprofAddU4ListToRecord(rec, (const u4 *)aobj->contents,
+ hprofAddU4ListToRecord(rec, (const u4 *)(void *)aobj->contents,
length);
} else if (size == 8) {
hprofAddU8ListToRecord(rec, (const u8 *)aobj->contents,
diff --git a/vm/hprof/HprofOutput.c b/vm/hprof/HprofOutput.cpp
index b84b29852..b84b29852 100644
--- a/vm/hprof/HprofOutput.c
+++ b/vm/hprof/HprofOutput.cpp
diff --git a/vm/hprof/HprofString.c b/vm/hprof/HprofString.cpp
index 3f697f58c..3f697f58c 100644
--- a/vm/hprof/HprofString.c
+++ b/vm/hprof/HprofString.cpp
diff --git a/vm/interp/Jit.h b/vm/interp/Jit.h
index 7dbe9ac78..67b9b4a3e 100644
--- a/vm/interp/Jit.h
+++ b/vm/interp/Jit.h
@@ -22,6 +22,10 @@
#include "InterpDefs.h"
#include "mterp/common/jit-config.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define JIT_MAX_TRACE_LEN 100
#if defined (WITH_SELF_VERIFICATION)
@@ -166,4 +170,8 @@ void dvmJitUpdateThreadStateSingle(Thread* threead);
void dvmJitUpdateThreadStateAll(void);
void dvmJitResumeTranslation(Thread* self, const u2* pc, const u4* fp);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_INTERP_JIT*/
diff --git a/vm/interp/Stack.h b/vm/interp/Stack.h
index 10c04a0d2..403cae23c 100644
--- a/vm/interp/Stack.h
+++ b/vm/interp/Stack.h
@@ -23,6 +23,9 @@
#include "jni.h"
#include <stdarg.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
Stack layout
@@ -279,4 +282,8 @@ void dvmCleanupStackOverflow(Thread* self, const Object* exception);
void dvmDumpThreadStack(const DebugOutputTarget* target, Thread* thread);
void dvmDumpRunningThreadStack(const DebugOutputTarget* target, Thread* thread);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_INTERP_STACK*/
diff --git a/vm/native/InternalNative.h b/vm/native/InternalNative.h
index 7c82dc0cb..4d32de2db 100644
--- a/vm/native/InternalNative.h
+++ b/vm/native/InternalNative.h
@@ -17,6 +17,10 @@
#ifndef _DALVIK_NATIVE_INTERNALNATIVE
#define _DALVIK_NATIVE_INTERNALNATIVE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Some setup for internal native functions.
*/
@@ -29,4 +33,8 @@ DalvikNativeFunc dvmLookupInternalNativeMethod(const Method* method);
/* exception-throwing stub for abstract methods (DalvikNativeFunc) */
void dvmAbstractMethodStub(const u4* args, JValue* pResult);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_NATIVE_INTERNALNATIVE*/
diff --git a/vm/native/InternalNativePriv.h b/vm/native/InternalNativePriv.h
index 440e60d9d..35ab44c7d 100644
--- a/vm/native/InternalNativePriv.h
+++ b/vm/native/InternalNativePriv.h
@@ -20,6 +20,10 @@
#ifndef _DALVIK_NATIVE_INTERNALNATIVEPRIV
#define _DALVIK_NATIVE_INTERNALNATIVEPRIV
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Return macros. Note we use "->i" instead of "->z" for boolean; this
* is because the interpreter expects everything to be a 32-bit value.
@@ -112,4 +116,8 @@ extern const DalvikNativeMethod dvm_org_apache_harmony_dalvik_ddmc_DdmVmInternal
extern const DalvikNativeMethod dvm_org_apache_harmony_dalvik_NativeTestTarget[];
extern const DalvikNativeMethod dvm_sun_misc_Unsafe[];
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_NATIVE_INTERNALNATIVEPRIV*/
diff --git a/vm/oo/AccessCheck.h b/vm/oo/AccessCheck.h
index 105c9e1b5..8633d89c7 100644
--- a/vm/oo/AccessCheck.h
+++ b/vm/oo/AccessCheck.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_OO_ACCESSCHECK
#define _DALVIK_OO_ACCESSCHECK
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Determine whether the "accessFrom" class is allowed to get at "clazz".
*/
@@ -40,4 +44,8 @@ bool dvmCheckFieldAccess(const ClassObject* accessFrom, const Field* field);
*/
bool dvmInSamePackage(const ClassObject* class1, const ClassObject* class2);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_OO_ACCESSCHECK*/
diff --git a/vm/oo/Array.h b/vm/oo/Array.h
index 9a873e6b9..585f8966e 100644
--- a/vm/oo/Array.h
+++ b/vm/oo/Array.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_OO_ARRAY
#define _DALVIK_OO_ARRAY
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* width of an object reference, for arrays of objects */
#define kObjectArrayRefWidth sizeof(Object*)
@@ -167,4 +171,8 @@ size_t dvmArrayObjectSize(const ArrayObject *array);
*/
size_t dvmArrayClassElementWidth(const ClassObject* clazz);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_OO_ARRAY*/
diff --git a/vm/oo/Class.h b/vm/oo/Class.h
index 3ad44bd5b..43a3954ae 100644
--- a/vm/oo/Class.h
+++ b/vm/oo/Class.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_OO_CLASS
#define _DALVIK_OO_CLASS
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* The classpath and bootclasspath differ in that only the latter is
* consulted when looking for classes needed by the VM. When searching
@@ -285,4 +289,8 @@ int dvmCompareNameDescriptorAndMethod(const char* name,
*/
size_t dvmClassObjectSize(const ClassObject *clazz);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_OO_CLASS*/
diff --git a/vm/oo/Object.h b/vm/oo/Object.h
index b32d5b92e..86c0b95f9 100644
--- a/vm/oo/Object.h
+++ b/vm/oo/Object.h
@@ -21,9 +21,12 @@
#ifndef _DALVIK_OO_OBJECT
#define _DALVIK_OO_OBJECT
-#include <Atomic.h>
-
#include <stddef.h>
+#include "Atomic.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/* fwd decl */
struct DataObject;
@@ -779,4 +782,8 @@ INLINE u4 dvmGetMethodInsnsSize(const Method* meth) {
/* debugging */
void dvmDumpObject(const Object* obj);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_OO_OBJECT*/
diff --git a/vm/oo/ObjectInlines.h b/vm/oo/ObjectInlines.h
index ef01834c4..1579a56c7 100644
--- a/vm/oo/ObjectInlines.h
+++ b/vm/oo/ObjectInlines.h
@@ -20,6 +20,10 @@
#ifndef _DALVIK_OO_OBJECTINLINES
#define _DALVIK_OO_OBJECTINLINES
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Store a single value in the array, and if the value isn't null,
* note in the write barrier.
@@ -354,4 +358,8 @@ INLINE void dvmSetStaticFieldObjectVolatile(StaticField* sfield, Object* val) {
}
}
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_OO_OBJECTINLINES*/
diff --git a/vm/oo/Resolve.h b/vm/oo/Resolve.h
index 70b22942e..1403e772d 100644
--- a/vm/oo/Resolve.h
+++ b/vm/oo/Resolve.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_OO_RESOLVE
#define _DALVIK_OO_RESOLVE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* "Direct" and "virtual" methods are stored independently. The type of call
* used to invoke the method determines which list we search, and whether
@@ -92,4 +96,8 @@ StringObject* dvmResolveString(const ClassObject* referrer, u4 stringIdx);
*/
const char* dvmMethodTypeStr(MethodType methodType);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_OO_RESOLVE*/
diff --git a/vm/oo/TypeCheck.h b/vm/oo/TypeCheck.h
index 139799890..07bae47c6 100644
--- a/vm/oo/TypeCheck.h
+++ b/vm/oo/TypeCheck.h
@@ -19,6 +19,10 @@
#ifndef _DALVIK_OO_TYPECHECK
#define _DALVIK_OO_TYPECHECK
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* VM startup/shutdown */
bool dvmInstanceofStartup(void);
void dvmInstanceofShutdown(void);
@@ -75,4 +79,8 @@ INLINE int dvmIsSubClass(const ClassObject* sub, const ClassObject* clazz) {
bool dvmCanPutArrayElement(const ClassObject* elemClass,
const ClassObject* arrayClass);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*_DALVIK_OO_TYPECHECK*/