use partiy.h and textual

This commit is contained in:
iceman1001 2021-07-14 15:01:01 +02:00
commit e5fc1d83b2
2 changed files with 32 additions and 24 deletions

View file

@ -23,6 +23,24 @@ static inline uint8_t evenparity8(const uint8_t x) {
return !OddByteParity[x];
}
static inline uint8_t evenparity16(uint16_t x) {
#if !defined __GNUC__
x ^= x >> 8;
return evenparity8(x);
#else
return (__builtin_parity(x) & 0xFF);
#endif
}
static inline uint8_t oddparity16(uint16_t x) {
#if !defined __GNUC__
x ^= x >> 8;
return oddparity8(x);
#else
return !__builtin_parity(x);
#endif
}
static inline uint8_t evenparity32(uint32_t x) {
#if !defined __GNUC__
x ^= x >> 16;