diff options
| -rw-r--r-- | components/libc/compilers/newlib/libc_syms.c | 53 | ||||
| -rw-r--r-- | components/libc/posix/io/README.md | 10 | ||||
| -rw-r--r-- | components/libc/posix/io/SConscript | 15 | ||||
| -rw-r--r-- | components/libc/posix/io/poll/SConscript | 5 | ||||
| -rw-r--r-- | components/libc/posix/io/poll/select.c (renamed from components/libc/posix/io/select.c) | 0 | ||||
| -rw-r--r-- | components/libc/posix/io/stdio/SConscript | 22 | ||||
| -rw-r--r-- | components/libc/posix/io/stdio/libc.c (renamed from components/libc/posix/io/libc.c) | 26 | ||||
| -rw-r--r-- | components/libc/posix/io/stdio/libc.h (renamed from components/libc/posix/io/libc.h) | 0 | ||||
| -rw-r--r-- | components/libc/posix/io/termios/termios.c | 2 | ||||
| -rw-r--r-- | components/libc/posix/libdl/SConscript | 2 | ||||
| -rw-r--r-- | components/libc/posix/libdl/dlsyms.c (renamed from components/libc/compilers/gcc/newlib/dlsyms.c) | 0 | ||||
| -rw-r--r-- | components/libc/posix/readme.md | 5 | ||||
| -rw-r--r-- | components/libc/posix/src/SConscript | 16 | ||||
| -rw-r--r-- | components/libc/posix/src/unistd.c | 41 |
14 files changed, 64 insertions, 133 deletions
diff --git a/components/libc/compilers/newlib/libc_syms.c b/components/libc/compilers/newlib/libc_syms.c deleted file mode 100644 index e6ca23b393..0000000000 --- a/components/libc/compilers/newlib/libc_syms.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2017/10/15 bernard the first version - */ - -#include <rtthread.h> -#include <rtm.h> - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> - -RTM_EXPORT(strcpy); -RTM_EXPORT(strncpy); -RTM_EXPORT(strlen); -RTM_EXPORT(strcat); -RTM_EXPORT(strstr); -RTM_EXPORT(strchr); -RTM_EXPORT(strcmp); -RTM_EXPORT(strtol); -RTM_EXPORT(strtoul); -RTM_EXPORT(strncmp); - -RTM_EXPORT(memcpy); -RTM_EXPORT(memcmp); -RTM_EXPORT(memmove); -RTM_EXPORT(memset); -RTM_EXPORT(memchr); - -RTM_EXPORT(putchar); -RTM_EXPORT(puts); -RTM_EXPORT(printf); -RTM_EXPORT(sprintf); -RTM_EXPORT(snprintf); - -RTM_EXPORT(fwrite); - -#include <setjmp.h> -RTM_EXPORT(longjmp); -RTM_EXPORT(setjmp); - -RTM_EXPORT(exit); -RTM_EXPORT(abort); - -RTM_EXPORT(rand); - -#include <assert.h> -RTM_EXPORT(__assert_func); diff --git a/components/libc/posix/io/README.md b/components/libc/posix/io/README.md new file mode 100644 index 0000000000..54f5c0a02d --- /dev/null +++ b/components/libc/posix/io/README.md @@ -0,0 +1,10 @@ +This folder contains: + +| sub-folders | description | +| ----------- | ------------------------- | +| aio | Asynchronous I/O | +| mman | Memory-Mapped I/O | +| poll | Nonblocking I/O | +| stdio | Standard Input/Output I/O | +| termios | Terminal I/O | + diff --git a/components/libc/posix/io/SConscript b/components/libc/posix/io/SConscript index bb45211ec0..e016836a9d 100644 --- a/components/libc/posix/io/SConscript +++ b/components/libc/posix/io/SConscript @@ -3,24 +3,9 @@ import os from building import * -src = [] cwd = GetCurrentDir() -CPPPATH = [cwd] group = [] -flag = False - -if GetDepend('RT_USING_POSIX_STDIO'): - src += ['libc.c'] - flag = True - -if GetDepend('RT_USING_POSIX_SELECT'): - src += ['select.c'] - flag = True - -if flag == True: - group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH) - list = os.listdir(cwd) for d in list: path = os.path.join(cwd, d) diff --git a/components/libc/posix/io/poll/SConscript b/components/libc/posix/io/poll/SConscript index 39b321b6c5..7e7c0f55f7 100644 --- a/components/libc/posix/io/poll/SConscript +++ b/components/libc/posix/io/poll/SConscript @@ -7,7 +7,10 @@ src = [] CPPPATH = [cwd] if GetDepend('RT_USING_POSIX_POLL'): - src += ['poll.c'] + src += ['poll.c'] + +if GetDepend('RT_USING_POSIX_SELECT'): + src += ['select.c'] group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH) diff --git a/components/libc/posix/io/select.c b/components/libc/posix/io/poll/select.c index bac63258a5..bac63258a5 100644 --- a/components/libc/posix/io/select.c +++ b/components/libc/posix/io/poll/select.c diff --git a/components/libc/posix/io/stdio/SConscript b/components/libc/posix/io/stdio/SConscript new file mode 100644 index 0000000000..d33809ce42 --- /dev/null +++ b/components/libc/posix/io/stdio/SConscript @@ -0,0 +1,22 @@ +# RT-Thread building script for component + +import os +from building import * + +src = [] +cwd = GetCurrentDir() +CPPPATH = [cwd] +group = [] + +if GetDepend('RT_USING_POSIX_STDIO'): + src += ['libc.c'] + +group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH) + +list = os.listdir(cwd) +for d in list: + path = os.path.join(cwd, d) + if os.path.isfile(os.path.join(path, 'SConscript')): + group = group + SConscript(os.path.join(d, 'SConscript')) + +Return('group') diff --git a/components/libc/posix/io/libc.c b/components/libc/posix/io/stdio/libc.c index e57749f1da..ebdc3a537b 100644 --- a/components/libc/posix/io/libc.c +++ b/components/libc/posix/io/stdio/libc.c @@ -15,9 +15,8 @@ #include <unistd.h> #include <fcntl.h> #include <sys/time.h> +#include <sys/errno.h> #include "libc.h" -#include <stdio.h> -#include <stdlib.h> int libc_system_init(void) { @@ -108,7 +107,7 @@ int libc_stdio_get_console(void) return -1; } -#else +#elif defined(RT_USING_POSIX_STDIO) #define STDIO_DEVICE_NAME_MAX 32 static int std_fd = -1; int libc_stdio_set_console(const char* device_name, int mode) @@ -136,3 +135,24 @@ int libc_stdio_get_console(void) { return std_fd; } #endif /* defined(RT_USING_POSIX_STDIO) && defined(RT_USING_NEWLIB) */ + +int isatty(int fd) +{ +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) + if(fd == STDOUT_FILENO || fd == STDERR_FILENO) + { + return 1; + } +#endif + +#ifdef RT_USING_POSIX_STDIO + if(fd == STDIN_FILENO) + { + return 1; + } +#endif + + rt_set_errno(ENOTTY); + return 0; +} +RTM_EXPORT(isatty); diff --git a/components/libc/posix/io/libc.h b/components/libc/posix/io/stdio/libc.h index 6b5dfd1fcc..6b5dfd1fcc 100644 --- a/components/libc/posix/io/libc.h +++ b/components/libc/posix/io/stdio/libc.h diff --git a/components/libc/posix/io/termios/termios.c b/components/libc/posix/io/termios/termios.c index 14d85e9f0c..8333b594bf 100644 --- a/components/libc/posix/io/termios/termios.c +++ b/components/libc/posix/io/termios/termios.c @@ -11,8 +11,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <sys/stat.h> -#include <sys/statfs.h> #include <sys/errno.h> #include "termios.h" diff --git a/components/libc/posix/libdl/SConscript b/components/libc/posix/libdl/SConscript index 964e05ef76..7c5f9b8085 100644 --- a/components/libc/posix/libdl/SConscript +++ b/components/libc/posix/libdl/SConscript @@ -1,7 +1,7 @@ from building import * Import('rtconfig') -src = Glob('*.c') + Glob('*.cpp') + Glob('arch/*.c') +src = Glob('*.c') + Glob('arch/*.c') cwd = GetCurrentDir() group = [] CPPPATH = [cwd] diff --git a/components/libc/compilers/gcc/newlib/dlsyms.c b/components/libc/posix/libdl/dlsyms.c index e6ca23b393..e6ca23b393 100644 --- a/components/libc/compilers/gcc/newlib/dlsyms.c +++ b/components/libc/posix/libdl/dlsyms.c diff --git a/components/libc/posix/readme.md b/components/libc/posix/readme.md index df01047d6b..9683a02a6a 100644 --- a/components/libc/posix/readme.md +++ b/components/libc/posix/readme.md @@ -4,5 +4,8 @@ This folder provides functions that are not part of the standard C library but a ## NOTE -1. For consistency of compilation results across the different of platforms(gcc, keil, iar) , you better use ``#include <sys/time.h>`` to instead of ``#include <time.h>``. +1. For consistency of compilation results across the different of platforms(gcc, keil, iar) , use: + - `#include <sys/time.h>` to instead of `#include <time.h>` + - `#include <sys/errno.h>` to instead of `#include <errno.h>` + - `#include <sys/signal.h>` to instead of `#include <signal.h>` diff --git a/components/libc/posix/src/SConscript b/components/libc/posix/src/SConscript deleted file mode 100644 index 93bb93b0ad..0000000000 --- a/components/libc/posix/src/SConscript +++ /dev/null @@ -1,16 +0,0 @@ -# RT-Thread building script for component - -from building import * - -src = [] -cwd = GetCurrentDir() -CPPPATH = [cwd] -group = [] - -flag = False -src += ['unistd.c'] #TODO - -if flag == True: - group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH) - -Return('group') diff --git a/components/libc/posix/src/unistd.c b/components/libc/posix/src/unistd.c deleted file mode 100644 index cb18dd3499..0000000000 --- a/components/libc/posix/src/unistd.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 - * 2020-09-01 Meco Man first Version - * 2021-02-12 Meco Man move all functions located in <pthread_sleep.c> to this file - */ - -#include <rtthread.h> -#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)*/ -} -#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); |
