+ /* If the user provided a function for the process then use it
+ otherwise is the context for maestro */
+ if (code) {
+
+ xbt_assert2(getcontext(&(context->uc)) == 0,
+ "Error in context saving: %d (%s)", errno,
+ strerror(errno));
+
+ context->uc.uc_link = NULL;
+
+ context->uc.uc_stack.ss_sp =
+ pth_skaddr_makecontext(context->stack, CONTEXT_STACK_SIZE);
+
+ context->uc.uc_stack.ss_size =
+ pth_sksize_makecontext(context->stack, CONTEXT_STACK_SIZE);
+
+#ifdef HAVE_VALGRIND_VALGRIND_H
+ context->valgrind_stack_id =
+ VALGRIND_STACK_REGISTER(context->uc.uc_stack.ss_sp,
+ ((char *) context->uc.uc_stack.ss_sp) +
+ context->uc.uc_stack.ss_size);
+#endif /* HAVE_VALGRIND_VALGRIND_H */
+
+ makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper,
+ sizeof(void*)/sizeof(int), context);
+ }else{
+ maestro_context = context;
+ }
+
+ return (smx_context_t) context;