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( |
| 14 base::LINKER_INITIALIZED); |
14 | 15 |
15 MemoryMappedFile::Region::Region() : offset(0), size(0) { | 16 MemoryMappedFile::Region::Region(base::LinkerInitialized) : offset(0), size(0) { |
16 } | 17 } |
17 | 18 |
18 MemoryMappedFile::Region::Region(int64 offset, int64 size) | 19 MemoryMappedFile::Region::Region(int64 offset, int64 size) |
19 : offset(offset), size(size) { | 20 : offset(offset), size(size) { |
20 DCHECK_GE(offset, 0); | 21 DCHECK_GE(offset, 0); |
21 DCHECK_GT(size, 0); | 22 DCHECK_GT(size, 0); |
22 } | 23 } |
23 | 24 |
24 bool MemoryMappedFile::Region::operator==( | 25 bool MemoryMappedFile::Region::operator==( |
25 const MemoryMappedFile::Region& other) const { | 26 const MemoryMappedFile::Region& other) const { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 int32* offset) { | 80 int32* offset) { |
80 // Sadly, on Windows, the mmap alignment is not just equal to the page size. | 81 // Sadly, on Windows, the mmap alignment is not just equal to the page size. |
81 const int64 mask = static_cast<int64>(SysInfo::VMAllocationGranularity()) - 1; | 82 const int64 mask = static_cast<int64>(SysInfo::VMAllocationGranularity()) - 1; |
82 DCHECK_LT(mask, std::numeric_limits<int32>::max()); | 83 DCHECK_LT(mask, std::numeric_limits<int32>::max()); |
83 *offset = start & mask; | 84 *offset = start & mask; |
84 *aligned_start = start & ~mask; | 85 *aligned_start = start & ~mask; |
85 *aligned_size = (size + *offset + mask) & ~mask; | 86 *aligned_size = (size + *offset + mask) & ~mask; |
86 } | 87 } |
87 | 88 |
88 } // namespace base | 89 } // namespace base |
OLD | NEW |