Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libutils: util.h: Relax ROUNDDOWN() and add ROUNDDOWN2()
Remove constraint on ROUNDDOWN() to have its size argument being a power of 2 and add new ROUNDDOWN2() macro with that constraint. The previous implementation of ROUNDDOWN(), optimized for when size argument is a power of 2, is now used for ROUNDDOWN2() but this latter also asserts (in debug build mode) that the size argument conforms to this condition. The new implementation of ROUNDDOWN() is less optimal but modern compilers produce the same optimized assembly code with this macro when the size argument is a constant value known from the compiler so all use of ROUNDDOWN() with a known constant value do not need move to ROUNDDOWN2(). Performance sensitive routines should now on use ROUNDDOWN2() to leverage the power-of-2 rounding optimization. Signed-off-by: Etienne Carriere <[email protected]> Reviewed-by: Jens Wiklander <[email protected]>
- Loading branch information