提交 ede8ef3f 编写于 作者: M Michael Ellerman

selftests/powerpc: Add have_hwcap2() helper

We already do this twice and want to add another so add a helper.
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
上级 fcb45ec0
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/auxvec.h>
#include "trace.h" #include "trace.h"
#include "reg.h" #include "reg.h"
...@@ -324,7 +323,7 @@ bool ebb_is_supported(void) ...@@ -324,7 +323,7 @@ bool ebb_is_supported(void)
{ {
#ifdef PPC_FEATURE2_EBB #ifdef PPC_FEATURE2_EBB
/* EBB requires at least POWER8 */ /* EBB requires at least POWER8 */
return ((long)get_auxv_entry(AT_HWCAP2) & PPC_FEATURE2_EBB); return have_hwcap2(PPC_FEATURE2_EBB);
#else #else
return false; return false;
#endif #endif
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <sys/syscall.h> #include <sys/syscall.h>
#include <asm/tm.h> #include <asm/tm.h>
#include <asm/cputable.h> #include <asm/cputable.h>
#include <linux/auxvec.h>
#include <sys/time.h> #include <sys/time.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -80,7 +79,7 @@ pid_t getppid_tm(bool suspend) ...@@ -80,7 +79,7 @@ pid_t getppid_tm(bool suspend)
static inline bool have_htm_nosc(void) static inline bool have_htm_nosc(void)
{ {
#ifdef PPC_FEATURE2_HTM_NOSC #ifdef PPC_FEATURE2_HTM_NOSC
return ((long)get_auxv_entry(AT_HWCAP2) & PPC_FEATURE2_HTM_NOSC); return have_hwcap2(PPC_FEATURE2_HTM_NOSC);
#else #else
printf("PPC_FEATURE2_HTM_NOSC not defined, can't check AT_HWCAP2\n"); printf("PPC_FEATURE2_HTM_NOSC not defined, can't check AT_HWCAP2\n");
return false; return false;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <linux/auxvec.h>
/* Avoid headaches with PRI?64 - just use %ll? always */ /* Avoid headaches with PRI?64 - just use %ll? always */
typedef unsigned long long u64; typedef unsigned long long u64;
...@@ -22,6 +23,11 @@ typedef uint8_t u8; ...@@ -22,6 +23,11 @@ typedef uint8_t u8;
int test_harness(int (test_function)(void), char *name); int test_harness(int (test_function)(void), char *name);
extern void *get_auxv_entry(int type); extern void *get_auxv_entry(int type);
static inline bool have_hwcap2(unsigned long ftr2)
{
return ((unsigned long)get_auxv_entry(AT_HWCAP2) & ftr2) == ftr2;
}
/* Yes, this is evil */ /* Yes, this is evil */
#define FAIL_IF(x) \ #define FAIL_IF(x) \
do { \ do { \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册