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 extern void exit (int);
6 
7 typedef unsigned int uword_t __attribute__ ((mode (__word__)));
8 
9 #define ERROR		0x12345670
10 #define IP		0x12345671
11 #define CS		0x12345672
12 #define FLAGS		0x12345673
13 #define SP		0x12345674
14 #define SS		0x12345675
15 
16 #define STRING(x)	XSTRING(x)
17 #define XSTRING(x)	#x
18 #define ASMNAME(cname)  ASMNAME2 (__USER_LABEL_PREFIX__, cname)
19 #define ASMNAME2(prefix, cname) XSTRING (prefix) cname
20 
21 struct interrupt_frame
22 {
23   uword_t ip;
24   uword_t cs;
25   uword_t flags;
26   uword_t sp;
27   uword_t ss;
28 };
29 
30 __attribute__((interrupt, used))
31 void
fn(struct interrupt_frame * frame,uword_t error)32 fn (struct interrupt_frame *frame, uword_t error)
33 {
34   if (ERROR != error)
35     __builtin_abort ();
36   if (IP != frame->ip)
37     __builtin_abort ();
38   if (CS != frame->cs)
39     __builtin_abort ();
40   if (FLAGS != frame->flags)
41     __builtin_abort ();
42   if (SP != frame->sp)
43     __builtin_abort ();
44   if (SS != frame->ss)
45     __builtin_abort ();
46 
47   exit (0);
48 }
49 
50 int
main()51 main ()
52 {
53   asm ("push	$" STRING (SS) ";		\
54 	push	$" STRING (SP) ";		\
55 	push	$" STRING (FLAGS) ";		\
56 	push	$" STRING (CS) ";		\
57 	push	$" STRING (IP) ";		\
58 	push	$" STRING (ERROR) ";		\
59 	jmp	 " ASMNAME ("fn"));
60   return 0;
61 }
62