File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -209,7 +209,11 @@ class Semaphore
209209 struct timespec ts;
210210 const int usecs_in_1_sec = 1000000 ;
211211 const int nsecs_in_1_sec = 1000000000 ;
212+ #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,30) && defined(_GNU_SOURCE)
213+ clock_gettime (CLOCK_MONOTONIC , &ts);
214+ #else
212215 clock_gettime (CLOCK_REALTIME , &ts);
216+ #endif
213217 ts.tv_sec += (time_t )(usecs / usecs_in_1_sec);
214218 ts.tv_nsec += (long )(usecs % usecs_in_1_sec) * 1000 ;
215219 // sem_timedwait bombs if you have more than 1e9 in tv_nsec
@@ -221,7 +225,11 @@ class Semaphore
221225
222226 int rc;
223227 do {
228+ #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,30) && defined(_GNU_SOURCE)
229+ rc = sem_clockwait (&m_sema, CLOCK_MONOTONIC , &ts);
230+ #else
224231 rc = sem_timedwait (&m_sema, &ts);
232+ #endif
225233 } while (rc == -1 && errno == EINTR );
226234 return rc == 0 ;
227235 }
You can’t perform that action at this time.
0 commit comments