]> rtime.felk.cvut.cz Git - jailhouse.git/blobdiff - inmates/lib/string.c
Merge remote-tracking branch 'kiszka/master'
[jailhouse.git] / inmates / lib / string.c
diff --git a/inmates/lib/string.c b/inmates/lib/string.c
new file mode 100644 (file)
index 0000000..7816140
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) Siemens AG, 2016
+ *
+ * Authors:
+ *  Jan Kiszka <jan.kiszka@siemens.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include <inmate.h>
+
+void *memset(void *s, int c, unsigned long n)
+{
+       u8 *p = s;
+
+       while (n-- > 0)
+               *p++ = c;
+       return s;
+}
+
+unsigned long strlen(const char *s1)
+{
+       unsigned long len = 0;
+
+       while (*s1++)
+               len++;
+
+       return len;
+}
+
+int strncmp(const char *s1, const char *s2, unsigned long n)
+{
+       int diff;
+
+       while (n-- > 0) {
+               diff = *s1 - *s2;
+               if (diff)
+                       return diff;
+               if (*s1 == 0)
+                       break;
+               s1++;
+               s2++;
+       }
+       return 0;
+}