diff options
Diffstat (limited to 'fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c')
-rw-r--r-- | fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c b/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c new file mode 100644 index 000000000..e80097803 --- /dev/null +++ b/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c @@ -0,0 +1,27 @@ +#include <inttypes.h> +#include <stdio.h> +#define LONGx1 "8192" +#define LONGx2 "16384" +void main(void) { + const char *n = "abcdefghijklmnopqrstuvwxyz0123456789"; + uint64_t c0 = 0, c1 = 1, c2 = 2; + uint64_t s; + uint32_t eax = 1, ecx; + __asm__("cpuid" : "=c"(ecx) : "a"(eax) : "%ebx", "%edx"); + __asm__( + "crc32b\t" + "(%1), %0" + : "=r"(c0) + : "r"(n), "0"(c0)); + __asm__( + "crc32q\t" + "(%3), %0\n\t" + "crc32q\t" LONGx1 + "(%3), %1\n\t" + "crc32q\t" LONGx2 "(%3), %2" + : "=r"(c0), "=r"(c1), "=r"(c2) + : "r"(n), "0"(c0), "1"(c1), "2"(c2)); + s = c0 + c1 + c2; + printf("avoiding unused code removal by printing %d, %d, %d\n", (int)s, + (int)eax, (int)ecx); +} |