Browse Source

mips: fix memmove() call when __ARCH_HAS_BWD_MEMCPY__ is not defined

When arch (such as MIPS) does not define __ARCH_HAS_BWD_MEMCPY__, memmove()
calls memcpy() which is wrong for overlapping regions.

Signed-off-by: Petar Jovanovic <petar.jovanovic@rt-rk.com>
Petar Jovanovic 4 years ago
parent
commit
785dee7855
1 changed files with 3 additions and 3 deletions
  1. 3 3
      libc/string/generic/memmove.c

+ 3 - 3
libc/string/generic/memmove.c

@@ -23,7 +23,7 @@
 #include "memcopy.h"
 #include "pagecopy.h"
 
-#ifdef __ARCH_HAS_BWD_MEMCPY__
+#ifndef __ARCH_HAS_BWD_MEMCPY__
 /* generic-opt memmove assumes memcpy does forward copying! */
 #include "_memcpy_fwd.c"
 #endif
@@ -224,8 +224,8 @@ void *memmove (void *dest, const void *src, size_t len)
      Reduces the working set.  */
   if (dstp - srcp >= len)	/* *Unsigned* compare!  */
     {
-#ifndef __ARCH_HAS_BWD_MEMCPY__
-      /* Backward memcpy implementation cannot be used */
+#ifdef __ARCH_HAS_BWD_MEMCPY__
+      /* Backward memcpy implementation can be used */
       memcpy(dest, src, len);
 #else
       /* Copy from the beginning to the end.  */