From 7f6f38735411f44357208a952278a419454b52b2 Mon Sep 17 00:00:00 2001
From: Brian Norris <banorris@uci.edu>
Date: Wed, 3 Oct 2012 15:26:52 -0700
Subject: [PATCH] fixup usage of int vs. thread_id_t

---
 datarace.cc   |  4 ++--
 libthreads.cc |  2 +-
 model.cc      | 11 ++++++-----
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/datarace.cc b/datarace.cc
index d6e0875..f5501fe 100644
--- a/datarace.cc
+++ b/datarace.cc
@@ -123,8 +123,8 @@ bool checkDataRaces() {
 void printRace(struct DataRace * race) {
 	printf("Datarace detected\n");
 	printf("Location %p\n", race->address);
-	printf("Initial access: thread %u clock %u, iswrite %u\n",race->oldthread,race->oldclock, race->isoldwrite);
-	printf("Second access: thread %u clock %u, iswrite %u\n", race->newaction->get_tid(), race->newaction->get_seq_number() , race->isnewwrite);
+	printf("Initial access: thread %u clock %u, iswrite %u\n", id_to_int(race->oldthread), race->oldclock, race->isoldwrite);
+	printf("Second access: thread %u clock %u, iswrite %u\n", id_to_int(race->newaction->get_tid()), race->newaction->get_seq_number(), race->isnewwrite);
 }
 
 /** This function does race detection for a write on an expanded record. */
diff --git a/libthreads.cc b/libthreads.cc
index 4d6a024..f973176 100644
--- a/libthreads.cc
+++ b/libthreads.cc
@@ -23,7 +23,7 @@ int thrd_create(thrd_t *t, thrd_start_t start_routine, void *arg)
 int thrd_join(thrd_t t)
 {
 	Thread *th = model->get_thread(thrd_to_id(t));
-	model->switch_to_master(new ModelAction(THREAD_JOIN, std::memory_order_seq_cst, th, thrd_to_id(t)));
+	model->switch_to_master(new ModelAction(THREAD_JOIN, std::memory_order_seq_cst, th, id_to_int(thrd_to_id(t))));
 	return 0;
 }
 
diff --git a/model.cc b/model.cc
index 8d8944d..788a670 100644
--- a/model.cc
+++ b/model.cc
@@ -178,7 +178,7 @@ Thread * ModelChecker::get_next_thread(ModelAction *curr)
 	} else {
 		tid = next->get_tid();
 	}
-	DEBUG("*** ModelChecker chose next thread = %d ***\n", tid);
+	DEBUG("*** ModelChecker chose next thread = %d ***\n", id_to_int(tid));
 	ASSERT(tid != THREAD_ID_T_NONE);
 	return thread_map->get(id_to_int(tid));
 }
@@ -324,7 +324,8 @@ void ModelChecker::set_backtracking(ModelAction *act)
 		if (!node->set_backtrack(tid))
 			continue;
 		DEBUG("Setting backtrack: conflict = %d, instead tid = %d\n",
-					prev->get_tid(), t->get_id());
+					id_to_int(prev->get_tid()),
+					id_to_int(t->get_id()));
 		if (DBG_ENABLED()) {
 			prev->print();
 			act->print();
@@ -794,8 +795,7 @@ bool ModelChecker::isfinalfeasible() {
 
 /** Close out a RMWR by converting previous RMWR into a RMW or READ. */
 ModelAction * ModelChecker::process_rmw(ModelAction *act) {
-	int tid = id_to_int(act->get_tid());
-	ModelAction *lastread = get_last_action(tid);
+	ModelAction *lastread = get_last_action(act->get_tid());
 	lastread->process_rmw(act);
 	if (act->is_rmw() && lastread->get_reads_from()!=NULL) {
 		mo_graph->addRMWEdge(lastread->get_reads_from(), lastread);
@@ -1776,7 +1776,8 @@ bool ModelChecker::take_step() {
 	if (!isfeasible())
 		return false;
 
-	DEBUG("(%d, %d)\n", curr ? curr->get_id() : -1, next ? next->get_id() : -1);
+	DEBUG("(%d, %d)\n", curr ? id_to_int(curr->get_id()) : -1,
+			next ? id_to_int(next->get_id()) : -1);
 
 	/* next == NULL -> don't take any more steps */
 	if (!next)
-- 
2.34.1