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

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

Issue 2268993002: FreeBSD: Fix semaphore alignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 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. 77 // Unaligned native handle can later cause a failure in semaphore signal.
78 // Check the alignment here to catch the failure earlier. 78 // Check the alignment here to catch the failure earlier.
79 // Context: crbug.com/605349. 79 // Context: crbug.com/605349.
80 #if V8_OS_AIX 80 #if V8_OS_AIX || V8_OS_FREEBSD
81 // On aix sem_t is of type int 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; 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 int result = sem_init(&native_handle_, 0, count); 90 int result = sem_init(&native_handle_, 0, count);
91 DCHECK_EQ(0, result); 91 DCHECK_EQ(0, result);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 DCHECK(result == WAIT_OBJECT_0); 196 DCHECK(result == WAIT_OBJECT_0);
197 return true; 197 return true;
198 } 198 }
199 } 199 }
200 } 200 }
201 201
202 #endif // V8_OS_MACOSX 202 #endif // V8_OS_MACOSX
203 203
204 } // namespace base 204 } // namespace base
205 } // namespace v8 205 } // 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