1 2#include "tests/malloc.h" 3#include <stdio.h> 4#include <stdlib.h> 5#include <string.h> 6#include <assert.h> 7#include <signal.h> 8 9void maybe_fault ( int delta ) 10{ 11 char* x = memalign16(32); 12 memset(x, 0, 32); 13 __asm__ __volatile__( 14 "pabsb (%0),%%xmm7" 15 : /*out*/ : /*in*/ "r"(x+delta) : /*trash*/"xmm7" ); 16 free(x); 17} 18 19void handler ( int signo ) 20{ 21 assert(signo == SIGSEGV); 22 fprintf(stderr, "three\n"); 23 exit(0); 24} 25 26int main ( void ) 27{ 28 signal(SIGSEGV, handler); 29 fprintf(stderr, "you should see: \"one\\ntwo\\nthree\\n\"\n"); 30 fprintf(stderr, "one\n"); 31 maybe_fault(0); 32 fprintf(stderr, "two\n"); 33 maybe_fault(5); 34 fprintf(stderr, "test failed! you shouldn't see this\n"); 35 return 0; 36} 37