From 4b8d6554374b0acfd016ea89992b0d2f8e7986bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Manuel=20de=20Morais=20Santos=20Costa?= Date: Thu, 28 Jan 2010 15:44:31 +0000 Subject: [PATCH] cut cps are different from everyone else? --- OPTYap/opt.structs.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/OPTYap/opt.structs.h b/OPTYap/opt.structs.h index 583b9a725..3bba5f66d 100644 --- a/OPTYap/opt.structs.h +++ b/OPTYap/opt.structs.h @@ -22,14 +22,29 @@ typedef unsigned long bitmap; static inline choiceptr offset_to_cptr(Int node) { - return (choiceptr)(LCL0-node); + return (choiceptr)(LCL0+node); } static inline Int cptr_to_offset(choiceptr node) { - return (Int)(LCL0-(CELL *)node); + return (Int)((CELL *)node-LCL0); } + +static inline choiceptr +offset_to_cptr_with_null(Int node) +{ + if (node == 0L) return NULL; + return (choiceptr)(LCL0+node); +} + +static inline Int +cptr_to_offset_with_null(choiceptr node) +{ + if (node == NULL) return 0L; + return (Int)((CELL *)node-LCL0); +} + #endif /* ---------------------------- ** @@ -327,7 +342,7 @@ struct local_data{ #if THREADS Int prune_request_offset; #else - choiceptr prune_request_offset; + choiceptr prune_request; #endif volatile int share_request; struct local_signals share_signals; @@ -370,8 +385,8 @@ extern struct local_data *LOCAL; #endif #define LOCAL_top_or_fr (LOCAL->top_or_frame) #if THREADS -#define Get_LOCAL_prune_request() offset_to_cptr(LOCAL->prune_request_offset) -#define Set_LOCAL_prune_request(cpt) (LOCAL->prune_request_offset = cptr_to_offset(cpt)) +#define Get_LOCAL_prune_request() offset_to_cptr_with_null(LOCAL->prune_request_offset) +#define Set_LOCAL_prune_request(cpt) (LOCAL->prune_request_offset = cptr_to_offset_with_null(cpt)) #else #define LOCAL_prune_request (LOCAL->prune_request) #define Get_LOCAL_prune_request() (LOCAL->prune_request) @@ -413,8 +428,8 @@ extern struct local_data *LOCAL; #endif #define REMOTE_top_or_fr(worker) (REMOTE[worker].top_or_frame) #if THREADS -#define Get_REMOTE_prune_request(worker) offset_to_cptr(REMOTE[worker].prune_request_offset) -#define Set_REMOTE_prune_request(worker,cp) (REMOTE[worker].prune_request_offset = cptr_to_offset(cp)) +#define Get_REMOTE_prune_request(worker) offset_to_cptr_with_null(REMOTE[worker].prune_request_offset) +#define Set_REMOTE_prune_request(worker,cp) (REMOTE[worker].prune_request_offset = cptr_to_offset_with_null(cp)) #else #define REMOTE_prune_request(worker) (REMOTE[worker].prune_request) #define Get_REMOTE_prune_request(worker) (REMOTE[worker].prune_request)