Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102646241
D40698.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D40698.diff
View Options
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -127,43 +127,6 @@
__asm __volatile("sti");
}
-#ifdef _KERNEL
-
-#define HAVE_INLINE_FFS
-#define ffs(x) __builtin_ffs(x)
-
-#define HAVE_INLINE_FFSL
-#define ffsl(x) __builtin_ffsl(x)
-
-#define HAVE_INLINE_FFSLL
-#define ffsll(x) __builtin_ffsll(x)
-
-#define HAVE_INLINE_FLS
-
-static __inline __pure2 int
-fls(int mask)
-{
- return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
-}
-
-#define HAVE_INLINE_FLSL
-
-static __inline __pure2 int
-flsl(long mask)
-{
- return (mask == 0 ? mask : (int)bsrq((u_long)mask) + 1);
-}
-
-#define HAVE_INLINE_FLSLL
-
-static __inline __pure2 int
-flsll(long long mask)
-{
- return (flsl((long)mask));
-}
-
-#endif /* _KERNEL */
-
static __inline void
halt(void)
{
diff --git a/sys/arm/include/cpufunc.h b/sys/arm/include/cpufunc.h
--- a/sys/arm/include/cpufunc.h
+++ b/sys/arm/include/cpufunc.h
@@ -183,63 +183,6 @@
extern int arm_dcache_align;
extern int arm_dcache_align_mask;
-
-#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));
-}
#else /* !_KERNEL */
static __inline void
diff --git a/sys/arm64/include/cpufunc.h b/sys/arm64/include/cpufunc.h
--- a/sys/arm64/include/cpufunc.h
+++ b/sys/arm64/include/cpufunc.h
@@ -37,64 +37,6 @@
}
#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.i386 b/sys/conf/files.i386
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -141,8 +141,6 @@
kern/subr_sfbuf.c standard
libkern/divdi3.c standard
libkern/divmoddi4.c standard
-libkern/ffsll.c standard
-libkern/flsll.c standard
libkern/memcmp.c standard
libkern/memset.c standard
libkern/moddi3.c standard
diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc
--- a/sys/conf/files.powerpc
+++ b/sys/conf/files.powerpc
@@ -189,10 +189,6 @@
libkern/bcopy.c standard
libkern/cmpdi2.c optional powerpc | powerpcspe
libkern/divdi3.c optional powerpc | powerpcspe
-libkern/ffs.c standard
-libkern/ffsl.c standard
-libkern/ffsll.c standard
-libkern/flsll.c standard
libkern/lshrdi3.c optional powerpc | powerpcspe
libkern/memcmp.c standard
libkern/memset.c standard
diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv
--- a/sys/conf/files.riscv
+++ b/sys/conf/files.riscv
@@ -23,12 +23,6 @@
kern/subr_intr.c standard
kern/subr_physmem.c standard
libkern/bcopy.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/strcmp.c standard
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h
--- a/sys/i386/include/cpufunc.h
+++ b/sys/i386/include/cpufunc.h
@@ -180,48 +180,6 @@
__asm __volatile("sfence" : : : "memory");
}
-#ifdef _KERNEL
-
-#define HAVE_INLINE_FFS
-
-static __inline __pure2 int
-ffs(int mask)
-{
- /*
- * Note that gcc-2's builtin ffs would be used if we didn't declare
- * this inline or turn off the builtin. The builtin is faster but
- * broken in gcc-2.4.5 and slower but working in gcc-2.5 and later
- * versions.
- */
- return (mask == 0 ? mask : (int)bsfl((u_int)mask) + 1);
-}
-
-#define HAVE_INLINE_FFSL
-
-static __inline __pure2 int
-ffsl(long mask)
-{
- return (ffs((int)mask));
-}
-
-#define HAVE_INLINE_FLS
-
-static __inline __pure2 int
-fls(int mask)
-{
- return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
-}
-
-#define HAVE_INLINE_FLSL
-
-static __inline __pure2 int
-flsl(long mask)
-{
- return (fls((int)mask));
-}
-
-#endif /* _KERNEL */
-
static __inline void
halt(void)
{
diff --git a/sys/powerpc/include/cpufunc.h b/sys/powerpc/include/cpufunc.h
--- a/sys/powerpc/include/cpufunc.h
+++ b/sys/powerpc/include/cpufunc.h
@@ -258,20 +258,6 @@
return (ret);
}
-#define HAVE_INLINE_FLS
-static __inline __pure2 int
-fls(int mask)
-{
- return (mask ? 32 - __builtin_clz(mask) : 0);
-}
-
-#define HAVE_INLINE_FLSL
-static __inline __pure2 int
-flsl(long mask)
-{
- return (mask ? (8 * sizeof(long) - __builtin_clzl(mask)) : 0);
-}
-
/* "NOP" operations to signify priorities to the kernel. */
static __inline void
nop_prio_vlow(void)
diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h
--- a/sys/sys/libkern.h
+++ b/sys/sys/libkern.h
@@ -132,24 +132,63 @@
int timingsafe_bcmp(const void *, const void *, size_t);
void *bsearch(const void *, const void *, size_t,
size_t, int (*)(const void *, const void *));
-#ifndef HAVE_INLINE_FFS
-int ffs(int);
-#endif
-#ifndef HAVE_INLINE_FFSL
-int ffsl(long);
-#endif
-#ifndef HAVE_INLINE_FFSLL
-int ffsll(long long);
-#endif
-#ifndef HAVE_INLINE_FLS
-int fls(int);
-#endif
-#ifndef HAVE_INLINE_FLSL
-int flsl(long);
-#endif
-#ifndef HAVE_INLINE_FLSLL
-int flsll(long long);
-#endif
+
+/*
+ * MHTODO: remove the 'HAVE_INLINE_FOO' defines once use of these flags has
+ * been purged everywhere. For now we provide them unconditionally.
+ */
+#define HAVE_INLINE_FFS
+#define HAVE_INLINE_FFSL
+#define HAVE_INLINE_FFSLL
+#define HAVE_INLINE_FLS
+#define HAVE_INLINE_FLSL
+#define HAVE_INLINE_FLSLL
+
+static __inline __pure2 int
+ffs(int mask)
+{
+
+ return (__builtin_ffs((u_int)mask));
+}
+
+static __inline __pure2 int
+ffsl(long mask)
+{
+
+ return (__builtin_ffsl((u_long)mask));
+}
+
+static __inline __pure2 int
+ffsll(long long mask)
+{
+
+ return (__builtin_ffsll((unsigned long long)mask));
+}
+
+static __inline __pure2 int
+fls(int mask)
+{
+
+ return (mask == 0 ? 0 :
+ 8 * sizeof(mask) - __builtin_clz((u_int)mask));
+}
+
+static __inline __pure2 int
+flsl(long mask)
+{
+
+ return (mask == 0 ? 0 :
+ 8 * sizeof(mask) - __builtin_clzl((u_long)mask));
+}
+
+static __inline __pure2 int
+flsll(long long mask)
+{
+
+ return (mask == 0 ? 0 :
+ 8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
+}
+
#define bitcount64(x) __bitcount64((uint64_t)(x))
#define bitcount32(x) __bitcount32((uint32_t)(x))
#define bitcount16(x) __bitcount16((uint16_t)(x))
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 7:17 AM (21 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14655055
Default Alt Text
D40698.diff (7 KB)
Attached To
Mode
D40698: Consistently provide ffs/fls using builtins
Attached
Detach File
Event Timeline
Log In to Comment