mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
refactory parity files a bit
This commit is contained in:
parent
61c9252e15
commit
0942ce7a68
8 changed files with 30 additions and 76 deletions
|
@ -23,20 +23,42 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
extern const uint8_t g_OddByteParity[256];
|
||||
static const uint8_t g_odd_byte_parity[256] = {
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
|
||||
};
|
||||
|
||||
//extern const uint8_t OddByteParity[256];
|
||||
|
||||
#define ODD_PARITY8(x) { g_odd_byte_parity[x] }
|
||||
#define EVEN_PARITY8(x) { !g_odd_byte_parity[x] }
|
||||
|
||||
static inline uint8_t oddparity8(const uint8_t x) {
|
||||
return g_OddByteParity[x];
|
||||
return g_odd_byte_parity[x];
|
||||
}
|
||||
|
||||
static inline uint8_t evenparity8(const uint8_t x) {
|
||||
return !g_OddByteParity[x];
|
||||
return !g_odd_byte_parity[x];
|
||||
}
|
||||
|
||||
static inline uint8_t evenparity16(uint16_t x) {
|
||||
#if !defined __GNUC__
|
||||
x ^= x >> 8;
|
||||
return evenparity8(x);
|
||||
return EVEN_PARITY8(x) ;
|
||||
#else
|
||||
return (__builtin_parity(x) & 0xFF);
|
||||
#endif
|
||||
|
@ -45,7 +67,7 @@ static inline uint8_t evenparity16(uint16_t x) {
|
|||
static inline uint8_t oddparity16(uint16_t x) {
|
||||
#if !defined __GNUC__
|
||||
x ^= x >> 8;
|
||||
return oddparity8(x);
|
||||
return ODD_PARITY8(x);
|
||||
#else
|
||||
return !__builtin_parity(x);
|
||||
#endif
|
||||
|
@ -55,7 +77,7 @@ static inline uint8_t evenparity32(uint32_t x) {
|
|||
#if !defined __GNUC__
|
||||
x ^= x >> 16;
|
||||
x ^= x >> 8;
|
||||
return evenparity8(x);
|
||||
return EVEN_PARITY8(x);
|
||||
#else
|
||||
return (__builtin_parity(x) & 0xFF);
|
||||
#endif
|
||||
|
@ -65,7 +87,7 @@ static inline uint8_t oddparity32(uint32_t x) {
|
|||
#if !defined __GNUC__
|
||||
x ^= x >> 16;
|
||||
x ^= x >> 8;
|
||||
return oddparity8(x);
|
||||
return ODD_PARITY8(x);
|
||||
#else
|
||||
return !__builtin_parity(x);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue