[PATCH] selftests/powerpc: Fix build failure of load_unaligned_zeropad test

Michael Ellerman mpe at ellerman.id.au
Mon Oct 12 15:28:57 AEDT 2015


Commit 7a5692e6e533 ("arch/powerpc: provide zero_bytemask() for
big-endian") added a call to __fls() in our word-at-a-time.h. That was
fine for the kernel build but missed the fact that we also use
word-at-a-time.h in a userspace test.

Pulling in the kernel version of __fls() gets messy, so just define our
own, it's unlikely to change often. We also need to forward declare it
to avoid header inclusion mess.

Fixes: 7a5692e6e533 ("arch/powerpc: provide zero_bytemask() for big-endian")
Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
---
 .../selftests/powerpc/primitives/load_unaligned_zeropad.c        | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c b/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c
index d1b647509596..9b569ec3dbc5 100644
--- a/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c
+++ b/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad.c
@@ -25,10 +25,19 @@
 
 #define FIXUP_SECTION ".ex_fixup"
 
+static unsigned long __fls(unsigned long x);
+
 #include "word-at-a-time.h"
 
 #include "utils.h"
 
+static unsigned long __fls(unsigned long x)
+{
+	int lz;
+
+	asm (PPC_CNTLZL "%0,%1" : "=r" (lz) : "r" (x));
+	return sizeof(unsigned long) - 1 - lz;
+}
 
 static int page_size;
 static char *mem_region;
-- 
2.1.4



More information about the Linuxppc-dev mailing list