Blob Blame History Raw
From 07d1911206aabc493fa32267446d699bc72deca8 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Fri, 20 Jul 2018 05:50:13 -0400
Subject: [PATCH 2/5] Use fallback for PPC64 and S390x.

There is no SSE2 on PPC64, and no other optimized version is implemented
yet.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.cpp | 12 ++++++++++++
 pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.h   |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.cpp b/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.cpp
index fac36b6..6da16c4 100644
--- a/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.cpp
+++ b/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.cpp
@@ -75,7 +75,9 @@
 #include "ARM/cpu-features.h"
 #endif
 #else // 'nix
+#if !(defined(__ppc64__) || defined(__PPC64__) || defined(__s390x__))
 #include <cpuid.h>
+#endif
 #include "inttypes.h"
 #endif
 int FastNoiseSIMD::s_currentSIMDLevel = -1;
@@ -111,6 +113,15 @@ uint64_t xgetbv(unsigned int x) {
 	return _xgetbv(x);
 }
 #else
+#if defined(__ppc64__) || defined(__PPC64__) || defined(__s390x__)
+void cpuid(int32_t out[4], int32_t x) {
+	/* Just disable it as anything better is unimplemented. */
+	out[0] = 0;
+}
+uint64_t xgetbv(unsigned int index) {
+	return 0;
+}
+#else
 void cpuid(int32_t out[4], int32_t x) {
 	__cpuid_count(x, 0, out[0], out[1], out[2], out[3]);
 }
@@ -119,6 +130,7 @@ uint64_t xgetbv(unsigned int index) {
 	__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
 	return ((uint64_t)edx << 32) | eax;
 }
+#endif
 #define _XCR_XFEATURE_ENABLED_MASK  0
 #endif
 
diff --git a/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.h b/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.h
index 9554384..6fff8bf 100644
--- a/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.h
+++ b/pyfastnoisesimd/fastnoisesimd/FastNoiseSIMD.h
@@ -45,7 +45,7 @@
 #define FN_ALIGNED_SETS
 
 // SSE2/NEON support is guaranteed on 64bit CPUs so no fallback is needed
-#if !(defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__) || defined(FN_IOS)) || defined(_DEBUG)
+#if !(defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__) || defined(FN_IOS)) || defined(_DEBUG)
 #define FN_COMPILE_NO_SIMD_FALLBACK
 #endif
 
-- 
2.29.2