You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/04/05 10:26:00 UTC

[incubator-nuttx] branch master updated (9785d6606c -> ae6bfdc9b9)

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from 9785d6606c openamp: Change the dependence from OPENAMP to RPTUN
     new 34e17ba0ce libc/string: Fix the minor style issue
     new ae6bfdc9b9 libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 include/nuttx/compiler.h         | 16 +++++++++++++++-
 libs/libc/string/lib_memcmp.c    |  1 +
 libs/libc/string/lib_memcpy.c    |  1 +
 libs/libc/string/lib_memmove.c   |  1 +
 libs/libc/string/lib_memset.c    |  1 +
 libs/libc/string/lib_strcat.c    |  6 +++---
 libs/libc/string/lib_strtokr.c   |  4 ++--
 libs/libc/string/lib_vikmemcpy.c |  7 +------
 8 files changed, 25 insertions(+), 12 deletions(-)


[incubator-nuttx] 02/02: libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit ae6bfdc9b9274cbba13a615be26ac10c5367bc9c
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Apr 4 03:19:30 2022 +0800

    libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively
    
    please reference the similar change done by other libc implementation:
    https://reviews.llvm.org/D68028?id=224286
    https://github.com/bminor/glibc/commit/85c2e6110c9a01ec817c30f1b7e20549d7229987
    https://github.com/bminor/musl/commit/4a1f55e92fa74ee382909baa96302231f566b5e1
    https://github.com/bminor/newlib/commit/82dfae9ab0734b9946321590162dc6021057fec1
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 include/nuttx/compiler.h         | 16 +++++++++++++++-
 libs/libc/string/lib_memcmp.c    |  1 +
 libs/libc/string/lib_memcpy.c    |  1 +
 libs/libc/string/lib_memmove.c   |  1 +
 libs/libc/string/lib_memset.c    |  1 +
 libs/libc/string/lib_vikmemcpy.c |  1 +
 6 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h
index 6efefcdd24..3772cf23d0 100644
--- a/include/nuttx/compiler.h
+++ b/include/nuttx/compiler.h
@@ -182,7 +182,7 @@
 #  if defined(__clang__)
 #    define nostackprotect_function __attribute__ ((optnone))
 #  else
-#    define nostackprotect_function __attribute__ ((__optimize__ ("-fno-stack-protector")))
+#    define nostackprotect_function __attribute__ ((__optimize__("-fno-stack-protector")))
 #  endif
 #endif
 
@@ -381,6 +381,12 @@
 
 #  define UNUSED(a) ((void)(1 || (a)))
 
+#  if defined(__clang__)
+#    define no_builtin(n) __attribute__((no_builtin(n)))
+#  else
+#    define no_builtin(n) __attribute__((__optimize__("-fno-tree-loop-distribute-patterns")))
+#endif
+
 /* SDCC-specific definitions ************************************************/
 
 #elif defined(SDCC) || defined(__SDCC)
@@ -537,6 +543,8 @@
 
 #  define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
 
+#  define no_builtin(n)
+
 /* Zilog-specific definitions ***********************************************/
 
 #elif defined(__ZILOG__)
@@ -677,6 +685,8 @@
 
 #  define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
 
+#  define no_builtin(n)
+
 /* ICCARM-specific definitions **********************************************/
 
 #elif defined(__ICCARM__)
@@ -746,6 +756,8 @@
 
 #  define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
 
+#  define no_builtin(n)
+
 /* Unknown compiler *********************************************************/
 
 #else
@@ -803,6 +815,8 @@
 
 #  define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
 
+#  define no_builtin(n)
+
 #endif
 
 /****************************************************************************
diff --git a/libs/libc/string/lib_memcmp.c b/libs/libc/string/lib_memcmp.c
index 1f788f451e..9602c9a254 100644
--- a/libs/libc/string/lib_memcmp.c
+++ b/libs/libc/string/lib_memcmp.c
@@ -32,6 +32,7 @@
 
 #ifndef CONFIG_LIBC_ARCH_MEMCMP
 #undef memcmp /* See mm/README.txt */
