]> git.zerfleddert.de Git - proxmark3-svn/blame - common/parity.h
updated
[proxmark3-svn] / common / parity.h
CommitLineData
2b1f4228 1//-----------------------------------------------------------------------------
2// This code is licensed to you under the terms of the GNU GPL, version 2 or,
3// at your option, any later version. See the LICENSE.txt file for the text of
4// the license.
5//-----------------------------------------------------------------------------
6// Generic CRC calculation code.
7//-----------------------------------------------------------------------------
8
9#ifndef __PARITY_H
10#define __PARITY_H
11
e36b07ef 12#ifdef __cplusplus
13extern "C" {
14#endif
15
2b1f4228 16#include <stdint.h>
17
18extern const uint8_t OddByteParity[256];
e36b07ef 19extern const uint8_t EvenByteParity[256];
2b1f4228 20
b351374c 21static inline uint8_t oddparity8(uint8_t bt)
22{
23 return OddByteParity[bt];
24}
2b1f4228 25
b351374c 26static inline uint8_t evenparity8(const uint8_t bt)
27{
28 return EvenByteParity[bt];
2b1f4228 29}
30
a531720a 31static inline uint8_t evenparity32(uint32_t x)
2b1f4228 32{
33 x ^= x >> 16;
34 x ^= x >> 8;
35 return EvenByteParity[x & 0xff];
36}
37
e36b07ef 38#ifdef __cplusplus
39}
40#endif
2b1f4228 41
42#endif /* __PARITY_H */
Impressum, Datenschutz