Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102154712
D45483.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
913 B
Referenced Files
None
Subscribers
None
D45483.diff
View Options
diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c
--- a/sys/amd64/vmm/x86.c
+++ b/sys/amd64/vmm/x86.c
@@ -61,14 +61,13 @@
&cpuid_leaf_b, 0, NULL);
/*
- * Round up to the next power of two, if necessary, and then take log2.
- * Returns -1 if argument is zero.
+ * Compute ceil(log2(x)). Returns -1 if x is zero.
*/
static __inline int
log2(u_int x)
{
- return (fls(x << (1 - powerof2(x))) - 1);
+ return (x == 0 ? -1 : fls(x - 1));
}
int
diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c
--- a/sys/x86/x86/mp_x86.c
+++ b/sys/x86/x86/mp_x86.c
@@ -183,15 +183,13 @@
}
/*
- * Round up to the next power of two, if necessary, and then
- * take log2.
- * Returns -1 if argument is zero.
+ * Compute ceil(log2(x)). Returns -1 if x is zero.
*/
static __inline int
mask_width(u_int x)
{
- return (fls(x << (1 - powerof2(x))) - 1);
+ return (x == 0 ? -1 : fls(x - 1));
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 7:23 AM (21 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14552864
Default Alt Text
D45483.diff (913 B)
Attached To
Mode
D45483: x86: simplify ceil(log2(x)) function
Attached
Detach File
Event Timeline
Log In to Comment