mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-03-02 19:05:28 +08:00
add errno implementation in RT-Thread.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1682 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
da74af2347
commit
472cc9334a
@ -3,9 +3,7 @@
|
|||||||
|
|
||||||
#include <rtconfig.h>
|
#include <rtconfig.h>
|
||||||
|
|
||||||
#if defined(RT_USING_NEWLIB) || defined(RT_USING_MINILIBC)
|
|
||||||
#define ERRNO 1
|
#define ERRNO 1
|
||||||
#endif
|
|
||||||
|
|
||||||
#define NO_SYS 0
|
#define NO_SYS 0
|
||||||
#define LWIP_SOCKET 1
|
#define LWIP_SOCKET 1
|
||||||
|
@ -365,6 +365,12 @@ void rt_kprintf(const char *fmt, ...);
|
|||||||
|
|
||||||
rt_err_t rt_get_errno(void);
|
rt_err_t rt_get_errno(void);
|
||||||
void rt_set_errno(rt_err_t no);
|
void rt_set_errno(rt_err_t no);
|
||||||
|
int *_rt_errno(void);
|
||||||
|
#ifndef RT_USING_NEWLIB
|
||||||
|
#ifndef errno
|
||||||
|
#define errno *_rt_errno()
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void* rt_memset(void *src, int c, rt_ubase_t n);
|
void* rt_memset(void *src, int c, rt_ubase_t n);
|
||||||
void* rt_memcpy(void *dest, const void *src, rt_ubase_t n);
|
void* rt_memcpy(void *dest, const void *src, rt_ubase_t n);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#ifndef RT_USING_NEWLIB
|
#ifndef RT_USING_NEWLIB
|
||||||
/* global errno in RT-Thread*/
|
/* global errno in RT-Thread*/
|
||||||
volatile int errno;
|
static volatile int _errno;
|
||||||
#else
|
#else
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
@ -47,11 +47,11 @@ rt_err_t rt_get_errno(void)
|
|||||||
if(rt_interrupt_get_nest() != 0)
|
if(rt_interrupt_get_nest() != 0)
|
||||||
{
|
{
|
||||||
/* it's in interrupt context */
|
/* it's in interrupt context */
|
||||||
return errno;
|
return _errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
tid = rt_thread_self();
|
tid = rt_thread_self();
|
||||||
if (tid == RT_NULL) return errno;
|
if (tid == RT_NULL) return _errno;
|
||||||
|
|
||||||
return tid->error;
|
return tid->error;
|
||||||
}
|
}
|
||||||
@ -68,16 +68,33 @@ void rt_set_errno(rt_err_t error)
|
|||||||
if(rt_interrupt_get_nest() != 0)
|
if(rt_interrupt_get_nest() != 0)
|
||||||
{
|
{
|
||||||
/* it's in interrupt context */
|
/* it's in interrupt context */
|
||||||
errno = error;
|
_errno = error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tid = rt_thread_self();
|
tid = rt_thread_self();
|
||||||
if (tid == RT_NULL) { errno = error; return; }
|
if (tid == RT_NULL) { _errno = error; return; }
|
||||||
|
|
||||||
tid->error = error;
|
tid->error = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns errno.
|
||||||
|
*
|
||||||
|
* @return the errno in the system
|
||||||
|
*/
|
||||||
|
int *_rt_errno(void)
|
||||||
|
{
|
||||||
|
rt_thread_t tid;
|
||||||
|
|
||||||
|
if (rt_interrupt_get_nest() != 0) return (int *)&_errno;
|
||||||
|
|
||||||
|
tid = rt_thread_self();
|
||||||
|
if (tid != RT_NULL) return (int *)&(tid->error);
|
||||||
|
|
||||||
|
return (int *)&_errno;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will set the content of memory to specified value
|
* This function will set the content of memory to specified value
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user