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