Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project 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 "src/base/platform/semaphore.h" | 5 #include "src/base/platform/semaphore.h" |
| 6 | 6 |
| 7 #if V8_OS_MACOSX | 7 #if V8_OS_MACOSX |
| 8 #include <mach/mach_init.h> | 8 #include <mach/mach_init.h> |
| 9 #include <mach/task.h> | 9 #include <mach/task.h> |
| 10 #endif | 10 #endif |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 #elif V8_OS_POSIX | 74 #elif V8_OS_POSIX |
| 75 | 75 |
| 76 Semaphore::Semaphore(int count) { | 76 Semaphore::Semaphore(int count) { |
| 77 // The sem_init() does not check for alignment of the native handle. | 77 // The sem_init() does not check for alignment of the native handle. |
| 78 // Unaligned native handle can later cause a failure in semaphore signal. | 78 // Unaligned native handle can later cause a failure in semaphore signal. |
| 79 // Check the alignment here to catch the failure earlier. | 79 // Check the alignment here to catch the failure earlier. |
| 80 // Context: crbug.com/605349. | 80 // Context: crbug.com/605349. |
| 81 #if V8_OS_AIX | |
| 82 // On aix sem_t is of type int | |
| 83 const uintptr_t kPointerAlignmentMask = sizeof(int) - 1; | |
|
jochen (gone - plz use gerrit)
2016/05/03 11:03:09
please keep to rename of kPointerAlignmentMask to
| |
| 84 #else | |
| 81 const uintptr_t kPointerAlignmentMask = sizeof(void*) - 1; | 85 const uintptr_t kPointerAlignmentMask = sizeof(void*) - 1; |
| 86 #endif | |
| 82 CHECK_EQ( | 87 CHECK_EQ( |
| 83 0, reinterpret_cast<uintptr_t>(&native_handle_) & kPointerAlignmentMask); | 88 0, reinterpret_cast<uintptr_t>(&native_handle_) & kPointerAlignmentMask); |
| 84 DCHECK(count >= 0); | 89 DCHECK(count >= 0); |
| 85 #if V8_LIBC_GLIBC | 90 #if V8_LIBC_GLIBC |
| 86 // sem_init in glibc prior to 2.1 does not zero out semaphores. | 91 // sem_init in glibc prior to 2.1 does not zero out semaphores. |
| 87 memset(&native_handle_, 0, sizeof(native_handle_)); | 92 memset(&native_handle_, 0, sizeof(native_handle_)); |
| 88 #endif | 93 #endif |
| 89 int result = sem_init(&native_handle_, 0, count); | 94 int result = sem_init(&native_handle_, 0, count); |
| 90 DCHECK_EQ(0, result); | 95 DCHECK_EQ(0, result); |
| 91 USE(result); | 96 USE(result); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 DCHECK(result == WAIT_OBJECT_0); | 213 DCHECK(result == WAIT_OBJECT_0); |
| 209 return true; | 214 return true; |
| 210 } | 215 } |
| 211 } | 216 } |
| 212 } | 217 } |
| 213 | 218 |
| 214 #endif // V8_OS_MACOSX | 219 #endif // V8_OS_MACOSX |
| 215 | 220 |
| 216 } // namespace base | 221 } // namespace base |
| 217 } // namespace v8 | 222 } // namespace v8 |
| OLD | NEW |