54 static exitPvt * pExitPvtPerProcess = 0;
58 static int exitLaterStatus;
60 static void destroyExitPvt(
exitPvt * pep)
66 static exitPvt * createExitPvt(
void)
68 exitPvt * pep = calloc ( 1,
sizeof ( * pep ) );
75 static void exitPvtOnceFunc(
void *pParm)
78 assert ( exitPvtPerThread );
82 static void epicsExitInit(
void)
87 static void epicsExitCallAtExitsPvt(
exitPvt *pep)
93 fprintf(
stderr,
"atExit %s(%p)\n", pexitNode->
name, pexitNode->
arg);
95 fprintf(
stderr,
"atExit %p(%p)\n", pexitNode->
func, pexitNode->
arg);
96 pexitNode->
func ( pexitNode->
arg );
108 if ( pExitPvtPerProcess ) {
109 pep = pExitPvtPerProcess;
110 pExitPvtPerProcess = 0;
114 epicsExitCallAtExitsPvt ( pep );
115 destroyExitPvt ( pep );
128 epicsExitCallAtExitsPvt ( pep );
129 destroyExitPvt ( pep );
137 exitNode * pExitNode = calloc ( 1,
sizeof( *pExitNode ) + (name?strlen(name):0) );
143 strcpy(pExitNode->
name, name);
157 pep = createExitPvt ();
163 return epicsAtExitPvt ( pep, func, arg,
NULL );
172 if ( !pExitPvtPerProcess ) {
173 pExitPvtPerProcess = createExitPvt ();
175 if ( pExitPvtPerProcess ) {
176 status = epicsAtExitPvt ( pExitPvtPerProcess, func, arg, name );
189 static void exitNow(
void *junk)
194 static void exitLaterOnceFunc(
void *raw)
197 exitLaterStatus = *
status;
epicsThreadId epicsStdCall epicsThreadMustCreate(const char *name, unsigned int priority, unsigned int stackSize, EPICSTHREADFUNC funptr, void *parm)
#define assert(exp)
Declare that a condition should be true.
LIBCOM_API int epicsAtThreadExit(epicsExitFunc func, void *arg)
Register a function and an context value to be run by this thread when it returns from its entry rout...
LIBCOM_API void epicsExitCallAtThreadExits(void)
Internal routine that runs the registered thread exit routines.
LIBCOM_API void *epicsStdCall epicsThreadPrivateGet(epicsThreadPrivateId)
LIBCOM_API void epicsExitLater(int status)
Arrange to call epicsExit() later from a low priority thread.
#define epicsMutexMustCreate()
Create an epicsMutex semaphore for use from C code.
epicsExportAddress(int, atExitDebug)
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
LIBCOM_API unsigned int epicsStdCall epicsThreadGetStackSize(epicsThreadStackSizeClass size)
A doubly-linked list library.
void ellAdd(ELLLIST *pList, ELLNODE *pNode)
Adds a node to the end of a list.
#define ellFree(PLIST)
Free up the list.
#define EPICS_THREAD_ONCE_INIT
APIs for the epicsMutex mutual exclusion semaphore.
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
LIBCOM_API void epicsStdCall epicsThreadPrivateSet(epicsThreadPrivateId, void *)
void epicsMutexCleanup(void)
#define epicsThreadPriorityLow
LIBCOM_API void epicsExit(int status)
Calls epicsExitCallAtExits(), then the OS exit() routine.
Extended replacement for the Posix exit and atexit routines.
#define ellLast(PLIST)
Find the last node in list.
void(* epicsExitFunc)(void *arg)
Pointer to a callback function that is to be called by the epicsExit subsystem.
#define ellInit(PLIST)
Initialize a list type.
LIBCOM_API void epicsStdCall epicsThreadSleep(double seconds)
Block the calling thread for at least the specified time.
LIBCOM_API void epicsExitCallAtExits(void)
Internal routine that runs the registered exit routines.
Routines for code that can't continue or return after an error.
C++ and C descriptions for a thread.
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.
LIBCOM_API epicsThreadPrivateId epicsStdCall epicsThreadPrivateCreate(void)
LIBCOM_API int epicsAtExit3(epicsExitFunc func, void *arg, const char *name)
Register a function and an associated context parameter.