mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[wpiutil] Fix compilation of MathExtras.h on Windows with /sdl (#5809)
Fix copied from the LLVM main branch.
This commit is contained in:
@@ -356,7 +356,10 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align) {
|
||||
inline uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align) {
|
||||
assert(Align != 0 && (Align & (Align - 1)) == 0 &&
|
||||
"Align must be a power of 2");
|
||||
return (Value + Align - 1) & -Align;
|
||||
// Replace unary minus to avoid compilation error on Windows:
|
||||
// "unary minus operator applied to unsigned type, result still unsigned"
|
||||
uint64_t negAlign = (~Align) + 1;
|
||||
return (Value + Align - 1) & negAlign;
|
||||
}
|
||||
|
||||
/// If non-zero \p Skew is specified, the return value will be a minimal integer
|
||||
|
||||
Reference in New Issue
Block a user