X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=crc%2Fcrc32c-intel.c;h=77d6df411973510298342d79e190db4b3a447ffa;hb=refs%2Ftags%2Ffio-1.41.6;hp=cec5ad5dec9d5d88ec7498133f2915ae0c1bd146;hpb=419484b934222e589f0b718e9494b045df176167;p=fio.git diff --git a/crc/crc32c-intel.c b/crc/crc32c-intel.c index cec5ad5d..77d6df41 100644 --- a/crc/crc32c-intel.c +++ b/crc/crc32c-intel.c @@ -1,4 +1,10 @@ #include +#include +#include +#include +#include +#include +#include #include "crc32c.h" /* @@ -68,5 +74,30 @@ uint32_t crc32c_intel(unsigned char const *data, unsigned long length) return crc; } -#endif /* ARCH_HAVE_SSE */ +static void do_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, + unsigned int *edx) +{ + int id = *eax; + + asm("movl %4, %%eax;" + "cpuid;" + "movl %%eax, %0;" + "movl %%ebx, %1;" + "movl %%ecx, %2;" + "movl %%edx, %3;" + : "=r" (*eax), "=r" (*ebx), "=r" (*ecx), "=r" (*edx) + : "r" (id) + : "eax", "ebx", "ecx", "edx"); +} + +int crc32c_intel_works(void) +{ + unsigned int eax, ebx, ecx, edx; + + eax = 1; + do_cpuid(&eax, &ebx, &ecx, &edx); + return (ecx & (1 << 20)) != 0; +} + +#endif /* ARCH_HAVE_SSE */