action: bugfix - use non-zero fence "location"
authorBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 16:46:58 +0000 (09:46 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 18:38:01 +0000 (11:38 -0700)
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).

action.h
cmodelint.cc
execution.cc

index dc560174bee561ca9f32fcec2d11d358ab040782..ad34c830f4b61d0b2a214199c5d208aa5abddca2 100644 (file)
--- a/action.h
+++ b/action.h
@@ -37,6 +37,15 @@ using std::memory_order_seq_cst;
  */
 #define VALUE_NONE 0xdeadbeef
 
  */
 #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 {
 /** @brief Represents an action type, identifying one of several types of
  * ModelAction */
 typedef enum action_type {
index 47aef05f28a1c61e72101e171e59da02354c5f09..1632581101e0c5801f8ba14c05d3d12e1fa4c94c 100644 (file)
@@ -39,5 +39,5 @@ void model_rmwc_action(void *obj, memory_order ord) {
 
 /** Issues a fence operation. */
 void model_fence_action(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));
 }
 }
index 8b507718ee2d3579b7bab555d7c424b6d2a4083b..17ea954a65570160ffccd1a42f247c95956b8fa2 100644 (file)
@@ -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
 {
  */
 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) {
        action_list_t::reverse_iterator rit = list->rbegin();
 
        if (before_fence) {