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

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

Issue 1936003002: AIX:Proposal to use kSemaphoreAlignmentMask instead kPointerAlignmentMask (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« src/base/platform/semaphore.h ('K') | « src/base/platform/semaphore.h ('k') | 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const uintptr_t kPointerAlignmentMask = sizeof(void*) - 1;
82 CHECK_EQ( 81 CHECK_EQ(
83 0, reinterpret_cast<uintptr_t>(&native_handle_) & kPointerAlignmentMask); 82 0, reinterpret_cast<uintptr_t>(&native_handle_) & kSemaphoreAlignmentMask);
84 DCHECK(count >= 0); 83 DCHECK(count >= 0);
85 #if V8_LIBC_GLIBC 84 #if V8_LIBC_GLIBC
86 // sem_init in glibc prior to 2.1 does not zero out semaphores. 85 // sem_init in glibc prior to 2.1 does not zero out semaphores.
87 memset(&native_handle_, 0, sizeof(native_handle_)); 86 memset(&native_handle_, 0, sizeof(native_handle_));
88 #endif 87 #endif
89 int result = sem_init(&native_handle_, 0, count); 88 int result = sem_init(&native_handle_, 0, count);
90 DCHECK_EQ(0, result); 89 DCHECK_EQ(0, result);
91 USE(result); 90 USE(result);
92 } 91 }
93 92
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 DCHECK(result == WAIT_OBJECT_0); 207 DCHECK(result == WAIT_OBJECT_0);
209 return true; 208 return true;
210 } 209 }
211 } 210 }
212 } 211 }
213 212
214 #endif // V8_OS_MACOSX 213 #endif // V8_OS_MACOSX
215 214
216 } // namespace base 215 } // namespace base
217 } // namespace v8 216 } // namespace v8
OLDNEW
« src/base/platform/semaphore.h ('K') | « src/base/platform/semaphore.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698