blob: 4a2d42842aa79bbe1071df75e1c0e55839f11bfa (
plain)
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
|
/* Public domain. */
#ifndef _LINUX_IOPOLL_H
#define _LINUX_IOPOLL_H
#define readx_poll_timeout(op, addr, val, cond, sleep_us, timeout_us) \
({ \
struct timeval __end, __now, __timeout_tv; \
int __timed_out = 0; \
\
if (timeout_us) { \
microuptime(&__now); \
USEC_TO_TIMEVAL(timeout_us, &__timeout_tv); \
timeradd(&__now, &__timeout_tv, &__end); \
} \
\
for (;;) { \
(val) = (op)(addr); \
if (cond) \
break; \
if (timeout_us) { \
microuptime(&__now); \
if (timercmp(&__end, &__now, <=)) { \
__timed_out = 1; \
break; \
} \
} \
if (sleep_us) \
delay((sleep_us) / 2); \
} \
(__timed_out) ? -ETIMEDOUT : 0; \
})
#endif
|