Add MOD to match mod with powers of 2
This commit is contained in:
@@ -85,6 +85,12 @@
|
||||
#define SAFE_DIV(a, b) ((a) / (b))
|
||||
#endif
|
||||
|
||||
// The below macro does a%n, but (to match) will switch to a&(n-1) if n is a power of 2.
|
||||
// There are cases where GF does a&(n-1) where we would really like to have a%n, because
|
||||
// if n is changed to a value that isn't a power of 2 then a&(n-1) is unlikely to work as
|
||||
// intended, and a%n for powers of 2 isn't always optimized to use &.
|
||||
#define MOD(a, n)(((n) & ((n)-1)) ? ((a) % (n)) : ((a) & ((n)-1)))
|
||||
|
||||
// Extracts the upper 16 bits of a 32-bit number
|
||||
#define HIHALF(n) (((n) & 0xFFFF0000) >> 16)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user