This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Cbe-oss-dev] memalign weirdness in newlib

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]