#include #include extern "C" void * test_thread_stackaligned(void *) { double array[1] __attribute__((aligned(16)));; printf("BAD address: %p\n", array); return NULL; } void * test_thread(void *param) { return ( { register void *res; register void *temp; __asm ( "push %%ebp;" "movl %%esp, %2;" "movl %%esp, %%ebp;" "subl $4, %2;" "andl $0xfffffff0, %2;" "movl %2, %%esp;" "movl %1, (%2);" "call test_thread_stackaligned;" "movl %%ebp, %%esp;" "pop %%ebp;" : "=a" (res) : "r" (param), "r" (temp) ); res; }); } int main(int argc, char *argv[]) { double array[1] __attribute__((aligned(16)));; printf("OK address: %p\n", array); pthread_t tid; pthread_create(&tid, NULL, test_thread, NULL); pthread_join(tid, NULL); return 0; }