diff options
| author | Man, Jianting (Meco) <[email protected]> | 2022-01-10 14:25:46 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-10 14:25:46 -0500 |
| commit | c6852aa306d07932bc1a62118029ac332acc3fc9 (patch) | |
| tree | 035cae3629b0a8a63686ffd5212162a334bfeeff /components/libc/compilers/dlib | |
| parent | 1f2e93f1a39590af9a71ecc31b12045696ca6055 (diff) | |
| parent | 982ad7bcbcbdc31305883803fadf63bad72dbc73 (diff) | |
Merge branch 'master' into removeinit
Diffstat (limited to 'components/libc/compilers/dlib')
| -rw-r--r-- | components/libc/compilers/dlib/README.md | 6 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/SConscript | 2 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_close.c | 6 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_lseek.c | 6 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_mem.c | 3 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_open.c | 84 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_read.c | 16 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_remove.c | 6 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_write.c | 8 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscalls.c | 1 |
10 files changed, 81 insertions, 57 deletions
diff --git a/components/libc/compilers/dlib/README.md b/components/libc/compilers/dlib/README.md index acd08f9074..e4d70e8135 100644 --- a/components/libc/compilers/dlib/README.md +++ b/components/libc/compilers/dlib/README.md @@ -1,9 +1,3 @@ # DLIB (IAR) porting for RT-Thread -Please define RT_USING_LIBC and compile RT-Thread with IAR compiler. - - - -## More Information - http://www.iarsys.co.jp/download/LMS2/arm/7502/ewarm7502doc/arm/doc/EWARM_DevelopmentGuide.ENU.pdf P.130
\ No newline at end of file diff --git a/components/libc/compilers/dlib/SConscript b/components/libc/compilers/dlib/SConscript index f685873e16..e11ea65b97 100644 --- a/components/libc/compilers/dlib/SConscript +++ b/components/libc/compilers/dlib/SConscript @@ -15,6 +15,6 @@ if rtconfig.PLATFORM == 'iar': if LooseVersion(IARVersion()) < LooseVersion("8.20.1"): CPPDEFINES = CPPDEFINES + ['_DLIB_THREAD_SUPPORT'] - group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], CPPDEFINES = CPPDEFINES) + group = DefineGroup('Compiler', src, depend = [''], CPPDEFINES = CPPDEFINES) Return('group') diff --git a/components/libc/compilers/dlib/syscall_close.c b/components/libc/compilers/dlib/syscall_close.c index 30ee6f2388..736023023d 100644 --- a/components/libc/compilers/dlib/syscall_close.c +++ b/components/libc/compilers/dlib/syscall_close.c @@ -7,9 +7,14 @@ * Date Author Notes * 2015-01-28 Bernard first version */ + #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> +#include <compiler_private.h> +#define DBG_TAG "dlib.syscall.close" +#define DBG_LVL DBG_INFO +#include <rtdbg.h> /* * The "__close" function should close the file corresponding to @@ -27,6 +32,7 @@ int __close(int handle) #ifdef DFS_USING_POSIX return close(handle); #else + LOG_W(_WARNING_WITHOUT_FS); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_lseek.c b/components/libc/compilers/dlib/syscall_lseek.c index 622f613c51..b2c47e71c9 100644 --- a/components/libc/compilers/dlib/syscall_lseek.c +++ b/components/libc/compilers/dlib/syscall_lseek.c @@ -7,9 +7,14 @@ * Date Author Notes * 2015-01-28 Bernard first version */ + #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> +#include <compiler_private.h> +#define DBG_TAG "dlib.syscall.lseek" +#define DBG_LVL DBG_INFO +#include <rtdbg.h> /* * The "__lseek" function makes the next file operation (__read or @@ -36,6 +41,7 @@ long __lseek(int handle, long offset, int whence) #ifdef DFS_USING_POSIX return lseek(handle, offset, whence); #else + LOG_W(_WARNING_WITHOUT_FS); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c index 74b960f0b9..2de0974e4e 100644 --- a/components/libc/compilers/dlib/syscall_mem.c +++ b/components/libc/compilers/dlib/syscall_mem.c @@ -8,11 +8,12 @@ * 2015-01-28 Bernard first version * 2021-11-13 Meco Man implement no-heap warning */ + #include <rtthread.h> #include <stddef.h> #ifndef RT_USING_HEAP -#define DBG_TAG "dlib.syscall_mem" +#define DBG_TAG "dlib.syscall.mem" #define DBG_LVL DBG_INFO #include <rtdbg.h> #define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\ diff --git a/components/libc/compilers/dlib/syscall_open.c b/components/libc/compilers/dlib/syscall_open.c index 66cddc83c1..4d557db4b0 100644 --- a/components/libc/compilers/dlib/syscall_open.c +++ b/components/libc/compilers/dlib/syscall_open.c @@ -11,6 +11,10 @@ #include <rtthread.h> #include <LowLevelIOInterface.h> #include <fcntl.h> +#include <compiler_private.h> +#define DBG_TAG "dlib.syscall.open" +#define DBG_LVL DBG_INFO +#include <rtdbg.h> /* * The "__open" function opens the file named "filename" as specified @@ -22,56 +26,58 @@ int __open(const char *filename, int mode) { #ifdef DFS_USING_POSIX - int handle; - int open_mode = O_RDONLY; + int handle; + int open_mode = O_RDONLY; - if (mode & _LLIO_CREAT) - { - open_mode |= O_CREAT; - - /* Check what we should do with it if it exists. */ - if (mode & _LLIO_APPEND) + if (mode & _LLIO_CREAT) { - /* Append to the existing file. */ - open_mode |= O_APPEND; + open_mode |= O_CREAT; + + /* Check what we should do with it if it exists. */ + if (mode & _LLIO_APPEND) + { + /* Append to the existing file. */ + open_mode |= O_APPEND; + } + + if (mode & _LLIO_TRUNC) + { + /* Truncate the existsing file. */ + open_mode |= O_TRUNC; + } } - if (mode & _LLIO_TRUNC) + if (mode & _LLIO_TEXT) { - /* Truncate the existsing file. */ - open_mode |= O_TRUNC; + /* we didn't support text mode */ } - } - if (mode & _LLIO_TEXT) - { - /* we didn't support text mode */ - } - - switch (mode & _LLIO_RDWRMASK) - { - case _LLIO_RDONLY: - break; - - case _LLIO_WRONLY: - open_mode |= O_WRONLY; - break; + switch (mode & _LLIO_RDWRMASK) + { + case _LLIO_RDONLY: + break; - case _LLIO_RDWR: - /* The file should be opened for both reads and writes. */ - open_mode |= O_RDWR; - break; + case _LLIO_WRONLY: + open_mode |= O_WRONLY; + break; - default: - return _LLIO_ERROR; - } + case _LLIO_RDWR: + /* The file should be opened for both reads and writes. */ + open_mode |= O_RDWR; + break; - handle = open(filename, open_mode, 0); - if (handle < 0) - return _LLIO_ERROR; + default: + return _LLIO_ERROR; + } - return handle; + handle = open(filename, open_mode, 0); + if (handle < 0) + { + return _LLIO_ERROR; + } + return handle; #else - return _LLIO_ERROR; + LOG_W(_WARNING_WITHOUT_FS); + return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index 62bc05d243..a276a3e401 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -11,11 +11,11 @@ #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include "libc.h" -#endif /* RT_USING_POSIX_DEVIO */ - -#define DBG_TAG "dlib.syscall_read" +#endif /* RT_USING_POSIX_STDIO */ +#include <compiler_private.h> +#define DBG_TAG "dlib.syscall.read" #define DBG_LVL DBG_INFO #include <rtdbg.h> @@ -39,16 +39,17 @@ size_t __read(int handle, unsigned char *buf, size_t len) if (handle == _LLIO_STDIN) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { - LOG_W("Do not invoke standard input before initializing libc"); + LOG_W("Do not invoke standard input before initializing Compiler"); return 0; /* error, but keep going */ } return read(STDIN_FILENO, buf, len); /* return the length of the data read */ #else + LOG_W(_WARNING_WITHOUT_STDIO); return _LLIO_ERROR; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ } else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { @@ -58,6 +59,7 @@ size_t __read(int handle, unsigned char *buf, size_t len) size = read(handle, buf, len); return size; /* return the length of the data read */ #else + LOG_W(_WARNING_WITHOUT_FS); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_remove.c b/components/libc/compilers/dlib/syscall_remove.c index 870f91b8c1..04230544da 100644 --- a/components/libc/compilers/dlib/syscall_remove.c +++ b/components/libc/compilers/dlib/syscall_remove.c @@ -7,9 +7,14 @@ * Date Author Notes * 2015-01-28 Bernard first version */ + #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> +#include <compiler_private.h> +#define DBG_TAG "dlib.syscall.remove" +#define DBG_LVL DBG_INFO +#include <rtdbg.h> /* * The "remove" function should remove the file named "filename". It @@ -23,6 +28,7 @@ int remove(const char *filename) #ifdef DFS_USING_POSIX return unlink(filename); #else + LOG_W(_WARNING_WITHOUT_FS); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index 2bc5863d8a..4eead9aa38 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -11,7 +11,8 @@ #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> -#define DBG_TAG "dlib.syscall_write" +#include <compiler_private.h> +#define DBG_TAG "dlib.syscall.write" #define DBG_LVL DBG_INFO #include <rtdbg.h> @@ -39,7 +40,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len) if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { -#ifdef RT_USING_CONSOLE +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) rt_device_t console_device; console_device = rt_console_get_device(); @@ -51,7 +52,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len) return len; /* return the length of the data written */ #else return _LLIO_ERROR; -#endif /* RT_USING_CONSOLE */ +#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */ } else if (handle == _LLIO_STDIN) { @@ -63,6 +64,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len) size = write(handle, buf, len); return size; /* return the length of the data written */ #else + LOG_W(_WARNING_WITHOUT_FS); return _LLIO_ERROR; #endif /* DFS_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscalls.c b/components/libc/compilers/dlib/syscalls.c index 1ee6a3bc12..391cbcac8a 100644 --- a/components/libc/compilers/dlib/syscalls.c +++ b/components/libc/compilers/dlib/syscalls.c @@ -7,6 +7,7 @@ * Date Author Notes * 2021-02-13 Meco Man implement exit() and abort() */ + #include <rtthread.h> /* for exit() and abort() */ |
