Chromium Code Reviews| Index: src/IceUtils.h |
| diff --git a/src/IceUtils.h b/src/IceUtils.h |
| index 50a115bf7bbc5ff4ef50b4f60756151ae41f55e5..75855bda53131cebb705d75a4e95277829e64944 100644 |
| --- a/src/IceUtils.h |
| +++ b/src/IceUtils.h |
| @@ -53,6 +53,14 @@ public: |
| return ((X > 0 && Y > 0 && (X > std::numeric_limits<T>::max() - Y)) || |
| (X < 0 && Y < 0 && (X < std::numeric_limits<T>::min() - Y))); |
| } |
| + |
| + static inline uint64_t OffsetToAlignment(uint64_t Pos, uint64_t Align) { |
| + assert(llvm::isPowerOf2_32(Align)); |
|
Jim Stichnoth
2015/01/28 20:35:08
isPowerOf2_64 ?
jvoung (off chromium)
2015/01/28 23:37:53
Done.
|
| + uint64_t Mod = Pos & (Align - 1); |
| + if (Mod == 0) |
| + return 0; |
| + return Align - Mod; |
| + } |
| }; |
| // BoundedProducerConsumerQueue is a work queue that allows multiple |