shithub: riscv

Download patch

ref: 07c7fa6716a2f54f9feab3eb56f8677edb1b033d
parent: eaf91d0f8ef43344ea9b8b030ab1a446211b8d10
author: cinap_lenrek <[email protected]>
date: Wed Mar 4 05:20:31 EST 2015

libthread: get rid of chaninit() (thanks qrstuv)

chaninit() does not initialize Chan.qentry and Chan.nentry
and there is no way to get rid of such a channel. nobody is
using it, so removing the function to avoid confusion.

--- a/sys/include/thread.h
+++ b/sys/include/thread.h
@@ -63,7 +63,6 @@
 int	chanclose(Channel*);
 int	chanclosing(Channel *c);
 Channel*chancreate(int elemsize, int bufsize);
-int	chaninit(Channel *c, int elemsize, int elemcnt);
 void	chanfree(Channel *c);
 int	chanprint(Channel *, char *, ...);
 long	decref(Ref *r);			/* returns 0 iff value is now zero */
--- a/sys/man/2/thread
+++ b/sys/man/2/thread
@@ -4,7 +4,6 @@
 chanclose,
 chancreate,
 chanfree,
-chaninit,
 chanclosing,
 chanprint,
 mainstacksize,
@@ -107,7 +106,6 @@
 void**	threaddata(void)
 void**	procdata(void)
 .XX
-int	chaninit(Channel *c, int elsize, int nel)
 Channel*	chancreate(int elsize, int nel)
 void	chanfree(Channel *c)
 .XX
@@ -384,10 +382,8 @@
 .I recv
 operation occurs and
 .IR "vice versa" .
-.I Chaninit
-initializes a
-.B Channel
-for messages of size
+.I Chancreate
+allocates a new channel for messages of size
 .I elsize
 and with a buffer holding
 .I nel
@@ -395,8 +391,6 @@
 If
 .I nel
 is zero, the channel is unbuffered.
-.IR Chancreate
-allocates a new channel and initializes it.
 .I Chanfree
 frees a channel that is no longer used.
 .I Chanfree
--- a/sys/src/libthread/channel.c
+++ b/sys/src/libthread/channel.c
@@ -49,21 +49,6 @@
 	unlock(&chanlock);
 }
 
-int
-chaninit(Channel *c, int elemsize, int elemcnt)
-{
-	if(elemcnt < 0 || elemsize <= 0 || c == nil)
-		return -1;
-	c->f = 0;
-	c->n = 0;
-	c->closed = 0;
-	c->freed = 0;
-	c->e = elemsize;
-	c->s = elemcnt;
-	_threaddebug(DBGCHAN, "chaninit %p", c);
-	return 1;
-}
-
 Channel*
 chancreate(int elemsize, int elemcnt)
 {