summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authora1012112796 <[email protected]>2022-06-29 14:21:21 +0800
committerGitHub <[email protected]>2022-06-29 14:21:21 +0800
commit697bf139b2385daac4968bac3c4f551a47c00d10 (patch)
treec8bf1b6377efce24d7ccd157d3668d5703773cfd /src
parent5b00165f6ef9161f67103df583564472a1371a3b (diff)
[enhancement] Add string information for error (#3186)
* [enhancement]Add string information for error * Update src/kservice.c * Update src/kservice.c Co-authored-by: Man, Jianting (Meco) <[email protected]> * remove %m Signed-off-by: a1012112796 <[email protected]> Co-authored-by: Meco Man <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/kservice.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/kservice.c b/src/kservice.c
index 4e6dc22675..dfa0da9cd6 100644
--- a/src/kservice.c
+++ b/src/kservice.c
@@ -53,6 +53,40 @@ RT_WEAK void rt_hw_us_delay(rt_uint32_t us)
"Please consider implementing rt_hw_us_delay() in another file."));
}
+static const char* rt_errno_strs[] =
+{
+ "OK",
+ "ERROR",
+ "ETIMOUT",
+ "ERSFULL",
+ "ERSEPTY",
+ "ENOMEM",
+ "ENOSYS",
+ "EBUSY",
+ "EIO",
+ "EINTRPT",
+ "EINVAL",
+ "EUNKNOW"
+};
+
+/**
+ * This function return a pointer to a string that contains the
+ * message of error.
+ *
+ * @param error the errorno code
+ * @return a point to error message string
+ */
+const char *rt_strerror(rt_err_t error)
+{
+ if (error < 0)
+ error = -error;
+
+ return (error > RT_EINVAL + 1) ?
+ rt_errno_strs[RT_EINVAL + 1] :
+ rt_errno_strs[error];
+}
+RTM_EXPORT(rt_strerror);
+
/**
* This function gets the global errno for the current thread.
*