OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // Platform-specific code for POSIX goes here. This is not a platform on its | 5 // Platform-specific code for POSIX goes here. This is not a platform on its |
6 // own, but contains the parts which are the same across the POSIX platforms | 6 // own, but contains the parts which are the same across the POSIX platforms |
7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. | 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 DCHECK(data_->thread_ != kNoThread); | 624 DCHECK(data_->thread_ != kNoThread); |
625 USE(result); | 625 USE(result); |
626 } | 626 } |
627 | 627 |
628 | 628 |
629 void Thread::Join() { | 629 void Thread::Join() { |
630 pthread_join(data_->thread_, NULL); | 630 pthread_join(data_->thread_, NULL); |
631 } | 631 } |
632 | 632 |
633 | 633 |
634 void Thread::YieldCPU() { | |
635 int result = sched_yield(); | |
636 DCHECK_EQ(0, result); | |
637 USE(result); | |
638 } | |
639 | |
640 | |
641 static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) { | 634 static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) { |
642 #if V8_OS_CYGWIN | 635 #if V8_OS_CYGWIN |
643 // We need to cast pthread_key_t to Thread::LocalStorageKey in two steps | 636 // We need to cast pthread_key_t to Thread::LocalStorageKey in two steps |
644 // because pthread_key_t is a pointer type on Cygwin. This will probably not | 637 // because pthread_key_t is a pointer type on Cygwin. This will probably not |
645 // work on 64-bit platforms, but Cygwin doesn't support 64-bit anyway. | 638 // work on 64-bit platforms, but Cygwin doesn't support 64-bit anyway. |
646 STATIC_ASSERT(sizeof(Thread::LocalStorageKey) == sizeof(pthread_key_t)); | 639 STATIC_ASSERT(sizeof(Thread::LocalStorageKey) == sizeof(pthread_key_t)); |
647 intptr_t ptr_key = reinterpret_cast<intptr_t>(pthread_key); | 640 intptr_t ptr_key = reinterpret_cast<intptr_t>(pthread_key); |
648 return static_cast<Thread::LocalStorageKey>(ptr_key); | 641 return static_cast<Thread::LocalStorageKey>(ptr_key); |
649 #else | 642 #else |
650 return static_cast<Thread::LocalStorageKey>(pthread_key); | 643 return static_cast<Thread::LocalStorageKey>(pthread_key); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 } | 747 } |
755 | 748 |
756 | 749 |
757 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 750 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
758 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 751 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
759 int result = pthread_setspecific(pthread_key, value); | 752 int result = pthread_setspecific(pthread_key, value); |
760 DCHECK_EQ(0, result); | 753 DCHECK_EQ(0, result); |
761 USE(result); | 754 USE(result); |
762 } | 755 } |
763 | 756 |
764 | 757 } // namespace base |
765 } } // namespace v8::base | 758 } // namespace v8 |
OLD | NEW |