1 /* Copyright (c) 2010, 2014-2016. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #define _XOPEN_SOURCE 700
22 static volatile char *handler_addr = (char *) 0xDEAD;
23 static ucontext_t uc_handler;
24 static ucontext_t uc_main;
29 for (int i = 0; i < 1024; i++)
31 handler_addr = (char *) &dummy;
32 swapcontext(&uc_handler, &uc_main);
36 int main(int argc, char *argv[])
41 char *skbuf = (char *) malloc(sksize * 2 + 2 * sizeof(union alltypes));
44 for (int i = 0; i < sksize * 2 + 2 * sizeof(union alltypes); i++)
46 char *skaddr = skbuf + sizeof(union alltypes);
48 if (getcontext(&uc_handler) != 0)
50 uc_handler.uc_link = NULL;
51 uc_handler.uc_stack.ss_sp = (void *) (skaddr + sksize);
52 uc_handler.uc_stack.ss_size = sksize;
53 uc_handler.uc_stack.ss_flags = 0;
54 makecontext(&uc_handler, handler, 0);
55 swapcontext(&uc_main, &uc_handler);
57 if (handler_addr == (char *) 0xDEAD)
59 if (handler_addr < skaddr + sksize) {
60 /* stack was placed into lower area */
61 if (*(skaddr + sksize) != 'A')
62 sprintf(result, "(skaddr)+(sksize)-%d,(sksize)-%d", sizeof(union alltypes), sizeof(union alltypes));
64 strcpy(result, "(skaddr)+(sksize),(sksize)");
66 /* stack was placed into higher area */
67 if (*(skaddr + sksize * 2) != 'A')
68 sprintf(result, "(skaddr),(sksize)-%d", sizeof(union alltypes));
70 strcpy(result, "(skaddr),(sksize)");
72 if ((f = fopen("conftestval", "w")) == NULL)
74 fprintf(f, "%s\n", result);