Index: src/platform-solaris.cc |
diff --git a/src/platform-solaris.cc b/src/platform-solaris.cc |
index dd5c7a0d8483aac5e9ab5c78d7e180a2146e27b5..99636d6430267336c0919e77c86fdf3243610e58 100644 |
--- a/src/platform-solaris.cc |
+++ b/src/platform-solaris.cc |
@@ -393,84 +393,6 @@ bool VirtualMemory::HasLazyCommits() { |
} |
-class SolarisSemaphore : public Semaphore { |
- public: |
- explicit SolarisSemaphore(int count) { sem_init(&sem_, 0, count); } |
- virtual ~SolarisSemaphore() { sem_destroy(&sem_); } |
- |
- virtual void Wait(); |
- virtual bool Wait(int timeout); |
- virtual void Signal() { sem_post(&sem_); } |
- private: |
- sem_t sem_; |
-}; |
- |
- |
-void SolarisSemaphore::Wait() { |
- while (true) { |
- int result = sem_wait(&sem_); |
- if (result == 0) return; // Successfully got semaphore. |
- CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. |
- } |
-} |
- |
- |
-#ifndef TIMEVAL_TO_TIMESPEC |
-#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \ |
- (ts)->tv_sec = (tv)->tv_sec; \ |
- (ts)->tv_nsec = (tv)->tv_usec * 1000; \ |
-} while (false) |
-#endif |
- |
- |
-#ifndef timeradd |
-#define timeradd(a, b, result) \ |
- do { \ |
- (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ |
- (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ |
- if ((result)->tv_usec >= 1000000) { \ |
- ++(result)->tv_sec; \ |
- (result)->tv_usec -= 1000000; \ |
- } \ |
- } while (0) |
-#endif |
- |
- |
-bool SolarisSemaphore::Wait(int timeout) { |
- const long kOneSecondMicros = 1000000; // NOLINT |
- |
- // Split timeout into second and nanosecond parts. |
- struct timeval delta; |
- delta.tv_usec = timeout % kOneSecondMicros; |
- delta.tv_sec = timeout / kOneSecondMicros; |
- |
- struct timeval current_time; |
- // Get the current time. |
- if (gettimeofday(¤t_time, NULL) == -1) { |
- return false; |
- } |
- |
- // Calculate time for end of timeout. |
- struct timeval end_time; |
- timeradd(¤t_time, &delta, &end_time); |
- |
- struct timespec ts; |
- TIMEVAL_TO_TIMESPEC(&end_time, &ts); |
- // Wait for semaphore signalled or timeout. |
- while (true) { |
- int result = sem_timedwait(&sem_, &ts); |
- if (result == 0) return true; // Successfully got semaphore. |
- if (result == -1 && errno == ETIMEDOUT) return false; // Timeout. |
- CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. |
- } |
-} |
- |
- |
-Semaphore* OS::CreateSemaphore(int count) { |
- return new SolarisSemaphore(count); |
-} |
- |
- |
void OS::SetUp() { |
// Seed the random number generator. |
// Convert the current time to a 64-bit integer first, before converting it |