Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: base/shared_memory_nacl.cc

Issue 10827400: Advertise a minimum alignment for SharedMemory::Map(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename enum. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/shared_memory.h ('k') | base/shared_memory_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shared_memory.h" 5 #include "base/shared_memory.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 bool SharedMemory::Map(uint32 bytes) { 85 bool SharedMemory::Map(uint32 bytes) {
86 if (mapped_file_ == -1) 86 if (mapped_file_ == -1)
87 return false; 87 return false;
88 88
89 memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE), 89 memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE),
90 MAP_SHARED, mapped_file_, 0); 90 MAP_SHARED, mapped_file_, 0);
91 91
92 bool mmap_succeeded = memory_ != MAP_FAILED && memory_ != NULL; 92 bool mmap_succeeded = memory_ != MAP_FAILED && memory_ != NULL;
93 if (mmap_succeeded) 93 if (mmap_succeeded) {
94 mapped_size_ = bytes; 94 mapped_size_ = bytes;
95 else 95 DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) &
96 (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
97 } else {
96 memory_ = NULL; 98 memory_ = NULL;
99 }
97 100
98 return mmap_succeeded; 101 return mmap_succeeded;
99 } 102 }
100 103
101 bool SharedMemory::Unmap() { 104 bool SharedMemory::Unmap() {
102 if (memory_ == NULL) 105 if (memory_ == NULL)
103 return false; 106 return false;
104 107
105 if (munmap(memory_, mapped_size_) < 0) 108 if (munmap(memory_, mapped_size_) < 0)
106 DPLOG(ERROR) << "munmap"; 109 DPLOG(ERROR) << "munmap";
(...skipping 24 matching lines...) Expand all
131 NOTIMPLEMENTED(); 134 NOTIMPLEMENTED();
132 } 135 }
133 136
134 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, 137 bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
135 SharedMemoryHandle *new_handle, 138 SharedMemoryHandle *new_handle,
136 bool close_self) { 139 bool close_self) {
137 return false; 140 return false;
138 } 141 }
139 142
140 } // namespace base 143 } // namespace base
OLDNEW
« no previous file with comments | « base/shared_memory.h ('k') | base/shared_memory_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698