Fix potential overflow when we're nearing 4G blocks..
This commit is contained in:
+4
-3
@@ -104,11 +104,12 @@ typedef unsigned __int128 U128;
|
||||
(const type *)((const void *)(const unsigned char *)__mptr - offsetof(const type, member)); \
|
||||
})
|
||||
|
||||
#define AlignUpPow2(val, align) (((val) + (align) - 1UL) & ~((align) - 1UL))
|
||||
#define AlignDownPow2(val, align) ((val) & ~((align) - 1UL))
|
||||
// align needs to be pow2
|
||||
#define AlignUp(val, align) (((val) + (align) - 1UL) & ~((align) - 1UL))
|
||||
#define AlignDown(val, align) ((val) & ~((align) - 1UL))
|
||||
#define IsPow2(x) ((x) && !((x) & ((x) - 1UL)))
|
||||
#define IsPow2OrZero(x) (!((x) & ((x) - 1UL)))
|
||||
#define IsAlignedToPow2(x, y) (IsPow2(y) && !((x) & ((y) - 1UL)))
|
||||
#define IsAlignedTo(x, align) (IsPow2(align) && !((x) & ((align) - 1UL)))
|
||||
|
||||
#define GetBit(val, idx) (((val) >> (idx)) & 1)
|
||||
// Get n_bits starting at idx going left
|
||||
|
||||
Reference in New Issue
Block a user