Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 May 2019 15:52:17 +0000 (UTC)
From:      Doug Moore <dougm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r347927 - in head/sys: arm64/include conf
Message-ID:  <201905171552.x4HFqH2g020147@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dougm
Date: Fri May 17 15:52:17 2019
New Revision: 347927
URL: https://svnweb.freebsd.org/changeset/base/347927

Log:
  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

Modified:
  head/sys/arm64/include/cpufunc.h
  head/sys/conf/files.arm64

Modified: head/sys/arm64/include/cpufunc.h
==============================================================================
--- head/sys/arm64/include/cpufunc.h	Fri May 17 15:44:11 2019	(r347926)
+++ head/sys/arm64/include/cpufunc.h	Fri May 17 15:52:17 2019	(r347927)
@@ -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);

Modified: head/sys/conf/files.arm64
==============================================================================
--- head/sys/conf/files.arm64	Fri May 17 15:44:11 2019	(r347926)
+++ head/sys/conf/files.arm64	Fri May 17 15:52:17 2019	(r347927)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905171552.x4HFqH2g020147>