Signed-off-by: Ralf Ramsauer <[email protected]>
---
 inmates/lib/inmate_common.h |  1 +
 inmates/lib/string.c        | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/inmates/lib/inmate_common.h b/inmates/lib/inmate_common.h
index dfe33347..ba39550e 100644
--- a/inmates/lib/inmate_common.h
+++ b/inmates/lib/inmate_common.h
@@ -71,6 +71,7 @@ void printk(const char *fmt, ...);
 
 void *memset(void *s, int c, unsigned long n);
 void *memcpy(void *d, const void *s, unsigned long n);
+int memcmp(const void *s1, const void *s2, unsigned long n);
 unsigned long strlen(const char *s);
 int strncmp(const char *s1, const char *s2, unsigned long n);
 int strcmp(const char *s1, const char *s2);
diff --git a/inmates/lib/string.c b/inmates/lib/string.c
index a7c46229..5e2f1445 100644
--- a/inmates/lib/string.c
+++ b/inmates/lib/string.c
@@ -57,6 +57,16 @@ void *memset(void *s, int c, unsigned long n)
        return s;
 }
 
+int memcmp(const void *s1, const void *s2, unsigned long n)
+{
+       const unsigned char *_s1 = s1, *_s2 = s2;
+
+       while (n-- > 0)
+               if (*_s1++ != *_s2++)
+                       return _s1[-1] < _s2[-1] ? -1 : 1;
+       return 0;
+}
+
 unsigned long strlen(const char *s1)
 {
        unsigned long len = 0;
-- 
2.17.0

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to