diff options
author | Doug Moore <dougm@FreeBSD.org> | 2019-05-17 15:52:17 +0000 |
---|---|---|
committer | Doug Moore <dougm@FreeBSD.org> | 2019-05-17 15:52:17 +0000 |
commit | 60645781d6132d7a3f810420e8f407424cc52f9d (patch) | |
tree | 872500cd789f24658749d112c2b7b438b04594ae | |
parent | 72796f6ae01db6c3ab44eaf4c4b61bc7007d8cb7 (diff) | |
download | src-60645781d6132d7a3f810420e8f407424cc52f9d.tar.gz src-60645781d6132d7a3f810420e8f407424cc52f9d.zip |
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
Notes
Notes:
svn path=/head/; revision=347927
-rw-r--r-- | sys/arm64/include/cpufunc.h | 57 | ||||
-rw-r--r-- | sys/conf/files.arm64 | 6 |
2 files changed, 57 insertions, 6 deletions
diff --git a/sys/arm64/include/cpufunc.h b/sys/arm64/include/cpufunc.h index c4fc67aa4a7f..a89a6306e976 100644 --- a/sys/arm64/include/cpufunc.h +++ b/sys/arm64/include/cpufunc.h @@ -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); diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index 73c1901d7a96..8af4f96cd58d 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -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 |