Index: src/platform-cygwin.cc |
diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc |
index 7bedfe8881ad52f732c18f90b8eb9447b9e11113..10525d934584608f8987a298cc9e6cfc5b82e290 100644 |
--- a/src/platform-cygwin.cc |
+++ b/src/platform-cygwin.cc |
@@ -398,71 +398,6 @@ bool VirtualMemory::HasLazyCommits() { |
} |
-class CygwinSemaphore : public Semaphore { |
- public: |
- explicit CygwinSemaphore(int count) { sem_init(&sem_, 0, count); } |
- virtual ~CygwinSemaphore() { sem_destroy(&sem_); } |
- |
- virtual void Wait(); |
- virtual bool Wait(int timeout); |
- virtual void Signal() { sem_post(&sem_); } |
- private: |
- sem_t sem_; |
-}; |
- |
- |
-void CygwinSemaphore::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 |
- |
- |
-bool CygwinSemaphore::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 CygwinSemaphore(count); |
-} |
- |
- |
void OS::SetUp() { |
// Seed the random number generator. |
// Convert the current time to a 64-bit integer first, before converting it |