Cleanups
This commit is contained in:
+11
-2
@@ -177,7 +177,8 @@ typedef unsigned __int128 U128;
|
||||
#define CeilDiv(x, y) (((x) + ((y) - 1)) / (y))
|
||||
|
||||
/**
|
||||
* Round x up to nearest multiple of y
|
||||
* Round x up to nearest multiple of y:
|
||||
* (((x) + (y) - 1) - (((x) + (y) - 1) % (y)))
|
||||
* e.g. RoundUp(30,48) == 48
|
||||
* e.g. RoundUp(49,48) == 96
|
||||
*
|
||||
@@ -185,7 +186,15 @@ typedef unsigned __int128 U128;
|
||||
* @param y denominator
|
||||
* @return x rounded up to nearest multiple of y
|
||||
*/
|
||||
#define RoundUpToMultiple(x, y) (CeilDiv((x), (y)) * (y))
|
||||
#define RoundUpToMultiple(x, y) \
|
||||
({ \
|
||||
__typeof__(x) _x = (x); \
|
||||
__typeof__(y) _y = (y); \
|
||||
Assert(_y ! = 0); \
|
||||
__typeof__(x) _tmp = _x + _y - 1; \
|
||||
_tmp - _tmp % _y; \
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* Round x down to nearest multiple of y
|
||||
|
||||
Reference in New Issue
Block a user