Subject: Re: libsa/alloc.c 'freelist' initialization
To: None <tech-kern@netbsd.org>
From: Chris G. Demetriou <cgd@netbsd.org>
List: tech-kern
Date: 05/10/1999 16:31:01
Simon Burge <simonb@netbsd.org> writes:
> Sounds like a good call to me.  I don't suppose egcs is smart enough to
> move variables initialised to 0 to the BSS?

Err, uh, that'd actually be Smart, not smart.

Often the point of initializing a variable to 0 is just so that you
can patch it later.

The compiler _shouldn't even think about_ trying that, unless it's
explicitly requested.


> FWIW, I'm sitting on an alloc that's basically:
> 	
> 	void *
> 	alloc()
> 	{
> 		void *old;
> 		static top = end;
> 		old = top
> 		top += size;
> 		return(old);
> 	}
> 
> with no implementation of free().  I was using this then the first stage
> pmax bootblocks didn't fit into 7.5k when we first changed from gcc to
> egcs.  There was less than half a dozen calls to alloc() totalling less
> than 30kB.

Hmm.  That could be a useful hack, but nobody seems to be screaming
for it right now.  8-)

Your code is a tiny bit broken, though: to work on all archs, it
should do the right things to make sure allocated blocks are aligned.  8-)




cgd
-- 
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.