Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c1a9e7804f80fafe125ed675332de67853f7fe7f
[simgrid.git] / buildtools / Cmake / test_prog / prog_stackgrowth.c
1 /* Copyright (c) 2010. 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 int main(int argc, char *argv[])
21 {
22     FILE *f;
23     auto int x;
24     if ((f = fopen("conftestval", "w")) == NULL)
25         exit(1);
26     fprintf(f, "%s\n", growsdown(&x) ? "down" : "up");;
27     fclose(f);
28     exit(0);
29         return 1;
30 }