|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XTF 4/4] libc: add strncmp() function
Signed-off-by: Pawel Wieczorkiewicz <wipawel@xxxxxxxxx>
---
common/libc/string.c | 11 +++++++++++
include/xtf/libc.h | 3 +++
2 files changed, 14 insertions(+)
diff --git a/common/libc/string.c b/common/libc/string.c
index 5c25e27..d81e324 100644
--- a/common/libc/string.c
+++ b/common/libc/string.c
@@ -56,6 +56,17 @@ int (strcmp)(const char *_s1, const char *_s2)
return (s1 < s2) ? -1 : (s1 > s2);
}
+int (strncmp)(const char *_s1, const char *_s2, size_t n)
+{
+ size_t ctr;
+ for (ctr = 0; ctr < n; ctr++) {
+ if (_s1[ctr] != _s2[ctr])
+ return (int)(_s1[ctr] - _s2[ctr]);
+ }
+
+ return 0;
+}
+
void *(memset)(void *s, int c, size_t n)
{
char *p = s;
diff --git a/include/xtf/libc.h b/include/xtf/libc.h
index 75f193b..c3783a8 100644
--- a/include/xtf/libc.h
+++ b/include/xtf/libc.h
@@ -26,6 +26,9 @@ char *strncpy(char *dst, const char *src, size_t n);
int strcmp(const char *s1, const char *s2);
#define strcmp(s1, s2) __builtin_strcmp(s1, s2)
+int strncmp(const char *s1, const char *s2, size_t n);
+#define strncmp(s1, s2, n) __builtin_strncmp(s1, s2, n)
+
void *memset(void *s, int c, size_t n);
#define memset(d, c, n) __builtin_memset(d, c, n)
--
2.16.6
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |