Skip to content

Commit

Permalink
[rtdef] support POSIX compatible errno
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterywolf committed Aug 14, 2023
1 parent 4d20416 commit 871763c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion include/rtdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <stddef.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/errno.h>
#endif /* RT_USING_LIBC */

#ifdef __cplusplus
Expand Down Expand Up @@ -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 */
Expand All @@ -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 */

/**@}*/

Expand Down

0 comments on commit 871763c

Please sign in to comment.