From: Brian Norris Date: Tue, 1 May 2012 20:08:35 +0000 (-0700) Subject: threads: add id_to_int() and int_to_id() inline functions X-Git-Tag: pldi2013~478 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3cade2fadc95d3dcbc37f5e6c4da4b8e9b559c23;p=model-checker.git threads: add id_to_int() and int_to_id() inline functions --- diff --git a/libthreads.cc b/libthreads.cc index 7dd043c..73a948c 100644 --- a/libthreads.cc +++ b/libthreads.cc @@ -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; } diff --git a/model.cc b/model.cc index 3cc536b..04a8773 100644 --- 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); } diff --git a/threads.h b/threads.h index 69bd115..7a21a30 100644 --- 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__ */