Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / arch / x86 / klib / fast_crc.c
1 #include <lunaix/types.h>
2 #include <klibc/crc.h>
3
4 #ifdef CONFIG_X86_ENABLE_SSE_FEATURE
5 unsigned int
6 crc32b(unsigned char* data, unsigned int size)
7 {
8     unsigned int ret;
9     asm volatile(
10         "xorl %%ebx, %%ebx\n"
11         "xorl %%eax, %%eax\n"
12         "1:\n"
13         "crc32 (%%edx, %%ebx, 1), %%eax\n"
14         "incl %%ebx\n"
15         "cmpl %%ebx, %%ecx\n"
16         "jne 1b\n"
17         : "=a"(ret)
18         : "d"((ptr_t)data),
19           "c"(size)
20         :
21     );
22     return ret;
23 }
24 #endif