- 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 */
- ctx_addr = (uintptr_t)context;
- makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper,
- SIZEOF_VOIDP / SIZEOF_INT + 1, SIZEOF_VOIDP / SIZEOF_INT,
-#if (SIZEOF_VOIDP == SIZEOF_INT)
- (int)ctx_addr
-#elif (SIZEOF_VOIDP == 2 * SIZEOF_INT)
- (int)(ctx_addr >> (8 * sizeof(int))),
- (int)(ctx_addr)
-#else
-#error Your architecture is not supported yet
-#endif
- );
- }else{
- maestro_context = context;
+ pth_sksize_makecontext(context->stack, smx_context_usable_stack_size);
+
+ memcpy(ctx_addr, &context, sizeof(smx_ctx_sysv_t));
+ switch (CTX_ADDR_LEN) {
+ case 1:
+ makecontext(&context->uc, (void (*)())smx_ctx_sysv_wrapper,
+ 1, ctx_addr[0]);
+ break;
+ case 2:
+ makecontext(&context->uc, (void (*)())smx_ctx_sysv_wrapper,
+ 2, ctx_addr[0], ctx_addr[1]);
+ break;
+ default:
+ xbt_die("Ucontexts are not supported on this arch yet (addr len = %zu/%zu = %zu)",
+ sizeof(smx_ctx_sysv_t), sizeof(int), CTX_ADDR_LEN);
+ }
+ } else {
+ if (process != NULL && sysv_maestro_context == NULL)
+ sysv_maestro_context = context;