blob: 8b1a46864ed7dac39eace98d6f34655b3d49b154 (
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
32
33
34
35
36
37
38
|
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PRinternal/osint.h"
s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags) {
register u32 saveMask;
register s32 last;
#ifdef _DEBUG
if ((flags != OS_MESG_NOBLOCK) && (flags != OS_MESG_BLOCK)) {
__osError(ERR_OSSENDMESG, 1, flags);
return -1;
}
#endif
saveMask = __osDisableInt();
while (MQ_IS_FULL(mq)) {
if (flags == OS_MESG_BLOCK) {
__osRunningThread->state = OS_STATE_WAITING;
__osEnqueueAndYield(&mq->fullqueue);
} else {
__osRestoreInt(saveMask);
return -1;
}
}
last = (mq->first + mq->validCount) % mq->msgCount;
mq->msg[last] = msg;
mq->validCount++;
if (mq->mtqueue->next != NULL) {
osStartThread(__osPopThread(&mq->mtqueue));
}
__osRestoreInt(saveMask);
return 0;
}
|