Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Don't use division since we are only deali...
details: https://anonhg.NetBSD.org/src/rev/ccbf23774e52
branches: trunk
changeset: 765401:ccbf23774e52
user: christos <christos%NetBSD.org@localhost>
date: Wed May 25 14:41:46 2011 +0000
description:
Don't use division since we are only dealing with powers of 2.
diffstat:
libexec/ld.elf_so/xmalloc.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diffs (50 lines):
diff -r 02a1983025fa -r ccbf23774e52 libexec/ld.elf_so/xmalloc.c
--- a/libexec/ld.elf_so/xmalloc.c Wed May 25 14:11:36 2011 +0000
+++ b/libexec/ld.elf_so/xmalloc.c Wed May 25 14:41:46 2011 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index