diff --git a/src/libCom/osi/os/WIN32/osdPoolStatus.c b/src/libCom/osi/os/WIN32/osdPoolStatus.c new file mode 100644 index 000000000..59e410fbc --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdPoolStatus.c @@ -0,0 +1,14 @@ + +#define epicsExportSharedSymbols +#include "osiPoolStatus.h" + +/* + * osiSufficentSpaceInPool () + * + * @@@@@ not implemented @@@@@ + * + */ +epicsShareFunc int epicsShareAPI osiSufficentSpaceInPool () +{ + return 1; +} diff --git a/src/libCom/osi/os/WIN32/osdPoolStatus.h b/src/libCom/osi/os/WIN32/osdPoolStatus.h new file mode 100644 index 000000000..b1a2a1ff2 --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdPoolStatus.h @@ -0,0 +1,5 @@ + +#ifdef osdPoolStatush +#define osdPoolStatush + +#endif /* osdPoolStatush */ \ No newline at end of file diff --git a/src/libCom/osi/os/WIN32/osdSem.c b/src/libCom/osi/os/WIN32/osdSem.c new file mode 100644 index 000000000..068888d57 --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdSem.c @@ -0,0 +1,49 @@ +/* osiSem.c */ +/* + * $Id$ + * WIN32 version + * + * Author Jeffrey O. Hill + * johill@lanl.gov + * 505 665 1831 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + */ + +#define epicsExportSharedSymbols +#include "shareLib.h" +#include "osiSem.h" + + +/* + * semBinaryShow () + * + */ +epicsShareFunc void epicsShareAPI semBinaryShow (semId id) +{ } + +/* + * semMutexShow () + * + */ +epicsShareFunc void epicsShareAPI semMutexShow (semId id) +{ } diff --git a/src/libCom/osi/os/WIN32/osdSem.h b/src/libCom/osi/os/WIN32/osdSem.h new file mode 100644 index 000000000..957fc2689 --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdSem.h @@ -0,0 +1,240 @@ + +/* osiSem.c */ +/* + * $Id$ + * WIN32 version + * + * Author Jeffrey O. Hill + * johill@lanl.gov + * 505 665 1831 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + */ + +#ifndef osdSemh +#define osdSemh + + +#ifndef VC_EXTRALEAN +# define VC_EXTRALEAN +#endif +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +/* including less than this causes conflicts with winsock2.h :-( */ +#include + +#include "epicsAssert.h" +#include "cantProceed.h" + +static const unsigned mSecPerSecOsdSem = 1000u; + +/* + * semBinaryCreate () + */ +epicsShareFunc INLINE semId epicsShareAPI semBinaryCreate (int initialState) +{ + HANDLE newEvent; + + newEvent = CreateEvent (NULL, FALSE, initialState?TRUE:FALSE, NULL); + return (semId) newEvent; +} + + +/* + * semBinaryDestroy () + */ +epicsShareFunc INLINE void epicsShareAPI semBinaryDestroy (semId id) +{ + HANDLE destroyee = (HANDLE) id; + BOOL success; + + success = CloseHandle (destroyee); + assert (success); +} + +/* + * semBinaryGive () + */ +epicsShareFunc INLINE void epicsShareAPI semBinaryGive (semId id) +{ + HANDLE event = (HANDLE) id; + BOOL status; + + status = SetEvent (event); + assert (status); +} + +/* + * semBinaryTake () + */ +epicsShareFunc INLINE semTakeStatus epicsShareAPI semBinaryTake (semId id) +{ + HANDLE event = (HANDLE) id; + DWORD status; + + status = WaitForSingleObject (event, INFINITE); + if ( status == WAIT_OBJECT_0 ) { + return semTakeOK; + } + else { + return semTakeError; + } +} + +/* + * semBinaryTakeTimeout () + */ +epicsShareFunc INLINE semTakeStatus epicsShareAPI semBinaryTakeTimeout (semId id, double timeOut) +{ + HANDLE event = (HANDLE) id; + DWORD status; + DWORD tmo; + + tmo = (DWORD) (timeOut * mSecPerSecOsdSem); + status = WaitForSingleObject (event, tmo); + if ( status == WAIT_OBJECT_0 ) { + return semTakeOK; + } + else if (status == WAIT_TIMEOUT) { + return semTakeTimeout; + } + else { + return semTakeError; + } +} + +/* + * semBinaryTakeNoWait () + */ +epicsShareFunc INLINE semTakeStatus epicsShareAPI semBinaryTakeNoWait (semId id) +{ + HANDLE mutex = (HANDLE) id; + DWORD status; + + status = WaitForSingleObject (mutex, 0); + if ( status == WAIT_OBJECT_0 ) { + return semTakeOK; + } + else if (status == WAIT_TIMEOUT) { + return semTakeTimeout; + } + else { + return semTakeError; + } +} + +/* + * semMutexCreate () + */ +epicsShareFunc INLINE semId epicsShareAPI semMutexCreate (void) +{ + HANDLE newMutex; + + newMutex = CreateMutex (NULL, FALSE, NULL); + return (semId) newMutex; +} + +/* + * semMutexDestroy () + */ +epicsShareFunc INLINE void epicsShareAPI semMutexDestroy (semId id) +{ + HANDLE destroyee = (HANDLE) id; + BOOL success; + + success = CloseHandle (destroyee); + assert (success); +} + +/* + * semMutexGive () + */ +epicsShareFunc INLINE void epicsShareAPI semMutexGive (semId id) +{ + HANDLE destroyee = (HANDLE) id; + BOOL success; + + success = ReleaseMutex (destroyee); + assert (success); +} + +/* + * semMutexTake () + */ +epicsShareFunc INLINE semTakeStatus epicsShareAPI semMutexTake (semId id) +{ + HANDLE mutex = (HANDLE) id; + DWORD status; + + status = WaitForSingleObject (mutex, INFINITE); + if ( status == WAIT_OBJECT_0 ) { + return semTakeOK; + } + else { + return semTakeError; + } +} + +/* + * semMutexTakeTimeout () + */ +epicsShareFunc INLINE semTakeStatus epicsShareAPI semMutexTakeTimeout (semId id, double timeOut) +{ + HANDLE mutex = (HANDLE) id; + DWORD status; + DWORD tmo; + + tmo = (DWORD) (timeOut * mSecPerSecOsdSem); + status = WaitForSingleObject (mutex, tmo); + if ( status == WAIT_OBJECT_0 ) { + return semTakeOK; + } + else if (status == WAIT_TIMEOUT) { + return semTakeTimeout; + } + else { + return semTakeError; + } +} + +/* + * semMutexTakeNoWait () + */ +epicsShareFunc INLINE semTakeStatus epicsShareAPI semMutexTakeNoWait (semId id) +{ + HANDLE mutex = (HANDLE) id; + DWORD status; + + status = WaitForSingleObject (mutex, 0); + if ( status == WAIT_OBJECT_0 ) { + return semTakeOK; + } + else if (status == WAIT_TIMEOUT) { + return semTakeTimeout; + } + else { + return semTakeError; + } +} + +#endif /* osdSemh */ \ No newline at end of file diff --git a/src/libCom/osi/os/WIN32/osdSigPipeIgnore.c b/src/libCom/osi/os/WIN32/osdSigPipeIgnore.c new file mode 100644 index 000000000..691355db7 --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdSigPipeIgnore.c @@ -0,0 +1,11 @@ + +#define epicsExportSharedSymbols +#include "osiSigPipeIgnore.h" + +/* + * NOOP + */ +epicsShareFunc void epicsShareAPI installSigPipeIgnore (void) +{ +} + diff --git a/src/libCom/osi/os/WIN32/osdSigPipeIgnore.h b/src/libCom/osi/os/WIN32/osdSigPipeIgnore.h new file mode 100644 index 000000000..27370f0e3 --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdSigPipeIgnore.h @@ -0,0 +1,5 @@ + +#ifndef osdSigPipeIgnoreh +#define osdSigPipeIgnoreh + +#endif /* osdSigPipeIgnoreh */ \ No newline at end of file diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c new file mode 100644 index 000000000..e69de29bb diff --git a/src/libCom/osi/os/WIN32/osdThread.h b/src/libCom/osi/os/WIN32/osdThread.h new file mode 100644 index 000000000..3a66d797f --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdThread.h @@ -0,0 +1,57 @@ + +#ifndef osdThreadh +#define osdThreadh + +#include + +#ifndef VC_EXTRALEAN +# define VC_EXTRALEAN +#endif +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif +/* including less than this causes conflicts with winsock2.h :-( */ +#include + +struct osdThreadPrivate +{ +#ifdef __cpluplus + osdThreadPrivate (); + ~osdThreadPrivate (); +#endif + DWORD key; +}; + +#ifdef __cpluplus + +template +inline T *osiThreadPrivate::get () +{ + return static_cast (TlsGetValue (this->key)); +} + +template +inline void osiThreadPrivate::set (T *pIn) +{ + BOOL stat = TlsSetValue (this->key, static_cast (pIn) ); + assert (stat); +} + +#else /* ifdef __cplusplus */ + +epicsShareFunc INLINE void epicsShareAPI threadPrivateSet (threadVarId id, void *pVal) +{ + struct osdThreadPrivate *pPvt = (struct osdThreadPrivate *) id; + BOOL stat = TlsSetValue (pPvt->key, (void *) pVal ); + assert (stat); +} + +epicsShareFunc INLINE void * epicsShareAPI threadPrivateGet (threadVarId id) +{ + struct osdThreadPrivate *pPvt = (struct osdThreadPrivate *) id; + return (void *) TlsGetValue (pPvt->key); +} + +#endif /* ifdef/else __cplusplus */ + +#endif /* osdThreadh */ diff --git a/src/libCom/osi/os/WIN32/osdThreadPrivate.h b/src/libCom/osi/os/WIN32/osdThreadPrivate.h new file mode 100644 index 000000000..fc9b70f09 --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdThreadPrivate.h @@ -0,0 +1,12 @@ + +#include + +#include + + + +#ifdef __cplusplus + + + +#endif /* __cplusplus */ \ No newline at end of file diff --git a/src/libCom/osi/os/vxWorks/osdAssert.c b/src/libCom/osi/os/vxWorks/osdAssert.c new file mode 100644 index 000000000..ed976d736 --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdAssert.c @@ -0,0 +1,86 @@ +/* $Id$ + * assertVX.c + * Author: Jeff Hill + * Date: 02-27-95 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * + *************************************************************************** + */ + +#include +#include +#include +#include + +#define epicsExportSharedSymbols +#include "osiThread.h" +#include "epicsPrint.h" +#include "epicsVersion.h" +#include "epicsAssert.h" + +/* + * epicsAssert () + * + * This forces assert failures into the log file and then + * calls threadSuspend() instead of exit() so that we can debug + * the problem. + */ +epicsShareFunc void epicsShareAPI epicsAssert (const char *pFile, const unsigned line, const char *pExp, + const char *pAuthorName) +{ + threadId threadid = threadGetIdSelf(); + + epicsPrintf ( +"\n\n\n%s: A call to \"assert (%s)\" failed in %s at %d\n", + threadGetName (threadid), + pExp, + pFile, + line); + + if (pAuthorName) { + + epicsPrintf ( +"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", + pAuthorName); + + } + else { + + epicsPrintf ( +"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"); + + } + epicsPrintf ("This problem occurred in \"%s\"\n", epicsReleaseVersion); + + threadSuspend (threadid); +} + diff --git a/src/libCom/osi/os/vxWorks/osdFindGlobalSymbol.c b/src/libCom/osi/os/vxWorks/osdFindGlobalSymbol.c new file mode 100644 index 000000000..f4cd60377 --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdFindGlobalSymbol.c @@ -0,0 +1,33 @@ +/* osi/os/vxWorks/osiFindGlobalSymbol */ + +#include +#include +#include +#include +#include +#include + +#include "dbmf.h" +#include "osiFindGlobalSymbol.h" +void *osiFindGlobalSymbol(const char *name) +{ + STATUS status; + SYM_TYPE type; + char *pvalue; + + status = symFindByName( sysSymTbl, (char *)name, &pvalue, &type ); + if(status) { + if(name[0] == '_' ) { + status = symFindByName(sysSymTbl, (char *)(name+1), &pvalue, &type); + } else { + char *pname; + pname = dbmfMalloc(strlen(name) + 2); + strcpy(pname,"_"); + strcat(pname,name); + status = symFindByName(sysSymTbl,pname, &pvalue, &type); + dbmfFree(pname); + } + } + if(status) return(0); + return((void *)pvalue); +} diff --git a/src/libCom/osi/os/vxWorks/osdInterrupt.c b/src/libCom/osi/os/vxWorks/osdInterrupt.c new file mode 100644 index 000000000..8a7132dc8 --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdInterrupt.c @@ -0,0 +1,16 @@ +/* osi/os/vxWorks/osiInterrupt.c */ + +/* Author: Marty Kraimer Date: 25AUG99 */ + +/********************COPYRIGHT NOTIFICATION********************************** +This software was developed under a United States Government license +described on the COPYRIGHT_UniversityOfChicago file included as part +of this distribution. +****************************************************************************/ + +/* Entire implementation is in header file */ + +static void dummy() +{ +} + diff --git a/src/libCom/osi/os/vxWorks/osdInterrupt.h b/src/libCom/osi/os/vxWorks/osdInterrupt.h new file mode 100644 index 000000000..b92efba85 --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdInterrupt.h @@ -0,0 +1,10 @@ +#include +#include +#include + + +#define interruptLock intLock +#define interruptUnlock intUnlock +#define interruptIsInterruptContext intContext +#define interruptContextMessage(MESSAGE) \ + (logMsg((char *)(MESSAGE),0,0,0,0,0,0)) diff --git a/src/libCom/osi/os/vxWorks/osdPoolStatus.c b/src/libCom/osi/os/vxWorks/osdPoolStatus.c new file mode 100644 index 000000000..59e410fbc --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdPoolStatus.c @@ -0,0 +1,14 @@ + +#define epicsExportSharedSymbols +#include "osiPoolStatus.h" + +/* + * osiSufficentSpaceInPool () + * + * @@@@@ not implemented @@@@@ + * + */ +epicsShareFunc int epicsShareAPI osiSufficentSpaceInPool () +{ + return 1; +} diff --git a/src/libCom/osi/os/vxWorks/osdRing.c b/src/libCom/osi/os/vxWorks/osdRing.c new file mode 100644 index 000000000..3ecd1acbb --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdRing.c @@ -0,0 +1,14 @@ +/* osiRing.c */ + +/* Author: Marty Kraimer Date: 09SEP99 */ + +/********************COPYRIGHT NOTIFICATION********************************** +This software was developed under a United States Government license +described on the COPYRIGHT_UniversityOfChicago file included as part +of this distribution. +****************************************************************************/ + +/* Entire implementation is in header file */ + +static void dummy() +{ } diff --git a/src/libCom/osi/os/vxWorks/osdRing.h b/src/libCom/osi/os/vxWorks/osdRing.h new file mode 100644 index 000000000..da85f4e1a --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdRing.h @@ -0,0 +1,20 @@ +#ifndef osiRingh +#define osiRingh + +#include +#include + +#define ringId RING_ID + +#define ringCreate rngCreate +#define ringDelete rngDelete +#define ringGet rngBufGet +#define ringPut rngBufPut +#define ringFlush rngFlush +#define ringFreeBytes rngFreeBytes +#define ringUsedBytes rngNBytes +#define ringSize(ID) (rngFreeBytes((ID)) + rngNBytes((ID))) +#define ringIsEmpty rngIsEmpty +#define ringIsFull rngIsFull + +#endif /* osiRingh */ diff --git a/src/libCom/osi/os/vxWorks/osdSem.c b/src/libCom/osi/os/vxWorks/osdSem.c new file mode 100644 index 000000000..08767c180 --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdSem.c @@ -0,0 +1,29 @@ +/* os/vxWorks/osiSem.c */ + +/* Author: Marty Kraimer Date: 25AUG99 */ + +/********************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 "osiSem.h" +#include "cantProceed.h" + + +semBinaryId semBinaryMustCreate(int initialState) +{ + semBinaryId id; + id = semBinaryCreate(initialState); + if(!id) cantProceed("semBinaryMustCreate"); + return(id); +} + +semMutexId semMutexMustCreate(void) +{ + semMutexId id; + id = semMutexCreate(); + if(!id) cantProceed("semMutexMustCreate"); + return(id); +} diff --git a/src/libCom/osi/os/vxWorks/osdSem.h b/src/libCom/osi/os/vxWorks/osdSem.h new file mode 100644 index 000000000..633d7257f --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdSem.h @@ -0,0 +1,53 @@ +#ifndef osiSemh +#define osiSemh + +#include +#include +#include +#include +#include + +#include "epicsAssert.h" + +#define semBinaryId SEM_ID +#define semMutexId SEM_ID +#define semEmpty SEM_EMPTY +#define semFull SEM_FULL + +typedef enum {semTakeOK,semTakeTimeout,semTakeError} semTakeStatus; + +#define semBinaryCreate(IS) semBCreate(SEM_Q_FIFO,(IS)) +semBinaryId semBinaryMustCreate(int initialState); +#define semBinaryDestroy semDelete +#define semBinaryGive semGive +#define semBinaryTake(ID) \ + ((semTake((ID),WAIT_FOREVER)==OK ? semTakeOK : semTakeError)) +#define semBinaryMustTake(ID) \ + assert(semTake((ID),WAIT_FOREVER)==OK) +#define semBinaryTakeTimeout(ID,TIMEOUT) \ + ((semTake((ID),((int)((TIMEOUT)*sysClkRateGet())))==OK ? semTakeOK \ + : (errno==S_objLib_OBJ_TIMEOUT ? semTakeTimeout : semTakeError))) +#define semBinaryTakeNoWait(ID) \ + ((semTake((ID),NO_WAIT)==OK ? semTakeOK \ + : (errno==S_objLib_OBJ_UNAVAILABLE ? semTakeTimeout : semTakeError))) + +#define semBinaryShow(ID) semShow((ID),1) + +#define semMutexCreate() \ + semMCreate(SEM_DELETE_SAFE|SEM_INVERSION_SAFE|SEM_Q_PRIORITY) +semMutexId semMutexMustCreate(); +#define semMutexDestroy semDelete +#define semMutexGive semGive +#define semMutexTake(ID) \ + ((semTake((ID),WAIT_FOREVER)==OK ? semTakeOK : semTakeError)) +#define semMutexMustTake(ID) \ + assert(semTake((ID),WAIT_FOREVER)==OK) +#define semMutexTakeTimeout(ID,TIMEOUT) \ + ((semTake((ID),((int)((TIMEOUT)*sysClkRateGet())))==OK ? semTakeOK \ + : (errno==S_objLib_OBJ_TIMEOUT ? semTakeTimeout : semTakeError))) +#define semMutexTakeNoWait(ID) \ + ((semTake((ID),NO_WAIT)==OK ? semTakeOK \ + : (errno==S_objLib_OBJ_UNAVAILABLE ? semTakeTimeout : semTakeError))) +#define semMutexShow(ID) semShow((ID),1) + +#endif /*osiSemh*/ diff --git a/src/libCom/osi/os/vxWorks/osdSigPipeIgnore.c b/src/libCom/osi/os/vxWorks/osdSigPipeIgnore.c new file mode 100644 index 000000000..691355db7 --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdSigPipeIgnore.c @@ -0,0 +1,11 @@ + +#define epicsExportSharedSymbols +#include "osiSigPipeIgnore.h" + +/* + * NOOP + */ +epicsShareFunc void epicsShareAPI installSigPipeIgnore (void) +{ +} + diff --git a/src/libCom/osi/os/vxWorks/osdThread.c b/src/libCom/osi/os/vxWorks/osdThread.c new file mode 100644 index 000000000..f92329db7 --- /dev/null +++ b/src/libCom/osi/os/vxWorks/osdThread.c @@ -0,0 +1,158 @@ +/* osi/os/vxWorks/osiThread.c */ + +/* Author: Marty Kraimer Date: 25AUG99 */ + +/********************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 +#include +#include +#include +#include + +#include +#include +#include + +#include "errlog.h" +#include "ellLib.h" +#include "osiThread.h" +#include "cantProceed.h" + +/* Just map osi 0 to 99 into vx 100 to 199 */ +/* remember that for vxWorks lower number means higher priority */ +/* vx = 100 + (99 -osi) = 199 - osi*/ +/* osi = 199 - vx */ + +static unsigned int getOsiPriorityValue(int ossPriority) +{ + return(199-ossPriority); +} + +static int getOssPriorityValue(unsigned int osiPriority) +{ + return(199 - osiPriority); +} + + +#if CPU_FAMILY == MC680X0 +#define ARCH_STACK_FACTOR 1 +#elif CPU_FAMILY == SPARC +#define ARCH_STACK_FACTOR 2 +#else +#define ARCH_STACK_FACTOR 2 +#endif + +/* + * threadGetStackSize () + */ +epicsShareFunc unsigned int epicsShareAPI threadGetStackSize (threadStackSizeClass stackSizeClass) +{ + static const unsigned stackSizeTable[threadStackBig+1] = + {4000*ARCH_STACK_FACTOR, 6000*ARCH_STACK_FACTOR, 11000*ARCH_STACK_FACTOR}; + + if (stackSizeClassthreadStackBig) { + errlogPrintf("threadGetStackSize illegal argument (too large)"); + return stackSizeTable[threadStackBig]; + } + + return stackSizeTable[stackSizeClass]; +} + + +threadId threadCreate(const char *name, + unsigned int priority, unsigned int stackSize, + THREADFUNC funptr,void *parm) +{ + int tid; + if(stackSize<100) { + errlogPrintf("threadCreate %s illegal stackSize %d\n",name,stackSize); + return(0); + } + tid = taskSpawn((char *)name,getOssPriorityValue(priority), + VX_FP_TASK, stackSize, (FUNCPTR)funptr,(int)parm,0,0,0,0,0,0,0,0,0); + if(tid==0) { + errlogPrintf("threadCreate taskSpawn failure for %s\n",name); + return(0); + } + return((threadId)tid); +} + +void threadSuspend(threadId id) +{ + int tid = (int)id; + STATUS status; + + status = taskSuspend(tid); + if(status) errlogPrintf("threadSuspend failed\n"); +} + +void threadResume(threadId id) +{ + int tid = (int)id; + STATUS status; + + status = taskResume(tid); + if(status) errlogPrintf("threadResume failed\n"); +} + +unsigned int threadGetPriority(threadId id) +{ + int tid = (int)id; + STATUS status; + int priority = 0; + + status = taskPriorityGet(tid,&priority); + if(status) errlogPrintf("threadGetPriority failed\n"); + return(getOsiPriorityValue(priority)); +} + +void threadSetPriority(threadId id,unsigned int osip) +{ + int tid = (int)id; + STATUS status; + int priority = 0; + + priority = getOssPriorityValue(osip); + status = taskPrioritySet(tid,priority); + if(status) errlogPrintf("threadSetPriority failed\n"); +} + +int threadIsEqual(threadId id1, threadId id2) +{ + return((id1==id2) ? 1 : 0); +} + +int threadIsReady(threadId id) +{ + int tid = (int)id; + return((int)taskIsReady(tid)); +} + +int threadIsSuspended(threadId id) +{ + int tid = (int)id; + return((int)taskIsSuspended(tid)); +} + +void threadSleep(double seconds) +{ + STATUS status; + + status = taskDelay((int)(seconds*sysClkRateGet())); + if(status) errlogPrintf(0,"threadSleep\n"); +} + +threadId threadGetIdSelf(void) +{ + return((threadId)taskIdSelf()); +}