Subject: Re: libsa/alloc.c 'freelist' initialization
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: tech-kern
Date: 05/11/1999 10:30:22
Chris G. Demetriou wrote:

> 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.

Hmm, engage coffee _before_ brain.  gcc -fdo-what-i-mean-not-what-you-want ...

> > 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-)

Nah, too much extra code! :-)  FWIW, everything the pmax alloc()d was
either 512 bytes or 8192 bytes.  No excuse not to align it though...

Simon.