c/c++语言开发共享CRC中的CRC32算法/实现没有查找表和公共许可证

我试图在C中实现一个不使用查找表的CRC32算法(我需要在没有足够内存可用的引导加载程序中使用它)。 是否有可用的公共许可证解决方案?

    快速搜索收获了这个网页 。 我无法找到这些代码段的许可证。

    以下应该做的工作:

    需要了解更多c/c++开发分享CRC中的CRC32算法/实现没有查找表和公共许可证,也可以关注C/ C++技术分享栏目—计算机技术网(www.ctvol.com)!

    // ----------------------------- crc32b -------------------------------- /* This is the basic CRC-32 calculation with some optimization but no table lookup. The the byte reversal is avoided by shifting the crc reg right instead of left and by using a reversed 32-bit word to represent the polynomial. When compiled to Cyclops with GCC, this function executes in 8 + 72n instructions, where n is the number of bytes in the input message. It should be doable in 4 + 61n instructions. If the inner loop is strung out (approx. 5*8 = 40 instructions), it would take about 6 + 46n instructions. */ unsigned int crc32b(unsigned char *message) { int i, j; unsigned int byte, crc, mask; i = 0; crc = 0xFFFFFFFF; while (message[i] != 0) { byte = message[i]; // Get next byte. crc = crc ^ byte; for (j = 7; j >= 0; j--) { // Do eight times. mask = -(crc & 1); crc = (crc >> 1) ^ (0xEDB88320 & mask); } i = i + 1; } return ~crc; } 

      以上就是c/c++开发分享CRC中的CRC32算法/实现没有查找表和公共许可证相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/979431.html

      (0)
      上一篇 2021年12月12日
      下一篇 2021年12月12日

      精彩推荐