From ca9985cb791e4e73b27c45963dae91e8ee143f9d Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Thu, 14 May 2009 18:54:04 +0000 Subject: Add two hooks allowing MD code get a MD header to be included if needed, and to override the way HEAP_START and HEAP_LIMIT are defined. --- sys/lib/libsa/alloc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/lib/libsa/alloc.c b/sys/lib/libsa/alloc.c index 2f41d683364..64f8a0bc643 100644 --- a/sys/lib/libsa/alloc.c +++ b/sys/lib/libsa/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.9 2003/08/11 06:23:09 deraadt Exp $ */ +/* $OpenBSD: alloc.c,v 1.10 2009/05/14 18:54:03 miod Exp $ */ /* $NetBSD: alloc.c,v 1.6 1997/02/04 18:36:33 thorpej Exp $ */ /* @@ -78,6 +78,12 @@ * * HEAP_START start address of heap (defaults to '&end'). * + * NEEDS_HEAP_H needs to #include "heap.h" to declare things + * needed by HEAP_LIMIT and/or HEAP_START. + * + * NEEDS_HEAP_INIT needs to invoke heap_init() to initialize + * heap boundaries. + * * DEBUG enable debugging sanity checks. */ @@ -111,12 +117,17 @@ struct fl { struct fl *next; } *freelist = (struct fl *)0; +#ifdef NEEDS_HEAP_H +#include "heap.h" +#endif +#ifndef NEEDS_HEAP_INIT #ifdef HEAP_START static char *top = (char *)HEAP_START; #else extern char end[]; static char *top = end; #endif +#endif void * alloc(unsigned int size) @@ -128,6 +139,10 @@ alloc(unsigned int size) char *help; int failed; +#ifdef NEEDS_HEAP_INIT + heap_init(); +#endif + #ifdef ALLOC_TRACE printf("alloc(%u)", size); #endif -- cgit v1.2.3