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 "base/files/memory_mapped_file.h" | 5 #include "base/files/memory_mapped_file.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 return true; | 69 return true; |
70 } | 70 } |
71 | 71 |
72 bool MemoryMappedFile::IsValid() const { | 72 bool MemoryMappedFile::IsValid() const { |
73 return data_ != NULL; | 73 return data_ != NULL; |
74 } | 74 } |
75 | 75 |
76 // static | 76 // static |
77 void MemoryMappedFile::CalculateVMAlignedBoundaries(int64 start, | 77 void MemoryMappedFile::CalculateVMAlignedBoundaries(int64_t start, |
78 int64 size, | 78 int64_t size, |
79 int64* aligned_start, | 79 int64_t* aligned_start, |
80 int64* aligned_size, | 80 int64_t* aligned_size, |
81 int32* offset) { | 81 int32_t* offset) { |
82 // Sadly, on Windows, the mmap alignment is not just equal to the page size. | 82 // Sadly, on Windows, the mmap alignment is not just equal to the page size. |
83 const int64 mask = static_cast<int64>(SysInfo::VMAllocationGranularity()) - 1; | 83 const int64_t mask = |
84 DCHECK_LT(mask, std::numeric_limits<int32>::max()); | 84 static_cast<int64_t>(SysInfo::VMAllocationGranularity()) - 1; |
| 85 DCHECK_LT(mask, std::numeric_limits<int32_t>::max()); |
85 *offset = start & mask; | 86 *offset = start & mask; |
86 *aligned_start = start & ~mask; | 87 *aligned_start = start & ~mask; |
87 *aligned_size = (size + *offset + mask) & ~mask; | 88 *aligned_size = (size + *offset + mask) & ~mask; |
88 } | 89 } |
89 #endif | 90 #endif |
90 | 91 |
91 } // namespace base | 92 } // namespace base |
OLD | NEW |