]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - common/parity.h
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
5 //-----------------------------------------------------------------------------
6 // Generic CRC calculation code.
7 //-----------------------------------------------------------------------------
14 extern const uint8_t OddByteParity
[256];
16 #define oddparity8(x) (OddByteParity[(x)])
19 extern const uint8_t EvenByteParity
[256];
21 static inline bool /*__attribute__((always_inline))*/ evenparity8(const uint8_t x
) {
22 #if !defined __i386__ || !defined __GNUC__
23 return EvenByteParity
[x
];
26 __asm( "testb $255, %1\n"
27 "setpo %0\n" : "=r"(y
) : "r"(x
): );
33 static inline uint8_t evenparity32(uint32_t x
)
37 return EvenByteParity
[x
& 0xff];
41 #endif /* __PARITY_H */