| OLD | NEW |
| 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 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 void CheckUserPointerWithCount(const void* pointer, size_t count) { | 33 void CheckUserPointerWithCount(const void* pointer, size_t count) { |
| 34 CHECK_LE(count, std::numeric_limits<size_t>::max() / size); | 34 CHECK_LE(count, std::numeric_limits<size_t>::max() / size); |
| 35 CHECK(count == 0 || (pointer && IsAligned<alignment>(pointer))); | 35 CHECK(count == 0 || (pointer && IsAligned<alignment>(pointer))); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Explicitly instantiate the sizes we need. Add instantiations as needed. | 38 // Explicitly instantiate the sizes we need. Add instantiations as needed. |
| 39 template void CheckUserPointerWithCount<1, 1>(const void*, size_t); | 39 template void CheckUserPointerWithCount<1, 1>(const void*, size_t); |
| 40 template void CheckUserPointerWithCount<4, 4>(const void*, size_t); | 40 template void CheckUserPointerWithCount<4, 4>(const void*, size_t); |
| 41 template void CheckUserPointerWithCount<8, 4>(const void*, size_t); | 41 template void CheckUserPointerWithCount<8, 4>(const void*, size_t); |
| 42 template void CheckUserPointerWithCount<8, 8>(const void*, size_t); | 42 template void CheckUserPointerWithCount<8, 8>(const void*, size_t); |
| 43 template void CheckUserPointerWithCount<24, 8>(const void*, size_t); |
| 43 | 44 |
| 44 template <size_t alignment> | 45 template <size_t alignment> |
| 45 void CheckUserPointerWithSize(const void* pointer, size_t size) { | 46 void CheckUserPointerWithSize(const void* pointer, size_t size) { |
| 46 // TODO(vtl): If running in kernel mode, do a full verification. For now, just | 47 // TODO(vtl): If running in kernel mode, do a full verification. For now, just |
| 47 // check that it's non-null and aligned. (A faster user mode implementation is | 48 // check that it's non-null and aligned. (A faster user mode implementation is |
| 48 // also possible if this check is skipped.) | 49 // also possible if this check is skipped.) |
| 49 CHECK(size == 0 || (!!pointer && internal::IsAligned<alignment>(pointer))); | 50 CHECK(size == 0 || (!!pointer && internal::IsAligned<alignment>(pointer))); |
| 50 } | 51 } |
| 51 | 52 |
| 52 // Explicitly instantiate the sizes we need. Add instantiations as needed. | 53 // Explicitly instantiate the sizes we need. Add instantiations as needed. |
| 53 template void CheckUserPointerWithSize<1>(const void*, size_t); | 54 template void CheckUserPointerWithSize<1>(const void*, size_t); |
| 54 template void CheckUserPointerWithSize<4>(const void*, size_t); | 55 template void CheckUserPointerWithSize<4>(const void*, size_t); |
| 55 template void CheckUserPointerWithSize<8>(const void*, size_t); | 56 template void CheckUserPointerWithSize<8>(const void*, size_t); |
| 56 | 57 |
| 57 } // namespace internal | 58 } // namespace internal |
| 58 } // namespace system | 59 } // namespace system |
| 59 } // namespace mojo | 60 } // namespace mojo |
| OLD | NEW |