From 081ceea52d7e5d8982f54cfb7b2a027e11a3f8ce Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Tue, 13 Jun 2000 19:08:16 +0000 Subject: [PATCH] call threadInit where needed --- src/libCom/osi/os/RTEMS/osdThread.c | 6 ++---- src/libCom/osi/os/posix/osdThread.c | 4 ++++ src/libCom/osi/os/vxWorks/osdThread.c | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libCom/osi/os/RTEMS/osdThread.c b/src/libCom/osi/os/RTEMS/osdThread.c index ddd8ad192..e587eb998 100644 --- a/src/libCom/osi/os/RTEMS/osdThread.c +++ b/src/libCom/osi/os/RTEMS/osdThread.c @@ -237,8 +237,7 @@ threadCreate (const char *name, rtems_status_code sc; char c[4]; - if (!initialized) - badInit ("threadCreate"); + if (!initialized) threadInit(); if (stackSize < RTEMS_MINIMUM_STACK_SIZE) { errlogPrintf ("threadCreate %s illegal stackSize %d\n",name,stackSize); return 0; @@ -421,8 +420,7 @@ threadId threadGetId (const char *name) */ void threadOnceOsd(threadOnceId *id, void(*func)(void *), void *arg) { - if (!initialized) - badInit ("threadOnce"); + if (!initialized) threadInit(); semMutexMustTake(onceMutex); if (*id == 0) { *id = -1; diff --git a/src/libCom/osi/os/posix/osdThread.c b/src/libCom/osi/os/posix/osdThread.c index 73b07037b..a7674fe3e 100644 --- a/src/libCom/osi/os/posix/osdThread.c +++ b/src/libCom/osi/os/posix/osdThread.c @@ -52,6 +52,7 @@ static semMutexId onceMutex; static semMutexId listMutex; static ELLLIST pthreadList; static commonAttr *pcommonAttr = 0; +static int threadInitCalled = 0; #define checkStatus(status,message) \ if((status)) {\ @@ -256,6 +257,7 @@ void threadInit(void) { static pthread_once_t once_control = PTHREAD_ONCE_INIT; int status = pthread_once(&once_control,once); + threadInitCalled = 1; checkStatusQuit(status,"pthread_once","threadInit"); } @@ -263,6 +265,7 @@ void threadInit(void) void threadOnceOsd(threadOnceId *id, void (*func)(void *), void *arg) { + if(!threadInitCalled) threadInit(); if(semMutexTake(onceMutex) != semTakeOK) { fprintf(stderr,"threadOnceOsd semMutexTake failed.\n"); fprintf(stderr,"Did you call threadInit? Program exiting\n"); @@ -283,6 +286,7 @@ threadId threadCreate(const char *name, threadInfo *pthreadInfo; int status; + if(!threadInitCalled) threadInit(); if(pcommonAttr==0) { fprintf(stderr,"It appears that threadCreate was called before threadInit.\n"); fprintf(stderr,"Program is exiting\n"); diff --git a/src/libCom/osi/os/vxWorks/osdThread.c b/src/libCom/osi/os/vxWorks/osdThread.c index 05a60a97f..b3d54c118 100644 --- a/src/libCom/osi/os/vxWorks/osdThread.c +++ b/src/libCom/osi/os/vxWorks/osdThread.c @@ -119,6 +119,7 @@ threadId threadCreate(const char *name, THREADFUNC funptr,void *parm) { int tid; + if(threadOnceMutex==0) threadInit(); if(stackSize<100) { errlogPrintf("threadCreate %s illegal stackSize %d\n",name,stackSize); return(0);