Index: base/bits.h |
diff --git a/base/bits.h b/base/bits.h |
index b2209e8ed7934a6dfc918c3d7d12b9c455f594e1..505d2c8f75d901688186ed2e1f981b3a9a2562bc 100644 |
--- a/base/bits.h |
+++ b/base/bits.h |
@@ -41,6 +41,12 @@ inline int Log2Ceiling(uint32 n) { |
} |
} |
+// Round up |size| to a multiple of alignment, which must be a power of two. |
+inline size_t Align(size_t size, size_t alignment) { |
+ DCHECK_EQ(alignment & (alignment - 1), 0u); |
+ return (size + alignment - 1) & ~(alignment - 1); |
+} |
+ |
} // namespace bits |
} // namespace base |