aboutsummaryrefslogtreecommitdiff
path: root/testcases/kernel/syscalls/switch/endian_switch01.c
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/kernel/syscalls/switch/endian_switch01.c')
-rw-r--r--testcases/kernel/syscalls/switch/endian_switch01.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/testcases/kernel/syscalls/switch/endian_switch01.c b/testcases/kernel/syscalls/switch/endian_switch01.c
index bee35184a..fac9e2382 100644
--- a/testcases/kernel/syscalls/switch/endian_switch01.c
+++ b/testcases/kernel/syscalls/switch/endian_switch01.c
@@ -2,7 +2,7 @@
/*
* Copyright (c) International Business Machines Corp., 2008
* Copyright (c) Paul Mackerras, IBM Corp., 2008
- * Copyright (c) 2018 Linux Test Project
+ * Copyright (c) 2018-2023 Linux Test Project
*/
/*
@@ -17,14 +17,17 @@
#include <elf.h>
#include <sys/types.h>
#include <sys/wait.h>
+
#include "tst_test.h"
#if defined(__powerpc64__) || defined(__powerpc__)
+
# ifndef PPC_FEATURE_TRUE_LE
-# define PPC_FEATURE_TRUE_LE 0x00000002
+# define PPC_FEATURE_TRUE_LE 0x00000002
# endif
-# define TST_NO_DEFAULT_MAIN
+# ifdef HAVE_GETAUXVAL
+# include <sys/auxv.h>
/*
* Make minimal call to 0x1ebe. If we get ENOSYS then syscall is not
@@ -42,6 +45,9 @@ void check_le_switch_supported(void)
exit(errno);
}
+ if (!(getauxval(AT_HWCAP) & PPC_FEATURE_TRUE_LE))
+ tst_brk(TCONF, "Processor does not support little-endian mode");
+
SAFE_WAIT(&status);
if (WIFSIGNALED(status)) {
int sig = WTERMSIG(status);
@@ -96,18 +102,9 @@ static struct tst_test test = {
.forks_child = 1,
};
-int main4(int argc, char **argv, LTP_ATTRIBUTE_UNUSED char **envp,
- unsigned long *auxv)
-{
- for (; *auxv != AT_NULL && *auxv != AT_HWCAP; auxv += 2)
- ;
-
- if (!(auxv[0] == AT_HWCAP && (auxv[1] & PPC_FEATURE_TRUE_LE)))
- tst_brk(TCONF, "Processor does not support little-endian mode");
-
- tst_run_tcases(argc, argv, &test);
- return 0;
-}
+# else
+TST_TEST_TCONF("Toolchain does not have <sys/auxv.h>");
+# endif /* HAVE_GETAUXVAL */
#else /* defined (__powerpc64__) || (__powerpc__) */
TST_TEST_TCONF("This system does not support running of switch() syscall");