summaryrefslogtreecommitdiff
path: root/components/libc/compilers/common
diff options
context:
space:
mode:
Diffstat (limited to 'components/libc/compilers/common')
-rw-r--r--components/libc/compilers/common/SConscript7
-rw-r--r--components/libc/compilers/common/delay.c41
-rw-r--r--components/libc/compilers/common/readme.md11
-rw-r--r--components/libc/compilers/common/unistd.c119
4 files changed, 3 insertions, 175 deletions
diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript
index fbdb2f11ec..b7a6626a36 100644
--- a/components/libc/compilers/common/SConscript
+++ b/components/libc/compilers/common/SConscript
@@ -6,18 +6,15 @@ src = []
cwd = GetCurrentDir()
group = []
CPPPATH = [cwd]
+CPPDEFINES = []
if GetDepend('RT_USING_LIBC'):
src += Glob('*.c')
- if GetDepend('RT_USING_POSIX') == False:
- SrcRemove(src, ['unistd.c', 'delay.c'])
elif GetDepend('RT_LIBC_USING_TIME'):
src += Glob('time.c')
if rtconfig.CROSS_TOOL == 'keil':
- CPPDEFINES = ['__CLK_TCK=RT_TICK_PER_SECOND']
-else:
- CPPDEFINES = []
+ CPPDEFINES += ['__CLK_TCK=RT_TICK_PER_SECOND']
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
diff --git a/components/libc/compilers/common/delay.c b/components/libc/compilers/common/delay.c
deleted file mode 100644
index 4666258d3b..0000000000
--- a/components/libc/compilers/common/delay.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2021-05-07 Meco Man first Version
- */
-#include <rtthread.h>
-#include <rthw.h>
-
-void msleep(unsigned int msecs)
-{
- rt_thread_mdelay(msecs);
-}
-RTM_EXPORT(msleep);
-
-void ssleep(unsigned int seconds)
-{
- msleep(seconds * 1000);
-}
-RTM_EXPORT(ssleep);
-
-void mdelay(unsigned long msecs)
-{
- rt_hw_us_delay(msecs * 1000);
-}
-RTM_EXPORT(mdelay);
-
-void udelay(unsigned long usecs)
-{
- rt_hw_us_delay(usecs);
-}
-RTM_EXPORT(udelay);
-
-void ndelay(unsigned long nsecs)
-{
- rt_hw_us_delay(1);
-}
-RTM_EXPORT(ndelay);
diff --git a/components/libc/compilers/common/readme.md b/components/libc/compilers/common/readme.md
index 856ddeb045..82e23f8970 100644
--- a/components/libc/compilers/common/readme.md
+++ b/components/libc/compilers/common/readme.md
@@ -1,10 +1 @@
-## Attentions
-
-1. This folder is "common" for all toolchains.
-
-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
+This folder is "common" for all toolchains. \ No newline at end of file
diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c
deleted file mode 100644
index 9a457c4200..0000000000
--- a/components/libc/compilers/common/unistd.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2020-09-01 Meco Man first Version
- * 2021-02-12 Meco Man move all functions located in <pthread_sleep.c> to this file
- */
-
-#include <unistd.h>
-#include <rtthread.h>
-#include <rthw.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)*/
-}
-#else
-int isatty(int fd)
-{
- if (fd >=0 && fd < 3)
- {
- return 1;
- }
- else
- {
- return 0;
- }
-}
-#endif
-RTM_EXPORT(isatty);
-
-char *ttyname(int fd)
-{
- return "/dev/tty"; /* TODO: need to add more specific */
-}
-RTM_EXPORT(ttyname);
-
-unsigned int sleep(unsigned int seconds)
-{
- if (rt_thread_self() != RT_NULL)
- {
- rt_thread_delay(seconds * RT_TICK_PER_SECOND);
- }
- else /* scheduler has not run yet */
- {
- while(seconds > 0)
- {
- rt_hw_us_delay(1000000u);
- seconds --;
- }
- }
-
- return 0;
-}
-RTM_EXPORT(sleep);
-
-int usleep(useconds_t usec)
-{
- if (rt_thread_self() != RT_NULL)
- {
- rt_thread_mdelay(usec / 1000u);
- }
- else /* scheduler has not run yet */
- {
- rt_hw_us_delay(usec / 1000u);
- }
- rt_hw_us_delay(usec % 1000u);
-
- return 0;
-}
-RTM_EXPORT(usleep);
-
-pid_t gettid(void)
-{
- /*TODO*/
- return 0;
-}
-
-pid_t getpid(void)
-{
- return gettid();
-}
-RTM_EXPORT(getpid);
-
-pid_t getppid(void)
-{
- return 0;
-}
-RTM_EXPORT(getppid);
-
-uid_t getuid(void)
-{
- return 0; /*ROOT*/
-}
-RTM_EXPORT(getuid);
-
-uid_t geteuid(void)
-{
- return 0; /*ROOT*/
-}
-RTM_EXPORT(geteuid);
-
-gid_t getgid(void)
-{
- return 0; /*ROOT*/
-}
-RTM_EXPORT(getgid);
-
-gid_t getegid(void)
-{
- return 0; /*ROOT*/
-}
-RTM_EXPORT(getegid);