I am trying to create an application that uses pthreads and type SSE __m128. According to GCC guidelines, the default alignment is 16 bytes by default. Using __m128 requires 16-byte alignment.
My target processor supports SSE. I use the GCC compiler, which does not support reinstalling the stack at runtime (e.g. -mstackrealign). I can not use another version of the GCC compiler.
My test application looks like this:
#include <xmmintrin.h> #include <pthread.h> void *f(void *x){ __m128 y; ... } int main(void){ pthread_t p; pthread_create(&p, NULL, f, NULL); }
The application throws an exception and exits. After simple debugging (printf "% p", & y), I found that the variable y is not aligned by 16 bytes.
My question is: how can I correctly rewrite the stack (16-byte) without using any GCC flags and attributes (they do not help)? Should I use the GCC inline assembler in this f () thread function?
c gcc stack pthreads sse
psihodelia
source share