Page MenuHomeFreeBSD

D45483.diff
No OneTemporary

D45483.diff

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

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)

Event Timeline