/* This function sets the global errno for the current thread.  */
void rt_set_errno(rt_err_t error)
/* This function sets the global errno for the current thread.  */
void rt_set_errno(rt_err_t error)
{
    rt_thread_t tid = RT_NULL;
    if (rt_interrupt_get_nest() != 0)
    {
        __rt_errno = error;
        return;
    }
    tid = rt_thread_self();
    if (tid == RT_NULL)
    {
        __rt_errno = error;
        return;
    }
    tid->error = error;
}