epicsExit and epicsStdioRedirect
This commit is contained in:
@@ -118,6 +118,7 @@ INC += adjustment.h
|
||||
INC += cantProceed.h
|
||||
INC += dbDefs.h
|
||||
INC += epicsConvert.h
|
||||
INC += epicsExit.h
|
||||
INC += epicsString.h
|
||||
INC += epicsTypes.h
|
||||
INC += gsd_sync_defs.h
|
||||
@@ -131,6 +132,7 @@ SRCS += aToIPAddr.c
|
||||
SRCS += adjustment.c
|
||||
SRCS += cantProceed.c
|
||||
SRCS += epicsConvert.c
|
||||
SRCS += epicsExit.c
|
||||
SRCS += epicsString.c
|
||||
SRCS += truncateFile.c
|
||||
SRCS += ipAddrToAsciiAsynchronous.cpp
|
||||
@@ -166,6 +168,7 @@ INC += osiWireFormat.h
|
||||
INC += epicsReadline.h
|
||||
INC += epicsMessageQueue.h
|
||||
INC += epicsStdio.h
|
||||
INC += epicsStdioRedirect.h
|
||||
INC += epicsGetopt.h
|
||||
|
||||
INC += devLib.h
|
||||
|
||||
@@ -21,11 +21,12 @@
|
||||
#include "epicsGuard.h"
|
||||
#include "epicsThread.h"
|
||||
#include "epicsSingleton.h"
|
||||
#include "epicsExit.h"
|
||||
|
||||
static epicsThreadOnceId epicsSingletonOnceId = EPICS_THREAD_ONCE_INIT;
|
||||
static epicsMutex *pSingletonBaseMutexEPICS;
|
||||
|
||||
static void epicsSingletonCleanup ()
|
||||
static void epicsSingletonCleanup (void *)
|
||||
{
|
||||
delete pSingletonBaseMutexEPICS;
|
||||
}
|
||||
@@ -33,7 +34,7 @@ static void epicsSingletonCleanup ()
|
||||
static void epicsSingletonOnce ( void * )
|
||||
{
|
||||
pSingletonBaseMutexEPICS = new epicsMutex;
|
||||
atexit ( epicsSingletonCleanup );
|
||||
epicsAtExit ( epicsSingletonCleanup,0 );
|
||||
}
|
||||
|
||||
epicsSingletonBase::epicsSingletonBase () : pSingleton ( 0 )
|
||||
@@ -58,4 +59,4 @@ void epicsSingletonBase::lockedFactory ()
|
||||
this->pSingleton = this->factory ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "errlog.h"
|
||||
#include "logClient.h"
|
||||
#include "epicsStdio.h"
|
||||
#include "epicsExit.h"
|
||||
|
||||
|
||||
#ifndef LOCAL
|
||||
@@ -49,7 +50,7 @@
|
||||
epicsShareDef int errVerbose=0;
|
||||
|
||||
LOCAL void errlogCleanup(void);
|
||||
LOCAL void exitHandler(void);
|
||||
LOCAL void exitHandler(void*);
|
||||
LOCAL void errlogThread(void);
|
||||
|
||||
LOCAL char *msgbufGetFree(int noConsoleMessage);
|
||||
@@ -366,7 +367,7 @@ epicsShareFunc void errPrintf(long status, const char *pFileName,
|
||||
msgbufSetSize(totalChar);
|
||||
}
|
||||
|
||||
LOCAL void exitHandler(void)
|
||||
LOCAL void exitHandler(void *pvt)
|
||||
{
|
||||
pvtData.atExit = 1;
|
||||
epicsEventSignal(pvtData.waitForWork);
|
||||
@@ -403,7 +404,7 @@ LOCAL void errlogInitPvt(void *arg)
|
||||
if(tid) {
|
||||
pvtData.errlogInitFailed = FALSE;
|
||||
}
|
||||
atexit(exitHandler);
|
||||
epicsAtExit(exitHandler,0);
|
||||
}
|
||||
|
||||
LOCAL void errlogCleanup(void)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "errlog.h"
|
||||
#include "envDefs.h"
|
||||
#include "ellLib.h"
|
||||
#include "epicsExit.h"
|
||||
|
||||
#include "logClient.h"
|
||||
|
||||
@@ -175,14 +176,8 @@ LOCAL void logClientDestroy (logClient *pClient)
|
||||
/*
|
||||
* logClientShutdown()
|
||||
*/
|
||||
LOCAL void logClientShutdown (void)
|
||||
LOCAL void logClientShutdown (void * pvt)
|
||||
{
|
||||
/*
|
||||
* unfortunately this does not currently work on vxWorks because WRS
|
||||
* runs the reboot hooks in the order that
|
||||
* they are installed (and the network is already shutdown
|
||||
* by the time we get here)
|
||||
*/
|
||||
logClient *pClient;
|
||||
epicsMutexMustLock (logClientGlobalMutex);
|
||||
while ( ( pClient = (logClient *) ellGet (&logClientList) ) ) {
|
||||
@@ -317,7 +312,7 @@ void epicsShareAPI logClientFlush ( logClientId id )
|
||||
}
|
||||
|
||||
/*
|
||||
* iocLogShow ()
|
||||
* iocLogFlush ()
|
||||
*/
|
||||
void epicsShareAPI epicsShareAPI iocLogFlush ()
|
||||
{
|
||||
@@ -586,7 +581,7 @@ LOCAL void logClientGlobalInit ()
|
||||
return;
|
||||
}
|
||||
|
||||
atexit (logClientShutdown);
|
||||
epicsAtExit (logClientShutdown,0);
|
||||
|
||||
epicsMutexUnlock (logClientGlobalMutex);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsStdioRedirect.h"
|
||||
|
||||
//
|
||||
// Its probably preferable to not make these inline because they are in
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsMessageQueue.h"
|
||||
#include "epicsStdioRedirect.h"
|
||||
|
||||
epicsMessageQueue::epicsMessageQueue(unsigned int aCapacity,
|
||||
unsigned int aMaxMessageSize)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsStdioRedirect.h"
|
||||
#include "epicsThread.h"
|
||||
#include "ellLib.h"
|
||||
#include "errlog.h"
|
||||
|
||||
@@ -18,11 +18,8 @@
|
||||
#include <errno.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#define epicsStdioh
|
||||
#include "shareLib.h"
|
||||
#include "epicsThread.h"
|
||||
#undef epicsStdioh
|
||||
#define epicsStdioPVT
|
||||
#include "epicsStdio.h"
|
||||
|
||||
static epicsThreadOnceId onceId = EPICS_THREAD_ONCE_INIT;
|
||||
|
||||
@@ -54,21 +54,6 @@ epicsShareFunc void epicsShareAPI epicsSetStderr(FILE *);
|
||||
epicsShareFunc int epicsShareAPI epicsStdoutPrintf(
|
||||
const char *pformat, ...) EPICS_PRINTF_STYLE(1,2);
|
||||
|
||||
#ifndef epicsStdioPVT
|
||||
#undef stdin
|
||||
#define stdin epicsGetStdin()
|
||||
#undef stdout
|
||||
#define stdout epicsGetStdout()
|
||||
#undef stderr
|
||||
#define stderr epicsGetStderr()
|
||||
|
||||
/*The following are for making printf be fprintf(stdout */
|
||||
#ifdef printf
|
||||
#undef printf
|
||||
#endif /*printf*/
|
||||
#define printf epicsStdoutPrintf
|
||||
#endif /* epicsStdioPVT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsStdioRedirect.h"
|
||||
#include "locationException.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "epicsVersion.h"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <rtems.h>
|
||||
#include <rtems/error.h>
|
||||
|
||||
#include "epicsStdioRedirect.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "errlog.h"
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <rtems.h>
|
||||
#include <rtems/error.h>
|
||||
|
||||
#include "epicsStdio.h"
|
||||
#include "errlog.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsString.h"
|
||||
@@ -194,6 +195,7 @@ badInit (const char *msg)
|
||||
const char fmt[] = "%s called before epicsThreadInit finished!";
|
||||
|
||||
syslog (LOG_CRIT, fmt, msg);
|
||||
/* may not be safe to call epicsGetStderr */
|
||||
fprintf (stderr, fmt, msg);
|
||||
fprintf (stderr, "\n");
|
||||
rtems_task_suspend (RTEMS_SELF);
|
||||
@@ -572,7 +574,7 @@ showInternalTaskInfo (rtems_id tid)
|
||||
|
||||
the_thread = _Thread_Get (tid, &location);
|
||||
if (location != OBJECTS_LOCAL) {
|
||||
printf ("%-30s", " *** RTEMS task gone! ***");
|
||||
fprintf(epicsGetStdout(),"%-30s", " *** RTEMS task gone! ***");
|
||||
return;
|
||||
}
|
||||
thread = *the_thread;
|
||||
@@ -586,40 +588,40 @@ showInternalTaskInfo (rtems_id tid)
|
||||
*/
|
||||
epicsPri = 199-thread.real_priority;
|
||||
if (epicsPri < 0)
|
||||
printf (" <0");
|
||||
fprintf(epicsGetStdout()," <0");
|
||||
else if (epicsPri > 99)
|
||||
printf (" >99");
|
||||
fprintf(epicsGetStdout()," >99");
|
||||
else
|
||||
printf (" %4d", epicsPri);
|
||||
fprintf(epicsGetStdout()," %4d", epicsPri);
|
||||
if (thread.current_priority == thread.real_priority)
|
||||
printf ("%4d ", thread.current_priority);
|
||||
fprintf(epicsGetStdout(),"%4d ", thread.current_priority);
|
||||
else
|
||||
printf ("%4d/%-3d", thread.real_priority, thread.current_priority);
|
||||
fprintf(epicsGetStdout(),"%4d/%-3d", thread.real_priority, thread.current_priority);
|
||||
showBitmap (bitbuf, thread.current_state, taskState);
|
||||
printf ("%8.8s", bitbuf);
|
||||
fprintf(epicsGetStdout(),"%8.8s", bitbuf);
|
||||
if (thread.current_state & (STATES_WAITING_FOR_SEMAPHORE |
|
||||
STATES_WAITING_FOR_MUTEX |
|
||||
STATES_WAITING_FOR_MESSAGE))
|
||||
printf (" %8.8x", thread.Wait.id);
|
||||
fprintf(epicsGetStdout()," %8.8x", thread.Wait.id);
|
||||
else
|
||||
printf (" %8.8s", "");
|
||||
fprintf(epicsGetStdout()," %8.8s", "");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
epicsThreadShowHeader (void)
|
||||
{
|
||||
printf (" PRIORITY\n");
|
||||
printf (" ID EPICS RTEMS STATE WAIT NAME\n");
|
||||
printf ("+--------+-----------+--------+--------+---------------------+\n");
|
||||
fprintf(epicsGetStdout()," PRIORITY\n");
|
||||
fprintf(epicsGetStdout()," ID EPICS RTEMS STATE WAIT NAME\n");
|
||||
fprintf(epicsGetStdout(),"+--------+-----------+--------+--------+---------------------+\n");
|
||||
}
|
||||
|
||||
static void
|
||||
epicsThreadShowInfo (struct taskVar *v, unsigned int level)
|
||||
{
|
||||
printf ("%9.8x", v->id);
|
||||
fprintf(epicsGetStdout(),"%9.8x", v->id);
|
||||
showInternalTaskInfo (v->id);
|
||||
printf (" %s\n", v->name);
|
||||
fprintf(epicsGetStdout()," %s\n", v->name);
|
||||
}
|
||||
|
||||
void epicsThreadShow (epicsThreadId id, unsigned int level)
|
||||
@@ -638,7 +640,7 @@ void epicsThreadShow (epicsThreadId id, unsigned int level)
|
||||
}
|
||||
}
|
||||
taskVarUnlock ();
|
||||
printf ("*** Thread %x does not exist.\n", (unsigned int)id);
|
||||
fprintf(epicsGetStdout(),"*** Thread %x does not exist.\n", (unsigned int)id);
|
||||
}
|
||||
|
||||
void epicsThreadShowAll (unsigned int level)
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "shareLib.h"
|
||||
#include "epicsMutex.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "epicsStdioRedirect.h"
|
||||
|
||||
typedef struct epicsMutexOSD {
|
||||
union {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <process.h> /* for _endthread() etc */
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "epicsStdio.h"
|
||||
#include "shareLib.h"
|
||||
#include "epicsThread.h"
|
||||
#include "cantProceed.h"
|
||||
@@ -849,24 +850,24 @@ static void epicsThreadShowPrivate ( epicsThreadId id, unsigned level )
|
||||
win32ThreadParam * pParm = ( win32ThreadParam * ) id;
|
||||
|
||||
if ( pParm ) {
|
||||
printf ( "%-15s %-8p %-8x %-9u %-9s %-7s", pParm->pName,
|
||||
fprintf (epicsGetStdout(), "%-15s %-8p %-8x %-9u %-9s %-7s", pParm->pName,
|
||||
(void *) pParm, pParm->id, pParm->epicsPriority,
|
||||
epics_GetThreadPriorityAsString ( pParm->handle ),
|
||||
epicsThreadIsSuspended ( id ) ? "suspend" : "ok" );
|
||||
if ( level ) {
|
||||
printf ( " %-8p %-8p %-8p ",
|
||||
fprintf (epicsGetStdout(), " %-8p %-8p %-8p ",
|
||||
(void *) pParm->handle, (void *) pParm->funptr,
|
||||
(void *) pParm->parm );
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf (
|
||||
fprintf (epicsGetStdout(),
|
||||
"NAME EPICS-ID WIN32-ID EPICS-PRI WIN32-PRI STATE " );
|
||||
if ( level ) {
|
||||
printf ( " HANDLE FUNCTION PARAMETER" );
|
||||
fprintf (epicsGetStdout(), " HANDLE FUNCTION PARAMETER" );
|
||||
}
|
||||
}
|
||||
printf ("\n" );
|
||||
fprintf (epicsGetStdout(),"\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <epicsStdioRedirect.h>
|
||||
#include <errlog.h>
|
||||
#include <cantProceed.h>
|
||||
#include <envDefs.h>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "epicsStdio.h"
|
||||
#include "ellLib.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsMutex.h"
|
||||
@@ -600,7 +601,7 @@ void epicsThreadGetName(epicsThreadId pthreadInfo, char *name, size_t size)
|
||||
static void showThreadInfo(epicsThreadOSD *pthreadInfo,unsigned int level)
|
||||
{
|
||||
if(!pthreadInfo) {
|
||||
printf (" NAME EPICS ID PTHREAD ID OSIPRI OSSPRI STATE\n");
|
||||
fprintf(epicsGetStdout()," NAME EPICS ID PTHREAD ID OSIPRI OSSPRI STATE\n");
|
||||
}
|
||||
else {
|
||||
struct sched_param param;
|
||||
@@ -610,7 +611,7 @@ static void showThreadInfo(epicsThreadOSD *pthreadInfo,unsigned int level)
|
||||
if ((pthreadInfo->tid != 0)
|
||||
&& (pthread_getschedparam(pthreadInfo->tid,&policy,¶m) == 0))
|
||||
priority = param.sched_priority;
|
||||
printf("%16.16s %12p %12lu %3d%8d %8.8s\n", pthreadInfo->name,(void *)
|
||||
fprintf(epicsGetStdout(),"%16.16s %12p %12lu %3d%8d %8.8s\n", pthreadInfo->name,(void *)
|
||||
pthreadInfo,(unsigned long)pthreadInfo->tid,
|
||||
pthreadInfo->osiPriority,priority,
|
||||
pthreadInfo->isSuspended?"SUSPEND":"OK");
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <ctype.h>
|
||||
#include <envLib.h>
|
||||
|
||||
#include <epicsStdioRedirect.h>
|
||||
#include <errlog.h>
|
||||
#include <cantProceed.h>
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@ epicsOkToBlockTestHost_SRCS += epicsOkToBlockTestMain.cpp epicsOkToBlockTest.cpp
|
||||
PROD_HOST += epicsOkToBlockTestHost
|
||||
OBJS_IOC_vxWorks += epicsOkToBlockTest
|
||||
|
||||
epicsExitTestHost_SRCS += epicsExitTestMain.c epicsExitTest.c
|
||||
PROD_HOST += epicsExitTestHost
|
||||
OBJS_IOC_vxWorks += epicsExitTest
|
||||
|
||||
|
||||
epicsTimerTestHost_SRCS += epicsTimerTestMain.cpp epicsTimerTest.cpp
|
||||
PROD_HOST += epicsTimerTestHost
|
||||
|
||||
@@ -45,15 +45,16 @@ static void thread(void *arg)
|
||||
void epicsOkToBlockTest(void)
|
||||
{
|
||||
unsigned int stackSize;
|
||||
info *pinfo;
|
||||
info *pinfoA;
|
||||
info *pinfoB;
|
||||
|
||||
stackSize = epicsThreadGetStackSize(epicsThreadStackSmall);
|
||||
pinfo = (info *)calloc(1,sizeof(info));
|
||||
pinfo->isOkToBlock = 0;
|
||||
epicsThreadCreate("threadA",50,stackSize,thread,pinfo);
|
||||
pinfo = (info *)calloc(1,sizeof(info));
|
||||
pinfo->isOkToBlock = 1;
|
||||
epicsThreadCreate("threadB",50,stackSize,thread,pinfo);
|
||||
pinfoA = (info *)calloc(1,sizeof(info));
|
||||
pinfoA->isOkToBlock = 0;
|
||||
epicsThreadCreate("threadA",50,stackSize,thread,pinfoA);
|
||||
pinfoB = (info *)calloc(1,sizeof(info));
|
||||
pinfoB->isOkToBlock = 1;
|
||||
epicsThreadCreate("threadB",50,stackSize,thread,pinfoB);
|
||||
epicsThreadSleep(2.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user