summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/interrupt-23.c
blob: c42049c1280d093219eabe1103f835182ca90575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* { dg-do compile { target ia32 } } */
/* { dg-options "-O2 -mno-mpx -mno-sse -mno-mmx -mno-80387 -mno-cld -miamcu -maccumulate-outgoing-args" } */

struct interrupt_frame;

extern void callback0 (unsigned int id, unsigned int len)
  __attribute__((no_caller_saved_registers));
extern void callback1 (unsigned int id, unsigned int len)
  __attribute__((no_caller_saved_registers));
extern void callback2 (unsigned int id, unsigned int len)
  __attribute__((no_caller_saved_registers));

typedef void (*callback_t) (unsigned int id, unsigned int len)
  __attribute__((no_caller_saved_registers));

callback_t callback[] =
{
  callback0,
  callback1,
  callback2,
};

unsigned int remaining;

void
__attribute__((no_caller_saved_registers))
handler(int uart)
{
  while (1) {
    if (remaining) {
      callback[uart](0, 0);
      break;
    }
  }
}

int uart;

void
__attribute__((interrupt))
my_isr(struct interrupt_frame *frame)
{
  handler(uart);
}

/* { dg-final { scan-assembler-times "\tcld" 1 } } */