# HG changeset patch # User Paper # Date 1770618060 18000 # Node ID ead9f84d11dbb3527e4205c7937d8a54a4ca9582 # Parent 90cb48b87dcc8b601c2318ad6562f9e6f039b07c *: make it work on non-x86 too diff -r 90cb48b87dcc -r ead9f84d11db README --- a/README Mon Feb 09 01:18:06 2026 -0500 +++ b/README Mon Feb 09 01:21:00 2026 -0500 @@ -7,7 +7,9 @@ through a combination of enums and preprocessor trickery. Note that this may cause this code to compile slowly on some machines or compilers. -At the moment it is hardcoded for x86-64 and gcc, but it could be adapted to -other compilers if they also have features like e.g. alignas() or whatever. -You'd also need to disable the x86 code which isn't difficult but is a bit -annoying. +At the moment it is hardcoded for gcc, but it could be adapted to other +compilers if they also have features like e.g. alignas() or whatever. +The code relies on C99 stdint.h but if that's not available you can just +typedef to the suitable C89 types on your system. + +--paper diff -r 90cb48b87dcc -r ead9f84d11db crc32-impls.h --- a/crc32-impls.h Mon Feb 09 01:18:06 2026 -0500 +++ b/crc32-impls.h Mon Feb 09 01:21:00 2026 -0500 @@ -3,5 +3,7 @@ #endif CRC32_IMPL(c) CRC32_IMPL(qw) +#ifdef __x86_64__ CRC32_IMPL(x86_vpclmulqdq) +#endif #undef CRC32_IMPL \ No newline at end of file diff -r 90cb48b87dcc -r ead9f84d11db crc32-test.c --- a/crc32-test.c Mon Feb 09 01:18:06 2026 -0500 +++ b/crc32-test.c Mon Feb 09 01:21:00 2026 -0500 @@ -22,7 +22,7 @@ uint32_t thiscrc = ~crc[i](0xFFFFFFFF, testdata, sizeof(testdata)); if (thiscrc != crcc) { - fprintf(stderr, "%zu, mismatch: %08x, %08x\n", i, crcc, thiscrc); + fprintf(stderr, "%zu, mismatch: %08" PRIX32 ", %08" PRIx32 "\n", i, crcc, thiscrc); return -1; } } diff -r 90cb48b87dcc -r ead9f84d11db crc32x86.c --- a/crc32x86.c Mon Feb 09 01:18:06 2026 -0500 +++ b/crc32x86.c Mon Feb 09 01:21:00 2026 -0500 @@ -1,5 +1,7 @@ /* x86-specific CRC routines */ +#ifdef __x86_64__ + #include "crc32.h" #include "crc32i.h" #include @@ -201,3 +203,5 @@ * need to align any more (or use crc32c_r). */ return crc32qw_r(crc, msg, sz); } + +#endif