Implement the ffs and fls functions, and their longer counterparts, in

cpufunc, in terms of __builtin_ffs and the like, for arm64
architectures, and use those, rather than the simple libkern
implementations, in building arm64 kernels.

Tested by: greg_unrelenting.technology (earlier version)
Reviewed by: alc
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D20250
This commit is contained in:
Doug Moore 2019-05-17 15:52:17 +00:00
parent 72796f6ae0
commit 60645781d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347927
2 changed files with 57 additions and 6 deletions

View File

@ -38,6 +38,63 @@ breakpoint(void)
#ifdef _KERNEL
#define HAVE_INLINE_FFS
static __inline __pure2 int
ffs(int mask)
{
return (__builtin_ffs(mask));
}
#define HAVE_INLINE_FFSL
static __inline __pure2 int
ffsl(long mask)
{
return (__builtin_ffsl(mask));
}
#define HAVE_INLINE_FFSLL
static __inline __pure2 int
ffsll(long long mask)
{
return (__builtin_ffsll(mask));
}
#define HAVE_INLINE_FLS
static __inline __pure2 int
fls(int mask)
{
return (mask == 0 ? 0 :
8 * sizeof(mask) - __builtin_clz((u_int)mask));
}
#define HAVE_INLINE_FLSL
static __inline __pure2 int
flsl(long mask)
{
return (mask == 0 ? 0 :
8 * sizeof(mask) - __builtin_clzl((u_long)mask));
}
#define HAVE_INLINE_FLSLL
static __inline __pure2 int
flsll(long long mask)
{
return (mask == 0 ? 0 :
8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
}
#include <machine/armreg.h>
void pan_enable(void);

View File

@ -258,12 +258,6 @@ kern/pic_if.m optional intrng
kern/subr_devmap.c standard
kern/subr_intr.c optional intrng
libkern/bcmp.c standard
libkern/ffs.c standard
libkern/ffsl.c standard
libkern/ffsll.c standard
libkern/fls.c standard
libkern/flsl.c standard
libkern/flsll.c standard
libkern/memcmp.c standard
libkern/memset.c standard
libkern/arm64/crc32c_armv8.S standard