changes for 3.14
This commit is contained in:
@@ -1,7 +1,192 @@
|
||||
|
||||
TOP=../..
|
||||
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
include $(TOP)/configure/CONFIG
|
||||
|
||||
include $(TOP)/config/RULES_ARCHS
|
||||
CMPLR = STRICT
|
||||
|
||||
USR_CFLAGS = -D_NO_PROTO
|
||||
|
||||
# includes to install from this sub-project
|
||||
#
|
||||
INC += cantProceed.h
|
||||
INC += cvtFast.h
|
||||
INC += ellLib.h
|
||||
INC += envDefs.h
|
||||
INC += epicsAssert.h
|
||||
INC += errlog.h
|
||||
INC += epicsPrint.h
|
||||
INC += errMdef.h
|
||||
INC += error.h
|
||||
INC += fdmgr.h
|
||||
INC += freeList.h
|
||||
INC += gpHash.h
|
||||
INC += memDebugLib.h
|
||||
INC += tsDefs.h
|
||||
INC += bucketLib.h
|
||||
INC += pal.h
|
||||
INC += fdManager.h
|
||||
INC += osiTime.h
|
||||
INC += osiTimer.h
|
||||
INC += macLib.h
|
||||
INC += sigPipeIgnore.h
|
||||
INC += dbmf.h
|
||||
INC += epicsString.h
|
||||
INC += truncateFile.h
|
||||
INC += adjustment.h
|
||||
INC += postfix.h
|
||||
INC += sCalcPostfix.h
|
||||
INC += osiSleep.h
|
||||
INC += bsdSocketResource.h
|
||||
|
||||
# For WIN32 we supply getopt as part of libCom:
|
||||
INC_WIN32 := getopt.h
|
||||
|
||||
####################################
|
||||
# general contents of library on all platforms
|
||||
#
|
||||
# system specific lines in RULES.Host figure out
|
||||
# 1) what object names (.o, .obj,...) to build
|
||||
# 2) where to find the sources: ., ./os/<ARCH_CLASS>, ./os/generic, ...
|
||||
#
|
||||
LIBSRCS += cantProceed.c
|
||||
LIBSRCS += bucketLib.c
|
||||
LIBSRCS += cvtFast.c
|
||||
LIBSRCS += ellLib.c
|
||||
LIBSRCS += envSubr.c
|
||||
LIBSRCS += envData.c
|
||||
LIBSRCS += errlogUNIX.c
|
||||
LIBSRCS += errSymLib.c
|
||||
LIBSRCS += errSymTbl.c
|
||||
LIBSRCS += fdmgr.c
|
||||
LIBSRCS += freeListLib.c
|
||||
LIBSRCS += gpHashLib.c
|
||||
LIBSRCS += memDebugLib.c
|
||||
LIBSRCS += postfix.c
|
||||
LIBSRCS += calcPerform.c
|
||||
LIBSRCS += sCalcPostfix.c
|
||||
LIBSRCS += sCalcPerform.c
|
||||
LIBSRCS += realpath.c
|
||||
LIBSRCS += tsSubr.c
|
||||
LIBSRCS += assertUNIX.c
|
||||
LIBSRCS += macCore.c
|
||||
LIBSRCS += macUtil.c
|
||||
LIBSRCS += sigPipeIgnore.c
|
||||
LIBSRCS += dbmf.c
|
||||
LIBSRCS += epicsString.c
|
||||
LIBSRCS += truncateFile.c
|
||||
LIBSRCS += aToIPAddr.c
|
||||
LIBSRCS += adjustment.c
|
||||
LIBSRCS += bsdSockResource.c
|
||||
LIBSRCS += osiSleep.c
|
||||
LIBSRCS += bsdSockResCom.c
|
||||
|
||||
#
|
||||
# if CPLUSPLUS isnt empty then include C++ src codes
|
||||
# Note: After including/excluding files here,
|
||||
# e.g. the C++ stuff,
|
||||
# please check Com.def!
|
||||
#
|
||||
LIBSRCS += $(patsubst %,osiTime.cc,$(strip $(CPLUSPLUS)))
|
||||
LIBSRCS += $(patsubst %,osdTime.cc,$(strip $(CPLUSPLUS)))
|
||||
LIBSRCS += $(patsubst %,osiTimer.cc,$(strip $(CPLUSPLUS)))
|
||||
LIBSRCS += $(patsubst %,fdManager.cc,$(strip $(CPLUSPLUS)))
|
||||
|
||||
# WIN32 has no getopt, we add it to the Com lib,
|
||||
# special initialisation is done in winmain.c
|
||||
LIBSRCS_WIN32 := getopt.c getLastWSAErrorAsString.c
|
||||
LIBSRCS_WIN32 += $(patsubst %,dllmain.cc,$(strip $(CPLUSPLUS)))
|
||||
|
||||
# Library to build:
|
||||
# lib$(LIBRARY).a or ..dll/..exp/..lib
|
||||
#
|
||||
LIBRARY:=Com
|
||||
|
||||
# only for WIN32:
|
||||
# build LIBRARY as a DLL, use the specified def file
|
||||
LIBTYPE := SHARED
|
||||
|
||||
# libs needed for PROD and TESTPRODUCT
|
||||
PROD_LIBS := Com
|
||||
SYS_PROD_LIBS_WIN32 := ws2_32 advapi32
|
||||
|
||||
#USR_CFLAGS += -DTS_TEST
|
||||
#TESTPROD_SRCS=tsSubr.c
|
||||
#TESTPROD=testtsLib
|
||||
#TESTPROD=envtest
|
||||
#TESTPROD=osiTimeTest fdManagerTest
|
||||
|
||||
MAN3 = gpHash.3 freeList.3
|
||||
|
||||
# for bldErrSymTbl:
|
||||
#
|
||||
ERR_S_FILES += $(TOP)/src/as/asLib.h
|
||||
ERR_S_FILES += $(TOP)/src/db/dbAccess.h
|
||||
ERR_S_FILES += $(TOP)/src/db/devSup.h
|
||||
ERR_S_FILES += $(TOP)/src/db/drvSup.h
|
||||
ERR_S_FILES += $(TOP)/src/db/recSup.h
|
||||
ERR_S_FILES += $(TOP)/src/dbStatic/dbStaticLib.h
|
||||
ERR_S_FILES += ../tsDefs.h
|
||||
ERR_S_FILES += ../errMdef.h
|
||||
ERR_S_FILES += $(TOP)/src/cas/generic/casdef.h
|
||||
ERR_S_FILES += $(TOP)/src/gdd/gddAppFuncTable.h
|
||||
|
||||
#================================================
|
||||
|
||||
USR_INCLUDES_68k = -I$(TOP)/src/include/os/vxWorks
|
||||
|
||||
VPATH = ../os/$(OS_CLASS)
|
||||
|
||||
libCom_SRCS += cantProceed.c
|
||||
libCom_SRCS += cvtFast.c
|
||||
libCom_SRCS += gpHashLib.c
|
||||
libCom_SRCS += freeListLib.c
|
||||
libCom_SRCS += ellLib.c
|
||||
libCom_SRCS += envSubr.c
|
||||
libCom_SRCS += envData.c
|
||||
libCom_SRCS += errSymLib.c
|
||||
libCom_SRCS += postfix.c
|
||||
libCom_SRCS += calcPerform.c
|
||||
libCom_SRCS += sCalcPostfix.c
|
||||
libCom_SRCS += sCalcPerform.c
|
||||
libCom_SRCS += bucketLib.c
|
||||
libCom_SRCS += memDebugLib.c
|
||||
libCom_SRCS += tsSubr.c
|
||||
libCom_SRCS += pal.c
|
||||
libCom_SRCS += paldef.c
|
||||
libCom_SRCS += errSymTbl.c
|
||||
libCom_SRCS += errlogVX.c
|
||||
libCom_SRCS += assertVX.c
|
||||
libCom_SRCS += macCore.c
|
||||
libCom_SRCS += macUtil.c
|
||||
#libCom_SRCS += osiTimer.c
|
||||
#libCom_SRCS += osdTime.c
|
||||
libCom_SRCS += sigPipeIgnore.c
|
||||
libCom_SRCS += dbmf.c
|
||||
libCom_SRCS += epicsString.c
|
||||
libCom_SRCS += aToIPAddr.c
|
||||
libCom_SRCS += adjustment.c
|
||||
libCom_SRCS += bsdSockResCom.c
|
||||
libCom_SRCS += bsdSockResource.c
|
||||
libCom_SRCS += osiSleep.c
|
||||
|
||||
IOC_LIBRARY_vxWorks = libCom
|
||||
|
||||
#================================================
|
||||
|
||||
include $(TOP)/configure/RULES_BUILD
|
||||
|
||||
# The real dependecies seem to confuse GNUmake:
|
||||
# envData.c is rebuild every time...
|
||||
#envData.c: ../envDefs.h $(CONFIG)/CONFIG_ENV $(CONFIG)/CONFIG_SITE_ENV
|
||||
envData.c: ../envDefs.h ../bldEnvData.pl
|
||||
$(PERL) ../bldEnvData.pl $(CONFIG)
|
||||
|
||||
errSymTbl.c: $(ERR_S_FILES)
|
||||
$(PERL) ../makeStatTbl.pl $(ERR_S_FILES)
|
||||
|
||||
clean::
|
||||
@$(RM) errSymTbl.c envData.c
|
||||
|
||||
# EOF Makefile.Host for base/src/libCom
|
||||
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
# Makefile.Host for base/src/libCom
|
||||
#
|
||||
#
|
||||
|
||||
TOP = ../../..
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
CMPLR = STRICT
|
||||
|
||||
USR_CFLAGS = -D_NO_PROTO
|
||||
|
||||
# includes to install from this sub-project
|
||||
#
|
||||
INC += cvtFast.h
|
||||
INC += ellLib.h
|
||||
INC += envDefs.h
|
||||
INC += epicsAssert.h
|
||||
INC += errlog.h
|
||||
INC += epicsPrint.h
|
||||
INC += errMdef.h
|
||||
INC += error.h
|
||||
INC += fdmgr.h
|
||||
INC += freeList.h
|
||||
INC += gpHash.h
|
||||
INC += memDebugLib.h
|
||||
INC += tsDefs.h
|
||||
INC += bucketLib.h
|
||||
INC += pal.h
|
||||
INC += fdManager.h
|
||||
INC += osiTime.h
|
||||
INC += osiTimer.h
|
||||
INC += macLib.h
|
||||
INC += sigPipeIgnore.h
|
||||
INC += dbmf.h
|
||||
INC += epicsString.h
|
||||
INC += truncateFile.h
|
||||
INC += adjustment.h
|
||||
INC += postfix.h
|
||||
INC += sCalcPostfix.h
|
||||
INC += osiSleep.h
|
||||
INC += bsdSocketResource.h
|
||||
|
||||
# For WIN32 we supply getopt as part of libCom:
|
||||
INC_WIN32 := getopt.h
|
||||
|
||||
# general contents of library on all platforms
|
||||
#
|
||||
# system specific lines in RULES.Host figure out
|
||||
# 1) what object names (.o, .obj,...) to build
|
||||
# 2) where to find the sources: ., ./os/<ARCH_CLASS>, ./os/generic, ...
|
||||
#
|
||||
LIBSRCS += bucketLib.c
|
||||
LIBSRCS += cvtFast.c
|
||||
LIBSRCS += ellLib.c
|
||||
LIBSRCS += envSubr.c
|
||||
LIBSRCS += envData.c
|
||||
LIBSRCS += errlogUNIX.c
|
||||
LIBSRCS += errSymLib.c
|
||||
LIBSRCS += errSymTbl.c
|
||||
LIBSRCS += fdmgr.c
|
||||
LIBSRCS += freeListLib.c
|
||||
LIBSRCS += gpHashLib.c
|
||||
LIBSRCS += memDebugLib.c
|
||||
LIBSRCS += postfix.c
|
||||
LIBSRCS += calcPerform.c
|
||||
LIBSRCS += sCalcPostfix.c
|
||||
LIBSRCS += sCalcPerform.c
|
||||
LIBSRCS += realpath.c
|
||||
LIBSRCS += tsSubr.c
|
||||
LIBSRCS += assertUNIX.c
|
||||
LIBSRCS += macCore.c
|
||||
LIBSRCS += macUtil.c
|
||||
LIBSRCS += sigPipeIgnore.c
|
||||
LIBSRCS += dbmf.c
|
||||
LIBSRCS += epicsString.c
|
||||
LIBSRCS += truncateFile.c
|
||||
LIBSRCS += aToIPAddr.c
|
||||
LIBSRCS += adjustment.c
|
||||
LIBSRCS += bsdSockResource.c
|
||||
LIBSRCS += osiSleep.c
|
||||
LIBSRCS += bsdSockResCom.c
|
||||
|
||||
#
|
||||
# if CPLUSPLUS isnt empty then include C++ src codes
|
||||
# Note: After including/excluding files here,
|
||||
# e.g. the C++ stuff,
|
||||
# please check Com.def!
|
||||
#
|
||||
LIBSRCS += $(patsubst %,osiTime.cc,$(strip $(CPLUSPLUS)))
|
||||
LIBSRCS += $(patsubst %,osdTime.cc,$(strip $(CPLUSPLUS)))
|
||||
LIBSRCS += $(patsubst %,osiTimer.cc,$(strip $(CPLUSPLUS)))
|
||||
LIBSRCS += $(patsubst %,fdManager.cc,$(strip $(CPLUSPLUS)))
|
||||
|
||||
# WIN32 has no getopt, we add it to the Com lib,
|
||||
# special initialisation is done in winmain.c
|
||||
LIBSRCS_WIN32 := getopt.c
|
||||
LIBSRCS_WIN32 += $(patsubst %,dllmain.cc,$(strip $(CPLUSPLUS)))
|
||||
|
||||
# Library to build:
|
||||
# lib$(LIBRARY).a or ..dll/..exp/..lib
|
||||
#
|
||||
LIBRARY:=Com
|
||||
|
||||
# only for WIN32:
|
||||
# build LIBRARY as a DLL, use the specified def file
|
||||
LIBTYPE := SHARED
|
||||
|
||||
# libs needed for PROD and TESTPRODUCT
|
||||
PROD_LIBS := Com
|
||||
SYS_PROD_LIBS_WIN32 := ws2_32 advapi32
|
||||
|
||||
#USR_CFLAGS += -DTS_TEST
|
||||
#TESTPROD_SRCS=tsSubr.c
|
||||
#TESTPROD=testtsLib
|
||||
#TESTPROD=envtest
|
||||
#TESTPROD=osiTimeTest fdManagerTest
|
||||
|
||||
MAN3 = gpHash.3 freeList.3
|
||||
|
||||
# for bldErrSymTbl:
|
||||
#
|
||||
ERR_S_FILES += $(TOP)/src/as/asLib.h
|
||||
ERR_S_FILES += $(TOP)/src/db/dbAccess.h
|
||||
ERR_S_FILES += $(TOP)/src/db/devLib.h
|
||||
ERR_S_FILES += $(TOP)/src/db/devSup.h
|
||||
ERR_S_FILES += $(TOP)/src/db/drvSup.h
|
||||
ERR_S_FILES += $(TOP)/src/db/recSup.h
|
||||
ERR_S_FILES += $(TOP)/src/dbStatic/dbStaticLib.h
|
||||
ERR_S_FILES += $(TOP)/src/drv/ansi/drvEpvxi.h
|
||||
ERR_S_FILES += $(TOP)/src/drv/old/drvBitBusErr.h
|
||||
ERR_S_FILES += $(TOP)/src/drv/old/drvGpibErr.h
|
||||
ERR_S_FILES += ../tsDefs.h
|
||||
ERR_S_FILES += ../errMdef.h
|
||||
ERR_S_FILES += $(TOP)/src/cas/generic/casdef.h
|
||||
ERR_S_FILES += $(TOP)/src/gdd/gddAppFuncTable.h
|
||||
|
||||
include $(TOP)/config/RULES.Host
|
||||
|
||||
# The real dependecies seem to confuse GNUmake:
|
||||
# envData.c is rebuild every time...
|
||||
#envData.c: ../envDefs.h $(TOP)/config/CONFIG_ENV $(TOP)/config/CONFIG_SITE_ENV
|
||||
envData.c: ../envDefs.h ../bldEnvData.pl
|
||||
$(PERL) ../bldEnvData.pl $(TOP)/config
|
||||
|
||||
errSymTbl.c: $(ERR_S_FILES)
|
||||
$(PERL) ../makeStatTbl.pl $(ERR_S_FILES)
|
||||
|
||||
clean::
|
||||
@$(RM) errSymTbl.c envData.c
|
||||
|
||||
# EOF Makefile.Host for base/src/libCom
|
||||
@@ -1,107 +0,0 @@
|
||||
TOP = ../../..
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
|
||||
USR_INCLUDES = -I$(TOP)/src/include/os/vxWorks
|
||||
|
||||
VPATH = ../os/vxWorks
|
||||
|
||||
SRCS.c += ../cvtFast.c
|
||||
SRCS.c += ../gpHashLib.c
|
||||
SRCS.c += ../freeListLib.c
|
||||
SRCS.c += ../ellLib.c
|
||||
SRCS.c += ../envSubr.c
|
||||
SRCS.c += envData.c
|
||||
SRCS.c += ../errSymLib.c
|
||||
SRCS.c += ../postfix.c
|
||||
SRCS.c += ../calcPerform.c
|
||||
SRCS.c += ../sCalcPostfix.c
|
||||
SRCS.c += ../sCalcPerform.c
|
||||
SRCS.c += ../bucketLib.c
|
||||
SRCS.c += ../memDebugLib.c
|
||||
SRCS.c += ../tsSubr.c
|
||||
SRCS.c += ../pal.c
|
||||
SRCS.c += ../paldef.c
|
||||
SRCS.c += errSymTbl.c
|
||||
SRCS.c += ../errlogVX.c
|
||||
SRCS.c += ../assertVX.c
|
||||
SRCS.c += ../macCore.c
|
||||
SRCS.c += ../macUtil.c
|
||||
#SRCS.c += ../osiTimer.cc
|
||||
#SRCS.c += ../os/vxWorks/osdTime.cc
|
||||
SRCS.c += ../os/vxWorks/sigPipeIgnore.c
|
||||
SRCS.c += ../dbmf.c
|
||||
SRCS.c += ../epicsString.c
|
||||
SRCS.c += ../aToIPAddr.c
|
||||
SRCS.c += ../adjustment.c
|
||||
SRCS.c += ../bsdSockResCom.c
|
||||
SRCS.c += ../os/vxWorks/bsdSockResource.c
|
||||
SRCS.c += ../os/vxWorks/osiSleep.c
|
||||
|
||||
|
||||
LIBOBJS += cvtFast.o
|
||||
LIBOBJS += ellLib.o
|
||||
LIBOBJS += envData.o
|
||||
LIBOBJS += envSubr.o
|
||||
LIBOBJS += errSymLib.o
|
||||
LIBOBJS += errSymTbl.o
|
||||
LIBOBJS += postfix.o
|
||||
LIBOBJS += calcPerform.o
|
||||
LIBOBJS += sCalcPostfix.o
|
||||
LIBOBJS += sCalcPerform.o
|
||||
LIBOBJS += bucketLib.o
|
||||
LIBOBJS += tsSubr.o
|
||||
LIBOBJS += gpHashLib.o
|
||||
LIBOBJS += freeListLib.o
|
||||
LIBOBJS += pal.o
|
||||
LIBOBJS += paldef.o
|
||||
LIBOBJS += errlogVX.o
|
||||
LIBOBJS += assertVX.o
|
||||
LIBOBJS += macCore.o
|
||||
LIBOBJS += macUtil.o
|
||||
#LIBOBJS += osiTimer.o
|
||||
#LIBOBJS += osdTime.o
|
||||
LIBOBJS += sigPipeIgnore.o
|
||||
LIBOBJS += dbmf.o
|
||||
LIBOBJS += epicsString.o
|
||||
LIBOBJS += aToIPAddr.o
|
||||
LIBOBJS += adjustment.o
|
||||
LIBOBJS += bsdSockResCom.o
|
||||
LIBOBJS += bsdSockResource.o
|
||||
LIBOBJS += osiSleep.o
|
||||
|
||||
LIBNAME = libCom
|
||||
|
||||
MAN3 = gpHash.3 freeList.3
|
||||
|
||||
ERR_S_FILES += $(TOP)/src/as/asLib.h
|
||||
ERR_S_FILES += $(TOP)/src/db/dbAccess.h
|
||||
ERR_S_FILES += $(TOP)/src/db/devLib.h
|
||||
ERR_S_FILES += $(TOP)/src/db/devSup.h
|
||||
ERR_S_FILES += $(TOP)/src/db/drvSup.h
|
||||
ERR_S_FILES += $(TOP)/src/db/recSup.h
|
||||
ERR_S_FILES += $(TOP)/src/dbStatic/dbStaticLib.h
|
||||
ERR_S_FILES += $(TOP)/src/drv/ansi/drvEpvxi.h
|
||||
ERR_S_FILES += $(TOP)/src/drv/old/drvBitBusErr.h
|
||||
ERR_S_FILES += $(TOP)/src/drv/old/drvGpibErr.h
|
||||
ERR_S_FILES += ../tsDefs.h
|
||||
ERR_S_FILES += ../errMdef.h
|
||||
ERR_S_FILES += $(TOP)/src/cas/generic/casdef.h
|
||||
ERR_S_FILES += $(TOP)/src/gdd/gddAppFuncTable.h
|
||||
|
||||
include $(TOP)/config/RULES.Vx
|
||||
|
||||
clean::
|
||||
@$(RM) errSymTbl.c envData.c
|
||||
|
||||
# The (otherwise correct) $(TOP)... dependencies are handled wrong by GNUmake,
|
||||
# it rebuilds envData.c in any case:
|
||||
#envData.c: ../envDefs.h $(TOP)/config/CONFIG_ENV $(TOP)/config/CONFIG_SITE_ENV
|
||||
envData.c: ../envDefs.h
|
||||
$(PERL) ../bldEnvData.pl $(TOP)/config
|
||||
|
||||
errSymTbl.o: errSymTbl.c
|
||||
$(COMPILE.c) -o $@ $<
|
||||
|
||||
errSymTbl.c: $(ERR_S_FILES)
|
||||
$(PERL) ../makeStatTbl.pl $(ERR_S_FILES)
|
||||
|
||||
@@ -19,12 +19,6 @@ of this distribution.
|
||||
* .01 11-21-97 pmm Initial Implementation
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include "fast_lock.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include "osiThread.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsPrint.h"
|
||||
@@ -45,17 +44,17 @@
|
||||
* epicsAssert ()
|
||||
*
|
||||
* This forces assert failures into the log file and then
|
||||
* calls taskSuspend() instead of exit() so that we can debug
|
||||
* calls threadSuspend() instead of exit() so that we can debug
|
||||
* the problem.
|
||||
*/
|
||||
void epicsAssert (const char *pFile, const unsigned line, const char *pExp,
|
||||
const char *pAuthorName)
|
||||
{
|
||||
int taskId = taskIdSelf();
|
||||
threadId threadid = threadGetIdSelf();
|
||||
|
||||
epicsPrintf (
|
||||
"\n\n\n%s: A call to \"assert (%s)\" failed in %s at %d\n",
|
||||
taskName (taskId),
|
||||
threadGetName (threadid),
|
||||
pExp,
|
||||
pFile,
|
||||
line);
|
||||
@@ -63,8 +62,8 @@ void epicsAssert (const char *pFile, const unsigned line, const char *pExp,
|
||||
if (pAuthorName) {
|
||||
|
||||
epicsPrintf (
|
||||
"Please send a copy of the output from \"tt (0x%x)\" and a copy of this message\n",
|
||||
taskId);
|
||||
"Please send a copy of the output from \"tt (%p)\" and a copy of this message\n",
|
||||
threadid);
|
||||
|
||||
epicsPrintf (
|
||||
"to \"%s\" (the author of this call to assert()) or \"tech-talk@aps.anl.gov\"\n",
|
||||
@@ -74,8 +73,8 @@ void epicsAssert (const char *pFile, const unsigned line, const char *pExp,
|
||||
else {
|
||||
|
||||
epicsPrintf (
|
||||
"Please send a copy of the output from \"tt (0x%x)\" and a copy of this message\n",
|
||||
taskId);
|
||||
"Please send a copy of the output from \"tt (%p)\" and a copy of this message\n",
|
||||
threadid);
|
||||
|
||||
epicsPrintf (
|
||||
"to the author or \"tech-talk@aps.anl.gov\"\n");
|
||||
@@ -83,6 +82,6 @@ void epicsAssert (const char *pFile, const unsigned line, const char *pExp,
|
||||
}
|
||||
epicsPrintf ("This problem occurred in \"%s\"\n", epicsReleaseVersion);
|
||||
|
||||
taskSuspend (taskId);
|
||||
threadSuspend (threadid);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,11 +100,8 @@
|
||||
* double value between 0.00 and 1.00
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -89,10 +89,6 @@
|
||||
* FLASE expression element not found
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -59,10 +59,6 @@
|
||||
* double value between 0.00 and 1.00
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -92,10 +92,6 @@
|
||||
* UNKNOWN_ELEMENT unknown element found in the infix expression
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -267,8 +263,7 @@ static struct expression_element fetch_string_element = {
|
||||
"AA", 0, 0, OPERAND, SFETCH, /* fetch var */
|
||||
};
|
||||
|
||||
#if !defined(UNIX)
|
||||
static int strncasecmp(char *s1, char *s2, size_t n)
|
||||
static int strncasecmpPrivate(char *s1, char *s2, size_t n)
|
||||
{
|
||||
short i;
|
||||
for (i=0; i<(short)n && (*s1 || *s2); i++, s1++, s2++) {
|
||||
@@ -277,7 +272,6 @@ static int strncasecmp(char *s1, char *s2, size_t n)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* FIND_ELEMENT
|
||||
*
|
||||
@@ -293,7 +287,7 @@ static int find_element(pbuffer, pelement, pno_bytes, parg)
|
||||
/* compare the string to each element in the element table */
|
||||
*pelement = &elements[0];
|
||||
while ((*pelement)->element[0] != NULL){
|
||||
if (strncasecmp(pbuffer,(*pelement)->element, strlen((*pelement)->element)) == 0){
|
||||
if (strncasecmpPrivate(pbuffer,(*pelement)->element, strlen((*pelement)->element)) == 0){
|
||||
*pno_bytes += strlen((*pelement)->element);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@@ -100,11 +100,8 @@
|
||||
* double value between 0.00 and 1.00
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
47
src/libCom/cantProceed.c
Normal file
47
src/libCom/cantProceed.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* callocMustSucceed.c */
|
||||
|
||||
/* Author: Marty Kraimer Date: 04JAN99 */
|
||||
|
||||
/********************COPYRIGHT NOTIFICATION**********************************
|
||||
This software was developed under a United States Government license
|
||||
described on the COPYRIGHT_UniversityOfChicago file included as part
|
||||
of this distribution.
|
||||
****************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "errlog.h"
|
||||
#include "cantProceed.h"
|
||||
#include "osiThread.h"
|
||||
|
||||
void *callocMustSucceed(size_t count, size_t size, const char *errorMessage)
|
||||
{
|
||||
void *mem = calloc(count,size);
|
||||
if(mem==0) {
|
||||
errlogPrintf("%s callocMustSucceed failed count %d size %d\n",
|
||||
errorMessage,count,size);
|
||||
cantProceed(0);
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
|
||||
void *mallocMustSucceed(size_t size, const char *errorMessage)
|
||||
{
|
||||
void *mem = malloc(size);
|
||||
if(mem==0) {
|
||||
errlogPrintf("%s mallocMustSucceed failed size %d\n",
|
||||
errorMessage,size);
|
||||
cantProceed(0);
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
|
||||
void cantProceed(const char *errorMessage)
|
||||
{
|
||||
errlogPrintf("fatal error: %s\n",errorMessage);
|
||||
threadSuspend(threadGetIdSelf());
|
||||
}
|
||||
15
src/libCom/cantProceed.h
Normal file
15
src/libCom/cantProceed.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef INCcantProceedh
|
||||
#define INCcantProceedh
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void cantProceed(const char *errorMessage);
|
||||
void *callocMustSucceed(size_t count, size_t size, const char *errorMessage);
|
||||
void *mallocMustSucceed(size_t size, const char *errorMessage);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* cantProceedh */
|
||||
@@ -48,10 +48,7 @@
|
||||
* Also they are not used on vxWorks
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h> /* XPG2/XPG3/POSIX.1/FIPS151-1/ANSI-C */
|
||||
@@ -444,7 +441,7 @@ int epicsShareAPI cvtLongToString(
|
||||
}
|
||||
if(source<0) {
|
||||
if(source == LONG_MIN) {
|
||||
sprintf(pdest,"%ld", (long)LONG_MIN);
|
||||
sprintf(pdest,"%ld",(long)LONG_MIN);
|
||||
return((int)strlen(pdest));
|
||||
}
|
||||
*pdest++ = '-';
|
||||
|
||||
@@ -48,10 +48,7 @@
|
||||
* Also they are not used on vxWorks
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h> /* XPG2/XPG3/POSIX.1/FIPS151-1/ANSI-C */
|
||||
@@ -444,7 +441,7 @@ int epicsShareAPI cvtLongToString(
|
||||
}
|
||||
if(source<0) {
|
||||
if(source == LONG_MIN) {
|
||||
sprintf(pdest,"%ld", (long)LONG_MIN);
|
||||
sprintf(pdest,"%ld",(long)LONG_MIN);
|
||||
return((int)strlen(pdest));
|
||||
}
|
||||
*pdest++ = '-';
|
||||
|
||||
@@ -9,18 +9,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <semLib.h>
|
||||
#else
|
||||
#define SEM_ID int
|
||||
#define semGive(x)
|
||||
#define semTake(x,y)
|
||||
#define semBCreate(x,y) 0
|
||||
#define SEM_Q_PRIORITY 0
|
||||
#define SEM_FULL 0
|
||||
#endif
|
||||
#include "osiSem.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "ellLib.h"
|
||||
@@ -43,7 +34,7 @@ typedef struct itemHeader{
|
||||
|
||||
typedef struct dbmfPrivate {
|
||||
ELLLIST chunkList;
|
||||
SEM_ID sem;
|
||||
semId sem;
|
||||
size_t size;
|
||||
size_t allocSize;
|
||||
int chunkItems;
|
||||
@@ -65,7 +56,7 @@ int epicsShareAPI dbmfInit(size_t size, int chunkItems)
|
||||
}
|
||||
pdbmfPvt = &dbmfPvt;
|
||||
ellInit(&pdbmfPvt->chunkList);
|
||||
pdbmfPvt->sem = semBCreate(SEM_Q_PRIORITY,SEM_FULL);
|
||||
pdbmfPvt->sem = semMutexCreate();
|
||||
/*allign to at least a double*/
|
||||
pdbmfPvt->size = size + size%sizeof(double);
|
||||
pdbmfPvt->allocSize = pdbmfPvt->size + sizeof(itemHeader);
|
||||
@@ -88,7 +79,7 @@ void* epicsShareAPI dbmfMalloc(size_t size)
|
||||
itemHeader *pitemHeader;
|
||||
|
||||
if(!pdbmfPvt) dbmfInit(DBMF_SIZE,DBMF_INITIAL_ITEMS);
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
pfreeList = &pdbmfPvt->freeList;
|
||||
if(*pfreeList == NULL) {
|
||||
int i;
|
||||
@@ -98,7 +89,7 @@ void* epicsShareAPI dbmfMalloc(size_t size)
|
||||
nbytesTotal = pdbmfPvt->chunkSize + sizeof(chunkNode);
|
||||
pmem = (char *)malloc(nbytesTotal);
|
||||
if(!pmem) {
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
printf("dbmfMalloc malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
@@ -128,7 +119,7 @@ void* epicsShareAPI dbmfMalloc(size_t size)
|
||||
pitemHeader->pchunkNode = NULL;
|
||||
if(dbmfDebug) printf("dbmfMalloc: size %d mem %p\n",size,pmem);
|
||||
}
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
return((void *)(pmem + sizeof(itemHeader)));
|
||||
}
|
||||
|
||||
@@ -145,7 +136,7 @@ void epicsShareAPI dbmfFree(void* mem)
|
||||
return;
|
||||
}
|
||||
pmem -= sizeof(itemHeader);
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
pitemHeader = (itemHeader *)pmem;
|
||||
if(!pitemHeader->pchunkNode) {
|
||||
if(dbmfDebug) printf("dbmfGree: mem %p\n",pmem);
|
||||
@@ -159,7 +150,7 @@ void epicsShareAPI dbmfFree(void* mem)
|
||||
*pnextFree = *pfreeList; *pfreeList = pnextFree;
|
||||
pdbmfPvt->nAlloc--; pdbmfPvt->nFree++;
|
||||
}
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
}
|
||||
|
||||
int epicsShareAPI dbmfShow(int level)
|
||||
@@ -186,13 +177,13 @@ int epicsShareAPI dbmfShow(int level)
|
||||
if(level>1) {
|
||||
void **pnextFree;;
|
||||
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
pnextFree = (void**)pdbmfPvt->freeList;
|
||||
while(pnextFree) {
|
||||
printf("%p\n",*pnextFree);
|
||||
pnextFree = (void**)*pnextFree;
|
||||
}
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -206,11 +197,11 @@ void epicsShareAPI dbmfFreeChunks(void)
|
||||
printf("dbmfFreeChunks called but dbmfInit never called\n");
|
||||
return;
|
||||
}
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
if(pdbmfPvt->nFree
|
||||
!= (pdbmfPvt->chunkItems * ellCount(&pdbmfPvt->chunkList))) {
|
||||
printf("dbmfFinish: not all free\n");
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
return;
|
||||
}
|
||||
pchunkNode = (chunkNode *)ellFirst(&pdbmfPvt->chunkList);
|
||||
@@ -221,5 +212,5 @@ void epicsShareAPI dbmfFreeChunks(void)
|
||||
pchunkNode = pnext;
|
||||
}
|
||||
pdbmfPvt->nFree = 0; pdbmfPvt->freeList = NULL;
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
}
|
||||
|
||||
@@ -9,18 +9,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <semLib.h>
|
||||
#else
|
||||
#define SEM_ID int
|
||||
#define semGive(x)
|
||||
#define semTake(x,y)
|
||||
#define semBCreate(x,y) 0
|
||||
#define SEM_Q_PRIORITY 0
|
||||
#define SEM_FULL 0
|
||||
#endif
|
||||
#include "osiSem.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "ellLib.h"
|
||||
@@ -43,7 +34,7 @@ typedef struct itemHeader{
|
||||
|
||||
typedef struct dbmfPrivate {
|
||||
ELLLIST chunkList;
|
||||
SEM_ID sem;
|
||||
semId sem;
|
||||
size_t size;
|
||||
size_t allocSize;
|
||||
int chunkItems;
|
||||
@@ -65,7 +56,7 @@ int epicsShareAPI dbmfInit(size_t size, int chunkItems)
|
||||
}
|
||||
pdbmfPvt = &dbmfPvt;
|
||||
ellInit(&pdbmfPvt->chunkList);
|
||||
pdbmfPvt->sem = semBCreate(SEM_Q_PRIORITY,SEM_FULL);
|
||||
pdbmfPvt->sem = semMutexCreate();
|
||||
/*allign to at least a double*/
|
||||
pdbmfPvt->size = size + size%sizeof(double);
|
||||
pdbmfPvt->allocSize = pdbmfPvt->size + sizeof(itemHeader);
|
||||
@@ -88,7 +79,7 @@ void* epicsShareAPI dbmfMalloc(size_t size)
|
||||
itemHeader *pitemHeader;
|
||||
|
||||
if(!pdbmfPvt) dbmfInit(DBMF_SIZE,DBMF_INITIAL_ITEMS);
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
pfreeList = &pdbmfPvt->freeList;
|
||||
if(*pfreeList == NULL) {
|
||||
int i;
|
||||
@@ -98,7 +89,7 @@ void* epicsShareAPI dbmfMalloc(size_t size)
|
||||
nbytesTotal = pdbmfPvt->chunkSize + sizeof(chunkNode);
|
||||
pmem = (char *)malloc(nbytesTotal);
|
||||
if(!pmem) {
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
printf("dbmfMalloc malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
@@ -128,7 +119,7 @@ void* epicsShareAPI dbmfMalloc(size_t size)
|
||||
pitemHeader->pchunkNode = NULL;
|
||||
if(dbmfDebug) printf("dbmfMalloc: size %d mem %p\n",size,pmem);
|
||||
}
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
return((void *)(pmem + sizeof(itemHeader)));
|
||||
}
|
||||
|
||||
@@ -145,7 +136,7 @@ void epicsShareAPI dbmfFree(void* mem)
|
||||
return;
|
||||
}
|
||||
pmem -= sizeof(itemHeader);
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
pitemHeader = (itemHeader *)pmem;
|
||||
if(!pitemHeader->pchunkNode) {
|
||||
if(dbmfDebug) printf("dbmfGree: mem %p\n",pmem);
|
||||
@@ -159,7 +150,7 @@ void epicsShareAPI dbmfFree(void* mem)
|
||||
*pnextFree = *pfreeList; *pfreeList = pnextFree;
|
||||
pdbmfPvt->nAlloc--; pdbmfPvt->nFree++;
|
||||
}
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
}
|
||||
|
||||
int epicsShareAPI dbmfShow(int level)
|
||||
@@ -186,13 +177,13 @@ int epicsShareAPI dbmfShow(int level)
|
||||
if(level>1) {
|
||||
void **pnextFree;;
|
||||
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
pnextFree = (void**)pdbmfPvt->freeList;
|
||||
while(pnextFree) {
|
||||
printf("%p\n",*pnextFree);
|
||||
pnextFree = (void**)*pnextFree;
|
||||
}
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -206,11 +197,11 @@ void epicsShareAPI dbmfFreeChunks(void)
|
||||
printf("dbmfFreeChunks called but dbmfInit never called\n");
|
||||
return;
|
||||
}
|
||||
semTake(pdbmfPvt->sem,WAIT_FOREVER);
|
||||
semMutexTake(pdbmfPvt->sem);
|
||||
if(pdbmfPvt->nFree
|
||||
!= (pdbmfPvt->chunkItems * ellCount(&pdbmfPvt->chunkList))) {
|
||||
printf("dbmfFinish: not all free\n");
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
return;
|
||||
}
|
||||
pchunkNode = (chunkNode *)ellFirst(&pdbmfPvt->chunkList);
|
||||
@@ -221,5 +212,5 @@ void epicsShareAPI dbmfFreeChunks(void)
|
||||
pchunkNode = pnext;
|
||||
}
|
||||
pdbmfPvt->nFree = 0; pdbmfPvt->freeList = NULL;
|
||||
semGive(pdbmfPvt->sem);
|
||||
semMutexGive(pdbmfPvt->sem);
|
||||
}
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsAssert.h"
|
||||
#include "ellLib.h"
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsAssert.h"
|
||||
#include "ellLib.h"
|
||||
|
||||
21
src/libCom/env/envSubr.c
vendored
21
src/libCom/env/envSubr.c
vendored
@@ -76,12 +76,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <inetLib.h>
|
||||
#include <envLib.h>
|
||||
#include <errnoLib.h>
|
||||
#endif
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "errMdef.h"
|
||||
#include "envDefs.h"
|
||||
@@ -426,10 +420,6 @@ const ENV_PARAM *pParam, /* I pointer to config param structure */
|
||||
char *value /* I pointer to value string */
|
||||
)
|
||||
{
|
||||
#ifndef vxWorks
|
||||
fprintf(stderr, "envSetConfigParam can only be used under vxWorks\n");
|
||||
return -1L;
|
||||
#else
|
||||
long retCode = 0;
|
||||
int status;
|
||||
char *pEnv;
|
||||
@@ -447,7 +437,7 @@ char *value /* I pointer to value string */
|
||||
"Failed to set environment parameter \"%s\" to \"%s\" because \"%s\"\n",
|
||||
pParam->name,
|
||||
value,
|
||||
strerror (errnoGet()));
|
||||
strerror (errno));
|
||||
return -1L;
|
||||
}
|
||||
|
||||
@@ -463,17 +453,10 @@ char *value /* I pointer to value string */
|
||||
"Failed to set environment parameter \"%s\" to \"%s\" because \"%s\"\n",
|
||||
pParam->name,
|
||||
value,
|
||||
strerror (errnoGet()));
|
||||
strerror (errno));
|
||||
retCode = -1L;
|
||||
}
|
||||
/*
|
||||
* vxWorks copies into a private buffer
|
||||
* (this does not match UNIX behavior)
|
||||
*/
|
||||
free (pEnv);
|
||||
|
||||
return retCode;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*+/subr**********************************************************************
|
||||
|
||||
@@ -76,12 +76,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <inetLib.h>
|
||||
#include <envLib.h>
|
||||
#include <errnoLib.h>
|
||||
#endif
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "errMdef.h"
|
||||
#include "envDefs.h"
|
||||
@@ -426,10 +420,6 @@ const ENV_PARAM *pParam, /* I pointer to config param structure */
|
||||
char *value /* I pointer to value string */
|
||||
)
|
||||
{
|
||||
#ifndef vxWorks
|
||||
fprintf(stderr, "envSetConfigParam can only be used under vxWorks\n");
|
||||
return -1L;
|
||||
#else
|
||||
long retCode = 0;
|
||||
int status;
|
||||
char *pEnv;
|
||||
@@ -447,7 +437,7 @@ char *value /* I pointer to value string */
|
||||
"Failed to set environment parameter \"%s\" to \"%s\" because \"%s\"\n",
|
||||
pParam->name,
|
||||
value,
|
||||
strerror (errnoGet()));
|
||||
strerror (errno));
|
||||
return -1L;
|
||||
}
|
||||
|
||||
@@ -463,17 +453,10 @@ char *value /* I pointer to value string */
|
||||
"Failed to set environment parameter \"%s\" to \"%s\" because \"%s\"\n",
|
||||
pParam->name,
|
||||
value,
|
||||
strerror (errnoGet()));
|
||||
strerror (errno));
|
||||
retCode = -1L;
|
||||
}
|
||||
/*
|
||||
* vxWorks copies into a private buffer
|
||||
* (this does not match UNIX behavior)
|
||||
*/
|
||||
free (pEnv);
|
||||
|
||||
return retCode;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*+/subr**********************************************************************
|
||||
|
||||
@@ -70,16 +70,8 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include <types.h>
|
||||
#include <symLib.h>
|
||||
#include <errnoLib.h>
|
||||
|
||||
extern SYMTAB_ID statSymTbl;
|
||||
|
||||
#endif
|
||||
#include "cantProceed.h"
|
||||
#include <errno.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "dbDefs.h"
|
||||
@@ -87,18 +79,7 @@ extern SYMTAB_ID statSymTbl;
|
||||
#include "errSymTbl.h"
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
static unsigned short errhash(long errNum);
|
||||
#else /*__STDC__*/
|
||||
static unsigned short errhash();
|
||||
#endif /*__STDC__*/
|
||||
|
||||
|
||||
#ifdef vxWorks
|
||||
#define MYERRNO (errnoGet()&0xffff)
|
||||
#else
|
||||
#define MYERRNO errno
|
||||
#endif
|
||||
|
||||
typedef struct errnumnode {
|
||||
ELLNODE node;
|
||||
@@ -141,15 +122,8 @@ int epicsShareAPI errSymBld()
|
||||
unsigned short hashInd;
|
||||
|
||||
if(initialized) return(0);
|
||||
hashtable = (ERRNUMNODE**)calloc(NHASH, sizeof(ERRNUMNODE*));
|
||||
if(!hashtable) {
|
||||
printf("errSymBld: Can't allocate storage\n");
|
||||
#ifdef vxWorks
|
||||
taskSuspend(0);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
hashtable = (ERRNUMNODE**)callocMustSucceed
|
||||
(NHASH, sizeof(ERRNUMNODE*),"errSymBld");
|
||||
for (i = 0; i < errSymTbl->nsymbols; i++, errArray++) {
|
||||
modnum = errArray->errNum >> 16;
|
||||
if (modnum < 501) {
|
||||
@@ -186,14 +160,7 @@ int epicsShareAPI errSymBld()
|
||||
* HASH
|
||||
* returns the hash index of errNum
|
||||
****************************************************************/
|
||||
#ifdef __STDC__
|
||||
static
|
||||
unsigned short errhash(long errNum)
|
||||
#else
|
||||
static
|
||||
unsigned short errhash(errNum)
|
||||
long errNum;
|
||||
#endif /* __STDC__ */
|
||||
static unsigned short errhash(long errNum)
|
||||
{
|
||||
unsigned short modnum;
|
||||
unsigned short errnum;
|
||||
@@ -207,79 +174,22 @@ unsigned short errnum;
|
||||
* ERRSYMBOLADD
|
||||
* adds symbols to the master errnumlist as compiled from errSymTbl.c
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI errSymbolAdd (long errNum,char *name)
|
||||
#else
|
||||
int epicsShareAPI errSymbolAdd (errNum,name)
|
||||
long errNum;
|
||||
char *name;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
ELLLIST *perrnumlist = &errnumlist;
|
||||
ERRNUMNODE *pNew;
|
||||
|
||||
pNew = (ERRNUMNODE*)calloc(1, sizeof(ERRNUMNODE));
|
||||
if(!pNew) {
|
||||
printf("errSymbolAdd: Can't allocate storage\n");
|
||||
#ifdef vxWorks
|
||||
taskSuspend(0);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
pNew = (ERRNUMNODE*)callocMustSucceed(1,sizeof(ERRNUMNODE),"errSymbolAdd");
|
||||
pNew->errNum = errNum;
|
||||
pNew->message = name;
|
||||
ellAdd(perrnumlist,(ELLNODE*)pNew);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* UNIXSYMFIND
|
||||
***************************************************************/
|
||||
/*
|
||||
* Use of sys_nerr and sys_errlist in this routine
|
||||
* present portability problems
|
||||
*
|
||||
* ANSI strerror() provides this functionality
|
||||
* so this is hopefully no longer needed
|
||||
* joh 10-02-96
|
||||
*
|
||||
*/
|
||||
#if 0
|
||||
#ifndef vxWorks
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI UnixSymFind(long status, char *pname, long *pvalue)
|
||||
#else
|
||||
int epicsShareAPI UnixSymFind(status, pname, pvalue)
|
||||
long status;
|
||||
char *pname;
|
||||
long *pvalue;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
if(!initialized) errSymBld();
|
||||
if (status >= sys_nerr || status < 1) {
|
||||
*pvalue = -1;
|
||||
return(0);
|
||||
}
|
||||
strcpy(pname, sys_errlist[status]);
|
||||
*pvalue = status;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* MODSYMFIND
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI ModSymFind(long status, char *pname, long *pvalue)
|
||||
#else
|
||||
int epicsShareAPI ModSymFind(status, pname, pvalue)
|
||||
long status;
|
||||
char *pname;
|
||||
long *pvalue;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
unsigned short modNum;
|
||||
unsigned short hashInd;
|
||||
@@ -312,29 +222,15 @@ int epicsShareAPI ModSymFind(status, pname, pvalue)
|
||||
/****************************************************************
|
||||
* ERRSYMFIND
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI errSymFind(long status, char *name)
|
||||
#else
|
||||
/* errSymFind - Locate error symbol */
|
||||
int epicsShareAPI errSymFind(status, name)
|
||||
long status;
|
||||
char *name;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
long value;
|
||||
#ifdef vxWorks
|
||||
unsigned char type;
|
||||
#endif
|
||||
unsigned short modnum;
|
||||
|
||||
if (!initialized) errSymBld();
|
||||
|
||||
modnum = (unsigned short) (status >> 16);
|
||||
if (modnum <= 500)
|
||||
#ifdef vxWorks
|
||||
symFindByValue((SYMTAB_ID)statSymTbl, status, name,(int*) &value, (SYM_TYPE*)&type);
|
||||
#else
|
||||
{
|
||||
if (modnum <= 500) {
|
||||
const char *pStr = strerror(status);
|
||||
if (pStr) {
|
||||
strcpy(name,strerror(status));
|
||||
@@ -343,10 +239,9 @@ int epicsShareAPI errSymFind(status, name)
|
||||
else {
|
||||
sprintf(name,"err = %ld", status);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
} else {
|
||||
ModSymFind(status, name, &value);
|
||||
}
|
||||
if (value != status)
|
||||
return (-1);
|
||||
else
|
||||
@@ -357,11 +252,7 @@ int epicsShareAPI errSymFind(status, name)
|
||||
/****************************************************************
|
||||
* errSymDump
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
void epicsShareAPI errSymDump()
|
||||
#else
|
||||
void epicsShareAPI errSymDump()
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
ERRNUMNODE **phashnode = NULL;
|
||||
ERRNUMNODE *pNextNode;
|
||||
@@ -400,12 +291,7 @@ int firstTime;
|
||||
/****************************************************************
|
||||
* errSymTestPrint
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
void epicsShareAPI errSymTestPrint(long errNum)
|
||||
#else
|
||||
void epicsShareAPI errSymTestPrint(errNum)
|
||||
long errNum;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
char message[256];
|
||||
unsigned short modnum;
|
||||
@@ -431,14 +317,8 @@ long errNum;
|
||||
/****************************************************************
|
||||
* ERRSYMTEST
|
||||
****************************************************************/
|
||||
#ifdef __STDC__
|
||||
void epicsShareAPI errSymTest(unsigned short modnum, unsigned short begErrNum, unsigned short endErrNum)
|
||||
#else
|
||||
void epicsShareAPI errSymTest(modnum, begErrNum, endErrNum)
|
||||
unsigned short modnum;
|
||||
unsigned short begErrNum;
|
||||
unsigned short endErrNum;
|
||||
#endif /* __STDC__ */
|
||||
void epicsShareAPI errSymTest(unsigned short modnum,
|
||||
unsigned short begErrNum, unsigned short endErrNum)
|
||||
{
|
||||
long errNum;
|
||||
unsigned short errnum;
|
||||
|
||||
@@ -14,25 +14,22 @@ of this distribution.
|
||||
* NOTE: Original version is adaptation of old version of errPrintfVX.c
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <taskLib.h>
|
||||
#include <intLib.h>
|
||||
#include <semLib.h>
|
||||
#include <vxLib.h>
|
||||
#include <errnoLib.h>
|
||||
#include <logLib.h>
|
||||
|
||||
#define ERRLOG_INIT
|
||||
#include "osiThread.h"
|
||||
#include "osiSem.h"
|
||||
#include "osiInterrupt.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "epicsAssert.h"
|
||||
#include "errMdef.h"
|
||||
#include "error.h"
|
||||
#include "ellLib.h"
|
||||
#include "task_params.h"
|
||||
#include "errlog.h"
|
||||
|
||||
|
||||
@@ -53,7 +50,6 @@ LOCAL char * msgbufGetSend(void);
|
||||
LOCAL void msgbufFreeSend(void);
|
||||
|
||||
LOCAL void *pvtCalloc(size_t count,size_t size);
|
||||
LOCAL void pvtSemTake(SEM_ID semid);
|
||||
|
||||
typedef struct listenerNode{
|
||||
ELLNODE node;
|
||||
@@ -68,9 +64,9 @@ typedef struct msgNode {
|
||||
} msgNode;
|
||||
|
||||
LOCAL struct {
|
||||
SEM_ID errlogTaskWaitForWork;
|
||||
SEM_ID msgQueueLock;
|
||||
SEM_ID listenerLock;
|
||||
semId errlogTaskWaitForWork;
|
||||
semId msgQueueLock;
|
||||
semId listenerLock;
|
||||
ELLLIST listenerList;
|
||||
ELLLIST msgQueue;
|
||||
msgNode *pnextSend;
|
||||
@@ -86,8 +82,9 @@ epicsShareFunc int epicsShareAPIV errlogPrintf( const char *pFormat, ...)
|
||||
va_list pvar;
|
||||
int nchar;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogPrintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogPrintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -103,8 +100,9 @@ epicsShareFunc int epicsShareAPIV errlogVprintf(
|
||||
int nchar;
|
||||
char *pbuffer;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogVprintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogVprintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -117,12 +115,11 @@ epicsShareFunc int epicsShareAPIV errlogVprintf(
|
||||
|
||||
epicsShareFunc int epicsShareAPI errlogMessage(const char *message)
|
||||
{
|
||||
int status;
|
||||
char *pbuffer;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
status = logMsg ("errlogMessage called from interrupt level %s",
|
||||
message,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogMessage called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -139,8 +136,9 @@ epicsShareFunc int epicsShareAPIV errlogSevPrintf(
|
||||
va_list pvar;
|
||||
int nchar;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogSevPrintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogSevPrintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -159,8 +157,9 @@ epicsShareFunc int epicsShareAPIV errlogSevVprintf(
|
||||
int totalChar=0;
|
||||
|
||||
if(pvtData.sevToLog>severity) return(0);
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogSevVprintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogSevVprintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -206,10 +205,10 @@ epicsShareFunc void epicsShareAPI errlogAddListener(
|
||||
|
||||
errlogInit(0);
|
||||
plistenerNode = pvtCalloc(1,sizeof(listenerNode));
|
||||
pvtSemTake(pvtData.listenerLock);
|
||||
semMutexTake(pvtData.listenerLock);
|
||||
plistenerNode->listener = listener;
|
||||
ellAdd(&pvtData.listenerList,&plistenerNode->node);
|
||||
semGive(pvtData.listenerLock);
|
||||
semMutexGive(pvtData.listenerLock);
|
||||
}
|
||||
|
||||
epicsShareFunc void epicsShareAPI errlogRemoveListener(
|
||||
@@ -218,7 +217,7 @@ epicsShareFunc void epicsShareAPI errlogRemoveListener(
|
||||
listenerNode *plistenerNode;
|
||||
|
||||
errlogInit(0);
|
||||
pvtSemTake(pvtData.listenerLock);
|
||||
semMutexTake(pvtData.listenerLock);
|
||||
plistenerNode = (listenerNode *)ellFirst(&pvtData.listenerList);
|
||||
while(plistenerNode) {
|
||||
if(plistenerNode->listener==listener) {
|
||||
@@ -228,7 +227,7 @@ epicsShareFunc void epicsShareAPI errlogRemoveListener(
|
||||
}
|
||||
plistenerNode = (listenerNode *)ellNext(&plistenerNode->node);
|
||||
}
|
||||
semGive(pvtData.listenerLock);
|
||||
semMutexGive(pvtData.listenerLock);
|
||||
if(!plistenerNode) printf("errlogRemoveListener did not find listener\n");
|
||||
}
|
||||
|
||||
@@ -247,8 +246,8 @@ epicsShareFunc void epicsShareAPIV errPrintf(long status, const char *pFileName,
|
||||
int nchar;
|
||||
int totalChar=0;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errPrintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage("errPrintf called from interrupt level\n");
|
||||
return;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -259,7 +258,7 @@ epicsShareFunc void epicsShareAPIV errPrintf(long status, const char *pFileName,
|
||||
pFileName, lineno);
|
||||
pnext += nchar; totalChar += nchar;
|
||||
}
|
||||
if(status==0) status = MYERRNO;
|
||||
if(status==0) status = errno;
|
||||
if(status>0) {
|
||||
int rtnval;
|
||||
char name[256];
|
||||
@@ -288,36 +287,27 @@ epicsShareFunc void epicsShareAPIV errPrintf(long status, const char *pFileName,
|
||||
msgbufSetSize(totalChar);
|
||||
}
|
||||
|
||||
#define optionsSemM SEM_Q_PRIORITY|SEM_DELETE_SAFE|SEM_INVERSION_SAFE
|
||||
epicsShareFunc int epicsShareAPI errlogInit(int bufsize)
|
||||
{
|
||||
static int errlogInitFlag=0;
|
||||
void *pbuffer;;
|
||||
|
||||
if(!vxTas(&errlogInitFlag)) return(0);
|
||||
if(errlogInitFlag) return(0);
|
||||
errlogInitFlag = 1;
|
||||
if(bufsize<BUFFER_SIZE) bufsize = BUFFER_SIZE;
|
||||
pvtData.buffersize = bufsize;
|
||||
ellInit(&pvtData.listenerList);
|
||||
ellInit(&pvtData.msgQueue);
|
||||
pvtData.toConsole = TRUE;
|
||||
if((pvtData.errlogTaskWaitForWork=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL) {
|
||||
logMsg("semBCreate failed in errlogInit",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
if((pvtData.listenerLock=semMCreate(optionsSemM))==NULL) {
|
||||
logMsg("semMCreate failed in errlogInit",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
if((pvtData.msgQueueLock=semMCreate(optionsSemM))==NULL) {
|
||||
logMsg("semMCreate failed in errlogInit",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
pvtData.errlogTaskWaitForWork = semBinaryCreate(semEmpty);
|
||||
pvtData.listenerLock = semMutexCreate();
|
||||
pvtData.msgQueueLock = semMutexCreate();
|
||||
/*Allow an extra MAX_MESSAGE_SIZE for extra margain of safety*/
|
||||
pbuffer = pvtCalloc(pvtData.buffersize+MAX_MESSAGE_SIZE,sizeof(char));
|
||||
pvtData.pbuffer = pbuffer;
|
||||
taskSpawn(ERRLOG_NAME,ERRLOG_PRI,ERRLOG_OPT,
|
||||
ERRLOG_STACK,(FUNCPTR)errlogTask,
|
||||
0,0,0,0,0,0,0,0,0,0);
|
||||
threadCreate("errlog",threadPriorityLow,
|
||||
threadGetStackSize(threadStackSmall),
|
||||
(THREADFUNC)errlogTask,0);
|
||||
/*For now make sure iocLogInit is called*/
|
||||
iocLogInit();
|
||||
return(0);
|
||||
@@ -330,16 +320,16 @@ LOCAL void errlogTask(void)
|
||||
while(TRUE) {
|
||||
char *pmessage;
|
||||
|
||||
pvtSemTake(pvtData.errlogTaskWaitForWork);
|
||||
semBinaryTake(pvtData.errlogTaskWaitForWork);
|
||||
while((pmessage = msgbufGetSend())) {
|
||||
pvtSemTake(pvtData.listenerLock);
|
||||
semMutexTake(pvtData.listenerLock);
|
||||
if(pvtData.toConsole) printf("%s",pmessage);
|
||||
plistenerNode = (listenerNode *)ellFirst(&pvtData.listenerList);
|
||||
while(plistenerNode) {
|
||||
(*plistenerNode->listener)(pmessage);
|
||||
plistenerNode = (listenerNode *)ellNext(&plistenerNode->node);
|
||||
}
|
||||
semGive(pvtData.listenerLock);
|
||||
semMutexGive(pvtData.listenerLock);
|
||||
msgbufFreeSend();
|
||||
}
|
||||
}
|
||||
@@ -381,7 +371,7 @@ LOCAL char *msgbufGetFree()
|
||||
{
|
||||
msgNode *pnextSend;
|
||||
|
||||
pvtSemTake(pvtData.msgQueueLock);
|
||||
semMutexTake(pvtData.msgQueueLock);
|
||||
if((ellCount(&pvtData.msgQueue) == 0) && pvtData.missedMessages) {
|
||||
int nchar;
|
||||
|
||||
@@ -395,7 +385,7 @@ LOCAL char *msgbufGetFree()
|
||||
pvtData.pnextSend = pnextSend = msgbufGetNode();
|
||||
if(pnextSend) return(pnextSend->message);
|
||||
++pvtData.missedMessages;
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -427,8 +417,8 @@ LOCAL void msgbufSetSize(int size)
|
||||
pnextSend->length = size+1;
|
||||
}
|
||||
ellAdd(&pvtData.msgQueue,&pnextSend->node);
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semGive(pvtData.errlogTaskWaitForWork);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
semBinaryGive(pvtData.errlogTaskWaitForWork);
|
||||
}
|
||||
|
||||
/*errlogTask is the only task that calls msgbufGetSend and msgbufFreeSend*/
|
||||
@@ -439,9 +429,9 @@ LOCAL char * msgbufGetSend()
|
||||
{
|
||||
msgNode *pnextSend;
|
||||
|
||||
pvtSemTake(pvtData.msgQueueLock);
|
||||
semMutexTake(pvtData.msgQueueLock);
|
||||
pnextSend = (msgNode *)ellFirst(&pvtData.msgQueue);
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
if(!pnextSend) return(0);
|
||||
return(pnextSend->message);
|
||||
}
|
||||
@@ -450,14 +440,14 @@ LOCAL void msgbufFreeSend()
|
||||
{
|
||||
msgNode *pnextSend;
|
||||
|
||||
pvtSemTake(pvtData.msgQueueLock);
|
||||
semMutexTake(pvtData.msgQueueLock);
|
||||
pnextSend = (msgNode *)ellFirst(&pvtData.msgQueue);
|
||||
if(!pnextSend) {
|
||||
printf("errlog: msgbufFreeSend logic error\n");
|
||||
taskSuspend(0);
|
||||
threadSuspend(threadGetIdSelf());
|
||||
}
|
||||
ellDelete(&pvtData.msgQueue,&pnextSend->node);
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
}
|
||||
|
||||
LOCAL void *pvtCalloc(size_t count,size_t size)
|
||||
@@ -467,15 +457,7 @@ LOCAL void *pvtCalloc(size_t count,size_t size)
|
||||
pmem = calloc(count,size);
|
||||
if(!pmem) {
|
||||
printf("calloc failed in errlog\n");
|
||||
taskSuspend(0);
|
||||
threadSuspend(threadGetIdSelf());
|
||||
}
|
||||
return(pmem);
|
||||
}
|
||||
|
||||
LOCAL void pvtSemTake(SEM_ID semid)
|
||||
{
|
||||
if(semTake(semid,WAIT_FOREVER)!=OK) {
|
||||
logMsg("epicsPrint: semTake returned error\n",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,6 @@ typedef struct /* ERRSYMTAB - symbol table */
|
||||
} ERRSYMTAB;
|
||||
typedef ERRSYMTAB *ERRSYMTAB_ID;
|
||||
|
||||
#ifdef vxWorks
|
||||
#define MYERRNO (errnoGet()&0xffff)
|
||||
#else
|
||||
#define MYERRNO errno
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
struct errSet { /* This defines one module error set */
|
||||
long number; /* dimension of err strings */
|
||||
|
||||
@@ -70,16 +70,8 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include <types.h>
|
||||
#include <symLib.h>
|
||||
#include <errnoLib.h>
|
||||
|
||||
extern SYMTAB_ID statSymTbl;
|
||||
|
||||
#endif
|
||||
#include "cantProceed.h"
|
||||
#include <errno.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "dbDefs.h"
|
||||
@@ -87,18 +79,7 @@ extern SYMTAB_ID statSymTbl;
|
||||
#include "errSymTbl.h"
|
||||
|
||||
|
||||
#ifdef __STDC__
|
||||
static unsigned short errhash(long errNum);
|
||||
#else /*__STDC__*/
|
||||
static unsigned short errhash();
|
||||
#endif /*__STDC__*/
|
||||
|
||||
|
||||
#ifdef vxWorks
|
||||
#define MYERRNO (errnoGet()&0xffff)
|
||||
#else
|
||||
#define MYERRNO errno
|
||||
#endif
|
||||
|
||||
typedef struct errnumnode {
|
||||
ELLNODE node;
|
||||
@@ -141,15 +122,8 @@ int epicsShareAPI errSymBld()
|
||||
unsigned short hashInd;
|
||||
|
||||
if(initialized) return(0);
|
||||
hashtable = (ERRNUMNODE**)calloc(NHASH, sizeof(ERRNUMNODE*));
|
||||
if(!hashtable) {
|
||||
printf("errSymBld: Can't allocate storage\n");
|
||||
#ifdef vxWorks
|
||||
taskSuspend(0);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
hashtable = (ERRNUMNODE**)callocMustSucceed
|
||||
(NHASH, sizeof(ERRNUMNODE*),"errSymBld");
|
||||
for (i = 0; i < errSymTbl->nsymbols; i++, errArray++) {
|
||||
modnum = errArray->errNum >> 16;
|
||||
if (modnum < 501) {
|
||||
@@ -186,14 +160,7 @@ int epicsShareAPI errSymBld()
|
||||
* HASH
|
||||
* returns the hash index of errNum
|
||||
****************************************************************/
|
||||
#ifdef __STDC__
|
||||
static
|
||||
unsigned short errhash(long errNum)
|
||||
#else
|
||||
static
|
||||
unsigned short errhash(errNum)
|
||||
long errNum;
|
||||
#endif /* __STDC__ */
|
||||
static unsigned short errhash(long errNum)
|
||||
{
|
||||
unsigned short modnum;
|
||||
unsigned short errnum;
|
||||
@@ -207,79 +174,22 @@ unsigned short errnum;
|
||||
* ERRSYMBOLADD
|
||||
* adds symbols to the master errnumlist as compiled from errSymTbl.c
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI errSymbolAdd (long errNum,char *name)
|
||||
#else
|
||||
int epicsShareAPI errSymbolAdd (errNum,name)
|
||||
long errNum;
|
||||
char *name;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
ELLLIST *perrnumlist = &errnumlist;
|
||||
ERRNUMNODE *pNew;
|
||||
|
||||
pNew = (ERRNUMNODE*)calloc(1, sizeof(ERRNUMNODE));
|
||||
if(!pNew) {
|
||||
printf("errSymbolAdd: Can't allocate storage\n");
|
||||
#ifdef vxWorks
|
||||
taskSuspend(0);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
pNew = (ERRNUMNODE*)callocMustSucceed(1,sizeof(ERRNUMNODE),"errSymbolAdd");
|
||||
pNew->errNum = errNum;
|
||||
pNew->message = name;
|
||||
ellAdd(perrnumlist,(ELLNODE*)pNew);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* UNIXSYMFIND
|
||||
***************************************************************/
|
||||
/*
|
||||
* Use of sys_nerr and sys_errlist in this routine
|
||||
* present portability problems
|
||||
*
|
||||
* ANSI strerror() provides this functionality
|
||||
* so this is hopefully no longer needed
|
||||
* joh 10-02-96
|
||||
*
|
||||
*/
|
||||
#if 0
|
||||
#ifndef vxWorks
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI UnixSymFind(long status, char *pname, long *pvalue)
|
||||
#else
|
||||
int epicsShareAPI UnixSymFind(status, pname, pvalue)
|
||||
long status;
|
||||
char *pname;
|
||||
long *pvalue;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
if(!initialized) errSymBld();
|
||||
if (status >= sys_nerr || status < 1) {
|
||||
*pvalue = -1;
|
||||
return(0);
|
||||
}
|
||||
strcpy(pname, sys_errlist[status]);
|
||||
*pvalue = status;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* MODSYMFIND
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI ModSymFind(long status, char *pname, long *pvalue)
|
||||
#else
|
||||
int epicsShareAPI ModSymFind(status, pname, pvalue)
|
||||
long status;
|
||||
char *pname;
|
||||
long *pvalue;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
unsigned short modNum;
|
||||
unsigned short hashInd;
|
||||
@@ -312,29 +222,15 @@ int epicsShareAPI ModSymFind(status, pname, pvalue)
|
||||
/****************************************************************
|
||||
* ERRSYMFIND
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
int epicsShareAPI errSymFind(long status, char *name)
|
||||
#else
|
||||
/* errSymFind - Locate error symbol */
|
||||
int epicsShareAPI errSymFind(status, name)
|
||||
long status;
|
||||
char *name;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
long value;
|
||||
#ifdef vxWorks
|
||||
unsigned char type;
|
||||
#endif
|
||||
unsigned short modnum;
|
||||
|
||||
if (!initialized) errSymBld();
|
||||
|
||||
modnum = (unsigned short) (status >> 16);
|
||||
if (modnum <= 500)
|
||||
#ifdef vxWorks
|
||||
symFindByValue((SYMTAB_ID)statSymTbl, status, name,(int*) &value, (SYM_TYPE*)&type);
|
||||
#else
|
||||
{
|
||||
if (modnum <= 500) {
|
||||
const char *pStr = strerror(status);
|
||||
if (pStr) {
|
||||
strcpy(name,strerror(status));
|
||||
@@ -343,10 +239,9 @@ int epicsShareAPI errSymFind(status, name)
|
||||
else {
|
||||
sprintf(name,"err = %ld", status);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
} else {
|
||||
ModSymFind(status, name, &value);
|
||||
}
|
||||
if (value != status)
|
||||
return (-1);
|
||||
else
|
||||
@@ -357,11 +252,7 @@ int epicsShareAPI errSymFind(status, name)
|
||||
/****************************************************************
|
||||
* errSymDump
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
void epicsShareAPI errSymDump()
|
||||
#else
|
||||
void epicsShareAPI errSymDump()
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
ERRNUMNODE **phashnode = NULL;
|
||||
ERRNUMNODE *pNextNode;
|
||||
@@ -400,12 +291,7 @@ int firstTime;
|
||||
/****************************************************************
|
||||
* errSymTestPrint
|
||||
***************************************************************/
|
||||
#ifdef __STDC__
|
||||
void epicsShareAPI errSymTestPrint(long errNum)
|
||||
#else
|
||||
void epicsShareAPI errSymTestPrint(errNum)
|
||||
long errNum;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
char message[256];
|
||||
unsigned short modnum;
|
||||
@@ -431,14 +317,8 @@ long errNum;
|
||||
/****************************************************************
|
||||
* ERRSYMTEST
|
||||
****************************************************************/
|
||||
#ifdef __STDC__
|
||||
void epicsShareAPI errSymTest(unsigned short modnum, unsigned short begErrNum, unsigned short endErrNum)
|
||||
#else
|
||||
void epicsShareAPI errSymTest(modnum, begErrNum, endErrNum)
|
||||
unsigned short modnum;
|
||||
unsigned short begErrNum;
|
||||
unsigned short endErrNum;
|
||||
#endif /* __STDC__ */
|
||||
void epicsShareAPI errSymTest(unsigned short modnum,
|
||||
unsigned short begErrNum, unsigned short endErrNum)
|
||||
{
|
||||
long errNum;
|
||||
unsigned short errnum;
|
||||
|
||||
@@ -14,25 +14,22 @@ of this distribution.
|
||||
* NOTE: Original version is adaptation of old version of errPrintfVX.c
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <taskLib.h>
|
||||
#include <intLib.h>
|
||||
#include <semLib.h>
|
||||
#include <vxLib.h>
|
||||
#include <errnoLib.h>
|
||||
#include <logLib.h>
|
||||
|
||||
#define ERRLOG_INIT
|
||||
#include "osiThread.h"
|
||||
#include "osiSem.h"
|
||||
#include "osiInterrupt.h"
|
||||
#include "errno.h"
|
||||
|
||||
#include "epicsAssert.h"
|
||||
#include "errMdef.h"
|
||||
#include "error.h"
|
||||
#include "ellLib.h"
|
||||
#include "task_params.h"
|
||||
#include "errlog.h"
|
||||
|
||||
|
||||
@@ -53,7 +50,6 @@ LOCAL char * msgbufGetSend(void);
|
||||
LOCAL void msgbufFreeSend(void);
|
||||
|
||||
LOCAL void *pvtCalloc(size_t count,size_t size);
|
||||
LOCAL void pvtSemTake(SEM_ID semid);
|
||||
|
||||
typedef struct listenerNode{
|
||||
ELLNODE node;
|
||||
@@ -68,9 +64,9 @@ typedef struct msgNode {
|
||||
} msgNode;
|
||||
|
||||
LOCAL struct {
|
||||
SEM_ID errlogTaskWaitForWork;
|
||||
SEM_ID msgQueueLock;
|
||||
SEM_ID listenerLock;
|
||||
semId errlogTaskWaitForWork;
|
||||
semId msgQueueLock;
|
||||
semId listenerLock;
|
||||
ELLLIST listenerList;
|
||||
ELLLIST msgQueue;
|
||||
msgNode *pnextSend;
|
||||
@@ -86,8 +82,9 @@ epicsShareFunc int epicsShareAPIV errlogPrintf( const char *pFormat, ...)
|
||||
va_list pvar;
|
||||
int nchar;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogPrintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogPrintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -103,8 +100,9 @@ epicsShareFunc int epicsShareAPIV errlogVprintf(
|
||||
int nchar;
|
||||
char *pbuffer;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogVprintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogVprintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -117,12 +115,11 @@ epicsShareFunc int epicsShareAPIV errlogVprintf(
|
||||
|
||||
epicsShareFunc int epicsShareAPI errlogMessage(const char *message)
|
||||
{
|
||||
int status;
|
||||
char *pbuffer;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
status = logMsg ("errlogMessage called from interrupt level %s",
|
||||
message,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogMessage called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -139,8 +136,9 @@ epicsShareFunc int epicsShareAPIV errlogSevPrintf(
|
||||
va_list pvar;
|
||||
int nchar;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogSevPrintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogSevPrintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -159,8 +157,9 @@ epicsShareFunc int epicsShareAPIV errlogSevVprintf(
|
||||
int totalChar=0;
|
||||
|
||||
if(pvtData.sevToLog>severity) return(0);
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errlogSevVprintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage
|
||||
("errlogSevVprintf called from interrupt level\n");
|
||||
return 0;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -206,10 +205,10 @@ epicsShareFunc void epicsShareAPI errlogAddListener(
|
||||
|
||||
errlogInit(0);
|
||||
plistenerNode = pvtCalloc(1,sizeof(listenerNode));
|
||||
pvtSemTake(pvtData.listenerLock);
|
||||
semMutexTake(pvtData.listenerLock);
|
||||
plistenerNode->listener = listener;
|
||||
ellAdd(&pvtData.listenerList,&plistenerNode->node);
|
||||
semGive(pvtData.listenerLock);
|
||||
semMutexGive(pvtData.listenerLock);
|
||||
}
|
||||
|
||||
epicsShareFunc void epicsShareAPI errlogRemoveListener(
|
||||
@@ -218,7 +217,7 @@ epicsShareFunc void epicsShareAPI errlogRemoveListener(
|
||||
listenerNode *plistenerNode;
|
||||
|
||||
errlogInit(0);
|
||||
pvtSemTake(pvtData.listenerLock);
|
||||
semMutexTake(pvtData.listenerLock);
|
||||
plistenerNode = (listenerNode *)ellFirst(&pvtData.listenerList);
|
||||
while(plistenerNode) {
|
||||
if(plistenerNode->listener==listener) {
|
||||
@@ -228,7 +227,7 @@ epicsShareFunc void epicsShareAPI errlogRemoveListener(
|
||||
}
|
||||
plistenerNode = (listenerNode *)ellNext(&plistenerNode->node);
|
||||
}
|
||||
semGive(pvtData.listenerLock);
|
||||
semMutexGive(pvtData.listenerLock);
|
||||
if(!plistenerNode) printf("errlogRemoveListener did not find listener\n");
|
||||
}
|
||||
|
||||
@@ -247,8 +246,8 @@ epicsShareFunc void epicsShareAPIV errPrintf(long status, const char *pFileName,
|
||||
int nchar;
|
||||
int totalChar=0;
|
||||
|
||||
if(INT_CONTEXT()) {
|
||||
logMsg("errPrintf called from interrupt level\n",0,0,0,0,0,0);
|
||||
if(interruptIsInterruptContext()) {
|
||||
interruptContextMessage("errPrintf called from interrupt level\n");
|
||||
return;
|
||||
}
|
||||
errlogInit(0);
|
||||
@@ -259,7 +258,7 @@ epicsShareFunc void epicsShareAPIV errPrintf(long status, const char *pFileName,
|
||||
pFileName, lineno);
|
||||
pnext += nchar; totalChar += nchar;
|
||||
}
|
||||
if(status==0) status = MYERRNO;
|
||||
if(status==0) status = errno;
|
||||
if(status>0) {
|
||||
int rtnval;
|
||||
char name[256];
|
||||
@@ -288,36 +287,27 @@ epicsShareFunc void epicsShareAPIV errPrintf(long status, const char *pFileName,
|
||||
msgbufSetSize(totalChar);
|
||||
}
|
||||
|
||||
#define optionsSemM SEM_Q_PRIORITY|SEM_DELETE_SAFE|SEM_INVERSION_SAFE
|
||||
epicsShareFunc int epicsShareAPI errlogInit(int bufsize)
|
||||
{
|
||||
static int errlogInitFlag=0;
|
||||
void *pbuffer;;
|
||||
|
||||
if(!vxTas(&errlogInitFlag)) return(0);
|
||||
if(errlogInitFlag) return(0);
|
||||
errlogInitFlag = 1;
|
||||
if(bufsize<BUFFER_SIZE) bufsize = BUFFER_SIZE;
|
||||
pvtData.buffersize = bufsize;
|
||||
ellInit(&pvtData.listenerList);
|
||||
ellInit(&pvtData.msgQueue);
|
||||
pvtData.toConsole = TRUE;
|
||||
if((pvtData.errlogTaskWaitForWork=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL) {
|
||||
logMsg("semBCreate failed in errlogInit",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
if((pvtData.listenerLock=semMCreate(optionsSemM))==NULL) {
|
||||
logMsg("semMCreate failed in errlogInit",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
if((pvtData.msgQueueLock=semMCreate(optionsSemM))==NULL) {
|
||||
logMsg("semMCreate failed in errlogInit",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
pvtData.errlogTaskWaitForWork = semBinaryCreate(semEmpty);
|
||||
pvtData.listenerLock = semMutexCreate();
|
||||
pvtData.msgQueueLock = semMutexCreate();
|
||||
/*Allow an extra MAX_MESSAGE_SIZE for extra margain of safety*/
|
||||
pbuffer = pvtCalloc(pvtData.buffersize+MAX_MESSAGE_SIZE,sizeof(char));
|
||||
pvtData.pbuffer = pbuffer;
|
||||
taskSpawn(ERRLOG_NAME,ERRLOG_PRI,ERRLOG_OPT,
|
||||
ERRLOG_STACK,(FUNCPTR)errlogTask,
|
||||
0,0,0,0,0,0,0,0,0,0);
|
||||
threadCreate("errlog",threadPriorityLow,
|
||||
threadGetStackSize(threadStackSmall),
|
||||
(THREADFUNC)errlogTask,0);
|
||||
/*For now make sure iocLogInit is called*/
|
||||
iocLogInit();
|
||||
return(0);
|
||||
@@ -330,16 +320,16 @@ LOCAL void errlogTask(void)
|
||||
while(TRUE) {
|
||||
char *pmessage;
|
||||
|
||||
pvtSemTake(pvtData.errlogTaskWaitForWork);
|
||||
semBinaryTake(pvtData.errlogTaskWaitForWork);
|
||||
while((pmessage = msgbufGetSend())) {
|
||||
pvtSemTake(pvtData.listenerLock);
|
||||
semMutexTake(pvtData.listenerLock);
|
||||
if(pvtData.toConsole) printf("%s",pmessage);
|
||||
plistenerNode = (listenerNode *)ellFirst(&pvtData.listenerList);
|
||||
while(plistenerNode) {
|
||||
(*plistenerNode->listener)(pmessage);
|
||||
plistenerNode = (listenerNode *)ellNext(&plistenerNode->node);
|
||||
}
|
||||
semGive(pvtData.listenerLock);
|
||||
semMutexGive(pvtData.listenerLock);
|
||||
msgbufFreeSend();
|
||||
}
|
||||
}
|
||||
@@ -381,7 +371,7 @@ LOCAL char *msgbufGetFree()
|
||||
{
|
||||
msgNode *pnextSend;
|
||||
|
||||
pvtSemTake(pvtData.msgQueueLock);
|
||||
semMutexTake(pvtData.msgQueueLock);
|
||||
if((ellCount(&pvtData.msgQueue) == 0) && pvtData.missedMessages) {
|
||||
int nchar;
|
||||
|
||||
@@ -395,7 +385,7 @@ LOCAL char *msgbufGetFree()
|
||||
pvtData.pnextSend = pnextSend = msgbufGetNode();
|
||||
if(pnextSend) return(pnextSend->message);
|
||||
++pvtData.missedMessages;
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -427,8 +417,8 @@ LOCAL void msgbufSetSize(int size)
|
||||
pnextSend->length = size+1;
|
||||
}
|
||||
ellAdd(&pvtData.msgQueue,&pnextSend->node);
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semGive(pvtData.errlogTaskWaitForWork);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
semBinaryGive(pvtData.errlogTaskWaitForWork);
|
||||
}
|
||||
|
||||
/*errlogTask is the only task that calls msgbufGetSend and msgbufFreeSend*/
|
||||
@@ -439,9 +429,9 @@ LOCAL char * msgbufGetSend()
|
||||
{
|
||||
msgNode *pnextSend;
|
||||
|
||||
pvtSemTake(pvtData.msgQueueLock);
|
||||
semMutexTake(pvtData.msgQueueLock);
|
||||
pnextSend = (msgNode *)ellFirst(&pvtData.msgQueue);
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
if(!pnextSend) return(0);
|
||||
return(pnextSend->message);
|
||||
}
|
||||
@@ -450,14 +440,14 @@ LOCAL void msgbufFreeSend()
|
||||
{
|
||||
msgNode *pnextSend;
|
||||
|
||||
pvtSemTake(pvtData.msgQueueLock);
|
||||
semMutexTake(pvtData.msgQueueLock);
|
||||
pnextSend = (msgNode *)ellFirst(&pvtData.msgQueue);
|
||||
if(!pnextSend) {
|
||||
printf("errlog: msgbufFreeSend logic error\n");
|
||||
taskSuspend(0);
|
||||
threadSuspend(threadGetIdSelf());
|
||||
}
|
||||
ellDelete(&pvtData.msgQueue,&pnextSend->node);
|
||||
semGive(pvtData.msgQueueLock);
|
||||
semMutexGive(pvtData.msgQueueLock);
|
||||
}
|
||||
|
||||
LOCAL void *pvtCalloc(size_t count,size_t size)
|
||||
@@ -467,15 +457,7 @@ LOCAL void *pvtCalloc(size_t count,size_t size)
|
||||
pmem = calloc(count,size);
|
||||
if(!pmem) {
|
||||
printf("calloc failed in errlog\n");
|
||||
taskSuspend(0);
|
||||
threadSuspend(threadGetIdSelf());
|
||||
}
|
||||
return(pmem);
|
||||
}
|
||||
|
||||
LOCAL void pvtSemTake(SEM_ID semid)
|
||||
{
|
||||
if(semTake(semid,WAIT_FOREVER)!=OK) {
|
||||
logMsg("epicsPrint: semTake returned error\n",0,0,0,0,0,0);
|
||||
taskSuspend(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,6 @@ typedef struct /* ERRSYMTAB - symbol table */
|
||||
} ERRSYMTAB;
|
||||
typedef ERRSYMTAB *ERRSYMTAB_ID;
|
||||
|
||||
#ifdef vxWorks
|
||||
#define MYERRNO (errnoGet()&0xffff)
|
||||
#else
|
||||
#define MYERRNO errno
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
struct errSet { /* This defines one module error set */
|
||||
long number; /* dimension of err strings */
|
||||
|
||||
@@ -52,16 +52,14 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
|
||||
* .02 03-28-97 joh added freeListItemAvail() function
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include "fast_lock.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "cantProceed.h"
|
||||
#include "osiSem.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "freeList.h"
|
||||
#include "adjustment.h"
|
||||
@@ -76,9 +74,7 @@ typedef struct {
|
||||
void *head;
|
||||
allocMem *mallochead;
|
||||
size_t nBlocksAvailable;
|
||||
#ifdef vxWorks
|
||||
FAST_LOCK lock;
|
||||
#endif
|
||||
semId lock;
|
||||
}FREELISTPVT;
|
||||
|
||||
epicsShareFunc void epicsShareAPI
|
||||
@@ -86,22 +82,13 @@ epicsShareFunc void epicsShareAPI
|
||||
{
|
||||
FREELISTPVT *pfl;
|
||||
|
||||
pfl = (void *)calloc((size_t)1,(size_t)sizeof(FREELISTPVT));
|
||||
if(!pfl) {
|
||||
#ifdef vxWorks
|
||||
taskSuspend(0);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
pfl = callocMustSucceed(1,sizeof(FREELISTPVT), "freeListInitPvt");
|
||||
pfl->size = adjustToWorstCaseAlignment(size);
|
||||
pfl->nmalloc = nmalloc;
|
||||
pfl->head = NULL;
|
||||
pfl->mallochead = NULL;
|
||||
pfl->nBlocksAvailable = 0u;
|
||||
#ifdef vxWorks
|
||||
FASTLOCKINIT(&pfl->lock);
|
||||
#endif
|
||||
pfl->lock = semMutexCreate();
|
||||
*ppvt = (void *)pfl;
|
||||
return;
|
||||
}
|
||||
@@ -124,23 +111,17 @@ epicsShareFunc void * epicsShareAPI freeListMalloc(void *pvt)
|
||||
allocMem *pallocmem;
|
||||
int i;
|
||||
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexTake(pfl->lock);
|
||||
ptemp = pfl->head;
|
||||
if(ptemp==0) {
|
||||
ptemp = (void *)malloc(pfl->nmalloc*pfl->size);
|
||||
if(ptemp==0) {
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
return(0);
|
||||
}
|
||||
pallocmem = (allocMem *)calloc(1,sizeof(allocMem));
|
||||
if(pallocmem==0) {
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
free(ptemp);
|
||||
return(0);
|
||||
}
|
||||
@@ -160,9 +141,7 @@ epicsShareFunc void * epicsShareAPI freeListMalloc(void *pvt)
|
||||
ppnext = pfl->head;
|
||||
pfl->head = *ppnext;
|
||||
pfl->nBlocksAvailable--;
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
return(ptemp);
|
||||
}
|
||||
|
||||
@@ -171,16 +150,12 @@ epicsShareFunc void epicsShareAPI freeListFree(void *pvt,void*pmem)
|
||||
FREELISTPVT *pfl = pvt;
|
||||
void **ppnext;
|
||||
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexTake(pfl->lock);
|
||||
ppnext = pmem;
|
||||
*ppnext = pfl->head;
|
||||
pfl->head = pmem;
|
||||
pfl->nBlocksAvailable++;
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
}
|
||||
|
||||
epicsShareFunc void epicsShareAPI freeListCleanup(void *pvt)
|
||||
|
||||
@@ -52,16 +52,14 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
|
||||
* .02 03-28-97 joh added freeListItemAvail() function
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include "fast_lock.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "cantProceed.h"
|
||||
#include "osiSem.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "freeList.h"
|
||||
#include "adjustment.h"
|
||||
@@ -76,9 +74,7 @@ typedef struct {
|
||||
void *head;
|
||||
allocMem *mallochead;
|
||||
size_t nBlocksAvailable;
|
||||
#ifdef vxWorks
|
||||
FAST_LOCK lock;
|
||||
#endif
|
||||
semId lock;
|
||||
}FREELISTPVT;
|
||||
|
||||
epicsShareFunc void epicsShareAPI
|
||||
@@ -86,22 +82,13 @@ epicsShareFunc void epicsShareAPI
|
||||
{
|
||||
FREELISTPVT *pfl;
|
||||
|
||||
pfl = (void *)calloc((size_t)1,(size_t)sizeof(FREELISTPVT));
|
||||
if(!pfl) {
|
||||
#ifdef vxWorks
|
||||
taskSuspend(0);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
pfl = callocMustSucceed(1,sizeof(FREELISTPVT), "freeListInitPvt");
|
||||
pfl->size = adjustToWorstCaseAlignment(size);
|
||||
pfl->nmalloc = nmalloc;
|
||||
pfl->head = NULL;
|
||||
pfl->mallochead = NULL;
|
||||
pfl->nBlocksAvailable = 0u;
|
||||
#ifdef vxWorks
|
||||
FASTLOCKINIT(&pfl->lock);
|
||||
#endif
|
||||
pfl->lock = semMutexCreate();
|
||||
*ppvt = (void *)pfl;
|
||||
return;
|
||||
}
|
||||
@@ -124,23 +111,17 @@ epicsShareFunc void * epicsShareAPI freeListMalloc(void *pvt)
|
||||
allocMem *pallocmem;
|
||||
int i;
|
||||
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexTake(pfl->lock);
|
||||
ptemp = pfl->head;
|
||||
if(ptemp==0) {
|
||||
ptemp = (void *)malloc(pfl->nmalloc*pfl->size);
|
||||
if(ptemp==0) {
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
return(0);
|
||||
}
|
||||
pallocmem = (allocMem *)calloc(1,sizeof(allocMem));
|
||||
if(pallocmem==0) {
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
free(ptemp);
|
||||
return(0);
|
||||
}
|
||||
@@ -160,9 +141,7 @@ epicsShareFunc void * epicsShareAPI freeListMalloc(void *pvt)
|
||||
ppnext = pfl->head;
|
||||
pfl->head = *ppnext;
|
||||
pfl->nBlocksAvailable--;
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
return(ptemp);
|
||||
}
|
||||
|
||||
@@ -171,16 +150,12 @@ epicsShareFunc void epicsShareAPI freeListFree(void *pvt,void*pmem)
|
||||
FREELISTPVT *pfl = pvt;
|
||||
void **ppnext;
|
||||
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexTake(pfl->lock);
|
||||
ppnext = pmem;
|
||||
*ppnext = pfl->head;
|
||||
pfl->head = pmem;
|
||||
pfl->nBlocksAvailable++;
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pfl->lock);
|
||||
#endif
|
||||
semMutexGive(pfl->lock);
|
||||
}
|
||||
|
||||
epicsShareFunc void epicsShareAPI freeListCleanup(void *pvt)
|
||||
|
||||
@@ -22,9 +22,9 @@ typedef struct{
|
||||
} GPHENTRY;
|
||||
|
||||
void gphInitPvt(void **ppvt);
|
||||
GPHENTRY *gphFind(void *pvt,char *name,void *pvtid);
|
||||
GPHENTRY *gphAdd(void *pvt,char *name,void *pvtid);
|
||||
void gphDelete(void *pvt,char *name,void *pvtid);
|
||||
GPHENTRY *gphFind(void *pvt,const char *name,void *pvtid);
|
||||
GPHENTRY *gphAdd(void *pvt,const char *name,void *pvtid);
|
||||
void gphDelete(void *pvt,const char *name,void *pvtid);
|
||||
void gphFreeMem(void *pvt);
|
||||
void gphDump(void *pvt);
|
||||
|
||||
|
||||
@@ -59,22 +59,22 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
|
||||
#include "shareLib.h"
|
||||
|
||||
#include "ellLib.h"
|
||||
#ifdef vxWorks
|
||||
#include "fast_lock.h"
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
ELLNODE node;
|
||||
char *name; /*address of name placed in directory*/
|
||||
const char *name; /*address of name placed in directory*/
|
||||
void *pvtid; /*private name for subsystem user*/
|
||||
void *userPvt; /*private for user*/
|
||||
} GPHENTRY;
|
||||
|
||||
/*tableSize must be power of 2 in range 256 to 65536*/
|
||||
epicsShareFunc void epicsShareAPI gphInitPvt(void **ppvt,int tableSize);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid);
|
||||
epicsShareFunc void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI
|
||||
gphFind(void *pvt,const char *name,void *pvtid);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI
|
||||
gphAdd(void *pvt,const char *name,void *pvtid);
|
||||
epicsShareFunc void epicsShareAPI
|
||||
gphDelete(void *pvt,const char *name,void *pvtid);
|
||||
epicsShareFunc void epicsShareAPI gphFreeMem(void *pvt);
|
||||
epicsShareFunc void epicsShareAPI gphDump(void *pvt);
|
||||
#endif /*INCgpHashh*/
|
||||
|
||||
@@ -59,22 +59,22 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
|
||||
#include "shareLib.h"
|
||||
|
||||
#include "ellLib.h"
|
||||
#ifdef vxWorks
|
||||
#include "fast_lock.h"
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
ELLNODE node;
|
||||
char *name; /*address of name placed in directory*/
|
||||
const char *name; /*address of name placed in directory*/
|
||||
void *pvtid; /*private name for subsystem user*/
|
||||
void *userPvt; /*private for user*/
|
||||
} GPHENTRY;
|
||||
|
||||
/*tableSize must be power of 2 in range 256 to 65536*/
|
||||
epicsShareFunc void epicsShareAPI gphInitPvt(void **ppvt,int tableSize);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid);
|
||||
epicsShareFunc void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI
|
||||
gphFind(void *pvt,const char *name,void *pvtid);
|
||||
epicsShareFunc GPHENTRY * epicsShareAPI
|
||||
gphAdd(void *pvt,const char *name,void *pvtid);
|
||||
epicsShareFunc void epicsShareAPI
|
||||
gphDelete(void *pvt,const char *name,void *pvtid);
|
||||
epicsShareFunc void epicsShareAPI gphFreeMem(void *pvt);
|
||||
epicsShareFunc void epicsShareAPI gphDump(void *pvt);
|
||||
#endif /*INCgpHashh*/
|
||||
|
||||
@@ -52,14 +52,12 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "cantProceed.h"
|
||||
#include "osiSem.h"
|
||||
#define epicsExportSharedSymbols
|
||||
#include "dbDefs.h"
|
||||
#include "ellLib.h"
|
||||
@@ -70,9 +68,7 @@ typedef struct gphPvt {
|
||||
int tableSize;
|
||||
int nShift;
|
||||
ELLLIST **paplist; /*pointer to array of pointers to ELLLIST */
|
||||
#ifdef vxWorks
|
||||
FAST_LOCK lock;
|
||||
#endif
|
||||
semId lock;
|
||||
}gphPvt;
|
||||
|
||||
|
||||
@@ -106,17 +102,11 @@ static void *myCalloc(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,"freeListLib");
|
||||
return(p);
|
||||
}
|
||||
|
||||
static int hash( char *pname,int nShift)
|
||||
static int hash(const char *pname,int nShift)
|
||||
{
|
||||
unsigned char h0=0;
|
||||
unsigned char h1=0;
|
||||
@@ -156,14 +146,12 @@ void epicsShareAPI gphInitPvt(void **ppvt,int size)
|
||||
pgphPvt->tableSize = tableSize;
|
||||
pgphPvt->nShift = nShift;
|
||||
pgphPvt->paplist = myCalloc(tableSize, sizeof(ELLLIST *));
|
||||
#ifdef vxWorks
|
||||
FASTLOCKINIT(&pgphPvt->lock);
|
||||
#endif
|
||||
pgphPvt->lock = semMutexCreate();
|
||||
*ppvt = (void *)pgphPvt;
|
||||
return;
|
||||
}
|
||||
|
||||
GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid)
|
||||
GPHENTRY * epicsShareAPI gphFind(void *pvt,const char *name,void *pvtid)
|
||||
{
|
||||
int hashInd;
|
||||
gphPvt *pgphPvt = (gphPvt *)pvt;
|
||||
@@ -174,9 +162,7 @@ GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid)
|
||||
if(pgphPvt==NULL) return(NULL);
|
||||
paplist = pgphPvt->paplist;
|
||||
hashInd = hash(name,pgphPvt->nShift);
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexTake(pgphPvt->lock);
|
||||
if ((gphlist=paplist[hashInd]) == NULL) {
|
||||
pgphNode = NULL;
|
||||
} else {
|
||||
@@ -188,13 +174,11 @@ GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid)
|
||||
}
|
||||
pgphNode = (GPHENTRY *) ellNext((ELLNODE*)pgphNode);
|
||||
}
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return(pgphNode);
|
||||
}
|
||||
|
||||
GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
GPHENTRY * epicsShareAPI gphAdd(void *pvt,const char *name,void *pvtid)
|
||||
{
|
||||
int hashInd;
|
||||
gphPvt *pgphPvt = (gphPvt *)pvt;
|
||||
@@ -205,9 +189,7 @@ GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
if(pgphPvt==NULL) return(NULL);
|
||||
paplist = pgphPvt->paplist;
|
||||
hashInd = hash(name,pgphPvt->nShift);
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexTake(pgphPvt->lock);
|
||||
if(paplist[hashInd] == NULL) {
|
||||
paplist[hashInd] = myCalloc(1, sizeof(ELLLIST));
|
||||
ellInit(paplist[hashInd]);
|
||||
@@ -217,9 +199,7 @@ GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
while(pgphNode) {
|
||||
if((strcmp(name,(char *)pgphNode->name) == 0)
|
||||
&&(pvtid == pgphNode->pvtid)) {
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return(NULL);
|
||||
}
|
||||
pgphNode = (GPHENTRY *) ellNext((ELLNODE*)pgphNode);
|
||||
@@ -228,13 +208,11 @@ GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
pgphNode->name = name;
|
||||
pgphNode->pvtid = pvtid;
|
||||
ellAdd(plist, (ELLNODE*)pgphNode);
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return (pgphNode);
|
||||
}
|
||||
|
||||
void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid)
|
||||
void epicsShareAPI gphDelete(void *pvt,const char *name,void *pvtid)
|
||||
{
|
||||
int hashInd;
|
||||
gphPvt *pgphPvt = (gphPvt *)pvt;
|
||||
@@ -245,9 +223,7 @@ void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid)
|
||||
if(pgphPvt==NULL) return;
|
||||
paplist = pgphPvt->paplist;
|
||||
hashInd = hash(name,pgphPvt->nShift);
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexTake(pgphPvt->lock);
|
||||
if(paplist[hashInd] == NULL) {
|
||||
pgphNode = NULL;
|
||||
} else {
|
||||
@@ -263,9 +239,7 @@ void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid)
|
||||
}
|
||||
pgphNode = (GPHENTRY *) ellNext((ELLNODE*)pgphNode);
|
||||
}
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,14 +52,12 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "cantProceed.h"
|
||||
#include "osiSem.h"
|
||||
#define epicsExportSharedSymbols
|
||||
#include "dbDefs.h"
|
||||
#include "ellLib.h"
|
||||
@@ -70,9 +68,7 @@ typedef struct gphPvt {
|
||||
int tableSize;
|
||||
int nShift;
|
||||
ELLLIST **paplist; /*pointer to array of pointers to ELLLIST */
|
||||
#ifdef vxWorks
|
||||
FAST_LOCK lock;
|
||||
#endif
|
||||
semId lock;
|
||||
}gphPvt;
|
||||
|
||||
|
||||
@@ -106,17 +102,11 @@ static void *myCalloc(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,"freeListLib");
|
||||
return(p);
|
||||
}
|
||||
|
||||
static int hash( char *pname,int nShift)
|
||||
static int hash(const char *pname,int nShift)
|
||||
{
|
||||
unsigned char h0=0;
|
||||
unsigned char h1=0;
|
||||
@@ -156,14 +146,12 @@ void epicsShareAPI gphInitPvt(void **ppvt,int size)
|
||||
pgphPvt->tableSize = tableSize;
|
||||
pgphPvt->nShift = nShift;
|
||||
pgphPvt->paplist = myCalloc(tableSize, sizeof(ELLLIST *));
|
||||
#ifdef vxWorks
|
||||
FASTLOCKINIT(&pgphPvt->lock);
|
||||
#endif
|
||||
pgphPvt->lock = semMutexCreate();
|
||||
*ppvt = (void *)pgphPvt;
|
||||
return;
|
||||
}
|
||||
|
||||
GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid)
|
||||
GPHENTRY * epicsShareAPI gphFind(void *pvt,const char *name,void *pvtid)
|
||||
{
|
||||
int hashInd;
|
||||
gphPvt *pgphPvt = (gphPvt *)pvt;
|
||||
@@ -174,9 +162,7 @@ GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid)
|
||||
if(pgphPvt==NULL) return(NULL);
|
||||
paplist = pgphPvt->paplist;
|
||||
hashInd = hash(name,pgphPvt->nShift);
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexTake(pgphPvt->lock);
|
||||
if ((gphlist=paplist[hashInd]) == NULL) {
|
||||
pgphNode = NULL;
|
||||
} else {
|
||||
@@ -188,13 +174,11 @@ GPHENTRY * epicsShareAPI gphFind(void *pvt,char *name,void *pvtid)
|
||||
}
|
||||
pgphNode = (GPHENTRY *) ellNext((ELLNODE*)pgphNode);
|
||||
}
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return(pgphNode);
|
||||
}
|
||||
|
||||
GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
GPHENTRY * epicsShareAPI gphAdd(void *pvt,const char *name,void *pvtid)
|
||||
{
|
||||
int hashInd;
|
||||
gphPvt *pgphPvt = (gphPvt *)pvt;
|
||||
@@ -205,9 +189,7 @@ GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
if(pgphPvt==NULL) return(NULL);
|
||||
paplist = pgphPvt->paplist;
|
||||
hashInd = hash(name,pgphPvt->nShift);
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexTake(pgphPvt->lock);
|
||||
if(paplist[hashInd] == NULL) {
|
||||
paplist[hashInd] = myCalloc(1, sizeof(ELLLIST));
|
||||
ellInit(paplist[hashInd]);
|
||||
@@ -217,9 +199,7 @@ GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
while(pgphNode) {
|
||||
if((strcmp(name,(char *)pgphNode->name) == 0)
|
||||
&&(pvtid == pgphNode->pvtid)) {
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return(NULL);
|
||||
}
|
||||
pgphNode = (GPHENTRY *) ellNext((ELLNODE*)pgphNode);
|
||||
@@ -228,13 +208,11 @@ GPHENTRY * epicsShareAPI gphAdd(void *pvt,char *name,void *pvtid)
|
||||
pgphNode->name = name;
|
||||
pgphNode->pvtid = pvtid;
|
||||
ellAdd(plist, (ELLNODE*)pgphNode);
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return (pgphNode);
|
||||
}
|
||||
|
||||
void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid)
|
||||
void epicsShareAPI gphDelete(void *pvt,const char *name,void *pvtid)
|
||||
{
|
||||
int hashInd;
|
||||
gphPvt *pgphPvt = (gphPvt *)pvt;
|
||||
@@ -245,9 +223,7 @@ void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid)
|
||||
if(pgphPvt==NULL) return;
|
||||
paplist = pgphPvt->paplist;
|
||||
hashInd = hash(name,pgphPvt->nShift);
|
||||
#ifdef vxWorks
|
||||
FASTLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexTake(pgphPvt->lock);
|
||||
if(paplist[hashInd] == NULL) {
|
||||
pgphNode = NULL;
|
||||
} else {
|
||||
@@ -263,9 +239,7 @@ void epicsShareAPI gphDelete(void *pvt,char *name,void *pvtid)
|
||||
}
|
||||
pgphNode = (GPHENTRY *) ellNext((ELLNODE*)pgphNode);
|
||||
}
|
||||
#ifdef vxWorks
|
||||
FASTUNLOCK(&pgphPvt->lock);
|
||||
#endif
|
||||
semMutexGive(pgphPvt->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,22 +33,12 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "osiClock.h"
|
||||
#include "osiSem.h"
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsAssert.h"
|
||||
#include "ellLib.h"
|
||||
|
||||
#ifdef vxWorks
|
||||
#define LOCKS_REQUIRED
|
||||
#include <tickLib.h>
|
||||
#endif /*vxWorks*/
|
||||
|
||||
#ifdef LOCKS_REQUIRED
|
||||
#include "fast_lock.h"
|
||||
#else /*LOCKS_REQUIRED*/
|
||||
#define FASTLOCK(A)
|
||||
#define FASTUNLOCK(A)
|
||||
#define FASTLOCKINIT(A)
|
||||
#endif /*LOCKS_REQUIRED*/
|
||||
|
||||
unsigned memDebugLevel = 1;
|
||||
|
||||
@@ -73,10 +63,8 @@ typedef struct debugMallocHeader{
|
||||
|
||||
#define LOCAL static
|
||||
|
||||
#ifdef LOCKS_REQUIRED
|
||||
LOCAL int memDebugInit;
|
||||
LOCAL FAST_LOCK memDebugLock;
|
||||
#endif /*LOCKS_REQUIRED*/
|
||||
LOCAL semId memDebugLock;
|
||||
|
||||
#ifdef __STDC__
|
||||
LOCAL int memDebugVerify(DMH *pHdr);
|
||||
@@ -113,23 +101,17 @@ unsigned long size;
|
||||
pHdr->line = line;
|
||||
pHdr->size = size;
|
||||
pHdr->magic = debugMallocMagic;
|
||||
#ifdef vxWorks
|
||||
pHdr->tick = tickGet();
|
||||
#else /*vxWorks*/
|
||||
pHdr->tick = clock();
|
||||
#endif /*vxWorks*/
|
||||
pHdr->tick = clockGetCurrentTick();
|
||||
strcpy (pHdr->pFoot, debugMallocFooter);
|
||||
|
||||
#ifdef LOCKS_REQUIRED
|
||||
if(!memDebugInit){
|
||||
memDebugInit = 1;
|
||||
FASTLOCKINIT(&memDebugLock);
|
||||
memDebugLock = semMutexCreate();
|
||||
}
|
||||
#endif /*LOCKS_REQUIRED*/
|
||||
|
||||
FASTLOCK(&memDebugLock);
|
||||
semMutexTake(memDebugLock);
|
||||
ellAdd(&memDebugList, &pHdr->node);
|
||||
FASTUNLOCK(&memDebugLock);
|
||||
semMutexGive(memDebugLock);
|
||||
|
||||
if(memDebugLevel>2){
|
||||
fprintf(stderr, "%08x=malloc(%ld) %s.%ld\n",
|
||||
@@ -175,11 +157,11 @@ void *ptr;
|
||||
int status;
|
||||
|
||||
pHdr = -1 + (DMH *) ptr;
|
||||
FASTLOCK(&memDebugLock);
|
||||
semMutexTake(memDebugLock);
|
||||
status = ellFind(&memDebugList, &pHdr->node);
|
||||
|
||||
if(status<0 || (pHdr->pUser != ptr)){
|
||||
FASTUNLOCK(&memDebugLock);
|
||||
semMutexGive(memDebugLock);
|
||||
fprintf(stderr, "%s.%ld free(%08x) failed\n",
|
||||
pFile, line, (unsigned) ptr);
|
||||
fprintf(stderr, "malloc occured at %s.%ld\n",
|
||||
@@ -187,7 +169,7 @@ void *ptr;
|
||||
assert(0);
|
||||
}
|
||||
ellDelete(&memDebugList, &pHdr->node);
|
||||
FASTUNLOCK(&memDebugLock);
|
||||
semMutexGive(memDebugLock);
|
||||
|
||||
memDebugVerify(pHdr);
|
||||
|
||||
@@ -242,12 +224,12 @@ int memDebugVerifyAll()
|
||||
int status;
|
||||
DMH *pHdr;
|
||||
|
||||
FASTLOCK(&memDebugLock);
|
||||
semMutexTake(memDebugLock);
|
||||
pHdr = (DMH *) ellFirst(&memDebugList);
|
||||
while( (pHdr = (DMH *) ellNext(pHdr)) ){
|
||||
status = memDebugVerify(pHdr);
|
||||
}
|
||||
FASTUNLOCK(&memDebugLock);
|
||||
semMutexGive(memDebugLock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -264,7 +246,7 @@ unsigned long ignoreBeforeThisTick;
|
||||
{
|
||||
DMH *pHdr;
|
||||
|
||||
FASTLOCK(&memDebugLock);
|
||||
semMutexTake(memDebugLock);
|
||||
pHdr = (DMH *) ellFirst(&memDebugList);
|
||||
while(pHdr){
|
||||
if(pHdr->tick>=ignoreBeforeThisTick){
|
||||
@@ -278,6 +260,6 @@ unsigned long ignoreBeforeThisTick;
|
||||
}
|
||||
pHdr = (DMH *) ellNext(pHdr);
|
||||
}
|
||||
FASTUNLOCK(&memDebugLock);
|
||||
semMutexGive(memDebugLock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,6 @@ of this distribution.
|
||||
* .01 11-21-97 pmm Initial Implementation
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include "fast_lock.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
47
src/libCom/misc/cantProceed.c
Normal file
47
src/libCom/misc/cantProceed.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* callocMustSucceed.c */
|
||||
|
||||
/* Author: Marty Kraimer Date: 04JAN99 */
|
||||
|
||||
/********************COPYRIGHT NOTIFICATION**********************************
|
||||
This software was developed under a United States Government license
|
||||
described on the COPYRIGHT_UniversityOfChicago file included as part
|
||||
of this distribution.
|
||||
****************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "errlog.h"
|
||||
#include "cantProceed.h"
|
||||
#include "osiThread.h"
|
||||
|
||||
void *callocMustSucceed(size_t count, size_t size, const char *errorMessage)
|
||||
{
|
||||
void *mem = calloc(count,size);
|
||||
if(mem==0) {
|
||||
errlogPrintf("%s callocMustSucceed failed count %d size %d\n",
|
||||
errorMessage,count,size);
|
||||
cantProceed(0);
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
|
||||
void *mallocMustSucceed(size_t size, const char *errorMessage)
|
||||
{
|
||||
void *mem = malloc(size);
|
||||
if(mem==0) {
|
||||
errlogPrintf("%s mallocMustSucceed failed size %d\n",
|
||||
errorMessage,size);
|
||||
cantProceed(0);
|
||||
}
|
||||
return(mem);
|
||||
}
|
||||
|
||||
void cantProceed(const char *errorMessage)
|
||||
{
|
||||
errlogPrintf("fatal error: %s\n",errorMessage);
|
||||
threadSuspend(threadGetIdSelf());
|
||||
}
|
||||
15
src/libCom/misc/cantProceed.h
Normal file
15
src/libCom/misc/cantProceed.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef INCcantProceedh
|
||||
#define INCcantProceedh
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void cantProceed(const char *errorMessage);
|
||||
void *callocMustSucceed(size_t count, size_t size, const char *errorMessage);
|
||||
void *mallocMustSucceed(size_t size, const char *errorMessage);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* cantProceedh */
|
||||
@@ -89,10 +89,6 @@
|
||||
* FLASE expression element not found
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -59,10 +59,6 @@
|
||||
* double value between 0.00 and 1.00
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -92,10 +92,6 @@
|
||||
* UNKNOWN_ELEMENT unknown element found in the infix expression
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -267,8 +263,7 @@ static struct expression_element fetch_string_element = {
|
||||
"AA", 0, 0, OPERAND, SFETCH, /* fetch var */
|
||||
};
|
||||
|
||||
#if !defined(UNIX)
|
||||
static int strncasecmp(char *s1, char *s2, size_t n)
|
||||
static int strncasecmpPrivate(char *s1, char *s2, size_t n)
|
||||
{
|
||||
short i;
|
||||
for (i=0; i<(short)n && (*s1 || *s2); i++, s1++, s2++) {
|
||||
@@ -277,7 +272,6 @@ static int strncasecmp(char *s1, char *s2, size_t n)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* FIND_ELEMENT
|
||||
*
|
||||
@@ -293,7 +287,7 @@ static int find_element(pbuffer, pelement, pno_bytes, parg)
|
||||
/* compare the string to each element in the element table */
|
||||
*pelement = &elements[0];
|
||||
while ((*pelement)->element[0] != NULL){
|
||||
if (strncasecmp(pbuffer,(*pelement)->element, strlen((*pelement)->element)) == 0){
|
||||
if (strncasecmpPrivate(pbuffer,(*pelement)->element, strlen((*pelement)->element)) == 0){
|
||||
*pno_bytes += strlen((*pelement)->element);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# Makefile.Host for base/src/libCom
|
||||
#
|
||||
#
|
||||
|
||||
TOP = ../../../..
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
CMPLR = STRICT
|
||||
|
||||
USR_CFLAGS = -D_NO_PROTO
|
||||
|
||||
# libs needed for PROD and TESTPRODUCT
|
||||
PROD_LIBS := Com
|
||||
SYS_PROD_LIBS_WIN32 := ws2_32 advapi32
|
||||
|
||||
PROD = buckTest osiTimeTest
|
||||
|
||||
include $(TOP)/config/RULES.Host
|
||||
|
||||
# EOF Makefile.Host for base/src/libCom
|
||||
@@ -121,26 +121,13 @@
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#define INC_tsDefs_h
|
||||
#if defined(vxWorks)
|
||||
# include <vxWorks.h>
|
||||
# include "drvTS.h"
|
||||
#elif defined(VMS)
|
||||
# include <sys/types.h>
|
||||
# include <sys/time.h>
|
||||
# include <sys/socket.h>
|
||||
#elif defined(_WIN32)
|
||||
# include <winsock2.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#include "osiClock.h"
|
||||
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsAssert.h"
|
||||
#include "envDefs.h"
|
||||
#define createTSSubrGlobals
|
||||
#undef INC_tsDefs_h
|
||||
#include "tsDefs.h"
|
||||
|
||||
|
||||
@@ -666,95 +653,7 @@ long epicsShareAPI tsLocalTime(TS_STAMP *pStamp)
|
||||
long retStat=S_ts_OK;/* return status to caller */
|
||||
|
||||
assert(pStamp != NULL);
|
||||
|
||||
{
|
||||
# if defined(vxWorks)
|
||||
retStat = TScurrentTimeStamp((struct timespec*)pStamp);
|
||||
if (retStat == 0) {
|
||||
return S_ts_OK;
|
||||
}
|
||||
else {
|
||||
return S_ts_sysTimeError;
|
||||
}
|
||||
# elif defined(_WIN32)
|
||||
static long offset_time_s = 0; /* time diff (sec) from 1990 when EPICS started */
|
||||
static LARGE_INTEGER time_prev, time_freq;
|
||||
LARGE_INTEGER time_cur, time_sec, time_remainder;
|
||||
|
||||
if (offset_time_s == 0) {
|
||||
/*
|
||||
* initialize elapsed time counters
|
||||
*
|
||||
* All CPUs running win32 currently have HR
|
||||
* counters (Intel and Mips processors do)
|
||||
*/
|
||||
if (QueryPerformanceCounter (&time_prev)==0) {
|
||||
return S_ts_sysTimeError;
|
||||
}
|
||||
if (QueryPerformanceFrequency (&time_freq)==0) {
|
||||
return S_ts_sysTimeError;
|
||||
}
|
||||
offset_time_s = (long)time(NULL) - TS_EPOCH_SEC_PAST_1970
|
||||
- (long)(time_prev.QuadPart/time_freq.QuadPart);
|
||||
}
|
||||
|
||||
/*
|
||||
* dont need to check status since it was checked once
|
||||
* during initialization to see if the CPU has HR
|
||||
* counters (Intel and Mips processors do)
|
||||
*/
|
||||
QueryPerformanceCounter (&time_cur);
|
||||
if (time_prev.QuadPart > time_cur.QuadPart) { /* must have been a timer roll-over */
|
||||
double offset;
|
||||
/*
|
||||
* must have been a timer roll-over
|
||||
* It takes 9.223372036855e+18/time_freq sec
|
||||
* to roll over this counter (time_freq is 1193182
|
||||
* sec on my system). This is currently about 245118 years.
|
||||
*
|
||||
* attempt to add number of seconds in a 64 bit integer
|
||||
* in case the timer resolution improves
|
||||
*/
|
||||
offset = pow(2.0, 63.0)-1.0/time_freq.QuadPart;
|
||||
if (offset<=LONG_MAX-offset_time_s) {
|
||||
offset_time_s += (long) offset;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* this problem cant be fixed, but hopefully will never occurr
|
||||
*/
|
||||
fprintf (stderr, "%s.%d Timer overflowed\n", __FILE__, __LINE__);
|
||||
return S_ts_sysTimeError;
|
||||
}
|
||||
}
|
||||
time_sec.QuadPart = time_cur.QuadPart / time_freq.QuadPart;
|
||||
time_remainder.QuadPart = time_cur.QuadPart % time_freq.QuadPart;
|
||||
if (time_sec.QuadPart > LONG_MAX-offset_time_s) {
|
||||
/*
|
||||
* this problem cant be fixed, but hopefully will never occurr
|
||||
*/
|
||||
fprintf (stderr, "%s.%d Timer value larger than storage\n", __FILE__, __LINE__);
|
||||
return S_ts_sysTimeError;
|
||||
}
|
||||
|
||||
/* add time (sec) since 1990 */
|
||||
pStamp->secPastEpoch = offset_time_s + (long)time_sec.QuadPart;
|
||||
pStamp->nsec = (long)((time_remainder.QuadPart*1000000000)/time_freq.QuadPart);
|
||||
|
||||
time_prev = time_cur;
|
||||
|
||||
# else
|
||||
struct timeval curtime;
|
||||
|
||||
assert(pStamp != NULL);
|
||||
if (gettimeofday(&curtime, (struct timezone *)NULL) == -1)
|
||||
retStat = S_ts_sysTimeError;
|
||||
else {
|
||||
pStamp->nsec = curtime.tv_usec * 1000;
|
||||
pStamp->secPastEpoch = curtime.tv_sec - TS_EPOCH_SEC_PAST_1970;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
clockGetCurrentTime(pStamp);
|
||||
|
||||
pStamp->nsec = pStamp->nsec - (pStamp->nsec % TS_TRUNC);
|
||||
return retStat;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
TOP=../..
|
||||
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
include $(TOP)/configure/CONFIG_BASE
|
||||
|
||||
include $(TOP)/config/RULES_ARCHS
|
||||
include $(TOP)/configure/RULES_ARCHS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user