1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

libast/sfio: remove unused Vthread API and support code

Sfio may theoretically be compiled with threads support using a
separate AT&T library called Vthread, also by Kiem-Phong Vo. That
library was never shipped in the AST distribution, though. It is
only available with a standalone version of Sfio.

The only standalone Sfio version with Vthread that I've found is
from 2005, mirrored at <https://github.com/lichray/sfio>. More
recent versions never seem to have made it out of the defunct AT&T
software download site.

Even if they weren't, the rest of libast doesn't support threads,
and at this point it never will, so for our purposes the Sfio
threads code is never going to be usable. Meanwhile, macros such as
SFMTXENTER and SFMTXRETURN make the code a lot harder to read. And
not quite all threading code is disabled; some of it is dead code
that is getting compiled in.

Chances are that code now won't work properly in any case as we've
not had any chance to test it as we were making changes. Bit rot
has surely set in by now.

So this commit expands all the sfio/stdio threading-related macros
to their non-threads fallbacks (which is null for most of them, but
not all), deletes dead mutex-related code and struct fields, and
removes the related documentation from the sfio.3 man page. Unless
I did something wrong, there should be no change in behaviour.
This commit is contained in:
Martijn Dekker 2022-02-12 12:23:16 +00:00
parent 56c0c24b55
commit 4ca578bde4
63 changed files with 300 additions and 1065 deletions

View file

@ -110,18 +110,17 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
struct stat st;
uchar* obuf = NIL(uchar*);
ssize_t osize = 0;
SFMTXDECL(f);
SFONCE();
SFMTXENTER(f,NIL(void*));
if(!f)
return NIL(void*);
GETLOCAL(f,local);
if(size == 0 && buf)
{ /* special case to get buffer info */
_Sfi = f->val = (f->bits&SF_MMAP) ? (f->endb-f->data) : f->size;
SFMTXRETURN(f, (void*)f->data);
return (void*)f->data;
}
/* cleanup actions already done, don't allow write buffering any more */
@ -132,10 +131,10 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
if((init = f->mode&SF_INIT) )
{ if(!f->pool && _sfsetpool(f) < 0)
SFMTXRETURN(f, NIL(void*));
return NIL(void*);
}
else if((f->mode&SF_RDWR) != SFMODE(f,local) && _sfmode(f,0,local) < 0)
SFMTXRETURN(f, NIL(void*));
return NIL(void*);
if(init)
f->mode = (f->mode&SF_RDWR)|SF_LOCK;
@ -145,12 +144,12 @@ void* sfsetbuf(Sfio_t* f, /* stream to be buffered */
/* make sure there is no hidden read data */
if(f->proc && (f->flags&SF_READ) && (f->mode&SF_WRITE) &&
_sfmode(f,SF_READ,local) < 0)
SFMTXRETURN(f, NIL(void*));
return NIL(void*);
/* synchronize first */
SFLOCK(f,local); rv = SFSYNC(f); SFOPEN(f,local);
if(rv < 0)
SFMTXRETURN(f, NIL(void*));
return NIL(void*);
/* turn off the SF_SYNCED bit because buffer is changing */
f->mode &= ~SF_SYNCED;
@ -416,5 +415,5 @@ done:
SFOPEN(f,local);
SFMTXRETURN(f, (void*)obuf);
return (void*)obuf;
}