File tree 1 file changed +8
-0
lines changed
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,11 @@ class Semaphore
209
209
struct timespec ts;
210
210
const int usecs_in_1_sec = 1000000 ;
211
211
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
212
215
clock_gettime (CLOCK_REALTIME, &ts);
216
+ #endif
213
217
ts.tv_sec += (time_t )(usecs / usecs_in_1_sec);
214
218
ts.tv_nsec += (long )(usecs % usecs_in_1_sec) * 1000 ;
215
219
// sem_timedwait bombs if you have more than 1e9 in tv_nsec
@@ -221,7 +225,11 @@ class Semaphore
221
225
222
226
int rc;
223
227
do {
228
+ #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,30) && defined(_GNU_SOURCE)
229
+ rc = sem_clockwait (&m_sema, CLOCK_MONOTONIC, &ts);
230
+ #else
224
231
rc = sem_timedwait (&m_sema, &ts);
232
+ #endif
225
233
} while (rc == -1 && errno == EINTR);
226
234
return rc == 0 ;
227
235
}
You can’t perform that action at this time.
0 commit comments