1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
$NetBSD: patch-ab,v 1.2 2007/08/04 12:52:57 joerg Exp $
--- fifo.cpp.orig 2007-07-16 17:54:23.000000000 +0000
+++ fifo.cpp
@@ -39,6 +39,12 @@
#include "wave.h"
#include "debug.h"
+#ifndef timespeccmp
+#define timespeccmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#endif
//>
//<decls and function prototypes
@@ -306,10 +312,14 @@ int sleep_until_start_request_or_inactiv
to.tv_sec, to.tv_nsec,
ts.tv_sec, ts.tv_nsec);
- while ((err = sem_timedwait(&my_sem_start_is_required, &ts)) == -1
- && errno == EINTR)
+ while ((err = sem_trywait(&my_sem_start_is_required)) == -1
+ && (errno == EINTR || errno == EAGAIN))
{
- continue;
+ struct timespec help;
+ clock_gettime2(&help);
+ if (timespeccmp(&help, &ts, >=))
+ break;
+ sched_yield();
}
assert (gettimeofday(&tv, NULL) != -1);
|