aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/avr/torture/isr-01-simple.c
blob: 271d0cf47e954656d2d4822cfdc942e46f09bccf (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* { dg-do run } */
/* { dg-options "-std=c99" } */

#include "../isr-test.h"

int volatile v;

/**********************************************************************/

ISR (1, signal)
{
}

MK_RUN_ISR (1, 0)

void test1 (void)
{
  run_isr_1();
}

/**********************************************************************/

ISR (2, signal)
{
  v++;
}

MK_RUN_ISR (2, 0)

void test2 (void)
{
  v = 0;
  run_isr_2();
  if (v != 1)
    __builtin_abort();
}


/**********************************************************************/

ISR (3, signal)
{
  __asm __volatile__ ("$ lds  r27, v"
                      "$ swap r27"
                      "$ sts  v, r27"
                      ::: "memory", "r27");
}

MK_RUN_ISR (3, 0)

void test3 (void)
{
  run_isr_3();
  if (v != 0x10)
    __builtin_abort();
}

/**********************************************************************/

ISR (4, signal)
{
  __asm __volatile__ ("sts v,__zero_reg__" ::: "memory");
}

MK_RUN_ISR (4, 0)

void test4 (void)
{
  run_isr_4();
  if (v != 0)
    __builtin_abort();
}

/**********************************************************************/

ISR (5, signal)
{
  __asm __volatile__ ("clt");
}

MK_RUN_ISR (5, 0)

void test5 (void)
{
  run_isr_5();
}

/**********************************************************************/

int main (void)
{
  test1();
  test2();
  test3();
  test4();
  test5();
  return 0;
}