Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: mojo/public/cpp/bindings/lib/bindings_serialization.h

Issue 265403003: Make sure that ScratchBuffer::Allocate() always return 8-byte aligned address. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix on-stack allocation alignment. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "mojo/public/cpp/bindings/buffer.h" 10 #include "mojo/public/cpp/bindings/buffer.h"
11 #include "mojo/public/cpp/bindings/message.h" 11 #include "mojo/public/cpp/bindings/message.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace internal { 14 namespace internal {
15 15
16 size_t Align(size_t size); 16 size_t Align(size_t size);
17 char* AlignPointer(char* ptr);
17 18
18 // Pointers are encoded as relative offsets. The offsets are relative to the 19 // Pointers are encoded as relative offsets. The offsets are relative to the
19 // address of where the offset value is stored, such that the pointer may be 20 // address of where the offset value is stored, such that the pointer may be
20 // recovered with the expression: 21 // recovered with the expression:
21 // 22 //
22 // ptr = reinterpret_cast<char*>(offset) + *offset 23 // ptr = reinterpret_cast<char*>(offset) + *offset
23 // 24 //
24 // A null pointer is encoded as an offset value of 0. 25 // A null pointer is encoded as an offset value of 0.
25 // 26 //
26 void EncodePointer(const void* ptr, uint64_t* offset); 27 void EncodePointer(const void* ptr, uint64_t* offset);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!obj->ptr->DecodePointersAndHandles(message)) 59 if (!obj->ptr->DecodePointersAndHandles(message))
59 return false; 60 return false;
60 } 61 }
61 return true; 62 return true;
62 } 63 }
63 64
64 } // namespace internal 65 } // namespace internal
65 } // namespace mojo 66 } // namespace mojo
66 67
67 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_ 68 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDINGS_SERIALIZATION_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/bindings_serialization.cc » ('j') | mojo/public/cpp/bindings/lib/scratch_buffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698