| Index: src/platform-linux.cc
|
| diff --git a/src/platform-linux.cc b/src/platform-linux.cc
|
| index 37b4b11714cfb68ed703cb8feb82e5afbcf4719c..3416da3c230d930223fbd82f60fbc6d7721efa92 100644
|
| --- a/src/platform-linux.cc
|
| +++ b/src/platform-linux.cc
|
| @@ -497,76 +497,6 @@ bool VirtualMemory::HasLazyCommits() {
|
| }
|
|
|
|
|
| -class LinuxSemaphore : public Semaphore {
|
| - public:
|
| - explicit LinuxSemaphore(int count) { sem_init(&sem_, 0, count); }
|
| - virtual ~LinuxSemaphore() { sem_destroy(&sem_); }
|
| -
|
| - virtual void Wait();
|
| - virtual bool Wait(int timeout);
|
| - virtual void Signal() { sem_post(&sem_); }
|
| - private:
|
| - sem_t sem_;
|
| -};
|
| -
|
| -
|
| -void LinuxSemaphore::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 LinuxSemaphore::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 > 0) {
|
| - // For glibc prior to 2.3.4 sem_timedwait returns the error instead of -1.
|
| - errno = result;
|
| - result = -1;
|
| - }
|
| - if (result == -1 && errno == ETIMEDOUT) return false; // Timeout.
|
| - CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup.
|
| - }
|
| -}
|
| -
|
| -
|
| -Semaphore* OS::CreateSemaphore(int count) {
|
| - return new LinuxSemaphore(count);
|
| -}
|
| -
|
| -
|
| void OS::SetUp() {
|
| // Seed the random number generator. We preserve microsecond resolution.
|
| uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()) ^ (getpid() << 16);
|
|
|