added @pwpiwi 's latest changes to "hf mf hardnested"

This commit is contained in:
iceman1001
2016-01-03 17:16:50 +01:00
parent 58962d4c3e
commit a531720ae6
4 changed files with 226 additions and 153 deletions

View File

@@ -21,14 +21,20 @@
#include <stdlib.h>
#if !defined LOWMEM && defined __GNUC__
static uint8_t filterlut[1 << 20];
uint8_t filterlut[1 << 20];
static void __attribute__((constructor)) fill_lut()
{
uint32_t i;
for(i = 0; i < 1 << 20; ++i)
filterlut[i] = filter(i);
uint32_t x;
uint32_t f;
for(x = 0; x < 1 << 20; ++x) {
f = 0xf22c0 >> (x & 0xf) & 16;
f |= 0x6c9c0 >> (x >> 4 & 0xf) & 8;
f |= 0x3c8b0 >> (x >> 8 & 0xf) & 4;
f |= 0x1e458 >> (x >> 12 & 0xf) & 2;
f |= 0x0d938 >> (x >> 16 & 0xf) & 1;
filterlut[x] = BIT(0xEC57E80A, f);
}
}
#define filter(x) (filterlut[(x) & 0xfffff])
#endif

View File

@@ -80,6 +80,12 @@ static inline int parity(uint32_t x)
return x;
#endif
}
#if !defined LOWMEM && defined __GNUC__
extern uint8_t filterlut[1 << 20];
#define filter(x) (filterlut[(x) & 0xfffff])
#define filter_unsafe(x) (filterlut[x])
#else
static inline int filter(uint32_t const x)
{
uint32_t f;
@@ -91,6 +97,9 @@ static inline int filter(uint32_t const x)
f |= 0x0d938 >> (x >> 16 & 0xf) & 1;
return BIT(0xEC57E80A, f);
}
#define filter_unsafe(x) (filter(x))
#endif
#ifdef __cplusplus
}
#endif