mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-28 16:17:09 +08:00
move mg_InitMsgQueueThisThread, mg_FreeMsgQueueThisThread, and __mg_threadinfo_key to kernel/message.c
This commit is contained in:
+1
-44
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user