This commit was manufactured by cvs2svn to create branch 'B3.14'.
This commit is contained in:
37
src/libCom/osi/epicsStdioRedirect.h
Normal file
37
src/libCom/osi/epicsStdioRedirect.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* epicsStdioRedirect.h */
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
#ifndef epicsStdioRedirecth
|
||||
#define epicsStdioRedirecth
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <epicsStdio.h>
|
||||
|
||||
#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
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* epicsStdioRedirecth */
|
||||
67
src/libCom/test/epicsExitTest.c
Normal file
67
src/libCom/test/epicsExitTest.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
/* epicsExitTest.cpp */
|
||||
|
||||
/* Author: Marty Kraimer Date: 09JUL2004*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "epicsThread.h"
|
||||
#include "epicsAssert.h"
|
||||
#include "epicsEvent.h"
|
||||
#include "epicsExit.h"
|
||||
|
||||
|
||||
typedef struct info {
|
||||
epicsEventId terminate;
|
||||
epicsEventId terminated;
|
||||
}info;
|
||||
|
||||
static void atExit(void *pvt)
|
||||
{
|
||||
info *pinfo = (info *)pvt;
|
||||
epicsEventSignal(pinfo->terminate);
|
||||
/*Now wait for thread to terminate*/
|
||||
epicsEventMustWait(pinfo->terminated);
|
||||
epicsEventDestroy(pinfo->terminate);
|
||||
epicsEventDestroy(pinfo->terminated);
|
||||
free(pinfo);
|
||||
}
|
||||
|
||||
static void thread(void *arg)
|
||||
{
|
||||
info *pinfo = (info *)arg;
|
||||
|
||||
printf("thread %s starting\n", epicsThreadGetNameSelf());
|
||||
pinfo->terminate = epicsEventMustCreate(epicsEventEmpty);
|
||||
pinfo->terminated = epicsEventMustCreate(epicsEventEmpty);
|
||||
epicsAtExit(atExit,pinfo);
|
||||
printf("thread %s waiting for atExit\n", epicsThreadGetNameSelf());
|
||||
epicsEventMustWait(pinfo->terminate);
|
||||
printf("thread %s terminating\n", epicsThreadGetNameSelf());
|
||||
epicsEventSignal(pinfo->terminated);
|
||||
}
|
||||
void epicsExitTest(void)
|
||||
{
|
||||
unsigned int stackSize;
|
||||
info *pinfoA;
|
||||
info *pinfoB;
|
||||
|
||||
stackSize = epicsThreadGetStackSize(epicsThreadStackSmall);
|
||||
pinfoA = (info *)calloc(1,sizeof(info));
|
||||
epicsThreadCreate("threadA",50,stackSize,thread,pinfoA);
|
||||
pinfoB = (info *)calloc(1,sizeof(info));
|
||||
epicsThreadCreate("threadB",50,stackSize,thread,pinfoB);
|
||||
}
|
||||
34
src/libCom/test/epicsExitTestMain.c
Normal file
34
src/libCom/test/epicsExitTestMain.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
|
||||
* National Laboratory.
|
||||
* Copyright (c) 2002 The Regents of the University of California, as
|
||||
* Operator of Los Alamos National Laboratory.
|
||||
* EPICS BASE Versions 3.13.7
|
||||
* and higher are distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
/* epicsExitTestMain.c */
|
||||
|
||||
/* Author: Marty Kraimer Date: 24AUG2004 */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "epicsExit.h"
|
||||
#include "epicsThread.h"
|
||||
|
||||
void epicsExitTest(void);
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
epicsExitTest();
|
||||
epicsThreadSleep(1.0);
|
||||
printf("main calling epicsExit\n");
|
||||
epicsExit(0);
|
||||
return(0);
|
||||
}
|
||||
Reference in New Issue
Block a user