Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Stack alignment with pthreads

On Friday, at 22:49, Anthony Mallet wrote:
| - The only thing that had some effect was to artificially substract 4 bytes
| from the sp in makecontext, just before 'pushing' the args. (i.e. replaced
|  ``sp -= argc + 1'' by ``sp -= argc + 2'' in arch/i386/gen/makecontext.c).

Following up on myself...
I found more interesting info here:;r2=;f=h

Mimicking this patch to our i386/makecontext() gives this:
        sp  = (unsigned int *)((uintptr_t)sp & ~0x3); 
        sp -= argc;                     /* Make room for args. */ 
        sp  = (unsigned int *)((uintptr_t)sp & ~0xf); 
        sp --;                          /* Make room for ret */

(I can provide a real diff if this is not clear :)

What I understand is that the first arg should be aligned on 16 bytes, and this
effectively fixes the problem.

So what do you think about this change?


Home | Main Index | Thread Index | Old Index