mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-09 11:15:27 +00:00
move crc.h to sys/crc.h and create a shim for backward-compatibility. No functional changes to the headers. A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES. Related to #16539 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
27 lines
454 B
C
27 lines
454 B
C
/*
|
|
* Copyright (c) 2018 Workaround GmbH.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <sys/crc.h>
|
|
|
|
u32_t crc32_ieee(const u8_t *data, size_t len)
|
|
{
|
|
return crc32_ieee_update(0x0, data, len);
|
|
}
|
|
|
|
u32_t crc32_ieee_update(u32_t crc, const u8_t *data, size_t len)
|
|
{
|
|
crc = ~crc;
|
|
for (size_t i = 0; i < len; i++) {
|
|
crc = crc ^ data[i];
|
|
|
|
for (u8_t j = 0; j < 8; j++) {
|
|
crc = (crc >> 1) ^ (0xEDB88320 & -(crc & 1));
|
|
}
|
|
}
|
|
|
|
return (~crc);
|
|
}
|