Print this page
5255 uts shouldn't open-code ISP2
@@ -918,11 +918,11 @@
{
int hb;
int flist = 0;
ASSERT(MUTEX_HELD(&vmp->vm_lock));
- if ((size & (size - 1)) == 0)
+ if (ISP2(size))
flist = lowbit(P2ALIGN(vmp->vm_freemap, size));
else if ((hb = highbit(size)) < VMEM_FREELISTS)
flist = lowbit(P2ALIGN(vmp->vm_freemap, 1UL << hb));
return (flist);
@@ -957,12 +957,11 @@
panic("vmem_xalloc(%p, %lu, %lu, %lu, %lu, %p, %p, %x): "
"overconstrained allocation",
(void *)vmp, size, align_arg, phase, nocross,
minaddr, maxaddr, vmflag);
- if (phase >= align || (align & (align - 1)) != 0 ||
- (nocross & (nocross - 1)) != 0)
+ if (phase >= align || !ISP2(align) || !ISP2(nocross))
panic("vmem_xalloc(%p, %lu, %lu, %lu, %lu, %p, %p, %x): "
"parameters inconsistent or invalid",
(void *)vmp, size, align_arg, phase, nocross,
minaddr, maxaddr, vmflag);
@@ -992,11 +991,11 @@
* (3) We're in the highest possible freelist, which is
* always empty (e.g. the 4GB freelist on 32-bit systems);
*
* (4) We're doing a best-fit or first-fit allocation.
*/
- if ((size & (size - 1)) == 0) {
+ if (ISP2(size)) {
flist = lowbit(P2ALIGN(vmp->vm_freemap, size));
} else {
hb = highbit(size);
if ((vmp->vm_freemap >> hb) == 0 ||
hb == VMEM_FREELISTS ||
@@ -1288,11 +1287,11 @@
* Unconstrained instant-fit allocation from the segment list.
*/
mutex_enter(&vmp->vm_lock);
if (vmp->vm_nsegfree >= VMEM_MINFREE || vmem_populate(vmp, vmflag)) {
- if ((size & (size - 1)) == 0)
+ if (ISP2(size))
flist = lowbit(P2ALIGN(vmp->vm_freemap, size));
else if ((hb = highbit(size)) < VMEM_FREELISTS)
flist = lowbit(P2ALIGN(vmp->vm_freemap, 1UL << hb));
}