]> rtime.felk.cvut.cz Git - jailhouse.git/blob - inmates/lib/string.c
Merge remote-tracking branch 'kiszka/master'
[jailhouse.git] / inmates / lib / string.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2016
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <inmate.h>
14
15 void *memset(void *s, int c, unsigned long n)
16 {
17         u8 *p = s;
18
19         while (n-- > 0)
20                 *p++ = c;
21         return s;
22 }
23
24 unsigned long strlen(const char *s1)
25 {
26         unsigned long len = 0;
27
28         while (*s1++)
29                 len++;
30
31         return len;
32 }
33
34 int strncmp(const char *s1, const char *s2, unsigned long n)
35 {
36         int diff;
37
38         while (n-- > 0) {
39                 diff = *s1 - *s2;
40                 if (diff)
41                         return diff;
42                 if (*s1 == 0)
43                         break;
44                 s1++;
45                 s2++;
46         }
47         return 0;
48 }