1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
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. */
20 if (swapcontext(&uc_child, &uc_main) != 0)
24 int main(int argc, char *argv[])
29 /* the default is that it fails */
30 if ((fp = fopen("conftestval", "w")) == NULL)
35 /* configure a child user-space context */
36 if ((stack = malloc(64*1024)) == NULL)
38 if (getcontext(&uc_child) != 0)
40 uc_child.uc_link = NULL;
41 uc_child.uc_stack.ss_sp = (char *)stack+(32*1024);
42 uc_child.uc_stack.ss_size = 32*1024;
43 uc_child.uc_stack.ss_flags = 0;
44 makecontext(&uc_child, child, 0);
46 /* switch into the user context */
47 if (swapcontext(&uc_main, &uc_child) != 0)
50 /* Fine, child came home */
51 if ((fp = fopen("conftestval", "w")) == NULL)
56 /* die successfully */