At 12:29 AM 9/21/2001 +0200, Bart Lateur wrote:
>[I'm behind on my mail  :-)]
>
>On Wed, 12 Sep 2001 13:19:40 -0400, Dan Sugalski wrote:
>
> >We're trying to align to a power-of-two boundary, and mask is set to
> >chop off the low bits, not the high ones. It should be something like:
> >
> >    111111110000
> >
> >The calc:
> >
> >     mem & mask + (~mask + 1)
> >
> >will chop the low bits off of mem, making it too small, but power-of-two
> >aligned. Then we add in the inverse of mask + 1 (in the above example,
> >that'd be 10000) to jump it to the next power-of-two boundary.
> >
> >Horribly wasteful of memory, definitely, and the final allocation system
> >will do things better, but this is OK to start.
>
>So to stop it waste memory, subtract 1 first and add it again later.

Nah, it'll still waste memory. It can't not, because of the way it works. 
It has to ask for a big gob of memory and ignore bits to make sure it gets 
the alignment right. This particular implementation's not all that 
efficient I'm sure, but it'll get ripped out and replaced when we have a 
real memory management system.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to