From a8ac6ede8a189d3c72b5edcc1735afe620680048 Mon Sep 17 00:00:00 2001 From: lukileczo Date: Wed, 29 Nov 2023 12:56:50 +0100 Subject: [PATCH] sparcv8leon3: fix strncpy implementation JIRA: RTOS-693 --- arch/sparcv8leon3/string.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/sparcv8leon3/string.c b/arch/sparcv8leon3/string.c index 48d9e4fe..c9edef57 100644 --- a/arch/sparcv8leon3/string.c +++ b/arch/sparcv8leon3/string.c @@ -259,15 +259,23 @@ char *strncpy(char *dest, const char *src, size_t n) __asm__ volatile (" \ cmp %2, %%g0; \ - be 2f; \ + be 3f; \ 1: \ ldub [%1], %%g1; \ + inc %1; \ stb %%g1, [%0]; \ + deccc %2; \ + bz 3f; \ inc %0; \ + cmp %%g1, %%g0; \ + bne 1b; \ + nop; \ + 2: \ + stb %%g0, [%0]; \ deccc %2; \ - bnz 1b; \ - inc %1; \ - 2: " + bnz 2b; \ + inc %0; \ + 3: " : "+r"(p), "+r"(src), "+r"(n) : : "%g1", "memory", "cc");