Mercurial > crc32
view README @ 2:ead9f84d11db
*: make it work on non-x86 too
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 09 Feb 2026 01:21:00 -0500 |
| parents | 90cb48b87dcc |
| children |
line wrap: on
line source
This code was mostly written as an experiment, to see just how much could be done using only the C preprocessor (give or take). Turns out you can do quite a lot. In fact, *all* of the tables in this library are generated at compile-time. The polynomial is #define'd in crc32i.h, and all of the tables are generated 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 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 <paper@tflc.us>
