From: Erwin Janssen Date: Mon, 9 Jan 2017 12:56:29 +0000 (+0100) Subject: Remove disabled vt_threaded code from lib/sfio X-Git-Tag: 2.42.0~213^2~2^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c64fcea47924913cadaa1ac748c72912be5377c1;p=graphviz Remove disabled vt_threaded code from lib/sfio The threaded part of sfio and vthread is disabled for Graphviz by setting various defines. This commit removes the disabled code entirely, to make it more clear which code is actually part of the compilation. --- diff --git a/lib/ast/strton.c b/lib/ast/strton.c index 5ec24c0e9..6140da849 100644 --- a/lib/ast/strton.c +++ b/lib/ast/strton.c @@ -53,13 +53,6 @@ #include -/* For graphviz, only unthreaded */ -#ifdef WIN32_STATIC -#undef vt_threaded 0 -#else -#define vt_threaded 0 -#endif - #include "sfhdr.h" #define QL 01 diff --git a/lib/sfio/Makefile.am b/lib/sfio/Makefile.am index 9f6bce06b..571370b54 100644 --- a/lib/sfio/Makefile.am +++ b/lib/sfio/Makefile.am @@ -5,8 +5,6 @@ SUBDIRS = Sfio_f AM_CPPFLAGS = -I$(top_srcdir)/lib/ast -AM_CFLAGS = -Dvt_threaded=0 - noinst_HEADERS = sfhdr.h sfio.h sfio_t.h vthread.h noinst_LTLIBRARIES = libsfio_C.la diff --git a/lib/sfio/Sfio_f/Makefile.am b/lib/sfio/Sfio_f/Makefile.am index 5d96592fe..08b530345 100644 --- a/lib/sfio/Sfio_f/Makefile.am +++ b/lib/sfio/Sfio_f/Makefile.am @@ -3,8 +3,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/lib/sfio -AM_CFLAGS = -Dvt_threaded=0 - noinst_LTLIBRARIES = libsfiof_C.la libsfiof_C_la_SOURCES = _sfclrerr.c _sfdlen.c _sfeof.c _sferror.c \ diff --git a/lib/sfio/sfextern.c b/lib/sfio/sfextern.c index 20b096ab1..215c96f9d 100644 --- a/lib/sfio/sfextern.c +++ b/lib/sfio/sfextern.c @@ -54,16 +54,9 @@ Sfextern_t _Sfextern = { 0, /* _Sfpage */ /* accessible to application code for a few fast macro functions */ ssize_t _Sfi = -1; -#if vt_threaded -static Vtmutex_t _Sfmtxin, _Sfmtxout, _Sfmtxerr; -#define SFMTXIN (&_Sfmtxin) -#define SFMTXOUT (&_Sfmtxout) -#define SFMTXERR (&_Sfmtxerr) -#else #define SFMTXIN (0) #define SFMTXOUT (0) #define SFMTXERR (0) -#endif Sfio_t _Sfstdin = SFNEW(NIL(char *), -1, 0, (SF_READ | SF_STATIC | SF_MTSAFE), NIL(Sfdisc_t *), diff --git a/lib/sfio/sfhdr.h b/lib/sfio/sfhdr.h index 17910b372..6eea4d02d 100644 --- a/lib/sfio/sfhdr.h +++ b/lib/sfio/sfhdr.h @@ -30,7 +30,6 @@ extern "C" { #include "FEATURE/sfio" #include "sfio_t.h" -/* note that the macro vt_threaded has effect on vthread.h */ #include #if defined(__mips) && __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE) @@ -91,25 +90,6 @@ extern "C" { #include #include -#if vt_threaded - -/* initialization */ -#define SFONCE() (_Sfdone ? 0 : vtonce(_Sfonce,_Sfoncef)) - -/* to lock/unlock a stream on entering and returning from some function */ -#define SFMTXLOCK(f) (((f)->flags&SF_MTSAFE) ? sfmutex(f,SFMTX_LOCK) : 0) -#define SFMTXUNLOCK(f) (((f)->flags&SF_MTSAFE) ? sfmutex(f,SFMTX_UNLOCK) : 0) -#define SFMTXSTART(f,v) { if(!f || SFMTXLOCK(f) != 0) return(v); } -#define SFMTXRETURN(f,v) { SFMTXUNLOCK(f); return(v); } - -/* start and end critical region for a pool */ -#define POOLMTXLOCK(p) ( vtmtxlock(&(p)->mutex) ) -#define POOLMTXUNLOCK(p) ( vtmtxunlock(&(p)->mutex) ) -#define POOLMTXSTART(p) { POOLMTXLOCK(p); } -#define POOLMTXRETURN(p,v) { POOLMTXUNLOCK(p); return(v); } - -#else /*!vt_threaded */ - #undef SF_MTSAFE /* no need to worry about thread-safety */ #define SF_MTSAFE 0 @@ -125,9 +105,6 @@ extern "C" { #define POOLMTXSTART(p) #define POOLMTXRETURN(p,v) { return(v); } -#endif /*vt_threaded */ - - /* functions for polling readiness of streams */ #if _lib_select #undef _lib_poll diff --git a/lib/sfio/sfmutex.c b/lib/sfio/sfmutex.c index 883a0fd65..d8de8f9f7 100644 --- a/lib/sfio/sfmutex.c +++ b/lib/sfio/sfmutex.c @@ -21,35 +21,5 @@ /* the main locking/unlocking interface */ int sfmutex(Sfio_t * f, int type) { -#if !vt_threaded return 0; -#else - - SFONCE(); - - if (!f) - return -1; - - if (!f->mutex) { - if (f->bits & SF_PRIVATE) - return 0; - - vtmtxlock(_Sfmutex); - f->mutex = vtmtxopen(NIL(Vtmutex_t *), VT_INIT); - vtmtxunlock(_Sfmutex); - if (!f->mutex) - return -1; - } - - if (type == SFMTX_LOCK) - return vtmtxlock(f->mutex); - else if (type == SFMTX_TRYLOCK) - return vtmtxtrylock(f->mutex); - else if (type == SFMTX_UNLOCK) - return vtmtxunlock(f->mutex); - else if (type == SFMTX_CLRLOCK) - return vtmtxclrlock(f->mutex); - else - return -1; -#endif /*vt_threaded */ } diff --git a/lib/sfio/sfnew.c b/lib/sfio/sfnew.c index 854b42521..86a061f01 100644 --- a/lib/sfio/sfnew.c +++ b/lib/sfio/sfnew.c @@ -87,12 +87,6 @@ Sfio_t *sfnew(Sfio_t * oldf, void * buf, size_t size, int file, } } - /* create a mutex */ -#if vt_threaded - if (!f->mutex) - f->mutex = vtmtxopen(NIL(Vtmutex_t *), VT_INIT); -#endif - /* stream type */ f->mode = (flags & SF_READ) ? SF_READ : SF_WRITE; f->flags = (flags & SF_FLAGS) | (sflags & (SF_MALLOC | SF_STATIC)); diff --git a/lib/sfio/sfpkrd.c b/lib/sfio/sfpkrd.c index d0176fe0d..37273e4e3 100644 --- a/lib/sfio/sfpkrd.c +++ b/lib/sfio/sfpkrd.c @@ -117,9 +117,6 @@ ssize_t sfpkrd(int fd, void * argbuf, size_t n, int rc, long tm, #endif /*_lib_poll*/ #if _lib_select if (r == -2) { -#if _hpux_threads && vt_threaded -#define fd_set int -#endif fd_set rd; struct timeval tmb, *tmp; FD_ZERO(&rd); diff --git a/lib/sfio/vthread.h b/lib/sfio/vthread.h index 72d170249..2dff550a6 100644 --- a/lib/sfio/vthread.h +++ b/lib/sfio/vthread.h @@ -21,8 +21,6 @@ extern "C" { #define VTHREAD_VERSION 20001201L /* Header for the Vthread library. -** Note that the macro vt_threaded may be defined -** outside of vthread.h to suppress threading. ** ** Written by Kiem-Phong Vo */ @@ -35,12 +33,6 @@ extern "C" { # include #endif // HAVE_SYS_TYPES_H -#undef vt_threaded - -#ifndef vt_threaded -#define vt_threaded 0 -#endif - /* common attributes for various structures */ #define VT_RUNNING 000000001 /* thread is running */ #define VT_SUSPENDED 000000002 /* thread is suspended */ @@ -90,49 +82,7 @@ extern "C" { extern int vtmtxerror(Vtmutex_t *); extern int vtonceerror(Vtonce_t *); -#if defined(vt_threaded) && vt_threaded -/* mutex structure */ - struct _vtmutex_s { - _vtmtx_t lock; - int count; - _vtid_t owner; - int state; - int error; - }; - -/* structure for states of thread */ - struct _vthread_s { - _vtself_t self; /* self-handle */ - _vtid_t id; /* thread id */ - _vtattr_t attrs; /* attributes */ - size_t stack; /* stack size */ - int state; /* execution state */ - int error; /* error status */ - void *exit; /* exit value */ - }; - -/* structure for exactly once execution */ - struct _vtonce_s { - int done; - _vtonce_t once; - int error; - }; - -#if defined(_WIN32) -#define VTONCE_INITDATA {0, 0} -#else -#define VTONCE_INITDATA {0, PTHREAD_ONCE_INIT } -#endif - -#define vtstatus(vt) ((vt)->exit) -#define vterror(vt) ((vt)->error) -#define vtmtxerror(mtx) ((mtx)->error) -#define vtonceerror(once) ((once)->error) - -#endif /*vt_threaded */ - /* fake structures and functions */ -#if defined(vt_threaded) && !vt_threaded struct _vtmutex_s { int error; }; @@ -169,8 +119,6 @@ extern "C" { #define vtmtxerror(mtx) (0) #define vtonceerror(once) (0) -#endif /*!vt_threaded */ - #endif /*_VTHREAD_H*/ #ifdef __cplusplus