OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <fcntl.h> | 7 #include <fcntl.h> |
8 #include <sys/mman.h> | 8 #include <sys/mman.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 | 12 |
| 13 namespace base { |
| 14 |
13 namespace { | 15 namespace { |
14 // Paranoia. Semaphores and shared memory segments should live in different | 16 // Paranoia. Semaphores and shared memory segments should live in different |
15 // namespaces, but who knows what's out there. | 17 // namespaces, but who knows what's out there. |
16 const char kSemaphoreSuffix[] = "-sem"; | 18 const char kSemaphoreSuffix[] = "-sem"; |
17 } | 19 } |
18 | 20 |
19 SharedMemory::SharedMemory() | 21 SharedMemory::SharedMemory() |
20 : mapped_file_(-1), | 22 : mapped_file_(-1), |
21 memory_(NULL), | 23 memory_(NULL), |
22 read_only_(false), | 24 read_only_(false), |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void SharedMemory::Lock() { | 161 void SharedMemory::Lock() { |
160 DCHECK(lock_ != NULL); | 162 DCHECK(lock_ != NULL); |
161 sem_wait(lock_); | 163 sem_wait(lock_); |
162 } | 164 } |
163 | 165 |
164 void SharedMemory::Unlock() { | 166 void SharedMemory::Unlock() { |
165 DCHECK(lock_ != NULL); | 167 DCHECK(lock_ != NULL); |
166 sem_post(lock_); | 168 sem_post(lock_); |
167 } | 169 } |
168 | 170 |
| 171 } // namespace base |
OLD | NEW |