Get rid of uneeded extern, enum, typedef and struct qualifiers.
Change-Id: I236c5a1553a51f82c9bc3eaaab042046c854d3b4
diff --git a/dexdump/DexDump.cpp b/dexdump/DexDump.cpp
index 7d11752..59f149b 100644
--- a/dexdump/DexDump.cpp
+++ b/dexdump/DexDump.cpp
@@ -241,10 +241,10 @@
/*
* Flag for use with createAccessFlagStr().
*/
-typedef enum AccessFor {
+enum AccessFor {
kAccessForClass = 0, kAccessForMethod = 1, kAccessForField = 2,
kAccessForMAX
-} AccessFor;
+};
/*
* Create a new string with human-readable access flags.
diff --git a/vm/AllocTracker.h b/vm/AllocTracker.h
index fa8ba75..16d5168 100644
--- a/vm/AllocTracker.h
+++ b/vm/AllocTracker.h
@@ -19,16 +19,11 @@
#ifndef _DALVIK_ALLOCTRACKER
#define _DALVIK_ALLOCTRACKER
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* initialization */
bool dvmAllocTrackerStartup(void);
void dvmAllocTrackerShutdown(void);
struct AllocRecord;
-typedef struct AllocRecord AllocRecord;
/*
* Enable allocation tracking. Does nothing if tracking is already enabled.
@@ -64,8 +59,4 @@
*/
void dvmDumpTrackedAllocations(bool enable);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_ALLOCTRACKER*/
diff --git a/vm/Atomic.h b/vm/Atomic.h
index 713c5b4..9d43332 100644
--- a/vm/Atomic.h
+++ b/vm/Atomic.h
@@ -23,10 +23,6 @@
#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,
@@ -42,12 +38,12 @@
* Swap the 64-bit value at "addr" with "value". Returns the previous
* value.
*/
-int64_t dvmQuasiAtomicSwap64(int64_t value, volatile int64_t* addr);
+extern "C" int64_t dvmQuasiAtomicSwap64(int64_t value, volatile int64_t* addr);
/*
* Read the 64-bit value at "addr".
*/
-int64_t dvmQuasiAtomicRead64(volatile const int64_t* addr);
+extern "C" int64_t dvmQuasiAtomicRead64(volatile const int64_t* addr);
/*
* If the value at "addr" is equal to "oldvalue", replace it with "newvalue"
@@ -56,8 +52,4 @@
int dvmQuasiAtomicCas64(int64_t oldvalue, int64_t newvalue,
volatile int64_t* addr);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_ATOMIC*/
diff --git a/vm/AtomicCache.h b/vm/AtomicCache.h
index 2342162..29f1ebc 100644
--- a/vm/AtomicCache.h
+++ b/vm/AtomicCache.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_ATOMICCACHE
#define _DALVIK_ATOMICCACHE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* If set to "1", gather some stats on our caching success rate.
*/
@@ -35,12 +31,12 @@
*
* Must be exactly 16 bytes.
*/
-typedef struct AtomicCacheEntry {
+struct AtomicCacheEntry {
u4 key1;
u4 key2;
u4 value;
volatile u4 version; /* version and lock flag */
-} AtomicCacheEntry;
+};
/*
* One cache.
@@ -49,7 +45,7 @@
* struct and "entries" separately, avoiding an indirection. (We already
* handle "numEntries" separately in ATOMIC_CACHE_LOOKUP.)
*/
-typedef struct AtomicCache {
+struct AtomicCache {
AtomicCacheEntry* entries; /* array of entries */
int numEntries; /* #of entries, must be power of 2 */
@@ -61,7 +57,7 @@
int hits; /* found entry in cache */
int misses; /* entry was for other keys */
int fills; /* entry was empty */
-} AtomicCache;
+};
/*
* Do a cache lookup. We need to be able to read and write entries
@@ -174,8 +170,4 @@
*/
void dvmDumpAtomicCacheStats(const AtomicCache* pCache);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_ATOMICCACHE*/
diff --git a/vm/BitVector.h b/vm/BitVector.h
index 0d23350..01e2f1b 100644
--- a/vm/BitVector.h
+++ b/vm/BitVector.h
@@ -20,28 +20,24 @@
#ifndef _DALVIK_BITVECTOR
#define _DALVIK_BITVECTOR
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Expanding bitmap, used for tracking resources. Bits are numbered starting
* from zero.
*
* All operations on a BitVector are unsynchronized.
*/
-typedef struct BitVector {
+struct BitVector {
bool expandable; /* expand bitmap if we run out? */
u4 storageSize; /* current size, in 32-bit words */
u4* storage;
-} BitVector;
+};
/* Handy iterator to walk through the bit positions set to 1 */
-typedef struct BitVectorIterator {
+struct BitVectorIterator {
BitVector *pBits;
u4 idx;
u4 bitSize;
-} BitVectorIterator;
+};
/* allocate a bit vector with enough space to hold "startBits" bits */
BitVector* dvmAllocBitVector(unsigned int startBits, bool expandable);
@@ -104,8 +100,4 @@
/* 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 0ec9ec4..637ed18 100644
--- a/vm/Common.h
+++ b/vm/Common.h
@@ -31,10 +31,6 @@
#include <endian.h>
#include "utils/Log.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#if !defined(NDEBUG) && defined(WITH_DALVIK_ASSERT)
# undef assert
# define assert(x) \
@@ -106,8 +102,4 @@
#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_COMMON*/
diff --git a/vm/Ddm.h b/vm/Ddm.h
index af7f6e1..01f5d18 100644
--- a/vm/Ddm.h
+++ b/vm/Ddm.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_DDM
#define _DALVIK_DDM
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Handle a packet full of DDM goodness.
*
@@ -88,8 +84,4 @@
*/
ArrayObject* dvmDdmGetRecentAllocations(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_DDM*/
diff --git a/vm/Debugger.cpp b/vm/Debugger.cpp
index ae3bb77..a9c8b98 100644
--- a/vm/Debugger.cpp
+++ b/vm/Debugger.cpp
@@ -153,9 +153,9 @@
/* keep track of type, in case we need to distinguish them someday */
-typedef enum RegistryType {
+enum RegistryType {
kObjectId = 0xc1, kRefTypeId
-} RegistryType;
+};
/*
* Hash function for object IDs. Since objects are at least 8 bytes, and
@@ -1282,12 +1282,12 @@
}
}
-typedef struct DebugCallbackContext {
+struct DebugCallbackContext {
int numItems;
ExpandBuf* pReply;
// used by locals table
bool withGeneric;
-} DebugCallbackContext;
+};
static int lineTablePositionsCb(void *cnxt, u4 address, u4 lineNum)
{
@@ -2570,8 +2570,8 @@
* The JDWP event mechanism has registered a single-step event. Tell
* the interpreter about it.
*/
-bool dvmDbgConfigureStep(ObjectId threadId, enum JdwpStepSize size,
- enum JdwpStepDepth depth)
+bool dvmDbgConfigureStep(ObjectId threadId, JdwpStepSize size,
+ JdwpStepDepth depth)
{
Object* threadObj;
Thread* thread;
@@ -2854,12 +2854,12 @@
}
// for dvmAddressSetForLine
-typedef struct AddressSetContext {
+struct AddressSetContext {
bool lastAddressValid;
u4 lastAddress;
u4 lineNum;
AddressSet *pSet;
-} AddressSetContext;
+};
// for dvmAddressSetForLine
static int addressSetCb (void *cnxt, u4 address, u4 lineNum)
diff --git a/vm/Debugger.h b/vm/Debugger.h
index dd9679f..aaef02d 100644
--- a/vm/Debugger.h
+++ b/vm/Debugger.h
@@ -26,10 +26,6 @@
#include "Misc.h"
#include "jdwp/Jdwp.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* fwd decl */
struct Object;
struct ClassObject;
@@ -40,10 +36,10 @@
* Used by StepControl to track a set of addresses associated with
* a single line.
*/
-typedef struct AddressSet {
+struct AddressSet {
u4 setSize;
u1 set[1];
-} AddressSet;
+};
INLINE void dvmAddressSetSet(AddressSet *pSet, u4 toSet)
{
@@ -64,24 +60,24 @@
/*
* Single-step management.
*/
-typedef struct StepControl {
+struct StepControl {
/* request */
- enum JdwpStepSize size;
- enum JdwpStepDepth depth;
- struct Thread* thread; /* don't deref; for comparison only */
+ JdwpStepSize size;
+ JdwpStepDepth depth;
+ Thread* thread; /* don't deref; for comparison only */
/* current state */
- bool active;
- const struct Method* method;
- int line; /* line #; could be -1 */
- const AddressSet* pAddressSet; /* if non-null, address set for line */
- int frameDepth;
-} StepControl;
+ bool active;
+ const Method* method;
+ int line; /* line #; could be -1 */
+ const AddressSet* pAddressSet; /* if non-null, address set for line */
+ int frameDepth;
+};
/*
* Invoke-during-breakpoint support.
*/
-typedef struct DebugInvokeReq {
+struct DebugInvokeReq {
/* boolean; only set when we're in the tail end of an event handler */
bool ready;
@@ -89,24 +85,24 @@
bool invokeNeeded;
/* request */
- struct Object* obj; /* not used for ClassType.InvokeMethod */
- struct Object* thread;
- struct ClassObject* clazz;
- struct Method* method;
- u4 numArgs;
- u8* argArray; /* will be NULL if numArgs==0 */
- u4 options;
+ Object* obj; /* not used for ClassType.InvokeMethod */
+ Object* thread;
+ ClassObject* clazz;
+ Method* method;
+ u4 numArgs;
+ u8* argArray; /* will be NULL if numArgs==0 */
+ u4 options;
/* result */
- JdwpError err;
- u1 resultTag;
- JValue resultValue;
- ObjectId exceptObj;
+ JdwpError err;
+ u1 resultTag;
+ JValue resultValue;
+ ObjectId exceptObj;
/* condition variable to wait on while the method executes */
- pthread_mutex_t lock;
- pthread_cond_t cv;
-} DebugInvokeReq;
+ pthread_mutex_t lock;
+ pthread_cond_t cv;
+};
/* system init/shutdown */
bool dvmDebuggerStartup(void);
@@ -264,14 +260,13 @@
/*
* Debugger notification
*/
-void dvmDbgPostLocationEvent(const struct Method* method, int pcOffset,
- struct Object* thisPtr, int eventFlags);
+void dvmDbgPostLocationEvent(const Method* method, int pcOffset,
+ Object* thisPtr, int eventFlags);
void dvmDbgPostException(void* throwFp, int throwRelPc, void* catchFp,
- int catchRelPc, struct Object* exception);
-void dvmDbgPostThreadStart(struct Thread* thread);
-void dvmDbgPostThreadDeath(struct Thread* thread);
-void dvmDbgPostClassPrepare(struct ClassObject* clazz);
-// FieldAccess, FieldModification
+ int catchRelPc, Object* exception);
+void dvmDbgPostThreadStart(Thread* thread);
+void dvmDbgPostThreadDeath(Thread* thread);
+void dvmDbgPostClassPrepare(ClassObject* clazz);
/* for "eventFlags" */
enum {
@@ -283,8 +278,8 @@
bool dvmDbgWatchLocation(const JdwpLocation* pLoc);
void dvmDbgUnwatchLocation(const JdwpLocation* pLoc);
-bool dvmDbgConfigureStep(ObjectId threadId, enum JdwpStepSize size,
- enum JdwpStepDepth depth);
+bool dvmDbgConfigureStep(ObjectId threadId, JdwpStepSize size,
+ JdwpStepDepth depth);
void dvmDbgUnconfigureStep(ObjectId threadId);
JdwpError dvmDbgInvokeMethod(ObjectId threadId, ObjectId objectId,
@@ -293,7 +288,7 @@
void dvmDbgExecuteMethod(DebugInvokeReq* pReq);
/* Make an AddressSet for a line, for single stepping */
-const AddressSet *dvmAddressSetForLine(const struct Method* method, int line);
+const AddressSet *dvmAddressSetForLine(const Method* method, int line);
/* perform "late registration" of an object ID */
void dvmDbgRegisterObjectId(ObjectId id);
@@ -311,8 +306,4 @@
#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/DvmDex.h b/vm/DvmDex.h
index 937f09d..df14760 100644
--- a/vm/DvmDex.h
+++ b/vm/DvmDex.h
@@ -21,10 +21,6 @@
#ifndef _DALVIK_DVMDEX
#define _DALVIK_DVMDEX
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "libdex/DexFile.h"
/* extern */
@@ -38,7 +34,7 @@
/*
* Some additional VM data structures that are associated with the DEX file.
*/
-typedef struct DvmDex {
+struct DvmDex {
/* pointer to the DexFile we're associated with */
DexFile* pDexFile;
@@ -67,7 +63,7 @@
/* lock ensuring mutual exclusion during updates */
pthread_mutex_t modLock;
-} DvmDex;
+};
/*
@@ -162,8 +158,4 @@
pDvmDex->pResFields[fieldIdx] = field;
}
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_DVMDEX*/
diff --git a/vm/Exception.h b/vm/Exception.h
index 24c0eb4..81a0e76 100644
--- a/vm/Exception.h
+++ b/vm/Exception.h
@@ -20,10 +20,6 @@
#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").
@@ -177,7 +173,7 @@
* Returns the offset to the catch code on success, or -1 if we couldn't
* find a catcher.
*/
-int dvmFindCatchBlock(Thread* self, int relPc, Object* exception,
+extern "C" int dvmFindCatchBlock(Thread* self, int relPc, Object* exception,
bool doUnroll, void** newFrame);
/*
@@ -216,21 +212,20 @@
* Throw an ArithmeticException in the current thread, with the given detail
* message.
*/
-void dvmThrowArithmeticException(const char* msg);
+extern "C" void dvmThrowArithmeticException(const char* msg);
/*
* Throw an ArrayIndexOutOfBoundsException in the current thread,
* using the given array length and index in the detail message.
*/
-void dvmThrowArrayIndexOutOfBoundsException(int length, int index);
+extern "C" void dvmThrowArrayIndexOutOfBoundsException(int length, int index);
/*
* Throw an ArrayStoreException in the current thread, using the given classes'
* names in the detail message, indicating that an object of the given type
* can't be stored into an array of the given type.
*/
-void dvmThrowArrayStoreExceptionIncompatibleElement(ClassObject* objectType,
- ClassObject* arrayType);
+extern "C" void dvmThrowArrayStoreExceptionIncompatibleElement(ClassObject* objectType, ClassObject* arrayType);
/*
* Throw an ArrayStoreException in the current thread, using the given
@@ -259,7 +254,7 @@
* Throw a ClassCastException in the current thread, using the given classes'
* names in the detail message.
*/
-void dvmThrowClassCastException(ClassObject* actual, ClassObject* desired);
+extern "C" void dvmThrowClassCastException(ClassObject* actual, ClassObject* desired);
/**
* Throw a ClassCircularityError in the current thread, with the
@@ -365,7 +360,7 @@
* Throw an InternalError in the current thread, with the given
* detail message.
*/
-void dvmThrowInternalError(const char* msg);
+extern "C" void dvmThrowInternalError(const char* msg);
/**
* Throw an InterruptedException in the current thread, with the given
@@ -383,13 +378,13 @@
* Throw a NegativeArraySizeException in the current thread, with the
* given number as the detail message.
*/
-void dvmThrowNegativeArraySizeException(s4 size);
+extern "C" void dvmThrowNegativeArraySizeException(s4 size);
/**
* Throw a NoClassDefFoundError in the current thread, with the
* human-readable form of the given descriptor as the detail message.
*/
-void dvmThrowNoClassDefFoundError(const char* descriptor);
+extern "C" void dvmThrowNoClassDefFoundError(const char* descriptor);
/**
* Throw a NoClassDefFoundError in the current thread, with the given
@@ -403,7 +398,7 @@
* Throw a NoSuchFieldError in the current thread, with the given
* detail message.
*/
-void dvmThrowNoSuchFieldError(const char* msg);
+extern "C" void dvmThrowNoSuchFieldError(const char* msg);
/**
* Throw a NoSuchFieldException in the current thread, with the given
@@ -415,13 +410,13 @@
* Throw a NoSuchMethodError in the current thread, with the given
* detail message.
*/
-void dvmThrowNoSuchMethodError(const char* msg);
+extern "C" void dvmThrowNoSuchMethodError(const char* msg);
/**
* Throw a NullPointerException in the current thread, with the given
* detail message.
*/
-void dvmThrowNullPointerException(const char* msg);
+extern "C" void dvmThrowNullPointerException(const char* msg);
/**
* Throw an OutOfMemoryError in the current thread, with the given
@@ -487,8 +482,4 @@
*/
void dvmThrowVirtualMachineError(const char* msg);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_EXCEPTION*/
diff --git a/vm/Globals.h b/vm/Globals.h
index 6b5d786..db552c6 100644
--- a/vm/Globals.h
+++ b/vm/Globals.h
@@ -33,24 +33,20 @@
#include <stdarg.h>
#include <pthread.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* private structures */
-typedef struct GcHeap GcHeap;
-typedef struct BreakpointSet BreakpointSet;
-typedef struct InlineSub InlineSub;
+struct GcHeap;
+struct BreakpointSet;
+struct InlineSub;
/*
* One of these for each -ea/-da/-esa/-dsa on the command line.
*/
-typedef struct AssertionControl {
+struct AssertionControl {
char* pkgOrClass; /* package/class string, or NULL for esa/dsa */
int pkgOrClassLen; /* string length, for quick compare */
bool enable; /* enable or disable */
bool isPackage; /* string ended with "..."? */
-} AssertionControl;
+};
/*
* Register map generation mode. Only applicable when generateRegisterMaps
@@ -62,11 +58,11 @@
* maps, but allows type-precise GC. "LivePrecise" is even slower and
* requires additional heap during processing, but allows live-precise GC.
*/
-typedef enum {
+enum RegisterMapMode {
kRegisterMapModeUnknown = 0,
kRegisterMapModeTypePrecise,
kRegisterMapModeLivePrecise
-} RegisterMapMode;
+};
/*
* All fields are initialized to zero.
@@ -723,25 +719,25 @@
#if defined(WITH_JIT)
/* Trace profiling modes. Ordering matters - off states before on states */
-typedef enum TraceProfilingModes {
+enum TraceProfilingModes {
kTraceProfilingDisabled = 0, // Not profiling
kTraceProfilingPeriodicOff = 1, // Periodic profiling, off phase
kTraceProfilingContinuous = 2, // Always profiling
kTraceProfilingPeriodicOn = 3 // Periodic profiling, on phase
-} TraceProfilingModes;
+};
/*
* Exiting the compiled code w/o chaining will incur overhead to look up the
* target in the code cache which is extra work only when JIT is enabled. So
* we want to monitor it closely to make sure we don't have performance bugs.
*/
-typedef enum NoChainExits {
+enum NoChainExits {
kInlineCacheMiss = 0,
kCallsiteInterpreted,
kSwitchOverflow,
kHeavyweightMonitor,
kNoChainExitLast,
-} NoChainExits;
+};
/*
* JIT-specific global state
@@ -968,8 +964,4 @@
extern struct DvmJniGlobals gDvmJni;
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_GLOBALS*/
diff --git a/vm/Hash.h b/vm/Hash.h
index 2c6bd5e..12af8a7 100644
--- a/vm/Hash.h
+++ b/vm/Hash.h
@@ -22,10 +22,6 @@
#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);
@@ -62,10 +58,10 @@
*
* When an entry is released, we will call (HashFreeFunc)(entry->data).
*/
-typedef struct HashEntry {
+struct HashEntry {
u4 hashValue;
void* data;
-} HashEntry;
+};
#define HASH_TOMBSTONE ((void*) 0xcbcacccd) // invalid ptr value
@@ -74,14 +70,14 @@
*
* This structure should be considered opaque.
*/
-typedef struct HashTable {
+struct HashTable {
int tableSize; /* must be power of 2 */
int numEntries; /* current #of "live" entries */
int numDeadEntries; /* current #of tombstone entries */
HashEntry* pEntries; /* array on heap */
HashFreeFunc freeFunc;
pthread_mutex_t lock;
-} HashTable;
+};
/*
* Create and initialize a HashTable structure, using "initialSize" as
@@ -183,11 +179,11 @@
* MyData* data = (MyData*)dvmHashIterData(&iter);
* }
*/
-typedef struct HashIter {
+struct HashIter {
void* data;
HashTable* pHashTable;
int idx;
-} HashIter;
+};
INLINE void dvmHashIterNext(HashIter* pIter) {
int i = pIter->idx +1;
int lim = pIter->pHashTable->tableSize;
@@ -222,8 +218,4 @@
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 36d18ba..165bfb1 100644
--- a/vm/IndirectRefTable.h
+++ b/vm/IndirectRefTable.h
@@ -17,10 +17,6 @@
#ifndef _DALVIK_INDIRECTREFTABLE
#define _DALVIK_INDIRECTREFTABLE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Maintain a table of indirect references. Used for local/global JNI
* references.
@@ -95,22 +91,22 @@
*
* For convenience these match up with enum jobjectRefType from jni.h.
*/
-typedef enum IndirectRefKind {
+enum IndirectRefKind {
kIndirectKindInvalid = 0,
kIndirectKindLocal = 1,
kIndirectKindGlobal = 2,
kIndirectKindWeakGlobal = 3
-} IndirectRefKind;
+};
/*
* Extended debugging structure. We keep a parallel array of these, one
* per slot in the table.
*/
#define kIRTPrevCount 4
-typedef struct IndirectRefSlot {
+struct IndirectRefSlot {
u4 serial; /* slot serial */
Object* previous[kIRTPrevCount];
-} IndirectRefSlot;
+};
/*
* Table definition.
@@ -179,14 +175,14 @@
* add a "synchronized lookup" call that takes the mutex as an argument,
* and either locks or doesn't lock based on internal details.
*/
-typedef union IRTSegmentState {
+union IRTSegmentState {
u4 all;
struct {
u4 topIndex:16; /* index of first unused entry */
u4 numHoles:16; /* #of holes in entire table */
} parts;
-} IRTSegmentState;
-typedef struct IndirectRefTable {
+};
+struct IndirectRefTable {
/* semi-public - read/write by interpreter in native call handler */
IRTSegmentState segmentState;
@@ -201,7 +197,7 @@
// TODO: want hole-filling stats (#of holes filled, total entries scanned)
// for performance evaluation.
-} IndirectRefTable;
+};
/* use as initial value for "cookie", and when table has only one segment */
#define IRT_FIRST_SEGMENT 0
@@ -394,8 +390,4 @@
*/
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 7e91217..4d85c2e 100644
--- a/vm/Init.h
+++ b/vm/Init.h
@@ -20,10 +20,6 @@
#ifndef _DALVIK_INIT
#define _DALVIK_INIT
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Standard VM initialization, usually invoked through JNI.
*/
@@ -73,8 +69,4 @@
#endif
;
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_INIT*/
diff --git a/vm/InlineNative.cpp b/vm/InlineNative.cpp
index 8e538cc..f4f4e8c 100644
--- a/vm/InlineNative.cpp
+++ b/vm/InlineNative.cpp
@@ -511,16 +511,16 @@
* ===========================================================================
*/
-typedef union {
+union Convert32 {
u4 arg;
float ff;
-} Convert32;
+};
-typedef union {
+union Convert64 {
u4 arg[2];
s8 ll;
double dd;
-} Convert64;
+};
/*
* public static int abs(int)
diff --git a/vm/InlineNative.h b/vm/InlineNative.h
index bf08412..64caec9 100644
--- a/vm/InlineNative.h
+++ b/vm/InlineNative.h
@@ -20,10 +20,6 @@
#ifndef _DALVIK_INLINENATIVE
#define _DALVIK_INLINENATIVE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* startup/shutdown */
bool dvmInlineNativeStartup(void);
void dvmInlineNativeShutdown(void);
@@ -49,19 +45,19 @@
* generate assembly code that knows how many args it needs and has the
* target address embedded.
*/
-typedef struct InlineOperation {
+struct InlineOperation {
InlineOp4Func func; /* MUST be first entry */
const char* classDescriptor;
const char* methodName;
const char* methodSignature;
-} InlineOperation;
+};
/*
* Must be kept in sync w/ gDvmInlineOpsTable in InlineNative.c
*
* You should also add a test to libcore's IntrinsicTest.
*/
-typedef enum NativeInlineOps {
+enum NativeInlineOps {
INLINE_EMPTYINLINEMETHOD = 0,
INLINE_STRING_CHARAT = 1,
INLINE_STRING_COMPARETO = 2,
@@ -84,7 +80,7 @@
INLINE_DOUBLE_TO_LONG_BITS = 19,
INLINE_DOUBLE_TO_RAW_LONG_BITS = 20,
INLINE_LONG_BITS_TO_DOUBLE = 21,
-} NativeInlineOps;
+};
/*
* Get the inlineops table.
@@ -123,7 +119,7 @@
/*
* Return method & populate the table on first use.
*/
-Method* dvmResolveInlineNative(int opIndex);
+extern "C" Method* dvmResolveInlineNative(int opIndex);
/*
* The actual inline native definitions.
@@ -194,8 +190,4 @@
bool javaLangDouble_longBitsToDouble(u4 arg0, u4 arg1, u4 arg2, u4 arg,
JValue* pResult);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_INLINENATIVE*/
diff --git a/vm/Intern.h b/vm/Intern.h
index b6e669a..6630b69 100644
--- a/vm/Intern.h
+++ b/vm/Intern.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_INTERN
#define _DALVIK_INTERN
-#ifdef __cplusplus
-extern "C" {
-#endif
-
bool dvmStringInternStartup(void);
void dvmStringInternShutdown(void);
StringObject* dvmLookupInternedString(StringObject* strObj);
@@ -30,8 +26,4 @@
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 0569ee2..e199951 100644
--- a/vm/JarFile.h
+++ b/vm/JarFile.h
@@ -19,20 +19,16 @@
#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.)
*/
-typedef struct JarFile {
+struct JarFile {
ZipArchive archive;
//MemMapping map;
char* cacheFileName;
DvmDex* pDvmDex;
-} JarFile;
+};
/*
* Open the Zip archive and get a list of the classfile entries.
@@ -58,13 +54,13 @@
return pJarFile->cacheFileName;
}
-typedef enum DexCacheStatus {
+enum DexCacheStatus {
DEX_CACHE_ERROR = -2,
DEX_CACHE_BAD_ARCHIVE = -1,
DEX_CACHE_OK = 0,
DEX_CACHE_STALE,
DEX_CACHE_STALE_ODEX,
-} DexCacheStatus;
+};
/*
* Checks the dependencies of the dex cache file corresponding
@@ -72,8 +68,4 @@
*/
DexCacheStatus dvmDexCacheStatus(const char *fileName);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JARFILE*/
diff --git a/vm/JniInternal.h b/vm/JniInternal.h
index 173583d..9412ab8 100644
--- a/vm/JniInternal.h
+++ b/vm/JniInternal.h
@@ -21,10 +21,6 @@
#include "jni.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* system init/shutdown */
bool dvmJniStartup(void);
void dvmJniShutdown(void);
@@ -36,7 +32,7 @@
*/
struct JavaVMExt;
-typedef struct JNIEnvExt {
+struct JNIEnvExt {
const struct JNINativeInterface* funcTable; /* must be first */
const struct JNINativeInterface* baseFuncTable;
@@ -49,9 +45,9 @@
struct JNIEnvExt* prev;
struct JNIEnvExt* next;
-} JNIEnvExt;
+};
-typedef struct JavaVMExt {
+struct JavaVMExt {
const struct JNIInvokeInterface* funcTable; /* must be first */
const struct JNIInvokeInterface* baseFuncTable;
@@ -59,7 +55,7 @@
/* head of list of JNIEnvs associated with this VM */
JNIEnvExt* envList;
pthread_mutex_t envListLock;
-} JavaVMExt;
+};
/*
* Native function return type; used by dvmPlatformInvoke().
@@ -68,7 +64,7 @@
* Note: Assembly code in arch/<arch>/Call<arch>.S relies on
* the enum values defined here.
*/
-typedef enum DalvikJniReturnType {
+enum DalvikJniReturnType {
DALVIK_JNI_RETURN_VOID = 0, /* must be zero */
DALVIK_JNI_RETURN_FLOAT = 1,
DALVIK_JNI_RETURN_DOUBLE = 2,
@@ -77,7 +73,7 @@
DALVIK_JNI_RETURN_S2 = 5,
DALVIK_JNI_RETURN_U2 = 6,
DALVIK_JNI_RETURN_S1 = 7
-} DalvikJniReturnType;
+};
#define DALVIK_JNI_NO_ARG_INFO 0x80000000
#define DALVIK_JNI_RETURN_MASK 0x70000000
@@ -188,8 +184,4 @@
*/
void dvmDumpJniReferenceTables(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JNIINTERNAL*/
diff --git a/vm/LinearAlloc.h b/vm/LinearAlloc.h
index c06d2ab..3305e5b 100644
--- a/vm/LinearAlloc.h
+++ b/vm/LinearAlloc.h
@@ -19,10 +19,6 @@
#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.
@@ -34,7 +30,7 @@
* allocated region, but that would prevent us from sharing the rest of
* that first page.
*/
-typedef struct LinearAllocHdr {
+struct LinearAllocHdr {
int curOffset; /* offset where next data goes */
pthread_mutex_t lock; /* controls updates to this struct */
@@ -43,7 +39,7 @@
int firstOffset; /* for chasing through */
short* writeRefCount; /* for ENFORCE_READ_ONLY */
-} LinearAllocHdr;
+};
/*
@@ -121,8 +117,4 @@
*/
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 c1ab72c..6bce241 100644
--- a/vm/Misc.h
+++ b/vm/Misc.h
@@ -25,10 +25,6 @@
#include <sys/time.h>
#include "Inlines.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Used to shut up the compiler when a parameter isn't used.
*/
@@ -67,7 +63,7 @@
*
* If "tag" is NULL the default tag ("dalvikvm") will be used.
*/
-typedef enum { kHexDumpLocal, kHexDumpMem } HexDumpMode;
+enum HexDumpMode { kHexDumpLocal, kHexDumpMem };
void dvmPrintHexDumpEx(int priority, const char* tag, const void* vaddr,
size_t length, HexDumpMode mode);
@@ -90,17 +86,17 @@
#endif
}
-typedef enum {
+enum DebugTargetKind {
kDebugTargetUnknown = 0,
kDebugTargetLog,
kDebugTargetFile,
-} DebugTargetKind;
+};
/*
* We pass one of these around when we want code to be able to write debug
* info to either the log or to a file (or stdout/stderr).
*/
-typedef struct DebugOutputTarget {
+struct DebugOutputTarget {
/* where to? */
DebugTargetKind which;
@@ -114,7 +110,7 @@
FILE* fp;
} file;
} data;
-} DebugOutputTarget;
+};
/*
* Fill in a DebugOutputTarget struct.
@@ -145,7 +141,7 @@
* of 'descriptor'. So "I" would be "int", "[[I" would be "int[][]",
* "[Ljava/lang/String;" would be "java.lang.String[]", and so forth.
*/
-char* dvmHumanReadableDescriptor(const char* descriptor);
+extern "C" char* dvmHumanReadableDescriptor(const char* descriptor);
/*
* Return a newly-allocated string for the "dot version" of the class
@@ -260,7 +256,7 @@
* get from the abort may point at the wrong call site. Best to leave
* it undecorated.
*/
-void dvmAbort(void);
+extern "C" void dvmAbort(void);
void dvmPrintNativeBackTrace(void);
#if (!HAVE_STRLCPY)
@@ -278,11 +274,11 @@
/*
* Get some per-thread stats from /proc/self/task/N/stat.
*/
-typedef struct {
+struct ProcStatData {
unsigned long utime; /* number of jiffies scheduled in user mode */
unsigned long stime; /* number of jiffies scheduled in kernel mode */
int processor; /* number of CPU that last executed thread */
-} ProcStatData;
+};
bool dvmGetThreadStats(ProcStatData* pData, pid_t tid);
/*
@@ -304,8 +300,4 @@
*/
const char* dvmPathToAbsolutePortion(const char* path);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_MISC*/
diff --git a/vm/Native.cpp b/vm/Native.cpp
index 7d7980b..bbb4ce6 100644
--- a/vm/Native.cpp
+++ b/vm/Native.cpp
@@ -137,17 +137,17 @@
// are associated with it. (Or not -- can't determine if native code
// is still using parts of it.)
-typedef enum OnLoadState {
+enum OnLoadState {
kOnLoadPending = 0, /* initial state, must be zero */
kOnLoadFailed,
kOnLoadOkay,
-} OnLoadState;
+};
/*
* We add one of these to the hash table for every library we load. The
* hash is on the "pathName" field.
*/
-typedef struct SharedLib {
+struct SharedLib {
char* pathName; /* absolute path to library */
void* handle; /* from dlopen */
Object* classLoader; /* ClassLoader we are associated with */
@@ -156,7 +156,7 @@
pthread_cond_t onLoadCond; /* wait for JNI_OnLoad in other thread */
u4 onLoadThreadId; /* recursive invocation guard */
OnLoadState onLoadResult; /* result of earlier JNI_OnLoad */
-} SharedLib;
+};
/*
* (This is a dvmHashTableLookup callback.)
diff --git a/vm/Native.h b/vm/Native.h
index 7599bcc..eb2b84a 100644
--- a/vm/Native.h
+++ b/vm/Native.h
@@ -22,27 +22,23 @@
#ifndef _DALVIK_NATIVE
#define _DALVIK_NATIVE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Method description; equivalent to a JNI struct.
*/
-typedef struct DalvikNativeMethod {
+struct DalvikNativeMethod {
const char* name;
const char* signature;
DalvikNativeFunc fnPtr;
-} DalvikNativeMethod;
+};
/*
* All methods for one class. The last "methodInfo" has a NULL "name".
*/
-typedef struct DalvikNativeClass {
+struct DalvikNativeClass {
const char* classDescriptor;
const DalvikNativeMethod* methodInfo;
u4 classDescriptorHash; /* initialized at runtime */
-} DalvikNativeClass;
+};
/* init/shutdown */
@@ -53,8 +49,8 @@
/*
* Convert argc/argv into a function call. This is platform-specific.
*/
-void dvmPlatformInvoke(void* pEnv, ClassObject* clazz, int argInfo, int argc,
- const u4* argv, const char* signature, void* func, JValue* pResult);
+extern "C" void dvmPlatformInvoke(void* pEnv, ClassObject* clazz, int argInfo,
+ int argc, const u4* argv, const char* signature, void* func, JValue* pResult);
/*
* Generate hints to speed native calls. This is platform specific.
@@ -123,8 +119,4 @@
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 6e43f67..ddc5532 100644
--- a/vm/PointerSet.h
+++ b/vm/PointerSet.h
@@ -20,12 +20,7 @@
#ifndef _DALVIK_POINTERSET
#define _DALVIK_POINTERSET
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct PointerSet; /* private */
-typedef struct PointerSet PointerSet;
/*
* Allocate a new PointerSet.
@@ -96,8 +91,4 @@
*/
void dvmPointerSetDump(const PointerSet* pSet);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_POINTERSET*/
diff --git a/vm/Profile.h b/vm/Profile.h
index 12063b9..27d7c89 100644
--- a/vm/Profile.h
+++ b/vm/Profile.h
@@ -24,10 +24,6 @@
#include <stdio.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct Thread; // extern
@@ -39,7 +35,7 @@
* Method trace state. This is currently global. In theory we could make
* most of this per-thread.
*/
-typedef struct MethodTraceState {
+struct MethodTraceState {
/* active state */
pthread_mutex_t startStopLock;
pthread_cond_t threadExitCond;
@@ -53,7 +49,7 @@
volatile int curOffset;
u8 startWhen;
int overflow;
-} MethodTraceState;
+};
/*
* Memory allocation profiler state. This is used both globally and
@@ -61,7 +57,7 @@
*
* If you add a field here, zero it out in dvmStartAllocCounting().
*/
-typedef struct AllocProfState {
+struct AllocProfState {
bool enabled; // is allocation tracking enabled?
int allocCount; // #of objects allocated
@@ -77,7 +73,7 @@
int classInitCount; // #of initialized classes
u8 classInitTime; // cumulative time spent in class init (nsec)
-} AllocProfState;
+};
/*
@@ -141,9 +137,9 @@
void dvmMethodTraceClassPrepBegin(void);
void dvmMethodTraceClassPrepEnd(void);
-void dvmFastMethodTraceEnter(const Method* method, struct Thread* self);
-void dvmFastMethodTraceExit(struct Thread* self);
-void dvmFastNativeMethodTraceExit(const Method* method, struct Thread* self);
+extern "C" void dvmFastMethodTraceEnter(const Method* method, struct Thread* self);
+extern "C" void dvmFastMethodTraceExit(struct Thread* self);
+extern "C" void dvmFastNativeMethodTraceExit(const Method* method, struct Thread* self);
/*
* Start/stop alloc counting.
@@ -175,8 +171,4 @@
#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 6226d7f..138be41 100644
--- a/vm/Properties.h
+++ b/vm/Properties.h
@@ -19,18 +19,10 @@
#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 f2c1b68..ba777bb 100644
--- a/vm/RawDexFile.h
+++ b/vm/RawDexFile.h
@@ -21,18 +21,14 @@
#ifndef _DALVIK_RAWDEXFILE
#define _DALVIK_RAWDEXFILE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Structure representing a "raw" DEX file, in its unswapped unoptimized
* state.
*/
-typedef struct RawDexFile {
+struct RawDexFile {
char* cacheFileName;
DvmDex* pDvmDex;
-} RawDexFile;
+};
/*
* Open a raw ".dex" file, optimize it, and load it.
@@ -72,8 +68,4 @@
return pRawDexFile->cacheFileName;
}
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_RAWDEXFILE*/
diff --git a/vm/ReferenceTable.h b/vm/ReferenceTable.h
index ce7c1f7..db2389f 100644
--- a/vm/ReferenceTable.h
+++ b/vm/ReferenceTable.h
@@ -23,10 +23,6 @@
#ifndef _DALVIK_REFERENCETABLE
#define _DALVIK_REFERENCETABLE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Table definition.
*
@@ -40,13 +36,13 @@
* (This structure is still somewhat transparent; direct access to
* table/nextEntry is allowed.)
*/
-typedef struct ReferenceTable {
+struct ReferenceTable {
Object** nextEntry; /* top of the list */
Object** table; /* bottom of the list */
int allocEntries; /* #of entries we have space for */
int maxEntries; /* max #of entries allowed */
-} ReferenceTable;
+};
/*
* Initialize a ReferenceTable.
@@ -126,8 +122,4 @@
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 f9e1dd7..ece052c 100644
--- a/vm/SignalCatcher.h
+++ b/vm/SignalCatcher.h
@@ -19,15 +19,7 @@
#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.cpp b/vm/StdioConverter.cpp
index 7776688..a98d473 100644
--- a/vm/StdioConverter.cpp
+++ b/vm/StdioConverter.cpp
@@ -30,20 +30,20 @@
/*
* Hold our replacement stdout/stderr.
*/
-typedef struct StdPipes {
+struct StdPipes {
int stdoutPipe[2];
int stderrPipe[2];
-} StdPipes;
+};
#define kMaxLine 512
/*
* Hold some data.
*/
-typedef struct BufferedData {
+struct BufferedData {
char buf[kMaxLine+1];
int count;
-} BufferedData;
+};
// fwd
static void* stdioConverterThreadStart(void* arg);
diff --git a/vm/StdioConverter.h b/vm/StdioConverter.h
index 37384eb..ffbf807 100644
--- a/vm/StdioConverter.h
+++ b/vm/StdioConverter.h
@@ -19,15 +19,7 @@
#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 9f4592d..14b34fd 100644
--- a/vm/Sync.h
+++ b/vm/Sync.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_SYNC
#define _DALVIK_SYNC
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Monitor shape field. Used to distinguish immediate thin locks from
* indirecting fat locks.
@@ -70,7 +66,6 @@
struct Object;
struct Monitor;
struct Thread;
-typedef struct Monitor Monitor;
/*
* Returns true if the lock has been fattened.
@@ -80,25 +75,25 @@
/*
* Acquire the object's monitor.
*/
-void dvmLockObject(struct Thread* self, struct Object* obj);
+extern "C" void dvmLockObject(Thread* self, Object* obj);
/* Returns true if the unlock succeeded.
* If the unlock failed, an exception will be pending.
*/
-bool dvmUnlockObject(struct Thread* self, struct Object* obj);
+extern "C" bool dvmUnlockObject(Thread* self, Object* obj);
/*
* Implementations of some java/lang/Object calls.
*/
-void dvmObjectWait(struct Thread* self, struct Object* obj,
+void dvmObjectWait(Thread* self, Object* obj,
s8 timeout, s4 nanos, bool interruptShouldThrow);
-void dvmObjectNotify(struct Thread* self, struct Object* obj);
-void dvmObjectNotifyAll(struct Thread* self, struct Object* obj);
+void dvmObjectNotify(Thread* self, Object* obj);
+void dvmObjectNotifyAll(Thread* self, Object* obj);
/*
* Implementation of System.identityHashCode().
*/
-u4 dvmIdentityHashCode(struct Object* obj);
+u4 dvmIdentityHashCode(Object* obj);
/*
* Implementation of Thread.sleep().
@@ -110,10 +105,10 @@
*
* Interrupt a thread. If it's waiting on a monitor, wake it up.
*/
-void dvmThreadInterrupt(struct Thread* thread);
+void dvmThreadInterrupt(Thread* thread);
/* create a new Monitor struct */
-Monitor* dvmCreateMonitor(struct Object* obj);
+Monitor* dvmCreateMonitor(Object* obj);
/*
* Frees unmarked monitors from the monitor list. The given callback
@@ -131,7 +126,7 @@
* Returns NULL if "mon" is NULL or the monitor is not part of an object
* (which should only happen for Thread.sleep() in the current implementation).
*/
-struct Object* dvmGetMonitorObject(Monitor* mon);
+Object* dvmGetMonitorObject(Monitor* mon);
/*
* Get the thread that holds the lock on the specified object. The
@@ -139,12 +134,12 @@
*
* The caller must lock the thread list before calling here.
*/
-struct Thread* dvmGetObjectLockHolder(struct Object* obj);
+Thread* dvmGetObjectLockHolder(Object* obj);
/*
* Checks whether the object is held by the specified thread.
*/
-bool dvmHoldsLock(struct Thread* thread, struct Object* obj);
+bool dvmHoldsLock(Thread* thread, Object* obj);
/*
* Relative timed wait on condition
@@ -152,8 +147,4 @@
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 440dfe3..2f0a29d 100644
--- a/vm/Thread.h
+++ b/vm/Thread.h
@@ -26,10 +26,6 @@
#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 */
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
@@ -43,7 +39,7 @@
*
* Note that "suspended" is orthogonal to these values (so says JDWP).
*/
-typedef enum ThreadStatus {
+enum ThreadStatus {
THREAD_UNDEFINED = -1, /* makes enum compatible with int32_t */
/* these match up with JDWP values */
@@ -58,7 +54,7 @@
THREAD_NATIVE = 7, /* off in a JNI native method */
THREAD_VMWAIT = 8, /* waiting on a VM resource */
THREAD_SUSPENDED = 9, /* suspended, usually by GC or debugger */
-} ThreadStatus;
+};
/* thread priorities, from java.lang.Thread */
enum {
@@ -87,7 +83,7 @@
* Interpreter control struction. Packed into a long long to enable
* atomic updates.
*/
-typedef union InterpBreak {
+union InterpBreak {
volatile int64_t all;
struct {
uint16_t subMode;
@@ -99,14 +95,14 @@
void* unused;
#endif
} ctl;
-} InterpBreak;
+};
/*
* Our per-thread data.
*
* These are allocated on the system heap.
*/
-typedef struct Thread {
+struct Thread {
/*
* Interpreter state which must be preserved across nested
* interpreter invocations (via JNI callbacks). Must be the first
@@ -308,13 +304,13 @@
pthread_mutex_t callbackMutex;
SafePointCallback callback;
void* callbackArg;
-} Thread;
+};
/* start point for an internal thread; mimics pthread args */
typedef void* (*InternalThreadStart)(void* arg);
/* args for internal thread creation */
-typedef struct InternalStartArgs {
+struct InternalStartArgs {
/* inputs */
InternalThreadStart func;
void* funcArg;
@@ -324,7 +320,7 @@
/* result */
volatile Thread** pThread;
volatile int* pCreateStatus;
-} InternalStartArgs;
+};
/* finish init */
bool dvmPrepMainForJni(JNIEnv* pEnv);
@@ -350,7 +346,7 @@
/*
* Thread suspend/resume, used by the GC and debugger.
*/
-typedef enum SuspendCause {
+enum SuspendCause {
SUSPEND_NOT = 0,
SUSPEND_FOR_GC,
SUSPEND_FOR_DEBUG,
@@ -365,7 +361,7 @@
SUSPEND_FOR_CC_RESET, // code-cache reset
SUSPEND_FOR_REFRESH, // Reload data cached in interpState
#endif
-} SuspendCause;
+};
void dvmSuspendThread(Thread* thread);
void dvmSuspendSelf(bool jdwpActivity);
void dvmResumeThread(Thread* thread);
@@ -387,7 +383,7 @@
* Check to see if we should be suspended now. If so, suspend ourselves
* by sleeping on a condition variable.
*/
-bool dvmCheckSuspendPending(Thread* self);
+extern "C" bool dvmCheckSuspendPending(Thread* self);
/*
* Fast test for use in the interpreter. Returns "true" if our suspend
@@ -601,8 +597,4 @@
*/
void dvmNukeThread(Thread* thread);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_THREAD*/
diff --git a/vm/UtfString.h b/vm/UtfString.h
index 6b9a5e3..b577d3a 100644
--- a/vm/UtfString.h
+++ b/vm/UtfString.h
@@ -21,10 +21,6 @@
#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.)
@@ -149,8 +145,4 @@
*/
int dvmHashcmpStrings(const void* vstrObj1, const void* vstrObj2);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_STRING*/
diff --git a/vm/alloc/Copying.cpp b/vm/alloc/Copying.cpp
index a1e503a..47df05f 100644
--- a/vm/alloc/Copying.cpp
+++ b/vm/alloc/Copying.cpp
@@ -527,7 +527,7 @@
*gcHeap = NULL;
}
-size_t dvmHeapSourceGetValue(enum HeapSourceValueSpec spec,
+size_t dvmHeapSourceGetValue(HeapSourceValueSpec spec,
size_t perHeapStats[],
size_t arrayLen)
{
diff --git a/vm/alloc/HeapSource.cpp b/vm/alloc/HeapSource.cpp
index d944560..6666f88 100644
--- a/vm/alloc/HeapSource.cpp
+++ b/vm/alloc/HeapSource.cpp
@@ -652,7 +652,7 @@
* Caller must hold the heap lock.
*/
size_t
-dvmHeapSourceGetValue(enum HeapSourceValueSpec spec, size_t perHeapStats[],
+dvmHeapSourceGetValue(HeapSourceValueSpec spec, size_t perHeapStats[],
size_t arrayLen)
{
HeapSource *hs = gHs;
diff --git a/vm/analysis/CodeVerify.cpp b/vm/analysis/CodeVerify.cpp
index 2bf67d4..931569f 100644
--- a/vm/analysis/CodeVerify.cpp
+++ b/vm/analysis/CodeVerify.cpp
@@ -37,11 +37,11 @@
* we either only need it at branch points (for verification) or GC points
* and branches (for verification + type-precise register analysis).
*/
-typedef enum RegisterTrackingMode {
+enum RegisterTrackingMode {
kTrackRegsBranches,
kTrackRegsGcPoints,
kTrackRegsAll
-} RegisterTrackingMode;
+};
/*
* Set this to enable dead code scanning. This is not required, but it's
@@ -1820,12 +1820,12 @@
* We treat object references separately, so we have "category1nr". We
* don't support jsr/ret, so there is no "returnAddress" type.
*/
-typedef enum TypeCategory {
+enum TypeCategory {
kTypeCategoryUnknown = 0,
kTypeCategory1nr, // boolean, byte, char, short, int, float
kTypeCategory2, // long, double
kTypeCategoryRef, // object reference
-} TypeCategory;
+};
/*
* See if "type" matches "cat". All we're really looking for here is that
diff --git a/vm/analysis/CodeVerify.h b/vm/analysis/CodeVerify.h
index 4fbf700..1eb27b9 100644
--- a/vm/analysis/CodeVerify.h
+++ b/vm/analysis/CodeVerify.h
@@ -23,10 +23,6 @@
#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
* MUST immediately follow the "lo" piece in the enumeration, so we can check
@@ -129,32 +125,32 @@
* track the liveness of the method result register (which is not visible
* to the GC).
*/
-typedef struct {
+struct RegisterLine {
RegType* regTypes;
MonitorEntries* monitorEntries;
u4* monitorStack;
unsigned int monitorStackTop;
BitVector* liveRegs;
-} RegisterLine;
+};
/*
* Table that maps uninitialized instances to classes, based on the
* address of the new-instance instruction. One per method.
*/
-typedef struct UninitInstanceMap {
+struct UninitInstanceMap {
int numEntries;
struct {
int addr; /* code offset, or -1 for method arg ("this") */
ClassObject* clazz; /* class created at this address */
} map[1];
-} UninitInstanceMap;
+};
#define kUninitThisArgAddr (-1)
#define kUninitThisArgSlot 0
/*
* Various bits of data used by the verifier and register map generator.
*/
-typedef struct VerifierData {
+struct VerifierData {
/*
* The method we're working on.
*/
@@ -203,7 +199,7 @@
* for liveness analysis.
*/
VfyBasicBlock** basicBlocks;
-} VerifierData;
+};
/* table with static merge logic for primitive types */
@@ -325,8 +321,4 @@
*/
bool dvmVerifyCodeFlow(VerifierData* vdata);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_CODEVERIFY*/
diff --git a/vm/analysis/DexPrepare.h b/vm/analysis/DexPrepare.h
index 27668b1..9e43f26 100644
--- a/vm/analysis/DexPrepare.h
+++ b/vm/analysis/DexPrepare.h
@@ -20,10 +20,6 @@
#ifndef _DALVIK_DEXPREPARE
#define _DALVIK_DEXPREPARE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Global DEX optimizer control. Determines the circumstances in which we
* try to rewrite instructions in the DEX file.
@@ -31,13 +27,13 @@
* Optimizing is performed ahead-of-time by dexopt and, in some cases, at
* load time by the VM.
*/
-typedef enum DexOptimizerMode {
+enum DexOptimizerMode {
OPTIMIZE_MODE_UNKNOWN = 0,
OPTIMIZE_MODE_NONE, /* never optimize (except "essential") */
OPTIMIZE_MODE_VERIFIED, /* only optimize verified classes (default) */
OPTIMIZE_MODE_ALL, /* optimize verified & unverified (risky) */
OPTIMIZE_MODE_FULL /* fully opt verified classes at load time */
-} DexOptimizerMode;
+};
/* some additional bit flags for dexopt */
enum DexoptFlags {
@@ -54,7 +50,7 @@
/*
* An enumeration of problems that can turn up during verification.
*/
-typedef enum VerifyError {
+enum VerifyError {
VERIFY_ERROR_NONE = 0, /* no error; must be zero */
VERIFY_ERROR_GENERIC, /* VerifyError */
@@ -66,7 +62,7 @@
VERIFY_ERROR_ACCESS_METHOD, /* IllegalAccessError */
VERIFY_ERROR_CLASS_CHANGE, /* IncompatibleClassChangeError */
VERIFY_ERROR_INSTANTIATION, /* InstantiationError */
-} VerifyError;
+};
/*
* Identifies the type of reference in the instruction that generated the
@@ -75,11 +71,11 @@
*
* This must fit in two bits.
*/
-typedef enum VerifyErrorRefType {
+enum VerifyErrorRefType {
VERIFY_ERROR_REF_CLASS = 0,
VERIFY_ERROR_REF_FIELD = 1,
VERIFY_ERROR_REF_METHOD = 2,
-} VerifyErrorRefType;
+};
#define kVerifyErrorRefTypeShift 6
@@ -138,8 +134,4 @@
bool dvmCreateInlineSubsTable(void);
void dvmFreeInlineSubsTable(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_DEXPREPARE*/
diff --git a/vm/analysis/DexVerify.h b/vm/analysis/DexVerify.h
index a990502..d98cee9 100644
--- a/vm/analysis/DexVerify.h
+++ b/vm/analysis/DexVerify.h
@@ -20,21 +20,30 @@
#ifndef _DALVIK_DEXVERIFY
#define _DALVIK_DEXVERIFY
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Global verification mode. These must be in order from least verification
* to most. If we're using "exact GC", we may need to perform some of
* the verification steps anyway.
*/
-typedef enum {
+enum DexClassVerifyMode {
VERIFY_MODE_UNKNOWN = 0,
VERIFY_MODE_NONE,
VERIFY_MODE_REMOTE,
VERIFY_MODE_ALL
-} DexClassVerifyMode;
+};
+
+/* some verifier counters, for debugging */
+struct VerifierStats {
+ size_t methodsExamined; /* number of methods examined */
+ size_t monEnterMethods; /* number of methods with monitor-enter */
+ size_t instrsExamined; /* incr on first visit of instruction */
+ size_t instrsReexamined; /* incr on each repeat visit of instruction */
+ size_t copyRegCount; /* calls from updateRegisters->copyRegisters */
+ size_t mergeRegCount; /* calls from updateRegisters->merge */
+ size_t mergeRegChanged; /* calls from updateRegisters->merge, changed */
+ size_t uninitSearches; /* times we've had to search the uninit table */
+ size_t biggestAlloc; /* largest RegisterLine table alloc */
+};
/*
* Certain types of instructions can be GC points. To support precise
@@ -54,21 +63,4 @@
*/
void dvmFreeRegisterMap(RegisterMap* pMap);
-/* some verifier counters, for debugging */
-typedef struct {
- size_t methodsExamined; /* number of methods examined */
- size_t monEnterMethods; /* number of methods with monitor-enter */
- size_t instrsExamined; /* incr on first visit of instruction */
- size_t instrsReexamined; /* incr on each repeat visit of instruction */
- size_t copyRegCount; /* calls from updateRegisters->copyRegisters */
- size_t mergeRegCount; /* calls from updateRegisters->merge */
- size_t mergeRegChanged; /* calls from updateRegisters->merge, changed */
- size_t uninitSearches; /* times we've had to search the uninit table */
- size_t biggestAlloc; /* largest RegisterLine table alloc */
-} VerifierStats;
-
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_DEXVERIFY*/
diff --git a/vm/analysis/Liveness.h b/vm/analysis/Liveness.h
index d9ca9cf..6436f66 100644
--- a/vm/analysis/Liveness.h
+++ b/vm/analysis/Liveness.h
@@ -20,16 +20,8 @@
#ifndef _DALVIK_LIVENESS
#define _DALVIK_LIVENESS
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct VerifierData;
bool dvmComputeLiveness(struct VerifierData* vdata);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_LIVENESS*/
diff --git a/vm/analysis/Optimize.h b/vm/analysis/Optimize.h
index 9383881..75b6eab 100644
--- a/vm/analysis/Optimize.h
+++ b/vm/analysis/Optimize.h
@@ -20,10 +20,6 @@
#ifndef _DALVIK_OPTIMIZE
#define _DALVIK_OPTIMIZE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Entry point from DEX preparation.
*/
@@ -48,8 +44,4 @@
StaticField* dvmOptResolveStaticField(ClassObject* referrer, u4 sfieldIdx,
VerifyError* pFailure);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_OPTIMIZE*/
diff --git a/vm/analysis/RegisterMap.cpp b/vm/analysis/RegisterMap.cpp
index 54b5768..37b2116 100644
--- a/vm/analysis/RegisterMap.cpp
+++ b/vm/analysis/RegisterMap.cpp
@@ -58,7 +58,7 @@
#define kUpdatePosnMinRegs 24
#define kNumUpdatePosns 8
#define kMaxDiffBits 20
-typedef struct MapStats {
+struct MapStats {
/*
* Buckets measuring the distance between GC points. This tells us how
* many bits we need to encode the advancing program counter. We ignore
@@ -103,7 +103,7 @@
*/
int numExpandedMaps;
int totalExpandedMapSize;
-} MapStats;
+};
#endif
/*
diff --git a/vm/analysis/RegisterMap.h b/vm/analysis/RegisterMap.h
index becb1de..2f34c39 100644
--- a/vm/analysis/RegisterMap.h
+++ b/vm/analysis/RegisterMap.h
@@ -25,14 +25,10 @@
#include "analysis/VerifySubs.h"
#include "analysis/CodeVerify.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Format enumeration for RegisterMap data area.
*/
-typedef enum RegisterMapFormat {
+enum RegisterMapFormat {
kRegMapFormatUnknown = 0,
kRegMapFormatNone, /* indicates no map data follows */
kRegMapFormatCompact8, /* compact layout, 8-bit addresses */
@@ -40,7 +36,7 @@
kRegMapFormatDifferential, /* compressed, differential encoding */
kRegMapFormatOnHeap = 0x80, /* bit flag, indicates allocation on heap */
-} RegisterMapFormat;
+};
/*
* This is a single variable-size structure. It may be allocated on the
@@ -163,12 +159,12 @@
*
* These structures are 32-bit aligned.
*/
-typedef struct RegisterMapMethodPool {
+struct RegisterMapMethodPool {
u2 methodCount; /* chiefly used as a sanity check */
/* stream of per-method data starts here */
u4 methodData[1];
-} RegisterMapMethodPool;
+};
/*
* Header for the memory-mapped RegisterMap pool in the DEX file.
@@ -181,12 +177,12 @@
*
* These structures are 32-bit aligned.
*/
-typedef struct RegisterMapClassPool {
+struct RegisterMapClassPool {
u4 numClasses;
/* offset table starts here, 32-bit aligned; offset==0 means no data */
u4 classDataOffset[1];
-} RegisterMapClassPool;
+};
/*
* Find the register maps for this class. (Used during class loading.)
@@ -213,14 +209,14 @@
* In particular, it keeps track of our temporary mmap region so we can
* free it later.
*/
-typedef struct RegisterMapBuilder {
+struct RegisterMapBuilder {
/* public */
void* data;
size_t size;
/* private */
MemMapping memMap;
-} RegisterMapBuilder;
+};
/*
* Generate a register map set for all verified classes in "pDvmDex".
@@ -267,8 +263,4 @@
/* dump stats gathered during register map creation process */
void dvmRegisterMapDumpStats(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_REGISTERMAP*/
diff --git a/vm/analysis/VerifySubs.h b/vm/analysis/VerifySubs.h
index 452355b..625244d 100644
--- a/vm/analysis/VerifySubs.h
+++ b/vm/analysis/VerifySubs.h
@@ -20,10 +20,6 @@
#ifndef _DALVIK_VERIFYSUBS
#define _DALVIK_VERIFYSUBS
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* InsnFlags is a 32-bit integer with the following layout:
* 0-15 instruction length (or 0 if this address doesn't hold an opcode)
@@ -75,8 +71,4 @@
/* debugging */
bool dvmWantVerboseVerification(const Method* meth);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_VERIFYSUBS*/
diff --git a/vm/analysis/VfyBasicBlock.h b/vm/analysis/VfyBasicBlock.h
index f14953e..6d1d76f 100644
--- a/vm/analysis/VfyBasicBlock.h
+++ b/vm/analysis/VfyBasicBlock.h
@@ -23,10 +23,6 @@
#include "PointerSet.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct VerifierData;
@@ -43,14 +39,14 @@
* the RegisterLine for the last instruction in the block (which reflects
* the state *before* the instruction has executed).
*/
-typedef struct {
+struct VfyBasicBlock {
u4 firstAddr; /* address of first instruction */
u4 lastAddr; /* address of last instruction */
PointerSet* predecessors; /* set of basic blocks that can flow here */
BitVector* liveRegs; /* liveness for each register */
bool changed; /* input set has changed, must re-eval */
bool visited; /* block has been visited at least once */
-} VfyBasicBlock;
+};
/*
* Generate a list of basic blocks.
@@ -62,8 +58,4 @@
*/
void dvmFreeVfyBasicBlocks(struct VerifierData* vdata);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_VFYBASICBLOCK*/
diff --git a/vm/compiler/Compiler.h b/vm/compiler/Compiler.h
index 3ceb447..2cf2935 100644
--- a/vm/compiler/Compiler.h
+++ b/vm/compiler/Compiler.h
@@ -20,10 +20,6 @@
#include <setjmp.h>
#include "Thread.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Uncomment the following to enable JIT signature breakpoint
* #define SIGNATURE_BREAKPOINT
@@ -241,13 +237,9 @@
void dvmCompilerUpdateGlobalState(void);
JitTraceDescription *dvmCopyTraceDescriptor(const u2 *pc,
const struct JitEntry *desc);
-void *dvmCompilerGetInterpretTemplate();
+extern "C" 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/compiler/codegen/CompilerCodegen.h b/vm/compiler/codegen/CompilerCodegen.h
index 8223d2a..2e3b107 100644
--- a/vm/compiler/codegen/CompilerCodegen.h
+++ b/vm/compiler/codegen/CompilerCodegen.h
@@ -19,10 +19,6 @@
#include "compiler/CompilerIR.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Maximal number of switch cases to have inline chains */
#define MAX_CHAINED_SWITCH_CASES 64
@@ -39,7 +35,7 @@
void dvmCompilerAssembleLIR(CompilationUnit *cUnit, JitTranslationInfo *info);
/* Perform translation chain operation. */
-void* dvmJitChain(void* tgtAddr, u4* branchAddr);
+extern "C" void* dvmJitChain(void* tgtAddr, u4* branchAddr);
/* Install class objects in the literal pool */
void dvmJitInstallClassObjectPointers(CompilationUnit *cUnit,
@@ -75,8 +71,4 @@
/* Implemented in codegen/<target>/<target_variant>/ArchVariant.c */
void dvmCompilerGenMemBarrier(CompilationUnit *cUnit, int barrierKind);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* _DALVIK_VM_COMPILERCODEGEN_H_ */
diff --git a/vm/compiler/codegen/Optimizer.h b/vm/compiler/codegen/Optimizer.h
index 2b05476..dd8e788 100644
--- a/vm/compiler/codegen/Optimizer.h
+++ b/vm/compiler/codegen/Optimizer.h
@@ -23,14 +23,14 @@
* If the corresponding bit is set in gDvmJit.disableOpt, the selected
* optimization will be suppressed.
*/
-typedef enum optControlVector {
+enum optControlVector {
kLoadStoreElimination = 0,
kLoadHoisting,
kTrackLiveTemps,
kSuppressLoads,
kMethodInlining,
kMethodJit,
-} optControlVector;
+};
/* Forward declarations */
struct CompilationUnit;
diff --git a/vm/compiler/codegen/arm/CalloutHelper.h b/vm/compiler/codegen/arm/CalloutHelper.h
index 3bfb299..2660108 100644
--- a/vm/compiler/codegen/arm/CalloutHelper.h
+++ b/vm/compiler/codegen/arm/CalloutHelper.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_VM_COMPILER_CODEGEN_ARM_CALLOUT_HELPER_H
#define _DALVIK_VM_COMPILER_CODEGEN_ARM_CALLOUT_HELPER_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Declare/comment prototypes of all native callout functions invoked by the
* JIT'ed code here and use the LOAD_FUNC_ADDR macro to load the address into
@@ -35,37 +31,37 @@
#define LOAD_FUNC_ADDR(cUnit, reg, addr) loadConstant(cUnit, reg, addr)
/* Conversions */
-float __aeabi_i2f(int op1); // OP_INT_TO_FLOAT
-int __aeabi_f2iz(float op1); // OP_FLOAT_TO_INT
-float __aeabi_d2f(double op1); // OP_DOUBLE_TO_FLOAT
-double __aeabi_f2d(float op1); // OP_FLOAT_TO_DOUBLE
-double __aeabi_i2d(int op1); // OP_INT_TO_DOUBLE
-int __aeabi_d2iz(double op1); // OP_DOUBLE_TO_INT
-float __aeabi_l2f(long op1); // OP_LONG_TO_FLOAT
-double __aeabi_l2d(long op1); // OP_LONG_TO_DOUBLE
+extern "C" float __aeabi_i2f(int op1); // OP_INT_TO_FLOAT
+extern "C" int __aeabi_f2iz(float op1); // OP_FLOAT_TO_INT
+extern "C" float __aeabi_d2f(double op1); // OP_DOUBLE_TO_FLOAT
+extern "C" double __aeabi_f2d(float op1); // OP_FLOAT_TO_DOUBLE
+extern "C" double __aeabi_i2d(int op1); // OP_INT_TO_DOUBLE
+extern "C" int __aeabi_d2iz(double op1); // OP_DOUBLE_TO_INT
+extern "C" float __aeabi_l2f(long op1); // OP_LONG_TO_FLOAT
+extern "C" double __aeabi_l2d(long op1); // OP_LONG_TO_DOUBLE
s8 dvmJitf2l(float op1); // OP_FLOAT_TO_LONG
s8 dvmJitd2l(double op1); // OP_DOUBLE_TO_LONG
/* Single-precision FP arithmetics */
-float __aeabi_fadd(float a, float b); // OP_ADD_FLOAT[_2ADDR]
-float __aeabi_fsub(float a, float b); // OP_SUB_FLOAT[_2ADDR]
-float __aeabi_fdiv(float a, float b); // OP_DIV_FLOAT[_2ADDR]
-float __aeabi_fmul(float a, float b); // OP_MUL_FLOAT[_2ADDR]
-float fmodf(float a, float b); // OP_REM_FLOAT[_2ADDR]
+extern "C" float __aeabi_fadd(float a, float b); // OP_ADD_FLOAT[_2ADDR]
+extern "C" float __aeabi_fsub(float a, float b); // OP_SUB_FLOAT[_2ADDR]
+extern "C" float __aeabi_fdiv(float a, float b); // OP_DIV_FLOAT[_2ADDR]
+extern "C" float __aeabi_fmul(float a, float b); // OP_MUL_FLOAT[_2ADDR]
+extern "C" float fmodf(float a, float b); // OP_REM_FLOAT[_2ADDR]
/* Double-precision FP arithmetics */
-double __aeabi_dadd(double a, double b); // OP_ADD_DOUBLE[_2ADDR]
-double __aeabi_dsub(double a, double b); // OP_SUB_DOUBLE[_2ADDR]
-double __aeabi_ddiv(double a, double b); // OP_DIV_DOUBLE[_2ADDR]
-double __aeabi_dmul(double a, double b); // OP_MUL_DOUBLE[_2ADDR]
-double fmod(double a, double b); // OP_REM_DOUBLE[_2ADDR]
+extern "C" double __aeabi_dadd(double a, double b); // OP_ADD_DOUBLE[_2ADDR]
+extern "C" double __aeabi_dsub(double a, double b); // OP_SUB_DOUBLE[_2ADDR]
+extern "C" double __aeabi_ddiv(double a, double b); // OP_DIV_DOUBLE[_2ADDR]
+extern "C" double __aeabi_dmul(double a, double b); // OP_MUL_DOUBLE[_2ADDR]
+extern "C" double fmod(double a, double b); // OP_REM_DOUBLE[_2ADDR]
/* Integer arithmetics */
-int __aeabi_idivmod(int op1, int op2); // OP_REM_INT[_2ADDR|_LIT8|_LIT16]
-int __aeabi_idiv(int op1, int op2); // OP_DIV_INT[_2ADDR|_LIT8|_LIT16]
+extern "C" int __aeabi_idivmod(int op1, int op2); // OP_REM_INT[_2ADDR|_LIT8|_LIT16]
+extern "C" int __aeabi_idiv(int op1, int op2); // OP_DIV_INT[_2ADDR|_LIT8|_LIT16]
/* Long long arithmetics - OP_REM_LONG[_2ADDR] & OP_DIV_LONG[_2ADDR] */
-long long __aeabi_ldivmod(long long op1, long long op2);
+extern "C" long long __aeabi_ldivmod(long long op1, long long op2);
/* Originally declared in Sync.h */
bool dvmUnlockObject(struct Thread* self, struct Object* obj); //OP_MONITOR_EXIT
@@ -114,7 +110,7 @@
* Functions declared in gDvmInlineOpsTable[] are used for
* OP_EXECUTE_INLINE & OP_EXECUTE_INLINE_RANGE.
*/
-double sqrt(double x); // INLINE_MATH_SQRT
+extern "C" double sqrt(double x); // INLINE_MATH_SQRT
/*
* The following functions are invoked through the compiler templates (declared
@@ -125,8 +121,4 @@
* dvmLockObject // MONITOR_ENTER
*/
-#ifdef __cplusplus
-}
-#endif
-
#endif /* _DALVIK_VM_COMPILER_CODEGEN_ARM_CALLOUT_HELPER_H */
diff --git a/vm/compiler/codegen/arm/Codegen.h b/vm/compiler/codegen/arm/Codegen.h
index afeb340..e67f3d8 100644
--- a/vm/compiler/codegen/arm/Codegen.h
+++ b/vm/compiler/codegen/arm/Codegen.h
@@ -25,10 +25,6 @@
#include "compiler/CompilerIR.h"
#include "CalloutHelper.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#if defined(_CODEGEN_C)
/*
* loadConstant() sometimes needs to add a small imm to a pre-existing constant
@@ -60,14 +56,10 @@
#if defined(WITH_SELF_VERIFICATION)
/* Self Verification memory instruction decoder */
-void dvmSelfVerificationMemOpDecode(int lr, int* sp);
+extern "C" void dvmSelfVerificationMemOpDecode(int lr, int* sp);
#endif
extern void dvmCompilerSetupResourceMasks(ArmLIR *lir);
extern ArmLIR* dvmCompilerRegCopyNoInsert(CompilationUnit *cUnit, int rDest,
int rSrc);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.h b/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.h
index fa01210..452f2a5 100644
--- a/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.h
+++ b/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.h
@@ -19,7 +19,7 @@
/* Create the TemplateOpcode enum */
#define JIT_TEMPLATE(X) TEMPLATE_##X,
-typedef enum {
+enum TemplateOpcode {
#include "../../../template/armv5te-vfp/TemplateOpList.h"
/*
* For example,
@@ -28,7 +28,7 @@
* ...
*/
TEMPLATE_LAST_MARK,
-} TemplateOpcode;
+};
#undef JIT_TEMPLATE
#endif /* _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV5TE_VFP_ARCHVARIANT_H */
diff --git a/vm/compiler/codegen/arm/armv5te/ArchVariant.h b/vm/compiler/codegen/arm/armv5te/ArchVariant.h
index 4cc4fa6..07a1c8c 100644
--- a/vm/compiler/codegen/arm/armv5te/ArchVariant.h
+++ b/vm/compiler/codegen/arm/armv5te/ArchVariant.h
@@ -19,7 +19,7 @@
/* Create the TemplateOpcode enum */
#define JIT_TEMPLATE(X) TEMPLATE_##X,
-typedef enum {
+enum TemplateOpcode {
#include "../../../template/armv5te/TemplateOpList.h"
/*
* For example,
@@ -28,7 +28,7 @@
* ...
*/
TEMPLATE_LAST_MARK,
-} TemplateOpcode;
+};
#undef JIT_TEMPLATE
#endif /* _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV5TE_ARCHVARIANT_H */
diff --git a/vm/compiler/codegen/arm/armv7-a/ArchVariant.h b/vm/compiler/codegen/arm/armv7-a/ArchVariant.h
index 747ecc1..66e236b 100644
--- a/vm/compiler/codegen/arm/armv7-a/ArchVariant.h
+++ b/vm/compiler/codegen/arm/armv7-a/ArchVariant.h
@@ -14,16 +14,12 @@
* limitations under the License.
*/
-#ifndef _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV5TE_VFP_ARCHVARIANT_H
-#define _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV5TE_VFP_ARCHVARIANT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV7_A_ARCHVARIANT_H
+#define _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV7_A_ARCHVARIANT_H
/* Create the TemplateOpcode enum */
#define JIT_TEMPLATE(X) TEMPLATE_##X,
-typedef enum {
+enum TemplateOpcode {
#include "../../../template/armv5te-vfp/TemplateOpList.h"
/*
* For example,
@@ -32,11 +28,7 @@
* ...
*/
TEMPLATE_LAST_MARK,
-} TemplateOpcode;
+};
#undef JIT_TEMPLATE
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV5TE_VFP_ARCHVARIANT_H */
+#endif /* _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMV7_A_ARCHVARIANT_H */
diff --git a/vm/compiler/codegen/x86/CalloutHelper.h b/vm/compiler/codegen/x86/CalloutHelper.h
index a64f017..52c030f 100644
--- a/vm/compiler/codegen/x86/CalloutHelper.h
+++ b/vm/compiler/codegen/x86/CalloutHelper.h
@@ -54,6 +54,6 @@
* Functions declared in gDvmInlineOpsTable[] are used for
* OP_EXECUTE_INLINE & OP_EXECUTE_INLINE_RANGE.
*/
-double sqrt(double x); // INLINE_MATH_SQRT
+extern "C" double sqrt(double x); // INLINE_MATH_SQRT
#endif /* _DALVIK_VM_COMPILER_CODEGEN_X86_CALLOUT_HELPER_H */
diff --git a/vm/compiler/codegen/x86/ia32/ArchVariant.h b/vm/compiler/codegen/x86/ia32/ArchVariant.h
index e4eebf3..c5ce38e 100644
--- a/vm/compiler/codegen/x86/ia32/ArchVariant.h
+++ b/vm/compiler/codegen/x86/ia32/ArchVariant.h
@@ -19,7 +19,7 @@
/* Create the TemplateOpcode enum */
#define JIT_TEMPLATE(X) TEMPLATE_##X,
-typedef enum {
+enum TemplateOpcode {
#include "../../../template/ia32/TemplateOpList.h"
/*
* For example,
@@ -28,7 +28,7 @@
* ...
*/
TEMPLATE_LAST_MARK,
-} TemplateOpcode;
+};
#undef JIT_TEMPLATE
#endif /* _DALVIK_VM_COMPILER_CODEGEN_X86_IA32_ARCHVARIANT_H */
diff --git a/vm/hprof/Hprof.h b/vm/hprof/Hprof.h
index 1721a6e..e31ccc3 100644
--- a/vm/hprof/Hprof.h
+++ b/vm/hprof/Hprof.h
@@ -18,10 +18,6 @@
#include "Dalvik.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define HPROF_ID_SIZE (sizeof (u4))
#define UNIQUE_ERROR() \
@@ -36,7 +32,7 @@
typedef hprof_id hprof_object_id;
typedef hprof_id hprof_class_object_id;
-typedef enum hprof_basic_type {
+enum hprof_basic_type {
hprof_basic_object = 2,
hprof_basic_boolean = 4,
hprof_basic_char = 5,
@@ -46,9 +42,9 @@
hprof_basic_short = 9,
hprof_basic_int = 10,
hprof_basic_long = 11,
-} hprof_basic_type;
+};
-typedef enum hprof_tag_t {
+enum hprof_tag_t {
HPROF_TAG_STRING = 0x01,
HPROF_TAG_LOAD_CLASS = 0x02,
HPROF_TAG_UNLOAD_CLASS = 0x03,
@@ -63,13 +59,13 @@
HPROF_TAG_HEAP_DUMP_END = 0x2C,
HPROF_TAG_CPU_SAMPLES = 0x0D,
HPROF_TAG_CONTROL_SETTINGS = 0x0E,
-} hprof_tag_t;
+};
/* Values for the first byte of
* HEAP_DUMP and HEAP_DUMP_SEGMENT
* records:
*/
-typedef enum hprof_heap_tag_t {
+enum hprof_heap_tag_t {
/* standard */
HPROF_ROOT_UNKNOWN = 0xFF,
HPROF_ROOT_JNI_GLOBAL = 0x01,
@@ -95,7 +91,7 @@
HPROF_ROOT_JNI_MONITOR = 0x8e,
HPROF_UNREACHABLE = 0x90, /* obsolete */
HPROF_PRIMITIVE_ARRAY_NODATA_DUMP = 0xc3,
-} hprof_heap_tag_t;
+};
/* Represents a top-level hprof record, whose serialized
* format is:
@@ -106,22 +102,22 @@
* and belong to this record
* [u1]* BODY: as many bytes as specified in the above u4 field
*/
-typedef struct hprof_record_t {
+struct hprof_record_t {
unsigned char *body;
u4 time;
u4 length;
size_t allocLen;
u1 tag;
bool dirty;
-} hprof_record_t;
+};
-typedef enum {
+enum HprofHeapId {
HPROF_HEAP_DEFAULT = 0,
HPROF_HEAP_ZYGOTE = 'Z',
HPROF_HEAP_APP = 'A'
-} HprofHeapId;
+};
-typedef struct hprof_context_t {
+struct hprof_context_t {
/* curRec *must* be first so that we
* can cast from a context to a record.
*/
@@ -144,7 +140,7 @@
size_t fileDataSize; // for open_memstream
FILE *memFp;
int fd;
-} hprof_context_t;
+};
/*
@@ -228,8 +224,4 @@
void hprofFreeContext(hprof_context_t *ctx);
int hprofDumpHeap(const char* fileName, int fd, bool directToDdms);
-#ifdef __cplusplus
-}
-#endif
-
#endif // _DALVIK_HPROF_HPROF
diff --git a/vm/interp/Interp.cpp b/vm/interp/Interp.cpp
index c219f36..f61f7ba 100644
--- a/vm/interp/Interp.cpp
+++ b/vm/interp/Interp.cpp
@@ -79,12 +79,12 @@
* The debugger may ask us to create the same breakpoint multiple times.
* We only remove the breakpoint when the last instance is cleared.
*/
-typedef struct {
+struct Breakpoint {
Method* method; /* method we're associated with */
u2* addr; /* absolute memory address */
u1 originalOpcode; /* original 8-bit opcode value */
int setCount; /* #of times this breakpoint was set */
-} Breakpoint;
+};
/*
* Set of breakpoints.
diff --git a/vm/interp/Interp.h b/vm/interp/Interp.h
index f0f2198..0667a2e 100644
--- a/vm/interp/Interp.h
+++ b/vm/interp/Interp.h
@@ -20,10 +20,6 @@
#ifndef _DALVIK_INTERP_INTERP
#define _DALVIK_INTERP_INTERP
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Stash the dalvik PC in the frame. Called during interpretation.
*/
@@ -50,7 +46,8 @@
* This is called from the handler for the throw-verification-error
* instruction. "method" is the method currently being executed.
*/
-void dvmThrowVerificationError(const Method* method, int kind, int ref);
+extern "C" void dvmThrowVerificationError(const Method* method,
+ int kind, int ref);
/*
* One-time initialization and shutdown.
@@ -71,7 +68,7 @@
/*
* Recover the opcode that was replaced by a breakpoint.
*/
-u1 dvmGetOriginalOpcode(const u2* addr);
+extern "C" u1 dvmGetOriginalOpcode(const u2* addr);
/*
* Flush any breakpoints associated with methods in "clazz".
@@ -81,18 +78,18 @@
/*
* Debugger support
*/
-void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self);
-void dvmReportExceptionThrow(Thread* self, Object* exception);
-void dvmReportPreNativeInvoke(const Method* methodToCall, Thread* self, u4* fp);
-void dvmReportPostNativeInvoke(const Method* methodToCall, Thread* self, u4* fp);
-void dvmReportInvoke(Thread* self, const Method* methodToCall);
-void dvmReportReturn(Thread* self);
+extern "C" void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self);
+extern "C" void dvmReportExceptionThrow(Thread* self, Object* exception);
+extern "C" void dvmReportPreNativeInvoke(const Method* methodToCall, Thread* self, u4* fp);
+extern "C" void dvmReportPostNativeInvoke(const Method* methodToCall, Thread* self, u4* fp);
+extern "C" void dvmReportInvoke(Thread* self, const Method* methodToCall);
+extern "C" void dvmReportReturn(Thread* self);
/*
* InterpBreak & subMode control
*/
void dvmDisableSubMode(Thread* thread, ExecutionSubModes subMode);
-void dvmEnableSubMode(Thread* thread, ExecutionSubModes subMode);
+extern "C" void dvmEnableSubMode(Thread* thread, ExecutionSubModes subMode);
void dvmDisableAllSubMode(ExecutionSubModes subMode);
void dvmEnableAllSubMode(ExecutionSubModes subMode);
void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta);
@@ -118,8 +115,4 @@
extern void* dvmAsmAltInstructionStart[];
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_INTERP_INTERP*/
diff --git a/vm/interp/InterpDefs.h b/vm/interp/InterpDefs.h
index c2f4295..f362442 100644
--- a/vm/interp/InterpDefs.h
+++ b/vm/interp/InterpDefs.h
@@ -24,10 +24,6 @@
#ifndef _DALVIK_INTERP_DEFS
#define _DALVIK_INTERP_DEFS
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#if defined(WITH_JIT)
/*
* Size of save area for callee-save FP regs, which are not automatically
@@ -63,13 +59,13 @@
/*
* Process switch statement.
*/
-s4 dvmInterpHandlePackedSwitch(const u2* switchData, s4 testVal);
-s4 dvmInterpHandleSparseSwitch(const u2* switchData, s4 testVal);
+extern "C" s4 dvmInterpHandlePackedSwitch(const u2* switchData, s4 testVal);
+extern "C" s4 dvmInterpHandleSparseSwitch(const u2* switchData, s4 testVal);
/*
* Process fill-array-data.
*/
-bool dvmInterpHandleFillArrayData(ArrayObject* arrayObject,
+extern "C" bool dvmInterpHandleFillArrayData(ArrayObject* arrayObject,
const u2* arrayData);
/*
@@ -109,8 +105,4 @@
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_INTERP_DEFS*/
diff --git a/vm/interp/InterpState.h b/vm/interp/InterpState.h
index d50967d..3795bf9 100644
--- a/vm/interp/InterpState.h
+++ b/vm/interp/InterpState.h
@@ -24,21 +24,17 @@
#ifndef _DALVIK_INTERP_STATE
#define _DALVIK_INTERP_STATE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Execution mode, e.g. interpreter vs. JIT.
*/
-typedef enum ExecutionMode {
+enum ExecutionMode {
kExecutionModeUnknown = 0,
kExecutionModeInterpPortable,
kExecutionModeInterpFast,
#if defined(WITH_JIT)
kExecutionModeJit,
#endif
-} ExecutionMode;
+};
/*
* Execution sub modes, e.g. debugging, profiling, etc.
@@ -46,7 +42,7 @@
* by assembly code in the mterp interpeter and may also be used by
* code generated by the JIT. Take care when changing.
*/
-typedef enum ExecutionSubModes {
+enum ExecutionSubModes {
kSubModeNormal = 0x0000, /* No active subMode */
kSubModeMethodTrace = 0x0001,
kSubModeEmulatorTrace = 0x0002,
@@ -61,7 +57,7 @@
kSubModeEmulatorTrace |
kSubModeInstCounting |
kSubModeDebuggerActive)
-} ExecutionSubModes;
+};
/*
* Interpreter break flags. When set, causes the interpreter to
@@ -69,11 +65,11 @@
* handler.
*/
-typedef enum InterpBreakFlags {
+enum InterpBreakFlags {
kInterpNoBreak = 0x00, /* Don't check */
kInterpSingleStep = 0x01, /* Check between each inst */
kInterpSafePoint = 0x02, /* Check at safe points */
-} InterpBreakFlags;
+};
/*
* Mapping between subModes and required check intervals. Note: in
@@ -96,7 +92,7 @@
*/
#define LOCAL_SUBMODE (kSubModeJitTraceBuild)
-typedef struct InterpSaveState {
+struct InterpSaveState {
const u2* pc; // Dalvik PC
u4* curFrame; // Dalvik frame pointer
const Method *method; // Method being executed
@@ -108,7 +104,7 @@
int unused; // Keep struct size constant
#endif
struct InterpSaveState* prev; // To follow nested activations
-} InterpSaveState;
+};
#ifdef WITH_JIT
/*
@@ -150,7 +146,7 @@
};
/* States of the interpreter when serving a JIT-related request */
-typedef enum JitState {
+enum JitState {
/* Entering states in the debug interpreter */
kJitNot = 0, // Non-JIT related reasons */
kJitTSelectRequest = 1, // Request a trace (subject to filtering)
@@ -161,10 +157,10 @@
kJitTSelect = 4, // Actively selecting a trace
kJitTSelectEnd = 5, // Done with the trace - wrap it up
kJitDone = 6, // No further JIT actions for interpBreak
-} JitState;
+};
#if defined(WITH_SELF_VERIFICATION)
-typedef enum SelfVerificationState {
+enum SelfVerificationState {
kSVSIdle = 0, // Idle
kSVSStart = 1, // Shadow space set up, running compiled code
kSVSPunt = 2, // Exiting compiled code by punting
@@ -175,7 +171,7 @@
kSVSNoChain = 7, // Exiting compiled code by no chain
kSVSBackwardBranch = 8, // Exiting compiled code with backward branch trace
kSVSDebugInterp = 9, // Normal state restored, running debug interpreter
-} SelfVerificationState;
+};
#endif
/* Number of entries in the 2nd level JIT profiler filter cache */
@@ -184,23 +180,23 @@
#define JIT_TRACE_THRESH_FILTER_PC_BITS 4
#define MAX_JIT_RUN_LEN 64
-typedef enum JitHint {
+enum JitHint {
kJitHintNone = 0,
kJitHintTaken = 1, // Last inst in run was taken branch
kJitHintNotTaken = 2, // Last inst in run was not taken branch
kJitHintNoBias = 3, // Last inst in run was unbiased branch
-} jitHint;
+};
/*
* Element of a Jit trace description. If the isCode bit is set, it describes
* a contiguous sequence of Dalvik byte codes.
*/
-typedef struct {
+struct JitCodeDesc {
unsigned numInsts:8; // Number of Byte codes in run
unsigned runEnd:1; // Run ends with last byte code
- jitHint hint:7; // Hint to apply to final code of run
- u2 startOffset; // Starting offset for trace run
-} JitCodeDesc;
+ JitHint hint:7; // Hint to apply to final code of run
+ u2 startOffset; // Starting offset for trace run
+};
/*
* A complete list of trace runs passed to the compiler looks like the
@@ -224,19 +220,15 @@
* descriptor/loader of "this" and the currently resolved method pointer are
* three instances of meta information stored there.
*/
-typedef struct {
+struct JitTraceRun {
union {
JitCodeDesc frag;
void* meta;
} info;
u4 isCode:1;
u4 unused:31;
-} JitTraceRun;
+};
#endif
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_INTERP_STATE*/
diff --git a/vm/interp/Jit.h b/vm/interp/Jit.h
index c05fadd..89256ca 100644
--- a/vm/interp/Jit.h
+++ b/vm/interp/Jit.h
@@ -22,10 +22,6 @@
#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)
@@ -33,17 +29,17 @@
#define REG_SPACE 256 /* default size of shadow space */
#define HEAP_SPACE JIT_MAX_TRACE_LEN /* default size of heap space */
-typedef struct ShadowHeap {
+struct ShadowHeap {
int addr;
int data;
-} ShadowHeap;
+};
-typedef struct InstructionTrace {
+struct InstructionTrace {
int addr;
DecodedInstruction decInsn;
-} InstructionTrace;
+};
-typedef struct ShadowSpace {
+struct ShadowSpace {
const u2* startPC; /* starting pc of jitted region */
u4* fp; /* starting fp of jitted region */
const Method *method;
@@ -61,11 +57,12 @@
const void* endShadowFP; /* ending fp in shadow space */
InstructionTrace trace[JIT_MAX_TRACE_LEN]; /* opcode trace for debugging */
int traceLength; /* counter for current trace length */
-} ShadowSpace;
+};
/*
* Self verification functions.
*/
+extern "C" {
void* dvmSelfVerificationShadowSpaceAlloc(Thread* self);
void dvmSelfVerificationShadowSpaceFree(Thread* self);
void* dvmSelfVerificationSaveState(const u2* pc, u4* fp,
@@ -75,6 +72,7 @@
SelfVerificationState exitPoint,
Thread *self);
void dvmCheckSelfVerification(const u2* pc, Thread* self);
+}
#endif
/*
@@ -115,10 +113,10 @@
typedef s4 JitTraceCounter_t;
-typedef struct JitTraceProfCounters {
+struct JitTraceProfCounters {
unsigned int next;
JitTraceCounter_t *buckets[JIT_PROF_BLOCK_BUCKETS];
-} JitTraceProfCounters;
+};
/*
* Entries in the JIT's address lookup hash table.
@@ -126,7 +124,7 @@
* single 32-bit word to allow use of atomic update.
*/
-typedef struct JitEntryInfo {
+struct JitEntryInfo {
unsigned int isMethodEntry:1;
unsigned int inlineCandidate:1;
unsigned int profileEnabled:1;
@@ -134,19 +132,20 @@
unsigned int profileOffset:5;
unsigned int unused:5;
u2 chain; /* Index of next in chain */
-} JitEntryInfo;
+};
-typedef union JitEntryInfoUnion {
+union JitEntryInfoUnion {
JitEntryInfo info;
volatile int infoWord;
-} JitEntryInfoUnion;
+};
-typedef struct JitEntry {
+struct JitEntry {
JitEntryInfoUnion u;
const u2* dPC; /* Dalvik code address */
void* codeAddress; /* Code address of native translation */
-} JitEntry;
+};
+extern "C" {
void dvmCheckJit(const u2* pc, Thread* self);
void* dvmJitGetTraceAddr(const u2* dPC);
void* dvmJitGetMethodAddr(const u2* dPC);
@@ -162,7 +161,7 @@
void dvmJitStats(void);
bool dvmJitResizeJitTable(unsigned int size);
void dvmJitResetTable(void);
-struct JitEntry *dvmJitFindEntry(const u2* pc, bool isMethodEntry);
+JitEntry *dvmJitFindEntry(const u2* pc, bool isMethodEntry);
s8 dvmJitd2l(double d);
s8 dvmJitf2l(float f);
void dvmJitSetCodeAddr(const u2* dPC, void *nPC, JitInstructionSetType set,
@@ -176,9 +175,6 @@
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.cpp b/vm/interp/Stack.cpp
index 120726e..23d8049 100644
--- a/vm/interp/Stack.cpp
+++ b/vm/interp/Stack.cpp
@@ -780,10 +780,10 @@
return retObj;
}
-typedef struct LineNumFromPcContext {
+struct LineNumFromPcContext {
u4 address;
u4 lineNum;
-} LineNumFromPcContext;
+};
static int lineNumForPcCb(void *cnxt, u4 address, u4 lineNum)
{
diff --git a/vm/interp/Stack.h b/vm/interp/Stack.h
index 69dd3da..4e806b7 100644
--- a/vm/interp/Stack.h
+++ b/vm/interp/Stack.h
@@ -23,10 +23,6 @@
#include "jni.h"
#include <stdarg.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
Stack layout
@@ -111,7 +107,6 @@
struct StackSaveArea;
-typedef struct StackSaveArea StackSaveArea;
//#define PAD_SAVE_AREA /* help debug stack trampling */
@@ -274,15 +269,11 @@
/*
* Common handling for stack overflow.
*/
-void dvmHandleStackOverflow(Thread* self, const Method* method);
-void dvmCleanupStackOverflow(Thread* self, const Object* exception);
+extern "C" void dvmHandleStackOverflow(Thread* self, const Method* method);
+extern "C" void dvmCleanupStackOverflow(Thread* self, const Object* exception);
/* debugging; dvmDumpThread() is probably a better starting point */
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/jdwp/ExpandBuf.h b/vm/jdwp/ExpandBuf.h
index fea3a4d..6bdab0f 100644
--- a/vm/jdwp/ExpandBuf.h
+++ b/vm/jdwp/ExpandBuf.h
@@ -21,12 +21,7 @@
#include "Common.h" // need u1/u2/u4/u8 types
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct ExpandBuf; /* private */
-typedef struct ExpandBuf ExpandBuf;
/* create a new struct */
ExpandBuf* expandBufAlloc(void);
@@ -58,8 +53,4 @@
void expandBufAdd8BE(ExpandBuf* pBuf, u8 val);
void expandBufAddUtf8String(ExpandBuf* pBuf, const u1* str);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JDWP_EXPANDBUF*/
diff --git a/vm/jdwp/Jdwp.h b/vm/jdwp/Jdwp.h
index fb92e2a..9199a1e 100644
--- a/vm/jdwp/Jdwp.h
+++ b/vm/jdwp/Jdwp.h
@@ -30,12 +30,7 @@
#include "Bits.h"
#include <pthread.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct JdwpState; /* opaque */
-typedef struct JdwpState JdwpState;
/*
* Fundamental types.
@@ -82,34 +77,33 @@
/*
* Holds a JDWP "location".
*/
-typedef struct JdwpLocation {
+struct JdwpLocation {
u1 typeTag; /* class or interface? */
RefTypeId classId; /* method->clazz */
MethodId methodId; /* method in which "idx" resides */
u8 idx; /* relative index into code block */
-} JdwpLocation;
-//#define kJDWPLocationSize (25)
+};
/*
* How we talk to the debugger.
*/
-typedef enum JdwpTransportType {
+enum JdwpTransportType {
kJdwpTransportUnknown = 0,
kJdwpTransportSocket, /* transport=dt_socket */
kJdwpTransportAndroidAdb, /* transport=dt_android_adb */
-} JdwpTransportType;
+};
/*
* Holds collection of JDWP initialization parameters.
*/
-typedef struct JdwpStartupParams {
+struct JdwpStartupParams {
JdwpTransportType transport;
bool server;
bool suspend;
char host[64];
short port;
/* more will be here someday */
-} JdwpStartupParams;
+};
/*
* Perform one-time initialization.
@@ -239,8 +233,4 @@
void dvmJdwpDdmSendChunkV(JdwpState* state, int type, const struct iovec* iov,
int iovcnt);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JDWP_JDWP*/
diff --git a/vm/jdwp/JdwpConstants.cpp b/vm/jdwp/JdwpConstants.cpp
index 4b1418b..ab9d872 100644
--- a/vm/jdwp/JdwpConstants.cpp
+++ b/vm/jdwp/JdwpConstants.cpp
@@ -23,7 +23,7 @@
/*
* Return a string for the error code.
*/
-const char* dvmJdwpErrorStr(enum JdwpError error)
+const char* dvmJdwpErrorStr(JdwpError error)
{
switch (error) {
case ERR_NONE:
@@ -146,7 +146,7 @@
/*
* Return a string for the EventKind.
*/
-const char* dvmJdwpEventKindStr(enum JdwpEventKind kind)
+const char* dvmJdwpEventKindStr(JdwpEventKind kind)
{
switch (kind) {
case EK_SINGLE_STEP: return "SINGLE_STEP";
@@ -176,7 +176,7 @@
/*
* Return a string for the ModKind.
*/
-const char* dvmJdwpModKindStr(enum JdwpModKind kind)
+const char* dvmJdwpModKindStr(JdwpModKind kind)
{
switch (kind) {
case MK_COUNT: return "COUNT";
@@ -197,7 +197,7 @@
/*
* Return a string for the StepDepth.
*/
-const char* dvmJdwpStepDepthStr(enum JdwpStepDepth depth)
+const char* dvmJdwpStepDepthStr(JdwpStepDepth depth)
{
switch (depth) {
case SD_INTO: return "INTO";
@@ -210,7 +210,7 @@
/*
* Return a string for the StepSize.
*/
-const char* dvmJdwpStepSizeStr(enum JdwpStepSize size)
+const char* dvmJdwpStepSizeStr(JdwpStepSize size)
{
switch (size) {
case SS_MIN: return "MIN";
@@ -222,7 +222,7 @@
/*
* Return a string for the SuspendPolicy.
*/
-const char* dvmJdwpSuspendPolicyStr(enum JdwpSuspendPolicy policy)
+const char* dvmJdwpSuspendPolicyStr(JdwpSuspendPolicy policy)
{
switch (policy) {
case SP_NONE: return "NONE";
@@ -235,7 +235,7 @@
/*
* Return a string for the SuspendStatus.
*/
-const char* dvmJdwpSuspendStatusStr(enum JdwpSuspendStatus status)
+const char* dvmJdwpSuspendStatusStr(JdwpSuspendStatus status)
{
switch (status) {
case 0: return "Not SUSPENDED";
@@ -247,7 +247,7 @@
/*
* Return a string for the ThreadStatus.
*/
-const char* dvmJdwpThreadStatusStr(enum JdwpThreadStatus status)
+const char* dvmJdwpThreadStatusStr(JdwpThreadStatus status)
{
switch (status) {
case TS_ZOMBIE: return "ZOMBIE";
diff --git a/vm/jdwp/JdwpConstants.h b/vm/jdwp/JdwpConstants.h
index dc3a279..f3049e5 100644
--- a/vm/jdwp/JdwpConstants.h
+++ b/vm/jdwp/JdwpConstants.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_JDWP_JDWPCONSTANTS
#define _DALVIK_JDWP_JDWPCONSTANTS
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Error constants.
*/
@@ -84,8 +80,7 @@
ERR_NATIVE_METHOD = 511,
ERR_INVALID_COUNT = 512,
};
-typedef enum JdwpError JdwpError;
-const char* dvmJdwpErrorStr(enum JdwpError error);
+const char* dvmJdwpErrorStr(JdwpError error);
/*
@@ -123,7 +118,7 @@
EK_VM_START = EK_VM_INIT,
EK_THREAD_DEATH = EK_THREAD_END,
};
-const char* dvmJdwpEventKindStr(enum JdwpEventKind kind);
+const char* dvmJdwpEventKindStr(JdwpEventKind kind);
/*
* Values for "modKind" in EventRequest.Set.
@@ -141,7 +136,7 @@
MK_STEP = 10,
MK_INSTANCE_ONLY = 11,
};
-const char* dvmJdwpModKindStr(enum JdwpModKind kind);
+const char* dvmJdwpModKindStr(JdwpModKind kind);
/*
* InvokeOptions constants (bit flags).
@@ -159,7 +154,7 @@
SD_OVER = 1, /* step over method calls */
SD_OUT = 2, /* step out of current method */
};
-const char* dvmJdwpStepDepthStr(enum JdwpStepDepth depth);
+const char* dvmJdwpStepDepthStr(JdwpStepDepth depth);
/*
* StepSize constants.
@@ -168,7 +163,7 @@
SS_MIN = 0, /* step by minimum (e.g. 1 bytecode inst) */
SS_LINE = 1, /* if possible, step to next line */
};
-const char* dvmJdwpStepSizeStr(enum JdwpStepSize size);
+const char* dvmJdwpStepSizeStr(JdwpStepSize size);
/*
* SuspendPolicy constants.
@@ -178,7 +173,7 @@
SP_EVENT_THREAD = 1, /* suspend event thread */
SP_ALL = 2, /* suspend all threads */
};
-const char* dvmJdwpSuspendPolicyStr(enum JdwpSuspendPolicy policy);
+const char* dvmJdwpSuspendPolicyStr(JdwpSuspendPolicy policy);
/*
* SuspendStatus constants.
@@ -186,7 +181,7 @@
enum JdwpSuspendStatus {
SUSPEND_STATUS_SUSPENDED = 1,
};
-const char* dvmJdwpSuspendStatusStr(enum JdwpSuspendStatus status);
+const char* dvmJdwpSuspendStatusStr(JdwpSuspendStatus status);
/*
* ThreadStatus constants.
@@ -198,7 +193,7 @@
TS_MONITOR = 3, // WAITING (monitor wait)
TS_WAIT = 4, // (in Object.wait())
};
-const char* dvmJdwpThreadStatusStr(enum JdwpThreadStatus status);
+const char* dvmJdwpThreadStatusStr(JdwpThreadStatus status);
/*
* TypeTag constants.
@@ -231,8 +226,4 @@
JT_CLASS_OBJECT = 'c',
};
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JDWP_JDWPCONSTANTS*/
diff --git a/vm/jdwp/JdwpEvent.cpp b/vm/jdwp/JdwpEvent.cpp
index f93faaa..15f0b2a 100644
--- a/vm/jdwp/JdwpEvent.cpp
+++ b/vm/jdwp/JdwpEvent.cpp
@@ -100,7 +100,7 @@
* values for mods valid for the event being evaluated will be filled in.
* The rest will be zeroed.
*/
-typedef struct ModBasket {
+struct ModBasket {
const JdwpLocation* pLoc; /* LocationOnly */
const char* className; /* ClassMatch/ClassExclude */
ObjectId threadId; /* ThreadOnly */
@@ -110,7 +110,7 @@
FieldId field; /* FieldOnly */
ObjectId thisPtr; /* InstanceOnly */
/* nothing for StepOnly -- handled differently */
-} ModBasket;
+};
/*
* Get the next "request" serial number. We use this when sending
@@ -536,7 +536,7 @@
* DO NOT call this multiple times for the same eventKind, as Count mods are
* decremented during the scan.
*/
-static void findMatchingEvents(JdwpState* state, enum JdwpEventKind eventKind,
+static void findMatchingEvents(JdwpState* state, JdwpEventKind eventKind,
ModBasket* basket, JdwpEvent** matchList, int* pMatchCount)
{
/* start after the existing entries */
@@ -558,10 +558,10 @@
* Scan through the list of matches and determine the most severe
* suspension policy.
*/
-static enum JdwpSuspendPolicy scanSuspendPolicy(JdwpEvent** matchList,
+static JdwpSuspendPolicy scanSuspendPolicy(JdwpEvent** matchList,
int matchCount)
{
- enum JdwpSuspendPolicy policy = SP_NONE;
+ JdwpSuspendPolicy policy = SP_NONE;
while (matchCount--) {
if ((*matchList)->suspendPolicy > policy)
@@ -578,8 +578,7 @@
* SP_EVENT_THREAD - suspend ourselves
* SP_ALL - suspend everybody except JDWP support thread
*/
-static void suspendByPolicy(JdwpState* state,
- enum JdwpSuspendPolicy suspendPolicy)
+static void suspendByPolicy(JdwpState* state, JdwpSuspendPolicy suspendPolicy)
{
if (suspendPolicy == SP_NONE)
return;
@@ -745,7 +744,7 @@
*/
bool dvmJdwpPostVMStart(JdwpState* state, bool suspend)
{
- enum JdwpSuspendPolicy suspendPolicy;
+ JdwpSuspendPolicy suspendPolicy;
ObjectId threadId = dvmDbgGetThreadSelfId();
if (suspend)
@@ -811,7 +810,7 @@
bool dvmJdwpPostLocationEvent(JdwpState* state, const JdwpLocation* pLoc,
ObjectId thisPtr, int eventFlags)
{
- enum JdwpSuspendPolicy suspendPolicy = SP_NONE;
+ JdwpSuspendPolicy suspendPolicy = SP_NONE;
ModBasket basket;
char* nameAlloc = NULL;
@@ -920,7 +919,7 @@
*/
bool dvmJdwpPostThreadChange(JdwpState* state, ObjectId threadId, bool start)
{
- enum JdwpSuspendPolicy suspendPolicy = SP_NONE;
+ JdwpSuspendPolicy suspendPolicy = SP_NONE;
assert(threadId = dvmDbgGetThreadSelfId());
@@ -1024,7 +1023,7 @@
ObjectId exceptionId, RefTypeId exceptionClassId,
const JdwpLocation* pCatchLoc, ObjectId thisPtr)
{
- enum JdwpSuspendPolicy suspendPolicy = SP_NONE;
+ JdwpSuspendPolicy suspendPolicy = SP_NONE;
ModBasket basket;
char* nameAlloc = NULL;
@@ -1122,7 +1121,7 @@
bool dvmJdwpPostClassPrepare(JdwpState* state, int tag, RefTypeId refTypeId,
const char* signature, int status)
{
- enum JdwpSuspendPolicy suspendPolicy = SP_NONE;
+ JdwpSuspendPolicy suspendPolicy = SP_NONE;
ModBasket basket;
char* nameAlloc = NULL;
diff --git a/vm/jdwp/JdwpEvent.h b/vm/jdwp/JdwpEvent.h
index 110d0f2..1eb9b15 100644
--- a/vm/jdwp/JdwpEvent.h
+++ b/vm/jdwp/JdwpEvent.h
@@ -22,14 +22,10 @@
#include "JdwpConstants.h"
#include "ExpandBuf.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Event modifiers. A JdwpEvent may have zero or more of these.
*/
-typedef union JdwpEventMod {
+union JdwpEventMod {
u1 modKind; /* JdwpModKind */
struct {
u1 modKind;
@@ -80,24 +76,24 @@
u1 modKind;
ObjectId objectId;
} instanceOnly;
-} JdwpEventMod;
+};
/*
* One of these for every registered event.
*
* We over-allocate the struct to hold the modifiers.
*/
-typedef struct JdwpEvent {
- struct JdwpEvent* prev; /* linked list */
- struct JdwpEvent* next;
+struct JdwpEvent {
+ JdwpEvent* prev; /* linked list */
+ JdwpEvent* next;
- enum JdwpEventKind eventKind; /* what kind of event is this? */
- enum JdwpSuspendPolicy suspendPolicy; /* suspend all, none, or self? */
- int modCount; /* #of entries in mods[] */
- u4 requestId; /* serial#, reported to debugger */
+ JdwpEventKind eventKind; /* what kind of event is this? */
+ JdwpSuspendPolicy suspendPolicy; /* suspend all, none, or self? */
+ int modCount; /* #of entries in mods[] */
+ u4 requestId; /* serial#, reported to debugger */
- JdwpEventMod mods[1]; /* MUST be last field in struct */
-} JdwpEvent;
+ JdwpEventMod mods[1]; /* MUST be last field in struct */
+};
/*
* Allocate an event structure with enough space.
@@ -130,8 +126,4 @@
*/
bool dvmJdwpSendRequest(JdwpState* state, ExpandBuf* pReq);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JDWP_JDWPEVENT*/
diff --git a/vm/jdwp/JdwpHandler.cpp b/vm/jdwp/JdwpHandler.cpp
index 7776c83..930d25e 100644
--- a/vm/jdwp/JdwpHandler.cpp
+++ b/vm/jdwp/JdwpHandler.cpp
@@ -1713,12 +1713,12 @@
typedef JdwpError (*JdwpRequestHandler)(JdwpState* state,
const u1* buf, int dataLen, ExpandBuf* reply);
-typedef struct {
+struct JdwpHandlerMap {
u1 cmdSet;
u1 cmd;
JdwpRequestHandler func;
const char* descr;
-} JdwpHandlerMap;
+};
/*
* Map commands to functions.
diff --git a/vm/jdwp/JdwpHandler.h b/vm/jdwp/JdwpHandler.h
index 4486c9d..aade65d 100644
--- a/vm/jdwp/JdwpHandler.h
+++ b/vm/jdwp/JdwpHandler.h
@@ -22,19 +22,15 @@
#include "Common.h"
#include "ExpandBuf.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* JDWP message header for a request.
*/
-typedef struct JdwpReqHeader {
+struct JdwpReqHeader {
u4 length;
u4 id;
u1 cmdSet;
u1 cmd;
-} JdwpReqHeader;
+};
/*
* Process a request from the debugger.
@@ -48,8 +44,4 @@
/* helper function */
void dvmJdwpAddLocation(ExpandBuf* pReply, const JdwpLocation* pLoc);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JDWP_JDWPHANDLER*/
diff --git a/vm/jdwp/JdwpPriv.h b/vm/jdwp/JdwpPriv.h
index 8d78bbc..6b15fa9 100644
--- a/vm/jdwp/JdwpPriv.h
+++ b/vm/jdwp/JdwpPriv.h
@@ -28,10 +28,6 @@
#include <pthread.h>
#include <sys/uio.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* JDWP constants.
*/
@@ -47,14 +43,12 @@
* Transport-specific network status.
*/
struct JdwpNetState;
-typedef struct JdwpNetState JdwpNetState;
-
struct JdwpState;
/*
* Transport functions.
*/
-typedef struct JdwpTransport {
+struct JdwpTransport {
bool (*startup)(struct JdwpState* state, const JdwpStartupParams* pParams);
bool (*accept)(struct JdwpState* state);
bool (*establish)(struct JdwpState* state);
@@ -67,7 +61,7 @@
bool (*sendRequest)(struct JdwpState* state, ExpandBuf* pReq);
bool (*sendBufferedRequest)(struct JdwpState* state,
const struct iovec* iov, int iovcnt);
-} JdwpTransport;
+};
const JdwpTransport* dvmJdwpSocketTransport();
const JdwpTransport* dvmJdwpAndroidAdbTransport();
@@ -180,8 +174,4 @@
return (*state->transport->sendBufferedRequest)(state, iov, iovcnt);
}
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_JDWP_JDWPPRIV*/
diff --git a/vm/mterp/Mterp.h b/vm/mterp/Mterp.h
index 2dbc325..d68e0b1 100644
--- a/vm/mterp/Mterp.h
+++ b/vm/mterp/Mterp.h
@@ -26,15 +26,11 @@
#include "interp/Jit.h"
#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Call this during initialization to verify that the values in asm-constants.h
* are still correct.
*/
-bool dvmCheckAsmConstants(void);
+extern "C" bool dvmCheckAsmConstants(void);
/*
* Local entry and exit points. The platform-specific implementation must
@@ -46,17 +42,13 @@
*
* The "mterp" interpreter is always "standard".
*/
-bool dvmMterpStdRun(Thread* self);
-void dvmMterpStdBail(Thread* self, bool changeInterp);
+extern "C" bool dvmMterpStdRun(Thread* self);
+extern "C" void dvmMterpStdBail(Thread* self, bool changeInterp);
/*
* Helper for common_printMethod(), invoked from the assembly
* interpreter.
*/
-void dvmMterpPrintMethod(Method* method);
-
-#ifdef __cplusplus
-}
-#endif
+extern "C" void dvmMterpPrintMethod(Method* method);
#endif /*_DALVIK_MTERP_MTERP*/
diff --git a/vm/mterp/common/FindInterface.h b/vm/mterp/common/FindInterface.h
index a640adb..72d45ff 100644
--- a/vm/mterp/common/FindInterface.h
+++ b/vm/mterp/common/FindInterface.h
@@ -17,9 +17,7 @@
/* common includes */
#include "Dalvik.h"
-#ifdef __cplusplus
extern "C" {
-#endif
/*
* Look up an interface on a class using the cache.
@@ -40,6 +38,4 @@
#undef ATOMIC_CACHE_CALC
}
-#ifdef __cplusplus
}
-#endif
diff --git a/vm/native/InternalNative.h b/vm/native/InternalNative.h
index 4d32de2..e6b210d 100644
--- a/vm/native/InternalNative.h
+++ b/vm/native/InternalNative.h
@@ -17,10 +17,6 @@
#ifndef _DALVIK_NATIVE_INTERNALNATIVE
#define _DALVIK_NATIVE_INTERNALNATIVE
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Some setup for internal native functions.
*/
@@ -31,10 +27,6 @@
DalvikNativeFunc dvmLookupInternalNativeMethod(const Method* method);
/* exception-throwing stub for abstract methods (DalvikNativeFunc) */
-void dvmAbstractMethodStub(const u4* args, JValue* pResult);
-
-#ifdef __cplusplus
-}
-#endif
+extern "C" void dvmAbstractMethodStub(const u4* args, JValue* pResult);
#endif /*_DALVIK_NATIVE_INTERNALNATIVE*/
diff --git a/vm/native/InternalNativePriv.h b/vm/native/InternalNativePriv.h
index 35ab44c..440e60d 100644
--- a/vm/native/InternalNativePriv.h
+++ b/vm/native/InternalNativePriv.h
@@ -20,10 +20,6 @@
#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.
@@ -116,8 +112,4 @@
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/native/dalvik_system_DexFile.cpp b/vm/native/dalvik_system_DexFile.cpp
index e4bf5cd..59dddfc 100644
--- a/vm/native/dalvik_system_DexFile.cpp
+++ b/vm/native/dalvik_system_DexFile.cpp
@@ -34,14 +34,14 @@
/*
* Internal struct for managing DexFile.
*/
-typedef struct DexOrJar {
+struct DexOrJar {
char* fileName;
bool isDex;
bool okayToFree;
RawDexFile* pRawDexFile;
JarFile* pJarFile;
u1* pDexMemory; // malloc()ed memory, if any
-} DexOrJar;
+};
/*
* (This is a dvmHashTableFree callback.)
diff --git a/vm/oo/AccessCheck.h b/vm/oo/AccessCheck.h
index 8633d89..105c9e1 100644
--- a/vm/oo/AccessCheck.h
+++ b/vm/oo/AccessCheck.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_OO_ACCESSCHECK
#define _DALVIK_OO_ACCESSCHECK
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Determine whether the "accessFrom" class is allowed to get at "clazz".
*/
@@ -44,8 +40,4 @@
*/
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 3f8f253..9a5df52 100644
--- a/vm/oo/Array.h
+++ b/vm/oo/Array.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_OO_ARRAY
#define _DALVIK_OO_ARRAY
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* Find a matching array class. If it doesn't exist, create it.
*
@@ -45,7 +41,7 @@
*
* Returns NULL with an exception raised if allocation fails.
*/
-ArrayObject* dvmAllocArrayByClass(ClassObject* arrayClass,
+extern "C" ArrayObject* dvmAllocArrayByClass(ClassObject* arrayClass,
size_t length, int allocFlags);
/*
@@ -141,8 +137,4 @@
*/
size_t dvmArrayClassElementWidth(const ClassObject* clazz);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_OO_ARRAY*/
diff --git a/vm/oo/Class.cpp b/vm/oo/Class.cpp
index 2311f8a..259146b 100644
--- a/vm/oo/Class.cpp
+++ b/vm/oo/Class.cpp
@@ -937,10 +937,10 @@
*/
/* search for these criteria in the Class hash table */
-typedef struct ClassMatchCriteria {
+struct ClassMatchCriteria {
const char* descriptor;
Object* loader;
-} ClassMatchCriteria;
+};
#define kInitLoaderInc 4 /* must be power of 2 */
diff --git a/vm/oo/Class.h b/vm/oo/Class.h
index 83f6622..025989e 100644
--- a/vm/oo/Class.h
+++ b/vm/oo/Class.h
@@ -19,10 +19,6 @@
#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
@@ -39,19 +35,19 @@
* Ordering is significant. (Currently only ".dex" is supported directly
* by the VM.)
*/
-typedef enum {
+enum ClassPathEntryKind {
kCpeUnknown = 0,
kCpeDir,
kCpeJar,
kCpeDex,
kCpeLastEntry /* used as sentinel at end of array */
-} ClassPathEntryKind;
+};
-typedef struct ClassPathEntry {
+struct ClassPathEntry {
ClassPathEntryKind kind;
char* fileName;
void* ptr; /* JarFile* or DexFile* */
-} ClassPathEntry;
+};
bool dvmClassStartup(void);
void dvmClassShutdown(void);
@@ -134,7 +130,7 @@
/*
* Initialize a class.
*/
-bool dvmInitClass(ClassObject* clazz);
+extern "C" bool dvmInitClass(ClassObject* clazz);
/*
* Retrieve the system class loader.
@@ -287,8 +283,4 @@
*/
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 55c4d1a..abc819a 100644
--- a/vm/oo/Object.h
+++ b/vm/oo/Object.h
@@ -24,10 +24,6 @@
#include <stddef.h>
#include "Atomic.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* fwd decl */
struct DataObject;
struct InitiatingLoaderList;
@@ -41,18 +37,6 @@
struct InstField;
struct Field;
struct RegisterMap;
-typedef struct DataObject DataObject;
-typedef struct InitiatingLoaderList InitiatingLoaderList;
-typedef struct ClassObject ClassObject;
-typedef struct StringObject StringObject;
-typedef struct ArrayObject ArrayObject;
-typedef struct Method Method;
-typedef struct ExceptionEntry ExceptionEntry;
-typedef struct LineNumEntry LineNumEntry;
-typedef struct StaticField StaticField;
-typedef struct InstField InstField;
-typedef struct Field Field;
-typedef struct RegisterMap RegisterMap;
/*
* Native function pointer type.
@@ -70,16 +54,16 @@
/* vm-internal access flags and related definitions */
-typedef enum AccessFlags {
+enum AccessFlags {
ACC_MIRANDA = 0x8000, // method (internal to VM)
JAVA_FLAGS_MASK = 0xffff, // bits set from Java sources (low 16)
-} AccessFlags;
+};
/* Use the top 16 bits of the access flags field for
* other class flags. Code should use the *CLASS_FLAG*()
* macros to set/get these flags.
*/
-typedef enum ClassFlags {
+enum ClassFlags {
CLASS_ISFINALIZABLE = (1<<31), // class/ancestor overrides finalize()
CLASS_ISARRAY = (1<<30), // class is a "[*"
CLASS_ISOBJECTARRAY = (1<<29), // class is a "[L*" or "[[*"
@@ -96,7 +80,7 @@
/* unlike the others, these can be present in the optimized DEX file */
CLASS_ISOPTIMIZED = (1<<17), // class may contain opt instrs
CLASS_ISPREVERIFIED = (1<<16), // class has been pre-verified
-} ClassFlags;
+};
/* bits we can reasonably expect to see set in a DEX access flags field */
#define EXPECTED_FILE_FLAGS \
@@ -121,9 +105,9 @@
* Use the top 16 bits of the access flags field for other method flags.
* Code should use the *METHOD_FLAG*() macros to set/get these flags.
*/
-typedef enum MethodFlags {
+enum MethodFlags {
METHOD_ISWRITABLE = (1<<31), // the method's code is writable
-} MethodFlags;
+};
/*
* Get/set method flags.
@@ -141,7 +125,7 @@
((u4)((method)->accessFlags & (flags)))
/* current state of the class, increasing as we progress */
-typedef enum ClassStatus {
+enum ClassStatus {
CLASS_ERROR = -1,
CLASS_NOTREADY = 0,
@@ -152,7 +136,7 @@
CLASS_VERIFIED = 5, /* logically part of linking; done pre-init */
CLASS_INITIALIZING = 6, /* class init in progress */
CLASS_INITIALIZED = 7, /* ready to go */
-} ClassStatus;
+};
/*
* Definitions for packing refOffsets in ClassObject.
@@ -196,7 +180,7 @@
/*
* Used for iftable in ClassObject.
*/
-typedef struct InterfaceEntry {
+struct InterfaceEntry {
/* pointer to interface class */
ClassObject* clazz;
@@ -205,7 +189,7 @@
* which holds the vtables for all interfaces declared by this class.
*/
int* methodIndexArray;
-} InterfaceEntry;
+};
@@ -221,7 +205,7 @@
*
* All objects have an Object header followed by type-specific data.
*/
-typedef struct Object {
+struct Object {
/* ptr to class object */
ClassObject* clazz;
@@ -230,7 +214,7 @@
* the comments in Sync.c for a description of its layout.
*/
u4 lock;
-} Object;
+};
/*
* Properly initialize an Object.
@@ -793,8 +777,4 @@
/* 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 1579a56..ef01834 100644
--- a/vm/oo/ObjectInlines.h
+++ b/vm/oo/ObjectInlines.h
@@ -20,10 +20,6 @@
#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.
@@ -358,8 +354,4 @@
}
}
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_OO_OBJECTINLINES*/
diff --git a/vm/oo/Resolve.h b/vm/oo/Resolve.h
index 1403e77..5eb6814 100644
--- a/vm/oo/Resolve.h
+++ b/vm/oo/Resolve.h
@@ -19,10 +19,6 @@
#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
@@ -31,13 +27,13 @@
* (<clinit>, <init>, and methods declared "private" or "static" are stored
* in the "direct" list. All others are stored in the "virtual" list.)
*/
-typedef enum MethodType {
+enum MethodType {
METHOD_UNKNOWN = 0,
METHOD_DIRECT, // <init>, private
METHOD_STATIC, // static
METHOD_VIRTUAL, // virtual, super
METHOD_INTERFACE // interface
-} MethodType;
+};
/*
* Resolve a class, given the referring class and a constant pool index
@@ -47,8 +43,9 @@
*
* Throws an exception and returns NULL on failure.
*/
-ClassObject* dvmResolveClass(const ClassObject* referrer, u4 classIdx,
- bool fromUnverifiedConstant);
+extern "C" ClassObject* dvmResolveClass(const ClassObject* referrer,
+ u4 classIdx,
+ bool fromUnverifiedConstant);
/*
* Resolve a direct, static, or virtual method.
@@ -58,8 +55,8 @@
*
* Throws an exception and returns NULL on failure.
*/
-Method* dvmResolveMethod(const ClassObject* referrer, u4 methodIdx,
- MethodType methodType);
+extern "C" Method* dvmResolveMethod(const ClassObject* referrer, u4 methodIdx,
+ MethodType methodType);
/*
* Resolve an interface method.
@@ -73,7 +70,8 @@
*
* Throws an exception and returns NULL on failure.
*/
-InstField* dvmResolveInstField(const ClassObject* referrer, u4 ifieldIdx);
+extern "C" InstField* dvmResolveInstField(const ClassObject* referrer,
+ u4 ifieldIdx);
/*
* Resolve a static field.
@@ -82,22 +80,19 @@
*
* Throws an exception and returns NULL on failure.
*/
-StaticField* dvmResolveStaticField(const ClassObject* referrer, u4 sfieldIdx);
+extern "C" StaticField* dvmResolveStaticField(const ClassObject* referrer,
+ u4 sfieldIdx);
/*
* Resolve a "const-string" reference.
*
* Throws an exception and returns NULL on failure.
*/
-StringObject* dvmResolveString(const ClassObject* referrer, u4 stringIdx);
+extern "C" StringObject* dvmResolveString(const ClassObject* referrer, u4 stringIdx);
/*
* Return debug string constant for enum.
*/
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 07bae47..6ffdfe8 100644
--- a/vm/oo/TypeCheck.h
+++ b/vm/oo/TypeCheck.h
@@ -19,18 +19,14 @@
#ifndef _DALVIK_OO_TYPECHECK
#define _DALVIK_OO_TYPECHECK
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* VM startup/shutdown */
bool dvmInstanceofStartup(void);
void dvmInstanceofShutdown(void);
/* used by dvmInstanceof; don't call */
-int dvmInstanceofNonTrivial(const ClassObject* instance,
- const ClassObject* clazz);
+extern "C" int dvmInstanceofNonTrivial(const ClassObject* instance,
+ const ClassObject* clazz);
/*
* Determine whether "instance" is an instance of "clazz".
@@ -76,11 +72,7 @@
*
* Returns 0 (false) if not, 1 (true) if so.
*/
-bool dvmCanPutArrayElement(const ClassObject* elemClass,
+extern "C" bool dvmCanPutArrayElement(const ClassObject* elemClass,
const ClassObject* arrayClass);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_OO_TYPECHECK*/
diff --git a/vm/reflect/Annotation.cpp b/vm/reflect/Annotation.cpp
index e0b91f4..6b33af3 100644
--- a/vm/reflect/Annotation.cpp
+++ b/vm/reflect/Annotation.cpp
@@ -283,11 +283,11 @@
* constants for processAnnotationValue indicating what style of
* result is wanted
*/
-typedef enum {
+enum AnnotationResultStyle {
kAllObjects, /* return everything as an object */
kAllRaw, /* return everything as a raw value or index */
kPrimitivesOrObjects /* return primitives as-is but the rest as objects */
-} AnnotationResultStyle;
+};
/*
* Recursively process an annotation value.
diff --git a/vm/reflect/Reflect.h b/vm/reflect/Reflect.h
index 21523eb..63260b5 100644
--- a/vm/reflect/Reflect.h
+++ b/vm/reflect/Reflect.h
@@ -19,10 +19,6 @@
#ifndef _DALVIK_REFLECT_REFLECT
#define _DALVIK_REFLECT_REFLECT
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
* During startup, validate the "box" classes, e.g. java/lang/Integer.
*/
@@ -216,23 +212,23 @@
* Used to pass values out of annotation (and encoded array) processing
* functions.
*/
-typedef struct AnnotationValue {
+struct AnnotationValue {
JValue value;
u1 type;
-} AnnotationValue;
+};
/**
* Iterator structure for iterating over DexEncodedArray instances. The
* structure should be treated as opaque.
*/
-typedef struct {
+struct EncodedArrayIterator {
const u1* cursor; /* current cursor */
u4 elementsLeft; /* number of elements left to read */
const DexEncodedArray* encodedArray; /* instance being iterated over */
u4 size; /* number of elements in instance */
const ClassObject* clazz; /* class to resolve with respect to */
-} EncodedArrayIterator;
+};
/**
* Initializes an encoded array iterator.
@@ -264,8 +260,4 @@
bool dvmEncodedArrayIteratorGetNext(EncodedArrayIterator* iterator,
AnnotationValue* value);
-#ifdef __cplusplus
-}
-#endif
-
#endif /*_DALVIK_REFLECT_REFLECT*/