add threadid
diff --git a/include/thread.h b/include/thread.h
index 75592ee..9424d37 100644
--- a/include/thread.h
+++ b/include/thread.h
@@ -23,6 +23,7 @@
 void		_threadsleep(Rendez*);
 _Thread	*_threadwakeup(Rendez*);
 #define	yield		threadyield
+int		threadid(void);
 
 /*
  * I am tired of making this mistake.
diff --git a/src/libthread/thread.c b/src/libthread/thread.c
index 145a503..ca4d35a 100644
--- a/src/libthread/thread.c
+++ b/src/libthread/thread.c
@@ -370,6 +370,15 @@
 	va_end(arg);
 }
 
+int
+threadid(void)
+{
+	_Thread *t;
+	
+	t = proc()->thread;
+	return t->id;
+}
+
 void
 needstack(int n)
 {