found the bug, now I think I've got it right
This commit is contained in:
parent
9588d1e94b
commit
de84145e55
|
@ -28,7 +28,7 @@ void MqDestroy(PMSG_QUEUE queue)
|
||||||
free(queue);
|
free(queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void post_internal(MSG_QUEUE volatile *queue, PMSG msg)
|
static void post_internal(PMSG_QUEUE queue, PMSG msg)
|
||||||
{
|
{
|
||||||
PMSG nexttail;
|
PMSG nexttail;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ static void post_internal(MSG_QUEUE volatile *queue, PMSG msg)
|
||||||
pthread_mutex_unlock(&(queue->mutex));
|
pthread_mutex_unlock(&(queue->mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqPost(MSG_QUEUE volatile *queue, uintptr_t target, unsigned message, const uintptr_t *attrs, int nattrs)
|
void MqPost(PMSG_QUEUE queue, uintptr_t target, unsigned message, const uintptr_t *attrs, int nattrs)
|
||||||
{
|
{
|
||||||
MSG tmpmsg;
|
MSG tmpmsg;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ void MqPost(MSG_QUEUE volatile *queue, uintptr_t target, unsigned message, const
|
||||||
post_internal(queue, &tmpmsg);
|
post_internal(queue, &tmpmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqPost1(MSG_QUEUE volatile *queue, uintptr_t target, unsigned message, uintptr_t attr1)
|
void MqPost1(PMSG_QUEUE queue, uintptr_t target, unsigned message, uintptr_t attr1)
|
||||||
{
|
{
|
||||||
MSG tmpmsg;
|
MSG tmpmsg;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void MqPost1(MSG_QUEUE volatile *queue, uintptr_t target, unsigned message, uint
|
||||||
post_internal(queue, &tmpmsg);
|
post_internal(queue, &tmpmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MqPeek(MSG_QUEUE volatile *queue, PMSG msg, unsigned flags)
|
int MqPeek(PMSG_QUEUE queue, PMSG msg, unsigned flags)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
PMSG nexthead;
|
PMSG nexthead;
|
||||||
|
@ -87,6 +87,7 @@ int MqPeek(MSG_QUEUE volatile *queue, PMSG msg, unsigned flags)
|
||||||
memcpy(msg, queue->head, sizeof(MSG));
|
memcpy(msg, queue->head, sizeof(MSG));
|
||||||
if (flags & PEEK_REMOVE)
|
if (flags & PEEK_REMOVE)
|
||||||
queue->head = nexthead;
|
queue->head = nexthead;
|
||||||
|
rc = 1;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&(queue->mutex));
|
pthread_mutex_unlock(&(queue->mutex));
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -20,9 +20,8 @@ typedef struct tagMSG_QUEUE {
|
||||||
|
|
||||||
extern PMSG_QUEUE MqAlloc(int nentries);
|
extern PMSG_QUEUE MqAlloc(int nentries);
|
||||||
extern void MqDestroy(PMSG_QUEUE queue);
|
extern void MqDestroy(PMSG_QUEUE queue);
|
||||||
extern void MqPost(MSG_QUEUE volatile *queue, uintptr_t target, unsigned message, const uintptr_t *attrs,
|
extern void MqPost(PMSG_QUEUE queue, uintptr_t target, unsigned message, const uintptr_t *attrs, int nattrs);
|
||||||
int nattrs);
|
extern void MqPost1(PMSG_QUEUE queue, uintptr_t target, unsigned message, uintptr_t attr1);
|
||||||
extern void MqPost1(MSG_QUEUE volatile *queue, uintptr_t target, unsigned message, uintptr_t attr1);
|
extern int MqPeek(PMSG_QUEUE queue, PMSG msg, unsigned flags);
|
||||||
extern int MqPeek(MSG_QUEUE volatile *queue, PMSG msg, unsigned flags);
|
|
||||||
|
|
||||||
#endif /* __MSG_QUEUE_H_INCLUDED */
|
#endif /* __MSG_QUEUE_H_INCLUDED */
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "msg_queue.h"
|
#include "msg_queue.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
MSG_QUEUE volatile *Sys_Queue = NULL;
|
PMSG_QUEUE Sys_Queue = NULL;
|
||||||
|
|
||||||
static pthread_t ithread;
|
static pthread_t ithread;
|
||||||
static volatile sig_atomic_t running = 1;
|
static volatile sig_atomic_t running = 1;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "msg_queue.h"
|
#include "msg_queue.h"
|
||||||
|
|
||||||
extern MSG_QUEUE volatile *Sys_Queue;
|
extern PMSG_QUEUE Sys_Queue;
|
||||||
|
|
||||||
extern int SysEnableInput(void);
|
extern int SysEnableInput(void);
|
||||||
extern void SysDisableInput(void);
|
extern void SysDisableInput(void);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user