aboutsummaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorAlexey Lapshin <alexey.lapshin@espressif.com>2025-01-29 09:07:20 +0000
committerCorinna Vinschen <corinna@vinschen.de>2025-02-10 15:26:51 +0100
commitbc2723e98929a327d0a281407bd68cfe8420c16c (patch)
treeb7a015a2cd96cc2b8f25ebfb095445428def87e7 /newlib
parentc9b74e32892966c8f66280c752181292bc95f690 (diff)
downloadnewlib-bc2723e98929a327d0a281407bd68cfe8420c16c.zip
newlib-bc2723e98929a327d0a281407bd68cfe8420c16c.tar.gz
newlib-bc2723e98929a327d0a281407bd68cfe8420c16c.tar.bz2
newlib: memccpy: unify mask filling with other memory functions
This change made just to have memccpy like others mem-functions
Diffstat (limited to 'newlib')
-rw-r--r--newlib/libc/string/memccpy.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/newlib/libc/string/memccpy.c b/newlib/libc/string/memccpy.c
index 3323324..6e7e944 100644
--- a/newlib/libc/string/memccpy.c
+++ b/newlib/libc/string/memccpy.c
@@ -69,7 +69,7 @@ memccpy (void *__restrict dst0,
if (!TOO_SMALL_LITTLE_BLOCK(len0) && !UNALIGNED_X_Y(src, dst))
{
unsigned int i;
- unsigned long mask = 0;
+ unsigned long mask;
aligned_dst = (long*)dst;
aligned_src = (long*)src;
@@ -80,9 +80,10 @@ memccpy (void *__restrict dst0,
the word-sized segment with a word-sized block of the search
character and then detecting for the presence of NULL in the
result. */
- for (i = 0; i < sizeof(mask); i++)
- mask = (mask << 8) + endchar;
-
+ mask = endchar << 8 | endchar;
+ mask = mask << 16 | mask;
+ for (i = 32; i < sizeof(mask) * 8; i <<= 1)
+ mask = (mask << i) | mask;
/* Copy one long word at a time if possible. */
while (!TOO_SMALL_LITTLE_BLOCK(len0))