From: Marco Felsch <[email protected]>

For use by PBL code, import the barebox proper definition of strncmp
into pbl/string.c.

Signed-off-by: Marco Felsch <[email protected]>
Signed-off-by: Ahmad Fatoum <[email protected]>
---
v1 - > v2:
  - split off preparatory patch from
    
https://lore.barebox.org/barebox/20251110-v2025-09-0-topic-optee-of-handling-v1-0-8f0625ac5...@pengutronix.de/T/#t
  - add a commit message body
---
 pbl/string.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pbl/string.c b/pbl/string.c
index 528f62ef2055..89663fef3d6a 100644
--- a/pbl/string.c
+++ b/pbl/string.c
@@ -102,6 +102,21 @@ int strcmp(const char *cs, const char *ct)
        return res;
 }
 
+int strncmp(const char *cs, const char *ct, size_t count)
+{
+       register signed char __res = 0;
+
+       BUG_ON(!cs || !ct);
+
+       while (count) {
+               if ((__res = *cs - *ct++) != 0 || !*cs++)
+                       break;
+               count--;
+       }
+
+       return __res;
+}
+
 int strcasecmp(const char *s1, const char *s2)
 {
        int c1, c2;
-- 
2.47.3


Reply via email to