| Index: src/platform-openbsd.cc
|
| diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc
|
| index 114b8e2a55c4ba996e77b1e85d35fbf821821f7c..84039d34a87517f2460c3e1024a0393b633089a0 100644
|
| --- a/src/platform-openbsd.cc
|
| +++ b/src/platform-openbsd.cc
|
| @@ -429,75 +429,6 @@ bool VirtualMemory::HasLazyCommits() {
|
| }
|
|
|
|
|
| -class OpenBSDSemaphore : public Semaphore {
|
| - public:
|
| - explicit OpenBSDSemaphore(int count) { sem_init(&sem_, 0, count); }
|
| - virtual ~OpenBSDSemaphore() { sem_destroy(&sem_); }
|
| -
|
| - virtual void Wait();
|
| - virtual bool Wait(int timeout);
|
| - virtual void Signal() { sem_post(&sem_); }
|
| - private:
|
| - sem_t sem_;
|
| -};
|
| -
|
| -
|
| -void OpenBSDSemaphore::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 OpenBSDSemaphore::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);
|
| -
|
| - int to = ts.tv_sec;
|
| -
|
| - while (true) {
|
| - int result = sem_trywait(&sem_);
|
| - if (result == 0) return true; // Successfully got semaphore.
|
| - if (!to) return false; // Timeout.
|
| - CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup.
|
| - usleep(ts.tv_nsec / 1000);
|
| - to--;
|
| - }
|
| -}
|
| -
|
| -
|
| -Semaphore* OS::CreateSemaphore(int count) {
|
| - return new OpenBSDSemaphore(count);
|
| -}
|
| -
|
| -
|
| void OS::SetUp() {
|
| // Seed the random number generator. We preserve microsecond resolution.
|
| uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()) ^ (getpid() << 16);
|
|
|