Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'mc' into mc++
[simgrid.git] / buildtools / Cmake / test_prog / prog_stackgrowth.c
1 /* Copyright (c) 2010, 2014. 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 static int iterate = 10;
10 static int growsdown(int *x)
11 {
12   auto int y;
13   y = (x > &y);
14   if (--iterate > 0)
15     y = growsdown(&y);
16   if (y != (x > &y))
17     exit(1);
18   return y;
19 }
20
21 int main(int argc, char *argv[])
22 {
23   FILE *f;
24   auto int x;
25   if ((f = fopen("conftestval", "w")) == NULL)
26     exit(1);
27   fprintf(f, "%s\n", growsdown(&x) ? "down" : "up");;
28   fclose(f);
29   exit(0);
30   return 1;
31 }