summaryrefslogtreecommitdiff
path: root/TestPrograms/test_ppc_power8.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2021-04-20 04:44:21 -0400
committerJeffrey Walton <noloader@gmail.com>2021-04-20 04:44:21 -0400
commitc15aeaa7b5cdf4409d034a50efb3c0d2959a3f6a (patch)
tree0aabdf1ae1eccc30a641901e3c87144c6a6a6338 /TestPrograms/test_ppc_power8.cpp
parent21799b1fba6d9d3148cb56003a21f42f6fd086ed (diff)
downloadcryptopp-git-c15aeaa7b5cdf4409d034a50efb3c0d2959a3f6a.tar.gz
Use *.cpp file extension for test programs (GH #1024)
Diffstat (limited to 'TestPrograms/test_ppc_power8.cpp')
-rw-r--r--TestPrograms/test_ppc_power8.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/TestPrograms/test_ppc_power8.cpp b/TestPrograms/test_ppc_power8.cpp
new file mode 100644
index 00000000..c4cae74b
--- /dev/null
+++ b/TestPrograms/test_ppc_power8.cpp
@@ -0,0 +1,46 @@
+#if defined(__GNUC__)
+# define GNUC_VERSION (__GNUC__*1000 + __GNUC_MINOR__*10)
+#endif
+
+#if defined(__clang__) && defined(__apple_build_version__)
+# undef GNUC_VERSION
+# define APPLE_VERSION (__clang_major__*1000 + __clang_minor__*10)
+#elif defined(__clang__)
+# undef GNUC_VERSION
+# define LLVM_VERSION (__clang_major__*1000 + __clang_minor__*10)
+#endif
+
+#if (GNUC_VERSION >= 4060) || (LLVM_VERSION >= 1070) || (APPLE_VERSION >= 2000)
+# pragma GCC diagnostic ignored "-Wdeprecated"
+#endif
+
+// XL C++ on AIX does not define CRYPTO and does not
+// provide an option to set it. We have to set it
+// for the code below. This define must stay in
+// sync with the define in test_ppc_power8.cpp
+#if defined(_AIX) && defined(_ARCH_PWR8) && defined(__xlC__)
+# define __CRYPTO__ 1
+#endif
+
+#include <altivec.h>
+int main(int argc, char* argv[])
+{
+#if defined(_ARCH_PWR8)
+ __vector unsigned long long r = {1, 2};
+ __vector unsigned int s = vec_xl(0, (unsigned int*)argv[0]); // Power7
+ __vector unsigned long long w = (__vector unsigned long long)r;
+ __vector unsigned long long x = (__vector unsigned long long)s;
+ __vector unsigned long long y = vec_xor(w, x);
+ __vector unsigned long long z = vec_add(y, vec_add(w, x));
+# if defined(__ibmxl__) || (defined(_AIX) && defined(__xlC__))
+ __vector unsigned long long u = __vpmsumd (y, z);
+# elif defined(__clang__)
+ __vector unsigned long long u = __builtin_altivec_crypto_vpmsumd (y, z);
+# else
+ __vector unsigned long long u = __builtin_crypto_vpmsumd (y, z);
+# endif
+#else
+ int x[-1];
+#endif
+ return 0;
+}