Index: mojo/public/cpp/bindings/lib/bindings_serialization.cc |
diff --git a/mojo/public/cpp/bindings/lib/bindings_serialization.cc b/mojo/public/cpp/bindings/lib/bindings_serialization.cc |
index fc574d77e7ed5bce951a37dd3183c1aeb6d921e2..5e60c65a5c4b52e8e89a46b36ab368958d2c6696 100644 |
--- a/mojo/public/cpp/bindings/lib/bindings_serialization.cc |
+++ b/mojo/public/cpp/bindings/lib/bindings_serialization.cc |
@@ -11,9 +11,22 @@ |
namespace mojo { |
namespace internal { |
-size_t Align(size_t size) { |
+namespace { |
+ |
+template<typename T> |
+T AlignImpl(T t) { |
const size_t kAlignment = 8; |
- return size + (kAlignment - (size % kAlignment)) % kAlignment; |
+ return t + (kAlignment - (t % kAlignment)) % kAlignment; |
+} |
+ |
+} // namespace |
+ |
+size_t Align(size_t size) { |
+ return AlignImpl(size); |
+} |
+ |
+char* AlignPointer(char* ptr) { |
+ return reinterpret_cast<char*>(AlignImpl(reinterpret_cast<uintptr_t>(ptr))); |
} |
void EncodePointer(const void* ptr, uint64_t* offset) { |