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

Side by Side Diff: base/shared_memory_posix.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_nacl.cc ('k') | base/shared_memory_unittest.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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // transport_dib_android.cc. We should use ashmem_get_size_region() 233 // transport_dib_android.cc. We should use ashmem_get_size_region()
234 // in transport_dib_android.cc. 234 // in transport_dib_android.cc.
235 created_size_ = bytes; 235 created_size_ = bytes;
236 } 236 }
237 #endif 237 #endif
238 238
239 memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE), 239 memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE),
240 MAP_SHARED, mapped_file_, 0); 240 MAP_SHARED, mapped_file_, 0);
241 241
242 bool mmap_succeeded = memory_ != (void*)-1 && memory_ != NULL; 242 bool mmap_succeeded = memory_ != (void*)-1 && memory_ != NULL;
243 if (mmap_succeeded) 243 if (mmap_succeeded) {
244 mapped_size_ = bytes; 244 mapped_size_ = bytes;
245 else 245 DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) &
246 (SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
247 } else {
246 memory_ = NULL; 248 memory_ = NULL;
249 }
247 250
248 return mmap_succeeded; 251 return mmap_succeeded;
249 } 252 }
250 253
251 bool SharedMemory::Unmap() { 254 bool SharedMemory::Unmap() {
252 if (memory_ == NULL) 255 if (memory_ == NULL)
253 return false; 256 return false;
254 257
255 munmap(memory_, mapped_size_); 258 munmap(memory_, mapped_size_);
256 memory_ = NULL; 259 memory_ = NULL;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 new_handle->fd = new_fd; 370 new_handle->fd = new_fd;
368 new_handle->auto_close = true; 371 new_handle->auto_close = true;
369 372
370 if (close_self) 373 if (close_self)
371 Close(); 374 Close();
372 375
373 return true; 376 return true;
374 } 377 }
375 378
376 } // namespace base 379 } // namespace base
OLDNEW
« no previous file with comments | « base/shared_memory_nacl.cc ('k') | base/shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698