summaryrefslogtreecommitdiffstats
path: root/test-altivec.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:36:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:36:24 +0000
commit2d190fe39a843d10b121d8dcff234dd590e7fc0c (patch)
tree4489bd5d968f9696b1c807fec58839785f719962 /test-altivec.c
parentInitial commit. (diff)
downloadisa-support-2d190fe39a843d10b121d8dcff234dd590e7fc0c.tar.xz
isa-support-2d190fe39a843d10b121d8dcff234dd590e7fc0c.zip
Adding upstream version 15.1.upstream/15.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--test-altivec.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/test-altivec.c b/test-altivec.c
new file mode 100644
index 0000000..4c441f8
--- /dev/null
+++ b/test-altivec.c
@@ -0,0 +1,63 @@
+#include <stdbool.h>
+#include <sys/resource.h>
+#include <signal.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+
+#include <sys/auxv.h>
+
+#ifdef AT_PLATFORM
+/* detect ARM ABI version will be optimized away if not used */
+static inline bool need_armv_version(int atleastversion)
+{
+ int version;
+ const char * platform = (const char *)getauxval(AT_PLATFORM);
+ if (platform == NULL)
+ return false;
+ /* at least v5 */
+ if (strlen(platform) < strlen("v5"))
+ return false;
+ if (*(platform++) != 'v')
+ return false;
+
+ char *endstr;
+ errno = 0;
+ version = strtol(platform,&endstr,10);
+ if (errno != 0)
+ return false;
+ if (endstr == platform)
+ return false;
+
+ return (version >= atleastversion);
+
+}
+#endif
+
+const struct rlimit nocore = { 0, 0 };
+
+/* emulate kill by signal */
+void
+termination_handler (int signum)
+{
+ _exit(128+signum);
+}
+
+int main()
+{
+ /* no core */
+ (void) setrlimit(RLIMIT_CORE, &nocore);
+ /* return instead */
+ struct sigaction new_action;
+ new_action.sa_handler = termination_handler;
+ (void) sigemptyset (&new_action.sa_mask);
+ new_action.sa_flags = 0;
+ (void) sigaction (SIGILL, &new_action, NULL);
+ (void) sigaction (SIGBUS, &new_action, NULL);
+ (void) sigaction (SIGSEGV, &new_action, NULL);
+ /* now test */
+ asm volatile("vsldoi %v1,%v1,%v1,0");;
+ return 0;
+}