summaryrefslogtreecommitdiff
path: root/components/libc/compilers/common
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-03-02 15:00:43 +0800
committerGitHub <[email protected]>2021-03-02 15:00:43 +0800
commit2c12493ff342ea9ba808311c3f6835eba31a8d3e (patch)
treeb1e1dfbeaead7c08ab8d7d0f34066154c125841b /components/libc/compilers/common
parent5f17cf9204e501d971cd28486e0a7193d2f1fae4 (diff)
parent19871ac32e41590b1f3e3742d9ab023dc3147ba0 (diff)
Merge pull request #4404 from KyleChenjh/lts-v3.1.x
[Update] Sync from v4.0.3
Diffstat (limited to 'components/libc/compilers/common')
-rw-r--r--components/libc/compilers/common/SConscript11
-rw-r--r--components/libc/compilers/common/readme.md10
-rw-r--r--components/libc/compilers/common/sys/time.h23
-rw-r--r--components/libc/compilers/common/termios.h19
-rw-r--r--components/libc/compilers/common/unistd.c26
5 files changed, 72 insertions, 17 deletions
diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript
index a8d2606820..2407301405 100644
--- a/components/libc/compilers/common/SConscript
+++ b/components/libc/compilers/common/SConscript
@@ -8,12 +8,15 @@ group = []
CPPPATH = [cwd]
if GetDepend('RT_USING_LIBC'):
- src += Glob('*.c')
+ src += Glob('*.c')
else:
- if GetDepend('RT_LIBC_USING_TIME'):
+ if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'):
src += ['time.c']
-if (rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'iar') and rtconfig.ARCH != 'sim' :
- group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH)
+if GetDepend('RT_USING_POSIX') == False:
+ SrcRemove(src, ['unistd.c'])
+
+if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')):
+ group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
diff --git a/components/libc/compilers/common/readme.md b/components/libc/compilers/common/readme.md
new file mode 100644
index 0000000000..99797d933c
--- /dev/null
+++ b/components/libc/compilers/common/readme.md
@@ -0,0 +1,10 @@
+## Attentions
+
+1. This folder is "common" for armlibc newlibc and dlib. It's not "common" for minilibc.
+
+2. If you want to add new .c files, please do not forget to fix SConscript file too. eg:
+
+```python
+if GetDepend('RT_USING_POSIX') == False:
+ SrcRemove(src, ['unistd.c'])
+``` \ No newline at end of file
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h
index 1d68eeafa3..79cfbbfaf2 100644
--- a/components/libc/compilers/common/sys/time.h
+++ b/components/libc/compilers/common/sys/time.h
@@ -15,6 +15,14 @@
extern "C" {
#endif
+/*
+ * Skip define timespec for IAR version over 8.10.1 where __VER__ is 8010001.
+ */
+#if defined ( __ICCARM__ ) && (__VER__ >= 8010001)
+#define _TIMESPEC_DEFINED
+#endif
+
+
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
/*
@@ -27,23 +35,12 @@ struct timeval {
};
#endif /* _TIMEVAL_DEFINED */
-/*
- * Skip define timespec for IAR version over 8.10.1 where __VER__ is 8010001.
- */
-#if defined ( __ICCARM__ ) && (__VER__ >= 8010001)
-#define _TIMESPEC_DEFINED
-#endif
-
-#ifndef _TIMESPEC_DEFINED
-#define _TIMESPEC_DEFINED
-/*
- * Structure defined by POSIX.1b to be like a timeval.
- */
+#if !defined __GNUC__ && !defined __ICCARM__
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
-#endif /* _TIMESPEC_DEFINED */
+#endif
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
diff --git a/components/libc/compilers/common/termios.h b/components/libc/compilers/common/termios.h
new file mode 100644
index 0000000000..414d0c0cb3
--- /dev/null
+++ b/components/libc/compilers/common/termios.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+#ifndef _TERMIOS_H__
+#define _TERMIOS_H__
+
+#include <rtconfig.h>
+
+#ifdef RT_USING_POSIX_TERMIOS
+#include <sys/types.h>
+#include <posix_termios.h>
+#endif
+
+#endif
diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c
new file mode 100644
index 0000000000..df970b2b59
--- /dev/null
+++ b/components/libc/compilers/common/unistd.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-09-01 Meco Man First Version
+ */
+
+#include <unistd.h>
+
+#ifdef RT_USING_POSIX_TERMIOS
+#include "termios.h"
+
+int isatty(int fd)
+{
+ struct termios ts;
+ return(tcgetattr(fd,&ts) != -1);/*true if no error (is a tty)*/
+}
+#endif
+
+char *ttyname(int fd)
+{
+ return "/dev/tty0"; /*TODO: need to add more specific*/
+}