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

Side by Side Diff: src/platform-posix.cc

Issue 316133002: Move atomic ops and related files to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 <dlfcn.h> 9 #include <dlfcn.h>
10 #include <pthread.h> 10 #include <pthread.h>
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 intptr_t ptr_key = static_cast<intptr_t>(local_key); 592 intptr_t ptr_key = static_cast<intptr_t>(local_key);
593 return reinterpret_cast<pthread_key_t>(ptr_key); 593 return reinterpret_cast<pthread_key_t>(ptr_key);
594 #else 594 #else
595 return static_cast<pthread_key_t>(local_key); 595 return static_cast<pthread_key_t>(local_key);
596 #endif 596 #endif
597 } 597 }
598 598
599 599
600 #ifdef V8_FAST_TLS_SUPPORTED 600 #ifdef V8_FAST_TLS_SUPPORTED
601 601
602 static Atomic32 tls_base_offset_initialized = 0; 602 static base::Atomic32 tls_base_offset_initialized = 0;
Jakob Kummerow 2014/06/05 11:49:06 IWYU?
603 intptr_t kMacTlsBaseOffset = 0; 603 intptr_t kMacTlsBaseOffset = 0;
604 604
605 // It's safe to do the initialization more that once, but it has to be 605 // It's safe to do the initialization more that once, but it has to be
606 // done at least once. 606 // done at least once.
607 static void InitializeTlsBaseOffset() { 607 static void InitializeTlsBaseOffset() {
608 const size_t kBufferSize = 128; 608 const size_t kBufferSize = 128;
609 char buffer[kBufferSize]; 609 char buffer[kBufferSize];
610 size_t buffer_size = kBufferSize; 610 size_t buffer_size = kBufferSize;
611 int ctl_name[] = { CTL_KERN , KERN_OSRELEASE }; 611 int ctl_name[] = { CTL_KERN , KERN_OSRELEASE };
612 if (sysctl(ctl_name, 2, buffer, &buffer_size, NULL, 0) != 0) { 612 if (sysctl(ctl_name, 2, buffer, &buffer_size, NULL, 0) != 0) {
(...skipping 15 matching lines...) Expand all
628 #if V8_HOST_ARCH_IA32 628 #if V8_HOST_ARCH_IA32
629 kMacTlsBaseOffset = 0x48; 629 kMacTlsBaseOffset = 0x48;
630 #else 630 #else
631 kMacTlsBaseOffset = 0x60; 631 kMacTlsBaseOffset = 0x60;
632 #endif 632 #endif
633 } else { 633 } else {
634 // 11.x.x (Lion) changed the offset. 634 // 11.x.x (Lion) changed the offset.
635 kMacTlsBaseOffset = 0; 635 kMacTlsBaseOffset = 0;
636 } 636 }
637 637
638 Release_Store(&tls_base_offset_initialized, 1); 638 base::Release_Store(&tls_base_offset_initialized, 1);
639 } 639 }
640 640
641 641
642 static void CheckFastTls(Thread::LocalStorageKey key) { 642 static void CheckFastTls(Thread::LocalStorageKey key) {
643 void* expected = reinterpret_cast<void*>(0x1234CAFE); 643 void* expected = reinterpret_cast<void*>(0x1234CAFE);
644 Thread::SetThreadLocal(key, expected); 644 Thread::SetThreadLocal(key, expected);
645 void* actual = Thread::GetExistingThreadLocal(key); 645 void* actual = Thread::GetExistingThreadLocal(key);
646 if (expected != actual) { 646 if (expected != actual) {
647 V8_Fatal(__FILE__, __LINE__, 647 V8_Fatal(__FILE__, __LINE__,
648 "V8 failed to initialize fast TLS on current kernel"); 648 "V8 failed to initialize fast TLS on current kernel");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 690
691 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { 691 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
692 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); 692 pthread_key_t pthread_key = LocalKeyToPthreadKey(key);
693 int result = pthread_setspecific(pthread_key, value); 693 int result = pthread_setspecific(pthread_key, value);
694 ASSERT_EQ(0, result); 694 ASSERT_EQ(0, result);
695 USE(result); 695 USE(result);
696 } 696 }
697 697
698 698
699 } } // namespace v8::internal 699 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698