+no_builtin("memcmp")
 int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
 {
   unsigned char *p1 = (unsigned char *)s1;
diff --git a/libs/libc/string/lib_memcpy.c b/libs/libc/string/lib_memcpy.c
index de4f8eed23..ba91d5abb1 100644
--- a/libs/libc/string/lib_memcpy.c
+++ b/libs/libc/string/lib_memcpy.c
@@ -36,6 +36,7 @@
 
 #ifndef CONFIG_LIBC_ARCH_MEMCPY
 #undef memcpy /* See mm/README.txt */
+no_builtin("memcpy")
 FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n)
 {
   FAR unsigned char *pout = (FAR unsigned char *)dest;
diff --git a/libs/libc/string/lib_memmove.c b/libs/libc/string/lib_memmove.c
index bc72a85daf..afed8e0172 100644
--- a/libs/libc/string/lib_memmove.c
+++ b/libs/libc/string/lib_memmove.c
@@ -32,6 +32,7 @@
 
 #ifndef CONFIG_LIBC_ARCH_MEMMOVE
 #undef memmove /* See mm/README.txt */
+no_builtin("memmove")
 FAR void *memmove(FAR void *dest, FAR const void *src, size_t count)
 {
   FAR char *tmp;
diff --git a/libs/libc/string/lib_memset.c b/libs/libc/string/lib_memset.c
index e22a6cd205..4f20f15f9e 100644
--- a/libs/libc/string/lib_memset.c
+++ b/libs/libc/string/lib_memset.c
@@ -48,6 +48,7 @@
 
 #ifndef CONFIG_LIBC_ARCH_MEMSET
 #undef memset /* See mm/README.txt */
+no_builtin("memset")
 FAR void *memset(FAR void *s, int c, size_t n)
 {
 #ifdef CONFIG_MEMSET_OPTSPEED
diff --git a/libs/libc/string/lib_vikmemcpy.c b/libs/libc/string/lib_vikmemcpy.c
index 88e5676be7..ce9a89a4e2 100644
--- a/libs/libc/string/lib_vikmemcpy.c
+++ b/libs/libc/string/lib_vikmemcpy.c
@@ -305,6 +305,7 @@ typedef uint32_t            uintn;
  *
  ****************************************************************************/
 
+no_builtin("memcpy")
 FAR void *memcpy(FAR void *dest, FAR const void *src, size_t count)
 {
   FAR uint8_t *dst8 = (FAR uint8_t *)dest;


[incubator-nuttx] 01/02: libc/string: Fix the minor style issue

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 34e17ba0ce08c9f0cc62d8ce98740daa1663c392
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Apr 4 03:22:29 2022 +0800

    libc/string: Fix the minor style issue
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 libs/libc/string/lib_strcat.c    | 6 +++---
 libs/libc/string/lib_strtokr.c   | 4 ++--
 libs/libc/string/lib_vikmemcpy.c | 6 ------
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/libs/libc/string/lib_strcat.c b/libs/libc/string/lib_strcat.c
index beb23e2652..33f5a97b73 100644
--- a/libs/libc/string/lib_strcat.c
+++ b/libs/libc/string/lib_strcat.c
@@ -32,11 +32,11 @@
 
 #ifndef CONFIG_ARCH_STRCAT
 #undef strcat /* See mm/README.txt */
-char *strcat(char *dest, const char *src)
+FAR char *strcat(FAR char *dest, FAR const char *src)
 {
-  char *ret   = dest;
+  FAR char *ret = dest;
 
-  dest  += strlen(dest);
+  dest += strlen(dest);
   while (*src != '\0')
     {
       *dest++ = *src++;
diff --git a/libs/libc/string/lib_strtokr.c b/libs/libc/string/lib_strtokr.c
index 5193b83b51..f24d3428c2 100644
--- a/libs/libc/string/lib_strtokr.c
+++ b/libs/libc/string/lib_strtokr.c
@@ -77,8 +77,8 @@
 
 FAR char *strtok_r(FAR char *str, FAR const char *delim, FAR char **saveptr)
 {
-  char *pbegin;
-  char *pend = NULL;
+  FAR char *pbegin;
+  FAR char *pend = NULL;
 
   /* Decide if we are starting a new string or continuing from
    * the point we left off.
diff --git a/libs/libc/string/lib_vikmemcpy.c b/libs/libc/string/lib_vikmemcpy.c
index 3e93b175d3..88e5676be7 100644
--- a/libs/libc/string/lib_vikmemcpy.c
+++ b/libs/libc/string/lib_vikmemcpy.c
@@ -51,12 +51,6 @@
  *
  ****************************************************************************/
 
-/****************************************************************************
- * Configuration definitions.
- ****************************************************************************/
-
-#define CONFIG_MEMCPY_INDEXED_COPY
-
 /****************************************************************************
  * Included Files
  ****************************************************************************/