shithub: riscv

Download patch

ref: b55315c3fd5d745a3c5b15991dfa1c8c5da7a5ae
parent: 7562da90e562e65156042574e088d4359a8fccba
author: cinap_lenrek <[email protected]>
date: Sun Sep 6 19:25:14 EDT 2015

libthread: get rid of tprivalloc()/tprivfree()/tprivdata() and _workerdata() (thanks qrstuv)

these functions where undocumented and unused. especially
tprivfree() was buggy missing a unlock() call. theres not
much point in supporting these functions as theres
threaddata() and procdata().

--- a/sys/include/thread.h
+++ b/sys/include/thread.h
@@ -103,9 +103,6 @@
 int	threadsetgrp(int);		/* set thread group, return old */
 void	threadsetname(char *fmt, ...);
 Channel*threadwaitchan(void);
-int	tprivalloc(void);
-void	tprivfree(int);
-void	**tprivaddr(int);
 void	yield(void);
 
 #pragma	varargck	argpos	threadsetname	1
--- a/sys/src/libthread/id.c
+++ b/sys/src/libthread/id.c
@@ -89,51 +89,11 @@
 void**
 threaddata(void)
 {
-	return &_threadgetproc()->thread->udata[0];
+	return &_threadgetproc()->thread->udata;
 }
 
 void**
-_workerdata(void)
-{
-	return &_threadgetproc()->wdata;
-}
-
-void**
 procdata(void)
 {
 	return &_threadgetproc()->udata;
-}
-
-static Lock privlock;
-static int privmask = 1;
-
-int
-tprivalloc(void)
-{
-	int i;
-
-	lock(&privlock);
-	for(i=0; i<NPRIV; i++)
-		if(!(privmask&(1<<i))){
-			privmask |= 1<<i;
-			unlock(&privlock);
-			return i;
-		}
-	unlock(&privlock);
-	return -1;
-}
-
-void
-tprivfree(int i)
-{
-	if(i < 0 || i >= NPRIV)
-		abort();
-	lock(&privlock);
-	privmask &= ~(1<<i);
-}
-
-void**
-tprivaddr(int i)
-{
-	return &_threadgetproc()->thread->udata[i];
 }
--- a/sys/src/libthread/threadimpl.h
+++ b/sys/src/libthread/threadimpl.h
@@ -48,7 +48,6 @@
 {
 	RENDHASH = 13,
 	Printsize = 2048,
-	NPRIV = 8,
 };
 
 struct Rgrp
@@ -92,7 +91,7 @@
 	Chanstate	chan;		/* which channel operation is current */
 	Alt		*alt;		/* pointer to current alt structure (debugging) */
 
-	void*	udata[NPRIV];	/* User per-thread data pointer */
+	void*		udata;		/* User per-thread data pointer */
 };
 
 struct Execargs
@@ -131,7 +130,6 @@
 	void		*arg;			/* passed between shared and unshared stk */
 	char		str[ERRMAX];		/* used by threadexits to avoid malloc */
 
-	void*		wdata;			/* Lib(worker) per-proc data pointer */
 	void*		udata;			/* User per-proc data pointer */
 	char		threadint;		/* tag for threadexitsall() */
 };