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

Side by Side Diff: src/base/platform/semaphore.cc

Issue 2321473002: Merged: Remove semaphore alignment check for posix platform. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (result == KERN_SUCCESS) return true; // Semaphore was signalled. 66 if (result == KERN_SUCCESS) return true; // Semaphore was signalled.
67 if (result == KERN_OPERATION_TIMED_OUT) return false; // Timeout. 67 if (result == KERN_OPERATION_TIMED_OUT) return false; // Timeout.
68 DCHECK_EQ(KERN_ABORTED, result); 68 DCHECK_EQ(KERN_ABORTED, result);
69 now = TimeTicks::Now(); 69 now = TimeTicks::Now();
70 } 70 }
71 } 71 }
72 72
73 #elif V8_OS_POSIX 73 #elif V8_OS_POSIX
74 74
75 Semaphore::Semaphore(int count) { 75 Semaphore::Semaphore(int count) {
76 // The sem_init() does not check for alignment of the native handle.
77 // Unaligned native handle can later cause a failure in semaphore signal.
78 // Check the alignment here to catch the failure earlier.
79 // Context: crbug.com/605349.
80 #if V8_OS_AIX || V8_OS_FREEBSD
81 // On aix sem_t is of type int. On FreeBSD, it's a struct of 32 bits fields.
82 const uintptr_t kSemaphoreAlignmentMask = sizeof(int) - 1;
83 #else
84 const uintptr_t kSemaphoreAlignmentMask = sizeof(void*) - 1;
85 #endif
86 CHECK_EQ(
87 0, reinterpret_cast<uintptr_t>(&native_handle_) &
88 kSemaphoreAlignmentMask);
89 DCHECK(count >= 0); 76 DCHECK(count >= 0);
90 int result = sem_init(&native_handle_, 0, count); 77 int result = sem_init(&native_handle_, 0, count);
91 DCHECK_EQ(0, result); 78 DCHECK_EQ(0, result);
92 USE(result); 79 USE(result);
93 } 80 }
94 81
95 82
96 Semaphore::~Semaphore() { 83 Semaphore::~Semaphore() {
97 int result = sem_destroy(&native_handle_); 84 int result = sem_destroy(&native_handle_);
98 DCHECK_EQ(0, result); 85 DCHECK_EQ(0, result);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 DCHECK(result == WAIT_OBJECT_0); 183 DCHECK(result == WAIT_OBJECT_0);
197 return true; 184 return true;
198 } 185 }
199 } 186 }
200 } 187 }
201 188
202 #endif // V8_OS_MACOSX 189 #endif // V8_OS_MACOSX
203 190
204 } // namespace base 191 } // namespace base
205 } // namespace v8 192 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698