summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2014-11-01 15:35:26 +0800
committerBernard Xiong <[email protected]>2014-11-01 15:35:26 +0800
commite22264f1d078d980320e957c1f4a856313aa552e (patch)
tree84d31b5e0f51f7ad28cbeb38dfc2bb9d2725897e /components/libc
parenta9952648322ee8b99a2f2798408162423d7d0d84 (diff)
parentb081df6b937360aa53bc27f56066f83c2327167b (diff)
Merge pull request #361 from BernardXiong/master
Add cplusplus and sensor framework.
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/armlibc/stubs.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/components/libc/armlibc/stubs.c b/components/libc/armlibc/stubs.c
index 1f9e01ba3c..ea42777a08 100644
--- a/components/libc/armlibc/stubs.c
+++ b/components/libc/armlibc/stubs.c
@@ -50,6 +50,7 @@ FILEHANDLE _sys_open(const char *name, int openmode)
{
#ifdef RT_USING_DFS
int fd;
+ int mode = O_RDONLY;
#endif
/* Register standard Input Output devices. */
@@ -63,8 +64,33 @@ FILEHANDLE _sys_open(const char *name, int openmode)
#ifndef RT_USING_DFS
return -1;
#else
- /* TODO: adjust open file mode */
- fd = open(name, openmode, 0);
+ /* Correct openmode from fopen to open */
+ if (openmode & OPEN_PLUS)
+ {
+ if (openmode & OPEN_W)
+ {
+ mode |= (O_RDWR | O_TRUNC | O_CREAT);
+ }
+ else if (openmode & OPEN_A)
+ {
+ mode |= (O_RDWR | O_APPEND | O_CREAT);
+ }
+ else
+ mode |= O_RDWR;
+ }
+ else
+ {
+ if (openmode & OPEN_W)
+ {
+ mode |= (O_WRONLY | O_TRUNC | O_CREAT);
+ }
+ else if (openmode & OPEN_A)
+ {
+ mode |= (O_WRONLY | O_APPEND | O_CREAT);
+ }
+ }
+
+ fd = open(name, mode, 0);
if(fd < 0)
return -1;
else
@@ -140,7 +166,6 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
return 0;
#else
rt_device_t console_device;
- extern rt_device_t rt_console_get_device(void);
console_device = rt_console_get_device();
if (console_device != 0) rt_device_write(console_device, 0, buf, len);
@@ -227,7 +252,6 @@ int _sys_istty(FILEHANDLE fh)
return 0;
}
-
int remove(const char *filename)
{
#ifndef RT_USING_DFS
@@ -238,7 +262,7 @@ int remove(const char *filename)
}
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) && defined(RT_USING_MODULE) && defined(RT_USING_DFS)
-/* use system implementation in the msh */
+/* use system(const char *string) implementation in the msh */
#else
int system(const char *string)
{