aboutsummaryrefslogtreecommitdiff
path: root/sys/libkern
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-02-02 09:52:52 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-04-22 09:41:09 +0000
commitb20f358a2de4fa442e8650f78187ad19764c7db8 (patch)
tree96ba938c3c4be5dce75cf7c8486386c5bf63859b /sys/libkern
parent76713be0f593d7b6cea0696024b804888a61547a (diff)
downloadsrc-b20f358a2de4fa442e8650f78187ad19764c7db8.tar.gz
src-b20f358a2de4fa442e8650f78187ad19764c7db8.zip
tests/sys/kern/crc32: Check for SSE4.2 before using it
This avoids a SIGILL when running these tests on QEMU (which defaults to a basic amd64 CPU without SSE4.2). This commit also tests the table-based implementations in addition to testing the hw-accelerated crc32 versions. Reviewed By: cem, kib, markj Differential Revision: https://reviews.freebsd.org/D28395 (cherry picked from commit 83c20b8a2da04937cf4af127366b3dc92c855784)
Diffstat (limited to 'sys/libkern')
-rw-r--r--sys/libkern/gsb_crc32.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/libkern/gsb_crc32.c b/sys/libkern/gsb_crc32.c
index b2f7421c20eb..170ceb3aa710 100644
--- a/sys/libkern/gsb_crc32.c
+++ b/sys/libkern/gsb_crc32.c
@@ -46,11 +46,11 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/gsb_crc32.h>
#ifdef _KERNEL
#include <sys/libkern.h>
#include <sys/systm.h>
-#include <sys/gsb_crc32.h>
#if defined(__amd64__) || defined(__i386__)
#include <machine/md_var.h>
@@ -216,7 +216,10 @@ static const uint32_t crc32Table[256] = {
0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L
};
-static uint32_t
+#ifndef TESTING
+static
+#endif
+uint32_t
singletable_crc32c(uint32_t crc, const void *buf, size_t size)
{
const uint8_t *p = buf;
@@ -730,10 +733,13 @@ crc32c_sb8_64_bit(uint32_t crc,
return crc;
}
-static uint32_t
+#ifndef TESTING
+static
+#endif
+uint32_t
multitable_crc32c(uint32_t crc32c,
- const unsigned char *buffer,
- unsigned int length)
+ const void *buffer,
+ size_t length)
{
uint32_t to_even_word;