diff --git a/src/kernel/init.c b/src/kernel/init.c index 46752c24..19a2294d 100644 --- a/src/kernel/init.c +++ b/src/kernel/init.c @@ -257,10 +257,7 @@ ndef __USE_TIMER_THREAD return NULL; } -/************************** Thread Information ******************************/ - -pthread_key_t __mg_threadinfo_key; - +/* The following function is moved to src/include/internals.h as inline functions. static inline BOOL createThreadInfoKey (void) { if (pthread_key_create (&__mg_threadinfo_key, NULL)) @@ -273,46 +270,6 @@ static inline void deleteThreadInfoKey (void) pthread_key_delete (__mg_threadinfo_key); } -MSGQUEUE* mg_InitMsgQueueThisThread (void) -{ - MSGQUEUE* pMsgQueue; - - if (!(pMsgQueue = malloc(sizeof(MSGQUEUE))) ) { - return NULL; - } - - if (!mg_InitMsgQueue(pMsgQueue, 0)) { - free (pMsgQueue); - return NULL; - } - - pthread_setspecific (__mg_threadinfo_key, pMsgQueue); - return pMsgQueue; -} - -void mg_FreeMsgQueueThisThread (void) -{ - MSGQUEUE* pMsgQueue; - - pMsgQueue = pthread_getspecific (__mg_threadinfo_key); -#ifdef __VXWORKS__ - if (pMsgQueue != (void *)0 && pMsgQueue != (void *)-1) { -#else - if (pMsgQueue) { -#endif - mg_DestroyMsgQueue (pMsgQueue); - free (pMsgQueue); -#ifdef __VXWORKS__ - pthread_setspecific (__mg_threadinfo_key, (void*)-1); -#else - pthread_setspecific (__mg_threadinfo_key, NULL); -#endif - } -} - -/* -The following function is moved to src/include/internals.h as an inline -function. MSGQUEUE* GetMsgQueueThisThread (void) { return (MSGQUEUE*) pthread_getspecific (__mg_threadinfo_key); diff --git a/src/kernel/message.c b/src/kernel/message.c index 2cabd115..75dde400 100644 --- a/src/kernel/message.c +++ b/src/kernel/message.c @@ -143,6 +143,44 @@ inline static void FreeQMSG (PQMSG pqmsg) } /****************************** Message Queue Management ************************/ +pthread_key_t __mg_threadinfo_key; + +MSGQUEUE* mg_InitMsgQueueThisThread (void) +{ + MSGQUEUE* pMsgQueue; + + if (!(pMsgQueue = malloc(sizeof(MSGQUEUE)))) { + return NULL; + } + + if (!mg_InitMsgQueue(pMsgQueue, 0)) { + free (pMsgQueue); + return NULL; + } + + pthread_setspecific (__mg_threadinfo_key, pMsgQueue); + return pMsgQueue; +} + +void mg_FreeMsgQueueThisThread (void) +{ + MSGQUEUE* pMsgQueue; + + pMsgQueue = pthread_getspecific (__mg_threadinfo_key); +#ifdef __VXWORKS__ + if (pMsgQueue != (void *)0 && pMsgQueue != (void *)-1) { +#else + if (pMsgQueue) { +#endif + mg_DestroyMsgQueue (pMsgQueue); + free (pMsgQueue); +#ifdef __VXWORKS__ + pthread_setspecific (__mg_threadinfo_key, (void*)-1); +#else + pthread_setspecific (__mg_threadinfo_key, NULL); +#endif + } +} BOOL mg_InitMsgQueue (PMSGQUEUE pMsgQueue, int iBufferLen) {