Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149337374
D45170.id138444.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
832 B
Referenced Files
None
Subscribers
None
D45170.id138444.diff
View Options
Index: sys/sys/libkern.h
===================================================================
--- sys/sys/libkern.h
+++ sys/sys/libkern.h
@@ -186,6 +186,31 @@
8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
}
+static __inline __pure2 int
+ilog2(int mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 - __builtin_clz((u_int)mask));
+}
+
+static __inline __pure2 int
+ilog2l(long mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 - __builtin_clzl((u_long)mask));
+}
+
+static __inline __pure2 int
+ilog2ll(long long mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 -
+ __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
Tue, Mar 24, 8:31 PM (14 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30270339
Default Alt Text
D45170.id138444.diff (832 B)
Attached To
Mode
D45170: libkern: add ilog2 helpers
Attached
Detach File
Event Timeline
Log In to Comment