File: sparc-getcontext-1.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A8-2019-q3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 571,828 kB
  • sloc: ansic: 2,937,651; cpp: 881,644; ada: 597,189; makefile: 65,528; asm: 56,499; xml: 46,621; exp: 24,747; sh: 19,684; python: 7,256; pascal: 4,370; awk: 3,497; perl: 2,695; yacc: 316; ml: 285; f90: 234; lex: 198; objc: 194; haskell: 119
file content (118 lines) | stat: -rw-r--r-- 2,004 bytes parent folder | download | duplicates (10)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* PR middle-end/22127 */
/* Testcase by <akr@m17n.org> */

/* { dg-do run { target *-*-solaris2.* } } */
/* { dg-require-effective-target ilp32 } */
/* { dg-options "-O" } */

typedef unsigned int size_t;
extern int printf(const char *, ...);
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned int uint_t;
typedef char *caddr_t;
typedef int greg_t;
typedef greg_t gregset_t[19];
struct rwindow {
 greg_t rw_local[8];
 greg_t rw_in[8];
};
typedef struct gwindows {
 int wbcnt;
 greg_t *spbuf[31];
 struct rwindow wbuf[31];
} gwindows_t;
struct fpu {
 union {
  uint32_t fpu_regs[32];
  double fpu_dregs[16];
 } fpu_fr;
 struct fq *fpu_q;
 uint32_t fpu_fsr;
 uint8_t fpu_qcnt;
 uint8_t fpu_q_entrysize;
 uint8_t fpu_en;
};
typedef struct fpu fpregset_t;
typedef struct {
 unsigned int xrs_id;
 caddr_t xrs_ptr;
} xrs_t;
typedef struct {
 gregset_t gregs;
 gwindows_t *gwins;
 fpregset_t fpregs;
 xrs_t xrs;
 long filler[19];
} mcontext_t;
typedef struct {
 unsigned int __sigbits[4];
} sigset_t;
typedef struct sigaltstack {
 void *ss_sp;
 size_t ss_size;
 int ss_flags;
} stack_t;
typedef struct ucontext ucontext_t;
struct ucontext {
 uint_t uc_flags;
 ucontext_t *uc_link;
 sigset_t uc_sigmask;
 stack_t uc_stack;
 mcontext_t uc_mcontext;
 long uc_filler[23];
};
extern int getcontext(ucontext_t *);
extern int setcontext(const ucontext_t *);

int flag;
ucontext_t cont;
int pad[100];
typedef void (*fun_t)(int);
fun_t p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12;

int global;

extern void abort(void);

void h1(int v)
{
  global = v;
}

void h2(int v)
{
  if (v != 1)
    abort();
}

void f(void)
{
  flag = 1;
  setcontext(&cont);
}

int g(void)
{
  int ret;

  flag = 0;
  getcontext(&cont);
  ret = flag;
  if (ret == 0) {
    h1 (flag);
    p0 = p1 = p2 = p3 = p4 = p5 = p6 = p7 = p8 = h1;
    f();
    p0(ret); p1(ret); p2(ret); p3(ret); p4(ret); p5(ret); p6(ret); p7(ret); p8(ret);
  }
  else {
    h2 (flag);
  }
  return ret;
}

int main(void)
{
  g();
  return 0;
}