summaryrefslogtreecommitdiff
path: root/include/klibc
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2024-09-22 13:28:15 -0400
committerRbb666 <[email protected]>2024-09-23 21:30:37 +0800
commitee5014d32f7b1ee61b6d00218e6b1ffa8770ae96 (patch)
treec2e614c9df0382828525ceb4d573758d87849f79 /include/klibc
parent8a53e6d63947a0ee0c60da53d322c75e0f5048cc (diff)
[klibc] add kerrno.h
Diffstat (limited to 'include/klibc')
-rw-r--r--include/klibc/kerrno.h77
-rw-r--r--include/klibc/kstdio.h27
-rw-r--r--include/klibc/kstring.h36
3 files changed, 140 insertions, 0 deletions
diff --git a/include/klibc/kerrno.h b/include/klibc/kerrno.h
new file mode 100644
index 0000000000..2f7699923f
--- /dev/null
+++ b/include/klibc/kerrno.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2006-2024, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2024-09-22 Meco Man the first version
+ */
+
+#ifndef __RT_KERRNO_H__
+#define __RT_KERRNO_H__
+
+#include <rtconfig.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(RT_USING_LIBC) && !defined(RT_USING_NANO)
+/* POSIX error code compatible */
+#define RT_EOK 0 /**< There is no error */
+#define RT_ERROR 255 /**< A generic/unknown error happens */
+#define RT_ETIMEOUT ETIMEDOUT /**< Timed out */
+#define RT_EFULL ENOSPC /**< The resource is full */
+#define RT_EEMPTY ENODATA /**< The resource is empty */
+#define RT_ENOMEM ENOMEM /**< No memory */
+#define RT_ENOSYS ENOSYS /**< Function not implemented */
+#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_ENOENT ENOENT /**< No entry */
+#define RT_ENOSPC ENOSPC /**< No space left */
+#define RT_EPERM EPERM /**< Operation not permitted */
+#define RT_EFAULT EFAULT /**< Bad address */
+#define RT_ENOBUFS ENOBUFS /**< No buffer space is available */
+#define RT_ESCHEDISR 253 /**< scheduler failure in isr context */
+#define RT_ESCHEDLOCKED 252 /**< scheduler failure in critical region */
+#define RT_ETRAP 254 /**< Trap event */
+#else
+#define RT_EOK 0 /**< There is no error */
+#define RT_ERROR 1 /**< A generic/unknown error happens */
+#define RT_ETIMEOUT 2 /**< Timed out */
+#define RT_EFULL 3 /**< The resource is full */
+#define RT_EEMPTY 4 /**< The resource is empty */
+#define RT_ENOMEM 5 /**< No memory */
+#define RT_ENOSYS 6 /**< Function not implemented */
+#define RT_EBUSY 7 /**< Busy */
+#define RT_EIO 8 /**< IO error */
+#define RT_EINTR 9 /**< Interrupted system call */
+#define RT_EINVAL 10 /**< Invalid argument */
+#define RT_ENOENT 11 /**< No entry */
+#define RT_ENOSPC 12 /**< No space left */
+#define RT_EPERM 13 /**< Operation not permitted */
+#define RT_ETRAP 14 /**< Trap event */
+#define RT_EFAULT 15 /**< Bad address */
+#define RT_ENOBUFS 16 /**< No buffer space is available */
+#define RT_ESCHEDISR 17 /**< scheduler failure in isr context */
+#define RT_ESCHEDLOCKED 18 /**< scheduler failure in critical region */
+#endif /* defined(RT_USING_LIBC) && !defined(RT_USING_NANO) */
+
+rt_err_t rt_get_errno(void);
+void rt_set_errno(rt_err_t no);
+int *_rt_errno(void);
+const char *rt_strerror(rt_err_t error);
+#if !defined(RT_USING_NEWLIBC) && !defined(_WIN32)
+#ifndef errno
+#define errno *_rt_errno()
+#endif
+#endif /* !defined(RT_USING_NEWLIBC) && !defined(_WIN32) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/klibc/kstdio.h b/include/klibc/kstdio.h
new file mode 100644
index 0000000000..215e9a9245
--- /dev/null
+++ b/include/klibc/kstdio.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2006-2024, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2024-09-22 Meco Man the first version
+ */
+
+#ifndef __RT_KSTDIO_H__
+#define __RT_KSTDIO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
+int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args);
+int rt_sprintf(char *buf, const char *format, ...);
+int rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/klibc/kstring.h b/include/klibc/kstring.h
new file mode 100644
index 0000000000..48fbe60091
--- /dev/null
+++ b/include/klibc/kstring.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2006-2024, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2024-09-22 Meco Man the first version
+ */
+
+#ifndef __RT_KSTRING_H__
+#define __RT_KSTRING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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_memmove(void *dest, const void *src, rt_size_t n);
+rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_size_t count);
+char *rt_strdup(const char *s);
+rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen);
+char *rt_strstr(const char *str1, const char *str2);
+rt_int32_t rt_strcasecmp(const char *a, const char *b);
+char *rt_strcpy(char *dst, const char *src);
+char *rt_strncpy(char *dest, const char *src, rt_size_t n);
+rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_size_t count);
+rt_int32_t rt_strcmp(const char *cs, const char *ct);
+rt_size_t rt_strlen(const char *src);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif