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

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

Issue 454603002: Mojo: Plumb new Wait/WaitMany API out to Core. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 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
« no previous file with comments | « mojo/system/entrypoints.cc ('k') | no next file » | 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/system/memory.h" 5 #include "mojo/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 17 matching lines...) Expand all
28 #endif 28 #endif
29 29
30 template <size_t size, size_t alignment> 30 template <size_t size, size_t alignment>
31 void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer(const void* pointer) { 31 void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer(const void* pointer) {
32 CHECK(pointer && IsAligned<alignment>(pointer)); 32 CHECK(pointer && IsAligned<alignment>(pointer));
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, 8>(const void*); 39 template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<8, 8>(const void*);
39 40
40 template <size_t size, size_t alignment> 41 template <size_t size, size_t alignment>
41 void MOJO_SYSTEM_IMPL_EXPORT 42 void MOJO_SYSTEM_IMPL_EXPORT
42 CheckUserPointerWithCount(const void* pointer, size_t count) { 43 CheckUserPointerWithCount(const void* pointer, size_t count) {
43 CHECK_LE(count, std::numeric_limits<size_t>::max() / size); 44 CHECK_LE(count, std::numeric_limits<size_t>::max() / size);
44 CHECK(count == 0 || (pointer && IsAligned<alignment>(pointer))); 45 CHECK(count == 0 || (pointer && IsAligned<alignment>(pointer)));
45 } 46 }
46 47
47 // Explicitly instantiate the sizes we need. Add instantiations as needed. 48 // Explicitly instantiate the sizes we need. Add instantiations as needed.
48 template void MOJO_SYSTEM_IMPL_EXPORT 49 template void MOJO_SYSTEM_IMPL_EXPORT
49 CheckUserPointerWithCount<1, 1>(const void*, size_t); 50 CheckUserPointerWithCount<1, 1>(const void*, size_t);
50 template void MOJO_SYSTEM_IMPL_EXPORT 51 template void MOJO_SYSTEM_IMPL_EXPORT
51 CheckUserPointerWithCount<4, 4>(const void*, size_t); 52 CheckUserPointerWithCount<4, 4>(const void*, size_t);
52 template void MOJO_SYSTEM_IMPL_EXPORT 53 template void MOJO_SYSTEM_IMPL_EXPORT
54 CheckUserPointerWithCount<8, 4>(const void*, size_t);
55 template void MOJO_SYSTEM_IMPL_EXPORT
53 CheckUserPointerWithCount<8, 8>(const void*, size_t); 56 CheckUserPointerWithCount<8, 8>(const void*, size_t);
54 57
55 template <size_t alignment> 58 template <size_t alignment>
56 void CheckUserPointerWithSize(const void* pointer, size_t size) { 59 void CheckUserPointerWithSize(const void* pointer, size_t size) {
57 // 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
58 // 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
59 // also possible if this check is skipped.) 62 // also possible if this check is skipped.)
60 CHECK(size == 0 || (!!pointer && internal::IsAligned<alignment>(pointer))); 63 CHECK(size == 0 || (!!pointer && internal::IsAligned<alignment>(pointer)));
61 } 64 }
62 65
(...skipping 14 matching lines...) Expand all
77 (!!pointer && reinterpret_cast<uintptr_t>(pointer) % 8 == 0)); 80 (!!pointer && reinterpret_cast<uintptr_t>(pointer) % 8 == 0));
78 } 81 }
79 #else 82 #else
80 template void MOJO_SYSTEM_IMPL_EXPORT 83 template void MOJO_SYSTEM_IMPL_EXPORT
81 CheckUserPointerWithSize<8>(const void*, size_t); 84 CheckUserPointerWithSize<8>(const void*, size_t);
82 #endif 85 #endif
83 86
84 } // namespace internal 87 } // namespace internal
85 } // namespace system 88 } // namespace system
86 } // namespace mojo 89 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/entrypoints.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698