Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146675103
D40698.id123618.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.id123618.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
@@ -129,16 +129,7 @@
#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
+#define HAVE_MD_FLS
static __inline __pure2 int
fls(int mask)
@@ -146,7 +137,7 @@
return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
}
-#define HAVE_INLINE_FLSL
+#define HAVE_MD_FLSL
static __inline __pure2 int
flsl(long mask)
@@ -154,7 +145,7 @@
return (mask == 0 ? mask : (int)bsrq((u_long)mask) + 1);
}
-#define HAVE_INLINE_FLSLL
+#define HAVE_MD_FLSLL
static __inline __pure2 int
flsll(long long mask)
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
@@ -140,8 +140,6 @@
kern/imgact_aout.c optional compat_aout
kern/subr_sfbuf.c standard
libkern/divdi3.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
@@ -182,7 +182,7 @@
#ifdef _KERNEL
-#define HAVE_INLINE_FFS
+#define HAVE_MD_FFS
static __inline __pure2 int
ffs(int mask)
@@ -196,7 +196,7 @@
return (mask == 0 ? mask : (int)bsfl((u_int)mask) + 1);
}
-#define HAVE_INLINE_FFSL
+#define HAVE_MD_FFSL
static __inline __pure2 int
ffsl(long mask)
@@ -204,7 +204,7 @@
return (ffs((int)mask));
}
-#define HAVE_INLINE_FLS
+#define HAVE_MD_FLS
static __inline __pure2 int
fls(int mask)
@@ -212,7 +212,7 @@
return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1);
}
-#define HAVE_INLINE_FLSL
+#define HAVE_MD_FLSL
static __inline __pure2 int
flsl(long mask)
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,78 @@
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);
+
+/*
+ * Find First Set bit (ffs) and Find Last Set bit (fls) family of functions.
+ * These definitions may be overridden by machine/cpufunc.h.
+ *
+ * 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
+
+#ifndef HAVE_MD_FFS
+static __inline __pure2 int
+ffs(int mask)
+{
+
+ return (__builtin_ffs((u_int)mask));
+}
#endif
-#ifndef HAVE_INLINE_FFSL
-int ffsl(long);
+
+#ifndef HAVE_MD_FFSL
+static __inline __pure2 int
+ffsl(long mask)
+{
+
+ return (__builtin_ffsl((u_long)mask));
+}
#endif
-#ifndef HAVE_INLINE_FFSLL
-int ffsll(long long);
+
+#ifndef HAVE_MD_FFSLL
+static __inline __pure2 int
+ffsll(long long mask)
+{
+
+ return (__builtin_ffsll((unsigned long long)mask));
+}
#endif
-#ifndef HAVE_INLINE_FLS
-int fls(int);
+
+#ifndef HAVE_MD_FLS
+static __inline __pure2 int
+fls(int mask)
+{
+
+ return (mask == 0 ? 0 :
+ 8 * sizeof(mask) - __builtin_clz((u_int)mask));
+}
#endif
-#ifndef HAVE_INLINE_FLSL
-int flsl(long);
+
+#ifndef HAVE_MD_FLSL
+static __inline __pure2 int
+flsl(long mask)
+{
+
+ return (mask == 0 ? 0 :
+ 8 * sizeof(mask) - __builtin_clzl((u_long)mask));
+}
#endif
-#ifndef HAVE_INLINE_FLSLL
-int flsll(long long);
+
+#ifndef HAVE_MD_FLSLL
+static __inline __pure2 int
+flsll(long long mask)
+{
+
+ return (mask == 0 ? 0 :
+ 8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
+}
#endif
+
#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
Thu, Mar 5, 3:18 PM (20 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29289728
Default Alt Text
D40698.id123618.diff (7 KB)
Attached To
Mode
D40698: Consistently provide ffs/fls using builtins
Attached
Detach File
Event Timeline
Log In to Comment