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[])
39 char *skbuf = (char *) malloc(sksize * 2 + 2 * sizeof(union alltypes));
42 for (int i = 0; i < sksize * 2 + 2 * sizeof(union alltypes); i++)
44 char *skaddr = skbuf + sizeof(union alltypes);
46 if (getcontext(&uc_handler) != 0)
48 uc_handler.uc_link = NULL;
49 uc_handler.uc_stack.ss_sp = (void *) (skaddr + sksize);
50 uc_handler.uc_stack.ss_size = sksize;
51 uc_handler.uc_stack.ss_flags = 0;
52 makecontext(&uc_handler, handler, 0);
53 swapcontext(&uc_main, &uc_handler);
55 if (handler_addr == (char *) 0xDEAD)
57 if (handler_addr < skaddr + sksize) {
58 /* stack was placed into lower area */
59 if (*(skaddr + sksize) != 'A')
60 printf("(skaddr)+(sksize)-%d;(sksize)-%d", sizeof(union alltypes), sizeof(union alltypes));
62 printf("(skaddr)+(sksize);(sksize)");
64 /* stack was placed into higher area */
65 if (*(skaddr + sksize * 2) != 'A')
66 printf("(skaddr);(sksize)-%d", sizeof(union alltypes));
68 printf("(skaddr);(sksize)");