Allow host "detection" on non-linux hosts.

Signed-off-by: Richard Henderson <r...@twiddle.net>
---
 util/getauxval.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 54 insertions(+), 2 deletions(-)

diff --git a/util/getauxval.c b/util/getauxval.c
index 59f53ff..e7f7d63 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -60,12 +60,64 @@ void qemu_init_auxval(char **envp)
 
 static const char *default_platform(void)
 {
-    return NULL;
+    const char *ret = NULL;
+
+#ifdef _ARCH_PPC
+# if defined(_ARCH_PWR8)
+    ret = "power8";
+# elif defined(_ARCH_PWR7)
+    ret = "power7";
+# elif defined(_ARCH_PWR6X) || defined(_ARCH_PWR6)
+    ret = "power6";
+# elif defined(_ARCH_PWR5X)
+    ret = "power5+";
+# elif defined(_ARCH_PWR5)
+    ret = "power5";
+# elif defined(_ARCH_PWR4)
+    ret = "power4";
+# else
+    ret = "power3";
+# endif
+#endif /* _ARCH_PPC */
+
+    return ret;
 }
 
 static unsigned long default_hwcap(void)
 {
-    return 0;
+    unsigned long ret = 0;
+
+#ifdef _ARCH_PPC
+# if defined(_ARCH_PWR8) || defined(_ARCH_PWR7)
+    ret |= PPC_FEATURE_ARCH_2_06;
+# elif defined(_ARCH_PWR6X) || defined(_ARCH_PWR6)
+    ret |= PPC_FEATURE_ARCH_2_05;
+# elif defined(_ARCH_PWR5X)
+    ret |= PPC_FEATURE_POWER5_PLUS;
+# elif defined(_ARCH_PWR5)
+    ret |= PPC_FEATURE_POWER5;
+# elif defined(_ARCH_PWR4)
+    ret |= PPC_FEATURE_POWER4;
+# endif
+# if defined(_ARCH_PWR6) /* and later */
+    ret |= PPC_FEATURE_TRUE_LE | PPC_FEATURE_PSERIES_PERFMON_COMPAT;
+# endif
+# if defined(_ARCH_PWR5) /* and later */
+    ret |= PPC_FEATURE_SMT | PPC_FEATURE_ICACHE_SNOOP;
+# endif
+# if defined(_ARCH_PPC64)
+    ret |= PPC_FEATURE_64;
+# endif
+# if defined(__VSX__)
+    ret |= PPC_FEATURE_HAS_VSX;
+# endif
+# if defined(__ALTIVEC__)
+    ret |= PPC_FEATURE_HAS_ALTIVEC;
+# endif
+    ret |= PPC_FEATURE_32 | PPC_FEATURE_HAS_FPU | PPC_FEATURE_HAS_MMU;
+#endif /* _ARCH_PPC */
+
+    return ret;
 }
 
 unsigned long qemu_getauxval(unsigned long type)
-- 
1.8.1.4


Reply via email to