Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move the cmake files in tools/cmake
[simgrid.git] / tools / cmake / test_prog / prog_stackgrowth.c
1 /* Copyright (c) 2010, 2014-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 static int iterate = 10;
11 static int growsdown(int *x)
12 {
13   int y;
14   y = (x > &y);
15   if (--iterate > 0)
16     y = growsdown(&y);
17   if (y != (x > &y))
18     exit(1);
19   return y;
20 }
21
22 int main(int argc, char *argv[])
23 {
24   int x;
25   printf("%s", growsdown(&x) ? "down" : "up");
26   exit(0);
27   return 1;
28 }