Index: mojo/system/memory.cc |
diff --git a/mojo/system/memory.cc b/mojo/system/memory.cc |
index 6199902bf9d1dece3258ac887fedda8249d503ae..dd8b3d2334ada19a88fbf647a0974a260c0383ba 100644 |
--- a/mojo/system/memory.cc |
+++ b/mojo/system/memory.cc |
@@ -11,62 +11,24 @@ |
namespace mojo { |
namespace system { |
-namespace internal { |
- |
-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 && reinterpret_cast<uintptr_t>(pointer) % alignment == 0; |
-} |
- |
-// Explicitly instantiate the sizes we need. Add instantiations as needed. |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerHelper<1, 1>( |
- const void*); |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerHelper<4, 4>( |
- const void*); |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerHelper<8, 8>( |
- const void*); |
- |
-template <size_t size, size_t alignment> |
-bool VerifyUserPointerWithCountHelper(const void* pointer, size_t count) { |
+template <size_t size> |
+bool VerifyUserPointerForSize(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 && reinterpret_cast<uintptr_t>(pointer) % alignment == 0); |
+ // check that it's non-null if |size| is nonzero. (A faster user mode |
+ // implementation is also possible if this check is skipped.) |
+ return count == 0 || !!pointer; |
} |
// Explicitly instantiate the sizes we need. Add instantiations as needed. |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerWithCountHelper<1, 1>( |
+template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerForSize<1>( |
const void*, size_t); |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerWithCountHelper<4, 4>( |
+template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerForSize<4>( |
const void*, size_t); |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerWithCountHelper<8, 8>( |
+template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerForSize<8>( |
const void*, size_t); |
- |
-} // nameespace 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 && reinterpret_cast<uintptr_t>(pointer) % alignment == 0); |
-} |
- |
-// Explicitly instantiate the alignments we need. Add instantiations as needed. |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerWithSize<1>(const void*, |
- size_t); |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerWithSize<4>(const void*, |
- size_t); |
-template MOJO_SYSTEM_IMPL_EXPORT bool VerifyUserPointerWithSize<8>(const void*, |
- size_t); |
} // namespace system |
} // namespace mojo |