]> hackdaworld.org Git - my-code/arm.git/blob - betty/functions.c
the interrupt routines
[my-code/arm.git] / betty / functions.c
1 /*
2  * * functions.c - severla functions usually served by libc
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  */
7
8 #include "functions.h"
9
10 /*
11  * functions
12  */
13
14 #define modulo(d,x,y)   (d)=(x); \
15                         while((d)>=(y)) \
16                                 (d)-=(y);
17
18 int strlen(char *s) {
19
20         int n;
21
22         n=0;
23
24         while(s[n])
25                 n++;
26
27         return n;
28 }
29
30 int strncmp(char *a,char *b,int n) {
31
32         if(!n)
33                 return 0;
34
35         while(n--) {
36                 if(*a!=*b)
37                         return (*(u8 *)a-*(u8 *)b++);
38                 if(!*a++)
39                         break;
40         }
41
42         return 0;
43 }
44
45 int strncpy(char *d,char *s,int n) {
46
47         while(n) {
48                 n--;
49                 d[n]=s[n];
50         }
51         
52         return 0;
53 }
54
55 int mset(u8 *s,u8 v,int n) {
56
57         while(n)
58                 s[--n]=v;
59
60         return 0;
61 }
62