diff --git a/include/rtdef.h b/include/rtdef.h index 1966595ced27..3fdc381ab3b3 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -60,6 +60,7 @@ #include #include #include +#include #endif /* RT_USING_LIBC */ #ifdef __cplusplus @@ -380,12 +381,30 @@ typedef int (*init_fn_t)(void); #endif /** - * @addtogroup Error + * @addtogroup Error Code */ /**@{*/ /* RT-Thread error code definitions */ +#ifdef RT_USING_LIBC +/* POSIX error code compatible */ +#define RT_EOK 0 /**< There is no error */ +#define RT_ERROR ERROR /**< A generic error happens */ +#define RT_ETIMEOUT ETIMEDOUT /**< Timed out */ +#define RT_EFULL ETIMEDOUT /**< The resource is full */ +#define RT_EEMPTY ENODATA /**< The resource is empty */ +#define RT_ENOMEM ENOMEM /**< No memory */ +#define RT_ENOSYS ENOSYS /**< No system */ +#define RT_EBUSY EBUSY /**< Busy */ +#define RT_EIO EIO /**< IO error */ +#define RT_EINTR EINTR /**< Interrupted system call */ +#define RT_EINVAL EINVAL /**< Invalid argument */ +#define RT_ETRAP ETRAP /**< Trap event */ +#define RT_ENOENT ENOENT /**< No entry */ +#define RT_ENOSPC ENOSPC /**< No space left */ +#define RT_EPERM EPERM /**< Operation not permitted */ +#else #define RT_EOK 0 /**< There is no error */ #define RT_ERROR 1 /**< A generic error happens */ #define RT_ETIMEOUT 2 /**< Timed out */ @@ -401,6 +420,7 @@ typedef int (*init_fn_t)(void); #define RT_ENOENT 12 /**< No entry */ #define RT_ENOSPC 13 /**< No space left */ #define RT_EPERM 14 /**< Operation not permitted */ +#endif /* RT_USING_LIBC */ /**@}*/