summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMeco Jianting Man <[email protected]>2021-03-01 07:25:48 -0600
committerGitHub <[email protected]>2021-03-01 07:25:48 -0600
commitfab4c5ebb13fd92273de8727c0f18d53716295ff (patch)
treeb8f309bfe504c942560ea56d90c6f349e80c4c56 /components
parent8932ffdb96b793031bbc71bb3bd23202939fcb2c (diff)
parent339ebf3c16e4c067f4ddfb7880709a534d41cf53 (diff)
Merge pull request #22 from RT-Thread/master
pr
Diffstat (limited to 'components')
-rw-r--r--components/drivers/i2c/i2c-bit-ops.c2
-rw-r--r--components/libc/Kconfig6
-rw-r--r--components/libc/compilers/newlib/minilib.c54
-rw-r--r--components/libc/compilers/newlib/syscalls.c17
-rw-r--r--components/libc/getline/README.md10
-rw-r--r--components/libc/getline/posix_getline.c3
-rw-r--r--components/libc/getline/posix_getline.h3
7 files changed, 68 insertions, 27 deletions
diff --git a/components/drivers/i2c/i2c-bit-ops.c b/components/drivers/i2c/i2c-bit-ops.c
index 96af567a1e..3a9b4efeb3 100644
--- a/components/drivers/i2c/i2c-bit-ops.c
+++ b/components/drivers/i2c/i2c-bit-ops.c
@@ -375,6 +375,8 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
rt_int32_t i, ret;
rt_uint16_t ignore_nack;
+ if (num == 0) return 0;
+
for (i = 0; i < num; i++)
{
msg = &msgs[i];
diff --git a/components/libc/Kconfig b/components/libc/Kconfig
index 65c8d44225..49b97481d1 100644
--- a/components/libc/Kconfig
+++ b/components/libc/Kconfig
@@ -54,9 +54,9 @@ if RT_USING_LIBC
endif
if RT_USING_LIBC != y
- config RT_LIBC_USING_TIME
- bool "Enable TIME FUNCTIONS WITHOUT COMPILER'S LIBC"
- default y
+ config RT_LIBC_USING_TIME
+ bool "Enable TIME FUNCTIONS WITHOUT COMPILER'S LIBC"
+ default y
endif
endmenu
diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c
index 2d07eabe5a..ca1bea0f91 100644
--- a/components/libc/compilers/newlib/minilib.c
+++ b/components/libc/compilers/newlib/minilib.c
@@ -11,8 +11,58 @@
#include <reent.h>
#include <rtthread.h>
-void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr)
+#ifdef RT_USING_HEAP /* Memory routine */
+void *
+_malloc_r (struct _reent *ptr, size_t size)
+{
+ void* result;
+
+ result = (void*)rt_malloc (size);
+ if (result == RT_NULL)
+ {
+ ptr->_errno = ENOMEM;
+ }
+
+ return result;
+}
+
+void *
+_realloc_r (struct _reent *ptr, void *old, size_t newlen)
+{
+ void* result;
+
+ result = (void*)rt_realloc (old, newlen);
+ if (result == RT_NULL)
+ {
+ ptr->_errno = ENOMEM;
+ }
+
+ return result;
+}
+
+void *_calloc_r (struct _reent *ptr, size_t size, size_t len)
+{
+ void* result;
+
+ result = (void*)rt_calloc (size, len);
+ if (result == RT_NULL)
+ {
+ ptr->_errno = ENOMEM;
+ }
+
+ return result;
+}
+
+void
+_free_r (struct _reent *ptr, void *addr)
+{
+ rt_free (addr);
+}
+
+#else
+void *
+_sbrk_r(struct _reent *ptr, ptrdiff_t incr)
{
- /* no use this routine to get memory */
return RT_NULL;
}
+#endif /*RT_USING_HEAP*/
diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c
index 949d8a61de..e54d7583cb 100644
--- a/components/libc/compilers/newlib/syscalls.c
+++ b/components/libc/compilers/newlib/syscalls.c
@@ -189,13 +189,6 @@ _rename_r(struct _reent *ptr, const char *old, const char *new)
#endif
}
-void *
-_sbrk_r(struct _reent *ptr, ptrdiff_t incr)
-{
- /* no use this routine to get memory */
- return RT_NULL;
-}
-
int
_stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
{
@@ -258,7 +251,7 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
#endif
}
-/* Memory routine */
+#ifdef RT_USING_HEAP /* Memory routine */
void *
_malloc_r (struct _reent *ptr, size_t size)
{
@@ -306,6 +299,14 @@ _free_r (struct _reent *ptr, void *addr)
rt_free (addr);
}
+#else
+void *
+_sbrk_r(struct _reent *ptr, ptrdiff_t incr)
+{
+ return RT_NULL;
+}
+#endif /*RT_USING_HEAP*/
+
/* for exit() and abort() */
__attribute__ ((noreturn)) void
_exit (int status)
diff --git a/components/libc/getline/README.md b/components/libc/getline/README.md
index 0b279755d3..ef3c19deae 100644
--- a/components/libc/getline/README.md
+++ b/components/libc/getline/README.md
@@ -18,13 +18,3 @@ For more details, see [Open Group Base Specification for getdelim/getline][openg
This code is unlicensed -- free and released into the public domain. See `UNLICENSE` file for more information.
[opengroup-spec]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html
-
-
-
-
-## 联系&维护
-Meco Man
-
-
-https://github.com/mysterywolf/getline
diff --git a/components/libc/getline/posix_getline.c b/components/libc/getline/posix_getline.c
index e2ac278242..99bcf5363e 100644
--- a/components/libc/getline/posix_getline.c
+++ b/components/libc/getline/posix_getline.c
@@ -5,9 +5,8 @@
* https://man7.org/linux/man-pages/man3/getline.3.html
* Authors:
* https://github.com/ivanrad/getline
- * https://github.com/mysterywolf/getline/
*
- * Meco Man 2020-09-03 First Version
+ * Meco Man 2020-09-03 porting to RT-Thread
*/
#include "posix_getline.h"
diff --git a/components/libc/getline/posix_getline.h b/components/libc/getline/posix_getline.h
index c7d6021af3..e9e0bf9c2b 100644
--- a/components/libc/getline/posix_getline.h
+++ b/components/libc/getline/posix_getline.h
@@ -5,9 +5,8 @@
* https://man7.org/linux/man-pages/man3/getline.3.html
* Authors:
* https://github.com/ivanrad/getline
- * https://github.com/mysterywolf/getline/
*
- * Meco Man 2020-09-03 First Version
+ * Meco Man 2020-09-03 porting to RT-Thread
*/