-
- makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper,
- sizeof(void*)/sizeof(int), context);
+ ctx_addr = (uintptr_t)context;
+ /* This switch select a case base on a static value: the compiler optimizes it out */
+ /* It could be replaced by a set of #ifdef/#else/#endif blocks */
+ switch(sizeof(uintptr_t) / sizeof(int)) {
+ case 1:
+ makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper,
+ 2, 1, (int)ctx_addr);
+ break;
+ case 2:
+ makecontext(&((smx_ctx_sysv_t) context)->uc, (void (*)())smx_ctx_sysv_wrapper,
+ 3, 2, (int)(ctx_addr >> (8 * sizeof(int))), (int)(ctx_addr));
+ break;
+ default:
+ THROW_IMPOSSIBLE;
+ }