threads: add id_to_int() and int_to_id() inline functions
authorBrian Norris <banorris@uci.edu>
Tue, 1 May 2012 20:08:35 +0000 (13:08 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 1 May 2012 20:11:30 +0000 (13:11 -0700)
libthreads.cc
model.cc
threads.h

index 7dd043c317c715e0604b3cdecf61d210c6bf9742..73a948cc4a493a7fa4b3c1bea65af8653c6ebc17 100644 (file)
@@ -13,7 +13,7 @@ int thrd_create(thrd_t *t, void (*start_routine)(), void *arg)
        int ret;
        DBG();
        ret = model->add_thread(new Thread(t, start_routine, arg));
-       DEBUG("create thread %d\n", thrd_to_id(*t));
+       DEBUG("create thread %d\n", id_to_int(thrd_to_id(*t)));
        return ret;
 }
 
index 3cc536b61cd357d4a329852930aaecdb0100575c..04a8773d2fc121b82303a2a4465a7767c52edbb6 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -331,5 +331,5 @@ void ModelAction::print(void)
                type_str = "unknown type";
        }
 
-       printf("Thread: %d\tAction: %s\tMO: %d\tLoc: %#014zx\tValue: %d\n", tid, type_str, order, (size_t)location, value);
+       printf("Thread: %d\tAction: %s\tMO: %d\tLoc: %#014zx\tValue: %d\n", id_to_int(tid), type_str, order, (size_t)location, value);
 }
index 69bd115c4a88243657ce8f92088962f97249dccb..7a21a30d8d93f49e4e0c13d37dfeb18f21260b47 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -48,4 +48,14 @@ static inline thread_id_t thrd_to_id(thrd_t t)
        return t;
 }
 
+static inline thread_id_t int_to_id(int i)
+{
+       return i;
+}
+
+static inline int id_to_int(thread_id_t id)
+{
+       return id;
+}
+
 #endif /* __THREADS_H__ */