Merge remote branch 'goog/dalvik-dev' into dalvik-dev-to-master

Change-Id: I99c4289bd34f63b0b970b6ed0fa992b44e805393
diff --git a/libdex/sha1.h b/libdex/sha1.h
index 0d8f691..f18a8c0 100644
--- a/libdex/sha1.h
+++ b/libdex/sha1.h
@@ -1,5 +1,5 @@
 /*
- * See "sha1.c" for author info.
+ * See "sha1.cpp" for author info.
  */
 #ifndef _DALVIK_SHA1
 #define _DALVIK_SHA1
diff --git a/vm/Dvm.mk b/vm/Dvm.mk
index dfb554b..feb53a8 100644
--- a/vm/Dvm.mk
+++ b/vm/Dvm.mk
@@ -25,7 +25,7 @@
 # Compiler defines.
 #
 LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
-LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wc++-compat
+LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter
 LOCAL_CFLAGS += -DARCH_VARIANT=\"$(dvm_arch_variant)\"
 
 #
diff --git a/vm/Misc.h b/vm/Misc.h
index 6bce241..7ce9708 100644
--- a/vm/Misc.h
+++ b/vm/Misc.h
@@ -261,7 +261,7 @@
 
 #if (!HAVE_STRLCPY)
 /* Implementation of strlcpy() for platforms that don't already have it. */
-size_t strlcpy(char *dst, const char *src, size_t size);
+extern "C" size_t strlcpy(char *dst, const char *src, size_t size);
 #endif
 
 /*
diff --git a/vm/compiler/codegen/arm/README.txt b/vm/compiler/codegen/arm/README.txt
index a49eef8..1bb4603 100644
--- a/vm/compiler/codegen/arm/README.txt
+++ b/vm/compiler/codegen/arm/README.txt
@@ -8,26 +8,26 @@
 --
 
 /* Architectural independent building blocks */
-#include "../CodegenCommon.c"
+#include "../CodegenCommon.cpp"
 
 /* Thumb2-specific factory utilities */
-#include "../Thumb2/Factory.c"
+#include "../Thumb2/Factory.cpp"
 /* Factory utilities dependent on arch-specific features */
-#include "../CodegenFactory.c"
+#include "../CodegenFactory.cpp"
 
 /* Thumb2-specific codegen routines */
-#include "../Thumb2/Gen.c"
+#include "../Thumb2/Gen.cpp"
 /* Thumb2+VFP codegen routines */
-#include "../FP/Thumb2VFP.c"
+#include "../FP/Thumb2VFP.cpp"
 
 /* Thumb2-specific register allocation */
-#include "../Thumb2/Ralloc.c"
+#include "../Thumb2/Ralloc.cpp"
 
 /* MIR2LIR dispatcher and architectural independent codegen routines */
-#include "../CodegenDriver.c"
+#include "../CodegenDriver.cpp"
 
 /* Architecture manifest */
-#include "ArchVariant.c"
+#include "ArchVariant.cpp"
 
 --
 
