From: Brian Norris Date: Tue, 16 Apr 2013 16:46:58 +0000 (-0700) Subject: action: bugfix - use non-zero fence "location" X-Git-Url: http://plrg.eecs.uci.edu/git/?p=cdsspec-compiler.git;a=commitdiff_plain;h=b5d7d602016a4640c31b79ba9598dceefa778ab6 action: bugfix - use non-zero fence "location" Our HashTable does not support zero-based keys (e.g., NULL pointer as a key). So as a hack, switch to use a small, arbitrary, non-zero location instead of NULL (0). --- diff --git a/action.h b/action.h index dc56017..ad34c83 100644 --- a/action.h +++ b/action.h @@ -37,6 +37,15 @@ using std::memory_order_seq_cst; */ #define VALUE_NONE 0xdeadbeef +/** + * @brief The "location" at which a fence occurs + * + * We need a non-zero memory location to associate with fences, since our hash + * tables don't handle NULL-pointer keys. HACK: Hopefully this doesn't collide + * with any legitimate memory locations. + */ +#define FENCE_LOCATION ((void *)0x7) + /** @brief Represents an action type, identifying one of several types of * ModelAction */ typedef enum action_type { diff --git a/cmodelint.cc b/cmodelint.cc index 47aef05..1632581 100644 --- a/cmodelint.cc +++ b/cmodelint.cc @@ -39,5 +39,5 @@ void model_rmwc_action(void *obj, memory_order ord) { /** Issues a fence operation. */ void model_fence_action(memory_order ord) { - model->switch_to_master(new ModelAction(ATOMIC_FENCE, ord, NULL)); + model->switch_to_master(new ModelAction(ATOMIC_FENCE, ord, FENCE_LOCATION)); } diff --git a/execution.cc b/execution.cc index 8b50771..17ea954 100644 --- a/execution.cc +++ b/execution.cc @@ -2215,8 +2215,8 @@ ModelAction * ModelExecution::get_last_seq_cst_write(ModelAction *curr) const */ ModelAction * ModelExecution::get_last_seq_cst_fence(thread_id_t tid, const ModelAction *before_fence) const { - /* All fences should have NULL location */ - action_list_t *list = get_safe_ptr_action(obj_map, NULL); + /* All fences should have location FENCE_LOCATION */ + action_list_t *list = get_safe_ptr_action(obj_map, FENCE_LOCATION); action_list_t::reverse_iterator rit = list->rbegin(); if (before_fence) {