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

Unified Diff: mojo/system/memory.cc

Issue 425523002: Mojo: Convert MemoryTest.Valid to the new user pointer handling (see r285350). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/memory.h ('k') | mojo/system/memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/memory.cc
diff --git a/mojo/system/memory.cc b/mojo/system/memory.cc
index b3cb149baa45f92b19b527579de592025f2a0ea1..9aa0f78c9a508915c41909109f32fd77f3300fa2 100644
--- a/mojo/system/memory.cc
+++ b/mojo/system/memory.cc
@@ -11,7 +11,6 @@
namespace mojo {
namespace system {
-
namespace internal {
template <size_t alignment>
@@ -33,14 +32,6 @@ void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer(const void* pointer) {
CHECK(pointer && IsAligned<alignment>(pointer));
}
-template <size_t size, size_t alignment>
-bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerHelper(const void* pointer) {
- // TODO(vtl): If running in kernel mode, do a full verification. For now, just
- // check that it's non-null and aligned. (A faster user mode implementation is
- // also possible if this check is skipped.)
- return !!pointer && IsAligned<alignment>(pointer);
-}
-
// Explicitly instantiate the sizes we need. Add instantiations as needed.
template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<1, 1>(
const void*);
@@ -48,12 +39,6 @@ template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<4, 4>(
const void*);
template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<8, 8>(
const void*);
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerHelper<1, 1>(
- const void*);
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerHelper<4, 4>(
- const void*);
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerHelper<8, 8>(
- const void*);
// Notwithstanding the comments above about MSVS, whenever we expect an
// alignment of 8 for something of size 4, it's due to an explicit (e.g.,
// #pragma align) alignment specification, which MSVS *does* respect. We want
@@ -64,16 +49,9 @@ void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointer<4, 8>(
const void* pointer) {
CHECK(pointer && reinterpret_cast<uintptr_t>(pointer) % 8 == 0);
}
-template <>
-bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerHelper<4, 8>(
- const void* pointer) {
- return !!pointer && reinterpret_cast<uintptr_t>(pointer) % 8 == 0;
-}
#else
template MOJO_SYSTEM_IMPL_EXPORT void CheckUserPointer<4, 8>(
const void*);
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerHelper<4, 8>(
- const void*);
#endif
template <size_t size, size_t alignment>
@@ -107,42 +85,6 @@ template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointerWithSize<4>(const void*,
template void MOJO_SYSTEM_IMPL_EXPORT CheckUserPointerWithSize<8>(const void*,
size_t);
-template <size_t size, size_t alignment>
-bool VerifyUserPointerWithCountHelper(const void* pointer, size_t count) {
- if (count > std::numeric_limits<size_t>::max() / size)
- return false;
-
- // TODO(vtl): If running in kernel mode, do a full verification. For now, just
- // check that it's non-null and aligned if |count| is nonzero. (A faster user
- // mode implementation is also possible if this check is skipped.)
- return count == 0 || (!!pointer && IsAligned<alignment>(pointer));
-}
-
-// Explicitly instantiate the sizes we need. Add instantiations as needed.
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithCountHelper<1, 1>(
- const void*, size_t);
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithCountHelper<4, 4>(
- const void*, size_t);
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithCountHelper<8, 8>(
- const void*, size_t);
-
} // namespace internal
-
-template <size_t alignment>
-bool VerifyUserPointerWithSize(const void* pointer, size_t size) {
- // TODO(vtl): If running in kernel mode, do a full verification. For now, just
- // check that it's non-null and aligned. (A faster user mode implementation is
- // also possible if this check is skipped.)
- return size == 0 || (!!pointer && internal::IsAligned<alignment>(pointer));
-}
-
-// Explicitly instantiate the alignments we need. Add instantiations as needed.
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithSize<1>(const void*,
- size_t);
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithSize<4>(const void*,
- size_t);
-template bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithSize<8>(const void*,
- size_t);
-
} // namespace system
} // namespace mojo
« no previous file with comments | « mojo/system/memory.h ('k') | mojo/system/memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698