-#endif /* HAVE_VALGRIND_VALGRIND_H */
-
-XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smx_context);
-
-typedef struct s_smx_ctx_sysv {
- SMX_CTX_BASE_T;
- ucontext_t uc; /* the thread that execute the code */
- char stack[STACK_SIZE]; /* the thread stack size */
- struct s_smx_ctx_sysv *prev; /* the previous process */
-#ifdef HAVE_VALGRIND_VALGRIND_H
- unsigned int valgrind_stack_id; /* the valgrind stack id */
-#endif
-} s_smx_ctx_sysv_t, *smx_ctx_sysv_t;
-
-
-/* callback: context fetching */
-static ex_ctx_t *xbt_jcontext_ex_ctx(void);
-
-/* callback: termination */
-static void xbt_jcontext_ex_terminate(xbt_ex_t *e);
-
-static smx_context_t smx_ctx_sysv_factory_create_context(xbt_main_func_t code);
-
-static int smx_ctx_sysv_factory_finalize(smx_context_factory_t *factory);
-
-static smx_context_t smx_ctx_sysv_factory_create_maestro_context(void);
-
-static void smx_ctx_sysv_free(smx_context_t context);
-
-static void smx_ctx_sysv_start(smx_context_t context);
-
-static void smx_ctx_sysv_stop(int exit_code);
-
-static void smx_ctx_sysv_suspend(smx_context_t context);
-
-static void smx_ctx_sysv_resume(smx_context_t old_context,
- smx_context_t new_context);
-
-static void smx_ctx_sysv_wrapper(void);
-
-/* callback: context fetching */
-static ex_ctx_t *xbt_ctx_sysv_ex_ctx(void)
-{
- return simix_global->current_process->context->exception;
-}
-
-/* callback: termination */
-static void xbt_ctx_sysv_ex_terminate(xbt_ex_t * e)
-{
- xbt_ex_display(e);
- abort();
-}
+#endif /* HAVE_VALGRIND_VALGRIND_H */
+
+#ifdef _XBT_WIN32
+#include "win32_ucontext.h"
+#include "win32_ucontext.c"
+#else
+#include "ucontext.h"
+#endif
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_context);
+
+#ifdef CONTEXT_THREADS
+static xbt_parmap_t parmap;
+#endif
+
+static smx_context_t
+smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv,
+ void_pfn_smxprocess_t cleanup_func, void* data);
+
+static void smx_ctx_sysv_wrapper(int count, ...);
+
+/* This is a bit paranoid about SIZEOF_VOIDP not being a multiple of SIZEOF_INT,
+ * but it doesn't harm. */
+#define CTX_ADDR_LEN (SIZEOF_VOIDP / SIZEOF_INT + !!(SIZEOF_VOIDP % SIZEOF_INT))
+union u_ctx_addr {
+ void *addr;
+ int intv[CTX_ADDR_LEN];
+};
+#if (CTX_ADDR_LEN == 1)
+# define CTX_ADDR_SPLIT(u) (u).intv[0]
+#elif (CTX_ADDR_LEN == 2)
+# define CTX_ADDR_SPLIT(u) (u).intv[0], (u).intv[1]
+#else
+# error Your architecture is not supported yet
+#endif