(unknown charset) provide fast versions of ffsl and flsl for i386; ffsll and flsll for amd64

From: (unknown charset) Andriy Gapon <avg_at_FreeBSD.org>
Date: Tue, 19 Nov 2013 20:49:27 +0200
These are just trivial wrappers based on the fact that int and long on i386 have
the same "bit layout" and likewise for long and long long on amd64.
For your reviewing pleasure :-)
Thanks!

commit fdc1228b113f8b4c9dbda2b0323cb087c6b6df9d
Author: Andriy Gapon <avg_at_icyb.net.ua>
Date:   Thu Nov 7 19:13:00 2013 +0200

    provide fast versions of ffsl and flsl for i386; ffsll and flsll for amd64

diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index 5f8197b..7464739 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
_at__at_ -154,6 +154,14 _at__at_ ffsl(long mask)
 	return (mask == 0 ? mask : (int)bsfq((u_long)mask) + 1);
 }

+#define	HAVE_INLINE_FFSLL
+
+static __inline int
+ffsll(long long mask)
+{
+	return (ffsl((long)mask));
+}
+
 #define	HAVE_INLINE_FLS

 static __inline int
_at__at_ -170,6 +178,14 _at__at_ flsl(long mask)
 	return (mask == 0 ? mask : (int)bsrq((u_long)mask) + 1);
 }

+#define	HAVE_INLINE_FLSLL
+
+static __inline int
+flsll(long long mask)
+{
+	return (flsl((long)mask));
+}
+
 #endif /* _KERNEL */

 static __inline void
diff --git a/sys/conf/files b/sys/conf/files
index d41b9d2..8077bfc 100644
--- a/sys/conf/files
+++ b/sys/conf/files
_at__at_ -3029,7 +3029,6 _at__at_ libkern/arc4random.c		standard
 libkern/bcd.c			standard
 libkern/bsearch.c		standard
 libkern/crc32.c			standard
-libkern/flsll.c                 standard
 libkern/fnmatch.c		standard
 libkern/iconv.c			optional libiconv
 libkern/iconv_converter_if.m	optional libiconv
diff --git a/sys/conf/files.arm b/sys/conf/files.arm
index 603fb2d..d15f014 100644
--- a/sys/conf/files.arm
+++ b/sys/conf/files.arm
_at__at_ -87,6 +87,7 _at__at_ libkern/divdi3.c		standard
 libkern/ffsl.c			standard
 libkern/fls.c			standard
 libkern/flsl.c			standard
+libkern/flsll.c			standard
 libkern/lshrdi3.c		standard
 libkern/moddi3.c		standard
 libkern/qdivrem.c		standard
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 23e03a3..030dbe1 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
_at__at_ -524,8 +524,7 _at__at_ kern/kern_clocksource.c		standard
 kern/imgact_aout.c		optional compat_aout
 kern/imgact_gzip.c		optional gzip
 libkern/divdi3.c		standard
-libkern/ffsl.c			standard
-libkern/flsl.c			standard
+libkern/flsll.c			standard
 libkern/memmove.c		standard
 libkern/memset.c		standard
 libkern/moddi3.c		standard
diff --git a/sys/conf/files.ia64 b/sys/conf/files.ia64
index 6719c98..e85c35d 100644
--- a/sys/conf/files.ia64
+++ b/sys/conf/files.ia64
_at__at_ -120,6 +120,7 _at__at_ libkern/bcmp.c			standard
 libkern/ffsl.c			standard
 libkern/fls.c			standard
 libkern/flsl.c			standard
+libkern/flsll.c			standard
 libkern/ia64/__divdi3.S		standard
 libkern/ia64/__divsi3.S		standard
 libkern/ia64/__moddi3.S		standard
diff --git a/sys/conf/files.mips b/sys/conf/files.mips
index 82d9a69..6522bb2 100644
--- a/sys/conf/files.mips
+++ b/sys/conf/files.mips
_at__at_ -56,6 +56,7 _at__at_ kern/subr_dummy_vdso_tc.c		standard
 libkern/ffsl.c				standard
 libkern/fls.c				standard
 libkern/flsl.c				standard
+libkern/flsll.c				standard
 libkern/memmove.c			standard
 libkern/cmpdi2.c			optional	mips | mipsel
 libkern/ucmpdi2.c			optional	mips | mipsel
diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98
index fd3ad4a..c95d956 100644
--- a/sys/conf/files.pc98
+++ b/sys/conf/files.pc98
_at__at_ -210,6 +210,7 _at__at_ kern/imgact_gzip.c		optional gzip
 libkern/divdi3.c		standard
 libkern/ffsl.c			standard
 libkern/flsl.c			standard
+libkern/flsll.c			standard
 libkern/memmove.c		standard
 libkern/memset.c		standard
 libkern/moddi3.c		standard
diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc
index 6d90fc7..98b3da0 100644
--- a/sys/conf/files.powerpc
+++ b/sys/conf/files.powerpc
_at__at_ -79,6 +79,7 _at__at_ libkern/ffs.c			standard
 libkern/ffsl.c			standard
 libkern/fls.c			standard
 libkern/flsl.c			standard
+libkern/flsll.c			standard
 libkern/lshrdi3.c		optional	powerpc
 libkern/memmove.c		standard
 libkern/memset.c		standard
diff --git a/sys/conf/files.sparc64 b/sys/conf/files.sparc64
index 5c00350..ccee247 100644
--- a/sys/conf/files.sparc64
+++ b/sys/conf/files.sparc64
_at__at_ -68,6 +68,7 _at__at_ libkern/ffs.c			standard
 libkern/ffsl.c			standard
 libkern/fls.c			standard
 libkern/flsl.c			standard
+libkern/flsll.c			standard
 libkern/memmove.c		standard
 sparc64/central/central.c	optional	central
 sparc64/ebus/ebus.c		optional	ebus
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h
index 7cd3663..98f82f2 100644
--- a/sys/i386/include/cpufunc.h
+++ b/sys/i386/include/cpufunc.h
_at__at_ -184,6 +184,14 _at__at_ ffs(int mask)
 	 return (mask == 0 ? mask : (int)bsfl((u_int)mask) + 1);
 }

+#define	HAVE_INLINE_FFSL
+
+static __inline int
+ffsl(long mask)
+{
+	return (ffs((int)mask));
+}
+
 #define	HAVE_INLINE_FLS

 static __inline int
_at__at_ -192,6 +200,14 _at__at_ fls(int mask)
 	return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
 }

+#define	HAVE_INLINE_FLSL
+
+static __inline int
+flsl(long mask)
+{
+	return (fls((int)mask));
+}
+
 #endif /* _KERNEL */

 static __inline void

-- 
Andriy Gapon
Received on Tue Nov 19 2013 - 17:50:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:44 UTC