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

Side by Side Diff: mojo/edk/system/memory.cc

Issue 728133002: Update mojo sdk to rev e01f9a49449381a5eb430c1fd88bf2cae73ec35a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + ios gyp fixes Created 6 years, 1 month 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
« no previous file with comments | « mojo/edk/system/memory.h ('k') | mojo/edk/system/message_in_transit.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "mojo/edk/system/memory.h" 5 #include "mojo/edk/system/memory.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 // Explicitly instantiate the sizes we need. Add instantiations as needed. 35 // Explicitly instantiate the sizes we need. Add instantiations as needed.
36 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<1, 1>(const void*); 36 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<1, 1>(const void*);
37 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<4, 4>(const void*); 37 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<4, 4>(const void*);
38 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<8, 4>(const void*); 38 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<8, 4>(const void*);
39 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<8, 8>(const void*); 39 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<8, 8>(const void*);
40 40
41 template <size_t size, size_t alignment> 41 template <size_t size, size_t alignment>
42 void MOJO_SYSTEM_IMPL_EXPORT 42 void MOJO_SYSTEM_IMPL_EXPORT
43 CheckUserPointerWithCount(const void* pointer, size_t count) { 43 CheckUserPointerWithCount(const void* pointer, size_t count) {
44 CHECK_LE(count, std::numeric_limits<size_t>::max() / size); 44 CHECK_LE(count, std::numeric_limits<size_t>::max() / size);
45 CHECK(count == 0 || (pointer && IsAligned<alignment>(pointer))); 45 CHECK(count == 0 || (pointer && IsAligned<alignment>(pointer)));
46 } 46 }
47 47
48 // Explicitly instantiate the sizes we need. Add instantiations as needed. 48 // Explicitly instantiate the sizes we need. Add instantiations as needed.
49 template void MOJO_SYSTEM_IMPL_EXPORT 49 template void MOJO_SYSTEM_IMPL_EXPORT
50 CheckUserPointerWithCount<1, 1>(const void*, size_t); 50 CheckUserPointerWithCount<1, 1>(const void*, size_t);
51 template void MOJO_SYSTEM_IMPL_EXPORT 51 template void MOJO_SYSTEM_IMPL_EXPORT
52 CheckUserPointerWithCount<4, 4>(const void*, size_t); 52 CheckUserPointerWithCount<4, 4>(const void*, size_t);
53 template void MOJO_SYSTEM_IMPL_EXPORT 53 template void MOJO_SYSTEM_IMPL_EXPORT
54 CheckUserPointerWithCount<8, 4>(const void*, size_t); 54 CheckUserPointerWithCount<8, 4>(const void*, size_t);
55 template void MOJO_SYSTEM_IMPL_EXPORT 55 template void MOJO_SYSTEM_IMPL_EXPORT
56 CheckUserPointerWithCount<8, 8>(const void*, size_t); 56 CheckUserPointerWithCount<8, 8>(const void*, size_t);
57 57
58 template <size_t alignment> 58 template <size_t alignment>
59 void CheckUserPointerWithSize(const void* pointer, size_t size) { 59 void CheckUserPointerWithSize(const void* pointer, size_t size) {
60 // TODO(vtl): If running in kernel mode, do a full verification. For now, just 60 // TODO(vtl): If running in kernel mode, do a full verification. For now, just
61 // check that it's non-null and aligned. (A faster user mode implementation is 61 // check that it's non-null and aligned. (A faster user mode implementation is
62 // also possible if this check is skipped.) 62 // also possible if this check is skipped.)
63 CHECK(size == 0 || (!!pointer && internal::IsAligned<alignment>(pointer))); 63 CHECK(size == 0 || (!!pointer && internal::IsAligned<alignment>(pointer)));
64 } 64 }
65 65
66 // Explicitly instantiate the sizes we need. Add instantiations as needed. 66 // Explicitly instantiate the sizes we need. Add instantiations as needed.
67 template void MOJO_SYSTEM_IMPL_EXPORT 67 template void MOJO_SYSTEM_IMPL_EXPORT
68 CheckUserPointerWithSize<1>(const void*, size_t); 68 CheckUserPointerWithSize<1>(const void*, size_t);
69 template void MOJO_SYSTEM_IMPL_EXPORT 69 template void MOJO_SYSTEM_IMPL_EXPORT
70 CheckUserPointerWithSize<4>(const void*, size_t); 70 CheckUserPointerWithSize<4>(const void*, size_t);
71 // Whereas the other |Check...()| functions are usually used with integral typs 71 // Whereas the other |Check...()| functions are usually used with integral typs
72 // or arrays of integral types, this one is used with Options structs for which 72 // or arrays of integral types, this one is used with Options structs for which
73 // alignment has been explicitly been specified (using |MOJO_ALIGNAS()|), which 73 // alignment has been explicitly been specified (using |MOJO_ALIGNAS()|), which
74 // MSVS *does* respect. 74 // MSVS *does* respect.
75 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS) 75 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS)
76 template <> 76 template <>
77 void MOJO_SYSTEM_IMPL_EXPORT 77 void MOJO_SYSTEM_IMPL_EXPORT
78 CheckUserPointerWithSize<8>(const void* pointer, size_t size) { 78 CheckUserPointerWithSize<8>(const void* pointer, size_t size) {
79 CHECK(size == 0 || 79 CHECK(size == 0 ||
80 (!!pointer && reinterpret_cast<uintptr_t>(pointer) % 8 == 0)); 80 (!!pointer && reinterpret_cast<uintptr_t>(pointer) % 8 == 0));
81 } 81 }
82 #else 82 #else
83 template void MOJO_SYSTEM_IMPL_EXPORT 83 template void MOJO_SYSTEM_IMPL_EXPORT
84 CheckUserPointerWithSize<8>(const void*, size_t); 84 CheckUserPointerWithSize<8>(const void*, size_t);
85 #endif 85 #endif
86 86
87 } // namespace internal 87 } // namespace internal
88 } // namespace system 88 } // namespace system
89 } // namespace mojo 89 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/memory.h ('k') | mojo/edk/system/message_in_transit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698