/*
* Based on file found here :
*
* https : //svnweb.freebsd.org/base/stable/10/sys/libkern/crc32.c?revision=256281
*/
/*-
* COPYRIGHT ( C ) 1986 Gary S . Brown . You may use this program , or
* code or tables extracted from it , as desired without restriction .
*/
/*
* First , the polynomial itself and its table of feedback terms . The
* polynomial is
* X ^ 32 + X ^ 26 + X ^ 23 + X ^ 22 + X ^ 16 + X ^ 12 + X ^ 11 + X ^ 10 + X ^ 8 + X ^ 7 + X ^ 5 + X ^ 4 + X ^ 2 + X ^ 1 + X ^ 0
*
* Note that we take it " backwards " and put the highest - order term in
* the lowest - order bit . The X ^ 32 term is " implied " ; the LSB is the
* X ^ 31 term , etc . The X ^ 0 term ( usually shown as " + 1 " ) results in
* the MSB being 1
*
* Note that the usual hardware shift register implementation , which
* is what we ' re using ( we ' re merely optimizing it by doing eight - bit
* chunks at a time ) shifts bits into the lowest - order term . In our
* implementation , that means shifting towards the right . Why do we
* do it this way ? Because the calculated CRC must be transmitted in
* order from highest - order term to lowest - order term . UARTs transmit
* characters in order from LSB to MSB . By storing the CRC this way
* we hand it to the UART in the order low - byte to high - byte ; the UART
* sends each low - bit to hight - bit ; and the result is transmission bit
* by bit from highest - to lowest - order term without requiring any bit
* shuffling on our part . Reception works similarly
*
* The feedback terms table consists of 256 , 32 - bit entries . Notes
*
* The table can be generated at runtime if desired ; code to do so
* is shown later . It might not be obvious , but the feedback
* terms simply represent the results of eight shift / xor opera
* tions for all combinations of data and CRC register values
*
* The values must be right - shifted by eight bits by the " updcrc
* logic ; the shift must be unsigned ( bring in zeroes ) . On some
* hardware you could probably optimize the shift in assembler by
* using byte - swap instructions
* polynomial $ edb88320
*
*
* CRC32 code derived from work by Gary S . Brown .
*/
#include "crc32c.h"
/* CRC32C routines, these use a different polynomial */
/*****************************************************************/
/* */
/* CRC LOOKUP TABLE */
/* ================ */
/* The following CRC lookup table was generated automagically */
/* by the Rocksoft^tm Model CRC Algorithm Table Generation */
/* Program V1.0 using the following model parameters: */
/* */
/* Width : 4 bytes. */
/* Poly : 0x1EDC6F41L */
/* Reverse : TRUE. */
/* */
/* For more information on the Rocksoft^tm Model CRC Algorithm, */
/* see the document titled "A Painless Guide to CRC Error */
/* Detection Algorithms" by Ross Williams */
/* (ross@guest.adelaide.edu.au.). This document is likely to be */
/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/*****************************************************************/
static const uint32_t crc32Table[256 ] = {
0 x00000000L, 0 xF26B8303L, 0 xE13B70F7L, 0 x1350F3F4L,
0 xC79A971FL, 0 x35F1141CL, 0 x26A1E7E8L, 0 xD4CA64EBL,
0 x8AD958CFL, 0 x78B2DBCCL, 0 x6BE22838L, 0 x9989AB3BL,
0 x4D43CFD0L, 0 xBF284CD3L, 0 xAC78BF27L, 0 x5E133C24L,
0 x105EC76FL, 0 xE235446CL, 0 xF165B798L, 0 x030E349BL,
0 xD7C45070L, 0 x25AFD373L, 0 x36FF2087L, 0 xC494A384L,
0 x9A879FA0L, 0 x68EC1CA3L, 0 x7BBCEF57L, 0 x89D76C54L,
0 x5D1D08BFL, 0 xAF768BBCL, 0 xBC267848L, 0 x4E4DFB4BL,
0 x20BD8EDEL, 0 xD2D60DDDL, 0 xC186FE29L, 0 x33ED7D2AL,
0 xE72719C1L, 0 x154C9AC2L, 0 x061C6936L, 0 xF477EA35L,
0 xAA64D611L, 0 x580F5512L, 0 x4B5FA6E6L, 0 xB93425E5L,
0 x6DFE410EL, 0 x9F95C20DL, 0 x8CC531F9L, 0 x7EAEB2FAL,
0 x30E349B1L, 0 xC288CAB2L, 0 xD1D83946L, 0 x23B3BA45L,
0 xF779DEAEL, 0 x05125DADL, 0 x1642AE59L, 0 xE4292D5AL,
0 xBA3A117EL, 0 x4851927DL, 0 x5B016189L, 0 xA96AE28AL,
0 x7DA08661L, 0 x8FCB0562L, 0 x9C9BF696L, 0 x6EF07595L,
0 x417B1DBCL, 0 xB3109EBFL, 0 xA0406D4BL, 0 x522BEE48L,
0 x86E18AA3L, 0 x748A09A0L, 0 x67DAFA54L, 0 x95B17957L,
0 xCBA24573L, 0 x39C9C670L, 0 x2A993584L, 0 xD8F2B687L,
0 x0C38D26CL, 0 xFE53516FL, 0 xED03A29BL, 0 x1F682198L,
0 x5125DAD3L, 0 xA34E59D0L, 0 xB01EAA24L, 0 x42752927L,
0 x96BF4DCCL, 0 x64D4CECFL, 0 x77843D3BL, 0 x85EFBE38L,
0 xDBFC821CL, 0 x2997011FL, 0 x3AC7F2EBL, 0 xC8AC71E8L,
0 x1C661503L, 0 xEE0D9600L, 0 xFD5D65F4L, 0 x0F36E6F7L,
0 x61C69362L, 0 x93AD1061L, 0 x80FDE395L, 0 x72966096L,
0 xA65C047DL, 0 x5437877EL, 0 x4767748AL, 0 xB50CF789L,
0 xEB1FCBADL, 0 x197448AEL, 0 x0A24BB5AL, 0 xF84F3859L,
0 x2C855CB2L, 0 xDEEEDFB1L, 0 xCDBE2C45L, 0 x3FD5AF46L,
0 x7198540DL, 0 x83F3D70EL, 0 x90A324FAL, 0 x62C8A7F9L,
0 xB602C312L, 0 x44694011L, 0 x5739B3E5L, 0 xA55230E6L,
0 xFB410CC2L, 0 x092A8FC1L, 0 x1A7A7C35L, 0 xE811FF36L,
0 x3CDB9BDDL, 0 xCEB018DEL, 0 xDDE0EB2AL, 0 x2F8B6829L,
0 x82F63B78L, 0 x709DB87BL, 0 x63CD4B8FL, 0 x91A6C88CL,
0 x456CAC67L, 0 xB7072F64L, 0 xA457DC90L, 0 x563C5F93L,
0 x082F63B7L, 0 xFA44E0B4L, 0 xE9141340L, 0 x1B7F9043L,
0 xCFB5F4A8L, 0 x3DDE77ABL, 0 x2E8E845FL, 0 xDCE5075CL,
0 x92A8FC17L, 0 x60C37F14L, 0 x73938CE0L, 0 x81F80FE3L,
0 x55326B08L, 0 xA759E80BL, 0 xB4091BFFL, 0 x466298FCL,
0 x1871A4D8L, 0 xEA1A27DBL, 0 xF94AD42FL, 0 x0B21572CL,
0 xDFEB33C7L, 0 x2D80B0C4L, 0 x3ED04330L, 0 xCCBBC033L,
0 xA24BB5A6L, 0 x502036A5L, 0 x4370C551L, 0 xB11B4652L,
0 x65D122B9L, 0 x97BAA1BAL, 0 x84EA524EL, 0 x7681D14DL,
0 x2892ED69L, 0 xDAF96E6AL, 0 xC9A99D9EL, 0 x3BC21E9DL,
0 xEF087A76L, 0 x1D63F975L, 0 x0E330A81L, 0 xFC588982L,
0 xB21572C9L, 0 x407EF1CAL, 0 x532E023EL, 0 xA145813DL,
0 x758FE5D6L, 0 x87E466D5L, 0 x94B49521L, 0 x66DF1622L,
0 x38CC2A06L, 0 xCAA7A905L, 0 xD9F75AF1L, 0 x2B9CD9F2L,
0 xFF56BD19L, 0 x0D3D3E1AL, 0 x1E6DCDEEL, 0 xEC064EEDL,
0 xC38D26C4L, 0 x31E6A5C7L, 0 x22B65633L, 0 xD0DDD530L,
0 x0417B1DBL, 0 xF67C32D8L, 0 xE52CC12CL, 0 x1747422FL,
0 x49547E0BL, 0 xBB3FFD08L, 0 xA86F0EFCL, 0 x5A048DFFL,
0 x8ECEE914L, 0 x7CA56A17L, 0 x6FF599E3L, 0 x9D9E1AE0L,
0 xD3D3E1ABL, 0 x21B862A8L, 0 x32E8915CL, 0 xC083125FL,
0 x144976B4L, 0 xE622F5B7L, 0 xF5720643L, 0 x07198540L,
0 x590AB964L, 0 xAB613A67L, 0 xB831C993L, 0 x4A5A4A90L,
0 x9E902E7BL, 0 x6CFBAD78L, 0 x7FAB5E8CL, 0 x8DC0DD8FL,
0 xE330A81AL, 0 x115B2B19L, 0 x020BD8EDL, 0 xF0605BEEL,
0 x24AA3F05L, 0 xD6C1BC06L, 0 xC5914FF2L, 0 x37FACCF1L,
0 x69E9F0D5L, 0 x9B8273D6L, 0 x88D28022L, 0 x7AB90321L,
0 xAE7367CAL, 0 x5C18E4C9L, 0 x4F48173DL, 0 xBD23943EL,
0 xF36E6F75L, 0 x0105EC76L, 0 x12551F82L, 0 xE03E9C81L,
0 x34F4F86AL, 0 xC69F7B69L, 0 xD5CF889DL, 0 x27A40B9EL,
0 x79B737BAL, 0 x8BDCB4B9L, 0 x988C474DL, 0 x6AE7C44EL,
0 xBE2DA0A5L, 0 x4C4623A6L, 0 x5F16D052L, 0 xAD7D5351L
};
// NOTE: See source URL at top of this file for multitable implementation which
// offers a performance boost at the cost of ~8KB of static tables.
uint32_t
ComputeCrc32c(uint32_t crc, const void *buf, size_t size)
{
const uint8_t *p = buf;
while (size--)
crc = crc32Table[(crc ^ *p++) & 0 xff] ^ (crc >> 8 );
return crc;
}
Messung V0.5 in Prozent C=89 H=96 G=92
¤ Dauer der Verarbeitung: 0.32 Sekunden
(vorverarbeitet am 2026-08-25)
¤
*© Formatika GbR, Deutschland