POK
/home/jaouen/pok_official/pok/trunk/libpok/libc/string/memcmp.c
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Tue Dec  8 15:53:28 2009 
00015  */
00016 
00017 #include <core/dependencies.h>
00018 #include <types.h>
00019 
00020 #ifdef POK_CONFIG_NEEDS_FUNC_MEMCMP
00021 
00022 int memcmp (const void* v1, const void* v2, size_t n)
00023 {
00024    uint32_t *s1;
00025    uint32_t *s2;
00026    size_t  i;
00027 
00028    s1 = (uint32_t*) v1;
00029    s2 = (uint32_t*) v2;
00030 
00031    for (i = 0; i < n; i++) {
00032                 if (*s1 != *s2) {
00033                         return *(const uint32_t *)s1 >
00034                                *(const uint32_t *)s2 ? 1 : -1;
00035                 }
00036                 s1++;
00037                 s2++;
00038         }
00039    return 0;
00040 }
00041 
00042 #endif
00043