[Cbe-oss-dev] memalign weirdness in newlib

Michael Ellerman michael at ellerman.id.au
Mon Dec 24 13:47:30 EST 2007


Hi all,

I know it's christmas but dammit I just wanted to get my damn raytracer
bug free before I go on holidays, but no.

Can anyone explain this to me?

[michael at schoenaich bug]$ cat memalign.c
#include <stdio.h>
#include <malloc.h>
#include <stdint.h>

int main(uint64_t spe_id, uint64_t data, uint64_t env)
{
        void *p, *q;
        int i;

        for (i = 0x10; i < 0x90; i += 0x10) {
                p = memalign(i, 0x1000);
                q = memalign(i, 0x1000);
                printf("align = 0x%x p = %p q = %p\n", i, p, q);
        }

        return 0;
}

[michael at schoenaich ~]$ rpm -q spu-newlib
spu-newlib-1.15.0-82

[michael at schoenaich bug]$ spu-gcc --version
spu-gcc (GCC) 4.1.1

[michael at schoenaich bug]$ spu-gcc -o memalign -Wextra -Wall memalign.c
memalign.c:5: warning: unused parameter 'spe_id'
memalign.c:5: warning: unused parameter 'data'
memalign.c:5: warning: unused parameter 'env'

[michael at schoenaich bug]$ elfspe memalign
align = 0x10 p = 0x1c20 q = 0x2e20
align = 0x20 p = 0x3e20 q = 0x4e60
align = 0x30 p = 0x5ec0 q = 0x5ec0
align = 0x40 p = 0x5ec0 q = 0x5ec0
align = 0x50 p = 0x5ef0 q = 0x5ef0
align = 0x60 p = 0x5f00 q = 0x5f00
align = 0x70 p = 0x5f00 q = 0x5f00
align = 0x80 p = 0x5f00 q = 0x5f00


For alignments > 0x20 successive calls to memalign() return the same
memory? Or am I going crazy.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20071224/dbf6e669/attachment.pgp>


More information about the cbe-oss-dev mailing list