[Cbe-oss-dev] memalign weirdness in newlib

Jeff Johnston jjohnstn at redhat.com
Tue Jan 8 05:47:44 EST 2008


Patrick Mansfield wrote:
> [adding newlib list ...]
> 
> On Sat, Jan 05, 2008 at 10:59:12AM +1100, Michael Ellerman wrote:
> 
>> Yeah you're right, that was a stupid test case I whipped up, here's a
>> fixed version:
>>
>> int main(uint64_t spe_id, uint64_t data, uint64_t env)
>> {
>>         void *p, *q;
>>         int i;
>>
>>         for (i = 0x10; i < 0x90; i *= 2) {
>>                 p = memalign(i, 0x1000);
>>                 q = memalign(i, 0x1000);
>>                 printf("align = 0x%x p = %p q = %p\n", i, p, q);
>>         }
>>
>>         return 0;
>> }
>>
>> And the output:
>>
>> [michael at schoenaich bug]$ ./memalign 
>> align = 0x10 p = 0x1c20 q = 0x2e20
>> align = 0x20 p = 0x3e20 q = 0x4e60
>> align = 0x40 p = 0x5ec0 q = 0x5ec0
>> align = 0x80 p = 0x5f00 q = 0x5f00
>>
>>
>> Which is still broken AFAICT, for alignments > 0x20.
> 
> Looks like a newlib bug.
> 
> I tried your test case with mainline newlib, and get similar results, I
> only tried for SPU (CELL).
> 

The test works fine for two 1.16.0 newlib local builds on my system 
(i686-linux-pc-gnu and mn10300-elf).

Could you debug further and isolate what is being passed to malloc, what 
is being passed to the low-level syscall, and finally what is being 
returned?

-- Jeff J.



More information about the cbe-oss-dev mailing list