Module Name: src Committed By: christos Date: Wed May 25 14:41:46 UTC 2011
Modified Files: src/libexec/ld.elf_so: xmalloc.c Log Message: Don't use division since we are only dealing with powers of 2. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/libexec/ld.elf_so/xmalloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/libexec/ld.elf_so/xmalloc.c diff -u src/libexec/ld.elf_so/xmalloc.c:1.10 src/libexec/ld.elf_so/xmalloc.c:1.11 --- src/libexec/ld.elf_so/xmalloc.c:1.10 Fri Dec 3 18:07:49 2010 +++ src/libexec/ld.elf_so/xmalloc.c Wed May 25 10:41:46 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xmalloc.c,v 1.10 2010/12/03 23:07:49 joerg Exp $ */ +/* $NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -77,7 +77,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: xmalloc.c,v 1.10 2010/12/03 23:07:49 joerg Exp $"); +__RCSID("$NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $"); #endif /* not lint */ #include <stdlib.h> @@ -148,6 +148,7 @@ static size_t pagesz; /* page size */ static size_t pagebucket; /* page size bucket */ +static size_t pageshift; /* page size shift */ #ifdef MSTATS /* @@ -203,6 +204,7 @@ bucket++; } pagebucket = bucket; + pageshift = ffs(pagesz) - 1; } /* * Convert amount of memory requested into closest block size @@ -277,13 +279,13 @@ #endif if (sz < pagesz) { amt = pagesz; - nblks = amt / sz; + nblks = amt >> (bucket + 3); } else { amt = sz + pagesz; nblks = 1; } if (amt > PAGEPOOL_SIZE) - if (morepages(amt/pagesz + NPOOLPAGES) == 0) + if (morepages((amt >> pageshift) + NPOOLPAGES) == 0) return; op = (union overhead *)pagepool_start; pagepool_start += amt;