minor code change for portability
This commit is contained in:
parent
c2d6ce0f8a
commit
92c4376498
24
ctx.c
24
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user