mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-10-12 08:23:42 +00:00
Bring unix sys_arch.c up to current CVS HEAD API
This commit is contained in:
parent
bddf652073
commit
e021174865
@ -176,7 +176,7 @@ sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksiz
|
|||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
struct sys_mbox *
|
struct sys_mbox *
|
||||||
sys_mbox_new()
|
sys_mbox_new(int size)
|
||||||
{
|
{
|
||||||
struct sys_mbox *mbox;
|
struct sys_mbox *mbox;
|
||||||
|
|
||||||
@ -213,7 +213,38 @@ sys_mbox_free(struct sys_mbox *mbox)
|
|||||||
free(mbox);
|
free(mbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
err_t
|
||||||
|
sys_mbox_trypost(struct sys_mbox *mbox, void *msg)
|
||||||
|
{
|
||||||
|
u8_t first;
|
||||||
|
|
||||||
|
sys_sem_wait(mbox->mutex);
|
||||||
|
|
||||||
|
LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_trypost: mbox %p msg %p\n",
|
||||||
|
(void *)mbox, (void *)msg));
|
||||||
|
|
||||||
|
if ((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE))
|
||||||
|
return ERR_MEM;
|
||||||
|
|
||||||
|
mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg;
|
||||||
|
|
||||||
|
if (mbox->last == mbox->first) {
|
||||||
|
first = 1;
|
||||||
|
} else {
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mbox->last++;
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
sys_sem_signal(mbox->mail);
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_sem_signal(mbox->mutex);
|
||||||
|
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
sys_mbox_post(struct sys_mbox *mbox, void *msg)
|
sys_mbox_post(struct sys_mbox *mbox, void *msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user