libthread: simplify alt tracking, possibly fixing bug
diff --git a/include/thread.h b/include/thread.h
index 2301191..739fe0f 100644
--- a/include/thread.h
+++ b/include/thread.h
@@ -82,7 +82,6 @@
 	void		*v;
 	uint		op;
 	_Thread		*thread;
-	Alt			*xalt;
 };
 
 struct _Altarray
diff --git a/src/libthread/channel.c b/src/libthread/channel.c
index 903889a..080f84d 100644
--- a/src/libthread/channel.c
+++ b/src/libthread/channel.c
@@ -234,8 +234,8 @@
 		i = rand()%ar->n;
 		other = ar->a[i];
 		altcopy(a, other);
-		altalldequeue(other->xalt);
-		other->xalt[0].xalt = other;
+		altalldequeue(other->thread->alt);
+		other->thread->alt = other;
 		_threadready(other->thread);
 	}else
 		altcopy(a, nil);
@@ -256,10 +256,9 @@
 	canblock = a[i].op == CHANEND;
 
 	t = proc()->thread;
-	for(i=0; i<n; i++){
+	for(i=0; i<n; i++)
 		a[i].thread = t;
-		a[i].xalt = a;
-	}
+	t->alt = a;
 	qlock(&chanlock);
 if(dbgalt) print("alt ");
 	ncan = 0;
@@ -307,9 +306,11 @@
 
 	/*
 	 * the guy who ran the op took care of dequeueing us
-	 * and then set a[0].alt to the one that was executed.
+	 * and then set t->alt to the one that was executed.
 	 */
-	return a[0].xalt - a;
+	if(t->alt < a || t->alt >= a+n)
+		sysfatal("channel bad alt");
+	return t->alt - a;
 }
 
 static int
diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h
index 2a69d49..bc18d3a 100644
--- a/src/libthread/threadimpl.h
+++ b/src/libthread/threadimpl.h
@@ -114,6 +114,7 @@
 	char	name[256];
 	char	state[256];
 	void *udata;
+	Alt	*alt;
 };
 
 struct _Procrendez