1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */ 2 /* { dg-skip-if "PR81210 sp not aligned to 16 bytes" { *-*-darwin* } } */ 3 /* { dg-options "-mgeneral-regs-only" } */ 4 5 #include <stddef.h> 6 7 extern void exit (int); 8 9 typedef unsigned int uword_t __attribute__ ((mode (__word__))); 10 typedef int aligned __attribute__((aligned(64))); 11 12 #define IP 0x12345671 13 #define CS 0x12345672 14 #define FLAGS 0x12345673 15 #define SP 0x12345674 16 #define SS 0x12345675 17 18 #define STRING(x) XSTRING(x) 19 #define XSTRING(x) #x 20 #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname) 21 #define ASMNAME2(prefix, cname) XSTRING (prefix) cname 22 23 struct interrupt_frame 24 { 25 uword_t ip; 26 uword_t cs; 27 uword_t flags; 28 uword_t sp; 29 uword_t ss; 30 }; 31 32 int check_int(int * i,int align)33check_int (int *i, int align) 34 { 35 *i = 20; 36 if ((((ptrdiff_t) i) & (align - 1)) != 0) 37 __builtin_abort (); 38 return *i; 39 } 40 41 __attribute__((interrupt, used)) 42 void fn(struct interrupt_frame * frame)43fn (struct interrupt_frame *frame) 44 { 45 aligned i; 46 if (check_int (&i, __alignof__(i)) != i) 47 __builtin_abort (); 48 49 if (IP != frame->ip) 50 __builtin_abort (); 51 if (CS != frame->cs) 52 __builtin_abort (); 53 if (FLAGS != frame->flags) 54 __builtin_abort (); 55 if (SP != frame->sp) 56 __builtin_abort (); 57 if (SS != frame->ss) 58 __builtin_abort (); 59 60 exit (0); 61 } 62 63 int main()64main () 65 { 66 asm ("push $" STRING (SS) "; \ 67 push $" STRING (SP) "; \ 68 push $" STRING (FLAGS) "; \ 69 push $" STRING (CS) "; \ 70 push $" STRING (IP) "; \ 71 jmp " ASMNAME ("fn")); 72 return 0; 73 } 74