| 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 |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 const MemoryMappedFile::Region MemoryMappedFile::Region::kWholeFile( | 13 const MemoryMappedFile::Region MemoryMappedFile::Region::kWholeFile = {0, 0}; |
| 14 base::LINKER_INITIALIZED); | |
| 15 | |
| 16 MemoryMappedFile::Region::Region(base::LinkerInitialized) : offset(0), size(0) { | |
| 17 } | |
| 18 | |
| 19 MemoryMappedFile::Region::Region() : offset(-1), size(-1) { | |
| 20 } | |
| 21 | |
| 22 MemoryMappedFile::Region::Region(int64 offset, int64 size) | |
| 23 : offset(offset), size(size) { | |
| 24 } | |
| 25 | 14 |
| 26 bool MemoryMappedFile::Region::operator==( | 15 bool MemoryMappedFile::Region::operator==( |
| 27 const MemoryMappedFile::Region& other) const { | 16 const MemoryMappedFile::Region& other) const { |
| 28 return other.offset == offset && other.size == size; | 17 return other.offset == offset && other.size == size; |
| 29 } | 18 } |
| 30 | 19 |
| 31 bool MemoryMappedFile::Region::operator!=( | 20 bool MemoryMappedFile::Region::operator!=( |
| 32 const MemoryMappedFile::Region& other) const { | 21 const MemoryMappedFile::Region& other) const { |
| 33 return other.offset != offset || other.size != size; | 22 return other.offset != offset || other.size != size; |
| 34 } | 23 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // 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. |
| 94 const int64 mask = static_cast<int64>(SysInfo::VMAllocationGranularity()) - 1; | 83 const int64 mask = static_cast<int64>(SysInfo::VMAllocationGranularity()) - 1; |
| 95 DCHECK_LT(mask, std::numeric_limits<int32>::max()); | 84 DCHECK_LT(mask, std::numeric_limits<int32>::max()); |
| 96 *offset = start & mask; | 85 *offset = start & mask; |
| 97 *aligned_start = start & ~mask; | 86 *aligned_start = start & ~mask; |
| 98 *aligned_size = (size + *offset + mask) & ~mask; | 87 *aligned_size = (size + *offset + mask) & ~mask; |
| 99 } | 88 } |
| 100 #endif | 89 #endif |
| 101 | 90 |
| 102 } // namespace base | 91 } // namespace base |
| OLD | NEW |