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. */
11 #include "win32_ucontext.h"
12 #include "win32_ucontext.c"
26 if (swapcontext(&uc_child, &uc_main) != 0)
30 int main(int argc, char *argv[])
35 /* the default is that it fails */
36 if ((fp = fopen("conftestval", "w")) == NULL)
41 /* configure a child user-space context */
42 if ((stack = malloc(64 * 1024)) == NULL)
44 if (getcontext(&uc_child) != 0)
46 uc_child.uc_link = NULL;
47 uc_child.uc_stack.ss_sp = (char *) stack + (32 * 1024);
48 uc_child.uc_stack.ss_size = 32 * 1024;
49 uc_child.uc_stack.ss_flags = 0;
50 makecontext(&uc_child, child, 0);
52 /* switch into the user context */
53 if (swapcontext(&uc_main, &uc_child) != 0)
56 /* Fine, child came home */
57 if ((fp = fopen("conftestval", "w")) == NULL)
62 /* die successfully */