zephyr/lib/os/crc32_sw.c
Anas Nashif 4e48e87fd2 cleanup: include/: move crc.h to sys/crc.h
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>
2019-06-27 22:55:49 -04:00

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);
}