diff --git a/src/as/Makefile b/src/as/Makefile index 8cca632b9..777bd8df8 100644 --- a/src/as/Makefile +++ b/src/as/Makefile @@ -1,7 +1,40 @@ TOP=../.. -include $(TOP)/config/CONFIG_BASE +include $(TOP)/configure/CONFIG -include $(TOP)/config/RULES_ARCHS +USR_CFLAGS += -D_NO_PROTO + +INC := asDbLib.h asLib.h + +# build lib As from asLib.c: +# +LIBSRCS := asLib.c +LIBRARY := As + + +# All systems link the libs As, Com, Db (and again Com ??), +# generic Unix needs also lib m: +# +SYS_PROD_LIBS_DEFAULT := m +SYS_PROD_LIBS_WIN32 := -nil- +PROD_LIBS := As Com Db Com Osi + +PROD := ascheck + +asLibrary_CFLAGS = -DACCESS_SECURITY -D_NO_PROTO + +asLibrary_SRCS = asDbLib.c asCa.c asLib.c + +IOC_LIBRARY_vxWorks = asLibrary + +include $(TOP)/configure/RULES_BUILD + +# Extra rule since asLib_lex.c is included in asLib.c +# In my opinion, these objects should really be built +# independently. +asLib$(OBJ): asLib_lex.c ../asLibRoutines.c + +clean:: + @$(RM) asLib.c asLib_lex.c diff --git a/src/as/Makefile.Host b/src/as/Makefile.Host deleted file mode 100644 index f6eeeacaf..000000000 --- a/src/as/Makefile.Host +++ /dev/null @@ -1,32 +0,0 @@ -TOP = ../../.. -include $(TOP)/config/CONFIG_BASE - -USR_CFLAGS += -D_NO_PROTO - -INC := asDbLib.h asLib.h - -# build lib As from asLib.c: -# -LIBSRCS := asLib.c -LIBRARY := As - - -# All systems link the libs As, Com, Db (and again Com ??), -# generic Unix needs also lib m: -# -SYS_PROD_LIBS_DEFAULT := m -SYS_PROD_LIBS_WIN32 := -nil- -PROD_LIBS := As Com Db Com - -PROD := ascheck - -include $(TOP)/config/RULES.Host - -# Extra rule since asLib_lex.c is included in asLib.c -# In my opinion, these objects should really be built -# independently. -asLib$(OBJ): asLib_lex.c ../asLibRoutines.c - -clean:: - @$(RM) asLib.c asLib_lex.c - diff --git a/src/as/Makefile.Vx b/src/as/Makefile.Vx deleted file mode 100644 index c57453975..000000000 --- a/src/as/Makefile.Vx +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -include $(TOP)/config/CONFIG_BASE - -USR_CFLAGS = -DACCESS_SECURITY -D_NO_PROTO - -SRCS.c = ../asDbLib.c ../asCa.c asLib.c -LIBOBJS = asDbLib.o asCa.o asLib.o -LIBNAME = asLibrary - -include $(TOP)/config/RULES.Vx - -# Extra rule since asLib_lex.c is included in asLib.c -# In my opinion, these objects should really be built -# independently. -asLib.o: asLib_lex.c ../asLibRoutines.c - -clean:: - @$(RM) asLib_lex.c asLib.c - - diff --git a/src/as/asCa.c b/src/as/asCa.c index 96bd961f3..ea25dfb95 100644 --- a/src/as/asCa.c +++ b/src/as/asCa.c @@ -19,33 +19,32 @@ of this distribution. */ /*This module is separate from asDbLib because CA uses old database access*/ -#include -#include -#include #include #include #include -#include +#include #include "dbDefs.h" +#include "osiThread.h" +#include "osiSem.h" +#include "cantProceed.h" #include "errlog.h" #include "taskwd.h" #include "asDbLib.h" #include "cadef.h" #include "caerr.h" #include "caeventmask.h" -#include "task_params.h" #include "alarm.h" int asCaDebug = 0; extern ASBASE volatile *pasbase; LOCAL int firstTime = TRUE; -LOCAL int taskid=0; +LOCAL threadId threadid=0; LOCAL int caInitializing=FALSE; -LOCAL SEM_ID asCaTaskLock; /*lock access to task */ -LOCAL SEM_ID asCaTaskWait; /*Wait for task to respond*/ -LOCAL SEM_ID asCaTaskAddChannels; /*Tell asCaTask to add channels*/ -LOCAL SEM_ID asCaTaskClearChannels; /*Tell asCaTask to clear channels*/ +LOCAL semId asCaTaskLock; /*lock access to task */ +LOCAL semId asCaTaskWait; /*Wait for task to respond*/ +LOCAL semId asCaTaskAddChannels; /*Tell asCaTask to add channels*/ +LOCAL semId asCaTaskClearChannels; /*Tell asCaTask to clear channels*/ typedef struct { struct dbr_sts_double rtndata; @@ -133,13 +132,10 @@ LOCAL void asCaTask(void) CAPVT *pcapvt; int status; - taskwdInsert(taskIdSelf(),NULL,NULL); + taskwdInsert(threadGetIdSelf(),NULL,NULL); SEVCHK(ca_task_initialize(),"ca_task_initialize"); while(TRUE) { - if(semTake(asCaTaskAddChannels,WAIT_FOREVER)!=OK) { - epicsPrintf("asCa semTake error for asCaTaskClearChannels\n"); - taskSuspend(0); - } + semBinaryTakeAssert(asCaTaskAddChannels); caInitializing = TRUE; pasg = (ASG *)ellFirst(&pasbase->asgList); while(pasg) { @@ -168,9 +164,9 @@ LOCAL void asCaTask(void) asComputeAllAsg(); caInitializing = FALSE; if(asCaDebug) printf("asCaTask initialized\n"); - semGive(asCaTaskWait); + semBinaryGive(asCaTaskWait); while(TRUE) { - if(semTake(asCaTaskClearChannels,NO_WAIT)==OK) break; + if(semBinaryTakeNoWait(asCaTaskClearChannels)==semTakeOK) break; ca_pend_event(2.0); } pasg = (ASG *)ellFirst(&pasbase->asgList); @@ -190,7 +186,7 @@ LOCAL void asCaTask(void) pasg = (ASG *)ellNext((ELLNODE *)pasg); } if(asCaDebug) printf("asCaTask has cleared all channels\n"); - semGive(asCaTaskWait); + semBinaryGive(asCaTaskWait); } } @@ -199,38 +195,36 @@ void asCaStart(void) if(asCaDebug) printf("asCaStart called\n"); if(firstTime) { firstTime = FALSE; - if((asCaTaskLock=semBCreate(SEM_Q_FIFO,SEM_FULL))==NULL) - epicsPrintf("asCa semBCreate failure\n"); - if((asCaTaskWait=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL) - epicsPrintf("asCa semBCreate failure\n"); - if((asCaTaskAddChannels=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL) - epicsPrintf("asCa semBCreate failure\n"); - if((asCaTaskClearChannels=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL) - epicsPrintf("asCa semBCreate failure\n"); - taskid = taskSpawn("asCaTask",CA_CLIENT_PRI-1,VX_FP_TASK, - CA_CLIENT_STACK, (FUNCPTR)asCaTask,0,0,0,0,0,0,0,0,0,0); - if(taskid==ERROR) { + if((asCaTaskLock=semMutexCreate())==0) + cantProceed("asCa semMutexCreate failure\n"); + if((asCaTaskWait=semBinaryCreate(semEmpty))==0) + cantProceed("asCa semBinaryCreate failure\n"); + if((asCaTaskAddChannels=semBinaryCreate(semEmpty))==0) + cantProceed("asCa semBinaryCreate failure\n"); + if((asCaTaskClearChannels=semBinaryCreate(semEmpty))==0) + cantProceed("asCa semBCreate failure\n"); + threadid = threadCreate("asCaTask", + (threadPriorityScanLow - 3), + threadGetStackSize(threadStackBig), + (THREADFUNC)asCaTask,0); + if(threadid==0) { errMessage(0,"asCaStart: taskSpawn Failure\n"); } } - if(semTake(asCaTaskLock,WAIT_FOREVER)!=OK) - epicsPrintf("asCa semTake error\n"); - semGive(asCaTaskAddChannels); - if(semTake(asCaTaskWait,WAIT_FOREVER)!=OK) - epicsPrintf("asCa semTake error\n"); + semMutexTakeAssert(asCaTaskLock); + semBinaryGive(asCaTaskAddChannels); + semBinaryTakeAssert(asCaTaskWait); if(asCaDebug) printf("asCaStart done\n"); - semGive(asCaTaskLock); + semMutexGive(asCaTaskLock); } void asCaStop(void) { - if(taskid==0 || taskid==ERROR) return; + if(threadid==0) return; if(asCaDebug) printf("asCaStop called\n"); - if(semTake(asCaTaskLock,WAIT_FOREVER)!=OK) - epicsPrintf("asCa semTake error\n"); - semGive(asCaTaskClearChannels); - if(semTake(asCaTaskWait,WAIT_FOREVER)!=OK) - epicsPrintf("asCa semTake error\n"); + semMutexTakeAssert(asCaTaskLock); + semBinaryGive(asCaTaskClearChannels); + semBinaryTakeAssert(asCaTaskWait); if(asCaDebug) printf("asCaStop done\n"); - semGive(asCaTaskLock); + semMutexGive(asCaTaskLock); } diff --git a/src/as/asDbLib.c b/src/as/asDbLib.c index df003e308..5a66ac8f4 100644 --- a/src/as/asDbLib.c +++ b/src/as/asDbLib.c @@ -18,14 +18,14 @@ of this distribution. * .01 02-11-94 mrk Initial Implementation */ -#include -#include #include #include #include #include #include "dbDefs.h" +#include "cantProceed.h" +#include "osiThread.h" #include "errlog.h" #include "taskwd.h" #include "alarm.h" @@ -38,13 +38,12 @@ of this distribution. #include "dbCommon.h" #include "recSup.h" #include "subRecord.h" -#include "task_params.h" extern struct dbBase *pdbbase; static char *pacf=NULL; static char *psubstitutions=NULL; -static int initTaskId=0; +static threadId asInitTheadId=0; static int firstTime = TRUE; static long asDbAddRecords(void) @@ -148,23 +147,21 @@ static void asInitTask(ASDBCALLBACK *pcallback) { long status; - taskwdInsert(taskIdSelf(),wdCallback,pcallback); + taskwdInsert(threadGetIdSelf(),wdCallback,pcallback); status = asInitCommon(); - taskwdRemove(taskIdSelf()); - initTaskId = 0; + taskwdRemove(threadGetIdSelf()); + asInitTheadId = 0; if(pcallback) { pcallback->status = status; callbackRequest(&pcallback->callback); } - status = taskDelete(taskIdSelf()); - if(status) errMessage(0,"asInitTask: taskDelete Failure"); + threadDestroy(threadGetIdSelf()); } int asInitAsyn(ASDBCALLBACK *pcallback) { - if(!pacf) return(0); - if(initTaskId) { + if(asInitTheadId) { errMessage(-1,"asInit: asInitTask already active"); if(pcallback) { pcallback->status = S_asLib_InitFailed; @@ -172,15 +169,17 @@ int asInitAsyn(ASDBCALLBACK *pcallback) } return(-1); } - initTaskId = taskSpawn("asInitTask",CA_CLIENT_PRI-1,VX_FP_TASK,CA_CLIENT_STACK, - (FUNCPTR)asInitTask,(int)pcallback,0,0,0,0,0,0,0,0,0); - if(initTaskId==ERROR) { - errMessage(0,"asInit: taskSpawn Error"); + asInitTheadId = threadCreate("asInitTask", + (threadPriorityChannelAccessServer + 9), + threadGetStackSize(threadStackBig), + (THREADFUNC)asInitTask,(void *)pcallback); + if(asInitTheadId==0) { + errMessage(0,"asInit: threadCreate Error"); if(pcallback) { pcallback->status = S_asLib_InitFailed; callbackRequest(&pcallback->callback); } - initTaskId = 0; + asInitTheadId = 0; } return(0); } @@ -208,7 +207,8 @@ long asSubInit(subRecord *precord,int pass) { ASDBCALLBACK *pcallback; - pcallback = (ASDBCALLBACK *)calloc(1,sizeof(ASDBCALLBACK)); + pcallback = (ASDBCALLBACK *)callocMustSucceed( + 1,sizeof(ASDBCALLBACK),"asSubInit"); precord->dpvt = (void *)pcallback; callbackSetCallback(myCallback,&pcallback->callback); callbackSetUser(precord,&pcallback->callback); diff --git a/src/as/asLib.y b/src/as/asLib.y index ac12a32ca..958a375b2 100644 --- a/src/as/asLib.y +++ b/src/as/asLib.y @@ -225,7 +225,7 @@ static int myParse(ASINPUTFUNCPTR inputfunction) if (!FirstFlag) { line_num=1; yyFailed = FALSE; - yyreset(NULL); + yyreset(); yyrestart(NULL); } FirstFlag = 0; diff --git a/src/as/asLibRoutines.c b/src/as/asLibRoutines.c index 24bb56ca9..2a36efe61 100644 --- a/src/as/asLibRoutines.c +++ b/src/as/asLibRoutines.c @@ -19,16 +19,14 @@ of this distribution. * .01 10-15-93 mrk Initial Implementation */ -#ifdef vxWorks -#include -#include -#endif -#include #include #include #include +#include #include "dbDefs.h" +#include "cantProceed.h" +#include "osiSem.h" #include "epicsPrint.h" #include "gpHash.h" #include "freeList.h" @@ -37,16 +35,9 @@ of this distribution. #include #include -#ifdef vxWorks -#include -static SEM_ID asLock; -#define LOCK semTake(asLock,WAIT_FOREVER) -#define UNLOCK semGive(asLock); -#else -/*This only works in a single threaded environment */ -#define LOCK -#define UNLOCK -#endif +static semId asLock; +#define LOCK semMutexTakeAssert(asLock) +#define UNLOCK semMutexGive(asLock) #define epicsExportSharedSymbols #include "shareLib.h" @@ -105,13 +96,10 @@ long epicsShareAPI asInitialize(ASINPUTFUNCPTR inputfunction) HAGNAME *phagname; if(asLockInit) { -#ifdef vxWorks - asLock = semMCreate(SEM_DELETE_SAFE|SEM_INVERSION_SAFE|SEM_Q_PRIORITY); + asLock = semMutexCreate(); if(!asLock) { - errMessage(0,"asInitialize semMCreate failed\n"); - exit(-1); + cantProceed("asInitialize semMCreate failed\n"); } -#endif asLockInit = FALSE; } LOCK; @@ -809,14 +797,8 @@ void * asCalloc(size_t nobj,size_t size) { void *p; - p=calloc(nobj,size); - if(p) return(p); -#ifdef vxWorks - taskSuspend(0); -#else - abort(); -#endif - return(NULL); + p=callocMustSucceed(nobj,size,"asCalloc"); + return(p); } static long asAddMemberPvt(ASMEMBERPVT *pasMemberPvt,char *asgName) diff --git a/src/bpt/Makefile b/src/bpt/Makefile index 8cca632b9..4e6919dcc 100644 --- a/src/bpt/Makefile +++ b/src/bpt/Makefile @@ -1,7 +1,25 @@ TOP=../.. -include $(TOP)/config/CONFIG_BASE +include $(TOP)/configure/CONFIG -include $(TOP)/config/RULES_ARCHS +INC := cvtTable.h + +SRCS := makeBpt.c +PROD := makeBpt + +MENUS += menuConvert.h + +BPTS += bptTypeJdegC.dbd +BPTS += bptTypeJdegF.dbd +BPTS += bptTypeKdegC.dbd +BPTS += bptTypeKdegF.dbd + +bptLibrary_SRCS = cvtBpt.c + +IOC_LIBRARY_vxWorks = bptLibrary + +include $(TOP)/configure/RULES_BUILD + +$(BPTS): $(EPICS_BASE_HOST_BIN)/makeBpt$(EXE) diff --git a/src/bpt/Makefile.Host b/src/bpt/Makefile.Host deleted file mode 100644 index c1d53d873..000000000 --- a/src/bpt/Makefile.Host +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../../.. -include $(TOP)/config/CONFIG_BASE - -INC := cvtTable.h - -SRCS := makeBpt.c -PROD := makeBpt - -MENUS += menuConvert.h - -BPTS += bptTypeJdegC.dbd -BPTS += bptTypeJdegF.dbd -BPTS += bptTypeKdegC.dbd -BPTS += bptTypeKdegF.dbd - -include $(TOP)/config/RULES.Host - -$(BPTS): $(INSTALL_PROD) - diff --git a/src/bpt/Makefile.Vx b/src/bpt/Makefile.Vx deleted file mode 100644 index 851e3c72e..000000000 --- a/src/bpt/Makefile.Vx +++ /dev/null @@ -1,21 +0,0 @@ -TOP = ../../.. -include $(TOP)/config/CONFIG_BASE - -MENUS += menuConvert.h - -BPTS += bptTypeJdegC.dbd -BPTS += bptTypeJdegF.dbd -BPTS += bptTypeKdegC.dbd -BPTS += bptTypeKdegF.dbd - - -SRCS.c = \ - ../cvtBpt.c - -LIBOBJS = \ - cvtBpt.o - -LIBNAME = pbtLib - -include $(TOP)/config/RULES.Vx - diff --git a/src/bpt/cvtBpt.c b/src/bpt/cvtBpt.c index 529d91c34..b71628703 100644 --- a/src/bpt/cvtBpt.c +++ b/src/bpt/cvtBpt.c @@ -32,17 +32,15 @@ * ----------------- * 01 04OCT95 mrk Taken from old bldCvtTable */ -#include -#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include +#include "ellLib.h" +#include "dbBase.h" +#include "dbStaticLib.h" +#include "cvtTable.h" +#include "epicsPrint.h" extern struct dbBase *pdbbase;