/* Allocate an IPC message from the statically-allocated array.  */
static rt_ipc_msg_t _ipc_msg_alloc(void)
/* Allocate an IPC message from the statically-allocated array.  */
static rt_ipc_msg_t _ipc_msg_alloc(void)
{
    rt_ipc_msg_t p = (rt_ipc_msg_t)RT_NULL;
    rt_base_t level;
    level = rt_spin_lock_irqsave(&_msg_list_lock);
    if (_ipc_msg_free_list)
    {
        p = _ipc_msg_free_list;
        _ipc_msg_free_list = (rt_ipc_msg_t)p->msg.sender;
    }
    else if (rt_ipc_msg_used < RT_CH_MSG_MAX_NR)
    {
        p = &ipc_msg_pool[rt_ipc_msg_used];
        rt_ipc_msg_used++;
    }
    rt_spin_unlock_irqrestore(&_msg_list_lock, level);
    return p;
}