LCOV - code coverage report
Current view: top level - common - crc16.h (source / functions) Hit Total Coverage
Test: a simple test Lines: 1 1 100.0 %
Date: 2024-06-05 20:10:43 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Implements the standard CRC-16:
       3             :  *   Width 16
       4             :  *   Poly  0x8005 (x^16 + x^15 + x^2 + 1)
       5             :  *   Init  0
       6             :  *
       7             :  * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
       8             :  *
       9             :  * This code was taken from the linux kernel. The license is GPL Version 2.
      10             :  */
      11             : 
      12             : #ifndef __CRC16_H__
      13             : #define __CRC16_H__
      14             : 
      15             : #include <stdlib.h>
      16             : #include <stdint.h>
      17             : 
      18             : extern uint16_t const crc16_table[256];
      19             : 
      20             : extern uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len);
      21             : 
      22             : static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data)
      23             : {
      24   122448257 :         return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
      25             : }
      26             : 
      27             : #endif /* __CRC16_H__ */

Generated by: LCOV version 1.13