Mail Archives: djgpp-workers/2002/02/11/16:42:18
> > We could add a sbrk(0) call before calling sbrk() with the expected
> > size - and if it's aligned the sbrk() value should be also. If
> > sbrk(0) not aligned, we sbrk() the small number of bytes to align -
> > which will always work (unless there's a equality bug right at the
> > boundary in sbrk...)
>
> That won't work if the remaining space in the current memory region is
> smaller than the malloc() request size. sbrk(0) will point to the
> tail of the current region, but sbrk(N) will return the beginning of a
> new region.
A new region will always be 8 byte aligned - so no problem in that case.
(Yes, that's a evil assumption which should be documented if we do that).
This can be the reason where some Windows change alignment. If you get
a new zone and it's not contiguous vs continuing to use the original
zone "extended" with the contiguous block.
Of course, unixy sbrk() always makes things predictable ...
> > By the way, I think the reason we are off by 4 is stubinfo is 0x54
> > bytes and it's the very first thing we sbrk() :-P
>
> Well, that's easily fixed!
Not so easy - we base that on the end of our bss section, which it seems
can also be 4 byte ended (?)
Some test programs always come up aligned ;-/
- Raw text -