diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2015-11-23 21:05:39 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-12-14 04:41:47 -0500 |
commit | ede8ef3f824ea6e853a5e4b27467f583cdaa314e (patch) | |
tree | 39237f6a1e7c5ff66bc6e0f216c789ee6f2cb2ac /tools | |
parent | fcb45ec074725baeb3aaa1b1854b9f44c3eebacf (diff) |
selftests/powerpc: Add have_hwcap2() helper
We already do this twice and want to add another so add a helper.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/powerpc/pmu/ebb/ebb.c | 3 | ||||
-rw-r--r-- | tools/testing/selftests/powerpc/tm/tm-syscall.c | 3 | ||||
-rw-r--r-- | tools/testing/selftests/powerpc/utils.h | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c index 9729d9f90218..e67452f1bcff 100644 --- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c +++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
14 | #include <string.h> | 14 | #include <string.h> |
15 | #include <sys/ioctl.h> | 15 | #include <sys/ioctl.h> |
16 | #include <linux/auxvec.h> | ||
17 | 16 | ||
18 | #include "trace.h" | 17 | #include "trace.h" |
19 | #include "reg.h" | 18 | #include "reg.h" |
@@ -324,7 +323,7 @@ bool ebb_is_supported(void) | |||
324 | { | 323 | { |
325 | #ifdef PPC_FEATURE2_EBB | 324 | #ifdef PPC_FEATURE2_EBB |
326 | /* EBB requires at least POWER8 */ | 325 | /* EBB requires at least POWER8 */ |
327 | return ((long)get_auxv_entry(AT_HWCAP2) & PPC_FEATURE2_EBB); | 326 | return have_hwcap2(PPC_FEATURE2_EBB); |
328 | #else | 327 | #else |
329 | return false; | 328 | return false; |
330 | #endif | 329 | #endif |
diff --git a/tools/testing/selftests/powerpc/tm/tm-syscall.c b/tools/testing/selftests/powerpc/tm/tm-syscall.c index e835bf7ec7ae..d7256b79ec4c 100644 --- a/tools/testing/selftests/powerpc/tm/tm-syscall.c +++ b/tools/testing/selftests/powerpc/tm/tm-syscall.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <sys/syscall.h> | 14 | #include <sys/syscall.h> |
15 | #include <asm/tm.h> | 15 | #include <asm/tm.h> |
16 | #include <asm/cputable.h> | 16 | #include <asm/cputable.h> |
17 | #include <linux/auxvec.h> | ||
18 | #include <sys/time.h> | 17 | #include <sys/time.h> |
19 | #include <stdlib.h> | 18 | #include <stdlib.h> |
20 | 19 | ||
@@ -80,7 +79,7 @@ pid_t getppid_tm(bool suspend) | |||
80 | static inline bool have_htm_nosc(void) | 79 | static inline bool have_htm_nosc(void) |
81 | { | 80 | { |
82 | #ifdef PPC_FEATURE2_HTM_NOSC | 81 | #ifdef PPC_FEATURE2_HTM_NOSC |
83 | return ((long)get_auxv_entry(AT_HWCAP2) & PPC_FEATURE2_HTM_NOSC); | 82 | return have_hwcap2(PPC_FEATURE2_HTM_NOSC); |
84 | #else | 83 | #else |
85 | printf("PPC_FEATURE2_HTM_NOSC not defined, can't check AT_HWCAP2\n"); | 84 | printf("PPC_FEATURE2_HTM_NOSC not defined, can't check AT_HWCAP2\n"); |
86 | return false; | 85 | return false; |
diff --git a/tools/testing/selftests/powerpc/utils.h b/tools/testing/selftests/powerpc/utils.h index b7d41086bb0a..fbf2bf530e50 100644 --- a/tools/testing/selftests/powerpc/utils.h +++ b/tools/testing/selftests/powerpc/utils.h | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <stdint.h> | 9 | #include <stdint.h> |
10 | #include <stdbool.h> | 10 | #include <stdbool.h> |
11 | #include <linux/auxvec.h> | ||
11 | 12 | ||
12 | /* Avoid headaches with PRI?64 - just use %ll? always */ | 13 | /* Avoid headaches with PRI?64 - just use %ll? always */ |
13 | typedef unsigned long long u64; | 14 | typedef unsigned long long u64; |
@@ -22,6 +23,11 @@ typedef uint8_t u8; | |||
22 | int test_harness(int (test_function)(void), char *name); | 23 | int test_harness(int (test_function)(void), char *name); |
23 | extern void *get_auxv_entry(int type); | 24 | extern void *get_auxv_entry(int type); |
24 | 25 | ||
26 | static inline bool have_hwcap2(unsigned long ftr2) | ||
27 | { | ||
28 | return ((unsigned long)get_auxv_entry(AT_HWCAP2) & ftr2) == ftr2; | ||
29 | } | ||
30 | |||
25 | /* Yes, this is evil */ | 31 | /* Yes, this is evil */ |
26 | #define FAIL_IF(x) \ | 32 | #define FAIL_IF(x) \ |
27 | do { \ | 33 | do { \ |