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 21095008: Revert the latest set of platform changes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 749
750 750
751 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { 751 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
752 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); 752 pthread_key_t pthread_key = LocalKeyToPthreadKey(key);
753 int result = pthread_setspecific(pthread_key, value); 753 int result = pthread_setspecific(pthread_key, value);
754 ASSERT_EQ(0, result); 754 ASSERT_EQ(0, result);
755 USE(result); 755 USE(result);
756 } 756 }
757 757
758 758
759 class POSIXMutex : public Mutex {
760 public:
761 POSIXMutex() {
762 pthread_mutexattr_t attr;
763 memset(&attr, 0, sizeof(attr));
764 int result = pthread_mutexattr_init(&attr);
765 ASSERT(result == 0);
766 result = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
767 ASSERT(result == 0);
768 result = pthread_mutex_init(&mutex_, &attr);
769 ASSERT(result == 0);
770 result = pthread_mutexattr_destroy(&attr);
771 ASSERT(result == 0);
772 USE(result);
773 }
774
775 virtual ~POSIXMutex() { pthread_mutex_destroy(&mutex_); }
776
777 virtual int Lock() { return pthread_mutex_lock(&mutex_); }
778
779 virtual int Unlock() { return pthread_mutex_unlock(&mutex_); }
780
781 virtual bool TryLock() {
782 int result = pthread_mutex_trylock(&mutex_);
783 // Return false if the lock is busy and locking failed.
784 if (result == EBUSY) {
785 return false;
786 }
787 ASSERT(result == 0); // Verify no other errors.
788 return true;
789 }
790
791 private:
792 pthread_mutex_t mutex_; // Pthread mutex for POSIX platforms.
793 };
794
795
796 Mutex* OS::CreateMutex() {
797 return new POSIXMutex();
798 }
799
800
759 // ---------------------------------------------------------------------------- 801 // ----------------------------------------------------------------------------
760 // POSIX socket support. 802 // POSIX socket support.
761 // 803 //
762 804
763 class POSIXSocket : public Socket { 805 class POSIXSocket : public Socket {
764 public: 806 public:
765 explicit POSIXSocket() { 807 explicit POSIXSocket() {
766 // Create the socket. 808 // Create the socket.
767 socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 809 socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
768 if (IsValid()) { 810 if (IsValid()) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 return ntohl(value); 990 return ntohl(value);
949 } 991 }
950 992
951 993
952 Socket* OS::CreateSocket() { 994 Socket* OS::CreateSocket() {
953 return new POSIXSocket(); 995 return new POSIXSocket();
954 } 996 }
955 997
956 998
957 } } // namespace v8::internal 999 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-openbsd.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698