POK
memcmp.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Tue Dec 8 15:53:28 2009
15  */
16 
17 #include <core/dependencies.h>
18 #include <types.h>
19 
20 #ifdef POK_CONFIG_NEEDS_FUNC_MEMCMP
21 
22 int memcmp (const void* v1, const void* v2, size_t n)
23 {
24  uint32_t *s1;
25  uint32_t *s2;
26  size_t i;
27 
28  s1 = (uint32_t*) v1;
29  s2 = (uint32_t*) v2;
30 
31  for (i = 0; i < n; i++) {
32  if (*s1 != *s2) {
33  return *(const uint32_t *)s1 >
34  *(const uint32_t *)s2 ? 1 : -1;
35  }
36  s1++;
37  s2++;
38  }
39  return 0;
40 }
41 
42 #endif
43