From 92c4376498f6356e8a718a6de6fc3650082e03a7 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 5 May 2025 17:43:06 +0000 Subject: [PATCH] minor code change for portability --- ctx.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ctx.c b/ctx.c index f7e9800..12ce311 100644 --- a/ctx.c +++ b/ctx.c @@ -31,11 +31,19 @@ typedef signed short hip_int16_t; typedef signed int hip_int32_t; typedef signed long long hip_int64_t; -typedef hip_uint64_t hip_oow_t; -typedef hip_int64_t hip_ooi_t; typedef hip_uint64_t hip_nsecdur_t; +#if defined(__ILP32__) || defined(_WIN32) +# define MKCTX_NARGS 1 +typedef hip_uint32_t hip_oow_t; +typedef hip_int32_t hip_ooi_t; +#else +# define MKCTX_NARGS 2 +typedef hip_uint64_t hip_oow_t; +typedef hip_int64_t hip_ooi_t; +#endif + #define HIP_NULL ((void*)0) #define HIP_INVALID_FD (-1) @@ -129,12 +137,20 @@ struct hip_t /* ---------------------------------------------------- */ +#if (MKCTX_NARGS <= 1) +static void invoke_uf(unsigned int a) +#else static void invoke_uf(unsigned int a, unsigned int b) +#endif { hip_t* hip; hip_uctx_t* uctx; +#if (MKCTX_NARGS <= 1) + uctx = (hip_uctx_t*)(hip_oow_t)a; +#else uctx = (hip_uctx_t*)(((hip_oow_t)a << 32) | (hip_oow_t)b); +#endif uctx->uf(uctx, uctx->ctx); printf ("invoke_uf XXXXXXXXXXXXXXXXXXXXX...%p\n", uctx); @@ -197,7 +213,11 @@ hip_uctx_t* hip_uctx_open(hip_t* hip, hip_oow_t stack_size, hip_ufun_t uf, void* uc->uc.uc_stack.ss_size = stack_size; uc->uc.uc_stack.ss_flags = 0; uc->uc.uc_link = HIP_NULL; + #if (MKCTX_NARGS <= 1) + makecontext(&uc->uc, (void(*)(void))invoke_uf, 1, uc); + #else makecontext(&uc->uc, (void(*)(void))invoke_uf, 2, (unsigned int)((hip_oow_t)uc >> 32), (unsigned int)((hip_oow_t)uc & 0xFFFFFFFFu)); + #endif } printf("NEW UCTX %p\n", uc);