| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 80 #if V8_OS_AIX | 80 #if V8_OS_AIX | 
| 81   // On aix sem_t is of type int | 81   // On aix sem_t is of type int | 
| 82   const uintptr_t kSemaphoreAlignmentMask = sizeof(int) - 1; | 82   const uintptr_t kSemaphoreAlignmentMask = sizeof(int) - 1; | 
| 83 #else | 83 #else | 
| 84   const uintptr_t kSemaphoreAlignmentMask = sizeof(void*) - 1; | 84   const uintptr_t kSemaphoreAlignmentMask = sizeof(void*) - 1; | 
| 85 #endif | 85 #endif | 
| 86   CHECK_EQ( | 86   CHECK_EQ( | 
| 87       0, reinterpret_cast<uintptr_t>(&native_handle_) & | 87       0, reinterpret_cast<uintptr_t>(&native_handle_) & | 
| 88       kSemaphoreAlignmentMask); | 88       kSemaphoreAlignmentMask); | 
| 89   DCHECK(count >= 0); | 89   DCHECK(count >= 0); | 
| 90 #if V8_LIBC_GLIBC |  | 
| 91   // sem_init in glibc prior to 2.1 does not zero out semaphores. |  | 
| 92   memset(&native_handle_, 0, sizeof(native_handle_)); |  | 
| 93 #endif |  | 
| 94   int result = sem_init(&native_handle_, 0, count); | 90   int result = sem_init(&native_handle_, 0, count); | 
| 95   DCHECK_EQ(0, result); | 91   DCHECK_EQ(0, result); | 
| 96   USE(result); | 92   USE(result); | 
| 97 } | 93 } | 
| 98 | 94 | 
| 99 | 95 | 
| 100 Semaphore::~Semaphore() { | 96 Semaphore::~Semaphore() { | 
| 101   int result = sem_destroy(&native_handle_); | 97   int result = sem_destroy(&native_handle_); | 
| 102   DCHECK_EQ(0, result); | 98   DCHECK_EQ(0, result); | 
| 103   USE(result); | 99   USE(result); | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 209       DCHECK(result == WAIT_OBJECT_0); | 205       DCHECK(result == WAIT_OBJECT_0); | 
| 210       return true; | 206       return true; | 
| 211     } | 207     } | 
| 212   } | 208   } | 
| 213 } | 209 } | 
| 214 | 210 | 
| 215 #endif  // V8_OS_MACOSX | 211 #endif  // V8_OS_MACOSX | 
| 216 | 212 | 
| 217 }  // namespace base | 213 }  // namespace base | 
| 218 }  // namespace v8 | 214 }  // namespace v8 | 
| OLD | NEW | 
|---|