summaryrefslogtreecommitdiff
path: root/components/libc/compilers/common/include/posix
diff options
context:
space:
mode:
authorMan, Jianting (Meco) <[email protected]>2022-06-19 09:56:24 -0400
committerGitHub <[email protected]>2022-06-19 21:56:24 +0800
commit8bee7a0c232f5df03e620b41cfc03347c1acfbf1 (patch)
treea37469cd64ce669afabc05b243c77bc0b5b19feb /components/libc/compilers/common/include/posix
parent8fa16f968a2e952fc8be84dc69724aa90ffa9b37 (diff)
[libc] implement extension standard C functions (#6044)
* implement extension standard C functions
Diffstat (limited to 'components/libc/compilers/common/include/posix')
-rw-r--r--components/libc/compilers/common/include/posix/ctype.h31
-rw-r--r--components/libc/compilers/common/include/posix/stdio.h28
-rw-r--r--components/libc/compilers/common/include/posix/stdlib.h32
-rw-r--r--components/libc/compilers/common/include/posix/string.h43
-rw-r--r--components/libc/compilers/common/include/posix/wchar.h27
5 files changed, 161 insertions, 0 deletions
diff --git a/components/libc/compilers/common/include/posix/ctype.h b/components/libc/compilers/common/include/posix/ctype.h
new file mode 100644
index 0000000000..0ac42e3faf
--- /dev/null
+++ b/components/libc/compilers/common/include/posix/ctype.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-06-07 Meco Man The first version.
+ */
+
+#ifndef __POSIX_CTYPE_H__
+#define __POSIX_CTYPE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ctype.h>
+
+#ifndef isascii /* some toolchain use macro to define it */
+int isascii(int c);
+#endif
+#ifndef toascii
+int toascii(int c);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POSIX_CTYPE_H__ */
diff --git a/components/libc/compilers/common/include/posix/stdio.h b/components/libc/compilers/common/include/posix/stdio.h
new file mode 100644
index 0000000000..7dea03bb0d
--- /dev/null
+++ b/components/libc/compilers/common/include/posix/stdio.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-06-07 Meco Man first version
+ */
+
+#ifndef __POSIX_STDIO_H__
+#define __POSIX_STDIO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+
+ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
+ssize_t getline(char **lineptr, size_t *n, FILE *stream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POSIX_STDIO_H__ */
diff --git a/components/libc/compilers/common/include/posix/stdlib.h b/components/libc/compilers/common/include/posix/stdlib.h
new file mode 100644
index 0000000000..bc53ebdecf
--- /dev/null
+++ b/components/libc/compilers/common/include/posix/stdlib.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-06-07 Meco Man The first version.
+ */
+
+#ifndef __POSIX_STDLIB_H__
+#define __POSIX_STDLIB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdlib.h>
+
+char *itoa(int n, char *buffer, int radix);
+char *lltoa(int64_t ll, char *buffer, int radix);
+char *ltoa(long l, char *buffer, int radix);
+char *ulltoa(uint64_t ll, char *buffer, int radix);
+char *ultoa(unsigned long l, char *buffer, int radix);
+char *utoa(unsigned int n, char *buffer, int radix);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POSIX_STDLIB_H__ */
diff --git a/components/libc/compilers/common/include/posix/string.h b/components/libc/compilers/common/include/posix/string.h
new file mode 100644
index 0000000000..475de513fc
--- /dev/null
+++ b/components/libc/compilers/common/include/posix/string.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-01-12 Meco Man The first version.
+ */
+
+#ifndef __POSIX_STRING_H__
+#define __POSIX_STRING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+#include <string.h>
+
+void bzero(void * s, size_t n);
+void bcopy(const void * src, void * dest, size_t n);
+int bcmp(const void * s1, const void * s2, size_t n);
+void explicit_bzero(void * s, size_t n);
+char *index(const char * s, int c);
+char *rindex(const char * s, int c);
+int ffs(int i);
+int ffsl(long i);
+int ffsll(long long i);
+void *memrchr(const void* ptr, int ch, size_t pos);
+size_t strnlen(const char *s, size_t maxlen);
+char* strchrnul(const char *s, int c);
+int strcasecmp(const char * s1, const char * s2);
+int strncasecmp(const char * s1, const char * s2, size_t n);
+char *strdup(const char *s);
+char *strndup(const char *s, size_t size);
+char *strtok_r(char *str, const char *delim, char **saveptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POSIX_STRING_H__ */
diff --git a/components/libc/compilers/common/include/posix/wchar.h b/components/libc/compilers/common/include/posix/wchar.h
new file mode 100644
index 0000000000..91aed4e279
--- /dev/null
+++ b/components/libc/compilers/common/include/posix/wchar.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2022-06-07 Meco Man The first version
+ */
+
+#ifndef __POSIX_WCHAR_H__
+#define __POSIX_WCHAR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <wchar.h>
+
+int wcwidth(wchar_t);
+int wcswidth(const wchar_t*, size_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POSIX_WCHAR_H__ */