[PATCH 15/23] pbl: string: add strncmp

Marco Felsch m.felsch at pengutronix.de
Mon Nov 10 12:34:55 PST 2025


Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
 pbl/string.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pbl/string.c b/pbl/string.c
index 528f62ef2055aa59643e7a882b2ac1358813386d..89663fef3d6a5b0bdcbda2f3c6bc686f1ee4da71 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




More information about the barebox mailing list