OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [pr42231.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
extern void abort (void);
2
 
3
static max;
4
 
5
static void __attribute__((noinline)) storemax (int i)
6
{
7
  if (i > max)
8
    max = i;
9
}
10
 
11
static int CallFunctionRec(int (*fun)(int depth), int depth) {
12
  if (!fun(depth)) {
13
    return 0;
14
  }
15
  if (depth < 10) {
16
    CallFunctionRec(fun, depth + 1);
17
  }
18
  return 1;
19
}
20
 
21
static int CallFunction(int (*fun)(int depth)) {
22
  return CallFunctionRec(fun, 1) && !fun(0);
23
}
24
 
25
static int callback(int depth) {
26
  storemax (depth);
27
  return depth != 0;
28
}
29
 
30
int main() {
31
  CallFunction(callback);
32
  if (max != 10)
33
    abort ();
34
  return 0;
35
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.