diff --git a/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.cpp b/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.cpp
index 3d85052..8ab956e 100644
--- a/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.cpp
+++ b/vm/compiler/codegen/arm/armv5te-vfp/ArchVariant.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+extern "C" void dvmCompilerTemplateStart(void);
+
 /*
  * This file is included by Codegen-armv5te-vfp.c, and implements architecture
  * variant-specific code.
@@ -28,16 +30,15 @@
     return DALVIK_JIT_THUMB;
 }
 
-/* Architecture-specific initializations and checks go here */
-bool dvmCompilerArchVariantInit(void)
-{
-    /* First, declare dvmCompiler_TEMPLATE_XXX for each template */
-#define JIT_TEMPLATE(X) extern void dvmCompiler_TEMPLATE_##X();
+/* First, declare dvmCompiler_TEMPLATE_XXX for each template */
+#define JIT_TEMPLATE(X) extern "C" void dvmCompiler_TEMPLATE_##X();
 #include "../../../template/armv5te-vfp/TemplateOpList.h"
 #undef JIT_TEMPLATE
 
+/* Architecture-specific initializations and checks go here */
+bool dvmCompilerArchVariantInit(void)
+{
     int i = 0;
-    extern void dvmCompilerTemplateStart(void);
 
     /*
      * Then, populate the templateEntryOffsets array with the offsets from the
diff --git a/vm/compiler/codegen/arm/armv5te-vfp/Codegen.cpp b/vm/compiler/codegen/arm/armv5te-vfp/Codegen.cpp
index a2d77ea..55321bb 100644
--- a/vm/compiler/codegen/arm/armv5te-vfp/Codegen.cpp
+++ b/vm/compiler/codegen/arm/armv5te-vfp/Codegen.cpp
@@ -29,28 +29,28 @@
 #include "ArchVariant.h"
 
 /* Arm codegen building blocks */
-#include "../CodegenCommon.c"
+#include "../CodegenCommon.cpp"
 
 /* Thumb-specific factory utilities */
-#include "../Thumb/Factory.c"
+#include "../Thumb/Factory.cpp"
 /* Target independent factory utilities */
-#include "../../CodegenFactory.c"
+#include "../../CodegenFactory.cpp"
 /* Arm-specific factory utilities */
-#include "../ArchFactory.c"
+#include "../ArchFactory.cpp"
 
 /* Thumb-specific codegen routines */
-#include "../Thumb/Gen.c"
+#include "../Thumb/Gen.cpp"
 /* Thumb+VFP codegen routines */
-#include "../FP/ThumbVFP.c"
+#include "../FP/ThumbVFP.cpp"
 
 /* Thumb-specific register allocation */
-#include "../Thumb/Ralloc.c"
+#include "../Thumb/Ralloc.cpp"
 
 /* MIR2LIR dispatcher and architectural independent codegen routines */
-#include "../CodegenDriver.c"
+#include "../CodegenDriver.cpp"
 
 /* Dummy driver for method-based JIT */
-#include "../armv5te/MethodCodegenDriver.c"
+#include "../armv5te/MethodCodegenDriver.cpp"
 
 /* Architecture manifest */
-#include "ArchVariant.c"
+#include "ArchVariant.cpp"
diff --git a/vm/compiler/codegen/arm/armv5te/ArchVariant.cpp b/vm/compiler/codegen/arm/armv5te/ArchVariant.cpp
index 5b2e1bf..3e13af5 100644
--- a/vm/compiler/codegen/arm/armv5te/ArchVariant.cpp
+++ b/vm/compiler/codegen/arm/armv5te/ArchVariant.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+extern "C" void dvmCompilerTemplateStart(void);
+
 /*
  * This file is included by Codegen-armv5te.c, and implements architecture
  * variant-specific code.
@@ -28,16 +30,15 @@
     return DALVIK_JIT_THUMB;
 }
 
-/* Architecture-specific initializations and checks go here */
-bool dvmCompilerArchVariantInit(void)
-{
-    /* First, declare dvmCompiler_TEMPLATE_XXX for each template */
-#define JIT_TEMPLATE(X) extern void dvmCompiler_TEMPLATE_##X();
+/* First, declare dvmCompiler_TEMPLATE_XXX for each template */
+#define JIT_TEMPLATE(X) extern "C" void dvmCompiler_TEMPLATE_##X();
 #include "../../../template/armv5te/TemplateOpList.h"
 #undef JIT_TEMPLATE
 
+/* Architecture-specific initializations and checks go here */
+bool dvmCompilerArchVariantInit(void)
+{
     int i = 0;
-    extern void dvmCompilerTemplateStart(void);
 
     /*
      * Then, populate the templateEntryOffsets array with the offsets from the
diff --git a/vm/compiler/codegen/arm/armv5te/Codegen.cpp b/vm/compiler/codegen/arm/armv5te/Codegen.cpp
index f74d968..a379c2a 100644
--- a/vm/compiler/codegen/arm/armv5te/Codegen.cpp
+++ b/vm/compiler/codegen/arm/armv5te/Codegen.cpp
@@ -29,28 +29,28 @@
 #include "ArchVariant.h"
 
 /* Arm codegen building blocks */
-#include "../CodegenCommon.c"
+#include "../CodegenCommon.cpp"
 
 /* Thumb-specific building blocks */
-#include "../Thumb/Factory.c"
+#include "../Thumb/Factory.cpp"
 /* Target independent factory utilities */
-#include "../../CodegenFactory.c"
+#include "../../CodegenFactory.cpp"
 /* Arm-specific factory utilities */
-#include "../ArchFactory.c"
+#include "../ArchFactory.cpp"
 
 /* Thumb-specific codegen routines */
-#include "../Thumb/Gen.c"
+#include "../Thumb/Gen.cpp"
 /* Thumb+Portable FP codegen routines */
-#include "../FP/ThumbPortableFP.c"
+#include "../FP/ThumbPortableFP.cpp"
 
 /* Thumb-specific register allocation */
-#include "../Thumb/Ralloc.c"
+#include "../Thumb/Ralloc.cpp"
 
 /* MIR2LIR dispatcher and architectural independent codegen routines */
-#include "../CodegenDriver.c"
+#include "../CodegenDriver.cpp"
 
 /* Dummy driver for method-based JIT */
-#include "MethodCodegenDriver.c"
+#include "MethodCodegenDriver.cpp"
 
 /* Architecture manifest */
-#include "ArchVariant.c"
+#include "ArchVariant.cpp"
diff --git a/vm/compiler/codegen/arm/armv7-a-neon/ArchVariant.cpp b/vm/compiler/codegen/arm/armv7-a-neon/ArchVariant.cpp
index 6234747..d68d150 100644
--- a/vm/compiler/codegen/arm/armv7-a-neon/ArchVariant.cpp
+++ b/vm/compiler/codegen/arm/armv7-a-neon/ArchVariant.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+extern "C" void dvmCompilerTemplateStart(void);
+
 /*
  * Determine the initial instruction set to be used for this trace.
  * Later components may decide to change this.
@@ -23,16 +25,15 @@
     return DALVIK_JIT_THUMB2;
 }
 
-/* Architecture-specific initializations and checks go here */
-bool dvmCompilerArchVariantInit(void)
-{
-    /* First, declare dvmCompiler_TEMPLATE_XXX for each template */
-#define JIT_TEMPLATE(X) extern void dvmCompiler_TEMPLATE_##X();
+/* First, declare dvmCompiler_TEMPLATE_XXX for each template */
+#define JIT_TEMPLATE(X) extern "C" void dvmCompiler_TEMPLATE_##X();
 #include "../../../template/armv5te-vfp/TemplateOpList.h"
 #undef JIT_TEMPLATE
 
+/* Architecture-specific initializations and checks go here */
+bool dvmCompilerArchVariantInit(void)
+{
     int i = 0;
-    extern void dvmCompilerTemplateStart(void);
 
     /*
      * Then, populate the templateEntryOffsets array with the offsets from the
diff --git a/vm/compiler/codegen/arm/armv7-a-neon/Codegen.cpp b/vm/compiler/codegen/arm/armv7-a-neon/Codegen.cpp
index 439add5..8f15174 100644
--- a/vm/compiler/codegen/arm/armv7-a-neon/Codegen.cpp
+++ b/vm/compiler/codegen/arm/armv7-a-neon/Codegen.cpp
@@ -29,28 +29,28 @@
 #include "ArchVariant.h"
 
 /* Arm codegen building blocks */
-#include "../CodegenCommon.c"
+#include "../CodegenCommon.cpp"
 
 /* Thumb2-specific factory utilities */
-#include "../Thumb2/Factory.c"
+#include "../Thumb2/Factory.cpp"
 /* Target indepedent factory utilities */
-#include "../../CodegenFactory.c"
+#include "../../CodegenFactory.cpp"
 /* Arm-specific factory utilities */
-#include "../ArchFactory.c"
+#include "../ArchFactory.cpp"
 
 /* Thumb2-specific codegen routines */
-#include "../Thumb2/Gen.c"
+#include "../Thumb2/Gen.cpp"
 /* Thumb2+VFP codegen routines */
-#include "../FP/Thumb2VFP.c"
+#include "../FP/Thumb2VFP.cpp"
 
 /* Thumb2-specific register allocation */
-#include "../Thumb2/Ralloc.c"
+#include "../Thumb2/Ralloc.cpp"
 
 /* MIR2LIR dispatcher and architectural independent codegen routines */
-#include "../CodegenDriver.c"
+#include "../CodegenDriver.cpp"
 
 /* Driver for method-based JIT */
-#include "MethodCodegenDriver.c"
+#include "MethodCodegenDriver.cpp"
 
 /* Architecture manifest */
-#include "ArchVariant.c"
+#include "ArchVariant.cpp"
diff --git a/vm/compiler/codegen/x86/ia32/ArchVariant.cpp b/vm/compiler/codegen/x86/ia32/ArchVariant.cpp
index 6992c16..5ccd26d 100644
--- a/vm/compiler/codegen/x86/ia32/ArchVariant.cpp
+++ b/vm/compiler/codegen/x86/ia32/ArchVariant.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+extern "C" void dvmCompilerTemplateStart(void);
+
 /*
  * This file is included by Codegen-x86.c, and implements architecture
  * variant-specific code.
@@ -37,7 +39,6 @@
 bool dvmCompilerArchVariantInit(void)
 {
     int i = 0;
-    extern void dvmCompilerTemplateStart(void);
 
     /*
      * Then, populate the templateEntryOffsets array with the offsets from the
diff --git a/vm/compiler/codegen/x86/ia32/Codegen.cpp b/vm/compiler/codegen/x86/ia32/Codegen.cpp
index 4c2a759..ae55cd1 100644
--- a/vm/compiler/codegen/x86/ia32/Codegen.cpp
+++ b/vm/compiler/codegen/x86/ia32/Codegen.cpp
@@ -28,18 +28,18 @@
 #include "ArchVariant.h"
 
 /* Architectural independent building blocks */
-//#include "../CodegenCommon.c"
+//#include "../CodegenCommon.cpp"
 
 /* Architectural independent building blocks */
-//#include "../Thumb/Factory.c"
+//#include "../Thumb/Factory.cpp"
 /* Factory utilities dependent on arch-specific features */
-//#include "../CodegenFactory.c"
+//#include "../CodegenFactory.cpp"
 
 /* ia32 register allocation */
-//#include "../ia32/Ralloc.c"
+//#include "../ia32/Ralloc.cpp"
 
 /* MIR2LIR dispatcher and architectural independent codegen routines */
-#include "../CodegenDriver.c"
+#include "../CodegenDriver.cpp"
 
 /* Architecture manifest */
-#include "ArchVariant.c"
+#include "ArchVariant.cpp"
diff --git a/vm/mterp/README.txt b/vm/mterp/README.txt
index e83e234..6106740 100644
--- a/vm/mterp/README.txt
+++ b/vm/mterp/README.txt
@@ -83,7 +83,7 @@
   import <filename>
 
     The specified file is included immediately, in its entirety.  No
-    substitutions are performed.  ".c" and ".h" files are copied to the
+    substitutions are performed.  ".cpp" and ".h" files are copied to the
     C output, ".S" files are copied to the asm output.
 
   asm-stub <filename>
diff --git a/vm/mterp/cstubs/stubdefs.cpp b/vm/mterp/cstubs/stubdefs.cpp
index ba2fe81..2e7f1b7 100644
--- a/vm/mterp/cstubs/stubdefs.cpp
+++ b/vm/mterp/cstubs/stubdefs.cpp
@@ -20,7 +20,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/out/InterpC-allstubs.cpp b/vm/mterp/out/InterpC-allstubs.cpp
index 91b20d0..8c2d622 100644
--- a/vm/mterp/out/InterpC-allstubs.cpp
+++ b/vm/mterp/out/InterpC-allstubs.cpp
@@ -390,7 +390,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/out/InterpC-armv5te-vfp.cpp b/vm/mterp/out/InterpC-armv5te-vfp.cpp
index cd1eda1..246b16c 100644
--- a/vm/mterp/out/InterpC-armv5te-vfp.cpp
+++ b/vm/mterp/out/InterpC-armv5te-vfp.cpp
@@ -390,7 +390,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/out/InterpC-armv5te.cpp b/vm/mterp/out/InterpC-armv5te.cpp
index 9f7d1e9..38ad1b3 100644
--- a/vm/mterp/out/InterpC-armv5te.cpp
+++ b/vm/mterp/out/InterpC-armv5te.cpp
@@ -390,7 +390,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/out/InterpC-armv7-a-neon.cpp b/vm/mterp/out/InterpC-armv7-a-neon.cpp
index e1e2d8e..097bcc8 100644
--- a/vm/mterp/out/InterpC-armv7-a-neon.cpp
+++ b/vm/mterp/out/InterpC-armv7-a-neon.cpp
@@ -390,7 +390,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/out/InterpC-armv7-a.cpp b/vm/mterp/out/InterpC-armv7-a.cpp
index f3a800d..dfbc45d 100644
--- a/vm/mterp/out/InterpC-armv7-a.cpp
+++ b/vm/mterp/out/InterpC-armv7-a.cpp
@@ -390,7 +390,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/out/InterpC-x86-atom.cpp b/vm/mterp/out/InterpC-x86-atom.cpp
index 0a53b14..81e84b9 100644
--- a/vm/mterp/out/InterpC-x86-atom.cpp
+++ b/vm/mterp/out/InterpC-x86-atom.cpp
@@ -390,7 +390,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/out/InterpC-x86.cpp b/vm/mterp/out/InterpC-x86.cpp
index 5f31de6..4cf6603 100644
--- a/vm/mterp/out/InterpC-x86.cpp
+++ b/vm/mterp/out/InterpC-x86.cpp
@@ -390,7 +390,7 @@
 
 /*
  * Redefine what used to be local variable accesses into Thread struct
- * references.  (These are undefined down in "footer.c".)
+ * references.  (These are undefined down in "footer.cpp".)
  */
 #define retval                  self->retval
 #define pc                      self->interpSave.pc
diff --git a/vm/mterp/x86-atom/TODO.txt b/vm/mterp/x86-atom/TODO.txt
index a16f857..228d3e2 100644
--- a/vm/mterp/x86-atom/TODO.txt
+++ b/vm/mterp/x86-atom/TODO.txt
@@ -13,7 +13,7 @@
      elminiates a separate debug interpreter.  Needs a dedicated
      rIBASE register (or alternate switching model with variable
      handler base).
-(hi) Add dvmReportXXXX()" calls in footer.c to support profilers &
+(hi) Add dvmReportXXXX()" calls in footer.cpp to support profilers &
      debuggers.
 (hi) Set self->debugIsMethodEntry in invoke code.