1 #include <u.h> 2 #include <libc.h> 3 4 int memcmp(void * a1,void * a2,ulong n)5memcmp(void *a1, void *a2, ulong n) 6 { 7 uchar *s1, *s2; 8 uint c1, c2; 9 10 s1 = a1; 11 s2 = a2; 12 while(n > 0) { 13 c1 = *s1++; 14 c2 = *s2++; 15 if(c1 != c2) { 16 if(c1 > c2) 17 return 1; 18 return -1; 19 } 20 n--; 21 } 22 return 0; 23 } 24