-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncs.c
More file actions
executable file
·51 lines (37 loc) · 735 Bytes
/
funcs.c
File metadata and controls
executable file
·51 lines (37 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "funcs.h"
void * memset(void *a, int ch, size_t sz)
{
unsigned int i = 0;
char *addr = (char *)a;
while ( i < sz ) {
addr[i++] = ch;
}
}
char * strncpy(char *dst, const char *src, int sz)
{
while(sz--)
*dst++ = *src++;
}
void * memcpy(void *dst, const void *src, size_t sz)
{
char *tdst = (char *)dst;
char *tsrc = (char *)src;
while (sz--) { *tdst++ = *tsrc++; }
}
int memcmp(void *s1, void *s2, int sz)
{
char *t1 = (char *)s1;
char *t2 = (char *)s2;
while (sz-- && *t1++ == *t2++);
return (*--t1 - *--t2);
}
int strncmp(const char *s1, const char *s2, size_t sz)
{
while(*s1 && sz-- && *s1++ == *s2++);
return (*--s1 - *--s2);
}
void panic(char *s)
{
printk("%s", s);
while(1);
}