summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-11-28 18:03:22 +0000
committermarcel <marcel@FreeBSD.org>2003-11-28 18:03:22 +0000
commit769360c4407229ea650d8944b6bdd883adcdf365 (patch)
tree4e1b95188d4f85ad5d9846aa69d293920531b248 /lib
parenta36a8ab06d69627279afdd6cb31c3c2e69f77c5a (diff)
downloadFreeBSD-src-769360c4407229ea650d8944b6bdd883adcdf365.zip
FreeBSD-src-769360c4407229ea650d8944b6bdd883adcdf365.tar.gz
Do not adjust to the pagesize at runtime. Besides for the one-time
initialization overhead, there's a problem in that we never call imalloc() and thus malloc_init() for zero-sized allocations. As a result, malloc(0) returns NULL when it's the first or only malloc in the program. Any non-zero allocation will initialize the malloc code with the side-effect that subsequent zero-sized allocations return a non-NULL pointer. This is because the pointer we return for zero- sized allocations is calculated from malloc_pageshift, which needs to be initialized at runtime on ia64. The result of the inconsistent behaviour described above is that configure scripts failed the test for a GNU compatible malloc. This resulted in a lot of broken ports. Other, even simpler, solutions were possible as well: 1. initialize malloc_pageshift with some non-zero value (say 13 for 8KB pages) and keep the runtime adjustment. 2. Stop using malloc_pageshift to calculate ZEROSIZEPTR. Removal of the runtime adjustment was chosen because then ia64 is the same as any other platform. It is not to say that using a page size obtained at runtime is bad per se. It's that there's currently a high level of gratuity for its existence and the moment it causes problems is the moment you need to get rid of it. Hence, it's not unthinkable that this commit is (partially) reverted some time in the future when we do have a good reason for it and a good way to achieve it. Approved by: re@ (rwatson) Reported by: kris (portmgr@) -- may the ports be with you
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/malloc.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index d99457a..b842ac8 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -50,9 +50,8 @@ __FBSDID("$FreeBSD$");
# define malloc_minsize 16U
# endif
# if defined(__ia64__)
- static int malloc_pageshift_value;
-# define malloc_pageshift malloc_pageshift_value
-# define malloc_minsize 16U
+# define malloc_pageshift 13U
+# define malloc_minsize 16U
# endif
# if defined(__alpha__)
# define malloc_pageshift 13U
@@ -414,11 +413,6 @@ malloc_init(void)
int i, j;
int save_errno = errno;
-#ifdef __ia64__
- malloc_pageshift = 0;
- while ((1L << malloc_pageshift) < getpagesize())
- malloc_pageshift++;
-#endif
INIT_MMAP();
#ifdef MALLOC_EXTRA_SANITY
OpenPOWER on IntegriCloud