blob: d01d5355fdeb26cb0253df605565793c2ee06cbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "libultra_internal.h"
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag) {
register u32 int_disabled;
register OSThread* thread;
int_disabled = __osDisableInt();
while (!mq->validCount) {
if (!flag) {
__osRestoreInt(int_disabled);
return -1;
}
__osRunningThread->state = OS_STATE_WAITING;
__osEnqueueAndYield(&mq->mtqueue);
}
if (msg != NULL) {
*msg = *(mq->first + mq->msg);
}
mq->first = (mq->first + 1) % mq->msgCount;
mq->validCount--;
if (mq->fullqueue->next != NULL) {
thread = __osPopThread(&mq->fullqueue);
osStartThread(thread);
}
__osRestoreInt(int_disabled);
return 0;
}
|