Merge "Fold "host-dir-parent" into "parent-dir""
diff --git a/build/tools/toolchain-patches/gcc/0013-Modify-LINK_SPEC-to-pass-fix-cortex-a53-843419-as-de.patch b/build/tools/toolchain-patches/gcc/0013-Modify-LINK_SPEC-to-pass-fix-cortex-a53-843419-as-de.patch
new file mode 100644
index 0000000..e55400f
--- /dev/null
+++ b/build/tools/toolchain-patches/gcc/0013-Modify-LINK_SPEC-to-pass-fix-cortex-a53-843419-as-de.patch
@@ -0,0 +1,88 @@
+From 0e1b74b6ffbeadab5351d6a426e530886e00aa69 Mon Sep 17 00:00:00 2001
+From: Lai Wei-Chih <Robert.Lai@mediatek.com>
+Date: Mon, 6 Apr 2015 13:59:54 +0800
+Subject: [PATCH] Modify LINK_SPEC to pass --fix-cortex-a53-843419 as default.
+
+For NDK toolchains, always enable the fix of cortex-a53 erratum 843419.
+Use -mno-fix-cortex-a53-843419 to disable this workaround.
+
+Change-Id: I69b8a71113abb172138bf0986697a94e42a5117e
+---
+ gcc-4.9/gcc/config/aarch64/aarch64-elf-raw.h | 6 +++++-
+ gcc-4.9/gcc/config/aarch64/aarch64-linux.h | 7 ++++++-
+ gcc-4.9/gcc/config/aarch64/aarch64.c | 5 +++++
+ gcc-4.9/gcc/config/aarch64/aarch64.opt | 4 ++++
+ 4 files changed, 20 insertions(+), 2 deletions(-)
+
+diff --git a/gcc-4.9/gcc/config/aarch64/aarch64-elf-raw.h b/gcc-4.9/gcc/config/aarch64/aarch64-elf-raw.h
+index eafdd55..99611c5 100644
+--- a/gcc-4.9/gcc/config/aarch64/aarch64-elf-raw.h
++++ b/gcc-4.9/gcc/config/aarch64/aarch64-elf-raw.h
+@@ -33,10 +33,14 @@
+ " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}"
+ #endif
+
++#define CA53_ERR_843419_SPEC \
++ " %{!mno-fix-cortex-a53-843419:--fix-cortex-a53-843419}"
++
+ #ifndef LINK_SPEC
+ #define LINK_SPEC "%{mbig-endian:-EB} %{mlittle-endian:-EL} -X \
+ -maarch64elf%{mabi=ilp32*:32}%{mbig-endian:b}" \
+- CA53_ERR_835769_SPEC
++ CA53_ERR_835769_SPEC \
++ CA53_ERR_843419_SPEC
+ #endif
+
+ #endif /* GCC_AARCH64_ELF_RAW_H */
+diff --git a/gcc-4.9/gcc/config/aarch64/aarch64-linux.h b/gcc-4.9/gcc/config/aarch64/aarch64-linux.h
+index b77becd..7b77c42 100644
+--- a/gcc-4.9/gcc/config/aarch64/aarch64-linux.h
++++ b/gcc-4.9/gcc/config/aarch64/aarch64-linux.h
+@@ -48,7 +48,12 @@
+ " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}"
+ #endif
+
+-#define LINUX_TARGET_LINK_SPEC LINUX_TARGET_LINK_SPEC0 CA53_ERR_835769_SPEC
++#define CA53_ERR_843419_SPEC \
++ " %{!mno-fix-cortex-a53-843419:--fix-cortex-a53-843419}"
++
++#define LINUX_TARGET_LINK_SPEC LINUX_TARGET_LINK_SPEC0 \
++ CA53_ERR_835769_SPEC \
++ CA53_ERR_843419_SPEC
+
+ #define LINK_SPEC LINUX_TARGET_LINK_SPEC
+
+diff --git a/gcc-4.9/gcc/config/aarch64/aarch64.c b/gcc-4.9/gcc/config/aarch64/aarch64.c
+index 2ff6c7c..0efb7e4 100644
+--- a/gcc-4.9/gcc/config/aarch64/aarch64.c
++++ b/gcc-4.9/gcc/config/aarch64/aarch64.c
+@@ -5265,6 +5265,11 @@ aarch64_override_options (void)
+ #endif
+ }
+
++ if (aarch64_fix_a53_err843419 == 2)
++ {
++ aarch64_fix_a53_err843419 = 1;
++ }
++
+ aarch64_override_options_after_change ();
+
+ if (TARGET_ANDROID)
+diff --git a/gcc-4.9/gcc/config/aarch64/aarch64.opt b/gcc-4.9/gcc/config/aarch64/aarch64.opt
+index fc0307e..ca27f50 100644
+--- a/gcc-4.9/gcc/config/aarch64/aarch64.opt
++++ b/gcc-4.9/gcc/config/aarch64/aarch64.opt
+@@ -71,6 +71,10 @@ mfix-cortex-a53-835769
+ Target Report Var(aarch64_fix_a53_err835769) Init(2)
+ Workaround for ARM Cortex-A53 Erratum number 835769
+
++mfix-cortex-a53-843419
++Target Report Var(aarch64_fix_a53_err843419) Init(2)
++Workaround for ARM Cortex-A53 Erratum number 843419
++
+ mlittle-endian
+ Target Report RejectNegative InverseMask(BIG_END)
+ Assume target CPU is configured as little endian
+--
+1.9.1
+
diff --git a/sources/android/cpufeatures/cpu-features.c b/sources/android/cpufeatures/cpu-features.c
index d75eebc..75bb9fc 100644
--- a/sources/android/cpufeatures/cpu-features.c
+++ b/sources/android/cpufeatures/cpu-features.c
@@ -28,7 +28,9 @@
/* ChangeLog for this library:
*
- * NDK r9?: Support for 64-bit CPUs (Intel, ARM & MIPS).
+ * NDK r10e?: Add MIPS MSA feature.
+ *
+ * NDK r10: Support for 64-bit CPUs (Intel, ARM & MIPS).
*
* NDK r8d: Add android_setCpu().
*
@@ -471,7 +473,13 @@
HWCAP_IDIVT )
#endif
-#if defined(__arm__) || defined(__aarch64__)
+#if defined(__mips__)
+// see <uapi/asm/hwcap.h> kernel header
+#define HWCAP_MIPS_R6 (1 << 0)
+#define HWCAP_MIPS_MSA (1 << 1)
+#endif
+
+#if defined(__arm__) || defined(__aarch64__) || defined(__mips__)
#define AT_HWCAP 16
#define AT_HWCAP2 26
@@ -993,6 +1001,21 @@
g_cpuFeatures |= ANDROID_CPU_X86_FEATURE_MOVBE;
}
#endif
+#if defined( __mips__)
+ { /* MIPS and MIPS64 */
+ /* Extract the list of CPU features from ELF hwcaps */
+ uint32_t hwcaps = 0;
+ hwcaps = get_elf_hwcap_from_getauxval(AT_HWCAP);
+ if (hwcaps != 0) {
+ int has_r6 = (hwcaps & HWCAP_MIPS_R6);
+ int has_msa = (hwcaps & HWCAP_MIPS_MSA);
+ if (has_r6)
+ g_cpuFeatures |= ANDROID_CPU_MIPS_FEATURE_R6;
+ if (has_msa)
+ g_cpuFeatures |= ANDROID_CPU_MIPS_FEATURE_MSA;
+ }
+ }
+#endif /* __mips__ */
free(cpuinfo);
}
diff --git a/sources/android/cpufeatures/cpu-features.h b/sources/android/cpufeatures/cpu-features.h
index e86cba8..d93f11a 100644
--- a/sources/android/cpufeatures/cpu-features.h
+++ b/sources/android/cpufeatures/cpu-features.h
@@ -65,10 +65,7 @@
* NOTE: This will return 0 for the following architectures that don't have
* optional features listed at the moment:
*
- * ANDROID_CPU_FAMILY_MIPS
- * ANDROID_CPU_FAMILY_ARM64
* ANDROID_CPU_FAMILY_X86_64
- * ANDROID_CPU_FAMILY_MIPS64
*/
extern uint64_t android_getCpuFeatures(void);
@@ -260,6 +257,7 @@
ANDROID_CPU_ARM64_FEATURE_SHA2 = (1 << 5),
ANDROID_CPU_ARM64_FEATURE_CRC32 = (1 << 6),
};
+
/* The bit flags corresponding to the output of android_getCpuFeatures()
* when android_getCpuFamily() returns ANDROID_CPU_FAMILY_X86.
*/
@@ -269,6 +267,23 @@
ANDROID_CPU_X86_FEATURE_MOVBE = (1 << 2),
};
+/* The bit flags corresponding to the output of android_getCpuFeatures()
+ * when android_getCpuFamily() returns ANDROID_CPU_FAMILY_MIPS
+ * or ANDROID_CPU_FAMILY_MIPS64. Values are:
+ *
+ * R6:
+ * CPU executes MIPS Release 6 instructions natively, and
+ * supports obsoleted R1..R5 instructions only via kernel traps.
+ *
+ * MSA:
+ * CPU supports Mips SIMD Architecture instructions.
+ */
+enum {
+ ANDROID_CPU_MIPS_FEATURE_R6 = (1 << 0),
+ ANDROID_CPU_MIPS_FEATURE_MSA = (1 << 1),
+};
+
+
/* Return the number of CPU cores detected on this device. */
extern int android_getCpuCount(void);